open-second-brain 2.0.0-rc.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-second-brain",
3
- "version": "2.0.0-rc.1",
3
+ "version": "2.0.0",
4
4
  "description": "Plugin-first second brain package for AI agents and humans.",
5
5
  "author": {
6
6
  "name": "Open Second Brain contributors"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-second-brain",
3
- "version": "2.0.0-rc.1",
3
+ "version": "2.0.0",
4
4
  "description": "Plugin-first second brain package for Codex, Hermes, Claude Code, OpenClaw, and other agent runtimes.",
5
5
  "author": {
6
6
  "name": "Open Second Brain contributors",
package/README.md CHANGED
@@ -1,147 +1,76 @@
1
1
  # Open Second Brain
2
2
 
3
- ![Open Second Brain - your knowledge, amplified by AI](docs/images/readme-poster.jpg)
4
-
5
- Open Second Brain is a memory layer for AI agents that lives in an [Obsidian](https://obsidian.md) vault. Agents read and write it through MCP servers, lifecycle hooks and the `o2b` CLI. Everything the agent learns is a Markdown file under `Brain/`, so you can open, edit, grep and version it like any other note. A deterministic `dream` pass turns repeated signals into rules and retires the ones nothing uses; no model runs inside that algorithm.
6
-
7
- ## How it fits
8
-
9
- ```mermaid
10
- flowchart LR
11
- subgraph Clients["Agent clients"]
12
- Plug["Plugins: Claude Code, Codex,<br/>Hermes, opencode, Grok Build"]
13
- Mcp["MCP config: Cursor, kiro, Copilot CLI,<br/>Gemini CLI, ZCode, any MCP host"]
14
- Claw["OpenClaw<br/>in-process plugin"]
15
- Cliu["Aider, Pi<br/>CLI and context file"]
16
- end
17
- subgraph Product["Open Second Brain"]
18
- Srv["MCP servers<br/>open-second-brain, open-second-brain-writer"]
19
- Hooks["Lifecycle hooks<br/>o2b-hook"]
20
- Cli["CLI<br/>o2b"]
21
- Core["Core"]
22
- end
23
- subgraph Vault["Your vault"]
24
- Brain["Brain/<br/>Markdown the agent writes"]
25
- Notes["Your notes"]
26
- Index[(".open-second-brain/brain.sqlite<br/>rebuildable search index")]
27
- end
28
- Plug --> Srv
29
- Plug --> Hooks
30
- Mcp --> Srv
31
- Claw --> Core
32
- Cliu --> Cli
33
- Srv --> Core
34
- Hooks --> Core
35
- Cli --> Core
36
- Core --> Brain
37
- Core --> Index
38
- Core -. reads, writes a named note on request .-> Notes
39
- ```
3
+ ![Open Second Brain carries what your agents learn into future sessions](docs/images/readme-hero.svg)
4
+
5
+ Open Second Brain is a program that runs on your machine and connects to the AI coding agents you use: Claude Code, Codex, Cursor and [others](install.md#supported-clients).
6
+ It keeps the corrections, decisions and notes your agents save, turns corrections that repeat into rules, and lets later sessions, in the same agent or a different one, use those rules.
7
+
8
+ ## Why
9
+
10
+ You correct an agent, and the next session makes the same mistake. You switch agents, and the new one knows nothing the old one learned.
11
+ With Open Second Brain connected, an agent can save a correction through its tools, and every connected agent can read the rules that come out of saved corrections. Every record names the agent that wrote it.
12
+ Once a day a background pass, called dream, makes a rule of a correction that keeps coming back. A rule stays while agents record that they applied it; it is retired when that record goes stale, when agents report it outdated, or when you reject it.
13
+
14
+ ## What it looks like
40
15
 
41
- Each client reaches the same core through a plugin, an MCP registration or the CLI. The core keeps its own records under `Brain/` and a generated search index under `.open-second-brain/` that it can rebuild from the files. Your notes are read; the note tools write one only at a path the caller names.
16
+ An example. You tell your agents a few times not to use internal abbreviations, and they save it each time:
42
17
 
43
- ```mermaid
44
- flowchart LR
45
- Agent["Agent"] -->|brain_feedback| Inbox["Brain/inbox/<br/>signal"]
46
- Inbox -->|dream pass| Pref["Brain/preferences/<br/>rule"]
47
- Pref -->|rendered into| Active["Brain/active.md"]
48
- Active -->|read at session start| Agent
49
- Agent -->|brain_apply_evidence| Log["Brain/log/"]
50
- Log -->|next dream pass| Pref
18
+ ```text
19
+ Correction, saved three times: Expand internal abbreviations in user-facing copy.
20
+ After dream and recorded use: Confirmed rule: Expand internal abbreviations in user-facing copy.
51
21
  ```
52
22
 
53
- The learning loop: signals become rules, rules reach the next session through `Brain/active.md`, and applied or violated evidence confirms, quarantines or retires them. Details: [`docs/how-it-works.md`](docs/how-it-works.md#a-preferences-lifecycle).
23
+ On hosts with a session-start hook, such as Claude Code and Codex, each new session receives the confirmed rules; on other hosts the agent asks for them through a tool.
24
+ If you name a folder for it (`view_target`), the rules are also written there as plain Markdown pages: `about-me.md` with the confirmed rules, a page per week of history, decisions and topics.
25
+ Rewrite a rule on `about-me.md` and your wording becomes the rule; delete its line and the rule is retired. Your edit is stored the next time the pages are rendered, and it wins over anything an agent or a model recorded.
54
26
 
55
27
  ## Install
56
28
 
57
- 1. Install [Bun](https://bun.sh/) 1.1 or later: [`install/prerequisites.md`](install/prerequisites.md).
58
- 2. Install the plugin for your client (guides below), or get the `o2b` CLI: [`install/prerequisites.md`](install/prerequisites.md#get-the-o2b-cli).
59
- 3. Create the vault files:
60
-
61
- ```bash
62
- o2b init --vault /path/to/vault --name "My Second Brain"
63
- o2b brain init --vault /path/to/vault
64
- ```
65
-
66
- 4. Connect the client (table below), then check the result:
67
-
68
- ```bash
69
- o2b doctor --vault /path/to/vault
70
- o2b install --check
71
- ```
72
-
73
- The full router with readiness criteria is [`install.md`](install.md); native Windows is covered in [`install/windows.md`](install/windows.md).
74
-
75
- ## Supported clients
76
-
77
- | Client | Integration | Guide |
78
- | ------------------ | ------------------------------------------------------------------------ | -------------------------------------------------- |
79
- | Claude Code | Marketplace plugin: MCP servers and hooks | [`install/claudecode.md`](install/claudecode.md) |
80
- | OpenAI Codex | Marketplace plugin, then `o2b install --target codex --apply` | [`install/codex.md`](install/codex.md) |
81
- | ChatGPT desktop | Reads the shared Codex config: `o2b install --target codex --apply` | [`install/codex.md`](install/codex.md) |
82
- | Hermes Agent | Plugin and memory provider | [`install/hermes.md`](install/hermes.md) |
83
- | OpenClaw | Native plugin, no MCP | [`install/openclaw.md`](install/openclaw.md) |
84
- | opencode | `o2b install --target opencode --apply`: MCP servers and a native plugin | [`install/opencode.md`](install/opencode.md) |
85
- | Grok Build | `o2b install --target grok --apply`: MCP servers and hooks | [`install/grok.md`](install/grok.md) |
86
- | Cursor | `o2b install --target cursor --apply` | [`install/cursor.md`](install/cursor.md) |
87
- | kiro | `o2b install --target kiro --apply` | [`install/kiro.md`](install/kiro.md) |
88
- | GitHub Copilot CLI | `o2b install --target copilot-cli --apply` | [`install/copilot-cli.md`](install/copilot-cli.md) |
89
- | Gemini CLI | `o2b install --target gemini-cli --apply` | [`install/gemini-cli.md`](install/gemini-cli.md) |
90
- | ZCode | MCP servers added to its config by hand | [`install/zcode.md`](install/zcode.md) |
91
- | Aider | `o2b install --target aider --apply`: context file, no MCP | [`install/aider.md`](install/aider.md) |
92
- | Pi | `o2b install --target pi --apply`: skill over the CLI | [`install/pi.md`](install/pi.md) |
93
- | Any other MCP host | `o2b install --target generic --apply --out -` prints the server entries | [`install/generic.md`](install/generic.md) |
94
-
95
- `o2b uninstall --target <name> --apply` removes what `o2b install` wrote; the vault is never touched ([`install.md`](install.md#uninstall)).
96
-
97
- ## Capabilities
98
-
99
- - **Preferences that learn and expire.** Signals, a deterministic dream pass, confidence and retirement: [how it works](docs/how-it-works.md#a-preferences-lifecycle).
100
- - **Reversible changes.** Brain mutations take a snapshot first; `o2b brain rollback` restores it: [snapshots](docs/how-it-works.md#snapshots-and-rollback).
101
- - **Attributed writes.** `o2b brain writes` lists every note write by agent and device, `writes revert` plans a restore, `o2b brain freeze` stops all writers, and `o2b brain log verify` checks the hash-chained log: [Brain CLI](docs/cli-reference.md#brain-observing-memory).
102
- - **Search.** Keyword search with an optional semantic lane, result explanations, recall profiles and compact cards; an opt-in iterative loop (`search_iterative_recall_enabled`, default off) keeps querying when coverage gaps survive, pausing with a plan the caller answers through `brain_search`'s round trip; and an opt-in per-source-session cap (`search_pool_max_per_session`, default off) keeps one long imported session from filling the candidate window, so diversity spreads across sessions: [search CLI](docs/cli-reference.md#search), [iterative recall](docs/cli-reference.md#iterative-recall-since-v1820), [pool cap](docs/cli-reference.md#the-per-source-session-pool-cap-since-v1830), [ranking](docs/how-it-works.md#full-text-search).
103
- - **Session recall.** Import agent transcripts already on disk, search them, or select whole-thread coverage under a character budget (`o2b brain session-grep --operation coverage --char-budget <n>`, with `--entity-key` seeding the fan-out from mined entity mentions): [session logs](docs/cli-reference.md#session-logs-this-machine-already-has-since-v1500), [coverage](docs/cli-reference.md#coverage-first-session-recall-since-v1820).
104
- - **Hygiene.** `o2b brain hygiene scan` finds contested, duplicate, stale and unused memories; `apply` runs only the findings you pick: [maintenance](docs/cli-reference.md#maintenance-and-operator-surfaces).
105
- - **Claim ledger.** `o2b brain truth ingest` records an entity claim with an optional validity window (`--valid-from`/`--valid-until`; with the flags absent, a window on the source record's frontmatter is adopted and frozen at ingest), `truth events` recalls a windowed slice of the ledger, and `truth state` grounds an agent-stated claim with an anchoring verdict - committed, or reported back with reason codes. `truth state` accepts an optional opaque `--sample-id` naming the context-pack sample the claim drew on, and claim reads report the receipt and outcome provenance behind it at the caller's reach - "receipt known, outcome unknown", never an invented verdict: [entity truth CLI](docs/cli-reference.md#entity-truth-and-self-improving-dream-since-v0430).
106
- - **Corrections.** `o2b brain lifecycle correct <target>` reports a correction's blast radius and retires the affected records - validity-closed by default, tombstoned with `--flatly-wrong`, dry run by default and `--apply` to write. A retired record that recall can still serve is served only beside its correction, never alone: [belief lifecycle CLI](docs/cli-reference.md#belief-lifecycle-and-decision-memory-since-v1330).
107
- - **Sharing and backup.** Knowledge packs export a chosen subset; `o2b brain bank-export` writes a one-file backup bundle: [knowledge packs](docs/cli-reference.md#knowledge-packs).
108
- - **Secret custody.** Credentials live encrypted in the vault's state dir behind a capability-gated store; `$secret:NAME` references resolve at the use sites, `o2b brain secret unlock` wraps the keyfile under a passphrase, and `secret export`/`import` move the store between installs as one passphrase-encrypted bundle: [custody CLI](docs/cli-reference.md#write-time-integrity-and-governance-since-v0440).
109
- - **Today view and note markers.** `o2b brain today`, `@osb loop` and `@osb set` markers: [Brain CLI](docs/cli-reference.md#brain-observing-memory).
110
- - **Self-inspection.** `o2b version`, `o2b install --friction` and `o2b state status` report what is installed and where state lives: [CLI reference](docs/cli-reference.md#core).
111
- - **MCP surface.** Tools, tool profiles for hosts with tool limits, and the always-loaded writer server: [`docs/mcp.md`](docs/mcp.md).
112
-
113
- ## Optional features
114
-
115
- - **Semantic search:** an embedding provider plus `sqlite-vec`; the `embeddings-setup` skill walks through it: [`skills/embeddings-setup/SKILL.md`](skills/embeddings-setup/SKILL.md).
116
- - **Decision models:** a typed judgment model that can rerank search and filter candidates, off by default per use: [`docs/decision-models.md`](docs/decision-models.md).
117
- - **Deep relational recall:** a fourth search arm over typed links, off by default. Its traversal runs under width budgets - 8 seeds, 4 edges per node, 16 nodes in total, and a hub above 12 walked edges is reached but not expanded - each overridable through an `OPEN_SECOND_BRAIN_SEARCH_TRAVERSAL_*` environment variable or a `search_traversal_*` config key; entity co-occurrence bridges join the walk by default and switch off separately (`OPEN_SECOND_BRAIN_SEARCH_ENTITY_BRIDGES`): [retrieval quality](docs/cli-reference.md#retrieval-quality-and-context-delivery-since-v1370).
118
- - **Staged review for agent writes, off by default.** With no key set every write publishes exactly as before. `write_approval.notes` / `OPEN_SECOND_BRAIN_WRITE_APPROVAL_NOTES_ENABLED` and `write_approval.ingest` / `OPEN_SECOND_BRAIN_WRITE_APPROVAL_INGEST_ENABLED` (each falling back to the `write_approval.enabled` master, default off) stage note creates and ingest summary pages into `Brain/pending/` beside the staged signals, where they stay out of the search index until an operator runs `o2b brain pending list` and applies or rejects them; [write-path integrity](docs/cli-reference.md#write-path-integrity-and-store-safety-since-v1320).
119
- - **A permissions document, absent by default.** `Brain/_permissions.yaml` (an operator-edited vault file) resolves `allow`/`ask`/`deny` per agent, role and target for the write, ingest and owner-write actions; with the file absent every check behaves exactly as today. `ask` stages the write, `deny` refuses with the `write-refused` token and the next command `o2b brain permissions show`, and every ask/deny verdict lands in a queryable decision ledger under `Brain/logs/decisions/`; `o2b brain permissions show` dry-runs the decision table, `ledger` reads the rows; [Brain CLI](docs/cli-reference.md#brain-observing-memory).
120
- - **The owner-write gate, off by default.** `integrity.owner_scope_writes` in `Brain/_brain.yaml` (`off` | `warn` | `fail`, default `off`) refuses a caller-named owner that differs from the caller's resolved identity on the preference and note lanes (`warn` allows and records one decision-ledger row); a document `owner_write` verdict composes most-restrictive-wins with the gate; [write-time integrity](docs/cli-reference.md#write-time-integrity-and-governance-since-v0440).
121
- - **Named MCP tokens, optional.** `o2b mcp token mint|rotate|revoke|list` keeps a hash-at-rest token per agent (`.open-second-brain/secrets/mcp-tokens.json`; material shown exactly once). Over HTTP a valid token authenticates as its agent per request, the shared `--api-key` stays valid as the operator master credential, and `mcp_tokens_required` / `OPEN_SECOND_BRAIN_MCP_TOKENS_REQUIRED` (default `false`) makes a non-empty token map refuse credential-less requests. `o2b bootstrap --target <harness> [--token] [--rotate] [--check]` provisions MCP registration, token and receipt in one idempotent command, and `o2b bootstrap --remove <harness>` tears a provision down again; the minted token authenticates HTTP clients configured by hand, while the registered stdio harness presents no credential and keeps its config-derived identity; [core CLI](docs/cli-reference.md#core).
122
- - **Ambient capture consent, opt-out.** `guardrails.ambient_writeback: false` suppresses the ambient extraction lane with a counted `ambient-withheld` event (absent keeps today's behavior), and `guardrails.ambient_ttl_days` stamps an `expiration_date` on ambient-extracted signals so reads drop them after the window (absent stamps nothing); a TTL-stamped signal still stages when the review gate is on and survives apply verbatim.
123
- - **Open decisions.** `o2b brain decision open --title <t> --question <q> --option <o> [...]` parks a question with enumerated options at `Brain/decisions/open-<slug>.md`; `resolve` mints the real `type: decision` page, `discard` closes without deciding, and the morning brief renders up to five open questions: [belief lifecycle](docs/cli-reference.md#belief-lifecycle-and-decision-memory-since-v1330).
124
-
125
- ## What is new
126
-
127
- Open Second Brain 1.98.0 is the agent-presence and self-improvement release. `o2b install --target <host> --apply` now writes the brain-usage block into the agent-instruction file the installed host reads at the vault root (AGENTS.md for codex, cursor, opencode and aider; GEMINI.md for gemini-cli) under the same consent prompt as the config writes, preserving every byte outside the block and recording its ownership so uninstall removes exactly the pair the tool wrote; the dream pass gains an operator-approved exit into those same files, where a lesson promotes into a managed lessons block only with a fresh approval pinned to the approved text, and the doctor grades every block state it can name. The skill lane gains a benchmark-gated rewrite loop: a skill is rewritten only after a candidate beats the incumbent on scored dev tasks with full coverage and survives the one held-out check - Open Second Brain never calls a model, the scorer reads structural predicates and nothing the agent claims about its own work, and the accept stays an operator step on the command line. And ChatGPT desktop is named where its operators look for it: it reads the shared Codex config, so one codex registration serves both. Every release is described in the [CHANGELOG](CHANGELOG.md).
29
+ ### The easy way: let your agent do it
30
+
31
+ Paste this into the agent you want to connect:
32
+
33
+ ```text
34
+ Set up Open Second Brain for this agent. Follow the "Agent setup" procedure in
35
+ https://raw.githubusercontent.com/itechmeat/open-second-brain/main/llms.txt
36
+ If Bun or the open-second-brain package is missing, tell me the command and
37
+ install it after I agree. Ask me only the questions the procedure lists. Run
38
+ o2b setup without --apply, show me the plan, then stop and wait for my explicit
39
+ approval. Apply only the plan I approved, run the verification commands the
40
+ procedure names, report every step that did not pass, and tell me how to undo it.
41
+ ```
42
+
43
+ ### By hand
44
+
45
+ With [Bun](https://bun.sh/) 1.1 or later, install the package, then print the setup plan for your host (`--no-vault` instead of `--vault` if you do not use Obsidian):
46
+
47
+ ```bash
48
+ bun add -g open-second-brain
49
+ o2b setup --target <host> --vault /path/to/vault --agent-name "<agent-name>" --timezone UTC
50
+ ```
51
+
52
+ The second command writes nothing; add `--apply` to carry out the plan it printed. Every host, the remaining steps, verification and uninstall: [`install.md`](install.md).
53
+
54
+ ## What you control
55
+
56
+ 1. **What runs on your machine.** The `o2b` command line, two MCP servers your agent host starts, lifecycle hooks on hosts that have them, and once a day a detached dream worker on the one machine that owns dream ([install](install.md), [dream](docs/dream.md#how-dream-starts)). Dream starts by itself from an agent session, through a session-start hook or the MCP server; Pi, Aider and OpenClaw have neither, so on a machine with only those, run `o2b dream run`. Automatic dream is on by default; `o2b brain settings set dream.auto false` turns it off.
57
+ 2. **What leaves your machine.** Dream's summaries and topic wording are written by the agent command you configure; items built from private records are included by default, and an agent that uses a hosted model sends them to its provider ([dream](docs/dream.md#what-a-session-can-and-cannot-do)). Remote embeddings and a decision model are optional and off until you configure them; [every outbound path](docs/cli-reference.md#what-leaves-the-machine-unscanned-network-egress) is listed with what it sends.
58
+ 3. **What it costs.** The software is MIT licensed. Dream's sessions use your agent's subscription or provider allowance; an optional decision model stops sending once a daily spending limit is reached, 0.50 USD unless you change it ([decision models](docs/decision-models.md)).
59
+ 4. **Your notes.** Records live in a brain store outside your vault. A 1.x brain kept in the vault's `Brain/` folder is moved into the store on upgrade ([updating](docs/updating.md#2-the-store-migration)), and an `@osb` marker you write in a note is annotated once it is captured ([how it works](docs/how-it-works.md#capture-surfaces)).
60
+ 5. **Undo.** `o2b uninstall --target <host> --apply` removes what setup wrote for a host, and `bun remove -g open-second-brain` removes the package; your vault, notes and brain store are kept ([uninstall](install.md#uninstall)).
61
+ 6. **Removed is not erased.** The store is append-only: retiring or correcting a rule adds a record, and the old one stays until a compaction rewrites it. Do not put a secret into the brain ([brain store](docs/brain-store.md#what-the-partitions-protect-and-what-they-do-not)).
62
+
63
+ ## Works with Agentic Playbooks
64
+
65
+ [![Open Second Brain and Agentic Playbooks](docs/brand/banner-open-second-brain-apb.svg)](https://github.com/itechmeat/agentic-playbooks)
66
+
67
+ apb runs the agents; Open Second Brain gives those agents memory, so what the agents of one run recorded is there for the agents of the next. Each works without the other.
68
+ [Agentic Playbooks (apb)](https://github.com/itechmeat/agentic-playbooks) is a separate project.
128
69
 
129
70
  ## Documentation
130
71
 
131
- | Topic | Page |
132
- | --------------------------------------------------------- | ---------------------------------------------------------------- |
133
- | Mental model, vault layout, dream pass, safety properties | [`docs/how-it-works.md`](docs/how-it-works.md) |
134
- | Every CLI verb and flag | [`docs/cli-reference.md`](docs/cli-reference.md) |
135
- | MCP protocol, tools, writer split | [`docs/mcp.md`](docs/mcp.md) |
136
- | Brain store: setup, sync, migration, the human view | [`docs/brain-store.md`](docs/brain-store.md) |
137
- | Architecture and configuration model | [`docs/architecture.md`](docs/architecture.md) |
138
- | Updating (`o2b update`) and upgrade notes | [`docs/updating.md`](docs/updating.md) |
139
- | Observability events | [`docs/observability.md`](docs/observability.md) |
140
- | Metrics data contract | [`docs/metrics.md`](docs/metrics.md) |
141
- | Cross-project pointer | [`docs/cross-project-pointer.md`](docs/cross-project-pointer.md) |
142
- | Scheduled Brain digest (Hermes cron) | [`docs/hermes-cron.md`](docs/hermes-cron.md) |
143
- | Stability policy | [`docs/stability.md`](docs/stability.md) |
144
- | Origin of the idea | [`docs/idea.md`](docs/idea.md) |
72
+ [The documentation index](docs/README.md) groups the documents by what you want to do: get started, connect an agent, understand how it works, operate, upgrade, contribute.
73
+ Upgrading from 1.x: [`docs/updating.md`](docs/updating.md).
145
74
 
146
75
  ## Project
147
76
 
@@ -2,7 +2,7 @@
2
2
  "id": "open-second-brain",
3
3
  "name": "Open Second Brain",
4
4
  "description": "Second brain for AI agents using Obsidian-compatible Markdown vaults.",
5
- "version": "2.0.0-rc.1",
5
+ "version": "2.0.0",
6
6
  "activation": { "onStartup": true },
7
7
  "skills": ["./skills"],
8
8
  "contracts": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-second-brain",
3
- "version": "2.0.0-rc.1",
3
+ "version": "2.0.0",
4
4
  "private": false,
5
5
  "description": "Second brain for AI agents using Obsidian-compatible Markdown vaults. Works with Hermes, Claude Code, Codex, and OpenClaw.",
6
6
  "keywords": [
@@ -23,7 +23,6 @@
23
23
  },
24
24
  "files": [
25
25
  "bin/*.js",
26
- "bin/o2b-discipline-report",
27
26
  "src/",
28
27
  "hooks/",
29
28
  "schemas/",
@@ -51,7 +50,6 @@
51
50
  "scripts/o2b-aider.cmd",
52
51
  "scripts/_bun-precheck.sh",
53
52
  "scripts/_macos-sqlite.sh",
54
- "scripts/discipline-report.ts",
55
53
  "README.md",
56
54
  "LICENSE",
57
55
  "pyproject.toml",
package/plugin.yaml CHANGED
@@ -1,5 +1,5 @@
1
1
  name: open-second-brain
2
- version: "2.0.0-rc.1"
2
+ version: "2.0.0"
3
3
  description: "Open Second Brain - native Hermes memory provider backed by an Obsidian-compatible Markdown vault."
4
4
  author: "Open Second Brain contributors"
5
5
  memory_provider: true
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-second-brain",
3
- "version": "2.0.0-rc.1",
3
+ "version": "2.0.0",
4
4
  "description": "Plugin-first second brain package for Codex, Hermes, Claude Code, OpenClaw, and other agent runtimes.",
5
5
  "author": {
6
6
  "name": "Open Second Brain contributors",
@@ -1,147 +1,76 @@
1
1
  # Open Second Brain
2
2
 
3
- ![Open Second Brain - your knowledge, amplified by AI](https://github.com/itechmeat/open-second-brain/raw/main/docs/images/readme-poster.jpg)
4
-
5
- Open Second Brain is a memory layer for AI agents that lives in an [Obsidian](https://obsidian.md) vault. Agents read and write it through MCP servers, lifecycle hooks and the `o2b` CLI. Everything the agent learns is a Markdown file under `Brain/`, so you can open, edit, grep and version it like any other note. A deterministic `dream` pass turns repeated signals into rules and retires the ones nothing uses; no model runs inside that algorithm.
6
-
7
- ## How it fits
8
-
9
- ```mermaid
10
- flowchart LR
11
- subgraph Clients["Agent clients"]
12
- Plug["Plugins: Claude Code, Codex,<br/>Hermes, opencode, Grok Build"]
13
- Mcp["MCP config: Cursor, kiro, Copilot CLI,<br/>Gemini CLI, ZCode, any MCP host"]
14
- Claw["OpenClaw<br/>in-process plugin"]
15
- Cliu["Aider, Pi<br/>CLI and context file"]
16
- end
17
- subgraph Product["Open Second Brain"]
18
- Srv["MCP servers<br/>open-second-brain, open-second-brain-writer"]
19
- Hooks["Lifecycle hooks<br/>o2b-hook"]
20
- Cli["CLI<br/>o2b"]
21
- Core["Core"]
22
- end
23
- subgraph Vault["Your vault"]
24
- Brain["Brain/<br/>Markdown the agent writes"]
25
- Notes["Your notes"]
26
- Index[(".open-second-brain/brain.sqlite<br/>rebuildable search index")]
27
- end
28
- Plug --> Srv
29
- Plug --> Hooks
30
- Mcp --> Srv
31
- Claw --> Core
32
- Cliu --> Cli
33
- Srv --> Core
34
- Hooks --> Core
35
- Cli --> Core
36
- Core --> Brain
37
- Core --> Index
38
- Core -. reads, writes a named note on request .-> Notes
39
- ```
3
+ ![Open Second Brain carries what your agents learn into future sessions](https://github.com/itechmeat/open-second-brain/raw/main/docs/images/readme-hero.svg)
4
+
5
+ Open Second Brain is a program that runs on your machine and connects to the AI coding agents you use: Claude Code, Codex, Cursor and [others](https://github.com/itechmeat/open-second-brain/blob/main/install.md#supported-clients).
6
+ It keeps the corrections, decisions and notes your agents save, turns corrections that repeat into rules, and lets later sessions, in the same agent or a different one, use those rules.
7
+
8
+ ## Why
9
+
10
+ You correct an agent, and the next session makes the same mistake. You switch agents, and the new one knows nothing the old one learned.
11
+ With Open Second Brain connected, an agent can save a correction through its tools, and every connected agent can read the rules that come out of saved corrections. Every record names the agent that wrote it.
12
+ Once a day a background pass, called dream, makes a rule of a correction that keeps coming back. A rule stays while agents record that they applied it; it is retired when that record goes stale, when agents report it outdated, or when you reject it.
13
+
14
+ ## What it looks like
40
15
 
41
- Each client reaches the same core through a plugin, an MCP registration or the CLI. The core keeps its own records under `Brain/` and a generated search index under `.open-second-brain/` that it can rebuild from the files. Your notes are read; the note tools write one only at a path the caller names.
16
+ An example. You tell your agents a few times not to use internal abbreviations, and they save it each time:
42
17
 
43
- ```mermaid
44
- flowchart LR
45
- Agent["Agent"] -->|brain_feedback| Inbox["Brain/inbox/<br/>signal"]
46
- Inbox -->|dream pass| Pref["Brain/preferences/<br/>rule"]
47
- Pref -->|rendered into| Active["Brain/active.md"]
48
- Active -->|read at session start| Agent
49
- Agent -->|brain_apply_evidence| Log["Brain/log/"]
50
- Log -->|next dream pass| Pref
18
+ ```text
19
+ Correction, saved three times: Expand internal abbreviations in user-facing copy.
20
+ After dream and recorded use: Confirmed rule: Expand internal abbreviations in user-facing copy.
51
21
  ```
52
22
 
53
- The learning loop: signals become rules, rules reach the next session through `Brain/active.md`, and applied or violated evidence confirms, quarantines or retires them. Details: [`docs/how-it-works.md`](https://github.com/itechmeat/open-second-brain/blob/main/docs/how-it-works.md#a-preferences-lifecycle).
23
+ On hosts with a session-start hook, such as Claude Code and Codex, each new session receives the confirmed rules; on other hosts the agent asks for them through a tool.
24
+ If you name a folder for it (`view_target`), the rules are also written there as plain Markdown pages: `about-me.md` with the confirmed rules, a page per week of history, decisions and topics.
25
+ Rewrite a rule on `about-me.md` and your wording becomes the rule; delete its line and the rule is retired. Your edit is stored the next time the pages are rendered, and it wins over anything an agent or a model recorded.
54
26
 
55
27
  ## Install
56
28
 
57
- 1. Install [Bun](https://bun.sh/) 1.1 or later: [`install/prerequisites.md`](https://github.com/itechmeat/open-second-brain/blob/main/install/prerequisites.md).
58
- 2. Install the plugin for your client (guides below), or get the `o2b` CLI: [`install/prerequisites.md`](https://github.com/itechmeat/open-second-brain/blob/main/install/prerequisites.md#get-the-o2b-cli).
59
- 3. Create the vault files:
60
-
61
- ```bash
62
- o2b init --vault /path/to/vault --name "My Second Brain"
63
- o2b brain init --vault /path/to/vault
64
- ```
65
-
66
- 4. Connect the client (table below), then check the result:
67
-
68
- ```bash
69
- o2b doctor --vault /path/to/vault
70
- o2b install --check
71
- ```
72
-
73
- The full router with readiness criteria is [`install.md`](https://github.com/itechmeat/open-second-brain/blob/main/install.md); native Windows is covered in [`install/windows.md`](https://github.com/itechmeat/open-second-brain/blob/main/install/windows.md).
74
-
75
- ## Supported clients
76
-
77
- | Client | Integration | Guide |
78
- | ------------------ | ------------------------------------------------------------------------ | -------------------------------------------------- |
79
- | Claude Code | Marketplace plugin: MCP servers and hooks | [`install/claudecode.md`](https://github.com/itechmeat/open-second-brain/blob/main/install/claudecode.md) |
80
- | OpenAI Codex | Marketplace plugin, then `o2b install --target codex --apply` | [`install/codex.md`](https://github.com/itechmeat/open-second-brain/blob/main/install/codex.md) |
81
- | ChatGPT desktop | Reads the shared Codex config: `o2b install --target codex --apply` | [`install/codex.md`](https://github.com/itechmeat/open-second-brain/blob/main/install/codex.md) |
82
- | Hermes Agent | Plugin and memory provider | [`install/hermes.md`](https://github.com/itechmeat/open-second-brain/blob/main/install/hermes.md) |
83
- | OpenClaw | Native plugin, no MCP | [`install/openclaw.md`](https://github.com/itechmeat/open-second-brain/blob/main/install/openclaw.md) |
84
- | opencode | `o2b install --target opencode --apply`: MCP servers and a native plugin | [`install/opencode.md`](https://github.com/itechmeat/open-second-brain/blob/main/install/opencode.md) |
85
- | Grok Build | `o2b install --target grok --apply`: MCP servers and hooks | [`install/grok.md`](https://github.com/itechmeat/open-second-brain/blob/main/install/grok.md) |
86
- | Cursor | `o2b install --target cursor --apply` | [`install/cursor.md`](https://github.com/itechmeat/open-second-brain/blob/main/install/cursor.md) |
87
- | kiro | `o2b install --target kiro --apply` | [`install/kiro.md`](https://github.com/itechmeat/open-second-brain/blob/main/install/kiro.md) |
88
- | GitHub Copilot CLI | `o2b install --target copilot-cli --apply` | [`install/copilot-cli.md`](https://github.com/itechmeat/open-second-brain/blob/main/install/copilot-cli.md) |
89
- | Gemini CLI | `o2b install --target gemini-cli --apply` | [`install/gemini-cli.md`](https://github.com/itechmeat/open-second-brain/blob/main/install/gemini-cli.md) |
90
- | ZCode | MCP servers added to its config by hand | [`install/zcode.md`](https://github.com/itechmeat/open-second-brain/blob/main/install/zcode.md) |
91
- | Aider | `o2b install --target aider --apply`: context file, no MCP | [`install/aider.md`](https://github.com/itechmeat/open-second-brain/blob/main/install/aider.md) |
92
- | Pi | `o2b install --target pi --apply`: skill over the CLI | [`install/pi.md`](https://github.com/itechmeat/open-second-brain/blob/main/install/pi.md) |
93
- | Any other MCP host | `o2b install --target generic --apply --out -` prints the server entries | [`install/generic.md`](https://github.com/itechmeat/open-second-brain/blob/main/install/generic.md) |
94
-
95
- `o2b uninstall --target <name> --apply` removes what `o2b install` wrote; the vault is never touched ([`install.md`](https://github.com/itechmeat/open-second-brain/blob/main/install.md#uninstall)).
96
-
97
- ## Capabilities
98
-
99
- - **Preferences that learn and expire.** Signals, a deterministic dream pass, confidence and retirement: [how it works](https://github.com/itechmeat/open-second-brain/blob/main/docs/how-it-works.md#a-preferences-lifecycle).
100
- - **Reversible changes.** Brain mutations take a snapshot first; `o2b brain rollback` restores it: [snapshots](https://github.com/itechmeat/open-second-brain/blob/main/docs/how-it-works.md#snapshots-and-rollback).
101
- - **Attributed writes.** `o2b brain writes` lists every note write by agent and device, `writes revert` plans a restore, `o2b brain freeze` stops all writers, and `o2b brain log verify` checks the hash-chained log: [Brain CLI](https://github.com/itechmeat/open-second-brain/blob/main/docs/cli-reference.md#brain-observing-memory).
102
- - **Search.** Keyword search with an optional semantic lane, result explanations, recall profiles and compact cards; an opt-in iterative loop (`search_iterative_recall_enabled`, default off) keeps querying when coverage gaps survive, pausing with a plan the caller answers through `brain_search`'s round trip; and an opt-in per-source-session cap (`search_pool_max_per_session`, default off) keeps one long imported session from filling the candidate window, so diversity spreads across sessions: [search CLI](https://github.com/itechmeat/open-second-brain/blob/main/docs/cli-reference.md#search), [iterative recall](https://github.com/itechmeat/open-second-brain/blob/main/docs/cli-reference.md#iterative-recall-since-v1820), [pool cap](https://github.com/itechmeat/open-second-brain/blob/main/docs/cli-reference.md#the-per-source-session-pool-cap-since-v1830), [ranking](https://github.com/itechmeat/open-second-brain/blob/main/docs/how-it-works.md#full-text-search).
103
- - **Session recall.** Import agent transcripts already on disk, search them, or select whole-thread coverage under a character budget (`o2b brain session-grep --operation coverage --char-budget <n>`, with `--entity-key` seeding the fan-out from mined entity mentions): [session logs](https://github.com/itechmeat/open-second-brain/blob/main/docs/cli-reference.md#session-logs-this-machine-already-has-since-v1500), [coverage](https://github.com/itechmeat/open-second-brain/blob/main/docs/cli-reference.md#coverage-first-session-recall-since-v1820).
104
- - **Hygiene.** `o2b brain hygiene scan` finds contested, duplicate, stale and unused memories; `apply` runs only the findings you pick: [maintenance](https://github.com/itechmeat/open-second-brain/blob/main/docs/cli-reference.md#maintenance-and-operator-surfaces).
105
- - **Claim ledger.** `o2b brain truth ingest` records an entity claim with an optional validity window (`--valid-from`/`--valid-until`; with the flags absent, a window on the source record's frontmatter is adopted and frozen at ingest), `truth events` recalls a windowed slice of the ledger, and `truth state` grounds an agent-stated claim with an anchoring verdict - committed, or reported back with reason codes. `truth state` accepts an optional opaque `--sample-id` naming the context-pack sample the claim drew on, and claim reads report the receipt and outcome provenance behind it at the caller's reach - "receipt known, outcome unknown", never an invented verdict: [entity truth CLI](https://github.com/itechmeat/open-second-brain/blob/main/docs/cli-reference.md#entity-truth-and-self-improving-dream-since-v0430).
106
- - **Corrections.** `o2b brain lifecycle correct <target>` reports a correction's blast radius and retires the affected records - validity-closed by default, tombstoned with `--flatly-wrong`, dry run by default and `--apply` to write. A retired record that recall can still serve is served only beside its correction, never alone: [belief lifecycle CLI](https://github.com/itechmeat/open-second-brain/blob/main/docs/cli-reference.md#belief-lifecycle-and-decision-memory-since-v1330).
107
- - **Sharing and backup.** Knowledge packs export a chosen subset; `o2b brain bank-export` writes a one-file backup bundle: [knowledge packs](https://github.com/itechmeat/open-second-brain/blob/main/docs/cli-reference.md#knowledge-packs).
108
- - **Secret custody.** Credentials live encrypted in the vault's state dir behind a capability-gated store; `$secret:NAME` references resolve at the use sites, `o2b brain secret unlock` wraps the keyfile under a passphrase, and `secret export`/`import` move the store between installs as one passphrase-encrypted bundle: [custody CLI](https://github.com/itechmeat/open-second-brain/blob/main/docs/cli-reference.md#write-time-integrity-and-governance-since-v0440).
109
- - **Today view and note markers.** `o2b brain today`, `@osb loop` and `@osb set` markers: [Brain CLI](https://github.com/itechmeat/open-second-brain/blob/main/docs/cli-reference.md#brain-observing-memory).
110
- - **Self-inspection.** `o2b version`, `o2b install --friction` and `o2b state status` report what is installed and where state lives: [CLI reference](https://github.com/itechmeat/open-second-brain/blob/main/docs/cli-reference.md#core).
111
- - **MCP surface.** Tools, tool profiles for hosts with tool limits, and the always-loaded writer server: [`docs/mcp.md`](https://github.com/itechmeat/open-second-brain/blob/main/docs/mcp.md).
112
-
113
- ## Optional features
114
-
115
- - **Semantic search:** an embedding provider plus `sqlite-vec`; the `embeddings-setup` skill walks through it: [`skills/embeddings-setup/SKILL.md`](https://github.com/itechmeat/open-second-brain/blob/main/skills/embeddings-setup/SKILL.md).
116
- - **Decision models:** a typed judgment model that can rerank search and filter candidates, off by default per use: [`docs/decision-models.md`](https://github.com/itechmeat/open-second-brain/blob/main/docs/decision-models.md).
117
- - **Deep relational recall:** a fourth search arm over typed links, off by default. Its traversal runs under width budgets - 8 seeds, 4 edges per node, 16 nodes in total, and a hub above 12 walked edges is reached but not expanded - each overridable through an `OPEN_SECOND_BRAIN_SEARCH_TRAVERSAL_*` environment variable or a `search_traversal_*` config key; entity co-occurrence bridges join the walk by default and switch off separately (`OPEN_SECOND_BRAIN_SEARCH_ENTITY_BRIDGES`): [retrieval quality](https://github.com/itechmeat/open-second-brain/blob/main/docs/cli-reference.md#retrieval-quality-and-context-delivery-since-v1370).
118
- - **Staged review for agent writes, off by default.** With no key set every write publishes exactly as before. `write_approval.notes` / `OPEN_SECOND_BRAIN_WRITE_APPROVAL_NOTES_ENABLED` and `write_approval.ingest` / `OPEN_SECOND_BRAIN_WRITE_APPROVAL_INGEST_ENABLED` (each falling back to the `write_approval.enabled` master, default off) stage note creates and ingest summary pages into `Brain/pending/` beside the staged signals, where they stay out of the search index until an operator runs `o2b brain pending list` and applies or rejects them; [write-path integrity](https://github.com/itechmeat/open-second-brain/blob/main/docs/cli-reference.md#write-path-integrity-and-store-safety-since-v1320).
119
- - **A permissions document, absent by default.** `Brain/_permissions.yaml` (an operator-edited vault file) resolves `allow`/`ask`/`deny` per agent, role and target for the write, ingest and owner-write actions; with the file absent every check behaves exactly as today. `ask` stages the write, `deny` refuses with the `write-refused` token and the next command `o2b brain permissions show`, and every ask/deny verdict lands in a queryable decision ledger under `Brain/logs/decisions/`; `o2b brain permissions show` dry-runs the decision table, `ledger` reads the rows; [Brain CLI](https://github.com/itechmeat/open-second-brain/blob/main/docs/cli-reference.md#brain-observing-memory).
120
- - **The owner-write gate, off by default.** `integrity.owner_scope_writes` in `Brain/_brain.yaml` (`off` | `warn` | `fail`, default `off`) refuses a caller-named owner that differs from the caller's resolved identity on the preference and note lanes (`warn` allows and records one decision-ledger row); a document `owner_write` verdict composes most-restrictive-wins with the gate; [write-time integrity](https://github.com/itechmeat/open-second-brain/blob/main/docs/cli-reference.md#write-time-integrity-and-governance-since-v0440).
121
- - **Named MCP tokens, optional.** `o2b mcp token mint|rotate|revoke|list` keeps a hash-at-rest token per agent (`.open-second-brain/secrets/mcp-tokens.json`; material shown exactly once). Over HTTP a valid token authenticates as its agent per request, the shared `--api-key` stays valid as the operator master credential, and `mcp_tokens_required` / `OPEN_SECOND_BRAIN_MCP_TOKENS_REQUIRED` (default `false`) makes a non-empty token map refuse credential-less requests. `o2b bootstrap --target <harness> [--token] [--rotate] [--check]` provisions MCP registration, token and receipt in one idempotent command, and `o2b bootstrap --remove <harness>` tears a provision down again; the minted token authenticates HTTP clients configured by hand, while the registered stdio harness presents no credential and keeps its config-derived identity; [core CLI](https://github.com/itechmeat/open-second-brain/blob/main/docs/cli-reference.md#core).
122
- - **Ambient capture consent, opt-out.** `guardrails.ambient_writeback: false` suppresses the ambient extraction lane with a counted `ambient-withheld` event (absent keeps today's behavior), and `guardrails.ambient_ttl_days` stamps an `expiration_date` on ambient-extracted signals so reads drop them after the window (absent stamps nothing); a TTL-stamped signal still stages when the review gate is on and survives apply verbatim.
123
- - **Open decisions.** `o2b brain decision open --title <t> --question <q> --option <o> [...]` parks a question with enumerated options at `Brain/decisions/open-<slug>.md`; `resolve` mints the real `type: decision` page, `discard` closes without deciding, and the morning brief renders up to five open questions: [belief lifecycle](https://github.com/itechmeat/open-second-brain/blob/main/docs/cli-reference.md#belief-lifecycle-and-decision-memory-since-v1330).
124
-
125
- ## What is new
126
-
127
- Open Second Brain 1.98.0 is the agent-presence and self-improvement release. `o2b install --target <host> --apply` now writes the brain-usage block into the agent-instruction file the installed host reads at the vault root (AGENTS.md for codex, cursor, opencode and aider; GEMINI.md for gemini-cli) under the same consent prompt as the config writes, preserving every byte outside the block and recording its ownership so uninstall removes exactly the pair the tool wrote; the dream pass gains an operator-approved exit into those same files, where a lesson promotes into a managed lessons block only with a fresh approval pinned to the approved text, and the doctor grades every block state it can name. The skill lane gains a benchmark-gated rewrite loop: a skill is rewritten only after a candidate beats the incumbent on scored dev tasks with full coverage and survives the one held-out check - Open Second Brain never calls a model, the scorer reads structural predicates and nothing the agent claims about its own work, and the accept stays an operator step on the command line. And ChatGPT desktop is named where its operators look for it: it reads the shared Codex config, so one codex registration serves both. Every release is described in the [CHANGELOG](https://github.com/itechmeat/open-second-brain/blob/main/CHANGELOG.md).
29
+ ### The easy way: let your agent do it
30
+
31
+ Paste this into the agent you want to connect:
32
+
33
+ ```text
34
+ Set up Open Second Brain for this agent. Follow the "Agent setup" procedure in
35
+ https://raw.githubusercontent.com/itechmeat/open-second-brain/main/llms.txt
36
+ If Bun or the open-second-brain package is missing, tell me the command and
37
+ install it after I agree. Ask me only the questions the procedure lists. Run
38
+ o2b setup without --apply, show me the plan, then stop and wait for my explicit
39
+ approval. Apply only the plan I approved, run the verification commands the
40
+ procedure names, report every step that did not pass, and tell me how to undo it.
41
+ ```
42
+
43
+ ### By hand
44
+
45
+ With [Bun](https://bun.sh/) 1.1 or later, install the package, then print the setup plan for your host (`--no-vault` instead of `--vault` if you do not use Obsidian):
46
+
47
+ ```bash
48
+ bun add -g open-second-brain
49
+ o2b setup --target <host> --vault /path/to/vault --agent-name "<agent-name>" --timezone UTC
50
+ ```
51
+
52
+ The second command writes nothing; add `--apply` to carry out the plan it printed. Every host, the remaining steps, verification and uninstall: [`install.md`](https://github.com/itechmeat/open-second-brain/blob/main/install.md).
53
+
54
+ ## What you control
55
+
56
+ 1. **What runs on your machine.** The `o2b` command line, two MCP servers your agent host starts, lifecycle hooks on hosts that have them, and once a day a detached dream worker on the one machine that owns dream ([install](https://github.com/itechmeat/open-second-brain/blob/main/install.md), [dream](https://github.com/itechmeat/open-second-brain/blob/main/docs/dream.md#how-dream-starts)). Dream starts by itself from an agent session, through a session-start hook or the MCP server; Pi, Aider and OpenClaw have neither, so on a machine with only those, run `o2b dream run`. Automatic dream is on by default; `o2b brain settings set dream.auto false` turns it off.
57
+ 2. **What leaves your machine.** Dream's summaries and topic wording are written by the agent command you configure; items built from private records are included by default, and an agent that uses a hosted model sends them to its provider ([dream](https://github.com/itechmeat/open-second-brain/blob/main/docs/dream.md#what-a-session-can-and-cannot-do)). Remote embeddings and a decision model are optional and off until you configure them; [every outbound path](https://github.com/itechmeat/open-second-brain/blob/main/docs/cli-reference.md#what-leaves-the-machine-unscanned-network-egress) is listed with what it sends.
58
+ 3. **What it costs.** The software is MIT licensed. Dream's sessions use your agent's subscription or provider allowance; an optional decision model stops sending once a daily spending limit is reached, 0.50 USD unless you change it ([decision models](https://github.com/itechmeat/open-second-brain/blob/main/docs/decision-models.md)).
59
+ 4. **Your notes.** Records live in a brain store outside your vault. A 1.x brain kept in the vault's `Brain/` folder is moved into the store on upgrade ([updating](https://github.com/itechmeat/open-second-brain/blob/main/docs/updating.md#2-the-store-migration)), and an `@osb` marker you write in a note is annotated once it is captured ([how it works](https://github.com/itechmeat/open-second-brain/blob/main/docs/how-it-works.md#capture-surfaces)).
60
+ 5. **Undo.** `o2b uninstall --target <host> --apply` removes what setup wrote for a host, and `bun remove -g open-second-brain` removes the package; your vault, notes and brain store are kept ([uninstall](https://github.com/itechmeat/open-second-brain/blob/main/install.md#uninstall)).
61
+ 6. **Removed is not erased.** The store is append-only: retiring or correcting a rule adds a record, and the old one stays until a compaction rewrites it. Do not put a secret into the brain ([brain store](https://github.com/itechmeat/open-second-brain/blob/main/docs/brain-store.md#what-the-partitions-protect-and-what-they-do-not)).
62
+
63
+ ## Works with Agentic Playbooks
64
+
65
+ [![Open Second Brain and Agentic Playbooks](https://github.com/itechmeat/open-second-brain/blob/main/docs/brand/banner-open-second-brain-apb.svg)](https://github.com/itechmeat/agentic-playbooks)
66
+
67
+ apb runs the agents; Open Second Brain gives those agents memory, so what the agents of one run recorded is there for the agents of the next. Each works without the other.
68
+ [Agentic Playbooks (apb)](https://github.com/itechmeat/agentic-playbooks) is a separate project.
128
69
 
129
70
  ## Documentation
130
71
 
131
- | Topic | Page |
132
- | --------------------------------------------------------- | ---------------------------------------------------------------- |
133
- | Mental model, vault layout, dream pass, safety properties | [`docs/how-it-works.md`](https://github.com/itechmeat/open-second-brain/blob/main/docs/how-it-works.md) |
134
- | Every CLI verb and flag | [`docs/cli-reference.md`](https://github.com/itechmeat/open-second-brain/blob/main/docs/cli-reference.md) |
135
- | MCP protocol, tools, writer split | [`docs/mcp.md`](https://github.com/itechmeat/open-second-brain/blob/main/docs/mcp.md) |
136
- | Brain store: setup, sync, migration, the human view | [`docs/brain-store.md`](https://github.com/itechmeat/open-second-brain/blob/main/docs/brain-store.md) |
137
- | Architecture and configuration model | [`docs/architecture.md`](https://github.com/itechmeat/open-second-brain/blob/main/docs/architecture.md) |
138
- | Updating (`o2b update`) and upgrade notes | [`docs/updating.md`](https://github.com/itechmeat/open-second-brain/blob/main/docs/updating.md) |
139
- | Observability events | [`docs/observability.md`](https://github.com/itechmeat/open-second-brain/blob/main/docs/observability.md) |
140
- | Metrics data contract | [`docs/metrics.md`](https://github.com/itechmeat/open-second-brain/blob/main/docs/metrics.md) |
141
- | Cross-project pointer | [`docs/cross-project-pointer.md`](https://github.com/itechmeat/open-second-brain/blob/main/docs/cross-project-pointer.md) |
142
- | Scheduled Brain digest (Hermes cron) | [`docs/hermes-cron.md`](https://github.com/itechmeat/open-second-brain/blob/main/docs/hermes-cron.md) |
143
- | Stability policy | [`docs/stability.md`](https://github.com/itechmeat/open-second-brain/blob/main/docs/stability.md) |
144
- | Origin of the idea | [`docs/idea.md`](https://github.com/itechmeat/open-second-brain/blob/main/docs/idea.md) |
72
+ [The documentation index](https://github.com/itechmeat/open-second-brain/blob/main/docs/README.md) groups the documents by what you want to do: get started, connect an agent, understand how it works, operate, upgrade, contribute.
73
+ Upgrading from 1.x: [`docs/updating.md`](https://github.com/itechmeat/open-second-brain/blob/main/docs/updating.md).
145
74
 
146
75
  ## Project
147
76
 
@@ -1,5 +1,5 @@
1
1
  name: open-second-brain
2
- version: "2.0.0-rc.1"
2
+ version: "2.0.0"
3
3
  description: "Open Second Brain - native Hermes memory provider backed by an Obsidian-compatible Markdown vault."
4
4
  author: "Open Second Brain contributors"
5
5
  memory_provider: true
package/pyproject.toml CHANGED
@@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta"
12
12
  # `hermes_agent.memory_providers` group, not a CLI script.
13
13
  [project]
14
14
  name = "open-second-brain"
15
- version = "2.0.0-rc.1"
15
+ version = "2.0.0"
16
16
  description = "Hermes Python shim for Open Second Brain. Most of the project (CLI, MCP server, OpenClaw plugin) is TypeScript on Bun; see package.json."
17
17
  readme = "README.md"
18
18
  requires-python = ">=3.11"
@@ -1,11 +1,12 @@
1
1
  /**
2
- * `o2b dream run [--claim <token>] [--vault <path>] [--config <file>]
3
- * [--json]` (change `dream-session-trigger`, design D3): the one command
4
- * that runs a whole live dream pass and records its day. The owner gate,
5
- * the front door (the closed questions produced and asked, the decision
6
- * model executor, the dream agent executor), the pass itself, then the
7
- * outcome (`dream-trigger/outcome.ts`), all under one deadline: the dream
8
- * safeguard's, as the maintenance lane's dream task spends it.
2
+ * `o2b dream run [--claim <token>] [--vault <path> | --no-vault]
3
+ * [--config <file>] [--json]` (change `dream-session-trigger`, design
4
+ * D3): the one command that runs a whole live dream pass and records its
5
+ * day. The owner gate, the front door (the closed questions produced and
6
+ * asked, the decision model executor, the dream agent executor), the pass
7
+ * itself, then the outcome (`dream-trigger/outcome.ts`), all under one
8
+ * deadline: the dream safeguard's, as the maintenance lane's dream task
9
+ * spends it.
9
10
  *
10
11
  * With `--claim` it is the worker the dream day check started: it runs
11
12
  * only when the trigger's claim file holds that token, writes its pid
@@ -19,6 +20,10 @@
19
20
  * Exit codes: 0 when the pass ran, 1 when it failed or was refused (a
20
21
  * device that is not the owner, a claim this run does not hold, another
21
22
  * pass running), 2 on a usage error (the dispatcher's).
23
+ *
24
+ * `--no-vault` runs the pass on no vault, as a day check that served none
25
+ * (an MCP server serving no vault) asks; without `--vault` or it, the
26
+ * vault the machine config resolves to.
22
27
  */
23
28
 
24
29
  import { discoverConfig, resolveVault } from "../../core/config.ts";
@@ -48,7 +53,7 @@ import { describeErrorChain } from "../brain/helpers.ts";
48
53
  import { sortedReplacer } from "../helpers.ts";
49
54
 
50
55
  export const DREAM_RUN_USAGE =
51
- "usage: o2b dream run [--claim <token>] [--vault <path>] [--config <file>] [--json]";
56
+ "usage: o2b dream run [--claim <token>] [--vault <path> | --no-vault] [--config <file>] [--json]";
52
57
 
53
58
  const EXIT = Object.freeze({ ok: 0, failed: 1 } as const);
54
59
 
@@ -86,6 +91,7 @@ export async function cmdRun(argv: ReadonlyArray<string>): Promise<number> {
86
91
  const { flags, positional } = parseFlags(argv, {
87
92
  claim: { type: "string" },
88
93
  vault: { type: "string" },
94
+ "no-vault": { type: "boolean" },
89
95
  config: { type: "string" },
90
96
  json: { type: "boolean" },
91
97
  });
@@ -94,6 +100,10 @@ export async function cmdRun(argv: ReadonlyArray<string>): Promise<number> {
94
100
  const json = flags["json"] === true;
95
101
  const token = flags["claim"] as string | undefined;
96
102
  if (token !== undefined && token.trim() === "") throw new CliError("--claim needs a token");
103
+ const noVault = flags["no-vault"] === true;
104
+ if (noVault && flags["vault"] !== undefined) {
105
+ throw new CliError("--vault and --no-vault cannot be given together");
106
+ }
97
107
  const configOpt = configPath !== undefined ? { configPath } : {};
98
108
 
99
109
  // The worker proves its claim before anything else and writes its pid
@@ -126,7 +136,7 @@ export async function cmdRun(argv: ReadonlyArray<string>): Promise<number> {
126
136
  let keepClaim = false;
127
137
  try {
128
138
  const ran = await runPass(
129
- (flags["vault"] as string | undefined) ?? resolveVault(configPath),
139
+ noVault ? null : ((flags["vault"] as string | undefined) ?? resolveVault(configPath)),
130
140
  configOpt,
131
141
  json,
132
142
  token !== undefined ? "worker" : "cli",
package/src/cli/setup.ts CHANGED
@@ -258,6 +258,13 @@ export async function cmdSetup(argv: string[]): Promise<number> {
258
258
  target,
259
259
  );
260
260
 
261
+ if (target === "aider" && explicitVault === undefined && !configuredVault)
262
+ return usage(
263
+ "Aider reads its context from a file in the vault; pass --vault <path>",
264
+ json,
265
+ target,
266
+ );
267
+
261
268
  const agentName = flags["agent-name"] as string | undefined;
262
269
  const timezone = flags["timezone"] as string | undefined;
263
270
  const identityConfigured = Boolean(config.data["agent_name"] && config.data["timezone"]);
@@ -32,11 +32,16 @@ export interface DreamTriggerClaim {
32
32
  readonly worker_pid: number | null;
33
33
  }
34
34
 
35
- /** A claim as read: the record, one that cannot be read (with its file's age), or none. */
35
+ /**
36
+ * A claim as read: the record; one read whole that is not a claim (with
37
+ * its file's age); one that is there and cannot be read now (permissions,
38
+ * I/O), which says nothing about its holder; or none.
39
+ */
36
40
  export type ClaimSeen =
37
41
  | { readonly kind: "absent" }
38
42
  | { readonly kind: "claim"; readonly claim: DreamTriggerClaim }
39
- | { readonly kind: "unreadable"; readonly mtimeMs: number };
43
+ | { readonly kind: "unreadable"; readonly mtimeMs: number }
44
+ | { readonly kind: "inconclusive" };
40
45
 
41
46
  function parseClaim(text: string): DreamTriggerClaim | null {
42
47
  try {
@@ -56,23 +61,22 @@ function parseClaim(text: string): DreamTriggerClaim | null {
56
61
  /** The claim at `path` as it is now. */
57
62
  export function readClaim(path: string): ClaimSeen {
58
63
  let text: string;
59
- let mtimeMs: number | null = null;
64
+ let mtimeMs: number;
60
65
  try {
61
66
  mtimeMs = statSync(path).mtimeMs;
62
67
  text = readFileSync(path, "utf8");
63
68
  } catch (err) {
64
69
  if ((err as NodeJS.ErrnoException).code === "ENOENT") return { kind: "absent" };
65
- // A claim that exists and cannot be read is judged by its file's age
66
- // (it ages like any claim); only one that cannot even be looked at is
67
- // judged as made now.
68
- return { kind: "unreadable", mtimeMs: mtimeMs ?? Date.now() };
70
+ // A claim that is there and cannot be read now hides its worker's
71
+ // pid: it is never aged out, only one read whole is.
72
+ return { kind: "inconclusive" };
69
73
  }
70
74
  const claim = parseClaim(text);
71
75
  return claim === null ? { kind: "unreadable", mtimeMs } : { kind: "claim", claim };
72
76
  }
73
77
 
74
78
  /** When the claim seen was made, for its age. */
75
- export function claimMadeAt(seen: Exclude<ClaimSeen, { kind: "absent" }>): number {
79
+ export function claimMadeAt(seen: Extract<ClaimSeen, { kind: "claim" | "unreadable" }>): number {
76
80
  return seen.kind === "claim" ? seen.claim.at : seen.mtimeMs;
77
81
  }
78
82
 
@@ -87,6 +91,7 @@ export function createClaim(
87
91
  now: number,
88
92
  workerPid: number | null = null,
89
93
  ): string | null {
94
+ retryFailedReleases(path);
90
95
  const claim: DreamTriggerClaim = {
91
96
  token: randomBytes(16).toString("hex"),
92
97
  at: now,
@@ -122,9 +127,67 @@ export function removeClaimIf(path: string, matches: (seen: ClaimSeen) => boolea
122
127
  });
123
128
  }
124
129
 
125
- /** Remove the claim at `path` when it still holds `token`. */
130
+ /**
131
+ * Claims this process failed to give back, by path. A claim a whole live
132
+ * run holds carries this process's pid, so it would stand for as long as
133
+ * the process lives: the next claim this process makes at the same path
134
+ * gives it back first.
135
+ */
136
+ const failedReleases = new Map<string, Set<string>>();
137
+
138
+ function retryFailedReleases(path: string): void {
139
+ const tokens = failedReleases.get(path);
140
+ if (tokens === undefined) return;
141
+ for (const token of tokens) {
142
+ try {
143
+ releaseClaim(path, token);
144
+ } catch {
145
+ // still not given back: the next claim tries again
146
+ }
147
+ }
148
+ }
149
+
150
+ /**
151
+ * Remove the claim at `path` when it still holds `token`. A failure is
152
+ * thrown and remembered: the next claim this process makes at `path`
153
+ * gives the claim back first. A claim that cannot be read stays
154
+ * remembered too: the token is forgotten only once the claim is removed,
155
+ * gone, or read whole holding another token.
156
+ */
126
157
  export function releaseClaim(path: string, token: string): boolean {
127
- return removeClaimIf(path, (seen) => seen.kind === "claim" && seen.claim.token === token);
158
+ let outcome: "removed" | "settled" | "unsure";
159
+ try {
160
+ // No claim, nothing to judge: the lock (and its folder) is not made.
161
+ outcome = !existsSync(path)
162
+ ? "settled"
163
+ : withLocalLock(path, () => {
164
+ const seen = readClaim(path);
165
+ if (seen.kind === "claim" && seen.claim.token === token) {
166
+ removeIfThere(path);
167
+ return "removed";
168
+ }
169
+ return seen.kind === "absent" || seen.kind === "claim" ? "settled" : "unsure";
170
+ });
171
+ } catch (err) {
172
+ remember(path, token);
173
+ throw err;
174
+ }
175
+ if (outcome === "unsure") {
176
+ remember(path, token);
177
+ return false;
178
+ }
179
+ const tokens = failedReleases.get(path);
180
+ if (tokens !== undefined) {
181
+ tokens.delete(token);
182
+ if (tokens.size === 0) failedReleases.delete(path);
183
+ }
184
+ return outcome === "removed";
185
+ }
186
+
187
+ function remember(path: string, token: string): void {
188
+ const tokens = failedReleases.get(path) ?? new Set<string>();
189
+ tokens.add(token);
190
+ failedReleases.set(path, tokens);
128
191
  }
129
192
 
130
193
  /**
@@ -37,6 +37,8 @@ export const DREAM_RUN_COMMAND = "o2b dream run";
37
37
  export const DREAM_STATUS_COMMAND = "o2b dream status";
38
38
  /** The argument that hands a claim to the worker. */
39
39
  export const DREAM_RUN_CLAIM_FLAG = "--claim";
40
+ /** The argument that runs the worker on no vault (a check that served none). */
41
+ export const DREAM_RUN_NO_VAULT_FLAG = "--no-vault";
40
42
 
41
43
  /** The code of the runtime notice that carries the day check's note. */
42
44
  export const DREAM_DAY_NOTICE_CODE = "dream-day";
@@ -22,8 +22,9 @@
22
22
  * or a retry time that has not come, gives the claim back.
23
23
  * 5. Start the worker, `o2b dream run --claim <token>`, detached; its
24
24
  * error output goes to a capped device-local log, one header per
25
- * attempt. A spawn that throws gives the claim back and records a
26
- * failed attempt.
25
+ * attempt. A spawn that throws, or an attempt that cannot be
26
+ * recorded before it, gives the claim back and records a failed
27
+ * attempt.
27
28
  *
28
29
  * Unknown is never read as an answer: a settings stream or an owner fold
29
30
  * that cannot be read completely starts nothing and caches nothing.
@@ -51,7 +52,11 @@ import {
51
52
  import { isoDate } from "../time.ts";
52
53
  import { readDreamAuto } from "./auto.ts";
53
54
  import { claimMadeAt, createClaim, releaseClaim, removeClaimIf, type ClaimSeen } from "./claim.ts";
54
- import { DREAM_RUN_CLAIM_FLAG, DREAM_TRIGGER_CLAIM_GRACE_MS } from "./constants.ts";
55
+ import {
56
+ DREAM_RUN_CLAIM_FLAG,
57
+ DREAM_RUN_NO_VAULT_FLAG,
58
+ DREAM_TRIGGER_CLAIM_GRACE_MS,
59
+ } from "./constants.ts";
55
60
  import { silentOwnerLineFor } from "./line.ts";
56
61
  import { retryDelayMs } from "./outcome.ts";
57
62
  import {
@@ -150,7 +155,8 @@ export function judgeClaim(
150
155
  grace: number,
151
156
  passLockHeld: () => boolean,
152
157
  ): ClaimVerdict {
153
- if (seen.kind === "absent") return "standing";
158
+ // No claim, or one that cannot be read now: nothing says its worker ended.
159
+ if (seen.kind === "absent" || seen.kind === "inconclusive") return "standing";
154
160
  const age = nowMs - claimMadeAt(seen);
155
161
  if (seen.kind === "claim") {
156
162
  const worker = seen.claim.worker_pid;
@@ -176,8 +182,12 @@ export function dueDreamDayCheck(input: DueCheckInput): DreamDayCheckResult {
176
182
  const vault = input.vault !== undefined ? input.vault : resolveVault(config.path);
177
183
  const opened = openDreamOwnerStore(vault, config.path);
178
184
  if (opened.store === null || !opened.store.partitions.has("shared")) {
179
- // Nothing here can be started today: no store, a legacy tree, no
180
- // device id, or no shared partition. Cached for the day.
185
+ // A legacy tree is the served vault's own: the record is the store
186
+ // root's, shared by every vault served on this machine, so it is not
187
+ // cached as this device's answer.
188
+ if (opened.store === null && opened.reason === "legacy-tree") return NOTHING;
189
+ // Nothing here can be started today: no store, no device id, or no
190
+ // shared partition. Cached for the day.
181
191
  update((r) => ({ ...r, owner: ownerOf(null, false), owner_checked_day: today }));
182
192
  return NOTHING;
183
193
  }
@@ -281,26 +291,33 @@ export function dueDreamDayCheck(input: DueCheckInput): DreamDayCheckResult {
281
291
  return NOTHING;
282
292
  }
283
293
 
284
- // The attempt is recorded before its worker starts, so the worker's
285
- // outcome, written when its pass ends, is the last word on it.
286
- update((r) => ({
287
- ...r,
288
- last_run: {
289
- started_at: new Date(nowMs).toISOString(),
290
- ended_at: null,
291
- outcome: null,
292
- by: "worker",
293
- },
294
- }));
295
294
  try {
295
+ // The attempt is recorded before its worker starts, so the worker's
296
+ // outcome, written when its pass ends, is the last word on it; a
297
+ // record that cannot be written gives the claim back like a spawn
298
+ // that throws.
299
+ update((r) => ({
300
+ ...r,
301
+ last_run: {
302
+ started_at: new Date(nowMs).toISOString(),
303
+ ended_at: null,
304
+ outcome: null,
305
+ by: "worker",
306
+ },
307
+ }));
296
308
  beginWorkerLogAttempt(
297
309
  log,
298
310
  workerLogAttemptHeader(new Date(nowMs), `started by process ${process.pid}`),
299
311
  );
300
312
  // The worker runs on the vault the check served, not the one its own
301
- // config would resolve to.
313
+ // config would resolve to; a check that served none starts a worker
314
+ // that serves none.
302
315
  const vaultArgs =
303
- input.vault !== undefined && input.vault !== null ? ["--vault", input.vault] : [];
316
+ input.vault === undefined
317
+ ? []
318
+ : input.vault === null
319
+ ? [DREAM_RUN_NO_VAULT_FLAG]
320
+ : ["--vault", input.vault];
304
321
  spawnSelfDetached([...command, "dream", "run", ...vaultArgs, DREAM_RUN_CLAIM_FLAG, token], {
305
322
  env: { ...input.env, OPEN_SECOND_BRAIN_CONFIG: config.path },
306
323
  stderrLog: log,
@@ -332,7 +332,7 @@ function releaseOf(path: string, token: string): () => void {
332
332
  try {
333
333
  releaseClaim(path, token);
334
334
  } catch {
335
- // a claim left behind is judged by its worker pid, this process
335
+ // remembered: this process's next claim gives it back first
336
336
  }
337
337
  };
338
338
  }
@@ -349,14 +349,16 @@ function runClaimGraceMs(configPath: string | undefined): number {
349
349
  * Whether a claim already there still stands for a run that wants its own:
350
350
  * its worker (the pid it wrote) lives; or no worker has proved it yet and
351
351
  * its maker started one within the start window, or the maker still lives
352
- * within the pass deadline; or it cannot be read and is younger than the
353
- * deadline. Anything else was left by a holder that is gone.
352
+ * within the pass deadline; or it was read whole, is not a claim, and is
353
+ * younger than the deadline; or it cannot be read now. Anything else was
354
+ * left by a holder that is gone.
354
355
  */
355
356
  export function runClaimStands(
356
357
  seen: Exclude<ClaimSeen, { kind: "absent" }>,
357
358
  nowMs: number,
358
359
  grace: number,
359
360
  ): boolean {
361
+ if (seen.kind === "inconclusive") return true;
360
362
  const age = nowMs - claimMadeAt(seen);
361
363
  if (seen.kind === "unreadable") return age < grace;
362
364
  const { claim } = seen;
@@ -385,6 +387,9 @@ function describeClaimHolder(seen: ClaimSeen | null): string {
385
387
  if (seen === null || seen.kind === "absent") {
386
388
  return "another dream pass on this machine is taking the claim now";
387
389
  }
390
+ if (seen.kind === "inconclusive") {
391
+ return "a dream pass on this machine holds it; the claim cannot be read now";
392
+ }
388
393
  const since = new Date(claimMadeAt(seen)).toISOString();
389
394
  if (seen.kind === "unreadable") return `a dream pass on this machine holds it since ${since}`;
390
395
  const { claim } = seen;
@@ -61,7 +61,17 @@ function resolveConfPath(env: InstallEnv): string {
61
61
  return join(env.home, ".aider.conf.yml");
62
62
  }
63
63
 
64
+ // The sidecar lives in the vault. With no vault the path would be relative
65
+ // to wherever setup ran, and Aider started elsewhere would not find it.
64
66
  function resolveSidecarPath(env: InstallEnv, opts: { aiderContextPath?: string }): string {
67
+ if (!opts.aiderContextPath && !env.vault) {
68
+ throw new InstallError(
69
+ "aider: Aider reads its context from a file in the vault, and no vault is configured",
70
+ TARGET,
71
+ "config-missing",
72
+ "pass --vault <path>",
73
+ );
74
+ }
65
75
  return resolveAiderSidecarPath(env, opts);
66
76
  }
67
77
 
@@ -8,6 +8,7 @@
8
8
 
9
9
  import { contextRecordOrigin } from "./shared.ts";
10
10
  import { resolve } from "node:path";
11
+ import { isStoreOnly } from "../../core/store/store-only.ts";
11
12
  import { loadPermissionsDocumentFor } from "../../core/brain/permissions/document-source.ts";
12
13
  import { resolveAgentName } from "../../core/config.ts";
13
14
  import { resolveEffectiveScope, signalRecordExists, writeSignal } from "../../core/brain/signal.ts";
@@ -194,6 +195,13 @@ export async function toolBrainFeedback(
194
195
  ): Promise<Record<string, unknown>> {
195
196
  // `null` on a server with no vault: the writes are store records (D14).
196
197
  const vault = contextVault(ctx);
198
+ // A store-only machine (no vault, or a switched one with a vault) wrote
199
+ // records, not files: every path field names the record (`store:<id>`),
200
+ // as the CLI does, never the legacy path the writer still composes.
201
+ let storeOnly: boolean | undefined;
202
+ const recordsOnly = (): boolean =>
203
+ (storeOnly ??=
204
+ vault === null || isStoreOnly({ vault, configPath: ctx.configPath ?? undefined }));
197
205
  // Single source of truth for the brain_feedback payload contract —
198
206
  // session-replay (sessions/import.ts) and the MCP live path now go
199
207
  // through the same validator so rule shape cannot drift between the
@@ -517,22 +525,26 @@ export async function toolBrainFeedback(
517
525
  kind: "preference",
518
526
  deduped: true,
519
527
  staged: false,
520
- signal_path:
521
- vault === null
522
- ? `${STORE_RECORD_PREFIX}${sigResult.id}`
523
- : toolPath(ctx, sigResult.path),
524
- signal_absolute_path:
525
- vault === null ? `${STORE_RECORD_PREFIX}${sigResult.id}` : resolve(sigResult.path),
528
+ signal_path: recordsOnly()
529
+ ? `${STORE_RECORD_PREFIX}${sigResult.id}`
530
+ : toolPath(ctx, sigResult.path),
531
+ signal_absolute_path: recordsOnly()
532
+ ? `${STORE_RECORD_PREFIX}${sigResult.id}`
533
+ : resolve(sigResult.path),
526
534
  signal_id: sigResult.id,
527
- preference_path:
528
- vault === null ? `${STORE_RECORD_PREFIX}${existing.id}` : toolPath(ctx, existingPath),
529
- preference_absolute_path:
530
- vault === null ? `${STORE_RECORD_PREFIX}${existing.id}` : resolve(existingPath),
535
+ preference_path: recordsOnly()
536
+ ? `${STORE_RECORD_PREFIX}${existing.id}`
537
+ : toolPath(ctx, existingPath),
538
+ preference_absolute_path: recordsOnly()
539
+ ? `${STORE_RECORD_PREFIX}${existing.id}`
540
+ : resolve(existingPath),
531
541
  preference_id: existing.id,
532
- path:
533
- vault === null ? `${STORE_RECORD_PREFIX}${existing.id}` : toolPath(ctx, existingPath),
534
- absolute_path:
535
- vault === null ? `${STORE_RECORD_PREFIX}${existing.id}` : resolve(existingPath),
542
+ path: recordsOnly()
543
+ ? `${STORE_RECORD_PREFIX}${existing.id}`
544
+ : toolPath(ctx, existingPath),
545
+ absolute_path: recordsOnly()
546
+ ? `${STORE_RECORD_PREFIX}${existing.id}`
547
+ : resolve(existingPath),
536
548
  id: existing.id,
537
549
  agent,
538
550
  };
@@ -547,19 +559,24 @@ export async function toolBrainFeedback(
547
559
  deduped: true,
548
560
  // The signal was deduped, so the retry staged nothing new.
549
561
  staged: false,
550
- signal_path:
551
- vault === null ? `${STORE_RECORD_PREFIX}${sigResult.id}` : toolPath(ctx, sigResult.path),
552
- signal_absolute_path:
553
- vault === null ? `${STORE_RECORD_PREFIX}${sigResult.id}` : resolve(sigResult.path),
562
+ signal_path: recordsOnly()
563
+ ? `${STORE_RECORD_PREFIX}${sigResult.id}`
564
+ : toolPath(ctx, sigResult.path),
565
+ signal_absolute_path: recordsOnly()
566
+ ? `${STORE_RECORD_PREFIX}${sigResult.id}`
567
+ : resolve(sigResult.path),
554
568
  signal_id: sigResult.id,
555
- preference_path:
556
- vault === null ? `${STORE_RECORD_PREFIX}${resumed.id}` : toolPath(ctx, resumed.path),
557
- preference_absolute_path:
558
- vault === null ? `${STORE_RECORD_PREFIX}${resumed.id}` : resolve(resumed.path),
569
+ preference_path: recordsOnly()
570
+ ? `${STORE_RECORD_PREFIX}${resumed.id}`
571
+ : toolPath(ctx, resumed.path),
572
+ preference_absolute_path: recordsOnly()
573
+ ? `${STORE_RECORD_PREFIX}${resumed.id}`
574
+ : resolve(resumed.path),
559
575
  preference_id: resumed.id,
560
- path: vault === null ? `${STORE_RECORD_PREFIX}${resumed.id}` : toolPath(ctx, resumed.path),
561
- absolute_path:
562
- vault === null ? `${STORE_RECORD_PREFIX}${resumed.id}` : resolve(resumed.path),
576
+ path: recordsOnly() ? `${STORE_RECORD_PREFIX}${resumed.id}` : toolPath(ctx, resumed.path),
577
+ absolute_path: recordsOnly()
578
+ ? `${STORE_RECORD_PREFIX}${resumed.id}`
579
+ : resolve(resumed.path),
563
580
  id: resumed.id,
564
581
  agent,
565
582
  };
@@ -569,15 +586,17 @@ export async function toolBrainFeedback(
569
586
  deduped: true,
570
587
  // A dedup wrote nothing, so it staged nothing.
571
588
  staged: false,
572
- signal_path:
573
- vault === null ? `${STORE_RECORD_PREFIX}${sigResult.id}` : toolPath(ctx, sigResult.path),
574
- signal_absolute_path:
575
- vault === null ? `${STORE_RECORD_PREFIX}${sigResult.id}` : resolve(sigResult.path),
589
+ signal_path: recordsOnly()
590
+ ? `${STORE_RECORD_PREFIX}${sigResult.id}`
591
+ : toolPath(ctx, sigResult.path),
592
+ signal_absolute_path: recordsOnly()
593
+ ? `${STORE_RECORD_PREFIX}${sigResult.id}`
594
+ : resolve(sigResult.path),
576
595
  signal_id: sigResult.id,
577
- path:
578
- vault === null ? `${STORE_RECORD_PREFIX}${sigResult.id}` : toolPath(ctx, sigResult.path),
579
- absolute_path:
580
- vault === null ? `${STORE_RECORD_PREFIX}${sigResult.id}` : resolve(sigResult.path),
596
+ path: recordsOnly() ? `${STORE_RECORD_PREFIX}${sigResult.id}` : toolPath(ctx, sigResult.path),
597
+ absolute_path: recordsOnly()
598
+ ? `${STORE_RECORD_PREFIX}${sigResult.id}`
599
+ : resolve(sigResult.path),
581
600
  id: sigResult.id,
582
601
  agent,
583
602
  };
@@ -653,12 +672,12 @@ export async function toolBrainFeedback(
653
672
  logConfirmedPreference(prefResult.id);
654
673
  }
655
674
 
656
- // With no vault the records have no file: both fields name the record
657
- // (`store:<id>`), as the CLI does.
675
+ // On a store-only machine the records have no file: both fields name
676
+ // the record (`store:<id>`), as the CLI does.
658
677
  const named = (path: string, id: string): string =>
659
- vault === null ? `${STORE_RECORD_PREFIX}${id}` : toolPath(ctx, path);
678
+ recordsOnly() ? `${STORE_RECORD_PREFIX}${id}` : toolPath(ctx, path);
660
679
  const absolute = (path: string, id: string): string =>
661
- vault === null ? `${STORE_RECORD_PREFIX}${id}` : resolve(path);
680
+ recordsOnly() ? `${STORE_RECORD_PREFIX}${id}` : resolve(path);
662
681
  return {
663
682
  kind: prefResult ? "preference" : "signal",
664
683
  ...mirrorReportFields(mirror),