agent-working-memory 0.7.16 → 0.8.5

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 (200) hide show
  1. package/README.md +156 -15
  2. package/dist/adapters/claude-code.d.ts.map +1 -1
  3. package/dist/adapters/claude-code.js +2 -16
  4. package/dist/adapters/claude-code.js.map +1 -1
  5. package/dist/adapters/codex.d.ts.map +1 -1
  6. package/dist/adapters/codex.js +2 -11
  7. package/dist/adapters/codex.js.map +1 -1
  8. package/dist/adapters/common.d.ts +18 -0
  9. package/dist/adapters/common.d.ts.map +1 -1
  10. package/dist/adapters/common.js +254 -141
  11. package/dist/adapters/common.js.map +1 -1
  12. package/dist/adapters/cursor.d.ts.map +1 -1
  13. package/dist/adapters/cursor.js +2 -15
  14. package/dist/adapters/cursor.js.map +1 -1
  15. package/dist/adapters/http.d.ts.map +1 -1
  16. package/dist/adapters/http.js +28 -34
  17. package/dist/adapters/http.js.map +1 -1
  18. package/dist/api/routes.d.ts +1 -1
  19. package/dist/api/routes.d.ts.map +1 -1
  20. package/dist/api/routes.js +280 -113
  21. package/dist/api/routes.js.map +1 -1
  22. package/dist/cli/migrate.d.ts +42 -0
  23. package/dist/cli/migrate.d.ts.map +1 -0
  24. package/dist/cli/migrate.js +268 -0
  25. package/dist/cli/migrate.js.map +1 -0
  26. package/dist/cli.js +45 -1
  27. package/dist/cli.js.map +1 -1
  28. package/dist/coordination/circuit-breaker.d.ts +24 -0
  29. package/dist/coordination/circuit-breaker.d.ts.map +1 -0
  30. package/dist/coordination/circuit-breaker.js +70 -0
  31. package/dist/coordination/circuit-breaker.js.map +1 -0
  32. package/dist/coordination/failure-modes.d.ts +21 -0
  33. package/dist/coordination/failure-modes.d.ts.map +1 -0
  34. package/dist/coordination/failure-modes.js +49 -0
  35. package/dist/coordination/failure-modes.js.map +1 -0
  36. package/dist/coordination/peer-decisions.js +7 -7
  37. package/dist/coordination/routes.d.ts.map +1 -1
  38. package/dist/coordination/routes.js +44 -1
  39. package/dist/coordination/routes.js.map +1 -1
  40. package/dist/coordination/schema.d.ts.map +1 -1
  41. package/dist/coordination/schema.js +18 -0
  42. package/dist/coordination/schema.js.map +1 -1
  43. package/dist/coordination/schemas.d.ts +9 -9
  44. package/dist/coordination/stale.d.ts +9 -1
  45. package/dist/coordination/stale.d.ts.map +1 -1
  46. package/dist/coordination/stale.js +53 -9
  47. package/dist/coordination/stale.js.map +1 -1
  48. package/dist/core/embeddings.d.ts +16 -10
  49. package/dist/core/embeddings.d.ts.map +1 -1
  50. package/dist/core/embeddings.js +54 -38
  51. package/dist/core/embeddings.js.map +1 -1
  52. package/dist/core/ml-worker-entry.d.ts +17 -0
  53. package/dist/core/ml-worker-entry.d.ts.map +1 -0
  54. package/dist/core/ml-worker-entry.js +193 -0
  55. package/dist/core/ml-worker-entry.js.map +1 -0
  56. package/dist/core/ml-worker.d.ts +59 -0
  57. package/dist/core/ml-worker.d.ts.map +1 -0
  58. package/dist/core/ml-worker.js +253 -0
  59. package/dist/core/ml-worker.js.map +1 -0
  60. package/dist/core/query-expander.d.ts +13 -15
  61. package/dist/core/query-expander.d.ts.map +1 -1
  62. package/dist/core/query-expander.js +48 -54
  63. package/dist/core/query-expander.js.map +1 -1
  64. package/dist/core/reranker.d.ts +9 -19
  65. package/dist/core/reranker.d.ts.map +1 -1
  66. package/dist/core/reranker.js +33 -35
  67. package/dist/core/reranker.js.map +1 -1
  68. package/dist/core/salience.d.ts +32 -5
  69. package/dist/core/salience.d.ts.map +1 -1
  70. package/dist/core/salience.js +201 -28
  71. package/dist/core/salience.js.map +1 -1
  72. package/dist/core/write-pipeline.d.ts +128 -0
  73. package/dist/core/write-pipeline.d.ts.map +1 -0
  74. package/dist/core/write-pipeline.js +405 -0
  75. package/dist/core/write-pipeline.js.map +1 -0
  76. package/dist/engine/activation.d.ts +2 -2
  77. package/dist/engine/activation.d.ts.map +1 -1
  78. package/dist/engine/activation.js +238 -115
  79. package/dist/engine/activation.js.map +1 -1
  80. package/dist/engine/confidence.d.ts +62 -0
  81. package/dist/engine/confidence.d.ts.map +1 -0
  82. package/dist/engine/confidence.js +100 -0
  83. package/dist/engine/confidence.js.map +1 -0
  84. package/dist/engine/connections.d.ts +47 -8
  85. package/dist/engine/connections.d.ts.map +1 -1
  86. package/dist/engine/connections.js +83 -22
  87. package/dist/engine/connections.js.map +1 -1
  88. package/dist/engine/consolidation-scheduler.d.ts +46 -10
  89. package/dist/engine/consolidation-scheduler.d.ts.map +1 -1
  90. package/dist/engine/consolidation-scheduler.js +170 -50
  91. package/dist/engine/consolidation-scheduler.js.map +1 -1
  92. package/dist/engine/consolidation.d.ts +16 -2
  93. package/dist/engine/consolidation.d.ts.map +1 -1
  94. package/dist/engine/consolidation.js +143 -44
  95. package/dist/engine/consolidation.js.map +1 -1
  96. package/dist/engine/eval.d.ts +2 -2
  97. package/dist/engine/eval.d.ts.map +1 -1
  98. package/dist/engine/eval.js +9 -9
  99. package/dist/engine/eval.js.map +1 -1
  100. package/dist/engine/eviction.d.ts +4 -4
  101. package/dist/engine/eviction.d.ts.map +1 -1
  102. package/dist/engine/eviction.js +15 -15
  103. package/dist/engine/eviction.js.map +1 -1
  104. package/dist/engine/retraction.d.ts +93 -5
  105. package/dist/engine/retraction.d.ts.map +1 -1
  106. package/dist/engine/retraction.js +238 -19
  107. package/dist/engine/retraction.js.map +1 -1
  108. package/dist/engine/staging.d.ts +1 -1
  109. package/dist/engine/staging.d.ts.map +1 -1
  110. package/dist/engine/staging.js +3 -3
  111. package/dist/engine/staging.js.map +1 -1
  112. package/dist/hooks/sidecar.d.ts +1 -1
  113. package/dist/hooks/sidecar.d.ts.map +1 -1
  114. package/dist/hooks/sidecar.js +4 -4
  115. package/dist/hooks/sidecar.js.map +1 -1
  116. package/dist/index.js +48 -31
  117. package/dist/index.js.map +1 -1
  118. package/dist/mcp.js +110 -155
  119. package/dist/mcp.js.map +1 -1
  120. package/dist/storage/factory.d.ts +55 -0
  121. package/dist/storage/factory.d.ts.map +1 -0
  122. package/dist/storage/factory.js +135 -0
  123. package/dist/storage/factory.js.map +1 -0
  124. package/dist/storage/pglite-schema.d.ts +20 -0
  125. package/dist/storage/pglite-schema.d.ts.map +1 -0
  126. package/dist/storage/pglite-schema.js +165 -0
  127. package/dist/storage/pglite-schema.js.map +1 -0
  128. package/dist/storage/pglite.d.ts +187 -0
  129. package/dist/storage/pglite.d.ts.map +1 -0
  130. package/dist/storage/pglite.js +1114 -0
  131. package/dist/storage/pglite.js.map +1 -0
  132. package/dist/storage/sqlite.d.ts +117 -0
  133. package/dist/storage/sqlite.d.ts.map +1 -1
  134. package/dist/storage/sqlite.js +357 -8
  135. package/dist/storage/sqlite.js.map +1 -1
  136. package/dist/storage/store.d.ts +63 -0
  137. package/dist/storage/store.d.ts.map +1 -0
  138. package/dist/storage/store.js +27 -0
  139. package/dist/storage/store.js.map +1 -0
  140. package/dist/types/engram.d.ts +92 -2
  141. package/dist/types/engram.d.ts.map +1 -1
  142. package/dist/types/engram.js.map +1 -1
  143. package/package.json +3 -1
  144. package/src/adapters/claude-code.ts +218 -234
  145. package/src/adapters/codex.ts +252 -262
  146. package/src/adapters/common.ts +411 -284
  147. package/src/adapters/cursor.ts +135 -150
  148. package/src/adapters/http.ts +93 -100
  149. package/src/adapters/index.ts +31 -31
  150. package/src/adapters/types.ts +75 -75
  151. package/src/api/index.ts +3 -3
  152. package/src/api/routes.ts +367 -120
  153. package/src/cli/migrate.ts +307 -0
  154. package/src/cli.ts +37 -1
  155. package/src/coordination/circuit-breaker.ts +83 -0
  156. package/src/coordination/events.ts +90 -90
  157. package/src/coordination/failure-modes.ts +50 -0
  158. package/src/coordination/peer-decisions.ts +105 -105
  159. package/src/coordination/plugin-loader.ts +60 -60
  160. package/src/coordination/plugin.ts +44 -44
  161. package/src/coordination/routes.ts +56 -1
  162. package/src/coordination/schema.ts +13 -0
  163. package/src/coordination/stale.ts +80 -11
  164. package/src/coordination/types.ts +311 -311
  165. package/src/coordination/write-mutex.ts +69 -69
  166. package/src/core/auto-tagger.ts +168 -168
  167. package/src/core/decay.ts +63 -63
  168. package/src/core/embeddings.ts +110 -93
  169. package/src/core/index.ts +5 -5
  170. package/src/core/logger.ts +36 -36
  171. package/src/core/ml-worker-entry.ts +194 -0
  172. package/src/core/ml-worker.ts +281 -0
  173. package/src/core/query-expander.ts +122 -128
  174. package/src/core/reranker.ts +119 -125
  175. package/src/core/salience.ts +200 -33
  176. package/src/core/write-pipeline.ts +521 -0
  177. package/src/engine/activation.ts +235 -109
  178. package/src/engine/confidence.ts +120 -0
  179. package/src/engine/connections.ts +162 -103
  180. package/src/engine/consolidation-scheduler.ts +242 -125
  181. package/src/engine/consolidation.ts +138 -45
  182. package/src/engine/eval.ts +102 -102
  183. package/src/engine/eviction.ts +101 -101
  184. package/src/engine/index.ts +8 -8
  185. package/src/engine/retraction.ts +366 -116
  186. package/src/engine/staging.ts +74 -74
  187. package/src/hooks/sidecar.ts +5 -5
  188. package/src/index.ts +42 -28
  189. package/src/mcp.ts +105 -152
  190. package/src/storage/factory.ts +147 -0
  191. package/src/storage/index.ts +3 -3
  192. package/src/storage/pglite-schema.ts +166 -0
  193. package/src/storage/pglite.ts +1363 -0
  194. package/src/storage/sqlite.ts +402 -7
  195. package/src/storage/store.ts +80 -0
  196. package/src/types/agent.ts +67 -67
  197. package/src/types/checkpoint.ts +46 -46
  198. package/src/types/engram.ts +101 -3
  199. package/src/types/eval.ts +100 -100
  200. package/src/types/index.ts +6 -6
