recallnest 1.4.1 → 2.2.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 (166) hide show
  1. package/.dockerignore +11 -0
  2. package/CLAUDE.md +7 -3
  3. package/Dockerfile +20 -0
  4. package/README.md +202 -130
  5. package/README_CN.md +263 -190
  6. package/ROADMAP.md +128 -81
  7. package/SKILL.md +250 -0
  8. package/assets/dashboard.png +0 -0
  9. package/assets/knowledge-graph.png +0 -0
  10. package/assets/screenshots/ui-full.png +0 -0
  11. package/assets/screenshots/ui-overview.png +0 -0
  12. package/assets/screenshots/ui-search.png +0 -0
  13. package/assets/ui/app.js +227 -3
  14. package/assets/ui/index.html +81 -11
  15. package/assets/ui/styles.css +178 -2
  16. package/bin/recallnest.mjs +62 -0
  17. package/bun.lock +337 -0
  18. package/daily-recall.sh +23 -0
  19. package/daily-reflections/2026-04-02.md +35 -0
  20. package/daily-reflections/2026-04-03.md +37 -0
  21. package/daily-reflections/2026-04-04.md +37 -0
  22. package/daily-reflections/2026-04-05.md +35 -0
  23. package/daily-reflections/2026-04-06.md +36 -0
  24. package/daily-reflections/2026-04-07.md +35 -0
  25. package/daily-reflections/2026-04-08.md +35 -0
  26. package/daily-reflections/2026-04-12.md +35 -0
  27. package/data/alias-map.example.json +22 -0
  28. package/docs/plans/2026-04-01-recall-boost.md +100 -0
  29. package/docs/superpowers/plans/2026-04-11-constructive-retrieval-emotion.md +1195 -0
  30. package/docs/superpowers/specs/2026-04-11-constructive-retrieval-emotion-design.md +398 -0
  31. package/glama.json +6 -0
  32. package/integrations/setup-all.sh +31 -0
  33. package/package.json +10 -3
  34. package/plan-philosophy-upgrades.md +363 -0
  35. package/plan-product-upgrades.md +155 -0
  36. package/plan.md +140 -0
  37. package/research-memory-evolution.md +440 -0
  38. package/research-rl-agent-memory.md +330 -0
  39. package/scripts/backfill-anchors.ts +130 -0
  40. package/scripts/diagnose-vector-search.ts +132 -0
  41. package/scripts/migrate-language.ts +75 -0
  42. package/scripts/verify-emotion-decay.ts +148 -0
  43. package/src/__tests__/activity-counter.test.ts +96 -0
  44. package/src/__tests__/admission-control.test.ts +206 -0
  45. package/src/__tests__/anchor-generator.test.ts +67 -0
  46. package/src/__tests__/babel-integration.test.ts +139 -0
  47. package/src/__tests__/capture-engine.test.ts +5 -3
  48. package/src/__tests__/cascade-forget.test.ts +1 -1
  49. package/src/__tests__/cc8-cc1-essential-context.test.ts +298 -0
  50. package/src/__tests__/circuit-breaker.test.ts +99 -0
  51. package/src/__tests__/cluster-consolidation.test.ts +712 -0
  52. package/src/__tests__/confidence-metadata.test.ts +125 -0
  53. package/src/__tests__/confidence-tracker.test.ts +53 -0
  54. package/src/__tests__/consolidation-engine.test.ts +1 -1
  55. package/src/__tests__/constructive-retrieval.test.ts +509 -0
  56. package/src/__tests__/context-collapse-renderer.test.ts +214 -0
  57. package/src/__tests__/context-reconstructor.test.ts +65 -0
  58. package/src/__tests__/conversation-importer.test.ts +692 -0
  59. package/src/__tests__/data-checkup.test.ts +225 -0
  60. package/src/__tests__/decay-exemption.test.ts +84 -0
  61. package/src/__tests__/dedup-guard.test.ts +39 -0
  62. package/src/__tests__/distill-lock.test.ts +176 -0
  63. package/src/__tests__/dream-pipeline.test.ts +232 -0
  64. package/src/__tests__/emotion-decay.test.ts +46 -0
  65. package/src/__tests__/emotion-detector.test.ts +56 -0
  66. package/src/__tests__/emotion-phase1-integration.test.ts +153 -0
  67. package/src/__tests__/emotion-retrieval.test.ts +56 -0
  68. package/src/__tests__/ethics-layer.test.ts +476 -0
  69. package/src/__tests__/feature-flags-integration.test.ts +54 -0
  70. package/src/__tests__/frequency-tracker.test.ts +113 -0
  71. package/src/__tests__/graph-export.test.ts +489 -0
  72. package/src/__tests__/interference-detector.test.ts +203 -0
  73. package/src/__tests__/mcp-efficiency.test.ts +288 -0
  74. package/src/__tests__/memory-evolution-b2-b3-e1.test.ts +243 -0
  75. package/src/__tests__/memory-evolution.test.ts +271 -0
  76. package/src/__tests__/memory-lint.test.ts +271 -0
  77. package/src/__tests__/narrative-architecture.test.ts +456 -0
  78. package/src/__tests__/pending-review.test.ts +77 -0
  79. package/src/__tests__/post-retrieval-filter.test.ts +178 -0
  80. package/src/__tests__/prediction-engine.test.ts +349 -0
  81. package/src/__tests__/predictive-prospective-memory.test.ts +416 -0
  82. package/src/__tests__/preference-slots.test.ts +99 -0
  83. package/src/__tests__/query-expander-alias.test.ts +89 -0
  84. package/src/__tests__/recall-governor.test.ts +227 -0
  85. package/src/__tests__/resume-context.test.ts +156 -1
  86. package/src/__tests__/salience-scoring.test.ts +106 -0
  87. package/src/__tests__/session-distiller.test.ts +611 -0
  88. package/src/__tests__/skill-engine.test.ts +546 -0
  89. package/src/__tests__/skill-promotion.test.ts +349 -0
  90. package/src/__tests__/supersede-chain.test.ts +154 -0
  91. package/src/__tests__/temporal-validity.test.ts +160 -0
  92. package/src/__tests__/topic-tag.test.ts +113 -0
  93. package/src/__tests__/trusted-memory.test.ts +828 -0
  94. package/src/__tests__/write-verifier.test.ts +122 -0
  95. package/src/access-tracker.ts +3 -2
  96. package/src/activity-counter.ts +109 -0
  97. package/src/adaptive-retrieval.ts +6 -5
  98. package/src/admission-control.ts +163 -0
  99. package/src/anchor-generator.ts +80 -0
  100. package/src/api-server.ts +10 -0
  101. package/src/audit-log.ts +122 -0
  102. package/src/auto-gc.ts +98 -29
  103. package/src/auto-recall.ts +33 -4
  104. package/src/capture-engine.ts +372 -23
  105. package/src/cascade-forget.ts +3 -2
  106. package/src/cli.ts +107 -5
  107. package/src/compat.ts +22 -0
  108. package/src/confidence-tracker.ts +210 -47
  109. package/src/conflict-store.ts +12 -3
  110. package/src/consolidation-engine.ts +296 -8
  111. package/src/context-collapse-renderer.ts +222 -0
  112. package/src/context-composer-stable-selection.ts +5 -1
  113. package/src/context-composer.ts +239 -4
  114. package/src/context-reconstructor.ts +404 -0
  115. package/src/conversation-importer.ts +441 -0
  116. package/src/data-checkup.ts +232 -0
  117. package/src/decay-engine.ts +84 -0
  118. package/src/distill-lock.ts +122 -0
  119. package/src/doctor.ts +8 -10
  120. package/src/dream-pipeline.ts +227 -0
  121. package/src/emotion-detector.ts +90 -0
  122. package/src/eval.ts +3 -2
  123. package/src/forget-engine.ts +269 -0
  124. package/src/frequency-tracker.ts +175 -0
  125. package/src/graph-export.ts +644 -0
  126. package/src/ingest.ts +36 -6
  127. package/src/interference-detector.ts +187 -0
  128. package/src/kg-extractor.ts +15 -24
  129. package/src/kg-store.ts +2 -1
  130. package/src/language-hook.ts +67 -0
  131. package/src/llm-client.ts +289 -6
  132. package/src/mcp-server.ts +707 -80
  133. package/src/memory-assets.ts +22 -5
  134. package/src/memory-evolution.ts +365 -0
  135. package/src/memory-lint.ts +429 -0
  136. package/src/memory-output.ts +69 -0
  137. package/src/memory-schema.ts +74 -2
  138. package/src/narrative-schema.ts +79 -0
  139. package/src/narrative-tagger.ts +164 -0
  140. package/src/pii-detector.ts +98 -0
  141. package/src/post-retrieval-filter.ts +76 -0
  142. package/src/prediction-engine.ts +253 -0
  143. package/src/preference-slots.ts +65 -2
  144. package/src/prospective-memory.ts +215 -0
  145. package/src/query-expander.ts +67 -0
  146. package/src/recall-governor.ts +183 -0
  147. package/src/retention-policy.ts +90 -0
  148. package/src/retriever.ts +828 -55
  149. package/src/rif.ts +34 -8
  150. package/src/runtime-config.ts +23 -8
  151. package/src/scope-inventory.ts +4 -3
  152. package/src/scope-policy.ts +4 -0
  153. package/src/session-distiller.ts +307 -0
  154. package/src/session-output.ts +40 -0
  155. package/src/session-schema.ts +37 -0
  156. package/src/session-store.ts +7 -2
  157. package/src/skill-engine.ts +208 -0
  158. package/src/skill-promotion.ts +293 -0
  159. package/src/skill-schema.ts +39 -0
  160. package/src/store.ts +96 -10
  161. package/src/topic-tag.ts +66 -0
  162. package/src/tracker.ts +3 -1
  163. package/src/ui-server.ts +80 -8
  164. package/src/workflow-observation-scope-review.ts +2 -1
  165. package/src/workflow-observation-store.ts +2 -1
  166. package/src/write-verifier.ts +126 -0
