@rt-tools/agent-kit 0.24.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 (279) hide show
  1. package/assets/agents/business-analyst.md +51 -50
  2. package/assets/agents/conscience.md +37 -35
  3. package/assets/agents/project-manager.md +49 -48
  4. package/assets/agents/prose-editor.md +31 -29
  5. package/assets/agents/qa-engineer.md +50 -48
  6. package/assets/agents/rules-reviewer.md +63 -58
  7. package/assets/agents/skill-curator.md +83 -78
  8. package/assets/agents/spec-critic.md +34 -29
  9. package/assets/agents/spec-writer.md +35 -32
  10. package/assets/agents/strict-teacher.md +39 -37
  11. package/assets/checks/archive-age.mjs +48 -28
  12. package/assets/checks/archive-prune.mjs +16 -14
  13. package/assets/checks/board-epics.github.mjs +75 -41
  14. package/assets/checks/board-folders.mjs +61 -0
  15. package/assets/checks/board-gh.github.mjs +35 -26
  16. package/assets/checks/board-long-work.github.mjs +24 -24
  17. package/assets/checks/board-paths.github.mjs +21 -16
  18. package/assets/checks/board-runs.github.mjs +45 -43
  19. package/assets/checks/board-titles.github.mjs +19 -17
  20. package/assets/checks/board.github.mjs +149 -127
  21. package/assets/checks/check-archive-age.mjs +23 -19
  22. package/assets/checks/check-board.github.mjs +172 -164
  23. package/assets/checks/check-descriptions.mjs +30 -29
  24. package/assets/checks/check-doc-paths.mjs +91 -88
  25. package/assets/checks/check-dupes.mjs +84 -80
  26. package/assets/checks/check-file-size.mjs +74 -71
  27. package/assets/checks/check-glossary.mjs +47 -37
  28. package/assets/checks/check-hook-scope.mjs +30 -27
  29. package/assets/checks/check-lib-layers.mjs +22 -21
  30. package/assets/checks/check-profile-drift.mjs +48 -43
  31. package/assets/checks/check-prose-style.mjs +120 -37
  32. package/assets/checks/check-push-gate.mjs +53 -50
  33. package/assets/checks/check-reuse.mjs +50 -40
  34. package/assets/checks/check-schema-drift.mjs +87 -83
  35. package/assets/checks/check-specs.mjs +155 -134
  36. package/assets/checks/check-state-next.mjs +66 -52
  37. package/assets/checks/check-states.mjs +32 -30
  38. package/assets/checks/check-styles.mjs +52 -51
  39. package/assets/checks/check-turn-map.mjs +54 -46
  40. package/assets/checks/lib-boundaries.mjs +32 -30
  41. package/assets/checks/lib-common.mjs +30 -29
  42. package/assets/checks/lib-domains.mjs +34 -34
  43. package/assets/checks/lib-manifests.mjs +17 -15
  44. package/assets/checks/lib-reexports.mjs +18 -18
  45. package/assets/checks/rt-kit-checks.config.mjs +174 -142
  46. package/assets/checks/signals.mjs +43 -39
  47. package/assets/checks/spec-anchors.mjs +114 -87
  48. package/assets/checks/spec-common.mjs +128 -84
  49. package/assets/checks/spec-contract.mjs +30 -30
  50. package/assets/checks/spec-proposed.mjs +27 -24
  51. package/assets/checks/spec-scenarios.mjs +51 -28
  52. package/assets/checks/task-new.github.mjs +85 -56
  53. package/assets/commands/feedback.md +65 -59
  54. package/assets/commands/next-session.md +64 -57
  55. package/assets/commands/skill-curator.md +83 -79
  56. package/assets/defaults/gate-map.sh +108 -97
  57. package/assets/defaults/project.sh +225 -185
  58. package/assets/defaults/shell.sh +73 -68
  59. package/assets/defaults/turn-map.md +45 -44
  60. package/assets/docs/GLOSSARY.md +142 -65
  61. package/assets/hooks/browser-device-id.sh +12 -12
  62. package/assets/hooks/browser-guard-device-id.sh +30 -28
  63. package/assets/hooks/browser-guard-no-asking.sh +5 -4
  64. package/assets/hooks/browser-guard-no-listing.sh +12 -11
  65. package/assets/hooks/browser-guard-no-other-drivers.sh +48 -42
  66. package/assets/hooks/browser-guard-require-select.sh +34 -23
  67. package/assets/hooks/claim-guard.sh +62 -56
  68. package/assets/hooks/commit-msg.sh +11 -10
  69. package/assets/hooks/conscience-guard.sh +91 -45
  70. package/assets/hooks/constitution-index.sh +16 -16
  71. package/assets/hooks/deny-tail.sh +28 -26
  72. package/assets/hooks/dev-server-guard.sh +46 -43
  73. package/assets/hooks/dispatch.sh +60 -46
  74. package/assets/hooks/docs-guard.sh +100 -91
  75. package/assets/hooks/exam-guard.sh +105 -93
  76. package/assets/hooks/git-guard-delivery-conflict.sh +38 -36
  77. package/assets/hooks/git-guard-delivery-draft.sh +45 -38
  78. package/assets/hooks/git-guard-delivery-folder.sh +50 -43
  79. package/assets/hooks/git-guard-delivery-signature.sh +88 -52
  80. package/assets/hooks/git-guard-delivery.sh +196 -180
  81. package/assets/hooks/git-guard-main.sh +38 -34
  82. package/assets/hooks/git-guard-push-tests.sh +99 -87
  83. package/assets/hooks/glossary-load.sh +23 -22
  84. package/assets/hooks/grill-gate-ask.sh +12 -11
  85. package/assets/hooks/grill-gate.sh +94 -87
  86. package/assets/hooks/guard-note.sh +20 -19
  87. package/assets/hooks/handoff-entry-guard.sh +26 -24
  88. package/assets/hooks/handoff-write.sh +74 -67
  89. package/assets/hooks/hook-input.sh +67 -58
  90. package/assets/hooks/lint-after-edit.sh +95 -61
  91. package/assets/hooks/observe.sh +28 -26
  92. package/assets/hooks/override-write-guard.sh +23 -21
  93. package/assets/hooks/postmortem-guard.sh +42 -39
  94. package/assets/hooks/profile-check.sh +22 -20
  95. package/assets/hooks/proposal-guard.sh +57 -49
  96. package/assets/hooks/prose-style-guard.sh +19 -17
  97. package/assets/hooks/qa-dataid-guard.sh +52 -49
  98. package/assets/hooks/rerun-guard.sh +31 -30
  99. package/assets/hooks/reuse-first-guard.sh +108 -87
  100. package/assets/hooks/roles.sh +14 -14
  101. package/assets/hooks/rule-article.sh +36 -34
  102. package/assets/hooks/rule-source-guard.sh +47 -42
  103. package/assets/hooks/skill-gate-layers.sh +59 -57
  104. package/assets/hooks/skill-gate-rearm.sh +15 -8
  105. package/assets/hooks/skill-gate.sh +89 -81
  106. package/assets/hooks/skill-loaded.sh +6 -6
  107. package/assets/hooks/sql-guard-parse.sh +68 -66
  108. package/assets/hooks/sql-guard-request.sh +48 -46
  109. package/assets/hooks/sql-guard-target.sh +57 -51
  110. package/assets/hooks/sql-guard-write.sh +84 -79
  111. package/assets/hooks/sql-guard.sh +52 -47
  112. package/assets/hooks/stand-login-guard.sh +40 -37
  113. package/assets/hooks/task-context-load.sh +60 -55
  114. package/assets/hooks/task-flow-context.sh +87 -69
  115. package/assets/hooks/task-flow-draft-guard.sh +55 -48
  116. package/assets/hooks/task-flow-guard.sh +67 -64
  117. package/assets/hooks/turn-entry-load.sh +39 -32
  118. package/assets/hooks/turn-exit-guard.sh +256 -204
  119. package/assets/hooks/turn-exit-patterns.sh +53 -0
  120. package/assets/hooks/utf8.sh +11 -11
  121. package/assets/hooks/waiting-turn-guard.sh +94 -94
  122. package/assets/hooks/window-fill-guard.sh +70 -62
  123. package/assets/hooks/work-start-guard.sh +52 -49
  124. package/assets/hooks/write-targets.sh +96 -44
  125. package/assets/laws/autonomous-work.md +29 -27
  126. package/assets/laws/code-structure.md +31 -30
  127. package/assets/laws/delivery.md +148 -137
  128. package/assets/laws/entity-editing.md +52 -50
  129. package/assets/laws/entity-models.md +14 -13
  130. package/assets/laws/frontend-application.md +39 -38
  131. package/assets/laws/lib-imports.md +27 -27
  132. package/assets/laws/lists.md +31 -29
  133. package/assets/laws/navigation.md +37 -37
  134. package/assets/laws/observability.md +41 -40
  135. package/assets/laws/project-documentation.md +106 -99
  136. package/assets/laws/reuse-first.md +31 -29
  137. package/assets/laws/shared-code.md +27 -27
  138. package/assets/laws/verifiability.md +131 -124
  139. package/assets/laws/work-conduct.md +250 -244
  140. package/assets/patterns/admin-lists-screen.md +72 -69
  141. package/assets/patterns/admin-nav-item.md +51 -46
  142. package/assets/patterns/angular-patterns-state.md +32 -31
  143. package/assets/patterns/api-layer-pair.md +33 -31
  144. package/assets/patterns/autonomous-work-run.md +50 -49
  145. package/assets/patterns/browser-verification-measure.md +124 -88
  146. package/assets/patterns/browser-verification-stand.md +169 -157
  147. package/assets/patterns/component-structure-new.md +51 -42
  148. package/assets/patterns/dependencies-upgrade.md +55 -39
  149. package/assets/patterns/doc-style-human.md +55 -37
  150. package/assets/patterns/doc-style-sweep.md +82 -79
  151. package/assets/patterns/doc-style-trace.md +87 -81
  152. package/assets/patterns/doc-style-write.md +130 -122
  153. package/assets/patterns/entity-aside.md +77 -63
  154. package/assets/patterns/entity-models-new.md +37 -37
  155. package/assets/patterns/entity-store.md +33 -33
  156. package/assets/patterns/git-workflow-commit.azure.md +93 -86
  157. package/assets/patterns/git-workflow-commit.github.md +152 -141
  158. package/assets/patterns/git-workflow-commit.gitlab.md +95 -89
  159. package/assets/patterns/git-workflow-docker.md +165 -147
  160. package/assets/patterns/git-workflow-freshness.md +45 -45
  161. package/assets/patterns/git-workflow-merge.md +98 -93
  162. package/assets/patterns/git-workflow-migration.md +54 -52
  163. package/assets/patterns/git-workflow-pr-ready.md +57 -56
  164. package/assets/patterns/git-workflow-pr.azure.md +126 -121
  165. package/assets/patterns/git-workflow-pr.github.md +179 -175
  166. package/assets/patterns/git-workflow-pr.gitlab.md +138 -131
  167. package/assets/patterns/git-workflow-restart.md +35 -31
  168. package/assets/patterns/git-workflow-secrets.md +80 -73
  169. package/assets/patterns/git-workflow-stack.md +131 -106
  170. package/assets/patterns/lib-layers-move.md +62 -53
  171. package/assets/patterns/lib-layers-new.md +59 -45
  172. package/assets/patterns/observability-record.md +72 -67
  173. package/assets/patterns/platform-access-di.md +31 -29
  174. package/assets/patterns/reuse-first-extend.md +66 -61
  175. package/assets/patterns/shared-code-new.md +39 -38
  176. package/assets/patterns/spec-driven-domain.md +161 -151
  177. package/assets/patterns/spec-driven-rule.md +179 -168
  178. package/assets/patterns/spec-driven-sweep.md +41 -39
  179. package/assets/patterns/status-report-table.github.md +37 -36
  180. package/assets/patterns/styling-bem-component.md +42 -42
  181. package/assets/patterns/styling-bem-layout.md +39 -34
  182. package/assets/patterns/styling-bem-sheet.md +59 -58
  183. package/assets/patterns/task-flow-archive.md +222 -215
  184. package/assets/patterns/task-flow-close.md +215 -203
  185. package/assets/patterns/task-flow-handoff.md +154 -145
  186. package/assets/patterns/task-flow-resume.md +138 -133
  187. package/assets/patterns/task-flow-start.md +204 -192
  188. package/assets/patterns/testing-e2e.md +102 -101
  189. package/assets/patterns/testing-unit.md +77 -70
  190. package/assets/patterns/ts-procedure.md +32 -29
  191. package/assets/patterns/turn-entry-map.md +50 -48
  192. package/assets/pitfalls/agent-kit.md +152 -141
  193. package/assets/pitfalls/doc-style.md +96 -91
  194. package/assets/pitfalls/git-workflow.azure.md +49 -46
  195. package/assets/pitfalls/git-workflow.github.md +264 -234
  196. package/assets/pitfalls/git-workflow.gitlab.md +49 -45
  197. package/assets/pitfalls/spec-driven.md +73 -71
  198. package/assets/pitfalls/styling-bem.md +46 -40
  199. package/assets/pitfalls/task-flow.md +262 -246
  200. package/assets/pitfalls/testing.md +99 -92
  201. package/assets/pitfalls/turn-conduct.md +96 -81
  202. package/assets/rules/angular-patterns.md +81 -80
  203. package/assets/rules/api-layer.md +77 -74
  204. package/assets/rules/autonomous-work.md +75 -74
  205. package/assets/rules/browser-verification.md +223 -214
  206. package/assets/rules/component-structure.md +72 -69
  207. package/assets/rules/dependencies.md +74 -67
  208. package/assets/rules/deploy-flow.azure.md +118 -108
  209. package/assets/rules/deploy-flow.github.md +145 -135
  210. package/assets/rules/deploy-flow.gitlab.md +120 -110
  211. package/assets/rules/doc-style.md +198 -173
  212. package/assets/rules/entity-conventions.needs-admin.md +81 -79
  213. package/assets/rules/entity-models.md +73 -70
  214. package/assets/rules/git-workflow.azure.md +224 -228
  215. package/assets/rules/git-workflow.github.md +250 -239
  216. package/assets/rules/git-workflow.gitlab.md +218 -217
  217. package/assets/rules/lib-layers.md +85 -86
  218. package/assets/rules/lists.md +101 -97
  219. package/assets/rules/navigation.md +78 -78
  220. package/assets/rules/observability.needs-app.md +165 -153
  221. package/assets/rules/platform-access.md +76 -75
  222. package/assets/rules/reuse-first.md +153 -143
  223. package/assets/rules/shared-code.md +82 -79
  224. package/assets/rules/spec-driven.md +272 -260
  225. package/assets/rules/status-report.md +55 -58
  226. package/assets/rules/styling-bem.md +81 -77
  227. package/assets/rules/task-flow.md +282 -270
  228. package/assets/rules/testing.md +224 -209
  229. package/assets/rules/turn-conduct.md +255 -258
  230. package/assets/rules/turn-entry.md +92 -87
  231. package/assets/rules/typescript-conventions.md +94 -88
  232. package/assets/samples/specs/_template/spec.md +47 -47
  233. package/assets/samples/tasks/_template/grill.md +20 -20
  234. package/assets/samples/tasks/_template/plan.md +32 -30
  235. package/assets/samples/tasks/_template/progress.md +16 -16
  236. package/assets/skills/agent-kit-extend.md +129 -113
  237. package/assets/skills/agent-kit.md +235 -211
  238. package/assets/skills/write-a-skill.md +76 -71
  239. package/assets/templates/findings.md +19 -19
  240. package/assets/templates/gate-map.sh +16 -14
  241. package/assets/templates/implementation.md +28 -27
  242. package/assets/templates/pattern.md +17 -17
  243. package/assets/templates/pitfalls.md +6 -6
  244. package/assets/templates/postmortem.md +24 -23
  245. package/assets/templates/project.sh +24 -24
  246. package/assets/templates/proposal.md +62 -60
  247. package/assets/templates/rule.md +38 -38
  248. package/assets/workflows/feature.js +46 -46
  249. package/assets/workflows/plan.js +54 -54
  250. package/lib/catalog.d.ts +2 -0
  251. package/lib/catalog.d.ts.map +1 -1
  252. package/lib/catalog.js +4 -3
  253. package/lib/catalog.js.map +1 -1
  254. package/lib/commands.d.ts.map +1 -1
  255. package/lib/commands.js +5 -2
  256. package/lib/commands.js.map +1 -1
  257. package/lib/companion.js +3 -2
  258. package/lib/companion.js.map +1 -1
  259. package/lib/enroll.d.ts +7 -1
  260. package/lib/enroll.d.ts.map +1 -1
  261. package/lib/enroll.js +12 -3
  262. package/lib/enroll.js.map +1 -1
  263. package/lib/plan.d.ts +11 -0
  264. package/lib/plan.d.ts.map +1 -1
  265. package/lib/plan.js +10 -1
  266. package/lib/plan.js.map +1 -1
  267. package/lib/ship.d.ts +0 -7
  268. package/lib/ship.d.ts.map +1 -1
  269. package/lib/ship.js +10 -2
  270. package/lib/ship.js.map +1 -1
  271. package/lib/shipment.d.ts.map +1 -1
  272. package/lib/shipment.js +6 -2
  273. package/lib/shipment.js.map +1 -1
  274. package/lib/sync.d.ts.map +1 -1
  275. package/lib/sync.js +45 -11
  276. package/lib/sync.js.map +1 -1
  277. package/package.json +1 -1
  278. package/rt-tools-agent-kit-0.26.0.tgz +0 -0
  279. package/rt-tools-agent-kit-0.24.0.tgz +0 -0
