Skip to content

Support opencode v2 plugin API (dual v1/v2 adapter) #15

Description

@sysread

Synopsis

opencode 2.0 replaced the plugin API. Thatch's plugin (v1 shape) fails to load on opencode v2 with a PluginModule.LoadError. This issue tracks the migration: dual v1/v2 support in the same @jeffober/thatch package -- no fork, MCP path untouched.

Plan

Full refined plan (CONSENSUS, 4 review rounds):

Why it breaks

  • v2 requires a default export { id, setup } (promise API) or { id, effect } (Effect API); the v1 named server export is not read. Verified at tag v2.0.9 (packages/core/src/plugin/module.ts).
  • The v2 SDK is a new npm name: @opencode/plugin (@opencode-ai/plugin frozen at 1.18.32).
  • Upstream migration doc is explicit: "Port plugins, because V1 plugin implementations do not run in V2."

Approach (from the plan)

  1. Merged default export { id, setup, server } -- both loaders consume their own keys; verified against v1.18.32's readV1Plugin and (empirically) v2.0.9's Effect Schema decoder.
  2. Lazy dynamic imports so each host's SDK (@opencode-ai/plugin vs @opencode/plugin) only resolves under its own runtime.
  3. Thin adapters src/opencode/v1.ts / src/opencode/v2.ts behind a HostCapabilities seam; shared core unchanged.
  4. Declared degradation for v2-missing surfaces (child-session delete, session.list/messages, tui commands, toast publish path) with strategies in the plan's capability table.

Acceptance

  • Milestone 1: seam extraction, dual entry, shim updates, zero behavior change, mise run check green
  • Milestone 2: smoke tests against real opencode-v2 + v1 binaries; open questions resolved
  • Milestones 3-5: v2 adapter, toasts-or-degrade, mirrored test suite + Bun 1.4.2 CI/publish legs
  • Milestone 6: README "2.0 not yet supported" note removed, dev docs updated, release cut

Activity

  1. self-assigned this
    on Sep 22, 2026
  2. sysread commented on Sep 24, 2026

    @sysread
    OwnerAuthor

    Shipped in the opencode v2 dual adapter, merged to main as b57fdc7 (PR #16, six review rounds). The plugin loads and works on both opencode 1.x and 2.x from one package; the v2 degrades and post-release verification list are in docs/dev/features/opencode-plugin.md and the README.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions