@rt-tools/agent-kit 0.24.0 → 0.27.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 (312) hide show
  1. package/assets/agents/business-analyst.md +51 -50
  2. package/assets/agents/cargo-writer.md +54 -0
  3. package/assets/agents/conscience.md +37 -35
  4. package/assets/agents/project-manager.md +49 -48
  5. package/assets/agents/prose-editor.md +31 -29
  6. package/assets/agents/qa-engineer.md +50 -48
  7. package/assets/agents/rules-reviewer.md +63 -58
  8. package/assets/agents/skill-curator.md +83 -78
  9. package/assets/agents/spec-critic.md +34 -29
  10. package/assets/agents/spec-writer.md +35 -32
  11. package/assets/agents/strict-teacher.md +39 -37
  12. package/assets/checks/archive-age.mjs +48 -28
  13. package/assets/checks/archive-prune.mjs +16 -14
  14. package/assets/checks/board-epic-link.github.mjs +29 -0
  15. package/assets/checks/board-epics.github.mjs +286 -49
  16. package/assets/checks/board-folders.mjs +61 -0
  17. package/assets/checks/board-gh.github.mjs +35 -26
  18. package/assets/checks/board-long-work.github.mjs +29 -25
  19. package/assets/checks/board-paths.github.mjs +21 -16
  20. package/assets/checks/board-pull-state.github.mjs +168 -0
  21. package/assets/checks/board-runs.github.mjs +45 -43
  22. package/assets/checks/board-task-dirs.github.mjs +98 -0
  23. package/assets/checks/board-titles.github.mjs +19 -17
  24. package/assets/checks/board.github.mjs +133 -194
  25. package/assets/checks/check-archive-age.mjs +23 -19
  26. package/assets/checks/check-board.github.mjs +131 -263
  27. package/assets/checks/check-descriptions.mjs +30 -29
  28. package/assets/checks/check-doc-paths.mjs +91 -88
  29. package/assets/checks/check-dupes.mjs +84 -80
  30. package/assets/checks/check-file-size.mjs +74 -71
  31. package/assets/checks/check-glossary.mjs +47 -37
  32. package/assets/checks/check-hook-scope.mjs +30 -27
  33. package/assets/checks/check-lib-layers.mjs +22 -21
  34. package/assets/checks/check-profile-drift.mjs +48 -43
  35. package/assets/checks/check-prose-style.mjs +138 -39
  36. package/assets/checks/check-push-gate.mjs +53 -50
  37. package/assets/checks/check-reuse.mjs +50 -40
  38. package/assets/checks/check-schema-drift.mjs +104 -84
  39. package/assets/checks/check-specs.mjs +155 -134
  40. package/assets/checks/check-state-next.mjs +66 -52
  41. package/assets/checks/check-states.mjs +32 -30
  42. package/assets/checks/check-styles.mjs +52 -51
  43. package/assets/checks/check-turn-map.mjs +54 -46
  44. package/assets/checks/epic-table.github.mjs +268 -0
  45. package/assets/checks/lib-boundaries.mjs +32 -30
  46. package/assets/checks/lib-common.mjs +30 -29
  47. package/assets/checks/lib-domains.mjs +34 -34
  48. package/assets/checks/lib-manifests.mjs +17 -15
  49. package/assets/checks/lib-reexports.mjs +18 -18
  50. package/assets/checks/rt-kit-checks.config.mjs +187 -142
  51. package/assets/checks/signals.mjs +43 -39
  52. package/assets/checks/spec-anchors.mjs +114 -87
  53. package/assets/checks/spec-common.mjs +128 -84
  54. package/assets/checks/spec-contract.mjs +30 -30
  55. package/assets/checks/spec-proposed.mjs +27 -24
  56. package/assets/checks/spec-scenarios.mjs +51 -28
  57. package/assets/checks/specs-for.mjs +214 -0
  58. package/assets/checks/task-new.github.mjs +315 -61
  59. package/assets/commands/feedback.md +65 -59
  60. package/assets/commands/next-session.md +64 -57
  61. package/assets/commands/night.md +115 -0
  62. package/assets/commands/skill-curator.md +83 -79
  63. package/assets/defaults/gate-map.sh +108 -97
  64. package/assets/defaults/project.sh +232 -185
  65. package/assets/defaults/shell.sh +73 -68
  66. package/assets/defaults/turn-map.md +47 -44
  67. package/assets/docs/GLOSSARY.md +142 -65
  68. package/assets/hooks/browser-device-id.sh +16 -12
  69. package/assets/hooks/browser-guard-device-id.sh +34 -28
  70. package/assets/hooks/browser-guard-no-asking.sh +5 -4
  71. package/assets/hooks/browser-guard-no-listing.sh +12 -11
  72. package/assets/hooks/browser-guard-no-other-drivers.sh +48 -42
  73. package/assets/hooks/browser-guard-require-select.sh +34 -23
  74. package/assets/hooks/claim-guard.sh +62 -56
  75. package/assets/hooks/commit-msg.sh +14 -10
  76. package/assets/hooks/conscience-guard.sh +91 -45
  77. package/assets/hooks/constitution-index.sh +16 -16
  78. package/assets/hooks/deny-tail.sh +28 -26
  79. package/assets/hooks/dev-server-guard.sh +50 -43
  80. package/assets/hooks/dispatch.sh +60 -46
  81. package/assets/hooks/docs-guard.sh +100 -91
  82. package/assets/hooks/epic-over.sh +49 -0
  83. package/assets/hooks/epic-stop-guard.sh +108 -0
  84. package/assets/hooks/exam-guard.sh +105 -93
  85. package/assets/hooks/git-guard-delivery-conflict.sh +41 -36
  86. package/assets/hooks/git-guard-delivery-draft.sh +48 -38
  87. package/assets/hooks/git-guard-delivery-epic.sh +167 -0
  88. package/assets/hooks/git-guard-delivery-folder.sh +50 -43
  89. package/assets/hooks/git-guard-delivery-signature.sh +119 -53
  90. package/assets/hooks/git-guard-delivery.sh +223 -183
  91. package/assets/hooks/git-guard-main.sh +38 -34
  92. package/assets/hooks/git-guard-push-tests.sh +99 -87
  93. package/assets/hooks/glossary-load.sh +23 -22
  94. package/assets/hooks/grill-gate-ask.sh +12 -11
  95. package/assets/hooks/grill-gate.sh +94 -87
  96. package/assets/hooks/guard-note.sh +20 -19
  97. package/assets/hooks/handoff-entry-guard.sh +45 -25
  98. package/assets/hooks/handoff-write.sh +74 -67
  99. package/assets/hooks/hook-input.sh +67 -58
  100. package/assets/hooks/lint-after-edit.sh +95 -61
  101. package/assets/hooks/observe.sh +28 -26
  102. package/assets/hooks/override-write-guard.sh +23 -21
  103. package/assets/hooks/postmortem-guard.sh +42 -39
  104. package/assets/hooks/profile-check.sh +22 -20
  105. package/assets/hooks/proposal-guard.sh +57 -49
  106. package/assets/hooks/prose-style-guard.sh +49 -24
  107. package/assets/hooks/qa-dataid-guard.sh +83 -58
  108. package/assets/hooks/rerun-guard.sh +31 -30
  109. package/assets/hooks/reuse-first-guard.sh +108 -87
  110. package/assets/hooks/roles.sh +14 -14
  111. package/assets/hooks/rule-article.sh +39 -34
  112. package/assets/hooks/rule-source-guard.sh +47 -42
  113. package/assets/hooks/skill-gate-layers.sh +63 -57
  114. package/assets/hooks/skill-gate-rearm.sh +15 -8
  115. package/assets/hooks/skill-gate.sh +89 -81
  116. package/assets/hooks/skill-loaded.sh +10 -6
  117. package/assets/hooks/sql-guard-parse.sh +71 -66
  118. package/assets/hooks/sql-guard-request.sh +51 -46
  119. package/assets/hooks/sql-guard-target.sh +60 -51
  120. package/assets/hooks/sql-guard-write.sh +87 -79
  121. package/assets/hooks/sql-guard.sh +52 -47
  122. package/assets/hooks/stand-login-guard.sh +43 -37
  123. package/assets/hooks/task-context-load.sh +60 -55
  124. package/assets/hooks/task-flow-context.sh +87 -69
  125. package/assets/hooks/task-flow-draft-guard.sh +55 -48
  126. package/assets/hooks/task-flow-guard.sh +67 -64
  127. package/assets/hooks/turn-entry-load.sh +39 -32
  128. package/assets/hooks/turn-exit-guard.sh +260 -204
  129. package/assets/hooks/turn-exit-patterns.sh +63 -0
  130. package/assets/hooks/utf8.sh +14 -11
  131. package/assets/hooks/waiting-turn-guard.sh +104 -94
  132. package/assets/hooks/window-fill-guard.sh +70 -62
  133. package/assets/hooks/work-start-guard.sh +52 -49
  134. package/assets/hooks/write-targets.sh +99 -44
  135. package/assets/laws/autonomous-work.md +29 -27
  136. package/assets/laws/code-structure.md +31 -30
  137. package/assets/laws/delivery.md +170 -137
  138. package/assets/laws/entity-editing.md +52 -50
  139. package/assets/laws/entity-models.md +14 -13
  140. package/assets/laws/frontend-application.md +39 -38
  141. package/assets/laws/lib-imports.md +27 -27
  142. package/assets/laws/lists.md +31 -29
  143. package/assets/laws/navigation.md +37 -37
  144. package/assets/laws/observability.md +41 -40
  145. package/assets/laws/project-documentation.md +106 -99
  146. package/assets/laws/reuse-first.md +31 -29
  147. package/assets/laws/shared-code.md +27 -27
  148. package/assets/laws/verifiability.md +131 -124
  149. package/assets/laws/work-conduct.md +250 -244
  150. package/assets/patterns/admin-lists-screen.md +72 -69
  151. package/assets/patterns/admin-nav-item.md +51 -46
  152. package/assets/patterns/angular-patterns-state.md +32 -31
  153. package/assets/patterns/api-layer-pair.md +33 -31
  154. package/assets/patterns/autonomous-work-run.md +50 -49
  155. package/assets/patterns/browser-verification-measure.md +124 -88
  156. package/assets/patterns/browser-verification-stand.md +169 -157
  157. package/assets/patterns/component-structure-new.md +51 -42
  158. package/assets/patterns/dependencies-upgrade.md +55 -39
  159. package/assets/patterns/doc-style-human.md +55 -37
  160. package/assets/patterns/doc-style-sweep.md +82 -79
  161. package/assets/patterns/doc-style-trace.md +87 -81
  162. package/assets/patterns/doc-style-write.md +130 -122
  163. package/assets/patterns/entity-aside.md +77 -63
  164. package/assets/patterns/entity-models-new.md +37 -37
  165. package/assets/patterns/entity-store.md +33 -33
  166. package/assets/patterns/git-workflow-commit.azure.md +94 -87
  167. package/assets/patterns/git-workflow-commit.github.md +160 -142
  168. package/assets/patterns/git-workflow-commit.gitlab.md +96 -90
  169. package/assets/patterns/git-workflow-docker.md +165 -147
  170. package/assets/patterns/git-workflow-freshness.md +45 -45
  171. package/assets/patterns/git-workflow-merge.md +102 -94
  172. package/assets/patterns/git-workflow-migration.md +54 -52
  173. package/assets/patterns/git-workflow-pr-ready.md +57 -56
  174. package/assets/patterns/git-workflow-pr.azure.md +127 -122
  175. package/assets/patterns/git-workflow-pr.github.md +186 -177
  176. package/assets/patterns/git-workflow-pr.gitlab.md +139 -132
  177. package/assets/patterns/git-workflow-restart.md +35 -31
  178. package/assets/patterns/git-workflow-secrets.md +80 -73
  179. package/assets/patterns/git-workflow-stack.md +136 -107
  180. package/assets/patterns/lib-layers-move.md +62 -53
  181. package/assets/patterns/lib-layers-new.md +59 -45
  182. package/assets/patterns/observability-record.md +72 -67
  183. package/assets/patterns/platform-access-di.md +31 -29
  184. package/assets/patterns/reuse-first-extend.md +66 -61
  185. package/assets/patterns/shared-code-new.md +39 -38
  186. package/assets/patterns/spec-driven-domain.md +161 -151
  187. package/assets/patterns/spec-driven-rule.md +179 -168
  188. package/assets/patterns/spec-driven-sweep.md +41 -39
  189. package/assets/patterns/status-report-table.github.md +48 -36
  190. package/assets/patterns/styling-bem-component.md +42 -42
  191. package/assets/patterns/styling-bem-layout.md +39 -34
  192. package/assets/patterns/styling-bem-sheet.md +59 -58
  193. package/assets/patterns/task-flow-archive.md +222 -215
  194. package/assets/patterns/task-flow-close.md +234 -203
  195. package/assets/patterns/task-flow-handoff.md +154 -145
  196. package/assets/patterns/task-flow-resume.md +138 -133
  197. package/assets/patterns/task-flow-start.md +228 -202
  198. package/assets/patterns/testing-e2e.md +102 -101
  199. package/assets/patterns/testing-unit.md +77 -70
  200. package/assets/patterns/ts-procedure.md +32 -29
  201. package/assets/patterns/turn-entry-map.md +50 -48
  202. package/assets/pitfalls/agent-kit.md +172 -142
  203. package/assets/pitfalls/doc-style.md +96 -91
  204. package/assets/pitfalls/git-workflow.azure.md +49 -46
  205. package/assets/pitfalls/git-workflow.github.md +270 -234
  206. package/assets/pitfalls/git-workflow.gitlab.md +49 -45
  207. package/assets/pitfalls/spec-driven.md +73 -71
  208. package/assets/pitfalls/styling-bem.md +46 -40
  209. package/assets/pitfalls/task-flow.md +262 -246
  210. package/assets/pitfalls/testing.md +99 -92
  211. package/assets/pitfalls/turn-conduct.md +96 -81
  212. package/assets/rules/angular-patterns.md +81 -80
  213. package/assets/rules/api-layer.md +77 -74
  214. package/assets/rules/autonomous-work.md +87 -74
  215. package/assets/rules/browser-verification.md +223 -214
  216. package/assets/rules/component-structure.md +72 -69
  217. package/assets/rules/dependencies.md +74 -67
  218. package/assets/rules/deploy-flow.azure.md +118 -108
  219. package/assets/rules/deploy-flow.github.md +145 -135
  220. package/assets/rules/deploy-flow.gitlab.md +120 -110
  221. package/assets/rules/doc-style.md +201 -173
  222. package/assets/rules/entity-conventions.needs-admin.md +81 -79
  223. package/assets/rules/entity-models.md +73 -70
  224. package/assets/rules/git-workflow.azure.md +224 -228
  225. package/assets/rules/git-workflow.github.md +268 -239
  226. package/assets/rules/git-workflow.gitlab.md +218 -217
  227. package/assets/rules/lib-layers.md +85 -86
  228. package/assets/rules/lists.md +101 -97
  229. package/assets/rules/navigation.md +78 -78
  230. package/assets/rules/observability.needs-app.md +165 -153
  231. package/assets/rules/platform-access.md +76 -75
  232. package/assets/rules/reuse-first.md +153 -143
  233. package/assets/rules/shared-code.md +82 -79
  234. package/assets/rules/spec-driven.md +279 -260
  235. package/assets/rules/status-report.md +62 -58
  236. package/assets/rules/styling-bem.md +81 -77
  237. package/assets/rules/task-flow.md +303 -270
  238. package/assets/rules/testing.md +224 -209
  239. package/assets/rules/turn-conduct.md +262 -258
  240. package/assets/rules/turn-entry.md +92 -87
  241. package/assets/rules/typescript-conventions.md +94 -88
  242. package/assets/samples/specs/_template/spec.md +47 -47
  243. package/assets/samples/tasks/_template/grill.md +20 -20
  244. package/assets/samples/tasks/_template/plan.md +32 -30
  245. package/assets/samples/tasks/_template/progress.md +16 -16
  246. package/assets/skills/agent-kit-extend.md +129 -113
  247. package/assets/skills/agent-kit.md +259 -233
  248. package/assets/skills/write-a-skill.md +76 -71
  249. package/assets/templates/findings.md +19 -19
  250. package/assets/templates/gate-map.sh +16 -14
  251. package/assets/templates/implementation.md +28 -27
  252. package/assets/templates/pattern.md +17 -17
  253. package/assets/templates/pitfalls.md +6 -6
  254. package/assets/templates/postmortem.md +24 -23
  255. package/assets/templates/project.sh +24 -24
  256. package/assets/templates/proposal.md +62 -60
  257. package/assets/templates/rule.md +38 -38
  258. package/assets/workflows/feature.js +46 -46
  259. package/assets/workflows/plan.js +54 -54
  260. package/bin/agent-kit.d.ts.map +1 -1
  261. package/bin/agent-kit.js +8 -1
  262. package/bin/agent-kit.js.map +1 -1
  263. package/lib/cargo-prose.d.ts +41 -0
  264. package/lib/cargo-prose.d.ts.map +1 -0
  265. package/lib/cargo-prose.js +88 -0
  266. package/lib/cargo-prose.js.map +1 -0
  267. package/lib/cargo.d.ts +12 -1
  268. package/lib/cargo.d.ts.map +1 -1
  269. package/lib/cargo.js +8 -2
  270. package/lib/cargo.js.map +1 -1
  271. package/lib/catalog.d.ts +2 -0
  272. package/lib/catalog.d.ts.map +1 -1
  273. package/lib/catalog.js +4 -3
  274. package/lib/catalog.js.map +1 -1
  275. package/lib/commands.d.ts.map +1 -1
  276. package/lib/commands.js +5 -2
  277. package/lib/commands.js.map +1 -1
  278. package/lib/companion.js +3 -2
  279. package/lib/companion.js.map +1 -1
  280. package/lib/enroll.d.ts +7 -1
  281. package/lib/enroll.d.ts.map +1 -1
  282. package/lib/enroll.js +12 -3
  283. package/lib/enroll.js.map +1 -1
  284. package/lib/fate.d.ts +29 -0
  285. package/lib/fate.d.ts.map +1 -0
  286. package/lib/fate.js +147 -0
  287. package/lib/fate.js.map +1 -0
  288. package/lib/override-marks.d.ts +7 -0
  289. package/lib/override-marks.d.ts.map +1 -1
  290. package/lib/override-marks.js +14 -0
  291. package/lib/override-marks.js.map +1 -1
  292. package/lib/plan.d.ts +11 -0
  293. package/lib/plan.d.ts.map +1 -1
  294. package/lib/plan.js +10 -1
  295. package/lib/plan.js.map +1 -1
  296. package/lib/ship.d.ts +29 -9
  297. package/lib/ship.d.ts.map +1 -1
  298. package/lib/ship.js +44 -2
  299. package/lib/ship.js.map +1 -1
  300. package/lib/shipment.d.ts.map +1 -1
  301. package/lib/shipment.fixture.d.ts +8 -1
  302. package/lib/shipment.fixture.d.ts.map +1 -1
  303. package/lib/shipment.fixture.js +9 -0
  304. package/lib/shipment.fixture.js.map +1 -1
  305. package/lib/shipment.js +38 -5
  306. package/lib/shipment.js.map +1 -1
  307. package/lib/sync.d.ts.map +1 -1
  308. package/lib/sync.js +45 -11
  309. package/lib/sync.js.map +1 -1
  310. package/package.json +1 -1
  311. package/rt-tools-agent-kit-0.27.0.tgz +0 -0
  312. package/rt-tools-agent-kit-0.24.0.tgz +0 -0
