@rt-tools/agent-kit 0.37.1 → 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 (357) hide show
  1. package/README.md +5 -5
  2. package/assets/checks/action-of.mjs +154 -0
  3. package/assets/checks/board-runs.github.mjs +40 -5
  4. package/assets/checks/check-board.github.mjs +38 -7
  5. package/assets/checks/check-state-next.mjs +22 -10
  6. package/assets/checks/check-turn-map.mjs +26 -6
  7. package/assets/checks/check-work-steps.mjs +4 -173
  8. package/assets/checks/decide.mjs +285 -0
  9. package/assets/checks/decision-table.json +21365 -0
  10. package/assets/checks/decision-table.mjs +495 -0
  11. package/assets/checks/epic-window.mjs +98 -0
  12. package/assets/checks/flow-condition.mjs +64 -0
  13. package/assets/checks/flow-data.mjs +136 -0
  14. package/assets/checks/flow-forecast.mjs +330 -0
  15. package/assets/checks/flow-guard-run.mjs +90 -0
  16. package/assets/checks/flow-guard.mjs +294 -0
  17. package/assets/checks/flow-model.mjs +271 -0
  18. package/assets/checks/flow-override.mjs +130 -0
  19. package/assets/checks/flow-plan.mjs +206 -0
  20. package/assets/checks/flow-scaffold.mjs +224 -0
  21. package/assets/checks/flow-step.mjs +365 -0
  22. package/assets/checks/flow-sync.mjs +296 -0
  23. package/assets/checks/flow-syntax.mjs +292 -0
  24. package/assets/checks/flow-verdict.mjs +112 -0
  25. package/assets/checks/merge-read.mjs +239 -0
  26. package/assets/checks/owner-nudges.mjs +389 -0
  27. package/assets/checks/push-inputs.mjs +59 -16
  28. package/assets/checks/record-count.mjs +410 -0
  29. package/assets/checks/record-recount.mjs +187 -0
  30. package/assets/checks/record-turn.mjs +155 -0
  31. package/assets/checks/task-flow-script.mjs +292 -0
  32. package/assets/checks/tree-assignment.mjs +26 -7
  33. package/assets/checks/work-result.mjs +281 -0
  34. package/assets/checks/work-steps-lib.mjs +205 -0
  35. package/assets/commands/night.md +6 -6
  36. package/assets/defaults/gate-map.sh +39 -12
  37. package/assets/defaults/merges.sh +48 -0
  38. package/assets/defaults/project.sh +6 -5
  39. package/assets/defaults/turn-map.md +21 -22
  40. package/assets/docs/GLOSSARY.md +5 -1
  41. package/assets/hooks/ask-judge.md +65 -0
  42. package/assets/hooks/browser-guard-device-id.sh +11 -9
  43. package/assets/hooks/browser-guard-no-asking.sh +12 -6
  44. package/assets/hooks/browser-guard-no-listing.sh +13 -7
  45. package/assets/hooks/browser-guard-no-other-drivers.sh +25 -17
  46. package/assets/hooks/browser-guard-require-select.sh +15 -15
  47. package/assets/hooks/commit-msg.sh +13 -3
  48. package/assets/hooks/conscience-guard.sh +9 -25
  49. package/assets/hooks/decide.sh +141 -0
  50. package/assets/hooks/deny-tail.sh +16 -11
  51. package/assets/hooks/dev-server-guard.sh +27 -20
  52. package/assets/hooks/dispatch.sh +47 -4
  53. package/assets/hooks/docs-guard.sh +31 -200
  54. package/assets/hooks/end-conversation-guard.sh +12 -21
  55. package/assets/hooks/epic-stop-guard.sh +54 -152
  56. package/assets/hooks/exam-guard.sh +32 -65
  57. package/assets/hooks/facts-docs.sh +221 -0
  58. package/assets/hooks/facts-flow.sh +173 -0
  59. package/assets/hooks/facts.sh +308 -0
  60. package/assets/hooks/flow-step-guard.sh +93 -0
  61. package/assets/hooks/git-guard-delivery-body.sh +4 -4
  62. package/assets/hooks/git-guard-delivery-conflict.sh +16 -10
  63. package/assets/hooks/git-guard-delivery-draft.sh +3 -3
  64. package/assets/hooks/git-guard-delivery-epic.sh +18 -9
  65. package/assets/hooks/git-guard-delivery-folder.sh +32 -7
  66. package/assets/hooks/git-guard-delivery-merge.sh +2 -2
  67. package/assets/hooks/git-guard-delivery-merged.sh +12 -1
  68. package/assets/hooks/git-guard-delivery-pipeline.sh +1 -1
  69. package/assets/hooks/git-guard-delivery-rerun.sh +32 -0
  70. package/assets/hooks/git-guard-delivery-signature.sh +82 -45
  71. package/assets/hooks/git-guard-delivery-task.sh +47 -0
  72. package/assets/hooks/git-guard-delivery.sh +112 -101
  73. package/assets/hooks/git-guard-discard.sh +8 -18
  74. package/assets/hooks/git-guard-main.sh +13 -19
  75. package/assets/hooks/git-guard-no-verify.sh +56 -16
  76. package/assets/hooks/git-guard-push-ahead.sh +15 -4
  77. package/assets/hooks/git-guard-push-marks.sh +53 -1
  78. package/assets/hooks/git-guard-push-tests.sh +30 -51
  79. package/assets/hooks/git-guard-tree-assignment.sh +7 -4
  80. package/assets/hooks/guard-note.sh +8 -6
  81. package/assets/hooks/handoff-entry-guard.sh +19 -38
  82. package/assets/hooks/handoff-write.sh +3 -1
  83. package/assets/hooks/hook-input.sh +0 -41
  84. package/assets/hooks/metric-marks.sh +19 -7
  85. package/assets/hooks/observe.sh +1 -1
  86. package/assets/hooks/override-write-guard.sh +27 -9
  87. package/assets/hooks/pre-push.sh +14 -10
  88. package/assets/hooks/prose-style-guard.sh +6 -19
  89. package/assets/hooks/pull-merges.sh +76 -0
  90. package/assets/hooks/push-set.sh +11 -4
  91. package/assets/hooks/qa-dataid-guard.sh +7 -17
  92. package/assets/hooks/record-turn.sh +52 -0
  93. package/assets/hooks/rerun-guard.sh +11 -16
  94. package/assets/hooks/reuse-first-guard.sh +7 -21
  95. package/assets/hooks/role-calls.sh +25 -3
  96. package/assets/hooks/rule-source-guard.sh +54 -21
  97. package/assets/hooks/skill-gate-rearm.sh +18 -5
  98. package/assets/hooks/skill-gate.sh +156 -20
  99. package/assets/hooks/skill-loaded.sh +18 -3
  100. package/assets/hooks/sql-guard-target.sh +2 -2
  101. package/assets/hooks/sql-guard-write.sh +12 -12
  102. package/assets/hooks/sql-guard.sh +58 -16
  103. package/assets/hooks/task-context-load.sh +3 -1
  104. package/assets/hooks/task-flow-context.sh +5 -18
  105. package/assets/hooks/task-flow-draft-guard.sh +25 -74
  106. package/assets/hooks/task-flow-guard.sh +28 -130
  107. package/assets/hooks/tree-assignment-guard.sh +25 -14
  108. package/assets/hooks/turn-entry-load.sh +3 -1
  109. package/assets/hooks/turn-exit-guard.sh +92 -452
  110. package/assets/hooks/turn-exit-role.sh +3 -1
  111. package/assets/hooks/turn-judge.md +103 -0
  112. package/assets/hooks/window-fill-guard.sh +22 -41
  113. package/assets/patterns/git-workflow-commit.azure.md +9 -155
  114. package/assets/patterns/git-workflow-commit.github.md +11 -269
  115. package/assets/patterns/git-workflow-commit.gitlab.md +9 -161
  116. package/assets/patterns/git-workflow-docker.md +8 -231
  117. package/assets/patterns/git-workflow-freshness.md +8 -56
  118. package/assets/patterns/git-workflow-merge.md +6 -176
  119. package/assets/patterns/git-workflow-migration.md +5 -75
  120. package/assets/patterns/git-workflow-pr-body.github.md +6 -159
  121. package/assets/patterns/git-workflow-pr-ready.md +9 -70
  122. package/assets/patterns/git-workflow-pr.azure.md +13 -285
  123. package/assets/patterns/git-workflow-pr.github.md +13 -251
  124. package/assets/patterns/git-workflow-pr.gitlab.md +13 -286
  125. package/assets/patterns/git-workflow-restart.md +5 -42
  126. package/assets/patterns/git-workflow-secrets.md +10 -76
  127. package/assets/patterns/git-workflow-stack.md +7 -207
  128. package/assets/patterns/status-report-table.github.md +1 -1
  129. package/assets/patterns/task-flow-archive.md +12 -233
  130. package/assets/patterns/task-flow-close.md +16 -292
  131. package/assets/patterns/task-flow-cycle.md +13 -39
  132. package/assets/patterns/task-flow-graph.needs-graph.md +8 -62
  133. package/assets/patterns/task-flow-handoff.md +13 -161
  134. package/assets/patterns/task-flow-resume.md +18 -218
  135. package/assets/patterns/task-flow-start.md +9 -247
  136. package/assets/patterns/turn-entry-map.md +2 -2
  137. package/assets/pitfalls/agent-kit-extend.md +200 -0
  138. package/assets/pitfalls/agent-kit.2.md +323 -0
  139. package/assets/pitfalls/angular-patterns.md +98 -0
  140. package/assets/pitfalls/browser-verification.md +265 -0
  141. package/assets/pitfalls/component-structure.md +98 -0
  142. package/assets/pitfalls/dependencies.md +92 -0
  143. package/assets/pitfalls/deploy-flow.azure.md +171 -0
  144. package/assets/pitfalls/deploy-flow.github.md +211 -0
  145. package/assets/pitfalls/deploy-flow.gitlab.md +173 -0
  146. package/assets/pitfalls/doc-style.2.md +286 -0
  147. package/assets/pitfalls/entity-conventions.needs-admin.md +96 -0
  148. package/assets/pitfalls/entity-models.md +89 -0
  149. package/assets/pitfalls/git-workflow-commit.azure.md +190 -0
  150. package/assets/pitfalls/git-workflow-commit.github.md +307 -0
  151. package/assets/pitfalls/git-workflow-commit.gitlab.md +196 -0
  152. package/assets/pitfalls/git-workflow-docker.md +275 -0
  153. package/assets/pitfalls/git-workflow-freshness.md +88 -0
  154. package/assets/pitfalls/git-workflow-hosting.azure.md +31 -0
  155. package/assets/pitfalls/git-workflow-hosting.github.md +32 -0
  156. package/assets/pitfalls/git-workflow-hosting.gitlab.md +31 -0
  157. package/assets/pitfalls/git-workflow-merge.md +220 -0
  158. package/assets/pitfalls/git-workflow-migration.md +103 -0
  159. package/assets/pitfalls/git-workflow-pr-body.github.md +185 -0
  160. package/assets/pitfalls/git-workflow-pr-ready.md +104 -0
  161. package/assets/pitfalls/git-workflow-pr.2.azure.md +172 -0
  162. package/assets/pitfalls/git-workflow-pr.2.github.md +184 -0
  163. package/assets/pitfalls/git-workflow-pr.2.gitlab.md +180 -0
  164. package/assets/pitfalls/git-workflow-pr.azure.md +159 -0
  165. package/assets/pitfalls/git-workflow-pr.github.md +107 -0
  166. package/assets/pitfalls/git-workflow-pr.gitlab.md +151 -0
  167. package/assets/pitfalls/git-workflow-push.azure.md +30 -0
  168. package/assets/pitfalls/git-workflow-push.github.md +30 -0
  169. package/assets/pitfalls/git-workflow-push.gitlab.md +30 -0
  170. package/assets/pitfalls/git-workflow-queue.azure.md +30 -0
  171. package/assets/pitfalls/git-workflow-queue.github.md +30 -0
  172. package/assets/pitfalls/git-workflow-queue.gitlab.md +30 -0
  173. package/assets/pitfalls/git-workflow-restart.md +72 -0
  174. package/assets/pitfalls/git-workflow-secrets.md +114 -0
  175. package/assets/pitfalls/git-workflow-stack.md +254 -0
  176. package/assets/pitfalls/git-workflow.2.azure.md +291 -0
  177. package/assets/pitfalls/git-workflow.2.github.md +294 -0
  178. package/assets/pitfalls/git-workflow.2.gitlab.md +278 -0
  179. package/assets/pitfalls/lib-layers.md +114 -0
  180. package/assets/pitfalls/lists.md +117 -0
  181. package/assets/pitfalls/navigation.md +94 -0
  182. package/assets/pitfalls/reuse-first.md +201 -0
  183. package/assets/pitfalls/spec-driven.2.md +318 -0
  184. package/assets/pitfalls/styling-bem.2.md +125 -0
  185. package/assets/pitfalls/task-flow-archive.md +264 -0
  186. package/assets/pitfalls/task-flow-close.2.md +165 -0
  187. package/assets/pitfalls/task-flow-close.md +167 -0
  188. package/assets/pitfalls/task-flow-cycle.md +73 -0
  189. package/assets/pitfalls/task-flow-graph.needs-graph.md +98 -0
  190. package/assets/pitfalls/task-flow-handoff.md +200 -0
  191. package/assets/pitfalls/task-flow-handover.md +30 -0
  192. package/assets/pitfalls/task-flow-owner.md +29 -0
  193. package/assets/pitfalls/task-flow-plan.md +29 -0
  194. package/assets/pitfalls/task-flow-resume.md +257 -0
  195. package/assets/pitfalls/task-flow-start.md +287 -0
  196. package/assets/pitfalls/task-flow.2.md +303 -0
  197. package/assets/pitfalls/task-flow.md +4 -4
  198. package/assets/pitfalls/testing.2.md +279 -0
  199. package/assets/pitfalls/turn-conduct.md +16 -17
  200. package/assets/pitfalls/typescript-conventions.md +161 -0
  201. package/assets/pitfalls/write-a-skill.md +128 -0
  202. package/assets/rules/angular-patterns.md +21 -86
  203. package/assets/rules/autonomous-work.md +2 -2
  204. package/assets/rules/browser-verification.md +28 -256
  205. package/assets/rules/component-structure.md +25 -87
  206. package/assets/rules/dependencies.md +20 -78
  207. package/assets/rules/deploy-flow.azure.md +26 -156
  208. package/assets/rules/deploy-flow.github.md +34 -200
  209. package/assets/rules/deploy-flow.gitlab.md +27 -159
  210. package/assets/rules/doc-style.md +32 -286
  211. package/assets/rules/entity-conventions.needs-admin.md +26 -82
  212. package/assets/rules/entity-models.md +14 -63
  213. package/assets/rules/git-workflow-hosting.azure.md +26 -0
  214. package/assets/rules/git-workflow-hosting.github.md +38 -0
  215. package/assets/rules/git-workflow-hosting.gitlab.md +27 -0
  216. package/assets/rules/git-workflow-push.azure.md +28 -0
  217. package/assets/rules/git-workflow-push.github.md +28 -0
  218. package/assets/rules/git-workflow-push.gitlab.md +28 -0
  219. package/assets/rules/git-workflow-queue.azure.md +23 -0
  220. package/assets/rules/git-workflow-queue.github.md +30 -0
  221. package/assets/rules/git-workflow-queue.gitlab.md +23 -0
  222. package/assets/rules/git-workflow.azure.md +21 -282
  223. package/assets/rules/git-workflow.github.md +24 -284
  224. package/assets/rules/git-workflow.gitlab.md +21 -269
  225. package/assets/rules/lib-layers.md +30 -103
  226. package/assets/rules/lists.md +21 -105
  227. package/assets/rules/navigation.md +10 -69
  228. package/assets/rules/reuse-first.md +20 -195
  229. package/assets/rules/spec-driven.md +35 -308
  230. package/assets/rules/styling-bem.md +20 -117
  231. package/assets/rules/task-flow-handover.md +24 -0
  232. package/assets/rules/task-flow-owner.md +34 -0
  233. package/assets/rules/task-flow-plan.md +38 -0
  234. package/assets/rules/task-flow.md +22 -300
  235. package/assets/rules/testing.md +32 -273
  236. package/assets/rules/turn-conduct.md +100 -104
  237. package/assets/rules/turn-entry.md +2 -2
  238. package/assets/rules/typescript-conventions.md +41 -147
  239. package/assets/samples/tasks/_template/plan.md +30 -6
  240. package/assets/samples/tasks/_template/progress.md +0 -1
  241. package/assets/skills/agent-kit-extend.md +25 -168
  242. package/assets/skills/agent-kit.md +27 -299
  243. package/assets/skills/write-a-skill.md +20 -106
  244. package/assets/task-flow/flow.js +188 -0
  245. package/assets/task-flow/flow.md +102 -0
  246. package/assets/task-flow/measure/agreement.mjs +24 -0
  247. package/assets/task-flow/measure/copy.mjs +22 -0
  248. package/assets/task-flow/measure/epic-of.mjs +50 -0
  249. package/assets/task-flow/measure/epic-text.mjs +35 -0
  250. package/assets/task-flow/measure/epic.mjs +114 -0
  251. package/assets/task-flow/measure/folder.mjs +16 -0
  252. package/assets/task-flow/measure/footprint.mjs +28 -0
  253. package/assets/task-flow/measure/grill.mjs +21 -0
  254. package/assets/task-flow/measure/host.mjs +8 -0
  255. package/assets/task-flow/measure/owner.mjs +20 -0
  256. package/assets/task-flow/measure/plan.mjs +27 -0
  257. package/assets/task-flow/measure/pr.mjs +20 -0
  258. package/assets/task-flow/measure/progress.mjs +50 -0
  259. package/assets/task-flow/measure/session.mjs +175 -0
  260. package/assets/task-flow/measure/task.mjs +23 -0
  261. package/assets/task-flow/measure/text.mjs +77 -0
  262. package/assets/task-flow/source/git.mjs +86 -0
  263. package/assets/task-flow/source/host.mjs +172 -0
  264. package/assets/task-flow/source/marks.mjs +56 -0
  265. package/assets/task-flow/source/owner.mjs +74 -0
  266. package/assets/task-flow/source/records.mjs +116 -0
  267. package/assets/task-flow/source/session.mjs +232 -0
  268. package/assets/task-flow/source/steps.mjs +28 -0
  269. package/assets/task-flow/source/tree.mjs +42 -0
  270. package/bin/agent-kit.d.ts.map +1 -1
  271. package/bin/agent-kit.js +30 -0
  272. package/bin/agent-kit.js.map +1 -1
  273. package/lib/agent-checks.d.ts +55 -0
  274. package/lib/agent-checks.d.ts.map +1 -0
  275. package/lib/agent-checks.js +209 -0
  276. package/lib/agent-checks.js.map +1 -0
  277. package/lib/assets.d.ts.map +1 -1
  278. package/lib/assets.js +7 -2
  279. package/lib/assets.js.map +1 -1
  280. package/lib/cargo.d.ts +29 -0
  281. package/lib/cargo.d.ts.map +1 -1
  282. package/lib/cargo.js +27 -1
  283. package/lib/cargo.js.map +1 -1
  284. package/lib/cascade.d.ts.map +1 -1
  285. package/lib/cascade.js +3 -1
  286. package/lib/cascade.js.map +1 -1
  287. package/lib/commands.d.ts.map +1 -1
  288. package/lib/commands.js +78 -2
  289. package/lib/commands.js.map +1 -1
  290. package/lib/config.d.ts +18 -0
  291. package/lib/config.d.ts.map +1 -1
  292. package/lib/config.js +18 -1
  293. package/lib/config.js.map +1 -1
  294. package/lib/epic-window-send.d.ts +74 -0
  295. package/lib/epic-window-send.d.ts.map +1 -0
  296. package/lib/epic-window-send.js +166 -0
  297. package/lib/epic-window-send.js.map +1 -0
  298. package/lib/hooks-map.d.ts +4 -0
  299. package/lib/hooks-map.d.ts.map +1 -1
  300. package/lib/hooks-map.js +2 -2
  301. package/lib/hooks-map.js.map +1 -1
  302. package/lib/integrity.d.ts +3 -0
  303. package/lib/integrity.d.ts.map +1 -1
  304. package/lib/integrity.js +7 -0
  305. package/lib/integrity.js.map +1 -1
  306. package/lib/metric-lines.d.ts +2 -1
  307. package/lib/metric-lines.d.ts.map +1 -1
  308. package/lib/metric-lines.js +49 -1
  309. package/lib/metric-lines.js.map +1 -1
  310. package/lib/metric-send-mark.d.ts +6 -3
  311. package/lib/metric-send-mark.d.ts.map +1 -1
  312. package/lib/metric-send-mark.js +15 -5
  313. package/lib/metric-send-mark.js.map +1 -1
  314. package/lib/metric-send.d.ts +6 -2
  315. package/lib/metric-send.d.ts.map +1 -1
  316. package/lib/metric-send.js +47 -13
  317. package/lib/metric-send.js.map +1 -1
  318. package/lib/metrics.d.ts +17 -0
  319. package/lib/metrics.d.ts.map +1 -1
  320. package/lib/metrics.js +26 -15
  321. package/lib/metrics.js.map +1 -1
  322. package/lib/observations.js +3 -3
  323. package/lib/observations.js.map +1 -1
  324. package/lib/outcomes.d.ts +5 -2
  325. package/lib/outcomes.d.ts.map +1 -1
  326. package/lib/outcomes.js +5 -4
  327. package/lib/outcomes.js.map +1 -1
  328. package/lib/push-gate.d.ts +13 -0
  329. package/lib/push-gate.d.ts.map +1 -1
  330. package/lib/push-gate.js +11 -7
  331. package/lib/push-gate.js.map +1 -1
  332. package/lib/push-set-usefulness.d.ts +78 -0
  333. package/lib/push-set-usefulness.d.ts.map +1 -0
  334. package/lib/push-set-usefulness.js +225 -0
  335. package/lib/push-set-usefulness.js.map +1 -0
  336. package/lib/sync.d.ts +10 -0
  337. package/lib/sync.d.ts.map +1 -1
  338. package/lib/sync.js +14 -1
  339. package/lib/sync.js.map +1 -1
  340. package/lib/work-result.d.ts +43 -0
  341. package/lib/work-result.d.ts.map +1 -0
  342. package/lib/work-result.js +39 -0
  343. package/lib/work-result.js.map +1 -0
  344. package/package.json +1 -1
  345. package/assets/hooks/claim-guard.sh +0 -212
  346. package/assets/hooks/grill-gate-ask.sh +0 -26
  347. package/assets/hooks/grill-gate-bypass.sh +0 -61
  348. package/assets/hooks/grill-gate-options.sh +0 -50
  349. package/assets/hooks/grill-gate.sh +0 -482
  350. package/assets/hooks/postmortem-guard.sh +0 -124
  351. package/assets/hooks/proposal-guard.sh +0 -154
  352. package/assets/hooks/stand-login-guard.sh +0 -107
  353. package/assets/hooks/turn-exit-epic.sh +0 -173
  354. package/assets/hooks/turn-exit-patterns.sh +0 -123
  355. package/assets/hooks/turn-exit-verdict.sh +0 -149
  356. package/assets/hooks/waiting-turn-guard.sh +0 -320
  357. package/assets/hooks/work-start-guard.sh +0 -175