@@ -1,40 +1,42 @@
1
1
  #!/usr/bin/env bash
2
2
  # rt-hook: PostToolUse Edit|Write|MultiEdit|Bash|mcp__webstorm__create_new_file
3
- # Требует: hooks/profile-check.sh
4
- # Линтер по следам правки. PostToolUse.
3
+ # Requires: hooks/profile-check.sh
4
+ # The linter in the footsteps of an edit. PostToolUse.
5
5
  #
6
- # Два входа. Правка файла — линтуется один изменённый файл. Команда оболочки — линтуется то,
7
- # что она записала: перенос меняет либу, а вместе с ней и границы, и импорт, законный на прежнем
8
- # месте, на новом уже запрещён; запись перенаправлением, дозаписью или интерпретатором меняет
9
- # сам файл, и линтера он прежде не получал вовсе. Ровно так запрещённый импорт уезжает в общую
10
- # либу молча, а правленая проверка выходит из-под форматтера: правило сработало бы — но его
11
- # никто не запустил.
6
+ # Two entries. A file edit — the one changed file is linted. A shell command — what it wrote is
7
+ # linted: a move changes the lib, and with it the boundaries, and an import lawful in the old
8
+ # place is already forbidden in the new one; a write by redirect, by append or by an interpreter
9
+ # changes the file itself, and before that it never got a linter at all. That is exactly how a
10
+ # forbidden import leaves for the shared lib silently, and an edited check slips out from under
11
+ # the formatter: the rule would have fired — but nobody ran it.
12
12
  #
