Repository navigation
fix: migrate the plugin to the OpenCode V2 plugin API - #12
Merged
Merged
Conversation
OpenCode V2 rejects the V1 function export with "Plugin must export a default definition with an id and an effect or setup function", so the plugin failed to load after the V2 upgrade. - export a dual definition: `id` plus `setup(ctx)` for V2, `server()` for V1 1.18.29+, with the legacy hooks unchanged in behavior - port registration to command/skill/agent transforms, system prompt injection to the session context hook, deactivation to the prompt hook, and `/caveman <level>` persistence into the command execute - register skills without frontmatter and upsert the cavecrew subagents, appending an edit deny for the two read-only ones - move the plugin to `.opencode/plugins/caveman/index.mjs`: V2 only discovers local plugins as directories with an index file - update package entry points, the root opencode.json, docs, and tests
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
Port the plugin to the OpenCode V2 plugin API. V1 keeps working through the legacy entry point the migration guide documents.
The directory form is required: V2 only discovers local plugins as
<dir>/index.*, not bare files.Evidence
opencode servein a scratch project with the published@miguelmartens/opencode-caveman@1.0.2:failed to load plugin ... Plugin must export a default definition with an id and an effect or setup function.active; all 4 commands, 4 skills, and 3 cavecrew agents registered;/caveman ultrapersisted the level;stop cavemanturned it off.npm test33/33 pass,npm run format:checkclean.Merge Danger
Door: two-way — reverting restores the V1 entrypoint.
Blast Radius: V1 below 1.18.29 no longer loads the package (function export becomes an object); 1.18.29+ works via
server(). In V2, same-ID skills already present in~/.agents/skillsor project config override the bundled copies, because config sources apply after plugin transforms.