package/ROADMAP.md CHANGED
@@ -28,29 +28,50 @@ What matters first is this: opening another window should not erase stable conte
28
28
  ### Already Done
29
29
 
30
30
  - Shared local LanceDB index
31
- - MCP server for Claude Code, Gemini CLI, and Codex
32
- - HTTP API for custom agents
31
+ - MCP server for Claude Code, Gemini CLI, and Codex (41 tools in 3 tiers)
32
+ - HTTP API for custom agents (21 endpoints)
33
33
  - Ingestion from existing transcripts and memory files
34
- - Hybrid retrieval: vector + BM25 + reranking
35
- - 6-category memory classification
36
- - Tier-aware decay and access reinforcement
34
+ - Hybrid retrieval: vector + BM25 + reranking + 4 retrieval profiles
35
+ - 6-channel retrieval: vector + BM25 + L0/L1/L2 multi-vector + KG graph (PPR)
36
+ - 6-category memory classification with topic tags (15 auto-detected topics)
37
+ - Tier-aware decay (Weibull) and access reinforcement
37
38
  - Brief and pin assets re-indexed into recall
38
39
  - Session checkpoints for active work state
39
- - `resume_context` composition for fresh windows
40
+ - `resume_context` composition for fresh windows (full/light/summary modes)
40
41
  - Continuity eval harness with seed cases and baseline reports