13
- # Что команда пишет и куда, знает профиль дерева, и знает он это одним способом для всех: тот
14
- # же признак читает гейт правил.
13
+ # What a command writes and where, the tree profile knows, and it knows it in one way for all:
14
+ # the rules gate reads the same sign.
15
15
  #
16
- # Полный набор гоняет гард на пуше, но это конец работы: к моменту, когда правило срабатывает,
17
- # поверх нарушения лежит десяток правок, и разбор превращается в археологию. Здесь тот же
18
- # линтер, но по затронутым файлам — секунды, сразу после действия, пока контекст ещё свой.
16
+ # The full suite is run by the guard on push, but that is the end of the work: by the time the
17
+ # rule fires, a dozen edits lie on top of the violation, and the analysis turns into archaeology.
18
+ # Here is the same linter, but over the touched files — seconds, right after the action, while
19
+ # the context is still one's own.
19
20
  #
20
- # Замечания возвращаются добавленным контекстом, а не отказом: действие уже применено, и
21
- # незаконченный промежуточный файл имеет право быть красным. Чинить их надо до конца задачи —
22
- # все, включая лежавшие в файле раньше.
21
+ # Findings come back as added context, not as a refusal: the action is already applied, and an
22
+ # unfinished intermediate file has the right to be red. They must be fixed before the end of the
23
+ # task — all of them, including those that lay in the file before.
23
24
  #
