Repository navigation
Conversation
- extract host-agnostic memory behavior into src/runtime.ts - add src/plugin-v2.ts using session/tool hooks and event subscription - port /memory TUI command to the V2 keymap and dialog APIs - export dual entrypoint: setup() for V2, server() for V1 - keep the existing on-disk memory format and storage paths - track V2 todowrite snapshots for compaction context
Mirr0ch1
force-pushed
the
feat/opencode-v2
branch
from
October 21, 2026 05:45
a74ef82 to
b271045
Compare
Author
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 replaced the V1 plugin API. The current package fails to load on V2 with:
This PR adds a V2 adapter while keeping the existing V1 implementation working from the same package.
What changed
src/runtime.ts.src/plugin.tsis now the V1 adapter (same hooks and behavior as before).src/plugin-v2.tsusingPlugin.define({ id, setup })./memoryTUI command to the V2 keymap/dialog APIs insrc/tui-plugin.ts; the legacy TUI implementation remains insrc/tui-plugin-v1.ts.tui.tsbesideindex.tsso V2 discovers the TUI entrypoint for local directory plugins. Published packages expose the same module throughexports["./tui"].index.tsexports both shapes:setupfor V2 andserverfor V1.V2 hook mapping
experimental.chat.system.transformctx.session.hook("context"), pushing text system partstool.execute.afterctx.tool.hook("execute.after")experimental.session.compactingctx.session.hook("compaction")event(session.compacted)ctx.event.subscribe()(session.compaction.ended)V2 behavior notes
[M#]refs as a system part. Memory extraction is equivalent and still makes no extra LLM call.todowritesnapshots in session state and renders them during compaction.shellinstead ofbash,pathinstead offilePath, andmetadata.exitfor command status. All are handled.session.parentID.Verification
npm run typechecknpm run buildnpm run check:package-integritynpm test: 548 passing, including 11 new V2 adapter/TUI tests2.1.1:GET /api/pluginreportsworking-memorywithstate.status: activeworking-memory-tuireachesstage=setupand registers the/memoryslash commandCompatibility
setup(ctx).>= 1.18.29supports the object entrypoint and usesserver(input, options)../serverexport directly.~/.local/share/opencode-working-memory/is reused as-is.The package version is bumped to
1.7.0; happy to drop that if you prefer to handle the release separately.