Skip to content

bug(windows): OpenCode doctor misidentifies valid file URI plugins #1497

Description

@knqiufan

Describe the bug

On Windows, powercontext doctor opencode can report that a PowerContext plugin is not configured even when OpenCode's configuration contains a valid file:///C:/... reference to that plugin. It also loses the distinction between a configured-but-inactive plugin and a missing configuration.

In _configured_plugin(), a file URI is decoded with unquote(parsed.path) and passed directly to Path. On Windows, the resulting /C:/... is not the native C:/... filesystem path, so the existing package.json cannot be found. The bridge installed under OpenCode's config directory can mask this problem through the alternative _owned_plugin() check; configurations using the file URI directly remain affected.

Steps to reproduce

Use a Windows checkout of 80d618bd61432d1bb4eae85433fa22f2bbd50bce with development dependencies installed:

uv run pytest -q tests/test_opencode_cli.py::test_doctor_opencode_rejects_configured_but_inactive_plugin

The existing test invokes the public Doctor CLI with a valid plugin directory, an OpenCode config containing plugin.as_uri(), and an inactive activation probe. No installed OpenCode instance or model credentials are required for this deterministic regression.

The path-decoding cause can also be isolated from the host process:

import json
from pathlib import Path
from powercontext.cli.opencode import _configured_plugin

plugin = Path("integrations/opencode/plugins/powercontext").resolve()
print(_configured_plugin(json.dumps({"plugin": [str(plugin)]})))
print(_configured_plugin(json.dumps({"plugin": [plugin.as_uri()]})))

Expected behavior

Both references identify the same installed plugin. Doctor should independently report configuration presence and runtime activation; the inactive fixture should report configured but did not activate.

Convert file URIs using Windows-aware path handling, including drive letters and escaped characters. Add appropriate UNC coverage and retain the current distinction between filesystem references and package specifications. The successful native-path and installed-bridge cases must remain valid.

Actual behavior

The isolated comparison prints True followed by False. The public CLI regression fails with:

AssertionError: assert 'did not activate' in 'PowerContext OpenCode plugin is not configured'

This is an incorrect diagnostic and can send users toward reinstalling or editing configuration when the failure is actually activation. It is independent of the DSH Doctor changes in #1493 / #1494.

Environment

  • Upstream master: 80d618bd61432d1bb4eae85433fa22f2bbd50bce.
  • Windows x64, CPython 3.12.13.
  • Reproduced with unmodified sources in an isolated checkout.
  • Open issues and the changed files of open PRs were checked; no existing open fix for this URI conversion was found.
  • AI assistance: OpenAI Codex assisted with source inspection, reproduction, and this report.

Are you willing to submit a PR to fix this bug?

  • Yes, I would like to submit a PR.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions