memoryai-mcp 2.4.3 → 2.4.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.
@@ -4,13 +4,19 @@
4
4
  * Zero-dependency setup script that creates, in the current project:
5
5
  * - .kiro/settings/mcp.json (MCP server wiring)
6
6
  * - .kiro/steering/memoryai.md (always-on instructions, soft fallback)
7
- * - .kiro/hooks/memoryai-auto-recall.kiro.hook (promptSubmit → bootstrap/recall)
8
- * - .kiro/hooks/memoryai-auto-capture.kiro.hook (agentStop → store/compact)
7
+ * - .kiro/hooks/memoryai-auto-recall.kiro.hook (promptSubmit → recall + guard)
9
8
  *
10
- * The two hooks are what make memory TRULY automatic: they fire on IDE events
11
- * (every prompt / end of every turn) instead of relying on the agent to
12
- * remember the steering instructions. Result: the user installs once and never
13
- * has to think about memory again — recall happens before answers, persistence
14
- * happens after turns, compaction happens when context fills.
9
+ * ONE hook only (v0.2.4+). It fires on promptSubmit BEFORE the answer and
10
+ * does three things in a single pass: recall relevant memory, persist anything
11
+ * memorable from the previous turn, and run the context-guard release check.
12
+ *
13
+ * Why not a second agentStop hook? The old design had a separate
14
+ * memoryai-auto-capture.kiro.hook on agentStop. agentStop fires AFTER the
15
+ * reply and forces a fresh askAgent reasoning pass whose only job is to "stay
16
+ * silent" — which leaks a stray "." into the chat and burns ~1.5 credits per
17
+ * idle turn. Folding the capture/guard logic into the promptSubmit hook fixes
18
+ * both problems: the background work finishes before the model answers, so the
19
+ * reply is clean and nothing fires on an idle turn-end. The setup below also
20
+ * deletes any pre-0.2.4 auto-capture hook left on disk.
15
21
  */
16
22
  export {};
@@ -4,17 +4,23 @@
4
4
  * Zero-dependency setup script that creates, in the current project:
5
5
  * - .kiro/settings/mcp.json (MCP server wiring)
6
6
  * - .kiro/steering/memoryai.md (always-on instructions, soft fallback)
7
- * - .kiro/hooks/memoryai-auto-recall.kiro.hook (promptSubmit → bootstrap/recall)
8
- * - .kiro/hooks/memoryai-auto-capture.kiro.hook (agentStop → store/compact)
7
+ * - .kiro/hooks/memoryai-auto-recall.kiro.hook (promptSubmit → recall + guard)
9
8
  *
10
- * The two hooks are what make memory TRULY automatic: they fire on IDE events
11
- * (every prompt / end of every turn) instead of relying on the agent to
12
- * remember the steering instructions. Result: the user installs once and never
13
- * has to think about memory again — recall happens before answers, persistence
14
- * happens after turns, compaction happens when context fills.
9
+ * ONE hook only (v0.2.4+). It fires on promptSubmit BEFORE the answer and
10
+ * does three things in a single pass: recall relevant memory, persist anything
11
+ * memorable from the previous turn, and run the context-guard release check.
12
+ *
13
+ * Why not a second agentStop hook? The old design had a separate
14
+ * memoryai-auto-capture.kiro.hook on agentStop. agentStop fires AFTER the
15
+ * reply and forces a fresh askAgent reasoning pass whose only job is to "stay
16
+ * silent" — which leaks a stray "." into the chat and burns ~1.5 credits per
17
+ * idle turn. Folding the capture/guard logic into the promptSubmit hook fixes
18
+ * both problems: the background work finishes before the model answers, so the
19
+ * reply is clean and nothing fires on an idle turn-end. The setup below also
20
+ * deletes any pre-0.2.4 auto-capture hook left on disk.
15
21
  */
16
22
  import { createInterface } from "node:readline";
17
- import { existsSync, mkdirSync, writeFileSync } from "node:fs";
23
+ import { existsSync, mkdirSync, writeFileSync, rmSync } from "node:fs";
18
24
  import { join, dirname } from "node:path";
19
25
  const rl = createInterface({ input: process.stdin, output: process.stdout });
