@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,32 +1,34 @@
1
1
  #!/usr/bin/env bash
2
2
  # rt-hook: PreToolUse Edit|Write|MultiEdit|NotebookEdit|Bash|mcp__webstorm__create_new_file|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_tool
3
- # Требует: hooks/profile-check.sh, hooks/deny-tail.sh, hooks/guard-note.sh
4
- # Гард пары «правка и её документ». PreToolUse.
3
+ # Requires: hooks/profile-check.sh, hooks/deny-tail.sh, hooks/guard-note.sh
4
+ # Guard of the pair "an edit and its document". PreToolUse.
5
5
  #
6
- # Расхождение кода с текстом беззвучно. Ни линтер, ни сборка, ни тесты не читают правила,
7
- # спеки и README, поэтому текст, описывающий прежнее устройство, живёт дальше и выглядит
8
- # действующей справкой — тем убедительнее, чем он старше. Ловится это только чтением, и ловит
9
- # обычно владелец, а не проверка.
6
+ # A divergence of the code from the text is soundless. Neither the linter, nor the build, nor the
7
+ # tests read the rules, the specs and the READMEs, so a text describing the previous arrangement
8
+ # lives on and looks like a working reference — the more convincingly, the older it is. It is
9
+ # caught only by reading, and it is usually the owner who catches it, not a check.
10
10
  #
11
- # Гард требует ровно тех пар, где связь механическая и спорить не о чем:
11
+ # The guard demands exactly those pairs where the link is mechanical and there is nothing to argue
12
+ # about:
12
13
  #
13
- # правило и его спутник — когда правится раздел с утверждениями, а не «Ловушки»;
14
- # заведение и удаление либы — README этой либы;
15
- # переезд файла между либами — README обеих;
16
- # остальные пары — их называет профиль дерева, функция `rt_docs_pair_for <файл>`.
14
+ # a rule and its companion — when the section with the statements is edited, not "Pitfalls";
15
+ # creating and removing a lib — the README of that lib;
16
+ # moving a file between libs — the READMEs of both;
17
+ # the rest of the pairs — named by the tree profile, the function `rt_docs_pair_for <file>`.
17
18
  #
18
- # Отдельно — законы. Совпал ли код с законом, машина не знает: правка файла, на который закон
19
- # ссылается якорем, поэтому не отклоняется, а выносится вопросом владельцу. Тем же вопросом
20
- # встречается и правка самого закона — как на месте, так и надстройкой над ним: закон описывает
21
- # договорённость о продукте, и менять её молча гард не даёт.
19
+ # Apart from them — the laws. Whether the code came together with a law, a machine does not know:
20
+ # an edit of a file a law points to by an anchor is therefore not rejected but put to the owner as
21
+ # a question. The same question meets an edit of the law itself — both in place and through an
22
+ # override over it: a law describes a product agreement, and the guard does not let it be changed
23
+ # silently.
22
24
  #
23
- # Обход — строка `Docs-skip: <причина>` в теле коммита. Причина остаётся в истории и видна при
24
- # разборе ветки; пустая не принимается.
25
+ # The bypass is the line `Docs-skip: <reason>` in the commit body. The reason stays in the history
26
+ # and is visible when the branch is reviewed; an empty one is not accepted.
25
27
  #
26
- # ОТКАЗ В ПОЛЬЗУ РАБОТЫ: не репозиторий, нет разборщика, битый ввод, пустой список файлов —
27
- # пропуск.
28
+ # FAIL-OPEN: not a repository, no parser, broken input, an empty list of files — let through.
28
29
 
29
- # Своё имя в наблюдениях: отбой пишет общий хвост отказа, а не сам гард.
30
+ # Its own name in the observations: the refusal is written by the shared deny tail, not by the
31
+ # guard itself.
30
32
  RT_GUARD_NAME=docs-guard
31
33
 
32
34
  . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
@@ -48,27 +50,27 @@ decide() {
48
50
  if command -v rt_deny_tail >/dev/null 2>&1; then
49
51
  reason="$2
50
52
 
51
- $(rt_deny_tail "строка \`Docs-skip: <причина>\` в теле коммита; пустая причина не принимается")"
53
+ $(rt_deny_tail "the line \`Docs-skip: <reason>\` in the commit body; an empty reason is not accepted")"
52
54
  fi
53
55
  fi
54
56
 
55
57
  jq -n --arg d "$1" --arg r "$reason" \
56
58
  '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:$d,permissionDecisionReason:$r}}' 2>/dev/null \
57
- || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"Документ едет тем же коммитом."}}\n'
59
+ || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"The document goes by the same commit."}}\n'
58
60
  exit 0
