@isaacriehm/cairn-core 0.14.0 → 0.14.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 (78) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/gc/classify.js +0 -1
  3. package/dist/gc/classify.js.map +1 -1
  4. package/dist/gc/doc-gardening.d.ts +0 -14
  5. package/dist/gc/doc-gardening.js +0 -40
  6. package/dist/gc/doc-gardening.js.map +1 -1
  7. package/dist/gc/sweep.d.ts +0 -2
  8. package/dist/gc/sweep.js +1 -4
  9. package/dist/gc/sweep.js.map +1 -1
  10. package/dist/gc/walk-source.js +0 -1
  11. package/dist/gc/walk-source.js.map +1 -1
  12. package/dist/init/curator/regex-prefilter.d.ts +1 -1
  13. package/dist/init/curator/regex-prefilter.js +2 -2
  14. package/dist/init/curator/regex-prefilter.js.map +1 -1
  15. package/dist/init/curator/walker.js +2 -2
  16. package/dist/init/curator/walker.js.map +1 -1
  17. package/dist/init/ingest-docs.js +0 -1
  18. package/dist/init/ingest-docs.js.map +1 -1
  19. package/dist/init/init.d.ts +1 -1
  20. package/dist/init/init.js +2 -2
  21. package/dist/init/init.js.map +1 -1
  22. package/dist/init/module-slicer.js +0 -1
  23. package/dist/init/module-slicer.js.map +1 -1
  24. package/dist/init/phases/5-preflight.js +0 -1
  25. package/dist/init/phases/5-preflight.js.map +1 -1
  26. package/dist/init/seed.d.ts +1 -1
  27. package/dist/init/seed.js +1 -2
  28. package/dist/init/seed.js.map +1 -1
  29. package/dist/init/source-comments/walker.js +0 -1
  30. package/dist/init/source-comments/walker.js.map +1 -1
  31. package/dist/init/topic-index/walk.js +0 -1
  32. package/dist/init/topic-index/walk.js.map +1 -1
  33. package/dist/init/walker.js +0 -1
  34. package/dist/init/walker.js.map +1 -1
  35. package/dist/mcp/index.d.ts +0 -2
  36. package/dist/mcp/index.js +0 -1
  37. package/dist/mcp/index.js.map +1 -1
  38. package/dist/mcp/path-allowlist.d.ts +1 -1
  39. package/dist/mcp/path-allowlist.js +1 -2
  40. package/dist/mcp/path-allowlist.js.map +1 -1
  41. package/dist/mcp/schemas.d.ts +0 -6
  42. package/dist/mcp/schemas.js +0 -7
  43. package/dist/mcp/schemas.js.map +1 -1
  44. package/dist/mcp/serve.js +8 -6
  45. package/dist/mcp/serve.js.map +1 -1
  46. package/dist/mcp/tools/index.js +0 -3
  47. package/dist/mcp/tools/index.js.map +1 -1
  48. package/dist/mcp/tools/retire-entity.d.ts +2 -2
  49. package/dist/mcp/tools/retire-entity.js +4 -4
  50. package/dist/mcp/tools/retire-entity.js.map +1 -1
  51. package/dist/session-start/build.d.ts +26 -0
  52. package/dist/session-start/build.js +30 -0
  53. package/dist/session-start/build.js.map +1 -1
  54. package/dist/session-start/index.d.ts +4 -4
  55. package/dist/session-start/index.js +4 -4
  56. package/dist/session-start/index.js.map +1 -1
  57. package/dist/session-start/templates.js +1 -2
  58. package/dist/session-start/templates.js.map +1 -1
  59. package/package.json +2 -2
  60. package/dist/mcp/history/index.d.ts +0 -6
  61. package/dist/mcp/history/index.js +0 -5
  62. package/dist/mcp/history/index.js.map +0 -1
  63. package/dist/mcp/history/prompt.d.ts +0 -33
  64. package/dist/mcp/history/prompt.js +0 -99
  65. package/dist/mcp/history/prompt.js.map +0 -1
  66. package/dist/mcp/history/schema.d.ts +0 -58
  67. package/dist/mcp/history/schema.js +0 -41
  68. package/dist/mcp/history/schema.js.map +0 -1
  69. package/dist/mcp/history/summarizer.d.ts +0 -81
  70. package/dist/mcp/history/summarizer.js +0 -201
  71. package/dist/mcp/history/summarizer.js.map +0 -1
  72. package/dist/mcp/history/walker.d.ts +0 -57
  73. package/dist/mcp/history/walker.js +0 -156
  74. package/dist/mcp/history/walker.js.map +0 -1
  75. package/dist/mcp/tools/query-history.d.ts +0 -20
  76. package/dist/mcp/tools/query-history.js +0 -51
  77. package/dist/mcp/tools/query-history.js.map +0 -1
  78. package/templates/.archive/README.md +0 -67
