@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,19 +1,21 @@
1
1
  #!/usr/bin/env bash
2
2
  # rt-hook: PreToolUse Bash|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_tool
3
- # Требует: hooks/deny-tail.sh, hooks/guard-note.sh
4
- # Гард главной ветки. PreToolUse на вызове коммита.
3
+ # Requires: hooks/deny-tail.sh, hooks/guard-note.sh
4
+ # Guard of the main branch. PreToolUse on a commit call.
5
5
  #
6
- # Коммит в главную ветку минует ветку, PR и разбор, а поставка построена на них целиком —
7
- # правило `git-workflow`. Прямой коммит туда почти всегда промах: «остался на главной после
8
- # слияния предыдущего PR».
6
+ # A commit into the main branch bypasses the branch, the PR and the review, while delivery is built
7
+ # on them entirely — rule `git-workflow`. A direct commit there is almost always a miss: "stayed on
8
+ # main after merging the previous PR".
9
9
  #
10
- # Имя главной ветки не зашито строкой: сначала спрашивается указатель удалённого репозитория,
11
- # затем пробуются существующие `origin/main` и `origin/master`, и лишь в конце берётся `main`.
10
+ # The name of the main branch is not hard-wired as a string: first the pointer of the remote
11
+ # repository is asked, then the existing `origin/main` and `origin/master` are tried, and only at
12
+ # the end `main` is taken.
12
13
  #
13
- # ОТКАЗ В ПОЛЬЗУ РАБОТЫ: не репозиторий, нет гита, открепившийся HEAD, битый ввод — пропуск.
14
- # Сломанный гард не должен мешать работать.
14
+ # FAIL-OPEN: not a repository, no git, a detached HEAD, broken input — pass. A broken guard must not
15
+ # get in the way of work.
15
16
 
16
- # Своё имя в наблюдениях: отбой пишет общий хвост отказа, а не сам гард.
17
+ # Its own name in the observations: the refusal is written by the shared deny tail, not by the
18
+ # guard itself.
17
19
  RT_GUARD_NAME=git-guard-main
18
20
 
19
21
  . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
@@ -24,8 +26,8 @@ input="$RT_HOOK_INPUT"
24
26
  [ -z "$input" ] && exit 0
25
27
 
26
28
  tool="$(rt_hook_tool)"
27
- # Терминал среды разработки исполняет ту же командную строку и кладёт её в то же поле. Пока
28
- # гард проверял только оболочку, весь его смысл обходился сменой инструмента.
29
+ # The terminal of the development environment runs the same command line and puts it into the same
30
+ # field. While the guard judged the shell alone, its whole point was bypassed by switching tools.
29
31
  case "$tool" in
30
32
  Bash | mcp__webstorm__execute_terminal_command | mcp__webstorm__execute_tool) ;;
31
33
  *) exit 0 ;;
@@ -33,9 +35,9 @@ esac
33
35
 
34
36
  cmd="$(rt_hook_cmd)"
35
37
 
36
- # Универсальный исполнитель среды передаёт настоящую команду вложенной строкой. Разбирать надо
37
- # её, а не обёртку: иначе имя команды стоит сразу за кавычкой и ни одно правило до него не
38
- # дотягивается.
38
+ # The universal executor of the environment passes the real command as a nested string. It is the
39
+ # one to parse, not the wrapper: otherwise the command name stands right after a quote and no rule
40
+ # reaches it.
39
41
  if [ "$tool" = "mcp__webstorm__execute_tool" ] && command -v perl >/dev/null 2>&1; then
40
42
  inner="$(printf '%s' "$cmd" | perl -0ne '
41
43
  if (/--command(?:=|\s+)(?:"((?:[^"\\]|\\.)*)"|\x27([^\x27]*)\x27|(.+))/s) {
@@ -44,13 +46,50 @@ if [ "$tool" = "mcp__webstorm__execute_tool" ] && command -v perl >/dev/null 2>&
44
46
  ' 2>/dev/null)"
45
47
  [ -n "$inner" ] && cmd="$inner"
46
48
  fi