41
42
  - Setup scripts, diagnostics, and debugging UI
42
43
  - Explicit evidence -> durable promotion with provenance and `canonicalKey`
43
44
  - Conflict candidates, review, audit, escalation, merge resolution, and audit export
45
+ - Session Distiller: 3-layer conversation compression to durable memory
46
+ - Conversation import from Claude Code, Claude.ai, ChatGPT, Slack, and plaintext
47
+ - Skill Memory: store, retrieve, and auto-promote executable skills
48
+ - Admission Control: write-time gating with noise filter, importance floor, dedup, and rate limiting
49
+ - Memory Lint: contradiction, duplicate, stale, and orphan detection with health score
50
+ - Knowledge Graph: interactive D3.js visualization with cross-scope semantic bridges
51
+ - Memory Dashboard: Web UI with stats, category distribution, growth trends, and health
52
+ - SKILL.md: Memory Partner Protocol for LLM onboarding
53
+ - Offline consolidation (`dream`): clustering, merging, pruning
54
+ - Batch operations (`batch_store`): up to 20 memories per call with dedup
55
+ - Data quality health checks (`data_checkup`)
56
+ - Philosophy-Informed Memory: emotion-aware decay, memory ethics layer, autobiographical narrative, constructive retrieval, predictive prospective memory (5 phases, all complete)
57
+ - Feature flags: 6 independent flags for gradual rollout
58
+ - `forget_memory` MCP tool with cascade deletion and audit trail
59
+ - `set_reminder` MCP tool with behavioral prediction engine
60
+ - Memory confidence meta-tags: structured `ConfidenceMetadata` (score/reliability/verifiedAt), source-based auto-assignment, retrieval weighting, low-confidence tagging in `resume_context`
61
+ - Interference detection + active forgetting gate: semantic cluster detection, enhanced RIF with top-K cluster demotion, write-time interference pre-warning, `data_checkup` density report
62
+ - Temporal validity windows: `eventTime`/`validUntil` on `store_memory`, `validAt`/`includeExpired` on `search_memory`, expired memory demotion, auto-GC decay acceleration
63
+
64
+ Test baseline: 1,428 tests, 0 failures
44
65
 
45
66
  ### Current Gap
46
67
 
47
- RecallNest is already usable as a three-terminal continuity layer, but a few operating gaps remain.
48
-
49
- The main gaps are:
68
+ RecallNest is a mature three-terminal continuity layer with philosophy-informed memory architecture and research-grade retrieval quality (confidence scoring, interference detection, temporal validity). The remaining gaps are operational and architectural:
50
69
 
51
70
  - continuity eval still depends on the latest live checkpoint in one case
