Skip to content

fix(install): write the global OpenCode plugin to ~/.config/opencode (#3398) - #4771

Closed
nothariharan wants to merge 1 commit into
Graphify-Labs:v8from
nothariharan:fix/opencode-global-plugin-path
Closed

nothariharan wants to merge 1 commit into
Graphify-Labs:v8from
nothariharan:fix/opencode-global-plugin-path

Conversation

@nothariharan

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #3398. A global (non---project) graphify install --platform opencode called _install_opencode_plugin(Path(".")), and the helper joined .opencode/plugins/graphify.js onto that base. The "global" plugin therefore landed in whatever directory the command ran from, and loaded only for that project. The issue explains why swapping the base path alone would not work: OpenCode's global plugin dir is ~/.config/opencode/plugins/, with no .opencode/ segment.

The plugin helpers now take the OpenCode config dir itself, chosen by a new _opencode_dir(): <project>/.opencode for a project install, ~/.config/opencode for a global one. To keep install and uninstall symmetric:

The slash-command half of #3398 no longer applies: v8 has no _install_opencode_command.

This takes the same approach as #3459 by @nikhilsaxena04, which now conflicts with v8. This branch is built on current v8, including the auto-refresh and opencode.json cleanup that landed after that PR. The diagnosis is theirs and the issue's.

Type of change

  • Bug fix

Verification & Invariants

Invariant: a global install writes only under the user's config dir, never under the cwd, and a project install writes only under its project.

  • Reproduced: on v8, test_opencode_global_install_writes_plugin_to_config_dir, test_uninstall_all_removes_the_global_opencode_plugin and test_a_v1_plugin_in_the_global_config_dir_is_rewritten fail. The project-scope guard test_opencode_project_install_keeps_plugin_in_project passes on both.
  • Existing project-scope opencode tests are unchanged and pass.
  • Limitation: a plugin that an older global install already dropped into some project's .opencode/ stays there. It behaves as a project plugin for that project.

How was this tested?

Windows 11, Python 3.12.

uv run --frozen pytest tests/test_install.py tests/test_opencode_plugin_refresh.py tests/test_uninstall_purge_safety.py -q -> all passed
new tests with graphify/install.py and graphify/__main__.py reverted to v8 -> 3 failed, guard passed
uv run --frozen pytest tests/ -q -> 7 failed, 8652 passed, 86 skipped. The same 7 tests fail on unmodified v8 on this machine (8648 passed): aider/devin code-only update, a shebang parse test, a watch relative-roots test, two getcwd memoization tests, one alias-resolution test. None is new.
uv run --frozen ruff check (changed files) -> All checks passed
uv run --frozen pyright graphify/install.py graphify/__main__.py -> no errors beyond the ones v8 already has

Graphify-specific checklist

  • No generated skill artifacts touched.
  • No change to AST/structural extraction.
  • No shell/Python interpolation added.
  • No API keys or local graph data included.

…raphify-Labs#3398)

A global `graphify install --platform opencode` passed Path(".") as the
plugin base and joined `.opencode/plugins/graphify.js` onto it, so the
"global" plugin landed in whatever directory the command ran from and
loaded only for that project. OpenCode's global plugin dir is
~/.config/opencode/plugins, with no `.opencode/` segment, so the base
path alone could not be swapped.

The plugin helpers now take the OpenCode config dir itself, chosen by
_opencode_dir(): <project>/.opencode for a project install and
~/.config/opencode for a global one. `graphify uninstall` removes the
global plugin as well, and the OpenCode 2 plugin refresh also checks the
global dir. The legacy `.opencode/plugins/graphify.js` entry that older
releases wrote into opencode.json is still matched by its old string.

The slash-command half of the issue no longer applies: v8 has no
_install_opencode_command.
@github-actions github-actions Bot added the contributor Pull request from a returning community contributor label Oct 26, 2026
@github-actions

Copy link
Copy Markdown

Thanks for the pull request, @nothariharan. A maintainer will review it soon.

Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions.

A couple of things that speed up review: make sure the test suite passes on Python 3.10 and 3.13, and that the change keeps extraction deterministic.

@graphify-labs graphify-labs Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graphify reviewed this change.

Worth a look — the grounded gate found no coupling regressions or blocking issues, but 2 advisory finding(s) below merit a look before merge.

Not checked: tests were not run; formal verification proved 0 of 9 changed function(s) (5 sampled, not proven, 4 not verified).

Formal verification. PR-changed functions: 5/9 verified (0 proven, 5 may-equivalent, 0 distinguished) · 4 not verified (2 vacuous, 1 unsupported, 1 witness not reproduced).

Not verified on this run: \_agents\_install (vacuous: never exercised), \_install\_opencode\_plugin (witness not reproduced), install (vacuous: never exercised), uninstall\_all (unsupported).


Graphify review — findings

Fixes the global OpenCode install so install("opencode") writes the plugin to ~/.config/opencode/plugins instead of the cwd, via a new _opencode_dir helper that resolves the project (<project>/.opencode) or global directory. The plugin install and uninstall helpers and the opencode.json cleanup now take that directory rather than a project root, so the same positional argument means something different, and the agents-based install and uninstall paths always resolve the project directory. uninstall_all also removes the plugin from the global config dir, and the startup v1-plugin refresh now scans the cwd, home and global directories, with paths in printed messages now showing the actual location.

Worth a look

  • _agents_install hardcodes project=True for the OpenCode plugin, so global installs still write to the cwd — graphify/install.py:1977 · Escalate · high
    • NOT verified (no proof, no reproducing execution) — needs human review
  • uninstall_all leaves legacy home OpenCode plugin — graphify/install.py:2330 · Escalate · medium
    • NOT verified (no proof, no reproducing execution) — needs human review
Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 791 functions depend on the 446 functions this change touches.

Health — this change adds coupling hotspots:

  • worse: install() — 19 callers, 12 callees
  • worse: _refresh_v1_opencode_plugins() — 19 callers, 8 callees
  • worse: uninstall_all() — 8 callers, 15 callees
  • worse: _agents_install() — 7 callers, 9 callees
  • worse: _agents_uninstall() — 8 callers, 7 callees

Verification — 791 functions in the blast radius were not formally verified this run (proofs are advisory here).

Gate & verification

graphify gate

PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.

Advisory (not blocking):

  • verification_scope: 790 function(s) in the blast radius were not formally verified this run

Test selection

Test selection

43 of 453 test file(s) selected (9%) via static blast radius.

  • tests/test_affected_cli.py — impact
  • tests/test_agents_platform.py — impact
  • tests/test_atomic_version_stamp.py — impact
  • tests/test_claude_md.py — impact
  • tests/test_codebuddy.py — impact
  • tests/test_dedup_shrink_refuses_force_write.py — impact
  • tests/test_detect.py — impact
  • tests/test_devin.py — impact
  • tests/test_explain_cli.py — impact
  • tests/test_explain_same_file_tie.py — impact
  • tests/test_extract_cli.py — impact
  • tests/test_gemini_hook.py — impact
  • tests/test_global_add_tag_inference.py — impact
  • tests/test_god_nodes_cli.py — impact
  • tests/test_hollow_chunks_arm_shrink_guard.py — impact
  • tests/test_home_sandbox.py — impact
  • tests/test_hook_strict.py — impact
  • tests/test_incomplete_build_guard.py — impact
  • tests/test_install.py — impact, changed-test
  • tests/test_install_hook_identity.py — impact
  • tests/test_install_line_endings.py — impact
  • tests/test_install_references.py — impact
  • tests/test_install_strings.py — impact
  • tests/test_install_version_warning.py — impact
  • tests/test_lookup_exit_codes.py — impact
  • tests/test_merge_chunks_validation.py — impact
  • tests/test_multigraph_diagnostics.py — impact
  • tests/test_no_dedup_flag.py — impact
  • tests/test_opencode_plugin_refresh.py — impact, changed-test
  • tests/test_path_cli.py — impact
  • tests/test_pi_guard_install.py — impact
  • tests/test_query_cli.py — impact
  • tests/test_query_induced_edges.py — impact
  • tests/test_query_seeds.py — impact
  • tests/test_read_hook.py — impact
  • tests/test_replace_or_append_section.py — impact
  • tests/test_search_hook.py — impact
  • tests/test_skill_auto_refresh.py — impact
  • tests/test_skill_version_warning.py — impact
  • tests/test_truncation_full_answer.py — impact
  • tests/test_uninstall_purge_safety.py — impact
  • tests/test_uninstall_scope.py — impact
  • tests/test_unverified_semantic_shrink.py — impact

Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.

Formal verification

Could not verify: \_install\_opencode\_plugin: a possible difference could NOT be confirmed.

The solver proposed a distinguishing input for \_install\_opencode\_plugin, but re-running both versions on it did NOT reproduce a difference. Treat as unconfirmed, not a behavior change.

Guarantee:

Note: Solver-proposed witness refuted on replay — not a hard failure.

No difference found (not proven): No behavior difference found in \_refresh\_v1\_opencode\_plugins (not a proof).

The verifier ran both versions of \_refresh\_v1\_opencode\_plugins on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.

Guarantee: Empirical: differential testing (both versions run on many generated inputs). A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.

Note: An input the sampler did not try could still differ.

Could not verify: Could not verify \_agents\_install.

The verifier did not have enough to check \_agents\_install, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: no capturable inputs from the test suite; property tier: not verifiable: all 220 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly NameError — names the real obstacle, not a sampling gap)

