@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,19 +1,20 @@
1
1
  #!/usr/bin/env bash
2
2
  # rt-hook: PreToolUse AskUserQuestion
3
- # Требует: hooks/grill-gate.sh
4
- # Половина гарда разговора, стоящая на инструменте вопроса: меню судится до отправки.
3
+ # Requires: hooks/grill-gate.sh
4
+ # The half of the conversation guard that stands on the question tool: the menu is judged before it
5
+ # is sent.
5
6
  #
6
- # Своим ресурсом, а не строкой в шапке соседа, потому что инструмент вопроса — единственный
7
- # способ спросить владельца, и у дерева на нём уже может стоять свой гард со своей причиной
8
- # отказа. Второй отказ на том же инструменте делает вопрос недоступным вовсе, и дерево
9
- # отказывается от гарда целиком вместо того, чтобы взять его половину. Разведённые по двум
10
- # ресурсам, половины отменяются порознь: строка отказа снимает одну и оставляет другую.
7
+ # A resource of its own, not a line in the neighbour's header, because the question tool is the
8
+ # only way to ask the owner, and the tree may already have its own guard on it with its own refusal
9
+ # reason. A second refusal on the same tool makes the question unavailable altogether, and the tree
10
+ # drops the guard whole instead of taking its half. Split over two resources, the halves are
11
+ # cancelled separately: a refusal line removes one and leaves the other.
11
12
  #
12
- # Судит вызов то же тело, что и завершение хода: требование одно, и расходиться двум его
13
- # редакциям нельзя. Здесь только объявление события и передача ввода.
13
+ # The call is judged by the same body as the turn end: the requirement is one, and its two editions
14
+ # must not diverge. Here only the event declaration and passing the input on.
14
15
  #
15
- # ОТКАЗ В ПОЛЬЗУ РАБОТЫ: нет соседнего файла — ход РАЗРЕШАЕТСЯ. Половина гарда, потерявшая
16
- # тело, не имеет права заклинить разговор.
16
+ # FAIL-OPEN: no neighbouring file — the turn is ALLOWED. A half of the guard that has lost its body
17
+ # has no right to jam the conversation.
17
18
 
18
19
  . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
19
20
  . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
@@ -1,39 +1,40 @@
1
1
  #!/usr/bin/env bash
2
- # Требует: hooks/deny-tail.sh
2
+ # Requires: hooks/deny-tail.sh
3
3
  # rt-hook: Stop
4
- # Гард разговора: вопрос владельцу не задаётся, пока за этот же ход не читались законы и
5
- # правила. Судит два события, и это не дублирование; второе объявлено соседним ресурсом
6
- # `hooks/grill-gate-ask.sh`, который отдаёт вызов сюда.
4
+ # The conversation guard: the owner is not asked a question until the laws and rules have been read
5
+ # within the same turn. It judges two events, and that is not duplication; the second is declared
6
+ # by the neighbouring resource `hooks/grill-gate-ask.sh`, which hands the call over here.
7
7
  #
8
- # Зачем именно так. Требование «правила читаются до разговора» исполнимо ровно до отправки
9
- # вопроса. Проверка на завершении хода отбивает задним числом: к моменту отказа вопрос уже у
10
- # владельца, и владелец видит его вместе с отбитым ходом — требование срабатывает, но работу не
11
- # спасает. Поэтому ход с вопросом судится на инструменте вопроса, до отправки.
8
+ # Why exactly this way. The requirement "the rules are read before the conversation" is enforceable
9
+ # right up to the moment the question is sent. A check at the turn end refuses after the fact: by
10
+ # the time of the refusal the question is already with the owner, and the owner sees it together
11
+ # with the refused turn — the requirement fires, but it does not save the work. So a turn with a
12
+ # question is judged on the question tool, before sending.
12
13
  #
13
- # Одним этим перехватом дыра не закрывается: вопрос чаще задаётся прозой, и ровно так был задан
14
- # тот, из-за которого гард заведён. Прозаический вопрос инструментом не является, и поймать его
15
- # можно только на завершении хода — событие получает путь к записи хода и видит его целиком.
16
- # Отсюда два события: меню ловится до отправки, проза — после. Объявлены они разными ресурсами
17
- # затем, чтобы дерево, у которого инструмент вопроса занят своим гардом, могло взять половину, а
18
- # не отказаться от требования целиком.
14
+ # This one interception does not close the hole: a question is more often asked in prose, and that
15
+ # is exactly how the one that brought this guard about was asked. A prose question is not a tool,
16
+ # and it can be caught only at the turn end — the event gets the path to the turn record and sees
17
+ # the turn whole. Hence two events: the menu is caught before sending, prose after. They are
18
+ # declared by different resources so that a tree whose question tool is already taken by a guard of
19
+ # its own can take one half instead of dropping the requirement whole.
19
20
  #
