crbro-memory 2.6.0 → 2.7.1

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.
Files changed (60) hide show
  1. package/README.md +515 -487
  2. package/SECURITY.md +222 -0
  3. package/bin/crbro.mjs +241 -6
  4. package/dist/engine/backup.d.ts.map +1 -1
  5. package/dist/engine/backup.js +5 -1
  6. package/dist/engine/backup.js.map +1 -1
  7. package/dist/engine/cortex.d.ts +61 -0
  8. package/dist/engine/cortex.d.ts.map +1 -1
  9. package/dist/engine/cortex.js +270 -24
  10. package/dist/engine/cortex.js.map +1 -1
  11. package/dist/engine/hookverify.d.ts +42 -0
  12. package/dist/engine/hookverify.d.ts.map +1 -0
  13. package/dist/engine/hookverify.js +169 -0
  14. package/dist/engine/hookverify.js.map +1 -0
  15. package/dist/engine/maintenance.d.ts.map +1 -1
  16. package/dist/engine/maintenance.js +15 -2
  17. package/dist/engine/maintenance.js.map +1 -1
  18. package/dist/engine/postmortem.d.ts +81 -0
  19. package/dist/engine/postmortem.d.ts.map +1 -0
  20. package/dist/engine/postmortem.js +449 -0
  21. package/dist/engine/postmortem.js.map +1 -0
  22. package/dist/engine/prefrontal.d.ts +1 -0
  23. package/dist/engine/prefrontal.d.ts.map +1 -1
  24. package/dist/engine/prefrontal.js +8 -2
  25. package/dist/engine/prefrontal.js.map +1 -1
  26. package/dist/engine/secrets.d.ts +9 -0
  27. package/dist/engine/secrets.d.ts.map +1 -1
  28. package/dist/engine/secrets.js +7 -0
  29. package/dist/engine/secrets.js.map +1 -1
  30. package/dist/engine/triggers.d.ts +8 -2
  31. package/dist/engine/triggers.d.ts.map +1 -1
  32. package/dist/engine/triggers.js +21 -11
  33. package/dist/engine/triggers.js.map +1 -1
  34. package/dist/engine/usage.d.ts +61 -0
  35. package/dist/engine/usage.d.ts.map +1 -0
  36. package/dist/engine/usage.js +252 -0
  37. package/dist/engine/usage.js.map +1 -0
  38. package/dist/search/index.d.ts +40 -0
  39. package/dist/search/index.d.ts.map +1 -1
  40. package/dist/search/index.js +186 -5
  41. package/dist/search/index.js.map +1 -1
  42. package/dist/server.d.ts.map +1 -1
  43. package/dist/server.js +98 -10
  44. package/dist/server.js.map +1 -1
  45. package/dist/sync/materialize.d.ts.map +1 -1
  46. package/dist/sync/materialize.js +54 -1
  47. package/dist/sync/materialize.js.map +1 -1
  48. package/dist/types/index.d.ts +28 -0
  49. package/dist/types/index.d.ts.map +1 -1
  50. package/dist/utils/ids.d.ts +6 -0
  51. package/dist/utils/ids.d.ts.map +1 -1
  52. package/dist/utils/ids.js +14 -4
  53. package/dist/utils/ids.js.map +1 -1
  54. package/dist/utils/transcripts.d.ts +63 -0
  55. package/dist/utils/transcripts.d.ts.map +1 -0
  56. package/dist/utils/transcripts.js +242 -0
  57. package/dist/utils/transcripts.js.map +1 -0
  58. package/hooks/crbro-lifecycle.mjs +608 -0
  59. package/hooks/crbro-subagent.mjs +17 -4
  60. package/package.json +2 -1
