@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,38 +1,43 @@
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
3
- # Требует: hooks/profile-check.sh, hooks/deny-tail.sh
4
- # Гард «ничего не пишется с нуля». PreToolUse на правке кода и разметки.
3
+ # Requires: hooks/profile-check.sh, hooks/deny-tail.sh
4
+ # The "nothing is written from scratch" guard. PreToolUse on an edit of code and markup.
5
5
  #
6
- # Линтеры знают правила, но не знают ИНВЕНТАРЬ: линтер стилей поймает сырой цвет, линтер кода —
7
- # нетипизированное значение, но ни один из них не знает, что готовое сообщение уже написано, и
8
- # молча пропустит свою область оповещения с текстом, кнопкой и стилями. Гард закрывает ровно
9
- # эту дыру: сверяет то, что пишется, с тем, что в дереве уже есть.
6
+ # Linters know the rules, but they do not know the INVENTORY: the style linter catches a raw
7
+ # colour, the code linter an untyped value, but neither of them knows that a ready-made message is
8
+ # already written, and both silently let through a notification area of one's own with its text,
9
+ # its button and its styles. The guard closes exactly this hole: it checks what is being written
10
+ # against what the tree already has.
10
11
  #
11
- # Правило целиком — `reuse-first`.
12
+ # The rule as a whole is `reuse-first`.
12
13
  #
13
- # Что считается переизобретением, знает профиль дерева: функция `rt_reinvented_in <файл>`
14
- # печатает по строке на правило, четырьмя полями через табуляцию:
14
+ # What counts as a reinvention is known by the tree profile: the function `rt_reinvented_in <file>`
15
+ # prints a line per rule, four fields separated by tabs:
15
16
  #
16
- # <над чем> <образец> <образец отмены> <чем заменить>
17
+ # <over what> <pattern> <cancelling pattern> <what to use instead>
17
18
  #
18
- # «Над чем» — `added` (только новый текст правки) или `whole` (правка вместе с содержимым
19
- # файла). Второе нужно там, где признак виден только целиком: наследование основы и метка
20
- # процедуры в точечную правку не попадают. «Образец отмены» гасит правило: маппер, который уже
21
- # наследует общую основу, переизобретением не является; пустое поле не гасит ничего.
19
+ # "Over what" is `added` (only the new text of the edit) or `whole` (the edit together with the
20
+ # content of the file). The second is needed where the sign is visible only as a whole: inheriting
21
+ # a base and the mark of a procedure do not get into a point edit. The "cancelling pattern" puts
22
+ # the rule out: a mapper that already inherits the shared base is never a reinvention; an empty
23
+ # field puts nothing out.
22
24
  #
23
- # Функция получает путь и вправе решать по нему сама — заглянуть в инвентарь кита, различить
24
- # слой дерева, промолчать на файле, который уже существует. Нет профиля или нет функции — гард
25
- # пропускает: инвентарь дерева пакет знать не может.
25
+ # The function gets the path and may decide by it on its own — look into the kit inventory, tell
26
+ # the layers of the tree apart, stay silent on a file that already exists. No profile or no
27
+ # function — the guard lets through: the package cannot know the inventory of the tree.
26
28
  #
27
- # Образцы разбирает `perl`: конъюнкция и отрицание пишутся заглядыванием вперёд, а без них
28
- # самодельный оверлей не отличить от липкой шапки, а нативную кнопку — от кнопки кита.
29
+ # The patterns are parsed by `perl`: conjunction and negation are written by lookahead, and without
30
+ # them a hand-made overlay is not to be told from a sticky header, nor a native button from a kit
31
+ # button.
29
32
  #
30
- # Осознанный выход: маркер отступления в тексте правки. Он объясняет, чего именно не хватает;
31
- # «эти строки были здесь раньше» причиной не считается, и оттого проверяется только НОВЫЙ текст.
33
+ # The deliberate exit: the departure marker in the text of the edit. It explains what exactly is
34
+ # missing; "these lines were here before" does not count as a reason, and that is why only the NEW
35
+ # text is checked.
32
36
  #
33
- # ОТКАЗ В ПОЛЬЗУ РАБОТЫ: нет разборщика, битый ввод, чужой инструмент — пропуск.
37
+ # FAIL-OPEN: no parser, broken input, a foreign tool — let through.
34
38
 
35
- # Своё имя в наблюдениях: отбой пишет общий хвост отказа, а не сам гард.
39
+ # Its own name in the observations: the refusal is written by the shared deny tail, not by the
40
+ # guard itself.
36
41
  RT_GUARD_NAME=reuse-first-guard
