@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,27 +1,29 @@
1
1
  #!/usr/bin/env bash
2
2
  # rt-hook: PreToolUse Edit|Write|MultiEdit|Bash|mcp__webstorm__create_new_file|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_tool|mcp__claude-in-chrome__.*
3
- # Требует: hooks/deny-tail.sh
4
- # Гейт правил: не даёт править файл, пока не загружено правило, под которое он подпадает.
3
+ # Requires: hooks/deny-tail.sh
4
+ # The rules gate: it does not let a file be edited until the rule it falls under has been loaded.
5
5
  #
6
- # Закон и правило, которых никто не открывает, не действуют. Напоминание в подсказке помогает
7
- # ровно до первой спешки, поэтому требование держит хук: правка отбивается ОДИН раз на сессию
8
- # для каждой области, а после загрузки правила та же область проходит молча — повторов нет, и
9
- # стоит это почти ничего.
6
+ # A law and a rule nobody opens do not act. A reminder in the prompt helps right up to the first
7
+ # rush, so the requirement is held by a hook: an edit is refused ONCE per session for each area,
8
+ # and after the rule is loaded the same area passes silently — there are no repeats, and it costs
9
+ # almost nothing.
10
10
  #
11
- # Карта «файл — правило» живёт не здесь, а в двух файлах рядом, и это не дублирование.
12
- # Умолчание — `.claude/rt-kit/defaults/gate-map.sh` — везёт пакет: деревья этой мастерской
13
- # устроены одинаково, и переписывать одну и ту же карту в каждом заново значило бы заводить
14
- # столько её редакций, сколько репозиториев. Надстройку — `.claude/rt-kit/gate-map.sh` — пишет
15
- # проект, и она необязательна: витрина, свой род файлов, чужая раскладка есть не у всех.
16
- # Обе объявляют `skill_for <род вызова> <цель> <текст правки>`, печатающую имена правил через
17
- # пробел; надстройка грузится второй и вправе позвать умолчание обратно — `skill_for_default`.
18
- # Нет ни одной — гейт пропускает всё: пустой гейт лучше гейта, отбивающего наугад.
11
+ # The "file — rule" map lives not here but in two files next door, and that is not duplication.
12
+ # The default — `.claude/rt-kit/defaults/gate-map.sh` — is carried by the package: the trees of
13
+ # this workshop are built alike, and rewriting one and the same map in each of them anew would
14
+ # mean as many editions of it as there are repositories. The override —
15
+ # `.claude/rt-kit/gate-map.sh` — is written by the project, and it is optional: a showcase, a file
16
+ # kind of its own, someone else's layout are not in every tree. Both declare
17
+ # `skill_for <call kind> <target> <edit text>`, printing rule names separated by a space; the
18
+ # override is loaded second and may call the default back — `skill_for_default`. There is neither
19
+ # — the gate passes everything: an empty gate is better than a gate that refuses at random.
19
20
  #
20
- # Род вызова — `edit`, `bash` или `browser`. Браузерная проверка — единственная область, где
21
- # правило нужно не под правку файла, а под инструмент: врут там не файлы, а стенд и координаты.
21
+ # The call kind is `edit`, `bash` or `browser`. Browser verification is the only area where a rule
22
+ # is needed not for a file edit but for a tool: what lies there is not the files but the stand and
23
+ # the coordinates.
22
24
  #
23
- # ОТКАЗ В ПОЛЬЗУ РАБОТЫ: любая ошибка и любой неопознанный путь пропускают правку (exit 0).
24
- # Сломанный гейт не имеет права остановить работу совсем.
25
+ # FAIL-OPEN: any error and any unrecognised path let the edit through (exit 0). A broken gate has
26
+ # no right to stop the work altogether.
25
27
 
26
28
  . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
27
29
  . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
@@ -33,7 +35,7 @@ input="$RT_HOOK_INPUT"
33
35
  sid="$(printf '%s' "$input" | jq -r '.session_id // "nosession"' 2>/dev/null)"
