claude-mem-lite 6.35.4 → 6.35.5

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.4",
12
+ "version": "6.35.5",
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.4",
3
+ "version": "6.35.5",
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/install.mjs CHANGED
@@ -4900,6 +4900,9 @@ async function rebuildBinding() {
4900
4900
  // dependency is the kind of thing that reads as corruption six months later.
4901
4901
  log(` the shipped prebuild would not load — moved aside to ${verify.quarantined}.unusable`);
4902
4902
  }
4903
+ for (const f of verify.setAside || []) {
4904
+ log(` a compiled addon would not load — moved aside to ${f}.unusable`);
4905
+ }
4903
4906
  } else {
4904
4907
  fail(`better-sqlite3 binding still unusable in ${label}: ${verify.error}`);
4905
4908
  log(`Try manually: ${nativeBindingRepairHint(root)}`);
@@ -66,12 +66,12 @@ export function nativeBindingRepairHint(root) {
66
66
  // double quotes, a `$` or backtick still expands), and a `cd` that splits hands the user a
67
67
  // command that fails on exactly the machines least able to debug it.
68
68
  const npmPair = `cd ${shellWord(root)} && ${NATIVE_BINDING_REBUILD_CMD} && ${NATIVE_BINDING_SOURCE_BUILD_CMD}`;
69
- // The pair above heals a platform better-sqlite3 ships NO prebuild for. It cannot heal a
70
- // prebuild that is present and will not load — 13 selects `prebuilds/<target>.node` on
71
- // existence alone and prefers it over `build/`, so the addon those two commands compile
72
- // stays shadowed. Only ensureBetterSqlite3Working moves the dead prebuild out of the way
73
- // first, and `rebuild-binding` is how a human reaches it — so it goes FIRST, because a user
74
- // runs the first command they are given and stops looking when it reports success.
69
+ // The pair above heals a platform better-sqlite3 ships NO prebuild for, and from 13.2.0 a
70
+ // prebuild that is present and will not load: 13.2.0 loads a compiled `build/` addon before
71
+ // `prebuilds/` (13.0.x did the reverse, and the pair could not heal that shape). Measured
72
+ // 2026-11-21: corrupt prebuild + healthy build/Release → opens via build/Release.
73
+ // `rebuild-binding` still goes FIRST: it runs the whole chain, and a user runs the first
74
+ // command they are given and stops looking when it reports success.
75
75
  const cli = join(root, 'cli.mjs');
76
76
  if (!existsSync(cli)) return npmPair;
77
77
  return `node ${shellWord(cli)} rebuild-binding (or, without the CLI: ${npmPair})`;
@@ -217,9 +217,10 @@ export function probeBindingInFreshProcess(installDir, { timeoutMs = 30_000 } =
217
217
  };
218
218
  }
219
219
 
220
- // Suffix for a prebuilt addon that is present and will not load. Renamed, never deleted:
221
- // the file is evidence for whoever debugs the machine, and `npm install` puts a fresh
222
- // prebuild back at the original name regardless.
220
+ // Suffix for a prebuilt addon that is present and will not load — and, since D#928, for a
221
+ // compiled `build/` addon in the same state. Renamed, never deleted: the file is evidence for
222
+ // whoever debugs the machine, and `npm install` puts a fresh prebuild back at the original
223
+ // name regardless.
223
224
  const UNUSABLE_PREBUILD_SUFFIX = '.unusable';
224
225
 
225
226
  /**
@@ -256,17 +257,76 @@ function resolvedPrebuildPath(installDir) {
256
257
  return p && existsSync(p) ? p : null;
257
258
  }
258
259
 
260
+ /** Out of process: does the addon at `file` dlopen? A crash or a hang counts as no. */
261
+ function addonLoadsInFreshProcess(file) {
262
+ const r = spawnSync(process.execPath, ['-e', `require(${JSON.stringify(file)})`], {
263
+ stdio: 'pipe',
264
+ timeout: 10_000,
265
+ });
266
+ return !r.error && r.status === 0;
267
+ }
268
+
269
+ /** Undo setAsideDeadCompiledAddons. Best-effort, like restorePrebuild below. */
270
+ function putBackCompiledAddons(files) {
271
+ for (const f of files) {
272
+ try {
273
+ renameSync(f + UNUSABLE_PREBUILD_SUFFIX, f);
274
+ } catch {
275
+ // Nothing better to do; the caller goes on to the npm and compile steps.
276
+ }
277
+ }
278
+ }
279
+
280
+ /**
281
+ * D#928. better-sqlite3 13.2.0 loads `build/Debug` or `build/Release/better_sqlite3.node`
282
+ * BEFORE the prebuild, so a compiled addon that will not load hides a prebuild that would.
283
+ * Measured 2026-11-21: that tree does not open. Renaming it is enough, needs no compiler, and
284
+ * so is safe on the time-budgeted SessionStart path that the source build below is not.
285
+ *
286
+ * Moves only compiled addons that themselves fail to load (a working one may be the user's
287
+ * own build — 13.2.0's release notes describe compiling a custom SQLite that way), and only when the
288
+ * prebuild loads in their place, so "broken addon" never becomes "no addon". The two paths
289
+ * are node-gyp's fixed output locations, checked in the order 13.2.0's `getBinding()` uses;
290
+ * the package exports no selector for them, unlike `getPrebuildPath()`.
291
+ *
292
+ * @param {string} installDir Directory whose node_modules holds better-sqlite3
293
+ * @returns {string[]} the files renamed to `<file>.unusable`; empty when the shape is absent
294
+ */
295
+ function setAsideDeadCompiledAddons(installDir) {
296
+ const pkg = join(installDir, 'node_modules', 'better-sqlite3');
297
+ const dead = ['Debug', 'Release']
298
+ .map((type) => join(pkg, 'build', type, 'better_sqlite3.node'))
299
+ .filter((f) => existsSync(f) && !addonLoadsInFreshProcess(f));
300
+ if (dead.length === 0) return [];
301
+ const prebuild = resolvedPrebuildPath(installDir);
302
+ if (!prebuild || !addonLoadsInFreshProcess(prebuild)) return [];
303
+ const moved = [];
304
+ for (const f of dead) {
305
+ try {
306
+ renameSync(f, f + UNUSABLE_PREBUILD_SUFFIX);
307
+ moved.push(f);
308
+ } catch {
309
+ // A read-only tree: leave it exactly as found and let the remaining steps try.
310
+ putBackCompiledAddons(moved);
311
+ return [];
312
+ }
313
+ }
314
+ return moved;
315
+ }
316
+
259
317
  /**
260
318
  * Verify better-sqlite3 binding works in `installDir`; if not, run
261
319
  * `npm rebuild better-sqlite3` and re-probe. Returns
262
- * { ok: true, action: 'verified' | 'rebuilt' } on success or
320
+ * { ok: true, action: 'verified' | 'rebuilt' } on success,
321
+ * { ok: true, action: 'restored', setAside } when moving dead compiled addons aside was
322
+ * enough (D#928), { ok: true, action: 'compiled', quarantined? } after the source build, or
263
323
  * { ok: false, error } if rebuild can't fix it. The `probe`, `verify` and
264
324
  * `rebuild` deps are injectable so this can be unit-tested without a real npm
265
325
  * subprocess.
266
326
  *
267
327
  * @param {string} installDir Directory containing node_modules/better-sqlite3
268
328
  * @param {{probe?: () => Promise<{ok: boolean, error?: string}>, verify?: () => Promise<{ok: boolean, error?: string}> | {ok: boolean, error?: string}, rebuild?: () => Promise<void>, exec?: (cmd: string, opts: object) => void}} [deps]
269
- * @returns {Promise<{ok: true, action: 'verified' | 'rebuilt'} | {ok: false, error: string}>}
329
+ * @returns {Promise<{ok: true, action: 'verified' | 'rebuilt'} | {ok: true, action: 'restored', setAside: string[]} | {ok: true, action: 'compiled', quarantined?: string} | {ok: false, error: string}>}
270
330
  */
271
331
  export async function ensureBetterSqlite3Working(installDir, deps = {}) {
272
332
  // BOTH probes run out of process by default, because a probe must never
@@ -321,6 +381,15 @@ export async function ensureBetterSqlite3Working(installDir, deps = {}) {
321
381
  const first = await probe();
322
382
  if (first.ok) return { ok: true, action: 'verified' };
323
383
 
384
+ // Before any npm step: the rename costs a few short spawns where the npm step can take its
385
+ // whole cap.
386
+ const setAside = setAsideDeadCompiledAddons(installDir);
387
+ if (setAside.length > 0) {
388
+ const unshadowed = await verify();
389
+ if (unshadowed.ok) return { ok: true, action: 'restored', setAside };
390
+ putBackCompiledAddons(setAside);
391
+ }
392
+
324
393
  try {
325
394
  await rebuild();
326
395
  } catch (e) {
@@ -361,14 +430,12 @@ export async function ensureBetterSqlite3Working(installDir, deps = {}) {
361
430
  : () => exec(NATIVE_BINDING_SOURCE_BUILD_CMD, { cwd: installDir, stdio: 'pipe' }));
362
431
  if (!sourceBuild) return { ok: false, error: second.error || first.error };
363
432
 
364
- // A prebuild that is present and unloadable SHADOWS everything the source build is about
365
- // to produce: better-sqlite3 13 picks `prebuilds/<target>.node` on existence alone and
366
- // prefers it over `build/`. Measured 2026-09-06 with a control — corrupt prebuild +
367
- // healthy build/Release → `wrong ELF class`; the same tree with the prebuild moved aside →
368
- // opens; with neither → fails. Until this, `rebuild-binding` (the foreground repair doctor
369
- // prints, deliberately given no time budget) exited 1 on that shape and the manual command
370
- // it offered instead could not fix it either. Reproduced end-to-end in
371
- // tests/sandbox/phaseB-npm.mjs before the fix.
433
+ // Quarantine the prebuild before compiling. On better-sqlite3 13.0.x this was the fix: it
434
+ // picked `prebuilds/<target>.node` on existence alone, before `build/`, so a dead prebuild
435
+ // shadowed the compile (measured 2026-09-06: corrupt prebuild + healthy build/Release →
436
+ // `wrong ELF class`; prebuild moved aside → opens). 13.2.0 loads `build/` first (measured
437
+ // 2026-11-21: the same tree opens via build/Release), so the compile no longer needs it. It
438
+ // stays: dropping it is a behaviour change of its own, not part of a dependency bump.
372
439
  //
373
440
  // Deliberately inside this branch and after the npm step: quarantining without a compile to
374
441
  // follow it turns "broken addon" into "no addon", which is strictly worse — so the
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "claude-mem-lite",
3
- "version": "6.35.4",
3
+ "version": "6.35.5",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "claude-mem-lite",
9
- "version": "6.35.4",
9
+ "version": "6.35.5",
10
10
  "os": [
11
11
  "darwin",
12
12
  "linux",
@@ -14,7 +14,7 @@
14
14
  ],
15
15
  "dependencies": {
16
16
  "@modelcontextprotocol/sdk": "^1.32.2",
17
- "better-sqlite3": "^13.0.3",
17
+ "better-sqlite3": "^13.2.0",
18
18
  "zod": "^4.6.7"
19
19
  },
20
20
  "bin": {
@@ -134,9 +134,9 @@
134
134
  }
135
135
  },
136
136
  "node_modules/better-sqlite3": {
137
- "version": "13.0.3",
138
- "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-13.0.3.tgz",
139
- "integrity": "sha512-RbOBxmLBG8uvFUc15X9+9SFemKcQ0WBuISBVkpuiaUB2qblC8UWlHEjdWVoZ8AdhSwmoEgsiXKfopX0CQxaACQ==",
137
+ "version": "13.2.0",
138
+ "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-13.2.0.tgz",
139
+ "integrity": "sha512-Z8Q/9x/uNyKxA1v4FNodyItRVRw1TeKBrmj32JhxhR0ceNcBY+wMobt/Bv7M7TzwPAXjnZRtNaEsATnUZSKWZQ==",
140
140
  "license": "MIT",
141
141
  "dependencies": {
142
142
  "node-addon-api": "^8.0.0"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-mem-lite",
3
- "version": "6.35.4",
3
+ "version": "6.35.5",
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",
@@ -241,7 +241,7 @@
241
241
  ],
242
242
  "dependencies": {
243
243
  "@modelcontextprotocol/sdk": "^1.32.2",
244
- "better-sqlite3": "^13.0.3",
244
+ "better-sqlite3": "^13.2.0",
245
245
  "zod": "^4.6.7"
246
246
  },
247
247
  "overrides": {
@@ -157,4 +157,9 @@ if (!result.ok) {
157
157
  if (result.action === 'rebuilt') {
158
158
  process.stderr.write('[claude-mem-lite] rebuilt better-sqlite3 binding for current Node ABI\n');
159
159
  }
160
+ for (const f of result.setAside || []) {
161
+ process.stderr.write(
162
+ `[claude-mem-lite] moved a compiled better-sqlite3 addon that would not load aside: ${f}.unusable\n`,
163
+ );
164
+ }
160
165
  process.exit(0);
package/scripts/setup.sh CHANGED
@@ -336,11 +336,8 @@ if [[ -d "$ROOT/node_modules/better-sqlite3" ]]; then
336
336
  # better-sqlite3 13 (no install script to run), so it never signals failure and
337
337
  # an `||` chain would never reach the source build. A20260906-R8-P1-1.
338
338
  #
339
- # …and the pair alone is still not enough. It heals a platform 13 ships no prebuild
340
- # for; it cannot heal a prebuild that is PRESENT and will not load, because 13 prefers
341
- # `prebuilds/<target>.node` over anything the source build produces. This string is what
342
- # the SessionStart dashboard prints as `Repair:`, so it leads with the CLI, which is the
343
- # only path that moves the dead prebuild aside first (lib/binding-probe.mjs). Mirrors
339
+ # This string is what the SessionStart dashboard prints as `Repair:`, so it leads with
340
+ # the CLI, which runs the whole chain (lib/binding-probe.mjs). Mirrors
344
341
  # nativeBindingRepairHint(); this file may not import lib/, hence the duplication —
345
342
  # tests/audit-r8-binding-repair-hint.test.mjs pins the set of files allowed to do that.
346
343
  # mark_deps_broken already prefixes `cd <root> && `, so these are root-relative.