memoryrouter-claude 2.6.1 → 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 +16 -0
- package/README.md +13 -41
- package/bin/cli.js +38 -15
- package/lib/config.js +6 -4
- package/lib/hook-runner.js +13 -20
- 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,21 @@
|
|
|
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
|
+
|
|
3
19
|
## 2.6.1 (2026-08-18)
|
|
4
20
|
|
|
5
21
|
### Added
|
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
|
|
|
@@ -256,10 +230,8 @@ When a vault is new (small, no completed import, not dismissed), injected recall
|
|
|
256
230
|
|
|
257
231
|
```json
|
|
258
232
|
{
|
|
259
|
-
"configVersion":
|
|
233
|
+
"configVersion": 3,
|
|
260
234
|
"apiKey": "mk_...",
|
|
261
|
-
"memoryScope": "project",
|
|
262
|
-
"includeGlobal": false,
|
|
263
235
|
"captureEnabled": true,
|
|
264
236
|
"contextLimit": 2000,
|
|
265
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
|
|
@@ -144,8 +145,7 @@ function parseArgs(argv) {
|
|
|
144
145
|
else if (value === '--user') args.scope = 'user';
|
|
145
146
|
else if (value === '--project') args.scope = 'project';
|
|
146
147
|
else if (value === '--local') args.scope = 'local';
|
|
147
|
-
else if (value === '--global') args.
|
|
148
|
-
else if (value === '--include-global') args.includeGlobal = true;
|
|
148
|
+
else if (value === '--global' || value === '--include-global') args.legacyScopeFlag = value;
|
|
149
149
|
else if (value === '--yes' || value === '-y') args.yes = true;
|
|
150
150
|
else if (value === '--purge') args.purge = true;
|
|
151
151
|
else if (value === '--tier') args.tier = parseInt(argv[++i], 10);
|
|
@@ -213,6 +213,15 @@ async function cmdInit(args) {
|
|
|
213
213
|
catch (err) { console.error('failed'); throw err; }
|
|
214
214
|
console.log(`✓ valid (${stats.totalVectors ?? stats.total_vectors ?? 0} memories in vault)`);
|
|
215
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
|
+
|
|
216
225
|
let scope = args.scope;
|
|
217
226
|
if (!scope && !args.yes) {
|
|
218
227
|
const answer = await ask(' Scope: [1] project, [2] local/private project, [3] user/all projects? [1]: ');
|
|
@@ -221,8 +230,7 @@ async function cmdInit(args) {
|
|
|
221
230
|
if (!scope) scope = 'project';
|
|
222
231
|
|
|
223
232
|
cfg.apiKey = key;
|
|
224
|
-
if (args.
|
|
225
|
-
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.`);
|
|
226
234
|
// Automatic subagent transcript capture was removed in v2.1: delegated and
|
|
227
235
|
// intermediate chatter is never part of the deterministic turn contract.
|
|
228
236
|
cfg.captureSubagents = false;
|
|
@@ -236,10 +244,10 @@ async function cmdInit(args) {
|
|
|
236
244
|
const project = deriveProjectIdentity({ cwd: process.cwd() }, cfg);
|
|
237
245
|
console.log(` ${migration.changed ? `Config migrated v${migration.fromVersion} → v${CONFIG_VERSION}; ` : ''}key saved → ${CONFIG_PATH} (0600)`);
|
|
238
246
|
console.log(` Hooks installed → ${file}`);
|
|
239
|
-
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})`);
|
|
240
248
|
console.log(`
|
|
241
249
|
Automatic engine:
|
|
242
|
-
SessionStart asynchronous
|
|
250
|
+
SessionStart asynchronous vault warmup
|
|
243
251
|
UserPromptSubmit one durable typed prompt, then separate semantic recall
|
|
244
252
|
Stop one durable final user-visible assistant response
|
|
245
253
|
StopFailure retry pending prompt only; no synthetic final
|
|
@@ -280,14 +288,20 @@ async function cmdStatus() {
|
|
|
280
288
|
const probe = await api.debtProbe(key);
|
|
281
289
|
if (probe.ok && probe.data) debt = probe.data.reflection || null;
|
|
282
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}`;
|
|
283
296
|
console.log(`
|
|
284
297
|
MemoryRouter status
|
|
285
298
|
───────────────────
|
|
286
299
|
Version: ${VERSION}
|
|
287
300
|
Config: v${cfg.configVersion}
|
|
288
301
|
Key: ${maskKey(key)} ✓ valid
|
|
289
|
-
Scope:
|
|
290
|
-
|
|
302
|
+
Scope: one vault for every session, repo and tool
|
|
303
|
+
OAuth: ${oauth}
|
|
304
|
+
Repo tag: ${project.id} (${project.source})
|
|
291
305
|
Memories: ${stats.totalVectors ?? stats.total_vectors ?? '?'} vectors
|
|
292
306
|
Tokens: ${stats.totalTokens ?? stats.total_tokens ?? '?'}
|
|
293
307
|
Storage: ${stats.storage ?? '?'}
|
|
@@ -440,7 +454,7 @@ async function cmdDoctor() {
|
|
|
440
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)' : ''}` });
|
|
441
455
|
|
|
442
456
|
const project = deriveProjectIdentity({ cwd: process.cwd() }, cfg);
|
|
443
|
-
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}` });
|
|
444
458
|
|
|
445
459
|
let hookCount = 0;
|
|
446
460
|
for (const scope of ['local', 'project', 'user']) {
|
|
@@ -462,6 +476,15 @@ async function cmdDoctor() {
|
|
|
462
476
|
const stats = await validateKey(key, 5000);
|
|
463
477
|
checks.push({ ok: true, name: 'API reachability', detail: `${maskKey(key)}; ${stats.totalVectors ?? stats.total_vectors ?? '?'} vectors` });
|
|
464
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
|
+
});
|
|
465
488
|
}
|
|
466
489
|
|
|
467
490
|
const mcp = claudeMcp(['get', 'memoryrouter'], 5000);
|
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,9 +92,7 @@ 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
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.";
|
|
@@ -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",
|