Local-first 🧠memory for Hermes Agent that lives in your Obsidian vault and remembers project context. Nightly 😴 dream passes turn repeat corrections into confirmed preferences with measurable confidence. Adapters ship for Claude Code, Codex, and OpenClaw, with an MCP server for anything else.
TypeScript
opencode native integration - implementation plan
Design: design.md. Each task is one atomic conventional commit on feat/opencode-native-integration, test-first.
Tasks
Task 1: Pluggable MCP entry shape in the shared JSON-merge layer
- Files:
src/core/install/json-merge.ts,src/core/install/adapters/_json-mcp.ts,src/core/install/payload-equals.ts,tests/core/install/adapters/json-mcp-smoke.test.ts(+ a focused unit test for the new injection points) - Acceptance:
mergeMcpServers/removeMcpServers/ drift comparison accept optionalserializeEntryandentryEquals; with them omitted, output for cursor/kiro/gemini-cli fixtures is byte-identical to today (smoke test pins it); a custom shape round-trips through merge → detect → verify. - Depends on: none
Task 2: opencode install adapter rewrite (opencode.json mcp block + legacy migration)
- Files:
src/core/install/adapters/opencode.ts,tests/core/install/adapters/opencode.test.ts,tests/fixtures/install/opencode/* - Acceptance: apply on a clean home writes
~/.config/opencode/opencode.jsonwithmcp.open-second-brainandmcp.open-second-brain-writershaped{type:"local", command:[array], environment, enabled:true}preserving user keys; apply with a legacy~/.config/opencode/mcp.jsoncontaining our keys removes them (file deleted only when empty and manifest-owned); detect/plan/verify/uninstall lifecycle green including drift detection on the new shape; XDG_CONFIG_HOME honored. - Depends on: Task 1
Task 3: Bundled opencode plugin (single file, zero-dep)
- Files:
plugins/opencode/open-second-brain.ts,src/core/install/opencode-plugin-asset.ts,tests/plugins/opencode-plugin.test.ts - Acceptance: plugin module exports the opencode plugin function; with a fake
clientand temp XDG dirs: (a)eventsession.idle/compacted/deleted produces a spool snapshot<sessionID>.jsonlwith meta lineformat:1+ normalized turn lines, atomic rewrite, idempotent across repeated idles; (b)experimental.chat.system.transformappends rendered context when theo2b-hook active-injectspawn succeeds (fake viaOSB_HOOK_BINpointing at a stub script) and no-ops (no throw) when the binary is missing; (c)tool.execute.afterappends the reminder only for file-mutating tool ids; (d) every hook body swallows internal errors (fail-soft assertion with a throwing fake client). - Depends on: none
Task 4: Plugin installation through the adapter (copy + manifest + drift)
- Files:
src/core/install/adapters/opencode.ts,src/core/install/opencode-plugin-asset.ts,tests/core/install/adapters/opencode.test.ts - Acceptance: apply copies the bundled plugin into
~/.config/opencode/plugins/open-second-brain.tswith version-stamped header; manifest records the content hash; verify reports drift when the installed copy is edited; uninstall removes the plugin file; re-apply after upgrade refreshes the copy. - Depends on: Task 2, Task 3
Task 5: opencode session adapter + registry wiring
- Files:
src/core/brain/sessions/opencode.ts,src/core/brain/sessions/types.ts,src/core/brain/sessions/registry.ts,tests/core/brain.sessions.opencode.test.ts,tests/fixtures/sessions/opencode-minimal.jsonl, cross-table cases intests/core/brain.sessions.registry.test.ts - Acceptance:
detectmatches only the spool meta line (originatoropen-second-brain-opencode-plugin), rejects claude/codex/hermes first lines and vice versa (cross-table test extended to 4x4);iterateyields normalized turns incl. tool calls;importSessionon the fixture produces the same counter semantics as other adapters; unknownformat> 1 fails with a versioned error. - Depends on: Task 3 (spool format frozen)
Task 6: Docs and changelog
- Files:
install/opencode.md,install.md,README.md,CHANGELOG.md - Acceptance: install/opencode.md documents the full flow (install, what gets written where, plugin behavior, spool import command, known gaps: no stop guardrail, experimental inject); install.md table row updated; README runtime list updated; CHANGELOG entry under the next version header;
bun run lintand docs checks green. - Depends on: Tasks 1-5