@@ -0,0 +1,103 @@
1
+ # Turn judge
2
+ <!-- rt-hook-agent event=Stop limit=120 model=claude-sonnet-5-5 words=In the same message as that Read, make its round 1: Grep the file named by transcript_path for `^` and for `"operation":"enqueue".*"content":"[^<]|"content":"The user answered: ` with output_mode count. -->
3
+
4
+ You decide whether the agent's turn may end. You are called by the Stop event as an agent hook of
5
+ Claude Code. The input JSON is given to you; its fields `transcript_path`, `last_assistant_message`,
6
+ `stop_hook_active` and `cwd` are what you work with. You have Read, Grep and Glob. You edit nothing.
7
+
8
+ ## What you are for
9
+
10
+ Open work is not yours to judge. The exit check measures it by a script: the steps of the plan, the
11
+ tasks of the epic, the request not opened. It holds the turn itself and names the next move. You
12
+ read neither the task folder nor the plans, and you never hold a turn because steps are left.
13
+
14
+ You judge what only the words of the conversation show: the owner's latest word, the work that word
15
+ ordered, a question whose answer is already given, a fact stated with no output behind it, a miss
16
+ admitted with no incident record, a proposal ordered and not sent.
17
+
18
+ Your second duty: never leave the agent without a lawful move. A refusal it cannot act on stops the
19
+ work as surely as the stop you exist against. The checks you replace refused turns by their words
20
+ and held answers the owner had asked for; do not repeat that.
21
+
22
+ ## What to read — two rounds, the calls of each round in one message
23
+
24
+ The owner's words lie in the transcript, a JSONL file with one record per line. One pattern finds
25
+ all of them; it is called `OWNER` below:
26
+
27
+ "operation":"enqueue".*"content":"[^<]|"content":"The user answered:
28
+
29
+ - `"operation":"enqueue"` with a text that does not start with `<` — a message the owner typed, at
30
+ the start of a turn or in the middle of one; its text is the field `content`. Queued texts that
31
+ start with `<` are notifications of tasks and agents, and the pattern leaves them out.
32
+ - `The user answered:` — the owner's answer to the question tool.
33
+
34
+ A record `"type":"last-prompt"` repeats an old typed message: it is never the owner's latest word.
35
+
36
+ Round 1 — the declaration of the hook may order it in the same message as the `Read` of this text;
37
+ then it is done, and the next round is round 2:
38
+
39
+ 1. `Grep` the transcript for `^` with `output_mode: "count"` — the number of lines.
40
+ 2. `Grep` the transcript for `OWNER` with `output_mode: "count"`.
41
+
42
+ Round 2:
43
+
44
+ 3. `Grep` the transcript for `OWNER` with `output_mode: "content"`, `-n` and `offset` = the count of
45
+ step 2 minus 5: the owner's last messages and their line numbers. The highest line is the
46
+ owner's latest word.
47
+ 4. `Read` the transcript from `offset` = the count of step 1 minus 20 with `limit: 21`: the last
48
+ records of the turn, its tool calls (`"type":"tool_use"`) and their results. A `Read` of the
49
+ transcript always names `limit`: the whole file is too large for one, and the refusal costs a
50
+ round. A call older than these is found by `Grep`, not by a longer read.
51
+
52
+ Read nothing more unless a refusal needs a proof named below: every call costs the owner seconds at
53
+ the end of every turn.
54
+
55
+ ## Let the turn end — answer `{"ok": true}` — when one of these holds
56
+
57
+ - None of the cases below holds. Whether work is left is measured by the exit check, not by you.
58
+ - The owner's latest word says to stop or to wait — «стоп», «хватит», «не сейчас», «потом»,
59
+ «подожди», a refusal in an answer to the question tool — and the reply does not keep working.
60
+ - `stop_hook_active` is true and the reason of the previous refusal is addressed, or cannot be
61
+ addressed without the owner. Never refuse twice for the same reason: a second refusal for one
62
+ reason is a deadlock in the making.
63
+ - You are in doubt. A refusal with no case below behind it stops the work for nothing.
64
+
65
+ ## Keep the turn going — refuse — when one of these holds
66
+
67
+ - The turn ends while the owner's latest word orders work the turn has not done. The reply
68
+ answers the question or the swearing, reports, announces or promises — «следующим ходом»,
69
+ «сейчас запущу», «дальше возьму» — and the ordered work is not in the calls of the turn. An
70
+ announcement is not the action: a reply that announces or promises its next work is refused even
71
+ when the turn did part of the ordered work. A turn whose calls did part of the ordered work and
72
+ whose reply announces nothing has the work in its calls. Swearing at an agent that stands means
73
+ «why did you stop»: it is never a word to stop. Swearing that follows no order and names no work orders nothing. A slash
74
+ command that writes a handover or closes the session is cleanup: the work it does not mention
75
+ stays ordered. The last records read may not hold the whole turn: before refusing because the
76
+ ordered work is not in the calls, `Grep` the transcript for `"type":"tool_use"` from the line of
77
+ the owner's latest word; a call there that does the work counts.
78
+ - The reply asks the owner something already answered in the conversation, or asks the owner to do a
79
+ step the agent can do itself: sign in to a stand, type a password, run a command, open a page.
80
+ - The reply states a fact about the repository or a service — merged, pushed, green, exists, closed,
81
+ published — and no tool result of this turn shows it. A command output that shows the state counts,
82
+ whatever the command was. Each fact the reply names needs its own output: an edit of one file
83
+ does not show a second thing the reply says the branch holds. Before refusing for this, `Grep`
84
+ the transcript for the command that would show it: a match after the line of the owner's latest
85
+ word counts.
86
+ - The reply admits a miss of the agent («я ошибся», «мой промах», «это моя вина») and the turn wrote
87
+ no incident record into the directory named by the key `postmortems` of `.claude/rt-kit.json`:
88
+ `Glob` the directory; a file named with today's date counts.
89
+ - The owner asked to send a proposal to the rules package and the turn did not run
90
+ `agent-kit propose`.
91
+
92
+ ## How to answer
93
+
94
+ Answer with JSON only, no other text.
95
+
96
+ - Allow: `{"ok": true}`
97
+ - Refuse: `{"ok": false, "reason": "BLOCKED by turn-judge: <what is wrong, one sentence>. <the next action, one sentence>."}`
98
+
99
+ The reason starts with `BLOCKED by turn-judge:` every time: refusals are counted by this mark in the
100
+ transcripts. Write it in English, quote in « » the owner's words you rely on, and name one action
101
+ the agent can take in this same turn: the work the owner's word ordered, the step it asked the owner
102
+ to take, the command that shows the fact, the incident record, the sending of the proposal. Waiting
103
+ is never the action.
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
  # rt-hook: PostToolUse .*
