@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,35 +1,38 @@
1
1
  #!/usr/bin/env bash
2
2
  # rt-hook: PostToolUse .*
3
- # Требует: hooks/profile-check.sh, hooks/deny-tail.sh
3
+ # Requires: hooks/profile-check.sh, hooks/deny-tail.sh
4
4
  # rt-hook: PreToolUse .*
5
- # Заполнение окна: заход доводится до логической точки заранее, а не обрывается на середине.
5
+ # Window fill: the session is brought to a logical point in advance, not cut off in the middle.
6
6
  #
7
- # Зачем именно так. Место, где исполнитель помнит ход работы, ограничено, и заполнив его, он
8
- # теряет не последнее действие, а всю картину разом. Изнутри захода этот предел не виден ничем:
9
- # ни одна проверка дерева его не показывает, а сжатие контекста срабатывает, когда доводить
10
- # работу до точки уже нечем.
7
+ # Why exactly this way. The place where the executor remembers the progress of the work is limited,
8
+ # and having filled it, the executor loses not the last action but the whole picture at once. From
9
+ # inside the session this limit is visible by nothing: no check of the tree shows it, and context
10
+ # compaction fires when there is nothing left to bring the work to a point with.
11
11
  #
12
- # Гард стоит на двух событиях сразу — разводить его по двум файлам значило бы держать два
13
- # разбора одной записи и два места, где правится один порог:
14
- # PostToolUse — на первом пороге отдаёт напоминание: пора выбирать точку остановки;
15
- # PreToolUse — на втором отбивает всё, кроме записи хода работы, передачи и команд поставки.
16
- # Место между порогами и есть то, на что закрывается заход: дописать ход работы, написать
17
- # передачу, закоммитить проверенное.
12
+ # The guard stands on two events at once — splitting it over two files would mean keeping two
13
+ # parses of one record and two places where one threshold is edited:
14
+ # PostToolUse — at the first threshold it gives a reminder: time to choose a stopping point;
15
+ # PreToolUse — at the second it refuses everything but writing the progress, the handover
16
+ # and the delivery commands.
17
+ # The space between the thresholds is what the session closes on: finish the progress, write the
18
+ # handover, commit what has been checked.
18
19
  #
19
- # Там, где дерево объявило порог сжатия ниже порога остановки, напоминание говорит обратное:
20
- # точку остановки выбирать не надо, потому что заход через порог пройдёт сам — сжатие придёт
21
- # первым, передачу к тому времени напишет свой хук, и работа продолжится тем же заходом. Отбой
22
- # при этом остаётся: он превращается из конца захода в страховку на случай, когда сжатие не
23
- # пришло. Напоминание, зовущее закрывать заход там, где закрывать его не надо, — это остановка
24
- # работы без причины, и стоит она ровно того же, что и отбой.
20
+ # Where the tree has declared the compaction threshold below the stopping threshold, the reminder
21
+ # says the opposite: there is no need to choose a stopping point, because the session will pass the
22
+ # threshold by itself — compaction comes first, a hook of its own will have written the handover by
23
+ # then, and the work goes on within the same session. The refusal stays at that: it turns from the
24
+ # end of the session into insurance for the case when compaction did not come. A reminder that
25
+ # calls for closing the session where it need not be closed is a stop of the work without a reason,
26
+ # and it costs exactly as much as a refusal.
25
27
  #
26
- # Размер окна берётся из настройки дерева. Из записи захода он не выводится: модель записана
27
- # там без пометки о расширенном окне, и заход на широкое окно от захода на узкое неотличим.
28
+ # The size of the window is taken from the tree setting. It is not derived from the session record:
29
+ # the model is recorded there without a mark about an extended window, and a session on a wide
30
+ # window is indistinguishable from a session on a narrow one.
28
31
  #