@@ -1,32 +1,34 @@
1
1
  #!/usr/bin/env bash
2
2
  # rt-hook: PreToolUse Edit|Write|MultiEdit|NotebookEdit|Bash|mcp__webstorm__create_new_file|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_tool
3
- # Требует: hooks/profile-check.sh, hooks/deny-tail.sh, hooks/guard-note.sh
4
- # Гард пары «правка и её документ». PreToolUse.
3
+ # Requires: hooks/profile-check.sh, hooks/deny-tail.sh, hooks/guard-note.sh
4
+ # Guard of the pair "an edit and its document". PreToolUse.
5
5
  #
6
- # Расхождение кода с текстом беззвучно. Ни линтер, ни сборка, ни тесты не читают правила,
7
- # спеки и README, поэтому текст, описывающий прежнее устройство, живёт дальше и выглядит
8
- # действующей справкой — тем убедительнее, чем он старше. Ловится это только чтением, и ловит
9
- # обычно владелец, а не проверка.
6
+ # A divergence of the code from the text is soundless. Neither the linter, nor the build, nor the
7
+ # tests read the rules, the specs and the READMEs, so a text describing the previous arrangement
8
+ # lives on and looks like a working reference — the more convincingly, the older it is. It is
9
+ # caught only by reading, and it is usually the owner who catches it, not a check.
10
10
  #
