Repository navigation
Conversation
|
Thanks for the pull request, @bercedev. 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. |
There was a problem hiding this comment.
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.
Formal verification. PR-changed functions: 3/4 verified (0 proven, 3 may-equivalent, 0 distinguished) · 1 not verified (1 witness not reproduced).
Not verified on this run: \_install\_opencode\_plugin (witness not reproduced).
Graphify review — findings
Rewrites the OpenCode plugin as a single default export that works on both runtimes: setup() for OpenCode 2, which hooks shell and reminds once per session, and server() for OpenCode 1.3.4+, which hooks bash. The install no longer registers the plugin in opencode.json, since OpenCode finds files in .opencode/plugins/ on its own. On every CLI run, _refresh_v1_opencode_plugins checks the working and home directories, replaces any graphify-written v1-only plugin, and drops the stale config entry; a commented (non-JSON) config is left alone with a "remove by hand" hint, and GRAPHIFY_NO_AUTO_REFRESH=1 keeps the old plugin for older OpenCode 1 users.
Worth a look
- Every CLI run silently rewrites the OpenCode plugin, which can break OpenCode 1 versions older than 1.3.4 —
graphify/__main__.py:798· Escalate · medium- agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
- Unlocked read-modify-write of OpenCode plugin and opencode.json on every CLI run —
graphify/__main__.py:424· Escalate · medium- agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 653 functions depend on the 391 functions this change touches.
Health — this change adds coupling hotspots:
- new:
main()— 98 callers, 3 callees - new:
dispatch_command()— 2 callers, 126 callees - new:
install()— 14 callers, 11 callees - new:
_refresh_stale_skills()— 25 callers, 5 callees - new:
_copy_skill_file()— 15 callers, 7 callees - new:
codebuddy_install()— 20 callers, 5 callees - new:
gemini_install()— 11 callers, 7 callees - new:
claude_install()— 19 callers, 4 callees - …and 21 more — each is listed as a finding
Verification — 653 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: 653 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
33 of 319 test file(s) selected (10%) via static blast radius.
tests/test_affected_cli.py— impacttests/test_agents_platform.py— impacttests/test_atomic_version_stamp.py— impacttests/test_claude_md.py— impacttests/test_codebuddy.py— impacttests/test_devin.py— impacttests/test_explain_cli.py— impacttests/test_extract_cli.py— impacttests/test_gemini_hook.py— impacttests/test_global_add_tag_inference.py— impacttests/test_god_nodes_cli.py— impacttests/test_hollow_chunks_arm_shrink_guard.py— impacttests/test_home_sandbox.py— impacttests/test_hook_strict.py— impacttests/test_incomplete_build_guard.py— impacttests/test_install.py— impact, changed-testtests/test_install_references.py— impacttests/test_install_strings.py— impacttests/test_install_version_warning.py— impacttests/test_merge_chunks_validation.py— impacttests/test_multigraph_diagnostics.py— impacttests/test_no_dedup_flag.py— impacttests/test_opencode_plugin_refresh.py— impact, changed-testtests/test_path_cli.py— impacttests/test_query_cli.py— impacttests/test_query_induced_edges.py— impacttests/test_read_hook.py— impacttests/test_replace_or_append_section.py— impacttests/test_search_hook.py— impacttests/test_skill_auto_refresh.py— impacttests/test_skill_version_warning.py— impacttests/test_uninstall_scope.py— impacttests/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.
Docs that may be stale (advisory)
.github/PULL_REQUEST_TEMPLATE.md§ Graphify-specific checklist (lines 33-39): references changed symbolsrunBENCHMARKS.md§ Reproducing (lines 174-187): references changed symbolsrunCHANGELOG.md§ 0.9.68 (2026-09-25) (lines 85-97): references changed symbolsrunCHANGELOG.md§ 0.9.59 (2026-09-12) (lines 189-196): references changed symbolsrunCHANGELOG.md§ 0.9.53 (2026-08-30) (lines 265-276): references changed symbolsrunCHANGELOG.md§ 0.9.47 (2026-08-19) (lines 353-369): references changed symbolsrunCHANGELOG.md§ 0.9.45 (2026-08-16) (lines 387-393): references changed symbolsrunCHANGELOG.md§ 0.9.39 (2026-08-10) (lines 466-473): references changed symbolsrunCHANGELOG.md§ 0.9.35 (2026-08-06) (lines 498-506): references changed symbolsrunCHANGELOG.md§ 0.9.24 (2026-07-22) (lines 614-628): references changed symbolsrun
…and 10 more.
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\_stale\_skills (not a proof).
The verifier ran both versions of \_refresh\_stale\_skills 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 \_run\_cli (not a proof).
The verifier ran both versions of \_run\_cli 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.
· 2 grounded finding(s) anchored inline below; 27 more finding(s) on lines outside this diff (see the check run).
| return os.environ.get("GRAPHIFY_NO_AUTO_REFRESH", "").strip().lower() in ("1", "true", "yes") | ||
|
|
||
|
|
||
| def _refresh_stale_skills() -> None: |
There was a problem hiding this comment.
_refresh_stale_skills()
25 callers depend on it (afferent coupling).
Grounded coupling-delta finding (deterministic), not an LLM guess.
| print(line, file=sys.stderr) | ||
|
|
||
|
|
||
| def _refresh_v1_opencode_plugins() -> None: |
There was a problem hiding this comment.
_refresh_v1_opencode_plugins()
12 callers depend on it (afferent coupling).
Grounded coupling-delta finding (deterministic), not an LLM guess.
58a27d3 to
e86a05d
Compare
…pies (Graphify-Labs#3554, Graphify-Labs#3732) `graphify opencode install` wrote a plugin with only a named export, the OpenCode 1 shape. OpenCode 2 rejects it ("Plugin must export a default definition with an id and an effect or setup function") and reads the bare path registered in opencode.json as an npm package name, so it fails twice on every start. The plugin is now one default export with `id`, `setup()` for OpenCode 2 and `server()` for OpenCode 1 (1.3.4 and later). The installer no longer writes the opencode.json entry, because both runtimes discover .opencode/plugins/ on their own, and it removes the entry older releases wrote. OpenCode loads .opencode/plugins/ from the project and from every directory above it, and OpenCode 2 fails a second plugin with the same id ("Duplicate plugin ID"). An install in ~ and one in a project are both normal, so the id carries the file's location and the copies share one record of who was reminded: both load, and a command still gets a single reminder. Upgrading graphify does not touch a plugin already on disk. So the CLI now rewrites an old-shape plugin in the working directory or in the home directory on its next run, and drops the stale entry there, next to the stale-skill refresh from Graphify-Labs#1805. It does so only when the `opencode` on PATH reports 1.3.4 or later, because older OpenCode 1 releases cannot load the new plugin and the one they have still works. The rewrite takes the same per-directory lock as the skill refresh and replaces both files atomically, because OpenCode watches them. GRAPHIFY_NO_AUTO_REFRESH=1 turns it off.
e86a05d to
0e539e1
Compare
|
Pushed an update. It is a single commit now ( It covers both advisory findings from the review bot:
It also fixes something I hit on my own machine. With one install in |
Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Landed in 0.9.84 (now on PyPI) via an authorship-preserving cherry-pick (commit 652020e), so your authorship is retained on the v8 history and the contributor graph. The plugin now loads on OpenCode 2 (a default export with |
What does this PR do?
Fixes #3554 and #3732.
graphify opencode installwrites a plugin in the OpenCode 1 shape. On OpenCode 2 that install fails twice on every start. This is the server log of OpenCode 2.0.22 opened in a project that graphify 0.9.74 set up:The first error is the plugin file, which only has a named export. The second is the
"plugin": [".opencode/plugins/graphify.js"]entry in.opencode/opencode.json: OpenCode 2 reads a bare path as an npm package name.There are three changes.
1. One plugin file for both runtimes. The default export has
id,setup(ctx)for OpenCode 2 andserver()for OpenCode 1. Each runtime ignores the other's function. On OpenCode 2 the command tool is calledshell, and the server is a background service that outlives a session, so the reminder is tracked per session there. The file imports nothing from an opencode package, because a plain file in.opencode/plugins/can't resolve one.The plugin id carries the file's own location (
graphify-<hash>). OpenCode loads.opencode/plugins/from the project and from each directory above it, and OpenCode 2 fails a second plugin with the same id:Duplicate plugin ID: graphify, shown as "1 plugin failed". With one install in~and one in a project, that happened in every such project. The copies share one record of who was reminded, so a command still gets a single reminder. On OpenCode 1 two copies used to add it twice.2. No opencode.json entry. Both runtimes load every file in
.opencode/plugins/on their own (OpenCode 1.2.0 and later), so the entry is not needed. Install no longer writes it. Install and uninstall remove the entry older releases wrote, underpluginorplugins, and leave everything else in the file alone. If the file has comments, it is not rewritten, because that would drop them. Install prints what to remove instead.3. Installed copies are refreshed. Upgrading graphify does not touch a plugin that is already on disk. So someone who upgrades OpenCode keeps both errors until they find out they have to run the install again in each project. The CLI now rewrites an old-shape plugin on its next run, next to the stale-skill refresh from #1805:
So nobody has to reinstall by hand: each project is upgraded the first time graphify runs in it after the upgrade, whether that is a
graphify query, anupdate, or the post-commit hook.It looks in the working directory and in the home directory. Home matters because
graphify opencode installrun from~puts the plugin in~/.opencode/plugins/(#1412), and OpenCode loads that one for every project below home. That is how I ran into this.GRAPHIFY_NO_AUTO_REFRESH=1turns it off, the same switch as the skill refresh.An old plugin is replaced only when the
opencodeon PATH reports 1.3.4 or later. Older OpenCode 1 releases can't load the new file, and the plugin they have still works, so it stays. The version is asked once (opencode --version), and only when an old plugin is actually found. If there is noopencodeon PATH, nothing is replaced.Only a plugin that graphify wrote is touched. The stale entry is also dropped when the plugin next to it is already current, because a checkout can bring
opencode.jsonback on its own. If the rewrite fails, for example in a read-only checkout, the command still runs and stderr gets onegraphify: could not refresh ...line. The rewrite takes the same per-directory lock as the skill refresh, without waiting, and both files are replaced with a temp file and one rename (write_text_atomic), so OpenCode, which watches them, never sees half a plugin.About the other open PRs
#3792, #3819 and #3896 are open for the same issues, so I checked what was still missing before sending another one:
Pluginfrom@opencode/plugin. I tried that import in a small plugin of my own: OpenCode 2.0.22 fails withCannot find package '@opencode/plugin'. That matches the comment on that PR. It also keeps the bare config entry.{ id, setup }withoutserver(). OpenCode 1.18.34 rejects a default export like that withmust default export an object with server(), and 1.18.34 is still npmlatest.Happy to rebase on top of one of them or to split this up if you prefer a different order.
Type of change
Verification & Invariants
Invariant: after
graphify opencode install, and after any graphify CLI run in a project that has an older install, OpenCode 1 (1.3.4 and later) and OpenCode 2 both load.opencode/plugins/graphify.jswithout an error, and the first shell command of a session carries the reminder.Limitations:
server()from a default export (1.3.4, March 2026) as the floor. I got this from the OpenCode source. I did not run a release that old.graphify opencode installthere still writes a plugin that release can't load.opencodeon PATH to ask for the version. Where it isn't (some hook environments, a desktop-only install), nothing is refreshed andgraphify opencode installis still the way..opencode/plugins/graphify.jsor.opencode/opencode.jsonis tracked in git, the first graphify run after the upgrade leaves them modified, also when that run comes from the post-commit hook..opencode/opencode.jsonis cleaned, as before. An entry that someone moved toopencode.jsoncor to the global config stays, and so does an entry in a file with comments.opencode.jsonthat only held graphify's entry is left as{}, the same as uninstall did before.How was this tested?
Three tests drive the installed file with node the way each runtime calls it: one for OpenCode 2, one for OpenCode 1, and one with two copies of the file at different paths. They are skipped when node is missing, like the node tests in
test_export.py.I also ran both runtimes for real, each with its own XDG directories, in a scratch project that has
graphify-out/graph.json:OpenCode 2.0.22 with the 0.9.74 install: the two errors at the top.
graphify --versionfrom this branch in that project: the refresh line shown above, nothing on the second run, andopencode.jsonno longer has the entry.The same refresh with no
opencodeon PATH, and with a fakeopencodethat prints1.3.3: the old plugin and the entry stay as they are.OpenCode 2.0.22 again: the plugin loads with no error. I asked for two shell commands. The server log shows what was spawned:
OpenCode 1.18.34 with a fresh
graphify opencode installfrom this branch, so with noopencode.jsonat all: the plugin is discovered, the firstbashcall got the reminder and the second did not.Two copies, one in the parent directory and one in the project. OpenCode 2.0.22 lists both as
active(with a shared id the second one wasfailed: Duplicate plugin ID: graphify), and the first shell command carries one reminder. OpenCode 1.18.34 loads both, and the firstbashcommand carries one reminder.Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments.Note: I used Claude Code while working on this fix. I reviewed and ran all of it myself.