Context
OpenCode V2 is currently beta and intentionally does not load V1 plugins. The migration guide describes the new plugin shape (Plugin.define({ id, setup })) and runtime registration APIs: https://opencode.ai/v2/docs/migrate-v1
opencode-pty currently targets the V1 contract in src/plugin.ts, exporting an async plugin function with PluginContext / PluginResult and depending on @opencode-ai/plugin ^1.3.13.
This issue is a planning request, not an expectation that unstable V2 support ship immediately.
Suggested port plan
- Keep the current V1 entry point while V2 remains beta; add a separate V2 entry point/export.
- Replace the V1 async plugin export with a unique V2
id and setup.
- Register PTY tools through the V2 tool transform/registration surface, preserving existing schemas and descriptions.
- Map command handling and session notifications to V2 command/session APIs.
- Review process ownership and cleanup against V2 session interruption, service restart, and standalone/managed modes.
- Avoid sharing host-specific client calls between V1 and V2; keep the PTY/process core shared and adapters thin.
Compatibility checks
- Plugin appears in
opencode2 api get /api/plugin.
- PTY creation, input, resize, output polling, and termination work in
opencode2 --standalone.
- Managed service mode behaves the same as standalone mode.
- Session interruption and service shutdown leave no orphan process.
- Invalid or expired PTY IDs return bounded errors rather than crashing the host.
- Existing V1 tests and package entry point remain unchanged.
Would V2 support be in scope once the API settles? I can help test a branch against current opencode2 previews.
Context
OpenCode V2 is currently beta and intentionally does not load V1 plugins. The migration guide describes the new plugin shape (
Plugin.define({ id, setup })) and runtime registration APIs: https://opencode.ai/v2/docs/migrate-v1opencode-ptycurrently targets the V1 contract insrc/plugin.ts, exporting an async plugin function withPluginContext/PluginResultand depending on@opencode-ai/plugin^1.3.13.This issue is a planning request, not an expectation that unstable V2 support ship immediately.
Suggested port plan
idandsetup.Compatibility checks
opencode2 api get /api/plugin.opencode2 --standalone.Would V2 support be in scope once the API settles? I can help test a branch against current
opencode2previews.