@rt-tools/agent-kit 0.37.1 → 0.39.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 (371) 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 +21432 -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 +135 -0
  14. package/assets/checks/flow-forecast.mjs +334 -0
  15. package/assets/checks/flow-guard-run.mjs +90 -0
  16. package/assets/checks/flow-guard.mjs +496 -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 +495 -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 +227 -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 +437 -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 +318 -0
  32. package/assets/checks/tree-assignment.mjs +26 -7
  33. package/assets/checks/work-result.mjs +362 -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 +23 -22
  40. package/assets/docs/GLOSSARY.md +5 -1
  41. package/assets/hooks/ask-judge.md +67 -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 +374 -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 +44 -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 +39 -6
  77. package/assets/hooks/git-guard-push-marks.sh +262 -13
  78. package/assets/hooks/git-guard-push-tests.sh +58 -52
  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 +40 -12
  88. package/assets/hooks/prose-style-guard.sh +6 -19
  89. package/assets/hooks/pull-merges.sh +76 -0
  90. package/assets/hooks/push-ahead-call-guard.sh +447 -0
  91. package/assets/hooks/push-set.sh +38 -8
  92. package/assets/hooks/qa-dataid-guard.sh +7 -17
  93. package/assets/hooks/record-turn.sh +52 -0
  94. package/assets/hooks/rerun-guard.sh +11 -16
  95. package/assets/hooks/reuse-first-guard.sh +7 -21
  96. package/assets/hooks/role-calls.sh +25 -3
  97. package/assets/hooks/rule-source-guard.sh +54 -21
  98. package/assets/hooks/skill-gate-rearm.sh +18 -5
  99. package/assets/hooks/skill-gate.sh +156 -20
  100. package/assets/hooks/skill-loaded.sh +18 -3
  101. package/assets/hooks/sql-guard-target.sh +2 -2
  102. package/assets/hooks/sql-guard-write.sh +12 -12
  103. package/assets/hooks/sql-guard.sh +58 -16
  104. package/assets/hooks/task-context-load.sh +3 -1
  105. package/assets/hooks/task-flow-context.sh +5 -18
  106. package/assets/hooks/task-flow-draft-guard.sh +25 -74
  107. package/assets/hooks/task-flow-guard.sh +28 -130
  108. package/assets/hooks/tree-assignment-guard.sh +25 -14
  109. package/assets/hooks/turn-entry-load.sh +3 -1
  110. package/assets/hooks/turn-exit-guard.sh +92 -452
  111. package/assets/hooks/turn-exit-role.sh +3 -1
  112. package/assets/hooks/turn-judge.md +113 -0
  113. package/assets/hooks/window-fill-guard.sh +22 -41
  114. package/assets/patterns/doc-style-human.md +36 -76
  115. package/assets/patterns/git-workflow-commit.azure.md +9 -155
  116. package/assets/patterns/git-workflow-commit.github.md +11 -269
  117. package/assets/patterns/git-workflow-commit.gitlab.md +9 -161
  118. package/assets/patterns/git-workflow-docker.md +8 -231
  119. package/assets/patterns/git-workflow-freshness.md +8 -56
  120. package/assets/patterns/git-workflow-merge.md +6 -176
  121. package/assets/patterns/git-workflow-migration.md +5 -75
  122. package/assets/patterns/git-workflow-pr-body.github.md +6 -159
  123. package/assets/patterns/git-workflow-pr-ready.md +9 -70
  124. package/assets/patterns/git-workflow-pr.azure.md +13 -285
  125. package/assets/patterns/git-workflow-pr.github.md +13 -251
  126. package/assets/patterns/git-workflow-pr.gitlab.md +13 -286
  127. package/assets/patterns/git-workflow-restart.md +5 -42
  128. package/assets/patterns/git-workflow-secrets.md +10 -76
  129. package/assets/patterns/git-workflow-stack.md +7 -207
  130. package/assets/patterns/status-report-table.github.md +1 -1
  131. package/assets/patterns/task-flow-archive.md +12 -233
  132. package/assets/patterns/task-flow-close.md +16 -292
  133. package/assets/patterns/task-flow-cycle.md +13 -39
  134. package/assets/patterns/task-flow-graph.needs-graph.md +8 -62
  135. package/assets/patterns/task-flow-handoff.md +13 -161
  136. package/assets/patterns/task-flow-resume.md +18 -218
  137. package/assets/patterns/task-flow-start.md +9 -247
  138. package/assets/patterns/turn-entry-map.md +2 -2
  139. package/assets/pitfalls/agent-kit-extend.md +200 -0
  140. package/assets/pitfalls/agent-kit.2.md +323 -0
  141. package/assets/pitfalls/angular-patterns.md +98 -0
  142. package/assets/pitfalls/browser-verification.md +265 -0
  143. package/assets/pitfalls/component-structure.md +98 -0
  144. package/assets/pitfalls/dependencies.md +92 -0
  145. package/assets/pitfalls/deploy-flow.azure.md +171 -0
  146. package/assets/pitfalls/deploy-flow.github.md +211 -0
  147. package/assets/pitfalls/deploy-flow.gitlab.md +173 -0
  148. package/assets/pitfalls/doc-style-human.md +112 -0
  149. package/assets/pitfalls/doc-style.2.md +286 -0
  150. package/assets/pitfalls/entity-conventions.needs-admin.md +96 -0
  151. package/assets/pitfalls/entity-models.md +89 -0
  152. package/assets/pitfalls/epic-flow.md +92 -0
  153. package/assets/pitfalls/git-workflow-commit.azure.md +190 -0
  154. package/assets/pitfalls/git-workflow-commit.github.md +307 -0
  155. package/assets/pitfalls/git-workflow-commit.gitlab.md +196 -0
  156. package/assets/pitfalls/git-workflow-docker.md +275 -0
  157. package/assets/pitfalls/git-workflow-freshness.md +88 -0
  158. package/assets/pitfalls/git-workflow-hosting.azure.md +31 -0
  159. package/assets/pitfalls/git-workflow-hosting.github.md +32 -0
  160. package/assets/pitfalls/git-workflow-hosting.gitlab.md +31 -0
  161. package/assets/pitfalls/git-workflow-merge.md +220 -0
  162. package/assets/pitfalls/git-workflow-migration.md +103 -0
  163. package/assets/pitfalls/git-workflow-pr-body.github.md +185 -0
  164. package/assets/pitfalls/git-workflow-pr-ready.md +104 -0
  165. package/assets/pitfalls/git-workflow-pr.2.azure.md +172 -0
  166. package/assets/pitfalls/git-workflow-pr.2.github.md +184 -0
  167. package/assets/pitfalls/git-workflow-pr.2.gitlab.md +180 -0
  168. package/assets/pitfalls/git-workflow-pr.azure.md +159 -0
  169. package/assets/pitfalls/git-workflow-pr.github.md +107 -0
  170. package/assets/pitfalls/git-workflow-pr.gitlab.md +151 -0
  171. package/assets/pitfalls/git-workflow-push.azure.md +30 -0
  172. package/assets/pitfalls/git-workflow-push.github.md +30 -0
  173. package/assets/pitfalls/git-workflow-push.gitlab.md +30 -0
  174. package/assets/pitfalls/git-workflow-queue.azure.md +30 -0
  175. package/assets/pitfalls/git-workflow-queue.github.md +30 -0
  176. package/assets/pitfalls/git-workflow-queue.gitlab.md +30 -0
  177. package/assets/pitfalls/git-workflow-restart.md +72 -0
  178. package/assets/pitfalls/git-workflow-secrets.md +114 -0
  179. package/assets/pitfalls/git-workflow-stack.md +254 -0
  180. package/assets/pitfalls/git-workflow.2.azure.md +291 -0
  181. package/assets/pitfalls/git-workflow.2.github.md +294 -0
  182. package/assets/pitfalls/git-workflow.2.gitlab.md +278 -0
  183. package/assets/pitfalls/lib-layers.md +114 -0
  184. package/assets/pitfalls/lists.md +117 -0
  185. package/assets/pitfalls/mockups.needs-mockups.md +87 -0
  186. package/assets/pitfalls/navigation.md +94 -0
  187. package/assets/pitfalls/observability.needs-app.md +186 -0
  188. package/assets/pitfalls/platform-access.md +94 -0
  189. package/assets/pitfalls/queue-audit.github.md +78 -0
  190. package/assets/pitfalls/reuse-first.md +201 -0
  191. package/assets/pitfalls/spec-driven.2.md +318 -0
  192. package/assets/pitfalls/styling-bem.2.md +125 -0
  193. package/assets/pitfalls/task-flow-archive.md +265 -0
  194. package/assets/pitfalls/task-flow-close.2.md +166 -0
  195. package/assets/pitfalls/task-flow-close.md +167 -0
  196. package/assets/pitfalls/task-flow-cycle.md +73 -0
  197. package/assets/pitfalls/task-flow-graph.needs-graph.md +98 -0
  198. package/assets/pitfalls/task-flow-handoff.md +200 -0
  199. package/assets/pitfalls/task-flow-handover.md +30 -0
  200. package/assets/pitfalls/task-flow-owner.md +58 -0
  201. package/assets/pitfalls/task-flow-plan.md +29 -0
  202. package/assets/pitfalls/task-flow-resume.md +257 -0
  203. package/assets/pitfalls/task-flow-start.md +287 -0
  204. package/assets/pitfalls/task-flow.2.md +303 -0
  205. package/assets/pitfalls/task-flow.md +4 -4
  206. package/assets/pitfalls/testing.2.md +279 -0
  207. package/assets/pitfalls/turn-conduct.md +16 -17
  208. package/assets/pitfalls/typescript-conventions.md +161 -0
  209. package/assets/pitfalls/write-a-skill.md +128 -0
  210. package/assets/rules/angular-patterns.md +21 -86
  211. package/assets/rules/autonomous-work.md +2 -2
  212. package/assets/rules/browser-verification.md +28 -256
  213. package/assets/rules/component-structure.md +25 -87
  214. package/assets/rules/dependencies.md +20 -78
  215. package/assets/rules/deploy-flow.azure.md +26 -156
  216. package/assets/rules/deploy-flow.github.md +34 -200
  217. package/assets/rules/deploy-flow.gitlab.md +27 -159
  218. package/assets/rules/doc-style.md +32 -286
  219. package/assets/rules/entity-conventions.needs-admin.md +26 -82
  220. package/assets/rules/entity-models.md +14 -63
  221. package/assets/rules/epic-flow.md +24 -63
  222. package/assets/rules/git-workflow-hosting.azure.md +26 -0
  223. package/assets/rules/git-workflow-hosting.github.md +38 -0
  224. package/assets/rules/git-workflow-hosting.gitlab.md +27 -0
  225. package/assets/rules/git-workflow-push.azure.md +28 -0
  226. package/assets/rules/git-workflow-push.github.md +28 -0
  227. package/assets/rules/git-workflow-push.gitlab.md +28 -0
  228. package/assets/rules/git-workflow-queue.azure.md +23 -0
  229. package/assets/rules/git-workflow-queue.github.md +30 -0
  230. package/assets/rules/git-workflow-queue.gitlab.md +23 -0
  231. package/assets/rules/git-workflow.azure.md +21 -282
  232. package/assets/rules/git-workflow.github.md +24 -284
  233. package/assets/rules/git-workflow.gitlab.md +21 -269
  234. package/assets/rules/lib-layers.md +30 -103
  235. package/assets/rules/lists.md +21 -105
  236. package/assets/rules/mockups.needs-mockups.md +25 -64
  237. package/assets/rules/navigation.md +10 -69
  238. package/assets/rules/observability.needs-app.md +43 -172
  239. package/assets/rules/platform-access.md +28 -75
  240. package/assets/rules/queue-audit.github.md +25 -52
  241. package/assets/rules/reuse-first.md +20 -195
  242. package/assets/rules/spec-driven.md +35 -308
  243. package/assets/rules/styling-bem.md +20 -117
  244. package/assets/rules/task-flow-handover.md +24 -0
  245. package/assets/rules/task-flow-owner.md +34 -0
  246. package/assets/rules/task-flow-plan.md +38 -0
  247. package/assets/rules/task-flow.md +22 -300
  248. package/assets/rules/testing.md +32 -273
  249. package/assets/rules/turn-conduct.md +105 -106
  250. package/assets/rules/turn-entry.md +2 -2
  251. package/assets/rules/typescript-conventions.md +41 -147
  252. package/assets/samples/tasks/_template/plan.md +30 -6
  253. package/assets/samples/tasks/_template/progress.md +0 -1
  254. package/assets/skills/agent-kit-extend.md +25 -168
  255. package/assets/skills/agent-kit.md +27 -299
  256. package/assets/skills/write-a-skill.md +20 -106
  257. package/assets/task-flow/flow.js +184 -0
  258. package/assets/task-flow/flow.md +101 -0
  259. package/assets/task-flow/measure/agreement.mjs +24 -0
  260. package/assets/task-flow/measure/ci.mjs +184 -0
  261. package/assets/task-flow/measure/copy.mjs +22 -0
  262. package/assets/task-flow/measure/epic-of.mjs +50 -0
  263. package/assets/task-flow/measure/epic-text.mjs +35 -0
  264. package/assets/task-flow/measure/epic.mjs +114 -0
  265. package/assets/task-flow/measure/folder.mjs +16 -0
  266. package/assets/task-flow/measure/footprint.mjs +28 -0
  267. package/assets/task-flow/measure/grill.mjs +21 -0
  268. package/assets/task-flow/measure/host.mjs +8 -0
  269. package/assets/task-flow/measure/owner.mjs +27 -0
  270. package/assets/task-flow/measure/plan.mjs +27 -0
  271. package/assets/task-flow/measure/pr.mjs +20 -0
  272. package/assets/task-flow/measure/progress.mjs +50 -0
  273. package/assets/task-flow/measure/session.mjs +252 -0
  274. package/assets/task-flow/measure/task.mjs +23 -0
  275. package/assets/task-flow/measure/text.mjs +77 -0
  276. package/assets/task-flow/source/git.mjs +254 -0
  277. package/assets/task-flow/source/host.mjs +277 -0
  278. package/assets/task-flow/source/marks.mjs +56 -0
  279. package/assets/task-flow/source/owner.mjs +94 -0
  280. package/assets/task-flow/source/records.mjs +116 -0
  281. package/assets/task-flow/source/session.mjs +269 -0
  282. package/assets/task-flow/source/steps.mjs +28 -0
  283. package/assets/task-flow/source/tree.mjs +42 -0
  284. package/bin/agent-kit.d.ts.map +1 -1
  285. package/bin/agent-kit.js +30 -0
  286. package/bin/agent-kit.js.map +1 -1
  287. package/lib/agent-checks.d.ts +55 -0
  288. package/lib/agent-checks.d.ts.map +1 -0
  289. package/lib/agent-checks.js +221 -0
  290. package/lib/agent-checks.js.map +1 -0
  291. package/lib/assets.d.ts.map +1 -1
  292. package/lib/assets.js +7 -2
  293. package/lib/assets.js.map +1 -1
  294. package/lib/cargo.d.ts +29 -0
  295. package/lib/cargo.d.ts.map +1 -1
  296. package/lib/cargo.js +27 -1
  297. package/lib/cargo.js.map +1 -1
  298. package/lib/cascade.d.ts.map +1 -1
  299. package/lib/cascade.js +3 -1
  300. package/lib/cascade.js.map +1 -1
  301. package/lib/commands.d.ts.map +1 -1
  302. package/lib/commands.js +78 -2
  303. package/lib/commands.js.map +1 -1
  304. package/lib/config.d.ts +18 -0
  305. package/lib/config.d.ts.map +1 -1
  306. package/lib/config.js +18 -1
  307. package/lib/config.js.map +1 -1
  308. package/lib/epic-window-send.d.ts +74 -0
  309. package/lib/epic-window-send.d.ts.map +1 -0
  310. package/lib/epic-window-send.js +166 -0
  311. package/lib/epic-window-send.js.map +1 -0
  312. package/lib/hooks-map.d.ts +4 -0
  313. package/lib/hooks-map.d.ts.map +1 -1
  314. package/lib/hooks-map.js +2 -2
  315. package/lib/hooks-map.js.map +1 -1
  316. package/lib/integrity.d.ts +3 -0
  317. package/lib/integrity.d.ts.map +1 -1
  318. package/lib/integrity.js +7 -0
  319. package/lib/integrity.js.map +1 -1
  320. package/lib/metric-lines.d.ts +2 -1
  321. package/lib/metric-lines.d.ts.map +1 -1
  322. package/lib/metric-lines.js +49 -1
  323. package/lib/metric-lines.js.map +1 -1
  324. package/lib/metric-send-mark.d.ts +6 -3
  325. package/lib/metric-send-mark.d.ts.map +1 -1
  326. package/lib/metric-send-mark.js +15 -5
  327. package/lib/metric-send-mark.js.map +1 -1
  328. package/lib/metric-send.d.ts +6 -2
  329. package/lib/metric-send.d.ts.map +1 -1
  330. package/lib/metric-send.js +47 -13
  331. package/lib/metric-send.js.map +1 -1
  332. package/lib/metrics.d.ts +17 -0
  333. package/lib/metrics.d.ts.map +1 -1
  334. package/lib/metrics.js +26 -15
  335. package/lib/metrics.js.map +1 -1
  336. package/lib/observations.js +3 -3
  337. package/lib/observations.js.map +1 -1
  338. package/lib/outcomes.d.ts +5 -2
  339. package/lib/outcomes.d.ts.map +1 -1
  340. package/lib/outcomes.js +5 -4
  341. package/lib/outcomes.js.map +1 -1
  342. package/lib/push-gate.d.ts +13 -0
  343. package/lib/push-gate.d.ts.map +1 -1
  344. package/lib/push-gate.js +11 -7
  345. package/lib/push-gate.js.map +1 -1
  346. package/lib/push-set-usefulness.d.ts +78 -0
  347. package/lib/push-set-usefulness.d.ts.map +1 -0
  348. package/lib/push-set-usefulness.js +225 -0
  349. package/lib/push-set-usefulness.js.map +1 -0
  350. package/lib/sync.d.ts +10 -0
  351. package/lib/sync.d.ts.map +1 -1
  352. package/lib/sync.js +14 -1
  353. package/lib/sync.js.map +1 -1
  354. package/lib/work-result.d.ts +43 -0
  355. package/lib/work-result.d.ts.map +1 -0
  356. package/lib/work-result.js +39 -0
  357. package/lib/work-result.js.map +1 -0
  358. package/package.json +1 -1
  359. package/assets/hooks/claim-guard.sh +0 -212
  360. package/assets/hooks/grill-gate-ask.sh +0 -26
  361. package/assets/hooks/grill-gate-bypass.sh +0 -61
  362. package/assets/hooks/grill-gate-options.sh +0 -50
  363. package/assets/hooks/grill-gate.sh +0 -482
  364. package/assets/hooks/postmortem-guard.sh +0 -124
  365. package/assets/hooks/proposal-guard.sh +0 -154
  366. package/assets/hooks/stand-login-guard.sh +0 -107
  367. package/assets/hooks/turn-exit-epic.sh +0 -173
  368. package/assets/hooks/turn-exit-patterns.sh +0 -123
  369. package/assets/hooks/turn-exit-verdict.sh +0 -149
  370. package/assets/hooks/waiting-turn-guard.sh +0 -320
  371. package/assets/hooks/work-start-guard.sh +0 -175
