@radix-ai/ai-memory 0.1.0 → 0.1.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.
Files changed (76) hide show
  1. package/README.md +17 -3
  2. package/dist/cli/adapters.d.ts.map +1 -1
  3. package/dist/cli/adapters.js +52 -9
  4. package/dist/cli/adapters.js.map +1 -1
  5. package/dist/cli/index.js +88 -27
  6. package/dist/cli/index.js.map +1 -1
  7. package/dist/evals/index.d.ts +2 -6
  8. package/dist/evals/index.d.ts.map +1 -1
  9. package/dist/evals/index.js +1 -1
  10. package/dist/evals/index.js.map +1 -1
  11. package/dist/evals/performance-comparison.d.ts +4 -10
  12. package/dist/evals/performance-comparison.d.ts.map +1 -1
  13. package/dist/evals/performance-comparison.js.map +1 -1
  14. package/dist/evals/platform-integration.d.ts +6 -12
  15. package/dist/evals/platform-integration.d.ts.map +1 -1
  16. package/dist/evals/platform-integration.js.map +1 -1
  17. package/dist/evals/types.d.ts +8 -0
  18. package/dist/evals/types.d.ts.map +1 -0
  19. package/dist/evals/types.js +2 -0
  20. package/dist/evals/types.js.map +1 -0
  21. package/dist/governance/p0-parser.d.ts +43 -0
  22. package/dist/governance/p0-parser.d.ts.map +1 -0
  23. package/dist/governance/p0-parser.js +108 -0
  24. package/dist/governance/p0-parser.js.map +1 -0
  25. package/dist/hybrid-search/index.js +2 -2
  26. package/dist/hybrid-search/index.js.map +1 -1
  27. package/dist/index.d.ts +1 -1
  28. package/dist/index.js +1 -1
  29. package/dist/mcp-server/index.d.ts.map +1 -1
  30. package/dist/mcp-server/index.js +7 -2
  31. package/dist/mcp-server/index.js.map +1 -1
  32. package/dist/mcp-server/resources.d.ts.map +1 -1
  33. package/dist/mcp-server/resources.js +5 -16
  34. package/dist/mcp-server/resources.js.map +1 -1
  35. package/dist/mcp-server/tools/collaboration.d.ts +5 -0
  36. package/dist/mcp-server/tools/collaboration.d.ts.map +1 -0
  37. package/dist/mcp-server/tools/collaboration.js +130 -0
  38. package/dist/mcp-server/tools/collaboration.js.map +1 -0
  39. package/dist/mcp-server/tools/docs.d.ts +5 -0
  40. package/dist/mcp-server/tools/docs.d.ts.map +1 -0
  41. package/dist/mcp-server/tools/docs.js +63 -0
  42. package/dist/mcp-server/tools/docs.js.map +1 -0
  43. package/dist/mcp-server/tools/governance.d.ts +17 -0
  44. package/dist/mcp-server/tools/governance.d.ts.map +1 -0
  45. package/dist/mcp-server/tools/governance.js +215 -0
  46. package/dist/mcp-server/tools/governance.js.map +1 -0
  47. package/dist/mcp-server/tools/index.d.ts +4 -0
  48. package/dist/mcp-server/tools/index.d.ts.map +1 -0
  49. package/dist/mcp-server/tools/index.js +233 -0
  50. package/dist/mcp-server/tools/index.js.map +1 -0
  51. package/dist/mcp-server/tools/memory.d.ts +8 -0
  52. package/dist/mcp-server/tools/memory.d.ts.map +1 -0
  53. package/dist/mcp-server/tools/memory.js +153 -0
  54. package/dist/mcp-server/tools/memory.js.map +1 -0
  55. package/dist/mcp-server/tools/shared.d.ts +19 -0
  56. package/dist/mcp-server/tools/shared.d.ts.map +1 -0
  57. package/dist/mcp-server/tools/shared.js +112 -0
  58. package/dist/mcp-server/tools/shared.js.map +1 -0
  59. package/dist/mcp-server/tools.d.ts.map +1 -1
  60. package/dist/mcp-server/tools.js +33 -17
  61. package/dist/mcp-server/tools.js.map +1 -1
  62. package/dist/schema-constants.d.ts +1 -1
  63. package/dist/schema-constants.d.ts.map +1 -1
  64. package/dist/schema-constants.js +1 -1
  65. package/dist/schema-constants.js.map +1 -1
  66. package/dist/utils/fs.d.ts +5 -0
  67. package/dist/utils/fs.d.ts.map +1 -0
  68. package/dist/utils/fs.js +22 -0
  69. package/dist/utils/fs.js.map +1 -0
  70. package/package.json +2 -2
  71. package/plugins/adapters/generic/BOOTSTRAP_INSTRUCTION.md +1 -0
  72. package/plugins/ai-memory/rules/parallel-safe-planning.md +2 -2
  73. package/plugins/ai-memory/skills/mem-compound/SKILL.md +1 -1
  74. package/plugins/ai-memory/skills/mem-init/SKILL.md +181 -30
  75. package/templates/.ai/IDENTITY.md +55 -2
  76. package/templates/.ai/reference/PROJECT.md +40 -3
