memoryrouter-claude 2.2.0 → 2.2.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.
- package/README.md +1 -1
- package/lib/hook-runner.js +4 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -198,7 +198,7 @@ How it works, and the guarantees it keeps:
|
|
|
198
198
|
- **No local state.** Each batch is protected by a 15 minute server-side lease. If a run crashes or is interrupted, the lease expires and the memories return to the pool; re-running simply continues. `--dry-run` deliberately lets its lease expire.
|
|
199
199
|
- **Idempotent commits.** Re-committing a completed batch is success, never a duplicate.
|
|
200
200
|
|
|
201
|
-
When your unconsolidated memory crosses the server threshold, injected recall context includes a one-line
|
|
201
|
+
When your unconsolidated memory crosses the server threshold, injected recall context includes a one-line consolidation suggestion on every injection, and `status` shows the current debt. The MCP surface (`mcp install`) exposes the same capability as in-session tools once the server-side reflect tools ship there.
|
|
202
202
|
|
|
203
203
|
## Configuration
|
|
204
204
|
|
package/lib/hook-runner.js
CHANGED
|
@@ -20,7 +20,6 @@ const { deriveProjectIdentity, sessionIdFor } = require('./project');
|
|
|
20
20
|
const MAX_CONTEXT_CHARS = 9500;
|
|
21
21
|
const MAX_EVENT_CHARS = 100000;
|
|
22
22
|
const RECENT_TURN_LIMIT = 50;
|
|
23
|
-
const NUDGE_WINDOW_MS = 24 * 60 * 60 * 1000;
|
|
24
23
|
|
|
25
24
|
function debug(...args) {
|
|
26
25
|
if (process.env.MEMORYROUTER_DEBUG) console.error('[memoryrouter]', ...args);
|
|
@@ -112,35 +111,21 @@ function reflectionNudgeLine(results) {
|
|
|
112
111
|
const total = (Number.isFinite(rawTokens) ? rawTokens : 0)
|
|
113
112
|
+ (Number.isFinite(tier2Tokens) ? tier2Tokens : 0);
|
|
114
113
|
const amount = total > 0 ? `${Math.round(total / 1000)}k` : 'significant';
|
|
115
|
-
return `[MemoryRouter] Consolidation
|
|
114
|
+
return `[MemoryRouter] Consolidation suggested: ${amount} unconsolidated memory tokens. Run: npx memoryrouter-claude reflect`;
|
|
116
115
|
}
|
|
117
116
|
return null;
|
|
118
117
|
}
|
|
119
118
|
|
|
120
119
|
async function maybeAppendNudge(input, context, results, maxChars) {
|
|
121
120
|
// Rules (connectors spec section c): only on an already-emitted context,
|
|
122
|
-
// never a context solely for the nudge,
|
|
123
|
-
//
|
|
121
|
+
// never a context solely for the nudge, and always inside the existing
|
|
122
|
+
// char cap so memory content wins. Fires on every run with a suggestion.
|
|
124
123
|
if (!context) return context;
|
|
125
124
|
const line = reflectionNudgeLine(results);
|
|
126
125
|
if (!line) return context;
|
|
127
126
|
const cap = Math.max(1000, Math.min(MAX_CONTEXT_CHARS, Number(maxChars) || MAX_CONTEXT_CHARS));
|
|
128
127
|
if (context.length + line.length + 1 > cap) return context;
|
|
129
|
-
|
|
130
|
-
try {
|
|
131
|
-
await withStateLock(stateKeyFor(input), async (state) => {
|
|
132
|
-
const last = Number(state.lastNudgeAt) || 0;
|
|
133
|
-
if (Date.now() - last >= NUDGE_WINDOW_MS) {
|
|
134
|
-
state.lastNudgeAt = Date.now();
|
|
135
|
-
saveState(stateKeyFor(input), state);
|
|
136
|
-
allowed = true;
|
|
137
|
-
}
|
|
138
|
-
}, { timeoutMs: 1500 });
|
|
139
|
-
} catch (error) {
|
|
140
|
-
debug('nudge state failed open:', error.message);
|
|
141
|
-
return context;
|
|
142
|
-
}
|
|
143
|
-
return allowed ? `${context}\n${line}` : context;
|
|
128
|
+
return `${context}\n${line}`;
|
|
144
129
|
}
|
|
145
130
|
|
|
146
131
|
async function retrieveContext(input, key, prompt, eventName) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "memoryrouter-claude",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "Deterministic, project-scoped persistent memory for Claude Code: automatic hook retrieval/capture plus an optional OAuth MCP control surface.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "John Rood <john@memoryrouter.ai>",
|