@lh8ppl/claude-memory-kit 0.2.3 → 0.2.4
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/package.json +1 -1
- package/src/doctor.mjs +52 -125
- package/src/mcp-server.mjs +1 -1
- package/src/result-shapes.mjs +2 -2
- package/src/search.mjs +6 -5
- package/src/spawn-bin.mjs +7 -2
- package/src/subcommands.mjs +6 -5
- package/template/support/cron-jobs/nightly-memsearch-index.md +0 -17
- package/template/support/milvus-deploy/README.md +0 -57
- package/template/support/milvus-deploy/docker-compose.yml +0 -66
- package/template/support/scripts/memsearch-index-with-flush.sh +0 -59
package/package.json
CHANGED
package/src/doctor.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// `cmk doctor` — health checks HC-1..HC-
|
|
1
|
+
// `cmk doctor` — health checks HC-1..HC-7 (Task 37, T-031; memsearch HC-1/HC-7 removed in Task 120).
|
|
2
2
|
//
|
|
3
3
|
// Public boundary:
|
|
4
4
|
// async runDoctor({projectRoot, userDir, now, promptUser?, ...overrides})
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
//
|
|
7
7
|
// HCResult shape:
|
|
8
8
|
// {
|
|
9
|
-
// id: 'HC-1' | ... | 'HC-
|
|
9
|
+
// id: 'HC-1' | ... | 'HC-7',
|
|
10
10
|
// name: string,
|
|
11
11
|
// status: 'pass' | 'fail' | 'skip',
|
|
12
12
|
// message: string,
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
// }
|
|
16
16
|
//
|
|
17
17
|
// Per design §14. Composes on:
|
|
18
|
-
// - cooldown.mjs (HC-
|
|
18
|
+
// - cooldown.mjs (HC-2 distill freshness via cooldown marker mtime is
|
|
19
19
|
// NOT used — we read recent.md mtime directly, more accurate)
|
|
20
|
-
// - lazy-compress.mjs::cronSentinelPath (HC-
|
|
21
|
-
// - lock-discipline.mjs::detectStaleLocks (HC-
|
|
20
|
+
// - lazy-compress.mjs::cronSentinelPath (HC-5 cron registration check)
|
|
21
|
+
// - lock-discipline.mjs::detectStaleLocks (HC-7)
|
|
22
22
|
// - platform-commands.mjs — cross-platform repair command emission
|
|
23
23
|
//
|
|
24
24
|
// Critical rule per design §14 + tasks.md 37.5: any repair requiring
|
|
@@ -38,7 +38,6 @@ import {
|
|
|
38
38
|
statSync,
|
|
39
39
|
writeFileSync,
|
|
40
40
|
} from 'node:fs';
|
|
41
|
-
import { spawnBinSync } from './spawn-bin.mjs';
|
|
42
41
|
import { homedir } from 'node:os';
|
|
43
42
|
import { basename, join } from 'node:path';
|
|
44
43
|
import { nowIso } from './audit-log.mjs';
|
|
@@ -56,62 +55,15 @@ const MEMORY_DIR_REL = ['context', 'memory'];
|
|
|
56
55
|
const LOCKS_REL = ['context', '.locks'];
|
|
57
56
|
const NATIVE_MEMORY_LOG_REL = ['context', '.locks', 'native-memory-status.log'];
|
|
58
57
|
|
|
59
|
-
// --- HC-1:
|
|
60
|
-
|
|
61
|
-
// Layer 5b (semantic search) is OPTIONAL per ADR-0008. Missing
|
|
62
|
-
// memsearch → skip (not fail). The kit ships keyword-only as v0.1.0;
|
|
63
|
-
// semantic requires a separate `pip install memsearch[onnx]`.
|
|
64
|
-
// `requiresInstall: true` so the CLI prompts before auto-installing.
|
|
65
|
-
try {
|
|
66
|
-
// spawnBinSync resolves the Windows .cmd shim without `shell:true`+args
|
|
67
|
-
// (no DEP0190; #4). memsearch's only arg is `--version` (no spaces), so
|
|
68
|
-
// the quoting is a no-op here — the win is dropping the deprecated combo.
|
|
69
|
-
const r = spawnBinSync('memsearch', ['--version'], {
|
|
70
|
-
encoding: 'utf8',
|
|
71
|
-
// M1 fix (skill-review 2026-05-28): 3.5s tolerates Windows
|
|
72
|
-
// cold-Python startup (AV scan + .pyc generation on first hit
|
|
73
|
-
// can push past 2s for a healthy install). HC-2..9 are file-
|
|
74
|
-
// system ops that complete in ≪100ms total, so HC-1 + the rest
|
|
75
|
-
// still fits comfortably inside the 5s NFR budget. Timeout →
|
|
76
|
-
// 'skip' so cmk doctor completes regardless.
|
|
77
|
-
timeout: 3_500,
|
|
78
|
-
});
|
|
79
|
-
if (r.status === 0) {
|
|
80
|
-
return {
|
|
81
|
-
id: 'HC-1',
|
|
82
|
-
name: 'memsearch installed (semantic search backend)',
|
|
83
|
-
status: 'pass',
|
|
84
|
-
message: `memsearch ${(r.stdout || '').trim() || 'detected'}`,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
} catch {
|
|
88
|
-
// fall through to skip
|
|
89
|
-
}
|
|
90
|
-
// The user (2026-05-28): make the feature impact explicit so users
|
|
91
|
-
// understand WHAT THEY LOSE by skipping the install, not just that
|
|
92
|
-
// a check failed. Matches the user's directive: "ask before we do
|
|
93
|
-
// anything, explain if they dont install they dont get certain
|
|
94
|
-
// features".
|
|
95
|
-
return {
|
|
96
|
-
id: 'HC-1',
|
|
97
|
-
name: 'memsearch installed (semantic search backend)',
|
|
98
|
-
status: 'skip',
|
|
99
|
-
message:
|
|
100
|
-
'memsearch not on PATH — Layer 5b semantic backend disabled. Features unavailable: `cmk search --mode=semantic` (will error), `cmk search --mode=hybrid` (will error). Keyword search (`cmk search --mode=keyword`, default) still works fully.',
|
|
101
|
-
recoveryCommand: 'python -m pip install "memsearch[onnx]"',
|
|
102
|
-
requiresInstall: true,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// --- HC-2: Stop + SessionStart hooks registered -----------------------
|
|
107
|
-
function hc2Hooks({ projectRoot }) {
|
|
58
|
+
// --- HC-1: Stop + SessionStart hooks registered -----------------------
|
|
59
|
+
function hc1Hooks({ projectRoot }) {
|
|
108
60
|
// Per design §5 — the kit's hooks live in .claude/settings.json
|
|
109
61
|
// alongside its plugin manifest. Required for auto-extract +
|
|
110
62
|
// session-end compression to fire.
|
|
111
63
|
const settingsPath = join(projectRoot, '.claude', 'settings.json');
|
|
112
64
|
if (!existsSync(settingsPath)) {
|
|
113
65
|
return {
|
|
114
|
-
id: 'HC-
|
|
66
|
+
id: 'HC-1',
|
|
115
67
|
name: 'Stop + SessionStart hooks registered',
|
|
116
68
|
status: 'fail',
|
|
117
69
|
message: '.claude/settings.json missing — hooks not wired',
|
|
@@ -123,7 +75,7 @@ function hc2Hooks({ projectRoot }) {
|
|
|
123
75
|
settings = JSON.parse(readFileSync(settingsPath, 'utf8'));
|
|
124
76
|
} catch (err) {
|
|
125
77
|
return {
|
|
126
|
-
id: 'HC-
|
|
78
|
+
id: 'HC-1',
|
|
127
79
|
name: 'Stop + SessionStart hooks registered',
|
|
128
80
|
status: 'fail',
|
|
129
81
|
message: `.claude/settings.json parse error: ${err?.message ?? err}`,
|
|
@@ -170,7 +122,7 @@ function hc2Hooks({ projectRoot }) {
|
|
|
170
122
|
}
|
|
171
123
|
if (missing.length > 0) {
|
|
172
124
|
return {
|
|
173
|
-
id: 'HC-
|
|
125
|
+
id: 'HC-1',
|
|
174
126
|
name: 'Stop + SessionStart hooks registered',
|
|
175
127
|
status: 'fail',
|
|
176
128
|
message: `missing hook references: ${missing.join(', ')}`,
|
|
@@ -178,15 +130,15 @@ function hc2Hooks({ projectRoot }) {
|
|
|
178
130
|
};
|
|
179
131
|
}
|
|
180
132
|
return {
|
|
181
|
-
id: 'HC-
|
|
133
|
+
id: 'HC-1',
|
|
182
134
|
name: 'Stop + SessionStart hooks registered',
|
|
183
135
|
status: 'pass',
|
|
184
136
|
message: 'all kit hooks wired to their correct event arrays in .claude/settings.json',
|
|
185
137
|
};
|
|
186
138
|
}
|
|
187
139
|
|
|
188
|
-
// --- HC-
|
|
189
|
-
function
|
|
140
|
+
// --- HC-2: distill freshness (≤2 days) --------------------------------
|
|
141
|
+
function hc2DistillFreshness({ projectRoot, now }) {
|
|
190
142
|
const recentPath = join(projectRoot, ...RECENT_MD_REL);
|
|
191
143
|
if (!existsSync(recentPath)) {
|
|
192
144
|
// Not a failure: on a fresh project there's nothing distilled yet, and
|
|
@@ -194,7 +146,7 @@ function hc3DistillFreshness({ projectRoot, now }) {
|
|
|
194
146
|
// (or `cmk daily-distill`). "Stale recent.md" below IS a real fail; a
|
|
195
147
|
// never-built one is just "not yet" — mirror HC-5's skip-on-fresh.
|
|
196
148
|
return {
|
|
197
|
-
id: 'HC-
|
|
149
|
+
id: 'HC-2',
|
|
198
150
|
name: 'Daily distill is fresh (≤2 days)',
|
|
199
151
|
status: 'skip',
|
|
200
152
|
message: 'recent.md not built yet — nothing to distill. Runs automatically (lazy-on-read at SessionStart, or `cmk daily-distill`) once there is session content.',
|
|
@@ -205,7 +157,7 @@ function hc3DistillFreshness({ projectRoot, now }) {
|
|
|
205
157
|
mtimeMs = statSync(recentPath).mtimeMs;
|
|
206
158
|
} catch (err) {
|
|
207
159
|
return {
|
|
208
|
-
id: 'HC-
|
|
160
|
+
id: 'HC-2',
|
|
209
161
|
name: 'Daily distill is fresh (≤2 days)',
|
|
210
162
|
status: 'fail',
|
|
211
163
|
message: `recent.md stat error: ${err?.message ?? err}`,
|
|
@@ -216,7 +168,7 @@ function hc3DistillFreshness({ projectRoot, now }) {
|
|
|
216
168
|
const ageMs = nowMs - mtimeMs;
|
|
217
169
|
if (ageMs > TWO_DAYS_MS) {
|
|
218
170
|
return {
|
|
219
|
-
id: 'HC-
|
|
171
|
+
id: 'HC-2',
|
|
220
172
|
name: 'Daily distill is fresh (≤2 days)',
|
|
221
173
|
status: 'fail',
|
|
222
174
|
message: `recent.md ${Math.round(ageMs / (24 * 60 * 60 * 1000))}d old (cutoff: 2d)`,
|
|
@@ -224,21 +176,21 @@ function hc3DistillFreshness({ projectRoot, now }) {
|
|
|
224
176
|
};
|
|
225
177
|
}
|
|
226
178
|
return {
|
|
227
|
-
id: 'HC-
|
|
179
|
+
id: 'HC-2',
|
|
228
180
|
name: 'Daily distill is fresh (≤2 days)',
|
|
229
181
|
status: 'pass',
|
|
230
182
|
message: `recent.md ${Math.round(ageMs / (60 * 60 * 1000))}h old`,
|
|
231
183
|
};
|
|
232
184
|
}
|
|
233
185
|
|
|
234
|
-
// --- HC-
|
|
235
|
-
function
|
|
186
|
+
// --- HC-3: transcripts firing (≤3 days) -------------------------------
|
|
187
|
+
function hc3Transcripts({ projectRoot, now }) {
|
|
236
188
|
const transcriptsDir = join(projectRoot, ...TRANSCRIPTS_REL);
|
|
237
189
|
if (!existsSync(transcriptsDir)) {
|
|
238
190
|
// Fresh project, never had a Claude Code session here → nothing to fire
|
|
239
191
|
// yet. Skip, don't fail (the dir + first transcript appear on the first turn).
|
|
240
192
|
return {
|
|
241
|
-
id: 'HC-
|
|
193
|
+
id: 'HC-3',
|
|
242
194
|
name: 'Transcripts firing (≤3 days)',
|
|
243
195
|
status: 'skip',
|
|
244
196
|
message: 'no transcripts yet — they appear after your first Claude Code turn in this project.',
|
|
@@ -262,7 +214,7 @@ function hc4Transcripts({ projectRoot, now }) {
|
|
|
262
214
|
// Dir exists (scaffolded) but no transcripts captured yet → still "not
|
|
263
215
|
// yet", not a failure.
|
|
264
216
|
return {
|
|
265
|
-
id: 'HC-
|
|
217
|
+
id: 'HC-3',
|
|
266
218
|
name: 'Transcripts firing (≤3 days)',
|
|
267
219
|
status: 'skip',
|
|
268
220
|
message: 'no transcripts yet — they appear after your first Claude Code turn in this project.',
|
|
@@ -272,7 +224,7 @@ function hc4Transcripts({ projectRoot, now }) {
|
|
|
272
224
|
// Transcripts EXIST but none recent → the kit was capturing and stopped.
|
|
273
225
|
// That IS a real signal (the Stop hook may not be firing here).
|
|
274
226
|
return {
|
|
275
|
-
id: 'HC-
|
|
227
|
+
id: 'HC-3',
|
|
276
228
|
name: 'Transcripts firing (≤3 days)',
|
|
277
229
|
status: 'fail',
|
|
278
230
|
message: 'transcripts exist but none within 3 days — the Stop hook may have stopped firing (is this project Claude Code\'s primary cwd?)',
|
|
@@ -280,20 +232,20 @@ function hc4Transcripts({ projectRoot, now }) {
|
|
|
280
232
|
};
|
|
281
233
|
}
|
|
282
234
|
return {
|
|
283
|
-
id: 'HC-
|
|
235
|
+
id: 'HC-3',
|
|
284
236
|
name: 'Transcripts firing (≤3 days)',
|
|
285
237
|
status: 'pass',
|
|
286
238
|
message: `${recentCount} transcript(s) within 3 days`,
|
|
287
239
|
};
|
|
288
240
|
}
|
|
289
241
|
|
|
290
|
-
// --- HC-
|
|
291
|
-
function
|
|
242
|
+
// --- HC-4: INDEX.md matches context/memory/ ---------------------------
|
|
243
|
+
function hc4IndexConsistency({ projectRoot }) {
|
|
292
244
|
const memoryDir = join(projectRoot, ...MEMORY_DIR_REL);
|
|
293
245
|
const indexPath = join(projectRoot, ...MEMORY_INDEX_REL);
|
|
294
246
|
if (!existsSync(memoryDir)) {
|
|
295
247
|
return {
|
|
296
|
-
id: 'HC-
|
|
248
|
+
id: 'HC-4',
|
|
297
249
|
name: 'INDEX.md matches context/memory/ files',
|
|
298
250
|
status: 'skip',
|
|
299
251
|
message: 'context/memory/ missing — no granular facts to index yet',
|
|
@@ -301,7 +253,7 @@ function hc5IndexConsistency({ projectRoot }) {
|
|
|
301
253
|
}
|
|
302
254
|
if (!existsSync(indexPath)) {
|
|
303
255
|
return {
|
|
304
|
-
id: 'HC-
|
|
256
|
+
id: 'HC-4',
|
|
305
257
|
name: 'INDEX.md matches context/memory/ files',
|
|
306
258
|
status: 'fail',
|
|
307
259
|
message: 'context/memory/INDEX.md missing',
|
|
@@ -316,7 +268,7 @@ function hc5IndexConsistency({ projectRoot }) {
|
|
|
316
268
|
);
|
|
317
269
|
} catch (err) {
|
|
318
270
|
return {
|
|
319
|
-
id: 'HC-
|
|
271
|
+
id: 'HC-4',
|
|
320
272
|
name: 'INDEX.md matches context/memory/ files',
|
|
321
273
|
status: 'fail',
|
|
322
274
|
message: `readdir error: ${err?.message ?? err}`,
|
|
@@ -330,7 +282,7 @@ function hc5IndexConsistency({ projectRoot }) {
|
|
|
330
282
|
indexText = readFileSync(indexPath, 'utf8');
|
|
331
283
|
} catch (err) {
|
|
332
284
|
return {
|
|
333
|
-
id: 'HC-
|
|
285
|
+
id: 'HC-4',
|
|
334
286
|
name: 'INDEX.md matches context/memory/ files',
|
|
335
287
|
status: 'fail',
|
|
336
288
|
message: `INDEX.md read error: ${err?.message ?? err}`,
|
|
@@ -365,7 +317,7 @@ function hc5IndexConsistency({ projectRoot }) {
|
|
|
365
317
|
const inIndexNotFacts = [...indexEntries].filter((f) => !factSet.has(f));
|
|
366
318
|
if (inFactsNotIndex.length === 0 && inIndexNotFacts.length === 0) {
|
|
367
319
|
return {
|
|
368
|
-
id: 'HC-
|
|
320
|
+
id: 'HC-4',
|
|
369
321
|
name: 'INDEX.md matches context/memory/ files',
|
|
370
322
|
status: 'pass',
|
|
371
323
|
message: `${factFiles.length} fact file(s); INDEX in sync`,
|
|
@@ -375,7 +327,7 @@ function hc5IndexConsistency({ projectRoot }) {
|
|
|
375
327
|
if (inFactsNotIndex.length > 0) parts.push(`missing from INDEX: ${inFactsNotIndex.length}`);
|
|
376
328
|
if (inIndexNotFacts.length > 0) parts.push(`stale in INDEX: ${inIndexNotFacts.length}`);
|
|
377
329
|
return {
|
|
378
|
-
id: 'HC-
|
|
330
|
+
id: 'HC-4',
|
|
379
331
|
name: 'INDEX.md matches context/memory/ files',
|
|
380
332
|
status: 'fail',
|
|
381
333
|
message: parts.join('; '),
|
|
@@ -383,11 +335,11 @@ function hc5IndexConsistency({ projectRoot }) {
|
|
|
383
335
|
};
|
|
384
336
|
}
|
|
385
337
|
|
|
386
|
-
// --- HC-
|
|
387
|
-
function
|
|
338
|
+
// --- HC-5: Cron jobs registered with host scheduler -------------------
|
|
339
|
+
function hc5CronRegistered({ projectRoot }) {
|
|
388
340
|
if (existsSync(cronSentinelPath(projectRoot))) {
|
|
389
341
|
return {
|
|
390
|
-
id: 'HC-
|
|
342
|
+
id: 'HC-5',
|
|
391
343
|
name: 'Cron jobs registered with host scheduler',
|
|
392
344
|
status: 'pass',
|
|
393
345
|
message: 'cron-registered sentinel present',
|
|
@@ -398,38 +350,15 @@ function hc6CronRegistered({ projectRoot }) {
|
|
|
398
350
|
// SKIP, not a FAIL — flagging an optional, working-by-fallback feature as a
|
|
399
351
|
// failure made a healthy fresh install read as broken.
|
|
400
352
|
return {
|
|
401
|
-
id: 'HC-
|
|
353
|
+
id: 'HC-5',
|
|
402
354
|
name: 'Cron jobs registered with host scheduler',
|
|
403
355
|
status: 'skip',
|
|
404
356
|
message: 'cron not registered (optional) — using the lazy-on-read fallback (compresses at SessionStart). Run `cmk register-crons` for scheduled background compression.',
|
|
405
357
|
};
|
|
406
358
|
}
|
|
407
359
|
|
|
408
|
-
// --- HC-
|
|
409
|
-
function
|
|
410
|
-
// Only relevant if HC-1 passed. Skip when memsearch isn't installed.
|
|
411
|
-
if (hc1Result.status !== 'pass') {
|
|
412
|
-
return {
|
|
413
|
-
id: 'HC-7',
|
|
414
|
-
name: 'memsearch backend reachable',
|
|
415
|
-
status: 'skip',
|
|
416
|
-
message: 'depends on HC-1 (memsearch installed) — skipped',
|
|
417
|
-
};
|
|
418
|
-
}
|
|
419
|
-
// HC-1 already proves memsearch --version succeeds. For HC-7 the
|
|
420
|
-
// additional check would be milvus reachability — out of scope for
|
|
421
|
-
// v0.1.0's keyword-only ship (Layer 5b is v0.1.x). Treat HC-7 as
|
|
422
|
-
// pass when HC-1 passes.
|
|
423
|
-
return {
|
|
424
|
-
id: 'HC-7',
|
|
425
|
-
name: 'memsearch backend reachable',
|
|
426
|
-
status: 'pass',
|
|
427
|
-
message: 'memsearch responds to --version (milvus reachability is Layer 5b / v0.1.x)',
|
|
428
|
-
};
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
// --- HC-8: Native Anthropic Auto Memory status -----------------------
|
|
432
|
-
function hc8NativeAutoMemory({ projectRoot, now }) {
|
|
360
|
+
// --- HC-6: Native Anthropic Auto Memory status -----------------------
|
|
361
|
+
function hc6NativeAutoMemory({ projectRoot, now }) {
|
|
433
362
|
// Per ADR-0011 — detect whether Anthropic's native Auto Memory is
|
|
434
363
|
// also active for this project. Non-fatal; informational. Log the
|
|
435
364
|
// result to context/.locks/native-memory-status.log so users can
|
|
@@ -507,19 +436,19 @@ function hc8NativeAutoMemory({ projectRoot, now }) {
|
|
|
507
436
|
}
|
|
508
437
|
|
|
509
438
|
return {
|
|
510
|
-
id: 'HC-
|
|
439
|
+
id: 'HC-6',
|
|
511
440
|
name: 'Native Anthropic Auto Memory status detected',
|
|
512
441
|
status: 'pass',
|
|
513
442
|
message,
|
|
514
443
|
};
|
|
515
444
|
}
|
|
516
445
|
|
|
517
|
-
// --- HC-
|
|
518
|
-
function
|
|
446
|
+
// --- HC-7: Stale lock files -------------------------------------------
|
|
447
|
+
function hc7StaleLocks({ projectRoot, userDir }) {
|
|
519
448
|
const stale = detectStaleLocks(projectRoot, { userDir }).filter((r) => r.stale);
|
|
520
449
|
if (stale.length === 0) {
|
|
521
450
|
return {
|
|
522
|
-
id: 'HC-
|
|
451
|
+
id: 'HC-7',
|
|
523
452
|
name: 'No stale lock files',
|
|
524
453
|
status: 'pass',
|
|
525
454
|
message: 'all locks healthy',
|
|
@@ -533,7 +462,7 @@ function hc9StaleLocks({ projectRoot, userDir }) {
|
|
|
533
462
|
? ` (+ ${stale.length - 1} more — re-run after cleaning to surface)`
|
|
534
463
|
: '';
|
|
535
464
|
return {
|
|
536
|
-
id: 'HC-
|
|
465
|
+
id: 'HC-7',
|
|
537
466
|
name: 'No stale lock files',
|
|
538
467
|
status: 'fail',
|
|
539
468
|
message: `${stale.length} stale lock(s); first: ${first.path} (${first.reason})${moreNote}`,
|
|
@@ -542,7 +471,7 @@ function hc9StaleLocks({ projectRoot, userDir }) {
|
|
|
542
471
|
}
|
|
543
472
|
|
|
544
473
|
/**
|
|
545
|
-
* Run the full
|
|
474
|
+
* Run the full 7-check health audit.
|
|
546
475
|
*
|
|
547
476
|
* @param {object} opts
|
|
548
477
|
* @param {string} opts.projectRoot
|
|
@@ -573,20 +502,18 @@ export async function runDoctor({
|
|
|
573
502
|
const ts = now ?? nowIso();
|
|
574
503
|
const resolvedUserDir = userDir ?? join(homedir(), '.claude-memory-kit');
|
|
575
504
|
|
|
576
|
-
// Run in order.
|
|
577
|
-
const c1 =
|
|
578
|
-
const c2 =
|
|
579
|
-
const c3 =
|
|
580
|
-
const c4 =
|
|
581
|
-
const c5 =
|
|
582
|
-
const c6 =
|
|
583
|
-
const c7 =
|
|
584
|
-
const c8 = hc8NativeAutoMemory({ projectRoot, now: ts });
|
|
585
|
-
const c9 = hc9StaleLocks({ projectRoot, userDir: resolvedUserDir });
|
|
505
|
+
// Run all checks in order.
|
|
506
|
+
const c1 = hc1Hooks({ projectRoot });
|
|
507
|
+
const c2 = hc2DistillFreshness({ projectRoot, now: ts });
|
|
508
|
+
const c3 = hc3Transcripts({ projectRoot, now: ts });
|
|
509
|
+
const c4 = hc4IndexConsistency({ projectRoot });
|
|
510
|
+
const c5 = hc5CronRegistered({ projectRoot });
|
|
511
|
+
const c6 = hc6NativeAutoMemory({ projectRoot, now: ts });
|
|
512
|
+
const c7 = hc7StaleLocks({ projectRoot, userDir: resolvedUserDir });
|
|
586
513
|
|
|
587
514
|
return {
|
|
588
515
|
action: 'completed',
|
|
589
|
-
checks: [c1, c2, c3, c4, c5, c6, c7
|
|
516
|
+
checks: [c1, c2, c3, c4, c5, c6, c7],
|
|
590
517
|
duration_ms: Date.now() - t0,
|
|
591
518
|
};
|
|
592
519
|
}
|
package/src/mcp-server.mjs
CHANGED
|
@@ -505,7 +505,7 @@ export function buildMcpServer({ projectRoot, userDir, db, semanticBackend }) {
|
|
|
505
505
|
server.registerTool(
|
|
506
506
|
'mk_search',
|
|
507
507
|
{
|
|
508
|
-
description: 'Search kit memory (FTS5 keyword by default; semantic + hybrid require Layer
|
|
508
|
+
description: 'Search kit memory (FTS5 keyword by default; semantic + hybrid require the Layer-5b semantic backend, not yet shipped).',
|
|
509
509
|
inputSchema: {
|
|
510
510
|
query: z.string().min(1).describe('search query'),
|
|
511
511
|
mode: z.enum(['keyword', 'semantic', 'hybrid']).optional(),
|
package/src/result-shapes.mjs
CHANGED
|
@@ -104,9 +104,9 @@ export const ERROR_CATEGORIES = Object.freeze({
|
|
|
104
104
|
POISON_GUARD: 'poison_guard',
|
|
105
105
|
|
|
106
106
|
// `cmk search` requested --mode=semantic or --mode=hybrid but the
|
|
107
|
-
// Layer
|
|
107
|
+
// Layer-5b semantic backend is not yet shipped (Task 30, design
|
|
108
108
|
// §9.3). Pairs with `process.exitCode = 2` in subcommands.mjs per
|
|
109
|
-
// tasks.md 30.2's explicit "exit 2 when
|
|
109
|
+
// tasks.md 30.2's explicit "exit 2 when unavailable" contract.
|
|
110
110
|
// NO silent fallback to keyword — the user asked for semantic,
|
|
111
111
|
// and the surface should fail-loud so they know what's missing.
|
|
112
112
|
SEMANTIC_UNAVAILABLE: 'semantic_unavailable',
|
package/src/search.mjs
CHANGED
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
// ~100ms for 10k bullets. Always available — the keyword
|
|
12
12
|
// backend ships in v0.1.0 with no extra install.
|
|
13
13
|
//
|
|
14
|
-
// semantic
|
|
15
|
-
//
|
|
14
|
+
// semantic the Layer-5b semantic backend (not yet shipped — the embedded
|
|
15
|
+
// vector backend is a future release; the DI seam below is the
|
|
16
|
+
// drop-in point). Until then this mode errors with
|
|
16
17
|
// ERROR_CATEGORIES.SEMANTIC_UNAVAILABLE when the caller
|
|
17
18
|
// requests it without injecting a semantic backend. NO silent
|
|
18
19
|
// fallback to keyword — design §9.3's explicit "exit 2 when
|
|
@@ -260,14 +261,14 @@ export function search(opts = {}) {
|
|
|
260
261
|
}
|
|
261
262
|
|
|
262
263
|
// Semantic + hybrid require an injected backend. Production v0.1.0
|
|
263
|
-
// passes undefined → error with the
|
|
264
|
-
// wires the real backend.
|
|
264
|
+
// passes undefined → error with the not-yet-shipped hint. A future
|
|
265
|
+
// release wires the real Layer-5b backend via the semanticBackend seam.
|
|
265
266
|
if (mode === SEARCH_MODES.SEMANTIC || mode === SEARCH_MODES.HYBRID) {
|
|
266
267
|
if (typeof opts.semanticBackend !== 'function') {
|
|
267
268
|
return errorResult({
|
|
268
269
|
category: ERROR_CATEGORIES.SEMANTIC_UNAVAILABLE,
|
|
269
270
|
errors: [
|
|
270
|
-
'
|
|
271
|
+
'the Layer-5b semantic backend is not yet shipped — semantic/hybrid search will land in a future release. ' +
|
|
271
272
|
'Use --mode=keyword for the always-available FTS5 search.',
|
|
272
273
|
],
|
|
273
274
|
});
|
package/src/spawn-bin.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
// Why this exists
|
|
5
5
|
// ---------------
|
|
6
|
-
// Spawning an npm-global bin (claude,
|
|
6
|
+
// Spawning an npm-global bin (claude, cmk-*) needs `shell:true` on
|
|
7
7
|
// Windows so the `.cmd` shim resolves through cmd.exe — Node won't auto-resolve
|
|
8
8
|
// `.cmd`/`.bat` without a shell (CVE-2024-27980 hardening). But `shell:true`
|
|
9
9
|
// WITH an args array is doubly bad:
|
|
@@ -73,7 +73,12 @@ export function spawnBin(bin, args = [], opts = {}, deps = {}) {
|
|
|
73
73
|
return spawnImpl(bin, args, { ...opts, shell: false });
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
/**
|
|
76
|
+
/**
|
|
77
|
+
* Synchronous twin of spawnBin, for one-shot bin checks.
|
|
78
|
+
* NOTE: currently unused — the `cmk doctor` memsearch probe that used it was
|
|
79
|
+
* removed in Task 120. Kept as the sync counterpart to spawnBin for future
|
|
80
|
+
* one-shot checks; remove if it stays unused.
|
|
81
|
+
*/
|
|
77
82
|
export function spawnBinSync(bin, args = [], opts = {}, deps = {}) {
|
|
78
83
|
const { spawnImpl = spawnSync, platform = process.platform } = deps;
|
|
79
84
|
if (platform === 'win32') {
|
package/src/subcommands.mjs
CHANGED
|
@@ -249,10 +249,11 @@ function runLessonsPromote(id, options = {}) {
|
|
|
249
249
|
/**
|
|
250
250
|
* `cmk search` — Task 30. Hybrid keyword + optional semantic.
|
|
251
251
|
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
252
|
+
* The keyword backend (FTS5 BM25 over the observations index) always
|
|
253
|
+
* ships. Semantic + hybrid modes require the Layer-5b semantic backend,
|
|
254
|
+
* which is not yet shipped; both error with exit code 2 and a clear
|
|
255
|
+
* "not yet shipped" hint per tasks.md 30.2. The `semanticBackend` DI seam
|
|
256
|
+
* is the drop-in point for the future backend.
|
|
256
257
|
*
|
|
257
258
|
* Filter flags (per tasks.md 30.4):
|
|
258
259
|
* --mode <keyword|semantic|hybrid> (default keyword)
|
|
@@ -1652,7 +1653,7 @@ export const subcommands = [
|
|
|
1652
1653
|
milestone: 30,
|
|
1653
1654
|
argSpec: [{ flags: '<query...>', description: 'query terms' }],
|
|
1654
1655
|
optionSpec: [
|
|
1655
|
-
{ flags: '--mode <mode>', description: 'keyword | semantic | hybrid (default: keyword; semantic+hybrid need
|
|
1656
|
+
{ flags: '--mode <mode>', description: 'keyword | semantic | hybrid (default: keyword; semantic + hybrid need the Layer-5b semantic backend, not yet shipped)' },
|
|
1656
1657
|
{ flags: '--min-trust <level>', description: 'low | medium | high' },
|
|
1657
1658
|
{ flags: '--tier <tier>', description: 'U | P | L (filter to a single tier)' },
|
|
1658
1659
|
{ flags: '--since <date>', description: 'ISO date — exclude observations older than this' },
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Nightly MemSearch Index
|
|
3
|
-
time: '02:00'
|
|
4
|
-
days: daily
|
|
5
|
-
active: 'true'
|
|
6
|
-
description: 'Re-indexes context/ markdown files for vector search'
|
|
7
|
-
timeout: 10m
|
|
8
|
-
job_type: shell_command
|
|
9
|
-
command: 'bash scripts/memsearch-index-with-flush.sh context/memory context/sessions context/transcripts'
|
|
10
|
-
working_directory: '${CLAUDE_PROJECT_DIR}'
|
|
11
|
-
# Requires Layer 5 installed (memsearch on PATH + a reachable Milvus backend).
|
|
12
|
-
# On Windows: Docker Desktop running with Milvus container — see context/SETUP.md.
|
|
13
|
-
# If memsearch isn't installed or backend isn't reachable, the task will fail;
|
|
14
|
-
# HC-7 (backend reachability) will flag it on the next session start.
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
Updates the memsearch vector index with any new content from `context/memory/`, `context/sessions/`, and `context/transcripts/`. Idempotent: only re-embeds chunks whose hash changed since the last run.
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
# Milvus deployment (Windows + optional)
|
|
2
|
-
|
|
3
|
-
This compose stack runs Milvus v2.6.16 plus its required dependencies (etcd, MinIO) as three local containers. It's used by **Layer 5** (memsearch vector search) of the memory system.
|
|
4
|
-
|
|
5
|
-
## When you need this
|
|
6
|
-
|
|
7
|
-
- **Windows**: required. `milvus-lite` (the default embedded vector store memsearch ships) has no Windows wheels on PyPI. Use this Docker stack instead.
|
|
8
|
-
- **Linux / macOS**: optional. memsearch auto-installs milvus-lite and uses it at `~/.memsearch/milvus.db`. Skip this directory entirely unless you specifically want a remote Milvus.
|
|
9
|
-
|
|
10
|
-
## Bring it up
|
|
11
|
-
|
|
12
|
-
```bash
|
|
13
|
-
cd milvus-deploy
|
|
14
|
-
docker compose up -d
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Wait ~30-60 seconds for all three containers to report `(healthy)`:
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
docker compose ps
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
You should see `milvus-etcd`, `milvus-minio`, `milvus-standalone` all `Up (healthy)`.
|
|
24
|
-
|
|
25
|
-
## Configure memsearch to use it
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
memsearch config set milvus.uri "http://localhost:19530"
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Bring it down
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
docker compose down
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
Volumes persist in `./volumes/` — re-running `up -d` reuses the same data.
|
|
38
|
-
|
|
39
|
-
## Why a multi-container stack and not just `milvus-standalone`?
|
|
40
|
-
|
|
41
|
-
Milvus standalone needs etcd (metadata store) and MinIO (object storage for segments and index data). On Linux/macOS, `milvus-lite` bundles all of that into one Python wheel; on Windows there's no equivalent wheel, so the three services run as separate containers.
|
|
42
|
-
|
|
43
|
-
The single-container `docker run milvusdb/milvus:latest standalone` pattern referenced in some older docs is no longer supported — `latest` is `v3.0-beta` whose entrypoint doesn't accept `standalone` as a command. Use this compose file with the pinned versions instead.
|
|
44
|
-
|
|
45
|
-
## Known quirk: memsearch index without flush
|
|
46
|
-
|
|
47
|
-
memsearch v0.4.x doesn't call `flush()` after `MilvusStore.upsert()`. On Milvus v2.6+ (Woodpecker WAL), this means `memsearch index` reports success but the data isn't searchable until a flush forces the growing segment to seal.
|
|
48
|
-
|
|
49
|
-
Use `scripts/memsearch-index-with-flush.sh` instead of raw `memsearch index` until upstream ships a fix. Tracked as [memsearch issue #534](https://github.com/zilliztech/memsearch/issues/534).
|
|
50
|
-
|
|
51
|
-
## Pinned versions
|
|
52
|
-
|
|
53
|
-
| Image | Version | Why pinned |
|
|
54
|
-
|---|---|---|
|
|
55
|
-
| `milvusdb/milvus` | `v2.6.16` | Latest stable v2.6 line. `latest` tag is v3.0-beta and crashes. |
|
|
56
|
-
| `quay.io/coreos/etcd` | `v3.5.25` | Compatible with milvus v2.6. |
|
|
57
|
-
| `minio/minio` | `RELEASE.2024-12-18T13-15-44Z` | Recent stable RELEASE tag. |
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
version: '3.5'
|
|
2
|
-
|
|
3
|
-
services:
|
|
4
|
-
etcd:
|
|
5
|
-
container_name: milvus-etcd
|
|
6
|
-
image: quay.io/coreos/etcd:v3.5.25
|
|
7
|
-
environment:
|
|
8
|
-
- ETCD_AUTO_COMPACTION_MODE=revision
|
|
9
|
-
- ETCD_AUTO_COMPACTION_RETENTION=1000
|
|
10
|
-
- ETCD_QUOTA_BACKEND_BYTES=4294967296
|
|
11
|
-
- ETCD_SNAPSHOT_COUNT=50000
|
|
12
|
-
volumes:
|
|
13
|
-
- ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/etcd:/etcd
|
|
14
|
-
command: etcd -advertise-client-urls=http://etcd:2379 -listen-client-urls http://0.0.0.0:2379 --data-dir /etcd
|
|
15
|
-
healthcheck:
|
|
16
|
-
test: ["CMD", "etcdctl", "endpoint", "health"]
|
|
17
|
-
interval: 30s
|
|
18
|
-
timeout: 20s
|
|
19
|
-
retries: 3
|
|
20
|
-
|
|
21
|
-
minio:
|
|
22
|
-
container_name: milvus-minio
|
|
23
|
-
image: minio/minio:RELEASE.2024-12-18T13-15-44Z
|
|
24
|
-
environment:
|
|
25
|
-
MINIO_ACCESS_KEY: minioadmin
|
|
26
|
-
MINIO_SECRET_KEY: minioadmin
|
|
27
|
-
ports:
|
|
28
|
-
- "9001:9001"
|
|
29
|
-
- "9000:9000"
|
|
30
|
-
volumes:
|
|
31
|
-
- ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/minio:/minio_data
|
|
32
|
-
command: minio server /minio_data --console-address ":9001"
|
|
33
|
-
healthcheck:
|
|
34
|
-
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
|
|
35
|
-
interval: 30s
|
|
36
|
-
timeout: 20s
|
|
37
|
-
retries: 3
|
|
38
|
-
|
|
39
|
-
standalone:
|
|
40
|
-
container_name: milvus-standalone
|
|
41
|
-
image: milvusdb/milvus:v2.6.16
|
|
42
|
-
command: ["milvus", "run", "standalone"]
|
|
43
|
-
security_opt:
|
|
44
|
-
- seccomp:unconfined
|
|
45
|
-
environment:
|
|
46
|
-
ETCD_ENDPOINTS: etcd:2379
|
|
47
|
-
MINIO_ADDRESS: minio:9000
|
|
48
|
-
MQ_TYPE: woodpecker
|
|
49
|
-
volumes:
|
|
50
|
-
- ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/milvus:/var/lib/milvus
|
|
51
|
-
healthcheck:
|
|
52
|
-
test: ["CMD", "curl", "-f", "http://localhost:9091/healthz"]
|
|
53
|
-
interval: 30s
|
|
54
|
-
start_period: 90s
|
|
55
|
-
timeout: 20s
|
|
56
|
-
retries: 3
|
|
57
|
-
ports:
|
|
58
|
-
- "19530:19530"
|
|
59
|
-
- "9091:9091"
|
|
60
|
-
depends_on:
|
|
61
|
-
- "etcd"
|
|
62
|
-
- "minio"
|
|
63
|
-
|
|
64
|
-
networks:
|
|
65
|
-
default:
|
|
66
|
-
name: milvus
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
# Wraps `memsearch index` to also force a Milvus flush afterward.
|
|
4
|
-
#
|
|
5
|
-
# Why: Milvus v2.6+ uses the Woodpecker WAL backend, which (unlike v2.5's
|
|
6
|
-
# Pulsar) does not auto-flush growing segments on a short timer. As a result,
|
|
7
|
-
# `memsearch index` reports "Indexed N chunks" successfully but
|
|
8
|
-
# `get_collection_stats` returns 0 rows and search returns no results until
|
|
9
|
-
# a manual flush forces the growing segment to seal.
|
|
10
|
-
#
|
|
11
|
-
# This wrapper runs the index, then issues a flush via pymilvus.
|
|
12
|
-
#
|
|
13
|
-
# Usage:
|
|
14
|
-
# bash scripts/memsearch-index-with-flush.sh context/memory context/sessions context/transcripts
|
|
15
|
-
#
|
|
16
|
-
# Reads MILVUS_URI from env (falls back to the memsearch config value, then localhost).
|
|
17
|
-
# Reads MILVUS_COLLECTION from env (falls back to memsearch config, then "memsearch_chunks").
|
|
18
|
-
|
|
19
|
-
# Task Scheduler / launchd / unattended cron contexts don't always inherit
|
|
20
|
-
# the user's PATH. Set it up explicitly for the common locations.
|
|
21
|
-
case ":$PATH:" in
|
|
22
|
-
*":/usr/bin:"*) ;;
|
|
23
|
-
*) export PATH="/usr/bin:/usr/local/bin:/opt/homebrew/bin:/c/Program Files/Git/usr/bin:$PATH" ;;
|
|
24
|
-
esac
|
|
25
|
-
|
|
26
|
-
# On Windows, also add the Python Scripts dir where `memsearch.exe` lands.
|
|
27
|
-
if [ -d "/c/Users/$USERNAME/AppData/Local/Programs/Python" ]; then
|
|
28
|
-
for d in /c/Users/$USERNAME/AppData/Local/Programs/Python/Python*/Scripts \
|
|
29
|
-
/c/Users/$USERNAME/AppData/Local/Programs/Python/Python*; do
|
|
30
|
-
[ -d "$d" ] && export PATH="$d:$PATH"
|
|
31
|
-
done
|
|
32
|
-
fi
|
|
33
|
-
|
|
34
|
-
set -euo pipefail
|
|
35
|
-
|
|
36
|
-
# Step 1 — index. Pass through all args.
|
|
37
|
-
memsearch index "$@"
|
|
38
|
-
|
|
39
|
-
# Step 2 — flush.
|
|
40
|
-
MILVUS_URI="${MILVUS_URI:-$(memsearch config get milvus.uri 2>/dev/null | tail -n1 | tr -d '\r')}"
|
|
41
|
-
MILVUS_COLLECTION="${MILVUS_COLLECTION:-$(memsearch config get milvus.collection 2>/dev/null | tail -n1 | tr -d '\r')}"
|
|
42
|
-
MILVUS_URI="${MILVUS_URI:-http://localhost:19530}"
|
|
43
|
-
MILVUS_COLLECTION="${MILVUS_COLLECTION:-memsearch_chunks}"
|
|
44
|
-
|
|
45
|
-
# Flush only if we're using a remote Milvus (milvus-lite auto-flushes).
|
|
46
|
-
case "$MILVUS_URI" in
|
|
47
|
-
http://*|https://*|tcp://*)
|
|
48
|
-
python -c "
|
|
49
|
-
from pymilvus import MilvusClient
|
|
50
|
-
client = MilvusClient(uri='${MILVUS_URI}')
|
|
51
|
-
client.flush('${MILVUS_COLLECTION}')
|
|
52
|
-
stats = client.get_collection_stats('${MILVUS_COLLECTION}')
|
|
53
|
-
print(f'Flushed. Collection {stats!r}')
|
|
54
|
-
"
|
|
55
|
-
;;
|
|
56
|
-
*)
|
|
57
|
-
echo "Local milvus-lite detected (${MILVUS_URI}); skipping flush (auto-flush)."
|
|
58
|
-
;;
|
|
59
|
-
esac
|