@@ -0,0 +1,233 @@
1
+ import { resolve } from "path";
2
+ import { ListToolsRequestSchema, CallToolRequestSchema, ErrorCode, McpError, } from "@modelcontextprotocol/sdk/types.js";
3
+ import { getRepoRoot, textResponse } from "./shared.js";
4
+ import { handleSearchMemory, handleGetMemory, handleCommitMemory, handlePruneMemory, handleGetOpenItems, handleGetEvals } from "./memory.js";
5
+ import { handleValidateContext, handleValidateSchema, handleGenerateHarness } from "./governance.js";
6
+ import { handleClaimTask, handlePublishResult, handleSyncMemory } from "./collaboration.js";
7
+ import { handleGetDocPath, handleValidateDocPlacement, handleListDocTypes } from "./docs.js";
8
+ export function registerTools(server, aiDir) {
9
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({
10
+ tools: [
11
+ {
12
+ name: "search_memory",
13
+ description: "Searches across .ai/ memory files (memory/, sessions/, agents/, skills/) and returns ranked results with excerpts. " +
14
+ "Uses hybrid search (keyword + semantic + RRF) by default. AI_SEARCH=keyword|semantic|hybrid. " +
15
+ "On Windows, onnxruntime-node may fail; set AI_SEARCH=keyword for keyword-only, or AI_SEARCH_WASM=1 to try WASM. " +
16
+ "Semantic/hybrid requires Linux or macOS for native; Windows uses keyword-only or WASM. " +
17
+ "Each result includes: file path (relative to .ai/), excerpt, and score. " +
18
+ "For best results: use specific terms from the task (e.g. 'MCP launcher Windows', 'claim locking'); optionally filter by tags if the query mentions them.",
19
+ inputSchema: {
20
+ type: "object",
21
+ properties: {
22
+ query: { type: "string", description: "Search query — use specific terms relevant to the task" },
23
+ tags: { type: "array", items: { type: "string" }, description: "Filter by tags (optional). Only files containing all tags are returned." },
24
+ limit: { type: "number", description: "Max results to return (default 10, max 20). Use lower values for focused queries." },
25
+ include_deprecated: { type: "boolean", description: "Include [DEPRECATED] entries in results (default false). Set true for auditing or history review." },
26
+ },
27
+ required: ["query"],
28
+ },
29
+ },
30
+ {
31
+ name: "get_repo_root",
32
+ description: "Returns the git repository root (absolute path) via `git rev-parse --show-toplevel`. " +
33
+ "Use to resolve paths for validate_context, path traversal checks, or when the agent runs from a subdirectory. " +
34
+ "Returns null if not in a git repo.",
35
+ inputSchema: { type: "object", properties: {} },
36
+ },
37
+ {
38
+ name: "validate_context",
39
+ description: "Validates a git diff against active [P0] constraint rules. Returns violations as errors — hard blocks if any P0 rule is triggered. " +
40
+ "You MUST run generate_harness first (or use init --full) to create .ai/temp/harness.json. " +
41
+ "Each violation includes: rule_id, message, severity (P0/P1/P2). P0 violations cause a hard block; P1/P2 return warnings. " +
42
+ "For best results: pass the full output of `git diff` (staged or unstaged) before committing.",
43
+ inputSchema: {
44
+ type: "object",
45
+ properties: {
46
+ git_diff: { type: "string", description: "Output of git diff (e.g. git diff or git diff --cached)" },
47
+ },
48
+ required: ["git_diff"],
49
+ },
50
+ },
51
+ {
52
+ name: "validate_schema",
53
+ description: "Validates a proposed memory entry's frontmatter against the canonical schema. Returns validation errors. " +
54
+ "Required fields: id, type, status. Valid types: identity, project-status, decision, pattern, debugging, improvement, index, session, reference, agent, skill, rule, acp, toolbox, docs-schema. Valid statuses: active, deprecated, experimental. " +
55
+ "Use before commit_memory when constructing entries programmatically to catch schema errors early.",
56
+ inputSchema: {
57
+ type: "object",
58
+ properties: {
59
+ entry: { type: "object", description: "Memory entry frontmatter fields to validate (id, type, status, etc.)" },
60
+ },
61
+ required: ["entry"],
62
+ },
63
+ },
64
+ {
65
+ name: "commit_memory",
66
+ description: "Writes a memory entry to .ai/. Enforces immutability: IDENTITY.md is immutable by default; PROJECT_STATUS.md is writable by default (configurable via frontmatter `writable`). Hard-blocks writes to toolbox/, acp/, rules/. Uses claim-based locking for multi-agent safety — if another session holds a claim on the path, wait for the 5-minute TTL or close the other session. " +
67
+ "Each write appends a session header for traceability. Use append: false to overwrite (creates new file or replaces). " +
68
+ "For best results: use validate_schema first when constructing entries; pass session_id when coordinating with claim_task or publish_result. When work is done: break down into atomic tasks that fit RALPH loops and avoid conflicts when agents work in parallel.",
69
+ inputSchema: {
70
+ type: "object",
71
+ properties: {
72
+ path: { type: "string", description: "Relative path within .ai/ (e.g. memory/decisions.md, memory/patterns.md)" },
73
+ content: { type: "string", description: "Content to append or write (include frontmatter for memory entries)" },
74
+ append: { type: "boolean", description: "Append to existing file (true) or overwrite (false). Default: true." },
75
+ session_id: { type: "string", description: "Optional session identifier for multi-agent tracking. Auto-generated if not provided." },
76
+ },
77
+ required: ["path", "content"],
78
+ },
79
+ },
80
+ {
81
+ name: "generate_harness",
82
+ description: "Compiles harness.json from current [P0] entries in memory/decisions.md. Writes .ai/temp/harness.json and rule tests to .ai/temp/rule-tests/tests.json. " +
83
+ "Required before validate_context. Run after adding or changing [P0] entries to refresh the rule set.",
84
+ inputSchema: { type: "object", properties: {} },
85
+ },
86
+ {
87
+ name: "get_open_items",
88
+ description: "Returns the current open and closed items from sessions/open-items.md. " +
89
+ "Use at session start to see pending tasks, or before claim_task to avoid duplicate work.",
90
+ inputSchema: { type: "object", properties: {} },
91
+ },
92
+ {
93
+ name: "get_memory",
94
+ description: "Returns a summary of memory for a specific topic. Searches .ai/ and returns top 5 matches with file path and excerpt. " +
95
+ "Use for quick lookups when you need a focused answer (e.g. 'authentication', 'MCP config'). " +
96
+ "For broader exploration, use search_memory instead.",
97
+ inputSchema: {
98
+ type: "object",
99
+ properties: {
100
+ topic: { type: "string", description: "Topic to summarize (e.g. 'authentication', 'database patterns', 'project status')" },
101
+ },
102
+ required: ["topic"],
103
+ },
104
+ },
105
+ {
106
+ name: "prune_memory",
107
+ description: "Identifies stale or deprecated memory entries for archiving. Scans memory/*.md for [DEPRECATED] entries. " +
108
+ "Returns a list of candidates with file and entry count. Use dry_run: true (default) to report without modifying; dry_run: false to flag for manual archiving. " +
109
+ "For best results: run periodically to keep memory lean; review candidates before archiving.",
110
+ inputSchema: {
111
+ type: "object",
112
+ properties: {
113
+ dry_run: { type: "boolean", description: "If true, report candidates without modifying files. Default: true." },
114
+ },
115
+ },
116
+ },
117
+ {
118
+ name: "get_evals",
119
+ description: "Returns the latest eval report from .ai/temp/eval-report.json. " +
120
+ "Use to check memory health and governance metrics. Run `ai-memory eval` to generate the report.",
121
+ inputSchema: { type: "object", properties: {} },
122
+ },
123
+ // ─── Autoresearch collaboration tools ────────────────────────────────
124
+ {
125
+ name: "claim_task",
126
+ description: "Claims a task before starting work. Searches the task source file (open-items.md by default, or PROJECT_STATUS.md) for a matching unclaimed item and marks it [CLAIMED:session_id]. Prevents duplicate work across concurrent agents. Claims expire after 5 minutes. " +
127
+ "If no match is found, creates a new claimed task in open-items.md. " +
128
+ "For best results: use task_description that matches the wording in the source (e.g. 'Add Context7 MCP'); specify source when the task lives in PROJECT_STATUS.md.",
129
+ inputSchema: {
130
+ type: "object",
131
+ properties: {
132
+ task_description: { type: "string", description: "Description of the task to claim (match wording in source for best match)" },
133
+ source: { type: "string", description: "Relative path to task source within .ai/ (default: sessions/open-items.md). Can be PROJECT_STATUS.md or another task list file." },
134
+ session_id: { type: "string", description: "Session identifier. Auto-generated if not provided. Use same ID for publish_result to link result to claim." },
135
+ },
136
+ required: ["task_description"],
137
+ },
138
+ },
139
+ {
140
+ name: "publish_result",
141
+ description: "Publishes an experiment or task result (success, failure, or partial) to sessions/archive/thread-archive.md. Every result is recorded for collective learning. " +
142
+ "If the task was claimed via claim_task with the same session_id, marks the task complete (success) or reopened (failure) in open-items.md. " +
143
+ "Each entry includes: date, outcome icon, summary, learnings (optional), session_id. " +
144
+ "For best results: include learnings (patterns, anti-patterns, decisions) to enrich the archive.",
145
+ inputSchema: {
146
+ type: "object",
147
+ properties: {
148
+ summary: { type: "string", description: "What was attempted and what happened" },
149
+ outcome: { type: "string", enum: ["success", "failure", "partial"], description: "Outcome: success, failure, or partial" },
150
+ learnings: { type: "string", description: "What was learned (patterns, anti-patterns, decisions). Optional but recommended." },
151
+ session_id: { type: "string", description: "Session identifier. Auto-generated if not provided. Use same ID as claim_task to link." },
152
+ },
153
+ required: ["summary", "outcome"],
154
+ },
155
+ },
156
+ {
157
+ name: "sync_memory",
158
+ description: "Persists all .ai/ changes to git. Stages .ai/, commits with a message, and optionally pushes. Essential for ephemeral environments (worktrees, cloud agents, sandbox). " +
159
+ "Requires a git repository. Returns the commit message and list of files committed. " +
160
+ "For best results: run after commit_memory or other .ai/ writes; use push: true when in a cloud agent or worktree to persist to remote.",
161
+ inputSchema: {
162
+ type: "object",
163
+ properties: {
164
+ message: { type: "string", description: "Commit message. Auto-generated if not provided." },
165
+ push: { type: "boolean", description: "Push to remote after commit. Default: false." },
166
+ },
167
+ },
168
+ },
169
+ // ─── Documentation management ───────────────────────────────────────────
170
+ {
171
+ name: "get_doc_path",
172
+ description: "Returns the canonical path for a documentation type from .ai/docs-schema.json. Use before creating or updating docs — do not infer paths. " +
173
+ "Types: design-system, adr, api-spec, api-guide, model-card, prompts, backlog, decisions-archive, changelog. " +
174
+ "Returns null if schema missing or type unknown. Pass slug for types with * in pattern (e.g. design-system slug=<Project>).",
175
+ inputSchema: {
176
+ type: "object",
177
+ properties: {
178
+ type: { type: "string", description: "Doc type (e.g. design-system, backlog, changelog)" },
179
+ slug: { type: "string", description: "Optional slug for parameterized types (e.g. project name for design-system)" },
180
+ },
181
+ required: ["type"],
182
+ },
183
+ },
184
+ {
185
+ name: "validate_doc_placement",
186
+ description: "Validates a file path against .ai/docs-schema.json. Checks naming convention (SCREAMING_SNAKE by default) and path. " +
187
+ "Returns valid: boolean and errors: string[]. Use before writing docs; run in background during compound. " +
188
+ "If schema missing, returns valid: true.",
189
+ inputSchema: {
190
+ type: "object",
191
+ properties: {
192
+ path: { type: "string", description: "Relative path to validate (e.g. docs/BACKLOG.md)" },
193
+ paths: { type: "array", items: { type: "string" }, description: "Multiple paths to validate" },
194
+ },
195
+ },
196
+ },
197
+ {
198
+ name: "list_doc_types",
199
+ description: "Lists all doc types from .ai/docs-schema.json with their path and pattern. " +
200
+ "Use to discover available types before get_doc_path. Returns empty if schema missing.",
201
+ inputSchema: { type: "object", properties: {} },
202
+ },
203
+ ],
204
+ }));
205
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
206
+ const { name, arguments: args = {} } = request.params;
207
+ switch (name) {
208
+ case "search_memory": return handleSearchMemory(aiDir, args);
209
+ case "get_memory": return handleGetMemory(aiDir, args);
210
+ case "commit_memory": return handleCommitMemory(aiDir, args);
211
+ case "prune_memory": return handlePruneMemory(aiDir, args);
212
+ case "get_open_items": return handleGetOpenItems(aiDir);
213
+ case "get_evals": return handleGetEvals(aiDir);
214
+ case "validate_context": return handleValidateContext(aiDir, args);
215
+ case "validate_schema": return handleValidateSchema(aiDir, args);
216
+ case "generate_harness": return handleGenerateHarness(aiDir);
217
+ case "claim_task": return handleClaimTask(aiDir, args);
218
+ case "publish_result": return handlePublishResult(aiDir, args);
219
+ case "sync_memory": return handleSyncMemory(aiDir, args);
220
+ case "get_doc_path": return handleGetDocPath(aiDir, args);
221
+ case "validate_doc_placement": return handleValidateDocPlacement(aiDir, args);
222
+ case "list_doc_types": return handleListDocTypes(aiDir);
223
+ case "get_repo_root": {
224
+ const cwd = resolve(aiDir, "..");
225
+ const root = getRepoRoot(cwd);
226
+ return textResponse(root ?? "null (not a git repository)");
227
+ }
228
+ default:
229
+ throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`);
230
+ }
231
+ });
232
+ }
233
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/mcp-server/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,SAAS,EACT,QAAQ,GACT,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,kBAAkB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,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { type McpResponse } from "./shared.js";
2
+ export declare function handleSearchMemory(aiDir: string, args: Record<string, unknown>): Promise<McpResponse>;
3
+ export declare function handleGetMemory(aiDir: string, args: Record<string, unknown>): Promise<McpResponse>;
4
+ export declare function handleCommitMemory(aiDir: string, args: Record<string, unknown>): Promise<McpResponse>;
5
+ export declare function handlePruneMemory(aiDir: string, args: Record<string, unknown>): Promise<McpResponse>;
6
+ export declare function handleGetOpenItems(aiDir: string): Promise<McpResponse>;
7
+ export declare function handleGetEvals(aiDir: string): Promise<McpResponse>;
8
+ //# sourceMappingURL=memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../src/mcp-server/tools/memory.ts"],"names":[],"mappings":"AAMA,OAAO,EAGmC,KAAK,WAAW,EACzD,MAAM,aAAa,CAAC;AAErB,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CA8B3G;AAED,wBAAsB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAwBxG;AAED,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAwC3G;AAED,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAwB1G;AAED,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAQ5E;AAED,wBAAsB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAQxE"}
@@ -0,0 +1,153 @@
1
+ import { readFile, writeFile, readdir, mkdir } from "fs/promises";
2
+ import { join, dirname } from "path";
3
+ import { existsSync } from "fs";
4
+ import { ErrorCode, McpError } from "@modelcontextprotocol/sdk/types.js";
5
+ import { hybridSearch, getSearchMode } from "../../hybrid-search/index.js";
6
+ import { assertPathWithinAiDir } from "../../utils/fs.js";
7
+ import { isImmutable, ALWAYS_IMMUTABLE, FRONTMATTER_CONTROLLED, generateSessionId, acquireClaim, releaseClaim, MAX_COMMIT_CONTENT_BYTES, textResponse, } from "./shared.js";
8
+ export async function handleSearchMemory(aiDir, args) {
9
+ const query = args.query;
10
+ if (typeof query !== "string" || !query.trim()) {
11
+ throw new McpError(ErrorCode.InvalidParams, "query is required and must be a non-empty string.");
12
+ }
13
+ const tags = args.tags;
14
+ const userLimit = Math.min(Number(args.limit) || 10, 20);
15
+ const includeDeprecated = args.include_deprecated ?? false;
16
+ const mode = getSearchMode();
17
+ let resp;
18
+ let fallbackNote = "";
19
+ try {
20
+ resp = await hybridSearch(aiDir, query, { mode, limit: userLimit, tags, includeDeprecated });
21
+ }
22
+ catch {
23
+ if (mode !== "keyword") {
24
+ resp = await hybridSearch(aiDir, query, { mode: "keyword", limit: userLimit, tags, includeDeprecated });
25
+ fallbackNote = "Note: Hybrid/semantic search failed (e.g. onnxruntime-node missing on Windows). Using keyword-only. Set AI_SEARCH=keyword to skip, or AI_SEARCH_WASM=1 to try WASM.\n\n";
26
+ }
27
+ else {
28
+ throw new McpError(ErrorCode.InternalError, "Search failed.");
29
+ }
30
+ }
31
+ const { results, backend } = resp;
32
+ if (results.length === 0)
33
+ return textResponse("No results found.");
34
+ const backendLabel = backend === "keyword" ? "Keyword-only" : backend === "native" ? "Hybrid (Native)" : "Hybrid (WASM)";
35
+ const text = fallbackNote + `Search backend: ${backendLabel}\n\n` +
36
+ results.map((r, i) => {
37
+ const excerpt = r.excerpt.length > 200 ? r.excerpt.slice(0, 200) + "…" : r.excerpt;
38
+ return `${i + 1}. **${r.file}** (score: ${r.score})\n ${excerpt}`;
39
+ }).join("\n\n");
40
+ return textResponse(text);
41
+ }
42
+ export async function handleGetMemory(aiDir, args) {
43
+ const topic = args.topic;
44
+ if (typeof topic !== "string" || !topic.trim()) {
45
+ throw new McpError(ErrorCode.InvalidParams, "topic is required and must be a non-empty string.");
46
+ }
47
+ const mode = getSearchMode();
48
+ let resp;
49
+ let fallbackNote = "";
50
+ try {
51
+ resp = await hybridSearch(aiDir, topic, { mode, limit: 5 });
52
+ }
53
+ catch {
54
+ if (mode !== "keyword") {
55
+ resp = await hybridSearch(aiDir, topic, { mode: "keyword", limit: 5 });
56
+ fallbackNote = "Note: Hybrid/semantic search failed. Using keyword-only. Set AI_SEARCH=keyword or AI_SEARCH_WASM=1.\n\n";
57
+ }
58
+ else {
59
+ throw new McpError(ErrorCode.InternalError, "Search failed.");
60
+ }
61
+ }
62
+ const { results, backend } = resp;
63
+ if (results.length === 0)
64
+ return textResponse(`No memory found for topic: ${topic}`);
65
+ const backendLabel = backend === "keyword" ? "Keyword-only" : backend === "native" ? "Hybrid (Native)" : "Hybrid (WASM)";
66
+ const text = fallbackNote + `Search backend: ${backendLabel}\n\nMemory for "${topic}":\n\n` +
67
+ results.map((r) => `**${r.file}**: ${r.excerpt}`).join("\n\n");
68
+ return textResponse(text);
69
+ }
70
+ export async function handleCommitMemory(aiDir, args) {
71
+ const memPath = args.path;
72
+ const memContent = args.content;
73
+ if (typeof memPath !== "string" || !memPath.trim()) {
74
+ throw new McpError(ErrorCode.InvalidParams, "path is required and must be a non-empty string.");
75
+ }
76
+ if (typeof memContent !== "string") {
77
+ throw new McpError(ErrorCode.InvalidParams, "content is required and must be a string.");
78
+ }
79
+ const contentBytes = Buffer.byteLength(memContent, "utf-8");
80
+ if (contentBytes > MAX_COMMIT_CONTENT_BYTES) {
81
+ throw new McpError(ErrorCode.InvalidParams, `content exceeds ${MAX_COMMIT_CONTENT_BYTES / 1024 / 1024}MB limit (got ${Math.round(contentBytes / 1024)}KB). Split into smaller entries.`);
82
+ }
83
+ const append = args.append ?? true;
84
+ const sessionId = (typeof args.session_id === "string" && args.session_id) || generateSessionId();
85
+ if (await isImmutable(memPath, aiDir)) {
86
+ const reason = FRONTMATTER_CONTROLLED.includes(memPath)
87
+ ? `${memPath} is immutable (set \`writable: true\` in its frontmatter to allow AI writes).`
88
+ : `${memPath} is in a structurally immutable path (${ALWAYS_IMMUTABLE.join(", ")}).`;
89
+ throw new McpError(ErrorCode.InvalidRequest, reason);
90
+ }
91
+ const fullPath = assertPathWithinAiDir(aiDir, memPath);
92
+ await acquireClaim(aiDir, memPath, sessionId);
93
+ try {
94
+ await mkdir(dirname(fullPath), { recursive: true });
95
+ const header = `<!-- session:${sessionId} at:${new Date().toISOString()} -->`;
96
+ if (append && existsSync(fullPath)) {
97
+ const existing = await readFile(fullPath, "utf-8");
98
+ await writeFile(fullPath, existing.trimEnd() + "\n\n" + header + "\n" + memContent);
99
+ }
100
+ else {
101
+ await writeFile(fullPath, header + "\n" + memContent);
102
+ }
103
+ }
104
+ finally {
105
+ await releaseClaim(aiDir, memPath);
106
+ }
107
+ return textResponse(`✓ Written to ${memPath} (session: ${sessionId})`);
108
+ }
109
+ export async function handlePruneMemory(aiDir, args) {
110
+ const dryRun = args.dry_run ?? true;
111
+ const memDir = join(aiDir, "memory");
112
+ const candidates = [];
113
+ if (existsSync(memDir)) {
114
+ const files = await readdir(memDir);
115
+ for (const file of files) {
116
+ if (!file.endsWith(".md"))
117
+ continue;
118
+ const content = await readFile(join(memDir, file), "utf-8");
119
+ const deprecatedMatches = content.match(/### \[P[0-2]\].+\[DEPRECATED\]/g);
120
+ if (deprecatedMatches) {
121
+ candidates.push(`${file}: ${deprecatedMatches.length} deprecated entry/entries`);
122
+ }
123
+ }
124
+ }
125
+ if (candidates.length === 0)
126
+ return textResponse("No candidates for pruning found.");
127
+ const report = candidates.map((c) => `• ${c}`).join("\n");
128
+ if (dryRun) {
129
+ return textResponse(`Prune candidates (dry run — no changes made):\n\n${report}\n\nRun with dry_run: false to archive these entries.`);
130
+ }
131
+ return textResponse(`Flagged for archiving:\n\n${report}\n\nReview and move to sessions/archive/ manually, or run \`ai-memory prune\` from the CLI.`);
132
+ }
133
+ export async function handleGetOpenItems(aiDir) {
134
+ const openItemsPath = join(aiDir, "sessions/open-items.md");
135
+ try {
136
+ const content = await readFile(openItemsPath, "utf-8");
137
+ return textResponse(content);
138
+ }
139
+ catch {
140
+ return textResponse("No open-items.md found. Initialize with `ai-memory init`.");
141
+ }
142
+ }
143
+ export async function handleGetEvals(aiDir) {
144
+ const evalPath = join(aiDir, "temp/eval-report.json");
145
+ try {
146
+ const content = await readFile(evalPath, "utf-8");
147
+ return textResponse(content);
148
+ }
149
+ catch {
150
+ return textResponse("No eval report found. Run `ai-memory eval` to generate one.");
151
+ }
152
+ }
153
+ //# sourceMappingURL=memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.js","sourceRoot":"","sources":["../../../src/mcp-server/tools/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EACL,WAAW,EAAE,gBAAgB,EAAE,sBAAsB,EACrD,iBAAiB,EAAE,YAAY,EAAE,YAAY,EAC7C,wBAAwB,EAAE,YAAY,GACvC,MAAM,aAAa,CA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Q,EAAE,OAAO,CAAC,CAAC;QAClD,OAAO,YAAY,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,YAAY,CAAC,6DAA6D,CAAC,CAAC;IACrF,CAAC;AACH,CAAC"}
@@ -0,0 +1,19 @@
1
+ export declare const MAX_COMMIT_CONTENT_BYTES: number;
2
+ export declare const MAX_GIT_DIFF_BYTES: number;
3
+ export declare const ALWAYS_IMMUTABLE: string[];
4
+ export declare const FRONTMATTER_CONTROLLED: string[];
5
+ export declare function isImmutable(path: string, aiDir: string): Promise<boolean>;
6
+ export declare function getRepoRoot(cwd: string): string | null;
7
+ export declare function generateSessionId(): string;
8
+ export declare function sanitizeCommitMessage(msg: string): string;
9
+ export declare function acquireClaim(aiDir: string, path: string, sessionId: string): Promise<void>;
10
+ export declare function releaseClaim(aiDir: string, path: string): Promise<void>;
11
+ export type McpResponse = {
12
+ content: Array<{
13
+ type: string;
14
+ text: string;
15
+ }>;
16
+ isError?: boolean;
17
+ };
18
+ export declare function textResponse(text: string, isError?: boolean): McpResponse;
19
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/mcp-server/tools/shared.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,wBAAwB,QAAc,CAAC;AACpD,eAAO,MAAM,kBAAkB,QAAa,CAAC;AAG7C,eAAO,MAAM,gBAAgB,UAAiC,CAAC;AAG/D,eAAO,MAAM,sBAAsB,UAAuC,CAAC;AAM3E,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAkB/E;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAWtD;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAOzD;AAWD,wBAAsB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAsChG;AAED,wBAAsB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG7E;AAGD,MAAM,MAAM,WAAW,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEhG,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,WAAW,CAIzE"}
@@ -0,0 +1,112 @@
1
+ import { readFile, mkdir, unlink, open } from "fs/promises";
2
+ import { join } from "path";
3
+ import { existsSync } from "fs";
4
+ import { execFileSync } from "child_process";
5
+ import matter from "gray-matter";
6
+ import { ErrorCode, McpError } from "@modelcontextprotocol/sdk/types.js";
7
+ // Input limits (security)
8
+ export const MAX_COMMIT_CONTENT_BYTES = 1024 * 1024; // 1MB
9
+ export const MAX_GIT_DIFF_BYTES = 512 * 1024; // 500KB
10
+ // Paths that are ALWAYS immutable (structural, not content)
11
+ export const ALWAYS_IMMUTABLE = ["toolbox/", "acp/", "rules/"];
12
+ // Paths whose immutability is controlled by frontmatter `writable` field
13
+ export const FRONTMATTER_CONTROLLED = ["IDENTITY.md", "PROJECT_STATUS.md"];
14
+ const WRITABLE_DEFAULTS = {
15
+ "IDENTITY.md": false,
16
+ "PROJECT_STATUS.md": true,
17
+ };
18
+ export async function isImmutable(path, aiDir) {
19
+ if (ALWAYS_IMMUTABLE.some((p) => path === p || path.startsWith(p))) {
20
+ return true;
21
+ }
22
+ for (const controlled of FRONTMATTER_CONTROLLED) {
23
+ if (path === controlled) {
24
+ const fullPath = join(aiDir, controlled);
25
+ try {
26
+ const content = await readFile(fullPath, "utf-8");
27
+ const { data } = matter(content);
28
+ if (typeof data.writable === "boolean")
29
+ return !data.writable;
30
+ return !WRITABLE_DEFAULTS[controlled];
31
+ }
32
+ catch {
33
+ return !WRITABLE_DEFAULTS[controlled];
34
+ }
35
+ }
36
+ }
37
+ return false;
38
+ }
39
+ export function getRepoRoot(cwd) {
40
+ try {
41
+ const out = execFileSync("git", ["rev-parse", "--show-toplevel"], {
42
+ cwd,
43
+ encoding: "utf-8",
44
+ timeout: 5000,
45
+ });
46
+ return out.trim() || null;
47
+ }
48
+ catch {
49
+ return null;
50
+ }
51
+ }
52
+ export function generateSessionId() {
53
+ return `s-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 6)}`;
54
+ }
55
+ export function sanitizeCommitMessage(msg) {
56
+ return msg
57
+ .replace(/\0/g, "")
58
+ .replace(/[\r\n]+/g, " ")
59
+ .replace(/["`]/g, "'")
60
+ .slice(0, 2000)
61
+ .trim() || "ai-memory: sync";
62
+ }
63
+ // Claim system: prevents concurrent writes to the same path
64
+ const CLAIM_TTL_MS = 5 * 60 * 1000;
65
+ export async function acquireClaim(aiDir, path, sessionId) {
66
+ const locksDir = join(aiDir, "temp", "locks");
67
+ await mkdir(locksDir, { recursive: true });
68
+ const lockFile = join(locksDir, path.replace(/[/\\]/g, "_") + ".lock");
69
+ if (existsSync(lockFile)) {
70
+ try {
71
+ const existing = JSON.parse(await readFile(lockFile, "utf-8"));
72
+ const age = Date.now() - existing.timestamp;
73
+ if (age < CLAIM_TTL_MS && existing.session_id !== sessionId) {
74
+ throw new McpError(ErrorCode.InvalidRequest, `Path "${path}" is claimed by another session (${existing.session_id}, ${Math.round(age / 1000)}s ago). ` +
75
+ `Wait for the claim to expire (${Math.round(CLAIM_TTL_MS / 1000)}s TTL) or close the other session.`);
76
+ }
77
+ await unlink(lockFile).catch(() => { });
78
+ }
79
+ catch (err) {
80
+ if (err instanceof McpError)
81
+ throw err;
82
+ await unlink(lockFile).catch(() => { });
83
+ }
84
+ }
85
+ const claim = { session_id: sessionId, timestamp: Date.now(), pid: process.pid };
86
+ const data = JSON.stringify(claim);
87
+ try {
88
+ const fd = await open(lockFile, "wx");
89
+ await fd.writeFile(data);
90
+ await fd.close();
91
+ }
92
+ catch (err) {
93
+ if (err.code === "EEXIST") {
94
+ throw new McpError(ErrorCode.InvalidRequest, `Path "${path}" was just claimed by another session. Retry shortly.`);
95
+ }
96
+ throw err;
97
+ }
98
+ }
99
+ export async function releaseClaim(aiDir, path) {
100
+ const lockFile = join(aiDir, "temp", "locks", path.replace(/[/\\]/g, "_") + ".lock");
101
+ try {
102
+ await unlink(lockFile);
103
+ }
104
+ catch { /* already gone */ }
105
+ }
106
+ export function textResponse(text, isError) {
107
+ const resp = { content: [{ type: "text", text }] };
108
+ if (isError)
109
+ resp.isError = true;
110
+ return resp;
111
+ }
112
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/mcp-server/tools/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAa,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAEzE,0BAA0B;AAC1B,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,MAAM;AAC3D,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC,QAAQ;AAEtD,4DAA4D;AAC5D,MAAM,CAAC,MAA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AE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAA;KAAE,CAAC,CAAC;CAC1F;AA4HD,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAitBjE"}
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/mcp-server/tools.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAgLxE,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC1E,KAAK,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAA;KAAE,CAAC,CAAC;CAC1F;AA4HD,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAkuBjE"}