@isaacriehm/cairn-core 0.7.3 → 0.9.1

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 (229) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/attention/bulk-accept.d.ts +0 -2
  3. package/dist/attention/bulk-accept.js +0 -3
  4. package/dist/attention/bulk-accept.js.map +1 -1
  5. package/dist/attention/scoring.d.ts +1 -3
  6. package/dist/attention/scoring.js +1 -12
  7. package/dist/attention/scoring.js.map +1 -1
  8. package/dist/claude/cache.js +1 -0
  9. package/dist/claude/cache.js.map +1 -1
  10. package/dist/claude/runner.js +25 -1
  11. package/dist/claude/runner.js.map +1 -1
  12. package/dist/claude/types.d.ts +8 -0
  13. package/dist/doctor/index.js +57 -0
  14. package/dist/doctor/index.js.map +1 -1
  15. package/dist/gc/citation-integrity.js +3 -1
  16. package/dist/gc/citation-integrity.js.map +1 -1
  17. package/dist/gc/doc-claims.d.ts +31 -0
  18. package/dist/gc/doc-claims.js +213 -0
  19. package/dist/gc/doc-claims.js.map +1 -0
  20. package/dist/gc/doc-source-drift.d.ts +31 -0
  21. package/dist/gc/doc-source-drift.js +190 -0
  22. package/dist/gc/doc-source-drift.js.map +1 -0
  23. package/dist/gc/index.d.ts +4 -0
  24. package/dist/gc/index.js +2 -0
  25. package/dist/gc/index.js.map +1 -1
  26. package/dist/gc/sweep.js +18 -0
  27. package/dist/gc/sweep.js.map +1 -1
  28. package/dist/gc/types.d.ts +2 -2
  29. package/dist/hooks/runners/context-threshold.d.ts +63 -0
  30. package/dist/hooks/runners/context-threshold.js +179 -0
  31. package/dist/hooks/runners/context-threshold.js.map +1 -0
  32. package/dist/hooks/runners/gc-autotrigger.d.ts +49 -0
  33. package/dist/hooks/runners/gc-autotrigger.js +87 -0
  34. package/dist/hooks/runners/gc-autotrigger.js.map +1 -0
  35. package/dist/hooks/runners/index.d.ts +2 -0
  36. package/dist/hooks/runners/index.js +1 -0
  37. package/dist/hooks/runners/index.js.map +1 -1
  38. package/dist/hooks/runners/payload.d.ts +10 -0
  39. package/dist/hooks/runners/payload.js +13 -0
  40. package/dist/hooks/runners/payload.js.map +1 -1
  41. package/dist/hooks/runners/session-end.js +2 -4
  42. package/dist/hooks/runners/session-end.js.map +1 -1
  43. package/dist/hooks/runners/session-start.js +157 -9
  44. package/dist/hooks/runners/session-start.js.map +1 -1
  45. package/dist/hooks/runners/stop.js +119 -0
  46. package/dist/hooks/runners/stop.js.map +1 -1
  47. package/dist/init/brand-derive.js +6 -1
  48. package/dist/init/brand-derive.js.map +1 -1
  49. package/dist/init/brand-setup.d.ts +12 -1
  50. package/dist/init/brand-setup.js +36 -1
  51. package/dist/init/brand-setup.js.map +1 -1
  52. package/dist/init/curator/corpus.d.ts +92 -0
  53. package/dist/init/curator/corpus.js +171 -0
  54. package/dist/init/curator/corpus.js.map +1 -0
  55. package/dist/init/curator/emit.d.ts +42 -0
  56. package/dist/init/curator/emit.js +230 -0
  57. package/dist/init/curator/emit.js.map +1 -0
  58. package/dist/init/curator/index.d.ts +1 -0
  59. package/dist/init/curator/index.js +2 -0
  60. package/dist/init/curator/index.js.map +1 -0
  61. package/dist/init/curator/regex-prefilter.d.ts +54 -0
  62. package/dist/init/curator/regex-prefilter.js +185 -0
  63. package/dist/init/curator/regex-prefilter.js.map +1 -0
  64. package/dist/init/curator/validate.d.ts +46 -0
  65. package/dist/init/curator/validate.js +100 -0
  66. package/dist/init/curator/validate.js.map +1 -0
  67. package/dist/init/curator/walker.d.ts +36 -0
  68. package/dist/init/curator/walker.js +380 -0
  69. package/dist/init/curator/walker.js.map +1 -0
  70. package/dist/init/eta-calibration.d.ts +39 -0
  71. package/dist/init/eta-calibration.js +143 -0
  72. package/dist/init/eta-calibration.js.map +1 -0
  73. package/dist/init/index.d.ts +8 -3
  74. package/dist/init/index.js +4 -1
  75. package/dist/init/index.js.map +1 -1
  76. package/dist/init/ingest-docs.d.ts +6 -1
  77. package/dist/init/ingest-docs.js.map +1 -1
  78. package/dist/init/init.js +15 -26
  79. package/dist/init/init.js.map +1 -1
  80. package/dist/init/mapper-merge.d.ts +4 -6
  81. package/dist/init/mapper-merge.js +11 -34
  82. package/dist/init/mapper-merge.js.map +1 -1
  83. package/dist/init/mapper-parallel.d.ts +0 -1
  84. package/dist/init/mapper-parallel.js +20 -12
  85. package/dist/init/mapper-parallel.js.map +1 -1
  86. package/dist/init/mapper-prompts.d.ts +1 -4
  87. package/dist/init/mapper-prompts.js +2 -6
  88. package/dist/init/mapper-prompts.js.map +1 -1
  89. package/dist/init/mapper.d.ts +8 -7
  90. package/dist/init/mapper.js +23 -15
  91. package/dist/init/mapper.js.map +1 -1
  92. package/dist/init/overlay.js +0 -1
  93. package/dist/init/overlay.js.map +1 -1
  94. package/dist/init/phases/1-detect.d.ts +17 -4
  95. package/dist/init/phases/1-detect.js +48 -4
  96. package/dist/init/phases/1-detect.js.map +1 -1
  97. package/dist/init/phases/10-rules-merge.d.ts +7 -2
  98. package/dist/init/phases/10-rules-merge.js +17 -32
  99. package/dist/init/phases/10-rules-merge.js.map +1 -1
  100. package/dist/init/phases/11-baseline.js.map +1 -1
  101. package/dist/init/phases/12-strip.js +14 -1
  102. package/dist/init/phases/12-strip.js.map +1 -1
  103. package/dist/init/phases/13-multidev.d.ts +5 -1
  104. package/dist/init/phases/13-multidev.js +23 -2
  105. package/dist/init/phases/13-multidev.js.map +1 -1
  106. package/dist/init/phases/3-mapper.js.map +1 -1
  107. package/dist/init/phases/4-seed.js +2 -3
  108. package/dist/init/phases/4-seed.js.map +1 -1
  109. package/dist/init/phases/5-preflight.d.ts +42 -0
  110. package/dist/init/phases/5-preflight.js +244 -0
  111. package/dist/init/phases/5-preflight.js.map +1 -0
  112. package/dist/init/phases/6-brand.js +2 -4
  113. package/dist/init/phases/6-brand.js.map +1 -1
  114. package/dist/init/phases/7-topic-index.d.ts +6 -0
  115. package/dist/init/phases/7-topic-index.js +13 -0
  116. package/dist/init/phases/7-topic-index.js.map +1 -1
  117. package/dist/init/phases/8-docs-ingest.d.ts +6 -5
  118. package/dist/init/phases/8-docs-ingest.js +16 -43
  119. package/dist/init/phases/8-docs-ingest.js.map +1 -1
  120. package/dist/init/phases/9a-walker.d.ts +15 -0
  121. package/dist/init/phases/9a-walker.js +63 -0
  122. package/dist/init/phases/9a-walker.js.map +1 -0
  123. package/dist/init/phases/9b-curate.d.ts +19 -0
  124. package/dist/init/phases/9b-curate.js +79 -0
  125. package/dist/init/phases/9b-curate.js.map +1 -0
  126. package/dist/init/phases/9c-emit.d.ts +13 -0
  127. package/dist/init/phases/9c-emit.js +57 -0
  128. package/dist/init/phases/9c-emit.js.map +1 -0
  129. package/dist/init/phases/index.d.ts +6 -5
  130. package/dist/init/phases/index.js +4 -4
  131. package/dist/init/phases/index.js.map +1 -1
  132. package/dist/init/phases/mapper-output-io.d.ts +5 -5
  133. package/dist/init/phases/mapper-output-io.js +5 -5
  134. package/dist/init/phases/orchestrator.d.ts +10 -0
  135. package/dist/init/phases/orchestrator.js +13 -1
  136. package/dist/init/phases/orchestrator.js.map +1 -1
  137. package/dist/init/phases/state-io.js +1 -1
  138. package/dist/init/phases/types.d.ts +115 -9
  139. package/dist/init/phases/types.js +4 -2
  140. package/dist/init/phases/types.js.map +1 -1
  141. package/dist/init/post-git-init.d.ts +53 -0
  142. package/dist/init/post-git-init.js +74 -0
  143. package/dist/init/post-git-init.js.map +1 -0
  144. package/dist/init/preflight-guards.d.ts +11 -2
  145. package/dist/init/preflight-guards.js +27 -5
  146. package/dist/init/preflight-guards.js.map +1 -1
  147. package/dist/init/rules-merge/index.d.ts +1 -1
  148. package/dist/init/rules-merge/ingest.d.ts +6 -1
  149. package/dist/init/rules-merge/ingest.js.map +1 -1
  150. package/dist/init/skill-budget.d.ts +39 -0
  151. package/dist/init/skill-budget.js +99 -0
  152. package/dist/init/skill-budget.js.map +1 -0
  153. package/dist/init/source-comments/ingest.d.ts +0 -2
  154. package/dist/init/source-comments/ingest.js.map +1 -1
  155. package/dist/init/source-comments/walker.js +2 -2
  156. package/dist/init/topic-index/index.d.ts +8 -0
  157. package/dist/init/topic-index/index.js +10 -2
  158. package/dist/init/topic-index/index.js.map +1 -1
  159. package/dist/init/topic-index/judge.d.ts +15 -0
  160. package/dist/init/topic-index/judge.js +15 -1
  161. package/dist/init/topic-index/judge.js.map +1 -1
  162. package/dist/init/topic-index/resolve.js +41 -14
  163. package/dist/init/topic-index/resolve.js.map +1 -1
  164. package/dist/init/types.d.ts +9 -0
  165. package/dist/init/walker.d.ts +1 -1
  166. package/dist/init/walker.js +1 -1
  167. package/dist/init/workflow-block.d.ts +5 -6
  168. package/dist/init/workflow-block.js +5 -9
  169. package/dist/init/workflow-block.js.map +1 -1
  170. package/dist/mcp/bootstrap-guard.js +2 -2
  171. package/dist/mcp/bootstrap-guard.js.map +1 -1
  172. package/dist/mcp/schemas.d.ts +34 -0
  173. package/dist/mcp/schemas.js +50 -0
  174. package/dist/mcp/schemas.js.map +1 -1
  175. package/dist/mcp/telemetry.d.ts +1 -1
  176. package/dist/mcp/tools/bootstrap-retry.d.ts +23 -0
  177. package/dist/mcp/tools/bootstrap-retry.js +53 -0
  178. package/dist/mcp/tools/bootstrap-retry.js.map +1 -0
  179. package/dist/mcp/tools/bulk-accept-attention.d.ts +1 -1
  180. package/dist/mcp/tools/bulk-accept-attention.js +4 -6
  181. package/dist/mcp/tools/bulk-accept-attention.js.map +1 -1
  182. package/dist/mcp/tools/index.js +10 -0
  183. package/dist/mcp/tools/index.js.map +1 -1
  184. package/dist/mcp/tools/init-phases.d.ts +7 -6
  185. package/dist/mcp/tools/init-phases.js +36 -65
  186. package/dist/mcp/tools/init-phases.js.map +1 -1
  187. package/dist/mcp/tools/resume.d.ts +21 -0
  188. package/dist/mcp/tools/resume.js +88 -0
  189. package/dist/mcp/tools/resume.js.map +1 -0
  190. package/dist/mcp/tools/task-complete.d.ts +23 -0
  191. package/dist/mcp/tools/task-complete.js +51 -0
  192. package/dist/mcp/tools/task-complete.js.map +1 -0
  193. package/dist/mcp/tools/task-create.js +17 -11
  194. package/dist/mcp/tools/task-create.js.map +1 -1
  195. package/dist/mcp/tools/task-journal-append.d.ts +22 -0
  196. package/dist/mcp/tools/task-journal-append.js +44 -0
  197. package/dist/mcp/tools/task-journal-append.js.map +1 -0
  198. package/dist/paths/index.js +1 -1
  199. package/dist/paths/index.js.map +1 -1
  200. package/dist/status-line/format.js +20 -0
  201. package/dist/status-line/format.js.map +1 -1
  202. package/dist/tasks/index.d.ts +2 -0
  203. package/dist/tasks/index.js +2 -0
  204. package/dist/tasks/index.js.map +1 -0
  205. package/dist/tasks/lifecycle.d.ts +107 -0
  206. package/dist/tasks/lifecycle.js +302 -0
  207. package/dist/tasks/lifecycle.js.map +1 -0
  208. package/dist/trace/index.d.ts +1 -1
  209. package/dist/trace/index.js +2 -2
  210. package/dist/trace/index.js.map +1 -1
  211. package/package.json +2 -2
  212. package/templates/.cairn/config/trust-policy.yaml +0 -3
  213. package/templates/.cairn/config/workflow.md +0 -1
  214. package/templates/.cairn/ground/canonical-map/topics.yaml +0 -12
  215. package/dist/init/phases/5-pilot.d.ts +0 -10
  216. package/dist/init/phases/5-pilot.js +0 -108
  217. package/dist/init/phases/5-pilot.js.map +0 -1
  218. package/dist/init/phases/9-source-comments.d.ts +0 -6
  219. package/dist/init/phases/9-source-comments.js +0 -55
  220. package/dist/init/phases/9-source-comments.js.map +0 -1
  221. package/dist/init/phases/parallel-8910.d.ts +0 -27
  222. package/dist/init/phases/parallel-8910.js +0 -172
  223. package/dist/init/phases/parallel-8910.js.map +0 -1
  224. package/dist/init/phases/source-comments-output-io.d.ts +0 -84
  225. package/dist/init/phases/source-comments-output-io.js +0 -81
  226. package/dist/init/phases/source-comments-output-io.js.map +0 -1
  227. package/templates/.cairn/ground/capabilities/mcp-tools.yaml +0 -29
  228. package/templates/.cairn/ground/capabilities/skills.yaml +0 -25
  229. package/templates/.cairn/ground/capabilities/snippets.yaml +0 -29