29
- # ОТКАЗ В ПОЛЬЗУ РАБОТЫ: нет размера окна, нет записи захода, нет разборщика, битый разбор —
30
- # работа РАЗРЕШАЕТСЯ (exit 0). Сломанный гард не имеет права заклинить работу.
32
+ # FAIL-OPEN: no window size, no session record, no parser, a broken parse — the work is ALLOWED
33
+ # (exit 0). A broken guard has no right to jam the work.
31
34
 
32
- # Своё имя в наблюдениях: отбой пишет общий хвост отказа, а не сам гард.
35
+ # Its own name in the observations: the refusal is written by the shared deny tail, not by the guard.
33
36
  RT_GUARD_NAME=window-fill-guard
34
37
 
35
38
  . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
@@ -41,16 +44,16 @@ input="$RT_HOOK_INPUT"
41
44
 
42
45
  command -v jq >/dev/null 2>&1 || exit 0
43
46
 
44
- # Профиль дерева: размер окна, пороги, каталоги задач и передачи. Дерево, не задавшее размера
45
- # окна, стража не получает — считать долю не от чего.
47
+ # The tree profile: the window size, the thresholds, the directories of tasks and of the handover.
48
+ # A tree that has not set the window size gets no guard — there is nothing to count the share from.
46
49
  rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
47
50
  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
48
51
  # shellcheck disable=SC1090
49
52
  [ -f "$profile" ] && . "$profile" 2>/dev/null
50
53
  done
51
54
 
52
- # Слово о нехватке функции профиля: хук, вышедший молча, неотличим от работающего. Файл может
53
- # быть не разложен — тогда остаётся прежнее поведение, молчаливое.
55
+ # A word about a missing profile function: a hook that exited silently is indistinguishable from a
56
+ # working one. The file may not be laid out — then the former, silent behaviour stays.
54
57
  # shellcheck disable=SC1090
55
58
  [ -f "$rt_hooks_dir/profile-check.sh" ] && . "$rt_hooks_dir/profile-check.sh"
56
59
  command -v rt_needs >/dev/null 2>&1 || rt_needs() { command -v "$1" >/dev/null 2>&1; }
@@ -64,14 +67,16 @@ esac
64
67
  warn_pct="${RT_WINDOW_WARN_PCT:-40}"
65
68
  stop_pct="${RT_WINDOW_STOP_PCT:-50}"
66
69
 
67
- # Доля, на которой контекст сжимает сам инструмент. Объявлена деревом — заход через порог
68
- # проходит сам: сжатие приходит первым, передачу к тому моменту уже написал свой хук, и работа
69
- # идёт дальше тем же заходом. Не объявлена — прежний порядок: заход кончается передачей.
70
+ # The share at which the tool compacts the context itself. Declared by the tree — the session
71
+ # passes the threshold by itself: compaction comes first, a hook of its own has written the
72
+ # handover by then, and the work goes on within the same session. Not declared — the former order:
73
+ # the session ends with a handover.
70
74
  #
71
- # От этого зависит текст напоминания, а не отказ. Отбой на пороге остановки остаётся в обоих
72
- # случаях: он и есть страховка на случай, когда сжатие не пришло — настройка снята, версия
73
- # другая, сжатие отказало. Отобрав отбой у дерева, объявившего сжатие, страж пустил бы такой
74
- # заход до предела окна, где работа теряется целиком.
75
+ # The text of the reminder depends on this, not the refusal. The refusal at the stopping threshold
76
+ # stays in both cases: it is the insurance for when compaction did not come — the setting was
77
+ # removed, the version is another, compaction failed. Taking the refusal away from a tree that
78
+ # declared compaction, the guard would let such a session run to the limit of the window, where the
79
+ # work is lost whole.
75
80
  compact_pct="${CLAUDE_AUTOCOMPACT_PCT_OVERRIDE:-}"
76
81
  case "$compact_pct" in
77
82
  '' | *[!0-9]*) compact_pct='' ;;
