Skip to content

feat(opencode): dual v1+v2 plugin entrypoint - #3819

Closed
Corxo91 wants to merge 1 commit into
Graphify-Labs:v8from
Corxo91:feat/opencode-v2-dual-plugin
Closed

Corxo91 wants to merge 1 commit into
Graphify-Labs:v8from
Corxo91:feat/opencode-v2-dual-plugin

Conversation

@Corxo91

@Corxo91 Corxo91 commented Sep 25, 2026

Copy link
Copy Markdown

Closes #3554.

Problem

graphify opencode install generates .opencode/plugins/graphify.js using only the v1 plugin API (export const GraphifyPlugin + (input, output) hooks). V1 implementations do not run on OpenCode v2, so the graph reminder silently never fires there.

Change

Single-file dual entrypoint per the official v1→v2 migration guide:

  • v2: default export via Plugin.define({ id: "graphify", setup(ctx) }) + ctx.tool.hook("execute.before"). Resolves the project dir per session (event fields → ctx.session.get → ctx.location fallback) instead of relying on the plugin-instance directory, so it also works as a global plugin.
  • v1 (1.18.29+): server() returning the same tool.execute.before hook.
  • Same install path (.opencode/plugins/graphify.js, discovered by both runtimes) and same config registration (v2 normalizes the v1 plugin key automatically), so no installer logic changes.

Reminder behavior unchanged: backtick/$()-free string (#1413), ';' separator for PowerShell 5.1 (#1646).

Tests

  • Existing opencode installer tests all green (backticks, semicolon, registration, uninstall).
  • New: test_opencode_plugin_supports_v2_api, test_opencode_plugin_keeps_v1_server_hook.
  • tests/test_install.py: 110 passed; ruff check clean; generated JS validated with node --check.

Note: left #1412/#1414 (global install path) untouched to avoid conflicts — happy to rebase if needed.

The generated .opencode/plugins/graphify.js used the v1 plugin API only,
so it never runs on OpenCode v2 (Closes Graphify-Labs#3554).

Export a dual entrypoint per the official migration guide: v2 reads the
default export's id/setup() via Plugin.define + ctx.tool.hook, while v1
(1.18.29+) calls server() and uses the returned hooks. A single file in
.opencode/plugins/ now serves both runtimes; config registration is
untouched (v2 normalizes the v1 "plugin" key automatically).

Reminder behavior unchanged: backtick/$()-free string, ';' separator
(Graphify-Labs#1413, Graphify-Labs#1646). Adds regression tests for both entrypoints.

@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 1 advisory finding(s) below merit a look before merge.


Graphify review — findings

Rewrites the generated OpenCode graphify plugin to expose both a v2 default export (id/setup() registering a tool.execute.before hook via ctx.tool.hook) and a legacy v1 server() hook, so one .opencode/plugins/graphify.js file works across both runtimes. Dedupes the reminder per session, resolves the project directory from event/session candidates before falling back to ctx.location.directory or process.cwd(), and matches bash/shell/execute tools while injecting the reminder into whichever of command/cmd/script the input carries. Adds tests asserting the file contains both the v2 entrypoint and the v1 server() hook.

Worth a look

  • OpenCode v2 reminder check/add races across concurrent hooks — graphify/install.py:1514 · 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 — 546 functions depend on the 314 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 — 546 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: 465 function(s) in the blast radius were not formally verified this run

Test selection

Test selection

31 of 300 test file(s) selected (10%) 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_devin.py — impact
  • tests/test_explain_cli.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_references.py — impact
  • tests/test_install_strings.py — impact
  • tests/test_install_version_warning.py — impact
  • tests/test_merge_chunks_validation.py — impact
  • tests/test_multigraph_diagnostics.py — impact
  • tests/test_no_dedup_flag.py — impact
  • tests/test_path_cli.py — impact
  • tests/test_query_cli.py — impact
  • tests/test_query_induced_edges.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_version_warning.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.

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

@MatyeusM

Copy link
Copy Markdown

I ran

uv tool install git+https://github.com/Corxo91/graphify.git@feat/opencode-v2-dual-plugin
graphify opencode install

this still fails both plugins for opencode2.

@safishamsi

Copy link
Copy Markdown
Member

Thanks @Corxo91. The dual OpenCode v1+v2 plugin entrypoint already shipped in 0.9.84 (via #3554/#4039), keeping a v1 server() hook alongside the v2 default export. Closing as superseded.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Opencode v2 plugin support

3 participants