@rt-tools/agent-kit 0.23.0 → 0.26.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 (288) hide show
  1. package/README.md +8 -2
  2. package/assets/agents/business-analyst.md +51 -50
  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-epics.github.mjs +75 -41
  15. package/assets/checks/board-folders.mjs +61 -0
  16. package/assets/checks/board-gh.github.mjs +35 -26
  17. package/assets/checks/board-long-work.github.mjs +24 -24
  18. package/assets/checks/board-paths.github.mjs +21 -16
  19. package/assets/checks/board-runs.github.mjs +45 -43
  20. package/assets/checks/board-titles.github.mjs +19 -17
  21. package/assets/checks/board.github.mjs +150 -128
  22. package/assets/checks/check-archive-age.mjs +23 -19
  23. package/assets/checks/check-board.github.mjs +179 -157
  24. package/assets/checks/check-descriptions.mjs +30 -29
  25. package/assets/checks/check-doc-paths.mjs +104 -82
  26. package/assets/checks/check-dupes.mjs +84 -80
  27. package/assets/checks/check-file-size.mjs +79 -70
  28. package/assets/checks/check-glossary.mjs +47 -37
  29. package/assets/checks/check-hook-scope.mjs +30 -27
  30. package/assets/checks/check-lib-layers.mjs +22 -21
  31. package/assets/checks/check-profile-drift.mjs +48 -43
  32. package/assets/checks/check-prose-style.mjs +125 -33
  33. package/assets/checks/check-push-gate.mjs +53 -50
  34. package/assets/checks/check-reuse.mjs +50 -40
  35. package/assets/checks/check-schema-drift.mjs +87 -83
  36. package/assets/checks/check-specs.mjs +155 -134
  37. package/assets/checks/check-state-next.mjs +66 -52
  38. package/assets/checks/check-states.mjs +32 -30
  39. package/assets/checks/check-styles.mjs +52 -51
  40. package/assets/checks/check-turn-map.mjs +54 -46
  41. package/assets/checks/lib-boundaries.mjs +32 -30
  42. package/assets/checks/lib-common.mjs +30 -29
  43. package/assets/checks/lib-domains.mjs +34 -34
  44. package/assets/checks/lib-manifests.mjs +17 -15
  45. package/assets/checks/lib-reexports.mjs +18 -18
  46. package/assets/checks/rt-kit-checks.config.mjs +174 -142
  47. package/assets/checks/signals.mjs +43 -39
  48. package/assets/checks/spec-anchors.mjs +114 -87
  49. package/assets/checks/spec-common.mjs +128 -84
  50. package/assets/checks/spec-contract.mjs +30 -30
  51. package/assets/checks/spec-proposed.mjs +27 -24
  52. package/assets/checks/spec-scenarios.mjs +51 -28
  53. package/assets/checks/task-new.github.mjs +85 -56
  54. package/assets/commands/feedback.md +65 -59
  55. package/assets/commands/next-session.md +64 -57
  56. package/assets/commands/skill-curator.md +83 -79
  57. package/assets/defaults/gate-map.sh +115 -91
  58. package/assets/defaults/project.sh +228 -178
  59. package/assets/defaults/shell.sh +85 -65
  60. package/assets/defaults/turn-map.md +45 -44
  61. package/assets/docs/GLOSSARY.md +142 -65
  62. package/assets/hooks/browser-device-id.sh +12 -12
  63. package/assets/hooks/browser-guard-device-id.sh +46 -14
  64. package/assets/hooks/browser-guard-no-asking.sh +5 -4
  65. package/assets/hooks/browser-guard-no-listing.sh +12 -11
  66. package/assets/hooks/browser-guard-no-other-drivers.sh +48 -42
  67. package/assets/hooks/browser-guard-require-select.sh +34 -23
  68. package/assets/hooks/claim-guard.sh +62 -56
  69. package/assets/hooks/commit-msg.sh +11 -10
  70. package/assets/hooks/conscience-guard.sh +91 -45
  71. package/assets/hooks/constitution-index.sh +16 -16
  72. package/assets/hooks/deny-tail.sh +28 -26
  73. package/assets/hooks/dev-server-guard.sh +46 -43
  74. package/assets/hooks/dispatch.sh +84 -39
  75. package/assets/hooks/docs-guard.sh +105 -86
  76. package/assets/hooks/exam-guard.sh +146 -84
  77. package/assets/hooks/git-guard-delivery-conflict.sh +38 -36
  78. package/assets/hooks/git-guard-delivery-draft.sh +85 -0
  79. package/assets/hooks/git-guard-delivery-folder.sh +50 -43
  80. package/assets/hooks/git-guard-delivery-signature.sh +88 -52
  81. package/assets/hooks/git-guard-delivery.sh +207 -253
  82. package/assets/hooks/git-guard-main.sh +65 -26
  83. package/assets/hooks/git-guard-push-tests.sh +133 -75
  84. package/assets/hooks/glossary-load.sh +23 -22
  85. package/assets/hooks/grill-gate-ask.sh +12 -11
  86. package/assets/hooks/grill-gate.sh +94 -87
  87. package/assets/hooks/guard-note.sh +20 -19
  88. package/assets/hooks/handoff-entry-guard.sh +26 -24
  89. package/assets/hooks/handoff-write.sh +74 -67
  90. package/assets/hooks/hook-input.sh +70 -50
  91. package/assets/hooks/lint-after-edit.sh +95 -61
  92. package/assets/hooks/observe.sh +28 -26
  93. package/assets/hooks/override-write-guard.sh +23 -21
  94. package/assets/hooks/postmortem-guard.sh +42 -39
  95. package/assets/hooks/profile-check.sh +22 -20
  96. package/assets/hooks/proposal-guard.sh +57 -49
  97. package/assets/hooks/prose-style-guard.sh +19 -17
  98. package/assets/hooks/qa-dataid-guard.sh +52 -49
  99. package/assets/hooks/rerun-guard.sh +31 -30
  100. package/assets/hooks/reuse-first-guard.sh +108 -87
  101. package/assets/hooks/roles.sh +14 -14
  102. package/assets/hooks/rule-article.sh +36 -34
  103. package/assets/hooks/rule-source-guard.sh +52 -36
  104. package/assets/hooks/skill-gate-layers.sh +59 -57
  105. package/assets/hooks/skill-gate-rearm.sh +15 -8
  106. package/assets/hooks/skill-gate.sh +89 -81
  107. package/assets/hooks/skill-loaded.sh +6 -6
  108. package/assets/hooks/sql-guard-parse.sh +68 -66
  109. package/assets/hooks/sql-guard-request.sh +48 -46
  110. package/assets/hooks/sql-guard-target.sh +57 -51
  111. package/assets/hooks/sql-guard-write.sh +84 -79
  112. package/assets/hooks/sql-guard.sh +52 -47
  113. package/assets/hooks/stand-login-guard.sh +104 -0
  114. package/assets/hooks/task-context-load.sh +60 -55
  115. package/assets/hooks/task-flow-context.sh +87 -69
  116. package/assets/hooks/task-flow-draft-guard.sh +55 -48
  117. package/assets/hooks/task-flow-guard.sh +67 -64
  118. package/assets/hooks/turn-entry-load.sh +39 -32
  119. package/assets/hooks/turn-exit-guard.sh +256 -204
  120. package/assets/hooks/turn-exit-patterns.sh +53 -0
  121. package/assets/hooks/utf8.sh +11 -11
  122. package/assets/hooks/waiting-turn-guard.sh +94 -94
  123. package/assets/hooks/window-fill-guard.sh +70 -62
  124. package/assets/hooks/work-start-guard.sh +52 -49
  125. package/assets/hooks/write-targets.sh +115 -30
  126. package/assets/laws/autonomous-work.md +29 -27
  127. package/assets/laws/code-structure.md +31 -30
  128. package/assets/laws/delivery.md +148 -137
  129. package/assets/laws/entity-editing.md +52 -50
  130. package/assets/laws/entity-models.md +14 -13
  131. package/assets/laws/frontend-application.md +39 -38
  132. package/assets/laws/lib-imports.md +27 -27
  133. package/assets/laws/lists.md +31 -29
  134. package/assets/laws/navigation.md +37 -37
  135. package/assets/laws/observability.md +41 -40
  136. package/assets/laws/project-documentation.md +106 -99
  137. package/assets/laws/reuse-first.md +31 -29
  138. package/assets/laws/shared-code.md +27 -27
  139. package/assets/laws/verifiability.md +131 -114
  140. package/assets/laws/work-conduct.md +250 -250
  141. package/assets/patterns/admin-lists-screen.md +72 -69
  142. package/assets/patterns/admin-nav-item.md +51 -46
  143. package/assets/patterns/angular-patterns-state.md +32 -31
  144. package/assets/patterns/api-layer-pair.md +33 -31
  145. package/assets/patterns/autonomous-work-run.md +50 -49
  146. package/assets/patterns/browser-verification-measure.md +143 -67
  147. package/assets/patterns/browser-verification-stand.md +181 -128
  148. package/assets/patterns/component-structure-new.md +51 -42
  149. package/assets/patterns/dependencies-upgrade.md +55 -39
  150. package/assets/patterns/doc-style-human.md +93 -0
  151. package/assets/patterns/doc-style-sweep.md +82 -79
  152. package/assets/patterns/doc-style-trace.md +87 -81
  153. package/assets/patterns/doc-style-write.md +130 -122
  154. package/assets/patterns/entity-aside.md +77 -63
  155. package/assets/patterns/entity-models-new.md +37 -37
  156. package/assets/patterns/entity-store.md +33 -33
  157. package/assets/patterns/git-workflow-commit.azure.md +94 -75
  158. package/assets/patterns/git-workflow-commit.github.md +153 -129
  159. package/assets/patterns/git-workflow-commit.gitlab.md +96 -78
  160. package/assets/patterns/git-workflow-docker.md +165 -147
  161. package/assets/patterns/git-workflow-freshness.md +45 -45
  162. package/assets/patterns/git-workflow-merge.md +99 -86
  163. package/assets/patterns/git-workflow-migration.md +54 -52
  164. package/assets/patterns/git-workflow-pr-ready.md +57 -56
  165. package/assets/patterns/git-workflow-pr.azure.md +126 -121
  166. package/assets/patterns/git-workflow-pr.github.md +179 -175
  167. package/assets/patterns/git-workflow-pr.gitlab.md +138 -131
  168. package/assets/patterns/git-workflow-restart.md +35 -31
  169. package/assets/patterns/git-workflow-secrets.md +80 -73
  170. package/assets/patterns/git-workflow-stack.md +131 -106
  171. package/assets/patterns/lib-layers-move.md +62 -53
  172. package/assets/patterns/lib-layers-new.md +59 -45
  173. package/assets/patterns/observability-record.md +72 -67
  174. package/assets/patterns/platform-access-di.md +31 -29
  175. package/assets/patterns/reuse-first-extend.md +66 -61
  176. package/assets/patterns/shared-code-new.md +39 -38
  177. package/assets/patterns/spec-driven-domain.md +161 -151
  178. package/assets/patterns/spec-driven-rule.md +179 -168
  179. package/assets/patterns/spec-driven-sweep.md +41 -39
  180. package/assets/patterns/status-report-table.github.md +37 -36
  181. package/assets/patterns/styling-bem-component.md +42 -42
  182. package/assets/patterns/styling-bem-layout.md +39 -34
  183. package/assets/patterns/styling-bem-sheet.md +59 -58
  184. package/assets/patterns/task-flow-archive.md +222 -215
  185. package/assets/patterns/task-flow-close.md +215 -203
  186. package/assets/patterns/task-flow-handoff.md +154 -145
  187. package/assets/patterns/task-flow-resume.md +138 -133
  188. package/assets/patterns/task-flow-start.md +204 -192
  189. package/assets/patterns/testing-e2e.md +103 -92
  190. package/assets/patterns/testing-unit.md +77 -70
  191. package/assets/patterns/ts-procedure.md +32 -29
  192. package/assets/patterns/turn-entry-map.md +50 -48
  193. package/assets/pitfalls/agent-kit.md +152 -141
  194. package/assets/pitfalls/doc-style.md +96 -91
  195. package/assets/pitfalls/git-workflow.azure.md +49 -46
  196. package/assets/pitfalls/git-workflow.github.md +264 -234
  197. package/assets/pitfalls/git-workflow.gitlab.md +49 -45
  198. package/assets/pitfalls/spec-driven.md +73 -71
  199. package/assets/pitfalls/styling-bem.md +46 -40
  200. package/assets/pitfalls/task-flow.md +262 -246
  201. package/assets/pitfalls/testing.md +99 -92
  202. package/assets/pitfalls/turn-conduct.md +96 -81
  203. package/assets/rules/angular-patterns.md +81 -80
  204. package/assets/rules/api-layer.md +77 -74
  205. package/assets/rules/autonomous-work.md +75 -74
  206. package/assets/rules/browser-verification.md +223 -188
  207. package/assets/rules/component-structure.md +72 -69
  208. package/assets/rules/dependencies.md +74 -67
  209. package/assets/rules/deploy-flow.azure.md +118 -108
  210. package/assets/rules/deploy-flow.github.md +145 -135
  211. package/assets/rules/deploy-flow.gitlab.md +120 -110
  212. package/assets/rules/doc-style.md +209 -148
  213. package/assets/rules/entity-conventions.needs-admin.md +81 -79
  214. package/assets/rules/entity-models.md +73 -70
  215. package/assets/rules/git-workflow.azure.md +224 -228
  216. package/assets/rules/git-workflow.github.md +250 -242
  217. package/assets/rules/git-workflow.gitlab.md +218 -217
  218. package/assets/rules/lib-layers.md +85 -86
  219. package/assets/rules/lists.md +101 -97
  220. package/assets/rules/navigation.md +78 -78
  221. package/assets/rules/observability.needs-app.md +165 -153
  222. package/assets/rules/platform-access.md +76 -75
  223. package/assets/rules/reuse-first.md +153 -137
  224. package/assets/rules/shared-code.md +82 -79
  225. package/assets/rules/spec-driven.md +272 -260
  226. package/assets/rules/status-report.md +55 -58
  227. package/assets/rules/styling-bem.md +83 -72
  228. package/assets/rules/task-flow.md +282 -270
  229. package/assets/rules/testing.md +224 -188
  230. package/assets/rules/turn-conduct.md +255 -258
  231. package/assets/rules/turn-entry.md +92 -87
  232. package/assets/rules/typescript-conventions.md +94 -88
  233. package/assets/samples/specs/_template/spec.md +47 -47
  234. package/assets/samples/tasks/_template/grill.md +20 -20
  235. package/assets/samples/tasks/_template/plan.md +32 -30
  236. package/assets/samples/tasks/_template/progress.md +16 -16
  237. package/assets/skills/agent-kit-extend.md +129 -113
  238. package/assets/skills/agent-kit.md +236 -222
  239. package/assets/skills/write-a-skill.md +76 -71
  240. package/assets/templates/findings.md +19 -19
  241. package/assets/templates/gate-map.sh +16 -14
  242. package/assets/templates/implementation.md +28 -27
  243. package/assets/templates/pattern.md +17 -17
  244. package/assets/templates/pitfalls.md +6 -6
  245. package/assets/templates/postmortem.md +24 -23
  246. package/assets/templates/project.sh +24 -24
  247. package/assets/templates/proposal.md +62 -60
  248. package/assets/templates/rule.md +38 -38
  249. package/assets/workflows/feature.js +46 -46
  250. package/assets/workflows/plan.js +54 -54
  251. package/lib/catalog.d.ts +2 -0
  252. package/lib/catalog.d.ts.map +1 -1
  253. package/lib/catalog.js +4 -3
  254. package/lib/catalog.js.map +1 -1
  255. package/lib/commands.d.ts.map +1 -1
  256. package/lib/commands.js +68 -4
  257. package/lib/commands.js.map +1 -1
  258. package/lib/companion.js +3 -2
  259. package/lib/companion.js.map +1 -1
  260. package/lib/enroll.d.ts +7 -1
  261. package/lib/enroll.d.ts.map +1 -1
  262. package/lib/enroll.js +13 -4
  263. package/lib/enroll.js.map +1 -1
  264. package/lib/observations.d.ts +10 -1
  265. package/lib/observations.d.ts.map +1 -1
  266. package/lib/observations.js +1 -0
  267. package/lib/observations.js.map +1 -1
  268. package/lib/override-marks.d.ts +24 -0
  269. package/lib/override-marks.d.ts.map +1 -0
  270. package/lib/override-marks.js +98 -0
  271. package/lib/override-marks.js.map +1 -0
  272. package/lib/plan.d.ts +11 -0
  273. package/lib/plan.d.ts.map +1 -1
  274. package/lib/plan.js +10 -1
  275. package/lib/plan.js.map +1 -1
  276. package/lib/ship.d.ts +0 -7
  277. package/lib/ship.d.ts.map +1 -1
  278. package/lib/ship.js +10 -2
  279. package/lib/ship.js.map +1 -1
  280. package/lib/shipment.d.ts.map +1 -1
  281. package/lib/shipment.js +7 -3
  282. package/lib/shipment.js.map +1 -1
  283. package/lib/sync.d.ts.map +1 -1
  284. package/lib/sync.js +45 -11
  285. package/lib/sync.js.map +1 -1
  286. package/package.json +1 -1
  287. package/rt-tools-agent-kit-0.26.0.tgz +0 -0
  288. package/rt-tools-agent-kit-0.23.0.tgz +0 -0
