@isaacriehm/cairn-core 0.23.0 → 0.24.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.
Files changed (44) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/context/index.d.ts +2 -0
  3. package/dist/context/index.js +1 -0
  4. package/dist/context/index.js.map +1 -1
  5. package/dist/context/task-summary.d.ts +18 -0
  6. package/dist/context/task-summary.js +94 -23
  7. package/dist/context/task-summary.js.map +1 -1
  8. package/dist/context/working-header.d.ts +29 -0
  9. package/dist/context/working-header.js +125 -0
  10. package/dist/context/working-header.js.map +1 -0
  11. package/dist/hooks/post-tool-use/post-write.js +16 -0
  12. package/dist/hooks/post-tool-use/post-write.js.map +1 -1
  13. package/dist/hooks/post-tool-use/read-enricher.js +96 -4
  14. package/dist/hooks/post-tool-use/read-enricher.js.map +1 -1
  15. package/dist/hooks/runners/annotate-surface.d.ts +41 -0
  16. package/dist/hooks/runners/annotate-surface.js +152 -0
  17. package/dist/hooks/runners/annotate-surface.js.map +1 -0
  18. package/dist/hooks/runners/stop.js +26 -0
  19. package/dist/hooks/runners/stop.js.map +1 -1
  20. package/dist/hooks/runners/user-prompt-submit.js +59 -9
  21. package/dist/hooks/runners/user-prompt-submit.js.map +1 -1
  22. package/dist/mcp/schemas.d.ts +27 -1
  23. package/dist/mcp/schemas.js +22 -0
  24. package/dist/mcp/schemas.js.map +1 -1
  25. package/dist/mcp/tools/component-annotate.d.ts +33 -0
  26. package/dist/mcp/tools/component-annotate.js +189 -0
  27. package/dist/mcp/tools/component-annotate.js.map +1 -0
  28. package/dist/mcp/tools/index.js +3 -1
  29. package/dist/mcp/tools/index.js.map +1 -1
  30. package/dist/mcp/tools/resume.js +10 -34
  31. package/dist/mcp/tools/resume.js.map +1 -1
  32. package/dist/session/index.d.ts +2 -0
  33. package/dist/session/index.js +2 -0
  34. package/dist/session/index.js.map +1 -1
  35. package/dist/session/seen.d.ts +37 -0
  36. package/dist/session/seen.js +110 -0
  37. package/dist/session/seen.js.map +1 -0
  38. package/dist/session/touched.d.ts +17 -0
  39. package/dist/session/touched.js +57 -0
  40. package/dist/session/touched.js.map +1 -0
  41. package/dist/tasks/spec-reader.d.ts +27 -0
  42. package/dist/tasks/spec-reader.js +60 -0
  43. package/dist/tasks/spec-reader.js.map +1 -0
  44. package/package.json +2 -2
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Shared `spec.tightened.md` frontmatter + `## Goal` reader.
3
+ *
4
+ * Factored out of `cairn_resume` (mcp/tools/resume.ts) so both the
5
+ * resume payload AND the UserPromptSubmit working-header (context
6
+ * engine, stage 1) read the spec the same way — one parse, no drift.
7
+ * The parse is verbatim from the original resume.ts implementation.
8
+ *
9
+ * Returns null when the task has no `spec.tightened.md` yet (e.g. a
10
+ * task still in `queued`/`tightening`). Malformed frontmatter degrades
11
+ * to defaults rather than throwing — callers run inside hooks that must
12
+ * never crash the agent loop.
13
+ */
14
+ import { existsSync, readFileSync } from "node:fs";
15
+ import { join } from "node:path";
16
+ import { parse as parseYaml } from "yaml";
17
+ /**
18
+ * Read `<taskDir>/spec.tightened.md`'s frontmatter (`title`,
19
+ * `in_scope_decisions[]`, `in_scope_invariants[]`, `target_path_globs[]`)
20
+ * and the body's `## Goal` section. `taskDir` is the absolute task
21
+ * directory (active or done). Returns null when the spec file is absent.
22
+ */
23
+ export function readTaskSpec(taskDir) {
24
+ const specPath = join(taskDir, "spec.tightened.md");
25
+ if (!existsSync(specPath))
26
+ return null;
27
+ let title = "";
28
+ let goal = "";
29
+ let inScopeDecisions = [];
30
+ let inScopeInvariants = [];
31
+ let targetPathGlobs = [];
32
+ const raw = readFileSync(specPath, "utf8");
33
+ const fmMatch = raw.match(/^---\r?\n([\s\S]*?)\n---\r?\n([\s\S]*)$/);
34
+ if (fmMatch) {
35
+ try {
36
+ const fm = parseYaml(fmMatch[1] ?? "");
37
+ if (typeof fm.title === "string")
38
+ title = fm.title;
39
+ if (Array.isArray(fm.in_scope_decisions)) {
40
+ inScopeDecisions = fm.in_scope_decisions.filter((x) => typeof x === "string");
41
+ }
42
+ if (Array.isArray(fm.in_scope_invariants)) {
43
+ inScopeInvariants = fm.in_scope_invariants.filter((x) => typeof x === "string");
44
+ }
45
+ if (Array.isArray(fm.target_path_globs)) {
46
+ targetPathGlobs = fm.target_path_globs.filter((x) => typeof x === "string");
47
+ }
48
+ }
49
+ catch {
50
+ // malformed frontmatter — fall through with defaults
51
+ }
52
+ const body = fmMatch[2] ?? "";
53
+ const goalMatch = body.match(/##\s+Goal\s*\r?\n+([\s\S]*?)(?:\r?\n##\s+|$)/);
54
+ if (goalMatch && goalMatch[1] !== undefined) {
55
+ goal = goalMatch[1].trim();
56
+ }
57
+ }
58
+ return { title, goal, inScopeDecisions, inScopeInvariants, targetPathGlobs };
59
+ }
60
+ //# sourceMappingURL=spec-reader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spec-reader.js","sourceRoot":"","sources":["../../src/tasks/spec-reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAiB1C;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;IACpD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO,IAAI,CAAC;IAEvC,IAAI,KAAK,GAAG,EAAE,CAAC;IACf,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,IAAI,gBAAgB,GAAa,EAAE,CAAC;IACpC,IAAI,iBAAiB,GAAa,EAAE,CAAC;IACrC,IAAI,eAAe,GAAa,EAAE,CAAC;IAEnC,MAAM,GAAG,GAA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SAAS,EAAE,CAAC;YAC5C,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,eAAe,EAAE,CAAC;AAC/E,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@isaacriehm/cairn-core",
3
- "version": "0.23.0",
3
+ "version": "0.24.0",
4
4
  "description": "Cairn core — state + context layer. Curated `.cairn/ground/` (decisions, §INV invariants, canonical-map, brand, quality-grades), MCP server, init wizard, hook runners, sensors, GC drift sweep.",
5
5
  "author": "Isaac Riehm",
6
6
  "license": "MIT",
@@ -39,7 +39,7 @@
39
39
  "simple-git": "^3.36.0",
40
40
  "yaml": "^2.9.0",
41
41
  "zod": "^4.4.3",
42
- "@isaacriehm/cairn-state": "0.23.0"
42
+ "@isaacriehm/cairn-state": "0.24.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/cli-progress": "^3.11.6",