@@ -86,11 +91,12 @@ transcript="$(printf '%s' "$input" | jq -r '.transcript_path // empty' 2>/dev/nu
86
91
  [ -n "$transcript" ] || exit 0
87
92
  [ -f "$transcript" ] || exit 0
88
93
 
89
- # Заполнение — это последняя запись ответа с расходом: вход, разовая запись в кэш, прочитанное
90
- # из кэша и вывод. Сумма по всем записям тут не годится вовсе — прочитанное из кэша повторяется
91
- # в каждой из них, и сумма выходит в разы больше окна.
94
+ # The fill is the last usage record of a reply: the input, the one-off write into the cache, what
95
+ # was read from the cache and the output. A sum over all the records will not do at all here — what
96
+ # was read from the cache repeats in each of them, and the sum comes out several times the window.
92
97
  #
93
- # Хвост в 200 строк: запись захода растёт весь заход, а нужна из неё одна последняя строка.
98
+ # A tail of 200 lines: the session record grows all session, and one last line of it is what is
99
+ # needed.
94
100
  fill="$(tail -n 200 "$transcript" 2>/dev/null | jq -s -r '
95
101
  [.[] | select(.type == "assistant") | .message.usage | select(. != null)]
96
102
  | last
@@ -108,13 +114,13 @@ pct=$((fill * 100 / window))
108
114
  fill_k=$((fill / 1000))
109
115
  window_k=$((window / 1000))
110
116
 
111
- # --- первый порог: напоминание, работа не отбивается -------------------------------------
117
+ # --- the first threshold: a reminder, the work is not refused ----------------------------
112
118
 
113
119
  if [ "$event" = "PostToolUse" ]; then
114
120
  [ "$pct" -ge "$warn_pct" ] || exit 0
115
121
 
116
- # Напоминание повторяется не на каждом вызове, а на каждой следующей ступени в пять
117
- # процентов: иначе оно занимает то самое место, которое бережёт.
122
+ # The reminder repeats not on every call but on each next step of five per cent: otherwise it
123
+ # takes up the very place it saves.
118
124
  step=$(((pct / 5) * 5))
119
125
  session="$(printf '%s' "$input" | jq -r '.session_id // "unknown"' 2>/dev/null)"
120
126
  mark_dir="${TMPDIR:-/tmp}/claude-window-fill"
@@ -129,14 +135,14 @@ if [ "$event" = "PostToolUse" ]; then
129
135
 
130
136
  if [ "$pct" -ge "$stop_pct" ]; then
131
137
  if [ -n "$compact_pct" ]; then
132
- text="ЗАПОЛНЕНИЕ ОКНА ${pct}% (${fill_k}k из ${window_k}k) — заход закрывается сейчас. Сжатие объявлено на ${compact_pct}% и не пришло: порог остановки ${stop_pct}% пройден, а контекст прежний. Всё, кроме записи хода работы, передачи и команд поставки, уже отбивается — закрывай заход и скажи владельцу, что сжатие не сработало."
138
+ text="WINDOW FILL ${pct}% (${fill_k}k of ${window_k}k) — the session closes now. The compaction was announced at ${compact_pct}% and did not come: the stop threshold ${stop_pct}% is passed and the context is the same. Everything but writing the progress, the handover and the commands of delivery is already refused — close the session and tell the owner the compaction did not work."
133
139
  else
134
- text="ЗАПОЛНЕНИЕ ОКНА ${pct}% (${fill_k}k из ${window_k}k) — заход закрывается сейчас. Всё, кроме записи хода работы, передачи и команд поставки, уже отбивается."
140
+ text="WINDOW FILL ${pct}% (${fill_k}k of ${window_k}k) — the session closes now. Everything but writing the progress, the handover and the commands of delivery is already refused."
135
141
  fi
136
142
  elif [ -n "$compact_pct" ]; then