@@ -1,34 +1,36 @@
1
1
  #!/usr/bin/env bash
2
- # Общий хвост отказа. НЕ гард: объявления `rt-hook:` у него нет, к событиям агента он не
3
- # подключается. Его источают сами гарды — тем же приёмом, каким они источают запись наблюдений и
4
- # слово о нехватке функции профиля.
2
+ # The shared deny tail. NOT a guard: it has no `rt-hook:` declaration and hooks into no agent event.
3
+ # The guards source it themselves — the same way they source the observation record and the word
4
+ # about a missing profile function.
5
5
  #
6
- # Зачем он есть. Отказ гарда называет промах и способ его снять, а что делать, когда снять не
7
- # выходит, не называет никто. Пустое место занимает третий ход, которого нет в правилах: обойти
8
- # молча — командой оболочки, соседним инструментом, правкой самого гарда. Так и было: за один час
9
- # отказ обошли дважды, и оба раза правка легла мимо гарда. Ходов законных два, и оба называются
10
- # прямо в тексте отказа, а не остаются на догадку читающего.
6
+ # Why it exists. A guard's refusal names the miss and the way to lift it, and nobody names what to
7
+ # do when lifting it does not work out. The empty place is taken by a third move that is in no rule:
8
+ # bypass silently — by a shell command, by a neighbouring tool, by editing the guard itself. That is
9
+ # what happened: within one hour a refusal was bypassed twice, and both times the edit landed past
10
+ # the guard. There are two lawful moves, and both are named right in the refusal text instead of
11
+ # being left to the reader's guess.
11
12
  #