20
- # Чтением правил считается любой из трёх путей: загрузка правила, чтение файла законов или
21
- # правил, поиск по ним. Требовать именно загрузку значило бы гнать на неё там, где хватило
22
- # одного поиска, — гард мешал бы работе вместо того, чтобы её выправлять.
21
+ # Reading the rules counts as any of three paths: loading a rule, reading a file of the laws or the
22
+ # rules, searching through them. To demand loading exactly would drive the executor to it where one
23
+ # search was enough — the guard would hinder the work instead of straightening it.
23
24
  #
24
- # Но чтение чего угодно из слоя правил вопроса не закрывает: прочитанный разбор чужого промаха
25
- # и поиск по каталогу засчитывались наравне с правилом, которое этой работе и требуется, — а
26
- # ответ на заданный владельцу вопрос лежал ровно в нём. Поэтому, когда область работы этого хода
27
- # известна, чтением считается только правило этой области. Область берётся оттуда же, откуда её
28
- # берёт гейт правил: по путям правок хода.
25
+ # But reading anything at all from the rules layer does not close the question: an incident
26
+ # analysis someone else read and a search over the catalog counted on a par with the rule this work
27
+ # actually needs — and the answer to the question put to the owner lay exactly in that rule. So,
28
+ # when the area of this turn's work is known, only the rule of that area counts as reading. The
29
+ # area is taken from where the rules gate takes it: from the paths edited in the turn.
29
30
  #
30
- # ОТКАЗ В ПОЛЬЗУ РАБОТЫ и здесь: правок в ходу нет, карты гейта нет, область не определилась —
31
- # засчитывается любое чтение, как прежде.
31
+ # FAIL-OPEN here too: there are no edits in the turn, there is no gate map, the area did not come
32
+ # out — any reading counts, as before.
32
33
  #
33
- # ОТКАЗ В ПОЛЬЗУ РАБОТЫ: при любой ошибке, отсутствии записи хода и повторном заходе ход
34
- # РАЗРЕШАЕТСЯ (exit 0). Сломанный гард не имеет права заклинить разговор.
34
+ # FAIL-OPEN: on any error, with no turn record and on a repeat pass the turn is ALLOWED (exit 0).
35
+ # A broken guard has no right to jam the conversation.
35
36
 
36
- # Своё имя в наблюдениях: отбой пишет общий хвост отказа, а не сам гард.
37
+ # Its own name in the observations: the refusal is written by the shared deny tail, not by the guard.
37
38
  RT_GUARD_NAME=grill-gate
38
39
 
39
40
  . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
@@ -45,11 +46,12 @@ input="$RT_HOOK_INPUT"
45
46
 
46
47
  command -v jq >/dev/null 2>&1 || exit 0
47
48
 
48
- # Какое событие пришло. У вызова инструмента есть его имя, у завершения хода — нет.
49
+ # Which event arrived. A tool call has its name, the turn end does not.
49
50
  tool="$(rt_hook_tool)"
50
51
 
51
- # Повторный заход по тому же ходу не судится: иначе ход не кончится никогда — гард сказал своё
52
- # один раз и отпускает. К вызову инструмента это не относится: там судится сам вызов.
52
+ # A repeat pass over the same turn is not judged: otherwise the turn would never end — the guard
53
+ # said its piece once and lets go. This does not apply to a tool call: there the call itself is
54
+ # judged.
53
55
  active="$(printf '%s' "$input" | jq -r '.stop_hook_active // false' 2>/dev/null)"
54
56
  [ -z "$tool" ] && [ "$active" = "true" ] && exit 0
55
57
 
@@ -57,45 +59,46 @@ transcript="$(printf '%s' "$input" | jq -r '.transcript_path // empty' 2>/dev/nu
57
59
  [ -z "$transcript" ] && exit 0
58
60
  [ -f "$transcript" ] || exit 0
59
61
 
60
- # Профиль дерева: каталоги законов, правил и спеков у каждого свои, а знать их надо и для
61
- # признака чтения, и для подсказки в отказе.
62
+ # The tree profile: the directories of laws, rules and specs differ from tree to tree, and they are
63
+ # needed both for the sign of reading and for the hint in the refusal.
62
64
  rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
63
65
  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
64
66
  # shellcheck disable=SC1090