47
- case "$cmd" in
48
- *git\ commit*) ;;
49
- *) exit 0 ;;
50
- esac
49
+ # The verb is looked for in the command position, not as a substring in the line.
50
+ #
51
+ # A bare search for "git commit" misses in both directions. A call with an option between `git` and
52
+ # the verb slips past it — `git -c user.name=… commit`, `git -C <tree> commit` — and that is exactly
53
+ # how one commits under the machine account. And it catches a line where these two words stand next
54
+ # to each other for another reason: `git log --grep 'git commit'`, parsing someone else's output,
55
+ # the text of a message. A refusal on reading the history costs more than a miss: a guard that gets
56
+ # in the way of reading is switched off on the first day.
57
+ #
58
+ # The parsing is simple: for every word `git` in the line the options are skipped — on their own and
59
+ # together with a value, if the option takes one — and the first word without a dash is the verb.
60
+ # There can be several `git` words in a line (`git add . && git commit`), so the verbs of all of
61
+ # them are printed and the list is judged as a whole.
62
+ if command -v awk >/dev/null 2>&1; then
63
+ verbs="$(printf '%s\n' "$cmd" | awk '
64
+ {
65
+ for (i = 1; i <= NF; i++) {
66
+ word = $i
67
+ sub(/^.*\//, "", word)
68
+ if (word != "git") continue
69
+ for (j = i + 1; j <= NF; j++) {
70
+ arg = $j
71
+ if (arg == "-c" || arg == "-C" || arg == "--git-dir" || arg == "--work-tree" \
72
+ || arg == "--namespace" || arg == "--exec-path") { j++; continue }
73
+ if (substr(arg, 1, 1) == "-") continue
74
+ print arg
75
+ break
76
+ }
77
+ }
78
+ }
79
+ ' 2>/dev/null)"
80
+ printf '%s\n' "$verbs" | grep -qx 'commit' || exit 0
81
+ else
82
+ # No parser — the former sign remains: it lies in both directions, but without it the guard
83
+ # judges nothing at all.
84
+ case "$cmd" in
85
+ *git\ commit*) ;;
86
+ *) exit 0 ;;
87
+ esac
88
+ fi
51
89
 
52
- # Коммит выполнится в рабочем каталоге вызова, поэтому и ветку смотрим там же; корень проекта
53
- # — запасной вариант, и он важен для отдельного рабочего дерева, где ветка своя.
90
+ # The commit will run in the working directory of the call, so the branch is looked at there too;
91
+ # the project root is the fallback, and it matters for a separate working tree with a branch of its
92
+ # own.
54
93
  workdir="$(rt_hook_cwd)"
55
94
  [ -z "$workdir" ] && workdir="${CLAUDE_PROJECT_DIR:-.}"
56
95
  cd "$workdir" 2>/dev/null || exit 0
@@ -58,7 +97,7 @@ cd "$workdir" 2>/dev/null || exit 0
58
97
  git rev-parse --is-inside-work-tree >/dev/null 2>&1 || exit 0
59
98
 
60
99
  branch="$(git branch --show-current 2>/dev/null)"
61
- [ -z "$branch" ] && exit 0 # открепившийся HEAD — не про этот случай
100
+ [ -z "$branch" ] && exit 0 # a detached HEAD is not about this case
62
101
 
63
102
  default="$(git symbolic-ref --quiet --short refs/remotes/origin/HEAD 2>/dev/null | sed 's#^origin/##')"
64
103
  if [ -z "$default" ]; then
@@ -73,10 +112,10 @@ fi
73
112
 
74
113
  [ "$branch" = "$default" ] || exit 0
75
114
 
76
- reason="Отбито: коммит прямо в «${default}». Работа едет через ветку и PR — правило git-workflow. Заведи ветку отдельным вызовом и коммить в неё: подготовленные изменения при этом сохранятся. Если коммит в ${default} действительно нужен — спроси владельца, сам не обходи."
115
+ reason="Refused: a commit straight into «${default}». Work travels through a branch and a PR — the rule git-workflow. Create a branch by a separate call and commit into it: the staged changes stay in place. If a commit into ${default} really is needed — ask the owner, do not bypass it yourself."
77
116
 
78
- # Общий хвост отказа: два законных хода и законная форма обхода, если она у отказа есть.
79
- # Файл может быть не разложен — тогда хвоста нет, а причина отказа остаётся прежней.
117
+ # The shared deny tail: the two lawful moves and the lawful form of bypass, if the refusal has one.
118
+ # The file may not be laid out — then there is no tail, and the refusal reason stays as it is.
80
119
  # shellcheck disable=SC1090
81
120
  [ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
82
121
  && . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
@@ -87,6 +126,6 @@ deny_tail_text="$(rt_deny_tail "")"
87
126
  ${deny_tail_text}"
88
127
 
89
128
  jq -n --arg r "$reason" '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:$r}}' 2>/dev/null \
90
- || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"Коммит в главную ветку отбит. Заведи ветку."}}\n'
129
+ || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"A commit into the main branch is refused. Create a branch."}}\n'
91
130
 