12
- # ЧТО ГОВОРИТСЯ. Починить названное и повторить вызов — либо принести владельцу цену обхода и
13
- # ждать его слова. Там, где у обхода есть законная форма — строка в теле коммита, строка в
14
- # замысле, ключ команды, — она называется тем же хвостом: обход, о котором известно, что он
15
- # законен, ищут не мимо гарда, а по его же словам.
13
+ # WHAT IS SAID. Fix what was named and repeat the call — or bring the owner the price of the bypass
14
+ # and wait for their word. Where the bypass has a lawful form — a line in the commit body, a line
15
+ # in the plan, a command flag — the same tail names it: a bypass known to be lawful is looked for by
16
+ # the guard's own words, not past the guard.
16
17
  #
17
- # ЧЕГО ХВОСТ НЕ ДЕЛАЕТ. Он не судит, годится ли обход в этом случае: это решает владелец. И он не
18
- # заменяет причины отказа — она стоит перед ним и называет промах поимённо.
18
+ # WHAT THE TAIL DOES NOT DO. It does not judge whether the bypass fits this case: the owner decides
19
+ # that. And it does not replace the refusal reason — that stands before it and names the miss by
20
+ # name.
19
21
  #
20
- # ЗАПИСЬ ОТБОЯ ИДЁТ ОТСЮДА ЖЕ. Хвост — единственное место, через которое проходит каждый отказ:
21
- # правило дерева требует называть два законных хода при любом отказе, и гард, который отказывает
22
- # мимо хвоста, нарушает его раньше, чем теряет счёт. Написанная в самом гарде, запись стояла в
23
- # пяти гардах из тридцати, и сводка отвечала по этой пятой части. Гард объявляет себя строкой
24
- # `RT_GUARD_NAME=<имя>` у себя вверху; не объявивший не пишет ничего — так своё отбитие считает
25
- # сам гейт правил.
22
+ # THE REFUSAL RECORD GOES FROM HERE TOO. The tail is the one place every refusal passes through: the
23
+ # tree's rule demands that the two lawful moves be named at every refusal, and a guard that refuses
24
+ # past the tail breaks that rule before it loses count. Written inside the guard itself, the record
25
+ # stood in five guards out of thirty, and the digest answered by that fifth. A guard declares itself
26
+ # by the line `RT_GUARD_NAME=<name>` at its top; one that has not declared writes nothing — that is
27
+ # how the rules gate counts its own refusals by itself.
26
28
 
