@spike1292/claude-memory 0.0.0-stage → 0.14.0

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.
Files changed (74) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +412 -2
  3. package/hooks/distill-session.mjs +74 -0
  4. package/hooks/graph-staleness-check.mjs +25 -0
  5. package/hooks/hooks.json +94 -0
  6. package/hooks/insights-surface.mjs +48 -0
  7. package/hooks/lib/distill-session.mjs +1560 -0
  8. package/hooks/lib/dupe-report.mjs +61 -0
  9. package/hooks/lib/env-shell.mjs +92 -0
  10. package/hooks/lib/graph-staleness-check.mjs +394 -0
  11. package/hooks/lib/hook-io.mjs +715 -0
  12. package/hooks/lib/insights-surface.mjs +165 -0
  13. package/hooks/lib/memory-link-lint.mjs +499 -0
  14. package/hooks/lib/memory-recall.mjs +219 -0
  15. package/hooks/lib/omp.mjs +103 -0
  16. package/hooks/lib/opencode.mjs +231 -0
  17. package/hooks/lib/paths.mjs +452 -0
  18. package/hooks/lib/semantic-index-refresh.mjs +155 -0
  19. package/hooks/lib/validate-note.mjs +218 -0
  20. package/hooks/lib/vault-env.sh +110 -0
  21. package/hooks/memory-link-lint.mjs +65 -0
  22. package/hooks/memory-recall.mjs +251 -0
  23. package/hooks/semantic-index-refresh.mjs +23 -0
  24. package/hooks/session-context.mjs +9 -0
  25. package/hooks/validate-note.mjs +52 -0
  26. package/hooks/vault-memory-sync.sh +154 -0
  27. package/omp/index.js +1 -0
  28. package/opencode/index.js +1 -0
  29. package/package.json +51 -4
  30. package/scripts/claude-memory.mjs +31 -0
  31. package/scripts/doctor-perf.mjs +121 -0
  32. package/scripts/doctor.sh +558 -0
  33. package/scripts/env.mjs +6 -0
  34. package/scripts/lib/claude-memory.mjs +168 -0
  35. package/scripts/lib/doctor-perf.mjs +434 -0
  36. package/scripts/lib/hook-stats.mjs +864 -0
  37. package/scripts/lib/lexical.mjs +85 -0
  38. package/scripts/lib/memory-adopt.mjs +69 -0
  39. package/scripts/lib/memory-audit-checks.mjs +344 -0
  40. package/scripts/lib/memory-eval.mjs +381 -0
  41. package/scripts/lib/memory-mark.mjs +135 -0
  42. package/scripts/lib/memory-mcp.mjs +142 -0
  43. package/scripts/lib/memory-merge.mjs +316 -0
  44. package/scripts/lib/memory-mine.mjs +108 -0
  45. package/scripts/lib/memory-promote.mjs +207 -0
  46. package/scripts/lib/memory-prune.mjs +84 -0
  47. package/scripts/lib/memory-semantic.mjs +999 -0
  48. package/scripts/lib/memory-setup.mjs +170 -0
  49. package/scripts/lib/memory-synth-vault.mjs +538 -0
  50. package/scripts/lib/model-default.mjs +7 -0
  51. package/scripts/lib/models.mjs +58 -0
  52. package/scripts/lib/prune-logs.mjs +130 -0
  53. package/scripts/lib/recall-stats.mjs +354 -0
  54. package/scripts/lib/share-modules.mjs +70 -0
  55. package/scripts/lib/slim-install.mjs +162 -0
  56. package/scripts/lib/vault-mcp.mjs +405 -0
  57. package/scripts/memory-adopt.mjs +160 -0
  58. package/scripts/memory-audit-checks.mjs +375 -0
  59. package/scripts/memory-eval.mjs +753 -0
  60. package/scripts/memory-mark.mjs +39 -0
  61. package/scripts/memory-mcp.mjs +35 -0
  62. package/scripts/memory-merge.mjs +55 -0
  63. package/scripts/memory-prune.mjs +44 -0
  64. package/scripts/memory-semantic.mjs +1192 -0
  65. package/scripts/memory-setup.mjs +33 -0
  66. package/scripts/memory-synth-vault.mjs +251 -0
  67. package/scripts/prune-logs.mjs +42 -0
  68. package/scripts/share-modules.mjs +79 -0
  69. package/scripts/slim-install.mjs +55 -0
  70. package/scripts/vault-mcp.mjs +50 -0
  71. package/stubs/onnxruntime-web/index.mjs +11 -0
  72. package/stubs/onnxruntime-web/package.json +12 -0
  73. package/stubs/sharp/index.mjs +11 -0
  74. package/stubs/sharp/package.json +12 -0