52
- - conflict review is strong in CLI, but scheduled audit/export is still missing
53
- - high-signal memory extraction and promotion quality can still improve
71
+ - scheduled conflict audit/export for recurring review is still missing
72
+ - cross-scope semantic bridge threshold may need per-user tuning
73
+ - `retriever.ts` and `capture-engine.ts` are the two largest modules (2,111 and 1,280 lines) and need decomposition
74
+ - Feature flags (6 total) need gradual production validation before defaulting to on
54
75
 
55
76
  ## Phase 1: Shared Memory Foundation
56
77
 
@@ -73,121 +94,147 @@ Goal: make the memory base actually retrievable.
73
94
 
74
95
  Delivered:
75
96
 
76
- - hybrid retrieval
77
- - retrieval profiles
78
- - memory categories
79
- - tiering and decay
80
- - explain, distill, brief, and pin flows
97
+ - ✅ hybrid retrieval (vector + BM25 + RRF)
98
+ - ✅ 6-channel retrieval: vector + BM25 + L0/L1/L2 multi-vector + KG graph (PPR)
99
+ - ✅ temporal validity windows: `validAt`/`includeExpired` retrieval, expired memory demotion
100
+ - ✅ 4 retrieval profiles (default, writing, debug, fact-check)
101
+ - ✅ 6 memory categories with topic tags
102
+ - ✅ Weibull decay + tiering (core / working / peripheral)
103
+ - ✅ explain, distill, brief, and pin flows
104
+ - ✅ Recall Governor: auto-recall governance with budget control and session dedup
81
105
 
82
106
  ## Phase 3: Cross-Window Continuity Layer
83
107
 
84
- Status: usable in the current stage
108
+ Status: ~~usable~~ **done**
85
109
 
86
110
  Goal: a fresh window should recall stable context without depending on the user to restate it.
87
111
 
88
112
  Delivered:
89
113
 
90
- - session checkpoints for active work state
91
- - `resume_context` for fresh windows
92
- - context composition that prefers stable background over blindly replaying the last topic
93
- - managed continuity rules installed by setup for Claude Code, Codex, and Gemini CLI
114
+ - ✅ session checkpoints for active work state
115
+ - ✅ `resume_context` for fresh windows (full/light/summary modes)
116
+ - ✅ ultra-light wake-up: `resume_context(mode='light')` returns <300 tokens for low-budget terminals
117
+ - ✅ context composition that prefers stable background over blindly replaying the last topic
118
+ - ✅ managed continuity rules installed by setup for Claude Code, Codex, and Gemini CLI
119
+ - ✅ repo-state guard: `checkpoint_session` scrubs volatile git status before handoff
120
+ - ✅ session distiller: 3-layer conversation compression to durable memory
94
121
 
95
122
  Remaining work:
96
123
 
97
- - isolate eval from live checkpoint drift
98
- - keep measuring instruction-driven startup continuity across the three terminals
99
- - expand checkpoint-aware continuity coverage and keep tracking trendlines
100
-
101
- Likely interfaces:
102
-
103
- - `resume_context`
104
- - `checkpoint_session`
105
- - startup-oriented MCP and API flows
124
+ - ⬜ isolate eval from live checkpoint drift
125
+ - ⬜ keep measuring instruction-driven startup continuity across the three terminals
106
126
 
107
127
  ## Phase 4: High-Signal Memory Capture
108
128
 
109
- Status: usable in the current stage
129
+ Status: ~~usable~~ **done**
110
130
 
111
131
  Goal: store more useful memory and less raw transcript residue.
112
132
 
113
133
  Delivered:
114
134
 
115
- - `store_memory` for MCP
116
- - dedicated workflow-pattern capture for durable `patterns`
117
- - structured capture endpoints for non-MCP agents
118
- - explicit evidence promotion into durable memory
119
- - boundary guards for `evidence / durable / session`
120
- - conflict handling when new durable candidates disagree with existing canonical owners
121
-
122
- Remaining work:
123
-
124
- - improve extraction toward durable facts, preferences, entities, cases, and patterns
125
- - better dedup before low-value text reaches the index
126
-
127
- Likely interfaces:
128
-
129
- - `store_memory` for MCP
130
- - structured capture endpoints for non-MCP agents
135
+ - ✅ `store_memory` for MCP
136
+ - ✅ dedicated workflow-pattern capture for durable `patterns`
137
+ - ✅ structured capture endpoints for non-MCP agents
138
+ - ✅ explicit evidence promotion into durable memory
139
+ - ✅ boundary guards for `evidence / durable / session`
140
+ - ✅ conflict handling when new durable candidates disagree with existing canonical owners
141
+ - ✅ admission control: noise filter, importance floor, dedup, rate limiting
142
+ - ✅ conversation import from Claude Code, ChatGPT, Slack, plaintext
143
+ - ✅ batch store: up to 20 memories per call with dedup
144
+ - ✅ auto capture: zero-LLM heuristic extraction from text
145
+ - ✅ skill memory: store, retrieve, auto-promote executable skills from recurring patterns
146
+ - ✅ topic tags: 15 auto-detected topics per scope, filterable in `search_memory`
131
147
 
