Repository navigation
Conversation
OpenCode >= 2.0 dropped the V1 function-export plugin API and requires a default export { id, setup(ctx) }. The plugin now registers tools via ctx.tool.transform (JSON Schema, returning { content }); execute.before/after via ctx.tool.hook; system digest via session.hook("context"), memory-first injection via session.hook("prompt"), compaction rollup via session.hook("compaction"); /repo-init via the commands-dir mirror; live root from ctx.location.directory. Business logic stays in the decoupled helper modules. Tests drive the V2 surface through a new test/harness.ts fake ctx (74 pass; typecheck clean).
2 tasks done
This was referenced Oct 29, 2026
This was referenced Nov 14, 2026
This was referenced Nov 25, 2026
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 and its test suite from the OpenCode 1.x (V1) function-export plugin API to the OpenCode 2.x plugin API.
OpenCode >= 2.0 dropped the V1 function-export style and requires a default export of the shape
{ id, setup(ctx) }. All plugin behavior is preserved; only the registration surface changed.Changes
src/index.ts): default export{ id, setup(ctx) }.ctx.tool.transform(JSON Schema, returning{ content }).execute.before/execute.afterviactx.tool.hook.session.hook("context").session.hook("prompt").session.hook("compaction")./repo-initvia the commands-dir mirror.ctx.location.directory.test/harness.tsprovides a fake V2ctxso the suite drives the new surface directly; existing tests updated accordingly.Test plan
bun test— 74 pass, 4 skip, 0 fail (323 assertions, 78 tests across 11 files)bunx tsc --noEmit -p tsconfig.json— clean