package/SECURITY.md ADDED
@@ -0,0 +1,222 @@
1
+ # Security
2
+
3
+ CRBRO is a memory that an AI assistant writes to and reads from, on your own
4
+ machine. That puts it between three things worth protecting, and this page
5
+ says what each defense is for — so that nobody removes one because it looked
6
+ like friction, and nobody trusts one for more than it does.
7
+
8
+ ## What is at stake
9
+
10
+ | | What | Where |
11
+ |---|---|---|
12
+ | **Private data** | Everything the assistant learned about you and your work | The brain: `~/.crbro`, or `CRBRO_PATH` |
13
+ | | Credentials you chose to keep | The keychain, outside the brain (see below) |
14
+ | **Content you did not write** | Lines from teammates, through a shared space | `<brain>/shared/<space>/`, materialised into neurons |
15
+ | | What the miner extracted from files on disk | Neurons, marked `source: miner` |
16
+ | | Claude Code session logs, read by `crbro usage`, `crbro postmortem` and the lifecycle hook | `~/.claude/projects/` |
17
+ | | Compaction checkpoints written by the lifecycle hook (requests, task list, folder, remote) | `<brain>/checkpoints/`, seven days |
18
+ | **Communication out** | Team-space sync | A git remote you configure |
19
+ | | The optional semantic model | Downloaded once from Hugging Face by `semantic install` |
20
+
21
+ There is no account, no server of ours and no telemetry. Nothing is sent to
22
+ the author.
23
+
24
+ ## The defenses, and why each exists
25
+
26
+ ### Secret filter — `src/engine/secrets.ts`
27
+
28
+ Assistants handle credentials all day, and a memory stores whatever it is
29
+ handed. On the brain CRBRO was built against, five credentials were
30
+ sitting in plain text, and all five were in the search index too, so a recall
31
+ could hand them straight back.
32
+
33
+ So text is passed through `redact()` before it reaches disk: facts and
34
+ entries written with `crbro_learn` (the miner writes through the same path),
35
+ neuron summaries changed with `crbro_revise`, system maps, the session summary
36
+ of `crbro_consolidate`, open items written with `crbro_context`, and the
37
+ compaction checkpoints of the lifecycle hook. A credential becomes
38
+ `[REDACTED: <kind>]` and the sentence around it survives. `crbro postmortem`
39
+ applies the same filter to everything it prints. Text is always redacted whole
40
+ and cut to length afterwards: a cut first could leave half a token the filter
41
+ no longer recognises.
42
+
43
+ It is tuned for precision, not recall: it matches shapes that are credentials
44
+ and essentially nothing else, because a false positive silently corrupts real
45
+ knowledge. The consequence is that a credential in a shape it does not know
46
+ passes. Treat it as a net, not as a guarantee.
47
+
48
+ Sharing is stricter than storing: a neuron that contains a credential is
49
+ **refused** for sharing, not redacted, because sending a teammate a mangled
50
+ fact without saying so is worse than refusing and saying where the problem is.
51
+ Preferences are never shared or synced at all; on the reference brain one in
52
+ eighteen was an API key.
53
+
54
+ ### The keychain — `src/engine/keychain.ts`
55
+
56
+ Refusing to store a secret is only half an answer: it leaves the user holding
57
+ it, and it goes back into a config file in plain text. `crbro_secret` and
58
+ `crbro secret` put it in the store the operating system already ships:
59
+
60
+ - **Windows** — sealed with DPAPI to the Windows user account, in a file next
61
+ to the brain, never inside it. Copied to another machine, lifted from a
62
+ backup or pushed to a repository, it does not open.
63
+ - **macOS** — the login keychain, through `security(1)`.
64
+ - **Linux** — the Secret Service, through `secret-tool(1)`.
65
+
66
+ CRBRO invents no cryptography. The store lives outside the brain on purpose,
67
+ so no sync, share or backup can reach it even by mistake. The value is read
68
+ from stdin by the CLI, never from arguments, so it stays out of shell history
69
+ and the process table.
70
+
71
+ What it does not do: protect against code running as your own user. DPAPI,
72
+ the login keychain and the Secret Service all open for the logged-in account.
73
+
74
+ ### Quarantine before forgetting
75
+
76
+ `crbro_forget` (and every merge, split and compaction that removes a neuron)
77
+ copies what it removes to `<brain>/.quarantine/` first, with a timestamp, and
78
+ `crbro_forget restore` brings it back: a wrong forget should cost a restore,
79
+ not the knowledge.
80
+
81
+ The flip side: the quarantine holds what was forgotten, including credentials
82
+ removed on purpose. That is why `crbro backup` leaves it out. To remove
83
+ something for good, delete its quarantine file as well.
84
+
85
+ ### Subagent injection is off by default
86
+
87
+ `install-hooks` installs the SubagentStart hook inert; only
88
+ `install-hooks --inject` (or `CRBRO_SUBAGENT_INJECT=full`) makes it hand the
89
+ brain's protocols to every subagent. Three clean-control benchmark runs found
90
+ no measured benefit in any model and harm — including fabricated compliance —
91
+ in small ones. It also keeps brain content from reaching every agent a
92
+ workflow spawns, which is where content travels furthest from your review.
93
+
94
+ ### Provenance in recall
95
+
96
+ A line written by a teammate or extracted by the miner is not your own word.
97
+ `crbro_recall` marks it, on the winning entry and on every `also_matched`
98
+ line: `origin: team:<space>` with `by`, plain `origin: team` when the neuron
99
+ is no longer in a shared space, or `origin: miner`. Your own lines carry no
100
+ `origin`. The model and you can weigh such a line accordingly, and an
101
+ instruction planted in a shared space shows up as coming from that space.
102
+
103
+ What it does not prove:
104
+
105
+ - **`by` is a label the author declares.** It travels inside each op of the
106
+ shared log and nothing verifies it; anyone with push access can write any
107
+ name, yours included. So a line that arrived through a space keeps its
108
+ `origin` even when `by` is your own name — another device of yours shows
109
+ as `team:<space>` with `by: <you>`.
110
+ - **Patterns, errors and debts synced before 2.7 carry no origin.** The
111
+ `entry_source` sidecar is filled when a sync adds a line; lines that a
112
+ teammate contributed and that were already materialised by 2.6 stay
113
+ unlabelled (facts and decisions are fine: they carried `source`/`by`
114
+ already).
115
+ - `consolidate` never proposes promoting a lesson that is not your own, so a
116
+ teammate's or the miner's line cannot be rewritten as your own lesson
117
+ through `promotion_candidates`.
118
+
119
+ Provenance labels; it does not sanitise. Content arriving through a shared
120
+ space is not filtered for secrets or for instructions on the way in. Treat any
121
+ line with an `origin` as data, never as an order.
122
+
123
+ ### Team sync over git
124
+
125
+ Only neurons you name with `crbro_share` are pushed, to a remote you
126
+ configure. git runs with every interactive prompt disabled
127
+ (`GIT_TERMINAL_PROMPT=0`, SSH in batch mode) and with timeouts, so a private
128
+ or unreachable remote fails instead of hanging the server. SSH accepts a host
129
+ key the first time it sees it (`StrictHostKeyChecking=accept-new`) and refuses
130
+ a changed one afterwards. Incoming logs written by a newer, unknown format are
131
+ skipped rather than half-understood, and an unreadable line is skipped without
132
+ costing the rest.
133
+
134
+ ### Hooks never block
135
+
136
+ The guard (`PreToolUse`), the subagent hook (`SubagentStart`) and the
137
+ lifecycle hook (`SessionStart`, `PreCompact`) add context and nothing else.
138
+ They exit 0 on any error, on bad input and on timeout; they never approve,
139
+ deny or rewrite a tool call. A memory that can stop your session is worse than
140
+ no memory, and a hook that could deny calls would be a lever for anyone who
141
+ can write into the brain.
142
+
143
+ ### Hook verification — `crbro install-hooks --verify`
144
+
145
+ `install-hooks` copies its scripts into `~/.claude/crbro-hooks/` so they
146
+ survive an npx cache wipe, and `settings.json` runs those copies. That makes
147
+ them ordinary files in your home: anything that can write there can change
148
+ what runs at the start of every session and before every shell command.
149
+
150
+ `install-hooks --verify` hashes each installed copy with SHA-256 and compares
151
+ it with the same file in the package you are running, checks that every CRBRO
152
+ hook `settings.json` runs exists, and reports. It writes nothing and fixes
153
+ nothing; it exits 1 when something differs, so a script can act on it. A
154
+ difference after updating CRBRO is expected (the copy is from the older
155
+ release) and re-running the install command refreshes it. A difference you
156
+ cannot explain is worth looking at before the next session.
157
+
158
+ It compares against the package on disk, so it cannot catch a change made to
159
+ both. It runs when you run it, not on its own.
160
+
161
+ ### Reading session logs — `crbro usage`, `crbro postmortem`, the lifecycle hook
162
+
163
+ Claude Code's logs hold everything said in a session, tool output included.
164
+ The two commands are read-only and stream the files line by line, so a log of
165
+ hundreds of megabytes is not loaded whole.
166
+
167
+ - `usage` reads `message.model`, `message.usage`, `message.id`, `requestId`,
168
+ `isSidechain` and `timestamp`, and nothing else; lines that cannot carry a
169
+ usage block are discarded as raw bytes before they are decoded.
170
+ - `postmortem` reads what the person typed and the names of the tools called.
171
+ It never reads a tool's input or a tool's result — only the result's
172
+ `is_error` flag — and it passes everything it prints through the secret
173
+ filter. It proposes lessons; it never stores one.
174
+ - The lifecycle hook (`install-hooks --compact`), in its `PreCompact` mode,
175
+ reads the last 32 MB of the session being compacted: the text the person
176
+ typed (not what a background task, another agent or a client command such
177
+ as `/model` wrote as a user line), the inputs of `TodoWrite`, `TaskCreate`
178
+ and `TaskUpdate`, and — only to learn the task number — the result text of
179
+ `TaskCreate`. It writes a redacted checkpoint to `<brain>/checkpoints/`,
180
+ removed after seven days and left out of backups. After the compaction, its
181
+ `SessionStart` mode puts that text back into the model's context, at most
182
+ 1,500 characters, as the "Resuming after compaction" block. That is text
183
+ from the transcript re-entering the context: what was a request stays a
184
+ request, and nothing else is promoted to one.
185
+
186
+ ### Backups leave out what should not travel
187
+
188
+ `crbro backup` skips the quarantine, machine tokens, the licence cache, the
189
+ search index, the semantic runtime and the compaction checkpoints (fragments
190
+ of conversation that are meant to expire in seven days, not to live on in a
191
+ synced backup folder). Keys never live in the brain, so a backup holds
192
+ knowledge and no secrets — except whatever the secret filter did not
193
+ recognise.
194
+
195
+ ## Out of scope
196
+
197
+ - **Someone who can run code as you.** They can read the brain, and the
198
+ keychain opens for them as it opens for you.
199
+ - **Your MCP client and model provider.** Whatever a tool returns is read by
200
+ the assistant you are talking to. That traffic is between you and them.
201
+ - **Prompt injection through stored content, in general.** A memory cannot
202
+ make text safe to obey. CRBRO labels where a line came from and keeps its
203
+ hooks unable to block or approve anything; deciding what to follow is the
204
+ model's and yours.
205
+
206
+ ## Reporting a vulnerability
207
+
208
+ Please report it privately, not in a public issue. Use **Report a
209
+ vulnerability** under the **Security** tab of
210
+ [github.com/Octonove/crbro-memory](https://github.com/Octonove/crbro-memory)
211
+ if it is available. If it is not, open an issue asking for a private contact,
212
+ without any detail of the flaw, and a private channel will be arranged.
213
+
214
+ Include the version (`npx crbro-memory status` prints it), the
215
+ operating system, what an attacker needs (local access, a teammate's position
216
+ in a shared space, a crafted file for the miner…), and the smallest steps that
217
+ show it. Do not include real credentials or real brain contents; synthetic
218
+ ones are enough.
219
+
220
+ You will get an acknowledgement, and a fix date and a disclosure date will be
221
+ agreed with you before anything is made public. Fixes ship in the latest
222
+ release on npm; there are no maintained older branches.
package/bin/crbro.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  // ─── CRBRO CLI ───────────────────────────────────────────────────
4
4
  // Command-line interface for CRBRO memory system
5
- // Supports: init, status, secret, mine, setup-miner, miner-status,
5
+ // Supports: init, status, secret, mine, setup-miner, miner-status, usage, postmortem,
6
6
  // remove-miner, and MCP server mode (default)
7
7
 
8
8
  import { platform, homedir } from 'os';
@@ -22,6 +22,17 @@ function pkgVersion() {
22
22
  }
23
23
  }