@@ -1,154 +0,0 @@
1
- #!/usr/bin/env bash
2
- # rt-hook: Stop
3
- # Requires: hooks/deny-tail.sh
4
- # Proposal guard: a turn in which the owner said to write or send a proposal to the rules layer
5
- # does not end until the sending has happened. Stop.
6
- #
7
- # Why this way. What is written and not sent lies in the tree indistinguishable from what was
8
- # sent: it has no record of its own in the rules layer, and the owner reads the work as done until
9
- # they ask directly. Sending is inconvenient in exactly one place — it writes marks into the
10
- # proposal files and makes the tree dirty — and with that argument the executor closes the
11
- # silence of the rules.
12
- #
13
- # The request is caught by samples, not by understanding the meaning: the appraisal "the owner
14
- # asked to send" would be assigned by whoever it hinders. The verb is mandatory: "go through the
15
- # proposals" is work on what has already arrived, and it does not end with sending. The word
16
- # "proposal" alone does not count either — it appears in every second turn about something else,
17
- # and next to it a word about the rules layer or about the package is needed.
18
- #
19
- # Sending is a call of the package command without a dry run, made in the same turn: a dry run
20
- # shows what would leave, creates nothing and leaves no trace outside.
21
- #
22
- # FAIL-OPEN: on any error, missing `jq`, missing turn transcript and a repeated pass, the turn is
23
- # ALLOWED (exit 0). A broken guard has no right to jam the conversation.
24
-
25
- # Its own name in the observations: the refusal is written by the shared deny tail, not by the
26
- # guard itself.
27
- RT_GUARD_NAME=proposal-guard
28
-
29
- . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
30
- . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
31
-
32
- rt_hook_read
33
- input="$RT_HOOK_INPUT"
34
- [ -z "$input" ] && exit 0
35
-
36
- command -v jq >/dev/null 2>&1 || exit 0
37
-
38
- # A repeated pass over the same turn is not judged: the guard has said its word once and lets go.
39
- active="$(printf '%s' "$input" | jq -r '.stop_hook_active // false' 2>/dev/null)"
40
- [ "$active" = "true" ] && exit 0
41
-
42
- transcript="$(printf '%s' "$input" | jq -r '.transcript_path // empty' 2>/dev/null)"
43
- [ -z "$transcript" ] && exit 0
44
- [ -f "$transcript" ] || exit 0
45
-
46
- # The proposals directory is the tree's own. Set to empty, it is the tree's opt-out from the
47
- # requirement: a tree that does not take the portable rules layer gets no guard imposed on it. No
48
- # directory on disk — the same: the tree does not use the mechanism, and the guard is not imposed
49
- # on it. Judging by one variable alone would demand sending where there is nothing to send with
50
- # and nowhere to send to.
51
- root="${CLAUDE_PROJECT_DIR:-.}"
52
- proposals_dir="${RT_PROPOSALS_DIR-.claude/rt-kit/proposals}"
53
- [ -z "$proposals_dir" ] && exit 0
54
- [ -d "$root/$proposals_dir" ] || exit 0
55
-
56
- # The owner's request. The set is open and grows by editing: its completeness is an open question
57
- # of the agreement, not a promise.
58
- #
59
- # Latin script is read on equal terms: a session the owner conducts in English differs from a
60
- # Russian one by its words, and the requirement in it is the same. It gets no branch of its own —
61
- # both pairs stand in one sample, otherwise one of them would be edited while the other is
62
- # forgotten.
63
- asked_re='(завед|напиш|отправ|пошл|зашл|отошл|выгруз|send|file|open|submit|raise|report)[а-яёa-z]*[^.!?]{0,40}(пропозал|предложени|proposal)|(пропозал|предложени|proposal)[а-яёa-z]*[^.!?]{0,40}(завед|напиш|отправ|пошл|зашл|отошл|выгруз|send|file|open|submit|raise|report)'
64
-
65
- # The neighbour without which the word "proposal" does not count as a request about the rules
66
- # layer.
67
- context_re='пропозал|слою правил|слоя правил|слой правил|пакет|agent-kit|наверх|proposal|rule layer|upstream|package'
68
-
69
- # A turn is everything recorded after the owner's last real input. A tool result arrives under
70
- # the same role, so lines with `tool_result` are not counted as input.
71
- #
72
- # A compaction summary is not input either, although it arrives under the owner's role and is not
73
- # a tool result. It retells turns that have already ended, and a request fulfilled yesterday reads
74
- # in it as said now: a turn in which not a word was said about proposals was refused on a retelling
75
- # of someone else's request — the proposals directory was empty at the time, and there was nothing
76
- # to send at all. By its words the summary is indistinguishable from the owner's speech and richer
77
- # than it, because it retells the whole session at once; it is recognised by a mark on the record,
78
- # not by the text.
79
- #
80
- # A 400-line tail: the transcript grows all session long, and only the last turn is judged.
81
- verdict="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r --arg asked "$asked_re" --arg ctx "$context_re" '
82
- # A report of a role and a loaded rule come in under the same role, marked `isMeta`: a role
83
- # that called its findings «proposal» woke the guard as if the owner had asked for a sending.
84
- def is_input:
85
- .type == "user"
86
- and ((.isCompactSummary // false) | not)
87
- and ((.isMeta // false) | not)
88
- and (((.message.content // []) | if type == "array"
89
- then ([.[] | select(.type == "tool_result")] | length)
90
- else 0 end) == 0);
91
-
92
- def text_of:
93
- (.message.content // []) | if type == "array"
94
- then ([.[] | select(.type == "text") | .text] | join("\n"))
95
- else (. // "") end;
96
-
97
- (map(is_input) | rindex(true)) as $i
98
- | (if $i == null then [] else .[$i:] end) as $turn
99
- | (if $i == null then "" else ($turn[0] | text_of) end) as $said
100
- | [$turn[] | select(.type == "assistant") | (.message.content // [])[] | select(.type == "tool_use")] as $uses
101
- # The sign is case-insensitive by a flag, not by lowercasing: lowercasing knows Latin script
102
- # only, and a capitalised "Send the Proposal" in Cyrillic would pass the sample set silently.
103
- | (($said | test($asked; "i")) and ($said | test($ctx; "i"))) as $wanted
104
- | ($uses | map(
105
- ((.name // "") | test("^Bash$"))
106
- and ((.input.command // "") | test("agent-kit[^|;&]*propose"))
107
- and ((.input.command // "") | test("--dry-run") | not)
108
- ) | any) as $sent
109
- | if $wanted and ($sent | not) then "owe" else "pass" end
110
- ' 2>/dev/null)"
111
-
112
- [ "$verdict" = "owe" ] || exit 0
113
-
114
- # The sending command is named as the one that runs in this tree. A tree that installed the
115
- # package as a dependency calls the binary from its dependencies; a tree where the package lives
116
- # as sources has no binary at all — there the built bin is called. A command named at random
117
- # costs the executor a turn: the refusal reads as an instruction, and a `npx agent-kit` call in
118
- # such a tree answers with an installation refusal.
119
- if [ -x "$root/node_modules/.bin/agent-kit" ]; then
120
- propose_cmd="npx agent-kit propose"
121
- else
122
- built="$(ls "$root"/dist/*/bin/agent-kit.js 2>/dev/null | head -1)"
123
- if [ -n "$built" ]; then
124
- propose_cmd="node ${built#"$root"/} propose"
125
- else
126
- propose_cmd="npx agent-kit propose"
127
- fi
128
- fi
129
-
130
- reason="BLOCKED by proposal-guard: the owner said to create or send a proposal to the rules layer, and no sending happened in this turn. What is written and not sent lies in the tree indistinguishable from what was sent: it has no record of its own in the rules layer, and the owner reads the work as done until they ask outright.
131
-
132
- A proposal is written as a file in \`$proposals_dir/\` and leaves in the same turn:
133
-
134
- $propose_cmd
135
-
136
- A dry run is not a sending: it shows what would have left and leaves no trace outward. The sending writes marks into the proposal files and makes the tree dirty — with an open PR they land as a second commit in the same branch, and that is their place, not a reason to postpone.
137
-
138
- The guard judges one turn: the next session is not refused."
139
-
140
- # The shared deny tail: the two lawful moves. The file may not be laid out — then there is no
141
- # tail, and the reason for the refusal stays the same.
142
- # shellcheck disable=SC1090
143
- [ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
144
- && . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
145
- command -v rt_deny_tail >/dev/null 2>&1 || rt_deny_tail() { :; }
146
- deny_tail_text="$(rt_deny_tail "")"
147
- [ -n "$deny_tail_text" ] && reason="${reason}
148
-
149
- ${deny_tail_text}"
150
-
151
- jq -n --arg r "$reason" '{decision:"block",reason:$r}' 2>/dev/null \
152
- || printf '{"decision":"block","reason":"proposal-guard: the owner asked for a proposal — send it by the command of the package."}\n'
153
-
154
- exit 0
@@ -1,107 +0,0 @@
1
- #!/usr/bin/env bash
2
- # rt-hook: Stop
3
- # Requires: hooks/deny-tail.sh
4
- # Guard of signing in to the stand. The Stop event. It does not let a turn end in which the executor
5
- # asks the owner to sign in to the stand or to type a password.
6
- #
7
- # Why. The stand, the sign-in and the accounts for checking are prepared by the agent. That demand
8
- # rested only on the executor's memory and did not hold: in one session the request "sign in
9
- # yourself" or "type the password" sounded four times in a row, each time with a new reason — the
10
- # field does not take input, a foreign extension is installed in the browser, the profile switched
11
- # off. The reason is real, so the request looks fitting; but the obstacle must be removed by the
12
- # agent all the same.
13
- #
14
- # The guard stands at the end of the turn, not at a tool call: the request is written as the text of
15
- # the reply, and until the turn ends it is not visible.
16
- #
17
- # The boundary. The guard checks a set of patterns: a verb of asking next to a word about a
18
- # password, a sign-in or a form. A request in other words, or through a menu of options, the guard
19
- # does not recognise. The set grows by an edit; its completeness is not guaranteed.
20
- #
21
- # What is allowed: asking to switch to the ordinary mode of work instead of the automatic one. The
22
- # typing is done by the agent, only the mode is asked of the owner — the guard tells these requests
23
- # apart.
24
- #
25
- # On an error the guard passes: on a failure, a missing turn record and a repeated call the turn is
26
- # ALLOWED. A broken guard must not block the conversation.
27
- #
28
- # FAIL-OPEN: no input, no jq, an already active turn — the turn ends as it did. A guard of the end
29
- # of a turn that refuses on doubt leaves the session with no lawful end at all.
30
-
31
- # The guard's name for the observations: it is written by the shared deny tail.
32
- RT_GUARD_NAME=stand-login-guard
33
-
34
- . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
35
- . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
36
-
37
- rt_hook_read
38
- input="$RT_HOOK_INPUT"
39
- [ -z "$input" ] && exit 0
40
-
41
- command -v jq >/dev/null 2>&1 || exit 0
42
-
43
- # A repeated call on the same turn is not judged: the guard says its refusal once.
44
- active="$(printf '%s' "$input" | jq -r '.stop_hook_active // false' 2>/dev/null)"
45
- [ "$active" = "true" ] && exit 0
46
-
47
- transcript="$(printf '%s' "$input" | jq -r '.transcript_path // empty' 2>/dev/null)"
48
- [ -z "$transcript" ] && exit 0
49
- [ -f "$transcript" ] || exit 0
50
-
51
- # The patterns of the request. The first group is a request to type instead of the agent, the
52
- # second a request to sign in oneself. A word about the mode of work is not in the set: asking for
53
- # it is allowed.
54
- asked_re='(введи|введите|набери|наберите|вбей|вбейте|заполни|заполните|подставь|вставь)[^.!?\n]{0,40}(пароль|учётн|учетн|логин|креды|форму входа)'
55
- asked_re="$asked_re"'|(войди|войдите|залогинься|залогиньтесь|авторизуйся|авторизуйтесь)[^.!?\n]{0,40}(сам|сами|рукой|руками|за меня|вместо меня|пожалуйста)?'
56
- asked_re="$asked_re"'|(нужно|надо|прошу)[^.!?\n]{0,20}(чтобы ты|чтобы вы)?[^.!?\n]{0,20}(ввёл|ввел|ввели|вошёл|вошел|вошли)[^.!?\n]{0,30}(пароль|вход|систему)'
57
-
58
- # The turn is everything recorded after the owner's last real input. A tool answer arrives under the
59
- # same role, so lines with `tool_result` do not count as input.
60
- #
61
- # The last 400 lines are read: the record grows all session long, and only the last turn is judged.
62
- verdict="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r --arg re "$asked_re" '
63
- def is_input:
64
- .type == "user"
65
- and ((.isCompactSummary // false) | not)
66
- and (((.message.content // []) | if type == "array"
67
- then ([.[] | select(.type == "tool_result")] | length)
68
- else 0 end) == 0);
69
-
70
- (map(is_input) | rindex(true)) as $i
71
- | (if $i == null then . else .[$i + 1:] end) as $turn
72
- | [$turn[] | select(.type == "assistant") | (.message.content // [])[] | select(.type == "text") | .text] as $texts
73
- # Case is ignored by a flag, not by lowercasing: lowercasing works only for the Latin alphabet,
74
- # and a request written with a capital letter would not match the pattern.
75
- | if (($texts | join("\n")) | test($re; "i")) then "asked" else "pass" end
76
- ' 2>/dev/null)"
77
-
78
- [ "$verdict" = "asked" ] || exit 0
79
-
80
- reason="BLOCKED by stand-login-guard: the executor asks the owner to sign in or to enter a password. The stand, the sign-in and the accounts for checking are prepared by the agent. An obstacle before the asking — a field that does not accept input, a foreign extension in the browser, a profile that dropped out — is removed by the agent.
81
-
82
- How to remove the obstacle by yourself:
83
-
84
- substitute the value by the form tool through a reference to the element
85
- switch off the interfering extension in the browser profile
86
- raise the stand on another address
87
- sign in with a pair from the seed of the local database instead of a production account
88
-
89
- What is asked of the owner is the mode of work, not input: the ordinary mode instead of the automatic one; the sign-in in it is done by the agent, and the automatic mode is returned by the same turn.
90
-
91
- The guard checks one turn: the next session is not blocked."
92
-
93
- # The shared deny tail: two lawful moves. The file may not be laid out — then there is no tail, and
94
- # the reason for the refusal stays.
95
- # shellcheck disable=SC1090
96
- [ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
97
- && . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
98
- command -v rt_deny_tail >/dev/null 2>&1 || rt_deny_tail() { :; }
99
- deny_tail_text="$(rt_deny_tail "")"
100
- [ -n "$deny_tail_text" ] && reason="${reason}
101
-
102
- ${deny_tail_text}"
103
-
104
- jq -n --arg r "$reason" '{decision:"block",reason:$r}' 2>/dev/null \
105
- || printf '{"decision":"block","reason":"stand-login-guard: the sign-in to the stand is done by the agent, not by the owner."}\n'
106
-
107
- exit 0
@@ -1,173 +0,0 @@
1
- #!/usr/bin/env bash
2
- # The tiers of the open epic for the turn-exit guard. NOT a guard: it has no `rt-hook:` declaration
3
- # and hooks into no agent event. The guard sources it right after the root of the tree is known.
4
- #
5
- # Why they live apart. Under an open epic a turn does not end by itself: the owner said it outright
6
- # — until the epic is closed the executor does not stop on its own. Two ends the guard used to
7
- # release are stops all the same: a turn that ended with work, and a second pass over the same turn.
8
- # The work stands where it stood, and the owner sees the executor standing still with the epic open.
9
- # The reading of the epic and the refusals about it lie here because the guard reached the file
10
- # length limit.
11
- #
12
- # The state of the epic is asked by the same command that prints the table for the owner, and only
13
- # on the way to a refusal: the call goes to the hosting and costs seconds. It is asked once per turn.
14
- #
15
- # FAIL-OPEN: no epic behind the branch, no table, no way to ask the hosting — the epic reads as not
16
- # open, and the guard works as it did before these tiers existed.
17
-
18
- # The unfinished tasks of the epic in one line; empty when the epic is over or cannot be read.
19
- rt_te_epic_left() {
20
- if [ -z "${rt_te_epic_asked:-}" ]; then
21
- rt_te_epic_asked=1
22
- rt_te_epic_left_cache=""
23
- rt_te_epic_read=""
24
- # shellcheck disable=SC1090
25
- if . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/epic-over.sh" 2>/dev/null \
26
- && command -v rt_epic_unfinished >/dev/null 2>&1; then
27
- rt_te_epic_raw="$(rt_epic_unfinished 2>/dev/null)" && rt_te_epic_read=1
28
- rt_te_epic_left_cache="$(printf '%s' "$rt_te_epic_raw" | tr -s '[:space:]' ' ' | sed 's/^ //; s/ $//')"
29
- fi
30
- fi
31
- printf '%s' "$rt_te_epic_left_cache"
32
- }
33
-
34
- # The standing word of the owner about a stop, quoted in « » in the line «Waiting for the owner» of
35
- # the progress. The guard reads their word, not a retelling: a line without a quote releases
36
- # nothing, and the quote holds until the owner rewrites the line. Expects `$progress` to be set.
37
- rt_te_owner_word_quoted() {
38
- [ -n "${progress:-}" ] || return 1
39
- local waiting
40
- # The first waiting line of the progress is read, in either language of the heading.
41
- waiting="$(sed -nE 's/^[[:space:]]*[-*][[:space:]]*\*\*(Waiting for the owner|Ждём владельца|Ждём от владельца):\*\*[[:space:]]*(.*)/\2/p' "$progress" 2>/dev/null | head -1)"
42
- # Three characters and more inside « » count as a word.
43
- printf '%s' "$waiting" | grep -q '«[^»]\{3,\}»' 2>/dev/null
44
- }
45
-
46
- # The epic is open: at least one of its tasks is left unfinished.
47
- rt_te_epic_open() {
48
- [ -n "$(rt_te_epic_left)" ]
49
- }
50
-
51
- # The epic is over: the table was read and printed not a single task. At that point the stop is
52
- # lawful — waiting for the word of the owner is the work itself — and the refusal releases the turn
53
- # whatever tier reached it. An epic that cannot be read — no table, the main branch, no way to ask
54
- # the hosting — is not over, and the turn is judged as before. Reads the same cache: one call per turn.
55
- rt_te_epic_over() {
56
- rt_te_epic_left >/dev/null
57
- [ -n "${rt_te_epic_read:-}" ] && [ -z "${rt_te_epic_left_cache:-}" ]
58
- }
59
-
60
- # The epic branch: named by the header line of an epic plan in the plans directory of the tree. It
61
- # has the shape of a task branch and by the rule carries no task folder, so the tier of the taken
62
- # task would read every turn on it as work taken and not begun. The plan is written by the command
63
- # that creates the epic and outlives the merge; the directory is named by the settings, `docs/plans`
64
- # by default. Expects `$root` and `$branch` to be set. FAIL-OPEN: no directory, no plan — not an
65
- # epic branch.
66
- rt_te_epic_branch() {
67
- [ -n "${root:-}" ] && [ -n "${branch:-}" ] || return 1
68
- local plans
69
- plans="$(jq -r ".plansDir // empty" "$root/.claude/rt-kit/checks.json" 2>/dev/null)"
70
- [ -n "$plans" ] || plans="docs/plans"
71
- [ -d "$root/$plans" ] || return 1
72
- grep -lE "^\\*\\*[^|]*\`$branch\`" "$root/$plans"/*.md 2>/dev/null | grep -q .
73
- }
74
-
75
- # The refusal of a stop under an open epic. The kind names what the turn ended with.
76
- rt_te_epic_deny() {
77
- local kind="$1" ended short
78
- case "$kind" in
79
- handed-by-hand)
80
- ended="the turn ended with a handover written by the hand of the executor, and no window guard refused in it"
81
- short="a handover by hand under an open epic."
82
- ;;
83
- *)
84
- ended="the turn ended with work, and the work stands where it stood"
85
- short="the turn ended with work under an open epic."
86
- ;;
87
- esac
88
- rt_te_deny "BLOCKED by turn-exit-guard: the epic is open — its unfinished tasks: $(rt_te_epic_left) — and ${ended}.
89
-
90
- Until the epic is closed the executor does not stop on its own: the owner said so outright. Under an open epic work handed over does not end a turn: the next task is worked on in it. A turn ends in three ways: a question to the owner through the question tool, when the work does not go without the answer; a refusal of a guard as the last action of the turn; the session handover written by the hook on window fill, or the refusal of the window guard. The word of the owner about stopping, quoted in the reply or in the line «Waiting for the owner», releases the guard as well. The end of the epic is a stop of its own: not one task of it is left.
91
-
92
- The next step is written in the progress: ${next_step}
93
-
94
- Do it in this same turn. The work of this task is done — take the next task of the epic. The owner said to stop — then write so: the guard reads their word, not a retelling.
95
-
96
- While the epic is open the guard judges every pass over the turn, not the first one alone." "$short"
97
- }
98
-
99
- # A question to the owner at the head of an empty turn in a running stage.
100
- rt_te_question_without_work_deny() {
101
- rt_te_deny "BLOCKED by turn-exit-guard: the work stands in the state 'этап-идёт', and the turn asked the owner without doing a single piece of the stage — neither an edit nor a command changing the tree.
102
-
103
- Waiting for one part of a stage is never a stop of the stage: the parts that do not depend on the answer are done in the same turn, and the question goes after them. A question at the head of an empty turn is a stop with a question attached.
104
-
105
- The next step is written in the progress: ${next_step}
106
-
107
- Do what does not depend on the answer in this same turn, then ask by the tool.
108
-
109
- The guard judges one turn: the next session is not refused." "a question without work in a running stage."
110
- }
111
-
112
- # The next step rewritten into the progress and not begun. The turn rewrote the progress, and after
113
- # that edit did nothing but commit and push it: the stage number moved, the report is full, and the
114
- # step the line names is untouched. Judged in a running stage alone; handed-in work has a tier of
115
- # its own. Expects the verdict signs and `$state` to be set.
116
- rt_te_next_step_deny() {
117
- [ "${progress_edited:-false}" = "true" ] || return 0
118
- [ "${after_progress:-false}" = "true" ] && return 0
119
- [ "${state:-}" = "этап-идёт" ] || return 0
120
- [ "${handed_over:-false}" = "true" ] && return 0
121
- rt_te_deny "BLOCKED by turn-exit-guard: the progress was rewritten in this turn, and after that edit the turn did nothing but commit and push it — the next step it names is not begun.
122
-
123
- The volume done before the line does not replace the step: a closed stage, a full report and a moved stage number are the shape of four stops in a row. A rewritten progress is a promise about the next action, and the turn that wrote it keeps it.
124
-
125
- The next step is written in the progress: ${next_step}
126
-
127
- Begin it in this same turn: an edit outside the task folder or a command changing the tree. The owner said to stop — then write so: the guard reads their word, not a retelling.
128
-
129
- The guard judges one turn: the next session is not refused." "the next step named by the progress is not begun."
130
- }
131
-
132
- # A launch in the background as the last action of the turn. A role sent to review, an exploration
133
- # sent to a subagent, a command sent behind the turn: none of them asks anything while it runs and
134
- # none goes faster for being waited on. A turn that ended on the launch stands exactly as long as an
135
- # empty one — the owner sees the executor standing still with the role working. The tier lives here
136
- # next to the state tiers because the guard file is at its length limit; it is not gated by the
137
- # epic. Expects the verdict signs to be set.
138
- rt_te_launch_last_deny() {
139
- [ "${launched_last:-false}" = "true" ] || return 0
140
- rt_te_deny "BLOCKED by turn-exit-guard: the last action of the turn was a launch in the background — a role or a command — and the turn ended on it.
141
-
142
- A launch is an announcement of intent, not work: what was sent goes on without the executor and asks nothing on the way. While it runs, what does not depend on it is done — the epic, the tasks, the branch, the next stage — and its findings are taken when they come back.
143
-
144
- The next step is written in the progress: ${next_step}
145
-
146
- Do it in this same turn; the launch may stand anywhere in the turn but last.
147
-
148
- The guard judges one turn: the next session is not refused." "the turn ended on a launch in the background."
149
- }
150
-
151
- # The state requirement after the folder is gone. It reads the history of the branch, as the tiers
152
- # above do, and lives here because the guard reached the file length limit.
153
- #
154
- # The same thing, but there is nothing left on disk to declare it with: the task folder is taken
155
- # apart before the PR opens, and the progress goes away with it. The sign is taken from the branch
156
- # history — the folder removed by its commit.
157
- #
158
- # A turn must not be released by that sign: the folder is removed BEFORE the PR, and between these
159
- # two movements the work is handed over to nobody. A turn caught in that gap used to leave here
160
- # with zero — and it was exactly one step short of the handover, and it did not make it. The sign
161
- # therefore only lifts the state requirement: from there the turn is judged by the second sign,
162
- # like any other. A turn in which the PR was opened or read passes the second sign by itself — it
163
- # counts a call of the hosting client as work.
164
- folder_archived() {
165
- [ -n "$branch" ] || return 1
166
- [ -n "$(git ls-tree -d --name-only HEAD -- "$tasks_dir/$branch" 2>/dev/null | head -1)" ] && return 1
167
- main_branch="${RT_MAIN_BRANCH:-main}"
168
- base="$(git merge-base "$main_branch" HEAD 2>/dev/null)"
169
- [ -z "$base" ] && return 1
170
- had="$(git ls-tree -d --name-only "$base" -- "$tasks_dir/$branch" 2>/dev/null | head -1)"
171
- [ -z "$had" ] && had="$(git log "$base..HEAD" --diff-filter=A --name-only --pretty=format: -- "$tasks_dir/$branch" 2>/dev/null | head -1)"
172
- [ -n "$had" ]
173
- }
@@ -1,123 +0,0 @@
1
- #!/usr/bin/env bash
2
- # The patterns of the turn-exit guard. NOT a guard: it has no `rt-hook:` declaration and hooks into
3
- # no agent event. The turn-exit guard sources it — the same way guards source the shared reading of
4
- # the input and the deny tail. It was moved out when the guard outgrew the file length limit: the
5
- # patterns and the reasons beside them read apart from the tiers that apply them.
6
- #
7
- # Every pattern is a shell variable; the guard passes them as arguments to the parsing of the turn
8
- # record.
9
-
10
- # A command that changes the tree or its state. Reading and searching are deliberately not included
11
- # here: they are exactly what a stalled turn is filled with.
12
- #
13
- # Output redirection is not here, and it was taken out after an analysis: the guard refused two
14
- # turns out of the seven that stood without work, and counted five as work by that very sign. The
15
- # body of a future PR was written into the session's temporary directory — outside the working tree
16
- # — and one of the waits carried only a diversion of the error stream into the null device. Neither
17
- # of the two changes the tree, and to the pattern they were indistinguishable from writing to a
18
- # working file: it saw the arrow itself and did not ask where it led. What stays as the sign is an
19
- # edit of a file by the editing tool and the commands listed here.
20
- work_re='git (add|commit|push|checkout|merge|rm)|npm run|pnpm (run|exec)|nx (build|test|run)|gh (pr|issue|api|run)|glab (mr|ci|issue|api)|task:(new|move)|mkdir|cp |mv |rm |sed -i|tee '
21
-
22
- # Exploration. The same words as in the work pattern, but the subcommand is a reading one:
23
- # switching a branch, pulling, looking through the history, reading PRs and runs. The work pattern
24
- # calls them work, because it knows only the first word — `git` and `gh` stand in it whole — and a
25
- # turn in which the executor switched to the main branch, read the history and wrote the owner a
26
- # report left here with a zero. The analysis is the record
27
- # "2026-08-25-read-only-turn-counted-as-work" in the intake.
28
- #
29
- # Exploration looks like work better than anything else: it has commands, numbers and exact answers.
30
- # That is what makes it dangerous — a turn stuffed with it reads as full both to the owner and to
31
- # the session itself.
32
- read_re='^[[:space:]]*(([^[:space:]]*/)?git[[:space:]]+(show|log|ls-tree|ls-files|ls-remote|diff|status|branch|tag|rev-parse|remote|describe|blame|fetch|pull|(checkout|switch)(?!([[:space:]]+-[A-Za-z-]+)*[[:space:]]+-[bc][[:space:]]))|([^[:space:]]*/)?gh[[:space:]]+(pr|issue|run|repo)[[:space:]]+(list|view|status|checks|diff|download|logs)|([^[:space:]]*/)?glab[[:space:]]+(mr|issue|ci|repo)[[:space:]]+(list|view|status|diff|trace|get))([[:space:]]|$)'
33
-
34
- # The parts of a compound command are judged one by one: a turn gathers reading and work into one
35
- # line through `&&`, and judging it whole would release exploration on the very first changing part.
36
- part_re='&&|\|\||;|\n'
37
-
38
- # Waiting for someone else's step. A run, the owner's review and a merge go on without the executor
39
- # and do not get faster from being looked at — the rule says outright that this is never a work
40
- # state. Only the LAST action of the turn is judged: waiting in the middle is lawful, and starting
41
- # work in the background stays work. The analysis is the record "2026-08-25-turn-ended-on-waiting"
42
- # in the intake.
43
- #
44
- # The former sign asked one thing: was there work during the turn. A turn where a conflict was
45
- # resolved, a commit and a push were made, and the last action became a loop until the run was ready
46
- # passed it whole — there was work, and plenty. It is exactly that fullness that deceives: the
47
- # emptiness behind such a turn is not visible.
48
- # Two more kinds of last action were added after an analysis. The first is a run of the checks
49
- # started in the background: the guard is given the background sign appended to the command, and on
50
- # the foreground the same command stays work — it holds the turn to its own end. The second is a
51
- # read of a background task's log: the run was started, the log was read, a report was written, and
52
- # the tree did not change by a single sign; such a turn stands exactly as long as an empty one.
53
- wait_re='gh[[:space:]]+(run[[:space:]]+watch|pr[[:space:]]+checks[^|]*--watch)|until[[:space:]].*sleep|while[[:space:]].*sleep|^[[:space:]]*sleep[[:space:]]|(nx[[:space:]]+(affected|run-many|test|build|lint|e2e)|npm[[:space:]]+run[[:space:]]+(lint|test|check:|e2e)|pnpm[[:space:]]+run|playwright[[:space:]]+test|vitest|jest|bash[[:space:]].*tests?/)[^&]*&[[:space:]]*$|(cat|tail|head|less|grep)[^|]*\.(log|output)([[:space:]]|$)|tasks/[A-Za-z0-9]+\.output'
54
-
55
- # A promise to do the work in the next turn. The same announcement of intent as a command named and
56
- # not run, only it sounds politer and is therefore recognised as a stop less often. An offer to the
57
- # owner to object to the announced intent is part of the promise, not a question: a turn ends with a
58
- # question when the work does not go without the answer, and here it did go.
59
- promise_re='следующим ходом|в следующий раз|дальше возьму|дальше допишу|допишу остальн|доделаю остальн|доделаю в следующ|продолжу в следующ|беру[^.]{0,40}следующим|возьму[^.]{0,40}следующим'
60
-
61
- # The owner's standing word to work without stops. It holds until they cancel it, and a turn that
62
- # ended with waiting for their word invents that cancellation. Without this the word about a stop
63
- # was read out of it by the piece «останов» in «без остановок» — the instruction to work was taken
64
- # for its opposite.
65
- standing_work_re='работай[^.]{0,40}(без остановок|без пауз|сам)|не останавливайся|продолжай[^.]{0,40}(без остановок|без пауз)|работай дальше'
66
-
67
- # Handing work over and starting the next. The rule calls handed-over work a lawful end of a turn —
68
- # but on a condition: the next one is started, and an ACTION has been done on it, not spoken.
69
- # The GitLab client opens a merge request — the same handing over.
70
- handover_re='gh[[:space:]]+pr[[:space:]]+create|glab[^|;&]*mr[[:space:]]+create'
71
- started_re='task:new|task:move|board\.mjs[[:space:]]+move|git[[:space:]]+checkout([[:space:]]+-[A-Za-z-]+)*[[:space:]]+-b|git[[:space:]]+switch([[:space:]]+-[A-Za-z-]+)*[[:space:]]+-c'
72
-
73
- # How many steps of the plan are not done yet. The progress mirrors the steps of the plan with a
74
- # mark each — `[x]` done, `[>]` going on right now, `[ ]` not begun — and a check keeps the two
75
- # lists matched. The reading is a local file, not a call to the hosting: it costs nothing and is
76
- # asked on every turn, unlike the state of the epic.
77
- #
78
- # Prints the number and answers non-zero when there is nothing to read: no progress, or a progress
79
- # with no list of steps. A tier that REFUSES a turn must tell "the work goes on" from "there is
80
- # nothing to ask with" — the same reason the count of the epic's tasks is printed rather than folded
81
- # into an exit code.
82
- rt_te_steps_left() {
83
- [ -f "$1" ] || return 1
84
- grep -qE '^-[[:space:]]+\[[x> ]\][[:space:]]+[0-9]+\.[0-9]+[[:space:]]' "$1" 2>/dev/null || return 1
85
- printf '%s' "$(grep -cE '^-[[:space:]]+\[[> ]\][[:space:]]+[0-9]+\.[0-9]+[[:space:]]' "$1" 2>/dev/null || printf '0')"
86
- return 0
87
- }
88
-
89
- # The step going on right now: its number and its name, as the progress writes them. Empty when no
90
- # step carries the mark — the refusal then names the count alone.
91
- rt_te_step_now() {
92
- [ -f "$1" ] || return 0
93
- sed -nE 's/^-[[:space:]]+\[>\][[:space:]]+([0-9]+\.[0-9]+[[:space:]]+.*)$/\1/p' "$1" 2>/dev/null | head -1
94
- }
95
-
96
- # The refusal about a step that is not done. The text lies here and not in the guard for the same
97
- # reason as the one about the epic: the guard stands at its length limit.
98
- #
99
- # Why the tier exists. The tier about the epic judges the whole: while the epic holds tasks, a turn
100
- # does not end. It says nothing about a turn inside one task — the epic may hold a single task, and
101
- # the work inside it breaks off in the middle all the same. The stage tier next to it reads the
102
- # «Verified by» command of a stage declared closed, and a stage nobody declared closed it does not
103
- # touch either.
104
- rt_te_steps_reason() {
105
- printf '%s' "BLOCKED by turn-exit-guard: ${1} steps of the plan are not done, and the turn ends without the word of the owner about stopping.
106
-
107
- The step going on right now: ${2:-none is marked as going on}
108
-
109
- Work is not finished while the plan holds steps that are not done. A turn that did work and then reported is no exception: the report ends the account, not the work.
110
-
111
- The steps are listed in the progress and counted by «npm run check:work-steps»; the plan holds the same list and is not edited.
112
-
113
- Do them in this same turn. Lawful exits stay as they were: a question to the owner through the tool, a refusal of another guard, a session handover, and the owner's own word about stopping — the guard reads that word from them, not from a retelling."
114
- }
115
-
116
- # The tier itself: the steps of the plan are not done. It lies here and not in the guard for the
117
- # same reason as the text above — the guard stands at its length limit. The tier judges the
118
- # progress of the current task and says nothing about the epic: the tier next to it does that.
119
- rt_te_steps_deny() {
120
- _steps_left="$(rt_te_steps_left "$1" 2>/dev/null)" || return 0
121
- [ "${_steps_left:-0}" -gt 0 ] 2>/dev/null || return 0
122
- rt_te_deny "$(rt_te_steps_reason "$_steps_left" "$(rt_te_step_now "$1")")" "${_steps_left} steps of the plan are not done."
123
- }