92
131
  exit 0
@@ -1,31 +1,32 @@
1
1
  #!/usr/bin/env bash
2
2
  # rt-hook: PreToolUse Bash|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 guard of the checks before a push. PreToolUse on the push call.
5
5
  #
6
- # Пуш — это вход в конвейер: слияние в главную ветку запускает выкатку, и всё, что не
7
- # проверено локально, проверяется уже на проде. Сюда дважды подряд уезжают правки, зелёные в
8
- # выборочном прогоне и красные в конвейере: один раз прогонялись только сквозные спеки, другой
9
- # — только затронутый проект.
6
+ # A push is the entry into the pipeline: a merge into the main branch starts the rollout, and
7
+ # everything not checked locally gets checked on production already. Edits go out this way twice in
8
+ # a row, green in a selective run and red in the pipeline: one time only the end-to-end specs were
9
+ # run, the other only the affected project.
10
10
  #
11
- # Гард не верит на слово: он сам гоняет то, что перечислил профиль дерева, и пускает пуш только
12
- # при нулевом коде возврата. Если прогонщик кэширует результат, набор на неизменившемся дереве
13
- # занимает секунды, а после правки гоняется заново.
11
+ # The guard does not take it on trust: it runs what the tree profile listed itself, and lets the
12
+ # push through only on a zero return code. If the runner caches the result, the set takes seconds
13
+ # on an unchanged tree, and after an edit it is run anew.
14
14
  #
15
- # Что гонять, знает профиль: функция `rt_push_checks <база>` — по команде на строку. База —
16
- # ветка, относительно которой считается вклад; пустая означает, что удалённого нет. Функция
17
- # зовётся из каталога, откуда идёт пуш, и вправе решать по нему сама: шаг, проверки которого в
18
- # дереве нет, она просто не печатает. Нет профиля или нет функции — гард пропускает: список
19
- # проверок пакет выдумать не может.
15
+ # What to run is known by the profile: the function `rt_push_checks <base>` — one command per line.
16
+ # The base is the branch the contribution is counted against; empty means there is no remote. The
17
+ # function is called from the directory the push goes from and may decide by it itself: a step
18
+ # whose checks the tree does not have it simply does not print. There is no profile or no function
19
+ # — the guard passes: the package cannot invent the list of checks.
20
20
  #
21
- # База берётся у удалённого, а не у локальной главной ветки: локальная отстаёт или расходится
22
- # молча. Это уже случалось — локальная стояла на слиянии, стёртом из истории силовым пушем, и
23
- # набор от неё посчитался бы не тот. Нет сети или нет удалённого — база пустая, и профиль
24
- # откатывается на полный прогон: гейт может оказаться строже нужного, но НИКОГДА не слабее.
21
+ # The base is taken from the remote, not from the local main branch: the local one falls behind or
22
+ # diverges silently. That has happened already — the local one stood at a merge wiped from the
23
+ # history by a force push, and the set counted against it would have been the wrong one. There is
24
+ # no network or no remote — the base is empty, and the profile falls back to a full run: the gate
25
+ # may turn out stricter than needed, but NEVER weaker.
25
26
  #
26
- # ОТКАЗ В ПОЛЬЗУ РАБОТЫ: не репозиторий, битый ввод, нет профиля — пропуск.
27
+ # FAIL-OPEN: not a repository, broken input, no profile — pass.
27
28
 
28
- # Своё имя в наблюдениях: отбой пишет общий хвост отказа, а не сам гард.
29
+ # Its own name in the observations: the refusal is written by the shared deny tail, not by the guard.
29
30
  RT_GUARD_NAME=git-guard-push-tests
30
31
 
31
32
  . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
@@ -37,48 +38,51 @@ input="$RT_HOOK_INPUT"
37
38
 
38
39
  tool="$(rt_hook_tool)"
39
40
  case "$tool" in
40
- # Терминал среды и универсальный исполнитель кладут команду в то же поле.
41
+ # The environment terminal and the universal runner put the command into the same field.
41
42
  Bash | mcp__webstorm__execute_terminal_command | mcp__webstorm__execute_tool) ;;
42
43
  *) exit 0 ;;
43
44
  esac
44
45
 
45
46
  cmd="$(rt_hook_cmd)"
46
47
 
