claude-mem-lite 6.35.1 → 6.35.2
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.
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"plugins": [
|
|
10
10
|
{
|
|
11
11
|
"name": "claude-mem-lite",
|
|
12
|
-
"version": "6.35.
|
|
12
|
+
"version": "6.35.2",
|
|
13
13
|
"source": "./",
|
|
14
14
|
"homepage": "https://github.com/sdsrss/claude-mem-lite",
|
|
15
15
|
"description": "Persistent long-term memory for Claude Code via MCP — captures coding decisions, bugfixes, and context across sessions. FTS5 BM25 keyword search with episode batching. Single SQLite DB, no external services. A lighter, lower-cost alternative to claude-mem (episode batching + a smaller model; cost savings are an internal estimate, not a measured benchmark)."
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-mem-lite",
|
|
3
|
-
"version": "6.35.
|
|
3
|
+
"version": "6.35.2",
|
|
4
4
|
"description": "Persistent long-term memory for Claude Code via MCP — captures coding decisions, bugfixes, and context across sessions. FTS5 BM25 keyword search with episode batching. Single SQLite DB, no external services. A lighter, lower-cost alternative to claude-mem (episode batching + a smaller model; cost savings are an internal estimate, not a measured benchmark).",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "sdsrss"
|
package/lib/persist-reminder.mjs
CHANGED
|
@@ -106,13 +106,16 @@ export function deliberatePersistenceIn(entry) {
|
|
|
106
106
|
|
|
107
107
|
/**
|
|
108
108
|
* The G3 gate: finalization signal present AND zero deliberate persistence.
|
|
109
|
-
* @param {{prompts: string[], persistenceCount
|
|
110
|
-
* session's countDeliberatePersistence
|
|
109
|
+
* @param {{prompts: string[], persistenceCount?: number, transcriptPath?: string}} input
|
|
110
|
+
* persistenceCount is the session's countDeliberatePersistence. Without it the count is taken
|
|
111
|
+
* from transcriptPath: v6.35.0's hook.mjs passes that, and an update swaps this file first.
|
|
111
112
|
* @returns {{fire: boolean, signal: string|null}}
|
|
112
113
|
*/
|
|
113
|
-
export function detectUnpersistedDecision({ prompts, persistenceCount }) {
|
|
114
|
+
export function detectUnpersistedDecision({ prompts, persistenceCount, transcriptPath }) {
|
|
114
115
|
const signal = detectFinalization(prompts);
|
|
115
116
|
if (!signal) return { fire: false, signal: null };
|
|
116
|
-
|
|
117
|
+
const count =
|
|
118
|
+
typeof persistenceCount === 'number' ? persistenceCount : countDeliberatePersistence(transcriptPath);
|
|
119
|
+
if (count > 0) return { fire: false, signal };
|
|
117
120
|
return { fire: true, signal };
|
|
118
121
|
}
|
|
@@ -12,12 +12,16 @@
|
|
|
12
12
|
// `maxBytes` over all files (a line is taken whole, and reads go in 4 MiB chunks), so a
|
|
13
13
|
// transcript first seen larger than that is caught up over several Stops; until it is,
|
|
14
14
|
// `complete` is false and the caller writes nothing, because a cited set read from part of
|
|
15
|
-
// the session would decide "uncited" for ids the rest of it cites.
|
|
15
|
+
// the session would decide "uncited" for ids the rest of it cites. Catching up needs the next
|
|
16
|
+
// call to resume from this one's state. A call whose state cannot be saved still stops at the
|
|
17
|
+
// budget, which is what keeps Stop inside its hook timeout.
|
|
16
18
|
//
|
|
17
19
|
// The saved state is used only when it still describes the file: same inode, not longer than
|
|
18
|
-
// the file, the same first and last 4 KiB before its offset,
|
|
19
|
-
//
|
|
20
|
-
// Otherwise the file is read again from its first
|
|
20
|
+
// the file, the same first and last 4 KiB before its offset, written by this release of the
|
|
21
|
+
// code (a release that changes a scanner's rule invalidates every saved state), and holding
|
|
22
|
+
// accumulators of the shapes this code builds. Otherwise the file is read again from its first
|
|
23
|
+
// byte. Each release keeps its state under its own name, so two installed releases running
|
|
24
|
+
// Stop on one session (a plugin registered twice during an update) do not reset each other.
|
|
21
25
|
|
|
22
26
|
import { closeSync, constants, fstatSync, openSync, readFileSync, readSync } from 'fs';
|
|
23
27
|
import { createHash } from 'crypto';
|
|
@@ -112,43 +116,59 @@ const SUBAGENT_KINDS = {
|
|
|
112
116
|
*/
|
|
113
117
|
export function digestTranscript(transcriptPath, { runtimeDir, maxBytes = DIGEST_BYTES_PER_STOP } = {}) {
|
|
114
118
|
const code = digestCodeIdentity();
|
|
115
|
-
const statePath = runtimeDir && code ? join(runtimeDir, digestFileName(transcriptPath)) : null;
|
|
119
|
+
const statePath = runtimeDir && code ? join(runtimeDir, digestFileName(transcriptPath, code)) : null;
|
|
116
120
|
const saved = statePath ? loadState(statePath, code, transcriptPath) : null;
|
|
117
|
-
const budget = { left: maxBytes };
|
|
118
121
|
const buf = Buffer.allocUnsafe(READ_CHUNK);
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
files.main = main.rec;
|
|
124
|
-
if (!main.done) complete = false;
|
|
122
|
+
const pass = digestPass(transcriptPath, saved?.files, { left: maxBytes }, buf);
|
|
123
|
+
saveState(statePath, code, transcriptPath, pass.files);
|
|
124
|
+
return { complete: pass.complete, main: pass.files.main.acc, subagents: pass.subagents };
|
|
125
|
+
}
|
|
125
126
|
|
|
127
|
+
/**
|
|
128
|
+
* One read over the transcript and its subagent files, resuming each from its record in `prev`.
|
|
129
|
+
* @returns {{complete: boolean, files: object, subagents: object[]}}
|
|
130
|
+
*/
|
|
131
|
+
function digestPass(transcriptPath, prev, budget, buf) {
|
|
132
|
+
const main = advance(transcriptPath, prev?.main, MAIN_KINDS, budget, buf);
|
|
133
|
+
const files = { main: main.rec };
|
|
134
|
+
let complete = main.done;
|
|
126
135
|
const subagents = [];
|
|
127
136
|
for (const p of findSubagentTranscripts(transcriptPath)) {
|
|
128
137
|
const key = `subagents/${basename(p)}`;
|
|
129
|
-
|
|
138
|
+
let r;
|
|
139
|
+
try {
|
|
140
|
+
r = advance(p, prev?.[key], SUBAGENT_KINDS, budget, buf);
|
|
141
|
+
} catch {
|
|
142
|
+
// D#854 F10: a record one of the subagent rules cannot read. The file adds nothing and
|
|
143
|
+
// keeps no record, and the main results are still written. v6.35.0 did the same for the
|
|
144
|
+
// whole subagent face.
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
130
147
|
files[key] = r.rec;
|
|
131
148
|
if (!r.done) complete = false;
|
|
132
149
|
subagents.push(r.rec.acc);
|
|
133
150
|
}
|
|
151
|
+
return { complete, files, subagents };
|
|
152
|
+
}
|
|
134
153
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
)
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
154
|
+
/** Keep `files` for the next call; a state that cannot be written is skipped. */
|
|
155
|
+
function saveState(statePath, code, transcriptPath, files) {
|
|
156
|
+
if (!statePath) return;
|
|
157
|
+
try {
|
|
158
|
+
atomicWriteFileSync(
|
|
159
|
+
statePath,
|
|
160
|
+
JSON.stringify({ v: DIGEST_FORMAT, code, path: transcriptPath, files }, toJson),
|
|
161
|
+
{ mode: 0o600 },
|
|
162
|
+
);
|
|
163
|
+
} catch {
|
|
164
|
+
/* this call's progress is not kept */
|
|
145
165
|
}
|
|
146
|
-
return { complete, main: main.rec.acc, subagents };
|
|
147
166
|
}
|
|
148
167
|
|
|
149
|
-
/** The state file's name for one transcript path (in the runtime dir). */
|
|
150
|
-
export function digestFileName(transcriptPath) {
|
|
151
|
-
|
|
168
|
+
/** The state file's name for one transcript path, as kept by one release of the code (in the runtime dir). */
|
|
169
|
+
export function digestFileName(transcriptPath, code = digestCodeIdentity()) {
|
|
170
|
+
const key = `${code}\n${transcriptPath}`;
|
|
171
|
+
return `${DIGEST_FILE_PREFIX}${createHash('sha256').update(key).digest('hex').slice(0, 16)}.json`;
|
|
152
172
|
}
|
|
153
173
|
|
|
154
174
|
let codeIdentity;
|
|
@@ -166,12 +186,18 @@ function digestCodeIdentity() {
|
|
|
166
186
|
}
|
|
167
187
|
|
|
168
188
|
function loadState(statePath, code, transcriptPath) {
|
|
189
|
+
let fd;
|
|
169
190
|
try {
|
|
170
|
-
|
|
191
|
+
// As for the transcript in advance(): a FIFO at this path would block a plain open (D#854
|
|
192
|
+
// F9). Opened this way it reads as empty, or throws EAGAIN while a writer holds it open.
|
|
193
|
+
fd = openSync(statePath, constants.O_RDONLY | (constants.O_NONBLOCK ?? 0));
|
|
194
|
+
const s = JSON.parse(readFileSync(fd, 'utf8'), fromJson);
|
|
171
195
|
if (s?.v !== DIGEST_FORMAT || s.code !== code || s.path !== transcriptPath) return null;
|
|
172
196
|
return s && typeof s.files === 'object' ? s : null;
|
|
173
197
|
} catch {
|
|
174
198
|
return null;
|
|
199
|
+
} finally {
|
|
200
|
+
if (fd !== undefined) closeSync(fd);
|
|
175
201
|
}
|
|
176
202
|
}
|
|
177
203
|
|
|
@@ -223,7 +249,7 @@ function advance(path, saved, kinds, budget, buf) {
|
|
|
223
249
|
*/
|
|
224
250
|
function continues(fd, st, saved, kinds) {
|
|
225
251
|
if (!saved || typeof saved !== 'object' || !saved.acc || typeof saved.acc !== 'object') return false;
|
|
226
|
-
if (!Object.keys(kinds).every((k) => k
|
|
252
|
+
if (!Object.keys(kinds).every((k) => sameShape(kinds[k].init(), saved.acc[k]))) return false;
|
|
227
253
|
if (saved.ino !== st.ino || !Number.isInteger(saved.offset) || saved.offset < 0) return false;
|
|
228
254
|
return (
|
|
229
255
|
hashRange(fd, 0, Math.min(PROBE_BYTES, saved.offset)) === saved.head &&
|
|
@@ -231,6 +257,25 @@ function continues(fd, st, saved, kinds) {
|
|
|
231
257
|
);
|
|
232
258
|
}
|
|
233
259
|
|
|
260
|
+
/**
|
|
261
|
+
* Whether `v` has the shape of `model`, an accumulator's init(): a Set where it has a Set, an
|
|
262
|
+
* object with its keys where it has an object, its primitive type otherwise. The version check
|
|
263
|
+
* passes a state whose accumulators changed shape under one version string (D#854 F9), and a
|
|
264
|
+
* rule folded into one of those throws on every Stop until the state is collected.
|
|
265
|
+
*/
|
|
266
|
+
function sameShape(model, v) {
|
|
267
|
+
if (model instanceof Set) return v instanceof Set;
|
|
268
|
+
if (model !== null && typeof model === 'object') {
|
|
269
|
+
return (
|
|
270
|
+
v !== null &&
|
|
271
|
+
typeof v === 'object' &&
|
|
272
|
+
!(v instanceof Set) &&
|
|
273
|
+
Object.keys(model).every((k) => sameShape(model[k], v[k]))
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
return typeof v === typeof model;
|
|
277
|
+
}
|
|
278
|
+
|
|
234
279
|
function hashRange(fd, start, end) {
|
|
235
280
|
const len = end - start;
|
|
236
281
|
const b = Buffer.alloc(len);
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-mem-lite",
|
|
3
|
-
"version": "6.35.
|
|
3
|
+
"version": "6.35.2",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "claude-mem-lite",
|
|
9
|
-
"version": "6.35.
|
|
9
|
+
"version": "6.35.2",
|
|
10
10
|
"os": [
|
|
11
11
|
"darwin",
|
|
12
12
|
"linux",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
"node_modules/@hono/node-server": {
|
|
39
|
-
"version": "2.1.
|
|
40
|
-
"resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-2.1.
|
|
41
|
-
"integrity": "sha512-
|
|
39
|
+
"version": "2.1.8",
|
|
40
|
+
"resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-2.1.8.tgz",
|
|
41
|
+
"integrity": "sha512-jdf7FHh6A1lzjpHHQUgxsg2GeER2vMetnAOfeActzcoli6jamlK+NAwL6Dsr5Fl3BS3tYUQzCdtZjU8Qxv7bEA==",
|
|
42
42
|
"license": "MIT",
|
|
43
43
|
"engines": {
|
|
44
44
|
"node": ">=20"
|
|
@@ -617,9 +617,9 @@
|
|
|
617
617
|
}
|
|
618
618
|
},
|
|
619
619
|
"node_modules/hono": {
|
|
620
|
-
"version": "4.13.
|
|
621
|
-
"resolved": "https://registry.npmjs.org/hono/-/hono-4.13.
|
|
622
|
-
"integrity": "sha512-
|
|
620
|
+
"version": "4.13.18",
|
|
621
|
+
"resolved": "https://registry.npmjs.org/hono/-/hono-4.13.18.tgz",
|
|
622
|
+
"integrity": "sha512-H9q/E1XizaWstJxUW881dmLxEj+t/TrGGnyxINkm4+sK0qUwsMtFdo2BWI9Vs3cIS19MU6b6iCijoUoEf4f3DA==",
|
|
623
623
|
"license": "MIT",
|
|
624
624
|
"engines": {
|
|
625
625
|
"node": ">=16.9.0"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-mem-lite",
|
|
3
|
-
"version": "6.35.
|
|
3
|
+
"version": "6.35.2",
|
|
4
4
|
"description": "Persistent long-term memory for Claude Code via MCP — captures coding decisions, bugfixes, and context across sessions. FTS5 BM25 keyword search with episode batching. Single SQLite DB, no external services. A lighter, lower-cost alternative to claude-mem (episode batching + a smaller model; cost savings are an internal estimate, not a measured benchmark).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "npm@10.9.2",
|