Repository navigation
feat: add OpenCode v2 plugin entrypoint (V2 compatible) - #41
Closed
scienceguy wants to merge 1 commit into
Closed
scienceguy wants to merge 1 commit into
scienceguy wants to merge 1 commit into
Conversation
…ility
- Add src/index-v2.ts with V2 {id, setup} schema
- Adapt V1 function-form plugin to V2 context API
- Export via package.json exports field (./v2)
- Build outputs to dist/v2.js
- Shim V1 client.session.*, client.tool.ids, client.app.log, etc. to V2 equivalents
- Register V1 hooks (tool.execute.before/after, chat.message, event) to V2 hook domains
Owner
|
This is the 3rd PR to add v2 support to this plugin, we are focusing on #37 |
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
This PR adds OpenCode v2 compatibility to the auto-resume plugin by providing a V2 entrypoint (
dist/v2.js) that wraps the existing V1 plugin factory.Changes
src/index-v2.ts- V2 plugin wrapper with{ id, setup }schemapackage.json- exports field and build script for V2 outputdist/v2.js- V2-compatible bundleTechnical Details
The V2 wrapper adapts the V1 function-form plugin (
AutoResumePlugin(ctx, options)) to the V2 object-form schema ({ id, setup }). It shims the V1 context API:ctx.client.session.prompt()ctx.session.prompt()ctx.client.session.messages()ctx.session.context()ctx.client.session.abort()ctx.session.interrupt()ctx.client.session.list()session_v2table)ctx.client.tool.ids()ctx.tool.list().map(t => t.id)ctx.client.app.log()ctx.client.provider.get()ctx.provider.list()filterctx.client.config.get()ctx.event.subscribe()Hook registrations:
tool.execute.before→ctx.tool.hook('execute.before')tool.execute.after→ctx.tool.hook('execute.after')chat.message→ctx.session.hook('prompt')event→ctx.event.subscribe()async iterationconfig→ Called on setupUsage
In
opencode.json:{ "plugins": [ { "package": "opencode-auto-resume/v2", "options": { "chunkTimeoutMs": 180000, "debug": false } } ] }Or auto-discovered from
.opencode/plugins/auto-resume/index.jspointing to the V2 entrypoint.Testing
bun run buildCloses #33 (OpenCode 2.x: fails to load — V1 entrypoint, no V2 setup(ctx))