47
- # Вызов пуша узнаётся по двум признакам сразу — команда `git` в начале строки или за
48
- # разделителем и слово `push` отдельным словом. Тем же приёмом, что у гарда поставки: одной
49
- # подстрокой «git push» пуш не поймать — помощник учётных данных и заголовок запроса ставятся
50
- # ключами `-c` между ними, и ровно этой формой здесь и пушат. Пока признаком была подстрока,
51
- # весь набор гейта на таком пуше не гонялся вовсе, а молчание гарда читалось как «зелено».
48
+ # A push call is recognised by two signs at once — the `git` command at the start of the line or
49
+ # after a separator, and the word `push` as a separate word. By the same technique as the delivery
50
+ # guard: the substring "git push" alone does not catch a push — the credentials helper and the
51
+ # request header are put between them by `-c` keys, and that is exactly the form pushed with here.
52
+ # While the sign was a substring, the whole gate set was not run at all on such a push, and the
53
+ # silence of the guard read as "green".
52
54
  printf '%s' "$cmd" | grep -qE "${RT_CMD_BOUND}git([[:space:]]|\$)" || exit 0
53
55
 
54
- # Отложенная правка пушем не бывает: `git stash push` кладёт правку в тайник этой же машины и
55
- # наружу не отправляет ничего. Слово `push` в ней стоит отдельным, и без этой строки гард гонял
56
- # на ней весь набор, а потом отбивал вызов на первой красной проверке — то есть отбивал команду,
57
- # которая ничего никуда не отправляет. Тайник вырезается из строки, и признак считается по
58
- # остатку: в составной команде рядом с ним может стоять и настоящий пуш.
56
+ # A stashed edit is never a push: `git stash push` puts the edit into the stash of this same
57
+ # machine and sends nothing outside. The word `push` in it stands separate, and without this line
58
+ # the guard ran the whole set on it and then refused the call on the first red check — that is, it
59
+ # refused a command that sends nothing anywhere. The stash is cut out of the line, and the sign is
60
+ # counted on the remainder: in a compound command a real push may stand next to it.
59
61
  probe="$(printf '%s' "$cmd" | sed -E 's/git[[:space:]]+stash[[:space:]]+push/git stash/g')"
60
62
  printf '%s' "$probe" | grep -qE '(^|[[:space:]])push([[:space:]]|$)' || exit 0
61
63
 
62
- # Пробный пуш ничего не отправляет: гонять ради него весь набор незачем.
64
+ # A dry-run push sends nothing: there is no point running the whole set for it.
63
65
  case "$cmd" in
64
66
  *--dry-run*) exit 0 ;;
65
67
  esac
66
68
 
67
- # Переключение ветки в той же команде отбивается целиком.
69
+ # A branch switch in the same command is refused whole.
68
70
  #
69
- # Гард — это разбор команды ДО её запуска: набор он гоняет в том дереве, какое лежит сейчас.
70
- # Составная «переключиться и запушить» проходит гейт по ПРЕЖНЕЙ ветке — молча, проверяя не то.
71
- # Отказа при этом нет, и зелёный набор читается как проверка того, что уходит на хостинг.
72
- # Поймано это было случайно: гейт отбил пуш красной проверкой длины файла, которого в пушимой
73
- # ветке нет вовсе — он смотрел ветку, с которой в этой же команде уходили.
71
+ # The guard is a parse of the command BEFORE it runs: it runs the set in the tree that lies there
72
+ # now. A compound "switch and push" passes the gate on the FORMER branch — silently, checking the
73
+ # wrong thing. There is no refusal at that, and a green set reads as a check of what goes to the
74
+ # hosting. This was caught by chance: the gate refused a push on a red check of file length for a
75
+ # file that is not in the pushed branch at all — it was looking at the branch the same command was
76
+ # leaving.
74
77
  #
75
- # Судится переключение на существующую ветку. Заведение новой (`checkout -b`, `switch -c`)
76
- # сюда не попадает: у свежей ветки дерево то же самое, что и было.
78
+ # What is judged is a switch to an existing branch. Creating a new one (`checkout -b`, `switch -c`)
79
+ # does not fall here: a fresh branch has the same tree as it had.
77
80
  if printf '%s' "$cmd" | grep -qE "${RT_CMD_BOUND}git[[:space:]]+(checkout|switch)[[:space:]]+" &&