No difference found (not proven): No behavior difference found in \_agents\_uninstall (not a proof).

The verifier ran both versions of \_agents\_uninstall on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.

Guarantee: Empirical: differential testing (both versions run on many generated inputs). A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.

Note: An input the sampler did not try could still differ.

No difference found (not proven): No behavior difference found in \_drop\_opencode\_config\_entry (not a proof).

The verifier ran both versions of \_drop\_opencode\_config\_entry on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.

Guarantee: Empirical: differential testing (both versions run on many generated inputs). A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.

Note: An input the sampler did not try could still differ.

No difference found (not proven): No behavior difference found in \_opencode\_config\_names\_plugin (not a proof).

The verifier ran both versions of \_opencode\_config\_names\_plugin on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.

Guarantee: Empirical: differential testing (both versions run on many generated inputs). A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.

Note: An input the sampler did not try could still differ.

No difference found (not proven): No behavior difference found in \_uninstall\_opencode\_plugin (not a proof).

The verifier ran both versions of \_uninstall\_opencode\_plugin on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.

Guarantee: Empirical: differential testing (both versions run on many generated inputs). A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.

Note: An input the sampler did not try could still differ.

Could not verify: Could not verify install.

The verifier did not have enough to check install, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: no capturable inputs from the test suite; property tier: not verifiable: all 41 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly SystemExit — names the real obstacle, not a sampling gap)

Could not verify: Could not verify uninstall\_all.

The verifier did not have enough to check uninstall\_all, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: no capturable inputs from the test suite; property tier: not verifiable: the input domain has 20 values but only 10 distinct were tested — a small finite domain must be EXHAUSTED, not sampled (an untested input could invert the result)

· 5 more finding(s) on lines outside this diff (see the check run).

safishamsi added a commit that referenced this pull request Oct 30, 2026
Go (#4867/#4868/#4866) and Python (#4773) extractor changes alter
per-file AST output and are AST-cached, so one combined _AST_CACHE_SCHEMA
bump 30->31 forces stale caches to re-extract. Install (#4770/#4771) and
the skill reword (#4721) need no bump. Folded into the unreleased 0.9.99.
Each PR omitted its own bump / carried a stale number; the single combined
bump lands here.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@safishamsi

Copy link
Copy Markdown
Member

Landed in v0.9.99, now on PyPI (pip install graphifyy==0.9.99). The global OpenCode plugin is written to ~/.config/opencode with install/uninstall/refresh kept symmetric. Thanks for the fix, @nothariharan.

@safishamsi safishamsi closed this Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor Pull request from a returning community contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenCode global install writes plugin and slash command to CWD instead of ~/.config/opencode/

2 participants