@@ -1 +1 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1B,OAAO,EAAE,gCAAgC;gBACzC,MAAM,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;aACtE;YACD,KAAK;SACN,CAAC;IACJ,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"8-docs-ingest.js","sourceRoot":"","sources":["../../../src/init/phases/8-docs-ingest.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,KAAiB;IACzD,MAAM,GAAG,GAAoB,EAAE,OAAO,EAAE,uBAAuB,EAAE,CAAC;IAClE,MAAM,IAAI,GAAe;QACvB,GAAG,KAAK;QACR,OAAO,EAAE,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,EAAE;KACpD,CAAC;IACF,OAAO;QACL,MAAM,EAAE,UAAU;QAClB,SAAS,EAAE,WAAW;QACtB,KAAK,EAAE,YAAY,CAAC,IAAI,CAAC;KAC1B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Phase 9a-walker — unified curator corpus walker (v0.9.0).
3
+ *
4
+ * Stub. Real implementation in a follow-up commit walks source
5
+ * comments + doc paragraphs + rule sections, applies the regex
6
+ * pre-filter from `curator/regex-prefilter.ts`, packs surviving
7
+ * records into shards capped at 120k input tokens, and writes
8
+ * `corpus.jsonl` + `shards.json` to `.cairn/init/curator/`.
9
+ *
10
+ * The cairn-adopt skill reads `shards.json` after this phase
11
+ * completes and dispatches `cairn:curator-map` subagents in parallel
12
+ * rounds of 4.
13
+ */
14
+ import type { PhaseResult, PhaseState } from "./types.js";
15
+ export declare function runPhase9aWalker(state: PhaseState): Promise<PhaseResult>;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Phase 9a-walker — unified curator corpus walker (v0.9.0).
3
+ *
4
+ * Stub. Real implementation in a follow-up commit walks source
5
+ * comments + doc paragraphs + rule sections, applies the regex
6
+ * pre-filter from `curator/regex-prefilter.ts`, packs surviving
7
+ * records into shards capped at 120k input tokens, and writes
8
+ * `corpus.jsonl` + `shards.json` to `.cairn/init/curator/`.
9
+ *
10
+ * The cairn-adopt skill reads `shards.json` after this phase
11
+ * completes and dispatches `cairn:curator-map` subagents in parallel
12
+ * rounds of 4.
13
+ */
14
+ import { advancePhase, isSelfAdoptState } from "./orchestrator.js";
15
+ export async function runPhase9aWalker(state) {
16
+ if (isSelfAdoptState(state)) {
17
+ const skipped = { skipped: "self-adopt" };
18
+ const next = {
19
+ ...state,
20
+ outputs: { ...state.outputs, "9a-walker": skipped },
21
+ };
22
+ return {
23
+ status: "complete",
24
+ nextPhase: "9b-curate",
25
+ state: advancePhase(next),
26
+ };
27
+ }
28
+ // Real walker plugged in by `runCuratorWalker`.
29
+ try {
30
+ const { runCuratorWalker } = await import("../curator/walker.js");
31
+ const walker = await runCuratorWalker({ repoRoot: state.repoRoot });
32
+ const out = {
33
+ corpus_path: walker.corpus_path,
34
+ shards_path: walker.shards_path,
35
+ records_total: walker.records_total,
36
+ records_by_kind: walker.records_by_kind,
37
+ dropped: walker.dropped,
38
+ shards: walker.shards,
39
+ total_input_tokens_estimate: walker.total_input_tokens_estimate,
40
+ };
41
+ const next = {
42
+ ...state,
43
+ outputs: { ...state.outputs, "9a-walker": out },
44
+ };
45
+ return {
46
+ status: "complete",
47
+ nextPhase: "9b-curate",
48
+ state: advancePhase(next),
49
+ };
50
+ }
51
+ catch (err) {
52
+ return {
53
+ status: "error",
54
+ error: {
55
+ code: "9a-walker-failed",
56
+ message: "Curator walker failed",
57
+ detail: err instanceof Error ? err.stack ?? err.message : String(err),
58
+ },
59
+ state,
60
+ };
61
+ }
62
+ }
63
+ //# sourceMappingURL=9a-walker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"9a-walker.js","source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AClB,SAAS,EAAE,WAAW;YACtB,KAAK,EAAE,YAAY,CAAC,IAAI,CAAC;SAC1B,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO;YACL,MAAM,EAAE,OAAO;YACf,KAAK,EAAE;gBACL,IAAI,EAAE,kBAAkB;gBACxB,OAAO,EAAE,uBAAuB;gBAChC,MAAM,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;aACtE;YACD,KAAK;SACN,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Phase 9b-curate — skill-driven map+reduce dispatch (v0.9.0).
3
+ *
4
+ * The actual map+reduce work runs in the cairn-adopt skill. The skill
5
+ * reads `shards.json` from Phase 9a, spawns `cairn:curator-map`
6
+ * subagents per shard in parallel rounds of 4, then spawns one
7
+ * `cairn:curator-reduce` subagent over the aggregated candidates,
8
+ * writing the final synthesized entries to
9
+ * `.cairn/init/curator/final.jsonl`.
10
+ *
11
+ * This MCP runner is the state-machine bookkeeper for that work — it
12
+ * confirms `final.jsonl` exists, counts entries, advances to 9c-emit.
13
+ * If the skill calls this runner before writing `final.jsonl`, the
14
+ * runner errors so the operator sees a clear "skill orchestration
15
+ * skipped" signal rather than 9c-emit silently emitting zero entries.
16
+ */
17
+ import type { PhaseResult, PhaseState } from "./types.js";
18
+ export declare const CURATOR_FINAL_PATH: string;
19
+ export declare function runPhase9bCurate(state: PhaseState): Promise<PhaseResult>;
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Phase 9b-curate — skill-driven map+reduce dispatch (v0.9.0).
3
+ *
4
+ * The actual map+reduce work runs in the cairn-adopt skill. The skill
5
+ * reads `shards.json` from Phase 9a, spawns `cairn:curator-map`
6
+ * subagents per shard in parallel rounds of 4, then spawns one
7
+ * `cairn:curator-reduce` subagent over the aggregated candidates,
8
+ * writing the final synthesized entries to
9
+ * `.cairn/init/curator/final.jsonl`.
10
+ *
11
+ * This MCP runner is the state-machine bookkeeper for that work — it
12
+ * confirms `final.jsonl` exists, counts entries, advances to 9c-emit.
13
+ * If the skill calls this runner before writing `final.jsonl`, the
14
+ * runner errors so the operator sees a clear "skill orchestration
15
+ * skipped" signal rather than 9c-emit silently emitting zero entries.
16
+ */
17
+ import { existsSync, readFileSync } from "node:fs";
18
+ import { join } from "node:path";
19
+ import { advancePhase, isSelfAdoptState } from "./orchestrator.js";
20
+ export const CURATOR_FINAL_PATH = join(".cairn", "init", "curator", "final.jsonl");
21
+ export async function runPhase9bCurate(state) {
22
+ if (isSelfAdoptState(state)) {
23
+ const skipped = { skipped: "self-adopt" };
24
+ const next = {
25
+ ...state,
26
+ outputs: { ...state.outputs, "9b-curate": skipped },
27
+ };
28
+ return {
29
+ status: "complete",
30
+ nextPhase: "9c-emit",
31
+ state: advancePhase(next),
32
+ };
33
+ }
34
+ const finalAbs = join(state.repoRoot, CURATOR_FINAL_PATH);
35
+ if (!existsSync(finalAbs)) {
36
+ return {
37
+ status: "error",
38
+ error: {
39
+ code: "9b-curate-missing-final",
40
+ message: "Curator skill orchestration did not write final.jsonl. The cairn-adopt skill must dispatch curator-map + curator-reduce subagents before invoking 9b-curate.",
41
+ detail: `Expected file at ${CURATOR_FINAL_PATH}`,
42
+ },
43
+ state,
44
+ };
45
+ }
46
+ let entries = 0;
47
+ try {
48
+ const text = readFileSync(finalAbs, "utf8");
49
+ for (const line of text.split("\n")) {
50
+ if (line.trim().length > 0)
51
+ entries += 1;
52
+ }
53
+ }
54
+ catch (err) {
55
+ return {
56
+ status: "error",
57
+ error: {
58
+ code: "9b-curate-read-failed",
59
+ message: "Failed to read curator final.jsonl",
60
+ detail: err instanceof Error ? err.stack ?? err.message : String(err),
61
+ },
62
+ state,
63
+ };
64
+ }
65
+ const out = {
66
+ final_path: CURATOR_FINAL_PATH,
67
+ final_entries: entries,
68
+ };
69
+ const next = {
70
+ ...state,
71
+ outputs: { ...state.outputs, "9b-curate": out },
72
+ };
73
+ return {
74
+ status: "complete",
75
+ nextPhase: "9c-emit",
76
+ state: advancePhase(next),
77
+ };
78
+ }
79
+ //# sourceMappingURL=9b-curate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"9b-curate.js","sourceRoot":"","sources":["../../../src/init/phases/9b-curate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAGnE,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;AAEnF,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,KAAiB;IACtD,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAiB,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;QACxD,MAAM,IAAI,GAAe;YACvB,GAAG,KAAK;YACR,OAAO,EAAE,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE;SACpD,CAAC;QACF,OAAO;YACL,MAAM,EAAE,UAAU;YAClB,SAAS,EAAE,SAAS;YACpB,KAAK,EAAE,YAAY,CAAC,IAAI,CAAC;SAC1B,CAAC;IACJ,CAAC;IACD,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;IAC1D,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,OAAO;YACL,MAAM,EAAE,OAAO;YACf,KAAK,EAAE;gBACL,IAAI,EAAE,yBAAyB;gBAC/B,OAAO,EACL,8JAA8J;gBAChK,MAAM,EAAE,oBAAoB,kBAAkB,EAAE;aACjD;YACD,KAAK;SACN,CAAC;IACJ,CAAC;IACD,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC5C,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YACpC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;gBAAE,OAAO,IAAI,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO;YACL,MAAM,EAAE,OAAO;YACf,KAAK,EAAE;gBACL,IAAI,EAAE,uBAAuB;gBAC7B,OAAO,EAAE,oCAAoC;gBAC7C,MAAM,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;aACtE;YACD,KAAK;SACN,CAAC;IACJ,CAAC;IACD,MAAM,GAAG,GAAiB;QACxB,UAAU,EAAE,kBAAkB;QAC9B,aAAa,EAAE,OAAO;KACvB,CAAC;IACF,MAAM,IAAI,GAAe;QACvB,GAAG,KAAK;QACR,OAAO,EAAE,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE;KAChD,CAAC;IACF,OAAO;QACL,MAAM,EAAE,UAAU;QAClB,SAAS,EAAE,SAAS;QACpB,KAAK,EAAE,YAAY,CAAC,IAAI,CAAC;KAC1B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Phase 9c-emit — deterministic curator emit (v0.9.0).
3
+ *
4
+ * Reads `.cairn/init/curator/final.jsonl`, validates each entry via
5
+ * the strict validators in `curator/validate.ts`, and writes
6
+ * surviving entries directly to `.cairn/ground/decisions/<id>.md`
7
+ * (DEC) or `.cairn/ground/invariants/<id>.md` (INV) with
8
+ * `status: accepted` / `status: active`. Invalid entries drop
9
+ * silently with a counter — operator's "auto-accept" directive in
10
+ * the curator plan means the bar is hard, not deferred to inbox.
11
+ */
12
+ import type { PhaseResult, PhaseState } from "./types.js";
13
+ export declare function runPhase9cEmit(state: PhaseState): Promise<PhaseResult>;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Phase 9c-emit — deterministic curator emit (v0.9.0).
3
+ *
4
+ * Reads `.cairn/init/curator/final.jsonl`, validates each entry via
5
+ * the strict validators in `curator/validate.ts`, and writes
6
+ * surviving entries directly to `.cairn/ground/decisions/<id>.md`
7
+ * (DEC) or `.cairn/ground/invariants/<id>.md` (INV) with
8
+ * `status: accepted` / `status: active`. Invalid entries drop
9
+ * silently with a counter — operator's "auto-accept" directive in
10
+ * the curator plan means the bar is hard, not deferred to inbox.
11
+ */
12
+ import { isSelfAdoptState, advancePhase } from "./orchestrator.js";
13
+ export async function runPhase9cEmit(state) {
14
+ if (isSelfAdoptState(state)) {
15
+ const skipped = { skipped: "self-adopt" };
16
+ const next = {
17
+ ...state,
18
+ outputs: { ...state.outputs, "9c-emit": skipped },
19
+ };
20
+ return {
21
+ status: "complete",
22
+ nextPhase: "10-rules-merge",
23
+ state: advancePhase(next),
24
+ };
25
+ }
26
+ try {
27
+ const { runCuratorEmit } = await import("../curator/emit.js");
28
+ const result = await runCuratorEmit({ repoRoot: state.repoRoot });
29
+ const out = {
30
+ decsWritten: result.decsWritten,
31
+ invsWritten: result.invsWritten,
32
+ dropped: result.dropped,
33
+ dropReasons: result.dropReasons,
34
+ };
35
+ const next = {
36
+ ...state,
37
+ outputs: { ...state.outputs, "9c-emit": out },
38
+ };
39
+ return {
40
+ status: "complete",
41
+ nextPhase: "10-rules-merge",
42
+ state: advancePhase(next),
43
+ };
44
+ }
45
+ catch (err) {
46
+ return {
47
+ status: "error",
48
+ error: {
49
+ code: "9c-emit-failed",
50
+ message: "Curator emit failed",
51
+ detail: err instanceof Error ? err.stack ?? err.message : String(err),
52
+ },
53
+ state,
54
+ };
55
+ }
56
+ }
57
+ //# sourceMappingURL=9c-emit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"9c-emit.js","sourceRoot":"","sources":["../../../src/init/phases/9c-emit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGnE,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,KAAiB;IACpD,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAe,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;QACtD,MAAM,IAAI,GAAe;YACvB,GAAG,KAAK;YACR,OAAO,EAAE,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE;SAClD,CAAC;QACF,OAAO;YACL,MAAM,EAAE,UAAU;YAClB,SAAS,EAAE,gBAAgB;YAC3B,KAAK,EAAE,YAAY,CAAC,IAAI,CAAC;SAC1B,CAAC;IACJ,CAAC;IACD,IAAI,CAAC;QACH,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAC;QAC9D,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;QAClE,MAAM,GAAG,GAAe;YACtB,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,WAAW,EAAE,MAAM,CAAC,WAAW;SAChC,CAAC;QACF,MAAM,IAAI,GAAe;YACvB,GAAG,KAAK;YACR,OAAO,EAAE,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE;SAC9C,CAAC;QACF,OAAO;YACL,MAAM,EAAE,UAAU;YAClB,SAAS,EAAE,gBAAgB;YAC3B,KAAK,EAAE,YAAY,CAAC,IAAI,CAAC;SAC1B,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO;YACL,MAAM,EAAE,OAAO;YACf,KAAK,EAAE;gBACL,IAAI,EAAE,gBAAgB;gBACtB,OAAO,EAAE,qBAAqB;gBAC9B,MAAM,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;aACtE;YACD,KAAK;SACN,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -1,4 +1,4 @@
1
- export { PHASE_IDS, type PhaseId, type PhaseState, type PhaseOutputs, type PhaseResult, type PhaseQuestion, type PhaseOption, type PhaseError, type ResumeReport, } from "./types.js";
1
+ export { PHASE_IDS, type PhaseId, type PhaseState, type PhaseOutputs, type PhaseResult, type PhaseQuestion, type PhaseOption, type PhaseError, type ResumeReport, type WalkerOutput, type CurateOutput, type EmitOutput, type NoopPhaseOutput, } from "./types.js";
2
2
  export { INIT_STATE_PATH, phaseStateAbsPath, readPhaseState, writePhaseState, clearPhaseState, } from "./state-io.js";
3
3
  export { MAPPER_OUTPUT_PATH, mapperOutputAbsPath, readMapperOutputFile, writeMapperOutputFile, toMapperResultPersisted, type MapperResultPersisted, } from "./mapper-output-io.js";
4
4
  export { freshPhaseState, resumePhases, nextPhaseAfter, advancePhase, } from "./orchestrator.js";
@@ -6,15 +6,16 @@ export { runPhase1Detect } from "./1-detect.js";
6
6
  export { runPhase2Walker } from "./2-walker.js";
7
7
  export { runPhase3Mapper } from "./3-mapper.js";
8
8
  export { runPhase4Seed } from "./4-seed.js";
9
- export { runPhase5Pilot } from "./5-pilot.js";
9
+ export { runPhase5Preflight } from "./5-preflight.js";
10
+ export type { PreflightOutput, PreflightUnits, PreflightEta } from "./5-preflight.js";
10
11
  export { runPhase6Brand } from "./6-brand.js";
11
12
  export { runPhase7TopicIndex } from "./7-topic-index.js";
12
13
  export type { TopicIndexPhaseOutput } from "./7-topic-index.js";
13
14
  export { runPhase8DocsIngest } from "./8-docs-ingest.js";
14
- export { runPhase9SourceComments } from "./9-source-comments.js";
15
+ export { runPhase9aWalker } from "./9a-walker.js";
16
+ export { runPhase9bCurate, CURATOR_FINAL_PATH } from "./9b-curate.js";
17
+ export { runPhase9cEmit } from "./9c-emit.js";
15
18
  export { runPhase10RulesMerge } from "./10-rules-merge.js";
16
19
  export { runPhase11Baseline } from "./11-baseline.js";
17
20
  export { runPhase12Strip } from "./12-strip.js";
18
21
  export { runPhase13Multidev } from "./13-multidev.js";
19
- export { runPhases8910Parallel } from "./parallel-8910.js";
20
- export { SOURCE_COMMENTS_WALK_PATH, sourceCommentsWalkAbsPath, readSourceCommentsWalkFile, writeSourceCommentsWalkFile, to7bResultPersisted, type IngestSourceCommentsResultPersisted, } from "./source-comments-output-io.js";
@@ -6,15 +6,15 @@ export { runPhase1Detect } from "./1-detect.js";
6
6
  export { runPhase2Walker } from "./2-walker.js";
7
7
  export { runPhase3Mapper } from "./3-mapper.js";
8
8
  export { runPhase4Seed } from "./4-seed.js";
9
- export { runPhase5Pilot } from "./5-pilot.js";
9
+ export { runPhase5Preflight } from "./5-preflight.js";
10
10
  export { runPhase6Brand } from "./6-brand.js";
11
11
  export { runPhase7TopicIndex } from "./7-topic-index.js";
12
12
  export { runPhase8DocsIngest } from "./8-docs-ingest.js";
13
- export { runPhase9SourceComments } from "./9-source-comments.js";
13
+ export { runPhase9aWalker } from "./9a-walker.js";
14
+ export { runPhase9bCurate, CURATOR_FINAL_PATH } from "./9b-curate.js";
15
+ export { runPhase9cEmit } from "./9c-emit.js";
14
16
  export { runPhase10RulesMerge } from "./10-rules-merge.js";
15
17
  export { runPhase11Baseline } from "./11-baseline.js";
16
18
  export { runPhase12Strip } from "./12-strip.js";
17
19
  export { runPhase13Multidev } from "./13-multidev.js";
18
- export { runPhases8910Parallel } from "./parallel-8910.js";
19
- export { SOURCE_COMMENTS_WALK_PATH, sourceCommentsWalkAbsPath, readSourceCommentsWalkFile, writeSourceCommentsWalkFile, to7bResultPersisted, } from "./source-comments-output-io.js";
20
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/init/phases/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,GASV,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,eAAe,GAChB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,GAExB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,eAAe,EACf,YAAY,EACZ,cAAc,EACd,YAAY,GACb,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CA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,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -8,13 +8,13 @@
8
8
  * `.cairn/init-state.json` skinny enough that the cairn-adopt skill can
9
9
  * thread it through the LLM without spilling, the heavy fields live in
10
10
  * `.cairn/init/mapper-output.json` instead. State carries only the
11
- * persisted-light projection (small globs, pilot pick, key modules,
12
- * domain summary, mechanical sensor list, run metadata).
11
+ * persisted-light projection (small globs, key modules, domain summary,
12
+ * mechanical sensor list, run metadata).
13
13
  *
14
- * Phase 3b-seed reloads the full mapper output via `readMapperOutputFile`
14
+ * Phase 4-seed reloads the full mapper output via `readMapperOutputFile`
15
15
  * to write `.cairn/ground/scope-index.yaml`. Other downstream phases
16
- * (4-pilot / 5-brand / 8-baseline) only need the light fields, so they
17
- * read from `state.outputs["3-mapper"]` directly.
16
+ * only need the light fields, so they read from `state.outputs["3-mapper"]`
17
+ * directly.
18
18
  */
19
19
  import type { MapperResult, MapperOutput } from "../mapper.js";
20
20
  /** Filename relative to repoRoot. */
@@ -8,13 +8,13 @@
8
8
  * `.cairn/init-state.json` skinny enough that the cairn-adopt skill can
9
9
  * thread it through the LLM without spilling, the heavy fields live in
10
10
  * `.cairn/init/mapper-output.json` instead. State carries only the
11
- * persisted-light projection (small globs, pilot pick, key modules,
12
- * domain summary, mechanical sensor list, run metadata).
11
+ * persisted-light projection (small globs, key modules, domain summary,
12
+ * mechanical sensor list, run metadata).
13
13
  *
14
- * Phase 3b-seed reloads the full mapper output via `readMapperOutputFile`
14
+ * Phase 4-seed reloads the full mapper output via `readMapperOutputFile`
15
15
  * to write `.cairn/ground/scope-index.yaml`. Other downstream phases
16
- * (4-pilot / 5-brand / 8-baseline) only need the light fields, so they
17
- * read from `state.outputs["3-mapper"]` directly.
16
+ * only need the light fields, so they read from `state.outputs["3-mapper"]`
17
+ * directly.
18
18
  */
19
19
  import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync, } from "node:fs";