27
- # Хвост отказа строкой. Первый параметр — законная форма обхода, если она у отказа есть; пусто —
28
- # значит законной формы нет вовсе, и говорится об этом прямо.
29
+ # The deny tail as a string. The first parameter is the lawful form of bypass, if the refusal has
30
+ # one; empty means there is no lawful form at all, and this is said outright.
29
31
  #
30
- # reason="BLOCKED: <причина>. $(rt_deny_tail 'строка `Docs-skip: <причина>` в теле коммита')"
31
- # reason="BLOCKED: <причина>. $(rt_deny_tail)"
32
+ # reason="BLOCKED: <reason>. $(rt_deny_tail 'the line `Docs-skip: <reason>` in the commit body')"
33
+ # reason="BLOCKED: <reason>. $(rt_deny_tail)"
32
34
  rt_deny_tail() {
33
35
  # shellcheck disable=SC1090
34
36
  [ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/guard-note.sh" ] \
@@ -36,9 +38,9 @@ rt_deny_tail() {
36
38
  command -v rt_guard_note >/dev/null 2>&1 && rt_guard_note
37
39
 
38
40
  if [ -n "$1" ]; then
39
- printf 'Ходов отсюда два: починить названное и повторить вызов — либо принести владельцу цену обхода и ждать его слова. Законная форма обхода: %s. Молча мимо гарда правка не кладётся: он отбивает один вызов, а обойдённый снимает требование со всего дерева и молчит об этом.' "$1"
41
+ printf 'Two moves from here: fix what is named and repeat the call, or bring the owner the price of a bypass and wait for their word. The lawful form of bypass: %s. An edit is not laid past the guard in silence: it refuses one call, and a bypassed one lifts the requirement from the whole tree and says nothing about it.' "$1"
40
42
  return 0
41
43
  fi
42
44
 
43
- printf 'Ходов отсюда два: починить названное и повторить вызов — либо принести владельцу цену обхода и ждать его слова. Законной формы обхода у этого отказа нет. Молча мимо гарда правка не кладётся: он отбивает один вызов, а обойдённый снимает требование со всего дерева и молчит об этом.'
45
+ printf 'Two moves from here: fix what is named and repeat the call, or bring the owner the price of a bypass and wait for their word. There is no lawful form of bypass for this refusal. An edit is not laid past the guard in silence: it refuses one call, and a bypassed one lifts the requirement from the whole tree and says nothing about it.'
44
46
  }
@@ -1,20 +1,22 @@
1
1
  #!/usr/bin/env bash
2
2
  # rt-hook: PreToolUse Bash|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_run_configuration|mcp__webstorm__execute_tool
3
- # Требует: hooks/deny-tail.sh
4
- # Гард второго сервера разработки. PreToolUse.
3
+ # Requires: hooks/deny-tail.sh
4
+ # Guard against a second dev server. PreToolUse.
5
5
  #
6
- # Приложения уже подняты владельцем, и всякая проверка через браузер идёт туда. Второй
7
- # экземпляр занимает лишний порт, отдаёт другую сборку и уводит разбор в сторону: расхождение
8
- # между двумя серверами читается как дефект правки. Вдобавок сборка, запущенная между делом,
9
- # гасит уже поднятый сервер молча.
6
+ # The applications are already raised by the owner, and every check through the browser goes there.
7
+ # A second instance takes an extra port, serves a different build and leads the investigation
8
+ # astray: a difference between two servers reads as a defect of the edit. On top of that, a build
9
+ # started in passing silently kills the server already raised.
10
10
  #
11
- # Отбивается всё, что ПОДНИМАЕТ сервер. Сборка, тесты, линтеры, запросы к поднятым портам и
12
- # осмотр слушателей проходят.
11
+ # Everything that RAISES a server is refused. Builds, tests, linters, requests to raised ports and
12
+ # looking at listeners pass.
13
13
  #
14
- # Где именно подняты приложения, знает профиль проекта: .claude/rt-kit/project.sh, переменная
15
- # RT_STANDS. Нет профиля — текст отказа остаётся общим, сам гард работает.
14
+ # Where exactly the applications are raised is known to the project profile:
15
+ # .claude/rt-kit/project.sh, variable RT_STANDS. No profile — the refusal text stays general, the
16
+ # guard itself works.
16
17
 
17
- # Своё имя в наблюдениях: отбой пишет общий хвост отказа, а не сам гард.
18
+ # Its own name in the observations: the refusal is written by the shared deny tail, not by the
19
+ # guard itself.
18
20
  RT_GUARD_NAME=dev-server-guard
19
21
 
20
22
  . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
@@ -26,27 +28,27 @@ input="$RT_HOOK_INPUT"
26
28
  tool="$(rt_hook_tool)"
27
29
  case "$tool" in
28
30
  Bash | mcp__webstorm__execute_terminal_command | mcp__webstorm__execute_tool) ;;
