@hiveai/mcp 0.3.2 → 0.3.3

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.
package/README.md CHANGED
@@ -23,11 +23,19 @@ npm install -g @hiveai/cli
23
23
  ## Quick start
24
24
 
25
25
  ```bash
26
- # 1. Initialize hAIve in your project
27
- haive init
26
+ # 1. Install the CLI
27
+ npm install -g @hiveai/cli
28
+
29
+ # 2. Initialize hAIve in your project (autopilot ON by default)
30
+ cd my-project
31
+ haive init # sets up .ai/, hooks, CI workflow, code-map — everything automatic
32
+ # haive init --manual # if you want to approve memories yourself
33
+
34
+ # 3. Point your AI client at the MCP server (see Client configuration below)
28
35
 
29
- # 2. Add your AI client config (see below)
30
- # 3. Ask your AI to call get_briefing before starting any task
36
+ # 4. Bootstrap project context — run bootstrap_project prompt in your AI client once
37
+
38
+ # 5. Your AI client now calls get_briefing at every session start automatically
31
39
  ```
32
40
 
33
41
  ---
@@ -135,7 +143,9 @@ One-shot onboarding: returns project context + module contexts + ranked relevant
135
143
 
136
144
  ### `mem_save`
137
145
 
138
- Save a new memory. For failed approaches, use `mem_tried` instead it enforces better structure.
146
+ Save a piece of knowledge as a persistent memory. For failed approaches, use `mem_tried` instead. For code discoveries during reading, use `mem_observe` instead.
147
+
148
+ > **Autopilot mode:** memories go directly to `validated` with `team` scope by default. No approval cycle.
139
149
 
140
150
  ```json
141
151
  {
@@ -144,24 +154,27 @@ Save a new memory. For failed approaches, use `mem_tried` instead — it enforce
144
154
  "scope": "team",
145
155
  "body": "spring.jpa.open-in-view=false is intentional — do not re-enable. Lazy loading outside transactions causes N+1 queries.",
146
156
  "paths": ["src/main/resources/application.properties"],
147
- "tags": ["spring", "jpa", "performance"]
157
+ "tags": ["spring", "jpa", "performance"],
158
+ "topic": "jpa-config"
148
159
  }
149
160
  ```
150
161
 
151
162
  | Parameter | Required | Description |
152
163
  |---|---|---|
153
164
  | `type` | ✅ | `convention` · `decision` · `gotcha` · `architecture` · `glossary` |
154
- | `slug` | ✅ | Short kebab-case identifier |
155
- | `scope` | — | `personal` (default) · `team` · `module` |
156
- | `body` | ✅ | Markdown content |
157
- | `paths` | — | File paths to anchor to (enables staleness detection). **Warning returned if path doesn't exist in project.** |
165
+ | `slug` | ✅ | Short kebab-case identifier used in the file name |
166
+ | `scope` | — | `personal` (default in manual mode) · `team` · `module` |
167
+ | `body` | ✅ | Markdown content of the memory |
168
+ | `paths` | — | Source file paths to anchor to enables staleness detection by `haive sync`. **Warning if path doesn't exist.** |
158
169
  | `symbols` | — | Function/class names to anchor to |
159
- | `tags` | — | Tags for filtering |
160
- | `topic` | — | Stable key for upsert: if a memory with this `topic`+`scope` already exists, it is updated in-place (`revision_count++`) |
170
+ | `tags` | — | Tags for filtering and search |
171
+ | `topic` | — | Stable key for upsert: if a memory with this `topic`+`scope` exists, update it in-place (`revision_count++`) |
161
172
  | `domain` | — | Business domain (e.g. `payments`) |
162
173
  | `author` | — | Author handle |
163
174
 
164
- **Deduplication:** identical body content (same SHA-256 hash) within the same scope is rejected with an error. Use `mem_update` to modify it instead.
175
+ **Response:** `{ id, scope, file_path, action: "created"|"updated", warning?, invalid_paths? }`
176
+
177
+ **Deduplication:** identical body content within the same scope is rejected. Use `mem_update` to modify an existing memory.
165
178
 
166
179
  ---
167
180
 