34
36
  tool="$(rt_hook_tool)"
35
37
 
36
- # Умолчание карты ищется и рядом с самим хуком: уезжают они вместе.
38
+ # The default map is looked for next to the hook itself too: they travel together.
37
39
  rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
38
40
  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
39
41
  # shellcheck disable=SC1090
@@ -45,46 +47,48 @@ req=""
45
47
  target=""
46
48
  kind=""
47
49
  case "$tool" in
48
- # Инструмент среды заводит файл теми же двумя данными, только называет их иначе — без этой
49
- # ветки файл заводился мимо гейта.
50
+ # The environment tool creates a file with the same two pieces of data, only it calls them
51
+ # differently — without this branch a file was created past the gate.
50
52
  Edit|Write|MultiEdit|mcp__webstorm__create_new_file)
51
53
  target="$(printf '%s' "$input" | jq -r '.tool_input.file_path // .tool_input.pathInProject // empty' 2>/dev/null)"
52
54
  [ -z "$target" ] && exit 0
53
- # Путь от корня проекта приводится к абсолютному один раз: иначе карту пришлось бы
54
- # писать в двух формах, и вторая расходилась бы с первой молча.
55
+ # A path from the project root is brought to absolute once: otherwise the map would have
56
+ # to be written in two forms, and the second would silently diverge from the first.
55
57
  case "$target" in
56
58
  /*) ;;
57
59
  ?*) target="${CLAUDE_PROJECT_DIR:-.}/$target" ;;
58
60
  esac
59
- # Правила этого дерева действуют на файлы этого дерева. Без проверки корня гейт ловил
60
- # бы и соседний репозиторий на той же машине.
61
+ # The rules of this tree act on the files of this tree. Without the root check the gate
62
+ # would catch a neighbouring repository on the same machine too.
61
63
  case "$target" in
62
64
  "${CLAUDE_PROJECT_DIR:-.}"/*) ;;
63
65
  *) exit 0 ;;
64
66
  esac
65
- # Текст правки идёт карте вторым доводом: есть правила, которые вступают не от того,
66
- # ЧТО за файл правится, а от того, ЧТО в него пишут, — обращение к среде исполнения
67
- # приходит в обычный сервис, а число-настройка в обычный класс.
67
+ # The edit text goes to the map as a second argument: there are rules that come into
68
+ # force not from WHAT file is edited but from WHAT is written into it — a call to the
69
+ # runtime arrives in an ordinary service, and a setting number in an ordinary class.
68
70
  written="$(printf '%s' "$input" | jq -r '[.tool_input.content, .tool_input.text, .tool_input.new_string, (.tool_input.edits[]?.new_string)] | map(select(. != null)) | join("\n")' 2>/dev/null)"
69
71
  req="$(skill_for edit "$target" "$written" 2>/dev/null)"
70
- # Слои поверх доменного правила лежат отдельным файлом и зовутся в этой же оболочке:
71
- # доменное правило выбирается один раз по пути, а слоёв полтора десятка, и вместе они не
72
- # помещаются в карту, которую читают целиком. Нет файла — гейт остаётся одним слоем.
72
+ # The layers on top of the domain rule lie in a separate file and are called in this same
73
+ # shell: the domain rule is chosen once by the path, while there are a dozen and a half
74
+ # layers, and together they do not fit into a map that is read whole. No file — the gate
75
+ # stays one layer.
73
76
  # shellcheck disable=SC1090
74
77
  [ -f "$rt_hooks_dir/skill-gate-layers.sh" ] && . "$rt_hooks_dir/skill-gate-layers.sh" 2>/dev/null
75
- # Род правки для наблюдения. Одно расширение, без пути и без имени файла: наблюдение
76
- # уезжает наружу, и всё, кроме рода, там было бы адресом этого дерева.
78
+ # The edit kind for the observation. One extension, without the path and without the file
79
+ # name: an observation travels outside, and everything but the kind would be an address of
80
+ # this tree there.
77
81
  case "${target##*/}" in
