claude-mem-lite 6.30.7 → 6.30.9
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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +5 -4
- package/README.zh-CN.md +5 -4
- package/cli/fts-check.mjs +4 -2
- package/hook.mjs +2 -2
- package/install.mjs +64 -19
- package/lib/db-backup.mjs +2 -2
- package/lib/db-unusable.mjs +448 -67
- package/lib/snapshot-probe.mjs +74 -0
- package/mem-cli.mjs +4 -2
- package/npm-shrinkwrap.json +11 -11
- package/package.json +4 -3
- package/schema.mjs +36 -8
- package/scripts/setup.sh +22 -4
- package/secret-scrub.mjs +259 -10
- package/server/fts-check.mjs +4 -3
- package/source-files.mjs +3 -0
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"plugins": [
|
|
10
10
|
{
|
|
11
11
|
"name": "claude-mem-lite",
|
|
12
|
-
"version": "6.30.
|
|
12
|
+
"version": "6.30.9",
|
|
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
|
+
"version": "6.30.9",
|
|
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/README.md
CHANGED
|
@@ -197,7 +197,7 @@ node install.mjs install
|
|
|
197
197
|
2. **Register MCP server** -- `mem-lite` server with 19 tool definitions (10 core + 9 hidden-but-callable; `mem_search_feedback` is registered only when search telemetry is enabled). The pre-v2.78 generic server name `mem` is renamed to `mem-lite` for namespace hygiene; the tool names themselves (`mem_search`, `mem_recall`, ...) are unchanged.
|
|
198
198
|
3. **Configure hooks** -- all seven lifecycle events: `SessionStart`, `PreCompact`, `PreToolUse`, `PostToolUse`, `PostToolUseFailure`, `Stop`, `UserPromptSubmit`
|
|
199
199
|
4. **Create data directory** -- `~/.claude-mem-lite/` (hidden) for database, runtime, and managed resource files
|
|
200
|
-
5. **Auto-migrate** -- `~/.claude-mem/claude-mem.db` (original claude-mem) is moved into `~/.claude-mem-lite/` as a `.legacy-backup-<time>` file and a fresh database is created. A database left in `~/claude-mem-lite/` (the unhidden directory of versions before the first release, 2.0.0) is moved into the data directory at the first open, when the data directory holds no database, log, snapshot or kept copy of a claude-mem-lite store yet; nothing else in either directory is moved or removed
|
|
200
|
+
5. **Auto-migrate** -- `~/.claude-mem/claude-mem.db` (original claude-mem) is moved into `~/.claude-mem-lite/` as a `.legacy-backup-<time>` file (the plugin, and install across filesystems, copy it instead) and a fresh database is created. A database left in `~/claude-mem-lite/` (the unhidden directory of versions before the first release, 2.0.0) is moved into the data directory at the first open, when the data directory holds no database, log, snapshot or kept copy of a claude-mem-lite store yet; nothing else in either directory is moved or removed
|
|
201
201
|
6. **Initialize database** -- SQLite with WAL mode, FTS5 indexes created on first server start
|
|
202
202
|
|
|
203
203
|
Restart Claude Code after installation to activate.
|
|
@@ -207,8 +207,9 @@ Restart Claude Code after installation to activate.
|
|
|
207
207
|
All installation methods auto-detect and migrate from previous versions:
|
|
208
208
|
|
|
209
209
|
**From claude-mem (original `~/.claude-mem/`):**
|
|
210
|
-
- `claude-mem.db` and its `-wal`/`-shm` are moved into `~/.claude-mem-lite/`
|
|
211
|
-
- The plugin install copies `claude-mem.db`
|
|
210
|
+
- `claude-mem.db` and its `-wal`/`-shm` are moved into `~/.claude-mem-lite/` as `claude-mem-lite.db.legacy-backup-<time>`, `claude-mem-lite.db.legacy-backup-<time>-wal` and `-shm`, when `~/.claude-mem-lite/claude-mem-lite.db` does not exist yet. With the data directory on another filesystem they are copied instead, `~/.claude-mem/` stays as it is, and a backup already there is not copied again
|
|
211
|
+
- The plugin install copies `claude-mem.db` and its `-wal` into the data directory under those names and leaves `~/.claude-mem/` as it is; it does so while the data directory holds neither a database nor such a backup
|
|
212
|
+
- A backup that `install` made before v6.30.8 names its log `claude-mem-lite.db-wal.legacy-backup-<time>`, and SQLite does not read that log with the backup; rename it to `claude-mem-lite.db.legacy-backup-<time>-wal` before opening the backup
|
|
212
213
|
- A fresh database is created: the original claude-mem schema has no upgrade path
|
|
213
214
|
|
|
214
215
|
**From the unhidden directory of versions before the first release, 2.0.0 (`~/claude-mem-lite/`):**
|
|
@@ -653,7 +654,7 @@ surface — reach them through the CLI column in the second table.
|
|
|
653
654
|
| `mem_maintain` | `claude-mem-lite maintain scan --ops dedup,decay` | dedup / decay / cleanup / vacuum (`scan` previews, `execute` applies). |
|
|
654
655
|
| `mem_optimize` | `claude-mem-lite optimize` | LLM-powered re-enrich / normalize / cluster-merge (preview default; `--run` to apply). |
|
|
655
656
|
| `mem_export` | `claude-mem-lite export` | JSON / JSONL dump, filters by project, type, date. |
|
|
656
|
-
| `mem_fts_check` | `claude-mem-lite fts-check <check\|rebuild>` | FTS5 integrity
|
|
657
|
+
| `mem_fts_check` | `claude-mem-lite fts-check <check\|rebuild>` | FTS5 integrity check; rebuild of the FTS5 indexes, then every other index (REINDEX). |
|
|
657
658
|
| `mem_browse` | `claude-mem-lite browse` | Tier-grouped dashboard (working / active / archive). |
|
|
658
659
|
|
|
659
660
|
**Headless runs (`claude -p`).** With no permission prompt to answer, Claude Code 2.1.292
|
package/README.zh-CN.md
CHANGED
|
@@ -159,7 +159,7 @@ node install.mjs install
|
|
|
159
159
|
> **想把托管块改写进 `CLAUDE.md`**(例如与团队共享)?运行 `claude-mem-lite adopt`:它向 `<cwd>/CLAUDE.md` 写入 slug 限定的托管块和详情文件,块以外的内容逐字保留,并删除自动写入的那份本地副本(`CLAUDE.local.md` 或 rules 文件)。`CLAUDE.md` 一存在,Claude Code 就不再读 `AGENTS.md`,所以 adopt 在 `AGENTS.md`(或 `.claude/AGENTS.md`)旁边新建 `CLAUDE.md` 时,会在文件开头导入它(`@AGENTS.md`,前面一行是 Claude Code 不加载的标记注释),`AGENTS.md` 因此继续加载;上层目录里的、或 git 跟踪在子目录里的 `AGENTS.md` 不能这样导入,adopt 会在输出里列出它们,并给出保留它们的设置(Project instructions 设为 `claude-md-and-agents-md`)。已经有你自己的 `CLAUDE.md` 时不导入,因为那里本来就不读 `AGENTS.md`。`unadopt` 会删除只剩这些行和托管块的 `CLAUDE.md`。带托管块的项目在**每次 SessionStart** 都会同步,出货模板变了会刷新,且不会再叠加本地副本或注入,从子目录启动的会话也一样。只有托管块的 `CLAUDE.md`(旧版本自动 adopt 写的)会在下一次从它所在目录启动的会话里补上同样的 `AGENTS.md` 导入,并给一次性提示。从子目录启动的会话看来,这个导入指向工作目录之外,Claude Code 会请你批准一次。插件创建过、又被你删掉(或被 `claude-mem-lite unadopt` 删掉)的本地托管块(`CLAUDE.local.md` 或 rules 文件)不会被写回,改为注入,直到运行 `claude-mem-lite adopt --enable`(在 `CLAUDE.local.md` 会让 `AGENTS.md` 失效的仓库里,还要设 `CLAUDE_MEM_RULES_STEERING=1` 才会再写文件)。关闭方式:项目级 `claude-mem-lite adopt --disable`(同时删除本地托管块;`CLAUDE.md` 托管块保留到 `unadopt`;重新启用用 `--enable`);全局 `export MEM_NO_AUTO_ADOPT=1`(已写入的托管块保留并继续加载,直到 `unadopt`);只冻结模板刷新用 `CLAUDE_MEM_NO_TEMPLATE_REFRESH=1`。`claude-mem-lite unadopt` 会移除 `CLAUDE.md` 托管块、详情文件,以及本地托管块(`CLAUDE.local.md` 或 `.claude/rules/claude-mem-lite.md`)和它的 exclude 条目。
|
|
160
160
|
3. **配置钩子** -- 全部七个生命周期事件:`SessionStart`、`PreCompact`、`PreToolUse`、`PostToolUse`、`PostToolUseFailure`、`Stop`、`UserPromptSubmit`
|
|
161
161
|
4. **创建数据目录** -- `~/.claude-mem-lite/`(隐藏目录),存放数据库与运行时文件
|
|
162
|
-
5. **自动迁移** -- `~/.claude-mem/claude-mem.db`(原版 claude-mem)以 `.legacy-backup-<时间>` 文件的形式移入 `~/.claude-mem-lite
|
|
162
|
+
5. **自动迁移** -- `~/.claude-mem/claude-mem.db`(原版 claude-mem)以 `.legacy-backup-<时间>` 文件的形式移入 `~/.claude-mem-lite/`(插件、以及跨文件系统时的 install 改为复制),并新建一个数据库。`~/claude-mem-lite/`(首个发布版 2.0.0 之前的非隐藏目录)里留下的数据库在第一次打开时移入数据目录,前提是数据目录里还没有 claude-mem-lite 的数据库、日志、快照或保留副本;两个目录里的其他文件都不移动、不删除
|
|
163
163
|
6. **初始化数据库** -- SQLite WAL 模式,FTS5 索引在服务器首次启动时创建
|
|
164
164
|
|
|
165
165
|
安装后重启 Claude Code 以激活。
|
|
@@ -169,8 +169,9 @@ node install.mjs install
|
|
|
169
169
|
所有安装方式自动检测并从旧版本迁移:
|
|
170
170
|
|
|
171
171
|
**从 claude-mem 原版(`~/.claude-mem/`):**
|
|
172
|
-
- `claude-mem.db` 连同 `-wal`/`-shm` 以
|
|
173
|
-
-
|
|
172
|
+
- `claude-mem.db` 连同 `-wal`/`-shm` 以 `claude-mem-lite.db.legacy-backup-<时间>`、`claude-mem-lite.db.legacy-backup-<时间>-wal` 和 `-shm` 的名字移入 `~/.claude-mem-lite/`,前提是 `~/.claude-mem-lite/claude-mem-lite.db` 还不存在。数据目录在另一个文件系统上时改为复制,`~/.claude-mem/` 原样不动,数据目录里已有备份就不再复制
|
|
173
|
+
- 插件安装把 `claude-mem.db` 连同 `-wal` 以上面的名字复制进数据目录,`~/.claude-mem/` 原样不动;数据目录里既没有数据库、也没有这样的备份时才复制
|
|
174
|
+
- v6.30.8 之前 `install` 做的备份,日志名是 `claude-mem-lite.db-wal.legacy-backup-<时间>`,SQLite 打开备份时不会读这个日志;打开备份前先把它改名为 `claude-mem-lite.db.legacy-backup-<时间>-wal`
|
|
174
175
|
- 新建一个数据库:原版 claude-mem 的 schema 没有升级路径
|
|
175
176
|
|
|
176
177
|
**从首个发布版(2.0.0)之前的非隐藏目录(`~/claude-mem-lite/`):**
|
|
@@ -512,7 +513,7 @@ README 和 `docs/ARCHITECTURE.md` 都钉在它上面。)
|
|
|
512
513
|
| `mem_maintain` | `claude-mem-lite maintain scan --ops dedup,decay` | 去重 / decay / 清理 / vacuum(`scan` 预览,`execute` 执行)。 |
|
|
513
514
|
| `mem_optimize` | `claude-mem-lite optimize` | LLM 深度优化:re-enrich / normalize / cluster-merge(默认 preview;`--run` 执行)。 |
|
|
514
515
|
| `mem_export` | `claude-mem-lite export` | JSON / JSONL 导出,支持项目/类型/日期过滤。 |
|
|
515
|
-
| `mem_fts_check` | `claude-mem-lite fts-check <check\|rebuild>` | FTS5
|
|
516
|
+
| `mem_fts_check` | `claude-mem-lite fts-check <check\|rebuild>` | FTS5 完整性检查;重建 FTS5 索引,再重建其余所有索引(REINDEX)。 |
|
|
516
517
|
| `mem_browse` | `claude-mem-lite browse` | 分层仪表盘(working / active / archive)。 |
|
|
517
518
|
|
|
518
519
|
**无人值守运行(`claude -p`)。** 没有权限确认可答时,Claude Code 2.1.292 拒绝了所有 `mem_*` 调用,直到服务的工具被放行;模型也没有自己改用 CLI。在 88 个无人值守会话里(2026-10-06),13 次调用全部被拒,什么都没存下。在 2.1.284 上(2026-09-29),同样的参数会放行这些调用,所以这取决于 Claude Code 版本。在这次运行读取的 `settings.json` 里放行一次即可:
|
package/cli/fts-check.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// cli/fts-check.mjs — `claude-mem-lite fts-check <check|rebuild>`.
|
|
2
2
|
// Extracted from mem-cli.mjs (v2.41, god-module split).
|
|
3
3
|
|
|
4
|
-
import { checkFTSIntegrity,
|
|
4
|
+
import { checkFTSIntegrity, rebuildIndexes } from '../schema.mjs';
|
|
5
5
|
import { parseArgs, out, fail } from './common.mjs';
|
|
6
6
|
import { CLI_INVOKE } from '../cli-path.mjs';
|
|
7
7
|
|
|
@@ -48,7 +48,9 @@ export function cmdFtsCheck(db, args) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
if (action === 'rebuild') {
|
|
51
|
-
|
|
51
|
+
// The FTS5 indexes, then every other index (REINDEX): the last step of doctor's restore
|
|
52
|
+
// command, which the restore check ran on its copy (D#558).
|
|
53
|
+
const result = rebuildIndexes(db);
|
|
52
54
|
if (result.errors.length > 0) {
|
|
53
55
|
// Partial success is a failure of the requested operation: the caller asked
|
|
54
56
|
// for a rebuild and at least one index still is not rebuilt.
|
package/hook.mjs
CHANGED
|
@@ -2780,14 +2780,14 @@ async function emitDbUnusableNotice() {
|
|
|
2780
2780
|
const mod = await import('./lib/db-unusable.mjs');
|
|
2781
2781
|
// TWO DIFFERENT STRINGS, unlike the skew twin, and the asymmetry is the point: the
|
|
2782
2782
|
// human channel carries the repair command, the model channel carries only the fact.
|
|
2783
|
-
// See formatDbUnusableModelNotice — this family's remedy
|
|
2783
|
+
// See formatDbUnusableModelNotice — this family's remedy moves the database file aside.
|
|
2784
2784
|
queueHookSystemMessage(
|
|
2785
2785
|
mod.formatDbUnusableNotice({
|
|
2786
2786
|
dbPath: DB_PATH,
|
|
2787
2787
|
remedy: mod.dbUnusableRemedy(DB_PATH, lastDbUnusableError()),
|
|
2788
2788
|
}),
|
|
2789
2789
|
);
|
|
2790
|
-
queueHookContext('SessionStart', mod.formatDbUnusableModelNotice());
|
|
2790
|
+
queueHookContext('SessionStart', mod.formatDbUnusableModelNotice(DB_PATH));
|
|
2791
2791
|
} catch (e) {
|
|
2792
2792
|
// A hook must never crash the host session, and a notice that cannot render is better
|
|
2793
2793
|
// handled by staying quiet than by taking SessionStart down with it.
|
package/install.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { OUR_MCP_SERVER_RE, isOurMcpRegistration } from './lib/mcp-ownership.mjs
|
|
|
5
5
|
import { execSync, execFileSync } from 'child_process';
|
|
6
6
|
import {
|
|
7
7
|
readFileSync,
|
|
8
|
+
copyFileSync,
|
|
8
9
|
writeFileSync,
|
|
9
10
|
existsSync,
|
|
10
11
|
rmSync,
|
|
@@ -176,10 +177,18 @@ export function copyHookScripts(srcDir, destDir) {
|
|
|
176
177
|
* first launch. Backing up rather than copying-as-current lets the new
|
|
177
178
|
* install create a fresh v28 DB while preserving legacy bytes for recovery.
|
|
178
179
|
*
|
|
179
|
-
* Returns: {action: 'noop'|'skip'|'backed-up', backupPath?}
|
|
180
|
+
* Returns: {action: 'noop'|'skip'|'backed-up'|'copied', backupPath?}
|
|
180
181
|
* - noop: no legacy DB found
|
|
181
|
-
* - skip: working `claude-mem-lite.db` already exists in newDir
|
|
182
|
-
*
|
|
182
|
+
* - skip: working `claude-mem-lite.db` already exists in newDir, or (across filesystems) a backup
|
|
183
|
+
* database is already there (an earlier install's copy, or the plugin's)
|
|
184
|
+
* - backed-up: legacy files renamed to `<newDir>/claude-mem-lite.db.legacy-backup-<ts>` and,
|
|
185
|
+
* beside it, that name with `-wal` and `-shm` added, the names SQLite pairs with it (D#584: the
|
|
186
|
+
* log was named `claude-mem-lite.db-wal.legacy-backup-<ts>`, and the backup opened as found
|
|
187
|
+
* read none of the rows only in it)
|
|
188
|
+
* - copied: newDir is on another filesystem, where a rename fails with EXDEV (D#579): the files
|
|
189
|
+
* are copied to those names and the source is left in place, as the plugin's setup.sh does.
|
|
190
|
+
* Every file is copied under a private name first and then renamed into place, the store's own
|
|
191
|
+
* file last, so a copy killed partway leaves no backup of the store.
|
|
183
192
|
*/
|
|
184
193
|
export function migrateLegacyClaudeMemData(oldDir, newDir, opts = {}) {
|
|
185
194
|
const legacyDb = join(oldDir, 'claude-mem.db');
|
|
@@ -190,10 +199,25 @@ export function migrateLegacyClaudeMemData(oldDir, newDir, opts = {}) {
|
|
|
190
199
|
if (!existsSync(newDir)) mkdirSync(newDir, { recursive: true });
|
|
191
200
|
const ts = opts.now ?? Date.now();
|
|
192
201
|
const backupPath = join(newDir, `claude-mem-lite.db.legacy-backup-${ts}`);
|
|
193
|
-
|
|
202
|
+
try {
|
|
203
|
+
renameSync(legacyDb, backupPath);
|
|
204
|
+
} catch (e) {
|
|
205
|
+
if (e?.code !== 'EXDEV') throw e;
|
|
206
|
+
// A copy killed partway left its private files. Only install names files so (the plugin's
|
|
207
|
+
// session start has its own prefix), and install runs one at a time (install.lock).
|
|
208
|
+
const names = readdirSync(newDir);
|
|
209
|
+
for (const n of names) if (n.startsWith('.legacy-backup-copy-')) rmSync(join(newDir, n), { force: true });
|
|
210
|
+
// The source stays, so a backup of the store here is the copy an earlier install made. Its log
|
|
211
|
+
// alone is not: a copy killed between the renames below leaves that.
|
|
212
|
+
if (names.some((n) => /^claude-mem-lite\.db\.legacy-backup-\d+$/.test(n))) return { action: 'skip' };
|
|
213
|
+
const exts = ['-wal', '-shm', ''].filter((ext) => existsSync(legacyDb + ext));
|
|
214
|
+
const tmp = join(newDir, `.legacy-backup-copy-${process.pid}-${ts}`);
|
|
215
|
+
for (const ext of exts) copyFileSync(legacyDb + ext, tmp + ext);
|
|
216
|
+
for (const ext of exts) renameSync(tmp + ext, backupPath + ext);
|
|
217
|
+
return { action: 'copied', backupPath };
|
|
218
|
+
}
|
|
194
219
|
for (const ext of ['-wal', '-shm']) {
|
|
195
|
-
|
|
196
|
-
if (existsSync(src)) renameSync(src, join(newDir, `claude-mem-lite.db${ext}.legacy-backup-${ts}`));
|
|
220
|
+
if (existsSync(legacyDb + ext)) renameSync(legacyDb + ext, backupPath + ext);
|
|
197
221
|
}
|
|
198
222
|
return { action: 'backed-up', backupPath };
|
|
199
223
|
}
|
|
@@ -473,24 +497,34 @@ export async function dbCheckRemedy(dbPath, err) {
|
|
|
473
497
|
// only inside the Database check's catch, so the cost of loading it lazily is paid by
|
|
474
498
|
// the rare failure rather than by every invocation. Same shape as the six dynamic
|
|
475
499
|
// imports doctor already uses.
|
|
476
|
-
const { isDbUnusableError, dbUnusableRemedy } = await import('./lib/db-unusable.mjs');
|
|
500
|
+
const { isDbUnusableError, dbUnusableRemedy, checkSnapshot } = await import('./lib/db-unusable.mjs');
|
|
477
501
|
if (!isDbUnusableError(err)) return null;
|
|
478
|
-
|
|
502
|
+
// doctor checks the snapshots (D#558): each is restored into a private copy and opened by the
|
|
503
|
+
// product's opener in a child process; the command names the newest that passes, and the older
|
|
504
|
+
// ones that pass are listed with their own commands (D#577). One line per check on stderr: a large
|
|
505
|
+
// snapshot takes seconds, and stdout may be the --json face.
|
|
506
|
+
const remedy = dbUnusableRemedy(dbPath, err, {
|
|
507
|
+
check: (path, { nth, of }) => {
|
|
508
|
+
process.stderr.write(` Checking backup snapshot ${nth} of ${of}: ${basename(path)}\n`);
|
|
509
|
+
return checkSnapshot(path);
|
|
510
|
+
},
|
|
511
|
+
});
|
|
479
512
|
if (remedy.kind === 'unknown') return remedy.note;
|
|
480
513
|
if (remedy.kind === 'schema') return `SQLite cannot read the database's schema. ${remedy.note}`;
|
|
481
|
-
// Both commands
|
|
482
|
-
//
|
|
483
|
-
//
|
|
514
|
+
// Both commands move the database file and its -wal aside and delete the -shm, under any session
|
|
515
|
+
// still holding the store (D#534). The SessionStart notice says the same before its copy of the
|
|
516
|
+
// command.
|
|
517
|
+
const kept = `The broken file and its log are kept as ${remedy.keptAs} and ${remedy.keptAs}-wal.`;
|
|
484
518
|
if (remedy.kind === 'set-aside') {
|
|
485
519
|
return (
|
|
486
|
-
|
|
487
|
-
`
|
|
520
|
+
`${remedy.found} Once every Claude Code session is closed, set the broken file aside so a fresh ` +
|
|
521
|
+
`store is created on the next session: ${remedy.command} — ${kept}`
|
|
488
522
|
);
|
|
489
523
|
}
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
524
|
+
// The older snapshots to choose from (D#577) follow the command they are the alternatives to; the
|
|
525
|
+
// list with their counts is in `found`, before it.
|
|
526
|
+
const also = (remedy.alternatives ?? []).map((a) => ` To restore ${a.path} instead: ${a.command}`).join('');
|
|
527
|
+
return `${remedy.found} Once every Claude Code session is closed, restore it: ${remedy.command} — ${kept}${also}`;
|
|
494
528
|
}
|
|
495
529
|
|
|
496
530
|
// ─── Install ────────────────────────────────────────────────────────────────
|
|
@@ -1371,8 +1405,9 @@ function backupLegacyClaudeMemData() {
|
|
|
1371
1405
|
// so the new install creates a fresh v28 DB.
|
|
1372
1406
|
try {
|
|
1373
1407
|
const r = migrateLegacyClaudeMemData(OLD_DATA_DIR, MEM_DATA_DIR);
|
|
1374
|
-
if (r.action === 'backed-up') {
|
|
1375
|
-
ok(`Legacy ~/.claude-mem/ DB backed up to ${r.backupPath}`);
|
|
1408
|
+
if (r.action === 'backed-up' || r.action === 'copied') {
|
|
1409
|
+
ok(`Legacy ~/.claude-mem/ DB ${r.action === 'copied' ? 'copied' : 'backed up'} to ${r.backupPath}`);
|
|
1410
|
+
if (r.action === 'copied') log('~/.claude-mem/ is on another filesystem and is left as it is.');
|
|
1376
1411
|
log('New v28 DB will be created on first launch (legacy schema is incompatible).');
|
|
1377
1412
|
}
|
|
1378
1413
|
} catch (e) {
|
|
@@ -3093,6 +3128,16 @@ async function doctor() {
|
|
|
3093
3128
|
}
|
|
3094
3129
|
|
|
3095
3130
|
// Database
|
|
3131
|
+
// A check of a backup snapshot that was interrupted (Ctrl-C, SIGTERM) leaves its private copy in
|
|
3132
|
+
// the data directory; sweep it before the check below, healthy store or not (D#558).
|
|
3133
|
+
if (!dataDirUnreadable) {
|
|
3134
|
+
try {
|
|
3135
|
+
const { sweepSnapshotChecks } = await import('./lib/db-unusable.mjs');
|
|
3136
|
+
sweepSnapshotChecks(dirname(DB_PATH));
|
|
3137
|
+
} catch {
|
|
3138
|
+
/* a sweep is housekeeping: it never takes the run */
|
|
3139
|
+
}
|
|
3140
|
+
}
|
|
3096
3141
|
if (dataDirUnreadable) {
|
|
3097
3142
|
notCheckedDenied('Database');
|
|
3098
3143
|
} else if (existsSync(DB_PATH) && bindingBrokenHere) {
|
package/lib/db-backup.mjs
CHANGED
|
@@ -52,7 +52,7 @@ const SNAPSHOT_STAMP_RE = /-\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}-\d{3}Z-\d+-\d+\.
|
|
|
52
52
|
* ends the reader's search with a false fact. Same rule the doctor bash-hook check
|
|
53
53
|
* settled on — "nothing to check" and "I could not look" are different answers.
|
|
54
54
|
*
|
|
55
|
-
* @returns {{ok: true, snapshots: Array<{path:string,size:number,mtimeMs:number}>}
|
|
55
|
+
* @returns {{ok: true, snapshots: Array<{path:string,size:number,mtimeMs:number,isFile:boolean}>}
|
|
56
56
|
* | {ok: false, reason: string}}
|
|
57
57
|
*/
|
|
58
58
|
export function readSnapshots(dbPath) {
|
|
@@ -76,7 +76,7 @@ export function readSnapshots(dbPath) {
|
|
|
76
76
|
const full = join(dir, n);
|
|
77
77
|
try {
|
|
78
78
|
const st = statSync(full);
|
|
79
|
-
snapshots.push({ path: full, size: st.size, mtimeMs: st.mtimeMs });
|
|
79
|
+
snapshots.push({ path: full, size: st.size, mtimeMs: st.mtimeMs, isFile: st.isFile() });
|
|
80
80
|
} catch {
|
|
81
81
|
/* raced away */
|
|
82
82
|
}
|