11
- # Гард требует ровно тех пар, где связь механическая и спорить не о чем:
11
+ # The guard demands exactly those pairs where the link is mechanical and there is nothing to argue
12
+ # about:
12
13
  #
13
- # правило и его спутник — когда правится раздел с утверждениями, а не «Ловушки»;
14
- # заведение и удаление либы — README этой либы;
15
- # переезд файла между либами — README обеих;
16
- # остальные пары — их называет профиль дерева, функция `rt_docs_pair_for <файл>`.
14
+ # a rule and its companion — when the section with the statements is edited, not "Pitfalls";
15
+ # creating and removing a lib — the README of that lib;
16
+ # moving a file between libs — the READMEs of both;
17
+ # the rest of the pairs — named by the tree profile, the function `rt_docs_pair_for <file>`.
17
18
  #
18
- # Отдельно — законы. Совпал ли код с законом, машина не знает: правка файла, на который закон
19
- # ссылается якорем, поэтому не отклоняется, а выносится вопросом владельцу. Тем же вопросом
20
- # встречается и правка самого закона — как на месте, так и надстройкой над ним: закон описывает
21
- # договорённость о продукте, и менять её молча гард не даёт.
19
+ # Apart from them — the laws. Whether the code came together with a law, a machine does not know:
20
+ # an edit of a file a law points to by an anchor is therefore not rejected but put to the owner as
21
+ # a question. The same question meets an edit of the law itself — both in place and through an
22
+ # override over it: a law describes a product agreement, and the guard does not let it be changed
23
+ # silently.
22
24
  #
