ctxpipe 0.2.0 → 0.3.2

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 (72) hide show
  1. package/README.md +54 -20
  2. package/dist/auth.js +1 -2
  3. package/dist/auth.js.map +1 -1
  4. package/dist/commands.d.ts +5 -2
  5. package/dist/commands.js +44 -12
  6. package/dist/commands.js.map +1 -1
  7. package/dist/fs-operations.d.ts +1 -1
  8. package/dist/fs-operations.js +8 -1
  9. package/dist/fs-operations.js.map +1 -1
  10. package/dist/mcp/doctor.d.ts +21 -0
  11. package/dist/mcp/doctor.js +326 -0
  12. package/dist/mcp/doctor.js.map +1 -0
  13. package/dist/mcp/mcp-operations.d.ts +12 -17
  14. package/dist/mcp/mcp-operations.js +116 -263
  15. package/dist/mcp/mcp-operations.js.map +1 -1
  16. package/dist/memory/capture.d.ts +79 -0
  17. package/dist/memory/capture.js +809 -0
  18. package/dist/memory/capture.js.map +1 -0
  19. package/dist/memory/hooks.d.ts +16 -0
  20. package/dist/memory/hooks.js +403 -0
  21. package/dist/memory/hooks.js.map +1 -0
  22. package/dist/memory/index.d.ts +1 -2
  23. package/dist/memory/index.js +1 -2
  24. package/dist/memory/index.js.map +1 -1
  25. package/dist/memory/paths.d.ts +2 -10
  26. package/dist/memory/paths.js +5 -59
  27. package/dist/memory/paths.js.map +1 -1
  28. package/dist/memory/run-capture.d.ts +12 -0
  29. package/dist/memory/run-capture.js +116 -0
  30. package/dist/memory/run-capture.js.map +1 -0
  31. package/dist/memory/run-init.d.ts +0 -1
  32. package/dist/memory/run-init.js +10 -14
  33. package/dist/memory/run-init.js.map +1 -1
  34. package/dist/memory/run-meta.js +49 -86
  35. package/dist/memory/run-meta.js.map +1 -1
  36. package/dist/memory/seed.d.ts +18 -0
  37. package/dist/memory/seed.js +258 -0
  38. package/dist/memory/seed.js.map +1 -0
  39. package/dist/memory/upgrade.d.ts +16 -0
  40. package/dist/memory/upgrade.js +283 -0
  41. package/dist/memory/upgrade.js.map +1 -0
  42. package/dist/program.js +79 -31
  43. package/dist/program.js.map +1 -1
  44. package/dist/prompts.js +15 -14
  45. package/dist/prompts.js.map +1 -1
  46. package/dist/ui.js +5 -1
  47. package/dist/ui.js.map +1 -1
  48. package/package.json +4 -4
  49. package/dist/memory/agentmemory-client.d.ts +0 -24
  50. package/dist/memory/agentmemory-client.js +0 -47
  51. package/dist/memory/agentmemory-client.js.map +0 -1
  52. package/dist/memory/hydration.d.ts +0 -141
  53. package/dist/memory/hydration.js +0 -390
  54. package/dist/memory/hydration.js.map +0 -1
  55. package/dist/memory/markdown.d.ts +0 -29
  56. package/dist/memory/markdown.js +0 -193
  57. package/dist/memory/markdown.js.map +0 -1
  58. package/dist/memory/mcp-server.d.ts +0 -48
  59. package/dist/memory/mcp-server.js +0 -322
  60. package/dist/memory/mcp-server.js.map +0 -1
  61. package/dist/memory/policy.d.ts +0 -16
  62. package/dist/memory/policy.js +0 -81
  63. package/dist/memory/policy.js.map +0 -1
  64. package/dist/memory/run-hook.d.ts +0 -13
  65. package/dist/memory/run-hook.js +0 -44
  66. package/dist/memory/run-hook.js.map +0 -1
  67. package/dist/memory/run-mcp.d.ts +0 -3
  68. package/dist/memory/run-mcp.js +0 -7
  69. package/dist/memory/run-mcp.js.map +0 -1
  70. package/dist/memory/supervisor.d.ts +0 -49
  71. package/dist/memory/supervisor.js +0 -217
  72. package/dist/memory/supervisor.js.map +0 -1