65
67
  [ -f "$profile" ] && . "$profile" 2>/dev/null
66
68
  done
67
69
 
68
- # Подстановка без двоеточия намеренно: заданное пустым — это отказ дерева от требования, и
69
- # подменять его умолчанием нельзя. Умолчание достаётся только тому, кто не задал переменной
70
- # вовсе.
70
+ # Substitution without a colon is deliberate: set to empty means the tree drops the requirement,
71
+ # and that must not be replaced by a default. The default goes only to the one who did not set the
72
+ # variable at all.
71
73
  laws_dir="${RT_LAWS_DIR-docs/constitution}"
72
74
  rules_dir="${RT_RULES_DIR-.claude/skills}"
73
75
  specs_dir="${RT_SPECS_DIR-docs/specs}"
74
- # Замысел эпика и описание прошлого читаются наравне с законами: решение, связывающее задачи
75
- # эпика, лежит именно там. Прочитавший замысел получал отказ наравне с не читавшим ничего, и
76
- # снимался тот отказ поиском по трём каталогам, среди которых нужного не было.
76
+ # The plan of an epic and the archive are read on a par with the laws: the decision that ties the
77
+ # tasks of an epic together lies exactly there. Whoever had read the plan was refused on a par with
78
+ # whoever had read nothing, and that refusal was lifted by a search over three directories among
79
+ # which the needed one was not.
77
80
  plans_dir="${RT_PLANS_DIR-docs/plans}"
78
81
  archive_dir="${RT_ARCHIVE_DIR-docs/archive}"
79
82
 
80
- # Дерево, у которого нет ни законов, ни правил, требования не получает: читать нечего.
83
+ # A tree that has neither laws nor rules gets no requirement: there is nothing to read.
81
84
  [ -z "$laws_dir" ] && [ -z "$rules_dir" ] && exit 0
82
85
 
83
- # Карта гейта: по ней имя правила достаётся из пути правки. Нет её — область не определяется, и
84
- # всё остаётся прежним.
86
+ # The gate map: by it the rule name is got from the edit path. There is none — the area does not
87
+ # come out, and everything stays as before.
85
88
  rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
86
89
  for map in "$rt_hooks_dir/../rt-kit/defaults/gate-map.sh" "$rt_hooks_dir/../defaults/gate-map.sh" "${CLAUDE_PROJECT_DIR:-.}/.claude/rt-kit/defaults/gate-map.sh" "${CLAUDE_PROJECT_DIR:-.}/.claude/rt-kit/gate-map.sh"; do
87
90
  # shellcheck disable=SC1090
88
91
  [ -f "$map" ] && . "$map" 2>/dev/null
89
92
  done
90
93
 
91
- # Образец, по которому вызов инструмента считается чтением правил. Каталоги идут в него как
92
- # есть: точка в `.claude` совпадает с любым знаком и лишнего сюда не приводит.
94
+ # The pattern by which a tool call counts as reading the rules. The directories go into it as they
95
+ # are: the dot in `.claude` matches any character and brings nothing extra here.
93
96
  read_re="$(printf '%s' "$laws_dir|$rules_dir|$specs_dir|$plans_dir|$archive_dir" | sed 's/^|*//; s/|*$//; s/||*/|/g')"
94
97
  [ -z "$read_re" ] && exit 0
95
98
 
96
- # Область работы этого хода: правила, которых требует гейт от путей, правленных в ходу. Пути
97
- # достаются тем же разбором хода, что и ниже, — своим вызовом, чтобы образец чтения был готов
98
- # к главному разбору.
99
+ # The area of this turn's work: the rules the gate demands of the paths edited in the turn. The
100
+ # paths are got by the same parse of the turn as below — by a call of its own, so that the reading
101
+ # pattern is ready for the main parse.
99
102
  need_re=''
100
103
  if command -v skill_for >/dev/null 2>&1 && [ -n "$rules_dir" ]; then
101
104
  edited="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r '
@@ -122,15 +125,14 @@ if command -v skill_for >/dev/null 2>&1 && [ -n "$rules_dir" ]; then
122
125
  done
123
126
  fi
124
127
 
125
- # Ход — это всё, что записано после последнего настоящего ввода владельца. Ответ инструмента
126
- # приходит той же ролью `user`, поэтому строки с `tool_result` вводом не считаются: иначе ходом
127
- # оказался бы кусок после последнего вызова инструмента, и чтение правил в его начале потерялось
128
- # бы.
128
+ # A turn is everything recorded after the last real input from the owner. A tool answer comes in
129
+ # under the same `user` role, so lines with `tool_result` do not count as input: otherwise the turn
130
+ # would be the piece after the last tool call, and reading the rules at its start would be lost.
129
131
  #
