@rt-tools/agent-kit 0.37.0 → 0.38.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 (436) hide show
  1. package/README.md +5 -5
  2. package/assets/checks/action-of.mjs +154 -0
  3. package/assets/checks/board-pull-state.github.mjs +82 -13
  4. package/assets/checks/board-runs.github.mjs +40 -5
  5. package/assets/checks/board.github.mjs +1 -1
  6. package/assets/checks/check-board.github.mjs +58 -19
  7. package/assets/checks/check-specs.mjs +2 -2
  8. package/assets/checks/check-state-next.mjs +22 -10
  9. package/assets/checks/check-turn-map.mjs +26 -6
  10. package/assets/checks/check-work-steps.mjs +4 -173
  11. package/assets/checks/decide.mjs +285 -0
  12. package/assets/checks/decision-table.json +21365 -0
  13. package/assets/checks/decision-table.mjs +495 -0
  14. package/assets/checks/epic-table.github.mjs +4 -3
  15. package/assets/checks/epic-window.mjs +98 -0
  16. package/assets/checks/flow-condition.mjs +64 -0
  17. package/assets/checks/flow-data.mjs +136 -0
  18. package/assets/checks/flow-forecast.mjs +330 -0
  19. package/assets/checks/flow-guard-run.mjs +90 -0
  20. package/assets/checks/flow-guard.mjs +294 -0
  21. package/assets/checks/flow-model.mjs +271 -0
  22. package/assets/checks/flow-override.mjs +130 -0
  23. package/assets/checks/flow-plan.mjs +206 -0
  24. package/assets/checks/flow-scaffold.mjs +224 -0
  25. package/assets/checks/flow-step.mjs +365 -0
  26. package/assets/checks/flow-sync.mjs +296 -0
  27. package/assets/checks/flow-syntax.mjs +292 -0
  28. package/assets/checks/flow-verdict.mjs +112 -0
  29. package/assets/checks/lib-common.mjs +10 -2
  30. package/assets/checks/lib-domains.mjs +1 -1
  31. package/assets/checks/lib-manifests.mjs +34 -2
  32. package/assets/checks/merge-read.mjs +239 -0
  33. package/assets/checks/owner-nudges.mjs +389 -0
  34. package/assets/checks/push-inputs.mjs +444 -0
  35. package/assets/checks/push-trace.mjs +108 -0
  36. package/assets/checks/record-count.mjs +410 -0
  37. package/assets/checks/record-recount.mjs +187 -0
  38. package/assets/checks/record-turn.mjs +155 -0
  39. package/assets/checks/rt-kit-checks.config.mjs +17 -2
  40. package/assets/checks/spec-anchors.mjs +4 -4
  41. package/assets/checks/spec-contract.mjs +5 -5
  42. package/assets/checks/task-flow-script.mjs +292 -0
  43. package/assets/checks/tree-assignment.mjs +26 -7
  44. package/assets/checks/work-result.mjs +281 -0
  45. package/assets/checks/work-steps-lib.mjs +205 -0
  46. package/assets/commands/next-session.md +3 -1
  47. package/assets/commands/night.md +28 -18
  48. package/assets/defaults/gate-map.sh +39 -12
  49. package/assets/defaults/merges.sh +48 -0
  50. package/assets/defaults/project.sh +43 -13
  51. package/assets/defaults/push.sh +23 -0
  52. package/assets/defaults/turn-map.md +24 -21
  53. package/assets/docs/GLOSSARY.md +6 -2
  54. package/assets/hooks/ask-judge.md +65 -0
  55. package/assets/hooks/browser-guard-device-id.sh +11 -9
  56. package/assets/hooks/browser-guard-no-asking.sh +12 -6
  57. package/assets/hooks/browser-guard-no-listing.sh +13 -7
  58. package/assets/hooks/browser-guard-no-other-drivers.sh +25 -17
  59. package/assets/hooks/browser-guard-require-select.sh +15 -15
  60. package/assets/hooks/commit-msg.sh +13 -3
  61. package/assets/hooks/conscience-guard.sh +9 -25
  62. package/assets/hooks/decide.sh +141 -0
  63. package/assets/hooks/deny-tail.sh +16 -11
  64. package/assets/hooks/dev-server-guard.sh +27 -20
  65. package/assets/hooks/dispatch.sh +47 -4
  66. package/assets/hooks/docs-guard.sh +31 -200
  67. package/assets/hooks/end-conversation-guard.sh +12 -21
  68. package/assets/hooks/epic-stop-guard.sh +54 -105
  69. package/assets/hooks/exam-guard.sh +32 -65
  70. package/assets/hooks/facts-docs.sh +221 -0
  71. package/assets/hooks/facts-flow.sh +173 -0
  72. package/assets/hooks/facts.sh +308 -0
  73. package/assets/hooks/flow-step-guard.sh +93 -0
  74. package/assets/hooks/git-guard-delivery-body.sh +4 -4
  75. package/assets/hooks/git-guard-delivery-conflict.sh +16 -10
  76. package/assets/hooks/git-guard-delivery-draft.sh +3 -3
  77. package/assets/hooks/git-guard-delivery-epic.sh +18 -9
  78. package/assets/hooks/git-guard-delivery-folder.sh +32 -7
  79. package/assets/hooks/git-guard-delivery-merge.sh +2 -2
  80. package/assets/hooks/git-guard-delivery-merged.sh +12 -1
  81. package/assets/hooks/git-guard-delivery-pipeline.sh +1 -1
  82. package/assets/hooks/git-guard-delivery-rerun.sh +32 -0
  83. package/assets/hooks/git-guard-delivery-signature.sh +82 -45
  84. package/assets/hooks/git-guard-delivery-task.sh +47 -0
  85. package/assets/hooks/git-guard-delivery.sh +112 -101
  86. package/assets/hooks/git-guard-discard.sh +8 -18
  87. package/assets/hooks/git-guard-main.sh +13 -19
  88. package/assets/hooks/git-guard-no-verify.sh +56 -16
  89. package/assets/hooks/git-guard-push-ahead.sh +46 -5
  90. package/assets/hooks/git-guard-push-marks.sh +227 -31
  91. package/assets/hooks/git-guard-push-tests.sh +51 -53
  92. package/assets/hooks/git-guard-tree-assignment.sh +7 -4
  93. package/assets/hooks/guard-note.sh +8 -6
  94. package/assets/hooks/handoff-entry-guard.sh +20 -39
  95. package/assets/hooks/handoff-write.sh +3 -1
  96. package/assets/hooks/hook-input.sh +0 -41
  97. package/assets/hooks/metric-marks.sh +19 -7
  98. package/assets/hooks/observe.sh +1 -1
  99. package/assets/hooks/override-write-guard.sh +27 -9
  100. package/assets/hooks/pre-push.sh +20 -10
  101. package/assets/hooks/prose-style-guard.sh +6 -19
  102. package/assets/hooks/pull-merges.sh +76 -0
  103. package/assets/hooks/push-set.sh +39 -7
  104. package/assets/hooks/qa-dataid-guard.sh +7 -17
  105. package/assets/hooks/record-turn.sh +52 -0
  106. package/assets/hooks/rerun-guard.sh +11 -16
  107. package/assets/hooks/reuse-first-guard.sh +7 -21
  108. package/assets/hooks/role-calls.sh +25 -3
  109. package/assets/hooks/rule-source-guard.sh +54 -21
  110. package/assets/hooks/skill-gate-rearm.sh +18 -5
  111. package/assets/hooks/skill-gate.sh +156 -20
  112. package/assets/hooks/skill-loaded.sh +18 -3
  113. package/assets/hooks/sql-guard-target.sh +2 -2
  114. package/assets/hooks/sql-guard-write.sh +12 -12
  115. package/assets/hooks/sql-guard.sh +58 -16
  116. package/assets/hooks/task-context-load.sh +3 -1
  117. package/assets/hooks/task-flow-context.sh +20 -22
  118. package/assets/hooks/task-flow-draft-guard.sh +25 -74
  119. package/assets/hooks/task-flow-guard.sh +28 -129
  120. package/assets/hooks/tree-assignment-guard.sh +25 -14
  121. package/assets/hooks/turn-entry-load.sh +3 -1
  122. package/assets/hooks/turn-exit-guard.sh +92 -452
  123. package/assets/hooks/turn-exit-role.sh +47 -0
  124. package/assets/hooks/turn-judge.md +103 -0
  125. package/assets/hooks/window-fill-guard.sh +22 -41
  126. package/assets/laws/work-conduct.md +9 -8
  127. package/assets/patterns/autonomous-work-run.md +35 -10
  128. package/assets/patterns/browser-verification-measure.md +10 -20
  129. package/assets/patterns/browser-verification-stand.md +30 -42
  130. package/assets/patterns/doc-style-human.md +0 -6
  131. package/assets/patterns/doc-style-sweep.md +7 -7
  132. package/assets/patterns/doc-style-trace.md +5 -4
  133. package/assets/patterns/doc-style-write.md +7 -7
  134. package/assets/patterns/epic-flow-declare.md +15 -8
  135. package/assets/patterns/git-workflow-commit.azure.md +9 -155
  136. package/assets/patterns/git-workflow-commit.github.md +11 -269
  137. package/assets/patterns/git-workflow-commit.gitlab.md +9 -161
  138. package/assets/patterns/git-workflow-docker.md +8 -231
  139. package/assets/patterns/git-workflow-freshness.md +9 -56
  140. package/assets/patterns/git-workflow-merge.md +7 -174
  141. package/assets/patterns/git-workflow-migration.md +5 -73
  142. package/assets/patterns/git-workflow-pr-body.github.md +6 -159
  143. package/assets/patterns/git-workflow-pr-ready.md +9 -69
  144. package/assets/patterns/git-workflow-pr.azure.md +14 -220
  145. package/assets/patterns/git-workflow-pr.github.md +13 -253
  146. package/assets/patterns/git-workflow-pr.gitlab.md +14 -241
  147. package/assets/patterns/git-workflow-restart.md +5 -41
  148. package/assets/patterns/git-workflow-secrets.md +10 -76
  149. package/assets/patterns/git-workflow-stack.md +9 -205
  150. package/assets/patterns/lib-layers-new.md +7 -3
  151. package/assets/patterns/queue-audit-read.github.md +9 -3
  152. package/assets/patterns/spec-driven-domain.md +50 -48
  153. package/assets/patterns/spec-driven-rule.md +18 -19
  154. package/assets/patterns/status-report-table.github.md +2 -2
  155. package/assets/patterns/task-flow-archive.md +15 -256
  156. package/assets/patterns/task-flow-close.md +16 -291
  157. package/assets/patterns/task-flow-cycle.md +13 -39
  158. package/assets/patterns/task-flow-graph.needs-graph.md +8 -58
  159. package/assets/patterns/task-flow-handoff.md +13 -161
  160. package/assets/patterns/task-flow-resume.md +19 -183
  161. package/assets/patterns/task-flow-start.md +9 -248
  162. package/assets/patterns/testing-e2e.md +14 -18
  163. package/assets/patterns/testing-unit.md +9 -13
  164. package/assets/patterns/turn-entry-map.md +15 -5
  165. package/assets/pitfalls/agent-kit-extend.md +200 -0
  166. package/assets/pitfalls/agent-kit.2.md +323 -0
  167. package/assets/pitfalls/angular-patterns.md +98 -0
  168. package/assets/pitfalls/autonomous-work.md +15 -0
  169. package/assets/pitfalls/browser-verification.md +265 -0
  170. package/assets/pitfalls/component-structure.md +98 -0
  171. package/assets/pitfalls/dependencies.md +92 -0
  172. package/assets/pitfalls/deploy-flow.azure.md +171 -0
  173. package/assets/pitfalls/deploy-flow.github.md +211 -0
  174. package/assets/pitfalls/deploy-flow.gitlab.md +173 -0
  175. package/assets/pitfalls/doc-style.2.md +286 -0
  176. package/assets/pitfalls/doc-style.md +3 -3
  177. package/assets/pitfalls/entity-conventions.needs-admin.md +96 -0
  178. package/assets/pitfalls/entity-models.md +89 -0
  179. package/assets/pitfalls/git-workflow-commit.azure.md +190 -0
  180. package/assets/pitfalls/git-workflow-commit.github.md +307 -0
  181. package/assets/pitfalls/git-workflow-commit.gitlab.md +196 -0
  182. package/assets/pitfalls/git-workflow-docker.md +275 -0
  183. package/assets/pitfalls/git-workflow-freshness.md +88 -0
  184. package/assets/pitfalls/git-workflow-hosting.azure.md +31 -0
  185. package/assets/pitfalls/git-workflow-hosting.github.md +32 -0
  186. package/assets/pitfalls/git-workflow-hosting.gitlab.md +31 -0
  187. package/assets/pitfalls/git-workflow-merge.md +220 -0
  188. package/assets/pitfalls/git-workflow-migration.md +103 -0
  189. package/assets/pitfalls/git-workflow-pr-body.github.md +185 -0
  190. package/assets/pitfalls/git-workflow-pr-ready.md +104 -0
  191. package/assets/pitfalls/git-workflow-pr.2.azure.md +172 -0
  192. package/assets/pitfalls/git-workflow-pr.2.github.md +184 -0
  193. package/assets/pitfalls/git-workflow-pr.2.gitlab.md +180 -0
  194. package/assets/pitfalls/git-workflow-pr.azure.md +159 -0
  195. package/assets/pitfalls/git-workflow-pr.github.md +107 -0
  196. package/assets/pitfalls/git-workflow-pr.gitlab.md +151 -0
  197. package/assets/pitfalls/git-workflow-push.azure.md +30 -0
  198. package/assets/pitfalls/git-workflow-push.github.md +30 -0
  199. package/assets/pitfalls/git-workflow-push.gitlab.md +30 -0
  200. package/assets/pitfalls/git-workflow-queue.azure.md +30 -0
  201. package/assets/pitfalls/git-workflow-queue.github.md +30 -0
  202. package/assets/pitfalls/git-workflow-queue.gitlab.md +30 -0
  203. package/assets/pitfalls/git-workflow-restart.md +72 -0
  204. package/assets/pitfalls/git-workflow-secrets.md +114 -0
  205. package/assets/pitfalls/git-workflow-stack.md +254 -0
  206. package/assets/pitfalls/git-workflow.2.azure.md +291 -0
  207. package/assets/pitfalls/git-workflow.2.github.md +294 -0
  208. package/assets/pitfalls/git-workflow.2.gitlab.md +278 -0
  209. package/assets/pitfalls/git-workflow.github.md +5 -9
  210. package/assets/pitfalls/lib-layers.md +114 -0
  211. package/assets/pitfalls/lists.md +117 -0
  212. package/assets/pitfalls/navigation.md +94 -0
  213. package/assets/pitfalls/reuse-first.md +201 -0
  214. package/assets/pitfalls/spec-driven.2.md +318 -0
  215. package/assets/pitfalls/spec-driven.md +9 -7
  216. package/assets/pitfalls/styling-bem.2.md +125 -0
  217. package/assets/pitfalls/task-flow-archive.md +264 -0
  218. package/assets/pitfalls/task-flow-close.2.md +165 -0
  219. package/assets/pitfalls/task-flow-close.md +167 -0
  220. package/assets/pitfalls/task-flow-cycle.md +73 -0
  221. package/assets/pitfalls/task-flow-graph.needs-graph.md +98 -0
  222. package/assets/pitfalls/task-flow-handoff.md +200 -0
  223. package/assets/pitfalls/task-flow-handover.md +30 -0
  224. package/assets/pitfalls/task-flow-owner.md +29 -0
  225. package/assets/pitfalls/task-flow-plan.md +29 -0
  226. package/assets/pitfalls/task-flow-resume.md +257 -0
  227. package/assets/pitfalls/task-flow-start.md +287 -0
  228. package/assets/pitfalls/task-flow.2.md +303 -0
  229. package/assets/pitfalls/task-flow.md +18 -29
  230. package/assets/pitfalls/testing.2.md +279 -0
  231. package/assets/pitfalls/testing.md +11 -12
  232. package/assets/pitfalls/turn-conduct.md +17 -18
  233. package/assets/pitfalls/typescript-conventions.md +161 -0
  234. package/assets/pitfalls/write-a-skill.md +128 -0
  235. package/assets/rules/angular-patterns.md +21 -86
  236. package/assets/rules/autonomous-work.md +37 -29
  237. package/assets/rules/browser-verification.md +28 -251
  238. package/assets/rules/component-structure.md +25 -87
  239. package/assets/rules/dependencies.md +20 -78
  240. package/assets/rules/deploy-flow.azure.md +27 -134
  241. package/assets/rules/deploy-flow.github.md +34 -196
  242. package/assets/rules/deploy-flow.gitlab.md +28 -137
  243. package/assets/rules/doc-style.md +32 -282
  244. package/assets/rules/entity-conventions.needs-admin.md +26 -82
  245. package/assets/rules/entity-models.md +14 -63
  246. package/assets/rules/epic-flow.md +5 -3
  247. package/assets/rules/git-workflow-hosting.azure.md +26 -0
  248. package/assets/rules/git-workflow-hosting.github.md +38 -0
  249. package/assets/rules/git-workflow-hosting.gitlab.md +27 -0
  250. package/assets/rules/git-workflow-push.azure.md +28 -0
  251. package/assets/rules/git-workflow-push.github.md +28 -0
  252. package/assets/rules/git-workflow-push.gitlab.md +28 -0
  253. package/assets/rules/git-workflow-queue.azure.md +23 -0
  254. package/assets/rules/git-workflow-queue.github.md +30 -0
  255. package/assets/rules/git-workflow-queue.gitlab.md +23 -0
  256. package/assets/rules/git-workflow.azure.md +21 -264
  257. package/assets/rules/git-workflow.github.md +24 -285
  258. package/assets/rules/git-workflow.gitlab.md +21 -258
  259. package/assets/rules/lib-layers.md +30 -103
  260. package/assets/rules/lists.md +21 -105
  261. package/assets/rules/navigation.md +10 -69
  262. package/assets/rules/queue-audit.github.md +5 -3
  263. package/assets/rules/reuse-first.md +20 -195
  264. package/assets/rules/spec-driven.md +35 -316
  265. package/assets/rules/status-report.md +5 -3
  266. package/assets/rules/styling-bem.md +20 -117
  267. package/assets/rules/task-flow-handover.md +24 -0
  268. package/assets/rules/task-flow-owner.md +34 -0
  269. package/assets/rules/task-flow-plan.md +38 -0
  270. package/assets/rules/task-flow.md +22 -289
  271. package/assets/rules/testing.md +32 -270
  272. package/assets/rules/turn-conduct.md +109 -111
  273. package/assets/rules/turn-entry.md +2 -2
  274. package/assets/rules/typescript-conventions.md +41 -147
  275. package/assets/samples/tasks/_template/plan.md +30 -6
  276. package/assets/samples/tasks/_template/progress.md +0 -1
  277. package/assets/skills/agent-kit-extend.md +25 -168
  278. package/assets/skills/agent-kit.md +27 -299
  279. package/assets/skills/write-a-skill.md +20 -106
  280. package/assets/task-flow/flow.js +188 -0
  281. package/assets/task-flow/flow.md +102 -0
  282. package/assets/task-flow/measure/agreement.mjs +24 -0
  283. package/assets/task-flow/measure/copy.mjs +22 -0
  284. package/assets/task-flow/measure/epic-of.mjs +50 -0
  285. package/assets/task-flow/measure/epic-text.mjs +35 -0
  286. package/assets/task-flow/measure/epic.mjs +114 -0
  287. package/assets/task-flow/measure/folder.mjs +16 -0
  288. package/assets/task-flow/measure/footprint.mjs +28 -0
  289. package/assets/task-flow/measure/grill.mjs +21 -0
  290. package/assets/task-flow/measure/host.mjs +8 -0
  291. package/assets/task-flow/measure/owner.mjs +20 -0
  292. package/assets/task-flow/measure/plan.mjs +27 -0
  293. package/assets/task-flow/measure/pr.mjs +20 -0
  294. package/assets/task-flow/measure/progress.mjs +50 -0
  295. package/assets/task-flow/measure/session.mjs +175 -0
  296. package/assets/task-flow/measure/task.mjs +23 -0
  297. package/assets/task-flow/measure/text.mjs +77 -0
  298. package/assets/task-flow/source/git.mjs +86 -0
  299. package/assets/task-flow/source/host.mjs +172 -0
  300. package/assets/task-flow/source/marks.mjs +56 -0
  301. package/assets/task-flow/source/owner.mjs +74 -0
  302. package/assets/task-flow/source/records.mjs +116 -0
  303. package/assets/task-flow/source/session.mjs +232 -0
  304. package/assets/task-flow/source/steps.mjs +28 -0
  305. package/assets/task-flow/source/tree.mjs +42 -0
  306. package/assets/templates/rule.md +2 -2
  307. package/bin/agent-kit.d.ts.map +1 -1
  308. package/bin/agent-kit.js +30 -0
  309. package/bin/agent-kit.js.map +1 -1
  310. package/lib/agent-checks.d.ts +55 -0
  311. package/lib/agent-checks.d.ts.map +1 -0
  312. package/lib/agent-checks.js +209 -0
  313. package/lib/agent-checks.js.map +1 -0
  314. package/lib/assets.d.ts.map +1 -1
  315. package/lib/assets.js +7 -2
  316. package/lib/assets.js.map +1 -1
  317. package/lib/cargo-prose.d.ts +2 -1
  318. package/lib/cargo-prose.d.ts.map +1 -1
  319. package/lib/cargo-prose.js.map +1 -1
  320. package/lib/cargo.d.ts +29 -0
  321. package/lib/cargo.d.ts.map +1 -1
  322. package/lib/cargo.js +27 -1
  323. package/lib/cargo.js.map +1 -1
  324. package/lib/cascade.d.ts.map +1 -1
  325. package/lib/cascade.js +3 -1
  326. package/lib/cascade.js.map +1 -1
  327. package/lib/commands.d.ts.map +1 -1
  328. package/lib/commands.js +78 -2
  329. package/lib/commands.js.map +1 -1
  330. package/lib/companion.d.ts +0 -5
  331. package/lib/companion.d.ts.map +1 -1
  332. package/lib/companion.js +1 -1
  333. package/lib/companion.js.map +1 -1
  334. package/lib/config.d.ts +18 -0
  335. package/lib/config.d.ts.map +1 -1
  336. package/lib/config.js +18 -1
  337. package/lib/config.js.map +1 -1
  338. package/lib/cost.d.ts +0 -8
  339. package/lib/cost.d.ts.map +1 -1
  340. package/lib/cost.js +4 -4
  341. package/lib/cost.js.map +1 -1
  342. package/lib/epic-window-send.d.ts +74 -0
  343. package/lib/epic-window-send.d.ts.map +1 -0
  344. package/lib/epic-window-send.js +166 -0
  345. package/lib/epic-window-send.js.map +1 -0
  346. package/lib/hooks-map.d.ts +4 -12
  347. package/lib/hooks-map.d.ts.map +1 -1
  348. package/lib/hooks-map.js +4 -27
  349. package/lib/hooks-map.js.map +1 -1
  350. package/lib/integrity.d.ts +3 -0
  351. package/lib/integrity.d.ts.map +1 -1
  352. package/lib/integrity.js +7 -0
  353. package/lib/integrity.js.map +1 -1
  354. package/lib/metric-lines.d.ts +2 -1
  355. package/lib/metric-lines.d.ts.map +1 -1
  356. package/lib/metric-lines.js +49 -1
  357. package/lib/metric-lines.js.map +1 -1
  358. package/lib/metric-send-mark.d.ts +6 -3
  359. package/lib/metric-send-mark.d.ts.map +1 -1
  360. package/lib/metric-send-mark.js +15 -5
  361. package/lib/metric-send-mark.js.map +1 -1
  362. package/lib/metric-send.d.ts +6 -2
  363. package/lib/metric-send.d.ts.map +1 -1
  364. package/lib/metric-send.js +47 -13
  365. package/lib/metric-send.js.map +1 -1
  366. package/lib/metrics.d.ts +17 -0
  367. package/lib/metrics.d.ts.map +1 -1
  368. package/lib/metrics.js +26 -15
  369. package/lib/metrics.js.map +1 -1
  370. package/lib/observations-cargo.d.ts +1 -5
  371. package/lib/observations-cargo.d.ts.map +1 -1
  372. package/lib/observations-cargo.js +2 -2
  373. package/lib/observations-cargo.js.map +1 -1
  374. package/lib/observations.d.ts +0 -2
  375. package/lib/observations.d.ts.map +1 -1
  376. package/lib/observations.js +3 -3
  377. package/lib/observations.js.map +1 -1
  378. package/lib/order.d.ts +0 -2
  379. package/lib/order.d.ts.map +1 -1
  380. package/lib/order.js +0 -4
  381. package/lib/order.js.map +1 -1
  382. package/lib/outcomes.d.ts +7 -9
  383. package/lib/outcomes.d.ts.map +1 -1
  384. package/lib/outcomes.js +8 -7
  385. package/lib/outcomes.js.map +1 -1
  386. package/lib/proposals.d.ts +0 -1
  387. package/lib/proposals.d.ts.map +1 -1
  388. package/lib/proposals.js +1 -1
  389. package/lib/proposals.js.map +1 -1
  390. package/lib/push-gate.d.ts +13 -0
  391. package/lib/push-gate.d.ts.map +1 -1
  392. package/lib/push-gate.js +11 -7
  393. package/lib/push-gate.js.map +1 -1
  394. package/lib/push-set-usefulness.d.ts +78 -0
  395. package/lib/push-set-usefulness.d.ts.map +1 -0
  396. package/lib/push-set-usefulness.js +225 -0
  397. package/lib/push-set-usefulness.js.map +1 -0
  398. package/lib/shipment.d.ts +2 -11
  399. package/lib/shipment.d.ts.map +1 -1
  400. package/lib/shipment.fixture.d.ts +0 -3
  401. package/lib/shipment.fixture.d.ts.map +1 -1
  402. package/lib/shipment.fixture.js +3 -3
  403. package/lib/shipment.fixture.js.map +1 -1
  404. package/lib/shipment.js +2 -2
  405. package/lib/shipment.js.map +1 -1
  406. package/lib/sync.d.ts +10 -0
  407. package/lib/sync.d.ts.map +1 -1
  408. package/lib/sync.js +14 -1
  409. package/lib/sync.js.map +1 -1
  410. package/lib/traits.d.ts +0 -3
  411. package/lib/traits.d.ts.map +1 -1
  412. package/lib/traits.js +2 -2
  413. package/lib/traits.js.map +1 -1
  414. package/lib/variants.d.ts +0 -1
  415. package/lib/variants.d.ts.map +1 -1
  416. package/lib/variants.js +1 -1
  417. package/lib/variants.js.map +1 -1
  418. package/lib/work-result.d.ts +43 -0
  419. package/lib/work-result.d.ts.map +1 -0
  420. package/lib/work-result.js +39 -0
  421. package/lib/work-result.js.map +1 -0
  422. package/package.json +1 -1
  423. package/assets/checks/signals/ui-kit.json +0 -11
  424. package/assets/hooks/claim-guard.sh +0 -212
  425. package/assets/hooks/grill-gate-ask.sh +0 -26
  426. package/assets/hooks/grill-gate-bypass.sh +0 -61
  427. package/assets/hooks/grill-gate-options.sh +0 -50
  428. package/assets/hooks/grill-gate.sh +0 -482
  429. package/assets/hooks/postmortem-guard.sh +0 -124
  430. package/assets/hooks/proposal-guard.sh +0 -154
  431. package/assets/hooks/stand-login-guard.sh +0 -107
  432. package/assets/hooks/turn-exit-epic.sh +0 -173
  433. package/assets/hooks/turn-exit-patterns.sh +0 -123
  434. package/assets/hooks/turn-exit-verdict.sh +0 -149
  435. package/assets/hooks/waiting-turn-guard.sh +0 -320
  436. package/assets/hooks/work-start-guard.sh +0 -175
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
  # rt-hook: PreToolUse Edit|Write|MultiEdit|NotebookEdit|Bash|mcp__webstorm__create_new_file|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_tool