24
- # Что здесь чем зовётся, знает профиль дерева:
25
- # rt_lint_for — чем линтуется этот файл;
26
- # rt_shell_writes — пишет ли эта команда;
27
- # rt_shell_paths — какие пути она записала;
28
- # rt_is_app_code — где лежит код, к которому линтеры вообще относятся;
29
- # RT_LINT_SKIP_RE — что из него исключено;
30
- # rt_push_checks — что гоняет гейт пуша. По нему же решается, догонит ли замечание позже:
31
- # линтер, которого в гейте нет, ловит только этот хук.
32
- # Нет профиля или нет функции — хук молчит.
25
+ # What is called what here, the tree profile knows:
26
+ # rt_lint_for — what this file is linted with;
27
+ # rt_shell_writes — whether this command writes;
28
+ # rt_shell_paths — which paths it wrote;
29
+ # rt_is_app_code — where the code the linters apply to at all lives;
30
+ # RT_LINT_SKIP_RE — what is excluded from it;
31
+ # rt_push_checks — what the push gate runs. It also decides whether a finding catches up
32
+ # later: a linter that is not in the gate is caught only by this hook.
33
+ # No profile or no function — the hook stays silent.
33
34
  #
34
- # ОТКАЗ В ПОЛЬЗУ РАБОТЫ и молча: нет линтера, файл вне дерева, зелёный результат — пустой вывод.
35
+ # FAIL-OPEN and silent: no linter, a file outside the tree, a green result — empty output.
35
36
 
36
- # Сколько файлов линтуется за один перенос. Переезд либы трогает десятки файлов, и прогон по
37
- # каждому превратил бы хук в минутную паузу; на нарушение границы хватает первых.
37
+ # How many files are linted per move. A lib move touches dozens of files, and a run over each
38
+ # would turn the hook into a minute-long pause; the first ones are enough for a boundary
39
+ # violation.
38
40
  . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
39
41
  . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
40
42
 
@@ -52,8 +54,9 @@ case "$tool" in
52
54
  *) exit 0 ;;
53
55
  esac
54
56
 
55
- # Отсев до всякой работы: хук висит на каждой команде оболочки, а пишет из них меньшинство.
56
- # Пустая команда отсеивается здесь же — признак записи у неё спрашивать не о чем.
57
+ # Screening before any work: the hook hangs on every shell command, and a minority of them
58
+ # write. An empty command is screened out right here — there is nothing to ask it the write sign
59
+ # about.
57
60
  command_text=""
58
61
  if [ "$mode" = "move" ]; then
59
62
  command_text="$(printf '%s' "$input" | jq -r '.tool_input.command // empty' 2>/dev/null)"
@@ -65,22 +68,22 @@ workdir="$(rt_hook_cwd)"
65
68
  cd "$workdir" 2>/dev/null || exit 0
66
69
  [ -f package.json ] || exit 0
67
70
 
68
- # Профиль дерева: сперва умолчание пакета, поверх него — надстройка проекта, если она есть.
71
+ # The tree profile: the package default first, the project override on top of it if there is one.
69
72
  rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
70
73
  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
71
74
  # shellcheck disable=SC1090
