Skip to content

v1.3.0 - Native OpenCode Integration

Choose a tag to compare

@solaitken solaitken released this 10 Jun 09:15
· 12 commits to main since this release
2abc90b

Open Second Brain v1.3.0 - Native OpenCode Integration

One conversation now stays one session: when the host compresses context and rotates the session id, Open Second Brain stitches the segments back into a single lineage, so recall over any segment id returns the whole conversation - and the Brain gains a hygiene pipeline that detects and remediates the entropy it accumulates: contested facts, near-duplicate rules, stale derived pages, never-recalled memories. The release also brings native OpenCode integration: one install command writes the config OpenCode actually reads and drops in a bundled plugin, so the same memory loop - rules into every answer, sessions captured into the vault - now runs in OpenCode too.

How the Open Second Brain plugin works with OpenCode

What ships

  • Native OpenCode integration. o2b install --target opencode --apply merges the two Open Second Brain MCP servers into ~/.config/opencode/opencode.json (the file OpenCode actually reads; the stale mcp.json written by earlier releases is migrated away) and installs a single zero-dependency plugin into ~/.config/opencode/plugins/. The plugin appends your active Brain digest to the system prompt before every answer, nudges the agent to log what it learned after file edits, and snapshots the conversation on session.idle / session.compacted / session.deleted into a spool that o2b brain import-session ingests through the new fourth session adapter. Every hook is fail-soft - a missing vault or binary never breaks the OpenCode session.
  • Sessions survive compaction. A session-lineage kernel resolves every session id to its conversation root. The native path reads the new optional parent_session_id / root_session_id / compression_depth hook-payload fields (ready for upstream Hermes PR #42940); until the deployed host emits them, a conservative interim inference - isolated in one file and marked CRUTCH(t_1459706f) - links a brand-new session to a predecessor only on compression evidence plus the same working directory inside a bounded window. Time proximity alone never stitches two sessions; every ambiguous case stays flat. brain_session_grep and brain_session_describe over any segment return the stitched conversation with its segment chain, transitively across deep chains.
  • Memory hygiene with discipline. o2b brain hygiene scan (and the new brain_hygiene MCP tool) composes pure detectors into a read-only digest: truth-layer value conflicts, semantic near-duplicate preferences (embedding cosine at 0.97 with a clearly labeled lexical fallback), source freshness, and never-recalled low-usefulness candidates. apply executes only explicitly selected finding ids through existing primitives - preference merge, claim append, targeted recompile, archive - with an audit record per run. Review findings never execute, and forget archives rather than deletes.
  • Advisory conflict resolution, deterministic core. When the operator configures hygiene.resolver_cmd in _brain.yaml, contested truth slots receive supersede / merge / flag verdicts with recorded rationale through the shared external-command bridge (extracted from the bench judge; fail-open). Without it - or on any failure - every conflict stays flagged for operator review. The command comes exclusively from operator config, never from tool arguments.
  • Source freshness and targeted recompile. Derived pages record source_paths + source_hashes at derivation (handoff notes stamp their transcript automatically); freshness computes on demand as fresh / stale / orphaned with no background jobs, and unreadable sources are reported separately so a transient I/O failure can never feed the cleanup path. o2b brain refresh --stale [--dry-run] re-derives only pages whose sources changed and archives orphans into Brain/.snapshots/.
  • Anticipatory context cache. Lifecycle hooks keep a small turn-specific bundle - the active context pack plus session-recall hits for the latest prompt - warm under Brain/.state/, keyed by the lineage root, TTL-debounced, atomically written: no daemon, no watcher. The new brain_anticipatory_context tool and o2b brain anticipate verb read it cache-or-live with an explicit cache_state.
  • Staged degradation ladder. With recall.degradation: staged, over-budget recall entries trim at the last sentence terminator (structural punctuation across scripts), then whole leading lines, then the historical hard cut - which stays the byte-identical default.

Process wins

  • Two kernels instead of nine silos: a lineage resolver consumed by capture, recall, and the cache, and one detector contract behind the whole hygiene surface - chosen in a three-variant brainstorm committed under docs/brainstorm/continuity-hygiene-freshness/.
  • The frozen MCP surface grew deliberately from 54 to 56 tools, with the parity, name-list, and count guards updated in the same change that added the tools.
  • Quality record: 4,229 tests / 0 fail (about 90 new), TypeScript clean, lint at 0 errors, version synced across all manifests, an independent three-reviewer self-review before push, and one CodeRabbit pass: 8 findings, 7 applied (one stronger than suggested - transitive lineage-root resolution instead of the proposed root-drop), 1 applied partially with a documented trade-off.

Notes

  • The interim lineage crutch is tracked for removal in one kanban task: once upstream Hermes PR #42940 merges and the deployed host emits parent_session_id, the native payload path already takes precedence and the crutch file deletes wholesale.
  • New _brain.yaml blocks: hygiene (resolver_cmd, dedup_threshold), anticipatory (ttl_seconds, max_tokens), recall (degradation). All optional; defaults keep prior behavior byte-identical.
  • Release image: the OpenCode interaction loop in the canonical terminal style (animated GIF in this body; static PNG and the SVG source attached as assets).