3
- # Requires: hooks/profile-check.sh, hooks/deny-tail.sh, hooks/guard-note.sh
3
+ # Requires: checks/decide.mjs, hooks/decide.sh, hooks/facts.sh, hooks/facts-docs.sh, hooks/profile-check.sh, hooks/deny-tail.sh, hooks/guard-note.sh
4
4
  # Guard of the pair "an edit and its document". PreToolUse.
5
5
  #
6
6
  # A divergence of the code from the text is soundless. Neither the linter, nor the build, nor the
@@ -42,22 +42,27 @@ command -v jq >/dev/null 2>&1 || exit 0
42
42
 
43
43
  tool="$(rt_hook_tool)"
44
44
 
45
+ # The decision, the move and the text come from the decision table. Parameters: the action, the facts
46
+ # of this guard, the params of the text. A refusal names the edit of the first awaited document, and
47
+ # the facts of the neighbours are those they judge that edit by: the decider puts first what they want.
45
48
  decide() {
46
- reason="$2"
47
- if [ "$1" = "deny" ]; then
48
- # shellcheck disable=SC1090
49
- [ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
50
- && . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
51
- if command -v rt_deny_tail >/dev/null 2>&1; then
52
- reason="$2
53
-
54
- $(rt_deny_tail "the line \`Docs-skip: <reason>\` in the commit body; an empty reason is not accepted")"
55
- fi
56
- fi
57
-
58
- jq -n --arg d "$1" --arg r "$reason" \
59
- '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:$d,permissionDecisionReason:$r}}' 2>/dev/null \
60
- || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"The document goes by the same commit."}}\n'
49
+ # shellcheck disable=SC1091
50
+ . "$rt_hooks_dir/facts.sh" 2>/dev/null
51
+ dg_sid="$(printf '%s' "$input" | jq -r '.session_id // "nosession"' 2>/dev/null)"
52
+ dg_record="$(rt_fact_transcript "$input")"
53
+ dg_doc="${first_doc:-README.md}"
54
+ case "$dg_doc" in /*) ;; *) dg_doc="$(git rev-parse --show-toplevel 2>/dev/null)/$dg_doc" ;; esac
55
+ dg_facts="$(jq -cn --argjson own "$2" \
56
+ --arg exam "$(rt_fact_exam_holds "$dg_record")" \
57
+ --arg window "$(rt_fact_window_over_stop "$dg_sid" "$dg_record")" \
58
+ --arg rule "$(rt_fact_move_rule_loaded Edit "$(jq -cn --arg f "$dg_doc" '{file_path:$f,old_string:"",new_string:""}')" "$dg_sid")" \
59
+ --arg gate "$(rt_fact_move_gate_rule Edit "$(jq -cn --arg f "$dg_doc" '{file_path:$f,old_string:"",new_string:""}')" "$dg_sid")" \
60
+ --arg flow "$(rt_fact_rule_loaded "${RT_TASK_FLOW_RULE:-task-flow}" "$dg_sid")" \
61
+ --arg handoff "$(rt_fact_from_handoff "$dg_record")" \
62
+ '{exam:$exam, window_over_stop:$window, rule_loaded:$rule, gate_rule:$gate, task_flow_loaded:$flow, from_handoff:$handoff} + $own')"
63
+ # shellcheck disable=SC1091
64
+ . "$rt_hooks_dir/decide.sh" 2>/dev/null
65
+ command -v rt_decide >/dev/null 2>&1 && rt_decide docs-guard.sh "$1" "$dg_facts" "${3:-"{}"}" PreToolUse "$input"
61
66
  exit 0
62
67
  }
63
68
 
@@ -97,11 +102,12 @@ case "$tool" in
97
102
  case "$target" in
98
103
  */"$laws_dir"/*.implementation.md | "$laws_dir"/*.implementation.md) exit 0 ;;
99
104
  */"$laws_dir"/*.md | "$laws_dir"/*.md)
100
- decide ask "An edit of a law: \`${target##*/}\`. A law describes an agreement about the product, not the layout of the code — name to the owner what you are changing and why, and wait for the answer. If the edit is already agreed, confirm the call."
105
+ decide edit_laid_out '{}' "$(jq -cn --arg f "${target##*/}" '{file:$f}')"
101
106
  ;;
102
107
  */"$overrides_dir"/laws/*.implementation.md | "$overrides_dir"/laws/*.implementation.md) exit 0 ;;
103
108
  */"$overrides_dir"/laws/*.md | "$overrides_dir"/laws/*.md)
104
- decide ask "An edit of a law by an override: \`${target##*/}\`. A laid-out file is rewritten by the layout, so an edit of the override is an edit of the law itself: name to the owner what you are changing and why, and wait for the answer. If the edit is already agreed, confirm the call."
109
+ if [ "$tool" = Write ]; then dg_act=write_override; else dg_act=edit_override; fi
110
+ decide "$dg_act" '{}' "$(jq -cn --arg f "${target##*/}" '{file:$f}')"
105
111
  ;;
106
112
  esac
107
113
  exit 0
@@ -134,186 +140,14 @@ case "$cmd" in
134
140
  *) exit 0 ;;
135
141
  esac
136
142
 
137
- # The reason for the bypass stays in the history, so the bypass is lawful. An empty line does not
138
- # count as a bypass: "Docs-skip:" without a reason is the same silent skip, only with a colon.
139
- #
140
- # The line starts a line — its own in the commit body, or a comment at the end of the command — and
141
- # takes no substitutions. The same condition as for the bypass at the merge: otherwise a text that
142
- # EXPLAINS the bypass lifts the requirement all by itself. A commit body about an edit of the guard
143
- # names exactly this line, and without the binding to the start the guard would let such a commit
144
- # through silently.
145
- if printf '%s' "$cmd" | grep -qiE '(^|#)[[:space:]]*Docs-skip:[[:space:]]*[^[:space:]<"'"'"'][^[:space:]"'"'"']{2,}'; then
146
- exit 0
147
- fi
148
-
149
- workdir="$(rt_hook_cwd)"
150
- [ -z "$workdir" ] && workdir="${CLAUDE_PROJECT_DIR:-.}"
151
- cd "$workdir" 2>/dev/null || exit 0
152
- git rev-parse --is-inside-work-tree >/dev/null 2>&1 || exit 0
153
-
154
- # `-a` takes all tracked edits, `--amend` takes the files of the rewritten commit as well. Always
155
- # counting by the index would mean checking a set other than the one that travels into the history.
156
- changes=''
157
- source_mode='index'
158
- case "$cmd" in
159
- *' -a'* | *--all*)
160
- changes="$(git diff HEAD --name-status -M 2>/dev/null)"
161
- source_mode='worktree'
162
- ;;
163
- *) changes="$(git diff --cached --name-status -M 2>/dev/null)" ;;
164
- esac
165
- case "$cmd" in
166
- *--amend*) changes="$(printf '%s\n%s' "$changes" "$(git show --name-status --format= HEAD 2>/dev/null)")" ;;
167
- esac
168
-
169
- changes="$(printf '%s\n' "$changes" | grep -v '^[[:space:]]*$')"
170
- [ -z "$changes" ] && exit 0
171
-
172
- # The paths of the commit without the statuses. A rename comes as three fields — we take both sides.
173
- paths="$(printf '%s\n' "$changes" | awk -F'\t' '{ for (i = 2; i <= NF; i++) if ($i != "") print $i }' | sort -u)"
174
-
175
- has_path() { printf '%s\n' "$paths" | grep -qxF "$1"; }
176
-
177
- # The content as it will travel into the commit. The source is the same one the list of edits was
178
- # collected by: `-a` takes the working tree, an ordinary commit takes the index. Always reading the
179
- # index is not allowed — under `-a` the previous edition lies there, and the guard would hold the
180
- # very commit that fixes the divergence; always reading the working tree is not allowed either — an
181
- # unstaged edit will not get into the commit.
182
- content_of() {
183
- if [ "$source_mode" = 'worktree' ]; then
184
- cat "$1" 2>/dev/null
185
- else
186
- git show ":$1" 2>/dev/null || cat "$1" 2>/dev/null
187
- fi
188
- }
189
-
190
- problems=''
191
- add() { problems="${problems}
192
- • $1"; }
193
-
194
- # ── 1. A rule and its companion ───────────────────────────────────────────────
195
- #
196
- # The statements of a rule are keyed by their own text, and a rewording without an edit of the
197
- # companion breaks the link silently. The spec audit catches this, but it is run at the push gate —
198
- # here the same pair meets a commit earlier, while the edit is still in the author's head.
199
- #
200
- # The section with the statements is the only thing linked to the companion; an edit of "Pitfalls"
201
- # or of the "Where it lives" table does not touch it, so only this section is compared. The name of
202
- # the section is double: English in a package rule, Russian in a rule written by the tree before the
203
- # layer was translated. The end of the range is any heading not starting with their first letter.
204
- STATEMENTS='/^## (How the law applies here|Как закон применяется здесь)$/,/^## [^КH]/'
205
- statements_of() { content_of "$1" | awk "$STATEMENTS"; }
206
-
207
- for rule in $(printf '%s\n' "$paths" | grep -E '/SKILL\.md$'); do
208
- grep -q '^kind: rule$' "$rule" 2>/dev/null || continue
209
- companion="${rule%/SKILL.md}/implementation.md"
210
-
211
- [ -f "$companion" ] || continue
212
- has_path "$companion" && continue
213
-
214
- if [ "$(statements_of "$rule")" != "$(git show "HEAD:$rule" 2>/dev/null | awk "$STATEMENTS")" ]; then
215
- add "the statements of \`$rule\` are edited without the companion — add \`$companion\` to the commit"
216
- fi
217
- done
218
-
219
- # ── 2. The pairs the tree names ───────────────────────────────────────────────
220
- #
221
- # The contract and the domain spec, a guard and its scenarios — which exactly, the profile knows:
222
- # every tree has a link of its own, and the mechanics are one.
223
- if rt_needs rt_docs_pair_for docs-guard; then
224
- while IFS= read -r file; do
225
- [ -z "$file" ] && continue
226
-
227
- # A file put in place by the layout demands no pair: it has one author in a consuming tree
228
- # — the package, and the document about it lies there as well. Otherwise the very first
229
- # layout demands a bypass over its whole volume, and a bypass declared over a hundred files
230
- # lifts the requirement from future hand edits of those files too. The sign is the layout
231
- # header: it stands in every laid-out file and tells it apart more reliably than any list
232
- # of paths.
233
- if [ -f "$file" ] && head -12 "$file" 2>/dev/null | grep -qE 'rt-kit v[^ ]+ · [^ ]+ · [0-9a-f]+'; then
234
- continue
235
- fi
236
-
237
- want="$(rt_docs_pair_for "$file" 2>/dev/null)"
238
- [ -z "$want" ] && continue
239
- # The pair counts as arrived if at least one file of the commit fits the pattern.
240
- printf '%s\n' "$paths" | grep -qE "$want" && continue
241
- add "\`$file\` is edited without its document — the same commit awaits \`$want\`"
242
- done <<EOF
243
- $paths
244
- EOF
245
- fi
246
-
247
- # ── 3. A lib and its README ───────────────────────────────────────────────────
248
-
249
- lib_root() {
250
- dir="${1%/*}"
251
- while [ -n "$dir" ] && [ "$dir" != "." ]; do
252
- [ -f "$dir/$lib_marker" ] && { printf '%s' "$dir"; return 0; }
253
- case "$dir" in */*) dir="${dir%/*}" ;; *) dir='' ;; esac
254
- done
255
-
256
- return 1
257
- }
258
-
259
- need_readme=''
260
- want_readme() {
261
- root="$1"
262
- [ -n "$root" ] || return 0
263
- case " $need_readme " in *" $root "*) return 0 ;; esac
264
- need_readme="$need_readme $root"
265
- }
266
-
267
- # Creating and removing a lib: the README is the only place where it is written what lies in it and
268
- # who calls it, and it survives the layout only together with an edit of that text.
269
- while IFS="$(printf '\t')" read -r status first second; do
270
- case "$status" in
271
- A* | D*)
272
- case "$first" in */"$lib_marker") want_readme "${first%/"$lib_marker"}" ;; esac
273
- ;;
274
- R*)
275
- # A move of a file changes both sides: from one lib it disappeared, in the other it
276
- # appeared.
277
- from="$(lib_root "$first")" && to="$(lib_root "$second")"
278
- if [ -n "$from" ] && [ -n "$to" ] && [ "$from" != "$to" ]; then
279
- want_readme "$from"
280
- want_readme "$to"
281
- fi
282
- ;;
283
- esac
284
- done <<EOF
285
- $changes
286
- EOF
287
-
288
- # A move given as the pair "deleted there, added here": not everything that is a rename counts as
289
- # one — an edit of the content while moving throws the search off.
290
- moved_added="$(printf '%s\n' "$changes" | awk -F'\t' '$1 ~ /^A/ { n = split($2, p, "/"); print p[n] "\t" $2 }' | sort -u)"
291
- moved_deleted="$(printf '%s\n' "$changes" | awk -F'\t' '$1 ~ /^D/ { n = split($2, p, "/"); print p[n] "\t" $2 }' | sort -u)"
292
- if [ -n "$moved_added" ] && [ -n "$moved_deleted" ]; then
293
- while IFS="$(printf '\t')" read -r base added; do
294
- [ -n "$base" ] || continue
295
- gone="$(printf '%s\n' "$moved_deleted" | awk -F'\t' -v b="$base" '$1 == b { print $2; exit }')"
296
- [ -n "$gone" ] || continue
297
- to="$(lib_root "$added")" || continue
298
- from="$(lib_root "$gone")" || continue
299
- [ "$from" = "$to" ] && continue
300
- want_readme "$from"
301
- want_readme "$to"
302
- done <<EOF
303
- $moved_added
304
- EOF
305
- fi
306
-
307
- for root in $need_readme; do
308
- [ -d "$root" ] || continue # the lib was deleted whole — there is nothing to edit in it
309
- has_path "$root/README.md" || add "the content of the lib \`$root\` changed without an edit of \`$root/README.md\`"
310
- done
143
+ # The analysis of the pair lives in `facts-docs.sh`: the delivery hooks ask the same fact.
144
+ # shellcheck disable=SC1091
145
+ . "$rt_hooks_dir/facts-docs.sh" 2>/dev/null
146
+ command -v rt_fact_doc_problems >/dev/null 2>&1 || exit 0
147
+ rt_fact_doc_problems "$cmd" || exit 0
311
148
 
312
149
  if [ -n "$problems" ]; then
313
- decide deny "BLOCKED: the commit edits code but not the document that describes it.
314
- ${problems}
315
-
316
- Text is edited in the same branch as the code: a document that has drifted from the tree looks like a current reference and leads the next reader astray. If an edit of the document really is not needed here — name the reason by the line \`Docs-skip: <reason>\` in the commit body, it stays in the history."
150
+ decide commit '{"doc_pair":"no"}' "$(jq -cn --arg p "$problems" '{problems:$p}')"
317
151
  fi
318
152
 
319
153
  # ── 4. The laws ───────────────────────────────────────────────────────────────
@@ -334,10 +168,7 @@ if [ -d "$laws_dir" ] && ! printf '%s\n' "$paths" | grep -qE "^${laws_dir}/([^/]
334
168
  done
335
169
 
336
170
  if [ -n "$touched" ]; then
337
- decide ask "The edit touches the places where articles of laws are carried out:
338
- ${touched}
339
-
340
- The laws lie in \`${laws_dir}/\`, the binding — in the companions next to them. Read the law and tell the owner whether the edit agrees with it: if the edit refines it or contradicts it, the law is edited in this same branch, but only with their knowledge. If the law has not changed — confirm the call."
171
+ decide commit '{"doc_pair":"yes","law_anchor_touched":"yes"}' "$(jq -cn --arg t "$touched" --arg l "$laws_dir" '{touched:$t, laws_dir:$l}')"
341
172
  fi
342
173
  fi
343
174
 
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
  # rt-hook: PreToolUse .*EndConversation.*
3
- # Requires: hooks/deny-tail.sh
3
+ # Requires: hooks/decide.sh
4
4
  # The guard of the end of the conversation: the executor does not end the session. PreToolUse on
5
5
  # the tool that closes the conversation — refused always.
6
6
  #
@@ -10,13 +10,14 @@
10
10
  # package. There is no lawful form of bypass: no state of the work, no word in the turn and no
11
11
  # insult from the owner cancels it — a session that must close is closed by the owner.
12
12
  #
13
- # The name of the tool is read by jq, and without jq by grep over the raw input: a missing parser
14
- # must not turn into silence here. A tool name with a vendor prefix is matched by its tail.
13
+ # The name of the tool is read by jq, and without jq by grep over the raw input. A tool name with a
14
+ # vendor prefix is matched by its tail.
15
15
  #
16
- # FAIL-OPEN only where there is nothing to judge: an empty input or a name that is not the closing
17
- # tool passes. A readable call of the closing tool is refused with or without a JSON parser.
16
+ # FAIL-OPEN: an empty input or a name that is not the closing tool passes. The refusal itself comes
17
+ # from the decision table, so without jq or node the call passes, like the call of every guard that
18
+ # asks the decider: a broken decider has no right to jam the work.
18
19
 
19
- # Its own name in the observations: the refusal is recorded by the shared deny tail.
20
+ # Its own name in the observations: the refusal is recorded by the decider call.
20
21
  RT_GUARD_NAME=end-conversation-guard
21
22
  RT_GUARD_RULE=turn-conduct
22
23
 
@@ -42,19 +43,9 @@ case "$tool" in
42
43
  *) exit 0 ;;
43
44
  esac
44
45
 
45
- # shellcheck disable=SC1090
46
- [ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
47
- && . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
48
- command -v rt_deny_tail >/dev/null 2>&1 || rt_deny_tail() { :; }
49
-
50
- reason="BLOCKED by end-conversation-guard: the executor does not end the conversation. The session is ended by the owner and by nobody else.
51
-
52
- An assignment stands until the owner cancels it, and an insult cancels nothing: do what was assigned, and where the work stands on the owner's word, wait for the word. A session that must close is closed by the owner — say so in words and go on working. There is no lawful form of bypass for this refusal."
53
- tail_text="$(rt_deny_tail "")"
54
- [ -n "$tail_text" ] && reason="${reason}
55
-
56
- ${tail_text}"
57
-
58
- jq -n --arg r "$reason" '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:$r}}' 2>/dev/null \
59
- || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"BLOCKED by end-conversation-guard: the session is ended by the owner and by nobody else."}}\n'
46
+ # The decision and the words come from the decision table: the call itself is the whole fact.
47
+ # shellcheck disable=SC1091
48
+ . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/decide.sh" 2>/dev/null
49
+ command -v rt_decide >/dev/null 2>&1 || exit 0
50
+ rt_decide end-conversation-guard.sh end_conversation '{}' '{}' PreToolUse "$input"
60
51
  exit 0
@@ -1,28 +1,35 @@
1
1
  #!/usr/bin/env bash
2
2
  # rt-hook: PreToolUse Bash|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_tool
3
- # Requires: hooks/deny-tail.sh, hooks/epic-over.sh, checks/epic-table.github.mjs
3
+ # Requires: hooks/observe.sh, hooks/epic-over.sh, checks/epic-table.github.mjs
4
4
  # Guard of the stop at the end of an epic. PreToolUse on a call that takes new work.
5
5
  #
6
6
  # An epic used to end with the session taking the next piece of work. The owner learned that the
7
7
  # epic was over from an ordinary report, mixed in with everything else, and had nowhere to give an
8
8
  # order about its outcome: by the time they read it, the branch for the next work was already
9
- # created. The rule of the turn carried a line about this, and it was held the same way the line
10
- # about the table of tasks was held before the command — by memory, that is, sometimes.
9
+ # created.
11
10
  #
12
11
  # The guard stands on the call, not on the end of the turn: a turn ends with text, and a guard that
13
- # took to reading text would refuse by mood. Taking work is a call — a task, a branch by a number, a
14
- # column.
12
+ # took to reading text would refuse by mood. Taking work is a call — a created task or a branch by a
13
+ # task number.
14
+ #
15
+ # The decision is the owner's, and the guard asks them for it: the answer is `ask`, and the host
16
+ # shows the owner a window to allow or forbid this very command. The guard reads no record of the
17
+ # conversation. It once looked for the owner's consent there by words, and both misses came of it:
18
+ # a real «yes» given in other words was not found, and the owner was asked the same thing three
19
+ # times; an unrelated «yes» was taken for consent. Where nobody can answer the window — a subagent,
20
+ # a run without a person — the host hands the reason to the model, and the call does not go.
21
+ #
22
+ # A column moved to the working one is not judged: it follows the branch of the same work, and a
23
+ # window on it would ask the owner a second time about the decision they have just given.
15
24
  #
16
25
  # The state of the epic is asked by the same command that prints the table for the owner. A reader
17
- # of its own would diverge from the printed table in silence: it would refuse work the table itself
18
- # calls unfinished.
26
+ # of its own would diverge from the printed table in silence: it would ask about work the table
27
+ # itself calls unfinished.
19
28
  #
20
29
  # FAIL-OPEN: no `jq`, no `node`, no command, an epic that cannot be asked, any error of its own —
21
30
  # the call is ALLOWED. A guard that jams the work when the network is gone is switched off on the
22
31
  # first day, and the price of a miss here is one turn of the owner's attention.
23
32
 
24
- # Its own name in the observations: the refusal is written by the shared deny tail, not by the
25
- # guard itself.
26
33
  RT_GUARD_NAME=epic-stop-guard
27
34
  RT_GUARD_RULE=turn-conduct
28
35
 
@@ -56,25 +63,34 @@ if [ "$tool" = "mcp__webstorm__execute_tool" ] && command -v perl >/dev/null 2>&
56
63
  [ -n "$inner" ] && cmd="$inner"
57
64
  fi
58
65
 
59
- # The order of the owner travels in the call itself: the guard sees the call and does not see the
60
- # conversation. An empty reason is not a bypass — the line then says nothing about who allowed it.
61
- if printf '%s' "$cmd" | grep -qE 'Epic-stop-skip:[[:space:]]*[^[:space:]]' 2>/dev/null; then
62
- exit 0
63
- fi
64
-
65
- # What counts as taking new work: a branch by a task number, a created task, a column moved to the
66
- # working one. Everything else — a commit, a push, reading the history — is not judged: the epic is
67
- # closed by exactly these three, and a wider net would refuse the work of finishing it.
66
+ # What counts as taking new work: a created task or a branch by a task number, and only where the
67
+ # command itself is run. The body of a heredoc is a text for another program, and an argument of a
68
+ # reader is a file name: a script that edits this very guard and a `sed` over the creating command
69
+ # named the command and took no work, and both were refused on 13.11.2026. The command is cut into
70
+ # its pieces by the shell separators; a piece is judged by its head, after the assignments of
71
+ # variables and the options of git.
72
+ heads() {
73
+ printf '%s\n' "$1" | perl -e '
74
+ my $text = do { local $/; <STDIN> };
75
+ $text =~ s/<<-?\s*([\x27"]?)(\w+)\1[^\n]*\n.*?\n\s*\2[ \t]*(?:\n|$)/\n/sg;
76
+ for my $piece (split /&&|\|\||[;|\n]/, $text) {
77
+ $piece =~ s/^\s+//;
78
+ $piece =~ s/^(?:\w+=(?:\x27[^\x27]*\x27|"[^"]*"|\S*)\s+)+//;
79
+ print "$piece\n" if length $piece;
80
+ }
81
+ ' 2>/dev/null
82
+ }
68
83
  takes_work=no
69
- if printf '%s' "$cmd" | grep -qE '(checkout|switch)[[:space:]]+(-[A-Za-z]+[[:space:]]+)*-(b|c)[[:space:]]+[A-Za-z]+-[0-9]+-' 2>/dev/null; then
70
- takes_work=yes
71
- fi
72
- if printf '%s' "$cmd" | grep -qE 'task:new|task-new\.mjs' 2>/dev/null; then
73
- takes_work=yes
74
- fi
75
- if printf '%s' "$cmd" | grep -qE '(task:move|board\.mjs[[:space:]]+move)([^|;&]*)in-progress' 2>/dev/null; then
76
- takes_work=yes
77
- fi
84
+ while IFS= read -r piece; do
85
+ if printf '%s' "$piece" | grep -qE '^git([[:space:]]+-[cC][[:space:]]+[^[:space:]]+)*[[:space:]]+(checkout|switch)[[:space:]]+(-[A-Za-z]+[[:space:]]+)*-(b|c)[[:space:]]+[A-Za-z]+-[0-9]+-'; then
86
+ takes_work=yes
87
+ fi
88
+ if printf '%s' "$piece" | grep -qE '^(npm|pnpm|yarn)[[:space:]]+(run[[:space:]]+)?(-s[[:space:]]+)?task:new([[:space:]]|$)|^node[[:space:]]+[^[:space:]]*task-new(\.github)?\.mjs'; then
89
+ takes_work=yes
90
+ fi
91
+ done <<EOF
92
+ $(heads "$cmd")
93
+ EOF
78
94
  [ "$takes_work" = yes ] || exit 0
79
95
 
80
96
  # The reading of the end of an epic is shared with the two guards that judge the stop itself: written
@@ -86,89 +102,22 @@ fi
86
102
  command -v rt_epic_over >/dev/null 2>&1 || exit 0
87
103
  rt_epic_over || exit 0
88
104
 
89
- # The word of the owner about this very work releases the call: their message or their answer to a
90
- # menu that names the number the call takes. The line in the call was the only form before, and an
91
- # owner who forbade writing it left the executor one way out — stopping the work they had just set.
92
- # The number is read from the call; the words of the executor do not count.
93
- taken="$(printf '%s' "$cmd" | sed -nE 's/.*(checkout|switch)[[:space:]]+(-[A-Za-z]+[[:space:]]+)*-(b|c)[[:space:]]+[A-Za-z]+-([0-9]+)-.*/\4/p; s/.*(task:move|board\.mjs[[:space:]]+move)[^0-9|;&]*([0-9]+).*/\2/p; s/.*--epic-of[[:space:]=]+([0-9]+).*/\1/p' | head -1)"
94
- transcript="$(printf '%s' "$input" | jq -r '.transcript_path // empty' 2>/dev/null)"
95
- if [ -n "$taken" ] && [ -n "$transcript" ] && [ -f "$transcript" ]; then
96
- # A menu answer comes in two forms, «The user answered:» and «Your questions have been answered:»,
97
- # followed by "question"="answer" pairs. Only the answers count: the question is written by the
98
- # executor, and a number in «take RT-N?» answered «no» is not the owner's word.
99
- named="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r --arg n "$taken" '
100
- def menu_answers: if test("^(The user answered|Your questions have been answered):")
101
- then ([match("\"=\"([^\"]*)\""; "g") | .captures[0].string] | join("\n")) else "" end;
102
- [.[] | select(.type == "user")
103
- | select(((.isMeta // false) or (.isCompactSummary // false)) | not)
104
- | (.message.content // "")
105
- | if type == "string" then .
106
- elif type == "array" then (map(
107
- if .type == "text" then (.text // "")
108
- elif .type == "tool_result" then ((.content
109
- | if type == "string" then . elif type == "array"
110
- then (map(if type == "object" then (.text // "") else "" end) | join(" ")) else "" end)
111
- | menu_answers)
112
- else "" end) | join("\n"))
113
- else "" end]
114
- | map(test("(^|[^0-9])" + $n + "([^0-9]|$)")) | any
115
- ' 2>/dev/null)"
116
- [ "$named" = "true" ] && exit 0
117
- fi
118
-
119
- # A created task has no number yet, so no menu answer can name it, and the owner's answer to «create
120
- # a task for these findings?» left the call refused. The word of the owner here is their latest
121
- # answer to a menu: no message of theirs stands after it, the answer agrees to a task — a word of a
122
- # task, of creating it, or a plain «yes» — and it is not a refusal. Any answer was too wide: «not
123
- # now» and an answer about a button colour passed alike. A new epic needs the word of an epic.
124
- if [ -z "$taken" ] && [ -n "$transcript" ] && [ -f "$transcript" ] \
125
- && printf '%s' "$cmd" | grep -qE 'task:new|task-new\.mjs' 2>/dev/null; then
126
- consent='задач|карточ|task|issue|заве|завод|созда|create|^\s*(да|yes|ок|ok)([^[:alpha:]]|$)'
127
- if printf '%s' "$cmd" | grep -qE -- '--epic([[:space:]=]|$)' 2>/dev/null; then
128
- consent='эпик|epic'
129
- fi
130
- latest="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r --arg consent "$consent" '
131
- [.[] | select(.type == "user")
132
- | select(((.isMeta // false) or (.isCompactSummary // false)) | not)
133
- | (.message.content // "")
134
- | if type == "string" then {said: .}
135
- elif type == "array" then (map(
136
- if .type == "text" then {said: (.text // "")}
137
- elif .type == "tool_result" then ((.content
138
- | if type == "string" then . elif type == "array"
139
- then (map(if type == "object" then (.text // "") else "" end) | join(" ")) else "" end)
140
- | if test("^(The user answered|Your questions have been answered):")
141
- then {menu: ([match("\"=\"([^\"]*)\""; "g") | .captures[0].string] | first // "")}
142
- else empty end)
143
- else empty end) | .[])
144
- else empty end]
145
- | (last // {})
146
- | if (.menu // "") != ""
147
- and (.menu | test($consent; "i"))
148
- and ((.menu | test("^\\s*(нет|не\\s|нельзя|no\\b|стоп|stop|отмен|cancel|подожд|wait|позже|later|пока ничего|ничего|nothing)"; "i")) | not)
149
- then "yes" else "no" end
150
- ' 2>/dev/null)"
151
- [ "$latest" = "yes" ] && exit 0
152
- fi
153
-
154
105
  root="$(git rev-parse --show-toplevel 2>/dev/null)"
155
106
  checks="$(jq -r '.layout.checks // "tools"' "$root/.claude/rt-kit.json" 2>/dev/null)"
156
107
  if [ -z "$checks" ] || [ "$checks" = null ]; then
157
108
  checks=tools
158
109
  fi
159
110
 
160
- reason="Refused: the epic is over — every task of it is merged or handed over by a request, and this call takes new work. The end of an epic is a stop: print the table by «npm run epic:table» (or «node $checks/epic-table.mjs»), tell the owner what was done on each task and what confirms it, and say outright that the session waits for their orders. New work is taken by their word, not by the count of what is left: their message or their answer to a menu that names the number of this work releases the call; a task being created has no number yet, and it is released by the latest answer of the owner to a menu when that answer agrees to a task and is not a refusal. A new epic the owner has declared needs the bypass line in the calls that create its card, its tasks and its branch; once the branch of the new epic is taken, the guard reads that epic and stops refusing."
161
-
111
+ # The window is counted apart from the refusals: an unanswered window in a run without a person is
112
+ # a refusal by its effect, and a count of refusals alone would not see it.
162
113
  # shellcheck disable=SC1090
163
- [ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
164
- && . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
165
- command -v rt_deny_tail >/dev/null 2>&1 || rt_deny_tail() { :; }
166
- deny_tail_text="$(rt_deny_tail "the line «Epic-stop-skip: <the word of the owner>» in the call itself; an empty reason is not accepted")"
167
- [ -n "$deny_tail_text" ] && reason="${reason}
168
-
169
- ${deny_tail_text}"
170
-
171
- jq -n --arg r "$reason" '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:$r}}' 2>/dev/null \
172
- || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"The epic is over: the end of an epic is a stop, not the next task."}}\n'
173
-
114
+ . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/observe.sh" 2>/dev/null || true
115
+ command -v rt_note >/dev/null 2>&1 && rt_note guard-ask guard="$RT_GUARD_NAME" sid="$(printf '%s' "$input" | jq -r '.session_id // empty' 2>/dev/null)"
116
+
117
+ # The decision and the words come from the decision table; the class of the call is found by the
118
+ # decider from the call itself, and a run of the task script it does not know is taking a task.
119
+ # shellcheck disable=SC1091
120
+ . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/decide.sh" 2>/dev/null
121
+ command -v rt_decide >/dev/null 2>&1 || exit 0
122
+ rt_decide epic-stop-guard.sh "?task_new" '{"epic_over":"yes"}' "$(jq -cn --arg c "$checks" '{checks:$c}')" PreToolUse "$input"
174
123
  exit 0