29
- # Готовая конфигурация запуска командной строки не показывает — видно только её имя.
30
- # Отсюда правило: «serve», «dev» и «start» в имени отклоняются, потому что проверить, что
31
- # за ними стоит, гард не может, а второй сервер стоит дороже лишнего отказа.
31
+ # A ready run configuration does not show the command line — only its name is visible. Hence
32
+ # the rule: "serve", "dev" and "start" in the name are refused, because the guard cannot check
33
+ # what stands behind them, and a second server costs more than an extra refusal.
32
34
  mcp__webstorm__execute_run_configuration)
33
35
  name="$(printf '%s' "$input" | jq -r '.tool_input.configurationName // empty' 2>/dev/null)"
34
- # Второй режим инструмента — временная конфигурация из пары «файл и строка»: имени у
35
- # неё нет вовсе, и проверка по имени её пропускала. Именно так поднимается скрипт из
36
- # манифеста пакета.
36
+ # The tool's second mode is a temporary configuration made of a file and a line: it has
37
+ # no name at all, and the check by name let it through. That is exactly how a script from
38
+ # the package manifest is raised.
37
39
  if [ -z "$name" ]; then
38
40
  file="$(printf '%s' "$input" | jq -r '.tool_input.filePath // empty' 2>/dev/null)"
39
41
  case "$file" in
40
42
  */package.json|package.json)
41
- echo "Запуск скрипта прямо из манифеста: гард видит только файл и строку, а не сам скрипт, поэтому не может отличить подъём сервера от сборки. Приложения уже подняты владельцем — если нужна сборка или тест, запусти их командой в терминале." >&2
43
+ echo "A launch of a script straight from the manifest: the guard sees only the file and the line, not the script itself, so it cannot tell raising a server from a build. The applications are already raised by the owner — if a build or a test is needed, run them by a command in the terminal." >&2
42
44
  exit 2 ;;
43
45
  esac
44
46
  exit 0
45
47
  fi
46
- # Слово «start» без границы ловило и «restart», который сервер не поднимает.
48
+ # The word "start" without a boundary also caught "restart", which raises no server.
47
49
  case "$(printf '%s' "$name" | tr '[:upper:]' '[:lower:]')" in
48
50
  *serve*|*dev*|start*|*\ start*|*:start*)
49
- echo "Конфигурация «${name}» похожа на подъём сервера разработки, а приложения уже подняты владельцем — проверяй их. Если конфигурация делает другое, запусти это командой: по имени гард содержимого не видит." >&2
51
+ echo "The configuration «${name}» looks like raising a development server, and the applications are already raised by the owner — check those. If the configuration does something else, run it by a command: by the name alone the guard does not see the content." >&2
50
52
  exit 2 ;;
51
53
  esac
52
54
  exit 0 ;;
@@ -56,9 +58,9 @@ esac
56
58
  cmd="$(rt_hook_cmd)"
57
59
  [ -z "$cmd" ] && exit 0
58
60
 
59
- # Универсальный исполнитель среды передаёт настоящую команду вложенной строкой. Разбирать надо
60
- # её, а не обёртку: иначе имя раннера стоит сразу за кавычкой и ни одно правило до него не
61
- # дотягивается.
61
+ # The universal executor of the environment passes the real command as a nested string. It is the
62
+ # one to parse, not the wrapper: otherwise the runner name stands right after a quote and no rule
63
+ # reaches it.
62
64
  if [ "$tool" = "mcp__webstorm__execute_tool" ] && command -v perl >/dev/null 2>&1; then
63
65
  inner="$(printf '%s' "$cmd" | perl -0ne '
64
66
  if (/--command(?:=|\s+)(?:"((?:[^"\\]|\\.)*)"|\x27([^\x27]*)\x27|(.+))/s) {
@@ -68,14 +70,14 @@ if [ "$tool" = "mcp__webstorm__execute_tool" ] && command -v perl >/dev/null 2>&
68
70
  [ -n "$inner" ] && cmd="$inner"
