Skip to content

feat: port plugin adapter to OpenCode V2 plugin API - #8

Open
AleMuzzi wants to merge 3 commits into
CrewBeeLab:mainfrom
AleMuzzi:feat/opencode-v2-port
Open

AleMuzzi wants to merge 3 commits into
CrewBeeLab:mainfrom
AleMuzzi:feat/opencode-v2-port

Conversation

@AleMuzzi

@AleMuzzi AleMuzzi commented Nov 5, 2026

Copy link
Copy Markdown

Summary

Ports the CrewBee plugin adapter to the OpenCode V2 plugin API so the plugin loads on OpenCode 2.x, while keeping the V1 path working through a dual-shape entrypoint.

On OpenCode V2 (tested with 2.1.3) the current release fails to load with:

failed to load plugin target=crewbee
cause=PluginModule.LoadError: Plugin must export a default definition with an id and an effect or setup function.

V2 does not run V1 plugin implementations (see the official migration guide), so the adapter is provided as a new V2 module alongside the preserved V1 implementation.

Changes

  • src/adapters/opencode/v2/ (new): V2 adapter implementation
    • plugin.ts — Plugin.define({ id, setup(ctx) }) entrypoint wiring transforms, hooks, and event subscription
    • session-client.ts — V2 session/message client shims (messages via session.context, prompt, abort → interrupt)
    • tool-registration.ts — registers delegate tools through ctx.tool.transform with zod ValueSchema
    • agent-definition.ts — projects CrewBee agents via ctx.agent.transform
    • models.ts — available-model discovery via ctx.model.list()
    • permissions.ts — permission mapping for V2 agent definitions
    • logging.ts — console-based logging (V2 has no client.app.log)
  • src/adapters/opencode/plugin.ts — dual-shape default export: V2 setup + V1 server
  • src/adapters/opencode/plugin-v1.ts — previous V1 plugin body preserved as server()
  • src/adapters/opencode/tool-hooks.ts — execute.before/execute.after adapted to V2 hook shapes
  • src/install/opencode-config-file.ts — plugin entry written to V2 plugins config key (with plugin migration)
  • src/update/refresh.ts — V2 logging/context adaptation
  • package.json — targets OpenCode 2.2.0 SDK (@opencode/plugin)
  • docs/developer/opencode-v2-port.md — full porting notes (V1 → V2 API mapping)

Testing

  • npm run typecheck, npm run build, npm test
  • Empirical load test against OpenCode 2.x: plugin loads, agents projected, delegate tools registered

@AleMuzzi
AleMuzzi force-pushed the feat/opencode-v2-port branch from ac74314 to d75db24 Compare November 5, 2026 16:13
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.

1 participant