78
82
  *.*) kind="${target##*.}" ;;
79
83
  *) kind="none" ;;
80
84
  esac
81
85
  ;;
82
- # Терминал среды исполняет ту же командную строку и кладёт её в то же поле: без этой ветки
83
- # коммит из него не требовал правила, тогда как тот же коммит из оболочки требовал.
86
+ # The environment terminal runs the same command line and puts it into the same field: without
87
+ # this branch a commit from it required no rule, while the same commit from the shell did.
84
88
  Bash|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_tool)
85
89
  target="$(printf '%s' "$input" | jq -r '.tool_input.command // empty' 2>/dev/null)"
86
90
  [ -z "$target" ] && exit 0
87
- # Универсальный исполнитель прячет настоящую команду во вложенной строке.
91
+ # The universal runner hides the real command in a nested string.
88
92
  if [ "$tool" = "mcp__webstorm__execute_tool" ] && command -v perl >/dev/null 2>&1; then
89
93
  inner="$(printf '%s' "$target" | perl -0ne '
90
94
  if (/--command(?:=|\s+)(?:"((?:[^"\\]|\\.)*)"|\x27([^\x27]*)\x27|(.+))/s) {
@@ -95,9 +99,9 @@ case "$tool" in
95
99
  fi
96
100
  req="$(skill_for bash "$target" "" 2>/dev/null)"
97
101
  kind="command"
98
- # Команда оболочки, которая пишет файл, — та же правка, и правило ей нужно то же.
99
- # Без этого яруса гейт обходится сменой не инструмента, а способа записи: отбитая
100
- # правка легла командой дважды за один заход. Разбор —
102
+ # A shell command that writes a file is the same edit, and it needs the same rule. Without
103
+ # this tier the gate is bypassed by changing not the tool but the way of writing: a refused
104
+ # edit was laid down by a command twice within one session. The analysis is
101
105
  # `2026-08-15-guard-denied-shell-wrote-anyway.md`.
102
106
  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
103
107
  # shellcheck disable=SC1090
@@ -131,19 +135,20 @@ esac
131
135
 
132
136
  [ -z "$req" ] && exit 0
133
137
 
134
- # Карта вправе назвать несколько правил: доменное правило и то, что действует вторым слоем.
135
- # Требуется первое незагруженное, а не все сразу: отказ, перечисляющий три правила, читается
136
- # как «загрузи три», и загружают их подряд, теряя ту самую однократность.
138
+ # The map may name several rules: the domain rule and the one that acts as a second layer. The
139
+ # first unloaded one is demanded, not all at once: a refusal listing three rules reads as "load
140
+ # three", and they get loaded one after another, losing that very one-time-ness.
137
141
  loaded="${TMPDIR:-/tmp}/claude-skill-gate/${sid}.loaded"
138
142
  root="${CLAUDE_PROJECT_DIR:-.}"
139
143
  rules_dir="${RT_RULES_DIR:-.claude/skills}"
140
144
  want=""
141
145
  for name in $req; do
142
- # Правила, которого в дереве нет, гейт не требует. Карта умолчания называет и то, от чего
143
- # дерево отказалось списком: правило предметной области, чужой род файлов. Отказ «загрузи
144
- # правило X» на такое имя — отказ без действия: загружать нечего, и работа встаёт совсем.
146
+ # A rule the tree does not have, the gate does not demand. The default map names what the tree
147
+ # dropped by a list too: a rule of a subject area, someone else's file kind. A refusal "load
148
+ # rule X" on such a name is a refusal with nothing to do: there is nothing to load, and the
149
+ # work stops altogether.
145
150
  [ -f "$root/$rules_dir/${name}/SKILL.md" ] || continue