130
- # Хвост в 400 строк: запись хода растёт всю сессию, а судится только последний ход.
131
- # На событии вызова инструмента вопрос уже известен — он и есть вызов; судится только то,
132
- # читались ли за этот ход правила. На завершении хода вопрос ищется в тексте реплик: меню к
133
- # этому моменту уже отбито раньше.
132
+ # A tail of 400 lines: the turn record grows all session, and only the last turn is judged.
133
+ # On the tool call event the question is already known — it is the call; only whether the rules
134
+ # were read within this turn is judged. At the turn end the question is looked for in the text of
135
+ # the replies: the menu has by then already been refused earlier.
134
136
  verdict="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r --arg re "$read_re" --arg tool "$tool" --arg need "$need_re" --arg rules "$rules_dir" '
135
137
  def is_input:
136
138
  .type == "user"
@@ -150,8 +152,8 @@ verdict="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r --arg re "$read_re"
150
152
  or ((.name == "Bash") and ((.input.command // "") | test($re)))
151
153
  ) | any
152
154
  else
153
- # Область работы известна — засчитывается только правило этой области: прочитанный
154
- # разбор чужого промаха на заданный вопрос не отвечает.
155
+ # The area of the work is known — only the rule of that area counts: an incident
156
+ # analysis someone else read does not answer the question that was asked.
155
157
  ($need | split("|")) as $rules_needed
156
158
  | $uses | map(
157
159
  ((.name == "Skill") and (((.input.skill // "") | tostring) as $s | $rules_needed | index($s) != null))
@@ -165,20 +167,22 @@ verdict="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r --arg re "$read_re"
165
167
  | if ($asked_prose or $asking_now) and ($read | not) then "ask" else "pass" end
166
168
  ' 2>/dev/null)"
167
169
 
168
- # Второй признак того же гарда: на этот вопрос владелец уже отвечал.
170
+ # The second sign of the same guard: the owner has already answered this question.
169
171
  #
170
- # Первый признак судит, читались ли правила, и на разрешённой работе молчит. А промах бывает
171
- # другой: владелец дал указание прямой репликой, исполнитель нашёл факт, который меняет цену
172
- # указания, но не его смысл, — и вместо строки о цене задал меню, где два варианта из трёх
173
- # предлагали отменить решение владельца. Работа встала до ответа, разрешённая минутой раньше.
172
+ # The first sign judges whether the rules were read, and stays silent on work that is allowed. But
173
+ # the miss can be another one: the owner gave an instruction in a direct reply, the executor found
174
+ # a fact that changes the price of the instruction but not its meaning — and instead of a line
175
+ # about the price asked a menu where two options out of three offered to cancel the owner's
176
+ # decision. The work stopped until an answer, having been allowed a minute earlier.
174
177
  #
175
- # Судится пересечение слов: вопрос, который сейчас уходит, против последней реплики владельца —
176
- # и только там, где в записи уже был вызов инструмента вопроса, то есть владелец на вопрос
177
- # отвечал. Понимания текста здесь нет и не нужно: три общих значимых слова означают тот же
178
- # предмет, а разбор из шести вопросов идёт по разным предметам и порога не набирает.
178
+ # What is judged is the overlap of words: the question going out now against the owner's last reply
179
+ # — and only where the record already holds a call of the question tool, that is, the owner has
180
+ # answered a question. There is no understanding of the text here and none is needed: three shared
181
+ # significant words mean the same subject, while a grill of six questions runs over different
182
+ # subjects and does not reach the threshold.
179
183
  #
180
- # ОТКАЗ В ПОЛЬЗУ РАБОТЫ: нет вопроса в вызове, нет реплики владельца, нет прошлого вопроса —
181
- # признак молчит.
184
+ # FAIL-OPEN: no question in the call, no reply from the owner, no earlier question — the sign stays
185
+ # silent.
182
186
  if [ -n "$tool" ]; then
183
187
  asked_json="$(printf '%s' "$input" | jq -r '(.tool_input.questions // []) | tostring' 2>/dev/null)"
184
188
  seen="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r --arg now "$asked_json" '
@@ -192,27 +196,28 @@ if [ -n "$tool" ]; then
192
196
  def words: [splits("[^\\p{L}\\p{N}]+")] | map(select(length >= 5)) | unique;
193
197
 
194
198
  (map(is_input) | rindex(true)) as $i
195
- | if $i == null then "нет" else
199
+ | if $i == null then "no" else
196
200
  (.[$i] | (.message.content // []) | if type == "array"
197
201
  then ([.[] | select(.type == "text") | .text] | join(" "))
198
202
  else (. // "") end) as $said
199
203
  | ([.[:$i][] | select(.type == "assistant") | (.message.content // [])[]
200
204
  | select(.type == "tool_use") | select(.name == "AskUserQuestion")] | length) as $before
201
- | if $before == 0 or ($said | length) == 0 then "нет" else
205
+ | if $before == 0 or ($said | length) == 0 then "no" else
202
206
  (($now | words) - (($now | words) - ($said | words))) as $common
203
- | if ($common | length) >= 3 then "было" else "нет" end
207
+ | if ($common | length) >= 3 then "answered" else "no" end
204
208
  end
205
209
  end
206
210
  ' 2>/dev/null)"
207
211
 
208
- if [ "$seen" = "было" ]; then
209
- reason="BLOCKED by grill-gate: на этот вопрос владелец уже отвечал в этом разговоре — продолжай работу, а не переспрашивай.
212
+ if [ "$seen" = "answered" ]; then
213
+ reason="BLOCKED by grill-gate: the owner has already answered this question in this conversation — go on with the work instead of asking again.
210
214
 
211
- Указание владельца действует до его отмены. Новый факт против действующего указания — это строка в ответе о цене, а не новый вопрос: переспрашивают только то, чего указание не покрывает. Промах здесь не в форме вопроса, а в остановке работы, которая уже разрешена.
215
+ An instruction of the owner holds until they cancel it. A new fact against a standing instruction is a line in the reply about the price, not a new question: what is asked again is only what the instruction does not cover. The miss here is not in the form of the question but in stopping work that is already allowed.
212
216
 
213
- Вопрос всё-таки о другом предмете — назови в нём то, чего в прежнем ответе владельца нет: признак судит общие слова вопроса и последней реплики владельца, а не смысл."
217
+ The question really is about another matter — then name in it what the former answer of the owner lacks: the sign judges the shared words of the question and of the last message of the owner, not the meaning."
214
218
 
215
- # Общий хвост отказа: два законных хода и законная форма обхода, если она у отказа есть.
219
+ # The shared deny tail: the two lawful moves and the lawful form of bypass, if the
220
+ # refusal has one.
216
221
  # shellcheck disable=SC1090
217
222
  [ -f "$rt_hooks_dir/deny-tail.sh" ] && . "$rt_hooks_dir/deny-tail.sh" 2>/dev/null
218
223
  command -v rt_deny_tail >/dev/null 2>&1 || rt_deny_tail() { :; }
@@ -222,7 +227,7 @@ if [ -n "$tool" ]; then
222
227
  ${deny_tail_text}"
223
228
 
224
229
  jq -n --arg r "$reason" '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:$r}}' 2>/dev/null \
225
- || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"grill-gate: на этот вопрос уже отвечали."}}\n'
230
+ || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"grill-gate: this question has already been answered."}}\n'
226
231
  exit 0
227
232
  fi
228
233
  fi
@@ -230,19 +235,20 @@ fi
230
235
  [ "$verdict" = "ask" ] || exit 0
231
236
 
232
237
  if [ -n "$tool" ]; then
233
- head="BLOCKED by grill-gate: вопрос владельцу ещё не ушёл, и это единственный момент, когда требование исполнимо."
238
+ head="BLOCKED by grill-gate: the question to the owner has not left yet, and this is the only moment when the requirement can be met."
234
239
  else
235
- head="BLOCKED by grill-gate: в ответе есть вопрос владельцу, а законы и правила за этот ход не читались."
240
+ head="BLOCKED by grill-gate: the reply carries a question to the owner, and the laws and rules were not read in this turn."
236
241
  fi
237
242
 
238
- reason="$head Вопрос, ответ на который уже записан, владельцу не задаётся — правило ведения работы. Прогони поиск по словам темы и ответь по найденному; спрашивай только то, что документацией не покрыто:
243
+ reason="$head A question whose answer is already written down is not asked of the owner — the rule of work conduct. Run a search by the words of the subject and answer from what is found; ask only what the documents do not cover:
239
244
 
240
- grep -rn -i \"<слово темы>\" $laws_dir $rules_dir $specs_dir $plans_dir $archive_dir
245
+ grep -rn -i \"<a word of the subject>\" $laws_dir $rules_dir $specs_dir $plans_dir $archive_dir
241
246
 
242
- Гард судит один ход: следующий заход не отбивается."
247
+ The guard judges one turn: the next session is not refused."
243
248
 
244
- # Общий хвост отказа: два законных хода и законная форма обхода, если она у отказа есть.
245
- # Файл может быть не разложен — тогда хвоста нет, а причина отказа остаётся прежней.
249
+ # The shared deny tail: the two lawful moves and the lawful form of bypass, if the refusal has one.
250
+ # The file may not be laid out — then there is no tail, and the reason for the refusal stays as it
251
+ # was.
246
252
  # shellcheck disable=SC1090
247
253
  [ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
248
254
  && . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
@@ -252,14 +258,15 @@ deny_tail_text="$(rt_deny_tail "")"
252
258
 
253
259
  ${deny_tail_text}"
254
260
 
255
- # Форма отказа у двух событий разная: вызов инструмента отбивается решением о доступе, а
256
- # завершение хода — решением о ходе. Одна форма на оба события молча не срабатывает.
261
+ # The form of the refusal differs between the two events: a tool call is refused by a decision
262
+ # about access, and the turn end by a decision about the turn. One form for both events silently
263
+ # does not fire.
257
264
  if [ -n "$tool" ]; then
258
265
  jq -n --arg r "$reason" '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:$r}}' 2>/dev/null \
259
- || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"grill-gate: прочитай законы и правила по теме, прежде чем спрашивать владельца."}}\n'
266
+ || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"grill-gate: read the laws and rules on the subject before asking the owner."}}\n'
260
267
  else
261
268
  jq -n --arg r "$reason" '{decision:"block",reason:$r}' 2>/dev/null \
262
- || printf '{"decision":"block","reason":"grill-gate: прочитай законы и правила по теме, прежде чем спрашивать владельца."}\n'
269
+ || printf '{"decision":"block","reason":"grill-gate: read the laws and rules on the subject before asking the owner."}\n'
263
270
  fi
264
271
 
265
272
  exit 0
@@ -1,30 +1,31 @@
1
1
  #!/usr/bin/env bash
2
- # Запись отбоя гарда. НЕ гард: объявления `rt-hook:` у него нет, к событиям агента он не
3
- # подключается. Его источает общий хвост отказа — единственное место, через которое проходит
4
- # каждый отказ.
2
+ # The record of a guard refusal. NOT a guard: it has no `rt-hook:` declaration and hooks into no
3
+ # agent event. The shared deny tail sources it — the one place every refusal passes through.
5
4
  #
6
- # Зачем он есть. Запись отбоя стояла в самом гарде пятью строками: подключение записи, проверка
7
- # наличия функции, вызов с именем и признаком сессии. Написать их в каждом гарде не вышло — из
8
- # тридцати их написали в пяти, и сводка наблюдений отвечала по этой пятой части: гард, который
9
- # отбивать умеет, а записывать нет, не значится в ней ни отбивавшим, ни молчащим, и вопрос «стоял
10
- # и не работал» по нему не задать вовсе.
5
+ # Why it exists. The refusal record stood inside the guard itself as five lines: sourcing the
6
+ # record, checking the function exists, the call with the name and the session id. Writing them in
7
+ # every guard did not work out — of thirty guards, five had them, and the observation digest
8
+ # answered by that fifth: a guard that can refuse but cannot record is listed in it neither as
9
+ # refusing nor as silent, and the question "it stood there and did not work" cannot be asked about
10
+ # it at all.
11
11
  #
12
- # КАК ГАРД ЗАЯВЛЯЕТ О СЕБЕ. Одной строкой `RT_GUARD_NAME=<имя>` у себя вверху. Заявка добровольна
13
- # и точна: хук, который своё отбитие считает сам — как гейт правил, — её не ставит, и второй раз
14
- # то же событие в счёт не идёт.
12
+ # HOW A GUARD DECLARES ITSELF. By one line `RT_GUARD_NAME=<name>` at its top. The declaration is
13
+ # voluntary and exact: a hook that counts its own refusals by itself — like the rules gate — does
14
+ # not set it, and the same event is not counted a second time.
15
15
  #
16
- # ЧТО ЗАПИСЫВАЕТСЯ. Имя гарда и признак сессии. Чистит значения и решает, писать ли вообще, сама
17
- # запись наблюдений; здесь только сборка вызова.
16
+ # WHAT IS RECORDED. The guard name and the session id. Cleaning the values and deciding whether to
17
+ # write at all is done by the observation record itself; here only the call is assembled.
18
18
  #
19
- # ОТКАЗ В ПОЛЬЗУ РАБОТЫ. Записи может не быть вовсе — файла нет, дерево выключило наблюдения,
20
- # каталог недоступен. Гард, упавший на записи отбоя, останавливал бы работу ради статистики.
19
+ # FAIL-OPEN. There may be no record at all — no file, the tree switched observations off, the
20
+ # directory is unavailable. A guard that fell over on recording a refusal would stop work for the
21
+ # sake of statistics.
21
22
 
22
- # Отбой гарда в наблюдения. Имя берётся из `RT_GUARD_NAME`, признак сессии — из ввода хука;
23
- # без имени не пишется ничего.
23
+ # A guard refusal into the observations. The name is taken from `RT_GUARD_NAME`, the session id
24
+ # from the hook input; without a name nothing is written.
24
25
  rt_guard_note() {
25
26
  local rt_gn_dir rt_gn_sid rt_gn_name
26
- # Умолчание, а не голое чтение: гард бывает написан с обрывом на необъявленной переменной, и
27
- # запись, читающая её голой, роняет такой гард целиком — на каждом вызове, а не на отказе.
27
+ # A default, not a bare read: a guard may be written to abort on an undeclared variable, and a
28
+ # record that reads it bare brings such a guard down whole — on every call, not on a refusal.
28
29
  rt_gn_name="${RT_GUARD_NAME:-}"
29
30
  [ -n "$rt_gn_name" ] || return 0
30
31
 
@@ -1,20 +1,21 @@
1
1
  #!/usr/bin/env bash
2
- # rt-hook: PreToolUse Edit|Write|MultiEdit
3
- # Требует: rules/task-flow.md, hooks/deny-tail.sh
4
- # Гард входа из передачи: заход, начатый с передачи, не правит файлов, пока не загружено правило
5
- # ведения работы.
2
+ # rt-hook: PreToolUse Edit|Write|MultiEdit|Bash|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_tool
3
+ # Requires: rules/task-flow.md, hooks/deny-tail.sh, hooks/write-targets.sh
4
+ # Handover entry guard: a session started from a handover edits no file until the work-conduct rule
5
+ # is loaded.
6
6
  #
7
- # Передача написана прошлым заходом, лежит вне дерева и не читается ни одной проверкой. Её
8
- # читают как задание — и берутся за работу мимо правила: состояние не сверено с деревом, числа
9
- # взяты на веру, порядок входа исполняется по памяти. Порядок, записанный только словами,
10
- # исполняется, пока о нём помнят.
7
+ # The handover was written by the previous session, lies outside the tree and is read by no check.
8
+ # It gets read as an assignment, and work begins past the rule: the state is not checked against the
9
+ # tree, the numbers are taken on trust, the entry order is followed from memory. An order written
10
+ # only in words is followed as long as someone remembers it.
11
11
  #
12
- # Заход узнаётся по первой реплике владельца: в ней назван путь к передаче либо её текст.
13
- # Загрузка правила — по вызову инструмента правил за тот же заход.
12
+ # The session is recognised by the owner's first message: it names the handover path or carries its
13
+ # text. The rule load is recognised by a call of the rules tool in the same session.
14
14
  #
15
- # FAIL-OPEN: нет `jq`, нет записи хода, передачи в реплике нет → пропуск.
15
+ # FAIL-OPEN: no `jq`, no transcript, no handover in the message → pass.
16
16
 
17
- # Своё имя в наблюдениях: отбой пишет общий хвост отказа, а не сам гард.
17
+ # Its own name in the observations: the refusal is recorded by the shared deny tail, not by the
18
+ # guard itself.
18
19
  RT_GUARD_NAME=handoff-entry-guard
19
20
 
20
21
  . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
@@ -25,9 +26,27 @@ input="$RT_HOOK_INPUT"
25
26
  [ -z "$input" ] && exit 0
26
27
  command -v jq >/dev/null 2>&1 || exit 0
27
28
 
29
+ rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
30
+
31
+ # The write targets are taken by the shared parse: the same sign serves the guard of the place of an
32
+ # edit, and two copies of it would let through different shapes of a write. No file — a silent
33
+ # default remains, so that the guard does not break on an incomplete layout.
34
+ # shellcheck disable=SC1090
35
+ [ -f "$rt_hooks_dir/write-targets.sh" ] && . "$rt_hooks_dir/write-targets.sh" 2>/dev/null
36
+ command -v rt_write_targets >/dev/null 2>&1 || rt_write_targets() { cat >/dev/null; }
37
+
28
38
  tool="$(rt_hook_tool)"
29
39
  case "$tool" in
30
40
  Edit | Write | MultiEdit) ;;
41
+ # A write by a shell command is the same edit of a file: the same session with the name of the
42
+ # shell instead of the name of the edit worked past the rule whole. A command that writes
43
+ # nothing the guard does not wake: it must not get in the way of reading the tree, which is
44
+ # exactly what the order of entry begins with.
45
+ Bash | mcp__webstorm__execute_terminal_command | mcp__webstorm__execute_tool)
46
+ cmd="$(rt_hook_cmd)"
47
+ [ -z "$cmd" ] && exit 0
48
+ [ -n "$(printf '%s' "$cmd" | rt_write_targets)" ] || exit 0
49
+ ;;
31
50
  *) exit 0 ;;
32
51
  esac
33
52
 
@@ -35,7 +54,8 @@ transcript="$(printf '%s' "$input" | jq -r '.transcript_path // empty' 2>/dev/nu
35
54
  [ -z "$transcript" ] && exit 0
36
55
  [ -f "$transcript" ] || exit 0
37
56
 
38
- # Имя правила ведения работы у дерева своё, но каталог передач общий: гард смотрит оба признака.
57
+ # The work-conduct rule has its own name in each tree, but the handover directory is shared: the
58
+ # guard looks at both signs.
39
59
  rule="${RT_TASK_FLOW_RULE:-task-flow}"
40
60
 
41
61
  verdict="$(jq -s -r --arg rule "$rule" '
@@ -46,24 +66,24 @@ verdict="$(jq -s -r --arg rule "$rule" '
46
66
  | ((.name // "") + " " + ((.input.skill // .input.command // "") | tostring))] as $used
47
67
  | (($said | join("\n")) | test("handoff|передач[аи][[:space:]]+захода")) as $from_handoff
48
68
  | (($used | join("\n")) | test("Skill[[:space:]]+" + $rule + "|skills/" + $rule)) as $loaded
49
- | if ($from_handoff and ($loaded | not)) then "нет-правила" else "ладно" end
69
+ | if ($from_handoff and ($loaded | not)) then "no-rule" else "fine" end
50
70
  ' "$transcript" 2>/dev/null)"
51
71
 
52
- [ "$verdict" = "нет-правила" ] || exit 0
72
+ [ "$verdict" = "no-rule" ] || exit 0
53
73
 
54
- reason="BLOCKED by handoff-entry-guard: заход начат с передачи, а правило ведения работы за него не загружено.
74
+ reason="BLOCKED by handoff-entry-guard: the session began from a handover, and the rule of work conduct is not loaded for it.
55
75
 
56
- Передача написана прошлым заходом, лежит вне дерева и не читается ни одной проверкой: всё, что в ней стоит, проверяется деревом. Порядок входа — четыре шага:
76
+ The handover was written by the previous session, lies outside the tree and is read by no check: everything standing in it is verified against the tree. The order of entry is four steps:
57
77
 
58
- 1. правило ведения работы и паттерн возвращения — первым движением;
59
- 2. ветка и состояние работы читаются в дереве, а не в передаче;
60
- 3. числа из передачи пересчитываются на текущем коммите;
61
- 4. следующий шаг берётся из хода работы.
78
+ 1. the rule of work conduct and the pattern of returning — by the first move;
79
+ 2. the branch and the state of the work are read in the tree, not in the handover;
80
+ 3. the numbers from the handover are recomputed on the current commit;
81
+ 4. the next step is taken from the progress.
62
82
 
63
- Загрузи правило и повтори правку."
83
+ Load the rule and repeat the edit."
64
84
 
65
- # Общий хвост отказа: два законных хода и законная форма обхода, если она у отказа есть.
66
- # Файл может быть не разложен — тогда хвоста нет, а причина отказа остаётся прежней.
85
+ # The shared deny tail: the two lawful moves and the lawful form of bypass, if the refusal has one.
86
+ # The file may not be laid out — then there is no tail, and the refusal reason stays as it is.
67
87
  # shellcheck disable=SC1090
68
88
  [ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
69
89
  && . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
@@ -74,5 +94,5 @@ deny_tail_text="$(rt_deny_tail "")"
74
94
  ${deny_tail_text}"
75
95
 
76
96
  jq -n --arg r "$reason" '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:$r}}' 2>/dev/null \
77
- || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"handoff-entry-guard: правило ведения работы не загружено."}}\n'
97
+ || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"handoff-entry-guard: the rule of work conduct is not loaded."}}\n'
78
98
  exit 0