37
42
 
38
43
  . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
@@ -47,22 +52,22 @@ command -v perl >/dev/null 2>&1 || exit 0
47
52
  tool="$(rt_hook_tool)"
48
53
  shell_cmd=""
49
54
  case "$tool" in
50
- # Инструмент среды заводит файл теми же двумя данными, только называет их иначе — без этой
51
- # ветки файл заводился мимо всех проверок.
55
+ # The environment tool creates a file with the same two pieces of data, it only calls them
56
+ # differently — without this branch a file was created past every check.
52
57
  Edit | Write | MultiEdit | mcp__webstorm__create_new_file) ;;
53
- # Команда оболочки, которая пишет файл, — та же правка. Без этой ветки гард обходится
54
- # сменой не инструмента, а способа записи; текстом правки тогда служит сама команда, и
55
- # заведённое ею в heredoc читается наравне с телом правки. Разбор —
56
- # `2026-08-15-guard-denied-shell-wrote-anyway.md`.
58
+ # A shell command that writes a file is the same edit. Without this branch the guard is
59
+ # bypassed by changing not the tool but the way of writing; the text of the edit is then the
60
+ # command itself, and what it creates in a heredoc is read on a par with the body of the edit.
61
+ # Incident analysis — `2026-08-15-guard-denied-shell-wrote-anyway.md`.
57
62
  #
58
- # Терминал среды исполняет ту же командную строку и кладёт её в то же поле: без этих двух
59
- # имён гард стоял бы объявленным на них и молча пропускал — состояние хуже необъявленного,
60
- # потому что снаружи выглядит закрытым.
63
+ # The environment terminal runs the same command line and puts it in the same field: without
64
+ # these two names the guard would stand declared on them and let through silently — a state
65
+ # worse than an undeclared one, because from the outside it looks closed.
61
66
  Bash | mcp__webstorm__execute_terminal_command | mcp__webstorm__execute_tool)
62
67
  shell_cmd="$(rt_hook_cmd)"
63
68
  [ -z "$shell_cmd" ] && exit 0
64
- # Универсальный исполнитель прячет настоящую команду во вложенной строке: без её разбора
65
- # путь стоит за кавычкой, и до него не дотягивается ни один образец.
69
+ # The universal executor hides the real command in a nested string: without parsing it the
70
+ # path stands behind a quote, and no pattern reaches it.
66
71
  if [ "$tool" = "mcp__webstorm__execute_tool" ] && command -v perl >/dev/null 2>&1; then
67
72
  inner="$(printf '%s' "$shell_cmd" | perl -0ne '
68
73
  if (/--command(?:=|\s+)(?:"((?:[^"\\]|\\.)*)"|\x27([^\x27]*)\x27|(.+))/s) {
@@ -75,8 +80,9 @@ case "$tool" in
75
80
  *) exit 0 ;;
76
81
  esac
77
82
 
78
- # Профиль дерева: сперва умолчание пакета, поверх него — надстройка проекта, если она есть.
79
- # Читается до разбора пути: пути из команды оболочки вынимает как раз профиль.
83
+ # The tree profile: first the package default, and the project override on top of it, if there is
84
+ # one. It is read before the path is parsed: the paths out of a shell command are extracted by the
85
+ # profile itself.
80
86
  rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
81
87
  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
82
88
  # shellcheck disable=SC1090
@@ -86,7 +92,8 @@ done
86
92
  if [ -n "$shell_cmd" ]; then
87
93
  command -v rt_shell_writes >/dev/null 2>&1 && command -v rt_shell_paths >/dev/null 2>&1 || exit 0
88
94
  rt_shell_writes "$shell_cmd" || exit 0
89
- # Из команды берётся первый путь, чьё расширение гарду интересно: остальные ему безразличны.
95
+ # Out of the command the first path is taken whose extension the guard cares about: the rest
96
+ # are indifferent to it.
90
97
  path=""
91
98
  while IFS= read -r candidate; do
92
99
  case "$candidate" in
@@ -99,7 +106,7 @@ EOF
99
106
  else
100
107
  path="$(printf '%s' "$input" | jq -r '.tool_input.file_path // .tool_input.pathInProject // empty' 2>/dev/null)"
101
108
  fi
102
- # Путь от корня дерева приводится к абсолютному один раз, чтобы образцы не двоились.
109
+ # A path from the root of the tree is made absolute once, so that the patterns do not double up.
103
110
  case "$path" in