146
- # Принимается и голое имя правила, и имя с областью каталога («<каталог>:<имя>»).
151
+ # Both a bare rule name and a name with a directory area ("<directory>:<name>") are accepted.
147
152
  if [ -f "$loaded" ] && grep -qE "^([^:]*:)?$(printf '%s' "$name" | sed 's/[][\.*^$/]/\\&/g')$" "$loaded" 2>/dev/null; then
148
153
  continue
149
154
  fi
@@ -152,9 +157,10 @@ for name in $req; do
152
157
  done
153
158
  [ -z "$want" ] && exit 0
154
159
 
155
- # Что потребуется дальше по этой же команде. Требуется по-прежнему одно правило за раз, но
156
- # длину пути заход видит с первого отказа: на сквозной правке отказы идут по одному на вызов и
157
- # читаются как разные требования — тринадцать подряд за одну задачу, и каждый стоил хода.
160
+ # What will be needed further along this same command. Still one rule at a time is demanded, but
161
+ # the session sees the length of the path from the first refusal: on a sweeping edit the refusals
162
+ # come one per call and read as different requirements — thirteen in a row for one task, and each
163
+ # cost a turn.
158
164
  ahead=""
159
165
  for name in $req; do
160
166
  [ "$name" = "$want" ] && continue
@@ -167,67 +173,69 @@ done
167
173
 
168
174
  req="$want"
169
175
 
170
- # Отбитие — наблюдение: правило, которое приходится требовать чаще прочего, и род правки, на
171
- # котором это происходит, говорят о слое правил больше, чем список загруженного.
176
+ # A refusal is an observation: the rule that has to be demanded more often than the rest, and the
177
+ # edit kind on which that happens, say more about the rules layer than a list of what was loaded.
172
178
  # shellcheck disable=SC1090
173
179
  [ -f "$rt_hooks_dir/observe.sh" ] && . "$rt_hooks_dir/observe.sh" 2>/dev/null
174
180
  command -v rt_note >/dev/null 2>&1 && rt_note gate-deny "res=$req" "kind=$kind" "sid=$sid"
175
181
 
176
- # Запасной ход называется прямо в отказе: правило, заведённое в этой же ветке, реестру правил
177
- # неизвестно — он собирается на запуске сессии, а гейт читает диск. Без этой строки следующий
178
- # заход ищет обход перебором и обычно находит не тот.
179
- fallback="Если инструмент такого имени не знает, правило завели после начала сессии — прочитай ${rules_dir}/${req}/SKILL.md и спутник рядом с ним."
180
- reason="Отбито гейтом правил: загрузи правило «${req}» инструментом Skill и повтори действие. ${fallback} Для этой области это происходит один раз за сессию."
182
+ # The fallback move is named in the refusal itself: a rule created in this same branch is unknown
183
+ # to the rules registry — it is assembled at session start, while the gate reads the disk. Without
184
+ # this line the next session looks for a bypass by trial and usually finds the wrong one.
185
+ fallback="If the tool does not know such a name, the rule was created after the session began — read ${rules_dir}/${req}/SKILL.md and the companion next to it."
186
+ reason="Refused by the rules gate: load the rule «${req}» by the tool Skill and repeat the action. ${fallback} For this area it happens once per session."
181
187
 
182
- # Правило называет свой закон одним словом, а слоёв законов два: общий лежит в корне, закон
183
- # приложения — в каталоге под ним. Путь ищется, а не собирается из имени, иначе отказ ведёт в
184
- # несуществующий файл ровно у тех правил, чей закон предметен.
188
+ # A rule names its law in one word, while there are two layers of laws: the shared one lies at the
189
+ # root, the application law in a directory under it. The path is looked for, not assembled from
190
+ # the name, otherwise the refusal leads to a file that does not exist for exactly those rules
191
+ # whose law is subject-specific.
185
192
  laws_dir="${RT_LAWS_DIR:-docs/constitution}"
186
193
  law="$(sed -n 's/^law:[[:space:]]*//p' "$root/$rules_dir/${req}/SKILL.md" 2>/dev/null | head -1)"
