@isaacriehm/cairn-core 0.7.0 → 0.7.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 (440) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/align-undo/undo.js +2 -2
  3. package/dist/align-undo/undo.js.map +1 -1
  4. package/dist/attention/bulk-accept.js +48 -40
  5. package/dist/attention/bulk-accept.js.map +1 -1
  6. package/dist/attention/dedup.js +23 -10
  7. package/dist/attention/dedup.js.map +1 -1
  8. package/dist/attention/restore.js +2 -2
  9. package/dist/attention/restore.js.map +1 -1
  10. package/dist/attention/scoring.js +1 -1
  11. package/dist/attention/scoring.js.map +1 -1
  12. package/dist/attention/serve/api.d.ts +1 -0
  13. package/dist/attention/serve/api.js +127 -80
  14. package/dist/attention/serve/api.js.map +1 -1
  15. package/dist/attention/serve/index.d.ts +1 -0
  16. package/dist/attention/serve/index.js +21 -7
  17. package/dist/attention/serve/index.js.map +1 -1
  18. package/dist/attention/source-strip.js +41 -46
  19. package/dist/attention/source-strip.js.map +1 -1
  20. package/dist/claude/cache.d.ts +10 -19
  21. package/dist/claude/cache.js +0 -0
  22. package/dist/claude/cache.js.map +1 -1
  23. package/dist/claude/runner.d.ts +4 -6
  24. package/dist/claude/runner.js +242 -203
  25. package/dist/claude/runner.js.map +1 -1
  26. package/dist/claude/types.d.ts +5 -5
  27. package/dist/context/handoff-builder.d.ts +28 -4
  28. package/dist/context/handoff-builder.js +75 -157
  29. package/dist/context/handoff-builder.js.map +1 -1
  30. package/dist/context/spec-delta.js +61 -9
  31. package/dist/context/spec-delta.js.map +1 -1
  32. package/dist/context/task-summary.js +5 -1
  33. package/dist/context/task-summary.js.map +1 -1
  34. package/dist/decision-capture/id.js +1 -1
  35. package/dist/decision-capture/id.js.map +1 -1
  36. package/dist/doctor/index.d.ts +9 -11
  37. package/dist/doctor/index.js +118 -175
  38. package/dist/doctor/index.js.map +1 -1
  39. package/dist/drain/drain.d.ts +1 -1
  40. package/dist/drain/drain.js +16 -16
  41. package/dist/drain/drain.js.map +1 -1
  42. package/dist/drain/index.d.ts +1 -1
  43. package/dist/drain/index.js +1 -1
  44. package/dist/events/reader.d.ts +9 -10
  45. package/dist/events/reader.js +46 -57
  46. package/dist/events/reader.js.map +1 -1
  47. package/dist/events/writer.js +1 -1
  48. package/dist/events/writer.js.map +1 -1
  49. package/dist/fix-align/index.d.ts +1 -1
  50. package/dist/fix-align/index.js +1 -1
  51. package/dist/fix-align/run.d.ts +1 -1
  52. package/dist/fix-align/run.js +4 -3
  53. package/dist/fix-align/run.js.map +1 -1
  54. package/dist/fix-align/sentinel.d.ts +1 -2
  55. package/dist/fix-align/sentinel.js +3 -4
  56. package/dist/fix-align/sentinel.js.map +1 -1
  57. package/dist/gc/apply.js +1 -1
  58. package/dist/gc/apply.js.map +1 -1
  59. package/dist/gc/attested-commits.d.ts +19 -0
  60. package/dist/gc/attested-commits.js +48 -0
  61. package/dist/gc/attested-commits.js.map +1 -0
  62. package/dist/gc/canary.d.ts +11 -21
  63. package/dist/gc/canary.js +18 -24
  64. package/dist/gc/canary.js.map +1 -1
  65. package/dist/gc/citation-integrity.d.ts +11 -14
  66. package/dist/gc/citation-integrity.js +124 -125
  67. package/dist/gc/citation-integrity.js.map +1 -1
  68. package/dist/gc/classify.d.ts +1 -1
  69. package/dist/gc/classify.js +2 -2
  70. package/dist/gc/classify.js.map +1 -1
  71. package/dist/gc/completion-integrity.d.ts +6 -7
  72. package/dist/gc/completion-integrity.js +45 -53
  73. package/dist/gc/completion-integrity.js.map +1 -1
  74. package/dist/gc/doc-gardening.js +1 -9
  75. package/dist/gc/doc-gardening.js.map +1 -1
  76. package/dist/gc/frontmatter.js +2 -2
  77. package/dist/gc/frontmatter.js.map +1 -1
  78. package/dist/gc/index.d.ts +7 -6
  79. package/dist/gc/index.js +3 -2
  80. package/dist/gc/index.js.map +1 -1
  81. package/dist/gc/quality-update.d.ts +6 -10
  82. package/dist/gc/quality-update.js +12 -15
  83. package/dist/gc/quality-update.js.map +1 -1
  84. package/dist/gc/scope-coverage.js +1 -1
  85. package/dist/gc/scope-coverage.js.map +1 -1
  86. package/dist/gc/stub-hits.d.ts +7 -25
  87. package/dist/gc/stub-hits.js +14 -40
  88. package/dist/gc/stub-hits.js.map +1 -1
  89. package/dist/gc/sweep.js +15 -6
  90. package/dist/gc/sweep.js.map +1 -1
  91. package/dist/gc/types.d.ts +5 -5
  92. package/dist/gc/types.js +2 -2
  93. package/dist/gc/walk-source.js +8 -28
  94. package/dist/gc/walk-source.js.map +1 -1
  95. package/dist/hooks/defer.d.ts +9 -20
  96. package/dist/hooks/defer.js +10 -27
  97. package/dist/hooks/defer.js.map +1 -1
  98. package/dist/hooks/post-tool-use/allowlist-reader.d.ts +2 -1
  99. package/dist/hooks/post-tool-use/allowlist-reader.js +49 -34
  100. package/dist/hooks/post-tool-use/allowlist-reader.js.map +1 -1
  101. package/dist/hooks/post-tool-use/index.d.ts +3 -4
  102. package/dist/hooks/post-tool-use/index.js +3 -3
  103. package/dist/hooks/post-tool-use/index.js.map +1 -1
  104. package/dist/hooks/post-tool-use/legend-builder.d.ts +2 -2
  105. package/dist/hooks/post-tool-use/legend-builder.js +2 -2
  106. package/dist/hooks/post-tool-use/legend-builder.js.map +1 -1
  107. package/dist/hooks/post-tool-use/post-write.d.ts +8 -0
  108. package/dist/hooks/post-tool-use/post-write.js +112 -0
  109. package/dist/hooks/post-tool-use/post-write.js.map +1 -0
  110. package/dist/hooks/post-tool-use/read-enricher.d.ts +10 -5
  111. package/dist/hooks/post-tool-use/read-enricher.js +114 -155
  112. package/dist/hooks/post-tool-use/read-enricher.js.map +1 -1
  113. package/dist/hooks/post-tool-use/sot-align.d.ts +12 -0
  114. package/dist/hooks/post-tool-use/sot-align.js +73 -49
  115. package/dist/hooks/post-tool-use/sot-align.js.map +1 -1
  116. package/dist/hooks/post-tool-use/write-guardian.d.ts +40 -8
  117. package/dist/hooks/post-tool-use/write-guardian.js +202 -254
  118. package/dist/hooks/post-tool-use/write-guardian.js.map +1 -1
  119. package/dist/hooks/pre-commit/sot-align-precommit.js +2 -2
  120. package/dist/hooks/pre-commit/sot-align-precommit.js.map +1 -1
  121. package/dist/hooks/runners/index.d.ts +2 -2
  122. package/dist/hooks/runners/index.js +1 -1
  123. package/dist/hooks/runners/index.js.map +1 -1
  124. package/dist/hooks/runners/payload.d.ts +34 -19
  125. package/dist/hooks/runners/payload.js +47 -44
  126. package/dist/hooks/runners/payload.js.map +1 -1
  127. package/dist/hooks/runners/session-end.js +12 -11
  128. package/dist/hooks/runners/session-end.js.map +1 -1
  129. package/dist/hooks/runners/session-start.d.ts +4 -2
  130. package/dist/hooks/runners/session-start.js +88 -261
  131. package/dist/hooks/runners/session-start.js.map +1 -1
  132. package/dist/hooks/runners/stop.js +27 -8
  133. package/dist/hooks/runners/stop.js.map +1 -1
  134. package/dist/hooks/runners/user-prompt-submit.js +7 -1
  135. package/dist/hooks/runners/user-prompt-submit.js.map +1 -1
  136. package/dist/hooks/sot-align-common.d.ts +1 -2
  137. package/dist/hooks/sot-align-common.js +2 -2
  138. package/dist/hooks/sot-align-common.js.map +1 -1
  139. package/dist/index.d.ts +1 -1
  140. package/dist/index.js +12 -3
  141. package/dist/index.js.map +1 -1
  142. package/dist/init/baseline-audit.d.ts +14 -58
  143. package/dist/init/baseline-audit.js +92 -320
  144. package/dist/init/baseline-audit.js.map +1 -1
  145. package/dist/init/brand-derive.d.ts +11 -15
  146. package/dist/init/brand-derive.js +21 -46
  147. package/dist/init/brand-derive.js.map +1 -1
  148. package/dist/init/brand-setup.d.ts +1 -1
  149. package/dist/init/brand-setup.js +1 -1
  150. package/dist/init/detect.d.ts +25 -6
  151. package/dist/init/detect.js +107 -136
  152. package/dist/init/detect.js.map +1 -1
  153. package/dist/init/index.d.ts +2 -2
  154. package/dist/init/index.js +1 -1
  155. package/dist/init/index.js.map +1 -1
  156. package/dist/init/ingest-docs.d.ts +2 -2
  157. package/dist/init/ingest-docs.js +31 -43
  158. package/dist/init/ingest-docs.js.map +1 -1
  159. package/dist/init/init.d.ts +21 -21
  160. package/dist/init/init.js +41 -61
  161. package/dist/init/init.js.map +1 -1
  162. package/dist/init/mapper-merge.js +1 -1
  163. package/dist/init/mapper-merge.js.map +1 -1
  164. package/dist/init/mapper-parallel.d.ts +1 -1
  165. package/dist/init/mapper-parallel.js +2 -1
  166. package/dist/init/mapper-parallel.js.map +1 -1
  167. package/dist/init/mapper.js +1 -1
  168. package/dist/init/mapper.js.map +1 -1
  169. package/dist/init/multi-dev/install.d.ts +5 -5
  170. package/dist/init/multi-dev/install.js +4 -4
  171. package/dist/init/overlay.js +1 -0
  172. package/dist/init/overlay.js.map +1 -1
  173. package/dist/init/phases/1-detect.js +1 -1
  174. package/dist/init/phases/1-detect.js.map +1 -1
  175. package/dist/init/phases/{7c-rules-merge.d.ts → 10-rules-merge.d.ts} +2 -2
  176. package/dist/init/phases/{7c-rules-merge.js → 10-rules-merge.js} +6 -12
  177. package/dist/init/phases/10-rules-merge.js.map +1 -0
  178. package/dist/init/phases/11-baseline.d.ts +7 -0
  179. package/dist/init/phases/{8-baseline.js → 11-baseline.js} +5 -9
  180. package/dist/init/phases/11-baseline.js.map +1 -0
  181. package/dist/init/phases/12-strip.d.ts +10 -0
  182. package/dist/init/phases/{10-strip.js → 12-strip.js} +10 -14
  183. package/dist/init/phases/12-strip.js.map +1 -0
  184. package/dist/init/phases/{12-multidev.d.ts → 13-multidev.d.ts} +2 -2
  185. package/dist/init/phases/{12-multidev.js → 13-multidev.js} +4 -4
  186. package/dist/init/phases/{12-multidev.js.map → 13-multidev.js.map} +1 -1
  187. package/dist/init/phases/3-mapper.d.ts +1 -1
  188. package/dist/init/phases/3-mapper.js +2 -2
  189. package/dist/init/phases/3-mapper.js.map +1 -1
  190. package/dist/init/phases/{3b-seed.d.ts → 4-seed.d.ts} +2 -2
  191. package/dist/init/phases/{3b-seed.js → 4-seed.js} +7 -7
  192. package/dist/init/phases/4-seed.js.map +1 -0
  193. package/dist/init/phases/{4-pilot.d.ts → 5-pilot.d.ts} +2 -2
  194. package/dist/init/phases/{4-pilot.js → 5-pilot.js} +9 -9
  195. package/dist/init/phases/{4-pilot.js.map → 5-pilot.js.map} +1 -1
  196. package/dist/init/phases/{5-brand.d.ts → 6-brand.d.ts} +2 -7
  197. package/dist/init/phases/{5-brand.js → 6-brand.js} +6 -14
  198. package/dist/init/phases/6-brand.js.map +1 -0
  199. package/dist/init/phases/{5b-topic-index.d.ts → 7-topic-index.d.ts} +2 -11
  200. package/dist/init/phases/{5b-topic-index.js → 7-topic-index.js} +9 -18
  201. package/dist/init/phases/7-topic-index.js.map +1 -0
  202. package/dist/init/phases/8-docs-ingest.d.ts +10 -0
  203. package/dist/init/phases/{6-docs-ingest.js → 8-docs-ingest.js} +6 -11
  204. package/dist/init/phases/8-docs-ingest.js.map +1 -0
  205. package/dist/init/phases/9-source-comments.d.ts +6 -0
  206. package/dist/init/phases/{7b-source-comments.js → 9-source-comments.js} +7 -26
  207. package/dist/init/phases/9-source-comments.js.map +1 -0
  208. package/dist/init/phases/index.d.ts +12 -12
  209. package/dist/init/phases/index.js +11 -11
  210. package/dist/init/phases/index.js.map +1 -1
  211. package/dist/init/phases/{parallel-678.d.ts → parallel-8910.d.ts} +7 -8
  212. package/dist/init/phases/{parallel-678.js → parallel-8910.js} +26 -44
  213. package/dist/init/phases/parallel-8910.js.map +1 -0
  214. package/dist/init/phases/source-comments-output-io.d.ts +3 -3
  215. package/dist/init/phases/source-comments-output-io.js +3 -3
  216. package/dist/init/phases/types.d.ts +1 -1
  217. package/dist/init/phases/types.js +10 -10
  218. package/dist/init/phases/types.js.map +1 -1
  219. package/dist/init/rules-merge/discover.d.ts +2 -2
  220. package/dist/init/rules-merge/discover.js +28 -43
  221. package/dist/init/rules-merge/discover.js.map +1 -1
  222. package/dist/init/rules-merge/ingest.d.ts +6 -6
  223. package/dist/init/rules-merge/ingest.js +9 -10
  224. package/dist/init/rules-merge/ingest.js.map +1 -1
  225. package/dist/init/rules-merge/keep-markers.d.ts +1 -1
  226. package/dist/init/rules-merge/keep-markers.js +1 -1
  227. package/dist/init/rules-merge/regenerate.d.ts +3 -3
  228. package/dist/init/rules-merge/regenerate.js +3 -3
  229. package/dist/init/seed.js +17 -24
  230. package/dist/init/seed.js.map +1 -1
  231. package/dist/init/sot-emit.d.ts +27 -9
  232. package/dist/init/sot-emit.js +39 -7
  233. package/dist/init/sot-emit.js.map +1 -1
  234. package/dist/init/source-comments/classify.d.ts +2 -2
  235. package/dist/init/source-comments/classify.js +9 -1
  236. package/dist/init/source-comments/classify.js.map +1 -1
  237. package/dist/init/source-comments/index.d.ts +1 -1
  238. package/dist/init/source-comments/index.js.map +1 -1
  239. package/dist/init/source-comments/ingest.d.ts +2 -2
  240. package/dist/init/source-comments/ingest.js +6 -8
  241. package/dist/init/source-comments/ingest.js.map +1 -1
  242. package/dist/init/source-comments/strip-replace.js +3 -2
  243. package/dist/init/source-comments/strip-replace.js.map +1 -1
  244. package/dist/init/source-comments/walker.d.ts +3 -26
  245. package/dist/init/source-comments/walker.js +18 -30
  246. package/dist/init/source-comments/walker.js.map +1 -1
  247. package/dist/init/topic-index/index.d.ts +1 -1
  248. package/dist/init/topic-index/index.js +3 -3
  249. package/dist/init/topic-index/index.js.map +1 -1
  250. package/dist/init/topic-index/judge.d.ts +5 -9
  251. package/dist/init/topic-index/judge.js +17 -22
  252. package/dist/init/topic-index/judge.js.map +1 -1
  253. package/dist/init/topic-index/resolve.d.ts +5 -4
  254. package/dist/init/topic-index/resolve.js +6 -6
  255. package/dist/init/topic-index/resolve.js.map +1 -1
  256. package/dist/init/topic-index/walk.d.ts +6 -6
  257. package/dist/init/topic-index/walk.js +9 -9
  258. package/dist/init/topic-index/walk.js.map +1 -1
  259. package/dist/lock.js +4 -1
  260. package/dist/lock.js.map +1 -1
  261. package/dist/logger.js +3 -0
  262. package/dist/logger.js.map +1 -1
  263. package/dist/mcp/history/summarizer.js +1 -1
  264. package/dist/mcp/history/summarizer.js.map +1 -1
  265. package/dist/mcp/history/walker.js +1 -1
  266. package/dist/mcp/history/walker.js.map +1 -1
  267. package/dist/mcp/path-allowlist.js +1 -1
  268. package/dist/mcp/path-allowlist.js.map +1 -1
  269. package/dist/mcp/schemas.d.ts +16 -38
  270. package/dist/mcp/schemas.js +8 -22
  271. package/dist/mcp/schemas.js.map +1 -1
  272. package/dist/mcp/server.js +10 -0
  273. package/dist/mcp/server.js.map +1 -1
  274. package/dist/mcp/tools/archive.js +1 -1
  275. package/dist/mcp/tools/archive.js.map +1 -1
  276. package/dist/mcp/tools/attention-wait.js +12 -2
  277. package/dist/mcp/tools/attention-wait.js.map +1 -1
  278. package/dist/mcp/tools/bulk-accept-attention.js +29 -30
  279. package/dist/mcp/tools/bulk-accept-attention.js.map +1 -1
  280. package/dist/mcp/tools/canonical-for-topic.js +37 -15
  281. package/dist/mcp/tools/canonical-for-topic.js.map +1 -1
  282. package/dist/mcp/tools/decision-get.js +2 -2
  283. package/dist/mcp/tools/decision-get.js.map +1 -1
  284. package/dist/mcp/tools/decisions-for-symbol.js +2 -2
  285. package/dist/mcp/tools/decisions-for-symbol.js.map +1 -1
  286. package/dist/mcp/tools/get-full.js +1 -1
  287. package/dist/mcp/tools/get-full.js.map +1 -1
  288. package/dist/mcp/tools/ground-get.js +1 -1
  289. package/dist/mcp/tools/ground-get.js.map +1 -1
  290. package/dist/mcp/tools/in-scope.d.ts +8 -0
  291. package/dist/mcp/tools/in-scope.js +125 -0
  292. package/dist/mcp/tools/in-scope.js.map +1 -0
  293. package/dist/mcp/tools/index.js +7 -10
  294. package/dist/mcp/tools/index.js.map +1 -1
  295. package/dist/mcp/tools/init-phases.d.ts +3 -2
  296. package/dist/mcp/tools/init-phases.js +125 -124
  297. package/dist/mcp/tools/init-phases.js.map +1 -1
  298. package/dist/mcp/tools/invariant-get.js +2 -2
  299. package/dist/mcp/tools/invariant-get.js.map +1 -1
  300. package/dist/mcp/tools/record-decision.d.ts +4 -3
  301. package/dist/mcp/tools/record-decision.js +111 -36
  302. package/dist/mcp/tools/record-decision.js.map +1 -1
  303. package/dist/mcp/tools/reject-candidate.d.ts +1 -1
  304. package/dist/mcp/tools/reject-candidate.js +3 -3
  305. package/dist/mcp/tools/reject-candidate.js.map +1 -1
  306. package/dist/mcp/tools/resolve-attention.d.ts +5 -18
  307. package/dist/mcp/tools/resolve-attention.js +58 -158
  308. package/dist/mcp/tools/resolve-attention.js.map +1 -1
  309. package/dist/mcp/tools/search-candidates.d.ts +1 -1
  310. package/dist/mcp/tools/search-candidates.js +4 -4
  311. package/dist/mcp/tools/search-candidates.js.map +1 -1
  312. package/dist/mcp/tools/search.js +5 -4
  313. package/dist/mcp/tools/search.js.map +1 -1
  314. package/dist/mcp/tools/supersedes-chain.js +2 -2
  315. package/dist/mcp/tools/supersedes-chain.js.map +1 -1
  316. package/dist/mcp/tools/task-create.d.ts +1 -0
  317. package/dist/mcp/tools/task-create.js +2 -0
  318. package/dist/mcp/tools/task-create.js.map +1 -1
  319. package/dist/mcp/tools/timeline.js +1 -1
  320. package/dist/mcp/tools/timeline.js.map +1 -1
  321. package/dist/mcp/tools/types.d.ts +1 -0
  322. package/dist/mcp/tools/types.js +9 -1
  323. package/dist/mcp/tools/types.js.map +1 -1
  324. package/dist/sensors/attestation.d.ts +1 -1
  325. package/dist/sensors/attestation.js +2 -2
  326. package/dist/sensors/attestation.js.map +1 -1
  327. package/dist/sensors/catalog.d.ts +26 -28
  328. package/dist/sensors/catalog.js +79 -81
  329. package/dist/sensors/catalog.js.map +1 -1
  330. package/dist/sensors/decisions.d.ts +1 -1
  331. package/dist/sensors/decisions.js +15 -14
  332. package/dist/sensors/decisions.js.map +1 -1
  333. package/dist/sensors/diff.js +46 -22
  334. package/dist/sensors/diff.js.map +1 -1
  335. package/dist/sensors/runner.d.ts +2 -2
  336. package/dist/sensors/runner.js +3 -3
  337. package/dist/sensors/shell.d.ts +4 -0
  338. package/dist/sensors/shell.js +16 -0
  339. package/dist/sensors/shell.js.map +1 -0
  340. package/dist/sensors/structural.d.ts +3 -2
  341. package/dist/sensors/structural.js +3 -11
  342. package/dist/sensors/structural.js.map +1 -1
  343. package/dist/sensors/stub-catalog.d.ts +2 -1
  344. package/dist/sensors/stub-catalog.js +2 -9
  345. package/dist/sensors/stub-catalog.js.map +1 -1
  346. package/dist/sensors/types.d.ts +3 -4
  347. package/dist/sensors/types.js +1 -2
  348. package/dist/sensors/types.js.map +1 -1
  349. package/dist/session-start/build.js +1 -1
  350. package/dist/session-start/build.js.map +1 -1
  351. package/dist/status-line/event-queue.js +1 -1
  352. package/dist/status-line/index.d.ts +1 -1
  353. package/package.json +3 -2
  354. package/templates/.cairn/config/sensors.yaml +8 -8
  355. package/templates/attention-ui/app.js +61 -36
  356. package/dist/fs.d.ts +0 -5
  357. package/dist/fs.js +0 -11
  358. package/dist/fs.js.map +0 -1
  359. package/dist/ground/alignment-pending.d.ts +0 -28
  360. package/dist/ground/alignment-pending.js +0 -83
  361. package/dist/ground/alignment-pending.js.map +0 -1
  362. package/dist/ground/anchor-map.d.ts +0 -14
  363. package/dist/ground/anchor-map.js +0 -56
  364. package/dist/ground/anchor-map.js.map +0 -1
  365. package/dist/ground/drift.d.ts +0 -8
  366. package/dist/ground/drift.js +0 -23
  367. package/dist/ground/drift.js.map +0 -1
  368. package/dist/ground/file-candidates-map.d.ts +0 -23
  369. package/dist/ground/file-candidates-map.js +0 -76
  370. package/dist/ground/file-candidates-map.js.map +0 -1
  371. package/dist/ground/frontmatter.d.ts +0 -32
  372. package/dist/ground/frontmatter.js +0 -77
  373. package/dist/ground/frontmatter.js.map +0 -1
  374. package/dist/ground/glob.d.ts +0 -10
  375. package/dist/ground/glob.js +0 -46
  376. package/dist/ground/glob.js.map +0 -1
  377. package/dist/ground/index.d.ts +0 -25
  378. package/dist/ground/index.js +0 -19
  379. package/dist/ground/index.js.map +0 -1
  380. package/dist/ground/ledgers.d.ts +0 -14
  381. package/dist/ground/ledgers.js +0 -105
  382. package/dist/ground/ledgers.js.map +0 -1
  383. package/dist/ground/manifest.d.ts +0 -10
  384. package/dist/ground/manifest.js +0 -84
  385. package/dist/ground/manifest.js.map +0 -1
  386. package/dist/ground/paths.d.ts +0 -43
  387. package/dist/ground/paths.js +0 -109
  388. package/dist/ground/paths.js.map +0 -1
  389. package/dist/ground/quality-grades.d.ts +0 -11
  390. package/dist/ground/quality-grades.js +0 -100
  391. package/dist/ground/quality-grades.js.map +0 -1
  392. package/dist/ground/rejected.d.ts +0 -42
  393. package/dist/ground/rejected.js +0 -100
  394. package/dist/ground/rejected.js.map +0 -1
  395. package/dist/ground/schemas.d.ts +0 -582
  396. package/dist/ground/schemas.js +0 -372
  397. package/dist/ground/schemas.js.map +0 -1
  398. package/dist/ground/scope-index.d.ts +0 -96
  399. package/dist/ground/scope-index.js +0 -290
  400. package/dist/ground/scope-index.js.map +0 -1
  401. package/dist/ground/slug.d.ts +0 -60
  402. package/dist/ground/slug.js +0 -103
  403. package/dist/ground/slug.js.map +0 -1
  404. package/dist/ground/sot-bindings.d.ts +0 -14
  405. package/dist/ground/sot-bindings.js +0 -79
  406. package/dist/ground/sot-bindings.js.map +0 -1
  407. package/dist/ground/sot-cache.d.ts +0 -18
  408. package/dist/ground/sot-cache.js +0 -62
  409. package/dist/ground/sot-cache.js.map +0 -1
  410. package/dist/ground/topic-index.d.ts +0 -27
  411. package/dist/ground/topic-index.js +0 -82
  412. package/dist/ground/topic-index.js.map +0 -1
  413. package/dist/ground/walk.d.ts +0 -7
  414. package/dist/ground/walk.js +0 -53
  415. package/dist/ground/walk.js.map +0 -1
  416. package/dist/hooks/post-tool-use/ledger-cache.d.ts +0 -53
  417. package/dist/hooks/post-tool-use/ledger-cache.js +0 -338
  418. package/dist/hooks/post-tool-use/ledger-cache.js.map +0 -1
  419. package/dist/init/phases/10-strip.d.ts +0 -11
  420. package/dist/init/phases/10-strip.js.map +0 -1
  421. package/dist/init/phases/3b-seed.js.map +0 -1
  422. package/dist/init/phases/5-brand.js.map +0 -1
  423. package/dist/init/phases/5b-topic-index.js.map +0 -1
  424. package/dist/init/phases/6-docs-ingest.d.ts +0 -15
  425. package/dist/init/phases/6-docs-ingest.js.map +0 -1
  426. package/dist/init/phases/7b-source-comments.d.ts +0 -15
  427. package/dist/init/phases/7b-source-comments.js.map +0 -1
  428. package/dist/init/phases/7c-rules-merge.js.map +0 -1
  429. package/dist/init/phases/8-baseline.d.ts +0 -10
  430. package/dist/init/phases/8-baseline.js.map +0 -1
  431. package/dist/init/phases/parallel-678.js.map +0 -1
  432. package/dist/mcp/tools/decisions-in-scope.d.ts +0 -7
  433. package/dist/mcp/tools/decisions-in-scope.js +0 -66
  434. package/dist/mcp/tools/decisions-in-scope.js.map +0 -1
  435. package/dist/mcp/tools/invariants-in-scope.d.ts +0 -7
  436. package/dist/mcp/tools/invariants-in-scope.js +0 -81
  437. package/dist/mcp/tools/invariants-in-scope.js.map +0 -1
  438. package/dist/mcp/tools/propose-decision.d.ts +0 -34
  439. package/dist/mcp/tools/propose-decision.js +0 -200
  440. package/dist/mcp/tools/propose-decision.js.map +0 -1
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Combined PostToolUse hook for Write/Edit tools.
3
+ *
4
+ * Merges the Write Guardian (safety/scope hints) and Layer A alignment
5
+ * into a single runner. This saves ~300ms of Node/CLI boot overhead
6
+ * by running both logically sequential tasks in a single process.
7
+ */
8
+ import { z } from "zod";
9
+ import { resolveRepoRoot } from "../../session-start/index.js";
10
+ import { readHookStdin } from "../runners/payload.js";
11
+ import { executeSotAlign } from "./sot-align.js";
12
+ import { executeWriteGuardian } from "./write-guardian.js";
13
+ import { logger } from "../../logger.js";
14
+ const log = logger("hooks.post-tool-use.post-write");
15
+ const ClaudePostToolUsePayloadSchema = z.object({
16
+ session_id: z.string().optional(),
17
+ transcript_path: z.string().optional(),
18
+ cwd: z.string().optional(),
19
+ hook_event_name: z.string().optional(),
20
+ tool_name: z.string().optional(),
21
+ tool_input: z.object({
22
+ file_path: z.string().optional(),
23
+ new_string: z.string().optional(),
24
+ }).passthrough().optional(),
25
+ tool_response: z.object({
26
+ content: z.string().optional(),
27
+ text: z.string().optional(),
28
+ output: z.string().optional(),
29
+ }).passthrough().optional(),
30
+ }).passthrough();
31
+ function parsePayload(text) {
32
+ if (text.trim().length === 0)
33
+ return {};
34
+ try {
35
+ const raw = JSON.parse(text);
36
+ const result = ClaudePostToolUsePayloadSchema.safeParse(raw);
37
+ return result.success ? result.data : {};
38
+ }
39
+ catch {
40
+ return {};
41
+ }
42
+ }
43
+ function emitShapeB(additionalContext) {
44
+ const out = {
45
+ continue: true,
46
+ hookSpecificOutput: {
47
+ hookEventName: "PostToolUse",
48
+ additionalContext,
49
+ },
50
+ };
51
+ process.stdout.write(JSON.stringify(out));
52
+ process.stdout.write("\n");
53
+ }
54
+ function emitBlock(reason) {
55
+ const out = {
56
+ continue: false,
57
+ decision: "block",
58
+ reason,
59
+ };
60
+ process.stdout.write(JSON.stringify(out));
61
+ process.stdout.write("\n");
62
+ }
63
+ export async function runPostWriteHook() {
64
+ try {
65
+ const raw = await readHookStdin();
66
+ const payload = parsePayload(raw);
67
+ const tool = payload.tool_name;
68
+ if (tool !== "Write" && tool !== "Edit") {
69
+ emitShapeB("");
70
+ return;
71
+ }
72
+ const filePath = payload.tool_input?.file_path;
73
+ if (filePath === undefined || filePath.length === 0) {
74
+ emitShapeB("");
75
+ return;
76
+ }
77
+ const cwd = payload.cwd ?? process.cwd();
78
+ const repoRoot = resolveRepoRoot(cwd);
79
+ if (repoRoot === null) {
80
+ emitShapeB("");
81
+ return;
82
+ }
83
+ // 1. Run Guardian (can block)
84
+ // Needs content — extract from tool_response
85
+ const content = payload.tool_response?.content ?? payload.tool_response?.text ?? payload.tool_response?.output ?? "";
86
+ const guard = executeWriteGuardian({
87
+ repoRoot,
88
+ relPath: filePath,
89
+ content,
90
+ payload,
91
+ });
92
+ if (guard.kind === "block") {
93
+ emitBlock(guard.message ?? "blocked");
94
+ return;
95
+ }
96
+ // 2. Run SoT Align (hint only)
97
+ const alignSummary = await executeSotAlign(payload, repoRoot);
98
+ // 3. Merge and Emit
99
+ const sections = [];
100
+ if (guard.message)
101
+ sections.push(guard.message);
102
+ if (alignSummary.length > 0)
103
+ sections.push(alignSummary);
104
+ emitShapeB(sections.join("\n\n"));
105
+ }
106
+ catch (err) {
107
+ const message = err instanceof Error ? err.message : String(err);
108
+ log.warn({ err: message }, "Post-write hook failed; degrading to no-op");
109
+ emitShapeB("");
110
+ }
111
+ }
112
+ //# sourceMappingURL=post-write.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"post-write.js","sourceRoot":"","sources":["../../../src/hooks/post-tool-use/post-write.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,MAAM,GAAG,GAAG,MAAM,CAAC,gCAAgC,CAAC,CAAC;AAErD,MAAM,8BAA8B,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9C,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACjC,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACtC,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC1B,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACtC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC,UAAU,EAAE,CAAC,CAAC,MAAM,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,MAAM,IAAI,EAAE,CAAC;QACrH,MAAM,KAAK,GAAG,oBAAoB,CAAC;YACjC,QAAQ;YACR,OAAO,EAAE,QAAQ;YACjB,OAAO;YACP,OAAO;SACR,CAAC,CAAC;QACH,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC3B,SAAS,CAAC,KAAK,CAAC,OAAO,IAAI,SAAS,CAAC,CAAC;YACtC,OAAO;QACT,CAAC;QAED,+BAA+B;QAC/B,MAAM,YAAY,GAAG,MAAM,eAAe,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAE9D,oBAAoB;QACpB,MAAM,QAAQ,GAAa,EAAE,CAAC;QAC9B,IAAI,KAAK,CAAC,OAAO;YAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAChD,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC;YAAE,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAEzD,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACpC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjE,GAAG,CAAC,IAAI,CACN,EAAE,GAAG,EAAE,OAAO,EAAE,EAChB,4CAA4C,CAC7C,CAAC;QACF,UAAU,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;AACH,CAAC"}
@@ -3,11 +3,16 @@
3
3
  *