72
75
  [ -f "$profile" ] && . "$profile" 2>/dev/null
73
76
  done
74
77
 
75
- # Слово о нехватке функции профиля: хук, вышедший молча, неотличим от работающего. Файл может
76
- # быть не разложен — тогда остаётся прежнее поведение, молчаливое.
78
+ # A word about a missing profile function: a hook that exited silently cannot be told from a
79
+ # working one. The file may not be laid out — then the old behaviour, the silent one, stays.
77
80
  # shellcheck disable=SC1090
78
81
  [ -f "$rt_hooks_dir/profile-check.sh" ] && . "$rt_hooks_dir/profile-check.sh"
79
82
  command -v rt_needs >/dev/null 2>&1 || rt_needs() { command -v "$1" >/dev/null 2>&1; }
80
83
  rt_needs rt_lint_for lint-after-edit || exit 0
81
84
 
82
- # Признак записи спрашивается после профиля: до него функций ещё нет. Дерево, которое признака
83
- # не объявило, остаётся при прежнем поведении — разбирается один перенос.
85
+ # The write sign is asked after the profile: before it there are no functions yet. A tree that
86
+ # has not declared the sign keeps the old behaviour — a single move is parsed.
84
87
  if [ "$mode" = "move" ] && rt_needs rt_shell_writes lint-after-edit; then
85
88
  case "$command_text" in
86
89
  *"git mv "*) ;;
@@ -88,20 +91,20 @@ if [ "$mode" = "move" ] && rt_needs rt_shell_writes lint-after-edit; then
88
91
  esac
89
92
  fi
90
93
 
91
- # --- какие файлы проверяем -------------------------------------------------------------
94
+ # --- which files are checked -----------------------------------------------------------
92
95
 
93
- # Пути назначения всех переносов в команде. Команда бывает составной, поэтому режется по
94
- # разделителям, и каждый кусок разбирается отдельно.
96
+ # The destination paths of all moves in the command. A command can be compound, so it is cut by
97
+ # separators, and each piece is parsed on its own.
95
98
  collect_moved() {
96
- # Перевод строки в конце обязателен: чтение без него теряет последний кусок, а команда
97
- # чаще всего состоит ровно из одного.
99
+ # The trailing newline is mandatory: reading without it loses the last piece, and a command
100
+ # most often consists of exactly one.
98
101
  printf '%s\n' "$1" | tr ';&\n' '\n\n\n' | while IFS= read -r segment; do
99
102
  case "$segment" in
100
103
  *"git mv "*) ;;
101
104
  *) continue ;;
102
105
  esac
103
106
 
