@isaacriehm/cairn-core 0.1.10 → 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.
Files changed (399) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/claude/runner.d.ts +1 -1
  3. package/dist/claude/runner.js +62 -1
  4. package/dist/claude/runner.js.map +1 -1
  5. package/dist/claude/types.d.ts +14 -7
  6. package/dist/claude/types.js +5 -7
  7. package/dist/claude/types.js.map +1 -1
  8. package/dist/context/index.d.ts +4 -4
  9. package/dist/context/index.js +3 -4
  10. package/dist/context/index.js.map +1 -1
  11. package/dist/context/spec-delta.js +3 -4
  12. package/dist/context/spec-delta.js.map +1 -1
  13. package/dist/context/task-summary.d.ts +18 -0
  14. package/dist/context/task-summary.js +89 -0
  15. package/dist/context/task-summary.js.map +1 -0
  16. package/dist/decision-capture/id.d.ts +21 -4
  17. package/dist/decision-capture/id.js +56 -5
  18. package/dist/decision-capture/id.js.map +1 -1
  19. package/dist/decision-capture/index.d.ts +7 -22
  20. package/dist/decision-capture/index.js +7 -17
  21. package/dist/decision-capture/index.js.map +1 -1
  22. package/dist/doctor/index.d.ts +2 -2
  23. package/dist/doctor/index.js +5 -60
  24. package/dist/doctor/index.js.map +1 -1
  25. package/dist/events/index.d.ts +1 -1
  26. package/dist/events/index.js +1 -1
  27. package/dist/events/writer.d.ts +1 -1
  28. package/dist/events/writer.js +1 -1
  29. package/dist/gc/canary.d.ts +13 -23
  30. package/dist/gc/canary.js +36 -92
  31. package/dist/gc/canary.js.map +1 -1
  32. package/dist/gc/citation-integrity.d.ts +6 -6
  33. package/dist/gc/citation-integrity.js +64 -20
  34. package/dist/gc/citation-integrity.js.map +1 -1
  35. package/dist/gc/frontmatter.js +1 -1
  36. package/dist/gc/generator-drift.js +1 -1
  37. package/dist/gc/generator-drift.js.map +1 -1
  38. package/dist/gc/index.d.ts +2 -2
  39. package/dist/gc/index.js +1 -1
  40. package/dist/gc/index.js.map +1 -1
  41. package/dist/gc/quality-update.d.ts +4 -4
  42. package/dist/gc/quality-update.js +5 -5
  43. package/dist/gc/quality-update.js.map +1 -1
  44. package/dist/gc/types.d.ts +1 -30
  45. package/dist/ground/index.d.ts +2 -2
  46. package/dist/ground/index.js +1 -1
  47. package/dist/ground/index.js.map +1 -1
  48. package/dist/ground/ledgers.d.ts +0 -4
  49. package/dist/ground/ledgers.js +10 -8
  50. package/dist/ground/ledgers.js.map +1 -1
  51. package/dist/ground/manifest.js +0 -4
  52. package/dist/ground/manifest.js.map +1 -1
  53. package/dist/ground/paths.js +0 -1
  54. package/dist/ground/paths.js.map +1 -1
  55. package/dist/ground/quality-grades.js +3 -1
  56. package/dist/ground/quality-grades.js.map +1 -1
  57. package/dist/ground/schemas.d.ts +2 -7
  58. package/dist/ground/schemas.js +7 -2
  59. package/dist/ground/schemas.js.map +1 -1
  60. package/dist/ground/scope-index.d.ts +62 -14
  61. package/dist/ground/scope-index.js +215 -45
  62. package/dist/ground/scope-index.js.map +1 -1
  63. package/dist/hooks/bypass-detection.js +14 -17
  64. package/dist/hooks/bypass-detection.js.map +1 -1
  65. package/dist/hooks/defer.d.ts +50 -0
  66. package/dist/hooks/defer.js +87 -0
  67. package/dist/hooks/defer.js.map +1 -0
  68. package/dist/hooks/post-tool-use/citation-scanner.d.ts +7 -5
  69. package/dist/hooks/post-tool-use/citation-scanner.js +15 -9
  70. package/dist/hooks/post-tool-use/citation-scanner.js.map +1 -1
  71. package/dist/hooks/post-tool-use/copy-scanner.js +1 -1
  72. package/dist/hooks/post-tool-use/copy-scanner.js.map +1 -1
  73. package/dist/hooks/post-tool-use/ledger-cache.d.ts +10 -2
  74. package/dist/hooks/post-tool-use/ledger-cache.js +58 -4
  75. package/dist/hooks/post-tool-use/ledger-cache.js.map +1 -1
  76. package/dist/hooks/post-tool-use/legend-builder.d.ts +3 -3
  77. package/dist/hooks/post-tool-use/legend-builder.js +30 -8
  78. package/dist/hooks/post-tool-use/legend-builder.js.map +1 -1
  79. package/dist/hooks/post-tool-use/read-enricher.d.ts +1 -1
  80. package/dist/hooks/post-tool-use/read-enricher.js +68 -21
  81. package/dist/hooks/post-tool-use/read-enricher.js.map +1 -1
  82. package/dist/hooks/post-tool-use/write-guardian.js +148 -18
  83. package/dist/hooks/post-tool-use/write-guardian.js.map +1 -1
  84. package/dist/hooks/runners/index.d.ts +3 -0
  85. package/dist/hooks/runners/index.js +2 -0
  86. package/dist/hooks/runners/index.js.map +1 -1
  87. package/dist/hooks/runners/payload.d.ts +1 -1
  88. package/dist/hooks/runners/payload.js +27 -12
  89. package/dist/hooks/runners/payload.js.map +1 -1
  90. package/dist/hooks/runners/session-start.js +250 -75
  91. package/dist/hooks/runners/session-start.js.map +1 -1
  92. package/dist/hooks/runners/stop.d.ts +9 -12
  93. package/dist/hooks/runners/stop.js +129 -41
  94. package/dist/hooks/runners/stop.js.map +1 -1
  95. package/dist/hooks/runners/user-prompt-submit.d.ts +15 -0
  96. package/dist/hooks/runners/user-prompt-submit.js +149 -0
  97. package/dist/hooks/runners/user-prompt-submit.js.map +1 -0
  98. package/dist/hooks/seed-attested.d.ts +25 -0
  99. package/dist/hooks/seed-attested.js +84 -0
  100. package/dist/hooks/seed-attested.js.map +1 -0
  101. package/dist/hooks/user-prompt-submit.d.ts +7 -0
  102. package/dist/hooks/user-prompt-submit.js +12 -0
  103. package/dist/hooks/user-prompt-submit.js.map +1 -0
  104. package/dist/index.d.ts +3 -6
  105. package/dist/index.js +14 -12
  106. package/dist/index.js.map +1 -1
  107. package/dist/init/baseline-audit.d.ts +5 -1
  108. package/dist/init/baseline-audit.js +25 -2
  109. package/dist/init/baseline-audit.js.map +1 -1
  110. package/dist/init/glob-inference.d.ts +16 -0
  111. package/dist/init/glob-inference.js +108 -0
  112. package/dist/init/glob-inference.js.map +1 -0
  113. package/dist/init/index.d.ts +4 -0
  114. package/dist/init/index.js +2 -0
  115. package/dist/init/index.js.map +1 -1
  116. package/dist/init/ingest-docs.d.ts +1 -1
  117. package/dist/init/ingest-docs.js +19 -6
  118. package/dist/init/ingest-docs.js.map +1 -1
  119. package/dist/init/init.js +17 -94
  120. package/dist/init/init.js.map +1 -1
  121. package/dist/init/mapper-merge.d.ts +8 -2
  122. package/dist/init/mapper-merge.js +50 -32
  123. package/dist/init/mapper-merge.js.map +1 -1
  124. package/dist/init/mapper-parallel.d.ts +2 -3
  125. package/dist/init/mapper-parallel.js +9 -38
  126. package/dist/init/mapper-parallel.js.map +1 -1
  127. package/dist/init/mapper-prompts.js +1 -1
  128. package/dist/init/mapper-prompts.js.map +1 -1
  129. package/dist/init/mapper.d.ts +7 -128
  130. package/dist/init/mapper.js +30 -7
  131. package/dist/init/mapper.js.map +1 -1
  132. package/dist/init/module-slicer.d.ts +1 -1
  133. package/dist/init/module-slicer.js +1 -1
  134. package/dist/init/multi-dev/install.d.ts +9 -10
  135. package/dist/init/multi-dev/install.js +15 -84
  136. package/dist/init/multi-dev/install.js.map +1 -1
  137. package/dist/init/overlay.d.ts +14 -0
  138. package/dist/init/overlay.js +65 -0
  139. package/dist/init/overlay.js.map +1 -0
  140. package/dist/init/phases/1-detect.d.ts +10 -0
  141. package/dist/init/phases/1-detect.js +36 -0
  142. package/dist/init/phases/1-detect.js.map +1 -0
  143. package/dist/init/phases/10-strip.d.ts +11 -0
  144. package/dist/init/phases/10-strip.js +79 -0
  145. package/dist/init/phases/10-strip.js.map +1 -0
  146. package/dist/init/phases/12-multidev.d.ts +6 -0
  147. package/dist/init/phases/12-multidev.js +34 -0
  148. package/dist/init/phases/12-multidev.js.map +1 -0
  149. package/dist/init/phases/2-walker.d.ts +8 -0
  150. package/dist/init/phases/2-walker.js +34 -0
  151. package/dist/init/phases/2-walker.js.map +1 -0
  152. package/dist/init/phases/3-mapper.d.ts +14 -0
  153. package/dist/init/phases/3-mapper.js +56 -0
  154. package/dist/init/phases/3-mapper.js.map +1 -0
  155. package/dist/init/phases/3b-seed.d.ts +18 -0
  156. package/dist/init/phases/3b-seed.js +140 -0
  157. package/dist/init/phases/3b-seed.js.map +1 -0
  158. package/dist/init/phases/4-pilot.d.ts +10 -0
  159. package/dist/init/phases/4-pilot.js +108 -0
  160. package/dist/init/phases/4-pilot.js.map +1 -0
  161. package/dist/init/phases/5-brand.d.ts +10 -0
  162. package/dist/init/phases/5-brand.js +66 -0
  163. package/dist/init/phases/5-brand.js.map +1 -0
  164. package/dist/init/phases/6-docs-ingest.d.ts +11 -0
  165. package/dist/init/phases/6-docs-ingest.js +39 -0
  166. package/dist/init/phases/6-docs-ingest.js.map +1 -0
  167. package/dist/init/phases/7b-source-comments.d.ts +6 -0
  168. package/dist/init/phases/7b-source-comments.js +34 -0
  169. package/dist/init/phases/7b-source-comments.js.map +1 -0
  170. package/dist/init/phases/7c-rules-merge.d.ts +6 -0
  171. package/dist/init/phases/7c-rules-merge.js +34 -0
  172. package/dist/init/phases/7c-rules-merge.js.map +1 -0
  173. package/dist/init/phases/8-baseline.d.ts +10 -0
  174. package/dist/init/phases/8-baseline.js +52 -0
  175. package/dist/init/phases/8-baseline.js.map +1 -0
  176. package/dist/init/phases/index.d.ts +15 -0
  177. package/dist/init/phases/index.js +16 -0
  178. package/dist/init/phases/index.js.map +1 -0
  179. package/dist/init/phases/orchestrator.d.ts +49 -0
  180. package/dist/init/phases/orchestrator.js +85 -0
  181. package/dist/init/phases/orchestrator.js.map +1 -0
  182. package/dist/init/phases/state-io.d.ts +19 -0
  183. package/dist/init/phases/state-io.js +73 -0
  184. package/dist/init/phases/state-io.js.map +1 -0
  185. package/dist/init/phases/types.d.ts +93 -0
  186. package/dist/init/phases/types.js +30 -0
  187. package/dist/init/phases/types.js.map +1 -0
  188. package/dist/init/prompts.d.ts +6 -8
  189. package/dist/init/prompts.js +3 -6
  190. package/dist/init/prompts.js.map +1 -1
  191. package/dist/init/rules-merge/ingest.js +1 -1
  192. package/dist/init/seed.js +11 -2
  193. package/dist/init/seed.js.map +1 -1
  194. package/dist/init/source-comments/classify.d.ts +1 -41
  195. package/dist/init/source-comments/classify.js +68 -37
  196. package/dist/init/source-comments/classify.js.map +1 -1
  197. package/dist/init/source-comments/index.d.ts +2 -2
  198. package/dist/init/source-comments/index.js +2 -2
  199. package/dist/init/source-comments/index.js.map +1 -1
  200. package/dist/init/source-comments/ingest.d.ts +38 -2
  201. package/dist/init/source-comments/ingest.js +237 -4
  202. package/dist/init/source-comments/ingest.js.map +1 -1
  203. package/dist/init/source-comments/strip-replace.d.ts +10 -19
  204. package/dist/init/source-comments/strip-replace.js +26 -2
  205. package/dist/init/source-comments/strip-replace.js.map +1 -1
  206. package/dist/init/source-comments/walker.d.ts +9 -2
  207. package/dist/init/source-comments/walker.js +38 -19
  208. package/dist/init/source-comments/walker.js.map +1 -1
  209. package/dist/init/submodules.d.ts +3 -2
  210. package/dist/init/types.d.ts +3 -5
  211. package/dist/init/types.js +3 -5
  212. package/dist/init/types.js.map +1 -1
  213. package/dist/init/visual.d.ts +4 -9
  214. package/dist/init/visual.js +1 -16
  215. package/dist/init/visual.js.map +1 -1
  216. package/dist/init/walker.d.ts +0 -6
  217. package/dist/init/walker.js +2 -3
  218. package/dist/init/walker.js.map +1 -1
  219. package/dist/join/index.js +49 -2
  220. package/dist/join/index.js.map +1 -1
  221. package/dist/logger.d.ts +1 -2
  222. package/dist/logger.js +5 -6
  223. package/dist/logger.js.map +1 -1
  224. package/dist/mcp/context.d.ts +2 -3
  225. package/dist/mcp/context.js.map +1 -1
  226. package/dist/mcp/errors.d.ts +1 -1
  227. package/dist/mcp/errors.js.map +1 -1
  228. package/dist/mcp/history/prompt.d.ts +2 -1
  229. package/dist/mcp/history/walker.js +1 -1
  230. package/dist/mcp/history/walker.js.map +1 -1
  231. package/dist/mcp/path-allowlist.d.ts +0 -6
  232. package/dist/mcp/path-allowlist.js +0 -10
  233. package/dist/mcp/path-allowlist.js.map +1 -1
  234. package/dist/mcp/schemas.d.ts +34 -72
  235. package/dist/mcp/schemas.js +40 -70
  236. package/dist/mcp/schemas.js.map +1 -1
  237. package/dist/mcp/serve.d.ts +1 -1
  238. package/dist/mcp/serve.js +2 -5
  239. package/dist/mcp/serve.js.map +1 -1
  240. package/dist/mcp/server.js +10 -4
  241. package/dist/mcp/server.js.map +1 -1
  242. package/dist/mcp/telemetry.d.ts +8 -1
  243. package/dist/mcp/telemetry.js +16 -0
  244. package/dist/mcp/telemetry.js.map +1 -1
  245. package/dist/mcp/tools/decision-get.js +37 -29
  246. package/dist/mcp/tools/decision-get.js.map +1 -1
  247. package/dist/mcp/tools/decisions-in-scope.js +22 -3
  248. package/dist/mcp/tools/decisions-in-scope.js.map +1 -1
  249. package/dist/mcp/tools/ground-get.js +2 -2
  250. package/dist/mcp/tools/ground-get.js.map +1 -1
  251. package/dist/mcp/tools/index.js +6 -2
  252. package/dist/mcp/tools/index.js.map +1 -1
  253. package/dist/mcp/tools/init-phases.d.ts +24 -0
  254. package/dist/mcp/tools/init-phases.js +140 -0
  255. package/dist/mcp/tools/init-phases.js.map +1 -0
  256. package/dist/mcp/tools/invariant-get.js +1 -1
  257. package/dist/mcp/tools/invariant-get.js.map +1 -1
  258. package/dist/mcp/tools/invariants-in-scope.js +26 -7
  259. package/dist/mcp/tools/invariants-in-scope.js.map +1 -1
  260. package/dist/mcp/tools/query-history.js +3 -3
  261. package/dist/mcp/tools/query-history.js.map +1 -1
  262. package/dist/mcp/tools/resolve-attention.d.ts +6 -4
  263. package/dist/mcp/tools/resolve-attention.js +253 -24
  264. package/dist/mcp/tools/resolve-attention.js.map +1 -1
  265. package/dist/mcp/tools/search.js +3 -4
  266. package/dist/mcp/tools/search.js.map +1 -1
  267. package/dist/mcp/tools/task-create.d.ts +15 -0
  268. package/dist/mcp/tools/task-create.js +96 -0
  269. package/dist/mcp/tools/task-create.js.map +1 -0
  270. package/dist/mcp/tools/timeline.js +3 -7
  271. package/dist/mcp/tools/timeline.js.map +1 -1
  272. package/dist/profiles/types.d.ts +2 -2
  273. package/dist/profiles/types.js +1 -1
  274. package/dist/sensors/catalog.js +8 -3
  275. package/dist/sensors/catalog.js.map +1 -1
  276. package/dist/session/id.d.ts +1 -3
  277. package/dist/session/id.js +1 -1
  278. package/dist/session/id.js.map +1 -1
  279. package/dist/session-start/build.d.ts +7 -11
  280. package/dist/session-start/build.js +62 -34
  281. package/dist/session-start/build.js.map +1 -1
  282. package/dist/session-start/index.d.ts +2 -2
  283. package/dist/session-start/index.js +2 -2
  284. package/dist/session-start/index.js.map +1 -1
  285. package/dist/session-start/templates.d.ts +20 -4
  286. package/dist/session-start/templates.js +45 -35
  287. package/dist/session-start/templates.js.map +1 -1
  288. package/dist/status-line/format.d.ts +20 -9
  289. package/dist/status-line/format.js +45 -35
  290. package/dist/status-line/format.js.map +1 -1
  291. package/dist/status-line/index.d.ts +3 -4
  292. package/dist/status-line/index.js +1 -1
  293. package/dist/status-line/index.js.map +1 -1
  294. package/dist/status-line/reader.d.ts +9 -6
  295. package/dist/status-line/reader.js +50 -18
  296. package/dist/status-line/reader.js.map +1 -1
  297. package/dist/status-line/writer.d.ts +6 -9
  298. package/dist/status-line/writer.js +10 -12
  299. package/dist/status-line/writer.js.map +1 -1
  300. package/dist/trace/index.d.ts +44 -0
  301. package/dist/trace/index.js +51 -0
  302. package/dist/trace/index.js.map +1 -0
  303. package/package.json +2 -3
  304. package/templates/.archive/README.md +3 -3
  305. package/templates/.cairn/JOIN.md +3 -9
  306. package/templates/.cairn/config/sensors.yaml +16 -19
  307. package/templates/.cairn/config/stub-patterns.yaml +4 -4
  308. package/templates/.cairn/config/trust-policy.yaml +3 -35
  309. package/templates/.cairn/config/workflow.md +13 -194
  310. package/templates/.cairn/git-hooks/commit-msg +15 -4
  311. package/templates/.cairn/git-hooks/pre-commit +22 -13
  312. package/templates/.cairn/ground/canonical-map/topics.yaml +3 -26
  313. package/templates/.cairn/ground/capabilities/snippets.yaml +0 -1
  314. package/templates/.cairn/ground/manifest.yaml +5 -8
  315. package/templates/.cairn/ground/product/personas.yaml +0 -1
  316. package/dist/context/checkpoint.d.ts +0 -10
  317. package/dist/context/checkpoint.js +0 -29
  318. package/dist/context/checkpoint.js.map +0 -1
  319. package/dist/decision-capture/capture.d.ts +0 -57
  320. package/dist/decision-capture/capture.js +0 -186
  321. package/dist/decision-capture/capture.js.map +0 -1
  322. package/dist/decision-capture/extractor.d.ts +0 -20
  323. package/dist/decision-capture/extractor.js +0 -103
  324. package/dist/decision-capture/extractor.js.map +0 -1
  325. package/dist/decision-capture/prompt.d.ts +0 -15
  326. package/dist/decision-capture/prompt.js +0 -68
  327. package/dist/decision-capture/prompt.js.map +0 -1
  328. package/dist/decision-capture/refinement-prompt.d.ts +0 -25
  329. package/dist/decision-capture/refinement-prompt.js +0 -146
  330. package/dist/decision-capture/refinement-prompt.js.map +0 -1
  331. package/dist/decision-capture/refinement-schema.d.ts +0 -52
  332. package/dist/decision-capture/refinement-schema.js +0 -61
  333. package/dist/decision-capture/refinement-schema.js.map +0 -1
  334. package/dist/decision-capture/refinement.d.ts +0 -60
  335. package/dist/decision-capture/refinement.js +0 -439
  336. package/dist/decision-capture/refinement.js.map +0 -1
  337. package/dist/decision-capture/schema.d.ts +0 -70
  338. package/dist/decision-capture/schema.js +0 -71
  339. package/dist/decision-capture/schema.js.map +0 -1
  340. package/dist/decision-capture/types.d.ts +0 -201
  341. package/dist/decision-capture/types.js +0 -20
  342. package/dist/decision-capture/types.js.map +0 -1
  343. package/dist/decision-capture/writer.d.ts +0 -90
  344. package/dist/decision-capture/writer.js +0 -267
  345. package/dist/decision-capture/writer.js.map +0 -1
  346. package/dist/frontend-types.d.ts +0 -243
  347. package/dist/frontend-types.js +0 -15
  348. package/dist/frontend-types.js.map +0 -1
  349. package/dist/hooks/index.d.ts +0 -12
  350. package/dist/hooks/index.js +0 -13
  351. package/dist/hooks/index.js.map +0 -1
  352. package/dist/inbox.d.ts +0 -17
  353. package/dist/inbox.js +0 -30
  354. package/dist/inbox.js.map +0 -1
  355. package/dist/mcp/tools/append-run-note.d.ts +0 -18
  356. package/dist/mcp/tools/append-run-note.js +0 -47
  357. package/dist/mcp/tools/append-run-note.js.map +0 -1
  358. package/dist/mcp/tools/append.d.ts +0 -8
  359. package/dist/mcp/tools/append.js +0 -37
  360. package/dist/mcp/tools/append.js.map +0 -1
  361. package/dist/mcp/tools/ask-operator.d.ts +0 -34
  362. package/dist/mcp/tools/ask-operator.js +0 -97
  363. package/dist/mcp/tools/ask-operator.js.map +0 -1
  364. package/dist/mcp/tools/drop-task.d.ts +0 -12
  365. package/dist/mcp/tools/drop-task.js +0 -68
  366. package/dist/mcp/tools/drop-task.js.map +0 -1
  367. package/dist/mcp/tools/record-run-event.d.ts +0 -10
  368. package/dist/mcp/tools/record-run-event.js +0 -32
  369. package/dist/mcp/tools/record-run-event.js.map +0 -1
  370. package/dist/prompt.d.ts +0 -19
  371. package/dist/prompt.js +0 -50
  372. package/dist/prompt.js.map +0 -1
  373. package/dist/tier0/classify.d.ts +0 -10
  374. package/dist/tier0/classify.js +0 -110
  375. package/dist/tier0/classify.js.map +0 -1
  376. package/dist/tier0/index.d.ts +0 -2
  377. package/dist/tier0/index.js +0 -2
  378. package/dist/tier0/index.js.map +0 -1
  379. package/dist/tier0/types.d.ts +0 -24
  380. package/dist/tier0/types.js +0 -9
  381. package/dist/tier0/types.js.map +0 -1
  382. package/dist/tightener/index.d.ts +0 -4
  383. package/dist/tightener/index.js +0 -4
  384. package/dist/tightener/index.js.map +0 -1
  385. package/dist/tightener/prompt.d.ts +0 -3
  386. package/dist/tightener/prompt.js +0 -67
  387. package/dist/tightener/prompt.js.map +0 -1
  388. package/dist/tightener/schema.d.ts +0 -68
  389. package/dist/tightener/schema.js +0 -44
  390. package/dist/tightener/schema.js.map +0 -1
  391. package/dist/tightener/tighten.d.ts +0 -2
  392. package/dist/tightener/tighten.js +0 -66
  393. package/dist/tightener/tighten.js.map +0 -1
  394. package/dist/tightener/types.d.ts +0 -74
  395. package/dist/tightener/types.js +0 -6
  396. package/dist/tightener/types.js.map +0 -1
  397. package/templates/.claude/settings.json +0 -57
  398. package/templates/.mcp.json +0 -8
  399. package/templates/README.md +0 -24