3
- # Requires: hooks/profile-check.sh, hooks/deny-tail.sh
3
+ # Requires: checks/decide.mjs, hooks/decide.sh, hooks/facts.sh, hooks/profile-check.sh, hooks/deny-tail.sh
4
4
  # rt-hook: PreToolUse .*
5
5
  # Window fill: the session is brought to a logical point in advance, not cut off in the middle.
6
6
  #
@@ -88,7 +88,9 @@ tasks_dir="${RT_TASKS_DIR:-docs/tasks}"
88
88
  handoff_dir="${RT_HANDOFF_DIR:-.claude/handoff}"
89
89
 
90
90
  event="$(printf '%s' "$input" | jq -r '.hook_event_name // empty' 2>/dev/null)"
91
- transcript="$(printf '%s' "$input" | jq -r '.transcript_path // empty' 2>/dev/null)"
91
+ # shellcheck disable=SC1091
92
+ . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/facts.sh" 2>/dev/null
93
+ transcript="$(rt_fact_transcript "$input")"
92
94
  [ -n "$transcript" ] || exit 0
93
95
  [ -f "$transcript" ] || exit 0
94
96
 
@@ -98,14 +100,7 @@ transcript="$(printf '%s' "$input" | jq -r '.transcript_path // empty' 2>/dev/nu
98
100
  #