20
20
  import { dirname, join } from "node:path";
@@ -35,6 +35,16 @@ export declare function freshPhaseState(repoRoot: string): PhaseState;
35
35
  * runs again.
36
36
  */
37
37
  export declare function resumePhases(repoRoot: string): ResumeReport;
38
+ /**
39
+ * Self-adoption flag check. True when Phase 1 detect set
40
+ * `outputs["1-detect"].is_self_adopt = true` because the operator is
41
+ * dogfooding Cairn against its own source repo via the
42
+ * `CAIRN_SELF_ADOPT=1` escape hatch. Phases 8 / 9 / 10 / 12 read this
43
+ * and short-circuit so the recursive-ingest scenario (Cairn's own
44
+ * docs / source comments / CLAUDE.md / essay-class block strip)
45
+ * never runs against the source tree.
46
+ */
47
+ export declare function isSelfAdoptState(state: PhaseState): boolean;
38
48
  /**
39
49
  * Compute the phase id that follows `current` in PHASE_IDS, or null
40
50
  * when `current` is already the last id. Pure function — useful from
@@ -23,7 +23,7 @@ export function freshPhaseState(repoRoot) {
23
23
  currentPhase: PHASE_IDS[0],
24
24
  outputs: {},
25
25
  startedAt: new Date().toISOString(),
26
- schemaVersion: 1,
26
+ schemaVersion: 3,
27
27
  };
28
28
  }
29
29
  /**
@@ -58,6 +58,18 @@ export function resumePhases(repoRoot) {
58
58
  state: persisted,
59
59
  };
60
60
  }
61
+ /**
62
+ * Self-adoption flag check. True when Phase 1 detect set
63
+ * `outputs["1-detect"].is_self_adopt = true` because the operator is
64
+ * dogfooding Cairn against its own source repo via the
65
+ * `CAIRN_SELF_ADOPT=1` escape hatch. Phases 8 / 9 / 10 / 12 read this
66
+ * and short-circuit so the recursive-ingest scenario (Cairn's own
67
+ * docs / source comments / CLAUDE.md / essay-class block strip)
68
+ * never runs against the source tree.
69
+ */
70
+ export function isSelfAdoptState(state) {
71
+ return state.outputs["1-detect"]?.is_self_adopt === true;
72
+ }
61
73
  /**
62
74
  * Compute the phase id that follows `current` in PHASE_IDS, or null
63
75
  * when `current` is already the last id. Pure function — useful from
@@ -1 +1 @@
1
- {"version":3,"file":"orchestrator.js","sourceRoot":"","sources":["../../../src/init/phases/orchestrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,SAAS,EAAoD,MAAM,YAAY,CAAC;AACzF,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,OAAO;QACL,QAAQ;QACR,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC;QAC1B,OAAO,EAAE,EAAE;QACX,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,aAAa,EAAE,CAAC;KACjB,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,YAAY,CAAC,QAAgB;IAC3C,MAAM,SAAS,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC3C,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QACvB,OAAO;YACL,MAAM,EAAE,OAAO;YACf,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;YACvB,KAAK,EAAE,eAAe,CAAC,QAAQ,CAAC;SACjC,CAAC;IACJ,CAAC;IACD,OAAO;QACL,MAAM,EAAE,OAAO;QACf,SAAS,EAAE,SAAS,CAAC,YAAY;QACjC,KAAK,EAAE,SAAS;KACjB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,OAAgB;IAC7C,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,IAAI,GAAG,KAAK,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAC5B,IAAI,GAAG,KAAK,SAAS,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAC9C,OAAO,SAAS,CAAC,GAAG,GAAG,CAAC,CAAC,I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AiB;IAChD,OAAO,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;AAC3D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,OAAgB;IAC7C,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,IAAI,GAAG,KAAK,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAC5B,IAAI,GAAG,KAAK,SAAS,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAC9C,OAAO,SAAS,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC;AACpC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,KAAiB;IAC5C,MAAM,IAAI,GAAG,cAAc,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAChD,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAChC,OAAO,EAAE,GAAG,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AAC7D,CAAC"}
@@ -56,7 +56,7 @@ function isPhaseState(x) {
56
56
  if (x === null || typeof x !== "object")
57
57
  return false;
58
58
  const o = x;
59
- if (o["schemaVersion"] !== 1)
59
+ if (o["schemaVersion"] !== 3)
60
60
  return false;
61
61
  if (typeof o["repoRoot"] !== "string")
62
62
  return false;
@@ -12,14 +12,21 @@
12
12
  * pipeline is crash-safe — operator can `/exit` Claude Code mid-init
13
13
  * and pick up at the same phase on the next session.
14
14
  */