104
- # shellcheck disable=SC2086 # разбиение по пробелам здесь и нужно
107
+ # shellcheck disable=SC2086 # splitting by spaces is exactly what is wanted here
105
108
  set -- ${segment#*git mv }
106
109
  args=''
107
110
  for arg in "$@"; do
@@ -118,7 +121,7 @@ collect_moved() {
118
121
  dest=''
119
122
  for arg in "$@"; do dest="$arg"; done
120
123
 
121
- # Назначение — каталог: имя файла остаётся прежним, меняется только путь.
124
+ # The destination is a directory: the file name stays as it was, only the path changes.
122
125
  if [ -d "$dest" ]; then
123
126
  for arg in "$@"; do
124
127
  [ "$arg" = "$dest" ] && continue
@@ -130,7 +133,7 @@ collect_moved() {
130
133
  done
131
134
  }
132
135
 
133
- # Каталог разворачивается в лежащие в нём файлы: перенос умеет двигать целые слои.
136
+ # A directory is expanded into the files lying in it: a move can shift whole layers.
134
137
  expand() {
135
138
  if [ -d "$1" ]; then
136
139
  find "$1" -type f \( -name '*.ts' -o -name '*.html' -o -name '*.scss' \) 2>/dev/null
@@ -142,16 +145,16 @@ expand() {
142
145
  if [ "$mode" = "edit" ]; then
143
146
  path="$(printf '%s' "$input" | jq -r '.tool_input.file_path // .tool_input.pathInProject // empty' 2>/dev/null)"
144
147
  [ -z "$path" ] && exit 0
145
- # Путь от корня дерева приводится к абсолютному один раз, чтобы образцы не двоились.
148
+ # A path from the tree root is made absolute once, so that the patterns do not double.
146
149
  case "$path" in
147
150
  /*) ;;
148
151
  *) path="${CLAUDE_PROJECT_DIR:-.}/$path" ;;
149
152
  esac
150
153
  candidates="$(expand "$path")"
151
154
  else
152
- # Перенос разворачивает каталог: он двигает целые слои. Запись — нет: пишут всегда в файл,
153
- # а каталог в команде записи — это рабочий каталог, и развёрнутый он отдаёт линтеру половину
154
- # дерева. Поэтому у записанных путей берутся только существующие файлы.
155
+ # A move expands a directory: it shifts whole layers. A write does not: writes always go to
156
+ # a file, and a directory in a write command is the working directory, and expanded it hands
157
+ # the linter half of the tree. So of the written paths only existing files are taken.
155
158
  written=""
156
159
  if rt_needs rt_shell_paths lint-after-edit; then
157
160
  written="$(rt_shell_paths "$command_text" 2>/dev/null | while IFS= read -r path; do
@@ -164,7 +167,7 @@ fi
164
167
 
165
168
  [ -z "$candidates" ] && exit 0
166
169
 
167
- # --- отсев того, что линтерами дерева не покрыто ----------------------------------------
170
+ # --- screening out what the tree's linters do not cover ---------------------------------
168
171
 
169
172
  lintable() {
170
173
  if rt_needs rt_is_app_code lint-after-edit; then
@@ -177,8 +180,8 @@ lintable() {
177
180
  return 0
178
181
  }
179
182
 
180
- # Имя линтера в команде — первое слово, которое не запускатель. Оно идёт в заголовок и по нему
181
- # же ищется гейт пуша.
183
+ # The linter name in the command is the first word that is not a launcher. It goes into the
184
+ # heading, and the push gate is searched by it too.
182
185
  linter_name() {
183
186
  printf '%s' "$1" | awk '{
184
187
  for (i = 1; i <= NF; i++) {
@@ -188,7 +191,7 @@ linter_name() {
188
191
  }'
189
192
  }
190
193
 
191
- # --- прогон -----------------------------------------------------------------------------
194
+ # --- the run ----------------------------------------------------------------------------
192
195
 
193
196
  push_checks="$(rt_needs rt_push_checks lint-after-edit && rt_push_checks 2>/dev/null)"
194
197
 
@@ -196,6 +199,7 @@ report=""
196
199
  linters=""
197
200
  covered=1
198
201
  checked=0
202
+ path_gap=0
199
203
 
200
204
  while IFS= read -r file; do
201
205
  [ -z "$file" ] && continue
@@ -206,9 +210,19 @@ while IFS= read -r file; do
206
210
  [ -z "$lint" ] && continue
207
211
  checked=$((checked + 1))
208
212
 
213
+ # A command without the path of the edited file reads as a clean linter, and does one of two
214
+ # things: walks the whole tree or checks nothing. There is nothing to tell it from an honest
215
+ # run over the whole suite, so here is a word, not a refusal; said once per session — like
216
+ # the word about a missing profile function.
217
+ case "$lint" in
218
+ *"$file"*) ;;
219
+ *) path_gap=1 ;;
220
+ esac
221
+
209
222
  out="$(eval "$lint" 2>&1)" && continue
210
223
 
211
- # Линтера нет или он упал сам по себе — это не замечание к файлу, молчим.
224
+ # There is no linter, or it crashed on its own — that is not a finding about the file, we
225
+ # stay silent.
212
226
  printf '%s' "$out" | grep -qiE 'command not found|could not determine executable|Cannot find module' && continue
213
227
 
214
228
  linter="$(linter_name "$lint")"
@@ -226,32 +240,52 @@ done <<EOF
226
240
  $candidates
227
241
  EOF
228
242
 
243
+ # The mark lives in the temporary files directory: on every edit the same line would repeat
244
+ # dozens of times per session and would stop being read.
245
+ if [ "$path_gap" = 1 ]; then
246
+ gap_key="$(printf '%s' "$input" | jq -r '.session_id // empty' 2>/dev/null)"
247
+ [ -z "$gap_key" ] && gap_key="$(date +%Y%m%d 2>/dev/null || printf 'nosession')"
248
+ gap_mark="${TMPDIR:-/tmp}/rt-kit-lint-path-gap-$gap_key"
249
+ if [ ! -f "$gap_mark" ]; then
250
+ printf 'the linter on the trail of an edit: the command of the profile did not name the
251
+ ' >&2
252
+ printf 'edited file. It either walks the whole tree or checks nothing at all, and in both
253
+ ' >&2
254
+ printf 'cases looks like a clean linter. The path is substituted when the command is
255
+ ' >&2
256
+ printf 'printed — the sample stands in the default of the profile, the function rt_lint_for.
257
+ ' >&2
258
+ : >"$gap_mark" 2>/dev/null || true
259
+ fi
260
+ fi
261
+
229
262
  [ -z "$report" ] && exit 0
230
263
 
231
- # Длинный вывод режем: важен факт и первые нарушения, остальное видно при полном прогоне.
264
+ # Long output is cut: the fact and the first violations matter, the rest is visible in a full run.
232
265
  report="$(printf '%s' "$report" | head -c 6000)"
233
266
 
234
267
  if [ "$covered" -eq 1 ]; then
235
- tail_line="Пуш всё равно не пройдёт, пока набор красный."
268
+ tail_line="The push will not pass anyway while the suite is red."
236
269
  else
237
- tail_line="Почини их сейчас: этот линтер в гейт пуша не входит, и отложенное замечание уедет в главную ветку молча."
270
+ tail_line="Fix them now: this linter is not part of the push gate, and a postponed finding travels into the main branch in silence."
238
271
  fi
239
272
 
240
273
  case "$mode:$command_text" in
241
- # Перенос назван отдельно: замечание после него объясняется не правкой файла, а сменой его
242
- # места, и без этой строки читатель ищет промах в тексте, которого никто не менял.
274
+ # A move is named separately: a finding after it is explained not by an edit of the file but
275
+ # by a change of its place, and without this line the reader looks for a miss in text that
276
+ # nobody changed.
243
277
  move:*"git mv "*)
244
- head_line="ЛИНТЕР (${linters}) НАШЁЛ ЗАМЕЧАНИЯ ПОСЛЕ ПЕРЕНОСА. Перенос меняет либу, а вместе с ней границы: импорт, законный на прежнем месте, на новом может быть запрещён." ;;
278
+ head_line="THE LINTER (${linters}) FOUND ISSUES AFTER A MOVE. A move changes the lib, and with it the boundaries: an import lawful in the former place may be forbidden in the new one." ;;
245
279
  move:*)
246
- head_line="ЛИНТЕР (${linters}) НАШЁЛ ЗАМЕЧАНИЯ ПОСЛЕ ЗАПИСИ КОМАНДОЙ:" ;;
280
+ head_line="THE LINTER (${linters}) FOUND ISSUES AFTER A WRITE BY A COMMAND:" ;;
247
281
  *)
248
- head_line="ЛИНТЕР (${linters}) НАШЁЛ ЗАМЕЧАНИЯ:" ;;
282
+ head_line="THE LINTER (${linters}) FOUND ISSUES:" ;;
249
283
  esac
250
284
 
251
285
  ctx="${head_line}
252
286
  ${report}
253
287
 
254
- Почини их до конца задачи — правятся ВСЕ замечания в затронутом файле, и новые, и лежавшие раньше: накопленные нарушения глушат сигнал о свежих. ${tail_line}"
288
+ Fix them before the task ends — ALL the issues in the touched file are fixed, the new ones and those that lay there before: accumulated violations drown the signal about fresh ones. ${tail_line}"
255
289
 
256
290
  jq -n --arg c "$ctx" '{hookSpecificOutput:{hookEventName:"PostToolUse",additionalContext:$c}}' 2>/dev/null
257
291
 
@@ -1,24 +1,25 @@
1
1
  #!/usr/bin/env bash
2
- # Запись наблюдений о слое правил. НЕ гард: объявления `rt-hook:` у него нет, к событиям агента
3
- # он не подключается. Его источают гарды — тем же приёмом, каким гейт источает карту.
2
+ # Recording observations about the rules layer. NOT a guard: it has no `rt-hook:` declaration and it
3
+ # hooks into no agent event. The guards source it — the same way the gate sources the map.
4
4
  #
5
- # Зачем он есть. Правки в тексты пакета шли из головы того, кто их пишет: чем из разложенного
6
- # пользуются каждый день, чем не пользовались ни разу и обо что спотыкаются по второму кругу,
7
- # пакету было неизвестно. Часть данных при этом уже собиралась и выбрасывалась — запись загрузок
8
- # жила во временном каталоге и гибла со сжатием контекста.
5
+ # Why it exists. Edits to the package texts came out of the head of whoever writes them: what of the
6
+ # laid-out is used every day, what was never used once and what people stumble over a second time
7
+ # was unknown to the package. Part of the data was already being gathered and thrown away — the
8
+ # record of loads lived in a temporary directory and died with the compaction of the context.
9
9
  #
10
- # ЧТО ЗАПИСЫВАЕТСЯ. Только имена ресурсов пакета и счётчики: имя правила или гарда, род события,
11
- # род файла, версия пакета и признак сессии. Ни путей дерева, ни имён его доменов, ни имени
12
- # самого дерева — и держится это не памятью зовущего, а `rt_observe_clean`: значение со слэшем
13
- # не пишется вовсе. Наблюдение уезжает потом в чужой репозиторий, и запрет называть чужое дерево
14
- # обязан держаться конструкцией.
10
+ # WHAT IS RECORDED. Only the names of package resources and counters: the name of a rule or a guard,
11
+ # the kind of event, the kind of file, the package version and the sign of a session. No tree paths,
12
+ # no names of its domains, no name of the tree itself — and this rests not on the caller's memory
13
+ # but on `rt_observe_clean`: a value with a slash is not written at all. An observation later
14
+ # travels into someone else's repository, and the ban on naming a foreign tree has to rest on the
15
+ # construction.
15
16
  #
16
- # ОТКАЗ В ПОЛЬЗУ РАБОТЫ. Наблюдение — побочная работа гарда, и любая её поломка молча пропускает
17
- # действие: недоступный каталог, отсутствие `date`, полный диск. Гард, упавший на записи
18
- # наблюдения, останавливал бы работу ради статистики.
17
+ # FAIL-OPEN. An observation is a guard's side work, and any breakage of it silently lets the action
18
+ # through: an unavailable directory, a missing `date`, a full disk. A guard that fell over on
19
+ # recording an observation would stop work for the sake of statistics.
19
20
 
20
- # Значение, годное к записи. Путь не выносится ни при каких обстоятельствах, остальное чистится
21
- # до имени и обрезается: длинное значение в наблюдении не значит ничего, кроме утечки.
21
+ # A value fit for recording. A path is not carried out under any circumstances, the rest is cleaned
22
+ # down to a name and trimmed: a long value in an observation means nothing but a leak.
22
23
  . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
23
24
 
24
25
  rt_observe_clean() {
@@ -28,35 +29,36 @@ rt_observe_clean() {
28
29
  printf '%s' "$1" | LC_ALL=C tr -cd 'A-Za-z0-9._:-' | cut -c1-48
29
30
  }
30
31
 
31
- # Признак сессии: считается по её имени и обратно не восстанавливается. Нужен, чтобы сводка
32
- # знала число заходов, а не только число событий.
32
+ # The sign of a session: it is computed from the session name and cannot be restored back. It is
33
+ # needed so that the digest knows the number of sessions, not only the number of events.
33
34
  rt_observe_session() {
34
35
  printf '%s' "$1" | cksum 2>/dev/null | cut -d' ' -f1
35
36
  }
36
37
 
37
- # Версия пакета, разложившего этот файл. Стоит в шапке, которую ставит раскладка; в исходниках
38
- # пакета шапки нет, и там версия — `dev`.
38
+ # The version of the package that laid this file out. It stands in the header put there by the
39
+ # layout; in the package sources there is no header, and the version there is `dev`.
39
40
  rt_observe_version() {
40
41
  local found
41
42
  found="$(sed -n 's/^# rt-kit v\([^ ]*\) .*/\1/p' "${BASH_SOURCE[0]}" 2>/dev/null | head -1)"
42
43
  printf '%s' "${found:-dev}"
43
44
  }
44
45
 
45
- # Каталог наблюдений этого дерева. Пустая строка — записи не будет.
46
+ # The observations directory of this tree. An empty string — there will be no record.
46
47
  rt_observe_dir() {
47
48
  local root="${CLAUDE_PROJECT_DIR:-.}" config
48
49
  config="$root/.claude/rt-kit.json"
49
- # Выключатель дерева гасит запись целиком, а не частями: пакет стоит и у тех, о ком мы не
50
- # знаем. Нечитаемая настройка выключателем не считается — иначе сломанный JSON тихо
51
- # выключал бы наблюдения, и понять это было бы нечем.
50
+ # The tree's switch kills the recording whole, not in parts: the package is installed by those
51
+ # we know nothing about too. An unreadable setting does not count as switching off — otherwise
52
+ # broken JSON would quietly switch the observations off, and there would be nothing to see it
53
+ # by.
52
54
  if [ -f "$config" ] && command -v jq >/dev/null 2>&1; then
53
55
  [ "$(jq -r 'if .observe == false then "off" else "on" end' "$config" 2>/dev/null)" = "off" ] && return 0
54
56
  fi
55
57
  printf '%s' "$root/.claude/rt-kit/observations"
56
58
  }
57
59
 
58
- # Одно наблюдение: род события и пары `ключ=значение`. Ключ `sid` хешируется, остальные
59
- # чистятся. Пустое значение поля не заводит.
60
+ # One observation: the kind of event and `key=value` pairs. The `sid` key is hashed, the rest are
61
+ # cleaned. An empty value creates no field.
60
62
  #
61
63
  # rt_note gate-deny res=styling-bem kind=scss sid="$sid"
62
64
  rt_note() {
@@ -1,26 +1,27 @@
1
1
  #!/usr/bin/env bash
2
2
  # rt-hook: PreToolUse Write|Bash|mcp__webstorm__create_new_file|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_tool
3
- # Требует: hooks/deny-tail.sh, hooks/guard-note.sh
4
- # Гард затирания надстройки: запись поверх — не то же самое, что правка.
3
+ # Requires: hooks/deny-tail.sh, hooks/guard-note.sh
4
+ # Guard against wiping out an override: writing over is not the same as editing.
5
5
  #
6
- # Надстройка дерева сливается с ресурсом пакета по разделу «## »: раздел, который дерево
7
- # переписало, замещает пакетный, а остальные приходят из пакета. Файл надстройки поэтому
8
- # накапливается — разделы в него дописывают разные ветки и разные заходы, — и выглядит он как
9
- # обычный текст, который можно положить целиком.
6
+ # The tree's override merges with the package resource by `## ` section: a section the tree has
7
+ # rewritten replaces the package one, and the rest come from the package. That is why the override
8
+ # file accumulates — sections are appended to it by different branches and different sessions — and
9
+ # it looks like ordinary text that can be put down whole.
10
10
  #
11
- # Положенный целиком, он уносит с собой все разделы, которых эта правка не касалась. Пропажу не
12
- # видно ничем: раскладка сходится, проверки зелёные, а пакетный раздел молча вернулся на место
13
- # того, что дерево о себе говорило. Заметит это тот, кто через месяц удивится, почему правило
14
- # снова требует чужих имён.
11
+ # Put down whole, it carries away every section this edit did not touch. There is nothing to see the
12
+ # loss by: the layout converges, the checks are green, and the package section has quietly returned
13
+ # to the place of what the tree said about itself. It is noticed by whoever wonders a month later
14
+ # why the rule again demands foreign names.
15
15
  #
16
- # ЧТО СУДИТСЯ. Запись файла целиком поверх существующей непустой надстройки: инструмент записи,
17
- # перенаправление `>`, `tee` без дописывания, копирование поверх. Дописывание в конец — `>>`,
18
- # `tee -a` — и правка по месту проходят: они ничего не уносят.
16
+ # WHAT IS JUDGED. Writing a file whole over an existing non-empty override: the writing tool, a `>`
17
+ # redirection, `tee` without appending, a copy over the top. Appending to the end — `>>`, `tee -a` —
18
+ # and an in-place edit pass: they carry nothing away.
19
19
  #
20
- # ОТКАЗ В ПОЛЬЗУ РАБОТЫ: нет `jq`, битый ввод, чужой инструмент, файла нет, файл пуст —
21
- # правка РАЗРЕШАЕТСЯ. Сломанный гард не имеет права заклинить работу.
20
+ # FAIL-OPEN: no `jq`, broken input, a foreign tool, no file, an empty file — the edit is ALLOWED. A
21
+ # broken guard has no right to jam work.
22
22
 
23
- # Своё имя в наблюдениях: отбой пишет общий хвост отказа, а не сам гард.
23
+ # Its own name in the observations: the refusal is written by the shared deny tail, not by the
24
+ # guard itself.
24
25
  RT_GUARD_NAME=override-write-guard
25
26
 
26
27
  . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
@@ -41,12 +42,13 @@ deny() {
41
42
 
42
43
  reason="$1 $(rt_deny_tail "$2")"
43
44
  jq -n --arg r "$reason" '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:$r}}' 2>/dev/null \
44
- || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"Гард затирания надстройки."}}\n'
45
+ || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"The override overwrite guard."}}\n'
45
46
  exit 0
46
47
  }