69
71
  fi
70
72
 
71
- # Гит ничего не слушает на портах, а тексты сообщений и веток свободно содержат слова вроде
72
- # «serve» — без этой ветки гард ловит собственный коммит про себя же.
73
+ # Git listens on no port, while message and branch texts freely contain words like "serve" —
74
+ # without this branch the guard catches its own commit about itself.
73
75
  case "$cmd" in
74
76
  git\ *|*/git\ *)
75
77
  printf '%s' "$cmd" | grep -qE '(^|[[:space:]])git[[:space:]]+daemon([[:space:]]|$)' || exit 0 ;;
76
78
  esac
77
79
 
78
- # Профиль дерева: сперва умолчание пакета, поверх него — надстройка проекта, если она есть.
80
+ # The tree profile: first the package default, and over it the project override, if there is one.
79
81
  rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
80
82
  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
81
83
  # shellcheck disable=SC1090
@@ -90,39 +92,40 @@ command -v rt_deny_tail >/dev/null 2>&1 || rt_deny_tail() { :; }
90
92
 
91
93
  deny() {
92
94
  if [ -n "$stands" ]; then
93
- echo "$1 Приложения уже подняты владельцем: ${stands} — проверяй их. Свой экземпляр не поднимай; если порт не отвечает, скажи владельцу, а не запускай второй. $(rt_deny_tail)" >&2
95
+ echo "$1 The applications are already raised by the owner: ${stands} — check those. Do not raise an instance of your own; if a port does not answer, tell the owner instead of launching a second one. $(rt_deny_tail)" >&2
94
96
  else
95
- echo "$1 Приложения уже подняты владельцем — проверяй их. Свой экземпляр не поднимай; если порт не отвечает, скажи владельцу, а не запускай второй. $(rt_deny_tail)" >&2
97
+ echo "$1 The applications are already raised by the owner — check those. Do not raise an instance of your own; if a port does not answer, tell the owner instead of launching a second one. $(rt_deny_tail)" >&2
96
98
  fi
97
99
  exit 2
98
100
  }
99
101
 
100
- # Раннеры перечисляются явно. Группа «любое слово перед именем» отклоняла даже заметку о том,
101
- # что сервер поднимает владелец.
102
+ # The runners are listed outright. A group meaning "any word before the name" refused even a note
103
+ # saying that the server is raised by the owner.
102
104
  RUNNER='((npx|pnpm|yarn|bun|npm)([[:space:]]+(exec|run|dlx))?[[:space:]]+)?'
103
105
 
104
- # Начало вызова: начало строки или разделитель команд. Кавычку в границы вносить нельзя — тогда
105
- # поиск по тексту и снятие процесса по шаблону читаются как запуск.
106
+ # The start of a call: the start of the line or a command separator. A quote must not be put into
107
+ # the boundary — then a text search and killing a process by pattern read as a start.
106
108
  BOUND="$RT_CMD_BOUND"
107
109
 
108
110
  printf '%s' "$cmd" | grep -qE "${BOUND}${RUNNER}(nx|ng)[[:space:]]+(run[[:space:]]+[^[:space:]]*:)?(serve|dev)" \
109
- && deny "Запуск ещё одного сервера разработки через каркас."
111
+ && deny "A launch of one more development server through the framework."
110
112
 
111
- # Требование пробела сразу после имени рвало совпадение на двоеточии: скрипты вида «serve:site»
112
- # гард пропускал — то есть ровно те команды, ради которых написан.
113
+ # Requiring a space right after the name broke the match on a colon: the guard let through scripts
114
+ # like "serve:site" — that is, exactly the commands it is written for.
113
115
  printf '%s' "$cmd" | grep -qE "${BOUND}(npm|pnpm|yarn|bun)([[:space:]]+run)?[[:space:]]+(dev|start|serve)([:._-][A-Za-z0-9:._-]*)?([[:space:]]|\$)" \
114
- && deny "Запуск ещё одного сервера разработки через пакетный раннер."
116
+ && deny "A launch of one more development server through the package runner."
115
117
 
116
- # Подкоманда обязательна: пока она была необязательной, под правило попадало голое слово
117
- # сборщика — то есть любой однострочник, где оно встречается внутри текста.
118
+ # The subcommand is mandatory: while it was optional, the bare name of the bundler fell under the
119
+ # rule — that is, any one-liner where it occurs inside the text.
118
120
  printf '%s' "$cmd" | grep -qE "${BOUND}${RUNNER}vite([[:space:]]+(dev|serve|preview))?[[:space:]]*(\$|[;&|\"'])" \
119
- && deny "Запуск ещё одного сервера разработки."
121
+ && deny "A launch of one more development server."
120
122
  printf '%s' "$cmd" | grep -qE "${BOUND}${RUNNER}(next|astro|nuxt)[[:space:]]+(dev|start|preview)([[:space:]]|\$)" \
121
- && deny "Запуск ещё одного сервера разработки."
123
+ && deny "A launch of one more development server."
122
124
 
123
- # Статика поверх сборки — тот же второй экземпляр. Каждое имя под общим якорем начала команды:
124
- # без него перечисление пакетов и поиск по документам читались как запуск.
125
+ # Static files served over a build are the same second instance. Every name sits under the shared
126
+ # anchor of the command start: without it a package listing and a search through documents read as
127
+ # a start.
125
128
  printf '%s' "$cmd" | grep -qE "${BOUND}(python3?[[:space:]]+-m[[:space:]]+http\.server|${RUNNER}(http-server|live-server|serve)([[:space:]]|\$))" \
126
- && deny "Подъём статического сервера поверх сборки — тот же второй экземпляр."
129
+ && deny "Raising a static server on top of a build — the same second instance."
127
130
 
128
131
  exit 0
@@ -1,23 +1,26 @@
1
1
  #!/usr/bin/env bash
2
- # Диспетчер событий агента. НЕ гард: объявления `rt-hook:` у него нет — наоборот, он читает
3
- # такие объявления у остальных. В настройке агента он стоит один на событие вместо списка.
2
+ # The dispatcher of agent events. NOT a guard: it has no `rt-hook:` declaration — on the contrary,
3
+ # it reads such declarations in the others. In the agent settings it stands alone on an event
4
+ # instead of a list.
4
5
  #