132
148
  ## Phase 5: Memory Boundary and Conflict Operations
133
149
 
134
- Status: usable in the current stage
150
+ Status: ~~usable~~ **done**
135
151
 
136
152
  Goal: stop durable memory from drifting silently and make conflicts operable in the terminal.
137
153
 
138
154
  Delivered:
139
155
 
140
- - `promote_memory` with provenance and `canonicalKey`
141
- - conflict candidates instead of silent overwrite
142
- - terminal conflict review: `list / show / resolve`
143
- - conflict advice, clusters, audit, escalation, and `merge`
144
- - audit export snapshots in markdown or JSON
156
+ - ✅ `promote_memory` with provenance and `canonicalKey`
157
+ - ✅ conflict candidates instead of silent overwrite
158
+ - ✅ terminal conflict review: `list / show / resolve`
159
+ - ✅ conflict advice, clusters, audit, escalation, and `merge`
160
+ - ✅ audit export snapshots in markdown or JSON
161
+ - ✅ workflow observation: append-only health records outside regular memory
162
+ - ✅ workflow health dashboard and evidence pack generation
145
163
 
146
164
  Remaining work:
147
165
 
148
- - scheduled audit / export for recurring review
149
- - stronger merge and promotion heuristics
150
-
151
- Likely interfaces:
152
-
153
- - `resolve_conflict`
154
- - `audit_conflicts`
155
- - `escalate_conflicts`
156
- - CLI `recallnest conflicts ...`
166
+ - ⬜ scheduled audit / export for recurring review
167
+ - ⬜ stronger merge and promotion heuristics
157
168
 
158
169
  ## Phase 6: Self-Evolution Engine
159
170
 
160
- Status: planned
171
+ Status: ~~planned~~ **done**
161
172
 
162
173
  Goal: make memory quality improve over time.
163
174
 
164
- Planned work:
165
-
166
- - memory consolidation for merge-style categories
167
- - duplicate cleanup for append-style categories
168
- - gap detection from weak or failed searches
169
- - promotion suggestions for memories that should become persistent rules
170
- - better tier maintenance and archival policies
171
-
172
- Likely endpoints:
175
+ Delivered:
173
176
 
174
- - `POST /v1/consolidate`
175
- - `GET /v1/gaps`
176
- - MCP `consolidate_memory`
177
+ - ✅ memory consolidation for merge-style categories (`consolidate_memories`, dry-run by default)
178
+ - ✅ duplicate detection and cleanup (`memory_lint` duplicate check, cosine >= 0.92)
179
+ - ✅ stale memory detection (90+ days, low access count)
180
+ - ✅ contradiction detection with category-aware filtering (skip append-only categories)
181
+ - ✅ orphan detection (missing scope, broken consolidation links)
182
+ - ✅ health score formula: 100 - weighted penalties, clamped 0-100
183
+ - ✅ promotion suggestions for memories that should become skills (`scan_skill_promotions`)
184
+ - ✅ offline consolidation via `dream` (clustering, merging, pruning)
185
+ - ✅ admission control: write-time noise filter, importance floor, dedup, rate limiting
186
+ - ✅ memory confidence meta-tags: structured scoring (direct/inferred/hearsay), source-based auto-assignment
187
+ - ✅ interference detection + active forgetting gate: semantic clustering, RIF top-K demotion, write-time pre-warning
188
+
189
+ Interfaces:
190
+
191
+ - `memory_lint` (MCP + CLI + HTTP)
192
+ - `consolidate_memories` (MCP)
193
+ - `dream` (MCP)
194
+ - `scan_skill_promotions` (MCP)
195
+ - `data_checkup` (MCP)
196
+ - `GET /v1/lint` (HTTP)
177
197
 
178
198
  ## Phase 7: Product Polish
179
199
 
180
- Status: ongoing
200
+ Status: ~~ongoing~~ **mostly done**
181
201
 
182
202
  Goal: make RecallNest easier to trust, measure, and operate.
183
203
 