59
61
  }
60
62
 
61
- # Профиль дерева: сперва умолчание пакета, поверх него — надстройка проекта, если она есть.
62
- # Объявленная в надстройке функция замещает умолчание целиком и вправе позвать его обратно
63
- # суффиксом `_default`.
63
+ # The tree profile: first the package default, and the project override on top of it, if there is
64
+ # one. A function declared in the override replaces the default whole and may call it back through
65
+ # the `_default` suffix.
64
66
  rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
65
67
  for profile in "$rt_hooks_dir/../rt-kit/defaults/project.sh" "$rt_hooks_dir/../defaults/project.sh" "${CLAUDE_PROJECT_DIR:-.}/.claude/rt-kit/defaults/project.sh" "${CLAUDE_PROJECT_DIR:-.}/.claude/rt-kit/project.sh"; do
66
68
  # shellcheck disable=SC1090
67
69
  [ -f "$profile" ] && . "$profile" 2>/dev/null
68
70
  done
69
71
 
70
- # Слово о нехватке функции профиля: хук, вышедший молча, неотличим от работающего. Файл может
71
- # быть не разложен — тогда остаётся прежнее поведение, молчаливое.
72
+ # A word about a missing profile function: a hook that left silently is indistinguishable from a
73
+ # working one. The file may be not laid out — then the previous behaviour stays, the silent one.
72
74
  # shellcheck disable=SC1090
73
75
  [ -f "$rt_hooks_dir/profile-check.sh" ] && . "$rt_hooks_dir/profile-check.sh"
74
76
  command -v rt_needs >/dev/null 2>&1 || rt_needs() { command -v "$1" >/dev/null 2>&1; }
@@ -77,36 +79,37 @@ laws_dir="${RT_LAWS_DIR:-docs/constitution}"
77
79
  lib_marker="${RT_LIB_MARKER:-project.json}"
78
80
  overrides_dir="${RT_OVERRIDES_DIR:-.claude/rt-kit/overrides}"
79
81
 
80
- # ── Правка закона спрашивает владельца ────────────────────────────────────────
82
+ # ── An edit of a law asks the owner ───────────────────────────────────────────
81
83
  #
82
- # Спутник рядом с законом — привязка статей к коду, она устаревает при каждом переименовании и
83
- # правится свободно. Спрашивается только сам текст закона.
84
+ # The companion next to a law is the binding of the articles to the code; it goes stale on every
85
+ # rename and is edited freely. Only the text of the law itself is asked about.
84
86
  #
85
- # Путей к тексту закона два, и ходят чаще вторым. Разложенный закон на месте не правится вовсе:
86
- # правка теряется на следующей раскладке, а сама раскладка на неё отказывает, — поэтому правят
87
- # надстройку, и файл закона переписывает раскладка. Гард, знающий один каталог законов, сторожит
88
- # ровно тот путь, которым к закону и не ходят: чем сложнее надстройка дерева, тем реже закон
89
- # правят на месте. Спрашивается и надстройка — по содержанию это правка закона, а не обвязки.
87
+ # There are two paths to the text of a law, and the second is walked more often. A laid-out law is
88
+ # not edited in place at all: the edit is lost on the next layout, and the layout itself refuses it
89
+ # — so the override is edited, and the file of the law is rewritten by the layout. A guard that
90
+ # knows one laws directory watches exactly the path by which nobody goes to a law: the more
91
+ # involved the tree's override, the more rarely a law is edited in place. The override is asked
92
+ # about too — by its content it is an edit of the law, not of the wrapping.
90
93
  case "$tool" in
91
94
  Edit | Write | MultiEdit | NotebookEdit | mcp__webstorm__create_new_file)
92
95
  target="$(printf '%s' "$input" | jq -r '.tool_input.file_path // .tool_input.filePath // .tool_input.path // .tool_input.pathInProject // empty' 2>/dev/null)"
93
96
  case "$target" in
