Repository navigation
Conversation
OpenCode 2.x only loads plugins whose default export is an object with an id and setup()/effect(); the previous bare-function default export failed with 'Plugin must export a default definition...'. - core.ts: version-agnostic server connection, leader election, skins - index.ts: one default export serving both APIs (V2 id+setup, V1 server()) - connect in the background and dispose cleanly on unload - map V2 events (session.status/idle/execution.failed) to the shapes the frontend already understands - tests (bun test), tsconfig, README for both config keys - @opencode-ai/plugin is now types-only (devDependency)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On OpenCode 2.x the plugin fails to load:
2.x only loads plugins whose default export is an object with an
idandsetup()/effect(). This package default-exports a bare 1.x plugin function, so it can't load on 2.x. See theV1 → V2 plugin migration guide.
Change
One default export now serves both plugin APIs:
id+setup(ctx)for 2.x andserver()for 1.x (the dual-support shape from the migration guide).core.ts(new): version-agnostic server connection, leader election, reconnects, skin selection and loggingindex.ts: thin 1.x and 2.x adapters over the corectx.event.subscribe()andctx.tool.hook("execute.before" | "execute.after"). 2.x events (session.status,session.idle,session.execution.failed/session.step.failed) are mapped to the message shapes the frontend already reads, sovisualizer/is unchanged.@opencode-ai/pluginis now types-only (devDependency). The 2.x context is typed with a small local interface, so the 2.x SDK isn't needed.bun test, 15 tests),tsconfig.json, README updated for both config keys. Version bumped to 1.1.0.Testing
Loaded this branch in the real runtimes (isolated config/data dirs) and confirmed the plugin loads once and connects to the visualizer server:
failed to load plugin, connectsI also observed
tool.execute.before/afterevents from a live 2.x session arriving at the frontend. Unit tests cover event mapping, reconnect/dispose and both adapters; I confirmed they fail when a mapping is broken.Notes
package.json. Pointing atindex.tsgives "configured plugin path must be a directory". 1.x accepts the file. The README documents this.session.status/session.idleforwarding is covered by unit tests, not an end-to-end run.tui.ts(the/visualizercommand) still targets the 1.x TUI API. A 2.x port is a separate change; the README notes this.visualizer/ocv-server.tshas 5 existing type errors under currentbun-types. I left it untouched, so there is notypecheckscript.When you open the PR, check that the base is psinetron/opencode-visualiser:main and the compare branch is wesselOC:feat/opencode-v2-support. If the push is rejected or ssh -T shows an error, paste the output and I'll help sort it out.