104
111
  /*) ;;
105
112
  ?*) path="${CLAUDE_PROJECT_DIR:-.}/$path" ;;
@@ -109,27 +116,27 @@ case "$path" in
109
116
  *) exit 0 ;;
110
117
  esac
111
118
 
112
- # Слово о нехватке функции профиля: хук, вышедший молча, неотличим от работающего. Файл может
113
- # быть не разложен — тогда остаётся прежнее поведение, молчаливое.
119
+ # A word about a missing profile function: a hook that left silently is indistinguishable from a
120
+ # working one. The file may be not laid out — then the previous behaviour stays, the silent one.
114
121
  # shellcheck disable=SC1090
115
122
  [ -f "$rt_hooks_dir/profile-check.sh" ] && . "$rt_hooks_dir/profile-check.sh"
116
123
  command -v rt_needs >/dev/null 2>&1 || rt_needs() { command -v "$1" >/dev/null 2>&1; }
117
124
  rt_needs rt_reinvented_in reuse-first-guard || exit 0
118
125
 
119
- # Правила этого дерева действуют на код этого дерева: без положительной проверки гард требовал
120
- # бы собирать готовым и в черновике за пределами дерева.
126
+ # The rules of this tree apply to the code of this tree: without a positive check the guard would
127
+ # demand assembling from the ready-made in a draft outside the tree as well.
121
128
  if rt_needs rt_is_app_code reuse-first-guard; then
122
129
  rt_is_app_code "$path" || exit 0
123
130
  fi
124
131
 
125
- # Готовое собирается там, где ему и место: внутри кита нативные контролы и примитивы уместны,
126
- # витрина и спеки — тоже не забота этого гарда.
132
+ # The ready-made is assembled where it belongs: inside the kit native controls and primitives are
133
+ # in place, and the showcase and the tests are not this guard's concern either.
127
134
  if [ -n "${RT_REUSE_SKIP_RE:-}" ] && printf '%s' "$path" | grep -qE "$RT_REUSE_SKIP_RE"; then
128
135
  exit 0
129
136
  fi
130
137
 
131
- # Только новый текст: строка, уже лежавшая в файле, этой правкой не заводилась. У команды
132
- # оболочки таким текстом служит она сама: что она кладёт в файл, лежит в ней же.
138
+ # Only the new text: a line that already lay in the file was not created by this edit. For a shell
139
+ # command that text is the command itself: what it puts into the file lies in it.
133
140
  if [ -n "$shell_cmd" ]; then
134
141
  added="$shell_cmd"
135
142
  else
@@ -140,18 +147,20 @@ else
140
147
  fi
141
148
  [ -z "$added" ] && exit 0
142
149
 
143
- # Явный отказ от правила: готового такого нет, автор это осознал и пометил. Считается по
144
- # исходному тексту правки, до вычёркивания ниже: маркер обычно и стоит на строке, которая уже
145
- # лежит в файле, и вычеркнутый маркер отбивал бы правку соседней строки.
150
+ # An explicit refusal of the rule: there is no such ready-made, the author realised it and marked
151
+ # it. It is counted by the source text of the edit, before the crossing-out below: the marker
152
+ # usually stands on a line that already lies in the file, and a crossed-out marker would refuse an
153
+ # edit of the neighbouring line.
146
154
  case "$added" in
147
155
  *native-ok*) exit 0 ;;
148
156
  esac
149
157
 
150
- # Перенос — не написание заново. Строку, которая уже лежит в файле, гард из проверяемого текста
151
- # вычёркивает: блок, переехавший вместе с экраном из одного места файла в другое, отбивался
152
- # наравне с новым, и маркер отступления приходилось ставить вслепую.
158
+ # A move is not writing anew. A line that already lies in the file the guard crosses out of the
159
+ # text being checked: a block that travelled together with a screen from one place of the file to
160
+ # another was refused on a par with a new one, and the departure marker had to be set blindly.
153
161
  #
154
- # Сверка идёт без отступов: при переезде блок меняет отступ, оставаясь тем же кодом.
162
+ # The comparison goes without indentation: on a move a block changes its indent while staying the
163
+ # same code.
155
164
  if [ -f "$path" ]; then
156
165
  added="$(
157
166
  printf '%s' "$added" | awk '
@@ -171,8 +180,8 @@ if [ -f "$path" ]; then
171
180
  [ -z "${added//[[:space:]]/}" ] && exit 0
172
181
  fi
173
182
 
174
- # Признак, который виден только целиком по файлу (наследование основы, метка процедуры),
175
- # считается по итоговому содержимому: точечная правка приносит кусок без объявления класса.
183
+ # A sign visible only as a whole over the file (inheriting a base, the mark of a procedure) is
184
+ # counted by the resulting content: a point edit brings a piece without the class declaration.
176
185
  whole="$added"
177
186
  if [ -f "$path" ]; then
178
187
  whole="$added
@@ -183,9 +192,9 @@ has_re() {
183
192
  printf '%s' "$1" | RT_RE="$2" perl -0777 -ne 'exit(/$ENV{RT_RE}/s ? 0 : 1)' 2>/dev/null
184
193
  }
185
194
 
186
- # Что дерево объявило своим: наборы признаков и файл собственных. Настройка проверок — та же,
187
- # что читает сплошная проверка; каталог наборов называет профиль дерева, потому что раскладка
188
- # проверок у каждого дерева своя.
195
+ # What the tree declared as its own: the sets of signs and the file of its own ones. The checks
196
+ # settings are the same ones the full check reads; the directory of the sets is named by the tree
197
+ # profile, because the layout of the checks is each tree's own.
189
198
  rt_checks_json="${CLAUDE_PROJECT_DIR:-.}/.claude/rt-kit/checks.json"
190
199
  rt_bundles=''
191
200
  rt_own_signals=''
@@ -194,22 +203,22 @@ if [ -f "$rt_checks_json" ]; then
194
203
  rt_bundles="$(jq -r '.reuse.bundles[]? // empty' "$rt_checks_json" 2>/dev/null | tr '\n' ' ')"
195
204
  own="$(jq -r '.reuse.signals // empty' "$rt_checks_json" 2>/dev/null)"
196
205
  [ -n "$own" ] && rt_own_signals="${CLAUDE_PROJECT_DIR:-.}/$own"
197
- # Тем же ключом, каким их читает сплошная проверка: второе объявление тех же корней
198
- # разошлось бы с первым молча.
206
+ # By the same key the full check reads them: a second declaration of the same roots would
207
+ # diverge from the first silently.
199
208
  rt_backend_roots="$(jq -r '.backendRoots[]? // empty' "$rt_checks_json" 2>/dev/null | tr '\n' ' ')"
200
209
  fi
201
210
 
202
- # Путь от корня дерева: образец в признаке пишет дерево, и писать его от корня машины оно не
203
- # может. Абсолютный путь нужен только для чтения файла с диска.
211
+ # A path from the root of the tree: the pattern in a sign is written by the tree, and it cannot
212
+ # write it from the root of the machine. The absolute path is needed only to read the file from disk.
204
213
  rel_path="${path#"${CLAUDE_PROJECT_DIR:-.}"/}"
205
214
  rt_signals_dir="${CLAUDE_PROJECT_DIR:-.}/${RT_REUSE_SIGNALS_DIR:-tools/signals}"
206
215
 
207
- # Признаки объявленных наборов: те же файлы читает сплошная проверка. Ключ признака совпал с
208
- # ключом дерева — побеждает дерево: оно видит своё готовое, а пакет его не видел.
216
+ # The signs of the declared sets: the full check reads the same files. If the key of a sign matched
217
+ # the key of the tree, the tree wins: it sees its own ready-made, and the package did not see it.
209
218
  signals_json() {
210
219
  [ -n "$rt_signals_dir" ] || return 0
211
220
  [ -d "$rt_signals_dir" ] || return 0
212
- # Шапка раскладки снимается до разбора: в JSON комментария нет, и с ней разбор падает.
221
+ # The layout header is stripped before parsing: JSON has no comment, and the parse falls on it.
213
222
  for name in $rt_bundles; do
214
223
  file="$rt_signals_dir/$name.json"
215
224
  [ -f "$file" ] && grep -v '^# rt-kit ' "$file" | jq -c '.signals[]?' 2>/dev/null
@@ -217,8 +226,9 @@ signals_json() {
217
226
  [ -n "$rt_own_signals" ] && [ -f "$rt_own_signals" ] && grep -v '^# rt-kit ' "$rt_own_signals" | jq -c '.signals[]?' 2>/dev/null
218
227
  }
219
228
 
220
- # Поля читаются по одному, а не разбором строки: таб в `IFS` — пробельный разделитель, и пустое
221
- # поле в середине схлопывается, из-за чего совет уезжает в образец отмены и гасит признак молча.
229
+ # The fields are read one by one, not by parsing the line: a tab in `IFS` is a whitespace separator,
230
+ # and an empty field in the middle collapses, because of which the advice travels into the
231
+ # cancelling pattern and puts the sign out silently.
222
232
  field() { printf '%s' "$1" | jq -r "$2 // empty" 2>/dev/null; }
223
233
 
224
234
  found=''
@@ -231,11 +241,11 @@ while IFS= read -r signal; do
231
241
  '') ;;
232
242
  *) case "$path" in *"$ext") ;; *) continue ;; esac ;;
233
243
  esac
234
- # Пропуск корней бэкенда: признак, объявленный с ним, на бэкенде не действует вовсе — там
235
- # принят другой способ, и базового класса, которого признак требует, у бэкенда нет. Поле
236
- # читает и сплошная проверка; читать его одному из двоих значит отбивать гардом ту самую
237
- # правку, которую проверка пропускает, — а провести её больше нечем: маркер отступления
238
- # объявляет обход готового, а обхода тут не было.
244
+ # Skipping the backend roots: a sign declared with it does not apply on the backend at all —
245
+ # another way is accepted there, and the backend has no base class the sign demands. The full
246
+ # check reads the field too; reading it in one of the two would mean refusing by the guard
247
+ # exactly the edit the check lets through — and there would be nothing else to put it through
248
+ # with: the departure marker declares a bypass of the ready-made, and there was no bypass here.
239
249
  if [ "$(field "$signal" '.skipBackendRoots')" = 'true' ] && [ -n "$rt_backend_roots" ]; then
240
250
  skip_backend=''
241
251
  for backend_root in $rt_backend_roots; do
@@ -244,14 +254,23 @@ while IFS= read -r signal; do
244
254
  [ -n "$skip_backend" ] && continue
245
255
  fi
246
256
 
247
- # Образец имени сверяется с путём от корня дерева, а не с именем файла: слои, которые
248
- # признак и разделяет, зовут свои файлы одинаково, и по имени они неразличимы. Сплошная
249
- # проверка сверяет с путём — расходиться им нельзя.
257
+ # The name pattern is checked against the path from the root of the tree, not against the file
258
+ # name: the layers the sign separates call their files alike, and by name they are
259
+ # indistinguishable. The full check checks against the path — they must not diverge.
250
260
  only_named="$(field "$signal" '.onlyNamed')"
251
261
  if [ -n "$only_named" ]; then
252
262
  printf '%s' "$rel_path" | grep -qE "$only_named" || continue
253
263
  fi
254
264
 
265
+ # The other side of the name pattern: a tree that writes the ready-made itself takes the source
266
+ # folders of that ready-made out from under the sign. Without it such a tree has one choice —
267
+ # not to take the set at all, and then inside the set of ready-made components nothing catches
268
+ # a bypass of the ready-made. The full check reads the field too: they must not diverge.
269
+ except_named="$(field "$signal" '.exceptNamed')"
270
+ if [ -n "$except_named" ]; then
271
+ printf '%s' "$rel_path" | grep -qE "$except_named" && continue
272
+ fi
273
+
255
274
  case "$(field "$signal" '.scope')" in
256
275
  whole) text="$whole" ;;
257
276
  *) text="$added" ;;
@@ -282,8 +301,8 @@ done <<EOF
282
301
  $(signals_json | jq -s -c 'reduce .[] as $one ({}; .[$one.key] = $one) | .[]' 2>/dev/null)
283
302
  EOF
284
303
 
285
- # Функция профиля остаётся вторым источником: деревья её уже написали. Поля читаются построчно,
286
- # по тем же четырём колонкам, что объявлены выше.
304
+ # The profile function stays the second source: trees have already written it. The fields are read
305
+ # line by line, by the same four columns declared above.
287
306
  while IFS= read -r line; do
288
307
  [ -z "$line" ] && continue
289
308
  signals_seen=1
@@ -304,33 +323,35 @@ done <<EOF
304
323
  $(rt_reinvented_in "$path" 2>/dev/null)
305
324
  EOF
306
325
 
307
- # Гард без единого признака неотличим от гарда, которому нечего отбивать. Правку он пропускает —
308
- # останавливать работу за ненастроенное дерево не за что, — но говорит, чем это настраивается.
326
+ # A guard without a single sign is indistinguishable from a guard that has nothing to refuse. It
327
+ # lets the edit through — there is nothing to stop the work over an unconfigured tree for — but it
328
+ # says what this is configured with.
309
329
  if [ "$signals_seen" = 0 ]; then
310
- printf '%s\n' 'reuse-first-guard: признаков нет — объявите наборы ключом `reuse.bundles` в настройке проверок' >&2
330
+ printf '%s\n' 'reuse-first-guard: no signs — declare the bundles by the key `reuse.bundles` in the checks config' >&2
311
331
  exit 0
312
332
  fi
313
333
 
314
334
  [ -z "$found" ] && exit 0
315
335
 
316
- reason="BLOCKED: это уже написано. Файл: ${path##*/}
336
+ reason="BLOCKED: this is already written. File: ${path##*/}
317
337
  ${found}