4
4
  * Scans the file content the agent just read for cairn citation
5
5
  * patterns (`§INV-NNNN`, `TODO(TSK-<id>)`, banned `DEC-<N>`) and prepends a
6
- * legend block via Claude Code's documented Shape-B `additionalContext`
7
- * field so the agent sees authoritative resolutions inline with the
8
- * file content. No MCP round-trip; all sources read directly from
9
- * `.cairn/` on disk.
6
+ * legend block to Shape-B `additionalContext`.
10
7
  *
11
- * Spec: docs/READ_ENRICHER_SPEC.md
8
+ * This hook is critical for "Honest Agent" context continuity — it
9
+ * ensures that if an agent reads a file carrying a bare cite, it
10
+ * immediately sees the definition and rationale for that cite without
11
+ * having to manually fetch the DEC/INV artifact.
12
+ *
13
+ * Spec: docs/READ_ENRICHER_SPEC.md.
14
+ */
15
+ /**
16
+ * Hook entry point.
12
17
  */
13
18
  export declare function runReadEnricher(): Promise<void>;
@@ -3,93 +3,49 @@
3
3
  *
4
4
  * Scans the file content the agent just read for cairn citation
5
5
  * patterns (`§INV-NNNN`, `TODO(TSK-<id>)`, banned `DEC-<N>`) and prepends a