187
194
  if [ -n "$law" ]; then
188
195
  law_path="$laws_dir/${law}.md"
189
196
  [ -f "$root/$law_path" ] || law_path="$laws_dir/application/${law}.md"
190
197
  [ -f "$root/$law_path" ] \
191
- && reason="Отбито гейтом правил: загрузи правило «${req}» инструментом Skill — оно применяет закон ${law_path} к этому дереву — и повтори действие. ${fallback} Для этой области это происходит один раз за сессию."
198
+ && reason="Refused by the rules gate: load the rule «${req}» by the tool Skill — it applies the law ${law_path} to this tree — and repeat the action. ${fallback} For this area it happens once per session."
192
199
  fi
193
200
 
194
- # Статья, под которую подпадает эта правка. Правило весит от двадцати до шестидесяти килобайт,
195
- # и отказ, зовущий его целиком, платит за решение полной ценой правила. Статья говорит о своей
196
- # применимости сама — разбирает её помощник рядом; нет помощника или нет размеченных статей,
197
- # отказ остаётся прежним, и это тот же отказ в пользу работы, что и везде.
201
+ # The article this edit falls under. A rule weighs from twenty to sixty kilobytes, and a refusal
202
+ # that calls it whole pays the full price of the rule for one decision. An article says whether it
203
+ # applies itself — a helper next door parses that; there is no helper or there are no marked
204
+ # articles, the refusal stays as it was, and that is the same fail-open as everywhere.
198
205
  #
199
- # Загрузку правила статья не отменяет: она снимает чтение правила целиком, а не сам отказ.
200
- # Правило целиком остаётся вторым ходом — для того, кому статьи мало.
206
+ # The article does not cancel loading the rule: it removes reading the rule whole, not the refusal
207
+ # itself. The rule whole stays the second move — for whoever finds the article not enough.
201
208
  # shellcheck disable=SC1090
202
209
  [ -f "$rt_hooks_dir/rule-article.sh" ] && . "$rt_hooks_dir/rule-article.sh" 2>/dev/null
203
210
  if [ "$kind" != "command" ] && [ "$kind" != "browser" ] && command -v rt_rule_article_heads >/dev/null 2>&1; then
204
211
  article="$(rt_rule_article_heads "$root/$rules_dir/${req}/SKILL.md" "$target" 2>/dev/null)"
205
212
  if [ -n "$article" ]; then
206
- reason="Отбито гейтом правил. Под эту правку подпадают статьи правила «${req}»:
213
+ reason="Refused by the rules gate. This edit falls under the articles of the rule «${req}»:
207
214
 
208
215
  ${article}
209
216
 
210
- Текст этих статей придёт в контекст вместе с правилом, и пересказывать его здесь значило бы платить за один текст дважды: загрузи правило «${req}» инструментом Skill и повтори действие. ${fallback} Для этой области это происходит один раз за сессию."
217
+ The text of these articles arrives with the rule itself, and retelling it here would mean paying for one text twice: load the rule «${req}» by the tool Skill and repeat the action. ${fallback} For this area it happens once per session."
211
218
  fi
212
219
  fi
213
220
 
214
- # Что потребуется дальше по этой же команде. Строка стоит после всех веток текста: их три, и
215
- # каждая переписывает причину целиком.
216
- [ -n "$ahead" ] && reason="${reason} Дальше по этой команде потребуются: ${ahead}."
221
+ # What will be needed further along this same command. The line stands after all the text
222
+ # branches: there are three of them, and each rewrites the reason whole.
223
+ [ -n "$ahead" ] && reason="${reason} Further along this same command these will be needed: ${ahead}."
217
224
 