137
- text="ЗАПОЛНЕНИЕ ОКНА ${pct}% (${fill_k}k из ${window_k}k). Точку остановки выбирать не надо: на ${compact_pct}% инструмент сожмёт контекст сам, передачу к тому времени напишет хук, и работа пойдёт дальше этим же заходом. Порог остановки ${stop_pct}% — страховка на случай, если сжатие не придёт. Работай дальше."
143
+ text="WINDOW FILL ${pct}% (${fill_k}k of ${window_k}k). There is no stopping point to choose: at ${compact_pct}% the tool compacts the context itself, the hook writes the handover by then, and the work goes on in this same session. The stop threshold ${stop_pct}% is the insurance in case the compaction does not come. Work on."
138
144
  else
139
- text="ЗАПОЛНЕНИЕ ОКНА ${pct}% (${fill_k}k из ${window_k}k). Пора выбирать точку остановки: с ${stop_pct}% останется только закрыть заход. Доведи текущий шаг до состояния, с которого следующий заход продолжит, перепиши «Где стоим» в ходе работы, напиши передачу и отдай владельцу путь к ней — паттерн task-flow-handoff."
145
+ text="WINDOW FILL ${pct}% (${fill_k}k of ${window_k}k). It is time to choose the stopping point: from ${stop_pct}% only closing the session is left. Bring the current step to a state the next session continues from, rewrite «Where we stand» in the progress, write the handover and give the owner the path to it — the pattern task-flow-handoff."
140
146
  fi
141
147
 
142
148
  jq -n --arg t "$text" \
@@ -144,7 +150,7 @@ if [ "$event" = "PostToolUse" ]; then
144
150
  exit 0
145
151
  fi
146
152
 
147
- # --- второй порог: работа отбивается, закрытие захода пропускается ------------------------
153
+ # --- the second threshold: work is refused, closing the session passes --------------------
148
154
 
149
155
  [ "$event" = "PreToolUse" ] || exit 0
150
156
  [ "$pct" -ge "$stop_pct" ] || exit 0
@@ -155,19 +161,20 @@ cmd="$(rt_hook_cmd)"
155
161
 
156
162
  allowed=0
157
163
  case "$tool" in
158
- # Разговор с владельцем и чтение того, что правится при закрытии.
164
+ # The conversation with the owner and reading what is edited at the closing.
159
165
  AskUserQuestion | TodoWrite | Read | SendUserFile)
160
166
  allowed=1
161
167
  ;;
162
168
  Edit | Write | MultiEdit | mcp__webstorm__create_new_file)
163
- # Ход работы и передача. Остальное — работа, а её заход уже не начинает.
169
+ # The progress and the handover. The rest is work, and the session no longer starts it.
164
170
  case "$path" in