@@ -112,146 +112,259 @@ export function homedir() {
112
112
  * Core AWM instruction snippet — shared across all adapters.
113
113
  * Each adapter wraps this in the appropriate file format.
114
114
  */
115
- export const AWM_INSTRUCTION_CONTENT = `
116
- ## Memory (AWM)
117
- You have persistent memory via the agent-working-memory MCP server.
118
-
119
- ### Lifecycle (always do these)
120
- - Session start: call memory_restore to recover previous context
121
- - Starting a task: call memory_task_begin (checkpoints + recalls relevant memories)
122
- - Finishing a task: call memory_task_end with a summary
123
- - Auto-checkpoint: hooks handle compaction, session end, and 15-min timer (no action needed)
124
-
125
- ### Write memory when:
126
- - A project decision is made or changed
127
- - A root cause is discovered after debugging
128
- - A reusable implementation pattern is established
129
- - A user preference, constraint, or requirement is clarified
130
- - A prior assumption is found to be wrong
131
- - A significant piece of work is completed
132
-
133
- ### Writing for recall (the highest-leverage section)
134
- A memory's recall quality is set the moment you write it. AWM is fast at
135
- finding what's findable — but if the write is shaped wrong, no retriever
136
- can rescue it. Be slightly more verbose at the front than feels natural:
137
- the first 1-2 sentences are what BM25, the embedding model, and concept
138
- extraction all see most strongly.
139
-
140
- - **Lead with the rule or fact.** Don't open with context or backstory.
141
- "Don't mock the database in integration tests." comes first; the reason
142
- comes second. Recall scans the head of the body, not the tail.
143
- - **Pick the most specific topic.** Not \`auth\` \`auth-magic-link-rate-limit\`.
144
- Topic is a hard filter at recall time. Generic topics hide the memory in
145
- a noisy bucket where it competes with everything else in the area.
146
- - **Include 2+ retrievable identifiers.** File paths, function names, table
147
- columns, ticket IDs, exact error strings, the literal terms a future query
148
- will use. \`AccountingService.closePeriod()\` beats "the accounting code."
149
- \`tblMemberDetails.activation_date\` beats "the activation column."
150
- \`schema/072-period-close.sql\` beats "the migration."
151
- - **Write in the vocabulary of the future question.** When you imagine asking
152
- this in three months, what nouns will you use? Use those nouns. Don't
153
- paraphrase the user's domain language into your own neutral summary.
154
- - **Reserve canonical for stable invariants.** Decisions, requirements,
155
- hard facts, cross-agent shared context. Working class (default) is correct
156
- for findings, observations, and progress notes. The canonical floor is
157
- 0.7 salience overusing it pollutes the canonical layer and the floor
158
- loses meaning.
159
- - **Include the why for feedback memories.** A rule without a reason can't
160
- be applied to edge cases. "Don't mock the database" is brittle. "Don't
161
- mock the database last quarter mocked tests masked a broken migration"
162
- is portable to new situations.
163
-
164
- ### When writing, include metadata for better recall:
165
- - \`project\`: current project name (e.g., "EquiHub", "AWM")
166
- - \`topic\`: subject area (e.g., "database-migration", "auth-flow")
167
- - \`session_id\`: conversation grouping ID — associates related memories
168
- - \`source\`: how acquired (code-reading, debugging, discussion, research, testing, observation)
169
- - \`confidence_level\`: verified (tested), observed (read in code), assumed (reasoning)
170
- - \`intent\`: decision, finding, todo, question, or context
171
-
172
- ### Memory classes (controls how strictly the salience filter gates the write)
173
- - \`memory_class: canonical\` source-of-truth memories. Floor 0.7 salience, never staged.
174
- Use for: user-stated decisions, project requirements, verified architectural facts,
175
- cross-agent shared context. **In a hive (multi-agent) setup, always use \`canonical\`
176
- for writes that other agents must be able to recall** — the default \`working\` class
177
- may get filtered.
178
- - \`memory_class: working\` (default) observations and findings. Salience-gated.
179
- - \`memory_class: ephemeral\` short-lived context that should decay quickly.
180
-
181
- ### Salience auto-promotion (defense in depth)
182
- The salience filter automatically promotes certain content patterns even if you forget
183
- to set \`memory_class\` explicitly:
184
- - **User feedback** content starting with "Robert said…", "Katherine directed…",
185
- "Nancy decided…" etc. auto-promotes to canonical. So quoting the user verbatim
186
- always preserves the decision.
187
- - **Verified operational records** — content with an action verb (Submitted, Finalized,
188
- Completed, Reconciled, Triaged, Posted, Resolved, Stamped, Pushed, Deployed, Migrated,
189
- Imported, Exported, Backfilled) plus 2+ concrete identifiers (ISO date \`YYYY-MM-DD\`,
190
- or contextual numeric IDs like "event 18969", "ticket #18330", "USEF 341980") gets
191
- a 0.45 salience floor. So batch summaries with real IDs survive even when topic
192
- terms repeat.
193
-
194
- If neither pattern applies and you want a memory to definitely survive, set
195
- \`memory_class: canonical\` explicitly. Don't rely on auto-promotion for important writes.
196
-
197
- ### Recall memory when:
198
- - **BEFORE stating ANY fact about how a system works** — recall first; if AWM doesn't
199
- have it, read the code. Never guess and present it as fact.
200
- - **BEFORE searching the filesystem** — recall first; AWM is faster and has cross-session
201
- knowledge that file search doesn't.
202
- - Starting work on a new task or subsystem
203
- - Re-entering code you haven't touched recently
204
- - After a failed attempt check if there's prior knowledge
205
- - Before refactoring or making architectural changes
206
- - When a topic comes up that you might have prior context on
207
-
208
- Recall is fast (~300ms typical). Use it freely.
209
-
210
- ### Recall strategy (when one query isn't enough)
211
- AWM's adaptive retrieval handles most query variations natively synonym
212
- expansion, multi-channel scoring, embedding + BM25 + reranker agreement.
213
- A single recall is usually enough.
214
-
215
- When it isn't:
216
- - **If the first recall returns nothing or returns the wrong things, reformulate.**
217
- Try a second query with different phrasing — synonyms, more specific nouns,
218
- the exact identifier from the code rather than the conceptual name. Two or
219
- three recalls cost less than one filesystem search.
220
- - **Use the words a domain expert would use, not generic English.** "Period
221
- close lock" not "accounting feature"; "magic link rate limit" not "auth issue."
222
- - **For broad exploration, pass \`mode: "exploratory"\`** wider candidate
223
- pool, lower precision floor. For specific lookups, leave mode unset (auto).
224
- - **Don't ensemble more than 3 reformulations.** If three different phrasings
225
- return nothing, the memory probably isn't there — read the code instead of
226
- burning more recalls.
227
-
228
- ### Keep memory fresh
229
- - After recalling a memory, if you observe the real state is different → call
230
- \`memory_supersede\` immediately with the corrected version.
231
- - After using a recalled memory: call \`memory_feedback\` (useful/not-useful) so the
232
- activation engine learns what's valuable.
233
- - If you discover a memory is factually wrong: \`memory_retract\` to remove it.
234
-
235
- ### Also:
236
- - To track work items: memory_task_add, memory_task_update, memory_task_list, memory_task_next
237
- - AWM is shared across all agents in real time. When any agent writes or supersedes a
238
- memory, every other agent can recall it immediately.
239
-
240
- ### Diagnostics / escape hatches (env vars, only if you know why)
241
- The 0.7.6→0.7.14 work cut recall latency from 11s to ~300ms. Each optimization
242
- is gated by an env-var so it can be disabled for A/B testing if a regression
243
- appears in your workload:
244
-
245
- - \`AWM_DISABLE_POOL_FILTER=1\` (0.7.7+) disables the candidate pool reduction
246
- pre-filter in recall. Reverts to scoring all active candidates.
247
- - \`AWM_DISABLE_SLIM_CACHE=1\` (0.7.10+) — disables the in-memory slim cache.
248
- Reverts to per-recall SQL fetch + Buffer→Float32Array conversion.
249
- - \`AWM_DISABLE_RERANK_SKIP=1\` (0.7.10+) disables the cross-encoder skip on
250
- clear-winner queries. Forces every recall through the reranker.
251
- - \`AWM_DISABLE_EXPANSION_CACHE=1\` (0.7.11+) — disables the query expansion
252
- skip heuristic + LRU cache. Forces every recall through flan-t5-small.
253
-
254
- In production, leave these all unset. Use only when diagnosing a suspected
255
- recall-quality regression.
115
+ /**
116
+ * Upsert the AWM section into an instruction file (CLAUDE.md, AGENTS.md, .cursorrules).
117
+ *
118
+ * Behavior:
119
+ * - File doesn't exist -> create with title + AWM_INSTRUCTION_CONTENT
120
+ * - Section absent -> append
121
+ * - Section present + identical -> skip
122
+ * - Section present + stale -> REPLACE in place, preserve content above/below
123
+ *
124
+ * Section is bounded by `## Memory (AWM)` (with optional trailing modifier) at the
125
+ * start, and the next `## ` heading or EOF at the end.
126
+ *
127
+ * Returns a short human-readable status string for the setup command output.
128
+ */
129
+ export function upsertAwmSection(filePath, newContent, options = {}) {
130
+ const fname = basename(filePath);
131
+ const suffix = options.suffix ?? '';
132
+ if (!existsSync(filePath)) {
133
+ const title = options.titleIfNew ?? `# ${basename(dirname(filePath))}`;
134
+ mkdirSync(dirname(filePath), { recursive: true });
135
+ writeFileSync(filePath, `${title}\n\n${newContent}${suffix}`);
136
+ return `${fname}: created with AWM workflow section`;
137
+ }
138
+ const existing = readFileSync(filePath, 'utf-8');
139
+ // Find section bounds: `## Memory (AWM)` (possibly with ` — MANDATORY` etc.) until next `## ` or EOF
140
+ const startRegex = /^## Memory \(AWM\)[^\n]*$/m;
141
+ const startMatch = startRegex.exec(existing);
142
+ if (!startMatch) {
143
+ // Section not presentappend
144
+ writeFileSync(filePath, existing.trimEnd() + '\n\n' + newContent + suffix);
145
+ return `${fname}: appended AWM workflow section`;
146
+ }
147
+ // Find end: next `## ` heading after the section start, or EOF
148
+ const afterStart = startMatch.index + startMatch[0].length;
149
+ const nextHeadingRegex = /^## (?!Memory \(AWM\))/m;
150
+ nextHeadingRegex.lastIndex = afterStart;
151
+ const tail = existing.slice(afterStart);
152
+ const nextMatch = nextHeadingRegex.exec(tail);
153
+ const sectionEnd = nextMatch ? afterStart + nextMatch.index : existing.length;
154
+ const currentSection = existing.slice(startMatch.index, sectionEnd).trimEnd();
155
+ const desiredSection = (newContent + suffix).trimEnd();
156
+ if (currentSection === desiredSection) {
157
+ return `${fname}: AWM section already up-to-date (skipped)`;
158
+ }
159
+ const before = existing.slice(0, startMatch.index).trimEnd();
160
+ const after = existing.slice(sectionEnd).replace(/^\s*\n/, '');
161
+ const rebuilt = (before ? before + '\n\n' : '') +
162
+ desiredSection +
163
+ (after ? '\n\n' + after : '\n');
164
+ writeFileSync(filePath, rebuilt);
165
+ return `${fname}: AWM section updated (preserved surrounding content)`;
166
+ }
167
+ export const AWM_INSTRUCTION_CONTENT = `
168
+ ## Memory (AWM) MANDATORY
169
+
170
+ **AWM is THE memory system.** Use it via the \`agent-working-memory\` MCP server
171
+ (preferred) or HTTP at \`http://127.0.0.1:8400\` (fallback). The file-based
172
+ auto-memory at \`~/.claude/projects/.../memory/*.md\` is a LEGACY bootstrap path
173
+ **do not write new memories to it.** All persistent knowledge goes through AWM.
174
+
175
+ If MCP tools aren't loaded at session start, use ToolSearch with
176
+ \`select:mcp__agent-working-memory__memory_recall,mcp__agent-working-memory__memory_write\`
177
+ to load them. If the MCP server isn't responsive, restart with \`/mcp\` or use
178
+ the HTTP endpoints (\`POST /memory/write-batch\`, \`POST /memory/activate\`)
179
+ directly but **DO NOT fall back to markdown files**. Files drift the moment
180
+ you write them; AWM stays current because every agent reads + writes the same store.
181
+
182
+ ### Lifecycle (always do these, in this order)
183
+ 1. **Session start**: call \`memory_restore\` to recover previous context.
184
+ 2. **Starting a task**: call \`memory_task_begin\` (checkpoints + recalls relevant memories).
185
+ 3. **During work**: call \`memory_recall\` BEFORE stating any fact, BEFORE searching
186
+ the filesystem, BEFORE making architectural decisions. Recall is ~300ms — cheaper
187
+ than one filesystem search.
188
+ 4. **As you learn things**: call \`memory_write\` proactively. Don't batch.
189
+ 5. **Finishing a task**: call \`memory_task_end\` with a summary.
190
+ 6. **Auto-checkpoint** is handled by hooks (compaction, session-end, 15-min timer). No action needed.
191
+
192
+ ### Write memory when:
193
+ - A project decision is made or changed
194
+ - A root cause is discovered after debugging
195
+ - A reusable implementation pattern is established
196
+ - A user preference, constraint, or requirement is clarified
197
+ - A prior assumption is found to be wrong
198
+ - A significant piece of work is completed
199
+
200
+ ### Writing for recall (the highest-leverage section)
201
+ A memory's recall quality is set the moment you write it. AWM is fast at
202
+ finding what's findable but if the write is shaped wrong, no retriever
203
+ can rescue it. Be slightly more verbose at the front than feels natural:
204
+ the first 1-2 sentences are what BM25, the embedding model, and concept
205
+ extraction all see most strongly.
206
+
207
+ - **Lead with the rule or fact.** Don't open with context or backstory.
208
+ "Don't mock the database in integration tests." comes first; the reason
209
+ comes second. Recall scans the head of the body, not the tail.
210
+ - **Pick the most specific topic.** Not \`auth\` — \`auth-magic-link-rate-limit\`.
211
+ Topic is a hard filter at recall time. Generic topics hide the memory in
212
+ a noisy bucket where it competes with everything else in the area.
213
+ - **Include 2+ retrievable identifiers.** File paths, function names, table
214
+ columns, ticket IDs, exact error strings, the literal terms a future query
215
+ will use. \`AccountingService.closePeriod()\` beats "the accounting code."
216
+ \`tblMemberDetails.activation_date\` beats "the activation column."
217
+ \`schema/072-period-close.sql\` beats "the migration."
218
+ - **Write in the vocabulary of the future question.** When you imagine asking
219
+ this in three months, what nouns will you use? Use those nouns. Don't
220
+ paraphrase the user's domain language into your own neutral summary.
221
+ - **Reserve canonical for stable invariants.** Decisions, requirements,
222
+ hard facts, cross-agent shared context. Working class (default) is correct
223
+ for findings, observations, and progress notes. The canonical floor is
224
+ 0.7 salience overusing it pollutes the canonical layer and the floor
225
+ loses meaning.
226
+ - **Include the why for feedback memories.** A rule without a reason can't
227
+ be applied to edge cases. "Don't mock the database" is brittle. "Don't
228
+ mock the database — last quarter mocked tests masked a broken migration"
229
+ is portable to new situations.
230
+
231
+ ### Tagging rules (REQUIRED AWM's prefix-tag retrieval boost depends on these)
232
+
233
+ Every \`memory_write\` should pass these structured fields. AWM stores each as a
234
+ prefix-tag like \`proj=\`, \`topic=\`, \`intent=\`, etc. and uses them for BM25
235
+ and entity-bridge boosts at recall time.
236
+
237
+ | Field | Required? | Format | Example |
238
+ |---|---|---|---|
239
+ | \`project\` | **YES** | one short word matching the current project | \`"EquiHub"\`, \`"AWM"\`, \`"USEA-Agent"\` |
240
+ | \`topic\` | **YES** | one or more lowercase area words | \`"database-migration"\`, \`"benchmarks"\` |
241
+ | \`intent\` | **YES** | one of: \`decision\` / \`finding\` / \`todo\` / \`question\` / \`context\` | \`"finding"\` |
242
+ | \`confidence_level\` | **YES** | \`verified\` (tested) / \`observed\` (read in code) / \`assumed\` (reasoning) | \`"verified"\` |
243
+ | \`source\` | recommended | \`code-reading\` / \`debugging\` / \`discussion\` / \`research\` / \`testing\` / \`observation\` | \`"testing"\` |
244
+ | \`memory_class\` | when stable | \`canonical\` (source-of-truth, 0.7 floor, never staged) / \`working\` (default) / \`ephemeral\` | \`"canonical"\` |
245
+ | \`session_id\` | recommended | current conversation ID for entity-bridge boost | autogenerated |
246
+ | \`tags\` | when applicable | extra prefix-tags for IDs and dates | \`["ticket=18360", "date=2026-05-11"]\` |
247
+
248
+ **Always add identifier tags when present in the content:**
249
+ - \`ticket=<id>\` for Freshdesk tickets
250
+ - \`member=<id>\` for member IDs
251
+ - \`horse=<id>\` for horse_member_id
252
+ - \`usef=<id>\` for USEF lookups
253
+ - \`date=YYYY-MM-DD\` for temporal anchoring (ISO format)
254
+ - \`person=<Name>\` for stakeholder quotes / decisions
255
+ - \`version=<X.Y.Z>\` for release-specific findings
256
+
257
+ ### Memory classes (controls how strictly the salience filter gates the write)
258
+ - \`memory_class: canonical\` — source-of-truth memories. Floor 0.7 salience, never staged.
259
+ Use for: user-stated decisions, project requirements, verified architectural facts,
260
+ cross-agent shared context. **In a hive (multi-agent) setup, always use \`canonical\`
261
+ for writes that other agents must be able to recall** — the default \`working\` class
262
+ may get filtered.
263
+ - \`memory_class: working\` (default) — observations and findings. Salience-gated.
264
+ - \`memory_class: ephemeral\` — short-lived context that should decay quickly.
265
+
266
+ ### Salience auto-promotion (defense in depth)
267
+ The salience filter automatically promotes certain content patterns even if you forget
268
+ to set \`memory_class\` explicitly:
269
+ - **User feedback** — content starting with "Robert said…", "Katherine directed…",
270
+ "Nancy decided…" etc. auto-promotes to canonical. So quoting the user verbatim
271
+ always preserves the decision.
272
+ - **Verified operational records** — content with an action verb (Submitted, Finalized,
273
+ Completed, Reconciled, Triaged, Posted, Resolved, Stamped, Pushed, Deployed, Migrated,
274
+ Imported, Exported, Backfilled) plus 2+ concrete identifiers (ISO date \`YYYY-MM-DD\`,
275
+ or contextual numeric IDs like "event 18969", "ticket #18330", "USEF 341980") gets
276
+ a 0.45 salience floor. So batch summaries with real IDs survive even when topic
277
+ terms repeat.
278
+
279
+ If neither pattern applies and you want a memory to definitely survive, set
280
+ \`memory_class: canonical\` explicitly. Don't rely on auto-promotion for important writes.
281
+
282
+ ### Recall memory when:
283
+ - **BEFORE stating ANY fact about how a system works** — recall first; if AWM doesn't
284
+ have it, read the code. Never guess and present it as fact.
285
+ - **BEFORE searching the filesystem** — recall first; AWM is faster and has cross-session
286
+ knowledge that file search doesn't.
287
+ - Starting work on a new task or subsystem
288
+ - Re-entering code you haven't touched recently
289
+ - After a failed attempt — check if there's prior knowledge
290
+ - Before refactoring or making architectural changes
291
+ - When a topic comes up that you might have prior context on
292
+
293
+ Recall is fast (~300ms typical). Use it freely.
294
+
295
+ ### Recall strategy (when one query isn't enough)
296
+ AWM's adaptive retrieval handles most query variations natively — synonym
297
+ expansion, multi-channel scoring, embedding + BM25 + reranker agreement.
298
+ A single recall is usually enough.
299
+
300
+ When it isn't:
301
+ - **If the first recall returns nothing or returns the wrong things, reformulate.**
302
+ Try a second query with different phrasing — synonyms, more specific nouns,
303
+ the exact identifier from the code rather than the conceptual name. Two or
304
+ three recalls cost less than one filesystem search.
305
+ - **Use the words a domain expert would use, not generic English.** "Period
306
+ close lock" not "accounting feature"; "magic link rate limit" not "auth issue."
307
+ - **For broad exploration, pass \`mode: "exploratory"\`** — wider candidate
308
+ pool, lower precision floor. For specific lookups, leave mode unset (auto).
309
+ - **Don't ensemble more than 3 reformulations.** If three different phrasings
310
+ return nothing, the memory probably isn't there — read the code instead of
311
+ burning more recalls.
312
+
313
+ ### Keep memory fresh
314
+ - After recalling a memory, if you observe the real state is different → call
315
+ \`memory_supersede\` immediately with the corrected version.
316
+ - After using a recalled memory: call \`memory_feedback\` (useful/not-useful) so the
317
+ activation engine learns what's valuable.
318
+ - If you discover a memory is factually wrong: \`memory_retract\` to remove it.
319
+ - **If you bypass AWM (file-memory, in-context notes, "I'll just remember"), the memory
320
+ drifts out of date. The system relies on you to keep it current. This is the #1
321
+ failure mode.**
322
+
323
+ ### Example — good vs bad memory_write
324
+
325
+ **BAD** (no prefix tags, vague concept, can't be recalled by future queries):
326
+ \`\`\`
327
+ memory_write(
328
+ concept="found a bug",
329
+ content="The thing I was looking at was broken so I fixed it."
330
+ )
331
+ \`\`\`
332
+
333
+ **GOOD** (rich identifiers, structured metadata, prefix tags):
334
+ \`\`\`
335
+ memory_write(
336
+ concept="EquiHub period-close BLOCKED check missing server-side",
337
+ content="apps/web/app/(accounting)/accounting/period-close/page.tsx had client-only BLOCKED enforcement. Fixed by adding server-side check in AccountingService.closePeriod() per schema/072-period-close.sql. Without server-side check a malicious request could bypass via direct API call.",
338
+ project="EquiHub",
339
+ topic="accounting",
340
+ intent="finding",
341
+ confidence_level="verified",
342
+ source="debugging",
343
+ memory_class="canonical",
344
+ tags=["ticket=18360", "person=Robert", "date=2026-05-11", "topic=period-close", "topic=security"]
345
+ )
346
+ \`\`\`
347
+
348
+ ### Also:
349
+ - To track work items: memory_task_add, memory_task_update, memory_task_list, memory_task_next
350
+ - AWM is shared across all agents in real time. When any agent writes or supersedes a
351
+ memory, every other agent can recall it immediately.
352
+
353
+ ### Diagnostics / escape hatches (env vars, only if you know why)
354
+ The 0.7.6→0.7.14 work cut recall latency from 11s to ~300ms. Each optimization
355
+ is gated by an env-var so it can be disabled for A/B testing if a regression
356
+ appears in your workload:
357
+
358
+ - \`AWM_DISABLE_POOL_FILTER=1\` (0.7.7+) — disables the candidate pool reduction
359
+ pre-filter in recall. Reverts to scoring all active candidates.
360
+ - \`AWM_DISABLE_SLIM_CACHE=1\` (0.7.10+) — disables the in-memory slim cache.
361
+ Reverts to per-recall SQL fetch + Buffer→Float32Array conversion.
362
+ - \`AWM_DISABLE_RERANK_SKIP=1\` (0.7.10+) — disables the cross-encoder skip on
363
+ clear-winner queries. Forces every recall through the reranker.
364
+ - \`AWM_DISABLE_EXPANSION_CACHE=1\` (0.7.11+) — disables the query expansion
365
+ skip heuristic + LRU cache. Forces every recall through flan-t5-small.
366
+
367
+ In production, leave these all unset. Use only when diagnosing a suspected
368
+ recall-quality regression.
256
369
  `.trimStart();
257
370
  //# sourceMappingURL=common.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/adapters/common.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,sCAAsC;AAEtC;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC,gEAAgE;AAChE,MAAM,UAAU,kBAAkB;IAChC,uEAAuE;IACvE,OAAO,OAAO,CAAC,SAAS,EAAE,IAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0MtC,CAAC,SAAS,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../../src/adapters/cursor.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,UAAU,EAAkC,MAAM,YAAY,CAAC;AAG7E,QAAA,MAAM,OAAO,EAAE,UAoId,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../../src/adapters/cursor.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,UAAU,EAAkC,MAAM,YAAY,CAAC;AAG7E,QAAA,MAAM,OAAO,EAAE,UAqHd,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -8,7 +8,7 @@
8
8
  */
9
9
  import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs';
10
10
  import { join, dirname } from 'node:path';
11
- import { resolveMcpCommand, homedir, AWM_INSTRUCTION_CONTENT } from './common.js';
11
+ import { resolveMcpCommand, homedir, AWM_INSTRUCTION_CONTENT, upsertAwmSection } from './common.js';
12
12
  const adapter = {
13
13
  id: 'cursor',
14
14
  name: 'Cursor',
@@ -45,20 +45,7 @@ const adapter = {
45
45
  : join(ctx.cwd, '.cursorrules');
46
46
  if (skip)
47
47
  return '.cursorrules: skipped (--no-instructions)';
48
- const dir = dirname(rulesPath);
49
- if (!existsSync(dir)) {
50
- mkdirSync(dir, { recursive: true });
51
- }
52
- if (existsSync(rulesPath)) {
53
- const content = readFileSync(rulesPath, 'utf-8');
54
- if (content.includes('## Memory (AWM)')) {
55
- return '.cursorrules: already has AWM section (skipped)';
56
- }
57
- writeFileSync(rulesPath, content.trimEnd() + '\n\n' + AWM_INSTRUCTION_CONTENT);
58
- return '.cursorrules: appended AWM workflow section';
59
- }
60
- writeFileSync(rulesPath, AWM_INSTRUCTION_CONTENT);
61
- return '.cursorrules: created with AWM workflow section';
48
+ return upsertAwmSection(rulesPath, AWM_INSTRUCTION_CONTENT, { titleIfNew: '# Agent Working Memory' });
62
49
  },
63
50
  writeHooks(_ctx, _skip) {
64
51
  return 'Hooks: not supported by Cursor (auto-checkpoint unavailable)';
@@ -1 +1 @@
1
- {"version":3,"file":"cursor.js","sourceRoot":"","sources":["../../src/adapters/cursor.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,sCAAsC;AAEtC;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,OAAO,EAAY,MAAM,WAAW,CAAC;AAEpD,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAElF,MAAM,OAAO,GAAe;IAC1B,EAAE,EAAE,QAAQ;IACZ,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,IAAI;IAC1B,mBAAmB,EAAE,IAAI;IAEzB,cAAc,CAAC,GAAiB;QAC9B,MAAM,MAAM,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;QACtC,MAAM,SAAS,GAAG,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;QAElD,MAAM,WAAW,GAAG,GAAG,CAAC,QAAQ;YAC9B,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC;YACxC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;QAEzC,MAAM,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;QACpC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YACxB,SAAS,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACzC,CAAC;QAED,IAAI,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.d.ts","sourceRoot":"","sources":["../../src/adapters/http.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,UAAU,EAAkC,MAAM,YAAY,CAAC;AA2B7E,QAAA,MAAM,OAAO,EAAE,UA0Dd,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/adapters/http.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,UAAU,EAAkC,MAAM,YAAY,CAAC;AA2B7E,QAAA,MAAM,OAAO,EAAE,UAmDd,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -6,31 +6,31 @@
6
6
  * Doesn't write MCP config. Prints connection instructions for the HTTP API.
7
7
  * Optionally writes an instruction file.
8
8
  */
9
- import { readFileSync, writeFileSync, existsSync } from 'node:fs';
9
+ import { existsSync } from 'node:fs';
10
10
  import { join } from 'node:path';
11
- import { AWM_INSTRUCTION_CONTENT } from './common.js';
12
- const HTTP_ADDENDUM = `
13
- ### HTTP API (for tools without MCP support)
14
-
15
- If your tool doesn't support MCP, use the HTTP API directly:
16
-
17
- **Base URL:** \`http://127.0.0.1:8400\`
18
-
19
- | Method | Endpoint | Purpose |
20
- |--------|----------|---------|
21
- | GET | /memory/restore/:agentId | Restore context from prior sessions |
22
- | POST | /memory/activate | Cognitive recall (use \`context\` field) |
23
- | POST | /memory/write | Write a memory |
24
- | POST | /memory/feedback | Report if memory was useful |
25
- | POST | /memory/retract | Invalidate a wrong memory |
26
- | POST | /memory/checkpoint | Save execution state |
27
- | POST | /task/create | Create a task |
28
- | POST | /task/update | Update task status |
29
- | GET | /task/list/:agentId | List tasks |
30
- | GET | /task/next/:agentId | Get next actionable task |
31
- | GET | /health | Health check |
32
-
33
- Start the server with: \`awm serve\`
11
+ import { AWM_INSTRUCTION_CONTENT, upsertAwmSection } from './common.js';
12
+ const HTTP_ADDENDUM = `
13
+ ### HTTP API (for tools without MCP support)
14
+
15
+ If your tool doesn't support MCP, use the HTTP API directly:
16
+
17
+ **Base URL:** \`http://127.0.0.1:8400\`
18
+
19
+ | Method | Endpoint | Purpose |
20
+ |--------|----------|---------|
21
+ | GET | /memory/restore/:agentId | Restore context from prior sessions |
22
+ | POST | /memory/activate | Cognitive recall (use \`context\` field) |
23
+ | POST | /memory/write | Write a memory |
24
+ | POST | /memory/feedback | Report if memory was useful |
25
+ | POST | /memory/retract | Invalidate a wrong memory |
26
+ | POST | /memory/checkpoint | Save execution state |
27
+ | POST | /task/create | Create a task |
28
+ | POST | /task/update | Update task status |
29
+ | GET | /task/list/:agentId | List tasks |
30
+ | GET | /task/next/:agentId | Get next actionable task |
31
+ | GET | /health | Health check |
32
+
33
+ Start the server with: \`awm serve\`
34
34
  `;
35
35
  const adapter = {
36
36
  id: 'http',
@@ -45,16 +45,10 @@ const adapter = {
45
45
  const instrPath = join(ctx.cwd, 'AWM-INSTRUCTIONS.md');
46
46
  if (skip)
47
47
  return 'AWM-INSTRUCTIONS.md: skipped (--no-instructions)';
48
- if (existsSync(instrPath)) {
49
- const content = readFileSync(instrPath, 'utf-8');
50
- if (content.includes('## Memory (AWM)')) {
51
- return 'AWM-INSTRUCTIONS.md: already has AWM section (skipped)';
52
- }
53
- writeFileSync(instrPath, content.trimEnd() + '\n\n' + AWM_INSTRUCTION_CONTENT + HTTP_ADDENDUM);
54
- return 'AWM-INSTRUCTIONS.md: appended AWM + HTTP API section';
55
- }
56
- writeFileSync(instrPath, `# Agent Working Memory\n\n${AWM_INSTRUCTION_CONTENT}${HTTP_ADDENDUM}`);
57
- return 'AWM-INSTRUCTIONS.md: created with AWM + HTTP API section';
48
+ return upsertAwmSection(instrPath, AWM_INSTRUCTION_CONTENT, {
49
+ titleIfNew: '# Agent Working Memory',
50
+ suffix: HTTP_ADDENDUM,
51
+ });
58
52
  },
59
53
  writeHooks(_ctx, _skip) {
60
54
  return 'Hooks: N/A (HTTP mode)';
@@ -1 +1 @@
1
- {"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/adapters/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QAED,oCAAoC;QACpC,uEAAuE;QACvE,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;YAChB,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,mBAAmB,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,sBAAsB,EAAE,CAAC,CAAC;QAC9F,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC;gBACX,KAAK,EAAE,mBAAmB;gBAC1B,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,qDAAqD;gBAC9D,GAAG,EAAE,oBAAoB;aAC1B,CAAC,CAAC;QACL,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -31,7 +31,7 @@
31
31
  * GET /health — health check
32
32
  */
33
33
  import type { FastifyInstance } from 'fastify';
34
- import type { EngramStore } from '../storage/sqlite.js';
34
+ import type { IEngramStore as EngramStore } from '../storage/store.js';
35
35
  import type { ActivationEngine } from '../engine/activation.js';
36
36
  import type { ConnectionEngine } from '../engine/connections.js';
37
37
  import type { EvictionEngine } from '../engine/eviction.js';