@@ -0,0 +1,258 @@
1
+ /** Seed content for `ctxpipe memory init` — Markdown-only layout (ADR-024). */
2
+ export const MEMORY_README_SEED = `# Project memory (\`.ai/memory\`)
3
+
4
+ Canonical durable knowledge for coding agents in this repo. Navigate via
5
+ [\`index.md\`](./index.md). Candidate observations from host hooks land in
6
+ gitignored [\`events/\`](./events/) and are promoted by agents using capture skills.
7
+
8
+ ## Default read order
9
+
10
+ 1. This README (routing only).
11
+ 2. [\`index.md\`](./index.md) — top-level map of durable stores.
12
+ 3. [\`lessons-learned.md\`](./lessons-learned.md) — highest-priority confirmed rules.
13
+ 4. [\`decisions/index.md\`](./decisions/index.md) — ADR index (not every ADR).
14
+ 5. [\`product-context.md\`](./product-context.md) — overview/architecture as needed.
15
+ 6. Open **one** ADR or glossary entry when the task touches that area.
16
+
17
+ ## Write rules
18
+
19
+ | Change | Where |
20
+ |--------|--------|
21
+ | Confirmed convention / correction | \`lessons-learned.md\` + update root \`index.md\` if needed |
22
+ | Architecture decision | \`decisions/ADR-NNN-*.md\` + \`decisions/index.md\` |
23
+ | Term | \`glossary.md\` |
24
+ | Product/PRD fact | \`PRDs/\` + \`PRDs/index.md\` or \`product-context.md\` |
25
+ | Session wrap-up | \`sessions/YYYY-MM-DD-*.md\` + \`sessions/index.md\` |
26
+
27
+ Hooks never write durable ADRs. Promote from \`events/\` via capture skills.
28
+ Recall with \`index.md\` routers and \`rg\` (see the \`memory-search\` skill) —
29
+ no local memory search daemon.
30
+ `;
31
+ export const MEMORY_INDEX_SEED = `# Memory index
32
+
33
+ | Store | Path | Notes |
34
+ |-------|------|--------|
35
+ | Lessons | [lessons-learned.md](./lessons-learned.md) | User-confirmed rules |
36
+ | Glossary | [glossary.md](./glossary.md) | Domain terms |
37
+ | Product context | [product-context.md](./product-context.md) | Overview / architecture |
38
+ | ADRs | [decisions/index.md](./decisions/index.md) | Architecture decisions |
39
+ | PRDs | [PRDs/index.md](./PRDs/index.md) | Living product requirements |
40
+ | Sessions | [sessions/index.md](./sessions/index.md) | Episodic summaries |
41
+ | Events (local) | [events/](./events/) | Gitignored candidate inbox |
42
+
43
+ Update this file when adding a new top-level durable store.
44
+ `;
45
+ export const LESSONS_SEED = `# Lessons learned
46
+
47
+ Highest-priority, user-confirmed rules for agents. Prefer short, enforceable
48
+ entries.
49
+
50
+ ## Format
51
+
52
+ \`\`\`md
53
+ ### <short title>
54
+ - **Rule:** …
55
+ - **Category:** convention | correction | workflow
56
+ - **Date:** YYYY-MM-DD
57
+ - **Source:** session / user / PR
58
+ \`\`\`
59
+
60
+ ## Entries
61
+ `;
62
+ export const GLOSSARY_SEED = `# Glossary
63
+
64
+ | Term | Definition |
65
+ |------|------------|
66
+ | | |
67
+ `;
68
+ export const PRODUCT_CONTEXT_SEED = `# Product context
69
+
70
+ ## Overview
71
+
72
+ <!-- Short product description -->
73
+
74
+ ## Architecture
75
+
76
+ <!-- High-level system shape -->
77
+ `;
78
+ export const DECISIONS_INDEX_SEED = `# Architecture Decision Records
79
+
80
+ Naming: \`ADR-NNN-title-slug.md\`. Status | Date | Tags; Context; Decision; Consequences.
81
+
82
+ ## Index
83
+
84
+ | ADR | Title | Status |
85
+ |-----|-------|--------|
86
+ `;
87
+ export const SESSIONS_INDEX_SEED = `# Sessions
88
+
89
+ Episodic session summaries. Naming: \`YYYY-MM-DD-topic.md\`.
90
+
91
+ ## Index
92
+
93
+ | Date | Topic | File |
94
+ |------|-------|------|
95
+ `;
96
+ export const PRDS_INDEX_SEED = `# PRDs
97
+
98
+ Living product requirement documents for this repo.
99
+
100
+ ## Index
101
+
102
+ | PRD | Title | Status |
103
+ |-----|-------|--------|
104
+ `;
105
+ export const AI_MEMORY_RULE = `---
106
+ description: Local .ai/memory load order, indexes, and candidate-first capture
107
+ alwaysApply: true
108
+ ---
109
+
110
+ # Local memory (\`.ai/memory\`)
111
+
112
+ ## Read order (non-trivial tasks)
113
+
114
+ 1. [.ai/memory/README.md](.ai/memory/README.md)
115
+ 2. [.ai/memory/index.md](.ai/memory/index.md)
116
+ 3. [.ai/memory/lessons-learned.md](.ai/memory/lessons-learned.md) when conventions matter
117
+ 4. [.ai/memory/decisions/index.md](.ai/memory/decisions/index.md) — then **one** ADR if needed
118
+ 5. [.ai/memory/product-context.md](.ai/memory/product-context.md) selectively
119
+
120
+ Do **not** load every ADR or the entire memory tree by default.
121
+
122
+ ## Recall (unknown fact)
123
+
124
+ 1. Start at \`.ai/memory/index.md\` (then a store \`index.md\` if the category is clear).
125
+ 2. Otherwise search with ripgrep, **excluding** the candidate inbox:
126
+
127
+ \`\`\`bash
128
+ rg -i "keyword" .ai/memory --glob '*.md' --glob '!events/**'
129
+ \`\`\`
130
+
131
+ 3. Open **one** matching file/section. Use the \`memory-search\` skill for the full procedure.
132
+ 4. No AgentMemory / embeddings process — Markdown + indexes + \`rg\` only.
133
+
134
+ ## Write / promote
135
+
136
+ - Host hooks only append **candidates** under \`.ai/memory/events/\` (gitignored).
137
+ - Promote a **lesson** only if it is a **lasting, cross-session convention** the user (or a clear product decision) would still want months later.
138
+ - **Dismiss** hook candidates that are: library/API docs, compiler/test output, grep/search payloads, echoes of Markdown we just wrote, or “Memory candidates” follow-ups.
139
+ - Implementation / this-PR polish belongs in the PR or an ADR, not \`lessons-learned.md\`.
140
+ - Hook follow-ups are **not** user product requests; if they fail the bar, dismiss ids and stop — do not start a research turn.
141
+ - Promote durable knowledge with capture skills (\`capture-adr\`, \`capture-lesson\`, \`capture-glossary\`, \`capture-decision\`).
142
+ - **Always update the relevant \`index.md\`** when adding or renaming durable entries.
143
+ - Never commit secrets into \`.ai/memory/\`.
144
+ `;
145
+ export function captureSkill(name, description, body) {
146
+ return `---
147
+ name: ${name}
148
+ description: ${description}
149
+ ---
150
+
151
+ ${body}
152
+ `;
153
+ }
154
+ export const SKILL_MEMORY_SEARCH = captureSkill("memory-search", "Find facts in .ai/memory via index.md routers and rg (excludes events/). Use when recalling a convention, decision, glossary term, or PRD detail without loading the whole tree.", `# Memory search (Markdown recall)
155
+
156
+ No embeddings daemon. Durable knowledge is Markdown under \`.ai/memory/\`.
157
+
158
+ ## Procedure
159
+
160
+ 1. **Indexes first** — open \`.ai/memory/index.md\`, then the matching store index (\`decisions/index.md\`, \`PRDs/index.md\`, \`sessions/index.md\`) if the category is known.
161
+ 2. **Targeted \`rg\`** — when the category is unknown or indexes are thin:
162
+
163
+ \`\`\`bash
164
+ rg -i "keyword" .ai/memory --glob '*.md' --glob '!events/**'
165
+ \`\`\`
166
+
167
+ Narrow when possible:
168
+
169
+ - Decisions: \`rg -i "keyword" .ai/memory/decisions --glob '*.md'\`
170
+ - Lessons: \`rg -i "keyword" .ai/memory/lessons-learned.md\`
171
+ - Glossary: \`rg -i "keyword" .ai/memory/glossary.md\`
172
+ - PRDs: \`rg -i "keyword" .ai/memory/PRDs --glob '*.md'\`
173
+
174
+ 3. **Open one hit** — read the matching section or single ADR, not every match.
175
+ 4. **Skip \`events/\`** — candidate inbox is gitignored runtime noise; do not treat it as durable recall.
176
+
177
+ ## Do not
178
+
179
+ - Spawn AgentMemory / hosted embedding search
180
+ - Load the entire \`.ai/memory/\` tree into context
181
+ - Search \`events/\` for "source of truth" facts
182
+ `);
183
+ const LIFECYCLE_CLOSE = `
184
+ ## Close the candidate lifecycle
185
+
186
+ After durable Markdown is written (or you reject the candidate), mark ids so they
187
+ leave the pending/surfaced sets:
188
+
189
+ \`\`\`bash
190
+ npx -y ctxpipe memory capture promote <candidateId>
191
+ # or
192
+ npx -y ctxpipe memory capture dismiss <candidateId>
193
+ \`\`\`
194
+ `;
195
+ export const SKILL_CAPTURE_ADR = captureSkill("capture-adr", "Write or update an ADR under .ai/memory/decisions and refresh decisions/index.md", `# Capture ADR
196
+
197
+ Use when an architectural or tooling decision should be durable.
198
+
199
+ 1. Pick the next \`ADR-NNN\` number from \`.ai/memory/decisions/\`.
200
+ 2. Write \`ADR-NNN-title-slug.md\` (Status, Date, Tags, Context, Decision, Consequences).
201
+ 3. **Update** \`.ai/memory/decisions/index.md\`.
202
+ 4. If needed, link from \`.ai/memory/index.md\` or product context.
203
+ 5. Do not invent decisions from noisy hook candidates — confirm with the user or clear session evidence.
204
+ ${LIFECYCLE_CLOSE}
205
+ `);
206
+ export const SKILL_CAPTURE_LESSON = captureSkill("capture-lesson", "Append a confirmed lesson to .ai/memory/lessons-learned.md", `# Capture lesson
207
+
208
+ Use when the user states a lasting preference, correction, or convention that should
209
+ still apply months later (cross-session). Implementation / this-PR polish belongs in
210
+ the PR or an ADR, not \`lessons-learned.md\`.
211
+
212
+ 1. Append a short entry to \`.ai/memory/lessons-learned.md\` (Rule / Category / Date / Source).
213
+ 2. Prefer lessons over duplicating the same rule in multiple files.
214
+ 3. Update root \`.ai/memory/index.md\` only if the lessons store itself changes role.
215
+
216
+ ## Dismiss (do not promote)
217
+
218
+ Hook candidates that are any of:
219
+
220
+ - library or API docs
221
+ - compiler / test output
222
+ - grep / search payloads
223
+ - echoes of Markdown we just wrote
224
+ - “Memory candidates” Stop follow-ups
225
+
226
+ Hook follow-ups are **not** user product requests. If they fail this bar, dismiss the
227
+ ids and stop — do not start a research turn.
228
+ ${LIFECYCLE_CLOSE}
229
+ `);
230
+ export const SKILL_CAPTURE_GLOSSARY = captureSkill("capture-glossary", "Add or update a term in .ai/memory/glossary.md", `# Capture glossary term
231
+
232
+ 1. Add or update the term in \`.ai/memory/glossary.md\`.
233
+ 2. Keep definitions project-specific and concise.
234
+ 3. Cross-link ADRs when a term is decision-shaped.
235
+ ${LIFECYCLE_CLOSE}
236
+ `);
237
+ export const SKILL_CAPTURE_DECISION = captureSkill("capture-decision", "Capture a lighter decision note or route to capture-adr for full ADRs", `# Capture decision
238
+
239
+ - If the change is a major architecture/tooling choice → use **capture-adr**.
240
+ - Otherwise note it under the matching durable file (lessons, PRD, product-context) and **update the matching index.md**.
241
+ - Never auto-write durable decisions from hook candidates without review.
242
+ ${LIFECYCLE_CLOSE}
243
+ `);
244
+ export const GITIGNORE_EVENTS_BLOCK = `
245
+ # ctxpipe local memory candidate inbox (ADR-024)
246
+ .ai/memory/events/**
247
+ !.ai/memory/events/.gitkeep
248
+ .ai/memory/active-context.md
249
+ .ai/memory/progress.md
250
+ `;
251
+ export function mergeGitignoreForMemory(existing) {
252
+ const base = existing ?? "";
253
+ if (base.includes(".ai/memory/events/**"))
254
+ return base.endsWith("\n") ? base : `${base}\n`;
255
+ const trimmed = base.replace(/\s*$/, "");
256
+ return `${trimmed}${trimmed ? "\n" : ""}${GITIGNORE_EVENTS_BLOCK.trim()}\n`;
257
+ }
258
+ //# sourceMappingURL=seed.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AsBA,eAAe;CAChB,CACA,CAAA;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,YAAY,CAChD,kBAAkB,EAClB,gDAAgD,EAChD;;;;;EAKA,eAAe;CAChB,CACA,CAAA;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,YAAY,CAChD,kBAAkB,EAClB,uEAAuE,EACvE;;;;;EAKA,eAAe;CAChB,CACA,CAAA;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG;;;;;;CAMrC,CAAA;AAED,MAAM,UAAU,uBAAuB,CAAC,QAAuB;IAC7D,MAAM,IAAI,GAAG,QAAQ,IAAI,EAAE,CAAA;IAC3B,IAAI,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAAC;QAAE,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,CAAA;IAC1F,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IACxC,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,sBAAsB,CAAC,IAAI,EAAE,IAAI,CAAA;AAC7E,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { Operation, OperationContext } from "../mcp/mcp-operations.js";
2
+ /** Legacy AgentMemory / ConKeeper guidance that must not survive re-init. */
3
+ export declare function isLegacyMemoryDoc(text: string): boolean;
4
+ /**
5
+ * Strip retired local-memory MCP tables from Codex config.toml
6
+ * (e.g. `[mcp_servers.ctxpipe-memory]` from `codex mcp add`).
7
+ */
8
+ export declare function stripLegacyCodexMemoryToml(existing: string): string;
9
+ /** Strip legacy AgentMemory MCP + memory stanza from JSON configs. */
10
+ export declare function stripLegacyMemoryMcp(existing: Record<string, unknown>): Record<string, unknown>;
11
+ /**
12
+ * One-shot upgrade ops so re-init leaves no AgentMemory / ConKeeper dual layout.
13
+ */
14
+ export declare function buildMemoryUpgradeOperations({ context, }?: {
15
+ context?: OperationContext;
16
+ }): Operation[];
@@ -0,0 +1,283 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { join, resolve } from "node:path";
3
+ import { createOperationContext } from "../mcp/mcp-operations.js";
4
+ import { isObject } from "../mcp/json.js";
5
+ import { relativePath } from "../mcp/paths.js";
6
+ import { LESSONS_SEED, MEMORY_README_SEED } from "./seed.js";
7
+ /** Legacy AgentMemory / ConKeeper guidance that must not survive re-init. */
8
+ export function isLegacyMemoryDoc(text) {
9
+ // Require multiple signals so a single negated mention ("do not use AgentMemory")
10
+ // does not wipe a custom README.
11
+ let score = 0;
12
+ if (/\bagentmemory\b/i.test(text) &&
13
+ !/\b(?:do not|don't|never|without|no longer)\b[^\n]{0,40}\bagentmemory\b/i.test(text)) {
14
+ score += 1;
15
+ }
16
+ if (/\bctxpipe-memory\b/i.test(text) &&
17
+ !/\b(?:do not|don't|never|without|strips?|remove[sd]?)\b[^\n]{0,48}\bctxpipe-memory\b/i.test(text)) {
18
+ score += 1;
19
+ }
20
+ if (/npx\s+[^\n]*\bmemory\s+mcp\b/i.test(text) &&
21
+ !/\b(?:do not|don't|never|without|avoid)\b[^\n]{0,48}npx\s+[^\n]*\bmemory\s+mcp\b/i.test(text)) {
22
+ score += 2;
23
+ }
24
+ if (/conkeeper/i.test(text))
25
+ score += 2;
26
+ if (/memory-(?:sync|init|reflect|insights|search)/i.test(text))
27
+ score += 1;
28
+ if (/\bpatterns\.md\b/i.test(text) && /lessons-learned/i.test(text)) {
29
+ score += 1;
30
+ }
31
+ return score >= 2;
32
+ }
33
+ /**
34
+ * Strip retired local-memory MCP tables from Codex config.toml
35
+ * (e.g. `[mcp_servers.ctxpipe-memory]` from `codex mcp add`).
36
+ */
37
+ export function stripLegacyCodexMemoryToml(existing) {
38
+ // Match section headers even when indented; stop at the next header line.
39
+ let text = existing.replace(/^[ \t]*\[(?:mcp_servers|mcp\.servers)\.ctxpipe-memory\][^\n]*(?:\n(?![ \t]*\[)[^\n]*)*/gm, "");
40
+ // Drop orphaned blank runs introduced by section removal.
41
+ text = text.replace(/\n{3,}/g, "\n\n");
42
+ if (!text.trim())
43
+ return text.endsWith("\n") ? "\n" : text;
44
+ return text.endsWith("\n") ? text : `${text}\n`;
45
+ }
46
+ const RETIRED_SKILLS = [
47
+ "memory-init",
48
+ "memory-sync",
49
+ // memory-search is reintroduced as Markdown+rg recall (ADR-024) — do not delete.
50
+ "memory-reflect",
51
+ "memory-insights",
52
+ "session-handoff",
53
+ ];
54
+ const RETIRED_RULES = ["project-memory.mdc"];
55
+ /** True only for the retired local memory MCP / hook paths — not the remote product MCP. */
56
+ function isLegacyLocalMemoryServer(key, value) {
57
+ if (key === "ctxpipe-memory")
58
+ return true;
59
+ if (typeof value === "string") {
60
+ return /memory mcp|memory hook|agentmemory/i.test(value);
61
+ }
62
+ if (!isObject(value))
63
+ return false;
64
+ const cmd = typeof value.command === "string" ? value.command : "";
65
+ const args = Array.isArray(value.args)
66
+ ? value.args.filter((a) => typeof a === "string").join(" ")
67
+ : "";
68
+ const joined = `${cmd} ${args}`;
69
+ // Keep remote streamable-http `ctxpipe` entries (url-based, no memory mcp/hook).
70
+ if (typeof value.url === "string" && value.url.includes("/mcp"))
71
+ return false;
72
+ return (/memory mcp|agentmemory/i.test(joined) ||
73
+ (/memory hook/i.test(joined) && !/memory capture/i.test(joined)));
74
+ }
75
+ function stripServerMap(servers) {
76
+ const next = {};
77
+ for (const [key, value] of Object.entries(servers)) {
78
+ if (isLegacyLocalMemoryServer(key, value))
79
+ continue;
80
+ next[key] = value;
81
+ }
82
+ return next;
83
+ }
84
+ /** Strip legacy AgentMemory MCP + memory stanza from JSON configs. */
85
+ export function stripLegacyMemoryMcp(existing) {
86
+ const next = { ...existing };
87
+ for (const key of ["mcpServers", "servers", "mcp"]) {
88
+ if (isObject(next[key])) {
89
+ next[key] = stripServerMap(next[key]);
90
+ }
91
+ }
92
+ if ("memory" in next) {
93
+ delete next.memory;
94
+ }
95
+ return next;
96
+ }
97
+ function stripMcpJsonOperation(path, context) {
98
+ return {
99
+ type: "write-json",
100
+ path,
101
+ description: `remove legacy ctxpipe-memory MCP from ${relativePath(path, context.cwd)}`,
102
+ content(existing = {}) {
103
+ return stripLegacyMemoryMcp(existing);
104
+ },
105
+ };
106
+ }
107
+ function isLegacyMemoryHookCommand(cmd) {
108
+ if (/memory capture/i.test(cmd))
109
+ return false;
110
+ return /memory hook|memory mcp|agentmemory/i.test(cmd);
111
+ }
112
+ function stripLegacyClaudeHooks(existing) {
113
+ if (!isObject(existing.hooks))
114
+ return existing;
115
+ const hooks = { ...existing.hooks };
116
+ for (const [event, matchers] of Object.entries(hooks)) {
117
+ if (!Array.isArray(matchers))
118
+ continue;
119
+ hooks[event] = matchers
120
+ .map((matcher) => {
121
+ if (!isObject(matcher))
122
+ return matcher;
123
+ const inner = Array.isArray(matcher.hooks) ? matcher.hooks : null;
124
+ if (!inner) {
125
+ const cmd = typeof matcher.command === "string" ? matcher.command : "";
126
+ if (isLegacyMemoryHookCommand(cmd))
127
+ return null;
128
+ return matcher;
129
+ }
130
+ const nextInner = inner.filter((hook) => {
131
+ if (!isObject(hook))
132
+ return true;
133
+ const cmd = typeof hook.command === "string" ? hook.command : "";
134
+ return !isLegacyMemoryHookCommand(cmd);
135
+ });
136
+ if (nextInner.length === 0)
137
+ return null;
138
+ return { ...matcher, hooks: nextInner };
139
+ })
140
+ .filter((m) => m !== null);
141
+ }
142
+ return { ...existing, hooks };
143
+ }
144
+ function migratePatternsToLessonsOperation(context) {
145
+ const memoryRoot = resolve(context.cwd, ".ai", "memory");
146
+ const patternsPath = resolve(memoryRoot, "patterns.md");
147
+ const lessonsPath = resolve(memoryRoot, "lessons-learned.md");
148
+ return {
149
+ type: "write-text",
150
+ path: lessonsPath,
151
+ description: "migrate patterns.md into lessons-learned.md when present",
152
+ content(existing) {
153
+ if (!existsSync(patternsPath)) {
154
+ return existing ?? LESSONS_SEED;
155
+ }
156
+ const patterns = readFileSync(patternsPath, "utf8");
157
+ if (!patterns.trim())
158
+ return existing ?? LESSONS_SEED;
159
+ if (existing && existing.includes("Migrated from former `patterns.md`")) {
160
+ return existing;
161
+ }
162
+ const header = existing && existing.trim()
163
+ ? existing.trimEnd()
164
+ : LESSONS_SEED.trimEnd();
165
+ return `${header}\n\n## Migrated from former \`patterns.md\`\n\n${patterns.trim()}\n`;
166
+ },
167
+ };
168
+ }
169
+ function pushRetiredSkillAndRuleRemovals(ops, root) {
170
+ const skillsRoot = resolve(root, "skills");
171
+ const rulesRoot = resolve(root, "rules");
172
+ for (const name of RETIRED_SKILLS) {
173
+ ops.push({
174
+ type: "remove-path",
175
+ path: resolve(skillsRoot, name),
176
+ description: `remove retired skill ${name} under ${relativePath(skillsRoot, root)}`,
177
+ });
178
+ }
179
+ for (const name of RETIRED_RULES) {
180
+ ops.push({
181
+ type: "remove-path",
182
+ path: resolve(rulesRoot, name),
183
+ description: `remove retired rule ${name}`,
184
+ });
185
+ }
186
+ }
187
+ /**
188
+ * One-shot upgrade ops so re-init leaves no AgentMemory / ConKeeper dual layout.
189
+ */
190
+ export function buildMemoryUpgradeOperations({ context = createOperationContext(), } = {}) {
191
+ const ops = [];
192
+ const cwd = context.cwd;
193
+ const memoryRoot = resolve(cwd, ".ai", "memory");
194
+ // MCP / config cleanup — only touch files that already exist (do not create empties).
195
+ for (const path of [
196
+ resolve(cwd, ".cursor", "mcp.json"),
197
+ resolve(cwd, ".agents", "mcp.json"),
198
+ resolve(cwd, ".mcp.json"),
199
+ resolve(cwd, ".vscode", "mcp.json"),
200
+ resolve(cwd, "opencode.json"),
201
+ join(context.homeDir, ".config", "opencode", "opencode.json"),
202
+ resolve(cwd, ".ctxpipe", "config.json"),
203
+ join(context.homeDir, ".cursor", "mcp.json"),
204
+ ]) {
205
+ if (existsSync(path))
206
+ ops.push(stripMcpJsonOperation(path, context));
207
+ }
208
+ // Codex TOML (user + repo): strip ctxpipe-memory MCP tables from `codex mcp add`.
209
+ for (const path of [
210
+ resolve(cwd, ".codex", "config.toml"),
211
+ join(context.homeDir, ".codex", "config.toml"),
212
+ ]) {
213
+ if (!existsSync(path))
214
+ continue;
215
+ ops.push({
216
+ type: "write-text",
217
+ path,
218
+ description: `strip legacy ctxpipe-memory from Codex config ${relativePath(path, context.cwd)}`,
219
+ content(existing) {
220
+ return stripLegacyCodexMemoryToml(existing ?? "");
221
+ },
222
+ });
223
+ }
224
+ // Replace AgentMemory-era README so skipIfExists seed cannot leave dual guidance.
225
+ const readmePath = resolve(memoryRoot, "README.md");
226
+ if (existsSync(readmePath)) {
227
+ ops.push({
228
+ type: "write-text",
229
+ path: readmePath,
230
+ description: "replace legacy AgentMemory README with ADR-024 seed when detected",
231
+ content(existing) {
232
+ if (existing && isLegacyMemoryDoc(existing))
233
+ return MEMORY_README_SEED;
234
+ return existing ?? MEMORY_README_SEED;
235
+ },
236
+ });
237
+ }
238
+ // Claude settings: strip retired memory hook commands (user + project).
239
+ for (const path of [
240
+ join(context.homeDir, ".claude", "settings.json"),
241
+ join(context.homeDir, ".claude", "settings.local.json"),
242
+ resolve(cwd, ".claude", "settings.json"),
243
+ resolve(cwd, ".claude", "settings.local.json"),
244
+ ]) {
245
+ if (!existsSync(path))
246
+ continue;
247
+ ops.push({
248
+ type: "write-json",
249
+ path,
250
+ description: `strip legacy Claude memory hooks from ${relativePath(path, context.cwd)}`,
251
+ content(existing = {}) {
252
+ return stripLegacyClaudeHooks(existing);
253
+ },
254
+ });
255
+ }
256
+ // Migrate patterns → lessons, then remove patterns.md
257
+ ops.push(migratePatternsToLessonsOperation(context));
258
+ ops.push({
259
+ type: "remove-path",
260
+ path: resolve(memoryRoot, "patterns.md"),
261
+ description: "remove legacy patterns.md after migration",
262
+ });
263
+ // Retired ConKeeper skills / rule — both Cursor-primary and legacy .agents roots
264
+ pushRetiredSkillAndRuleRemovals(ops, resolve(cwd, ".cursor"));
265
+ // Only if .agents is a real directory (not the same inode as .cursor via symlink).
266
+ const agentsRoot = resolve(cwd, ".agents");
267
+ if (existsSync(agentsRoot)) {
268
+ pushRetiredSkillAndRuleRemovals(ops, agentsRoot);
269
+ }
270
+ // Legacy decisions/sessions README routers (replaced by index.md)
271
+ ops.push({
272
+ type: "remove-path",
273
+ path: resolve(memoryRoot, "decisions", "README.md"),
274
+ description: "remove legacy decisions/README.md (use index.md)",
275
+ });
276
+ ops.push({
277
+ type: "remove-path",
278
+ path: resolve(memoryRoot, "sessions", "README.md"),
279
+ description: "remove legacy sessions/README.md (use index.md)",
280
+ });
281
+ return ops;
282
+ }
283
+ //# sourceMappingURL=upgrade.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgrade.js","sourceRoot":"","sources":["../../src/memory/upgrade.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAOzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAE5D,6EAA6E;AAC7E,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,kFAAkF;IAClF,iCAAiC;IACjC,IAAI,KAAK,GAAG,CAAC,CAAA;IACb,IACE,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC;QAC7B,CAAC,yEAAyE,CAAC,IAAI,CAC7E,IAAI,CACL,EACD,CAAC;QACD,KAAK,IAAI,CAAC,CAAA;IACZ,CAAC;IACD,IACE,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC;QAChC,CAAC,sFAAsF,CAAC,IAAI,CAC1F,IAAI,CACL,EACD,CAAC;QACD,KAAK,IAAI,CAAC,CA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