318
338
 
319
- Порядок действий: 1) открой готовое — барель кита или базовый класс — и используй его; 2) найди в дереве экран, где этот случай уже собран, и повтори сборку; 3) если готового правда не хватает — расширяй его на месте, у готового, а не клонируй рядом: клон забирает правки на себя и расходится с оригиналом с первой же.
320
- Свой примитив, своя основа и свои инлайновые стили заводятся только с явного одобрения владельца, и спрашивается это до первого написанного файла. Разовое исключение помечается маркером отступления в той же строке, с объяснением, чего именно нет в готовом. Переименованием файла это не обходится."
339
+ The order of moves: 1) open the ready-made — the barrel of the kit or the base class — and use it; 2) find in the tree a screen where this case is already assembled, and repeat that assembly; 3) if the ready-made really is not enough — extend it in place, at the ready-made, instead of cloning it alongside: a clone takes the edits onto itself and drifts from the original from the very first one.
340
+ A primitive of one's own, a base of one's own and inline styles of one's own are created only with the explicit approval of the owner, and it is asked before the first file is written. A one-off exception is marked by a departure marker on the same line, with an explanation of what exactly the ready-made lacks. Renaming the file does not bypass this."
321
341
 
322
- # Общий хвост отказа: два законных хода и законная форма обхода, если она у отказа есть.
323
- # Файл может быть не разложен — тогда хвоста нет, а причина отказа остаётся прежней.
342
+ # The shared refusal tail: the two lawful moves and the lawful form of the bypass, if the refusal
343
+ # has one. The file may be not laid out — then there is no tail, and the reason for the refusal
344
+ # stays as it was.
324
345
  # shellcheck disable=SC1090
