claude-mem-lite 6.30.3 → 6.30.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.30.3",
12
+ "version": "6.30.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.30.3",
3
+ "version": "6.30.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
@@ -483,9 +483,8 @@ export async function dbCheckRemedy(dbPath, err) {
483
483
  // its copy of the command.
484
484
  if (remedy.kind === 'set-aside') {
485
485
  return (
486
- `No backup snapshot exists beside the database. Once every Claude Code session is closed, ` +
487
- `set the broken file aside so a fresh store is created on the next session: ${remedy.command} ` +
488
- `— memories in that file are not recoverable without a backup.`
486
+ `No non-empty backup snapshot exists beside the database. Once every Claude Code session is closed, ` +
487
+ `set the broken file aside so a fresh store is created on the next session: ${remedy.command}`
489
488
  );
490
489
  }
491
490
  return (
package/lib/db-backup.mjs CHANGED
@@ -7,7 +7,7 @@
7
7
  //
8
8
  // MUST be called OUTSIDE any transaction — VACUUM cannot run inside one, which is
9
9
  // why the maintenance entry points snapshot before opening their db.transaction().
10
- import { readdirSync, unlinkSync, statSync } from 'fs';
10
+ import { existsSync, readdirSync, unlinkSync, statSync } from 'fs';
11
11
  import { dirname, basename, join } from 'path';
12
12
  import { debugLog } from '../utils.mjs';
13
13
 
@@ -149,7 +149,20 @@ export function snapshotDb(db, { tag = 'pre-maintain', retain = 3 } = {}) {
149
149
  const out = `${dbPath}.${tag}-${stamp}.bak`;
150
150
  // Path is internal (db.name from our own config), but escape single quotes
151
151
  // defensively since VACUUM INTO takes a string literal, not a bound param.
152
- db.exec(`VACUUM INTO '${out.replace(/'/g, "''")}'`);
152
+ const fresh = !existsSync(out);
153
+ try {
154
+ db.exec(`VACUUM INTO '${out.replace(/'/g, "''")}'`);
155
+ } catch (e) {
156
+ // A failed VACUUM INTO can leave its target behind: 0 bytes on a damaged store, newer than
157
+ // every real snapshot, so a restore command named it (D#551). Only a file it created goes.
158
+ if (fresh)
159
+ try {
160
+ unlinkSync(out);
161
+ } catch {
162
+ /* never created */
163
+ }
164
+ throw e;
165
+ }
153
166
  pruneSnapshots(dbPath, tag, retain);
154
167
  enforceBackupBudget(dbPath);
155
168
  return out;
@@ -171,46 +171,49 @@ export function dbUnusableRemedy(dbPath, err) {
171
171
  `fix that directory first, then look for ${basename(dbPath)}.*.bak beside the database.`,
172
172
  };
173
173
  }
174
- if (schema && snap.snapshots.length === 0) {
174
+ // A 0-byte `.bak` is what a failed snapshot of a damaged store left before 6.31.0 (D#551),
175
+ // usually the newest one; it is not a copy of anything.
176
+ const snapshots = snap.snapshots.filter((s) => s.size > 0);
177
+ const empty = snap.snapshots.length - snapshots.length;
178
+ const none =
179
+ empty > 0
180
+ ? `No backup snapshot beside the database holds any data (${empty} empty .bak file${empty === 1 ? '' : 's'} skipped).`
181
+ : 'No backup snapshot exists beside the database.';
182
+ if (schema && snapshots.length === 0) {
175
183
  return {
176
184
  kind: 'schema',
177
185
  command: '',
178
186
  snapshotCount: 0,
179
- note: 'No backup snapshot exists beside the database.',
187
+ note: none,
180
188
  };
181
189
  }
182
- if (snap.snapshots.length === 0) {
190
+ if (snapshots.length === 0) {
183
191
  return {
184
192
  kind: 'set-aside',
185
193
  command: `${clear} && mv ${shellWord(dbPath)} ${shellWord(`${dbPath}.corrupt`)}`,
186
194
  snapshotCount: 0,
187
- note:
188
- 'No backup snapshot exists beside the database. That command sets the broken file ' +
189
- 'aside so a fresh store is created on the next session — memories in it are not ' +
190
- 'recoverable without a backup.',
195
+ note: `${none} That command sets the broken file aside so a fresh store is created on the next session.`,
191
196
  };
192
197
  }
193
198
  // Newest by mtime, ties broken by name (which carries an ISO stamp) so the answer is total
194
199
  // rather than dependent on readdir order — the D#9 shape.
195
- const newest = snap.snapshots
196
- .slice()
197
- .sort((a, b) => b.mtimeMs - a.mtimeMs || (a.path < b.path ? 1 : -1))[0];
200
+ const newest = snapshots.slice().sort((a, b) => b.mtimeMs - a.mtimeMs || (a.path < b.path ? 1 : -1))[0];
198
201
  if (schema) {
199
202
  return {
200
203
  kind: 'schema',
201
204
  command: '',
202
- snapshotCount: snap.snapshots.length,
205
+ snapshotCount: snapshots.length,
203
206
  note:
204
- `${snap.snapshots.length} backup snapshot(s) exist beside it; the newest is ${newest.path}. ` +
207
+ `${snapshots.length} backup snapshot(s) exist beside it; the newest is ${newest.path}. ` +
205
208
  'Restoring one replaces the database file, so copy the broken file aside first.',
206
209
  };
207
210
  }
208
211
  return {
209
212
  kind: 'restore',
210
213
  command: `${clear} && cp ${shellWord(newest.path)} ${shellWord(dbPath)}`,
211
- snapshotCount: snap.snapshots.length,
214
+ snapshotCount: snapshots.length,
212
215
  note:
213
- `Restores the newest of ${snap.snapshots.length} backup snapshot(s). Move the broken ` +
216
+ `Restores the newest of ${snapshots.length} backup snapshot(s). Move the broken ` +
214
217
  'file aside first if you want to keep it for inspection.',
215
218
  };
216
219
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "claude-mem-lite",
3
- "version": "6.30.3",
3
+ "version": "6.30.5",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "claude-mem-lite",
9
- "version": "6.30.3",
9
+ "version": "6.30.5",
10
10
  "os": [
11
11
  "darwin",
12
12
  "linux",
@@ -668,9 +668,9 @@
668
668
  "license": "ISC"
669
669
  },
670
670
  "node_modules/ip-address": {
671
- "version": "10.7.2",
672
- "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.7.2.tgz",
673
- "integrity": "sha512-7H/2gFSIitxc0hG3nOI1glS8QLo/EHBFFLk8vEUjXY/xu0AdL8jZ9U1IzO2PUm0d2D/ofQcAifb0g6OBkt8U7w==",
671
+ "version": "10.7.4",
672
+ "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.7.4.tgz",
673
+ "integrity": "sha512-DWBMKyeM25D70nrIiTkgQth59/G+naKOTep6huF9j+GmeK3DMD60Zvxg5d5qQnz+38AHgou6ean2LECX+lrKDg==",
674
674
  "license": "MIT",
675
675
  "engines": {
676
676
  "node": ">= 12"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-mem-lite",
3
- "version": "6.30.3",
3
+ "version": "6.30.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",