package/dist/index.js CHANGED
@@ -1919,7 +1919,7 @@ function summarizeTools(events) {
1919
1919
 
1920
1920
  // src/server.ts
1921
1921
  var SERVER_NAME = "haive";
1922
- var SERVER_VERSION = "0.3.2";
1922
+ var SERVER_VERSION = "0.3.3";
1923
1923
  function jsonResult(data) {
1924
1924
  return {
1925
1925
  content: [
@@ -1940,7 +1940,30 @@ function createHaiveServer(options = {}) {
1940
1940
  );
1941
1941
  server.tool(
1942
1942
  "mem_save",
1943
- "Save a new memory (convention, decision, gotcha, architecture, glossary). For failed approaches use mem_tried instead \u2014 it enforces a structured format that is more useful to future agents. Use scope=team to share with the whole team.",
1943
+ [
1944
+ "Save a piece of knowledge as a persistent memory that survives across AI sessions.",
1945
+ "",
1946
+ "USE THIS WHEN you discover something worth remembering for future sessions:",
1947
+ " - A project convention (how things are done here)",
1948
+ " - An architectural decision and its rationale",
1949
+ " - A gotcha or non-obvious behavior that surprised you",
1950
+ " - A domain term and what it means in this codebase",
1951
+ "",
1952
+ "DO NOT USE for failed approaches \u2192 use mem_tried instead (better structure).",
1953
+ "DO NOT USE for code discoveries during exploration \u2192 use mem_observe instead.",
1954
+ "",
1955
+ "PARAMETERS:",
1956
+ " type \u2014 convention | decision | gotcha | architecture | glossary | attempt",
1957
+ " slug \u2014 short kebab-case id (e.g. 'flyway-no-modify-existing')",
1958
+ " body \u2014 Markdown content with the full knowledge",
1959
+ " scope \u2014 team (shared with all devs) | personal (private) | module (component-scoped)",
1960
+ " paths \u2014 anchor to source files for staleness detection (STRONGLY recommended)",
1961
+ " topic \u2014 stable key for upsert: if a memory with same topic+scope exists, update it in-place",
1962
+ "",
1963
+ "RETURNS: { id, scope, file_path, action: 'created'|'updated', warning?, invalid_paths? }",
1964
+ "WARNING: if paths point to non-existent files, they will be immediately stale after haive sync.",
1965
+ "DEDUP: identical body content within the same scope is rejected \u2014 use mem_update to modify."
1966
+ ].join("\n"),
1944
1967
  MemSaveInputSchema,
1945
1968
  async (input) => {
1946
1969
  tracker.record("mem_save", input.slug);
@@ -1948,26 +1971,125 @@ function createHaiveServer(options = {}) {
1948
1971
  }
1949
1972
  );
1950
1973
  server.tool(
1951
- "mem_search",
1952
- "Search memories by substring across id, tags, and body. Optional filters by scope/type/module.",
1953
- MemSearchInputSchema,
1954
- async (input) => jsonResult(await memSearch(input, context))
1974
+ "mem_tried",
1975
+ [
1976
+ "Record a FAILED approach so future agents don't repeat the same mistake.",
1977
+ "",
1978
+ "USE THIS IMMEDIATELY when you try something and it doesn't work. This is the",
1979
+ "most valuable type of negative knowledge \u2014 it saves hours of debugging for",
1980
+ "future agents working on the same codebase.",
1981
+ "",
1982
+ "Auto-validated (no approval cycle). Surfaced FIRST in future get_briefing calls",
1983
+ "so it's impossible to miss.",
1984
+ "",
1985
+ "PARAMETERS:",
1986
+ " what \u2014 short title of what you tried (e.g. 'importing X with ESM dynamic import')",
1987
+ " why_failed \u2014 the exact error or reason it failed",
1988
+ " instead \u2014 what to do instead (the correct approach)",
1989
+ " scope \u2014 team (default) | personal",
1990
+ " paths \u2014 source files where the issue lives",
1991
+ "",
1992
+ "RETURNS: { id, file_path, action: 'created' }"
1993
+ ].join("\n"),
1994
+ MemTriedInputSchema,
1995
+ async (input) => {
1996
+ tracker.record("mem_tried", input.what.slice(0, 80));
1997
+ return jsonResult(await memTried(input, context));
1998
+ }
1955
1999
  );
1956
2000
  server.tool(
1957
- "mem_list",
1958
- "List memories with optional filters by scope/type/module/tag.",
1959
- MemListInputSchema,
1960
- async (input) => jsonResult(await memList(input, context))
2001
+ "mem_observe",
2002
+ [
2003
+ "Capture a code-level discovery made WHILE READING existing code.",
2004
+ "",
2005
+ "USE THIS when you read a file and spot something the team may not know about:",
2006
+ " - A bug or race condition hiding in the code",
2007
+ " - A security gap or missing validation",
2008
+ " - An inconsistency between two files",
2009
+ " - A missing configuration or environment variable",
2010
+ " - Anything that could silently break in production",
2011
+ "",
2012
+ "DIFFERENCE from mem_save: mem_observe is for REACTIVE discoveries during code",
2013
+ "reading. mem_save is for deliberate knowledge capture (conventions, decisions).",
2014
+ "",
2015
+ "Auto-validated, anchored to file paths for staleness detection.",
2016
+ "",
2017
+ "PARAMETERS:",
2018
+ " what \u2014 one-line title (e.g. 'MobilePaymentController: duplicate @RequestBody')",
2019
+ " where \u2014 file path(s) where the issue lives",
2020
+ " impact \u2014 what breaks or could break because of this",
2021
+ " fix \u2014 suggested fix (optional)",
2022
+ " scope \u2014 team (default, since discoveries benefit everyone)",
2023
+ "",
2024
+ "RETURNS: { id, file_path }"
2025
+ ].join("\n"),
2026
+ MemObserveInputSchema,
2027
+ async (input) => {
2028
+ tracker.record("mem_observe", input.where);
2029
+ return jsonResult(await memObserve(input, context));
2030
+ }
1961
2031
  );
1962
2032
  server.tool(
1963
- "get_project_context",
1964
- "Read the shared .ai/project-context.md (and optionally a module context).",
1965
- GetProjectContextInputSchema,
1966
- async (input) => jsonResult(await getProjectContext(input, context))
2033
+ "mem_session_end",
2034
+ [
2035
+ "Save an end-of-session recap so the NEXT session starts with fresh context.",
2036
+ "",
2037
+ "CALL THIS before closing any significant working session. In autopilot mode,",
2038
+ "the MCP server saves a minimal recap automatically on exit \u2014 but calling this",
2039
+ "manually produces a richer, more useful recap.",
2040
+ "",
2041
+ "HOW IT WORKS: uses topic-upsert \u2014 one recap per scope is kept and updated",
2042
+ "in-place (revision_count increments). get_briefing surfaces the latest recap",
2043
+ "at the very top of the next session's briefing, before project context.",
2044
+ "",
2045
+ "PARAMETERS:",
2046
+ " goal \u2014 what you were trying to accomplish (1\u20132 sentences)",
2047
+ " accomplished \u2014 what was actually done (bullet list recommended)",
2048
+ " discoveries \u2014 bugs, surprises, missing knowledge found during this session",
2049
+ " files_touched \u2014 key files read or modified (used as anchor for staleness)",
2050
+ " next_steps \u2014 what should happen in the next session or for a teammate",
2051
+ " scope \u2014 personal (default) | team",
2052
+ "",
2053
+ "RETURNS: { id, scope, action: 'created'|'updated', revision_count }"
2054
+ ].join("\n"),
2055
+ MemSessionEndInputSchema,
2056
+ async (input) => {
2057
+ tracker.record("mem_session_end", input.goal.slice(0, 80));
2058
+ return jsonResult(await memSessionEnd(input, context));
2059
+ }
1967
2060
  );
1968
2061
  server.tool(
1969
2062
  "get_briefing",
1970
- "One-shot onboarding: returns project context + module contexts + ranked relevant memories under a token budget. Replaces 4\u20135 separate calls when an agent starts a task.",
2063
+ [
2064
+ "\u2B50 CALL THIS FIRST at the start of every task. One-shot onboarding that returns",
2065
+ "everything relevant in a single call under a token budget.",
2066
+ "",
2067
+ "RETURNS (in order of priority):",
2068
+ " 1. last_session \u2014 recap of the previous session (goal, what was done, next steps)",
2069
+ " 2. project_context \u2014 .ai/project-context.md (auto-generated from code-map if template)",
2070
+ " 3. module_contexts \u2014 relevant .ai/modules/<name>/context.md based on files being edited",
2071
+ " 4. memories \u2014 ranked team memories relevant to your task",
2072
+ " 5. symbol_locations \u2014 file:line:kind for any requested symbols (no grep needed)",
2073
+ " 6. setup_warnings \u2014 actionable warnings if setup is incomplete",
2074
+ " 7. decay_warnings \u2014 memories not read in >90 days (consider reviewing)",
2075
+ "",
2076
+ "KEY PARAMETERS:",
2077
+ " task \u2014 what you are about to do (1\u20132 sentences) \u2014 ALWAYS provide this",
2078
+ " files \u2014 files you are about to edit \u2014 surfaces anchored memories",
2079
+ " symbols \u2014 symbol names to look up in the code-map (e.g. ['PaymentService'])",
2080
+ " format \u2014 'full' (default) | 'compact' (1-line summaries, use when token budget is tight)",
2081
+ "",
2082
+ "EXAMPLE USAGE:",
2083
+ " get_briefing({ task: 'add a Stripe payment integration', files: ['src/payments/'], symbols: ['PaymentService'] })",
2084
+ "",
2085
+ "CONFIDENCE LEVELS in memories:",
2086
+ " authoritative \u2014 validated + read 10+ times (highest trust)",
2087
+ " trusted \u2014 validated or proposed + read 3+ times",
2088
+ " low \u2014 proposed, few reads (take with caution)",
2089
+ " unverified \u2014 draft (unverified: true flag set)",
2090
+ "",
2091
+ "Replaces 4\u20135 separate tool calls. Always call this before any other tool."
2092
+ ].join("\n"),
1971
2093
  GetBriefingInputSchema,
1972
2094
  async (input) => {
1973
2095
  tracker.record("get_briefing", input.task ?? "");
@@ -1975,113 +2097,305 @@ function createHaiveServer(options = {}) {
1975
2097
  }
1976
2098
  );
1977
2099
  server.tool(
1978
- "code_map",
1979
- "Browse the project's pre-computed code map (file \u2192 exports + 1-line description) instead of grepping. Requires `haive index code`.",
1980
- CodeMapInputSchema,
1981
- async (input) => jsonResult(await codeMapTool(input, context))
1982
- );
1983
- server.tool(
1984
- "bootstrap_project_save",
1985
- "Persist a project (or module) context document analyzed by the AI client.",
1986
- BootstrapProjectSaveInputSchema,
1987
- async (input) => jsonResult(await bootstrapProjectSave(input, context))
1988
- );
1989
- server.tool(
1990
- "mem_verify",
1991
- "Check anchor freshness for one or every memory; optionally write status updates back to disk.",
1992
- MemVerifyInputSchema,
1993
- async (input) => jsonResult(await memVerify(input, context))
1994
- );
1995
- server.tool(
1996
- "mem_reject",
1997
- "Record a rejection for a memory (blocks auto-promotion and lowers its trust signal).",
1998
- MemRejectInputSchema,
1999
- async (input) => jsonResult(await memReject(input, context))
2100
+ "mem_search",
2101
+ [
2102
+ "Search memories by keyword or semantic similarity.",
2103
+ "",
2104
+ "USE WHEN you need to find a specific memory and don't know its id.",
2105
+ "For session onboarding, use get_briefing instead (richer, ranked, budgeted).",
2106
+ "",
2107
+ "SEARCH MODES:",
2108
+ " Literal (default): AND search across id, tags, and body \u2014 all tokens must match.",
2109
+ " Falls back to OR automatically if no AND results (partial match).",
2110
+ " Semantic (semantic: true): embedding-based similarity \u2014 finds related memories",
2111
+ " even with different wording. Requires haive embeddings index to be built.",
2112
+ "",
2113
+ "PARAMETERS:",
2114
+ " query \u2014 search terms or natural language question",
2115
+ " scope \u2014 filter by personal | team | module",
2116
+ " type \u2014 filter by convention | decision | gotcha | architecture | glossary",
2117
+ " semantic \u2014 true for embedding-based search (requires @hiveai/embeddings)",
2118
+ " limit \u2014 max results (default 10)",
2119
+ "",
2120
+ "RETURNS: array of { id, type, scope, status, confidence, body, match_quality }"
2121
+ ].join("\n"),
2122
+ MemSearchInputSchema,
2123
+ async (input) => jsonResult(await memSearch(input, context))
2000
2124
  );
2001
2125
  server.tool(
2002
2126
  "mem_for_files",
2003
- "Given the file paths the agent is currently working on, return relevant memories grouped by reason (anchor overlap, module, domain) plus any matching .ai/modules/<name>/context.md contents.",
2127
+ [
2128
+ "Surface memories relevant to the files you are currently editing.",
2129
+ "",
2130
+ "USE WHEN starting work on specific files and you want to know:",
2131
+ " - What conventions apply to these files",
2132
+ " - What gotchas are anchored to these paths",
2133
+ " - What decisions were made about this module",
2134
+ "",
2135
+ "Matching strategy (in priority order):",
2136
+ " 1. Anchor overlap \u2014 memories whose paths overlap with your files",
2137
+ " 2. Module context \u2014 .ai/modules/<name>/context.md if module is inferred",
2138
+ " 3. Domain/tag match \u2014 memories whose tags include path segments",
2139
+ "",
2140
+ "PARAMETERS:",
2141
+ " files \u2014 list of project-relative file paths you are editing",
2142
+ " scope \u2014 filter by scope (default: all)",
2143
+ "",
2144
+ "RETURNS: { memories: [...], module_contexts: [...] }"
2145
+ ].join("\n"),
2004
2146
  MemForFilesInputSchema,
2005
2147
  async (input) => jsonResult(await memForFiles(input, context))
2006
2148
  );
2007
2149
  server.tool(
2008
2150
  "mem_get",
2009
- "Fetch a single memory by id, including its body, anchor, usage, and confidence.",
2151
+ [
2152
+ "Fetch a single memory by its full id with all details.",
2153
+ "",
2154
+ "USE WHEN get_briefing returned a memory in 'compact' format and you need",
2155
+ "the full body, or when you know the exact id of a memory.",
2156
+ "",
2157
+ "PARAMETERS:",
2158
+ " id \u2014 full memory id (e.g. '2026-04-28-gotcha-flyway-strict-no-ddl')",
2159
+ "",
2160
+ "RETURNS: { id, type, scope, status, confidence, body, anchor, tags, usage }"
2161
+ ].join("\n"),
2010
2162
  MemGetInputSchema,
2011
2163
  async (input) => jsonResult(await memGet(input, context))
2012
2164
  );
2013
2165
  server.tool(
2014
- "mem_delete",
2015
- "Delete a memory by id (and its usage entry by default).",
2016
- MemDeleteInputSchema,
2017
- async (input) => jsonResult(await memDelete(input, context))
2166
+ "mem_list",
2167
+ [
2168
+ "List memories with optional filters. Use for browsing, not for task onboarding.",
2169
+ "",
2170
+ "For task onboarding use get_briefing (ranked + budgeted).",
2171
+ "For keyword search use mem_search.",
2172
+ "",
2173
+ "PARAMETERS:",
2174
+ " scope \u2014 personal | team | module",
2175
+ " type \u2014 convention | decision | gotcha | architecture | glossary",
2176
+ " status \u2014 draft | proposed | validated | stale | rejected",
2177
+ " tags \u2014 filter by tags (AND match)",
2178
+ " module \u2014 filter by module name",
2179
+ "",
2180
+ "RETURNS: array of { id, type, scope, status, confidence, tags, created_at }"
2181
+ ].join("\n"),
2182
+ MemListInputSchema,
2183
+ async (input) => jsonResult(await memList(input, context))
2184
+ );
2185
+ server.tool(
2186
+ "get_project_context",
2187
+ [
2188
+ "Read .ai/project-context.md (and optionally a module context) directly.",
2189
+ "",
2190
+ "USE WHEN you need the full project context without the memory ranking and",
2191
+ "token budgeting of get_briefing \u2014 e.g. for a reference architecture review.",
2192
+ "",
2193
+ "For normal task onboarding, use get_briefing instead (more efficient).",
2194
+ "",
2195
+ "PARAMETERS:",
2196
+ " module \u2014 also load .ai/modules/<module>/context.md if provided",
2197
+ "",
2198
+ "RETURNS: { content: string, module_context?: string }"
2199
+ ].join("\n"),
2200
+ GetProjectContextInputSchema,
2201
+ async (input) => jsonResult(await getProjectContext(input, context))
2202
+ );
2203
+ server.tool(
2204
+ "bootstrap_project_save",
2205
+ [
2206
+ "Persist the project context document (.ai/project-context.md) or a module",
2207
+ "context (.ai/modules/<name>/context.md) analyzed by the AI.",
2208
+ "",
2209
+ "USE AFTER the bootstrap_project MCP prompt: the prompt tells you how to",
2210
+ "analyze the codebase; this tool saves the result.",
2211
+ "",
2212
+ "PARAMETERS:",
2213
+ " content \u2014 full Markdown content of the context document",
2214
+ " module \u2014 if provided, saves as a module context (not root project context)",
2215
+ "",
2216
+ "RETURNS: { file_path, module? }"
2217
+ ].join("\n"),
2218
+ BootstrapProjectSaveInputSchema,
2219
+ async (input) => jsonResult(await bootstrapProjectSave(input, context))
2220
+ );
2221
+ server.tool(
2222
+ "code_map",
2223
+ [
2224
+ "Look up where symbols (classes, functions, interfaces) are defined in the codebase.",
2225
+ "",
2226
+ "USE INSTEAD OF grepping when you need to find where something lives.",
2227
+ "Requires haive index code to have been run (done automatically in autopilot mode).",
2228
+ "",
2229
+ "TIP: include symbols in get_briefing directly for auto-lookup at session start.",
2230
+ "",
2231
+ "PARAMETERS:",
2232
+ " symbol \u2014 name or partial name to search (e.g. 'PaymentService')",
2233
+ " file \u2014 filter by file path substring",
2234
+ " max_files \u2014 cap on results (default 40)",
2235
+ "",
2236
+ "RETURNS: { available: bool, files: [{ path, exports: [{ name, kind, line, description }] }] }",
2237
+ "If available: false \u2192 run haive index code first."
2238
+ ].join("\n"),
2239
+ CodeMapInputSchema,
2240
+ async (input) => jsonResult(await codeMapTool(input, context))
2018
2241
  );
2019
2242
  server.tool(
2020
2243
  "mem_update",
2021
- "Update the body, tags, or anchor of an existing memory without changing its id or losing usage history.",
2244
+ [
2245
+ "Update the body, tags, or anchor of an existing memory in-place.",
2246
+ "",
2247
+ "USE WHEN a memory exists but its content has become outdated or incomplete.",
2248
+ "This preserves the memory's id, usage history, and read_count.",
2249
+ "",
2250
+ "For evolving memories that you will update repeatedly, use mem_save with a",
2251
+ "topic key instead (topic-upsert pattern).",
2252
+ "",
2253
+ "PARAMETERS:",
2254
+ " id \u2014 full memory id to update",
2255
+ " body \u2014 new Markdown content (replaces existing body)",
2256
+ " tags \u2014 new tag list (replaces existing tags)",
2257
+ " paths \u2014 new anchor paths (replaces existing paths)",
2258
+ " symbols \u2014 new anchor symbols (replaces existing symbols)",
2259
+ "",
2260
+ "RETURNS: { id, file_path, updated_fields: string[] }"
2261
+ ].join("\n"),
2022
2262
  MemUpdateInputSchema,
2023
2263
  async (input) => jsonResult(await memUpdate(input, context))
2024
2264
  );
2025
2265
  server.tool(
2026
- "mem_pending",
2027
- "List 'proposed' memories awaiting review, sorted by reads (most-read first).",
2028
- MemPendingInputSchema,
2029
- async (input) => jsonResult(await memPending(input, context))
2266
+ "mem_verify",
2267
+ [
2268
+ "Check whether memory anchor paths and symbols still exist in the current code.",
2269
+ "",
2270
+ "USE WHEN you want to know if a specific memory is still valid after a refactor,",
2271
+ "or to check all memories for staleness (haive sync does this automatically).",
2272
+ "",
2273
+ "PARAMETERS:",
2274
+ " id \u2014 check a single memory (omit to check all)",
2275
+ " update \u2014 write 'stale' or 'validated' status back to disk",
2276
+ "",
2277
+ "RETURNS: { results: [{ id, status: 'fresh'|'stale'|'anchorless', reason? }] }",
2278
+ "Stale means the anchored file/symbol no longer exists at that path.",
2279
+ "Anchorless means the memory has no paths/symbols \u2014 staleness is undetectable."
2280
+ ].join("\n"),
2281
+ MemVerifyInputSchema,
2282
+ async (input) => jsonResult(await memVerify(input, context))
2030
2283
  );
2031
2284
  server.tool(
2032
2285
  "mem_approve",
2033
- "Mark a memory as validated immediately (explicit team review).",
2286
+ [
2287
+ "Mark a memory as validated (trusted, approved by a human or the team).",
2288
+ "",
2289
+ "In autopilot mode, memories are validated automatically \u2014 you rarely need this.",
2290
+ "In manual mode, call this after reviewing a proposed memory to activate it.",
2291
+ "",
2292
+ "PARAMETERS:",
2293
+ " id \u2014 full memory id to approve",
2294
+ "",
2295
+ "RETURNS: { id, previous_status, new_status: 'validated' }"
2296
+ ].join("\n"),
2034
2297
  MemApproveInputSchema,
2035
2298
  async (input) => jsonResult(await memApprove(input, context))
2036
2299
  );
2037
2300
  server.tool(
2038
- "mem_tried",
2039
- "Preferred way to record a failed approach. Enforces a structured what/why_failed/instead format that is immediately actionable for future agents. Auto-validated (no approval cycle). Use whenever you tried an approach and it failed \u2014 prevents the same mistake from happening in the next session.",
2040
- MemTriedInputSchema,
2041
- async (input) => {
2042
- tracker.record("mem_tried", input.what.slice(0, 80));
2043
- return jsonResult(await memTried(input, context));
2044
- }
2301
+ "mem_reject",
2302
+ [
2303
+ "Mark a memory as rejected and record a reason.",
2304
+ "",
2305
+ "USE WHEN a memory is factually wrong, outdated, or not useful.",
2306
+ "Rejection blocks auto-promotion and lowers the memory's trust signal.",
2307
+ "Rejected memories are excluded from get_briefing by default.",
2308
+ "",
2309
+ "PARAMETERS:",
2310
+ " id \u2014 full memory id to reject",
2311
+ " reason \u2014 why this memory is being rejected (stored in frontmatter)",
2312
+ "",
2313
+ "RETURNS: { id, previous_status, new_status: 'rejected' }"
2314
+ ].join("\n"),
2315
+ MemRejectInputSchema,
2316
+ async (input) => jsonResult(await memReject(input, context))
2045
2317
  );
2046
2318
  server.tool(
2047
- "mem_diff",
2048
- "Compare two memories side-by-side: shows frontmatter fields that differ and lines unique to each body. Useful before merging or deduplicating memories.",
2049
- MemDiffInputSchema,
2050
- async (input) => jsonResult(await memDiff(input, context))
2319
+ "mem_pending",
2320
+ [
2321
+ "List memories in 'proposed' status awaiting review, sorted by read count.",
2322
+ "",
2323
+ "USE IN MANUAL MODE to see what memories are waiting for human review.",
2324
+ "In autopilot mode, proposed memories auto-approve after 72h.",
2325
+ "",
2326
+ "High read_count on a proposed memory = many agents found it useful without",
2327
+ "rejecting it = strong signal to approve.",
2328
+ "",
2329
+ "RETURNS: array of { id, type, scope, read_count, created_at, body_preview }"
2330
+ ].join("\n"),
2331
+ MemPendingInputSchema,
2332
+ async (input) => jsonResult(await memPending(input, context))
2051
2333
  );
2052
2334
  server.tool(
2053
- "mem_observe",
2054
- "Capture a code-level discovery made during exploration: a bug, inconsistency, missing config, or security gap found by reading existing code that was NOT in the briefing. Use this whenever you read code and spot something that could silently break in production. Auto-validated, anchored to file paths for staleness detection. Prefer this over mem_save for reactive discoveries during code reading.",
2055
- MemObserveInputSchema,
2056
- async (input) => {
2057
- tracker.record("mem_observe", input.where);
2058
- return jsonResult(await memObserve(input, context));
2059
- }
2335
+ "mem_delete",
2336
+ [
2337
+ "Permanently delete a memory by id.",
2338
+ "",
2339
+ "USE WITH CAUTION \u2014 prefer mem_reject for outdated memories (preserves history).",
2340
+ "Use delete only for accidentally created memories or duplicates.",
2341
+ "",
2342
+ "PARAMETERS:",
2343
+ " id \u2014 full memory id to delete",
2344
+ " delete_usage \u2014 also delete usage stats (default: true)",
2345
+ "",
2346
+ "RETURNS: { deleted: true, id }"
2347
+ ].join("\n"),
2348
+ MemDeleteInputSchema,
2349
+ async (input) => jsonResult(await memDelete(input, context))
2060
2350
  );
2061
2351
  server.tool(
2062
- "mem_session_end",
2063
- "Save a structured end-of-session recap (goal / accomplished / discoveries / next steps). Uses topic-upsert: one recap per scope is kept and updated in-place so the next session always has fresh context. Call this before closing every significant session. get_briefing automatically surfaces the latest recap at the top of the next session's briefing.",
2064
- MemSessionEndInputSchema,
2065
- async (input) => {
2066
- tracker.record("mem_session_end", input.goal.slice(0, 80));
2067
- return jsonResult(await memSessionEnd(input, context));
2068
- }
2352
+ "mem_diff",
2353
+ [
2354
+ "Compare two memories side-by-side to decide if they should be merged.",
2355
+ "",
2356
+ "USE BEFORE merging or deduplicating similar memories.",
2357
+ "Shows: frontmatter fields that differ + lines unique to each body.",
2358
+ "",
2359
+ "PARAMETERS:",
2360
+ " id_a \u2014 first memory id",
2361
+ " id_b \u2014 second memory id",
2362
+ "",
2363
+ "RETURNS: { frontmatter_diff: {...}, body_only_in_a: [...], body_only_in_b: [...] }"
2364
+ ].join("\n"),
2365
+ MemDiffInputSchema,
2366
+ async (input) => jsonResult(await memDiff(input, context))
2069
2367
  );
2070
2368
  server.prompt(
2071
2369
  "bootstrap_project",
2072
- "Instructions for the AI client to analyze the project and save the context.",
2370
+ [
2371
+ "Analyze the project codebase and write .ai/project-context.md \u2014 run once after haive init.",
2372
+ "The AI explores the directory structure, reads key files (package.json, README, config),",
2373
+ "identifies the tech stack, architectural patterns, key modules, and conventions,",
2374
+ "then persists everything via bootstrap_project_save.",
2375
+ "For multi-component projects, run with module param to create .ai/modules/<name>/context.md."
2376
+ ].join(" "),
2073
2377
  BootstrapProjectArgsSchema,
2074
2378
  (args) => bootstrapProjectPrompt(args, context)
2075
2379
  );
2076
2380
  server.prompt(
2077
2381
  "post_task",
2078
- "Post-task checklist: run this after completing a task to capture failed approaches, new conventions, decisions, and gotchas before closing the session.",
2382
+ [
2383
+ "\u2B50 Post-task reflection \u2014 run at the end of every session to capture what you learned:",
2384
+ "failed approaches (mem_tried), new conventions/decisions/gotchas (mem_save),",
2385
+ "code discoveries (mem_observe), and an end-of-session recap (mem_session_end).",
2386
+ "In autopilot mode a minimal recap saves automatically; calling this produces a richer one."
2387
+ ].join(" "),
2079
2388
  PostTaskArgsSchema,
2080
2389
  (args) => postTaskPrompt(args, context)
2081
2390
  );
2082
2391
  server.prompt(
2083
2392
  "import_docs",
2084
- "Analyze documentation (README, ADR, wiki page, etc.) and save the actionable knowledge as hAIve memories. Pass the content and an optional source/scope.",
2393
+ [
2394
+ "Import knowledge from a document (README, ADR, wiki, API spec) as hAIve memories.",
2395
+ "Pass the full document content; the AI extracts up to 10 actionable memories",
2396
+ "(conventions, decisions, gotchas, architecture) and saves them via mem_save.",
2397
+ "Good candidates: ADRs, onboarding docs, runbooks, team wikis."
2398
+ ].join(" "),
2085
2399
  ImportDocsArgsSchema,
2086
2400
  (args) => importDocsPrompt(args, context)
2087
2401
  );