325
346
  [ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
326
347
  && . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
327
348
  command -v rt_deny_tail >/dev/null 2>&1 || rt_deny_tail() { :; }
328
- deny_tail_text="$(rt_deny_tail "маркер отступления в той же строке, с объяснением, чего именно нет в готовом")"
349
+ deny_tail_text="$(rt_deny_tail "a departure marker on the same line, with an explanation of what exactly the ready-made lacks")"
329
350
  [ -n "$deny_tail_text" ] && reason="${reason}
330
351
 
331
352
  ${deny_tail_text}"
332
353
 
333
354
  jq -n --arg r "$reason" '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:$r}}' 2>/dev/null \
334
- || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"Написано своё там, где готовое уже есть."}}\n'
355
+ || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"Something of its own is written where the ready-made already exists."}}\n'
335
356
 
336
357
  exit 0
@@ -1,22 +1,22 @@
1
1
  #!/usr/bin/env bash
2
- # Состояние роли слоя правил. НЕ гард: объявления `rt-hook:` у него нет, к событиям агента он не
3
- # подключается. Его источают гарды, стоящие при ролях, — тем же приёмом, каким гейт источает
4
- # карту, а гарды — профиль дерева.
2
+ # The state of a rules-layer role. NOT a guard: it has no `rt-hook:` declaration and hooks into no
3
+ # agent event. The guards that stand at roles source it — the same way the gate sources the map and
4
+ # the guards source the tree profile.
5
5
  #