23
- # Обход — строка `Docs-skip: <причина>` в теле коммита. Причина остаётся в истории и видна при
24
- # разборе ветки; пустая не принимается.
25
+ # The bypass is the line `Docs-skip: <reason>` in the commit body. The reason stays in the history
26
+ # and is visible when the branch is reviewed; an empty one is not accepted.
25
27
  #
26
- # ОТКАЗ В ПОЛЬЗУ РАБОТЫ: не репозиторий, нет разборщика, битый ввод, пустой список файлов —
27
- # пропуск.
28
+ # FAIL-OPEN: not a repository, no parser, broken input, an empty list of files — let through.
28
29
 
29
- # Своё имя в наблюдениях: отбой пишет общий хвост отказа, а не сам гард.
30
+ # Its own name in the observations: the refusal is written by the shared deny tail, not by the
31
+ # guard itself.
30
32
  RT_GUARD_NAME=docs-guard
31
33
 
32
34
  . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
@@ -48,27 +50,27 @@ decide() {
48
50
  if command -v rt_deny_tail >/dev/null 2>&1; then
49
51
  reason="$2
50
52
 
51
- $(rt_deny_tail "строка \`Docs-skip: <причина>\` в теле коммита; пустая причина не принимается")"
53
+ $(rt_deny_tail "the line \`Docs-skip: <reason>\` in the commit body; an empty reason is not accepted")"
52
54
  fi
53
55
  fi
54
56
 
55
57
  jq -n --arg d "$1" --arg r "$reason" \
56
58
  '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:$d,permissionDecisionReason:$r}}' 2>/dev/null \
57
- || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"Документ едет тем же коммитом."}}\n'
59
+ || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"The document goes by the same commit."}}\n'
58
60
  exit 0
59
61
  }
60
62
 
61
- # Профиль дерева: сперва умолчание пакета, поверх него — надстройка проекта, если она есть.
62
- # Объявленная в надстройке функция замещает умолчание целиком и вправе позвать его обратно
63
- # суффиксом `_default`.
63
+ # The tree profile: first the package default, and the project override on top of it, if there is
64
+ # one. A function declared in the override replaces the default whole and may call it back through
65
+ # the `_default` suffix.
64
66
  rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
65
67
  for profile in "$rt_hooks_dir/../rt-kit/defaults/project.sh" "$rt_hooks_dir/../defaults/project.sh" "${CLAUDE_PROJECT_DIR:-.}/.claude/rt-kit/defaults/project.sh" "${CLAUDE_PROJECT_DIR:-.}/.claude/rt-kit/project.sh"; do
66
68
  # shellcheck disable=SC1090
67
69
  [ -f "$profile" ] && . "$profile" 2>/dev/null
68
70
  done
69
71
 
70
- # Слово о нехватке функции профиля: хук, вышедший молча, неотличим от работающего. Файл может
71
- # быть не разложен — тогда остаётся прежнее поведение, молчаливое.
72
+ # A word about a missing profile function: a hook that left silently is indistinguishable from a
73
+ # working one. The file may be not laid out — then the previous behaviour stays, the silent one.
72
74
  # shellcheck disable=SC1090
73
75
  [ -f "$rt_hooks_dir/profile-check.sh" ] && . "$rt_hooks_dir/profile-check.sh"
74
76
  command -v rt_needs >/dev/null 2>&1 || rt_needs() { command -v "$1" >/dev/null 2>&1; }
@@ -77,36 +79,37 @@ laws_dir="${RT_LAWS_DIR:-docs/constitution}"
77
79
  lib_marker="${RT_LIB_MARKER:-project.json}"
78
80
  overrides_dir="${RT_OVERRIDES_DIR:-.claude/rt-kit/overrides}"
79
81
 
80
- # ── Правка закона спрашивает владельца ────────────────────────────────────────
82
+ # ── An edit of a law asks the owner ───────────────────────────────────────────
81
83
  #
82
- # Спутник рядом с законом — привязка статей к коду, она устаревает при каждом переименовании и
83
- # правится свободно. Спрашивается только сам текст закона.
84
+ # The companion next to a law is the binding of the articles to the code; it goes stale on every
85
+ # rename and is edited freely. Only the text of the law itself is asked about.
84
86
  #
85
- # Путей к тексту закона два, и ходят чаще вторым. Разложенный закон на месте не правится вовсе:
86
- # правка теряется на следующей раскладке, а сама раскладка на неё отказывает, — поэтому правят
87
- # надстройку, и файл закона переписывает раскладка. Гард, знающий один каталог законов, сторожит
88
- # ровно тот путь, которым к закону и не ходят: чем сложнее надстройка дерева, тем реже закон
89
- # правят на месте. Спрашивается и надстройка — по содержанию это правка закона, а не обвязки.
87
+ # There are two paths to the text of a law, and the second is walked more often. A laid-out law is
88
+ # not edited in place at all: the edit is lost on the next layout, and the layout itself refuses it
89
+ # — so the override is edited, and the file of the law is rewritten by the layout. A guard that
90
+ # knows one laws directory watches exactly the path by which nobody goes to a law: the more
91
+ # involved the tree's override, the more rarely a law is edited in place. The override is asked
92
+ # about too — by its content it is an edit of the law, not of the wrapping.
90
93
  case "$tool" in
