Repository navigation
Conversation
`graphify opencode install` writes `.opencode/plugins/graphify.js` with only
the v1 plugin API, so OpenCode v2 refuses to load it:
failed to load plugin <path> : Plugin must export a default definition with
an id and an effect or setup function (Missing key at ["default"])
The installer also registers the plugin in `.opencode/opencode.json` under the
bare relative path ".opencode/plugins/graphify.js". OpenCode v2 resolves a bare
specifier as an npm package and fails:
NpmInstallFailedError (cause: Could not read package.json: ENOENT ...)
Fix both, in one file:
- Port `_OPENCODE_PLUGIN_JS` to a single dual entrypoint: a v2 default export
({ id, setup }) that prepends the reminder via ctx.shell.hook("create.before"),
plus the v1 named export ("tool.execute.before") kept alongside so the same
file still loads on v1. The v2 path walks up from the hook cwd so the reminder
also fires when the first command runs from a subdirectory.
- Register the plugin by its resolved file:// URI (the form the Kilo installer
already uses) rather than a bare relative path. Uninstall drops both the URI
form and any legacy bare relative entry, so an old config cannot keep tripping
v2's npm-spec resolution.
Tests: the existing opencode install tests stay green; add regression coverage
for the v2 default export, the absolute file:// registration, and legacy-entry
cleanup on uninstall. The reminder policy is unchanged (Graphify-Labs#1413 backtick/$()-free,
Graphify-Labs#1646 ';' separator).
Verified end-to-end on OpenCode 2.0.18 (macOS): the plugin loads with no errors
and the reminder is injected into the first shell command (observed in the
spawned /bin/zsh args).
Refs Graphify-Labs#3554, Graphify-Labs#3732.
Co-Authored-By: Hermes Agent <[email protected]>
|
Thanks for the pull request, @coder-zhw. 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.
Graphify review — findings
Makes the OpenCode plugin load on both OpenCode v1 and v2: the generated graphify.js now exports a v2 default definition ({ id, setup }) that rewrites the first bash command via ctx.shell.hook("create.before") alongside the existing v1 GraphifyPlugin named export, with the reminder string shared as REMINDER and graph detection walking up to 5 parent dirs. Registers the plugin in opencode.json as an absolute file:// URI instead of a bare relative path, since v2 mis-resolves the relative form as an npm package spec and fails. Extends uninstall to drop both the new file:// entry and legacy relative .opencode/plugins/graphify.js entries while preserving unrelated plugins.
Worth a look
- OpenCode install leaves legacy relative plugin entry in config —
graphify/install.py:1528· Escalate · medium- agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
- Uninstall drops any plugin entry ending in 'plugins/graphify.js', including unrelated third-party plugins —
graphify/install.py:1552· 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 — 548 functions depend on the 316 functions this change touches.
Health — this change adds coupling hotspots:
- new:
main()— 98 callers, 3 callees - new:
dispatch_command()— 2 callers, 125 callees - new:
install()— 13 callers, 11 callees - new:
codebuddy_install()— 20 callers, 5 callees - new:
gemini_install()— 11 callers, 7 callees - new:
claude_install()— 19 callers, 4 callees - new:
_copy_skill_file()— 12 callers, 6 callees - new:
claude_uninstall()— 17 callers, 4 callees - …and 15 more — each is listed as a finding
Verification — 548 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: 467 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
31 of 304 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_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_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.
· 23 more finding(s) on lines outside this diff (see the check run).
|
Thanks @coder-zhw. The dual v1+v2 plugin with location-keyed registration already shipped in 0.9.84 (via #3554/#4039). Closing as superseded. |
What does this PR do?
graphify opencode installwrites.opencode/plugins/graphify.jsusing only the v1 plugin API, so OpenCode v2 refuses to load it:The installer also registers the plugin in
.opencode/opencode.jsonunder the bare relative path".opencode/plugins/graphify.js". OpenCode v2 resolves a bare specifier as an npm package spec and fails:So on v2 the integration is dead on arrival — one error or the other fires from the directory you open OpenCode in.
Fixes both in one file:
_OPENCODE_PLUGIN_JSto a single dual entrypoint: a v2 default export ({ id, setup }) that prepends the reminder viactx.shell.hook("create.before", event), plus the v1 named export ("tool.execute.before") kept alongside, so the same file still loads on v1. The v2 path walks up from the hook'sevent.cwdso the reminder also fires when the first command runs from a subdirectory.file://URI (the form the Kilo installer already uses) instead of a bare relative path. Uninstall drops both the URI form and any legacy bare relative entry, so an oldopencode.jsoncannot keep tripping v2's npm-spec resolution.Refs #3554, #3732. Note: this overlaps #3819 (dual entrypoint) and #3792 (drop the stale config entry); this PR does both, keeps v1 compatibility, and registers the plugin explicitly rather than relying on auto-discovery.
Type of change
Verification & Invariants
The invariant:
graphify opencode installmust produce a plugin that loads and injects on both OpenCode v1 and v2, from any project directory, without leaving a config entry that v2 misparses.How was this tested?
End-to-end on OpenCode 2.0.18 (macOS): the plugin loads with no errors, and the reminder is injected into the first shell command — observed in the spawned process args:
Also verified that both v2 hook shapes fire on 2.0.18 (
ctx.shell.hook("create.before")in this PR;ctx.tool.hook("execute.before")used by #3792/#3819) and that afile://entry, unlike a bare relative path, loads clean.Pre-existing failures (unrelated):
tests/has ~19 failures intest_skillgen.py/test_solidity_extractor.py/test_vbnet_extractor.pythat reproduce unchanged on a cleanv8checkout in this environment; none touch the opencode install path.Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments. — N/A:install.pyis not skillgen-generated (the plugin JS is a hand-maintained constant).$()-free (bug: opencode plugin reminder string has unescaped backticks → bash command substitution silently runs 'graphify query "<question>"' on every search #1413) and uses the;separator (OpenCode Graphify plugin uses &&, which fails in Windows PowerShell 5.1 #1646); no new interpolation.