6
- # Зачем он есть. Роль, при которой стоит гард, зовётся не по усмотрению исполнителя: гард держит
7
- # работу, пока роль не сказала своё. Выключить её было нечем — отказ от файла роли в настройке
8
- # убирал роль и оставлял гард, и дереву, которому роль в эту минуту мешает, оставалось вырезать
9
- # гард из настроек руками. Теперь дерево называет выключенные роли одним списком, а гард при
10
- # такой роли выходит молча.
6
+ # Why it exists. A role with a guard at it is not called at the executor's discretion: the guard
7
+ # holds the work until the role has had its say. There was nothing to switch it off with — dropping
8
+ # the role file in the settings removed the role and left the guard, and a tree that the role gets
9
+ # in the way of at this minute was left to cut the guard out of the settings by hand. Now the tree
10
+ # names the disabled roles in one list, and the guard at such a role leaves silently.
11
11
  #
12
- # Выключается обязательность вызова, а не сама роль: файл роли остаётся разложенным, и позвать
13
- # её руками можно в любую минуту.
12
+ # What is disabled is the mandatory call, not the role itself: the role file stays laid out, and it
13
+ # can be called by hand at any minute.
14
14
  #
15
- # ОТКАЗ В ПОЛЬЗУ РАБОТЫ наоборот: всё, чего не хватило, читается как «роль включена». Нет `jq`,
16
- # нет настройки, настройка не разбирается — гард работает, как работал. Сломанное чтение,
17
- # гасящее роль, выключало бы слой правил молча, и заметить это было бы нечем.
15
+ # FAIL-OPEN the other way round: everything that was missing reads as "the role is on". No `jq`, no
16
+ # settings, settings that do not parse — the guard works as it did. A broken read that muted a role
17
+ # would switch the rules layer off silently, and there would be nothing to notice it with.
18
18
 