78
- ! printf '%s' "$cmd" | grep -qE 'git[[:space:]]+(checkout[[:space:]]+-b|switch[[:space:]]+-c)([[:space:]]|$)'; then
79
- reason="BLOCKED: переключение ветки и пуш одной командой. Набор гейта гоняется в том дереве, какое лежит на момент разбора команды, — то есть по ПРЕЖНЕЙ ветке, а не по той, что уходит на хостинг. Зелёный набор при этом читается как проверка ушедшего, хотя проверял он другое. Раздели вызовы: сперва переключись, затем отдельной командой пушь."
80
- # Общий хвост отказа: два законных хода и законная форма обхода, если она у отказа есть.
81
- # Файл может быть не разложен — тогда хвоста нет, а причина отказа остаётся прежней.
81
+ ! printf '%s' "$cmd" | grep -qE 'git[[:space:]]+(checkout([[:space:]]+-[A-Za-z-]+)*[[:space:]]+-b|switch([[:space:]]+-[A-Za-z-]+)*[[:space:]]+-c)([[:space:]]|$)'; then
82
+ reason="BLOCKED: switching the branch and pushing by one command. The gate set runs on the tree that lies there at the minute the command is parsed — that is, on the FORMER branch, not the one that leaves for the hosting. A green set then reads as a check of what left, though it checked something else. Split the calls: switch first, then push by a separate command."
83
+ # The shared deny tail: the two lawful moves and the lawful form of bypass, if the refusal has
84
+ # one. The file may not be laid out — then there is no tail, and the reason for the refusal
85
+ # stays as it was.
82
86
  # shellcheck disable=SC1090
83
87
  [ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
84
88
  && . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
@@ -89,7 +93,7 @@ if printf '%s' "$cmd" | grep -qE "${RT_CMD_BOUND}git[[:space:]]+(checkout|switch
89
93
  ${deny_tail_text}"
90
94
 
91
95
  jq -n --arg r "$reason" '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:$r}}' 2>/dev/null \
92
- || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"Переключение ветки и пуш одной командой."}}\n'
96
+ || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"Switching the branch and pushing by one command."}}\n'
93
97
  exit 0
94
98
  fi
95
99
 
@@ -99,22 +103,45 @@ cd "$workdir" 2>/dev/null || exit 0
99
103
  git rev-parse --is-inside-work-tree >/dev/null 2>&1 || exit 0
100
104
  [ -f package.json ] || exit 0
101
105
 
102
- # Профиль дерева: сперва умолчание пакета, поверх него — надстройка проекта, если она есть.
103
- # Объявленная в надстройке функция замещает умолчание целиком и вправе позвать его обратно
104
- # суффиксом `_default`. Нет ни того ни другого — хук пропускает: пустой гард лучше гарда,
105
- # отбивающего наугад.
106
+ # The tree profile: first the package default, over it the project override, if there is one. A
107
+ # function declared in the override replaces the default whole and may call it back by the
108
+ # `_default` suffix. There is neither — the hook passes: an empty guard is better than a guard
109
+ # that refuses at random.
106
110
  rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
107
111
  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
108
112
  # shellcheck disable=SC1090
109
113
  [ -f "$profile" ] && . "$profile" 2>/dev/null
110
114
  done
111
115
 
112
- # Слово о нехватке функции профиля: хук, вышедший молча, неотличим от работающего. Файл может
113
- # быть не разложен — тогда остаётся прежнее поведение, молчаливое.
116
+ # A word about a missing profile function: a hook that exited silently is indistinguishable from a
117
+ # working one. The file may not be laid out — then the former, silent behaviour stays.
114
118
  # shellcheck disable=SC1090
115
119
  [ -f "$rt_hooks_dir/profile-check.sh" ] && . "$rt_hooks_dir/profile-check.sh"
116
120
  command -v rt_needs >/dev/null 2>&1 || rt_needs() { command -v "$1" >/dev/null 2>&1; }
117
- rt_needs rt_push_checks git-guard-push-tests || exit 0
121
+
122
+ # An observation line on every outcome. A guard that writes only refusals answers one question out
123
+ # of three: how many pushes it stopped. "The set was run and is green" and "no set was found" look
124
+ # the same in the record — as silence — and a gate that has not run a single check in a week is
125
+ # indistinguishable from a gate where everything is green. This is written into the same
126
+ # observations record as guard refusals, and goes out by the same tree switch.
127
+ rt_push_gate_note() {
128
+ local outcome="$1" sid
129
+ # shellcheck disable=SC1090
130
+ [ -f "$rt_hooks_dir/observe.sh" ] && . "$rt_hooks_dir/observe.sh" 2>/dev/null
131
+ command -v rt_note >/dev/null 2>&1 || return 0
132
+ sid="$(printf '%s' "$input" | jq -r '.session_id // empty' 2>/dev/null)"
133
+ if [ -n "$sid" ]; then
134
+ rt_note push-gate "res=$outcome" "sid=$sid"
135
+ else
136
+ rt_note push-gate "res=$outcome"
137
+ fi
138
+ return 0
139
+ }
140
+
141
+ if ! rt_needs rt_push_checks git-guard-push-tests; then
142
+ rt_push_gate_note no-checks
143
+ exit 0
144
+ fi
118
145
 
