o2b install --target opencode --apply performs a native integration
in one pass:
- MCP servers - merges the two Open Second Brain servers
(
open-second-brain,open-second-brain-writer) into${XDG_CONFIG_HOME:-$HOME/.config}/opencode/opencode.jsonunder themcpkey, using opencode's entry schema ({"type": "local", "command": [...], "environment": {...}, "enabled": true}). User-authored entries are preserved. - Plugin - copies the bundled Open Second Brain plugin into
${XDG_CONFIG_HOME:-$HOME/.config}/opencode/plugins/open-second-brain.ts. opencode auto-loads it at startup. - Legacy cleanup - releases before v1.4.0 wrote
~/.config/opencode/mcp.json, a file opencode never reads. Apply removes the two Open Second Brain keys from it (and deletes the file when nothing else remains).
o2b install --target opencode --applyRestart opencode to load the MCP servers and the plugin.
opencode's Brain writes attribute to an opencode-specific identity derived
from your configured agent_name: the host segment is kept and the vendor
token is swapped to opencode (claude-vps-agent -> opencode-vps-agent; a
name that does not fit the <vendor>-<host>-agent shape is prefixed with
opencode-). So opencode activity is distinguishable per runtime - and, in a
shared multi-device vault, per device - rather than logged under the shared
identity. apply stamps this on VAULT_AGENT_NAME in opencode.json; no
manual step is needed.
-
Active context inject - appends the rendered
Brain/active.mddigest to the system prompt of each chat request (cached, 5 minute TTL), so the agent sees live preferences without callingbrain_queryfirst. Uses the sameo2b-hook active-injectshim as the Claude Code and Codex hook layers; if the shim or the vault is missing the inject silently skips. -
Session capture - on
session.idle/session.compacted/session.deletedthe plugin snapshots the session as a JSONL spool under${XDG_DATA_HOME:-$HOME/.local/share}/open-second-brain/opencode/. Import captured sessions with:o2b brain import-session ~/.local/share/open-second-brain/opencode/ \ --vault /path/to/vault -
Post-write reminder - after file-mutating tools (
write,edit,multiedit,patch,apply_patch) the standard logging nudge is appended to the tool output so the agent considersbrain_feedback/brain_apply_evidence/brain_notebefore its final reply.
Every plugin hook is fail-soft: a missing vault, missing o2b-hook
binary, or SDK error never breaks the opencode session.
o2b install --check --target opencodeReports drift when the MCP entries differ from canonical or the installed plugin copy differs from the bundled version (for example after an Open Second Brain upgrade - re-run apply to refresh it).
o2b uninstall --target opencode --applyRemoves the two mcp keys from opencode.json and deletes the
installed plugin file. User-authored config is untouched.
- No stop-log guardrail. opencode exposes no blocking stop hook, so the guardrail that vetoes an unlogged artifact turn cannot be reproduced; the post-write reminder still fires.
- Context inject rides an experimental hook
(
experimental.chat.system.transform). If a future opencode release changes it, the inject degrades to no-op while capture and the MCP servers keep working.
- Upstream is
anomalyco/opencode(formerly hosted undersst/opencode); config schema verified against https://opencode.ai/docs 2026-06-10. - Rules: opencode reads
AGENTS.mdnatively, so vault-level rules can also travel as project instructions without any Open Second Brain involvement.