5
- # Зачем он есть. Агент зовёт каждый гард своим процессом и каждому подаёт один и тот же ввод.
6
- # Гардов на вызове инструмента восемнадцать, и каждый разбирает ввод заново — по шесть-семь
7
- # вызовов разборщика. Замер этого дерева: восемьсот двадцать шесть миллисекунд на вызов, из
8
- # которых восемьдесят пять — запуск оболочек, а остальное — повторный разбор одного текста.
6
+ # Why it exists. The agent calls every guard in a process of its own and feeds each of them the same
7
+ # input. There are eighteen guards on a tool call, and each parses the input anew — six or seven
8
+ # calls of the parser. The measurement of this tree: eight hundred and twenty-six milliseconds per
9
+ # call, of which eighty-five are the starting of shells, and the rest is repeated parsing of one
10
+ # text.
9
11
  #
10
- # Что он делает. Читает ввод один раз, разбирает его один раз, кладёт поля в окружение и зовёт
11
- # ветки события по порядку. Первый ненулевой код возврата отдаётся агенту вместе с выводом
12
- # гарда — остальные ветки не зовутся: отказ и раньше кончал вызов на первом же гарде.
12
+ # What it does. It reads the input once, parses it once, puts the fields into the environment and
13
+ # calls the branches of the event in order. The first non-zero return code is given to the agent
14
+ # together with the output of the guard — the remaining branches are not called: a refusal ended the
15
+ # call at the very first guard before as well.
13
16
  #
14
- # Чего он не делает. Он не судит ничего сам и ни одного гарда не заменяет: файлы остаются как
15
- # были, меняется точка входа. Событие и образец вызова гард несёт сам, строкой `# rt-hook:` в
16
- # своей шапке, и карта собирается из них — список, выписанный отдельно, разошёлся бы с набором
17
- # файлов на первом же добавленном.
17
+ # What it does not do. It judges nothing itself and replaces no guard: the files stay as they were,
18
+ # the entry point changes. The event and the call pattern are carried by the guard itself, by the
19
+ # `# rt-hook:` line in its header, and the map is assembled from them — a list written out
20
+ # separately would diverge from the set of files at the very first one added.
18
21
  #
19
- # ОТКАЗ В ПОЛЬЗУ РАБОТЫ: нет события в доводе, нет каталога гардов, нет разборщика — выход нулём.
20
- # Сломанный диспетчер не имеет права заклинить работу.
22
+ # FAIL-OPEN, IN FAVOUR OF WORK: no event in the argument, no guards directory, no parser — exit with
23
+ # zero. A broken dispatcher has no right to jam the work.
21
24
 
22
25
  set -u
23
26
 
@@ -30,15 +33,15 @@ event="${1:-}"
30
33
  input="$(cat 2>/dev/null)"
31
34
  [ -z "$input" ] && exit 0
32
35
 
