Repository navigation
Conversation
OpenCode v2 replaces the plugin API, so the default export now carries both
entrypoints: v1 keeps calling server(), v2 calls setup().
- src/memoryTool.ts: shared, API-free core (tool description, JSON schema,
runtime, the six handlers) used by both entrypoints
- src/v2.ts: v2 glue via @opencode/plugin — ctx.tool.transform() registers
the memory tool, ctx.session.hook("context") injects the memory context,
ctx.tool.hook("execute.after") handles cache invalidation and the
daily-log reminder, ctx.event.subscribe() tracks the session lifecycle
- @opencode-ai/plugin raised to ^1.18.30: the object entrypoint
({ id, server }) and its PluginModule type exist from 1.18.29
- @opencode/plugin is a devDependency (types only, no runtime coupling)
V1 behaviour is unchanged; both entrypoints share one implementation.
- README: v2 section with the v1 -> v2 hook mapping and the >= 1.18.29 note - LICENSE: MIT text, matching the license already declared in package.json
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.
OpenCode v2 replaces the plugin API, so v1 plugin implementations stop working. This adds a v2 entrypoint next to the existing one instead of replacing it: the default export carries both, and the shared implementation lives in one place.
What changed
src/memoryTool.ts(new) — the API-free core: tool description, JSON schema, runtime wiring and the six handlers, moved out ofindex.tsunchanged.src/v2.ts(new) — the v2 glue via@opencode/plugin:ctx.tool.transform(e => e.add({ name, description, input, execute }))registers thememorytool (plain JSON Schema instead of the v1tool.schemaargs)ctx.session.hook("context", …)injects MEMORY/IDENTITY/USER plus the instructionsctx.tool.hook("execute.after", …)keeps the cache invalidation and the daily-log reminderctx.event.subscribe({ signal })tracks the session lifecycle; cleanup is returned fromsetup()src/index.ts— now the slim v1 entrypoint:export default { ...V2Plugin, ...{ id: "memory-md", server: MemoryPlugin } }.@opencode-ai/plugin→^1.18.30(the object entrypoint and itsPluginModuletype exist from 1.18.29),@opencode/plugin^2.0.9as a devDependency (types only — the v2 runtime is never imported in a v1 process), version →1.3.0.Hook mapping
tool: { memory: tool({ … }) }ctx.tool.transform(e => e.add({ … }))"tool.execute.after"ctx.tool.hook("execute.after", …)"experimental.chat.system.transform"ctx.session.hook("context", …)eventctx.event.subscribe(…)ctx.client.tui.showToastVerified
bun run format:check,bun run typecheckandbun run buildall pass — compiled against the real@opencode/plugin@2.0.9types.memorytool is registered and read/write/search/list work.tuidifference above is a deliberate, documented deviation.One caveat worth deciding on
The object entrypoint (
{ id, server }) is only understood from opencode 1.18.29 onwards; on older versions the default export gets called as a function and would fail. If the v1 path should keep working on older releases, the v2 entrypoint can live behind a subpath export (@zhafron/opencode-memory-md/v2) instead — happy to rework it that way.The
LICENSEfile is a separate commit and easy to drop if you would rather not add it.