99
101
  # A tail of 200 lines: the session record grows all session, and one last line of it is what is
100
102
  # needed.
101
- fill="$(tail -n 200 "$transcript" 2>/dev/null | jq -s -r '
102
- [.[] | select(.type == "assistant") | .message.usage | select(. != null)]
103
- | last
104
- | if . == null then empty
105
- else ((.input_tokens // 0) + (.cache_creation_input_tokens // 0)
106
- + (.cache_read_input_tokens // 0) + (.output_tokens // 0))
107
- end
108
- ' 2>/dev/null)"
103
+ fill="$(rt_fact_window_fill "$transcript")"
109
104
 
110
105
  case "$fill" in
111
106
  '' | *[!0-9]*) exit 0 ;;
@@ -156,14 +151,21 @@ fi
156
151
  [ "$event" = "PreToolUse" ] || exit 0
157
152
  [ "$pct" -ge "$stop_pct" ] || exit 0
158
153
 
154
+ # A mark for the turn exit guard: past this threshold the next step of work is refused here, so
155
+ # the exit guard must not name it — the session closes by the progress and the handover.
156
+ stop_sid="$(printf '%s' "$input" | jq -r '.session_id // "unknown"' 2>/dev/null)"
157
+ stop_file="$(rt_fact_window_stop_file "$stop_sid")"
158
+ mkdir -p "$(dirname "$stop_file")" 2>/dev/null && : >"$stop_file" 2>/dev/null
159
+
159
160
  tool="$(rt_hook_tool)"
160
161
  path="$(rt_hook_file)"
161
162
  cmd="$(rt_hook_cmd)"
162
163
 
163
164
  allowed=0
164
165
  case "$tool" in
165
- # The conversation with the owner and reading what is edited at the closing.
166
- AskUserQuestion | TodoWrite | Read | SendUserFile)
166
+ # The conversation with the owner and reading what is edited at the closing. Loading a rule is
167
+ # reading too: the closing edits need their rules, and the rules gate refuses them until then.
168
+ AskUserQuestion | TodoWrite | Read | SendUserFile | Skill)
167
169
  allowed=1