33
- # Разбор один на все ветки: четыре поля одним вызовом разборщика вместо шести на каждый гард.
34
- # Значения приходят уже закавыченными для оболочки — `@sh` в разборщике для того и сделан:
35
- # командная строка держит и кавычки, и переводы строк, и подставить её иначе нельзя.
36
- assignments="$(printf '%s' "$input" | jq -r '@sh "RT_HOOK_TOOL=\(.tool_name // "") RT_HOOK_CMD=\(.tool_input.command // "") RT_HOOK_FILE=\(.tool_input.file_path // "") RT_HOOK_CWD=\(.cwd // "")"' 2>/dev/null)"
36
+ # One parse for all the branches: four fields by one call of the parser instead of six per guard.
37
+ # The values arrive already quoted for the shell — that is what `@sh` in the parser is made for: the
38
+ # command line holds both quotes and newlines, and there is no other way to substitute it.
39
+ assignments="$(printf '%s' "$input" | jq -r '@sh "RT_HOOK_TOOL=\(.tool_name // "") RT_HOOK_CMD=\(.tool_input.command // "") RT_HOOK_FILE=\(.tool_input.file_path // "") RT_HOOK_CWD=\(.cwd // "") RT_HOOK_SOURCE=\(.source // "")"' 2>/dev/null)"
37
40
  if [ -n "$assignments" ]; then
38
41
  eval "$assignments" 2>/dev/null || true
39
- export RT_HOOK_TOOL RT_HOOK_CMD RT_HOOK_FILE RT_HOOK_CWD
40
- # Признак разбора: по нему ветки отличают готовое поле от пустой переменной, случайно
41
- # оказавшейся в окружении прогона. Без него пустое значение читается как «поля нет».
42
+ export RT_HOOK_TOOL RT_HOOK_CMD RT_HOOK_FILE RT_HOOK_CWD RT_HOOK_SOURCE
43
+ # The sign of parsing: by it the branches tell a ready field from an empty variable that ended
44
+ # up in the run environment by chance. Without it an empty value reads as "there is no field".
42
45
  export RT_HOOK_PARSED=1
43
46
  fi
44
47
  export RT_HOOK_INPUT="$input"
@@ -46,9 +49,10 @@ export RT_HOOK_INPUT="$input"
46
49
  branches="$(grep -l '^# rt-hook:' "$here"/*.sh 2>/dev/null | sort)"
47
50
  [ -z "$branches" ] && exit 0
48
51
 
49
- # Объявлений у файла бывает несколько: гард, стоящий и на вызове инструмента, и на завершении
50
- # хода, называет оба события своими строками. Читалось прежде только первое — и вторая ветка не
51
- # звалась ни разу, молча: снаружи это неотличимо от гарда, который посмотрел и пропустил.
52
+ # A file happens to have several declarations: a guard standing both on a tool call and on the end
53
+ # of a turn names both events by lines of its own. Before, only the first was read — and the second
54
+ # branch was never called, silently: from the outside that is indistinguishable from a guard that
55
+ # looked and let through.
52
56
  collected=""
53
57
  for branch in $branches; do
54
58
  matched=0
@@ -58,13 +62,21 @@ for branch in $branches; do
58
62
  branch_event="${declaration%% *}"
59
63
  [ "$branch_event" = "$event" ] || continue
60
64
 
61
- # Образец вызова: его нет вовсе — гард зовётся на любом; есть — сверяется с именем
62
- # инструмента целиком, а не куском. Звёздочка и точка со звёздочкой значат одно: любой
63
- # вызов.
65
+ # The call pattern: there is none at all — the guard is called on any; there is one — it is
66
+ # matched in full, not by a piece. A star and a dot with a star mean the same: any call.
67
+ #
68
+ # The subject of the match depends on the event. For a tool call it is the tool name; at the
69
+ # entry into a session there is no tool name, and the pattern there names the kind of start
70
+ # — `startup`, `resume`, `compact`, `clear`. A match against an empty name never coincided,
71
+ # and not a single entry hook was called through the dispatcher: the session began without
72
+ # the body of laws, without the glossary, without the work state and without the handover of
73
+ # the previous session — with a zero code and empty output.
64
74
  matcher="${declaration#"$branch_event"}"
65
75
  matcher="${matcher#"${matcher%%[![:space:]]*}"}"
76
+ subject="${RT_HOOK_TOOL:-}"
77
+ [ -z "$subject" ] && subject="${RT_HOOK_SOURCE:-}"
66
78
  if [ -n "$matcher" ] && [ "$matcher" != '*' ] && [ "$matcher" != '.*' ]; then
67
- [[ "${RT_HOOK_TOOL:-}" =~ ^(${matcher})$ ]] || continue
79
+ [[ "$subject" =~ ^(${matcher})$ ]] || continue
68
80
  fi
69
81
 
70
82
  matched=1
@@ -73,21 +85,54 @@ for branch in $branches; do
73
85
  $(sed -n 's/^# rt-hook:[[:space:]]*//p' "$branch" 2>/dev/null)
74
86
  EOF
75
87
 
76
- # Совпало хоть одно объявление — ветка зовётся один раз. Два объявления одного события в
77
- # одном файле звали бы гард дважды на один ввод, и второй вызов судил бы то же самое.
88
+ # At least one declaration matched — the branch is called once. Two declarations of one event in
89
+ # one file would call the guard twice on one input, and the second call would judge the same
90
+ # thing.
78
91
  [ "$matched" = 1 ] || continue
79
92
 
80
- branch_out="$(printf '%s' "$input" | bash "$branch" 2>/dev/null)"
81
- code=$?
93
+ # The error stream of a branch is collected separately, not discarded: on a successful turn it
94
+ # is noise and does not go out, and on a refusal it is the reason itself. A guard that prints
95
+ # its refusal there reached the executor as a line about a broken file — with the file whole and
96
+ # the text plain, which nobody saw. In one session two refusals in a row were lost that way.
97
+ branch_err="$(mktemp 2>/dev/null)"
98
+ if [ -n "$branch_err" ]; then
99
+ branch_out="$(printf '%s' "$input" | bash "$branch" 2>"$branch_err")"
100
+ code=$?
101
+ said_err="$(cat "$branch_err" 2>/dev/null)"
102
+ rm -f "$branch_err" 2>/dev/null
103
+ else
104
+ branch_out="$(printf '%s' "$input" | bash "$branch" 2>/dev/null)"
105
+ code=$?
106
+ said_err=""
107
+ fi
82
108
  if [ "$code" -ne 0 ]; then
83
- [ -n "$branch_out" ] && printf '%s\n' "$branch_out"
109
+ if [ -n "$branch_out" ]; then
110
+ printf '%s\n' "$branch_out"
111
+ elif [ -n "$said_err" ]; then
112
+ printf '%s\n' "$said_err"
113
+ else
114
+ # The branch exited non-zero and said nothing by either stream. From the outside that
115
+ # is indistinguishable from a refusal on the merits, and there is nothing to fix: nobody
116
+ # knows which file is broken. So the dispatcher names it itself, otherwise nothing says
117
+ # anything about a broken branch.
118
+ printf 'The guard %s exited with code %s and printed nothing: the file looks broken.\n' \
119
+ "$(basename "$branch")" "$code"
120
+ fi
84
121
  exit "$code"
85
122
  fi
86
123
 
87
- # Отбой ветки приходит не кодом возврата, а решением в выводе: гарды завершения хода
88
- # печатают его и выходят нулём. Не остановившись здесь, диспетчер склеил бы этот объект с
89
- # выводом следующей ветки — а склеенное не разбирается, и отбой пропадает целиком.
90
- if [ -n "$branch_out" ] && printf '%s' "$branch_out" | jq -e '.decision == "block"' >/dev/null 2>&1; then
124
+ # A refusal from a branch comes not as a return code but as a decision in the output: the guards
125
+ # of the end of a turn print it and exit with zero. Without stopping here, the dispatcher would
126
+ # glue this object to the output of the next branch — and what is glued together is not parsed,
127
+ # so the refusal is lost entirely. There are two forms of a refusal under a zero code: the block
128
+ # decision of the guards of the end of a turn and the call-denied decision of the guards of an
129
+ # edit. The second was not recognised at all — the refusal went into the shared collected output
130
+ # and was glued to the output of a neighbouring branch, and what is glued together is not
131
+ # parsed: a guard called on its own answered with a denial, while through the dispatcher the
132
+ # refusal was lost entirely.
133
+ if [ -n "$branch_out" ] && printf '%s' "$branch_out" | jq -e '
134
+ .decision == "block" or .hookSpecificOutput.permissionDecision == "deny"
135
+ ' >/dev/null 2>&1; then
91
136
  printf '%s\n' "$branch_out"
92
137
  exit 0
93
138
  fi
@@ -96,7 +141,7 @@ EOF
96
141
  "
97
142
  done
98
143
 
99
- # Ни одна ветка не отбила: отдаётся то, что они напечатали, — подсказки и сводки.
144
+ # Not one branch refused: what they printed is given out — hints and digests.
100
145
  [ -n "${collected:-}" ] && printf '%s' "$collected"
101
146
 
102
147
  exit 0