6
- * legend block via Claude Code's documented Shape-B `additionalContext`
7
- * field so the agent sees authoritative resolutions inline with the
8
- * file content. No MCP round-trip; all sources read directly from
9
- * `.cairn/` on disk.
6
+ * legend block to Shape-B `additionalContext`.
10
7
  *
11
- * Spec: docs/READ_ENRICHER_SPEC.md
8
+ * This hook is critical for "Honest Agent" context continuity — it
9
+ * ensures that if an agent reads a file carrying a bare cite, it
10
+ * immediately sees the definition and rationale for that cite without
11
+ * having to manually fetch the DEC/INV artifact.
12
+ *
13
+ * Spec: docs/READ_ENRICHER_SPEC.md.
12
14
  */
13
- import { relative } from "node:path";
14
- import { readHookStdin } from "../runners/payload.js";
15
+ import { resolve, relative } from "node:path";
16
+ import { z } from "zod";
17
+ import { getDecisionsLedger, getInvariantsLedger, getScopeIndexEntry, lookupTask, } from "@isaacriehm/cairn-state";
18
+ import { readHookStdin, emitShapeB, appendTelemetry, } from "../runners/payload.js";
15
19
  import { resolveRepoRoot } from "../../session-start/index.js";
16
- import { appendTrace } from "../../trace/index.js";
17
20
  import { scanCitations } from "./citation-scanner.js";