119
146
  main_branch="${RT_MAIN_BRANCH:-main}"
120
147
  base=''
@@ -122,17 +149,20 @@ if git fetch --quiet origin "$main_branch" 2>/dev/null && git rev-parse --verify
122
149
  base="origin/$main_branch"
123
150
  fi
124
151
 
125
- # Код, которым проверка объявляет, что смотреть было не на что: ни «сошлось», ни «расхождение».
126
- # Прежде такая проверка говорила о себе строкой вывода и выходила нулём — в наборе этот ноль
127
- # стоял рядом с пройденными и ничем от них не отличался, а сводка читалась как проверенная
128
- # целиком. Пуш он не отбивает: проверка, которой нечего смотреть, поломкой не является.
152
+ # The code by which a check declares that there was nothing to look at: neither "it matched" nor
153
+ # "a divergence". Before, such a check said so by a line of output and exited with zero — in the
154
+ # set that zero stood next to the passed ones and differed from them in nothing, while the summary
155
+ # read as checked whole. It does not refuse the push: a check with nothing to look at is not a
156
+ # breakage.
129
157
  rt_skip_code="${RT_SKIP_CODE:-7}"
130
158
 
131
159
  failed=""
132
160
  output=""
133
161
  skipped=""
162
+ ran=0
134
163
  while IFS= read -r check; do
135
164
  [ -z "$check" ] && continue
165
+ ran=$((ran + 1))
136
166
  out="$(eval "$check" 2>&1)"
137
167
  status=$?
138
168
  [ "$status" -eq 0 ] && continue
@@ -148,44 +178,72 @@ done <<EOF
148
178
  $(rt_push_checks "$base")
149
179
  EOF
150
180
 
151
- # Пропущенное называется вслух и тогда, когда набор прошёл: молчание о нём и есть та самая
152
- # неотличимость, ради которой код заведён. Пуш при этом идёт — отказа здесь нет.
181
+ # What was skipped is named aloud even when the set passed: silence about it is exactly the
182
+ # indistinguishability this code was created for. The push goes through at that — there is no
183
+ # refusal here.
184
+ # The profile function is there, but it has nothing to print in this tree: the outcome is the same
185
+ # as without it — no set was found, and silence about that would read as a green run.
186
+ if [ "$ran" -eq 0 ]; then
187
+ rt_push_gate_note no-checks
188
+ exit 0
189
+ fi
190
+
153
191
  if [ -z "$failed" ] && [ -n "$skipped" ]; then
154
- printf 'гейт пуша: набор прошёл, но эти проверки смотреть было не на что:\n%s\n' "$skipped" >&2
192
+ printf 'the push gate: the set passed, but these checks had nothing to look at:\n%s\n' "$skipped" >&2
155
193
  fi
156
194
 
157
- # Чем набор гейта уже набора конвейера — сказанное один раз за сессию.
195
+ # How the gate set is narrower than the pipeline set — said once per session.
158
196
  #
159
- # Правило поставки требует, чтобы гейт не был уже конвейера, а собрать это требование нечем:
160
- # файл конвейера у каждого дерева свой, и вывести из него шаги набора пакет не может. Молчание
161
- # при этом читается как «проверено всё»: расхождение узнаётся из красного конвейера после
162
- # заявки, когда правка уже отдана человеку.
197
+ # The delivery rule demands that the gate not be narrower than the pipeline, and there is nothing
198
+ # to assemble that requirement from: the pipeline file differs from tree to tree, and the package
199
+ # cannot derive the steps of the set from it. Silence at that reads as "everything is checked": the
200
+ # divergence is learnt from a red pipeline after the PR, when the edit has already been handed to a
201
+ # person.
163
202
  #
164
- # Отметка живёт в каталоге временных файлов, как у слова о нехватке функции профиля: на каждый
165
- # пуш та же строка повторялась бы за заход десятки раз и перестала бы читаться.
203
+ # The mark lives in the temporary files directory, as with the word about a missing profile
204
+ # function: on every push the same line would repeat dozens of times per session and would stop
205
+ # being read.
166
206
  gap_key="$(printf '%s' "$input" | jq -r '.session_id // empty' 2>/dev/null)"
167
207
  [ -z "$gap_key" ] && gap_key="$(date +%Y%m%d 2>/dev/null || printf 'nosession')"
168
208
  gap_mark="${TMPDIR:-/tmp}/rt-kit-push-gate-gap-$gap_key"
