@codemem/mcp 0.31.4 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/audit.d.ts +54 -0
- package/dist/audit.d.ts.map +1 -0
- package/dist/content.d.ts +13 -0
- package/dist/content.d.ts.map +1 -0
- package/dist/http.d.ts +38 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +17075 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +2 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -602
- package/dist/memory-access.d.ts.map +1 -1
- package/dist/memory-kinds.d.ts +2 -0
- package/dist/memory-kinds.d.ts.map +1 -0
- package/dist/oauth.d.ts +176 -0
- package/dist/oauth.d.ts.map +1 -0
- package/dist/oidc.d.ts +35 -0
- package/dist/oidc.d.ts.map +1 -0
- package/dist/project-scope.d.ts +4 -0
- package/dist/project-scope.d.ts.map +1 -1
- package/dist/provider.d.ts +51 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/schemas.d.ts +36 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/server-Djvf0Yik.js +488 -0
- package/dist/server-Djvf0Yik.js.map +1 -0
- package/dist/server.d.ts +5 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/stdio.d.ts +9 -0
- package/dist/stdio.d.ts.map +1 -0
- package/dist/stdio.js +69 -0
- package/dist/stdio.js.map +1 -0
- package/dist/tool-context.d.ts +12 -0
- package/dist/tool-context.d.ts.map +1 -0
- package/dist/tools/items.d.ts +4 -0
- package/dist/tools/items.d.ts.map +1 -0
- package/dist/tools/learn.d.ts +3 -0
- package/dist/tools/learn.d.ts.map +1 -0
- package/dist/tools/schema.d.ts +3 -0
- package/dist/tools/schema.d.ts.map +1 -0
- package/dist/tools/search.d.ts +4 -0
- package/dist/tools/search.d.ts.map +1 -0
- package/dist/tools/timeline.d.ts +4 -0
- package/dist/tools/timeline.d.ts.map +1 -0
- package/package.json +19 -7
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
import { VERSION as e, dedupeOrderedIds as t, projectMatchesFilter as n, resolveProject as r, storeVectors as i, toJson as a } from "@codemem/core";
|
|
2
|
+
import { McpServer as o } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { z as s } from "zod";
|
|
4
|
+
//#region src/project-scope.ts
|
|
5
|
+
function c(e) {
|
|
6
|
+
return e?.trim() || null;
|
|
7
|
+
}
|
|
8
|
+
function l() {
|
|
9
|
+
return c(process.env.CODEMEM_PROJECT) ?? r(process.cwd());
|
|
10
|
+
}
|
|
11
|
+
function u(e) {
|
|
12
|
+
return c(e.project) ?? c(e.envProject) ?? null;
|
|
13
|
+
}
|
|
14
|
+
function d(e, t = l()) {
|
|
15
|
+
let n = {}, r = !1, i = (typeof e.project == "string" ? c(e.project) : void 0) || c(t) || void 0;
|
|
16
|
+
i && (n.project = i, r = !0);
|
|
17
|
+
for (let t of [
|
|
18
|
+
"kind",
|
|
19
|
+
"visibility",
|
|
20
|
+
"scope_id",
|
|
21
|
+
"include_scope_ids",
|
|
22
|
+
"exclude_scope_ids",
|
|
23
|
+
"include_visibility",
|
|
24
|
+
"exclude_visibility",
|
|
25
|
+
"include_workspace_ids",
|
|
26
|
+
"exclude_workspace_ids",
|
|
27
|
+
"include_workspace_kinds",
|
|
28
|
+
"exclude_workspace_kinds",
|
|
29
|
+
"include_actor_ids",
|
|
30
|
+
"exclude_actor_ids",
|
|
31
|
+
"include_trust_states",
|
|
32
|
+
"exclude_trust_states",
|
|
33
|
+
"ownership_scope",
|
|
34
|
+
"personal_first",
|
|
35
|
+
"trust_bias",
|
|
36
|
+
"widen_shared_when_weak",
|
|
37
|
+
"widen_shared_min_personal_results",
|
|
38
|
+
"widen_shared_min_personal_score"
|
|
39
|
+
]) {
|
|
40
|
+
let i = e[t];
|
|
41
|
+
i != null && (n[t] = i, r = !0);
|
|
42
|
+
}
|
|
43
|
+
return r ? n : void 0;
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/content.ts
|
|
47
|
+
function f(e) {
|
|
48
|
+
return { content: [{
|
|
49
|
+
type: "text",
|
|
50
|
+
text: JSON.stringify(e)
|
|
51
|
+
}] };
|
|
52
|
+
}
|
|
53
|
+
function p(e) {
|
|
54
|
+
return { content: [{
|
|
55
|
+
type: "text",
|
|
56
|
+
text: JSON.stringify({ error: e })
|
|
57
|
+
}] };
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/memory-access.ts
|
|
61
|
+
function m(e, t, n) {
|
|
62
|
+
return e.timeline(null, t, 0, 0, n ?? null).find((e) => e.id === t) ?? null;
|
|
63
|
+
}
|
|
64
|
+
function h(e, t, n) {
|
|
65
|
+
if (t.length === 0) return [];
|
|
66
|
+
let r = [];
|
|
67
|
+
for (let i of t) {
|
|
68
|
+
let t = m(e, i, n);
|
|
69
|
+
t && r.push(t);
|
|
70
|
+
}
|
|
71
|
+
return r;
|
|
72
|
+
}
|
|
73
|
+
function g(e, t, n) {
|
|
74
|
+
return m(e, t, n) ? (e.forget(t), !0) : !1;
|
|
75
|
+
}
|
|
76
|
+
function _(e, t, n = {}) {
|
|
77
|
+
return e.db.transaction(() => {
|
|
78
|
+
let r = n.now?.() ?? (/* @__PURE__ */ new Date()).toISOString(), i = n.user ?? process.env.USER ?? "unknown", o = n.cwd ?? process.cwd(), s = u({
|
|
79
|
+
project: t.project,
|
|
80
|
+
envProject: n.envProject
|
|
81
|
+
}), c = e.db.prepare("INSERT INTO sessions(started_at, ended_at, cwd, project, user, tool_version, metadata_json)\n VALUES (?, ?, ?, ?, ?, ?, ?)").run(r, r, o, s, i, "mcp-ts", a({ mcp: !0 })), l = Number(c.lastInsertRowid), d = e.remember(l, t.kind, t.title, t.body, t.confidence);
|
|
82
|
+
if (!m(e, d)) throw Error("unauthorized_scope");
|
|
83
|
+
return e.db.prepare("UPDATE sessions SET ended_at = ?, metadata_json = ? WHERE id = ?").run(n.now?.() ?? (/* @__PURE__ */ new Date()).toISOString(), a({ mcp: !0 }), l), {
|
|
84
|
+
memId: d,
|
|
85
|
+
title: t.title,
|
|
86
|
+
body: t.body
|
|
87
|
+
};
|
|
88
|
+
})();
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/schemas.ts
|
|
92
|
+
var v = {
|
|
93
|
+
scope_id: s.string().optional().describe("Filter by a single sharing domain scope_id"),
|
|
94
|
+
include_scope_ids: s.array(s.string()).optional().describe("Sharing domain scope_ids to include"),
|
|
95
|
+
exclude_scope_ids: s.array(s.string()).optional().describe("Sharing domain scope_ids to exclude")
|
|
96
|
+
}, y = {
|
|
97
|
+
kind: s.string().optional().describe("Filter by memory kind"),
|
|
98
|
+
project: s.string().optional().describe("Filter by project scope (matches sessions.project)"),
|
|
99
|
+
...v,
|
|
100
|
+
visibility: s.array(s.string()).optional(),
|
|
101
|
+
include_visibility: s.array(s.string()).optional(),
|
|
102
|
+
exclude_visibility: s.array(s.string()).optional(),
|
|
103
|
+
include_workspace_ids: s.array(s.string()).optional(),
|
|
104
|
+
exclude_workspace_ids: s.array(s.string()).optional(),
|
|
105
|
+
include_workspace_kinds: s.array(s.string()).optional(),
|
|
106
|
+
exclude_workspace_kinds: s.array(s.string()).optional(),
|
|
107
|
+
include_actor_ids: s.array(s.string()).optional(),
|
|
108
|
+
exclude_actor_ids: s.array(s.string()).optional(),
|
|
109
|
+
include_trust_states: s.array(s.string()).optional(),
|
|
110
|
+
exclude_trust_states: s.array(s.string()).optional(),
|
|
111
|
+
ownership_scope: s.string().optional(),
|
|
112
|
+
personal_first: s.union([s.boolean(), s.string()]).optional(),
|
|
113
|
+
trust_bias: s.string().optional(),
|
|
114
|
+
widen_shared_when_weak: s.union([s.boolean(), s.string()]).optional(),
|
|
115
|
+
widen_shared_min_personal_results: s.number().int().optional(),
|
|
116
|
+
widen_shared_min_personal_score: s.number().optional()
|
|
117
|
+
}, b = s.enum([
|
|
118
|
+
"discovery",
|
|
119
|
+
"change",
|
|
120
|
+
"feature",
|
|
121
|
+
"bugfix",
|
|
122
|
+
"refactor",
|
|
123
|
+
"decision",
|
|
124
|
+
"exploration"
|
|
125
|
+
]), x = Object.keys(y).toSorted();
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region src/tools/items.ts
|
|
128
|
+
function S(e, t) {
|
|
129
|
+
let { envProject: n, store: r } = t;
|
|
130
|
+
e.tool("memory_get", "Fetch a single memory item by ID.", {
|
|
131
|
+
memory_id: s.number().int().describe("Memory ID"),
|
|
132
|
+
...y
|
|
133
|
+
}, async (e) => {
|
|
134
|
+
try {
|
|
135
|
+
let t = m(r, e.memory_id, d(e, null));
|
|
136
|
+
return t ? f(t) : p("not_found");
|
|
137
|
+
} catch (e) {
|
|
138
|
+
return p(e instanceof Error ? e.message : String(e));
|
|
139
|
+
}
|
|
140
|
+
}), e.tool("memory_get_observations", "Fetch multiple memory items by their IDs.", {
|
|
141
|
+
ids: s.array(s.number().int()).max(200).describe("Memory IDs to fetch"),
|
|
142
|
+
...y
|
|
143
|
+
}, async (e) => {
|
|
144
|
+
try {
|
|
145
|
+
return f({ items: h(r, e.ids, d(e, null)) });
|
|
146
|
+
} catch (e) {
|
|
147
|
+
return p(e instanceof Error ? e.message : String(e));
|
|
148
|
+
}
|
|
149
|
+
}), e.tool("memory_remember", "Create a new memory. Use for milestones, decisions, and notable facts.", {
|
|
150
|
+
kind: b.describe("Memory kind"),
|
|
151
|
+
title: s.string().describe("Short title"),
|
|
152
|
+
body: s.string().describe("Body text (high-signal content)"),
|
|
153
|
+
confidence: s.number().min(0).max(1).default(.5).describe("Confidence 0-1"),
|
|
154
|
+
project: s.string().optional().describe("Project identifier")
|
|
155
|
+
}, async (e) => {
|
|
156
|
+
try {
|
|
157
|
+
let t = _(r, e, { envProject: n() });
|
|
158
|
+
try {
|
|
159
|
+
await i(r.db, t.memId, t.title, t.body);
|
|
160
|
+
} catch {}
|
|
161
|
+
return f({ id: t.memId });
|
|
162
|
+
} catch (e) {
|
|
163
|
+
return p(e instanceof Error ? e.message : String(e));
|
|
164
|
+
}
|
|
165
|
+
}), e.tool("memory_forget", "Soft-delete a memory item. Use for incorrect or sensitive data.", {
|
|
166
|
+
memory_id: s.number().int().describe("Memory ID to forget"),
|
|
167
|
+
...y
|
|
168
|
+
}, async (e) => {
|
|
169
|
+
try {
|
|
170
|
+
return g(r, e.memory_id, d(e, null)) ? f({ status: "ok" }) : p("not_found");
|
|
171
|
+
} catch (e) {
|
|
172
|
+
return p(e instanceof Error ? e.message : String(e));
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/tools/learn.ts
|
|
178
|
+
function C(e) {
|
|
179
|
+
e.tool("memory_learn", "Learn how to use codemem memory tools. Call this first if unfamiliar.", {}, async () => f({
|
|
180
|
+
intro: "Use this tool when you're new to codemem or unsure when to recall/persist.",
|
|
181
|
+
client_hint: "If you are unfamiliar with codemem, call memory.learn first.",
|
|
182
|
+
recall: {
|
|
183
|
+
when: ["Start of a task or when the user references prior work.", "When you need background context, decisions, or recent changes."],
|
|
184
|
+
how: [
|
|
185
|
+
"Use memory.search_index to get compact candidates.",
|
|
186
|
+
"Use memory.timeline to expand around a promising memory.",
|
|
187
|
+
"Use memory.get_observations for full details only when needed.",
|
|
188
|
+
"Use memory.pack for quick one-shot context blocks.",
|
|
189
|
+
"Use the project filter unless the user requests cross-project context."
|
|
190
|
+
],
|
|
191
|
+
examples: [
|
|
192
|
+
"memory.search_index(\"billing cache bug\", limit=5)",
|
|
193
|
+
"memory.timeline(memory_id=123)",
|
|
194
|
+
"memory.get_observations([123, 456])"
|
|
195
|
+
]
|
|
196
|
+
},
|
|
197
|
+
persistence: {
|
|
198
|
+
when: ["Milestones (task done, key decision, new facts learned).", "Notable regressions or follow-ups that should be remembered."],
|
|
199
|
+
how: [
|
|
200
|
+
"Use memory.remember with kind decision/discovery/change/exploration.",
|
|
201
|
+
"Keep titles short and bodies high-signal.",
|
|
202
|
+
"ALWAYS pass the project parameter if known."
|
|
203
|
+
],
|
|
204
|
+
examples: ["memory.remember(kind=\"decision\", title=\"Switch to async cache\", body=\"...why...\", project=\"my-service\")", "memory.remember(kind=\"change\", title=\"Fixed retry loop\", body=\"...impact...\", project=\"my-service\")"]
|
|
205
|
+
},
|
|
206
|
+
forget: {
|
|
207
|
+
when: ["Accidental or sensitive data stored in memory items.", "Obsolete or incorrect items that should no longer surface."],
|
|
208
|
+
how: ["Call memory.forget(id) to mark the item inactive.", "Prefer forgetting over overwriting to preserve auditability."],
|
|
209
|
+
examples: ["memory.forget(123)"]
|
|
210
|
+
},
|
|
211
|
+
prompt_hint: "At task start: call memory.search_index; during work: memory.timeline + memory.get_observations; at milestones: memory.remember.",
|
|
212
|
+
recommended_system_prompt: [
|
|
213
|
+
"Trigger policy (1-liner): If the user references prior work or starts a task,",
|
|
214
|
+
"immediately call memory.search_index; then use memory.timeline + memory.get_observations;",
|
|
215
|
+
"at milestones, call memory.remember; use memory.forget for incorrect/sensitive items.",
|
|
216
|
+
"",
|
|
217
|
+
"System prompt:",
|
|
218
|
+
"You have access to codemem MCP tools. If unfamiliar, call memory.learn first.",
|
|
219
|
+
"",
|
|
220
|
+
"Recall:",
|
|
221
|
+
"- Start of any task: call memory.search_index with a concise task query.",
|
|
222
|
+
"- If prior work is referenced (\"as before\", \"last time\", \"we already did…\", \"regression\"),",
|
|
223
|
+
" call memory.search_index or memory.timeline.",
|
|
224
|
+
"- Use memory.get_observations only after filtering IDs.",
|
|
225
|
+
"- Prefer project-scoped queries unless the user asks for cross-project.",
|
|
226
|
+
"",
|
|
227
|
+
"Persistence:",
|
|
228
|
+
"- On milestones (task done, key decision, new facts learned), call memory.remember.",
|
|
229
|
+
"- Use kind=decision for tradeoffs, kind=change for outcomes, kind=discovery/exploration for useful findings.",
|
|
230
|
+
"- Keep titles short and bodies high-signal.",
|
|
231
|
+
"- ALWAYS pass the project parameter if known.",
|
|
232
|
+
"",
|
|
233
|
+
"Safety:",
|
|
234
|
+
"- Use memory.forget(id) for incorrect or sensitive items.",
|
|
235
|
+
"",
|
|
236
|
+
"Examples:",
|
|
237
|
+
"- memory.search_index(\"billing cache bug\")",
|
|
238
|
+
"- memory.timeline(memory_id=123)",
|
|
239
|
+
"- memory.get_observations([123, 456])",
|
|
240
|
+
"- memory.remember(kind=\"decision\", title=\"Use async cache\", body=\"Chose async cache to avoid lock contention in X.\", project=\"my-service\")",
|
|
241
|
+
"- memory.remember(kind=\"change\", title=\"Fixed retry loop\", body=\"Root cause was Y; added guard in Z.\", project=\"my-service\")",
|
|
242
|
+
"- memory.forget(123)"
|
|
243
|
+
].join("\n")
|
|
244
|
+
}));
|
|
245
|
+
}
|
|
246
|
+
//#endregion
|
|
247
|
+
//#region src/memory-kinds.ts
|
|
248
|
+
var w = {
|
|
249
|
+
discovery: "Something learned about the codebase, architecture, or tools",
|
|
250
|
+
change: "A code change that was made",
|
|
251
|
+
feature: "A new feature that was implemented",
|
|
252
|
+
bugfix: "A bug that was found and fixed",
|
|
253
|
+
refactor: "Code that was refactored or restructured",
|
|
254
|
+
decision: "A design or architecture decision",
|
|
255
|
+
exploration: "An experiment or investigation (may not have shipped)"
|
|
256
|
+
};
|
|
257
|
+
//#endregion
|
|
258
|
+
//#region src/tools/schema.ts
|
|
259
|
+
function T(e) {
|
|
260
|
+
e.tool("memory_schema", "Return the memory schema — kinds, fields, and available filters.", {}, async () => f({
|
|
261
|
+
kinds: Object.keys(w),
|
|
262
|
+
kind_descriptions: w,
|
|
263
|
+
fields: {
|
|
264
|
+
title: "short text",
|
|
265
|
+
body: "long text",
|
|
266
|
+
subtitle: "short text",
|
|
267
|
+
facts: "list<string>",
|
|
268
|
+
narrative: "long text",
|
|
269
|
+
concepts: "list<string>",
|
|
270
|
+
files_read: "list<string>",
|
|
271
|
+
files_modified: "list<string>",
|
|
272
|
+
prompt_number: "int"
|
|
273
|
+
},
|
|
274
|
+
filters: x
|
|
275
|
+
}));
|
|
276
|
+
}
|
|
277
|
+
//#endregion
|
|
278
|
+
//#region src/tools/search.ts
|
|
279
|
+
function E(e, t) {
|
|
280
|
+
let { defaultProject: n, store: r } = t;
|
|
281
|
+
e.tool("memory_search", "Search memories by text query. Returns full body text for each match.", {
|
|
282
|
+
query: s.string().describe("Search query"),
|
|
283
|
+
limit: s.number().int().min(1).max(50).default(5).describe("Max results"),
|
|
284
|
+
...y
|
|
285
|
+
}, async (e) => {
|
|
286
|
+
try {
|
|
287
|
+
let t = d(e, n());
|
|
288
|
+
return f({ items: r.search(e.query, e.limit, t).map((e) => ({
|
|
289
|
+
id: e.id,
|
|
290
|
+
title: e.title,
|
|
291
|
+
kind: e.kind,
|
|
292
|
+
body: e.body_text,
|
|
293
|
+
confidence: e.confidence,
|
|
294
|
+
score: e.score,
|
|
295
|
+
session_id: e.session_id,
|
|
296
|
+
metadata: e.metadata
|
|
297
|
+
})) });
|
|
298
|
+
} catch (e) {
|
|
299
|
+
return p(e instanceof Error ? e.message : String(e));
|
|
300
|
+
}
|
|
301
|
+
}), e.tool("memory_search_index", "Search memories by text query. Returns compact index entries (no body) for browsing.", {
|
|
302
|
+
query: s.string().describe("Search query"),
|
|
303
|
+
limit: s.number().int().min(1).max(50).default(8).describe("Max results"),
|
|
304
|
+
...y
|
|
305
|
+
}, async (e) => {
|
|
306
|
+
try {
|
|
307
|
+
let t = d(e, n());
|
|
308
|
+
return f({ items: r.search(e.query, e.limit, t).map((e) => ({
|
|
309
|
+
id: e.id,
|
|
310
|
+
kind: e.kind,
|
|
311
|
+
title: e.title,
|
|
312
|
+
score: e.score,
|
|
313
|
+
created_at: e.created_at,
|
|
314
|
+
session_id: e.session_id,
|
|
315
|
+
metadata: e.metadata
|
|
316
|
+
})) });
|
|
317
|
+
} catch (e) {
|
|
318
|
+
return p(e instanceof Error ? e.message : String(e));
|
|
319
|
+
}
|
|
320
|
+
}), e.tool("memory_explain", "Explain search results with detailed scoring breakdown.", {
|
|
321
|
+
query: s.string().optional().describe("Search query"),
|
|
322
|
+
ids: s.array(s.number().int()).max(200).optional().describe("Specific memory IDs to explain"),
|
|
323
|
+
limit: s.number().int().min(1).max(50).default(10).describe("Max results"),
|
|
324
|
+
include_pack_context: s.boolean().default(!1).describe("Include formatted pack context"),
|
|
325
|
+
...y
|
|
326
|
+
}, async (e) => {
|
|
327
|
+
try {
|
|
328
|
+
let t = d(e, n());
|
|
329
|
+
return f(r.explain(e.query ?? null, e.ids ?? null, e.limit, t, { includePackContext: e.include_pack_context }));
|
|
330
|
+
} catch (e) {
|
|
331
|
+
return p(e instanceof Error ? e.message : String(e));
|
|
332
|
+
}
|
|
333
|
+
}), e.tool("memory_recent", "Return recent memories, newest first.", {
|
|
334
|
+
limit: s.number().int().min(1).max(100).default(8).describe("Max results"),
|
|
335
|
+
...y
|
|
336
|
+
}, async (e) => {
|
|
337
|
+
try {
|
|
338
|
+
let t = d(e, n());
|
|
339
|
+
return f({ items: r.recent(e.limit, t) });
|
|
340
|
+
} catch (e) {
|
|
341
|
+
return p(e instanceof Error ? e.message : String(e));
|
|
342
|
+
}
|
|
343
|
+
}), e.tool("memory_pack", "Build a formatted memory pack from search results — quick one-shot context block.", {
|
|
344
|
+
context: s.string().describe("Context description to search for"),
|
|
345
|
+
limit: s.number().int().min(1).max(50).optional().describe("Max items to include"),
|
|
346
|
+
compact: s.boolean().optional().describe("When true, render a scannable index of all items with full detail only for the top N (default 3). Saves tokens when broad overview matters more than per-item detail."),
|
|
347
|
+
compact_detail_count: s.number().int().min(0).max(50).optional().describe("Number of items to show in full detail in compact mode (default 3)"),
|
|
348
|
+
compression_mode: s.enum([
|
|
349
|
+
"off",
|
|
350
|
+
"compact",
|
|
351
|
+
"ids"
|
|
352
|
+
]).optional().describe("Near-related compression mode: off disables it, compact applies only to compact rendering, ids applies in all modes. Defaults to CODEMEM_PACK_COMPRESSION or compact."),
|
|
353
|
+
...y
|
|
354
|
+
}, async (e) => {
|
|
355
|
+
try {
|
|
356
|
+
let t = d(e, n()), i = e.compact || e.compact_detail_count != null || e.compression_mode != null ? {
|
|
357
|
+
compact: e.compact ?? (e.compact_detail_count == null ? void 0 : !0),
|
|
358
|
+
compactDetailCount: e.compact_detail_count,
|
|
359
|
+
compressionMode: e.compression_mode
|
|
360
|
+
} : void 0;
|
|
361
|
+
return f(await r.buildMemoryPackAsync(e.context, e.limit ?? void 0, null, t, i));
|
|
362
|
+
} catch (e) {
|
|
363
|
+
return p(e instanceof Error ? e.message : String(e));
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
//#endregion
|
|
368
|
+
//#region src/tools/timeline.ts
|
|
369
|
+
function D(e, r) {
|
|
370
|
+
let { defaultProject: i, store: a } = r;
|
|
371
|
+
e.tool("memory_timeline", "Get a chronological window of memories around an anchor (by ID or query).", {
|
|
372
|
+
query: s.string().optional().describe("Search query to find anchor"),
|
|
373
|
+
memory_id: s.number().int().optional().describe("Anchor memory ID"),
|
|
374
|
+
depth_before: s.number().int().min(0).default(3).describe("Items before anchor"),
|
|
375
|
+
depth_after: s.number().int().min(0).default(3).describe("Items after anchor"),
|
|
376
|
+
...y
|
|
377
|
+
}, async (e) => {
|
|
378
|
+
try {
|
|
379
|
+
let t = d(e, i());
|
|
380
|
+
return f({ items: a.timeline(e.query ?? null, e.memory_id ?? null, e.depth_before, e.depth_after, t) });
|
|
381
|
+
} catch (e) {
|
|
382
|
+
return p(e instanceof Error ? e.message : String(e));
|
|
383
|
+
}
|
|
384
|
+
}), e.tool("memory_expand", "Fetch memories by ID with surrounding timeline context.", {
|
|
385
|
+
ids: s.array(s.union([s.number(), s.string()])).max(200).describe("Memory IDs to expand"),
|
|
386
|
+
depth_before: s.number().int().min(0).default(3).describe("Timeline items before"),
|
|
387
|
+
depth_after: s.number().int().min(0).default(3).describe("Timeline items after"),
|
|
388
|
+
include_observations: s.boolean().default(!1).describe("Include full observation details"),
|
|
389
|
+
...y
|
|
390
|
+
}, async (e) => {
|
|
391
|
+
try {
|
|
392
|
+
let r = d(e, e.project !== void 0 && !e.project.trim() ? null : i()), o = r?.project ?? null, { ordered: s, invalid: c } = t(e.ids), l = [];
|
|
393
|
+
c.length > 0 && l.push({
|
|
394
|
+
code: "INVALID_ARGUMENT",
|
|
395
|
+
field: "ids",
|
|
396
|
+
message: "some ids are not valid integers",
|
|
397
|
+
ids: c
|
|
398
|
+
});
|
|
399
|
+
let u = [], p = [], m = [], g = [], _ = [], v = /* @__PURE__ */ new Set(), y = /* @__PURE__ */ new Map();
|
|
400
|
+
for (let t of s) {
|
|
401
|
+
let i = a.get(t);
|
|
402
|
+
if (!i?.active) {
|
|
403
|
+
u.push(t);
|
|
404
|
+
continue;
|
|
405
|
+
}
|
|
406
|
+
let s = i.session_id;
|
|
407
|
+
if (o && s > 0) {
|
|
408
|
+
if (!y.has(s)) {
|
|
409
|
+
let e = a.db.prepare("SELECT project FROM sessions WHERE id = ? LIMIT 1").get(s);
|
|
410
|
+
y.set(s, typeof e?.project == "string" ? e.project : null);
|
|
411
|
+
}
|
|
412
|
+
if (!n(o, y.get(s) ?? null)) {
|
|
413
|
+
p.push(t);
|
|
414
|
+
continue;
|
|
415
|
+
}
|
|
416
|
+
} else if (o && s <= 0) {
|
|
417
|
+
p.push(t);
|
|
418
|
+
continue;
|
|
419
|
+
}
|
|
420
|
+
let c = a.timeline(null, t, e.depth_before, e.depth_after, r), l = c.find((e) => e.id === t);
|
|
421
|
+
if (!l) {
|
|
422
|
+
m.push(t);
|
|
423
|
+
continue;
|
|
424
|
+
}
|
|
425
|
+
g.push(l);
|
|
426
|
+
for (let e of c) {
|
|
427
|
+
let t = e.id;
|
|
428
|
+
t <= 0 || v.has(t) || (v.add(t), _.push(e));
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
u.length > 0 && l.push({
|
|
432
|
+
code: "NOT_FOUND",
|
|
433
|
+
field: "ids",
|
|
434
|
+
message: "some requested ids were not found",
|
|
435
|
+
ids: u
|
|
436
|
+
}), p.length > 0 && l.push({
|
|
437
|
+
code: "PROJECT_MISMATCH",
|
|
438
|
+
field: "project",
|
|
439
|
+
message: "some requested ids are outside the requested project scope",
|
|
440
|
+
ids: p
|
|
441
|
+
}), m.length > 0 && l.push({
|
|
442
|
+
code: "FILTER_MISMATCH",
|
|
443
|
+
field: "filters",
|
|
444
|
+
message: "some requested ids are outside the requested filters",
|
|
445
|
+
ids: m
|
|
446
|
+
});
|
|
447
|
+
let b = [];
|
|
448
|
+
if (e.include_observations) {
|
|
449
|
+
let e = /* @__PURE__ */ new Set(), t = [];
|
|
450
|
+
for (let n of [...g, ..._]) n.id > 0 && !e.has(n.id) && (e.add(n.id), t.push(n.id));
|
|
451
|
+
b = h(a, t, r);
|
|
452
|
+
}
|
|
453
|
+
return f({
|
|
454
|
+
anchors: g,
|
|
455
|
+
timeline: _,
|
|
456
|
+
observations: b,
|
|
457
|
+
missing_ids: s.filter((e) => u.includes(e) || p.includes(e) || m.includes(e)),
|
|
458
|
+
errors: l,
|
|
459
|
+
metadata: {
|
|
460
|
+
project: o,
|
|
461
|
+
requested_ids_count: s.length,
|
|
462
|
+
returned_anchor_count: g.length,
|
|
463
|
+
timeline_count: _.length,
|
|
464
|
+
include_observations: e.include_observations
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
} catch (e) {
|
|
468
|
+
return p(e instanceof Error ? e.message : String(e));
|
|
469
|
+
}
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
//#endregion
|
|
473
|
+
//#region src/server.ts
|
|
474
|
+
function O(t, n = {}) {
|
|
475
|
+
let r = new o({
|
|
476
|
+
name: "codemem",
|
|
477
|
+
version: e
|
|
478
|
+
}), i = {
|
|
479
|
+
store: t,
|
|
480
|
+
defaultProject: () => n.resolveDefaultProject ? n.resolveDefaultProject() : n.defaultProject === void 0 ? l() : n.defaultProject,
|
|
481
|
+
envProject: () => n.envProject === void 0 ? process.env.CODEMEM_PROJECT ?? null : n.envProject
|
|
482
|
+
};
|
|
483
|
+
return E(r, i), D(r, i), S(r, i), T(r), C(r), r;
|
|
484
|
+
}
|
|
485
|
+
//#endregion
|
|
486
|
+
export { O as t };
|
|
487
|
+
|
|
488
|
+
//# sourceMappingURL=server-Djvf0Yik.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-Djvf0Yik.js","names":[],"sources":["../src/project-scope.ts","../src/content.ts","../src/memory-access.ts","../src/schemas.ts","../src/tools/items.ts","../src/tools/learn.ts","../src/memory-kinds.ts","../src/tools/schema.ts","../src/tools/search.ts","../src/tools/timeline.ts","../src/server.ts"],"sourcesContent":["import { type MemoryFilters, resolveProject } from \"@codemem/core\";\n\nfunction cleanProject(value: string | null | undefined): string | null {\n\tconst trimmed = value?.trim();\n\treturn trimmed ? trimmed : null;\n}\n\nexport function resolveDefaultProject(): string | null {\n\treturn cleanProject(process.env.CODEMEM_PROJECT) ?? resolveProject(process.cwd());\n}\n\nexport function resolveWriteProject(input: {\n\tproject?: string | null;\n\tenvProject?: string | null;\n}): string | null {\n\treturn cleanProject(input.project) ?? cleanProject(input.envProject) ?? null;\n}\n\nexport function buildFilters(\n\traw: Record<string, unknown>,\n\tdefaultProject = resolveDefaultProject(),\n): MemoryFilters | undefined {\n\tconst filters: MemoryFilters = {};\n\tlet hasAny = false;\n\n\tconst explicitProject = typeof raw.project === \"string\" ? cleanProject(raw.project) : undefined;\n\tconst resolvedProject = explicitProject || cleanProject(defaultProject) || undefined;\n\tif (resolvedProject) {\n\t\tfilters.project = resolvedProject;\n\t\thasAny = true;\n\t}\n\n\tfor (const key of [\n\t\t\"kind\",\n\t\t\"visibility\",\n\t\t\"scope_id\",\n\t\t\"include_scope_ids\",\n\t\t\"exclude_scope_ids\",\n\t\t\"include_visibility\",\n\t\t\"exclude_visibility\",\n\t\t\"include_workspace_ids\",\n\t\t\"exclude_workspace_ids\",\n\t\t\"include_workspace_kinds\",\n\t\t\"exclude_workspace_kinds\",\n\t\t\"include_actor_ids\",\n\t\t\"exclude_actor_ids\",\n\t\t\"include_trust_states\",\n\t\t\"exclude_trust_states\",\n\t\t\"ownership_scope\",\n\t\t\"personal_first\",\n\t\t\"trust_bias\",\n\t\t\"widen_shared_when_weak\",\n\t\t\"widen_shared_min_personal_results\",\n\t\t\"widen_shared_min_personal_score\",\n\t] as const) {\n\t\tconst val = raw[key];\n\t\tif (val !== undefined && val !== null) {\n\t\t\t(filters as Record<string, unknown>)[key] = val;\n\t\t\thasAny = true;\n\t\t}\n\t}\n\n\treturn hasAny ? filters : undefined;\n}\n","export function jsonContent(data: unknown) {\n\treturn { content: [{ type: \"text\" as const, text: JSON.stringify(data) }] };\n}\n\nexport function errorContent(message: string) {\n\treturn { content: [{ type: \"text\" as const, text: JSON.stringify({ error: message }) }] };\n}\n","import {\n\ttype MemoryFilters,\n\ttype MemoryItemResponse,\n\ttype MemoryStore,\n\ttoJson,\n} from \"@codemem/core\";\nimport { resolveWriteProject } from \"./project-scope.js\";\n\nexport function getMemoryForMcp(\n\tstore: MemoryStore,\n\tmemoryId: number,\n\tfilters?: MemoryFilters,\n): MemoryItemResponse | null {\n\tconst rows = store.timeline(null, memoryId, 0, 0, filters ?? null);\n\treturn rows.find((row) => row.id === memoryId) ?? null;\n}\n\nexport function getManyForMcp(\n\tstore: MemoryStore,\n\tids: number[],\n\tfilters?: MemoryFilters,\n): MemoryItemResponse[] {\n\tif (ids.length === 0) return [];\n\tconst results: MemoryItemResponse[] = [];\n\tfor (const id of ids) {\n\t\tconst item = getMemoryForMcp(store, id, filters);\n\t\tif (item) results.push(item);\n\t}\n\treturn results;\n}\n\nexport function forgetMemoryForMcp(\n\tstore: MemoryStore,\n\tmemoryId: number,\n\tfilters?: MemoryFilters,\n): boolean {\n\tconst item = getMemoryForMcp(store, memoryId, filters);\n\tif (!item) return false;\n\tstore.forget(memoryId);\n\treturn true;\n}\n\nexport interface RememberMemoryForMcpInput {\n\tkind: string;\n\ttitle: string;\n\tbody: string;\n\tconfidence: number;\n\tproject?: string | null;\n}\n\nexport interface RememberMemoryForMcpContext {\n\tcwd?: string;\n\tuser?: string;\n\tenvProject?: string | null;\n\tnow?: () => string;\n}\n\nexport function rememberMemoryForMcp(\n\tstore: MemoryStore,\n\tinput: RememberMemoryForMcpInput,\n\tcontext: RememberMemoryForMcpContext = {},\n): { memId: number; title: string; body: string } {\n\treturn store.db.transaction(() => {\n\t\tconst now = context.now?.() ?? new Date().toISOString();\n\t\tconst user = context.user ?? process.env.USER ?? \"unknown\";\n\t\tconst cwd = context.cwd ?? process.cwd();\n\t\tconst project = resolveWriteProject({\n\t\t\tproject: input.project,\n\t\t\tenvProject: context.envProject,\n\t\t});\n\n\t\tconst sessionInfo = store.db\n\t\t\t.prepare(\n\t\t\t\t`INSERT INTO sessions(started_at, ended_at, cwd, project, user, tool_version, metadata_json)\n\t\t\t\t VALUES (?, ?, ?, ?, ?, ?, ?)`,\n\t\t\t)\n\t\t\t.run(now, now, cwd, project, user, \"mcp-ts\", toJson({ mcp: true }));\n\t\tconst sessionId = Number(sessionInfo.lastInsertRowid);\n\n\t\tconst memId = store.remember(sessionId, input.kind, input.title, input.body, input.confidence);\n\t\tif (!getMemoryForMcp(store, memId)) {\n\t\t\tthrow new Error(\"unauthorized_scope\");\n\t\t}\n\n\t\tstore.db\n\t\t\t.prepare(\"UPDATE sessions SET ended_at = ?, metadata_json = ? WHERE id = ?\")\n\t\t\t.run(context.now?.() ?? new Date().toISOString(), toJson({ mcp: true }), sessionId);\n\n\t\treturn { memId, title: input.title, body: input.body };\n\t})();\n}\n","import { z } from \"zod\";\n\nconst scopeFilterSchema = {\n\tscope_id: z.string().optional().describe(\"Filter by a single sharing domain scope_id\"),\n\tinclude_scope_ids: z.array(z.string()).optional().describe(\"Sharing domain scope_ids to include\"),\n\texclude_scope_ids: z.array(z.string()).optional().describe(\"Sharing domain scope_ids to exclude\"),\n};\n\nexport const filterSchema = {\n\tkind: z.string().optional().describe(\"Filter by memory kind\"),\n\tproject: z.string().optional().describe(\"Filter by project scope (matches sessions.project)\"),\n\t...scopeFilterSchema,\n\tvisibility: z.array(z.string()).optional(),\n\tinclude_visibility: z.array(z.string()).optional(),\n\texclude_visibility: z.array(z.string()).optional(),\n\tinclude_workspace_ids: z.array(z.string()).optional(),\n\texclude_workspace_ids: z.array(z.string()).optional(),\n\tinclude_workspace_kinds: z.array(z.string()).optional(),\n\texclude_workspace_kinds: z.array(z.string()).optional(),\n\tinclude_actor_ids: z.array(z.string()).optional(),\n\texclude_actor_ids: z.array(z.string()).optional(),\n\tinclude_trust_states: z.array(z.string()).optional(),\n\texclude_trust_states: z.array(z.string()).optional(),\n\townership_scope: z.string().optional(),\n\tpersonal_first: z.union([z.boolean(), z.string()]).optional(),\n\ttrust_bias: z.string().optional(),\n\twiden_shared_when_weak: z.union([z.boolean(), z.string()]).optional(),\n\twiden_shared_min_personal_results: z.number().int().optional(),\n\twiden_shared_min_personal_score: z.number().optional(),\n};\n\nexport const memoryKindSchema = z.enum([\n\t\"discovery\",\n\t\"change\",\n\t\"feature\",\n\t\"bugfix\",\n\t\"refactor\",\n\t\"decision\",\n\t\"exploration\",\n]);\n\nexport const filterNames = Object.keys(filterSchema).toSorted();\n","import { storeVectors } from \"@codemem/core\";\nimport type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\nimport { errorContent, jsonContent } from \"../content.js\";\nimport {\n\tforgetMemoryForMcp,\n\tgetManyForMcp,\n\tgetMemoryForMcp,\n\trememberMemoryForMcp,\n} from \"../memory-access.js\";\nimport { buildFilters } from \"../project-scope.js\";\nimport { filterSchema, memoryKindSchema } from \"../schemas.js\";\nimport type { ToolRegistrationContext } from \"../tool-context.js\";\n\nexport function registerItemTools(server: McpServer, context: ToolRegistrationContext): void {\n\tconst { envProject, store } = context;\n\n\tserver.tool(\n\t\t\"memory_get\",\n\t\t\"Fetch a single memory item by ID.\",\n\t\t{\n\t\t\tmemory_id: z.number().int().describe(\"Memory ID\"),\n\t\t\t...filterSchema,\n\t\t},\n\t\tasync (args) => {\n\t\t\ttry {\n\t\t\t\t// Direct-ID ops do not inherit the server default project. Callers already\n\t\t\t\t// have an exact ID; cwd/env should not silently scope the lookup.\n\t\t\t\tconst item = getMemoryForMcp(store, args.memory_id, buildFilters(args, null));\n\t\t\t\tif (!item) return errorContent(\"not_found\");\n\t\t\t\treturn jsonContent(item);\n\t\t\t} catch (err) {\n\t\t\t\treturn errorContent(err instanceof Error ? err.message : String(err));\n\t\t\t}\n\t\t},\n\t);\n\n\tserver.tool(\n\t\t\"memory_get_observations\",\n\t\t\"Fetch multiple memory items by their IDs.\",\n\t\t{\n\t\t\tids: z.array(z.number().int()).max(200).describe(\"Memory IDs to fetch\"),\n\t\t\t...filterSchema,\n\t\t},\n\t\tasync (args) => {\n\t\t\ttry {\n\t\t\t\tconst items = getManyForMcp(store, args.ids, buildFilters(args, null));\n\t\t\t\treturn jsonContent({ items });\n\t\t\t} catch (err) {\n\t\t\t\treturn errorContent(err instanceof Error ? err.message : String(err));\n\t\t\t}\n\t\t},\n\t);\n\n\tserver.tool(\n\t\t\"memory_remember\",\n\t\t\"Create a new memory. Use for milestones, decisions, and notable facts.\",\n\t\t{\n\t\t\tkind: memoryKindSchema.describe(\"Memory kind\"),\n\t\t\ttitle: z.string().describe(\"Short title\"),\n\t\t\tbody: z.string().describe(\"Body text (high-signal content)\"),\n\t\t\tconfidence: z.number().min(0).max(1).default(0.5).describe(\"Confidence 0-1\"),\n\t\t\tproject: z.string().optional().describe(\"Project identifier\"),\n\t\t},\n\t\tasync (args) => {\n\t\t\ttry {\n\t\t\t\t// Writes never inherit the server default project. They only honor an\n\t\t\t\t// explicit `project` input or CODEMEM_PROJECT; otherwise project stays null.\n\t\t\t\tconst result = rememberMemoryForMcp(store, args, {\n\t\t\t\t\tenvProject: envProject(),\n\t\t\t\t});\n\n\t\t\t\ttry {\n\t\t\t\t\tawait storeVectors(store.db, result.memId, result.title, result.body);\n\t\t\t\t} catch {\n\t\t\t\t\t// Memory writes should succeed even if embeddings are unavailable.\n\t\t\t\t}\n\n\t\t\t\treturn jsonContent({ id: result.memId });\n\t\t\t} catch (err) {\n\t\t\t\treturn errorContent(err instanceof Error ? err.message : String(err));\n\t\t\t}\n\t\t},\n\t);\n\n\tserver.tool(\n\t\t\"memory_forget\",\n\t\t\"Soft-delete a memory item. Use for incorrect or sensitive data.\",\n\t\t{\n\t\t\tmemory_id: z.number().int().describe(\"Memory ID to forget\"),\n\t\t\t...filterSchema,\n\t\t},\n\t\tasync (args) => {\n\t\t\ttry {\n\t\t\t\tif (!forgetMemoryForMcp(store, args.memory_id, buildFilters(args, null))) {\n\t\t\t\t\treturn errorContent(\"not_found\");\n\t\t\t\t}\n\t\t\t\treturn jsonContent({ status: \"ok\" });\n\t\t\t} catch (err) {\n\t\t\t\treturn errorContent(err instanceof Error ? err.message : String(err));\n\t\t\t}\n\t\t},\n\t);\n}\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { jsonContent } from \"../content.js\";\n\nexport function registerLearnTools(server: McpServer): void {\n\tserver.tool(\n\t\t\"memory_learn\",\n\t\t\"Learn how to use codemem memory tools. Call this first if unfamiliar.\",\n\t\t{},\n\t\tasync () => {\n\t\t\treturn jsonContent({\n\t\t\t\tintro: \"Use this tool when you're new to codemem or unsure when to recall/persist.\",\n\t\t\t\tclient_hint: \"If you are unfamiliar with codemem, call memory.learn first.\",\n\t\t\t\trecall: {\n\t\t\t\t\twhen: [\n\t\t\t\t\t\t\"Start of a task or when the user references prior work.\",\n\t\t\t\t\t\t\"When you need background context, decisions, or recent changes.\",\n\t\t\t\t\t],\n\t\t\t\t\thow: [\n\t\t\t\t\t\t\"Use memory.search_index to get compact candidates.\",\n\t\t\t\t\t\t\"Use memory.timeline to expand around a promising memory.\",\n\t\t\t\t\t\t\"Use memory.get_observations for full details only when needed.\",\n\t\t\t\t\t\t\"Use memory.pack for quick one-shot context blocks.\",\n\t\t\t\t\t\t\"Use the project filter unless the user requests cross-project context.\",\n\t\t\t\t\t],\n\t\t\t\t\texamples: [\n\t\t\t\t\t\t'memory.search_index(\"billing cache bug\", limit=5)',\n\t\t\t\t\t\t\"memory.timeline(memory_id=123)\",\n\t\t\t\t\t\t\"memory.get_observations([123, 456])\",\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\tpersistence: {\n\t\t\t\t\twhen: [\n\t\t\t\t\t\t\"Milestones (task done, key decision, new facts learned).\",\n\t\t\t\t\t\t\"Notable regressions or follow-ups that should be remembered.\",\n\t\t\t\t\t],\n\t\t\t\t\thow: [\n\t\t\t\t\t\t\"Use memory.remember with kind decision/discovery/change/exploration.\",\n\t\t\t\t\t\t\"Keep titles short and bodies high-signal.\",\n\t\t\t\t\t\t\"ALWAYS pass the project parameter if known.\",\n\t\t\t\t\t],\n\t\t\t\t\texamples: [\n\t\t\t\t\t\t'memory.remember(kind=\"decision\", title=\"Switch to async cache\", body=\"...why...\", project=\"my-service\")',\n\t\t\t\t\t\t'memory.remember(kind=\"change\", title=\"Fixed retry loop\", body=\"...impact...\", project=\"my-service\")',\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\tforget: {\n\t\t\t\t\twhen: [\n\t\t\t\t\t\t\"Accidental or sensitive data stored in memory items.\",\n\t\t\t\t\t\t\"Obsolete or incorrect items that should no longer surface.\",\n\t\t\t\t\t],\n\t\t\t\t\thow: [\n\t\t\t\t\t\t\"Call memory.forget(id) to mark the item inactive.\",\n\t\t\t\t\t\t\"Prefer forgetting over overwriting to preserve auditability.\",\n\t\t\t\t\t],\n\t\t\t\t\texamples: [\"memory.forget(123)\"],\n\t\t\t\t},\n\t\t\t\tprompt_hint:\n\t\t\t\t\t\"At task start: call memory.search_index; during work: memory.timeline + memory.get_observations; at milestones: memory.remember.\",\n\t\t\t\trecommended_system_prompt: [\n\t\t\t\t\t\"Trigger policy (1-liner): If the user references prior work or starts a task,\",\n\t\t\t\t\t\"immediately call memory.search_index; then use memory.timeline + memory.get_observations;\",\n\t\t\t\t\t\"at milestones, call memory.remember; use memory.forget for incorrect/sensitive items.\",\n\t\t\t\t\t\"\",\n\t\t\t\t\t\"System prompt:\",\n\t\t\t\t\t\"You have access to codemem MCP tools. If unfamiliar, call memory.learn first.\",\n\t\t\t\t\t\"\",\n\t\t\t\t\t\"Recall:\",\n\t\t\t\t\t\"- Start of any task: call memory.search_index with a concise task query.\",\n\t\t\t\t\t'- If prior work is referenced (\"as before\", \"last time\", \"we already did…\", \"regression\"),',\n\t\t\t\t\t\" call memory.search_index or memory.timeline.\",\n\t\t\t\t\t\"- Use memory.get_observations only after filtering IDs.\",\n\t\t\t\t\t\"- Prefer project-scoped queries unless the user asks for cross-project.\",\n\t\t\t\t\t\"\",\n\t\t\t\t\t\"Persistence:\",\n\t\t\t\t\t\"- On milestones (task done, key decision, new facts learned), call memory.remember.\",\n\t\t\t\t\t\"- Use kind=decision for tradeoffs, kind=change for outcomes, kind=discovery/exploration for useful findings.\",\n\t\t\t\t\t\"- Keep titles short and bodies high-signal.\",\n\t\t\t\t\t\"- ALWAYS pass the project parameter if known.\",\n\t\t\t\t\t\"\",\n\t\t\t\t\t\"Safety:\",\n\t\t\t\t\t\"- Use memory.forget(id) for incorrect or sensitive items.\",\n\t\t\t\t\t\"\",\n\t\t\t\t\t\"Examples:\",\n\t\t\t\t\t'- memory.search_index(\"billing cache bug\")',\n\t\t\t\t\t\"- memory.timeline(memory_id=123)\",\n\t\t\t\t\t\"- memory.get_observations([123, 456])\",\n\t\t\t\t\t'- memory.remember(kind=\"decision\", title=\"Use async cache\", body=\"Chose async cache to avoid lock contention in X.\", project=\"my-service\")',\n\t\t\t\t\t'- memory.remember(kind=\"change\", title=\"Fixed retry loop\", body=\"Root cause was Y; added guard in Z.\", project=\"my-service\")',\n\t\t\t\t\t\"- memory.forget(123)\",\n\t\t\t\t].join(\"\\n\"),\n\t\t\t});\n\t\t},\n\t);\n}\n","export const MEMORY_KINDS: Record<string, string> = {\n\tdiscovery: \"Something learned about the codebase, architecture, or tools\",\n\tchange: \"A code change that was made\",\n\tfeature: \"A new feature that was implemented\",\n\tbugfix: \"A bug that was found and fixed\",\n\trefactor: \"Code that was refactored or restructured\",\n\tdecision: \"A design or architecture decision\",\n\texploration: \"An experiment or investigation (may not have shipped)\",\n};\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { jsonContent } from \"../content.js\";\nimport { MEMORY_KINDS } from \"../memory-kinds.js\";\nimport { filterNames } from \"../schemas.js\";\n\nexport function registerSchemaTools(server: McpServer): void {\n\tserver.tool(\n\t\t\"memory_schema\",\n\t\t\"Return the memory schema — kinds, fields, and available filters.\",\n\t\t{},\n\t\tasync () => {\n\t\t\treturn jsonContent({\n\t\t\t\tkinds: Object.keys(MEMORY_KINDS),\n\t\t\t\tkind_descriptions: MEMORY_KINDS,\n\t\t\t\tfields: {\n\t\t\t\t\ttitle: \"short text\",\n\t\t\t\t\tbody: \"long text\",\n\t\t\t\t\tsubtitle: \"short text\",\n\t\t\t\t\tfacts: \"list<string>\",\n\t\t\t\t\tnarrative: \"long text\",\n\t\t\t\t\tconcepts: \"list<string>\",\n\t\t\t\t\tfiles_read: \"list<string>\",\n\t\t\t\t\tfiles_modified: \"list<string>\",\n\t\t\t\t\tprompt_number: \"int\",\n\t\t\t\t},\n\t\t\t\tfilters: filterNames,\n\t\t\t});\n\t\t},\n\t);\n}\n","import type { MemoryResult } from \"@codemem/core\";\nimport type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\nimport { errorContent, jsonContent } from \"../content.js\";\nimport { buildFilters } from \"../project-scope.js\";\nimport { filterSchema } from \"../schemas.js\";\nimport type { ToolRegistrationContext } from \"../tool-context.js\";\n\nexport function registerSearchTools(server: McpServer, context: ToolRegistrationContext): void {\n\tconst { defaultProject, store } = context;\n\n\tserver.tool(\n\t\t\"memory_search\",\n\t\t\"Search memories by text query. Returns full body text for each match.\",\n\t\t{\n\t\t\tquery: z.string().describe(\"Search query\"),\n\t\t\tlimit: z.number().int().min(1).max(50).default(5).describe(\"Max results\"),\n\t\t\t...filterSchema,\n\t\t},\n\t\tasync (args) => {\n\t\t\ttry {\n\t\t\t\tconst filters = buildFilters(args, defaultProject());\n\t\t\t\tconst items = store.search(args.query, args.limit, filters);\n\t\t\t\treturn jsonContent({\n\t\t\t\t\titems: items.map((m: MemoryResult) => ({\n\t\t\t\t\t\tid: m.id,\n\t\t\t\t\t\ttitle: m.title,\n\t\t\t\t\t\tkind: m.kind,\n\t\t\t\t\t\tbody: m.body_text,\n\t\t\t\t\t\tconfidence: m.confidence,\n\t\t\t\t\t\tscore: m.score,\n\t\t\t\t\t\tsession_id: m.session_id,\n\t\t\t\t\t\tmetadata: m.metadata,\n\t\t\t\t\t})),\n\t\t\t\t});\n\t\t\t} catch (err) {\n\t\t\t\treturn errorContent(err instanceof Error ? err.message : String(err));\n\t\t\t}\n\t\t},\n\t);\n\n\tserver.tool(\n\t\t\"memory_search_index\",\n\t\t\"Search memories by text query. Returns compact index entries (no body) for browsing.\",\n\t\t{\n\t\t\tquery: z.string().describe(\"Search query\"),\n\t\t\tlimit: z.number().int().min(1).max(50).default(8).describe(\"Max results\"),\n\t\t\t...filterSchema,\n\t\t},\n\t\tasync (args) => {\n\t\t\ttry {\n\t\t\t\tconst filters = buildFilters(args, defaultProject());\n\t\t\t\tconst items = store.search(args.query, args.limit, filters);\n\t\t\t\treturn jsonContent({\n\t\t\t\t\titems: items.map((m: MemoryResult) => ({\n\t\t\t\t\t\tid: m.id,\n\t\t\t\t\t\tkind: m.kind,\n\t\t\t\t\t\ttitle: m.title,\n\t\t\t\t\t\tscore: m.score,\n\t\t\t\t\t\tcreated_at: m.created_at,\n\t\t\t\t\t\tsession_id: m.session_id,\n\t\t\t\t\t\tmetadata: m.metadata,\n\t\t\t\t\t})),\n\t\t\t\t});\n\t\t\t} catch (err) {\n\t\t\t\treturn errorContent(err instanceof Error ? err.message : String(err));\n\t\t\t}\n\t\t},\n\t);\n\n\tserver.tool(\n\t\t\"memory_explain\",\n\t\t\"Explain search results with detailed scoring breakdown.\",\n\t\t{\n\t\t\tquery: z.string().optional().describe(\"Search query\"),\n\t\t\tids: z.array(z.number().int()).max(200).optional().describe(\"Specific memory IDs to explain\"),\n\t\t\tlimit: z.number().int().min(1).max(50).default(10).describe(\"Max results\"),\n\t\t\tinclude_pack_context: z.boolean().default(false).describe(\"Include formatted pack context\"),\n\t\t\t...filterSchema,\n\t\t},\n\t\tasync (args) => {\n\t\t\ttry {\n\t\t\t\tconst filters = buildFilters(args, defaultProject());\n\t\t\t\tconst result = store.explain(args.query ?? null, args.ids ?? null, args.limit, filters, {\n\t\t\t\t\tincludePackContext: args.include_pack_context,\n\t\t\t\t});\n\t\t\t\treturn jsonContent(result);\n\t\t\t} catch (err) {\n\t\t\t\treturn errorContent(err instanceof Error ? err.message : String(err));\n\t\t\t}\n\t\t},\n\t);\n\n\tserver.tool(\n\t\t\"memory_recent\",\n\t\t\"Return recent memories, newest first.\",\n\t\t{\n\t\t\tlimit: z.number().int().min(1).max(100).default(8).describe(\"Max results\"),\n\t\t\t...filterSchema,\n\t\t},\n\t\tasync (args) => {\n\t\t\ttry {\n\t\t\t\tconst filters = buildFilters(args, defaultProject());\n\t\t\t\tconst items = store.recent(args.limit, filters);\n\t\t\t\treturn jsonContent({ items });\n\t\t\t} catch (err) {\n\t\t\t\treturn errorContent(err instanceof Error ? err.message : String(err));\n\t\t\t}\n\t\t},\n\t);\n\n\tserver.tool(\n\t\t\"memory_pack\",\n\t\t\"Build a formatted memory pack from search results — quick one-shot context block.\",\n\t\t{\n\t\t\tcontext: z.string().describe(\"Context description to search for\"),\n\t\t\tlimit: z.number().int().min(1).max(50).optional().describe(\"Max items to include\"),\n\t\t\tcompact: z\n\t\t\t\t.boolean()\n\t\t\t\t.optional()\n\t\t\t\t.describe(\n\t\t\t\t\t\"When true, render a scannable index of all items with full detail only for the top N (default 3). Saves tokens when broad overview matters more than per-item detail.\",\n\t\t\t\t),\n\t\t\tcompact_detail_count: z\n\t\t\t\t.number()\n\t\t\t\t.int()\n\t\t\t\t.min(0)\n\t\t\t\t.max(50)\n\t\t\t\t.optional()\n\t\t\t\t.describe(\"Number of items to show in full detail in compact mode (default 3)\"),\n\t\t\tcompression_mode: z\n\t\t\t\t.enum([\"off\", \"compact\", \"ids\"])\n\t\t\t\t.optional()\n\t\t\t\t.describe(\n\t\t\t\t\t\"Near-related compression mode: off disables it, compact applies only to compact rendering, ids applies in all modes. Defaults to CODEMEM_PACK_COMPRESSION or compact.\",\n\t\t\t\t),\n\t\t\t...filterSchema,\n\t\t},\n\t\tasync (args) => {\n\t\t\ttry {\n\t\t\t\tconst filters = buildFilters(args, defaultProject());\n\t\t\t\tconst renderOptions =\n\t\t\t\t\targs.compact || args.compact_detail_count != null || args.compression_mode != null\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tcompact: args.compact ?? (args.compact_detail_count != null ? true : undefined),\n\t\t\t\t\t\t\t\tcompactDetailCount: args.compact_detail_count,\n\t\t\t\t\t\t\t\tcompressionMode: args.compression_mode,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: undefined;\n\t\t\t\tconst result = await store.buildMemoryPackAsync(\n\t\t\t\t\targs.context,\n\t\t\t\t\targs.limit ?? undefined,\n\t\t\t\t\tnull,\n\t\t\t\t\tfilters,\n\t\t\t\t\trenderOptions,\n\t\t\t\t);\n\t\t\t\treturn jsonContent(result);\n\t\t\t} catch (err) {\n\t\t\t\treturn errorContent(err instanceof Error ? err.message : String(err));\n\t\t\t}\n\t\t},\n\t);\n}\n","import { dedupeOrderedIds, type MemoryItemResponse, projectMatchesFilter } from \"@codemem/core\";\nimport type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\nimport { errorContent, jsonContent } from \"../content.js\";\nimport { getManyForMcp } from \"../memory-access.js\";\nimport { buildFilters } from \"../project-scope.js\";\nimport { filterSchema } from \"../schemas.js\";\nimport type { ToolRegistrationContext } from \"../tool-context.js\";\n\nexport function registerTimelineTools(server: McpServer, context: ToolRegistrationContext): void {\n\tconst { defaultProject, store } = context;\n\n\tserver.tool(\n\t\t\"memory_timeline\",\n\t\t\"Get a chronological window of memories around an anchor (by ID or query).\",\n\t\t{\n\t\t\tquery: z.string().optional().describe(\"Search query to find anchor\"),\n\t\t\tmemory_id: z.number().int().optional().describe(\"Anchor memory ID\"),\n\t\t\tdepth_before: z.number().int().min(0).default(3).describe(\"Items before anchor\"),\n\t\t\tdepth_after: z.number().int().min(0).default(3).describe(\"Items after anchor\"),\n\t\t\t...filterSchema,\n\t\t},\n\t\tasync (args) => {\n\t\t\ttry {\n\t\t\t\tconst filters = buildFilters(args, defaultProject());\n\t\t\t\tconst items = store.timeline(\n\t\t\t\t\targs.query ?? null,\n\t\t\t\t\targs.memory_id ?? null,\n\t\t\t\t\targs.depth_before,\n\t\t\t\t\targs.depth_after,\n\t\t\t\t\tfilters,\n\t\t\t\t);\n\t\t\t\treturn jsonContent({ items });\n\t\t\t} catch (err) {\n\t\t\t\treturn errorContent(err instanceof Error ? err.message : String(err));\n\t\t\t}\n\t\t},\n\t);\n\n\tserver.tool(\n\t\t\"memory_expand\",\n\t\t\"Fetch memories by ID with surrounding timeline context.\",\n\t\t{\n\t\t\tids: z\n\t\t\t\t.array(z.union([z.number(), z.string()]))\n\t\t\t\t.max(200)\n\t\t\t\t.describe(\"Memory IDs to expand\"),\n\t\t\tdepth_before: z.number().int().min(0).default(3).describe(\"Timeline items before\"),\n\t\t\tdepth_after: z.number().int().min(0).default(3).describe(\"Timeline items after\"),\n\t\t\tinclude_observations: z.boolean().default(false).describe(\"Include full observation details\"),\n\t\t\t...filterSchema,\n\t\t},\n\t\tasync (args) => {\n\t\t\ttry {\n\t\t\t\t// Explicit blank `project` clears scoping for cross-project expansion.\n\t\t\t\t// Only fall back to the server default when `project` is omitted entirely.\n\t\t\t\tconst filterDefaultProject =\n\t\t\t\t\targs.project !== undefined && !args.project.trim() ? null : defaultProject();\n\t\t\t\tconst filters = buildFilters(args, filterDefaultProject);\n\t\t\t\tconst resolvedProject = filters?.project ?? null;\n\t\t\t\tconst { ordered: orderedIds, invalid: invalidIds } = dedupeOrderedIds(args.ids);\n\t\t\t\tconst errors: Array<Record<string, unknown>> = [];\n\n\t\t\t\tif (invalidIds.length > 0) {\n\t\t\t\t\terrors.push({\n\t\t\t\t\t\tcode: \"INVALID_ARGUMENT\",\n\t\t\t\t\t\tfield: \"ids\",\n\t\t\t\t\t\tmessage: \"some ids are not valid integers\",\n\t\t\t\t\t\tids: invalidIds,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tconst missingNotFound: number[] = [];\n\t\t\t\tconst missingProjectMismatch: number[] = [];\n\t\t\t\tconst missingFilterMismatch: number[] = [];\n\t\t\t\tconst anchors: MemoryItemResponse[] = [];\n\t\t\t\tconst timelineItems: MemoryItemResponse[] = [];\n\t\t\t\tconst timelineSeen = new Set<number>();\n\t\t\t\tconst sessionProjects = new Map<number, string | null>();\n\n\t\t\t\tfor (const memoryId of orderedIds) {\n\t\t\t\t\tconst item = store.get(memoryId);\n\t\t\t\t\tif (!item?.active) {\n\t\t\t\t\t\tmissingNotFound.push(memoryId);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst sessionId = item.session_id;\n\t\t\t\t\tif (resolvedProject && sessionId > 0) {\n\t\t\t\t\t\tif (!sessionProjects.has(sessionId)) {\n\t\t\t\t\t\t\tconst row = store.db\n\t\t\t\t\t\t\t\t.prepare(\"SELECT project FROM sessions WHERE id = ? LIMIT 1\")\n\t\t\t\t\t\t\t\t.get(sessionId) as { project: string | null } | undefined;\n\t\t\t\t\t\t\tsessionProjects.set(sessionId, typeof row?.project === \"string\" ? row.project : null);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!projectMatchesFilter(resolvedProject, sessionProjects.get(sessionId) ?? null)) {\n\t\t\t\t\t\t\tmissingProjectMismatch.push(memoryId);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (resolvedProject && sessionId <= 0) {\n\t\t\t\t\t\tmissingProjectMismatch.push(memoryId);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst expanded = store.timeline(\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\tmemoryId,\n\t\t\t\t\t\targs.depth_before,\n\t\t\t\t\t\targs.depth_after,\n\t\t\t\t\t\tfilters,\n\t\t\t\t\t);\n\t\t\t\t\tconst anchor = expanded.find((expandedItem) => expandedItem.id === memoryId);\n\t\t\t\t\tif (!anchor) {\n\t\t\t\t\t\tmissingFilterMismatch.push(memoryId);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tanchors.push(anchor);\n\t\t\t\t\tfor (const expandedItem of expanded) {\n\t\t\t\t\t\tconst expandedId = expandedItem.id;\n\t\t\t\t\t\tif (expandedId <= 0 || timelineSeen.has(expandedId)) continue;\n\t\t\t\t\t\ttimelineSeen.add(expandedId);\n\t\t\t\t\t\ttimelineItems.push(expandedItem);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (missingNotFound.length > 0) {\n\t\t\t\t\terrors.push({\n\t\t\t\t\t\tcode: \"NOT_FOUND\",\n\t\t\t\t\t\tfield: \"ids\",\n\t\t\t\t\t\tmessage: \"some requested ids were not found\",\n\t\t\t\t\t\tids: missingNotFound,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (missingProjectMismatch.length > 0) {\n\t\t\t\t\terrors.push({\n\t\t\t\t\t\tcode: \"PROJECT_MISMATCH\",\n\t\t\t\t\t\tfield: \"project\",\n\t\t\t\t\t\tmessage: \"some requested ids are outside the requested project scope\",\n\t\t\t\t\t\tids: missingProjectMismatch,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (missingFilterMismatch.length > 0) {\n\t\t\t\t\terrors.push({\n\t\t\t\t\t\tcode: \"FILTER_MISMATCH\",\n\t\t\t\t\t\tfield: \"filters\",\n\t\t\t\t\t\tmessage: \"some requested ids are outside the requested filters\",\n\t\t\t\t\t\tids: missingFilterMismatch,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tlet observations: MemoryItemResponse[] = [];\n\t\t\t\tif (args.include_observations) {\n\t\t\t\t\tconst observationSeen = new Set<number>();\n\t\t\t\t\tconst observationIds: number[] = [];\n\t\t\t\t\tfor (const item of [...anchors, ...timelineItems]) {\n\t\t\t\t\t\tif (item.id > 0 && !observationSeen.has(item.id)) {\n\t\t\t\t\t\t\tobservationSeen.add(item.id);\n\t\t\t\t\t\t\tobservationIds.push(item.id);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tobservations = getManyForMcp(store, observationIds, filters);\n\t\t\t\t}\n\n\t\t\t\treturn jsonContent({\n\t\t\t\t\tanchors,\n\t\t\t\t\ttimeline: timelineItems,\n\t\t\t\t\tobservations,\n\t\t\t\t\tmissing_ids: orderedIds.filter(\n\t\t\t\t\t\t(memoryId: number) =>\n\t\t\t\t\t\t\tmissingNotFound.includes(memoryId) ||\n\t\t\t\t\t\t\tmissingProjectMismatch.includes(memoryId) ||\n\t\t\t\t\t\t\tmissingFilterMismatch.includes(memoryId),\n\t\t\t\t\t),\n\t\t\t\t\terrors,\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\tproject: resolvedProject,\n\t\t\t\t\t\trequested_ids_count: orderedIds.length,\n\t\t\t\t\t\treturned_anchor_count: anchors.length,\n\t\t\t\t\t\ttimeline_count: timelineItems.length,\n\t\t\t\t\t\tinclude_observations: args.include_observations,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t} catch (err) {\n\t\t\t\treturn errorContent(err instanceof Error ? err.message : String(err));\n\t\t\t}\n\t\t},\n\t);\n}\n","import { type MemoryStore, VERSION } from \"@codemem/core\";\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { resolveDefaultProject } from \"./project-scope.js\";\nimport type { CodememMcpServerOptions, ToolRegistrationContext } from \"./tool-context.js\";\nimport { registerItemTools } from \"./tools/items.js\";\nimport { registerLearnTools } from \"./tools/learn.js\";\nimport { registerSchemaTools } from \"./tools/schema.js\";\nimport { registerSearchTools } from \"./tools/search.js\";\nimport { registerTimelineTools } from \"./tools/timeline.js\";\n\nexport function createCodememMcpServer(\n\tstore: MemoryStore,\n\toptions: CodememMcpServerOptions = {},\n): McpServer {\n\tconst server = new McpServer({ name: \"codemem\", version: VERSION });\n\tconst context: ToolRegistrationContext = {\n\t\tstore,\n\t\t// Resolve lazily per call so long-running servers pick up the current\n\t\t// CODEMEM_PROJECT / process.cwd() rather than the value at construction.\n\t\tdefaultProject: () => {\n\t\t\tif (options.resolveDefaultProject) return options.resolveDefaultProject();\n\t\t\tif (options.defaultProject !== undefined) return options.defaultProject;\n\t\t\treturn resolveDefaultProject();\n\t\t},\n\t\tenvProject: () =>\n\t\t\toptions.envProject !== undefined ? options.envProject : (process.env.CODEMEM_PROJECT ?? null),\n\t};\n\n\tregisterSearchTools(server, context);\n\tregisterTimelineTools(server, context);\n\tregisterItemTools(server, context);\n\tregisterSchemaTools(server);\n\tregisterLearnTools(server);\n\n\treturn server;\n}\n"],"mappings":";;;;AAEA,SAAS,EAAa,GAAiD;AAEtE,QADgB,GAAO,MAAM,IACF;;AAG5B,SAAgB,IAAuC;AACtD,QAAO,EAAa,QAAQ,IAAI,gBAAgB,IAAI,EAAe,QAAQ,KAAK,CAAC;;AAGlF,SAAgB,EAAoB,GAGlB;AACjB,QAAO,EAAa,EAAM,QAAQ,IAAI,EAAa,EAAM,WAAW,IAAI;;AAGzE,SAAgB,EACf,GACA,IAAiB,GAAuB,EACZ;CAC5B,IAAM,IAAyB,EAAE,EAC7B,IAAS,IAGP,KADkB,OAAO,EAAI,WAAY,WAAW,EAAa,EAAI,QAAQ,GAAG,KAAA,MAC3C,EAAa,EAAe,IAAI,KAAA;AAC3E,CAAI,MACH,EAAQ,UAAU,GA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AAa,aAAe,QAAQ,EAAI,UAAU,OAAO,EAAI,CAAC;;GAGvE;;;;ACnGF,SAAgB,EAAmB,GAAyB;AAC3D,GAAO,KACN,gBACA,yEACA,EAAE,EACF,YACQ,EAAY;EAClB,OAAO;EACP,aAAa;EACb,QAAQ;GACP,MAAM,CACL,2DACA,kEACA;GACD,KAAK;IACJ;IACA;IACA;IACA;IACA;IACA;GACD,UAAU;IACT;IACA;IACA;IACA;GACD;EACD,aAAa;GACZ,MAAM,CACL,4DACA,+DACA;GACD,KAAK;IACJ;IACA;IACA;IACA;GACD,UAAU,CACT,mHACA,8GACA;GACD;EACD,QAAQ;GACP,MAAM,CACL,wDACA,6DACA;GACD,KAAK,CACJ,qDACA,+DACA;GACD,UAAU,CAAC,qBAAqB;GAChC;EACD,aACC;EACD,2BAA2B;GAC1B;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,CAAC,KAAK,KAAK;EACZ,CAAC,CAEH;;;;AC5FF,IAAa,IAAuC;CACnD,WAAW;CACX,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,UAAU;CACV,UAAU;CACV,aAAa;CACb;;;ACHD,SAAgB,EAAoB,GAAyB;AAC5D,GAAO,KACN,iBACA,oEACA,EAAE,EACF,YACQ,EAAY;EAClB,OAAO,OAAO,KAAK,EAAa;EAChC,mBAAmB;EACnB,QAAQ;GACP,OAAO;GACP,MAAM;GACN,UAAU;GACV,OAAO;GACP,WAAW;GACX,UAAU;GACV,YAAY;GACZ,gBAAgB;GAChB,eAAe;GACf;EACD,SAAS;EACT,CAAC,CAEH;;;;ACpBF,SAAgB,EAAoB,GAAmB,GAAwC;CAC9F,IAAM,EAAE,mBAAgB,aAAU;AAsGlC,CApGA,EAAO,KACN,iBACA,yEACA;EACC,OAAO,EAAE,QAAQ,CAAC,SAAS,eAAe;E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IACA,aAAa,EAAW,QACtB,MACA,EAAgB,SAAS,EAAS,IAClC,EAAuB,SAAS,EAAS,IACzC,EAAsB,SAAS,EAAS,CACzC;IACD;IACA,UAAU;KACT,SAAS;KACT,qBAAqB,EAAW;KAChC,uBAAuB,EAAQ;KAC/B,gBAAgB,EAAc;KAC9B,sBAAsB,EAAK;KAC3B;IACD,CAAC;WACM,GAAK;AACb,UAAO,EAAa,aAAe,QAAQ,EAAI,UAAU,OAAO,EAAI,CAAC;;GAGvE;;;;ACjLF,SAAgB,EACf,GACA,IAAmC,EAAE,EACzB;CACZ,IAAM,IAAS,IAAI,EAAU;EAAE,MAAM;EAAW,SAAS;EAAS,CAAC,EAC7D,IAAmC;EACxC;EAGA,sBACK,EAAQ,wBAA8B,EAAQ,uBAAuB,GACrE,EAAQ,mBAAmB,KAAA,IACxB,GAAuB,GADmB,EAAQ;EAG1D,kBACC,EAAQ,eAAe,KAAA,IAAkC,QAAQ,IAAI,mBAAmB,OAArD,EAAQ;EAC5C;AAQD,QANA,EAAoB,GAAQ,EAAQ,EACpC,EAAsB,GAAQ,EAAQ,EACtC,EAAkB,GAAQ,EAAQ,EAClC,EAAoB,EAAO,EAC3B,EAAmB,EAAO,EAEnB"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type MemoryStore } from "@codemem/core";
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import type { CodememMcpServerOptions } from "./tool-context.js";
|
|
4
|
+
export declare function createCodememMcpServer(store: MemoryStore, options?: CodememMcpServerOptions): McpServer;
|
|
5
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAW,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,KAAK,EAAE,uBAAuB,EAA2B,MAAM,mBAAmB,CAAC;AAO1F,wBAAgB,sBAAsB,CACrC,KAAK,EAAE,WAAW,EAClB,OAAO,GAAE,uBAA4B,GACnC,SAAS,CAsBX"}
|
package/dist/stdio.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @codemem/mcp — MCP stdio server bootstrap.
|
|
4
|
+
*
|
|
5
|
+
* Runs as a separate process spawned by the host (OpenCode/Claude).
|
|
6
|
+
* Owns its own better-sqlite3 connection. Communicates via stdio JSON-RPC.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=stdio.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["../src/stdio.ts"],"names":[],"mappings":";AAEA;;;;;GAKG"}
|