Repository navigation
Conversation
OpenCode v2 requires a plugin default export shaped { id, effect } or
{ id, setup }. Wrap the plugin in define({ id: 'oc-sync', setup }) and drop
the (never-invoked) V1 cleanup return. Make watcher/interval start idempotent
so reloads do not stack timers. Pin @opencode-ai/plugin to ^1.19.0 and bump to
0.2.0 (breaking: V1 and V2 module shapes are mutually exclusive).
Switch from the V1 function export to Plugin.define({ id, setup }) from
@opencode/plugin (matching OpenCode 2.0.28) and return stopBackgroundSync as
the setup cleanup function, so background sync is disposed on unload. Make
watcher/interval start idempotent. Replace @opencode-ai/plugin with
@opencode/plugin ^2.0.28; bump to 0.2.0. Update the upgrade plan for the
native 'plugins' config field and local install layout.
README, LLM-INSTALL, CONFIG and DEV-SETUP now use the V2 'plugins' field, opencode plugin add / local directory install, and 'opencode service restart'. Add release-line notes to PUBLISH (0.2.x=V2, 0.1.x=V1) and link the upgrade guide from README.
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.
Summary
OpenCode v2 rejects the V1 plugin shape, so
oc-syncfails to load with:This ports the plugin to the V2 API and updates the docs.
Root cause
oc-sync's default export is a V1 async function (export default async () => ...).OpenCode v2 requires the default export to be an object
{ id, setup }(Promise API) or{ id, effect }(Effect API).Changes
src/plugin/plugin.ts: usePlugin.define({ id: 'oc-sync', setup })from the official@opencode/pluginpackage;setupreturnsstopBackgroundSyncas the cleanup function(runs on plugin unload), so background sync is disposed properly.
src/plugin/background-sync.ts:startFileWatcher/startIntervalSyncare now idempotent(dispose any existing watcher/timer first) to avoid stacking on reload.
package.json: replace@opencode-ai/pluginwith@opencode/plugin@^2.0.28; bump to0.2.0.
docs/LLM-INSTALL.md,docs/CONFIG.md,docs/DEV-SETUP.mduse the V2pluginsfield,opencode plugin add/ local directory install, andopencode service restart;docs/PUBLISH.mddocuments the 0.2.x (V2) / 0.1.x (V1) release lines; addsdocs/UPGRADE-OPENCODE-V2.md.Breaking change
V1 (
functiondefault export) and V2 ({ id, setup }object) module shapes are mutuallyexclusive.
0.2.0targets OpenCode v2 (2.0.28+); OpenCode 1.x users should stay onoc-sync@0.1.x. Consider publishing0.2.0under thenextdist-tag first.Requirements
@opencode/pluginmatching the targeted OpenCode releaseTesting
npm run check(typecheck + lint + format) andnpm run buildpass.{ id: 'oc-sync', setup }.pluginsentry (absolute directory path);opencode plugin listshowsoc-sync, andopencode-sync.logreports:Plugin starting.../Token loaded from: config file/File watcher started/Interval sync started (every 5 min)/Plugin ready/Initial sync complete: Already in sync.PluginModule.LoadErrorafter load.Notes
setup's cleanup is wired, but the exact reload path (config change vsservice restart)should be confirmed when validating; a config change alone did not reload the plugin in testing —
opencode service restartwas required.@opencode/pluginv2 and pin docsaccordingly.