memoryrouter-claude 2.6.0 → 2.7.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.
- package/CHANGELOG.md +27 -0
- package/README.md +15 -41
- package/bin/cli.js +94 -17
- package/lib/config.js +6 -4
- package/lib/hook-runner.js +14 -21
- package/lib/project.js +11 -8
- package/lib/vault-binding.js +50 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.7.0 (2026-10-18)
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- One vault per user. The hooks no longer send a `session_id`, so recall and capture use the whole vault: every session, every repository, Codex (`memoryrouter-codex` 1.7.0+), and the hosted MCP share one memory. The `ccp_` repository tag stays as `capture_event.project_id` metadata.
|
|
8
|
+
- Recall is one `/prepare` request against the whole vault (the separate global leg is gone).
|
|
9
|
+
- Config v3 removes the retired `memoryScope` and `includeGlobal` settings; `--global` and `--include-global` are accepted and ignored with a note.
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- `init`, `status`, and `doctor` check the Memory Key against the vault selected in OAuth (`GET https://auth.memoryrouter.ai/v1/vault-binding`). A mismatch stops `init` before anything is written, with the selected vault named and the fix spelled out. Network failure fails open with a note.
|
|
14
|
+
|
|
15
|
+
### Migration
|
|
16
|
+
|
|
17
|
+
- Per-repository `ccp_` partitions written by 2.6.1 and earlier were moved into each vault's main memory server-side, with nothing lost or duplicated. Locally pending turns from 2.6.x are delivered to the main vault.
|
|
18
|
+
|
|
19
|
+
## 2.6.1 (2026-08-18)
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
- `inspect` CLI verb: lineage drill-down by memory id (`--id`, `--json`). Shows the tier, the source memories a reflection consolidated, and what a raw memory was consolidated into. Use repeatedly to walk from a tier 3 reflection through tier 2 to the raw memories underneath.
|
|
24
|
+
- `date-search` rows now print the memory id so inspect can be run directly on a result.
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- The verbatim-detail guidance in the injected hint and `date-search` help now teaches lineage drill-down: search `--tiers 3`, then inspect down through tier 2 to raw memories; direct `--tiers 1` remains the fallback when exact wording is known.
|
|
29
|
+
|
|
3
30
|
## 2.6.0 (2026-08-17)
|
|
4
31
|
|
|
5
32
|
### Changed
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# memoryrouter-claude
|
|
2
2
|
|
|
3
|
-
**Deterministic
|
|
3
|
+
**Deterministic persistent memory for Claude Code: one vault across every session, repo and tool.** Automatic hooks durably capture one user prompt and one final user-visible response per turn, retrieve relevant memory through a separate read-only request, and restore memory after compaction or resume.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
6
|
npx memoryrouter-claude init
|
|
@@ -42,13 +42,13 @@ Teams that deliberately want MemoryRouter tools loaded up front rather than defe
|
|
|
42
42
|
}
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
>
|
|
45
|
+
> The hooks and the remote MCP tools read and write the same whole vault. Per-memory deletion is available through the MCP `delete_memories` tool and the MemoryRouter dashboard.
|
|
46
46
|
|
|
47
47
|
## Lifecycle
|
|
48
48
|
|
|
49
49
|
| Claude Code event | Automatic action | Notes |
|
|
50
50
|
|---|---|---|
|
|
51
|
-
| `SessionStart` | Warm
|
|
51
|
+
| `SessionStart` | Warm the vault | Async hook; does not block startup |
|
|
52
52
|
| `UserPromptSubmit` | Create one local typed `user_prompt`, then deliver it and run semantic recall in parallel | Capture and `/prepare` recall are separate requests; recall stays read-only |
|
|
53
53
|
| `Stop` | Durably accept one typed `assistant_final` | Uses `last_assistant_message`; conservative transcript fallback accepts only a complete, main-chain, text-only final record |
|
|
54
54
|
| `StopFailure` | Retry an unacknowledged prompt | Marks the local turn failed; never invents or stores a final response |
|
|
@@ -66,13 +66,12 @@ The typed request is opt-in through `capture_event` on `POST /v1/memory/ingest`:
|
|
|
66
66
|
|
|
67
67
|
```json
|
|
68
68
|
{
|
|
69
|
-
"session_id": "ccp_project_partition",
|
|
70
69
|
"capture_event": {
|
|
71
70
|
"version": 1,
|
|
72
71
|
"source": "claude-code-hooks",
|
|
73
72
|
"event_type": "user_prompt",
|
|
74
73
|
"idempotency_key": "cce_stable_event_key",
|
|
75
|
-
"project_id": "
|
|
74
|
+
"project_id": "ccp_repository_tag",
|
|
76
75
|
"client_session_id": "claude-session-id",
|
|
77
76
|
"turn_id": "cct_stable_turn_id",
|
|
78
77
|
"occurred_at": 1785990000000,
|
|
@@ -106,51 +105,26 @@ Automatic capture never ingests intermediate assistant text, tool calls, command
|
|
|
106
105
|
- Local state is retained for 30 days by default. Server idempotency receipts are retained for 90 days, then bounded cleanup may remove completed receipts. Replaying an event after both retention windows is outside the retry guarantee.
|
|
107
106
|
- Read-only keys can recall but cannot durably accept capture. Pending local events are retained rather than falsely marked committed.
|
|
108
107
|
|
|
109
|
-
##
|
|
108
|
+
## One vault per user
|
|
110
109
|
|
|
111
|
-
|
|
110
|
+
Since **2.7.0**, automatic storage and recall send **no `session_id`**: every Claude Code session in every repository reads and writes your whole vault, the same vault Codex (`memoryrouter-codex` 1.7.0+), the hosted MCP, ChatGPT, and Claude use. A decision made in one repo or tool is recalled wherever it is relevant. Recall ranks by relevance to your prompt.
|
|
112
111
|
|
|
113
|
-
|
|
112
|
+
**Repository tag.** Each captured turn still carries an opaque `ccp_<24 hex>` repository tag in `capture_event.project_id` (metadata only, never a partition), derived in this order:
|
|
114
113
|
|
|
115
114
|
1. `MEMORYROUTER_PROJECT_ID` explicit environment override
|
|
116
115
|
2. `.memoryrouter.json` `projectId` / `project`
|
|
117
116
|
3. `~/.memoryrouter/config.json` `projectId` / `project`
|
|
118
117
|
4. normalized Git remote (`git@host:Org/Repo.git` and HTTPS normalize identically)
|
|
119
|
-
5. Git common directory
|
|
118
|
+
5. Git common directory
|
|
120
119
|
6. canonical `CLAUDE_PROJECT_DIR` / current directory for non-Git workspaces
|
|
121
120
|
|
|
122
|
-
|
|
121
|
+
Raw local paths, Git credentials, and remote URLs stay local.
|
|
123
122
|
|
|
124
|
-
|
|
123
|
+
**One user, one vault.** When you connect MemoryRouter over OAuth (`claude mcp login memoryrouter`, Codex, ChatGPT, Claude), pick the vault your hook key belongs to. `init` asks `https://auth.memoryrouter.ai/v1/vault-binding` whether the key is the vault your OAuth connections selected: a mismatch stops init before anything is written and names the selected vault; with no connection yet it tells you which vault to pick. `status` and `doctor` show the same check. The response never contains a key.
|
|
125
124
|
|
|
126
|
-
|
|
125
|
+
Create `.memoryrouterignore` at the project root, set `"enabled": false` in `.memoryrouter.json`, or export `MEMORYROUTER_DISABLE=1` to disable automatic recall/capture for a sensitive workspace without uninstalling hooks. For a strict boundary between two bodies of work, use a separate account and vault.
|
|
127
126
|
|
|
128
|
-
|
|
129
|
-
{
|
|
130
|
-
"projectId": "acme-api",
|
|
131
|
-
"memoryScope": "project",
|
|
132
|
-
"includeGlobal": false,
|
|
133
|
-
"captureEnabled": true
|
|
134
|
-
}
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
Create `.memoryrouterignore` at the project root, set `"enabled": false`, or export `MEMORYROUTER_DISABLE=1` to disable automatic recall/capture for a sensitive workspace without uninstalling hooks.
|
|
138
|
-
|
|
139
|
-
### Personal/global memory
|
|
140
|
-
|
|
141
|
-
Project memory is the secure default. To deliberately use one personal/global vault across projects:
|
|
142
|
-
|
|
143
|
-
```bash
|
|
144
|
-
npx memoryrouter-claude init --global --yes
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
To recall both isolated project memory and personal/global memory while continuing to write automatic captures only to the project:
|
|
148
|
-
|
|
149
|
-
```bash
|
|
150
|
-
npx memoryrouter-claude init --include-global --yes
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
Global recall is opt-in because it can intentionally surface facts across projects.
|
|
127
|
+
**Upgrading from 2.6.x.** Releases up to 2.6.1 used the repository tag as the `session_id`, a hard per-repository partition. When 2.7.0 shipped, those partitions were moved into each vault's main memory server-side (stored embeddings kept, exact repeats skipped, unflushed buffers saved), so old memories are recalled everywhere with nothing lost or duplicated. Turns that 2.6.x left pending locally are delivered to the main vault. The `--global` and `--include-global` flags and the `memoryScope` / `includeGlobal` settings are retired: init ignores the flags and config v3 removes the settings.
|
|
154
128
|
|
|
155
129
|
## Install, upgrade, and scopes
|
|
156
130
|
|
|
@@ -173,6 +147,7 @@ The key is stored only at `~/.memoryrouter/config.json` with mode `0600` in a mo
|
|
|
173
147
|
| `npx memoryrouter-claude doctor` | Diagnose config, permissions, hooks, project ID, pending capture, API, and MCP |
|
|
174
148
|
| `npx memoryrouter-claude status` | Show key, vault stats, consolidation debt, and active project scope |
|
|
175
149
|
| `npx memoryrouter-claude date-search` | Retrieve memories from a specific time window with tier and importance filters |
|
|
150
|
+
| `npx memoryrouter-claude inspect` | Drill down a memory's lineage by id: sources it consolidated and what it became |
|
|
176
151
|
| `npx memoryrouter-claude reflect` | Consolidate memories into reflections using your local `claude` CLI |
|
|
177
152
|
| `npx memoryrouter-claude mcp install` | Add the OAuth MCP manual surface with current Claude CLI syntax |
|
|
178
153
|
| `npx memoryrouter-claude mcp status` | Inspect MCP configuration |
|
|
@@ -189,6 +164,7 @@ npx memoryrouter-claude date-search --from 2026-08-10 #
|
|
|
189
164
|
npx memoryrouter-claude date-search --from 2026-08-01 --to 2026-08-15 --query "launches"
|
|
190
165
|
npx memoryrouter-claude date-search --from 2026-08-10 --tiers 2,3 --importance 7 # most important lately
|
|
191
166
|
npx memoryrouter-claude date-search --from 2026-08-10 --json # raw server response
|
|
167
|
+
npx memoryrouter-claude inspect --id <memory id> # lineage drill-down
|
|
192
168
|
```
|
|
193
169
|
|
|
194
170
|
Flags: `--from` (required, ISO 8601), `--to` (default now), `--query`, `--tiers 1,2,3` (only tiers 2 and 3 carry importance ratings), `--importance N` (minimum threshold 1 to 10; raw memories are excluded whenever this is set), `--max-tokens N` (1000 to 200000), `--json`. Truncated windows print a continuation cursor. The injected recall context also carries a one-line hint teaching Claude this exact pattern, so the agent can answer "what are the most important things we've done lately?" by itself.
|
|
@@ -254,10 +230,8 @@ When a vault is new (small, no completed import, not dismissed), injected recall
|
|
|
254
230
|
|
|
255
231
|
```json
|
|
256
232
|
{
|
|
257
|
-
"configVersion":
|
|
233
|
+
"configVersion": 3,
|
|
258
234
|
"apiKey": "mk_...",
|
|
259
|
-
"memoryScope": "project",
|
|
260
|
-
"includeGlobal": false,
|
|
261
235
|
"captureEnabled": true,
|
|
262
236
|
"contextLimit": 2000,
|
|
263
237
|
"density": "balanced",
|
package/bin/cli.js
CHANGED
|
@@ -24,6 +24,7 @@ const { runHook } = require('../lib/hook-runner');
|
|
|
24
24
|
const { runReflect } = require('../lib/reflect');
|
|
25
25
|
const { runAutoConsolidate } = require('../lib/auto');
|
|
26
26
|
const { runInstructions, runDismiss, runImportFile } = require('../lib/import');
|
|
27
|
+
const { checkVaultBinding, vaultLabel, VaultMismatchError } = require('../lib/vault-binding');
|
|
27
28
|
|
|
28
29
|
const PKG = require('../package.json');
|
|
29
30
|
const VERSION = PKG.version;
|
|
@@ -38,16 +39,16 @@ Usage:
|
|
|
38
39
|
--local ./.claude/settings.local.json (private project install)
|
|
39
40
|
--project ./.claude/settings.json (team/shareable; default)
|
|
40
41
|
--user ~/.claude/settings.json (all projects)
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
Memory is one vault for everything: every session and every repo (plus
|
|
43
|
+
Codex and the MemoryRouter MCP when connected with the same vault).
|
|
43
44
|
|
|
44
45
|
npx memoryrouter-claude doctor
|
|
45
|
-
Diagnose config migration, permissions, hooks,
|
|
46
|
-
|
|
46
|
+
Diagnose config migration, permissions, hooks, pending capture, API
|
|
47
|
+
reachability, OAuth vault match, and optional MCP configuration.
|
|
47
48
|
|
|
48
49
|
npx memoryrouter-claude status
|
|
49
|
-
Show key validity, vault stats, consolidation debt, and
|
|
50
|
-
|
|
50
|
+
Show key validity, vault stats, consolidation debt, and the current
|
|
51
|
+
repository tag.
|
|
51
52
|
|
|
52
53
|
npx memoryrouter-claude date-search --from <ISO> [--to <ISO>] [--query <text>] [--tiers 1,2,3] [--importance N] [--max-tokens N] [--json]
|
|
53
54
|
Retrieve memories from a specific time window. Use for questions like
|
|
@@ -61,7 +62,12 @@ Usage:
|
|
|
61
62
|
Specific lookups like 'find the decision about X': omit --tiers and
|
|
62
63
|
--importance; a high importance filter hides the specific detail you
|
|
63
64
|
are looking for. Specific events without raw noise: --tiers 2 or
|
|
64
|
-
--tiers 2,3. Exact verbatim detail:
|
|
65
|
+
--tiers 2,3. Exact verbatim detail: if the detail is not already in
|
|
66
|
+
context, drill down by lineage: search --tiers 3 to find the relevant
|
|
67
|
+
thread, then run inspect --id <memory id> to see the tier 2 reflections
|
|
68
|
+
it consolidated, then inspect those to reach the raw memories
|
|
69
|
+
underneath. Direct --tiers 1 search works when you know exact wording
|
|
70
|
+
to match. Mixing tiers is fine;
|
|
65
71
|
adjust the importance threshold to the question rather than always
|
|
66
72
|
setting it high. Only reflections (tiers 2 and 3) carry
|
|
67
73
|
importance ratings. Omit --query for a chronological review; include
|
|
@@ -78,6 +84,13 @@ Usage:
|
|
|
78
84
|
--max-tokens Token budget 1000 to 200000 (server default 50000)
|
|
79
85
|
--json Print the raw server response
|
|
80
86
|
|
|
87
|
+
npx memoryrouter-claude inspect --id <memory id> [--json]
|
|
88
|
+
Inspect a memory's consolidation lineage by id: its tier, the sources
|
|
89
|
+
it consolidated, and what it was consolidated into. Use repeatedly to
|
|
90
|
+
drill down from a high-level reflection to the tier 2 reflections and
|
|
91
|
+
raw memories beneath it. Memory ids come from date-search --json output
|
|
92
|
+
or a previous inspect.
|
|
93
|
+
|
|
81
94
|
npx memoryrouter-claude reflect [--tier 1|2] [--batches N|all] [--max-tokens N] [--dry-run]
|
|
82
95
|
Consolidate unconsolidated memories into reflections. Checks out a batch
|
|
83
96
|
under a 15 minute lease, runs YOUR local Claude Code (claude -p) with the
|
|
@@ -132,8 +145,7 @@ function parseArgs(argv) {
|
|
|
132
145
|
else if (value === '--user') args.scope = 'user';
|
|
133
146
|
else if (value === '--project') args.scope = 'project';
|
|
134
147
|
else if (value === '--local') args.scope = 'local';
|
|
135
|
-
else if (value === '--global') args.
|
|
136
|
-
else if (value === '--include-global') args.includeGlobal = true;
|
|
148
|
+
else if (value === '--global' || value === '--include-global') args.legacyScopeFlag = value;
|
|
137
149
|
else if (value === '--yes' || value === '-y') args.yes = true;
|
|
138
150
|
else if (value === '--purge') args.purge = true;
|
|
139
151
|
else if (value === '--tier') args.tier = parseInt(argv[++i], 10);
|
|
@@ -145,6 +157,7 @@ function parseArgs(argv) {
|
|
|
145
157
|
else if (value === '--file') args.file = argv[++i];
|
|
146
158
|
else if (value === '--dismiss') args.dismiss = true;
|
|
147
159
|
else if (value === '--final') args.final = true;
|
|
160
|
+
else if (value === '--id') args.id = argv[++i];
|
|
148
161
|
else if (value === '--from') args.from = argv[++i];
|
|
149
162
|
else if (value === '--to') args.to = argv[++i];
|
|
150
163
|
else if (value === '--query') args.query = argv[++i];
|
|
@@ -200,6 +213,15 @@ async function cmdInit(args) {
|
|
|
200
213
|
catch (err) { console.error('failed'); throw err; }
|
|
201
214
|
console.log(`✓ valid (${stats.totalVectors ?? stats.total_vectors ?? 0} memories in vault)`);
|
|
202
215
|
|
|
216
|
+
// One user = one vault: the key must be the vault selected in OAuth.
|
|
217
|
+
process.stdout.write(' Checking vault against your OAuth connection… ');
|
|
218
|
+
const binding = await checkVaultBinding(key);
|
|
219
|
+
if (binding.status === 'mismatch') { console.error('mismatch'); throw new VaultMismatchError(binding); }
|
|
220
|
+
if (binding.status === 'match') console.log(`✓ same vault ${vaultLabel(binding)}`);
|
|
221
|
+
else if (binding.status === 'mixed') console.log(`⚠ ${binding.message}`);
|
|
222
|
+
else if (binding.status === 'not-connected') console.log(`no OAuth connection yet; when you connect, select ${vaultLabel(binding)}`);
|
|
223
|
+
else console.log(`skipped (${binding.message})`);
|
|
224
|
+
|
|
203
225
|
let scope = args.scope;
|
|
204
226
|
if (!scope && !args.yes) {
|
|
205
227
|
const answer = await ask(' Scope: [1] project, [2] local/private project, [3] user/all projects? [1]: ');
|
|
@@ -208,8 +230,7 @@ async function cmdInit(args) {
|
|
|
208
230
|
if (!scope) scope = 'project';
|
|
209
231
|
|
|
210
232
|
cfg.apiKey = key;
|
|
211
|
-
if (args.
|
|
212
|
-
if (args.includeGlobal) cfg.includeGlobal = true;
|
|
233
|
+
if (args.legacyScopeFlag) console.log(` Note: ${args.legacyScopeFlag} is no longer needed. Every session and repo already uses your whole vault.`);
|
|
213
234
|
// Automatic subagent transcript capture was removed in v2.1: delegated and
|
|
214
235
|
// intermediate chatter is never part of the deterministic turn contract.
|
|
215
236
|
cfg.captureSubagents = false;
|
|
@@ -223,10 +244,10 @@ async function cmdInit(args) {
|
|
|
223
244
|
const project = deriveProjectIdentity({ cwd: process.cwd() }, cfg);
|
|
224
245
|
console.log(` ${migration.changed ? `Config migrated v${migration.fromVersion} → v${CONFIG_VERSION}; ` : ''}key saved → ${CONFIG_PATH} (0600)`);
|
|
225
246
|
console.log(` Hooks installed → ${file}`);
|
|
226
|
-
console.log(` Memory scope →
|
|
247
|
+
console.log(` Memory scope → your whole vault: every session, repo and tool (this repo is tagged ${project.id}, ${project.source})`);
|
|
227
248
|
console.log(`
|
|
228
249
|
Automatic engine:
|
|
229
|
-
SessionStart asynchronous
|
|
250
|
+
SessionStart asynchronous vault warmup
|
|
230
251
|
UserPromptSubmit one durable typed prompt, then separate semantic recall
|
|
231
252
|
Stop one durable final user-visible assistant response
|
|
232
253
|
StopFailure retry pending prompt only; no synthetic final
|
|
@@ -267,14 +288,20 @@ async function cmdStatus() {
|
|
|
267
288
|
const probe = await api.debtProbe(key);
|
|
268
289
|
if (probe.ok && probe.data) debt = probe.data.reflection || null;
|
|
269
290
|
} catch { /* status never fails because of the probe */ }
|
|
291
|
+
const binding = await checkVaultBinding(key, { timeoutMs: 5000 });
|
|
292
|
+
const oauth = binding.status === 'match' ? `same vault as your OAuth connection ${vaultLabel(binding)}`
|
|
293
|
+
: binding.status === 'not-connected' ? `no OAuth connection yet (select ${vaultLabel(binding)} when you connect)`
|
|
294
|
+
: binding.status === 'unknown' ? `not checked (${binding.message})`
|
|
295
|
+
: `${binding.status.toUpperCase()}: ${binding.message}`;
|
|
270
296
|
console.log(`
|
|
271
297
|
MemoryRouter status
|
|
272
298
|
───────────────────
|
|
273
299
|
Version: ${VERSION}
|
|
274
300
|
Config: v${cfg.configVersion}
|
|
275
301
|
Key: ${maskKey(key)} ✓ valid
|
|
276
|
-
Scope:
|
|
277
|
-
|
|
302
|
+
Scope: one vault for every session, repo and tool
|
|
303
|
+
OAuth: ${oauth}
|
|
304
|
+
Repo tag: ${project.id} (${project.source})
|
|
278
305
|
Memories: ${stats.totalVectors ?? stats.total_vectors ?? '?'} vectors
|
|
279
306
|
Tokens: ${stats.totalTokens ?? stats.total_tokens ?? '?'}
|
|
280
307
|
Storage: ${stats.storage ?? '?'}
|
|
@@ -336,7 +363,8 @@ async function cmdDateSearch(args) {
|
|
|
336
363
|
for (const row of rows) {
|
|
337
364
|
const tierTag = row.tier != null ? ` | tier ${row.tier}` : '';
|
|
338
365
|
const importanceTag = row.importance != null ? ` | importance ${row.importance}` : '';
|
|
339
|
-
|
|
366
|
+
const idTag = row.id ? ` | id ${row.id}` : '';
|
|
367
|
+
console.log(` [${row.date || 'unknown date'}${tierTag}${importanceTag}${idTag}]`);
|
|
340
368
|
console.log(` ${String(row.content || '').split('\n').join('\n ')}\n`);
|
|
341
369
|
}
|
|
342
370
|
if (data.truncated) {
|
|
@@ -426,7 +454,7 @@ async function cmdDoctor() {
|
|
|
426
454
|
checks.push({ ok: perms === null || (perms & 0o077) === 0, name: 'Credential permissions', detail: perms === null ? 'config not created' : `mode ${perms.toString(8)}${(perms & 0o077) ? ' (expected 600)' : ''}` });
|
|
427
455
|
|
|
428
456
|
const project = deriveProjectIdentity({ cwd: process.cwd() }, cfg);
|
|
429
|
-
checks.push({ ok: true, name: '
|
|
457
|
+
checks.push({ ok: true, name: 'Memory scope', detail: `whole vault (every session, repo and tool); captures tagged ${project.id} via ${project.source}` });
|
|
430
458
|
|
|
431
459
|
let hookCount = 0;
|
|
432
460
|
for (const scope of ['local', 'project', 'user']) {
|
|
@@ -448,6 +476,15 @@ async function cmdDoctor() {
|
|
|
448
476
|
const stats = await validateKey(key, 5000);
|
|
449
477
|
checks.push({ ok: true, name: 'API reachability', detail: `${maskKey(key)}; ${stats.totalVectors ?? stats.total_vectors ?? '?'} vectors` });
|
|
450
478
|
} catch (err) { checks.push({ ok: false, name: 'API reachability', detail: err.message }); }
|
|
479
|
+
const binding = await checkVaultBinding(key, { timeoutMs: 5000 });
|
|
480
|
+
checks.push({
|
|
481
|
+
ok: binding.status !== 'mismatch',
|
|
482
|
+
name: 'One vault (OAuth match)',
|
|
483
|
+
detail: binding.status === 'match' ? `hooks and OAuth use the same vault ${vaultLabel(binding)}`
|
|
484
|
+
: binding.status === 'not-connected' ? `no OAuth connection yet; select ${vaultLabel(binding)} when you connect`
|
|
485
|
+
: binding.status === 'unknown' ? `not checked (${binding.message})`
|
|
486
|
+
: binding.message,
|
|
487
|
+
});
|
|
451
488
|
}
|
|
452
489
|
|
|
453
490
|
const mcp = claudeMcp(['get', 'memoryrouter'], 5000);
|
|
@@ -503,6 +540,45 @@ async function cmdMcp(args) {
|
|
|
503
540
|
} else throw new Error(`Unknown mcp action: ${action}`);
|
|
504
541
|
}
|
|
505
542
|
|
|
543
|
+
async function cmdInspect(args) {
|
|
544
|
+
// Lineage drill-down. Use repeatedly to walk from a tier 3 reflection to
|
|
545
|
+
// the tier 2 reflections it consolidated and the raw memories underneath.
|
|
546
|
+
const key = getApiKey();
|
|
547
|
+
if (!key) throw new Error('No Memory Key configured. Run: npx memoryrouter-claude init');
|
|
548
|
+
const id = args.id || args._[1];
|
|
549
|
+
if (!id || typeof id !== 'string') throw new Error('--id <memory id> is required (from date-search --json or a previous inspect)');
|
|
550
|
+
const res = await api.inspect(key, String(id).trim(), { timeoutMs: 15000 });
|
|
551
|
+
if (!res.ok) {
|
|
552
|
+
if (res.status === 404) throw new Error('No memory with that id in the connected vault.');
|
|
553
|
+
const detail = res.data && res.data.error ? `: ${res.data.error}` : '';
|
|
554
|
+
throw new Error(`inspect failed (HTTP ${res.status})${detail}`);
|
|
555
|
+
}
|
|
556
|
+
const data = res.data || {};
|
|
557
|
+
if (args.json) {
|
|
558
|
+
console.log(JSON.stringify(data, null, 2));
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
console.log(`\n Memory ${data.memory_id || id} | tier ${data.tier != null ? data.tier : 'unknown'}`);
|
|
562
|
+
if (data.covers && (data.covers.from || data.covers.to)) {
|
|
563
|
+
console.log(` Covers ${data.covers.from || 'unknown'} to ${data.covers.to || 'unknown'}`);
|
|
564
|
+
}
|
|
565
|
+
const sources = Array.isArray(data.sources) ? data.sources : [];
|
|
566
|
+
if (sources.length) {
|
|
567
|
+
console.log(`\n Consolidated from ${sources.length} source memories:`);
|
|
568
|
+
for (const src of sources) {
|
|
569
|
+
const tierTag = src.tier != null ? ` | tier ${src.tier}` : '';
|
|
570
|
+
console.log(` [id ${src.id}${tierTag}]`);
|
|
571
|
+
console.log(` ${String(src.content || '').split('\n').join('\n ')}\n`);
|
|
572
|
+
}
|
|
573
|
+
} else {
|
|
574
|
+
console.log(' No sources: this is a raw memory or an unconsolidated row.');
|
|
575
|
+
}
|
|
576
|
+
const into = Array.isArray(data.consolidated_into) ? data.consolidated_into : [];
|
|
577
|
+
if (into.length) {
|
|
578
|
+
console.log(` Consolidated into: ${into.join(', ')}`);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
|
|
506
582
|
async function main() {
|
|
507
583
|
const args = parseArgs(process.argv.slice(2));
|
|
508
584
|
const cmd = args._[0];
|
|
@@ -512,6 +588,7 @@ async function main() {
|
|
|
512
588
|
case 'init': return cmdInit(args);
|
|
513
589
|
case 'status': return cmdStatus();
|
|
514
590
|
case 'date-search': return cmdDateSearch(args);
|
|
591
|
+
case 'inspect': return cmdInspect(args);
|
|
515
592
|
case 'reflect': return cmdReflect(args);
|
|
516
593
|
case 'reflect-auto': {
|
|
517
594
|
// Internal entrypoint for the detached automatic consolidation run
|
package/lib/config.js
CHANGED
|
@@ -5,7 +5,7 @@ const fs = require('fs');
|
|
|
5
5
|
const path = require('path');
|
|
6
6
|
const os = require('os');
|
|
7
7
|
|
|
8
|
-
const CONFIG_VERSION =
|
|
8
|
+
const CONFIG_VERSION = 3;
|
|
9
9
|
const CONFIG_DIR = process.env.MEMORYROUTER_CONFIG_DIR || path.join(os.homedir(), '.memoryrouter');
|
|
10
10
|
const CONFIG_PATH = path.join(CONFIG_DIR, 'config.json');
|
|
11
11
|
const STATE_DIR = path.join(CONFIG_DIR, 'state');
|
|
@@ -39,13 +39,15 @@ function migrateConfig(input) {
|
|
|
39
39
|
const fromVersion = Number.isInteger(cfg.configVersion) ? cfg.configVersion : 1;
|
|
40
40
|
if (fromVersion < 2) {
|
|
41
41
|
// v1 already used safe flat keys. Preserve every unknown/user key and add
|
|
42
|
-
//
|
|
43
|
-
if (!cfg.memoryScope) cfg.memoryScope = 'project';
|
|
44
|
-
if (cfg.includeGlobal === undefined) cfg.includeGlobal = false;
|
|
42
|
+
// lifecycle defaults rather than replacing the object.
|
|
45
43
|
if (cfg.captureSubagents === undefined) cfg.captureSubagents = false;
|
|
46
44
|
if (cfg.captureEnabled === undefined) cfg.captureEnabled = true;
|
|
47
45
|
if (cfg.stateTtlDays === undefined) cfg.stateTtlDays = DEFAULT_STATE_TTL_DAYS;
|
|
48
46
|
}
|
|
47
|
+
// v3 (2.7.0): one vault per user. The per-repo/global scoping switches no
|
|
48
|
+
// longer exist, so they are removed rather than left looking meaningful.
|
|
49
|
+
delete cfg.memoryScope;
|
|
50
|
+
delete cfg.includeGlobal;
|
|
49
51
|
cfg.configVersion = CONFIG_VERSION;
|
|
50
52
|
return { config: cfg, fromVersion, changed: fromVersion !== CONFIG_VERSION };
|
|
51
53
|
}
|
package/lib/hook-runner.js
CHANGED
|
@@ -16,7 +16,7 @@ const {
|
|
|
16
16
|
const api = require('./api');
|
|
17
17
|
const { maybeSpawnAutoConsolidate } = require('./auto');
|
|
18
18
|
const { hash, compactText, cleanText, finalAssistantFromTranscript } = require('./transcript');
|
|
19
|
-
const { deriveProjectIdentity
|
|
19
|
+
const { deriveProjectIdentity } = require('./project');
|
|
20
20
|
|
|
21
21
|
const MAX_CONTEXT_CHARS = 9500;
|
|
22
22
|
const MAX_EVENT_CHARS = 100000;
|
|
@@ -73,9 +73,9 @@ function transcriptSize(transcriptPath) {
|
|
|
73
73
|
try { return fs.statSync(transcriptPath).size; } catch { return null; }
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
// One vault per user: recall, capture, and warmup never send a session_id
|
|
77
|
+
// (the API treats session_id as a hard vault partition). The repository id is
|
|
78
|
+
// metadata only and travels inside capture_event.project_id.
|
|
79
79
|
|
|
80
80
|
function mergeContexts(results, identity, maxChars) {
|
|
81
81
|
const sections = [];
|
|
@@ -92,12 +92,10 @@ function mergeContexts(results, identity, maxChars) {
|
|
|
92
92
|
if (unique.length) sections.push(`${item.label} memory:\n${unique.join('\n')}`);
|
|
93
93
|
}
|
|
94
94
|
if (!sections.length) return '';
|
|
95
|
-
const header = identity.
|
|
96
|
-
? 'MemoryRouter recall (personal/global scope)'
|
|
97
|
-
: `MemoryRouter recall (project scope ${identity.id})`;
|
|
95
|
+
const header = `MemoryRouter recall (your vault: one memory across every session, repo and tool; current repo ${identity.id})`;
|
|
98
96
|
// One-line teaching hint: time-window and importance questions have a
|
|
99
97
|
// dedicated retrieval path the model cannot reach through /prepare.
|
|
100
|
-
const hint = "For time-window questions like 'what happened last week' or 'most important things lately', run: npx memoryrouter-claude date-search --from <ISO>. Tier guide: tier 3 holds the highest-level consolidated reflections (identity, principles, what matters most), tier 2 holds reflections of specific meaningful events, tier 1 holds raw verbatim memories. Match filters to the question: broad 'most important' questions use --tiers 3 --importance 8; big-picture overviews use --tiers 3 with no importance filter; specific lookups omit --tiers and --importance (a high importance filter hides the specific detail); specific events without raw noise use --tiers 2 or --tiers 2,3. Mixing tiers is fine; only reflections carry ratings. Resolve relative phrases to concrete ISO dates first.";
|
|
98
|
+
const hint = "For time-window questions like 'what happened last week' or 'most important things lately', run: npx memoryrouter-claude date-search --from <ISO>. Tier guide: tier 3 holds the highest-level consolidated reflections (identity, principles, what matters most), tier 2 holds reflections of specific meaningful events, tier 1 holds raw verbatim memories. Match filters to the question: broad 'most important' questions use --tiers 3 --importance 8; big-picture overviews use --tiers 3 with no importance filter; specific lookups omit --tiers and --importance (a high importance filter hides the specific detail); specific events without raw noise use --tiers 2 or --tiers 2,3; for exact verbatim detail not already in context, search --tiers 3 then drill down by lineage with npx memoryrouter-claude inspect --id <memory id> through tier 2 to the raw memories (direct --tiers 1 works when you know exact wording). Mixing tiers is fine; only reflections carry ratings. Resolve relative phrases to concrete ISO dates first.";
|
|
101
99
|
return compactText(`${header}\n${hint}\n${sections.join('\n\n')}`, maxChars);
|
|
102
100
|
}
|
|
103
101
|
|
|
@@ -153,8 +151,6 @@ async function retrieveContext(input, key, prompt, eventName) {
|
|
|
153
151
|
if (disabled(cfg, identity)) return;
|
|
154
152
|
const contextLimit = cfg.contextLimit;
|
|
155
153
|
const density = cfg.density;
|
|
156
|
-
const requests = [];
|
|
157
|
-
|
|
158
154
|
const toResult = (label) => (res) => ({
|
|
159
155
|
label,
|
|
160
156
|
context: res.ok && res.data && res.data.context,
|
|
@@ -162,14 +158,10 @@ async function retrieveContext(input, key, prompt, eventName) {
|
|
|
162
158
|
importState: res.ok && res.data && res.data.import,
|
|
163
159
|
});
|
|
164
160
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
if (identity.includeGlobal) {
|
|
170
|
-
requests.push(api.prepare(key, prompt, undefined, { timeoutMs: 5500, contextLimit, density }).then(toResult('Global')));
|
|
171
|
-
}
|
|
172
|
-
}
|
|
161
|
+
// One read-only /prepare against the whole vault (no session_id).
|
|
162
|
+
const requests = [
|
|
163
|
+
api.prepare(key, prompt, undefined, { timeoutMs: 5500, contextLimit, density }).then(toResult('Vault')),
|
|
164
|
+
];
|
|
173
165
|
|
|
174
166
|
const settled = await Promise.allSettled(requests);
|
|
175
167
|
const results = settled.filter((r) => r.status === 'fulfilled').map((r) => r.value);
|
|
@@ -234,7 +226,6 @@ function newTurn(state, input, identity, prompt) {
|
|
|
234
226
|
turnId,
|
|
235
227
|
projectId: identity.id,
|
|
236
228
|
clientSessionId: sessionId,
|
|
237
|
-
scopeSessionId: scopeSession(identity),
|
|
238
229
|
prompt,
|
|
239
230
|
promptHash: hash(prompt),
|
|
240
231
|
status: 'open',
|
|
@@ -309,7 +300,9 @@ async function sendTurnEvent(key, stateKey, state, turn, field, timeoutMs = 1000
|
|
|
309
300
|
if (!event || event.status === 'accepted' || event.status === 'conflict') return event && event.status === 'accepted';
|
|
310
301
|
let res;
|
|
311
302
|
try {
|
|
312
|
-
|
|
303
|
+
// Never send a session_id, including for turns written to local state by
|
|
304
|
+
// pre-2.7 releases (their scopeSessionId was the per-repo partition).
|
|
305
|
+
res = await api.ingestEvent(key, captureEventPayload(turn, event), undefined, {
|
|
313
306
|
timeoutMs,
|
|
314
307
|
model: 'claude-code-hook',
|
|
315
308
|
});
|
|
@@ -540,7 +533,7 @@ async function handleSessionStart(input, key) {
|
|
|
540
533
|
saveState(stateKey, state);
|
|
541
534
|
} catch (e) { debug('session state failed:', e.message); }
|
|
542
535
|
try {
|
|
543
|
-
await api.warmup(key,
|
|
536
|
+
await api.warmup(key, undefined, { timeoutMs: 8000 });
|
|
544
537
|
} catch (e) { debug('warmup failed:', e.message); }
|
|
545
538
|
}
|
|
546
539
|
|
package/lib/project.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
// Deterministic project/workspace identity for Claude Code hooks.
|
|
3
3
|
// Only the opaque hash is sent to MemoryRouter; local paths and remotes stay local.
|
|
4
|
+
//
|
|
5
|
+
// Since 2.7.0 MemoryRouter is one vault per user: every session in every
|
|
6
|
+
// repository (and Codex, the hosted MCP, ChatGPT, Claude) reads and writes the
|
|
7
|
+
// same core vault, so the hooks send NO session_id. The `ccp_` id below is now
|
|
8
|
+
// metadata only: it rides in capture_event.project_id and labels recall. Before
|
|
9
|
+
// 2.7.0 it was also the session_id, a hard per-repo vault partition; those
|
|
10
|
+
// per-repo piles were merged into each user's core vault server-side.
|
|
4
11
|
|
|
5
12
|
const fs = require('fs');
|
|
6
13
|
const path = require('path');
|
|
@@ -118,10 +125,6 @@ function deriveProjectIdentity(input = {}, config = {}) {
|
|
|
118
125
|
const digest = hashIdentity(canonical);
|
|
119
126
|
const id = `ccp_${digest.slice(0, 24)}`;
|
|
120
127
|
const localKey = `local_${hashIdentity(`local:${root}`).slice(0, 16)}`;
|
|
121
|
-
const configuredScope = projectConfig.memoryScope || projectConfig.scope || config.memoryScope || config.scope;
|
|
122
|
-
const memoryScope = configuredScope === 'global' ? 'global' : 'project';
|
|
123
|
-
const includeGlobal = projectConfig.includeGlobal === true || config.includeGlobal === true;
|
|
124
|
-
|
|
125
128
|
return {
|
|
126
129
|
id,
|
|
127
130
|
source,
|
|
@@ -130,15 +133,15 @@ function deriveProjectIdentity(input = {}, config = {}) {
|
|
|
130
133
|
remote,
|
|
131
134
|
localKey,
|
|
132
135
|
label: path.basename(root) || 'workspace',
|
|
133
|
-
memoryScope,
|
|
134
|
-
includeGlobal,
|
|
135
136
|
ignored,
|
|
136
137
|
projectConfig,
|
|
137
138
|
};
|
|
138
139
|
}
|
|
139
140
|
|
|
140
|
-
|
|
141
|
-
|
|
141
|
+
// The MemoryRouter session_id (vault partition) the hooks use: always
|
|
142
|
+
// undefined. One vault per user, no per-session or per-repo walls.
|
|
143
|
+
function sessionIdFor() {
|
|
144
|
+
return undefined;
|
|
142
145
|
}
|
|
143
146
|
|
|
144
147
|
module.exports = {
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// One user = one vault. The vault a user selects when connecting MemoryRouter
|
|
3
|
+
// over OAuth (the MCP login used by Claude Code, Codex, ChatGPT, Claude) must
|
|
4
|
+
// be the same vault the automatic hooks write to with the Memory Key. The auth
|
|
5
|
+
// server compares the two: GET /v1/vault-binding with the Memory Key as Bearer.
|
|
6
|
+
// The response never contains a key, only opaque vault refs and names.
|
|
7
|
+
|
|
8
|
+
const AUTH_BASE = 'https://auth.memoryrouter.ai';
|
|
9
|
+
|
|
10
|
+
function authBase(env = process.env) {
|
|
11
|
+
return String(env.MEMORYROUTER_AUTH_BASE || AUTH_BASE).replace(/\/+$/, '');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async function checkVaultBinding(key, options = {}) {
|
|
15
|
+
const env = options.env || process.env;
|
|
16
|
+
const controller = new AbortController();
|
|
17
|
+
const timer = setTimeout(() => controller.abort(), options.timeoutMs || 6000);
|
|
18
|
+
try {
|
|
19
|
+
const res = await fetch(`${authBase(env)}/v1/vault-binding`, {
|
|
20
|
+
headers: { Authorization: `Bearer ${key}`, Accept: 'application/json' },
|
|
21
|
+
signal: controller.signal,
|
|
22
|
+
});
|
|
23
|
+
let data = null;
|
|
24
|
+
try { data = await res.json(); } catch { /* not json */ }
|
|
25
|
+
if (!res.ok || !data || typeof data.status !== 'string') {
|
|
26
|
+
return { status: 'unknown', httpStatus: res.status, message: `vault check unavailable (HTTP ${res.status})` };
|
|
27
|
+
}
|
|
28
|
+
return data;
|
|
29
|
+
} catch (err) {
|
|
30
|
+
return { status: 'unknown', message: `vault check unavailable (${err && err.name === 'AbortError' ? 'timeout' : (err && err.message) || 'network error'})` };
|
|
31
|
+
} finally {
|
|
32
|
+
clearTimeout(timer);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function vaultLabel(binding) {
|
|
37
|
+
const vault = binding && binding.vault;
|
|
38
|
+
if (!vault) return 'this vault';
|
|
39
|
+
return vault.name ? `"${vault.name}" (${vault.ref})` : vault.ref;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
class VaultMismatchError extends Error {
|
|
43
|
+
constructor(binding) {
|
|
44
|
+
super(`${binding.message || 'This Memory Key is not the vault you selected in OAuth.'}\n Nothing was installed. Run init again with the Memory Key of the vault you selected (app.memoryrouter.ai), or reconnect MemoryRouter and select ${vaultLabel(binding)}.`);
|
|
45
|
+
this.name = 'VaultMismatchError';
|
|
46
|
+
this.binding = binding;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
module.exports = { AUTH_BASE, authBase, checkVaultBinding, vaultLabel, VaultMismatchError };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "memoryrouter-claude",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "Deterministic
|
|
3
|
+
"version": "2.7.0",
|
|
4
|
+
"description": "Deterministic persistent memory for Claude Code: one MemoryRouter vault shared by every session, repo and tool, with automatic hook retrieval/capture plus an optional OAuth MCP control surface.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "John Rood <john@memoryrouter.ai>",
|
|
7
7
|
"homepage": "https://memoryrouter.ai/claude-code",
|