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)
- 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.
- Lazy dynamic imports so each host's SDK (
@opencode-ai/plugin vs @opencode/plugin) only resolves under its own runtime.
- Thin adapters
src/opencode/v1.ts / src/opencode/v2.ts behind a HostCapabilities seam; shared core unchanged.
- 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
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/thatchpackage -- no fork, MCP path untouched.Plan
Full refined plan (CONSENSUS, 4 review rounds):
docs/plans/opencode-v2-plugin.mdon branchopencode-v2-migrationopencode-v2-migrationWhy it breaks
{ id, setup }(promise API) or{ id, effect }(Effect API); the v1 namedserverexport is not read. Verified at tag v2.0.9 (packages/core/src/plugin/module.ts).@opencode/plugin(@opencode-ai/pluginfrozen at 1.18.32).Approach (from the plan)
{ id, setup, server }-- both loaders consume their own keys; verified against v1.18.32'sreadV1Pluginand (empirically) v2.0.9's Effect Schema decoder.@opencode-ai/pluginvs@opencode/plugin) only resolves under its own runtime.src/opencode/v1.ts/src/opencode/v2.tsbehind aHostCapabilitiesseam; shared core unchanged.delete,session.list/messages, tui commands, toast publish path) with strategies in the plan's capability table.Acceptance
mise run checkgreen