15
+ import type { DetectionResult } from "../types.js";
16
+ import type { RepoSummary } from "../walker.js";
17
+ import type { BaselineAuditResult } from "../baseline-audit.js";
18
+ import type { MultiDevInstallResult } from "../multi-dev/index.js";
19
+ import type { MapperResultPersisted } from "./mapper-output-io.js";
20
+ import type { TopicIndexPhaseOutput } from "./7-topic-index.js";
21
+ import type { PreflightOutput } from "./5-preflight.js";
15
22
  /** Phase ids in execution order. */
16
- export declare const PHASE_IDS: readonly ["1-detect", "2-walker", "3-mapper", "4-seed", "5-pilot", "6-brand", "7-topic-index", "8-docs-ingest", "9-source-comments", "10-rules-merge", "11-baseline", "12-strip", "13-multidev"];
23
+ export declare const PHASE_IDS: readonly ["1-detect", "2-walker", "3-mapper", "4-seed", "5-preflight", "6-brand", "7-topic-index", "8-docs-ingest", "9a-walker", "9b-curate", "9c-emit", "10-rules-merge", "11-baseline", "12-strip", "13-multidev"];
17
24
  export type PhaseId = (typeof PHASE_IDS)[number];
18
25
  /** Inline A/B/C question rendered via AskUserQuestion in the skill. */