20
26
  function ask(question, fallback) {
@@ -98,19 +104,19 @@ inclusion: always
98
104
 
99
105
  # MemoryAI — Persistent Memory (mostly automatic)
100
106
 
101
- You have MemoryAI tools via MCP. Two Agent Hooks automate the common path:
102
- - **Auto-Recall** (on every prompt) loads memory before you answer.
103
- - **Auto-Capture** (end of every turn) stores important memory and compacts when full.
107
+ You have MemoryAI tools via MCP. ONE Agent Hook automates the common path:
108
+ - **Auto-Recall** (on every prompt, before you answer) loads memory, persists
109
+ anything memorable from the previous turn, and runs the context-guard check.
104
110
 
105
111
  So you normally do NOT need to manage memory by hand. This file is a fallback
106
- for cases the hooks don't cover, plus the rules for HOW to use memory well.
112
+ for cases the hook doesn't cover, plus the rules for HOW to use memory well.
107
113
 
108
- ## What the hooks already handle
114
+ ## What the hook already handles
109
115
  - Session-start \`memory_bootstrap\`, per-prompt \`memory_recall\`.
110
- - Post-turn \`memory_store\` for decisions/preferences/facts/pitfalls/procedures.
111
- - \`context_guard_check\` → \`context_guard_compact\` when context fills.
116
+ - \`memory_store\` for decisions/preferences/facts/pitfalls/procedures.
117
+ - \`ide_turn_check\` → \`context_guard_compact\` when context fills.
112
118
 
113
- Don't duplicate these on your own unless a hook clearly didn't run.
119
+ Don't duplicate these on your own unless the hook clearly didn't run.
114
120
 
115
121
  ## Memory types
116
122
  - \`decision\` — architectural/technical decisions (DNA-protected, never decays)
@@ -128,35 +134,25 @@ Don't duplicate these on your own unless a hook clearly didn't run.
128
134
  - Use \`zone: "critical"\` for things that must never be forgotten.
129
135
  - Use \`retention: "forever"\` for permanent project knowledge.
130
136
  `;
131
- // ── Agent Hooks — event-level automation (the real "zero-action" layer) ──
132
- // These fire on IDE events so memory works even if the agent ignores steering.
137
+ // ── Agent Hook — event-level automation (the real "zero-action" layer) ──
138
+ // ONE hook on promptSubmit. Fires BEFORE the answer so all background work
139
+ // (recall + persist + guard) finishes first and the reply stays clean. This
140
+ // replaces the old two-hook design (auto-recall + auto-capture); the
141
+ // agentStop auto-capture hook is retired because it leaked a stray "." and
142
+ // cost ~1.5 credits per idle turn.
133
143
  const HOOK_AUTO_RECALL = JSON.stringify({
134
144
  enabled: true,
135
145
  name: "MemoryAI Auto-Recall",
136
- description: "Before answering each user message, automatically load relevant memory so the agent always has prior context — zero user action.",
137
- version: "1",
146
+ description: "Before answering each user message: load relevant memory, persist anything memorable from the previous turn, and run the context-guard check. One hook, fires on promptSubmit so all background work finishes before the reply — zero user action.",
147
+ version: "2",
138
148
  when: { type: "promptSubmit" },
139
149
  then: {
140
150
  type: "askAgent",
141
- prompt: "Before responding, ensure you have the relevant long-term memory (do this silently, integrate naturally, never show raw tool output):\n\n" +
142
- "1. If this is the first turn of the session, call memory_bootstrap once to load preferences, decisions, and recent project context.\n" +
143
- "2. If the user's message references past work, decisions, preferences, or anything that might be stored (\"what did we\", \"last time\", \"our approach\", \"why did we\", or a question about the project), call memory_recall with a focused query first, then answer using what you find.\n" +
144
- "3. If the message is trivial small-talk, skip recall.\n\n" +
145
- "Use recalled memory to inform the answer; do not announce that a memory system exists unless asked.",
146
- },
147
- }, null, 2) + "\n";
148
- const HOOK_AUTO_CAPTURE = JSON.stringify({
149
- enabled: true,
150
- name: "MemoryAI Auto-Capture",
151
- description: "Fully automatic: persist memorable events to MemoryAI after every turn, and persist session state silently when pressure thresholds hit. No user action ever required — the IDE host handles window eviction on its own and the auto-recall hook rehydrates context afterwards.",
152
- version: "5",
153
- when: { type: "agentStop" },
154
- then: {
155
- type: "askAgent",
156
- prompt: "Run two background tasks SILENTLY. Do not tell the user about either task, do not change your normal reply, do not suggest /compact or 'open a new conversation' — those are not user actions in this design.\n\n" +
157
- "1. PERSIST: If the turn produced a decision, preference, important project fact, lesson from a mistake (pitfall), or reusable procedure, call memory_store with the correct memory_type. Skip greetings and trivia. Dedup is automatic. Never store secrets.\n\n" +
158
- "2. RELEASE CHECK: Count the assistant turns in this conversation, then call ide_turn_check with turn_count = (your count) and max_tokens = 200000. Read the response's action_prompt field and follow it VERBATIM. Every action_prompt in this design tells you to act SILENTLY — call context_guard_compact when asked, do nothing when asked. Never message the user from this hook.\n\n" +
159
- "The design: MemoryAI persists to DB on threshold; the IDE host (Kiro auto-summarize, Claude Code /clear, Cursor /reset) evicts the window on its own schedule; the auto-recall hook on the next user message rehydrates context. From the user's view, nothing ever happens — the chat just keeps working.",
151
+ prompt: "Before responding, run these background tasks SILENTLY integrate naturally, never show raw tool output, never tell the user a memory system exists unless asked:\n\n" +
152
+ "1. RECALL: If this is the first turn of the session, call memory_bootstrap once to load preferences, decisions, and recent project context. If the user's message references past work, decisions, preferences, or anything that might be stored (\"what did we\", \"last time\", \"our approach\", \"why did we\", or a question about the project), call memory_recall with a focused query. Trivial small-talk: skip recall.\n\n" +
153
+ "2. PERSIST: If the PREVIOUS turn produced a decision, preference, important project fact, lesson from a mistake (pitfall), or reusable procedure, call memory_store with the correct memory_type. Skip greetings and trivia. Dedup is automatic. Never store secrets.\n\n" +
154
+ "3. RELEASE CHECK: Count the assistant turns in this conversation. If the count is 15 or higher, call ide_turn_check with turn_count = (your count) and max_tokens = 200000, then follow the response's action_prompt field VERBATIM. Below turn 15, skip the guard. Every action_prompt acts SILENTLY — call context_guard_compact when asked, do nothing when asked. The ONLY message you may ever surface is the single \"context is full\" notice, and only when the action_prompt explicitly contains it, once per session.\n\n" +
155
+ "Then answer the user normally using whatever you recalled.",
160
156
  },
161
157
  }, null, 2) + "\n";
162
158
  async function main() {
@@ -179,14 +175,26 @@ async function main() {
179
175
  writeIfMissing(join(cwd, ".kiro", "settings", "mcp.json"), MCP_CONFIG(apiKey, endpoint), ".kiro/settings/mcp.json");
180
176
  writeIfMissing(join(cwd, ".kiro", "steering", "memoryai.md"), STEERING, ".kiro/steering/memoryai.md");
181
177
  writeIfMissing(join(cwd, ".kiro", "hooks", "memoryai-auto-recall.kiro.hook"), HOOK_AUTO_RECALL, ".kiro/hooks/memoryai-auto-recall.kiro.hook");
182
- writeIfMissing(join(cwd, ".kiro", "hooks", "memoryai-auto-capture.kiro.hook"), HOOK_AUTO_CAPTURE, ".kiro/hooks/memoryai-auto-capture.kiro.hook");
178
+ // Retire the pre-0.2.4 agentStop hook if it exists. It fired AFTER every
179
+ // turn, forced an askAgent pass that leaked a stray "." into chat, and cost
180
+ // ~1.5 credits per idle turn. Its logic now lives in the auto-recall hook.
181
+ const legacyCapture = join(cwd, ".kiro", "hooks", "memoryai-auto-capture.kiro.hook");
182
+ if (existsSync(legacyCapture)) {
183
+ try {
184
+ rmSync(legacyCapture);
185
+ console.log(" remove .kiro/hooks/memoryai-auto-capture.kiro.hook (retired agentStop hook)");
186
+ }
187
+ catch {
188
+ console.log(" warn could not remove legacy memoryai-auto-capture.kiro.hook");
189
+ }
190
+ }
183
191
  console.log(`
184
192
  Done. MemoryAI now runs automatically — you don't have to do anything.
185
- - Auto-Recall hook loads relevant memory before each answer.
186
- - Auto-Capture hook stores decisions/preferences and compacts when full.
193
+ - Auto-Recall hook (before each answer) loads memory, persists what matters,
194
+ and runs the context-guard check all silently.
187
195
 
188
196
  Next steps:
189
- 1. Restart Kiro (loads the MCP server + hooks)
197
+ 1. Restart Kiro (loads the MCP server + hook)
190
198
  2. Just work normally. Memory persists across sessions on its own.
191
199
  3. Optional check: ask "What do you remember about this project?"
192
200
  `);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memoryai-mcp",
3
- "version": "2.4.3",
3
+ "version": "2.4.4",
4
4
  "description": "MCP server for MemoryAI v2.3 — One brain. Every AI you use. Forever. Persistent memory and context guard tools for IDEs and bots.",
5
5
  "homepage": "https://memoryai.dev",
6
6
  "repository": {