@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,48 @@
1
+ #!/usr/bin/env node
2
+ // SessionStart entry: surface recent L3 Mistakes titles so past errors actually reach context —
3
+ // titles only; full lessons stay in the vault / via /memory:health.
4
+ //
5
+ // Thin on purpose: stdin, cwd, stdout only — see docs/architecture.md's "Entry files are thin
6
+ // wrappers over lib/" invariant (and G1, where the pattern breaks elsewhere).
7
+ import { readStdin, payload, hookCwd, logHook, standDown, sessionContext } from './lib/hook-io.mjs';
8
+ import { surface } from './lib/insights-surface.mjs';
9
+
10
+ // readStdin() and not `new Response(process.stdin)`: the web-streams path costs ~18 ms of runtime
11
+ // bootstrap per hook against ~0.5 ms for one readFileSync(0) — a third of this hook's whole wall
12
+ // time, paid to parse a 100-byte payload. Measured 2026-08-20,
13
+ // docs/decisions/2026-08-20-hook-startup-cost.md.
14
+ const p = payload(readStdin());
15
+ if (standDown('insights-surface', p)) process.exit(0);
16
+ const cwd = hookCwd(p);
17
+
18
+ // A SessionStart hook must never break a session.
19
+ /** @type {import('./lib/hook-io.mjs').HookOutcome} */
20
+ let outcome = 'ran';
21
+ /** @type {string | undefined} */
22
+ let reason;
23
+ /** @type {Record<string, number> | undefined} */
24
+ let extra;
25
+ try {
26
+ const text = surface(cwd);
27
+ if (text) console.log(sessionContext(text));
28
+ reason = text ? 'surfaced' : 'nothing to surface';
29
+ // What this hook COSTS the session, in bytes of context window. Omitted rather than logged as 0
30
+ // when it injects nothing, so "injected nothing" and "was not measuring yet" stay distinguishable
31
+ // — a week of older log files sits in the reader's window.
32
+ if (text) extra = { bytes: Buffer.byteLength(text) };
33
+ } catch (e) {
34
+ outcome = 'error';
35
+ reason = String(/** @type {Error} */ (e)?.message ?? e);
36
+ }
37
+
38
+ // Last, so the duration covers the work — and outside the try for the same reason the catch is
39
+ // there: the log is best-effort, and logHook swallows its own failures.
40
+ logHook({
41
+ hook: 'insights-surface',
42
+ event: String(p.hook_event_name ?? ''),
43
+ cwd,
44
+ session: /** @type {string|undefined} */ (p.session_id),
45
+ outcome,
46
+ reason,
47
+ extra,
48
+ });