19
- # Выключена ли роль. Успех — выключена.
19
+ # Is the role disabled. Success — disabled.
20
20
  #
21
21
  # rt_role_off strict-teacher && exit 0
22
22
  . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
@@ -1,41 +1,42 @@
1
1
  #!/usr/bin/env bash
2
- # Разбор признака применимости у статьи правила. Помощник: своего события не объявляет, его
3
- # подключает тот, кому нужен текст статьи, — гейт правил в своём отказе.
2
+ # Parsing the applicability sign of a rule article. A helper: it declares no event of its own, and
3
+ # is sourced by whoever needs the text of an article — the rules gate in its refusal.
4
4
  #
5
- # Правило весит от двадцати до шестидесяти килобайт, а под конкретную правку подпадает одна его
6
- # статья. Отказ, зовущий правило целиком, платит за решение полной ценой правила — и учит не
7
- # тому: дешевле не читать лишнего, то есть работать хуже разведанным.
5
+ # A rule weighs from twenty to sixty kilobytes, while one of its articles covers a particular edit.
6
+ # A refusal that calls the whole rule pays the full price of the rule for the decision — and teaches
7
+ # the wrong thing: it is cheaper to read nothing extra, that is, to work less well explored.
8
8
  #
9
- # Признак стоит при самой статье: карта гейта знает путь и правило, но не знает, какая из двух
10
- # десятков статей про этот путь. Статья знает о себе всё.
9
+ # The sign stands at the article itself: the gate map knows the path and the rule, but does not know
10
+ # which of two dozen articles is about that path. An article knows everything about itself.
11
11
  #
12
- # - **Заголовок статьи.** Текст статьи, как обычно.
12
+ # - **The article heading.** The text of the article, as usual.
13
13
  # <!-- rt-when: *.scss *.css -->
14
14
  #
15
- # Комментарий не виден в собранной разметке и не мешает читать статью; образцы разделены
16
- # пробелом и сверяются с путём правки самой оболочкой, а не поиском по словам: поиск называет не
17
- # ту статью и молчит об этом.
15
+ # The comment is not visible in the assembled markup and does not get in the way of reading the
16
+ # article; the patterns are separated by a space and are matched against the edit path by the shell
17
+ # itself, not by a word search: a search names the wrong article and says nothing about it.
18
18
  #
19
- # ОТКАЗ В ПОЛЬЗУ РАБОТЫ: статья без признака законна, правило без единого признака — тоже. Не
20
- # нашлось ни одной подошедшей статьи — печатается пусто, и зовущий остаётся при прежнем отказе.
19
+ # FAIL-OPEN: an article without a sign is lawful, and so is a rule without a single sign. If not one
20
+ # fitting article was found — nothing is printed, and the caller is left with the refusal it had.
21
21
 
