Conversation
V2 rejects the V1 function export, so the default export now carries
{id, setup} for OpenCode 2 plus server() for OpenCode 1. setup registers
the opencode_sync tool via ctx.tool.transform and subscribes to
session.idle via ctx.event.subscribe, mirroring the V1 behavior.
Also teach prunePluginCache the V2 plugins key (string and {package}
specs) while keeping the legacy plugin key, and update the install
docs. Covers both halves and the new pruning paths with tests/plugin.test.ts.
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.
OpenCode 2 rejects the V1 function export (
Plugin must export a default definition with an id...), so the plugin never loads there. Verified on 2.0.14:opencode plugin listshows the entry with no id, and the server log repeats the LoadError.This keeps one default export that both loaders accept:
{ id: 'opencode-github-sync', setup }— registers theopencode_synctool viactx.tool.transform(JSON Schema input,{ content }result), subscribes tosession.idleviactx.event.subscribefor the optional idle push, and runs the startup pull. No dependency on@opencode/plugin; the context shape is structural.server()hook map (event+tool), kept as a namedOpencodeGithubSyncexport.prunePluginCachenow reads the V2pluginskey (string and{ package }specs) with fallback to the legacypluginkey.pluginsin both READMEs.Verification:
npm run checkgreen (lint + typecheck + 104 tests, including newtests/plugin.test.tscovering both halves, idle push, and both config keys). Local V2 live-load confirmed:loading plugin .../dist/pluginwith no LoadError and the entry listed with idopencode-github-sync.