ctxpipe 0.1.0-alpha.0 → 0.2.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/LICENSE +21 -0
- package/README.md +74 -0
- package/bin/ctxpipe.js +6 -42
- package/dist/auth.d.ts +52 -0
- package/dist/auth.js +416 -0
- package/dist/auth.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +12 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands.d.ts +56 -0
- package/dist/commands.js +264 -0
- package/dist/commands.js.map +1 -0
- package/dist/constants.d.ts +8 -0
- package/dist/constants.js +19 -0
- package/dist/constants.js.map +1 -0
- package/dist/fs-operations.d.ts +16 -0
- package/dist/fs-operations.js +62 -0
- package/dist/fs-operations.js.map +1 -0
- package/dist/mcp/json.d.ts +3 -0
- package/dist/mcp/json.js +15 -0
- package/dist/mcp/json.js.map +1 -0
- package/dist/mcp/mcp-operations.d.ts +103 -0
- package/dist/mcp/mcp-operations.js +464 -0
- package/dist/mcp/mcp-operations.js.map +1 -0
- package/dist/mcp/paths.d.ts +7 -0
- package/dist/mcp/paths.js +17 -0
- package/dist/mcp/paths.js.map +1 -0
- package/dist/memory/agentmemory-client.d.ts +24 -0
- package/dist/memory/agentmemory-client.js +47 -0
- package/dist/memory/agentmemory-client.js.map +1 -0
- package/dist/memory/hydration.d.ts +141 -0
- package/dist/memory/hydration.js +390 -0
- package/dist/memory/hydration.js.map +1 -0
- package/dist/memory/index.d.ts +4 -0
- package/dist/memory/index.js +5 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/markdown.d.ts +29 -0
- package/dist/memory/markdown.js +193 -0
- package/dist/memory/markdown.js.map +1 -0
- package/dist/memory/mcp-server.d.ts +48 -0
- package/dist/memory/mcp-server.js +322 -0
- package/dist/memory/mcp-server.js.map +1 -0
- package/dist/memory/paths.d.ts +12 -0
- package/dist/memory/paths.js +71 -0
- package/dist/memory/paths.js.map +1 -0
- package/dist/memory/policy.d.ts +16 -0
- package/dist/memory/policy.js +81 -0
- package/dist/memory/policy.js.map +1 -0
- package/dist/memory/run-hook.d.ts +13 -0
- package/dist/memory/run-hook.js +44 -0
- package/dist/memory/run-hook.js.map +1 -0
- package/dist/memory/run-init.d.ts +11 -0
- package/dist/memory/run-init.js +92 -0
- package/dist/memory/run-init.js.map +1 -0
- package/dist/memory/run-mcp.d.ts +3 -0
- package/dist/memory/run-mcp.js +7 -0
- package/dist/memory/run-mcp.js.map +1 -0
- package/dist/memory/run-meta.d.ts +11 -0
- package/dist/memory/run-meta.js +124 -0
- package/dist/memory/run-meta.js.map +1 -0
- package/dist/memory/supervisor.d.ts +49 -0
- package/dist/memory/supervisor.js +217 -0
- package/dist/memory/supervisor.js.map +1 -0
- package/dist/program.d.ts +1 -0
- package/dist/program.js +209 -0
- package/dist/program.js.map +1 -0
- package/dist/prompts.d.ts +42 -0
- package/dist/prompts.js +336 -0
- package/dist/prompts.js.map +1 -0
- package/dist/system.d.ts +3 -0
- package/dist/system.js +27 -0
- package/dist/system.js.map +1 -0
- package/dist/ui.d.ts +20 -0
- package/dist/ui.js +115 -0
- package/dist/ui.js.map +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +4 -0
- package/dist/version.js.map +1 -0
- package/package.json +26 -4
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
import { homedir } from "node:os";
|
|
2
|
+
import { join, resolve } from "node:path";
|
|
3
|
+
import { CLIENTS, DEFAULT_BASE_URL } from "../constants.js";
|
|
4
|
+
import { isObject } from "./json.js";
|
|
5
|
+
import { mcpUrl, normalizeBaseUrl, relativePath, scopesFor } from "./paths.js";
|
|
6
|
+
export function createOperationContext(overrides = {}) {
|
|
7
|
+
return {
|
|
8
|
+
cwd: process.cwd(),
|
|
9
|
+
homeDir: homedir(),
|
|
10
|
+
commandExists: () => false,
|
|
11
|
+
...overrides,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function minimalRepoConfigFields({ org, baseUrl, existing = {}, }) {
|
|
15
|
+
const next = {};
|
|
16
|
+
const orgSlug = org ?? (typeof existing.orgSlug === "string" ? existing.orgSlug : undefined);
|
|
17
|
+
if (orgSlug)
|
|
18
|
+
next.orgSlug = orgSlug;
|
|
19
|
+
const urlSource = normalizeBaseUrl(baseUrl) !== DEFAULT_BASE_URL
|
|
20
|
+
? baseUrl
|
|
21
|
+
: typeof existing.baseUrl === "string"
|
|
22
|
+
? existing.baseUrl
|
|
23
|
+
: baseUrl;
|
|
24
|
+
const normalized = normalizeBaseUrl(urlSource);
|
|
25
|
+
if (normalized !== DEFAULT_BASE_URL) {
|
|
26
|
+
next.baseUrl = normalized;
|
|
27
|
+
}
|
|
28
|
+
return next;
|
|
29
|
+
}
|
|
30
|
+
export function buildCtxpipeConfigOperation({ baseUrl, org, context = createOperationContext(), }) {
|
|
31
|
+
const configPath = resolve(context.cwd, ".ctxpipe", "config.json");
|
|
32
|
+
return {
|
|
33
|
+
type: "write-json",
|
|
34
|
+
path: configPath,
|
|
35
|
+
description: `write repo ctxpipe config at ${relativePath(configPath, context.cwd)}`,
|
|
36
|
+
content() {
|
|
37
|
+
return minimalRepoConfigFields({ org, baseUrl });
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/** Memory-only init: records org/baseUrl when org is known; preserves existing org on re-run. */
|
|
42
|
+
export function buildMemoryConfigOperation({ org, baseUrl, context = createOperationContext(), }) {
|
|
43
|
+
const configPath = resolve(context.cwd, ".ctxpipe", "config.json");
|
|
44
|
+
return {
|
|
45
|
+
type: "write-json",
|
|
46
|
+
path: configPath,
|
|
47
|
+
description: `write memory config at ${relativePath(configPath, context.cwd)}`,
|
|
48
|
+
content(existing = {}) {
|
|
49
|
+
return minimalRepoConfigFields({ org, baseUrl, existing });
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const MEMORY_README_SEED = `# .ai/memory
|
|
54
|
+
|
|
55
|
+
This folder is **canonical** ctx| project memory. It is the source of truth for
|
|
56
|
+
durable knowledge across coding-agent sessions: architecture decisions,
|
|
57
|
+
patterns, lessons, and curated session summaries.
|
|
58
|
+
|
|
59
|
+
The local \`ctxpipe-memory\` MCP server hydrates these Markdown files into a
|
|
60
|
+
per-repo AgentMemory cache so agents can search and recall them. The
|
|
61
|
+
AgentMemory cache is disposable — anything we want to keep belongs here, in
|
|
62
|
+
Markdown, and is reviewed via the normal Git diff workflow.
|
|
63
|
+
|
|
64
|
+
## Record shape
|
|
65
|
+
|
|
66
|
+
Every \`.md\` file under this tree carries YAML frontmatter so the hydration
|
|
67
|
+
layer can give each record a stable identity across renames, branch switches,
|
|
68
|
+
and merges:
|
|
69
|
+
|
|
70
|
+
\`\`\`md
|
|
71
|
+
---
|
|
72
|
+
id: mem-auth-session-refresh
|
|
73
|
+
type: architecture
|
|
74
|
+
concepts: [auth, sessions, better-auth]
|
|
75
|
+
files:
|
|
76
|
+
- apps/backend/src/auth.ts
|
|
77
|
+
createdAt: 2026-05-25T00:00:00.000Z
|
|
78
|
+
updatedAt: 2026-05-25T00:00:00.000Z
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
# Auth Session Refresh
|
|
82
|
+
|
|
83
|
+
We refresh Better Auth sessions through ...
|
|
84
|
+
\`\`\`
|
|
85
|
+
|
|
86
|
+
## Rules
|
|
87
|
+
|
|
88
|
+
- \`id\` is the stable key — never rename it.
|
|
89
|
+
- Do not commit secrets, credentials, or private customer data here.
|
|
90
|
+
- Raw session logs and tool observations are local-only cache and must NOT be
|
|
91
|
+
committed under this tree.
|
|
92
|
+
- See [ADR-021](decisions/ADR-021-local-agent-memory-agentmemory-hybrid-mcp-proxy.md)
|
|
93
|
+
for the full design.
|
|
94
|
+
`;
|
|
95
|
+
export function buildMemoryArtifactOperations({ context = createOperationContext(), } = {}) {
|
|
96
|
+
const memoryRoot = resolve(context.cwd, ".ai", "memory");
|
|
97
|
+
const readme = resolve(memoryRoot, "README.md");
|
|
98
|
+
return [
|
|
99
|
+
{
|
|
100
|
+
type: "mkdir",
|
|
101
|
+
path: memoryRoot,
|
|
102
|
+
description: `create canonical memory root at ${relativePath(memoryRoot, context.cwd)}`,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
type: "write-text",
|
|
106
|
+
path: readme,
|
|
107
|
+
description: `seed ${relativePath(readme, context.cwd)} (only if absent)`,
|
|
108
|
+
skipIfExists: true,
|
|
109
|
+
content: () => MEMORY_README_SEED,
|
|
110
|
+
},
|
|
111
|
+
];
|
|
112
|
+
}
|
|
113
|
+
const CLAUDE_HOOK_BLOCK = {
|
|
114
|
+
SessionStart: [
|
|
115
|
+
{
|
|
116
|
+
hooks: [
|
|
117
|
+
{
|
|
118
|
+
type: "command",
|
|
119
|
+
command: "npx -y ctxpipe memory hook claude-session-start",
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
Stop: [
|
|
125
|
+
{
|
|
126
|
+
hooks: [
|
|
127
|
+
{
|
|
128
|
+
type: "command",
|
|
129
|
+
command: "npx -y ctxpipe memory hook claude-stop",
|
|
130
|
+
async: true,
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
};
|
|
136
|
+
export function buildClaudeHooksOperation({ context = createOperationContext(), } = {}) {
|
|
137
|
+
const path = join(context.homeDir, ".claude", "settings.local.json");
|
|
138
|
+
return {
|
|
139
|
+
type: "write-json",
|
|
140
|
+
path,
|
|
141
|
+
description: `install Claude Code SessionStart/Stop hooks in ~/.claude/settings.local.json`,
|
|
142
|
+
content(existing = {}) {
|
|
143
|
+
const existingHooks = isObject(existing.hooks) ? existing.hooks : {};
|
|
144
|
+
const sessionStartExisting = Array.isArray(existingHooks.SessionStart)
|
|
145
|
+
? existingHooks.SessionStart
|
|
146
|
+
: [];
|
|
147
|
+
const stopExisting = Array.isArray(existingHooks.Stop)
|
|
148
|
+
? existingHooks.Stop
|
|
149
|
+
: [];
|
|
150
|
+
return {
|
|
151
|
+
...existing,
|
|
152
|
+
hooks: {
|
|
153
|
+
...existingHooks,
|
|
154
|
+
SessionStart: dedupeHookEntries(sessionStartExisting, CLAUDE_HOOK_BLOCK.SessionStart),
|
|
155
|
+
Stop: dedupeHookEntries(stopExisting, CLAUDE_HOOK_BLOCK.Stop),
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function dedupeHookEntries(existing, ours) {
|
|
162
|
+
// Drop any prior ctxpipe-installed entries before re-adding ours, so the
|
|
163
|
+
// command is idempotent and `npx` upgrades don't double up the hook list.
|
|
164
|
+
const filtered = existing.filter((entry) => !entryMentionsCtxpipe(entry));
|
|
165
|
+
return [...filtered, ...ours];
|
|
166
|
+
}
|
|
167
|
+
function entryMentionsCtxpipe(entry) {
|
|
168
|
+
if (!isObject(entry))
|
|
169
|
+
return false;
|
|
170
|
+
const hooks = entry.hooks;
|
|
171
|
+
if (!Array.isArray(hooks))
|
|
172
|
+
return false;
|
|
173
|
+
return hooks.some((hook) => {
|
|
174
|
+
if (!isObject(hook))
|
|
175
|
+
return false;
|
|
176
|
+
const cmd = hook.command;
|
|
177
|
+
return typeof cmd === "string" && cmd.includes("ctxpipe memory hook");
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
export function buildMemoryMcpOperations({ clients, baseUrl, org, scope, context = createOperationContext(), }) {
|
|
181
|
+
const orgSlug = org ?? "local";
|
|
182
|
+
return clients.flatMap((client) => scopesFor(scope).flatMap((singleScope) => buildClientOperations({
|
|
183
|
+
client,
|
|
184
|
+
baseUrl,
|
|
185
|
+
org: orgSlug,
|
|
186
|
+
scope: singleScope,
|
|
187
|
+
memory: true,
|
|
188
|
+
memoryOnly: true,
|
|
189
|
+
context,
|
|
190
|
+
})));
|
|
191
|
+
}
|
|
192
|
+
export function buildMcpOperations({ clients, baseUrl, org, scope, memory, context = createOperationContext(), }) {
|
|
193
|
+
return clients.flatMap((client) => scopesFor(scope).flatMap((singleScope) => buildClientOperations({
|
|
194
|
+
client,
|
|
195
|
+
baseUrl,
|
|
196
|
+
org,
|
|
197
|
+
scope: singleScope,
|
|
198
|
+
memory,
|
|
199
|
+
context,
|
|
200
|
+
})));
|
|
201
|
+
}
|
|
202
|
+
export function buildClientOperations({ client, baseUrl, org, scope, memory, memoryOnly, context = createOperationContext(), }) {
|
|
203
|
+
const url = mcpUrl({ baseUrl, org: org === "local" ? "local" : org });
|
|
204
|
+
switch (client) {
|
|
205
|
+
case "cursor":
|
|
206
|
+
return [
|
|
207
|
+
writeMcpServersOperation({
|
|
208
|
+
path: scope === "user"
|
|
209
|
+
? join(context.homeDir, ".cursor", "mcp.json")
|
|
210
|
+
: resolve(context.cwd, ".cursor", "mcp.json"),
|
|
211
|
+
url,
|
|
212
|
+
label: "Cursor",
|
|
213
|
+
cwd: context.cwd,
|
|
214
|
+
memory,
|
|
215
|
+
memoryOnly,
|
|
216
|
+
}),
|
|
217
|
+
];
|
|
218
|
+
case "claude":
|
|
219
|
+
if (scope === "user" && context.commandExists("claude")) {
|
|
220
|
+
const ops = [];
|
|
221
|
+
if (!memoryOnly) {
|
|
222
|
+
ops.push({
|
|
223
|
+
type: "run",
|
|
224
|
+
command: [
|
|
225
|
+
"claude",
|
|
226
|
+
"mcp",
|
|
227
|
+
"add",
|
|
228
|
+
"--transport",
|
|
229
|
+
"http",
|
|
230
|
+
"ctxpipe",
|
|
231
|
+
"--scope",
|
|
232
|
+
"user",
|
|
233
|
+
url,
|
|
234
|
+
],
|
|
235
|
+
description: "run Claude Code MCP add command",
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
if (memory || memoryOnly) {
|
|
239
|
+
ops.push({
|
|
240
|
+
type: "run",
|
|
241
|
+
command: [
|
|
242
|
+
"claude",
|
|
243
|
+
"mcp",
|
|
244
|
+
"add",
|
|
245
|
+
"ctxpipe-memory",
|
|
246
|
+
"--scope",
|
|
247
|
+
"user",
|
|
248
|
+
"--",
|
|
249
|
+
"npx",
|
|
250
|
+
"-y",
|
|
251
|
+
"ctxpipe",
|
|
252
|
+
"memory",
|
|
253
|
+
"mcp",
|
|
254
|
+
],
|
|
255
|
+
description: "run Claude Code MCP add command for ctxpipe-memory",
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
return ops;
|
|
259
|
+
}
|
|
260
|
+
return [
|
|
261
|
+
writeMcpServersOperation({
|
|
262
|
+
path: resolve(context.cwd, ".mcp.json"),
|
|
263
|
+
url,
|
|
264
|
+
label: "Claude Code project",
|
|
265
|
+
cwd: context.cwd,
|
|
266
|
+
memory,
|
|
267
|
+
memoryOnly,
|
|
268
|
+
}),
|
|
269
|
+
];
|
|
270
|
+
case "opencode":
|
|
271
|
+
return [
|
|
272
|
+
writeOpenCodeOperation({
|
|
273
|
+
path: scope === "user"
|
|
274
|
+
? join(context.homeDir, ".config", "opencode", "opencode.json")
|
|
275
|
+
: resolve(context.cwd, "opencode.json"),
|
|
276
|
+
url,
|
|
277
|
+
cwd: context.cwd,
|
|
278
|
+
memory,
|
|
279
|
+
memoryOnly,
|
|
280
|
+
}),
|
|
281
|
+
];
|
|
282
|
+
case "vscode":
|
|
283
|
+
if (scope === "user") {
|
|
284
|
+
const ops = [];
|
|
285
|
+
if (!memoryOnly) {
|
|
286
|
+
ops.push({
|
|
287
|
+
type: "manual",
|
|
288
|
+
description: "open VS Code MCP install link",
|
|
289
|
+
detail: `Open vscode:mcp/install?${encodeURIComponent(JSON.stringify({ name: "ctxpipe", type: "http", url }))}`,
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
if (memory || memoryOnly) {
|
|
293
|
+
ops.push({
|
|
294
|
+
type: "manual",
|
|
295
|
+
description: "open VS Code MCP install link for ctxpipe-memory",
|
|
296
|
+
detail: `Open vscode:mcp/install?${encodeURIComponent(JSON.stringify({
|
|
297
|
+
name: "ctxpipe-memory",
|
|
298
|
+
type: "stdio",
|
|
299
|
+
command: "npx",
|
|
300
|
+
args: ["-y", "ctxpipe", "memory", "mcp"],
|
|
301
|
+
}))}`,
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
return ops;
|
|
305
|
+
}
|
|
306
|
+
return [
|
|
307
|
+
writeVsCodeOperation({
|
|
308
|
+
path: resolve(context.cwd, ".vscode", "mcp.json"),
|
|
309
|
+
url,
|
|
310
|
+
cwd: context.cwd,
|
|
311
|
+
memory,
|
|
312
|
+
memoryOnly,
|
|
313
|
+
}),
|
|
314
|
+
];
|
|
315
|
+
case "codex":
|
|
316
|
+
if (scope === "user" && context.commandExists("codex")) {
|
|
317
|
+
const ops = [];
|
|
318
|
+
if (!memoryOnly) {
|
|
319
|
+
ops.push({
|
|
320
|
+
type: "run",
|
|
321
|
+
command: ["codex", "mcp", "add", "ctxpipe", "--url", url],
|
|
322
|
+
description: "run Codex MCP add command",
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
if (memory || memoryOnly) {
|
|
326
|
+
ops.push({
|
|
327
|
+
type: "run",
|
|
328
|
+
command: [
|
|
329
|
+
"codex",
|
|
330
|
+
"mcp",
|
|
331
|
+
"add",
|
|
332
|
+
"ctxpipe-memory",
|
|
333
|
+
"--",
|
|
334
|
+
"npx",
|
|
335
|
+
"-y",
|
|
336
|
+
"ctxpipe",
|
|
337
|
+
"memory",
|
|
338
|
+
"mcp",
|
|
339
|
+
],
|
|
340
|
+
description: "run Codex MCP add command for ctxpipe-memory",
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
return ops;
|
|
344
|
+
}
|
|
345
|
+
{
|
|
346
|
+
const ops = [];
|
|
347
|
+
if (!memoryOnly) {
|
|
348
|
+
ops.push({
|
|
349
|
+
type: "manual",
|
|
350
|
+
description: "show Codex MCP add command",
|
|
351
|
+
detail: `Run: codex mcp add ctxpipe --url ${url}`,
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
if (memory || memoryOnly) {
|
|
355
|
+
ops.push({
|
|
356
|
+
type: "manual",
|
|
357
|
+
description: "show Codex MCP add command for ctxpipe-memory",
|
|
358
|
+
detail: `Run: codex mcp add ctxpipe-memory -- npx -y ctxpipe memory mcp`,
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
return ops;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
export function writeMcpServersOperation({ path, url, label, cwd, memory, memoryOnly, }) {
|
|
366
|
+
return {
|
|
367
|
+
type: "write-json",
|
|
368
|
+
path,
|
|
369
|
+
description: `configure ${label} MCP at ${relativePath(path, cwd)}${memory || memoryOnly ? " (with ctxpipe-memory)" : ""}`,
|
|
370
|
+
content(existing = {}) {
|
|
371
|
+
const servers = {
|
|
372
|
+
...(isObject(existing.mcpServers) ? existing.mcpServers : {}),
|
|
373
|
+
};
|
|
374
|
+
if (!memoryOnly) {
|
|
375
|
+
servers.ctxpipe = {
|
|
376
|
+
type: "streamable-http",
|
|
377
|
+
url,
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
if (memory || memoryOnly) {
|
|
381
|
+
servers["ctxpipe-memory"] = {
|
|
382
|
+
command: "npx",
|
|
383
|
+
args: ["-y", "ctxpipe", "memory", "mcp"],
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
return {
|
|
387
|
+
...existing,
|
|
388
|
+
mcpServers: servers,
|
|
389
|
+
};
|
|
390
|
+
},
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
export function writeOpenCodeOperation({ path, url, cwd, memory, memoryOnly, }) {
|
|
394
|
+
return {
|
|
395
|
+
type: "write-json",
|
|
396
|
+
path,
|
|
397
|
+
description: `configure OpenCode MCP at ${relativePath(path, cwd)}${memory || memoryOnly ? " (with ctxpipe-memory)" : ""}`,
|
|
398
|
+
content(existing = {}) {
|
|
399
|
+
const mcp = {
|
|
400
|
+
...(isObject(existing.mcp) ? existing.mcp : {}),
|
|
401
|
+
};
|
|
402
|
+
if (!memoryOnly) {
|
|
403
|
+
mcp.ctxpipe = {
|
|
404
|
+
type: "remote",
|
|
405
|
+
url,
|
|
406
|
+
enabled: true,
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
if (memory || memoryOnly) {
|
|
410
|
+
mcp["ctxpipe-memory"] = {
|
|
411
|
+
type: "local",
|
|
412
|
+
command: ["npx", "-y", "ctxpipe", "memory", "mcp"],
|
|
413
|
+
enabled: true,
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
return {
|
|
417
|
+
...existing,
|
|
418
|
+
mcp,
|
|
419
|
+
};
|
|
420
|
+
},
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
export function writeVsCodeOperation({ path, url, cwd, memory, memoryOnly, }) {
|
|
424
|
+
return {
|
|
425
|
+
type: "write-json",
|
|
426
|
+
path,
|
|
427
|
+
description: `configure VS Code MCP at ${relativePath(path, cwd)}${memory || memoryOnly ? " (with ctxpipe-memory)" : ""}`,
|
|
428
|
+
content(existing = {}) {
|
|
429
|
+
const servers = {
|
|
430
|
+
...(isObject(existing.servers) ? existing.servers : {}),
|
|
431
|
+
};
|
|
432
|
+
if (!memoryOnly) {
|
|
433
|
+
servers.ctxpipe = {
|
|
434
|
+
type: "http",
|
|
435
|
+
url,
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
if (memory || memoryOnly) {
|
|
439
|
+
servers["ctxpipe-memory"] = {
|
|
440
|
+
type: "stdio",
|
|
441
|
+
command: "npx",
|
|
442
|
+
args: ["-y", "ctxpipe", "memory", "mcp"],
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
return {
|
|
446
|
+
...existing,
|
|
447
|
+
servers,
|
|
448
|
+
};
|
|
449
|
+
},
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
export function validateScope(scope) {
|
|
453
|
+
if (!["repo", "user", "both"].includes(scope)) {
|
|
454
|
+
throw new Error("--scope must be one of: repo, user, both");
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
export function validateClients(clients) {
|
|
458
|
+
for (const client of clients) {
|
|
459
|
+
if (!CLIENTS.includes(client)) {
|
|
460
|
+
throw new Error(`Unsupported client "${client}". Use: ${CLIENTS.join(", ")}`);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
//# sourceMappingURL=mcp-operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-operations.js","sourceRoot":"","sources":["../../src/mcp/mcp-operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEzC,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAE3D,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAiD9E,MAAM,UAAU,sBAAsB,CACpC,YAAuC,EAAE;IAEzC,OAAO;QACL,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;QAClB,OAAO,EAAE,OAAO,EAAE;QAClB,aAAa,EAAE,GAAG,EAAE,CAAC,KAAK;QAC1B,GAAG,SAAS;KACb,CAAA;AACH,CAAC;AAED,SAAS,uBAAuB,CAAC,EAC/B,GAAG,EACH,OAAO,EACP,QAAQ,GAAG,EAAE,GAKd;IACC,MAAM,IAAI,GAAe,EAAE,CAAA;IAC3B,MAAM,OAAO,GACX,GAAG,IAAI,CAAC,OAAO,QAAQ,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;IAC9E,IAAI,OAAO;QAAE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IAEnC,MAAM,SAAS,GACb,gBAAgB,CAAC,OAAO,CAAC,KAAK,gBAAgB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,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAgB,CAAC,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CAAC,uBAAuB,MAAM,WAAW,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAC/E,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function relativePath(path: string, cwd: string): string;
|
|
2
|
+
export declare function normalizeBaseUrl(value: string): string;
|
|
3
|
+
export declare function mcpUrl({ baseUrl, org }: {
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
org: string;
|
|
6
|
+
}): string;
|
|
7
|
+
export declare function scopesFor(scope: "repo" | "user" | "both"): Array<"repo" | "user">;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function relativePath(path, cwd) {
|
|
2
|
+
return path.startsWith(cwd) ? path.slice(cwd.length + 1) : path;
|
|
3
|
+
}
|
|
4
|
+
export function normalizeBaseUrl(value) {
|
|
5
|
+
return value.replace(/\/+$/, "");
|
|
6
|
+
}
|
|
7
|
+
export function mcpUrl({ baseUrl, org }) {
|
|
8
|
+
const url = new URL("/mcp", normalizeBaseUrl(baseUrl));
|
|
9
|
+
url.searchParams.set("orgSlug", org);
|
|
10
|
+
return url.toString();
|
|
11
|
+
}
|
|
12
|
+
export function scopesFor(scope) {
|
|
13
|
+
if (scope === "both")
|
|
14
|
+
return ["repo", "user"];
|
|
15
|
+
return [scope];
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/mcp/paths.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,GAAW;IACpD,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AACjE,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;AAClC,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,EAAoC;IACvE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAA;IACtD,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,CAAA;IACpC,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAA;AACvB,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAA+B;IACvD,IAAI,KAAK,KAAK,MAAM;QAAE,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC7C,OAAO,CAAC,KAAK,CAAC,CAAA;AAChB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ImportPayload } from "./hydration.js";
|
|
2
|
+
export type AgentMemorySearchHit = {
|
|
3
|
+
id: string;
|
|
4
|
+
type: string;
|
|
5
|
+
title: string;
|
|
6
|
+
content: string;
|
|
7
|
+
concepts: string[];
|
|
8
|
+
files: string[];
|
|
9
|
+
score?: number;
|
|
10
|
+
};
|
|
11
|
+
export declare function agentMemorySearch(args: {
|
|
12
|
+
url: string;
|
|
13
|
+
secret?: string;
|
|
14
|
+
query: string;
|
|
15
|
+
project: string;
|
|
16
|
+
cwd: string;
|
|
17
|
+
limit?: number;
|
|
18
|
+
}): Promise<AgentMemorySearchHit[]>;
|
|
19
|
+
export declare function agentMemoryImport(args: {
|
|
20
|
+
url: string;
|
|
21
|
+
secret?: string;
|
|
22
|
+
payload: ImportPayload;
|
|
23
|
+
}): Promise<void>;
|
|
24
|
+
export declare function agentMemoryLiveZ(url: string): Promise<boolean>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export async function agentMemorySearch(args) {
|
|
2
|
+
const res = await fetch(`${args.url.replace(/\/$/, "")}/agentmemory/search`, {
|
|
3
|
+
method: "POST",
|
|
4
|
+
headers: bearer(args.secret),
|
|
5
|
+
body: JSON.stringify({
|
|
6
|
+
query: args.query,
|
|
7
|
+
project: args.project,
|
|
8
|
+
cwd: args.cwd,
|
|
9
|
+
limit: args.limit ?? 10,
|
|
10
|
+
}),
|
|
11
|
+
});
|
|
12
|
+
if (!res.ok) {
|
|
13
|
+
throw new Error(`AgentMemory search failed: ${res.status} ${res.statusText}`);
|
|
14
|
+
}
|
|
15
|
+
const json = (await res.json());
|
|
16
|
+
if (Array.isArray(json))
|
|
17
|
+
return json;
|
|
18
|
+
return json.results ?? json.matches ?? [];
|
|
19
|
+
}
|
|
20
|
+
export async function agentMemoryImport(args) {
|
|
21
|
+
const res = await fetch(`${args.url.replace(/\/$/, "")}/agentmemory/import`, {
|
|
22
|
+
method: "POST",
|
|
23
|
+
headers: bearer(args.secret),
|
|
24
|
+
body: JSON.stringify(args.payload),
|
|
25
|
+
});
|
|
26
|
+
if (!res.ok) {
|
|
27
|
+
throw new Error(`AgentMemory import failed: ${res.status} ${res.statusText}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export async function agentMemoryLiveZ(url) {
|
|
31
|
+
try {
|
|
32
|
+
const res = await fetch(`${url.replace(/\/$/, "")}/agentmemory/livez`, {
|
|
33
|
+
signal: AbortSignal.timeout(2_000),
|
|
34
|
+
});
|
|
35
|
+
return res.ok;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function bearer(secret) {
|
|
42
|
+
const headers = { "content-type": "application/json" };
|
|
43
|
+
if (secret)
|
|
44
|
+
headers.authorization = `Bearer ${secret}`;
|
|
45
|
+
return headers;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=agentmemory-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentmemory-client.js","sourceRoot":"","sources":["../../src/memory/agentmemory-client.ts"],"names":[],"mappings":"AAYA,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,IAOvC;IACC,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,qBAAqB,EAAE;QAC3E,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;QAC5B,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,EAAE;SACxB,CAAC;KACH,CAAC,CAAA;IACF,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CACb,8BAA8B,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,UAAU,EAAE,CAC7D,CAAA;IACH,CAAC;IACD,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAEJ,CAAA;IAC1B,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAA;IACpC,OAAO,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,IAAI,EAAE,CAAA;AAC3C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,IAIvC;IACC,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,qBAAqB,EAAE;QAC3E,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,MAAM,CAAC,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