@@ -0,0 +1,84 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { pruneLogs } from './prune-logs.mjs';
4
+
5
+ export const USAGE = 'memory-prune.mjs [--slug <key>] [--dry-run]';
6
+
7
+ /**
8
+ * @param {string[]} argv
9
+ * @returns {{ slug?: string, dryRun: boolean } | { error: string }}
10
+ */
11
+ export function parsePruneArgs(argv) {
12
+ /** @type {{ slug?: string, dryRun: boolean }} */
13
+ const out = { dryRun: false };
14
+ for (let i = 0; i < argv.length; i++) {
15
+ const a = argv[i];
16
+ if (a === '--dry-run') out.dryRun = true;
17
+ else if (a === '--slug') {
18
+ const v = argv[i + 1];
19
+ if (!v || v.startsWith('-')) return { error: '--slug needs a value' };
20
+ out.slug = argv[++i];
21
+ } else return { error: `unknown argument: ${a}` };
22
+ }
23
+ return out;
24
+ }
25
+
26
+ /**
27
+ * The mechanical half of /memory:prune: archive logs, refresh the index, list candidate
28
+ * duplicates one per line. Merging and marking need judgment and stay in the command.
29
+ *
30
+ * @param {{ slug: string, dryRun: boolean }} opts
31
+ * @param {{
32
+ * vault: string,
33
+ * days: number,
34
+ * run: (args: string[]) => { code: number, out: string },
35
+ * print: (line: string) => void,
36
+ * }} deps
37
+ * @returns {number} exit code
38
+ */
39
+ export function prune({ slug, dryRun }, { vault, days, run, print }) {
40
+ if (!slug || slug === '.' || slug === '..' || /[/\\\x00]/.test(slug))
41
+ return (print('logs\tFAIL\tinvalid project key'), 1);
42
+ if (!dryRun && !fs.statSync(vault, { throwIfNoEntry: false })?.isDirectory())
43
+ return (print(`logs\tFAIL\tvault is not a directory: ${vault}`), 1);
44
+ const root = path.join(vault, 'Logs');
45
+ const logs = path.join(root, slug);
46
+ const rootStat = fs.lstatSync(root, { throwIfNoEntry: false });
47
+ if (rootStat && !rootStat.isDirectory())
48
+ return (print(`logs\tFAIL\tnot a real directory: ${root}`), 1);
49
+ const stat = fs.lstatSync(logs, { throwIfNoEntry: false });
50
+ if (stat && !stat.isDirectory()) return (print(`logs\tFAIL\tnot a real directory: ${logs}`), 1);
51
+ if (!stat) print(`logs\tskip\tno logs dir ${logs}`);
52
+ else {
53
+ const verb = dryRun ? 'would archive' : 'archived';
54
+ /** @param {import('./prune-logs.mjs').PruneResult} r */
55
+ const report = (r) => {
56
+ print(`logs\t${verb} ${r.moved.length}\t${logs}`);
57
+ for (const n of r.moved) print(`log\t${verb}\t${n}`);
58
+ for (const n of r.skipped) print(`log\tskipped, no date in name\t${n}`);
59
+ for (const n of r.collisions) print(`log\tskipped, already in Archive/\t${n}`);
60
+ };
61
+ try {
62
+ report(pruneLogs(logs, { days, dryRun }));
63
+ } catch (err) {
64
+ const e = /** @type {import('./prune-logs.mjs').PrunePartialError} */ (err);
65
+ if (e.partial) report(e.partial);
66
+ return (print(`logs\tFAIL\t${e.message}`), 1);
67
+ }
68
+ }
69
+
70
+ if (dryRun) print('index\tskip\tdry run');
71
+ else {
72
+ const r = run(['--index', '--slug', slug]);
73
+ const last = r.out.trim().split('\n').pop() ?? '';
74
+ if (r.code) return (print(`index\tFAIL\t${last}`), 1);
75
+ print(`index\tok\t${last}`);
76
+ }
77
+
78
+ for (const mode of ['--dupes', '--cross-dupes']) {
79
+ const r = run([mode, '--tsv', '--slug', slug]);
80
+ if (r.code) return (print(`${mode.slice(2)}\tFAIL\t${r.out.trim()}`), 1);
81
+ if (r.out.trim()) print(r.out.trim());
82
+ }
83
+ return 0;
84
+ }