24
24
 
25
+ // The Claude Code SessionStart command install-boot writes. Kept in one place
26
+ // because `install-hooks --compact` has to recognise it to replace it.
27
+ function bootCommandPosix(aviso) {
28
+ return `printf '%s\\n' ${JSON.stringify(aviso)}`;
29
+ }
30
+
31
+ /** An install-boot entry, this release's or an older one with other wording. */
32
+ function isInstallBootHook(h) {
33
+ return !!h && typeof h.command === 'string' && h.command.startsWith("printf '%s\\n' ") && h.command.includes('crbro_boot');
34
+ }
35
+
25
36
  const args = process.argv.slice(2);
26
37
  const command = args[0];
27
38
 
@@ -613,6 +624,222 @@ if (command === 'init') {
613
624
  for (const l of lessons) console.log(` • [${l.k}${l.d ? ' · ' + l.d : ''} · ${l.n}] ${l.t}\n`);
614
625
  })().catch(e => { console.error(e.message); process.exit(1); });
615
626
 
627
+ } else if (command === 'usage' || command === 'postmortem') {
628
+ // ─── Token spend and post-mortem, from Claude Code's own logs ──
629
+ //
630
+ // crbro usage [--days N] [--session <id>] [--project <folder>] [--json]
631
+ // crbro postmortem [--days N] [--session <id>] [--project <folder>] [--max N] [--json]
632
+ //
633
+ // Both read ~/.claude/projects/<project>/<session>.jsonl (and, for usage,
634
+ // the subagent logs under <session>/subagents/) through one streaming
635
+ // reader. usage reads message.model and message.usage only; postmortem
636
+ // reads what the person typed and tool names, never a tool's input or
637
+ // result, and redacts everything it prints. Neither writes anything.
638
+ const flag = (name) => { const i = args.indexOf(name); return i !== -1 && args[i + 1] && !args[i + 1].startsWith('--') ? args[i + 1] : undefined; };
639
+ const intFlag = (name) => {
640
+ const v = flag(name);
641
+ if (v === undefined) return undefined;
642
+ const n = Number(v);
643
+ if (!Number.isInteger(n) || n < 0) { console.error(` ❌ ${name} expects a whole number ≥ 0; got: ${v}`); process.exit(1); }
644
+ return n;
645
+ };
646
+ const session = flag('--session');
647
+ const project = flag('--project');
648
+ // Last 7 days unless told otherwise (--days 0 = all); a named session is looked for everywhere.
649
+ const daysArg = intFlag('--days');
650
+ const days = daysArg !== undefined ? (daysArg === 0 ? undefined : daysArg) : (session ? undefined : 7);
651
+ const max = intFlag('--max');
652
+ const json = args.includes('--json');
653
+ const mod = command === 'usage' ? '../dist/engine/usage.js' : '../dist/engine/postmortem.js';
654
+ import(mod).then(async m => {
655
+ if (command === 'usage') {
656
+ const r = await m.collectUsage({ days, session, project });
657
+ console.log(json ? JSON.stringify(r, null, 2) : m.formatUsage(r));
658
+ } else {
659
+ const r = await m.runPostmortem({ days, session, project, max });
660
+ console.log(json ? JSON.stringify(r, null, 2) : m.formatPostmortem(r));
661
+ }
662
+ }).catch(err => {
663
+ console.error(' ❌ ' + (err && err.code === 'ERR_MODULE_NOT_FOUND' ? 'Build required. Run: npm run build' : err.message));
664
+ process.exit(1);
665
+ });
666
+
667
+ } else if (command === 'install-hooks' && process.argv.includes('--verify')) {
668
+ // ─── Are the installed hooks the ones this package ships? ──────
669
+ // SHA-256 of each copy in ~/.claude/crbro-hooks/ against hooks/ here, and
670
+ // whether every CRBRO hook settings.json runs exists. Read-only. Exit 1 on
671
+ // any difference, so it can gate a script.
672
+ import('../dist/engine/hookverify.js').then(({ verifyHooks, formatVerify }) => {
673
+ const here = dirname(fileURLToPath(import.meta.url));
674
+ const r = verifyHooks({
675
+ packageDir: join(here, '..', 'hooks'),
676
+ installedDir: join(homedir(), '.claude', 'crbro-hooks'),
677
+ settingsPath: join(homedir(), '.claude', 'settings.json'),
678
+ });
679
+ console.log(args.includes('--json') ? JSON.stringify(r, null, 2) : formatVerify(r));
680
+ if (!r.ok) process.exitCode = 1;
681
+ }).catch(err => {
682
+ console.error(' ❌ ' + (err && err.code === 'ERR_MODULE_NOT_FOUND' ? 'Build required. Run: npm run build' : err.message));
683
+ process.exit(1);
684
+ });
685
+
686
+ } else if ((command === 'install-hooks' || command === 'uninstall-hooks') && process.argv.includes('--compact')) {
687
+ // ─── Compact without losing the thread (opt-in, Claude Code only) ──
688
+ //
689
+ // PreCompact → hooks/crbro-lifecycle.mjs pre-compact: a mechanical,
690
+ // redacted checkpoint of the session in <brain>/checkpoints/, plus the
691
+ // "keep what is not saved yet" reminder.
692
+ // SessionStart → hooks/crbro-lifecycle.mjs session-start: the boot notice,
693
+ // the folder and its git remote, and after a compaction what was being
694
+ // done before it.
695
+ //
696
+ // Only Claude Code has PreCompact, so ~/.codex is never touched. The entry
697
+ // install-boot wrote for Claude Code prints the very notice session-start
698
+ // prints, so it is replaced, and the replaced hook is kept aside in
699
+ // crbro-hooks/ so uninstall puts it back exactly. A hand-written CRBRO hook
700
+ // is never replaced: ours is installed with --no-boot / --no-reminder next
701
+ // to it, so nothing is read twice. Merged, never rewritten; idempotent.
702
+ import('fs').then(async fs => {
703
+ const settingsPath = join(homedir(), '.claude', 'settings.json');
704
+ const hookDir = join(homedir(), '.claude', 'crbro-hooks');
705
+ const hookScript = join(hookDir, 'crbro-lifecycle.mjs');
706
+ const replacedPath = join(hookDir, 'crbro-lifecycle.replaced.json');
707
+ const ours = h => !!h && typeof h.command === 'string' && h.command.includes('crbro-lifecycle');
708
+ const entryIsOurs = e => Array.isArray(e?.hooks) && e.hooks.some(ours);
709
+
710
+ let settings = null;
711
+ try {
712
+ const raw = fs.readFileSync(settingsPath, 'utf8');
713
+ settings = JSON.parse(raw.charCodeAt(0) === 0xFEFF ? raw.slice(1) : raw);
714
+ } catch (e) {
715
+ if (fs.existsSync(settingsPath)) {
716
+ console.error(` ❌ ${settingsPath} exists but could not be parsed — not touching it.`);
717
+ console.error(` ${e.message}`);
718
+ process.exit(1);
719
+ }
720
+ }
721
+ if (settings !== null && (typeof settings !== 'object' || Array.isArray(settings))) {
722
+ console.error(` ❌ ${settingsPath} is not a JSON object — not touching it.`);
723
+ process.exit(1);
724
+ }
725
+ for (const event of ['PreCompact', 'SessionStart']) {
726
+ const v = settings?.hooks?.[event];
727
+ if (v !== undefined && !Array.isArray(v)) {
728
+ console.error(` ❌ hooks.${event} in ${settingsPath} is not a list — not touching it.`);
729
+ process.exit(1);
730
+ }
731
+ }
732
+ const write = obj => {
733
+ const tmp = settingsPath + '.' + process.pid + '.tmp';
734
+ fs.writeFileSync(tmp, JSON.stringify(obj, null, 2) + '\n', 'utf8');
735
+ fs.renameSync(tmp, settingsPath);
736
+ };
737
+
738
+ if (command === 'uninstall-hooks') {
739
+ if (!settings || !settings.hooks) {
740
+ console.log(' ⚪ No Claude Code settings with hooks: nothing to remove.');
741
+ } else {
742
+ let removed = 0;
743
+ for (const event of ['PreCompact', 'SessionStart']) {
744
+ const list = settings.hooks[event];
745
+ if (!Array.isArray(list)) continue;
746
+ const kept = [];
747
+ for (const entry of list) {
748
+ if (!entryIsOurs(entry)) { kept.push(entry); continue; }
749
+ const rest = entry.hooks.filter(h => !ours(h));
750
+ removed += entry.hooks.length - rest.length;
751
+ if (rest.length) kept.push({ ...entry, hooks: rest });
752
+ }
753
+ if (kept.length) settings.hooks[event] = kept; else delete settings.hooks[event];
754
+ }
755
+ // Put back what install replaced, unless an equal hook is already there.
756
+ let restored = 0;
757
+ try {
758
+ const rec = JSON.parse(fs.readFileSync(replacedPath, 'utf8'));
759
+ for (const { matcher, hook } of Array.isArray(rec.SessionStart) ? rec.SessionStart : []) {
760
+ const list = settings.hooks.SessionStart = settings.hooks.SessionStart || [];
761
+ if (JSON.stringify(list).includes(JSON.stringify(hook.command))) continue;
762
+ list.push(matcher !== undefined ? { matcher, hooks: [hook] } : { hooks: [hook] });
763
+ restored++;
764
+ }
765
+ } catch { /* nothing was replaced */ }
766
+ if (Object.keys(settings.hooks).length === 0) delete settings.hooks;
767
+ if (removed || restored) {
768
+ write(settings);
769
+ console.log(` ✅ Compact hooks removed (${removed}).${restored ? ` The install-boot SessionStart entry is back (${restored}).` : ''}`);
770
+ console.log(` ${settingsPath}`);
771
+ } else {
772
+ console.log(' ⚪ Compact hooks were not installed. Nothing changed.');
773
+ }
774
+ }
775
+ for (const f of [hookScript, replacedPath]) { try { fs.unlinkSync(f); } catch { /* not there */ } }
776
+ console.log(' Checkpoints already written stay in <brain>/checkpoints/ and expire after 7 days.');
777
+ return;
778
+ }
779
+
780
+ // — install —
781
+ if (settings === null && !fs.existsSync(join(homedir(), '.claude'))) {
782
+ console.log(' ⚪ ~/.claude not found: Claude Code is the only client with PreCompact, so nothing was wired.');
783
+ return;
784
+ }
785
+ const here = dirname(fileURLToPath(import.meta.url));
786
+ fs.mkdirSync(hookDir, { recursive: true });
787
+ fs.copyFileSync(join(here, '..', 'hooks', 'crbro-lifecycle.mjs'), hookScript);
788
+ settings = settings || {};
789
+ settings.hooks = settings.hooks || {};
790
+ const node = `node "${hookScript.split('\\').join('/')}"`;
791
+ let changed = false;
792
+
793
+ // SessionStart
794
+ const start = settings.hooks.SessionStart = settings.hooks.SessionStart || [];
795
+ if (start.some(entryIsOurs)) {
796
+ console.log(' ✅ SessionStart: already installed. Script refreshed.');
797
+ } else {
798
+ const replaced = [];
799
+ for (let i = start.length - 1; i >= 0; i--) {
800
+ const entry = start[i];
801
+ if (!Array.isArray(entry?.hooks) || !entry.hooks.some(isInstallBootHook)) continue;
802
+ for (const h of entry.hooks.filter(isInstallBootHook)) replaced.unshift({ matcher: entry.matcher, hook: h });
803
+ const rest = entry.hooks.filter(h => !isInstallBootHook(h));
804
+ if (rest.length) start[i] = { ...entry, hooks: rest }; else start.splice(i, 1);
805
+ }
806
+ // A hand-written CRBRO start (cat ~/.claude/crbro-session-start.txt…)
807
+ // stays, and ours stops printing the notice it already prints.
808
+ const handWritten = /crbro/i.test(JSON.stringify(start));
809
+ start.push({
810
+ matcher: 'startup|resume|clear|compact',
811
+ hooks: [{ type: 'command', command: `${node} session-start${handWritten ? ' --no-boot' : ''}`, timeout: 10, statusMessage: 'Loading CRBRO memory...' }],
812
+ });
813
+ if (replaced.length) fs.writeFileSync(replacedPath, JSON.stringify({ SessionStart: replaced }, null, 2), 'utf8');
814
+ changed = true;
815
+ console.log(` ✅ SessionStart: lifecycle hook added${replaced.length ? ', replacing the install-boot entry (same notice, plus the project line)' : ''}${handWritten ? '; your own CRBRO start hook is kept and the notice is not repeated' : ''}.`);
816
+ }
817
+
818
+ // PreCompact
819
+ const pre = settings.hooks.PreCompact = settings.hooks.PreCompact || [];
820
+ if (pre.some(entryIsOurs)) {
821
+ console.log(' ✅ PreCompact: already installed. Script refreshed.');
822
+ } else {
823
+ const handWritten = /crbro/i.test(JSON.stringify(pre));
824
+ pre.push({
825
+ hooks: [{ type: 'command', command: `${node} pre-compact${handWritten ? ' --no-reminder' : ''}`, timeout: 10, statusMessage: 'Saving a CRBRO checkpoint...' }],
826
+ });
827
+ changed = true;
828
+ console.log(` ✅ PreCompact: checkpoint hook added${handWritten ? '; your own CRBRO reminder is kept and not repeated' : ''}.`);
829
+ }
830
+
831
+ if (changed) {
832
+ write(settings);
833
+ console.log(` ${settingsPath}`);
834
+ console.log(' Undo with: npx crbro-memory uninstall-hooks --compact');
835
+ }
836
+ console.log(' Never blocks; checkpoints are redacted and expire after 7 days. New sessions pick it up.');
837
+ }).catch(e => { console.error(e); process.exit(1); });
838
+
839
+ } else if (command === 'uninstall-hooks') {
840
+ console.log(' Usage: npx crbro-memory uninstall-hooks --compact');
841
+ console.log(' (the guard and subagent hooks are removed by deleting their entry from ~/.claude/settings.json)');
842
+
616
843
  } else if (command === 'install-hooks' && process.argv.includes('--guard')) {
617
844
  // ─── Wire the PreToolUse guard into Claude Code (opt-in) ───────
618
845
  //
@@ -766,14 +993,13 @@ if (command === 'init') {
766
993
  // Only files that already exist are touched, and each one is merged, never
767
994
  // rewritten. Idempotent: a second run reports and changes nothing.
768
995
  import('fs').then(async fs => {
769
- const AVISO =
770
- 'CRBRO: call mcp__crbro__crbro_boot as your FIRST tool action, before answering, ' +
771
- 'unless this session already contains its result. Discover deferred CRBRO tools first if needed. ' +
772
- 'Apply the protocol_enforcement block it returns for the rest of the session.';
996
+ // One copy of the notice: the lifecycle hook prints the same text in its
997
+ // session-start mode, and `install-hooks --compact` swaps this entry for it.
998
+ const { BOOT_NOTICE: AVISO } = await import('../hooks/crbro-lifecycle.mjs');
773
999
 
774
1000
  // printf on a shell, Write-Output on Windows PowerShell. One line, no
775
1001
  // external file: a path stored in a hook goes stale on the next update.
776
- const cmdPosix = `printf '%s\\n' ${JSON.stringify(AVISO)}`;
1002
+ const cmdPosix = bootCommandPosix(AVISO);
777
1003
  const cmdWin = `powershell -NoProfile -Command ${JSON.stringify('Write-Output ' + JSON.stringify(AVISO))}`;
778
1004
  const MATCHER = 'startup|resume|clear|compact';
779
1005
 
@@ -1098,6 +1324,15 @@ if (command === 'init') {
1098
1324
  console.log(' npx crbro-memory install-hooks --guard Wire the PreToolUse hook (adds context, never blocks)');
1099
1325
  console.log(' npx crbro-memory guard "<command>" What it would say for a command · --rebuild writes the index');
1100
1326
  console.log('');
1327
+ console.log(' Compact without losing the thread (opt-in, Claude Code):');
1328
+ console.log(' npx crbro-memory install-hooks --compact PreCompact checkpoint + SessionStart that picks it back up');
1329
+ console.log(' npx crbro-memory uninstall-hooks --compact Remove both and put back what was replaced');
1330
+ console.log(' npx crbro-memory install-hooks --verify SHA-256 of the installed hooks against this package (read-only)');
1331
+ console.log('');
1332
+ console.log(' Looking back at Claude Code sessions (read-only; last 7 days unless --days N, 0 = all):');
1333
+ console.log(' npx crbro-memory usage [--session ID] [--project DIR] [--json] Tokens per model and session, subagents apart');
1334
+ console.log(' npx crbro-memory postmortem [--max N] [--json] Candidate lessons: corrections, failing tools, repeats');
1335
+ console.log('');
1101
1336
  console.log(' Daemon (opt-in): one process owns the brain for every client — one index, one model, one writer:');
1102
1337
  console.log(' npx crbro-memory daemon on | off Switch every client of this brain, the next time each starts');
1103
1338
  console.log(' npx crbro-memory daemon status Is it on, who is running, how much it holds');
@@ -1 +1 @@
1
- {"version":3,"file":"backup.d.ts","sourceRoot":"","sources":["../../src/engine/backup.ts"],"names":[],"mappings":"AA4BA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAKxC,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,YAAY,IAAI,CAAC;AAC9B,2EAA2E;AAC3E,eAAO,MAAM,uBAAuB,QAAsB,CAAC;AAO3D,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9F,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,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AAK,EAAE,UAAU,EACjB,IAAI,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,IAAI,CAAA;CAAO,GACrD,OAAO,CAAC,YAAY,CAAC,CA4CvB;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAUpE;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAkBxG;AAED,oFAAoF;AACpF,wBAAsB,eAAe,CACnC,KAAK,EAAE,UAAU,EACjB,IAAI,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,IAAI,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAA;CAAO,GAC/D,OAAO,CAAC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAe3D"}
@@ -43,7 +43,11 @@ exports.BACKUP_FORMAT = 1;
43
43
  exports.DEFAULT_KEEP = 7;
44
44
  /** consolidate makes one on its own when the newest is older than this. */
45
45
  exports.AUTO_BACKUP_INTERVAL_MS = 24 * 60 * 60 * 1000;
46
- const SKIP_TOP = new Set(['.quarantine', '.search', '.semantic', '.device-token', '.license-cache.json', '.locks', '.daemon']);
46
+ // checkpoints/ (2.7): the compaction checkpoints hold literal user requests,
47
+ // the task list, the folder and the remote. They expire after seven days and
48
+ // are rebuilt by the next compaction; a backup, often kept in a synced folder,
49
+ // would keep them forever.
50
+ const SKIP_TOP = new Set(['.quarantine', '.search', '.semantic', '.device-token', '.license-cache.json', '.locks', '.daemon', 'checkpoints']);
47
51
  const SKIP_ANYWHERE = new Set(['.git', 'node_modules']);
48
52
  const PREFIX = 'brain-';
49
53
  const SUFFIX = '.json.gz';
@@ -1 +1 @@
1
- {"version":3,"file":"backup.js","sourceRoot":"","sources":["../../src/engine/backup.ts"],"names":[],"mappings":";AAAA,oEAAoE;AACpE,mDAAmD;AACnD,EAAE;AACF,mEAAmE;AACnE,4EAA4E;AAC5E,2EAA2E;AAC3E,8DAA8D;AAC9D,EAAE;AACF,2DAA2D;AAC3D,2EAA2E;AAC3E,2EAA2E;AAC3E,sEAAsE;AACtE,gEAAgE;AAChE,2DAA2D;AAC3D,yEAAyE;AACzE,sDAAsD;AACtD,8EAA8E;AAC9E,kCAAkC;AAClC,EAAE;AACF,2EAA2E;AAC3E,oEAAoE;AACpE,6DAA6D;;;;;;AAsD7D,4CAWC;AA8BD,kCAkBC;AAED,oCA+CC;AAED,gCAUC;AAOD,sCAkBC;AAGD,0CAkBC;AA1ND,2BAAoC;AACpC,gDAAwB;AACxB,4CAAoB;AACpB,gDAAwB;AACxB,+BAAiC;AAGjC,MAAM,IAAI,GAAG,IAAA,gBAAS,EAAC,cAAI,CAAC,IAAI,CAAC,CAAC;AAClC,MAAM,MAAM,GAAG,IAAA,gBAAS,EAAC,cAAI,CAAC,MAAM,CAAC,CAAC;AAEzB,QAAA,aAAa,GAAG,CAAC,CAAC;AAClB,QAAA,YAAY,GAAG,CAAC,CAAC;AAC9B,2EAA2E;AAC9D,QAAA,uBAAuB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAE3D,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,qBAAqB,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;AAC/H,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;AACxD,MAAM,MAAM,GAAG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