169
209
  if [ ! -f "$gap_mark" ]; then
170
- printf 'гейт пуша: набор гейта — не набор конвейера. Сборка образов, снимки показа и проверка
210
+ printf 'the push gate: the gate set is not the pipeline set. Image builds, showcase snapshots and
211
+ ' >&2
212
+ printf 'the check of assembled packages are not part of it: what stands in it is shown by the
171
213
  ' >&2
172
- printf 'собранных пакетов в него не входят: что в нём стоит, показывает разбор состояния
214
+ printf 'state review (agent-kit doctor, the section on the set before a push) — run what is
173
215
  ' >&2
174
- printf '(agent-kit doctor, раздел «набор перед пушем»), — прогони недостающее до заявки.
216
+ printf 'missing before the request.
175
217
  ' >&2
176
218
  : >"$gap_mark" 2>/dev/null || true
177
219
  fi
178
220
 
179
- [ -z "$failed" ] && exit 0
221
+ if [ -z "$failed" ]; then
222
+ rt_push_gate_note green
223
+ exit 0
224
+ fi
180
225
 
181
- # Хвост вывода, а не весь: у прогонщика он длинный, а нужна причина отказа.
226
+ rt_push_gate_note red
227
+
228
+ # The tail of the output, not all of it: the runner prints a long one, and what is needed is the
229
+ # reason for the refusal.
182
230
  tail_out="$(printf '%s' "$output" | tail -n 40 | tr -d '\000')"
183
- reason="BLOCKED: пуш без зелёного локального прогона. «${failed}» упала — почини и пушь снова, обходить гард нельзя. Пуш — вход в конвейер, и красное отсюда проверяется уже на проде. Хвост вывода:
231
+ # Red comes in two kinds, and the guard does not tell them apart: it checks only the return code.
232
+ # When a check of the code fails, "fix it and push again" is right. When the check itself is wrong,
233
+ # the same text orders fixing code nobody touched: a refusal once taken apart lay wholly in
234
+ # documents untouched by any commit of the branch. The verifiability law says a broken check does
235
+ # not stop the work, and until this line there was no such option in the refusal.
236
+ reason="BLOCKED: a push without a green local run. «${failed}» failed — fix it and push again, the guard must not be bypassed. A push is the entry into the pipeline, and red from here is checked already in production.
237
+
238
+ Three moves from here: fix what is named and repeat the call; fix the check itself, if it is the one that is wrong — take the refusals apart one by one, show the analysis to the owner and correct the check; or bring the owner the price of a bypass and wait for their word. What is in dispute is not added to the known list: it holds what was accepted, not the results of a broken check.
239
+
240
+ The tail of the output:
184
241
 
185
242
  ${tail_out}"
186
243
 
187
- # Общий хвост отказа: два законных хода и законная форма обхода, если она у отказа есть.
188
- # Файл может быть не разложен — тогда хвоста нет, а причина отказа остаётся прежней.
244
+ # The shared deny tail: the two lawful moves and the lawful form of bypass, if the refusal has one.
245
+ # The file may not be laid out — then there is no tail, and the reason for the refusal stays as it
246
+ # was.
189
247
  # shellcheck disable=SC1090
190
248
  [ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
191
249
  && . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
@@ -196,6 +254,6 @@ deny_tail_text="$(rt_deny_tail "")"
196
254
  ${deny_tail_text}"
197
255
 
198
256
  jq -n --arg r "$reason" '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:$r}}' 2>/dev/null \
199
- || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"Проверки перед пушем не прошли."}}\n'
257
+ || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"The checks before the push did not pass."}}\n'
200
258
 
201
259
  exit 0
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env bash
2
2
  # rt-hook: SessionStart startup|resume|compact|clear
3
- # SessionStart: словарь проекта уезжает в контекст целиком, на каждом запуске сессии.
3
+ # SessionStart: the project glossary goes into the context in full, on every session start.
4
4
  #
5
- # Памятью это не держится: словарь читают перед тем, как написать текст, а разговор с
6
- # владельцем идёт без чтения — и слово из левой колонки «Так не пишем» всплывает в ответе,
7
- # хотя в файлах его уже нет. Здесь словарь приходит до первой реплики и действует и на
8
- # тексты, и на ответы.
5
+ # Memory does not hold this: the glossary is read before a text is written, while the conversation
6
+ # with the owner goes on without reading — and a word from the left column of "Not written here"
7
+ # surfaces in a reply, though the files no longer have it. Here the glossary arrives before the
8
+ # first message and applies to texts and replies alike.
9
9
  #
