ctxpipe 0.1.1 → 0.3.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/README.md +72 -3
- package/dist/auth.d.ts +18 -0
- package/dist/auth.js +92 -1
- package/dist/auth.js.map +1 -1
- package/dist/commands.d.ts +23 -3
- package/dist/commands.js +71 -27
- package/dist/commands.js.map +1 -1
- package/dist/fs-operations.d.ts +1 -1
- package/dist/fs-operations.js +28 -1
- package/dist/fs-operations.js.map +1 -1
- package/dist/mcp/doctor.d.ts +21 -0
- package/dist/mcp/doctor.js +326 -0
- package/dist/mcp/doctor.js.map +1 -0
- package/dist/mcp/mcp-operations.d.ts +39 -4
- package/dist/mcp/mcp-operations.js +176 -54
- package/dist/mcp/mcp-operations.js.map +1 -1
- package/dist/memory/capture.d.ts +72 -0
- package/dist/memory/capture.js +677 -0
- package/dist/memory/capture.js.map +1 -0
- package/dist/memory/hooks.d.ts +16 -0
- package/dist/memory/hooks.js +393 -0
- package/dist/memory/hooks.js.map +1 -0
- package/dist/memory/index.d.ts +3 -0
- package/dist/memory/index.js +4 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/paths.d.ts +4 -0
- package/dist/memory/paths.js +17 -0
- package/dist/memory/paths.js.map +1 -0
- package/dist/memory/run-capture.d.ts +12 -0
- package/dist/memory/run-capture.js +116 -0
- package/dist/memory/run-capture.js.map +1 -0
- package/dist/memory/run-init.d.ts +10 -0
- package/dist/memory/run-init.js +88 -0
- package/dist/memory/run-init.js.map +1 -0
- package/dist/memory/run-meta.d.ts +11 -0
- package/dist/memory/run-meta.js +87 -0
- package/dist/memory/run-meta.js.map +1 -0
- package/dist/memory/seed.d.ts +18 -0
- package/dist/memory/seed.js +239 -0
- package/dist/memory/seed.js.map +1 -0
- package/dist/memory/upgrade.d.ts +16 -0
- package/dist/memory/upgrade.js +283 -0
- package/dist/memory/upgrade.js.map +1 -0
- package/dist/program.js +148 -16
- package/dist/program.js.map +1 -1
- package/dist/prompts.d.ts +15 -0
- package/dist/prompts.js +138 -1
- package/dist/prompts.js.map +1 -1
- package/dist/ui.js +12 -1
- package/dist/ui.js.map +1 -1
- package/package.json +4 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-capture.js","sourceRoot":"","sources":["../../src/memory/run-capture.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,cAAc,EACd,SAAS,EACT,aAAa,EACb,gBAAgB,GAEjB,MAAM,cAAc,CAAA;AAErB,SAAS,eAAe,CAAC,OAAgB;IACvC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE;YACtE,IAAI,GAAG;gBAAE,MAAM,CAAC,GAAG,CAAC,CAAA;;gBACf,OAAO,EAAE,CAAA;QAChB,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;QACtC,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,KAAK,UAAU,eAAe,CAC5B,IAAiB,EACjB,GAAuB,EACvB,OAAgC;IAEhC,IAAI,SAAS,GAAG,KAAK,CAAA;IACrB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,gBAAgB,CAAC,EAAE,GAAG,EAAE,CAAC,CAAA;QACxC,MAAM,MAAM,GAAG,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;QAC1D,MAAM,eAAe,CAAC,MAAM,CAAC,CAAA;QAC7B,SAAS,GAAG,IAAI,CAAA;QAChB,iFAAiF;QACjF,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AAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,GAAa;IACzD,IAAI,CAAC;QACH,aAAa,CAAC,GAAG,CAAC,CAAA;QAClB,MAAM,eAAe,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,CAAA;IACrD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;QACpB,OAAM;IACR,CAAC;IACD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;AACtB,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { CLIENT_LABELS } from "../constants.js";
|
|
2
|
+
import { confirmAndApply, isInteractive } from "../commands.js";
|
|
3
|
+
import { buildMemoryArtifactOperations, buildMemoryConfigOperation, createOperationContext, validateClients, validateScope, } from "../mcp/mcp-operations.js";
|
|
4
|
+
import { promptMemoryInitWizard } from "../prompts.js";
|
|
5
|
+
import { commandExists } from "../system.js";
|
|
6
|
+
import { buildMemoryHookOperations } from "./hooks.js";
|
|
7
|
+
import { buildMemoryUpgradeOperations } from "./upgrade.js";
|
|
8
|
+
export async function runMemoryInit(opts) {
|
|
9
|
+
const interactive = isInteractive(opts);
|
|
10
|
+
const answers = {
|
|
11
|
+
org: opts.org ?? null,
|
|
12
|
+
baseUrl: opts.baseUrl,
|
|
13
|
+
agents: [...opts.agents],
|
|
14
|
+
scope: opts.scope ?? null,
|
|
15
|
+
dryRun: opts.dryRun,
|
|
16
|
+
};
|
|
17
|
+
if (interactive) {
|
|
18
|
+
const wizard = await promptMemoryInitWizard({
|
|
19
|
+
org: answers.org,
|
|
20
|
+
baseUrl: answers.baseUrl,
|
|
21
|
+
agents: answers.agents,
|
|
22
|
+
scope: answers.scope,
|
|
23
|
+
});
|
|
24
|
+
if (wizard.org !== undefined)
|
|
25
|
+
answers.org = wizard.org;
|
|
26
|
+
if (wizard.scope)
|
|
27
|
+
answers.scope = wizard.scope;
|
|
28
|
+
if (wizard.agents)
|
|
29
|
+
answers.agents = wizard.agents;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
if (answers.agents.length === 0) {
|
|
33
|
+
throw new Error("Missing --agents for non-interactive memory init");
|
|
34
|
+
}
|
|
35
|
+
if (!answers.scope)
|
|
36
|
+
answers.scope = "repo";
|
|
37
|
+
}
|
|
38
|
+
const scope = answers.scope;
|
|
39
|
+
const agents = answers.agents;
|
|
40
|
+
if (!scope)
|
|
41
|
+
throw new Error("Missing --scope");
|
|
42
|
+
validateScope(scope);
|
|
43
|
+
validateClients(agents);
|
|
44
|
+
const context = createOperationContext({ commandExists });
|
|
45
|
+
const configOp = buildMemoryConfigOperation({
|
|
46
|
+
org: answers.org,
|
|
47
|
+
baseUrl: answers.baseUrl,
|
|
48
|
+
context,
|
|
49
|
+
});
|
|
50
|
+
const upgradeOps = buildMemoryUpgradeOperations({ context });
|
|
51
|
+
const memoryOps = buildMemoryArtifactOperations({ context });
|
|
52
|
+
const hookOps = buildMemoryHookOperations({
|
|
53
|
+
clients: agents,
|
|
54
|
+
scope,
|
|
55
|
+
context,
|
|
56
|
+
});
|
|
57
|
+
const operations = [configOp, ...upgradeOps, ...memoryOps, ...hookOps];
|
|
58
|
+
const orgLine = answers.org
|
|
59
|
+
? `Organization ${answers.org}`
|
|
60
|
+
: "Organization none (local Markdown memory)";
|
|
61
|
+
const modeLine = "Markdown-only memory — candidates via hooks; promote with capture skills";
|
|
62
|
+
await confirmAndApply({
|
|
63
|
+
operations,
|
|
64
|
+
json: opts.json,
|
|
65
|
+
nonInteractive: opts.nonInteractive,
|
|
66
|
+
interactive,
|
|
67
|
+
dryRun: answers.dryRun,
|
|
68
|
+
introShown: interactive,
|
|
69
|
+
setupSummary: [
|
|
70
|
+
orgLine,
|
|
71
|
+
scopeLabel(scope),
|
|
72
|
+
`Agents ${agents.map((a) => CLIENT_LABELS[a]).join(", ")}`,
|
|
73
|
+
modeLine,
|
|
74
|
+
],
|
|
75
|
+
successMessage: "Local memory is configured",
|
|
76
|
+
outroMessage: "Memory setup complete. Restart the agent host to pick up hooks and rules.",
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function scopeLabel(scope) {
|
|
80
|
+
if (scope === "repo")
|
|
81
|
+
return "Scope This repo";
|
|
82
|
+
if (scope === "user")
|
|
83
|
+
return "Scope Globally";
|
|
84
|
+
if (scope === "both")
|
|
85
|
+
return "Scope This repo and globally";
|
|
86
|
+
return `Scope ${scope}`;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=run-init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-init.js","sourceRoot":"","sources":["../../src/memory/run-init.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC/D,OAAO,EACL,6BAA6B,EAC7B,0BAA0B,EAC1B,sBAAsB,EACtB,eAAe,EACf,aAAa,GACd,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAA;AACtD,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAA;AAY3D,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,IAAuB;IACzD,MAAM,WAAW,GAAG,aAAa,CAAC,IAAI,CAAC,CAAA;IACvC,MAAM,OAAO,GAMT;QACF,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,IAAI;QACrB,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,CAAa;QACpC,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,IAAI;QACzB,MAAM,EAAE,IAAI,CAAC,MAAM;KACpB,CAAA;IAED,IAAI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
export declare function runMemoryStatus(opts: {
|
|
2
|
+
baseUrl: string;
|
|
3
|
+
json: boolean;
|
|
4
|
+
}): Promise<void>;
|
|
5
|
+
export declare function runMemoryDoctor(opts: {
|
|
6
|
+
baseUrl: string;
|
|
7
|
+
json: boolean;
|
|
8
|
+
}): Promise<void>;
|
|
9
|
+
export declare function runMemoryStop(opts: {
|
|
10
|
+
json: boolean;
|
|
11
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { log, note } from "@clack/prompts";
|
|
4
|
+
import { resolveCtxpipeBaseUrl } from "../auth.js";
|
|
5
|
+
import { resolveMemoryRoot, resolveRepoRoot } from "./paths.js";
|
|
6
|
+
export async function runMemoryStatus(opts) {
|
|
7
|
+
const cwd = resolveRepoRoot();
|
|
8
|
+
const baseUrl = resolveCtxpipeBaseUrl(cwd, opts.baseUrl);
|
|
9
|
+
const state = collectStatus(baseUrl);
|
|
10
|
+
if (opts.json) {
|
|
11
|
+
process.stdout.write(`${JSON.stringify(state, null, 2)}\n`);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
note(formatStatusText(state), "ctx| memory status");
|
|
15
|
+
}
|
|
16
|
+
export async function runMemoryDoctor(opts) {
|
|
17
|
+
const cwd = resolveRepoRoot();
|
|
18
|
+
const baseUrl = resolveCtxpipeBaseUrl(cwd, opts.baseUrl);
|
|
19
|
+
const status = collectStatus(baseUrl);
|
|
20
|
+
const checks = collectDoctorChecks(status);
|
|
21
|
+
if (opts.json) {
|
|
22
|
+
process.stdout.write(`${JSON.stringify({ ...status, checks }, null, 2)}\n`);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
note([formatStatusText(status), "", "Checks:", ...checks.map(formatCheck)].join("\n"), "ctx| memory doctor");
|
|
26
|
+
}
|
|
27
|
+
export async function runMemoryStop(opts) {
|
|
28
|
+
if (opts.json) {
|
|
29
|
+
process.stdout.write(`${JSON.stringify({
|
|
30
|
+
status: "noop",
|
|
31
|
+
detail: "No local memory runtime to stop (Markdown-only mode).",
|
|
32
|
+
})}\n`);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
log.info("No local memory runtime to stop (Markdown-only mode, ADR-024).");
|
|
36
|
+
}
|
|
37
|
+
function collectStatus(baseUrl) {
|
|
38
|
+
const cwd = resolveRepoRoot();
|
|
39
|
+
const memoryRoot = resolveMemoryRoot(cwd);
|
|
40
|
+
return {
|
|
41
|
+
baseUrl,
|
|
42
|
+
cwd,
|
|
43
|
+
memoryRoot,
|
|
44
|
+
memoryRootExists: existsSync(memoryRoot),
|
|
45
|
+
indexExists: existsSync(join(memoryRoot, "index.md")),
|
|
46
|
+
eventsDirExists: existsSync(join(memoryRoot, "events")),
|
|
47
|
+
mode: "markdown-only",
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function collectDoctorChecks(status) {
|
|
51
|
+
return [
|
|
52
|
+
{
|
|
53
|
+
name: "memory-root",
|
|
54
|
+
status: status.memoryRootExists ? "ok" : "warn",
|
|
55
|
+
detail: status.memoryRootExists
|
|
56
|
+
? `${status.memoryRoot} present`
|
|
57
|
+
: `${status.memoryRoot} missing — run \`npx ctxpipe memory init\``,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "index",
|
|
61
|
+
status: status.indexExists ? "ok" : "warn",
|
|
62
|
+
detail: status.indexExists
|
|
63
|
+
? "index.md present"
|
|
64
|
+
: "index.md missing — re-run memory init or create from seed",
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: "events",
|
|
68
|
+
status: status.eventsDirExists ? "ok" : "warn",
|
|
69
|
+
detail: status.eventsDirExists
|
|
70
|
+
? "events/ present (gitignored candidate inbox)"
|
|
71
|
+
: "events/ missing — re-run memory init",
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
function formatStatusText(state) {
|
|
76
|
+
return [
|
|
77
|
+
`mode: ${state.mode}`,
|
|
78
|
+
`memory root: ${state.memoryRoot}${state.memoryRootExists ? "" : " (missing)"}`,
|
|
79
|
+
`index.md: ${state.indexExists ? "yes" : "missing"}`,
|
|
80
|
+
`events/: ${state.eventsDirExists ? "yes" : "missing"}`,
|
|
81
|
+
].join("\n");
|
|
82
|
+
}
|
|
83
|
+
function formatCheck(check) {
|
|
84
|
+
const badge = check.status === "ok" ? "✓" : check.status === "warn" ? "!" : "✗";
|
|
85
|
+
return ` ${badge} ${check.name}: ${check.detail}`;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=run-meta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-meta.js","sourceRoot":"","sources":["../../src/memory/run-meta.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE/D,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAGrC;IACC,MAAM,GAAG,GAAG,eAAe,EAAE,CAAA;IAC7B,MAAM,OAAO,GAAG,qBAAqB,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;IACxD,MAAM,KAAK,GAAG,aAAa,CAAC,OAAO,CAAC,CAAA;IACpC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACd,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAA;QAC3D,OAAM;IACR,CAAC;IACD,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,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AC,KAAK,CAAC,CAAC,CAAC,SAAS,EAAE;QAC1D,mBAAmB,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,EAAE;KAC/D,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACd,CAAC;AAED,SAAS,WAAW,CAAC,KAAkB;IACrC,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAA;IAC/E,OAAO,KAAK,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,MAAM,EAAE,CAAA;AACpD,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Seed content for `ctxpipe memory init` — Markdown-only layout (ADR-024). */
|
|
2
|
+
export declare const MEMORY_README_SEED = "# Project memory (`.ai/memory`)\n\nCanonical durable knowledge for coding agents in this repo. Navigate via\n[`index.md`](./index.md). Candidate observations from host hooks land in\ngitignored [`events/`](./events/) and are promoted by agents using capture skills.\n\n## Default read order\n\n1. This README (routing only).\n2. [`index.md`](./index.md) \u2014 top-level map of durable stores.\n3. [`lessons-learned.md`](./lessons-learned.md) \u2014 highest-priority confirmed rules.\n4. [`decisions/index.md`](./decisions/index.md) \u2014 ADR index (not every ADR).\n5. [`product-context.md`](./product-context.md) \u2014 overview/architecture as needed.\n6. Open **one** ADR or glossary entry when the task touches that area.\n\n## Write rules\n\n| Change | Where |\n|--------|--------|\n| Confirmed convention / correction | `lessons-learned.md` + update root `index.md` if needed |\n| Architecture decision | `decisions/ADR-NNN-*.md` + `decisions/index.md` |\n| Term | `glossary.md` |\n| Product/PRD fact | `PRDs/` + `PRDs/index.md` or `product-context.md` |\n| Session wrap-up | `sessions/YYYY-MM-DD-*.md` + `sessions/index.md` |\n\nHooks never write durable ADRs. Promote from `events/` via capture skills.\nRecall with `index.md` routers and `rg` (see the `memory-search` skill) \u2014\nno local memory search daemon.\n";
|
|
3
|
+
export declare const MEMORY_INDEX_SEED = "# Memory index\n\n| Store | Path | Notes |\n|-------|------|--------|\n| Lessons | [lessons-learned.md](./lessons-learned.md) | User-confirmed rules |\n| Glossary | [glossary.md](./glossary.md) | Domain terms |\n| Product context | [product-context.md](./product-context.md) | Overview / architecture |\n| ADRs | [decisions/index.md](./decisions/index.md) | Architecture decisions |\n| PRDs | [PRDs/index.md](./PRDs/index.md) | Living product requirements |\n| Sessions | [sessions/index.md](./sessions/index.md) | Episodic summaries |\n| Events (local) | [events/](./events/) | Gitignored candidate inbox |\n\nUpdate this file when adding a new top-level durable store.\n";
|
|
4
|
+
export declare const LESSONS_SEED = "# Lessons learned\n\nHighest-priority, user-confirmed rules for agents. Prefer short, enforceable\nentries.\n\n## Format\n\n```md\n### <short title>\n- **Rule:** \u2026\n- **Category:** convention | correction | workflow\n- **Date:** YYYY-MM-DD\n- **Source:** session / user / PR\n```\n\n## Entries\n";
|
|
5
|
+
export declare const GLOSSARY_SEED = "# Glossary\n\n| Term | Definition |\n|------|------------|\n| | |\n";
|
|
6
|
+
export declare const PRODUCT_CONTEXT_SEED = "# Product context\n\n## Overview\n\n<!-- Short product description -->\n\n## Architecture\n\n<!-- High-level system shape -->\n";
|
|
7
|
+
export declare const DECISIONS_INDEX_SEED = "# Architecture Decision Records\n\nNaming: `ADR-NNN-title-slug.md`. Status | Date | Tags; Context; Decision; Consequences.\n\n## Index\n\n| ADR | Title | Status |\n|-----|-------|--------|\n";
|
|
8
|
+
export declare const SESSIONS_INDEX_SEED = "# Sessions\n\nEpisodic session summaries. Naming: `YYYY-MM-DD-topic.md`.\n\n## Index\n\n| Date | Topic | File |\n|------|-------|------|\n";
|
|
9
|
+
export declare const PRDS_INDEX_SEED = "# PRDs\n\nLiving product requirement documents for this repo.\n\n## Index\n\n| PRD | Title | Status |\n|-----|-------|--------|\n";
|
|
10
|
+
export declare const AI_MEMORY_RULE = "---\ndescription: Local .ai/memory load order, indexes, and candidate-first capture\nalwaysApply: true\n---\n\n# Local memory (`.ai/memory`)\n\n## Read order (non-trivial tasks)\n\n1. [.ai/memory/README.md](.ai/memory/README.md)\n2. [.ai/memory/index.md](.ai/memory/index.md)\n3. [.ai/memory/lessons-learned.md](.ai/memory/lessons-learned.md) when conventions matter\n4. [.ai/memory/decisions/index.md](.ai/memory/decisions/index.md) \u2014 then **one** ADR if needed\n5. [.ai/memory/product-context.md](.ai/memory/product-context.md) selectively\n\nDo **not** load every ADR or the entire memory tree by default.\n\n## Recall (unknown fact)\n\n1. Start at `.ai/memory/index.md` (then a store `index.md` if the category is clear).\n2. Otherwise search with ripgrep, **excluding** the candidate inbox:\n\n```bash\nrg -i \"keyword\" .ai/memory --glob '*.md' --glob '!events/**'\n```\n\n3. Open **one** matching file/section. Use the `memory-search` skill for the full procedure.\n4. No AgentMemory / embeddings process \u2014 Markdown + indexes + `rg` only.\n\n## Write / promote\n\n- Host hooks only append **candidates** under `.ai/memory/events/` (gitignored).\n- Promote durable knowledge with capture skills (`capture-adr`, `capture-lesson`, `capture-glossary`, `capture-decision`).\n- **Always update the relevant `index.md`** when adding or renaming durable entries.\n- Never commit secrets into `.ai/memory/`.\n";
|
|
11
|
+
export declare function captureSkill(name: string, description: string, body: string): string;
|
|
12
|
+
export declare const SKILL_MEMORY_SEARCH: string;
|
|
13
|
+
export declare const SKILL_CAPTURE_ADR: string;
|
|
14
|
+
export declare const SKILL_CAPTURE_LESSON: string;
|
|
15
|
+
export declare const SKILL_CAPTURE_GLOSSARY: string;
|
|
16
|
+
export declare const SKILL_CAPTURE_DECISION: string;
|
|
17
|
+
export declare const GITIGNORE_EVENTS_BLOCK = "\n# ctxpipe local memory candidate inbox (ADR-024)\n.ai/memory/events/**\n!.ai/memory/events/.gitkeep\n.ai/memory/active-context.md\n.ai/memory/progress.md\n";
|
|
18
|
+
export declare function mergeGitignoreForMemory(existing: string | null): string;
|
|
@@ -0,0 +1,239 @@
|
|
|
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 durable knowledge with capture skills (\`capture-adr\`, \`capture-lesson\`, \`capture-glossary\`, \`capture-decision\`).
|
|
138
|
+
- **Always update the relevant \`index.md\`** when adding or renaming durable entries.
|
|
139
|
+
- Never commit secrets into \`.ai/memory/\`.
|
|
140
|
+
`;
|
|
141
|
+
export function captureSkill(name, description, body) {
|
|
142
|
+
return `---
|
|
143
|
+
name: ${name}
|
|
144
|
+
description: ${description}
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
${body}
|
|
148
|
+
`;
|
|
149
|
+
}
|
|
150
|
+
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)
|
|
151
|
+
|
|
152
|
+
No embeddings daemon. Durable knowledge is Markdown under \`.ai/memory/\`.
|
|
153
|
+
|
|
154
|
+
## Procedure
|
|
155
|
+
|
|
156
|
+
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.
|
|
157
|
+
2. **Targeted \`rg\`** — when the category is unknown or indexes are thin:
|
|
158
|
+
|
|
159
|
+
\`\`\`bash
|
|
160
|
+
rg -i "keyword" .ai/memory --glob '*.md' --glob '!events/**'
|
|
161
|
+
\`\`\`
|
|
162
|
+
|
|
163
|
+
Narrow when possible:
|
|
164
|
+
|
|
165
|
+
- Decisions: \`rg -i "keyword" .ai/memory/decisions --glob '*.md'\`
|
|
166
|
+
- Lessons: \`rg -i "keyword" .ai/memory/lessons-learned.md\`
|
|
167
|
+
- Glossary: \`rg -i "keyword" .ai/memory/glossary.md\`
|
|
168
|
+
- PRDs: \`rg -i "keyword" .ai/memory/PRDs --glob '*.md'\`
|
|
169
|
+
|
|
170
|
+
3. **Open one hit** — read the matching section or single ADR, not every match.
|
|
171
|
+
4. **Skip \`events/\`** — candidate inbox is gitignored runtime noise; do not treat it as durable recall.
|
|
172
|
+
|
|
173
|
+
## Do not
|
|
174
|
+
|
|
175
|
+
- Spawn AgentMemory / hosted embedding search
|
|
176
|
+
- Load the entire \`.ai/memory/\` tree into context
|
|
177
|
+
- Search \`events/\` for "source of truth" facts
|
|
178
|
+
`);
|
|
179
|
+
const LIFECYCLE_CLOSE = `
|
|
180
|
+
## Close the candidate lifecycle
|
|
181
|
+
|
|
182
|
+
After durable Markdown is written (or you reject the candidate), mark ids so they
|
|
183
|
+
leave the pending/surfaced sets:
|
|
184
|
+
|
|
185
|
+
\`\`\`bash
|
|
186
|
+
npx -y ctxpipe memory capture promote <candidateId>
|
|
187
|
+
# or
|
|
188
|
+
npx -y ctxpipe memory capture dismiss <candidateId>
|
|
189
|
+
\`\`\`
|
|
190
|
+
`;
|
|
191
|
+
export const SKILL_CAPTURE_ADR = captureSkill("capture-adr", "Write or update an ADR under .ai/memory/decisions and refresh decisions/index.md", `# Capture ADR
|
|
192
|
+
|
|
193
|
+
Use when an architectural or tooling decision should be durable.
|
|
194
|
+
|
|
195
|
+
1. Pick the next \`ADR-NNN\` number from \`.ai/memory/decisions/\`.
|
|
196
|
+
2. Write \`ADR-NNN-title-slug.md\` (Status, Date, Tags, Context, Decision, Consequences).
|
|
197
|
+
3. **Update** \`.ai/memory/decisions/index.md\`.
|
|
198
|
+
4. If needed, link from \`.ai/memory/index.md\` or product context.
|
|
199
|
+
5. Do not invent decisions from noisy hook candidates — confirm with the user or clear session evidence.
|
|
200
|
+
${LIFECYCLE_CLOSE}
|
|
201
|
+
`);
|
|
202
|
+
export const SKILL_CAPTURE_LESSON = captureSkill("capture-lesson", "Append a confirmed lesson to .ai/memory/lessons-learned.md", `# Capture lesson
|
|
203
|
+
|
|
204
|
+
Use when the user states a lasting preference, correction, or convention.
|
|
205
|
+
|
|
206
|
+
1. Append a short entry to \`.ai/memory/lessons-learned.md\` (Rule / Category / Date / Source).
|
|
207
|
+
2. Prefer lessons over duplicating the same rule in multiple files.
|
|
208
|
+
3. Update root \`.ai/memory/index.md\` only if the lessons store itself changes role.
|
|
209
|
+
${LIFECYCLE_CLOSE}
|
|
210
|
+
`);
|
|
211
|
+
export const SKILL_CAPTURE_GLOSSARY = captureSkill("capture-glossary", "Add or update a term in .ai/memory/glossary.md", `# Capture glossary term
|
|
212
|
+
|
|
213
|
+
1. Add or update the term in \`.ai/memory/glossary.md\`.
|
|
214
|
+
2. Keep definitions project-specific and concise.
|
|
215
|
+
3. Cross-link ADRs when a term is decision-shaped.
|
|
216
|
+
${LIFECYCLE_CLOSE}
|
|
217
|
+
`);
|
|
218
|
+
export const SKILL_CAPTURE_DECISION = captureSkill("capture-decision", "Capture a lighter decision note or route to capture-adr for full ADRs", `# Capture decision
|
|
219
|
+
|
|
220
|
+
- If the change is a major architecture/tooling choice → use **capture-adr**.
|
|
221
|
+
- Otherwise note it under the matching durable file (lessons, PRD, product-context) and **update the matching index.md**.
|
|
222
|
+
- Never auto-write durable decisions from hook candidates without review.
|
|
223
|
+
${LIFECYCLE_CLOSE}
|
|
224
|
+
`);
|
|
225
|
+
export const GITIGNORE_EVENTS_BLOCK = `
|
|
226
|
+
# ctxpipe local memory candidate inbox (ADR-024)
|
|
227
|
+
.ai/memory/events/**
|
|
228
|
+
!.ai/memory/events/.gitkeep
|
|
229
|
+
.ai/memory/active-context.md
|
|
230
|
+
.ai/memory/progress.md
|
|
231
|
+
`;
|
|
232
|
+
export function mergeGitignoreForMemory(existing) {
|
|
233
|
+
const base = existing ?? "";
|
|
234
|
+
if (base.includes(".ai/memory/events/**"))
|
|
235
|
+
return base.endsWith("\n") ? base : `${base}\n`;
|
|
236
|
+
const trimmed = base.replace(/\s*$/, "");
|
|
237
|
+
return `${trimmed}${trimmed ? "\n" : ""}${GITIGNORE_EVENTS_BLOCK.trim()}\n`;
|
|
238
|
+
}
|
|
239
|
+
//# sourceMappingURL=seed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seed.js","sourceRoot":"","sources":["../../src/memory/seed.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAE/E,MAAM,CAAC,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BjC,CAAA;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;CAahC,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;CAgB3B,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;CAK5B,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;CASnC,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;CAQnC,CAAA;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;CAQlC,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG;;;;;;;;CAQ9B,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmC7B,CAAA;AAED,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,WAAmB,EAAE,IAAY;IAC1E,OAAO;QACD,IAAI;eACG,WAAW;;;EAGxB,IAAI;CACL,CAAA;AACD,CAAC;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,YAAY,CAC7C,eAAe,EACf,kLAAkL,EAClL;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BD,CACA,CAAA;AAED,MAAM,eAAe,GAAG;;;;;;;;;;;CAWvB,CAAA;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,YAAY,CAC3C,aAAa,EACb,kFAAkF,EAClF;;;;;;;;;EASA,eAAe;CAChB,CACA,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,YAAY,CAC9C,gBAAgB,EAChB,4DAA4D,EAC5D;;;;;;;EAOA,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[];
|