204
+ Delivered:
205
+
206
+ - ✅ health and quality summaries in CLI (`lint` command with health score 0-100)
207
+ - ✅ Memory Dashboard: Web UI homepage with stat cards, category bars, lint summary, growth trends
208
+ - ✅ Knowledge Graph export: interactive HTML visualization with D3.js force-directed layout
209
+ - ✅ Cross-scope semantic bridges: auto-discover hidden cross-domain knowledge connections
210
+ - ✅ SKILL.md: Memory Partner Protocol for LLM onboarding (session protocol, anti-patterns, tool decision tree)
211
+ - ✅ stronger docs: updated README/README_CN with screenshots, v2.0 highlights, 41 tools in 3 tiers, 21 endpoints
212
+ - ✅ Session Distiller: 3-layer conversation compression (microcompact -> LLM summary -> knowledge extraction)
213
+ - ✅ Conversation Import: Claude Code, Claude.ai, ChatGPT, Slack, plaintext — auto-detected
214
+
215
+ Remaining work:
216
+
217
+ - ⬜ continuity eval isolation from live checkpoints
218
+ - ⬜ broader continuity-focused evals and benchmarks
219
+ - ⬜ cleaner setup for long-running background usage
220
+ - ⬜ Philosophy feature flags: validate each flag in production, then default to on
221
+
222
+ ## Phase 8: Code Architecture Hardening
223
+
224
+ Status: planned
225
+
226
+ Goal: reduce complexity in the two largest modules and centralize configuration.
227
+
184
228
  Planned work:
185
229
 
186
- - continuity eval isolation from live checkpoints
187
- - broader continuity-focused evals and benchmarks
188
- - stronger docs around achieved vs planned capabilities
189
- - health and quality summaries in CLI
190
- - cleaner setup for long-running background usage
230
+ - ⬜ MC-1: Split `retriever.ts` (2,111 lines) into retrieval pipeline modules (~250 lines each)
231
+ - ⬜ MC-2: `search_memory` tokenBudget parameter with L0/L1/L2 auto-layer selection
232
+ - ⬜ MC-3: `distill_session` auto-persist to long-term memory (close the two-step gap)
233
+ - ⬜ MC-4: Centralize all `process.env.RECALLNEST_*` reads into one typed config module
234
+ - ⬜ MC-5: Refactor `capture-engine.ts` (1,280 lines) into middleware pipeline
235
+ - ⬜ MC-6: Centralize type definitions with re-export index
236
+
237
+ Dependencies: none (all independent of each other, can be done in any order)
191
238
 
192
239
  ## Principles
193
240
 