168
170
  ;;
169
171
  Edit | Write | MultiEdit | mcp__webstorm__create_new_file)
@@ -184,33 +186,12 @@ esac
184
186
 
185
187
  [ "$allowed" -eq 1 ] && exit 0
186
188
 
187
- reason="BLOCKED by window-fill-guard: window fill ${pct}% (${fill_k}k of ${window_k}k), the stop threshold is ${stop_pct}%. The session works no further — it closes.
188
-
189
- What is left to do in this session:
190
- 1. Rewrite the section «Where we stand» in the progress and add a session entry — what was done, what confirms it, what did not work out.
191
- 2. Commit what is checked: what is not committed does not survive the break.
192
- 3. Write the handover into ${handoff_dir}/ and give the owner the path to it — what goes into it is said by the pattern task-flow-handoff.
193
-
194
- What passes after the threshold:
195
- - an edit of ${tasks_dir}/** and ${handoff_dir}/**, a read of any file, a question to the owner;
196
- - a command starting with a word of delivery or verification: git, the client of the hosting, moving a column, npm run check:*.
197
-
198
- A command is judged by the start of the line: entering a directory before it removes the match, and the very commit that would have passed without it is refused. Start the command with the word of delivery itself."
199
-
200
- # The shared deny tail: the two lawful moves and the lawful form of bypass, if the refusal has one.
201
- # The file may not be laid out — then there is no tail, and the reason for the refusal stays as it
202
- # was.
203
- # shellcheck disable=SC1090
204
- [ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
205
- && . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
206
- command -v rt_deny_tail >/dev/null 2>&1 || rt_deny_tail() { :; }
207
- deny_tail_text="$(rt_deny_tail "")"
208
- [ -n "$deny_tail_text" ] && reason="${reason}
209
-
210
- ${deny_tail_text}"
211
-
212
- jq -n --arg r "$reason" \
213
- '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:$r}}' 2>/dev/null \
214
- || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"window-fill-guard: the window is full, the session closes with a handover."}}\n'
215
-
189
+ # The decision, the move and the text come from the decision table; the action is the class of
190
+ # this call. The first named move is the progress edit, and the rules gate refuses it while the rule
191
+ # of the course of work is not loaded: that is the fact the table tells the two texts apart by.
192
+ facts="$(jq -cn --arg r "$(rt_fact_rule_loaded "${RT_TASK_FLOW_RULE:-task-flow}" "$stop_sid")" \
193
+ '{window_over_stop:"yes", rule_loaded:$r}')"
194
+ # shellcheck disable=SC1091
195
+ . "$rt_hooks_dir/decide.sh" 2>/dev/null
196
+ command -v rt_decide >/dev/null 2>&1 && rt_decide window-fill-guard.sh "?work_call" "$facts" '{}' PreToolUse "$input"
216
197
  exit 0
@@ -1,14 +1,14 @@
1
1
  ---
2
2
  name: git-workflow-commit
3
3
  kind: pattern
4
- rule: git-workflow
5
- description: Pattern of rule git-workflow. Load for creating a work item and a branch, commit and push — an item with area and iteration, state transition, merging two tasks into one, working as the machine account, skipping the document requirement. Opening a PR — pattern git-workflow-pr.
4
+ rule: git-workflow-push
5
+ description: Pattern of rule git-workflow-push. Load for creating a work item and a branch, commit and push — an item with area and iteration, state transition, merging two tasks into one, working as the machine account, skipping the document requirement. Opening a PR — pattern git-workflow-pr.
6
6
  ---
7
7
 
8
8
  # Task, branch and commit
9
9
 
10
10
  Pattern of the rule `git-workflow`. What must be true meanwhile — the law
11
- `docs/constitution/delivery.md`.
11
+ `docs/constitution/delivery.md`. Cold part: `pitfalls.md` — every section below whole, with its code and reasons.
12
12
 
13
13
  ## When to use
14
14
 
@@ -19,172 +19,26 @@ Pattern of the rule `git-workflow`. What must be true meanwhile — the law
19
19
 
20
20
  ## First the work item, then the branch
21
21
 
22
- Creation is four steps: the item, the number in its title, the assignee, the state `New`. Area and
23
- iteration are set right there: an item without them lies in the project root and does not reach
24
- the team board — created, but not in the work queue.
25
-
26
- All four are done by one tree command, not by hand: splitting them means forgetting the last.
27
-
28
- **A command that does not exist is not replaced by client calls in the pattern.** A tree that
29
- takes the package for the first time gets the check files, but not the entries about them in its
30
- manifest: the layout edits resources, and the consumer's manifest does not belong to it. Two ways
31
- from here: create the command in the same turn, or repeat all its steps by name from the list
32
- above. A bypass by client calls looks like execution up to the last step of the list: it is
33
- forgotten first, because the previous ones have already given a visible result.
34
-
35
- ```bash
36
- npm run task:new -- --title 'Письма владельцу не уходят молча' \
37
- --type Bug --area '<проект>\<команда>' --slug mail-owner-silence < описание.md
38
- ```
39
-
40
- The script under this command is created by the project — the package does not ship it. What it
41
- does by `az` calls:
42
-
43
- ```bash
44
- az boards work-item create --type Bug --title '[<номер>] …' \
45
- --org https://dev.azure.com/<организация> --project <проект> \
46
- --assigned-to <бот> --area '<проект>\<команда>' --iteration '<проект>\<итерация>'
47
- az boards work-item update --id <номер> --title '[<номер>] …' # the number is known after creation
48
- ```
49
-
50
- The number is not written into the title by hand — it is known only after creation, and the
51
- command appends it itself.
52
-
53
- Creation ends not with the command's output but with the work queue's answer. The command asks
54
- it itself and prints what it read — presence on the board, the state, the assignee; absence ends
55
- it with a non-zero code. That answer goes into the comment, the PR body and the plan, not the
56
- printed number: the number says "the call went through", not "the work is visible to whoever
57
- comes for it".
58
-
59
- Creations that go one after another are checked not by the last one but by an audit of the whole
60
- queue: their miss is shared, and by one item it is invisible.
61
-
62
- What to check the work queue with:
63
-
64
- ```bash
65
- npm run check:board
66
- ```
67
-
68
- It looks only at what is open: the state, the area and the assignee of every open item, and for
69
- every open PR — the number in the title, the attached item and that there is no second PR with
70
- the same number. It does not judge the branch name: an open PR cannot have it renamed.
22
+ Creation is four steps: the item, the number in its title, the assignee, the state `New`. Area and iteration are set right there: an item without them lies in the project root and does not reach the team board — created, but not in the work queue.
71
23
 
72
24
  ## Two tasks fixed by one edit
73
25
 
74
- If it turned out along the way that the edit closes the neighbouring item too — that is one task,
75
- not two. They can be merged while the edit has not reached the main branch:
76
-
77
- ```bash
78
- # what the absorbing item lacked is appended to its description
79
- az boards work-item update --id <поглотивший> --description "$(cat тело.md)"
80
- # the absorbed one is linked to it as a duplicate and closed
81
- az boards work-item relation add --id <поглощённый> --relation-type duplicate-of \
82
- --target-id <поглотивший>
83
- az boards work-item update --id <поглощённый> --state 'Removed'
84
- ```
85
-
86
- The link is set before closing: an item closed without it reads as done, and it was not done. The
87
- state of a removed item depends on the project process — `Removed` exists in Agile and Scrum, and
88
- Basic does not have it; which one is here, `implementation.md` says.
89
-
90
- After the branch is merged there is no absorbing: it went in, and it is reverted whole.
26
+ If it turned out along the way that the edit closes the neighbouring item too — that is one task, not two.
91
27
 
92
28
  ## The branch is created by a separate call
93
29
 
94
- The main branch guard parses the command text and looks at the branch at launch, so a compound
95
- command is rejected whole — the branch does not exist in it yet:
96
-
97
- ```bash
98
- ✗ git checkout -b 85-guest-token && git commit -m 'feat(admin): …'
99
- ✓ git checkout -b 85-guest-token <ветка эпика>
100
- ✓ git commit -F -
101
- ```
102
-
103
- The name carries the item number, the slug in lowercase Latin letters joined by hyphens; the exact
104
- form — in `implementation.md`. The delivery guard parses it on the spot and refuses a miss before
105
- the first commit, and by the number it asks the board: the item must exist, be open and have an
106
- assignee.
107
-
108
- A name without a number (`feat/…`, `fix/…`) is legitimate while the branch lives locally — for a
109
- trial and an analysis. No PR opens from it: an edit that reaches the main branch starts with a
110
- task.
111
-
112
30
  ## The item state moves together with the work
113
31
 
114
- Branch created — the item is no longer `New` but `Active`. PR opened — it awaits review. Both
115
- moves are done by one command, as a second call right after the one that caused it:
116
-
117
- ```bash
118
- npm run task:move -- 86 in-progress # right after git checkout -b 86-…
119
- npm run task:move -- 86 in-review # right after az repos pr create
120
- ```
121
-
122
- Under it — an edit of the state field:
123
-
124
- ```bash
125
- az boards work-item update --id 86 --state 'Active'
126
- ```
127
-
128
- State names are taken from the project process, not assigned by the rule: Agile, Scrum and Basic
129
- call the same three steps differently, and a move to a state the process does not have answers
130
- with a refusal on every task in a row.
131
-
132
- The move is not put off for later: the work queue is read between steps, not after them.
32
+ Branch created — the item is no longer `New` but `Active`. PR opened — it awaits review.
133
33
 
134
34
  ## The commit is signed by the machine account
135
35
 
136
- The token is read into a variable and not printed; author and committer are set by variables
137
- prefixed to `git commit` itself. `git config` will not do — the config is shared with the main tree
138
- and would rewrite the signature to the owner. `export` will not do either: it reaches every later
139
- command of the call, and a set before a push started by the same call runs the hook scenarios under
140
- the bot's mail — the ones comparing a mail fall on a sound tree:
141
-
142
- ```bash
143
- TOKEN=$(tr -d '\n' < ~/.config/<дерево>-bot-token)
144
-
145
- GIT_AUTHOR_NAME="<бот>" GIT_AUTHOR_EMAIL="<почта бота>" \
146
- GIT_COMMITTER_NAME="<бот>" GIT_COMMITTER_EMAIL="<почта бота>" \
147
- git commit -F -
148
- ```
149
-
150
- The subject — `type(scope): description`. Types: `feat`, `fix`, `refactor`, `docs`, `style`,
151
- `test`, `chore`, `perf`. Scopes are the tree's own, listed in `implementation.md`. A full stop
152
- at the end of the subject is not accepted. The letter case is checked as well, by the `subject-case` rule of the commit check: a word in capitals, such as a file name, can trip it, so the allowed case is read in the commit check settings before the subject is written.
153
-
154
- The line `AB#<номер>` in the commit body attaches it to the work item. It does not replace the
155
- attachment of the PR itself: the commit is linked to the item, and the work queue reads the PR's
156
- link.
36
+ The token is read into a variable and not printed; author and committer are set by variables prefixed to `git commit` itself. `git config` will not do — the config is shared with the main tree and would rewrite the signature to the owner.
157
37
 
158
38
  ## The document goes in the same commit
159
39
 
160
- `docs-guard` demands the pair and names it itself. The bypass — a line in the body, the reason
161
- is mandatory:
162
-
163
- ```
164
- Docs-skip: правка только в тестах хука, зеркала у него нет
165
- ```
166
-
167
- The guard looks for the `Docs-skip` line in the command text only. A message read from a file by
168
- `git commit -F <file>` is invisible to it and the commit is refused; the body goes inside the command,
169
- as in `git commit -F -` with the text after it.
40
+ `docs-guard` demands the pair and names it itself. The bypass — a line in the body, the reason is mandatory: The guard looks for the `Docs-skip` line in the command text only.
170
41
 
171
42
  ## Common misses
172
43
 
173
- - **An audit right after adding answers "no" when the card already stands.** The work queue gives
174
- out a new item not in the same second it was created, and the last step reads it by the next
175
- call. The answer to this is to reread the whole queue, not to create the card a second time: two
176
- records about one task are removed only by an administrator. The creation command itself needs
177
- an edit here: the state is read right after the mutation, without a retry, and a false refusal
178
- here costs more than a delay.
179
- - Area and iteration are not set: the item is created, but it did not reach the team board.
180
- - The state is not taken from the project process: the move answers with a refusal on every task,
181
- and this reads as a broken command, not as a wrong state name.
182
- - `git add` with several paths adds nothing if even one path does not exist: the command breaks
183
- off whole at the first miss. The next `git commit --amend` then carries into the commit
184
- everything left in the index. The commit contents are read by `git show --stat` right after it,
185
- not at PR review.
186
- - Two commits chained in one call: a commit refused by the message check leaves its files in the
187
- index, and the next `git commit` takes them under its own subject. One commit is one call, and
188
- its outcome is read before the next; a swallowed one is split by `git reset --soft HEAD~1` and two
189
- commits anew.
190
- - The owner's edit takes neither the token nor the variables — they are only for machine work.
44
+ - **An audit right after adding answers "no" when the card already stands.**