Skip to content

feat: dual V2/V1 plugin API support (OpenCode V2) (#9) - #11

Draft
four-bytes-robby wants to merge 1 commit into
mainfrom
feat/9-v2-dual
Draft

four-bytes-robby wants to merge 1 commit into
mainfrom
feat/9-v2-dual

Conversation

@four-bytes-robby

@four-bytes-robby four-bytes-robby commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Closes #9

One default export for both generations: OpenCode 1.19.6 keeps reading server unchanged, V2 2.4.3 reads id/setup from the same export.

What changed

  • V1 server untouched: same go_usage tool, byte-identical description, string result.
  • V2 setup: Plugin.define({ id, setup }), tool registered via ctx.tool.transform, result normalised to { content }.
  • V2 tool input is zod-derived JSON Schema (tool.schema.toJSONSchema) with the $schema dialect marker dropped (PR #270 finding). One shared zod schema feeds both paths.
  • UsageReader injection keeps both tool paths testable without keys or network.

Local gate (implementation machine, bun 1.3.14)

  • bunx tsc --noEmit — 0 errors
  • bun test — 44 pass / 0 fail (4 files, 93 expects); existing V1 tests unchanged and green
  • bun run build — ok (dist/four-opencode-go-meter.js 5.04 KB, TUI + d.ts regenerated)
  • No linter configured in this repo (CI runs tsc + bun test); no console.* in plugin code
  • bash scripts/live-check-11.sh — 12/12 contract checks (opencode 1.19.6 on PATH)
  • @code-reviewer: hard gates green, no blocker/major/minor findings, soft score 98%

Not run here: live TUI check. scripts/live-check-11.sh is read-only (--live optional) and prints the V1 checklist; a V2 host smoke test still needs a V2 install.

Part of epic four-bytes/four-opencode-plugins#78.

V1 server() unchanged; V2 Plugin.define({ id, setup }) registers go_usage
through ctx.tool.transform. The V2 tool input is zod-derived JSON Schema with
the $schema dialect marker dropped (PR #270 finding).
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.

[FEAT] OpenCode V2 plugin API support (dual V2/V1 export)

1 participant