22
- # Статьи правила, чей признак совпал с путём правки. Доводы: файл правила, путь правки.
23
- # Печатает текст подошедших статей целиком, по статье, разделяя их пустой строкой.
22
+ # The articles of a rule whose sign matched the edit path. Arguments: the rule file, the edit path.
23
+ # Prints the text of the fitting articles whole, article by article, separated by an empty line.
24
24
  rt_rule_articles() {
25
25
  rule_file="$1"
26
26
  edited="$2"
27
27
  [ -f "$rule_file" ] || return 0
28
28
  [ -n "$edited" ] || return 0
29
29
 
30
- # Статьи выбираются в два прохода: сперва номера строк, где стоят признаки, и сами образцы,
31
- # затем — текст той статьи, чей образец совпал. Сопоставление делает оболочка: `case` знает
32
- # правила путей, а разборщик текста — нет.
30
+ # The articles are picked in two passes: first the line numbers where the signs stand and the
31
+ # patterns themselves, then the text of the article whose pattern matched. The matching is done
32
+ # by the shell: `case` knows the rules of paths, a text parser does not.
33
33
  while IFS=' ' read -r line patterns; do
34
34
  [ -n "$line" ] || continue
35
35
  hit=''
36
- # Образцы разбираются под выключенным раскрытием имён: `*.scss` в цикле развернулось бы
37
- # в имена файлов рабочего каталога, и статья выбиралась бы по тому, где стоял вызов.
38
- # Разделитель задаётся здесь же — внешний мог быть переопределён тем, кто нас позвал.
36
+ # The patterns are parsed with name expansion switched off: `*.scss` in the loop would
37
+ # expand into the file names of the working directory, and the article would be picked by
38
+ # where the call stood. The separator is set right here — an outer one could have been
39
+ # redefined by whoever called us.
39
40
  set -f
40
41
  old_ifs="$IFS"
41
42
  IFS=' '
@@ -49,8 +50,8 @@ rt_rule_articles() {
49
50
  case "$edited" in
50
51
  $pattern) hit=1; break ;;
51
52
  esac
52
- # Образец без каталога сверяется и с именем файла: статья говорит «про такие файлы»,
53
- # а правка приходит полным путём.
53
+ # A pattern without a directory is matched against the file name too: an article says
54
+ # "about files like these", while an edit arrives as a full path.
54
55
  # shellcheck disable=SC2254
55
56
  case "${edited##*/}" in
56
57
  $pattern) hit=1; break ;;
@@ -63,24 +64,25 @@ $(rt_rule_article_marks "$rule_file")
63
64
  EOF
64
65
  }
65
66
 
66
- # Признаки правила: строка «номер строки — образцы». Отдельной функцией, потому что её же зовёт
67
- # сверка полноты текстов: правило, у которого признак записан не той формой, тихо остаётся без
68
- # статьи в отказе, и заметить это нечем.
67
+ # The signs of a rule: a line of "line number — patterns". A function of its own, because the
68
+ # completeness check of the texts calls the same one: a rule whose sign is written in the wrong form
69
+ # quietly stays without an article in the refusal, and there is nothing to notice that by.
69
70
  rt_rule_article_marks() {
70
71
  [ -f "$1" ] || return 0
71
72
  grep -n 'rt-when:' "$1" 2>/dev/null \
72
73
  | sed -e 's/^\([0-9]*\):.*rt-when:[[:space:]]*/\1 /' -e 's/[[:space:]]*-->.*$//'
73
74
  }
74
75
 
75
- # Текст статьи, внутри которой стоит строка с признаком. Статья начинается ближайшим сверху
76
- # пунктом списка верхнего уровня и кончается перед следующим таким пунктом или перед строкой без
77
- # отступа: продолжение статьи всегда идёт с отступом.
78
- # Заголовок статьи — её жирная первая фраза. Отказ гейта называет статьи ею, а не пересказывает
79
- # их телом: правило заход грузит следом, и тело придёт в контекст вторым разом. У правила текстов
80
- # отказ печатал 4 134 знака одиннадцатью статьями, их заголовки — 718.
76
+ # The text of the article inside which the line with the sign stands. An article begins at the
77
+ # nearest top-level list item above and ends before the next such item or before a line without
78
+ # indentation: the continuation of an article always goes with indentation.
79
+ # The heading of an article is its bold first phrase. The gate refusal names articles by it and does
80
+ # not retell them by their body: the session loads the rule next, and the body would come into the
81
+ # context a second time. For the rule about texts the refusal printed 4,134 characters in eleven
82
+ # articles, their headings — 718.
81
83
  #
82
- # Заголовок при этом не украшение: по нему идёт привязка утверждения к коду, и он же называет
83
- # статью в отказе так, что её видно в правиле глазами.
84
+ # The heading is no ornament: the binding of a statement to code goes by it, and it also names the
85
+ # article in the refusal so that it can be found in the rule by eye.
84
86
  rt_rule_article_heads() {
85
87
  rule_file="$1"
86
88
  edited="$2"