94
97
  */"$laws_dir"/*.implementation.md | "$laws_dir"/*.implementation.md) exit 0 ;;
95
98
  */"$laws_dir"/*.md | "$laws_dir"/*.md)
96
- decide ask "Правка закона: \`${target##*/}\`. Закон описывает договорённость о продукте, а не устройство кода, — назови владельцу, что и почему меняешь, и дождись ответа. Если правка уже согласована, подтверди вызов."
99
+ decide ask "An edit of a law: \`${target##*/}\`. A law describes an agreement about the product, not the layout of the code — name to the owner what you are changing and why, and wait for the answer. If the edit is already agreed, confirm the call."
97
100
  ;;
98
101
  */"$overrides_dir"/laws/*.implementation.md | "$overrides_dir"/laws/*.implementation.md) exit 0 ;;
99
102
  */"$overrides_dir"/laws/*.md | "$overrides_dir"/laws/*.md)
100
- decide ask "Правка закона надстройкой: \`${target##*/}\`. Разложенный файл переписывает раскладка, поэтому правка надстройки — это правка самого закона: назови владельцу, что и почему меняешь, и дождись ответа. Если правка уже согласована, подтверди вызов."
103
+ decide ask "An edit of a law by an override: \`${target##*/}\`. A laid-out file is rewritten by the layout, so an edit of the override is an edit of the law itself: name to the owner what you are changing and why, and wait for the answer. If the edit is already agreed, confirm the call."
101
104
  ;;
102
105
  esac
103
106
  exit 0
104
107
  ;;
105
108
  esac
106
109
 
107
- # ── Коммит ────────────────────────────────────────────────────────────────────
110
+ # ── The commit ────────────────────────────────────────────────────────────────
108
111
 
109
- # Терминал среды и универсальный исполнитель кладут команду в то же поле.
112
+ # The environment terminal and the universal executor put the command in the same field.
110
113
  case "$tool" in
111
114
  Bash | mcp__webstorm__execute_terminal_command | mcp__webstorm__execute_tool) ;;
112
115
  *) exit 0 ;;
@@ -114,8 +117,8 @@ esac
114
117
 
115
118
  cmd="$(rt_hook_cmd)"
116
119
 
117
- # Универсальный исполнитель передаёт настоящую команду вложенной строкой. Разбирать надо её,
118
- # иначе имя команды стоит сразу за кавычкой и ни одно правило до него не дотягивается.
120
+ # The universal executor passes the real command as a nested string. It is that string that has to
121
+ # be parsed, otherwise the command name stands right after a quote and no rule reaches it.
119
122
  if [ "$tool" = "mcp__webstorm__execute_tool" ] && command -v perl >/dev/null 2>&1; then
120
123
  inner="$(printf '%s' "$cmd" | perl -0ne '
121
124
  if (/--command(?:=|\s+)(?:"((?:[^"\\]|\\.)*)"|\x27([^\x27]*)\x27|(.+))/s) {
@@ -130,13 +133,14 @@ case "$cmd" in
130
133
  *) exit 0 ;;
131
134
  esac
132
135
 
133
- # Причина обхода остаётся в истории, поэтому обход законен. Пустая строка обходом не считается:
134
- # «Docs-skip:» без причины — это тот же молчаливый пропуск, только с двоеточием.
136
+ # The reason for the bypass stays in the history, so the bypass is lawful. An empty line does not
137
+ # count as a bypass: "Docs-skip:" without a reason is the same silent skip, only with a colon.
135
138
  #
136
- # Строка начинает строку — свою в теле коммита или комментарий в конце команды — и подстановки
137
- # не принимает. То же условие, что у обхода при слиянии: иначе текст, который ОБЪЯСНЯЕТ обход,
138
- # снимает требование сам собой. Тело коммита о правке гарда как раз называет эту строку, и без
139
- # привязки к началу гард пропускал бы такой коммит молча.
139
+ # The line starts a line — its own in the commit body, or a comment at the end of the command — and
140
+ # takes no substitutions. The same condition as for the bypass at the merge: otherwise a text that
141
+ # EXPLAINS the bypass lifts the requirement all by itself. A commit body about an edit of the guard
142
+ # names exactly this line, and without the binding to the start the guard would let such a commit
143
+ # through silently.
140
144
  if printf '%s' "$cmd" | grep -qiE '(^|#)[[:space:]]*Docs-skip:[[:space:]]*[^[:space:]<"'"'"'][^[:space:]"'"'"']{2,}'; then
141
145
  exit 0
142
146
  fi
@@ -146,8 +150,8 @@ workdir="$(rt_hook_cwd)"
146
150
  cd "$workdir" 2>/dev/null || exit 0
147
151
  git rev-parse --is-inside-work-tree >/dev/null 2>&1 || exit 0
148
152
 
149
- # `-a` берёт все отслеживаемые правки, `--amend` — ещё и файлы переписываемого коммита.
150
- # Считать всегда по индексу значило бы проверять не тот набор, который уедет в историю.
153
+ # `-a` takes all tracked edits, `--amend` takes the files of the rewritten commit as well. Always
154
+ # counting by the index would mean checking a set other than the one that travels into the history.
151
155
  changes=''
152
156
  source_mode='index'
153
157
  case "$cmd" in
@@ -164,15 +168,16 @@ esac
164
168
  changes="$(printf '%s\n' "$changes" | grep -v '^[[:space:]]*$')"
165
169
  [ -z "$changes" ] && exit 0
166
170
 
167
- # Пути коммита без статусов. Переименование подаётся тремя полями — берём обе стороны.
171
+ # The paths of the commit without the statuses. A rename comes as three fields — we take both sides.
168
172
  paths="$(printf '%s\n' "$changes" | awk -F'\t' '{ for (i = 2; i <= NF; i++) if ($i != "") print $i }' | sort -u)"
169
173
 
170
174
  has_path() { printf '%s\n' "$paths" | grep -qxF "$1"; }
171
175
 
172
- # Содержимое таким, каким оно уедет в коммит. Источник тот же, по которому собран список
173
- # правок: `-a` заберёт рабочее дерево, обычный коммит — индекс. Читать индекс всегда нельзя —
174
- # при `-a` там лежит прежняя редакция, и гард держал бы коммит, который расхождение и чинит;
175
- # читать рабочее дерево всегда тоже нельзя — неподготовленная правка в коммит не попадёт.
176
+ # The content as it will travel into the commit. The source is the same one the list of edits was
177
+ # collected by: `-a` takes the working tree, an ordinary commit takes the index. Always reading the
178
+ # index is not allowed — under `-a` the previous edition lies there, and the guard would hold the
179
+ # very commit that fixes the divergence; always reading the working tree is not allowed either — an
180
+ # unstaged edit will not get into the commit.
176
181
  content_of() {
177
182
  if [ "$source_mode" = 'worktree' ]; then
178
183
  cat "$1" 2>/dev/null
@@ -185,15 +190,17 @@ problems=''
185
190
  add() { problems="${problems}
186
191
  • $1"; }
187
192
 
188
- # ── 1. Правило и его спутник ──────────────────────────────────────────────────
193
+ # ── 1. A rule and its companion ───────────────────────────────────────────────
189
194
  #
190
- # Утверждения правила ключуются своим текстом, и переформулировка без правки спутника рвёт
191
- # связь молча. Сверка спеков это ловит, но гоняется в гейте пуша — здесь та же пара
192
- # встречается коммитом раньше, пока правка ещё в голове у автора.
195
+ # The statements of a rule are keyed by their own text, and a rewording without an edit of the
196
+ # companion breaks the link silently. The spec audit catches this, but it is run at the push gate —
197
+ # here the same pair meets a commit earlier, while the edit is still in the author's head.
193
198
  #
194
- # Раздел с утверждениями — единственное, что связано со спутником; правка «Ловушек» или
195
- # таблицы «Где это лежит» его не трогает, поэтому сравнивается только этот раздел.
196
- STATEMENTS='/^## Как закон применяется здесь$/,/^## [^К]/'
199
+ # The section with the statements is the only thing linked to the companion; an edit of "Pitfalls"
200
+ # or of the "Where it lives" table does not touch it, so only this section is compared. The name of
201
+ # the section is double: English in a package rule, Russian in a rule written by the tree before the
202
+ # layer was translated. The end of the range is any heading not starting with their first letter.
203
+ STATEMENTS='/^## (How the law applies here|Как закон применяется здесь)$/,/^## [^КH]/'
197
204
  statements_of() { content_of "$1" | awk "$STATEMENTS"; }
198
205
 
199
206
  for rule in $(printf '%s\n' "$paths" | grep -E '/SKILL\.md$'); do
@@ -204,28 +211,39 @@ for rule in $(printf '%s\n' "$paths" | grep -E '/SKILL\.md$'); do
204
211
  has_path "$companion" && continue
205
212
 
206
213
  if [ "$(statements_of "$rule")" != "$(git show "HEAD:$rule" 2>/dev/null | awk "$STATEMENTS")" ]; then
207
- add "утверждения \`$rule\` правятся без спутника — добавь в коммит \`$companion\`"
214
+ add "the statements of \`$rule\` are edited without the companion — add \`$companion\` to the commit"
208
215
  fi
209
216
  done
210
217
 
211
- # ── 2. Пары, которые называет дерево ──────────────────────────────────────────
218
+ # ── 2. The pairs the tree names ───────────────────────────────────────────────
212
219
  #
213
- # Контракт и спек домена, гард и его сценарии — что именно, знает профиль: связь у каждого
214
- # дерева своя, а механика одна.
220
+ # The contract and the domain spec, a guard and its scenarios — which exactly, the profile knows:
221
+ # every tree has a link of its own, and the mechanics are one.
215
222
  if rt_needs rt_docs_pair_for docs-guard; then
216
223
  while IFS= read -r file; do
217
224
  [ -z "$file" ] && continue
225
+
226
+ # A file put in place by the layout demands no pair: it has one author in a consuming tree
227
+ # — the package, and the document about it lies there as well. Otherwise the very first
228
+ # layout demands a bypass over its whole volume, and a bypass declared over a hundred files
229
+ # lifts the requirement from future hand edits of those files too. The sign is the layout
230
+ # header: it stands in every laid-out file and tells it apart more reliably than any list
231
+ # of paths.
232
+ if [ -f "$file" ] && head -12 "$file" 2>/dev/null | grep -qE 'rt-kit v[^ ]+ · [^ ]+ · [0-9a-f]+'; then
233
+ continue
234
+ fi
235
+
218
236
  want="$(rt_docs_pair_for "$file" 2>/dev/null)"
219
237
  [ -z "$want" ] && continue
220
- # Пара считается приехавшей, если хоть один файл коммита подходит под образец.
238
+ # The pair counts as arrived if at least one file of the commit fits the pattern.
221
239
  printf '%s\n' "$paths" | grep -qE "$want" && continue
222
- add "\`$file\` правится без документа — тем же коммитом ждёт \`$want\`"
240
+ add "\`$file\` is edited without its document — the same commit awaits \`$want\`"
223
241
  done <<EOF
224
242
  $paths
225
243
  EOF
226
244
  fi
227
245
 
228
- # ── 3. Либа и её README ───────────────────────────────────────────────────────
246
+ # ── 3. A lib and its README ───────────────────────────────────────────────────
229
247
 
230
248
  lib_root() {
231
249
  dir="${1%/*}"
@@ -245,16 +263,16 @@ want_readme() {
245
263
  need_readme="$need_readme $root"
246
264
  }
247
265
 
248
- # Заведение и удаление либы: README — единственное место, где написано, что в ней лежит и кто
249
- # её зовёт, и раскладку она переживает только вместе с правкой этого текста.
266
+ # Creating and removing a lib: the README is the only place where it is written what lies in it and
267
+ # who calls it, and it survives the layout only together with an edit of that text.
250
268
  while IFS="$(printf '\t')" read -r status first second; do
251
269
  case "$status" in
252
270
  A* | D*)
253
271
  case "$first" in */"$lib_marker") want_readme "${first%/"$lib_marker"}" ;; esac
254
272
  ;;
255
273
  R*)
256
- # Переезд файла меняет обе стороны: у одной либы он пропал из состава, у другой
257
- # появился.
274
+ # A move of a file changes both sides: from one lib it disappeared, in the other it
275
+ # appeared.
258
276
  from="$(lib_root "$first")" && to="$(lib_root "$second")"
259
277
  if [ -n "$from" ] && [ -n "$to" ] && [ "$from" != "$to" ]; then
260
278
  want_readme "$from"
@@ -266,8 +284,8 @@ done <<EOF
266
284
  $changes
267
285
  EOF
268
286
 
269
- # Переезд, поданный парой «удалено там, добавлено тут»: переименованием считается не всё, что
270
- # им является, — правка содержимого при переносе сбивает поиск.
287
+ # A move given as the pair "deleted there, added here": not everything that is a rename counts as
288
+ # one — an edit of the content while moving throws the search off.
271
289
  moved_added="$(printf '%s\n' "$changes" | awk -F'\t' '$1 ~ /^A/ { n = split($2, p, "/"); print p[n] "\t" $2 }' | sort -u)"
272
290
  moved_deleted="$(printf '%s\n' "$changes" | awk -F'\t' '$1 ~ /^D/ { n = split($2, p, "/"); print p[n] "\t" $2 }' | sort -u)"
273
291
  if [ -n "$moved_added" ] && [ -n "$moved_deleted" ]; then
@@ -286,25 +304,26 @@ EOF
286
304
  fi
287
305
 
288
306
  for root in $need_readme; do
289
- [ -d "$root" ] || continue # либу удалили целиком — править в ней нечего
290
- has_path "$root/README.md" || add "состав либы \`$root\` изменился без правки \`$root/README.md\`"
307
+ [ -d "$root" ] || continue # the lib was deleted whole — there is nothing to edit in it
308
+ has_path "$root/README.md" || add "the content of the lib \`$root\` changed without an edit of \`$root/README.md\`"
291
309
  done
292
310
 
293
311
  if [ -n "$problems" ]; then
294
- decide deny "BLOCKED: коммит правит код, но не документ, который его описывает.
312
+ decide deny "BLOCKED: the commit edits code but not the document that describes it.
295
313
  ${problems}
296
314
 
297
- Текст правится в той же ветке, что и код: документ, разошедшийся с деревом, выглядит действующей справкой и уводит следующего читателя. Если правка документа здесь действительно не нужна — назови причину строкой \`Docs-skip: <причина>\` в теле коммита, она останется в истории."
315
+ Text is edited in the same branch as the code: a document that has drifted from the tree looks like a current reference and leads the next reader astray. If an edit of the document really is not needed here — name the reason by the line \`Docs-skip: <reason>\` in the commit body, it stays in the history."
298
316
  fi
299
317
 
300
- # ── 4. Законы ─────────────────────────────────────────────────────────────────
318
+ # ── 4. The laws ───────────────────────────────────────────────────────────────
301
319
  #
302
- # Отклонять нечего: сошлась ли правка с законом, видно только чтением. Но место, где статья
303
- # закона исполняется, названо якорем, и правка ровно этого файла — единственный момент, когда
304
- # сверку ещё дёшево сделать.
320
+ # There is nothing to reject: whether the edit came together with a law is visible only by reading.
321
+ # But the place where an article of a law is carried out is named by an anchor, and an edit of
322
+ # exactly that file is the only moment when the audit is still cheap to do.
305
323
  #
306
- # Слоёв законов два: общий в корне, закон приложения — в каталоге под ним. Образец принимает
307
- # оба, иначе правка предметного закона считалась бы правкой мимо законов.
324
+ # There are two layers of laws: the shared one in the root, an application law in a directory under
325
+ # it. The pattern accepts both, otherwise an edit of a subject law would count as an edit past the
326
+ # laws.
308
327
  if [ -d "$laws_dir" ] && ! printf '%s\n' "$paths" | grep -qE "^${laws_dir}/([^/]+/)?[^/]+\.md$"; then
309
328
  touched=''
310
329
  for anchor in $(grep -ohE '`[A-Za-z0-9_./@-]+\.(ts|mjs|html|scss|prisma|proto|json)(:[A-Za-z0-9_#.-]+)?`' "$laws_dir"/*.implementation.md 2>/dev/null \
@@ -314,10 +333,10 @@ if [ -d "$laws_dir" ] && ! printf '%s\n' "$paths" | grep -qE "^${laws_dir}/([^/]
314
333
  done
315
334
 
316
335
  if [ -n "$touched" ]; then
317
- decide ask "Правка задевает места, где исполняются статьи законов:
336
+ decide ask "The edit touches the places where articles of laws are carried out:
318
337
  ${touched}
319
338
 
320
- Законы лежат в \`${laws_dir}/\`, привязка — в спутниках рядом. Прочитай закон и скажи владельцу, сошлась ли с ним правка: если правка его уточняет или ему противоречит, закон правится в этой же ветке, но только с его ведома. Если закон не изменился — подтверди вызов."
339
+ The laws lie in \`${laws_dir}/\`, the binding — in the companions next to them. Read the law and tell the owner whether the edit agrees with it: if the edit refines it or contradicts it, the law is edited in this same branch, but only with their knowledge. If the law has not changed — confirm the call."
321
340
  fi
322
341
  fi
323
342