Skip to content

Port OpenCode entrypoint to V2 API (desktop 2.0.22) - #8

Open
Shadrous wants to merge 2 commits into
ndom91:mainfrom
Shadrous:v2-port
Open

Shadrous wants to merge 2 commits into
ndom91:mainfrom
Shadrous:v2-port

Conversation

@Shadrous

@Shadrous Shadrous commented Oct 3, 2026

Copy link
Copy Markdown

The OpenCode entrypoint (opencode/index.js) fails on V2 (Expected object at [default]).

  • export default Plugin.define({ id: 'open-plan-annotator', setup }) from @opencode/plugin 2.0.22
  • annotate_plan tool via ctx.tool.transform, system prompt via ctx.session.hook('context')
  • Added root index.js re-export so the V2 loader resolves the package directory correctly
  • Verified: bun test 99 pass, typecheck/lint clean, loads in desktop 2.0.22 with no warnings
  • Note: opencode plugin add from git still fails at dep prep (bun toolchain); local path works: { "package": "<repo>/opencode"

- Replace V1 function export with Plugin.define({id, setup})
- Register annotate_plan via ctx.tool.transform with JSON Schema input
- Inject plan instructions via ctx.session.hook(context)
- Resolve current agent via ctx.session.get + ctx.agent.list
- Handoff via ctx.session.switchAgent; cleanup via setup return
- Preserve bridge/config/server UI logic unchanged
@ndom91

ndom91 commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Thanks for this! Will have a look shortly

@ndom91

ndom91 commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

I checked the port against the 2.0.22 types and the API usage all looks right. Two things need changing before we can merge:

Blocking

  1. Keep V1 working. Removing the OpenPlanAnnotatorPlugin export breaks everyone still on OpenCode 1.x the moment they upgrade. Could we export both, the V1 function as a named export plus the V2 object as the default? Worth checking that the V1 loader is OK with a non-function default export.
  2. Drop the @opencode/plugin dependency. Plugin.define just returns its argument. The dependency adds about 600 lockfile lines plus solid-js/@opentui peer deps for every user, including people on Claude Code only. A plain export default { id, setup } with a JSDoc @type import does the same job.

Nits

  • The context hook event already includes event.agent, so you can drop the session.get + agent.list() calls on every model step.
  • getAgentList: the response is always { data }, so the bare-array branch and the candidate.id match can go.
  • With no implementation agent, the approval text says "Execute the approved plan directly now" twice.
  • The root index.js isn't in files, so it never ships. Either add it there or remove it.
  • Please add the JSDoc types back on the new functions. opencode/ relies on them, and typecheck doesn't cover that directory.

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.

2 participants