@@ -1,57 +0,0 @@
1
- /**
2
- * Archive walker — collects matching files from .archive/ for the
3
- * Tier-1 history summarizer.
4
- *
5
- * The walker reads file content but does NOT return it to the agent.
6
- * The MCP server feeds content to a Tier-1 LLM; the LLM emits
7
- * structured claims; only the structured claims reach the agent's
8
- * context. This is the load-bearing two-zone enforcement: raw stale
9
- * content never crosses the historical/canonical boundary.
10
- */
11
- export interface ArchiveFile {
12
- /** Absolute path. */
13
- absPath: string;
14
- /** Repo-relative POSIX path. */
15
- relPath: string;
16
- /**
17
- * Inferred archive date — from the path bucket
18
- * `.archive/YYYY-MM-DD/...` if present, else file mtime ISO.
19
- */
20
- archiveDate: string;
21
- /** Inferred bucket label — the segment immediately under .archive/. */
22
- bucket: string;
23
- /** UTF-8 content, truncated by `maxBytesPerFile`. */
24
- content: string;
25
- /** Size of original content in bytes (pre-truncation). */
26
- bytesOriginal: number;
27
- /** True iff `content` was truncated. */
28
- truncated: boolean;
29
- }
30
- export interface WalkArchiveResult {
31
- files: ArchiveFile[];
32
- /** True iff at least one match was skipped because totalBytes cap was reached. */
33
- capHit: boolean;
34
- totalBytes: number;
35
- /** Buckets discovered under .archive/ (top-level dirs). */
36
- bucketsScanned: string[];
37
- }
38
- export interface WalkArchiveOptions {
39
- repoRoot: string;
40
- /** Optional repo-relative glob (e.g. ".archive/2026-05-pre-cairn/**"). */
41
- pathHint?: string;
42
- /** ISO 8601 lower bound (inclusive). Compared to archiveDate. */
43
- since?: string;
44
- /** ISO 8601 upper bound (inclusive). Compared to archiveDate. */
45
- until?: string;
46
- /** Per-file content cap. Default 32 KB. */
47
- maxBytesPerFile?: number;
48
- /** Total content cap across all files. Default 200 KB. */
49
- maxBytesTotal?: number;
50
- /** Hard cap on number of files returned. Default 40. */
51
- maxFiles?: number;
52
- }
53
- /**
54
- * Walks `<repoRoot>/.archive/` collecting matching files. Returns content
55
- * inline so the summarizer can build a prompt without re-reading.
56
- */
57
- export declare function walkArchive(opts: WalkArchiveOptions): WalkArchiveResult;
@@ -1,156 +0,0 @@
1
- /**
2
- * Archive walker — collects matching files from .archive/ for the
3
- * Tier-1 history summarizer.
4
- *
5
- * The walker reads file content but does NOT return it to the agent.
6
- * The MCP server feeds content to a Tier-1 LLM; the LLM emits
7
- * structured claims; only the structured claims reach the agent's
8
- * context. This is the load-bearing two-zone enforcement: raw stale
9
- * content never crosses the historical/canonical boundary.
10
- */
11
- import { readdirSync, readFileSync, statSync } from "node:fs";
12
- import { basename, join, relative } from "node:path";
13
- import { matchAnyGlob } from "@isaacriehm/cairn-state";
14
- const DEFAULT_MAX_BYTES_PER_FILE = 32 * 1024;
15
- const DEFAULT_MAX_BYTES_TOTAL = 200 * 1024;
16
- const DEFAULT_MAX_FILES = 40;
17
- const CONTENT_EXTENSIONS = new Set([
18
- ".md",
19
- ".markdown",
20
- ".yaml",
21
- ".yml",
22
- ".json",
23
- ".txt",
24
- ".sql",
25
- ]);
26
- const BUCKET_DATE_RE = /^(\d{4}-\d{2}-\d{2})/;
27
- /**
28
- * Walks `<repoRoot>/.archive/` collecting matching files. Returns content
29
- * inline so the summarizer can build a prompt without re-reading.
30
- */
31
- export function walkArchive(opts) {
32
- const archiveRoot = join(opts.repoRoot, ".archive");
33
- const maxBytesPerFile = opts.maxBytesPerFile ?? DEFAULT_MAX_BYTES_PER_FILE;
34
- const maxBytesTotal = opts.maxBytesTotal ?? DEFAULT_MAX_BYTES_TOTAL;
35
- const maxFiles = opts.maxFiles ?? DEFAULT_MAX_FILES;
36
- const files = [];
37
- const bucketsScanned = [];
38
- let totalBytes = 0;
39
- let capHit = false;
40
- let topEntries;
41
- try {
42
- topEntries = readdirSync(archiveRoot, { withFileTypes: true, encoding: "utf8" });
43
- }
44
- catch {
45
- return { files: [], capHit: false, totalBytes: 0, bucketsScanned: [] };
46
- }
47
- for (const top of topEntries) {
48
- if (!top.isDirectory())
49
- continue;
50
- bucketsScanned.push(top.name);
51
- }
52
- bucketsScanned.sort();
53
- // DFS per bucket; caps bound total output regardless of traversal order.
54
- const stack = bucketsScanned.map((b) => ({
55
- absDir: join(archiveRoot, b),
56
- bucket: b,
57
- }));
58
- while (stack.length > 0 && files.length < maxFiles) {
59
- const cur = stack.pop();
60
- if (cur === undefined)
61
- break;
62
- let entries;
63
- try {
64
- entries = readdirSync(cur.absDir, { withFileTypes: true, encoding: "utf8" });
65
- }
66
- catch {
67
- continue;
68
- }
69
- for (const e of entries) {
70
- const abs = join(cur.absDir, e.name);
71
- if (e.isDirectory()) {
72
- stack.push({ absDir: abs, bucket: cur.bucket });
73
- continue;
74
- }
75
- if (!e.isFile())
76
- continue;
77
- if (!hasContentExtension(e.name))
78
- continue;
79
- const rel = relative(opts.repoRoot, abs).replace(/\\/g, "/");
80
- if (opts.pathHint && opts.pathHint.length > 0) {
81
- if (!matchAnyGlob(rel, [opts.pathHint]))
82
- continue;
83
- }
84
- const archiveDate = inferArchiveDate(cur.bucket, abs);
85
- if (!withinDateWindow(archiveDate, opts.since, opts.until))
86
- continue;
87
- let buf;
88
- try {
89
- buf = readFileSync(abs);
90
- }
91
- catch {
92
- continue;
93
- }
94
- const bytesOriginal = buf.byteLength;
95
- if (totalBytes + Math.min(bytesOriginal, maxBytesPerFile) > maxBytesTotal) {
96
- capHit = true;
97
- continue;
98
- }
99
- const truncated = bytesOriginal > maxBytesPerFile;
100
- const content = truncated
101
- ? buf.subarray(0, maxBytesPerFile).toString("utf8") + "\n…[truncated]"
102
- : buf.toString("utf8");
103
- totalBytes += truncated ? maxBytesPerFile : bytesOriginal;
104
- files.push({
105
- absPath: abs,
106
- relPath: rel,
107
- archiveDate,
108
- bucket: cur.bucket,
109
- content,
110
- bytesOriginal,
111
- truncated,
112
- });
113
- if (files.length >= maxFiles) {
114
- capHit = true;
115
- break;
116
- }
117
- }
118
- }
119
- files.sort((a, b) => a.relPath.localeCompare(b.relPath));
120
- return { files, capHit, totalBytes, bucketsScanned };
121
- }
122
- function hasContentExtension(name) {
123
- const dot = name.lastIndexOf(".");
124
- if (dot === -1)
125
- return false;
126
- const ext = name.slice(dot).toLowerCase();
127
- return CONTENT_EXTENSIONS.has(ext);
128
- }
129
- function inferArchiveDate(bucket, absPath) {
130
- const match = BUCKET_DATE_RE.exec(basename(bucket));
131
- if (match?.[1])
132
- return `${match[1]}T00:00:00Z`;
133
- try {
134
- return new Date(statSync(absPath).mtimeMs).toISOString();
135
- }
136
- catch {
137
- return new Date(0).toISOString();
138
- }
139
- }
140
- function withinDateWindow(date, since, until) {
141
- const t = Date.parse(date);
142
- if (Number.isNaN(t))
143
- return true;
144
- if (since !== undefined) {
145
- const s = Date.parse(since);
146
- if (!Number.isNaN(s) && t < s)
147
- return false;
148
- }
149
- if (until !== undefined) {
150
- const u = Date.parse(until);
151
- if (!Number.isNaN(u) && t > u)
152
- return false;
153
- }
154
- return true;
155
- }
156
- //# sourceMappingURL=walker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"walker.js","sourceRoot":"","sources":["../../../src/mcp/history/walker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAe,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AA+CvD,MAAM,0BAA0B,GAAG,EAAE,GAAG,IAAI,CAAC;AAC7C,MAAM,uBAAuB,GAAG,GAAG,GAAG,IAAI,CAAC;AAC3C,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC;IACjC,KAAK;IACL,WAAW;IACX,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;CACP,CAAC,CAAC;AAEH,MAAM,cAAc,GAAG,sBAAsB,CAAC;AAE9C;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,IAAwB;IAClD,MAAM,WAAW,GAAG,IAAI,CAAC,I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AM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC5B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC;IAC9C,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -1,20 +0,0 @@
1
- /**
2
- * cairn_query_history — the only sanctioned read path into .archive/.
3
- *
4
- * Walks .archive/ matching path_hint + date window, runs a Tier-1 (Haiku)
5
- * summarizer over the matched files, returns structured per-claim
6
- * records with source citations and supersedes-tags. The agent never
7
- * sees raw stale content — only the summary.
8
- *
9
- * Per MCP_SURFACE.md §"cairn_query_history". Implementation lives in
10
- * src/mcp/history/.
11
- */
12
- import type { ToolDef } from "./types.js";
13
- interface Input {
14
- scope: string;
15
- path_hint?: string;
16
- since?: string;
17
- until?: string;
18
- }
19
- export declare const queryHistoryTool: ToolDef<Input>;
20
- export {};
@@ -1,51 +0,0 @@
1
- /**
2
- * cairn_query_history — the only sanctioned read path into .archive/.
3
- *
4
- * Walks .archive/ matching path_hint + date window, runs a Tier-1 (Haiku)
5
- * summarizer over the matched files, returns structured per-claim
6
- * records with source citations and supersedes-tags. The agent never
7
- * sees raw stale content — only the summary.
8
- *
9
- * Per MCP_SURFACE.md §"cairn_query_history". Implementation lives in
10
- * src/mcp/history/.
11
- */
12
- import { mcpError } from "../errors.js";
13
- import { isQuotaKind, ClaudeError, classifyClaudeError, } from "../../claude/index.js";
14
- import { runQueryHistory } from "../history/summarizer.js";
15
- import { queryHistoryInput } from "../schemas.js";
16
- async function handler(ctx, input) {
17
- try {
18
- const args = {
19
- repoRoot: ctx.repoRoot,
20
- scope: input.scope,
21
- };
22
- if (input.path_hint !== undefined)
23
- args.pathHint = input.path_hint;
24
- if (input.since !== undefined)
25
- args.since = input.since;
26
- if (input.until !== undefined)
27
- args.until = input.until;
28
- return await runQueryHistory(args);
29
- }
30
- catch (err) {
31
- if (err instanceof ClaudeError) {
32
- if (isQuotaKind(err.kind)) {
33
- return mcpError("OPERATION_TIMEOUT", `history summarizer quota / rate-limit: ${err.message}`, { kind: err.kind, exit_code: err.exitCode ?? null });
34
- }
35
- return mcpError("INTERNAL_ERROR", `history summarizer call failed: ${err.message}`, { kind: err.kind, exit_code: err.exitCode ?? null });
36
- }
37
- const kind = classifyClaudeError({
38
- message: err instanceof Error ? err.message : String(err),
39
- exitCode: null,
40
- stderr: "",
41
- });
42
- return mcpError("INTERNAL_ERROR", `history summarizer threw: ${err instanceof Error ? err.message : String(err)}`, { kind });
43
- }
44
- }
45
- export const queryHistoryTool = {
46
- name: "cairn_query_history",
47
- description: "Returns summarized historical claims from .archive/ via Tier-1 LLM. Walks the archive by path_hint + since/until, summarizes per-claim with source citations and supersedes-tags. Raw archive content never enters agent context — only the structured summary does. The only sanctioned path into .archive/.",
48
- inputSchema: queryHistoryInput,
49
- handler,
50
- };
51
- //# sourceMappingURL=query-history.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"query-history.js","sourceRoot":"","sources":["../../../src/mcp/tools/query-history.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EACL,WAAW,EACX,WAAW,EACX,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAUlD,KAAK,UAAU,OAAO,CAAC,GAAe,EAAE,KAAY;IAClD,IAAI,CAAC;QACH,MAAM,IAAI,GAA0C;YAClD,QAAQ,EAAE,GAAG,CAAC,QAAQ;YACtB,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB,CAAC;QACF,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS;YAAE,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,SAAS,CAAC;QACnE,IAAI,KA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,EAAE,qBAAqB;IAC3B,WAAW,EACT,+SAA+S;IACjT,WAAW,EAAE,iBAAiB;IAC9B,OAAO;CACR,CAAC"}
@@ -1,67 +0,0 @@
1
- ---
2
- type: rule
3
- status: accepted
4
- audience: dual
5
- generated: 2026-05-02T13:19:00Z
6
- verified-at: 2026-05-02T13:19:00Z
7
- source-commits:
8
- - manual
9
- ---
10
-
11
- # `.archive/` — quarantine zone
12
-
13
- This directory holds files that were once canonical but are no longer current. **It is committed history, not deletion.** Per `docs/FILESYSTEM_LAYOUT.md` §2 it is Cairn's `historical` zone.
14
-
15
- ## What lives here
16
-
17
- - Pre-Cairn state files moved out at adoption (e.g. `2026-05-pre-cairn/STATE.md`)
18
- - Documents superseded by an ADR (the new ADR cites the archived path)
19
- - Stale generated artifacts whose source has been removed
20
- - Completed runs' terminal artifacts (auto-moved by Cairn)
21
-
22
- ## What does NOT live here
23
-
24
- - Files marked `[STALE]` in canonical paths — Cairn rejects this pattern. Stale files are MOVED here, never banner-flagged in place.
25
- - Branches or tagged refs — `.archive/` is filesystem-only.
26
- - Secrets — `.env*` patterns stay in `.gitignore` regardless.
27
-
28
- ## Layout convention
29
-
30
- ```
31
- .archive/
32
- ├── README.md
33
- ├── 2026-05-pre-cairn/ ← one bucket per migration / adoption / cleanup wave
34
- │ └── <original-path> ← preserves the file's prior path inside the bucket
35
- └── <YYYY-MM-DD>/ ← daily quarantine drops
36
- └── <original-path>
37
- ```
38
-
39
- ## Reading from `.archive/`
40
-
41
- Agents do **not** read this directory directly. Soft enforcement, three layers:
42
-
43
- 1. The `cairn hook session-start` SessionStart hook injects a reminder instructing the agent that historical paths are off-default.
44
- 2. Cairn walkers (manifest build, GC sweep, sensor scans) exclude `.archive/` from canonical-zone reads.
45
- 3. The only sanctioned read path is the MCP tool:
46
-
47
- ```
48
- cairn_query_history(scope, question)
49
- ```
50
-
51
- `cairn_query_history` walks `.archive/` (matched by `path_hint` + `since`/`until`), runs a Tier-1 Haiku summarizer, and returns structured per-claim records with source citations and supersedes-pointers. The agent receives only the summary — raw stale content never enters its context.
52
-
53
- PreToolUse-style interception is **not** used (operator decision 2026-05-04). The combination of SessionStart instruction + walker exclusion + `cairn_query_history` is sufficient and avoids the brittleness of a hot-path tool-call hook.
54
-
55
- ## Writing to `.archive/`
56
-
57
- Only via `cairn_archive(path, reason)`. Direct moves are accepted but discouraged because they bypass the audit log. The MCP tool records the reason and timestamp.
58
-
59
- ## Why we don't delete
60
-
61
- 1. Decisions cite archived paths. Deletion breaks the audit trail.
62
- 2. The init script's mapper agent learns from prior moves what's project-specific.
63
- 3. Historical context is occasionally re-needed (e.g. confirming an old decision's premise). Quarantine preserves that without polluting canonical reads.
64
-
65
- ## Restoring an archived file
66
-
67
- `cairn restore <path>` (CLI subcommand, future) — moves a file out of `.archive/<bucket>/` back to its original location and logs the restoration. Use sparingly.