218
- # Спутник зовётся отдельным предложением и ко всем видам отказа разом. Прежде он был назван
219
- # только запасным ходом — «если инструмент такого имени не знает», — и читатель, у которого имя
220
- # известно, до него не доходил вовсе. Цена этого: правило называет способ, а спутник рядом
221
- # объявляет его здесь невозможным; работа, сделанная способом из правила, кончилась результатом,
222
- # которого для её заказчика не существовало, а разделы спутника за тот заход не открывались ни
223
- # разу.
225
+ # The companion is called by a sentence of its own and for all kinds of refusal at once. Before,
226
+ # it was named only as a fallback move — "if the tool does not know such a name" — and a reader
227
+ # who had the name known never got to it at all. The price of that: the rule names a way, and the
228
+ # companion next door declares it impossible here; work done the way the rule names ended in a
229
+ # result that did not exist for the one who ordered it, while the sections of the companion were
230
+ # not opened once in that session.
224
231
  companion="$rules_dir/${req}/implementation.md"
225
232
  [ -f "$root/$companion" ] && reason="${reason}
226
233
 
227
- Спутник правила — ${companion} — читается вместе с ним: правило говорит, что должно быть верно, а спутник — чем это верно здесь и что здесь названо невозможным. Инструментом он не грузится, его читают файлом."
234
+ The companion of the rule — ${companion} — is read together with it: the rule says what must be true, the companion — by what that is true here and what is named impossible here. It is not loaded by the tool, it is read as a file."
228
235
 
229
- # Общий хвост отказа: два законных хода и законная форма обхода, если она у отказа есть.
230
- # Файл может быть не разложен — тогда хвоста нет, а причина отказа остаётся прежней.
236
+ # The shared deny tail: the two lawful moves and the lawful form of bypass, if the refusal has one.
237
+ # The file may not be laid out — then there is no tail, and the reason for the refusal stays as it
238
+ # was.
231
239
  # shellcheck disable=SC1090
232
240
  [ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
233
241
  && . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
@@ -238,6 +246,6 @@ deny_tail_text="$(rt_deny_tail "")"
238
246
  ${deny_tail_text}"
239
247
 
240
248
  jq -n --arg r "$reason" '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:$r}}' 2>/dev/null \
241
- || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"Загрузи правило %s и повтори."}}\n' "$req"
249
+ || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"Load the rule %s and repeat."}}\n' "$req"
242
250
 
243
251
  exit 0
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env bash
2
2
  # rt-hook: PostToolUse Skill
3
- # Запись о загруженном правиле. PostToolUse на инструменте `Skill`.
3
+ # The record of a loaded rule. PostToolUse on the `Skill` tool.
4
4
  #
5
- # Гейт обязан знать, загружено правило или нет, а спросить об этом ему некого: инструмент о
6
- # своих прошлых вызовах не рассказывает. Поэтому загрузка записывается здесь, по сессии.
5
+ # The gate has to know whether a rule is loaded or not, and it has nobody to ask: the tool does not
6
+ # tell about its past calls. So the load is recorded here, per session.
7
7
  #
8
- # Хук только наблюдает: он всегда пропускает и ничего не отбивает.
8
+ # The hook only observes: it always passes and refuses nothing.
9
9
 
10
10
  . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
11
11
  . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
@@ -22,8 +22,8 @@ dir="${TMPDIR:-/tmp}/claude-skill-gate"
22
22
  mkdir -p "$dir" 2>/dev/null || exit 0
23
23
  printf '%s\n' "$skill" >> "$dir/${sid}.loaded" 2>/dev/null
24
24
 
25
- # Та же загрузка вторым адресом — в наблюдения дерева. Запись выше живёт до сжатия контекста и
26
- # гибнет вместе с ним: она отвечает гейту на вопрос «загружено ли», и больше ни на что.
25
+ # The same load at a second address — the tree's observations. The record above lives until context
26
+ # compaction and dies with it: it answers the gate's question "is it loaded", and nothing else.
27
27
  rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
28
28
  # shellcheck disable=SC1090
29
29
  [ -f "$rt_hooks_dir/observe.sh" ] && . "$rt_hooks_dir/observe.sh" 2>/dev/null