91
94
  Edit | Write | MultiEdit | NotebookEdit | mcp__webstorm__create_new_file)
92
95
  target="$(printf '%s' "$input" | jq -r '.tool_input.file_path // .tool_input.filePath // .tool_input.path // .tool_input.pathInProject // empty' 2>/dev/null)"
93
96
  case "$target" in
94
97
  */"$laws_dir"/*.implementation.md | "$laws_dir"/*.implementation.md) exit 0 ;;
95
98
  */"$laws_dir"/*.md | "$laws_dir"/*.md)
96
- decide ask "Правка закона: \`${target##*/}\`. Закон описывает договорённость о продукте, а не устройство кода, — назови владельцу, что и почему меняешь, и дождись ответа. Если правка уже согласована, подтверди вызов."
99
+ decide ask "An edit of a law: \`${target##*/}\`. A law describes an agreement about the product, not the layout of the code — name to the owner what you are changing and why, and wait for the answer. If the edit is already agreed, confirm the call."
97
100
  ;;
98
101
  */"$overrides_dir"/laws/*.implementation.md | "$overrides_dir"/laws/*.implementation.md) exit 0 ;;
99
102
  */"$overrides_dir"/laws/*.md | "$overrides_dir"/laws/*.md)
100
- decide ask "Правка закона надстройкой: \`${target##*/}\`. Разложенный файл переписывает раскладка, поэтому правка надстройки — это правка самого закона: назови владельцу, что и почему меняешь, и дождись ответа. Если правка уже согласована, подтверди вызов."
103
+ decide ask "An edit of a law by an override: \`${target##*/}\`. A laid-out file is rewritten by the layout, so an edit of the override is an edit of the law itself: name to the owner what you are changing and why, and wait for the answer. If the edit is already agreed, confirm the call."
101
104
  ;;
102
105
  esac
103
106
  exit 0
104
107
  ;;
105
108
  esac
106
109
 
107
- # ── Коммит ────────────────────────────────────────────────────────────────────
110
+ # ── The commit ────────────────────────────────────────────────────────────────
108
111
 
109
- # Терминал среды и универсальный исполнитель кладут команду в то же поле.
112
+ # The environment terminal and the universal executor put the command in the same field.
110
113
  case "$tool" in
111
114
  Bash | mcp__webstorm__execute_terminal_command | mcp__webstorm__execute_tool) ;;
112
115
  *) exit 0 ;;
@@ -114,8 +117,8 @@ esac
114
117
 
115
118
  cmd="$(rt_hook_cmd)"
116
119
 
117
- # Универсальный исполнитель передаёт настоящую команду вложенной строкой. Разбирать надо её,
118
- # иначе имя команды стоит сразу за кавычкой и ни одно правило до него не дотягивается.
120
+ # The universal executor passes the real command as a nested string. It is that string that has to
121
+ # be parsed, otherwise the command name stands right after a quote and no rule reaches it.
119
122
  if [ "$tool" = "mcp__webstorm__execute_tool" ] && command -v perl >/dev/null 2>&1; then
120
123
  inner="$(printf '%s' "$cmd" | perl -0ne '
121
124
  if (/--command(?:=|\s+)(?:"((?:[^"\\]|\\.)*)"|\x27([^\x27]*)\x27|(.+))/s) {
@@ -130,13 +133,14 @@ case "$cmd" in
130
133
  *) exit 0 ;;
131
134
  esac
132
135
 
133
- # Причина обхода остаётся в истории, поэтому обход законен. Пустая строка обходом не считается:
134
- # «Docs-skip:» без причины — это тот же молчаливый пропуск, только с двоеточием.
136
+ # The reason for the bypass stays in the history, so the bypass is lawful. An empty line does not
137
+ # count as a bypass: "Docs-skip:" without a reason is the same silent skip, only with a colon.
135
138
  #
136
- # Строка начинает строку — свою в теле коммита или комментарий в конце команды — и подстановки
137
- # не принимает. То же условие, что у обхода при слиянии: иначе текст, который ОБЪЯСНЯЕТ обход,
138
- # снимает требование сам собой. Тело коммита о правке гарда как раз называет эту строку, и без
139
- # привязки к началу гард пропускал бы такой коммит молча.
139
+ # The line starts a line — its own in the commit body, or a comment at the end of the command — and
140
+ # takes no substitutions. The same condition as for the bypass at the merge: otherwise a text that
141
+ # EXPLAINS the bypass lifts the requirement all by itself. A commit body about an edit of the guard
142
+ # names exactly this line, and without the binding to the start the guard would let such a commit
143
+ # through silently.
140
144
  if printf '%s' "$cmd" | grep -qiE '(^|#)[[:space:]]*Docs-skip:[[:space:]]*[^[:space:]<"'"'"'][^[:space:]"'"'"']{2,}'; then
141
145
  exit 0
142
146
  fi
@@ -146,8 +150,8 @@ workdir="$(rt_hook_cwd)"
146
150
  cd "$workdir" 2>/dev/null || exit 0
147
151
  git rev-parse --is-inside-work-tree >/dev/null 2>&1 || exit 0
148
152
 
149
- # `-a` берёт все отслеживаемые правки, `--amend` — ещё и файлы переписываемого коммита.
150
- # Считать всегда по индексу значило бы проверять не тот набор, который уедет в историю.
153
+ # `-a` takes all tracked edits, `--amend` takes the files of the rewritten commit as well. Always
154
+ # counting by the index would mean checking a set other than the one that travels into the history.
151
155
  changes=''
152
156
  source_mode='index'
153
157
  case "$cmd" in
@@ -164,15 +168,16 @@ esac
164
168
  changes="$(printf '%s\n' "$changes" | grep -v '^[[:space:]]*$')"
165
169
  [ -z "$changes" ] && exit 0
166
170
 
167
- # Пути коммита без статусов. Переименование подаётся тремя полями — берём обе стороны.
171
+ # The paths of the commit without the statuses. A rename comes as three fields — we take both sides.
168
172
  paths="$(printf '%s\n' "$changes" | awk -F'\t' '{ for (i = 2; i <= NF; i++) if ($i != "") print $i }' | sort -u)"
169
173
 
170
174
  has_path() { printf '%s\n' "$paths" | grep -qxF "$1"; }
171
175
 
172
- # Содержимое таким, каким оно уедет в коммит. Источник тот же, по которому собран список
173
- # правок: `-a` заберёт рабочее дерево, обычный коммит — индекс. Читать индекс всегда нельзя —
174
- # при `-a` там лежит прежняя редакция, и гард держал бы коммит, который расхождение и чинит;
175
- # читать рабочее дерево всегда тоже нельзя — неподготовленная правка в коммит не попадёт.
176
+ # The content as it will travel into the commit. The source is the same one the list of edits was
177
+ # collected by: `-a` takes the working tree, an ordinary commit takes the index. Always reading the
178
+ # index is not allowed — under `-a` the previous edition lies there, and the guard would hold the
179
+ # very commit that fixes the divergence; always reading the working tree is not allowed either — an
180
+ # unstaged edit will not get into the commit.
176
181
  content_of() {
177
182
  if [ "$source_mode" = 'worktree' ]; then
178
183
  cat "$1" 2>/dev/null
@@ -185,15 +190,17 @@ problems=''
185
190
  add() { problems="${problems}
186
191
  • $1"; }
187
192
 
188
- # ── 1. Правило и его спутник ──────────────────────────────────────────────────
193
+ # ── 1. A rule and its companion ───────────────────────────────────────────────
189
194
  #
190
- # Утверждения правила ключуются своим текстом, и переформулировка без правки спутника рвёт
191
- # связь молча. Сверка спеков это ловит, но гоняется в гейте пуша — здесь та же пара
192
- # встречается коммитом раньше, пока правка ещё в голове у автора.
195
+ # The statements of a rule are keyed by their own text, and a rewording without an edit of the
196
+ # companion breaks the link silently. The spec audit catches this, but it is run at the push gate —
197
+ # here the same pair meets a commit earlier, while the edit is still in the author's head.
193
198
  #
194
- # Раздел с утверждениями — единственное, что связано со спутником; правка «Ловушек» или
195
- # таблицы «Где это лежит» его не трогает, поэтому сравнивается только этот раздел.
196
- STATEMENTS='/^## Как закон применяется здесь$/,/^## [^К]/'
199
+ # The section with the statements is the only thing linked to the companion; an edit of "Pitfalls"
200
+ # or of the "Where it lives" table does not touch it, so only this section is compared. The name of
201
+ # the section is double: English in a package rule, Russian in a rule written by the tree before the
202
+ # layer was translated. The end of the range is any heading not starting with their first letter.
203
+ STATEMENTS='/^## (How the law applies here|Как закон применяется здесь)$/,/^## [^КH]/'
197
204
  statements_of() { content_of "$1" | awk "$STATEMENTS"; }
198
205
 
199
206
  for rule in $(printf '%s\n' "$paths" | grep -E '/SKILL\.md$'); do
@@ -204,38 +211,39 @@ for rule in $(printf '%s\n' "$paths" | grep -E '/SKILL\.md$'); do
204
211
  has_path "$companion" && continue
205
212
 
206
213
  if [ "$(statements_of "$rule")" != "$(git show "HEAD:$rule" 2>/dev/null | awk "$STATEMENTS")" ]; then
207
- add "утверждения \`$rule\` правятся без спутника — добавь в коммит \`$companion\`"
214
+ add "the statements of \`$rule\` are edited without the companion — add \`$companion\` to the commit"
208
215
  fi
209
216
  done
210
217
 
211
- # ── 2. Пары, которые называет дерево ──────────────────────────────────────────
218
+ # ── 2. The pairs the tree names ───────────────────────────────────────────────
212
219
  #
213
- # Контракт и спек домена, гард и его сценарии — что именно, знает профиль: связь у каждого
214
- # дерева своя, а механика одна.
220
+ # The contract and the domain spec, a guard and its scenarios — which exactly, the profile knows:
221
+ # every tree has a link of its own, and the mechanics are one.
215
222
  if rt_needs rt_docs_pair_for docs-guard; then
216
223
  while IFS= read -r file; do
217
224
  [ -z "$file" ] && continue
218
225
 
219
- # Файл, положенный раскладкой, пары не требует: автор у него в дереве-потребителе один —
220
- # пакет, и документ о нём лежит там же. Иначе первая же раскладка требует обход на весь
221
- # свой объём, а обход, объявленный на сотню файлов, снимает требование и с будущих правок
222
- # этих файлов вручную. Признак — шапка раскладки: она стоит в каждом разложенном файле и
223
- # отличает его надёжнее любого перечня путей.
226
+ # A file put in place by the layout demands no pair: it has one author in a consuming tree
227
+ # — the package, and the document about it lies there as well. Otherwise the very first
228
+ # layout demands a bypass over its whole volume, and a bypass declared over a hundred files
229
+ # lifts the requirement from future hand edits of those files too. The sign is the layout
230
+ # header: it stands in every laid-out file and tells it apart more reliably than any list
231
+ # of paths.
224
232
  if [ -f "$file" ] && head -12 "$file" 2>/dev/null | grep -qE 'rt-kit v[^ ]+ · [^ ]+ · [0-9a-f]+'; then
225
233
  continue
226
234
  fi
227
235
 
228
236
  want="$(rt_docs_pair_for "$file" 2>/dev/null)"
229
237
  [ -z "$want" ] && continue
230
- # Пара считается приехавшей, если хоть один файл коммита подходит под образец.
238
+ # The pair counts as arrived if at least one file of the commit fits the pattern.
231
239
  printf '%s\n' "$paths" | grep -qE "$want" && continue
232
- add "\`$file\` правится без документа — тем же коммитом ждёт \`$want\`"
240
+ add "\`$file\` is edited without its document — the same commit awaits \`$want\`"
233
241
  done <<EOF
234
242
  $paths
235
243
  EOF
236
244
  fi
237
245
 
238
- # ── 3. Либа и её README ───────────────────────────────────────────────────────
246
+ # ── 3. A lib and its README ───────────────────────────────────────────────────
239
247
 
240
248
  lib_root() {
241
249
  dir="${1%/*}"
@@ -255,16 +263,16 @@ want_readme() {
255
263
  need_readme="$need_readme $root"
256
264
  }
257
265
 
258
- # Заведение и удаление либы: README — единственное место, где написано, что в ней лежит и кто
259
- # её зовёт, и раскладку она переживает только вместе с правкой этого текста.
266
+ # Creating and removing a lib: the README is the only place where it is written what lies in it and
267
+ # who calls it, and it survives the layout only together with an edit of that text.
260
268
  while IFS="$(printf '\t')" read -r status first second; do
261
269
  case "$status" in
262
270
  A* | D*)
263
271
  case "$first" in */"$lib_marker") want_readme "${first%/"$lib_marker"}" ;; esac
264
272
  ;;
265
273
  R*)
266
- # Переезд файла меняет обе стороны: у одной либы он пропал из состава, у другой
267
- # появился.
274
+ # A move of a file changes both sides: from one lib it disappeared, in the other it
275
+ # appeared.
268
276
  from="$(lib_root "$first")" && to="$(lib_root "$second")"
269
277
  if [ -n "$from" ] && [ -n "$to" ] && [ "$from" != "$to" ]; then
270
278
  want_readme "$from"
@@ -276,8 +284,8 @@ done <<EOF
276
284
  $changes
277
285
  EOF
278
286
 
279
- # Переезд, поданный парой «удалено там, добавлено тут»: переименованием считается не всё, что
280
- # им является, — правка содержимого при переносе сбивает поиск.
287
+ # A move given as the pair "deleted there, added here": not everything that is a rename counts as
288
+ # one — an edit of the content while moving throws the search off.
281
289
  moved_added="$(printf '%s\n' "$changes" | awk -F'\t' '$1 ~ /^A/ { n = split($2, p, "/"); print p[n] "\t" $2 }' | sort -u)"
282
290
  moved_deleted="$(printf '%s\n' "$changes" | awk -F'\t' '$1 ~ /^D/ { n = split($2, p, "/"); print p[n] "\t" $2 }' | sort -u)"
283
291
  if [ -n "$moved_added" ] && [ -n "$moved_deleted" ]; then
@@ -296,25 +304,26 @@ EOF
296
304
  fi
297
305
 
298
306
  for root in $need_readme; do
299
- [ -d "$root" ] || continue # либу удалили целиком — править в ней нечего
300
- has_path "$root/README.md" || add "состав либы \`$root\` изменился без правки \`$root/README.md\`"
307
+ [ -d "$root" ] || continue # the lib was deleted whole — there is nothing to edit in it
308
+ has_path "$root/README.md" || add "the content of the lib \`$root\` changed without an edit of \`$root/README.md\`"
301
309
  done
302
310
 
303
311
  if [ -n "$problems" ]; then
304
- decide deny "BLOCKED: коммит правит код, но не документ, который его описывает.
312
+ decide deny "BLOCKED: the commit edits code but not the document that describes it.
305
313
  ${problems}
306
314
 
307
- Текст правится в той же ветке, что и код: документ, разошедшийся с деревом, выглядит действующей справкой и уводит следующего читателя. Если правка документа здесь действительно не нужна — назови причину строкой \`Docs-skip: <причина>\` в теле коммита, она останется в истории."
315
+ Text is edited in the same branch as the code: a document that has drifted from the tree looks like a current reference and leads the next reader astray. If an edit of the document really is not needed here — name the reason by the line \`Docs-skip: <reason>\` in the commit body, it stays in the history."
308
316
  fi
309
317
 
310
- # ── 4. Законы ─────────────────────────────────────────────────────────────────
318
+ # ── 4. The laws ───────────────────────────────────────────────────────────────
311
319
  #
312
- # Отклонять нечего: сошлась ли правка с законом, видно только чтением. Но место, где статья
313
- # закона исполняется, названо якорем, и правка ровно этого файла — единственный момент, когда
314
- # сверку ещё дёшево сделать.
320
+ # There is nothing to reject: whether the edit came together with a law is visible only by reading.
321
+ # But the place where an article of a law is carried out is named by an anchor, and an edit of
322
+ # exactly that file is the only moment when the audit is still cheap to do.
315
323
  #
316
- # Слоёв законов два: общий в корне, закон приложения — в каталоге под ним. Образец принимает
317
- # оба, иначе правка предметного закона считалась бы правкой мимо законов.
324
+ # There are two layers of laws: the shared one in the root, an application law in a directory under
325
+ # it. The pattern accepts both, otherwise an edit of a subject law would count as an edit past the
326
+ # laws.
318
327
  if [ -d "$laws_dir" ] && ! printf '%s\n' "$paths" | grep -qE "^${laws_dir}/([^/]+/)?[^/]+\.md$"; then
319
328
  touched=''
320
329
  for anchor in $(grep -ohE '`[A-Za-z0-9_./@-]+\.(ts|mjs|html|scss|prisma|proto|json)(:[A-Za-z0-9_#.-]+)?`' "$laws_dir"/*.implementation.md 2>/dev/null \
@@ -324,10 +333,10 @@ if [ -d "$laws_dir" ] && ! printf '%s\n' "$paths" | grep -qE "^${laws_dir}/([^/]
324
333
  done
325
334
 
326
335
  if [ -n "$touched" ]; then
327
- decide ask "Правка задевает места, где исполняются статьи законов:
336
+ decide ask "The edit touches the places where articles of laws are carried out:
328
337
  ${touched}
329
338
 
330
- Законы лежат в \`${laws_dir}/\`, привязка — в спутниках рядом. Прочитай закон и скажи владельцу, сошлась ли с ним правка: если правка его уточняет или ему противоречит, закон правится в этой же ветке, но только с его ведома. Если закон не изменился — подтверди вызов."
339
+ The laws lie in \`${laws_dir}/\`, the binding — in the companions next to them. Read the law and tell the owner whether the edit agrees with it: if the edit refines it or contradicts it, the law is edited in this same branch, but only with their knowledge. If the law has not changed — confirm the call."
331
340
  fi
332
341
  fi
333
342
 
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env bash
2
+ # The reading "the epic is over". NOT a guard: it has no `rt-hook:` declaration and hooks into no
3
+ # agent event. The guards that judge the end of an epic source it themselves.
4
+ #
5
+ # Why it lives apart. Three guards ask one and the same question, and each from its own side: one
6
+ # refuses taking new work after the end of an epic, and two others refuse the very stop that the end
7
+ # of an epic requires — a turn without the next task taken and a turn that says the session waits for
8
+ # a word. Written three times, the reading would diverge three ways, and the guards would refuse each
9
+ # other's lawful moves.
10
+ #
11
+ # The state is asked by the command that prints the table for the owner: a reader of its own would
12
+ # diverge from the printed table in silence. The call is not cheap — it goes to the hosting — so the
13
+ # Stop guards ask it right before a refusal, not on every turn.
14
+ #
15
+ # ZERO means the epic is over: not one of its tasks is left unfinished. Any other answer — a task in
16
+ # work, no epic behind the branch, no way to ask the hosting — is not zero, and the caller works as
17
+ # it did before this reading existed.
18
+
19
+ rt_epic_over() {
20
+ command -v jq >/dev/null 2>&1 || return 1
21
+ command -v node >/dev/null 2>&1 || return 1
22
+
23
+ local here root checks table left
24
+ # The turn names the directory it goes from, and a Stop guard is called from wherever the host
25
+ # stands: taken from the process, the tree would be a foreign one — or none at all.
26
+ here="."
27
+ if command -v rt_hook_cwd >/dev/null 2>&1; then
28
+ here="$(rt_hook_cwd 2>/dev/null)"
29
+ [ -z "$here" ] && here="."
30
+ fi
31
+
32
+ root="$(cd "$here" 2>/dev/null && git rev-parse --show-toplevel 2>/dev/null)"
33
+ [ -z "$root" ] && return 1
34
+
35
+ # Where the checks of the package lie is named by the tree: the directory differs from tree to
36
+ # tree, and a name written here would be right in the first one and wrong in the second.
37
+ checks="$(jq -r '.layout.checks // "tools"' "$root/.claude/rt-kit.json" 2>/dev/null)"
38
+ if [ -z "$checks" ] || [ "$checks" = null ]; then
39
+ checks=tools
40
+ fi
41
+
42
+ table="$root/$checks/epic-table.mjs"
43
+ [ -f "$table" ] || return 1
44
+
45
+ left="$(cd "$root" && node "$table" --unfinished 2>/dev/null)" || return 1
46
+ [ -n "$left" ] && return 1
47
+
48
+ return 0
49
+ }
@@ -0,0 +1,108 @@
1
+ #!/usr/bin/env bash
2
+ # rt-hook: PreToolUse Bash|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_tool
3
+ # Requires: hooks/deny-tail.sh, hooks/epic-over.sh, checks/epic-table.github.mjs
4
+ # Guard of the stop at the end of an epic. PreToolUse on a call that takes new work.
5
+ #
6
+ # An epic used to end with the session taking the next piece of work. The owner learned that the
7
+ # epic was over from an ordinary report, mixed in with everything else, and had nowhere to give an
8
+ # order about its outcome: by the time they read it, the branch for the next work was already
9
+ # created. The rule of the turn carried a line about this, and it was held the same way the line
10
+ # about the table of tasks was held before the command — by memory, that is, sometimes.
11
+ #
12
+ # The guard stands on the call, not on the end of the turn: a turn ends with text, and a guard that
13
+ # took to reading text would refuse by mood. Taking work is a call — a task, a branch by a number, a
14
+ # column.
15
+ #
16
+ # The state of the epic is asked by the same command that prints the table for the owner. A reader
17
+ # of its own would diverge from the printed table in silence: it would refuse work the table itself
18
+ # calls unfinished.
19
+ #
20
+ # FAIL-OPEN: no `jq`, no `node`, no command, an epic that cannot be asked, any error of its own —
21
+ # the call is ALLOWED. A guard that jams the work when the network is gone is switched off on the
22
+ # first day, and the price of a miss here is one turn of the owner's attention.
23
+
24
+ # Its own name in the observations: the refusal is written by the shared deny tail, not by the
25
+ # guard itself.
26
+ RT_GUARD_NAME=epic-stop-guard
27
+
28
+ . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
29
+ . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
30
+
31
+ rt_hook_read
32
+ input="$RT_HOOK_INPUT"
33
+ [ -z "$input" ] && exit 0
34
+
35
+ command -v jq >/dev/null 2>&1 || exit 0
36
+ command -v node >/dev/null 2>&1 || exit 0
37
+
38
+ tool="$(rt_hook_tool)"
39
+ case "$tool" in
40
+ Bash | mcp__webstorm__execute_terminal_command | mcp__webstorm__execute_tool) ;;
41
+ *) exit 0 ;;
42
+ esac
43
+
44
+ cmd="$(rt_hook_cmd)"
45
+ [ -z "$cmd" ] && exit 0
46
+
47
+ # The universal executor of the environment passes the real command as a nested string: it is the
48
+ # one to judge, not the wrapper.
49
+ if [ "$tool" = "mcp__webstorm__execute_tool" ] && command -v perl >/dev/null 2>&1; then
50
+ inner="$(printf '%s' "$cmd" | perl -0ne '
51
+ if (/--command(?:=|\s+)(?:"((?:[^"\\]|\\.)*)"|\x27([^\x27]*)\x27|(.+))/s) {
52
+ print defined $1 ? $1 : (defined $2 ? $2 : $3);
53
+ }
54
+ ' 2>/dev/null)"
55
+ [ -n "$inner" ] && cmd="$inner"
56
+ fi
57
+
58
+ # The order of the owner travels in the call itself: the guard sees the call and does not see the
59
+ # conversation. An empty reason is not a bypass — the line then says nothing about who allowed it.
60
+ if printf '%s' "$cmd" | grep -qE 'Epic-stop-skip:[[:space:]]*[^[:space:]]' 2>/dev/null; then
61
+ exit 0
62
+ fi
63
+
64
+ # What counts as taking new work: a branch by a task number, a created task, a column moved to the
65
+ # working one. Everything else — a commit, a push, reading the history — is not judged: the epic is
66
+ # closed by exactly these three, and a wider net would refuse the work of finishing it.
67
+ takes_work=no
68
+ if printf '%s' "$cmd" | grep -qE '(checkout|switch)[[:space:]]+(-[A-Za-z]+[[:space:]]+)*-(b|c)[[:space:]]+[A-Za-z]+-[0-9]+-' 2>/dev/null; then
69
+ takes_work=yes
70
+ fi
71
+ if printf '%s' "$cmd" | grep -qE 'task:new|task-new\.mjs' 2>/dev/null; then
72
+ takes_work=yes
73
+ fi
74
+ if printf '%s' "$cmd" | grep -qE '(task:move|board\.mjs[[:space:]]+move)([^|;&]*)in-progress' 2>/dev/null; then
75
+ takes_work=yes
76
+ fi
77
+ [ "$takes_work" = yes ] || exit 0
78
+
79
+ # The reading of the end of an epic is shared with the two guards that judge the stop itself: written
80
+ # apart, the three readings would diverge and refuse each other's lawful moves. A non-zero answer
81
+ # means a task in work, no epic behind the branch or no way to ask — there is nothing to judge by,
82
+ # and the work goes on.
83
+ # shellcheck disable=SC1090
84
+ . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/epic-over.sh" 2>/dev/null || exit 0
85
+ command -v rt_epic_over >/dev/null 2>&1 || exit 0
86
+ rt_epic_over || exit 0
87
+
88
+ root="$(git rev-parse --show-toplevel 2>/dev/null)"
89
+ checks="$(jq -r '.layout.checks // "tools"' "$root/.claude/rt-kit.json" 2>/dev/null)"
90
+ if [ -z "$checks" ] || [ "$checks" = null ]; then
91
+ checks=tools
92
+ fi
93
+
94
+ reason="Refused: the epic is over — every task of it is merged or handed over by a request, and this call takes new work. The end of an epic is a stop: print the table by «npm run epic:table» (or «node $checks/epic-table.mjs»), tell the owner what was done on each task and what confirms it, and say outright that the session waits for their orders. New work is taken by their word, not by the count of what is left."
95
+
96
+ # shellcheck disable=SC1090
97
+ [ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
98
+ && . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
99
+ command -v rt_deny_tail >/dev/null 2>&1 || rt_deny_tail() { :; }
100
+ deny_tail_text="$(rt_deny_tail "the line «Epic-stop-skip: <the word of the owner>» in the call itself; an empty reason is not accepted")"
101
+ [ -n "$deny_tail_text" ] && reason="${reason}
102
+
103
+ ${deny_tail_text}"
104
+
105
+ jq -n --arg r "$reason" '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:$r}}' 2>/dev/null \
106
+ || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"The epic is over: the end of an epic is a stop, not the next task."}}\n'
107
+
108
+ exit 0