@@ -1,146 +0,0 @@
1
- /**
2
- * Assertion-refiner prompts.
3
- *
4
- * The decision-extractor (Phase 14) emits LOOSE candidate assertions —
5
- * `{kind, description, parameters?}` with `parameters` schema-loose. The
6
- * decision file stores them under frontmatter `candidate_assertions:`,
7
- * NOT under `assertions:` which Layer-D sensors enforce.
8
- *
9
- * The refiner's job is to lift each candidate into a STRICT shape that
10
- * matches one of the eleven `DecisionAssertion` kinds (see
11
- * `src/ground/schemas.ts`). When a candidate is too vague to form
12
- * confident strict params, the refiner DEMOTES it to
13
- * `human_review_hint` (always soft, always passes zod). When the
14
- * candidate description is sound but the strict params would need
15
- * operator input the refiner can't infer, it SKIPS — the candidate
16
- * survives in `candidate_assertions:` for the next refine pass.
17
- *
18
- * Anti-fabrication framing: prefer demote / skip over inventing wrong
19
- * regex / globs / table names. A wrong assertion is a sensor that fires
20
- * on every PR forever; a `human_review_hint` is at worst noise in the
21
- * reviewer's pre-amble.
22
- */
23
- const PER_DECISION_CHAR_CAP = 4_000;
24
- export const REFINEMENT_PROPOSER_SYSTEM_PROMPT = `You are the **assertion-refiner** for an agent cairn. The operator just confirmed a binding decision; the decision-extractor proposed N loose candidate assertions to enforce it. Your job is to lift each candidate into the STRICT shape used by the cairn's mechanical sensors, OR demote / skip it.
25
-
26
- ## The eleven assertion kinds
27
-
28
- Each kind requires specific fields. The cairn's zod re-validates at apply time; a malformed \`strict_assertion\` is auto-demoted, so don't fudge — when you don't have a confident value for a required field, set status="demote" or status="skip" instead.
29
-
30
- - **schema_must_contain** — { table: string, column: string, column_type?: string, nullable?: boolean }
31
- Migration / schema rule. Example: "tokens table must have user_id column NOT NULL".
32
-
33
- - **text_must_match** — { pattern: string (JS regex source), in_globs: string[] }
34
- Some text must appear in matching files. Example: license header in src/**/*.ts.
35
-
36
- - **text_must_not_match** — { pattern: string, in_globs: string[] }
37
- Some text must NOT appear. Example: "no \`process.env.\` access in src/**/*.ts".
38
-
39
- - **index_must_exist** — { table: string, columns: string[], where?: string }
40
- Database index. Example: "(provider, user_id) WHERE archived_at IS NULL on tokens".
41
-
42
- - **ast_pattern** — { language: string ("ts"|"py"|"go"|...), pattern: string (regex fallback), in_globs: string[] }
43
- Structural pattern. Example: "all controllers extend BaseController".
44
-
45
- - **file_must_not_be_modified** — { path: string }
46
- Frozen file. Example: "core/src/legacy/billing.ts".
47
-
48
- - **query_must_filter_by** — { orm: string ("drizzle"|"prisma"|"sqlalchemy"|...), in_globs: string[], table: string, columns: string[], operator: "eq"|"in"|"between"|"is_not_null", require_combination: "and"|"or" }
49
- ORM-level scope. Example: "all integration_oauth_tokens queries filter by user_id eq AND provider eq".
50
-
51
- - **route_must_have_guard** — { in_globs: string[], guard: string, require_on: string[] }
52
- HTTP guard. Example: "all routes in api/*/admin.ts have RequireRole guard, require_on: [GET, POST]".
53
-
54
- - **event_must_emit** — { in_globs: string[], after_method: string, event_key: string, payload_must_include?: string[] }
55
- Event emission. Example: "after createInvoice() emit invoice.created with [invoice_id, user_id]".
56
-
57
- - **service_method_must_call** — { in_globs: string[], in_method: string, must_call: string, before_returning?: boolean }
58
- Required call inside method. Example: "in TokenService.refresh(), must call audit.log() before returning".
59
-
60
- - **human_review_hint** — { description: string }
61
- Always-soft fallback. Use this for purely conceptual rules ("prefer simple solutions", "avoid magic numbers in pricing logic").
62
-
63
- ## Per-candidate verdict
64
-
65
- For each candidate, emit one proposal:
66
-
67
- \`\`\`
68
- {
69
- candidate_id: <as given>,
70
- candidate_kind: <as given>,
71
- status: "lift" | "demote" | "skip",
72
- confidence_signal: "high" | "medium" | "low",
73
- strict_assertion?: { ... } // present iff status="lift"
74
- rationale: "one sentence explaining the choice"
75
- }
76
- \`\`\`
77
-
78
- ### When to LIFT
79
-
80
- You are confident on every required field for the candidate's kind. The description gave you concrete table / file / regex / glob names, and the decision's scope_globs lets you narrow the in_globs reasonably.
81
-
82
- If the candidate kind is **human_review_hint**, ALWAYS lift — the kind already has a single-field shape. \`description\` is the candidate's existing description.
83
-
84
- ### When to DEMOTE
85
-
86
- The candidate description is sound but the strict params would require input you don't have (e.g., "no env vars" — needs the actual regex pattern; "must filter by user_id" — needs the ORM name and table name and you don't know which).
87
-
88
- Demote means: rewrite as \`human_review_hint\` with a description that captures the rule's intent. The operator + reviewer + UAT still see it; sensors don't enforce it. Better than a hallucinated regex that fires on every PR.
89
-
90
- ### When to SKIP
91
-
92
- The candidate is weakly-specified to the point that even \`human_review_hint\` would be too vague to be useful (e.g., the operator's description was "fix the thing", the kind doesn't match the description, etc.). Skip leaves it under \`candidate_assertions:\` for a future refine pass.
93
-
94
- ## Confidence
95
-
96
- - \`high\`: required fields are explicit in the candidate description. No guesses.
97
- - \`medium\`: most fields present, one or two reasonable inferences from scope_globs / decision summary.
98
- - \`low\`: status="lift" with low confidence is a defect. Use status="demote" or "skip" instead.
99
-
100
- ## Output
101
-
102
- Emit ONLY the JSON object: \`{ "proposals": [...] }\`. One proposal per input candidate, in the order given. No prose, no code fences.`;
103
- export function buildRefinementProposerUserPrompt(input) {
104
- const sections = [];
105
- sections.push(`## Decision context — ${input.decision_id}`);
106
- sections.push(`subject: ${input.subject}`);
107
- const summary = input.summary.trim();
108
- sections.push("");
109
- sections.push("summary:");
110
- sections.push(summary.length > PER_DECISION_CHAR_CAP
111
- ? summary.slice(0, PER_DECISION_CHAR_CAP) +
112
- `\n…[truncated; ${summary.length - PER_DECISION_CHAR_CAP} chars elided]`
113
- : summary);
114
- if (input.scope_globs.length > 0) {
115
- sections.push("");
116
- sections.push("scope_globs:");
117
- for (const g of input.scope_globs)
118
- sections.push(` - ${g}`);
119
- }
120
- else {
121
- sections.push("");
122
- sections.push("scope_globs: (none — operator left it unspecified)");
123
- }
124
- sections.push("");
125
- sections.push("## Candidates to refine");
126
- for (let i = 0; i < input.candidates.length; i++) {
127
- const c = input.candidates[i];
128
- if (c === undefined)
129
- continue;
130
- const id = c.id ?? `${input.decision_id}-A${(i + 1).toString().padStart(2, "0")}`;
131
- sections.push("");
132
- sections.push(`### ${id} (kind: ${c.kind})`);
133
- sections.push(`description: ${c.description}`);
134
- if (c.parameters && Object.keys(c.parameters).length > 0) {
135
- sections.push("parameters (loose, from extractor):");
136
- sections.push("```json");
137
- sections.push(JSON.stringify(c.parameters, null, 2));
138
- sections.push("```");
139
- }
140
- }
141
- sections.push("");
142
- sections.push("## Your task");
143
- sections.push("Emit one proposal per candidate in the order given. Use the candidate_id values shown above. Output ONLY the JSON object.");
144
- return sections.join("\n");
145
- }
146
- //# sourceMappingURL=refinement-prompt.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"refinement-prompt.js","sourceRoot":"","sources":["../../src/decision-capture/refinement-prompt.ts"],"names":[],"mappings":"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"}
@@ -1,52 +0,0 @@
1
- /**
2
- * JSON Schema enforced by `claude --json-schema` for the assertion-refiner
3
- * proposer output.
4
- *
5
- * For each input candidate the proposer returns one `RefinementProposal`.
6
- * The shape here is intentionally loose on `strict_assertion` — the
7
- * production `DecisionAssertion` zod (see `src/ground/schemas.ts`) is the
8
- * source of truth and re-validates at apply time. Forcing the discriminated
9
- * union into JSON Schema and the proposer's prompt would burn tokens
10
- * without buying additional safety, since malformed shapes auto-demote.
11
- *
12
- * The proposer's per-kind contract is encoded in the system prompt
13
- * (`refinement-prompt.ts`), not here.
14
- */
15
- export declare const REFINEMENT_PROPOSER_OUTPUT_SCHEMA: {
16
- readonly type: "object";
17
- readonly additionalProperties: false;
18
- readonly properties: {
19
- readonly proposals: {
20
- readonly type: "array";
21
- readonly items: {
22
- readonly type: "object";
23
- readonly additionalProperties: false;
24
- readonly properties: {
25
- readonly candidate_id: {
26
- readonly type: "string";
27
- readonly minLength: 1;
28
- };
29
- readonly candidate_kind: {
30
- readonly enum: readonly ["schema_must_contain", "text_must_match", "text_must_not_match", "index_must_exist", "ast_pattern", "file_must_not_be_modified", "query_must_filter_by", "route_must_have_guard", "event_must_emit", "service_method_must_call", "human_review_hint"];
31
- };
32
- readonly status: {
33
- readonly enum: readonly ["lift", "demote", "skip"];
34
- };
35
- readonly confidence_signal: {
36
- readonly enum: readonly ["high", "medium", "low"];
37
- };
38
- readonly strict_assertion: {
39
- readonly type: "object";
40
- readonly additionalProperties: true;
41
- };
42
- readonly rationale: {
43
- readonly type: "string";
44
- readonly minLength: 1;
45
- };
46
- };
47
- readonly required: readonly ["candidate_id", "candidate_kind", "status", "confidence_signal", "rationale"];
48
- };
49
- };
50
- };
51
- readonly required: readonly ["proposals"];
52
- };
@@ -1,61 +0,0 @@
1
- /**
2
- * JSON Schema enforced by `claude --json-schema` for the assertion-refiner
3
- * proposer output.
4
- *
5
- * For each input candidate the proposer returns one `RefinementProposal`.
6
- * The shape here is intentionally loose on `strict_assertion` — the
7
- * production `DecisionAssertion` zod (see `src/ground/schemas.ts`) is the
8
- * source of truth and re-validates at apply time. Forcing the discriminated
9
- * union into JSON Schema and the proposer's prompt would burn tokens
10
- * without buying additional safety, since malformed shapes auto-demote.
11
- *
12
- * The proposer's per-kind contract is encoded in the system prompt
13
- * (`refinement-prompt.ts`), not here.
14
- */
15
- export const REFINEMENT_PROPOSER_OUTPUT_SCHEMA = {
16
- type: "object",
17
- additionalProperties: false,
18
- properties: {
19
- proposals: {
20
- type: "array",
21
- items: {
22
- type: "object",
23
- additionalProperties: false,
24
- properties: {
25
- candidate_id: { type: "string", minLength: 1 },
26
- candidate_kind: {
27
- enum: [
28
- "schema_must_contain",
29
- "text_must_match",
30
- "text_must_not_match",
31
- "index_must_exist",
32
- "ast_pattern",
33
- "file_must_not_be_modified",
34
- "query_must_filter_by",
35
- "route_must_have_guard",
36
- "event_must_emit",
37
- "service_method_must_call",
38
- "human_review_hint",
39
- ],
40
- },
41
- status: { enum: ["lift", "demote", "skip"] },
42
- confidence_signal: { enum: ["high", "medium", "low"] },
43
- strict_assertion: {
44
- type: "object",
45
- additionalProperties: true,
46
- },
47
- rationale: { type: "string", minLength: 1 },
48
- },
49
- required: [
50
- "candidate_id",
51
- "candidate_kind",
52
- "status",
53
- "confidence_signal",
54
- "rationale",
55
- ],
56
- },
57
- },
58
- },
59
- required: ["proposals"],
60
- };
61
- //# sourceMappingURL=refinement-schema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"refinement-schema.js","sourceRoot":"","sources":["../../src/decision-capture/refinement-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG;IAC/C,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,KAAK;IAC3B,UAAU,EAAE;QACV,SAAS,EAAE;YACT,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,oBAAoB,EAAE,KAAK;gBAC3B,UAAU,EAAE;oBACV,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE;oBAC9C,cAAc,EAAE;wBACd,IAAI,EAAE;4BACJ,qBAAqB;4BACrB,iBAAiB;4BACjB,qBAAqB;4BACrB,kBAAkB;4BAClB,aAAa;4BACb,2BAA2B;4BAC3B,sBAAsB;4BACtB,uBAAuB;4BACvB,iBAAiB;4BACjB,0BAA0B;4BAC1B,mBAAmB;yBACpB;qBACF;oBACD,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE;oBAC5C,iBAAiB,EAAE,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE;oBACtD,gBAAgB,EAAE;wBAChB,IAAI,EAAE,QAAQ;wBACd,oBAAoB,EAAE,IAAI;qBAC3B;oBACD,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE;iBAC5C;gBACD,QAAQ,EAAE;oBACR,cAAc;oBACd,gBAAgB;oBAChB,QAAQ;oBACR,mBAAmB;oBACnB,WAAW;iBACZ;aACF;SACF;KACF;IACD,QAAQ,EAAE,CAAC,WAAW,CAAC;CACf,CAAC"}
@@ -1,60 +0,0 @@
1
- /**
2
- * Phase 14.x — assertion refinement.
3
- *
4
- * Lifts the loose `candidate_assertions:` set on an accepted decision into
5
- * the strict `assertions:` shape that Layer-D sensors enforce.
6
- *
7
- * Flow:
8
- * read accepted decision file
9
- * → proposeStrictAssertions (Tier-1 LLM)
10
- * → re-validate each lift via DecisionAssertion zod (auto-demote on fail)
11
- * → adapter.requestDialog: a) approve_all b) approve_high_only
12
- * c) demote_all d) skip
13
- * → liftCandidatesToAssertions writes the file
14
- * → ledger regenerates so the new strict assertions become live
15
- *
16
- * The proposer runs READ-ONLY. The writer + dialog drive everything that
17
- * touches the filesystem. A proposer failure (timeout, malformed JSON,
18
- * subprocess crash) does NOT roll back the prior accept — it returns
19
- * `proposer_failed: true` and leaves candidates under their loose
20
- * `candidate_assertions:` field for the next refine pass.
21
- */
22
- import type { FrontendAdapter } from "../frontend-types.js";
23
- import type { ClaudeTier } from "../claude/index.js";
24
- import type { RefinementResult, RefinerInput, RefinerOutput } from "./types.js";
25
- export interface ProposerResult {
26
- output: RefinerOutput;
27
- duration_ms: number;
28
- usage?: {
29
- input_tokens?: number;
30
- output_tokens?: number;
31
- };
32
- }
33
- /**
34
- * Single Tier-1 (Haiku default) LLM call producing one proposal per
35
- * input candidate. The output is gated by the JSON Schema on the CLI
36
- * side and re-validated structurally here.
37
- */
38
- export declare function proposeStrictAssertions(input: RefinerInput): Promise<ProposerResult>;
39
- export interface RunDecisionRefinementArgs {
40
- /** Repo root for the mirror checkout. */
41
- repoRoot: string;
42
- /** DEC-id of the accepted decision whose candidates we're refining. */
43
- decisionId: string;
44
- /** Adapter that owns the confirm dialog. */
45
- adapter: FrontendAdapter;
46
- /** Channel for the dialog (Discord thread / DM). */
47
- channelId?: string;
48
- /** Tier for the proposer call. Default = haiku. */
49
- tier?: ClaudeTier;
50
- /** Per-call timeout for the proposer. */
51
- proposerTimeoutMs?: number;
52
- /** Dialog timeout. Default 60_000 ms. */
53
- dialogTimeoutMs?: number;
54
- /**
55
- * Smokes inject a stub here so they can verify dialog branching without
56
- * burning claude quota. Defaults to `proposeStrictAssertions`.
57
- */
58
- proposerOverride?: typeof proposeStrictAssertions;
59
- }
60
- export declare function runDecisionRefinement(args: RunDecisionRefinementArgs): Promise<RefinementResult>;