47
48
 
48
- # Цели записи поверх, названные командой прямо. Дописывание сюда не входит: `>>` прячется до
49
- # разбора и обратно не разворачивается, `tee` берётся только без довода о дописывании.
49
+ # The targets of writing over, named by the command outright. Appending is not included here: `>>`
50
+ # is hidden before the parsing and is not unfolded back, and `tee` is taken only without the
51
+ # appending argument.
50
52
  rt_overwrite_targets() {
51
53
  tr "\"'\`" ' ' \
52
54
  | sed -E 's/>>/\
@@ -98,8 +100,8 @@ while IFS= read -r candidate; do
98
100
  sections="$(grep -c '^## ' "$candidate" 2>/dev/null || printf '0')"
99
101
  resource="${relative#"$overrides_dir"/}"
100
102
 
101
- deny "BLOCKED by override-write-guard: «${relative}» — надстройка этого дерева, и в ней уже лежит ${lines} строк, разделов «## » — ${sections}. Запись целиком уносит все разделы, которых эта правка не касалась, и на их место молча возвращается пакетный текст ресурса «${resource}»: раскладка после этого сходится, проверки зелёные, а сказанного деревом о себе больше нет. Правь по месту — правкой раздела, а не записью файла." \
102
- "новый раздел дописывается в конец: надстройка сливается с пакетным ресурсом по заголовку «## », и пакетный текст замещается только теми разделами, которые дерево назвало"
103
+ deny "BLOCKED by override-write-guard: «${relative}» is an override of this tree, and it already holds ${lines} lines, sections «## » — ${sections}. A whole-file write carries away every section this edit did not touch, and the package text of the resource «${resource}» silently returns in their place: the layout matches after that, the checks are green, and what the tree said about itself is gone. Edit in place — by an edit of a section, not by a write of the file." \
104
+ "a new section is appended at the end: the override merges with the package resource by the heading «## », and the package text is replaced only by the sections the tree named"
103
105
  done <<EOF
104
106
  $candidates
105
107
  EOF