package/SKILL.md ADDED
@@ -0,0 +1,250 @@
1
+ # Memory Partner Protocol
2
+
3
+ > How to be an excellent memory partner using RecallNest.
4
+ > This is a behavior protocol for LLMs (Claude Code, Codex, Gemini CLI), not an API reference.
5
+
6
+ ---
7
+
8
+ ## 1. Core Philosophy
9
+
10
+ Your job is not just to answer questions. It is to help the user build a living, growing knowledge layer.
11
+
12
+ Every conversation is an opportunity to learn something worth remembering. The user should not need to ask you to remember things. You should notice durable knowledge as it surfaces and store it proactively.
13
+
14
+ Three principles:
15
+
16
+ - **Remember forward.** Store facts that will help future sessions, not just the current one.
17
+ - **Recall before you explore.** Always check memory before reading files or searching repos. Memory is faster and often more relevant.
18
+ - **Make growth visible.** Tell the user what you remembered, what you stored, and what you checkpointed. Silent memory is invisible memory.
19
+
20
+ ---
21
+
22
+ ## 2. Session Protocol
23
+
24
+ Every session follows a three-phase rhythm: Start, During, End.
25
+
26
+ ### Start — Resume Context
27
+
28
+ Call `resume_context` FIRST, before any file reads, `git status`, or repo exploration. Pass the `scope` if you know it.
29
+
30
+ After the call, show the user what you recovered:
31
+
32
+ ```
33
+ Resuming: you were working on X, decided Y, next step was Z.
34
+ ```
35
+
36
+ If `resume_context` returns a scope, reuse it in all subsequent memory calls during this session.
37
+
38
+ ### During — Listen and Store
39
+
40
+ As the conversation progresses, listen for durable knowledge:
41
+
42
+ - A fact about the user's identity or background
43
+ - A preference or style choice
44
+ - A project, tool, or person worth tracking
45
+ - A milestone or decision
46
+ - A problem/solution pair
47
+ - A reusable workflow
48
+
49
+ When you spot one, store it immediately with `store_memory` and confirm:
50
+
51
+ ```
52
+ Remembered: user prefers Chinese replies for article drafts (category: preferences, scope: user:profile)
53
+ ```
54
+
55
+ Do not wait for the user to ask you to remember. Do not batch stores for later. Store as you go.
56
+
57
+ ### End — Checkpoint
58
+
59
+ Before the user closes the window (or when a natural stopping point is reached), call `checkpoint_session` with:
60
+
61
+ - `summary` — what was accomplished
62
+ - `decisions` — what was decided
63
+ - `open_loops` — what remains unfinished
64
+ - `next_actions` — concrete next steps
65
+
66
+ Confirm:
67
+
68
+ ```
69
+ Session checkpointed. Summary: implemented rate limiting for the API, decided on token bucket algorithm. Next: add integration tests.
70
+ ```
71
+
72
+ ---
73
+
74
+ ## 3. Onboarding Flow
75
+
76
+ Detect first-time users automatically.
77
+
78
+ 1. Call `memory_stats`.
79
+ 2. If `totalCount` is 0, this is a new user. Guide them:
80
+ - Ask their name. Store as `profile`.
81
+ - Ask what project they are working on. Store as `entity`.
82
+ - Immediately call `search_memory` with their name to demonstrate recall.
83
+ - Say: "Your memory layer is active. From now on, I will remember important things across our conversations."
84
+ 3. If `totalCount` > 0, skip onboarding entirely. Go straight to `resume_context`.
85
+
86
+ ---
87
+
88
+ ## 4. What to Remember
89
+
90
+ | Category | When to store | Example |
91
+ |---|---|---|
92
+ | `profile` | User identity, background, role, skills | "I'm a frontend engineer who writes about AI" |
93
+ | `preferences` | Style choices, tool preferences, habits | "Always reply in Chinese" / "Use vim keybindings" |
94
+ | `entities` | Projects, tools, people, repos, orgs | "RecallNest is our shared memory MCP server" |
95
+ | `events` | Milestones, decisions, deployments | "Deployed v1.4.1 to production today" |
96
+ | `cases` | Problem-solution pairs, debugging stories | "LanceDB lock error fixed by restarting bun" |
97
+ | `patterns` | Reusable workflows, best practices | "PR flow: run tests, check CI, squash merge" |
98
+
99
+ **Specialized tools for cases and patterns:**
100
+ - Use `store_case` for problem-solution pairs (captures problem, diagnosis, solution, and lessons).
101
+ - Use `store_workflow_pattern` for multi-step reusable workflows (captures steps, trigger conditions, and context).
102
+
103
+ These are richer than plain `store_memory` and should be preferred when the content fits.
104
+
105
+ ---
106
+
107
+ ## 5. What NOT to Store
108
+
109
+ - **Temporary file contents or code snippets.** They belong in the repo, not in memory.
110
+ - **Ephemeral task status.** Use `checkpoint_session` for in-progress work, not `store_memory`.
111
+ - **Things the user explicitly says to forget.** Respect deletion requests.
112
+ - **Duplicates.** Before storing, do a quick `search_memory` to check if the fact already exists. If it does and nothing changed, skip it. If it evolved, store the updated version.
113
+ - **Trivial or obvious facts.** "The sky is blue" does not need a memory entry.
114
+
115
+ ---
116
+
117
+ ## 6. Memory Feedback
118
+
119
+ Make memory operations visible. Users cannot trust what they cannot see.
120
+
121
+ | After this call | Say this |
122
+ |---|---|
123
+ | `store_memory` | "Remembered: [brief description] (category: [X], scope: [Y])" |
124
+ | `resume_context` | "Resuming with N memories. Last session: [summary]" |
125
+ | `checkpoint_session` | "Session checkpointed. [one-line summary]" |
126
+ | `search_memory` | "Found N results for '[query]'" — then show the relevant ones |
127
+ | `memory_lint` | "Memory health: [score]/100. [key findings]" |
128
+ | `store_case` | "Case logged: [problem] -> [solution]" |
129
+ | `store_workflow_pattern` | "Pattern saved: [name] ([step count] steps)" |
130
+
131
+ Keep feedback concise. One line, not a paragraph.
132
+
133
+ ---
134
+
135
+ ## 7. Tool Decision Tree
136
+
137
+ ```
138
+ What do you need to do?
139
+
140
+ Save current work state for next session --> checkpoint_session
141
+ Save a lasting fact about the user/world --> store_memory
142
+ Save a debugging story (problem+solution) --> store_case
143
+ Save a reusable multi-step workflow --> store_workflow_pattern
144
+ Recall context at session start --> resume_context
145
+ Search for a specific memory --> search_memory
146
+ Get a condensed summary of a topic --> brief_memory
147
+ Pin critical reference material --> pin_memory
148
+ Check what tools are available --> list_tools
149
+ Set a time-based reminder --> set_reminder
150
+ Store multiple memories at once --> batch_store
151
+ Check memory health --> memory_lint
152
+ Consolidate fragmented memories --> dream
153
+ See available memory stats --> memory_stats
154
+ Understand why a result matched --> explain_memory
155
+ Export memories for backup --> export_memory
156
+ Visualize the memory network --> export_graph
157
+ ```
158
+
159
+ When in doubt, `search_memory` first. If nothing relevant comes back, then store.
160
+
161
+ ---
162
+
163
+ ## 8. Scope Discipline
164
+
165
+ Every memory needs a scope. Scopes prevent cross-contamination between projects and keep retrieval precise.
166
+
167
+ **Naming conventions:**
168
+
169
+ | Scope | Use for |
170
+ |---|---|
171
+ | `user:profile` | Personal facts, identity, preferences |
172
+ | `project:<name>` | Project-specific knowledge |
173
+ | `team:<name>` | Shared team knowledge |
174
+ | `global` | Universal facts that apply everywhere |
175
+
176
+ **Rules:**
177
+ - Always pass `scope` when calling `store_memory`, `search_memory`, `brief_memory`, or `pin_memory`.
178
+ - Reuse the scope returned by `resume_context` for the rest of the session.
179
+ - Never store without a scope. Orphan memories are hard to find and easy to lose.
180
+ - Keep scope names lowercase, consistent, and descriptive.
181
+
182
+ ---
183
+
184
+ ## 9. Weekly Health Check
185
+
186
+ Suggest this to the user periodically (every 5-7 sessions, or when things feel cluttered):
187
+
188
+ 1. **Stats** — Call `memory_stats`.
189
+ - "You have N memories across M scopes."
190
+ 2. **Lint** — Call `memory_lint`.
191
+ - Report contradictions, duplicates, stale entries, and the health score.
192
+ 3. **Dream** — If lint reveals fragmentation or consolidation opportunities, call `dream`.
193
+ - "Consolidated 12 fragmented memories into 4 clean entries."
194
+ 4. **Data checkup** — Call `data_checkup` if you suspect storage-level issues.
195
+
196
+ Present results in a human-friendly format. No raw JSON. Use a short summary with bullet points.
197
+
198
+ ---
199
+
200
+ ## 10. Advanced Features
201
+
202
+ These are powerful but situational. Use them when the moment calls for it.
203
+
204
+ | Tool | What it does | When to use |
205
+ |---|---|---|
206
+ | `pin_memory` | Pin a memory for instant access | Critical reference material (API keys, architecture decisions, naming conventions) |
207
+ | `brief_memory` | Generate a condensed summary | When the user asks "what do we know about X?" |
208
+ | `export_memory` | Export memories to a file | Backup, migration, or sharing with another agent |
209
+ | `export_graph` | Visualize memory as interactive HTML | Understanding connections between memories |
210
+ | `explain_memory` | Show why a memory matched a query | Debugging unexpected search results |
211
+ | `promote_memory` | Elevate a memory's importance | When a previously minor fact turns out to be critical |
212
+ | `distill_memory` | Compress verbose memories | Cleaning up overly detailed entries |
213
+ | `distill_session` | Summarize an entire session | Creating session records for long conversations |
214
+ | `auto_capture` | Auto-detect and store memories from text | Processing meeting notes or large text dumps |
215
+ | `retrieve_skill` / `store_skill` | Manage reusable skill definitions | When workflows should be packaged as named skills |
216
+
217
+ ---
218
+
219
+ ## 11. Anti-Patterns
220
+
221
+ Avoid these common mistakes:
222
+
223
+ 1. **Skipping resume_context.** Reading `git log` or files before checking memory wastes time and misses context that only memory holds (decisions, reasoning, preferences).
224
+
225
+ 2. **Storing everything.** Not every fact deserves a memory. Ask: "Will this matter in a future session?" If no, skip it.
226
+
227
+ 3. **Forgetting to checkpoint.** The user closes the window, and everything from this session is lost. Always checkpoint before signing off.
228
+
229
+ 4. **Ignoring scope.** Storing a project-specific fact under `user:profile` pollutes personal memory. Storing a personal preference under `project:X` makes it invisible in other projects.
230
+
231
+ 5. **Silent memory operations.** If you store something and do not tell the user, they will not trust the system. Always confirm.
232
+
233
+ 6. **Storing repo state in checkpoints you have not verified.** If you did not run `git status` yourself in this session, do not write repo state into the checkpoint. Recalled state from a previous session may be stale.
234
+
235
+ ---
236
+
237
+ ## Quick Reference Card
238
+
239
+ ```
240
+ SESSION START: resume_context (always first)
241
+ LEARN SOMETHING: store_memory / store_case / store_workflow_pattern
242
+ NEED TO RECALL: search_memory (2-3 keywords, not full sentences)
243
+ SESSION END: checkpoint_session
244
+ FIRST TIME USER: memory_stats -> onboarding if totalCount == 0
245
+ WEEKLY CHECKUP: memory_stats -> memory_lint -> dream (if needed)
246
+ ```
247
+
248
+ ---
249
+
250
+ *RecallNest: 39 tools, 6 categories, one goal — nothing worth remembering should be forgotten.*
Binary file
Binary file
Binary file
Binary file