10
- # FAIL-OPEN: нет файла или нет `jq` — выходим молча. Сессия важнее словаря.
10
+ # FAIL-OPEN: no file or no `jq` — leave silently. The session matters more than the glossary.
11
11
 
12
12
  . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
13
13
 
@@ -15,32 +15,33 @@ GLOSSARY="${CLAUDE_PROJECT_DIR:-.}/docs/GLOSSARY.md"
15
15
  [ -f "$GLOSSARY" ] || exit 0
16
16
  command -v jq >/dev/null 2>&1 || exit 0
17
17
 
18
- # Где слово заводят. Словарь бывает разложен пакетом — тогда правка на его месте теряется на
19
- # следующей раскладке, а до тех пор раскладка отказывает по нему целиком. Вводная, которую читает
20
- # каждая сессия, обязана вести в надстройку: она — единственный текст о словаре, доезжающий до
21
- # читателя гарантированно, и, ведя в собранный файл, она отменяет собой всё сказанное на других
22
- # слоях. Опровержение стоит строкой ниже, в шапке раскладки, но читается служебной строкой сборки:
23
- # начинается оно с версии и суммы, а не со слова.
18
+ # Where a word is introduced. The glossary may be laid out by the package — then an edit in its
19
+ # place is lost on the next layout, and until then the layout refuses the whole file. The preamble
20
+ # that every session reads must point to the override: it is the only text about the glossary that
21
+ # is guaranteed to reach the reader, and by pointing to the assembled file it would cancel
22
+ # everything said on the other layers. The correction stands one line lower, in the layout header,
23
+ # but reads as a service line of the build: it begins with a version and a digest, not with a word.
24
24
  #
25
- # Адрес выводится из идентификатора ресурса в самой шапке, а не зашивается: каталог надстроек у
26
- # каждого дерева свой, и зашитый путь врал бы в первом же, которое держит их иначе. Шапки нет —
27
- # словарь принадлежит дереву целиком, и «заводится здесь же» верно как есть.
25
+ # The address is derived from the resource id in the header itself, not hard-coded: each tree has
26
+ # its own override directory, and a hard-coded path would lie in the first tree that keeps them
27
+ # differently. No header — the glossary belongs to the tree as a whole, and "introduced right here"
28
+ # is true as it is.
28
29
  header="$(head -1 "$GLOSSARY" 2>/dev/null)"
29
30
  resource="$(printf '%s' "$header" | sed -n 's/.*rt-kit v[^ ]* · \([^ ]*\) · .*/\1/p')"
30
31
 
31
32
  if [ -n "$resource" ]; then
32
- where="$(printf 'Словарь разложен пакетом и на месте не правится: новое слово идёт в надстройку\n.claude/rt-kit/overrides/%s — она сливается по разделу «## » и раскладку переживает.\n' "$resource")"
33
+ where="$(printf 'The glossary is laid out by the package and is not edited in place: a new word goes to the override\n.claude/rt-kit/overrides/%s — it merges by `## ` section and survives the layout.\n' "$resource")"
33
34
  else
34
- where='Словарь принадлежит дереву целиком: новое слово заводится в нём же той же правкой.
35
+ where='The glossary belongs to the tree as a whole: a new word is added right here, by the same edit.
35
36
  '
36
37
  fi
37
38
 
38
39
  {
39
- printf 'СЛОВАРЬ ПРОЕКТА — `docs/GLOSSARY.md`, ниже целиком.\n\n'
40
- printf 'Слово отсюда употребляется в том значении, что здесь: и в файлах, и в ответах владельцу.\n'
41
- printf 'Раздел «Так не пишем» действует так же — левая колонка не пишется и не произносится нигде.\n'
42
- printf 'Слова, которого здесь нет, у читателя нет тоже: оно вводится тем же изменением, которым\n'
43
- printf 'впервые употреблено, либо заменяется тем, что уже есть.\n'
40
+ printf 'PROJECT GLOSSARY — `docs/GLOSSARY.md`, in full below.\n\n'
41
+ printf 'A word from here is used in the meaning given here: in files and in replies to the owner alike.\n'
42
+ printf 'The "Not written here" section works the same way: its left column is neither written nor said anywhere.\n'
43
+ printf 'A word that is not here does not exist for the reader either: it is introduced by the same change\n'
44
+ printf 'that first uses it, or replaced with a word that already exists.\n'
44
45
  printf '%s\n' "$where"
45
46
  cat "$GLOSSARY"
46
47
  } | jq -Rs '{hookSpecificOutput:{hookEventName:"SessionStart",additionalContext:.}}'