Repository navigation
test(opencode): pin the installed OpenCode plugin to a v2-loadable default export - #22389
Conversation
…fault export OpenCode 2 installs under the plain `opencode` executable name and its plugin loader requires the default export to carry `setup` (or `effect`) alongside an `id`; the v1 loader requires `server`. The emitted plugin source already carries both, but nothing asserted it on the file Orca actually installs into OpenCode's config directory — the exact surface that regressed in #22234. Load the installed file as an ES module and assert its default export satisfies both loaders. Reverting getOpenCodePluginSource() to the v1-only options makes this test fail with "expected undefined to be type of 'function'".
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughAdds an integration test that installs the generated OpenCode plugin, imports the installed source as ESM, and checks that its default export has the expected ID and function-valued Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to The added test covers the installed plugin’s loader-facing exports. No issue identified here needs resolution before merge. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
Full details: Linked Issues checkExplanation For [ ✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Installed-artifact plugin contract test — adds one test to
src/main/opencode/hook-service.test.tsthat drives the realbuildPtyEnvinstall path, copies the file Orca wrote into OpenCode's configplugins/directory to a temporary.mjs, imports it as an ES module, and asserts its default export exposesid,server(v1 loader), andsetup(v2 loader).
I confirmed the test can actually fail: reverting getOpenCodePluginSource() in src/main/opencode/hook-service.ts to the pre-1a3f4e88c0f v1-only options makes the new assertion at src/main/opencode/hook-service.test.ts:312 fail with expected undefined to be type of 'function'. The whole file passes on the PR head (33/33) and pnpm run check:code-quality:changed reports zero new findings. Note the regression is also caught by the pre-existing digest test and by hook-plugin-opencode2-setup.test.ts; this test's distinct value is exercising the install-path wiring (buildPtyEnv → writePluginToConfigDir → default variant) rather than the generator directly, which is the seam the source-level tests don't cover.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

ELI5
Orca writes a small plugin file into OpenCode so it can tell when the agent is working, idle, or waiting on you. OpenCode 2 changed the rules for what that file has to look like, and for a while Orca was writing the old shape — so OpenCode refused to load it and Orca's status indicators went dead. That was already fixed a few days ago. This PR adds a test so it can't quietly break again.
What Changed
Test only — no production code changes.
src/main/opencode/hook-service.test.tsgains one test that runs the real plugin install path (buildPtyEnv), takes the file Orca actually wrote to OpenCode's config directory, imports it as an ES module, and asserts its default export satisfies both plugin loaders:default.id+default.server— what OpenCode 1's loader requiresdefault.setup— what OpenCode 2's loader requiresWhy
#22234 reported OpenCode 2.0.12 rejecting
orca-opencode-status.jswith:This no longer reproduces on
main. It was fixed by1a3f4e88c0f(fix(opencode): support v2 plugins under plain executable name, Sep 21), which landed after the reporter's Orca 1.4.206.Root cause of the original bug:
setupis appended to the plugin's default export only when the generator is called withemitNextEvents: true.getOpenCodePluginSource()— the source installed for the plainopencodeexecutable — did not pass it, so it emittedexport default { id, server }. Because OpenCode 2.0.12 installs asopencode, the v2 loader received the v1-only shape.1a3f4e88c0fflipped that generator to{ emitSessionStart: true, emitNextEvents: true, expectedAgent: 'opencode' }.Why a test rather than a fix: the escape route is still open.
hook-plugin-opencode2-setup.test.tsalready assertssetupexists on the generated source, but nothing asserted it on the installed file. Every source-level test would have stayed green ifhook-service.tspicked the wrong generator — which is exactly how #22234 escaped. Asserting against the installed artifact closes that gap; asserting against the generator again would not.Alternative considered: also hardening
src/main/mimo/hook-service.ts:75, the last remaining caller still emitting the v1-only shape. Left alone — it is correct today because MiMo Code tracks OpenCode v1, and changing it would be an unrelated behavior change. Flagged here so it is on the record if MiMo rebases onto OpenCode 2.Linked Issue
Fixes #22234
Visual Proof
N/A— test-only change; no user-visible surface is touched. The behavioral proof is a realopencode serve(v2.0.12, macOS) pointed at each plugin shape viaOPENCODE_CONFIG_DIR:Pre-fix shape (
export default { id, server }, byte-identical to1a3f4e88c0f^):Byte-for-byte the reporter's error.
Current
main(export default { id, server, setup }):Same clean load for
orca-opencode2-status.js. End-to-end, with a hook receiver onORCA_AGENT_HOOK_PORT, creating a session over the v2 API delivered a real event through the v2setup()bridge:Testing
Platforms: macOS, against a real OpenCode v2.0.12 binary.
Reviewer steps:
pnpm test src/main/opencode/hook-service.test.ts— passes.getOpenCodePluginSource()insrc/main/opencode/status-plugin-factory-source.tsto the v1-only options (dropemitNextEvents/expectedAgent).expected undefined to be type of 'function', i.e. it catches exactly the [Bug]: orca-opencode-status.js hook is incompatible with OpenCode V2 and fails to load #22234 regression.Suite results:
pnpm test src/main/opencode src/main/opencode2— 16 files, 192 tests passedpnpm tc— cleanpnpm run check:code-quality:changed— 0 new findingsNot verified on a live OpenCode 1 server: only v2.0.12 is obtainable locally (
opencode2there is a 47-byte shim to the same v2 binary). The v1 half rests on the pre-existinghook-plugin-module-contract.test.ts, which assertsserveris present and callable.AI Disclosure
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
serverandsetup, so both the OpenCode 1 and OpenCode 2 loaders accept the same installed file. No user on either version changes behavior.buildPtyEnvinstall path used on all platforms and does no path-separator assertions of its own.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm testpass locally