19
26
  export interface PhaseQuestion {
20
27
  /** Stable identifier so the skill can correlate answers across re-invocations. */
21
28
  id: string;
22
- /** Operator-facing prompt — full English, not caveman. */
29
+ /** Operator-facing prompt — full plain English; no operator-personal voice. */
23
30
  prompt: string;
24
31
  /** Options labeled A/B/C/... */
25
32
  options: PhaseOption[];
@@ -51,16 +58,115 @@ export interface PhaseState {
51
58
  /** When the pipeline started (ISO-8601). */
52
59
  startedAt: string;
53
60
  /** Schema version for the on-disk state file (bump on breaking change). */
54
- schemaVersion: 1;
61
+ schemaVersion: 3;
62
+ }
63
+ export interface SeedPhaseOutput {
64
+ written_files: string[];
65
+ collisions: string[];
66
+ config_path: string;
67
+ scope_index_path: string;
68
+ workflow_slug_patched: boolean;
69
+ workflow_patch_error: string | null;
70
+ attested_seeded: number;
71
+ attested_seed_status: "ok" | "skipped" | "error";
72
+ }
73
+ export interface BrandOutput {
74
+ choice: string;
75
+ applied: {
76
+ updated: string[];
77
+ warnings: string[];
78
+ } | null;
79
+ }
80
+ export interface StripState {
81
+ pending: string[];
82
+ decisions: Record<string, "strip" | "keep" | "skip">;
55
83
  }
56
84
  /**
57
- * Phase outputs are deliberately loose-typed each phase function
58
- * stamps its own typed result under its id. Downstream phases read
59
- * via type-narrowing helpers in their own modules.
85
+ * Output of phases collapsed to no-ops by the curator pipeline merge
86
+ * (Phase 8 docs-ingest + Phase 10 rules-merge in v0.9.0). The runners
87
+ * stay registered so resumes from old state files don't blow up; they
88
+ * stamp this marker into outputs and advance.
60
89
  */
61
- export type PhaseOutputs = {
62
- -readonly [K in PhaseId]?: unknown;
63
- };
90
+ export interface NoopPhaseOutput {
91
+ skipped: "merged-into-9-curator" | "self-adopt";
92
+ }
93
+ /**
94
+ * Output of the unified curator walker (9a-walker). Counts what the
95
+ * regex pre-filter let through and points to the on-disk corpus +
96
+ * shard plan the skill driver picks up.
97
+ */
98
+ export interface WalkerOutput {
99
+ skipped?: "self-adopt";
100
+ /** Repo-relative path to the spilled corpus.jsonl. */
101
+ corpus_path?: string;
102
+ /** Repo-relative path to the spilled shards.json. */
103
+ shards_path?: string;
104
+ /** Total surviving records across all sub-walkers. */
105
+ records_total?: number;
106
+ /** Per-source-kind count. */
107
+ records_by_kind?: {
108
+ comment: number;
109
+ doc: number;
110
+ rule: number;
111
+ };
112
+ /** Records dropped by the regex pre-filter, by reason. */
113
+ dropped?: Record<string, number>;
114
+ /** Number of shards produced by the packer. */
115
+ shards?: number;
116
+ /** Total estimated input tokens across shards. */
117
+ total_input_tokens_estimate?: number;
118
+ }
119
+ /**
120
+ * Output stamped by the 9b-curate runner. The map+reduce dispatch is
121
+ * skill-driven (parallel subagents write JSONL); the runner merely
122
+ * confirms `final.jsonl` exists, counts its entries, and advances.
123
+ */
124
+ export interface CurateOutput {
125
+ skipped?: "self-adopt";
126
+ /** Repo-relative path to final.jsonl. */
127
+ final_path?: string;
128
+ /** Number of candidate entries the reducer emitted. */
129
+ final_entries?: number;
130
+ }
131
+ /**
132
+ * Output of the deterministic emit phase (9c-emit). Records what
133
+ * passed the strict validators and what dropped silently.
134
+ */
135
+ export interface EmitOutput {
136
+ skipped?: "self-adopt";
137
+ decsWritten?: {
138
+ id: string;
139
+ path: string;
140
+ title: string;
141
+ }[];
142
+ invsWritten?: {
143
+ id: string;
144
+ path: string;
145
+ title: string;
146
+ }[];
147
+ dropped?: number;
148
+ dropReasons?: Record<string, number>;
149
+ }
150
+ export interface PhaseOutputs {
151
+ "1-detect"?: DetectionResult;
152
+ "2-walker"?: RepoSummary;
153
+ "3-mapper"?: MapperResultPersisted;
154
+ "4-seed"?: SeedPhaseOutput;
155
+ "5-preflight"?: PreflightOutput;
156
+ "6-brand"?: BrandOutput;
157
+ "7-topic-index"?: TopicIndexPhaseOutput;
158
+ "8-docs-ingest"?: NoopPhaseOutput;
159
+ "9a-walker"?: WalkerOutput;
160
+ "9b-curate"?: CurateOutput;
161
+ "9c-emit"?: EmitOutput;
162
+ "10-rules-merge"?: NoopPhaseOutput;
163
+ "11-baseline"?: BaselineAuditResult;
164
+ "12-strip"?: StripState;
165
+ "13-multidev"?: MultiDevInstallResult & {
166
+ /** Number of files in the manifest after the phase 13 finalize rebuild. */
167
+ manifest_files?: number;
168
+ };
169
+ }
64
170
  /** Discriminated union returned by every phase function. */
65
171
  export type PhaseResult = {
66
172
  readonly status: "complete";
@@ -18,11 +18,13 @@ export const PHASE_IDS = [
18
18
  "2-walker",
19
19
  "3-mapper",
20
20
  "4-seed",
21
- "5-pilot",
21
+ "5-preflight",
22
22
  "6-brand",
23
23
  "7-topic-index",
24
24
  "8-docs-ingest",
25
- "9-source-comments",
25
+ "9a-walker",
26
+ "9b-curate",
27
+ "9c-emit",
26
28
  "10-rules-merge",
27
29
  "11-baseline",
28
30
  "12-strip",
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/init/phases/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,oCAAoC;AACpC,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,UAAU;IACV,UAAU;IACV,UAAU;IACV,QAAQ;IACR,SAAS;IACT,SAAS;IACT,eAAe;IACf,eAAe;IACf,mBAAmB;IACnB,gBAAgB;IAChB,aAAa;IACb,UAAU;IACV,aAAa;CACL,CAAC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/init/phases/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAUH,oCAAoC;AACpC,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,UAAU;IACV,UAAU;IACV,UAAU;IACV,QAAQ;IACR,aAAa;IACb,SAAS;IACT,eAAe;IACf,eAAe;IACf,WAAW;IACX,WAAW;IACX,SAAS;IACT,gBAAgB;IAChB,aAAa;IACb,UAAU;IACV,aAAa;CACL,CAAC"}