18
- import { getDecisionsLedger, getFileCandidateCount, getInvariantsLedger, getScopeIndexEntry, lookupTask, } from "./ledger-cache.js";
19
21
  import { buildLegend } from "./legend-builder.js";
22
+ import { logger } from "../../logger.js";
20
23
  const MAX_CONTENT_BYTES = 512_000;
21
24
  const BINARY_SAMPLE_BYTES = 1024;
22
25
  const BINARY_THRESHOLD = 0.05;
23
- function parsePayload(text) {
24
- if (text.trim().length === 0)
25
- return {};
26
- try {
27
- const parsed = JSON.parse(text);
28
- return typeof parsed === "object" && parsed !== null ? parsed : {};
29
- }
30
- catch {
31
- return {};
32
- }
33
- }
34
- function pickContent(resp) {
35
- if (!resp || typeof resp !== "object")
36
- return undefined;
37
- // Claude Code's Read tool wraps the body as `tool_response.file.content`.
38
- // Check the nested file shape FIRST so it wins over any same-named key
39
- // at the top level.
40
- if (resp.file !== undefined && typeof resp.file === "object" && resp.file !== null) {
41
- const f = resp.file;
42
- if (typeof f.content === "string" && f.content.length > 0)
43
- return f.content;
44
- if (typeof f.text === "string" && f.text.length > 0)
45
- return f.text;
46
- }
47
- const candidates = ["content", "text", "output"];
48
- for (const k of candidates) {
49
- const v = resp[k];
50
- if (typeof v === "string" && v.length > 0)
51
- return v;
52
- }
53
- return undefined;
54
- }
55
- function isBinary(content) {
56
- const sampleLen = Math.min(content.length, BINARY_SAMPLE_BYTES);
57
- if (sampleLen === 0)
58
- return false;
59
- let suspicious = 0;
60
- for (let i = 0; i < sampleLen; i++) {
61
- const code = content.charCodeAt(i);
62
- if (code < 0x09 || (code >= 0x0e && code <= 0x1f))
63
- suspicious++;
64
- }
65
- return suspicious / sampleLen > BINARY_THRESHOLD;
66
- }
67
- function isExcludedPath(relPath) {
68
- if (relPath.startsWith(".archive/") || relPath === ".archive")
69
- return true;
70
- if (relPath.startsWith(".cairn/ground/") ||
71
- relPath === ".cairn/ground") {
72
- return true;
73
- }
74
- return false;
75
- }
76
- function computeRelPath(repoRoot, filePath) {
77
- const rel = relative(repoRoot, filePath);
78
- if (rel.startsWith("..") || rel.length === 0)
79
- return filePath;
80
- return rel.replace(/\\/g, "/");
81
- }
82
- function emitShapeB(additionalContext) {
83
- const out = {
84
- continue: true,
85
- hookSpecificOutput: {
86
- hookEventName: "PostToolUse",
87
- additionalContext,
88
- },
89
- };
90
- process.stdout.write(JSON.stringify(out));
91
- process.stdout.write("\n");
92
- }
26
+ const ClaudePostToolUsePayloadSchema = z.object({
27
+ session_id: z.string().optional(),
28
+ transcript_path: z.string().optional(),
29
+ cwd: z.string().optional(),
30
+ hook_event_name: z.string().optional(),
31
+ tool_name: z.string().optional(),
32
+ tool_input: z.object({
33
+ file_path: z.string().optional(),
34
+ }).optional(),
35
+ tool_response: z.object({
36
+ content: z.string().optional(),
37
+ text: z.string().optional(),
38
+ output: z.string().optional(),
39
+ file: z.object({
40
+ content: z.string().optional(),
41
+ text: z.string().optional(),
42
+ }).passthrough().optional(),
43
+ }).passthrough().optional(),
44
+ }).passthrough();
45
+ const log = logger("hooks.post-tool-use.read-enricher");
46
+ /**
47
+ * Hook entry point.
48
+ */
93
49
  export async function runReadEnricher() {
94
50
  const ts = new Date().toISOString();
95
51
  let outcome = { skip: "unknown" };
@@ -98,15 +54,13 @@ export async function runReadEnricher() {
98
54
  try {
99
55
  const raw = await readHookStdin();
100
56
  const payload = parsePayload(raw);
101
- sessionForTrace = typeof payload.session_id === "string" ? payload.session_id : null;
57
+ sessionForTrace = payload.session_id ?? null;
102
58
  if (payload.tool_name !== "Read") {
103
59
  outcome = { skip: "non-read-tool", tool_name: payload.tool_name };
104
- emitShapeB("");
60
+ emitShapeB("", "PostToolUse");
105
61
  return;
106
62
  }
107
- const filePath = typeof payload.tool_input?.file_path === "string"
108
- ? payload.tool_input.file_path
109
- : undefined;
63
+ const filePath = payload.tool_input?.file_path;
110
64
  const content = pickContent(payload.tool_response);
111
65
  if (filePath === undefined || content === undefined || content.length === 0) {
112
66
  outcome = {
@@ -115,96 +69,101 @@ export async function runReadEnricher() {
115
69
  content_present: content !== undefined,
116
70
  content_chars: content?.length ?? 0,
117
71
  };
118
- emitShapeB("");
119
- return;
120
- }
121
- if (content.length > MAX_CONTENT_BYTES) {
122
- outcome = { skip: "content-too-large", content_chars: content.length };
123
- emitShapeB("");
72
+ emitShapeB("", "PostToolUse");
124
73
  return;
125
74
  }
126
- const repoRoot = resolveRepoRoot(filePath);
75
+ const cwd = payload.cwd ?? process.cwd();
76
+ const repoRoot = resolveRepoRoot(cwd);
127
77
  repoRootForTrace = repoRoot;
128
78
  if (repoRoot === null) {
129
- outcome = { skip: "no-cairn-ancestor", file_path: filePath };
130
- emitShapeB("");
131
- return;
132
- }
133
- const relPath = computeRelPath(repoRoot, filePath);
134
- if (isExcludedPath(relPath)) {
135
- outcome = { skip: "excluded-path", rel_path: relPath };
136
- emitShapeB("");
79
+ outcome = { skip: "not-adopted", cwd };
80
+ emitShapeB("", "PostToolUse");
137
81
  return;
138
82
  }
83
+ const relPath = relative(repoRoot, resolve(cwd, filePath));
139
84
  if (isBinary(content)) {
140
- outcome = { skip: "binary-content", rel_path: relPath };
141
- emitShapeB("");
85
+ outcome = { skip: "binary", path: relPath };
86
+ emitShapeB("", "PostToolUse");
142
87
  return;
143
88
  }
144
- const matches = scanCitations(content);
145
- const invariantsLedger = getInvariantsLedger(repoRoot);
89
+ const citations = scanCitations(content);
90
+ const scopeEntry = getScopeIndexEntry(repoRoot, relPath);
146
91
  const decisionsLedger = getDecisionsLedger(repoRoot);
147
- const cachedEntry = getScopeIndexEntry(repoRoot, relPath);
148
- const scopeHint = cachedEntry !== null
149
- ? {
150
- decisions: cachedEntry.decisions,
151
- invariants: cachedEntry.invariants,
152
- }
153
- : null;
154
- const resolveTaskFn = (taskId) => lookupTask(repoRoot, taskId);
155
- // PR 2 / PHASE_6_REDESIGN §4.7 — O(1) lookup against the
156
- // file-candidates-map. Stays at 0 (silent) on un-adopted projects
157
- // and on files that aren't the SoT for any unpromoted candidate.
158
- const unpromotedCandidates = getFileCandidateCount(repoRoot, relPath);
159
- const legend = buildLegend(matches, invariantsLedger, decisionsLedger, scopeHint, resolveTaskFn, unpromotedCandidates);
160
- if (legend === null) {
161
- outcome = {
162
- skip: "no-citations-no-scope",
163
- rel_path: relPath,
164
- decisions_matched: matches.decisions.length,
165
- invariants_matched: matches.invariants.length,
166
- todos_matched: matches.todos.length,
167
- unpromoted_candidates: unpromotedCandidates,
168
- };
169
- emitShapeB("");
170
- return;
171
- }
92
+ const invariantsLedger = getInvariantsLedger(repoRoot);
93
+ const resolveTaskFn = (id) => lookupTask(repoRoot, id);
94
+ const legend = buildLegend(citations, invariantsLedger, decisionsLedger, scopeEntry, resolveTaskFn);
172
95
  outcome = {
173
- emitted: true,
174
- rel_path: relPath,
175
- legend_chars: legend.length,
176
- decisions_matched: matches.decisions.length,
177
- invariants_matched: matches.invariants.length,
178
- todos_matched: matches.todos.length,
179
- unpromoted_candidates: unpromotedCandidates,
96
+ ok: true,
97
+ path: relPath,
98
+ citations: {
99
+ invariants: citations.invariants.length,
100
+ decisions: citations.decisions.length,
101
+ todos: citations.todos.length,
102
+ },
103
+ legend_chars: legend?.length ?? 0,
180
104
  };
181
- emitShapeB(legend);
105
+ emitShapeB(legend ?? "", "PostToolUse");
182
106
  }
183
107
  catch (err) {
184
- outcome = { error: err instanceof Error ? err.message : String(err) };
185
- // Defer-fail gracefully the hook is a no-op enrichment, NOT a gate.
186
- try {
187
- emitShapeB("");
188
- }
189
- catch {
190
- // Last-resort: nothing we can do.
191
- }
108
+ const message = err instanceof Error ? err.message : String(err);
109
+ outcome = { error: message };
110
+ log.error({ err: message }, "read-enricher hook failed");
111
+ emitShapeB("", "PostToolUse");
192
112
  }
193
113
  finally {
194
- // Skip trace writes for non-cairn projects — keeps
195
- // ~/.local/cairn/trace/ quiet outside cairn-adopted repos so the
196
- // hook leaves no footprint when there's nothing to enrich.
197
- if (outcome["skip"] !== "no-cairn-ancestor") {
198
- appendTrace({
199
- ts,
200
- source: "hook",
114
+ if (repoRootForTrace !== null) {
115
+ appendTelemetry({
116
+ repoRoot: repoRootForTrace,
117
+ sessionId: sessionForTrace,
201
118
  kind: "read-enrich",
202
- repo_root: repoRootForTrace,
203
- session_id: sessionForTrace,
204
- ok: outcome["error"] === undefined,
205
- payload: outcome,
119
+ durationMs: Date.now() - Date.parse(ts),
120
+ source: "hook",
121
+ warnings: [],
122
+ extra: outcome,
206
123
  });
207
124
  }
208
125
  }
209
126
  }
127
+ function parsePayload(text) {
128
+ if (text.trim().length === 0)
129
+ return {};
130
+ try {
131
+ const raw = JSON.parse(text);
132
+ const result = ClaudePostToolUsePayloadSchema.safeParse(raw);
133
+ return result.success ? result.data : {};
134
+ }
135
+ catch {
136
+ return {};
137
+ }
138
+ }
139
+ function pickContent(resp) {
140
+ if (resp === undefined)
141
+ return undefined;
142
+ // Claude Code's Read tool wraps the body as `tool_response.file.content`.
143
+ // Check the nested file shape FIRST so it wins over any same-named key
144
+ // at the top level.
145
+ if (resp.file !== undefined) {
146
+ const f = resp.file;
147
+ if (typeof f.content === "string" && f.content.length > 0)
148
+ return f.content;
149
+ if (typeof f.text === "string" && f.text.length > 0)
150
+ return f.text;
151
+ }
152
+ if (typeof resp.content === "string" && resp.content.length > 0)
153
+ return resp.content;
154
+ if (typeof resp.text === "string" && resp.text.length > 0)
155
+ return resp.text;
156
+ if (typeof resp.output === "string" && resp.output.length > 0)
157
+ return resp.output;
158
+ return undefined;
159
+ }
160
+ function isBinary(content) {
161
+ const sampleLen = Math.min(content.length, BINARY_SAMPLE_BYTES);
162
+ let nullCount = 0;
163
+ for (let i = 0; i < sampleLen; i++) {
164
+ if (content.charCodeAt(i) === 0)
165
+ nullCount++;
166
+ }
167
+ return nullCount / sampleLen > BINARY_THRESHOLD;
168
+ }
210
169
  //# sourceMappingURL=read-enricher.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"read-enricher.js","sourceRoot":"","sources":["../../../src/hooks/post-tool-use/read-enricher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE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CAAC,OAAO,KAAK,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC,OAAO,CAAC;IACrF,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC,IAAI,CAAC;IAC5E,IAAI,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC,MAAM,CAAC;IAElF,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,QAAQ,CAAC,OAAe;IAC/B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IAChE,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC;QACnC,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC;YAAE,SAAS,EAAE,CAAC;IAC/C,CAAC;IACD,OAAO,SAAS,GAAG,SAAS,GAAG,gBAAgB,CAAC;AAClD,CAAC"}
@@ -46,6 +46,17 @@
46
46
  * (`.md`/`.mdx`) skipped entirely — operator-curated narrative is
47
47
  * handled by phase 5b's topic-index + the doc-drift sensor.
48
48
  */
49
+ import { z } from "zod";
50
+ declare const ClaudePostToolUsePayloadSchema: z.ZodObject<{
51
+ session_id: z.ZodOptional<z.ZodString>;
52
+ cwd: z.ZodOptional<z.ZodString>;
53
+ hook_event_name: z.ZodOptional<z.ZodString>;
54
+ tool_name: z.ZodOptional<z.ZodString>;
55
+ tool_input: z.ZodOptional<z.ZodObject<{
56
+ file_path: z.ZodOptional<z.ZodString>;
57
+ }, z.core.$strip>>;
58
+ }, z.core.$loose>;
59
+ type ClaudePostToolUsePayload = z.infer<typeof ClaudePostToolUsePayloadSchema>;
49
60
  export interface AlignFileArgs {
50
61
  repoRoot: string;
51
62
  /** Repo-relative POSIX path written by Claude Code. */
@@ -163,4 +174,5 @@ export interface AlignFileResult {
163
174
  */
164
175
  export declare function alignFile(args: AlignFileArgs): Promise<AlignFileResult>;
165
176
  export declare function runSotAlign(): Promise<void>;
177
+ export declare function executeSotAlign(payload: ClaudePostToolUsePayload, repoRoot: string): Promise<string>;
166
178
  export {};