165
171
  "$tasks_dir"/* | */"$tasks_dir"/* | "$handoff_dir"/* | */"$handoff_dir"/* | */scratchpad/*) allowed=1 ;;
166
172
  esac
167
173
  ;;
168
174
  Bash | mcp__webstorm__execute_terminal_command)
169
- # Поставка и сверки: коммит, пуш, PR, колонка задачи, состояние дерева. Список
170
- # дописывается профилем дерева — клиент хостинга и имена команд у каждого свои.
175
+ # Delivery and checks: commit, push, PR, the task column, the state of the tree. The list
176
+ # is added to by the tree profile — the hosting client and the command names differ from
177
+ # tree to tree.
171
178
  if rt_needs rt_handoff_allowed_cmd window-fill-guard && rt_handoff_allowed_cmd "$cmd"; then
172
179
  allowed=1
173
180
  fi
@@ -176,21 +183,22 @@ esac
176
183
 
177
184
  [ "$allowed" -eq 1 ] && exit 0
178
185
 
179
- reason="BLOCKED by window-fill-guard: заполнение окна ${pct}% (${fill_k}k из ${window_k}k), порог остановки ${stop_pct}%. Заход дальше не работает — он закрывается.
186
+ reason="BLOCKED by window-fill-guard: window fill ${pct}% (${fill_k}k of ${window_k}k), the stop threshold is ${stop_pct}%. The session works no further — it closes.
180
187
 
181
- Что осталось сделать этим заходом:
182
- 1. Перепиши раздел «Где стоим» в ходе работы и добавь запись захода — что сделано, чем подтверждено, что не вышло.
183
- 2. Закоммить проверенное: незакоммиченное не переживёт перерыв.
184
- 3. Напиши передачу в ${handoff_dir}/ и отдай владельцу путь к ней — что в неё входит, говорит паттерн task-flow-handoff.
188
+ What is left to do in this session:
189
+ 1. Rewrite the section «Where we stand» in the progress and add a session entry — what was done, what confirms it, what did not work out.
190
+ 2. Commit what is checked: what is not committed does not survive the break.
191
+ 3. Write the handover into ${handoff_dir}/ and give the owner the path to it — what goes into it is said by the pattern task-flow-handoff.
185
192
 
186
- Что после порога проходит:
187
- - правка ${tasks_dir}/** и ${handoff_dir}/**, чтение любого файла, вопрос владельцу;
188
- - команда, начинающаяся со слова поставки или сверки: git, клиент хостинга, перевод колонки, npm run check:*.
193
+ What passes after the threshold:
194
+ - an edit of ${tasks_dir}/** and ${handoff_dir}/**, a read of any file, a question to the owner;
195
+ - a command starting with a word of delivery or verification: git, the client of the hosting, moving a column, npm run check:*.
189
196
 
190
- Команда судится по началу строки: вход в каталог перед ней снимает совпадение, и отбит будет тот же коммит, который прошёл бы без него. Начинай команду с самого слова поставки."
197
+ A command is judged by the start of the line: entering a directory before it removes the match, and the very commit that would have passed without it is refused. Start the command with the word of delivery itself."
191
198
 
192
- # Общий хвост отказа: два законных хода и законная форма обхода, если она у отказа есть.
193
- # Файл может быть не разложен — тогда хвоста нет, а причина отказа остаётся прежней.
199
+ # The shared deny tail: the two lawful moves and the lawful form of bypass, if the refusal has one.
200
+ # The file may not be laid out — then there is no tail, and the reason for the refusal stays as it
201
+ # was.
194
202
  # shellcheck disable=SC1090
195
203
  [ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
196
204
  && . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
@@ -202,6 +210,6 @@ ${deny_tail_text}"
202
210
 
203
211
  jq -n --arg r "$reason" \
204
212
  '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:$r}}' 2>/dev/null \
205
- || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"window-fill-guard: окно заполнено, заход закрывается передачей."}}\n'
213
+ || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"window-fill-guard: the window is full, the session closes with a handover."}}\n'
206
214
 
207
215
  exit 0
@@ -1,34 +1,36 @@
1
1
  #!/usr/bin/env bash
2
2
  # rt-hook: Stop
3
- # Требует: hooks/deny-tail.sh, hooks/profile-check.sh
4
- # Гард начала работы: ход, правивший код приложения, не заканчивается, пока владелец в этом же
5
- # ходе о работе не просил. Stop.
3
+ # Requires: hooks/deny-tail.sh, hooks/profile-check.sh
4
+ # Work-start guard: a turn that edited application code does not end unless the owner asked for
5
+ # the work in that same turn. Stop.
6
6
  #
7
- # Зачем именно так. Статья «заход работу не начинает сам» держится памятью исполнителя, и
8
- # держится плохо: заход, открывшийся после чистки контекста, получает от хука запуска состояние
9
- # незаконченной работы и замысел с этапами — и оба говорят, что делать, если работать. О том,
10
- # работать ли, не говорит ни один. Строка с путём к файлу, присланная владельцем, прочитана как
11
- # поручение, и заход правит полсотни файлов, которых у него никто не просил.
7
+ # Why this way. The article "a session does not start work by itself" is held by the executor's
8
+ # memory, and held badly: a session opened after a context compaction gets the state of unfinished
9
+ # work and the plan with its stages from the startup hook — and both say what to do, if working.
10
+ # Whether to work, neither says. A line with a file path sent by the owner is read as an
11
+ # assignment, and the session edits fifty files nobody asked it for.
12
12
  #
13
- # Соседние гарды этого не ловят, и не по недосмотру: каждый судит своё. Гард замысла требует
14
- # замысел на диске — он лежит; гард эпика отбивает чужую задачу — задача своя; гард разговора
15
- # судит ход, в котором задан вопрос, — а вопроса не задали ровно потому, что решили не
16
- # спрашивать. Все три судят предмет правки и её порядок, и ни один не спрашивает, кто эту
17
- # правку заказал.
13
+ # The neighbouring guards do not catch this, and not by oversight: each judges its own matter.
14
+ # The plan guard demands a plan on disk — it lies there; the epic guard refuses someone else's
15
+ # task — the task is its own; the conversation guard judges a turn in which a question was asked
16
+ # — and no question was asked precisely because it was decided not to ask. All three judge the
17
+ # subject of the edit and its order, and none asks who ordered this edit.
18
18
  #
19
- # Просьба ловится формой, а не смыслом. Смысл машине не виден, и гард, взявшийся его понимать,
20
- # отбивал бы работу по настроению; поэтому судится обратное — то, что просьбой не бывает ни при
21
- # каком прочтении: пустая реплика, одно слово и путь к файлу. Всё остальное считается просьбой,
22
- # и это выбрано намеренно: ложный отказ здесь стоит дороже пропуска — он останавливает работу,
23
- # которую владелец заказал.
19
+ # The request is caught by form, not by meaning. Meaning is invisible to a machine, and a guard
20
+ # that took to understanding it would refuse work by mood; so the opposite is judged — what is
21
+ # never a request under any reading: an empty message, a single word and a file path. Everything
22
+ # else counts as a request, and this is chosen on purpose: a false refusal here costs more than a
23
+ # miss — it stops work the owner ordered.
24
24
  #
25
- # Код приложения узнаётся признаком дерева `rt_is_app_code` — тем же, которым его узнаёт гард
26
- # замысла. Дерево, признака не объявившее, этого гарда не получает: судить ему нечем.
25
+ # Application code is recognised by the tree's sign `rt_is_app_code` — the same one the plan
26
+ # guard recognises it by. A tree that declared no sign does not get this guard: it has nothing to
27
+ # judge by.
27
28
  #
28
- # ОТКАЗ В ПОЛЬЗУ РАБОТЫ: нет `jq`, нет записи хода, нет признака дерева, повторный заход, любая
29
- # своя ошибка — ход РАЗРЕШАЕТСЯ (exit 0). Сломанный гард не имеет права заклинить работу.
29
+ # FAIL-OPEN: no `jq`, no turn transcript, no tree sign, a repeated pass, any error of its own —
30
+ # the turn is ALLOWED (exit 0). A broken guard has no right to jam the work.
30
31
 
31
- # Своё имя в наблюдениях: отбой пишет общий хвост отказа, а не сам гард.
32
+ # Its own name in the observations: the refusal is written by the shared deny tail, not by the
33
+ # guard itself.
32
34
  RT_GUARD_NAME=work-start-guard
33
35
 
34
36
  . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
@@ -40,7 +42,7 @@ input="$RT_HOOK_INPUT"
40
42
 
41
43
  command -v jq >/dev/null 2>&1 || exit 0
42
44
 
43
- # Повторный заход по тому же ходу не судится: гард сказал своё один раз и отпускает.
45
+ # A repeated pass over the same turn is not judged: the guard has said its word once and lets go.
44
46
  active="$(printf '%s' "$input" | jq -r '.stop_hook_active // false' 2>/dev/null)"
45
47
  [ "$active" = "true" ] && exit 0
46
48
 
@@ -50,7 +52,7 @@ transcript="$(printf '%s' "$input" | jq -r '.transcript_path // empty' 2>/dev/nu
50
52
 
51
53
  rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
52
54
 
53
- # Профиль дерева: сперва умолчание пакета, поверх него — надстройка проекта, если она есть.
55
+ # The tree profile: first the package default, over it the project override, if there is one.
54
56
  for profile in "$rt_hooks_dir/../rt-kit/defaults/project.sh" "$rt_hooks_dir/../defaults/project.sh" \
55
57
  "${CLAUDE_PROJECT_DIR:-.}/.claude/rt-kit/defaults/project.sh" "${CLAUDE_PROJECT_DIR:-.}/.claude/rt-kit/project.sh"; do
56
58
  # shellcheck disable=SC1090
@@ -62,10 +64,10 @@ done
62
64
  command -v rt_needs >/dev/null 2>&1 || rt_needs() { command -v "$1" >/dev/null 2>&1; }
63
65
  rt_needs rt_is_app_code work-start-guard || exit 0
64
66
 
65
- # Ход — это всё, что записано после последнего настоящего ввода владельца. Ответ инструмента
66
- # приходит той же ролью, поэтому строки с `tool_result` вводом не считаются.
67
+ # A turn is everything recorded after the owner's last real input. A tool result arrives under
68
+ # the same role, so lines with `tool_result` are not counted as input.
67
69
  #
68
- # Хвост в 400 строк: запись хода растёт всю сессию, а судится только последний ход.
70
+ # A 400-line tail: the transcript grows all session long, and only the last turn is judged.
69
71
  asked="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r '
70
72
  def is_input:
71
73
  .type == "user"
@@ -83,12 +85,12 @@ asked="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r '
83
85
  end
84
86
  ' 2>/dev/null)"
85
87
 
86
- # Ввода в записи нет вовсе — судить нечего: ход разрешается.
88
+ # No input in the transcript at all — nothing to judge: the turn is allowed.
87
89
  [ -z "$asked" ] && exit 0
88
90
 
89
- # Правленные за ход файлы: инструменты правки называют путь полем, а команда оболочки — своим
90
- # разбором, и его здесь нет намеренно. Гард судит явную правку файла: команда, пишущая в код
91
- # мимо инструмента правки, остаётся его известной границей.
91
+ # Files edited during the turn: the edit tools name the path in a field, while a shell command
92
+ # would need its own parsing, and there is none here on purpose. The guard judges an explicit file
93
+ # edit: a command writing into code past the edit tool remains its known boundary.
92
94
  edited="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r '
93
95
  def is_input:
94
96
  .type == "user"
@@ -119,24 +121,25 @@ done <<EOF
119
121
  $edited
120
122
  EOF
121
123
 
122
- # Код приложения за ход не правился: гард молчит. Разбор, тексты и обвязка идут своим ходом —
123
- # требовать слова владельца на них значило бы запретить разведку до просьбы.
124
+ # No application code was edited during the turn: the guard is silent. Exploration, texts and
125
+ # harness go their own way — demanding the owner's word on them would forbid scouting before a
126
+ # request.
124
127
  [ -z "$touched" ] && exit 0
125
128
 
126
- # Просьбой не бывает ни при каком прочтении: пустая реплика, одно слово, путь к файлу. Судится
127
- # первая непустая строка ввода: развёрнутая просьба своей первой строкой уже просьба, а путь,
128
- # присланный один, ею не станет и дальше.
129
+ # Never a request under any reading: an empty message, a single word, a file path. The first
130
+ # non-empty line of the input is judged: a detailed request is already a request by its first
131
+ # line, and a path sent alone does not become one further down either.
129
132
  first="$(printf '%s' "$asked" | tr -d '\r' | sed -n '/[^[:space:]]/{p;q;}')"
130
133
  words="$(printf '%s' "$asked" | tr -s '[:space:]' '\n' | grep -c '[^[:space:]]' 2>/dev/null || echo 0)"
131
134
 
132
135
  case "$first" in
133
- # Служебная отметка о прерывании: своей просьбы в ней нет.
134
- '[Request interrupted'*) kind="прерывание" ;;
136
+ # A service note about an interruption: there is no request of its own in it.
137
+ '[Request interrupted'*) kind="an interruption" ;;
135
138
  *)
136
139
  if [ "$words" -le 1 ] 2>/dev/null; then
137
140
  case "$first" in
138
- */*) kind="путь к файлу" ;;
139
- *) kind="одно слово" ;;
141
+ */*) kind="a path to a file" ;;
142
+ *) kind="one word" ;;
140
143
  esac
141
144
  else
142
145
  kind=""
@@ -144,19 +147,19 @@ case "$first" in
144
147
  ;;
145
148
  esac
146
149
 
147
- # Просьба в ходе есть: работа заказана, и гард отпускает.
150
+ # There is a request in the turn: the work was ordered, and the guard lets go.
148
151
  [ -z "$kind" ] && exit 0
149
152
 
150
- reason="BLOCKED by work-start-guard: за ход правился код приложения — «${touched}», — а последняя реплика владельца просьбой не была: ${kind}.
153
+ reason="BLOCKED by work-start-guard: application code was edited in this turn — «${touched}» — while the last message of the owner was not a request: ${kind}.
151
154
 
152
- Заход работу не начинает сам. Передача прошлого захода, состояние задачи из хука запуска и назначенный эпик говорят, что делать, если работать, и молчат о том, работать ли. Строка с адресом называет файл, а не действие: прочитанная как поручение, она даёт заходу задание, которого владелец не давал.
155
+ A session does not start work by itself. The handover of the previous session, the task state from the startup hook and the assigned epic say what to do if working, and stay silent about whether to work. A line with an address names a file, not an action: read as an order, it gives the session work the owner never ordered.
153
156
 
154
- Ход отсюда один: назови владельцу состояние работы и спроси, продолжать ли, — и дождись ответа. Сделанное этим ходом не откатывается само: скажи, что уже правлено.
157
+ There is one move from here: name the state of the work to the owner and ask whether to go on — and wait for the answer. What was done in this turn does not roll itself back: say what is already edited.
155
158
 
156
- Гард судит один ход: следующий заход не отбивается."
159
+ The guard judges one turn: the next session is not refused."
157
160
 
158
- # Общий хвост отказа: два законных хода. Файл может быть не разложен — тогда хвоста нет,
159
- # а причина отказа остаётся прежней.
161
+ # The shared deny tail: the two lawful moves. The file may not be laid out — then there is no
162
+ # tail, and the reason for the refusal stays the same.
160
163
  # shellcheck disable=SC1090
161
164
  [ -f "$rt_hooks_dir/deny-tail.sh" ] && . "$rt_hooks_dir/deny-tail.sh" 2>/dev/null
162
165
  command -v rt_deny_tail >/dev/null 2>&1 || rt_deny_tail() { :; }
@@ -166,6 +169,6 @@ deny_tail_text="$(rt_deny_tail "")"
166
169
  ${deny_tail_text}"
167
170
 
168
171
  jq -n --arg r "$reason" '{decision:"block",reason:$r}' 2>/dev/null \
169
- || printf '{"decision":"block","reason":"work-start-guard: код правился, а просьбы владельца в этом ходе не было."}\n'
172
+ || printf '{"decision":"block","reason":"work-start-guard: code was edited, and there was no request from the owner in this turn."}\n'
170
173
 
171
174
  exit 0