@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,39 +1,41 @@
1
1
  #!/usr/bin/env bash
2
- # Общий разбор для гардов хода работы. НЕ гард: объявления `rt-hook:` у него нет, к событиям
3
- # агента он не подключается. Его источают сами гарды — тем же приёмом, каким они источают общий
4
- # хвост отказа.
2
+ # Shared parsing for the work-conduct guards. NOT a guard: it has no `rt-hook:` declaration and
3
+ # is not attached to any agent event. The guards themselves source it — the same way they source
4
+ # the shared refusal tail.
5
5
  #
6
- # Зачем он есть. Требования к ходу работы стоят двумя гардами — папка задачи с замыслом и
7
- # состоянием отдельно, договорённость о продукте отдельно, — а разбор у обоих один и тот же:
8
- # какой путь пишет вызов, код ли это приложения, в какой ветке идёт правка и где лежит папка
9
- # задачи. Разложенный вторым разом, этот разбор расходится молча: правка одного гарда чинит
10
- # половину случаев, и видно это только там, где второй промолчал.
6
+ # Why it exists. The work-conduct requirements are kept by two guards — the task folder with the
7
+ # plan and the state by one, the product agreement by the other — and both parse the same things:
8
+ # which path the call writes, whether it is application code, in which branch the edit goes and
9
+ # where the task folder lies. Laid out twice, this parsing drifts silently: an edit to one guard
10
+ # fixes half of the cases, and that shows only where the other guard kept silent.
11
11
  #
12
- # ЧТО ОН ДЕЛАЕТ. Читает ввод, поднимает профиль дерева, вынимает из вызова пути, отбирает среди
13
- # них первый путь кода приложения, переходит в рабочий каталог правки и называет ветку, корень,
14
- # каталог папок задач, саму папку и замысел в ней.
12
+ # WHAT IT DOES. Reads the input, loads the tree profile, takes the paths out of the call, picks
13
+ # the first application-code path among them, moves into the working directory of the edit and
14
+ # names the branch, the root, the task folders directory, the folder itself and the plan in it.
15
15
  #
16
- # ЧЕГО ОН НЕ ДЕЛАЕТ. Он ничего не судит и ничего не отбивает: имя ветки, наличие папки, состояние
17
- # работы и договорённость — дело самих гардов, и отказ печатает тот, чьё это требование.
16
+ # WHAT IT DOES NOT DO. It judges nothing and refuses nothing: the branch name, the presence of
17
+ # the folder, the work state and the agreement are the business of the guards themselves, and the
18
+ # refusal is printed by the one whose requirement it is.
18
19
  #
19
- # FAIL-OPEN: нет jq, не git-репозиторий, битый ввод, чужой инструмент, нет функции профиля →
20
- # ответ «судить нечего». Сломанный разбор не должен мешать работать.
20
+ # FAIL-OPEN: no jq, not a git repository, broken input, a foreign tool, no profile function →
21
+ # the answer is "nothing to judge". Broken parsing must not get in the way of work.
21
22
 
22
- # Разбор вызова. Возвращает 0 и ставит переменные, если правка касается кода приложения в ветке
23
- # с историей; иначе — ненулевой код, и гард выходит молча.
23
+ # Parsing the call. Returns 0 and sets the variables if the edit touches application code in a
24
+ # branch with history; otherwise a non-zero code, and the guard exits silently.
24
25
  #
25
- # RT_TF_PATH — путь кода приложения, из-за которого гард вообще судит
26
- # RT_TF_BRANCH — текущая ветка рабочего каталога правки
27
- # RT_TF_ROOT — корень рабочего дерева
28
- # RT_TF_TASKS_DIR — каталог папок задач, как он назван в дереве
29
- # RT_TF_MAIN_BRANCH — главная ветка дерева
30
- # RT_TF_DIR — папка этой задачи
31
- # RT_TF_PLAN — замысел в ней
32
- # Разложенный слой правил судится наравне с кодом приложения. Путями кода он не покрыт нигде —
33
- # лежит в каталоге законов, в каталоге агента и среди проверок, — и полторы сотни его файлов
34
- # легли без единого отклика гарда; отбил он двумя ходами позже, на записи в папку задачи. Признак
35
- # тот же, по которому слой находит гейт правил: шапка раскладки в начале файла. Ресурс пакета, из
36
- # которого раскладка идёт, шапки не несёт и судится по-прежнему своим путём.
26
+ # RT_TF_PATH — the application-code path because of which the guard judges at all
27
+ # RT_TF_BRANCH — the current branch of the edit's working directory
28
+ # RT_TF_ROOT — the root of the working tree
29
+ # RT_TF_TASKS_DIR — the task folders directory, as the tree names it
30
+ # RT_TF_MAIN_BRANCH — the main branch of the tree
31
+ # RT_TF_DIR — the folder of this task
32
+ # RT_TF_PLAN — the plan in it
33
+ # The laid-out rules layer is judged on a par with application code. No code path covers it — it
34
+ # lies in the laws directory, in the agent directory and among the checks — and a hundred and
35
+ # fifty of its files landed without a single response from the guard; it refused two turns later,
36
+ # on a write into the task folder. The sign is the same one by which the layer finds the rules
37
+ # gate: the layout header at the top of the file. The package resource the layout comes from
38
+ # carries no header and is still judged by its path.
37
39
  rt_tf_laid_out() {
38
40
  [ -f "$1" ] || return 1
39
41
  head -n 3 "$1" 2>/dev/null | grep -q 'rt-kit v[^[:space:]]* ·'
@@ -52,8 +54,8 @@ rt_task_flow_context() {
52
54
  [ -z "$RT_HOOK_INPUT" ] && return 1
53
55
  command -v jq >/dev/null 2>&1 || return 1
54
56
 
55
- # Профиль дерева: сперва умолчание пакета, поверх него — надстройка проекта, если она есть.
56
- # Читается до разбора пути: пути из команды оболочки вынимает как раз профиль.
57
+ # The tree profile: the package default first, the project override on top of it if there is
58
+ # one. Read before the path parsing: it is the profile that takes paths out of a shell command.
57
59
  for rt_tf_profile in \
58
60
  "$rt_tf_hooks_dir/../rt-kit/defaults/project.sh" \
59
61
  "$rt_tf_hooks_dir/../defaults/project.sh" \
@@ -63,8 +65,8 @@ rt_task_flow_context() {
63
65
  [ -f "$rt_tf_profile" ] && . "$rt_tf_profile" 2>/dev/null
64
66
  done
65
67
 
66
- # Слово о нехватке функции профиля: хук, вышедший молча, неотличим от работающего. Файл может
67
- # быть не разложен — тогда остаётся прежнее поведение, молчаливое.
68
+ # A word about a missing profile function: a hook that exited silently cannot be told from a
69
+ # working one. The file may not be laid out — then the old behaviour, the silent one, stays.
68
70
  # shellcheck disable=SC1090
69
71
  [ -f "$rt_tf_hooks_dir/profile-check.sh" ] && . "$rt_tf_hooks_dir/profile-check.sh"
70
72
  command -v rt_needs >/dev/null 2>&1 || rt_needs() { command -v "$1" >/dev/null 2>&1; }
@@ -72,23 +74,23 @@ rt_task_flow_context() {
72
74
  rt_tf_tool="$(rt_hook_tool)"
73
75
  rt_tf_candidates=""
74
76
  case "$rt_tf_tool" in
75
- # Инструмент редактора заводит файл теми же двумя данными, только называет их иначе —
76
- # без этой ветки правка шла бы мимо гарда сменой инструмента.
77
+ # The editor tool creates a file with the same two pieces of data, only under different
78
+ # names — without this branch an edit would pass the guard by switching the tool.
77
79
  Edit | Write | MultiEdit | mcp__webstorm__create_new_file)
78
80
  rt_tf_candidates="$(printf '%s' "$RT_HOOK_INPUT" | jq -r '.tool_input.file_path // .tool_input.pathInProject // empty' 2>/dev/null)"
79
81
  ;;
80
- # Второй ярус: та же правка, положенная командой оболочки. Без него отказ гарда обходится
81
- # сменой не инструмента, а способа записи — перенаправлением, `sed -i`, интерпретатором с
82
- # heredoc.
82
+ # The second tier: the same edit, made by a shell command. Without it the guard's refusal
83
+ # is bypassed by switching not the tool but the way of writing — a redirect, `sed -i`, an
84
+ # interpreter with a heredoc.
83
85
  #
84
- # Терминал среды исполняет ту же командную строку и кладёт её в то же поле: без этих двух
85
- # имён гард стоял бы объявленным на них и молча пропускал — состояние хуже необъявленного,
86
- # потому что снаружи выглядит закрытым.
86
+ # The IDE terminal runs the same command line and puts it into the same field: without
87
+ # these two names the guard would stand declared on them and let them through silently —
88
+ # a state worse than undeclared, because from outside it looks closed.
87
89
  Bash | mcp__webstorm__execute_terminal_command | mcp__webstorm__execute_tool)
88
90
  rt_tf_cmd="$(rt_hook_cmd)"
89
91
  [ -z "$rt_tf_cmd" ] && return 1
90
- # Универсальный исполнитель прячет настоящую команду во вложенной строке: без её
91
- # разбора путь стоит за кавычкой, и до него не дотягивается ни один образец.
92
+ # The universal runner hides the real command in a nested string: without parsing it
93
+ # the path stands behind a quote, and no pattern reaches it.
92
94
  if [ "$rt_tf_tool" = "mcp__webstorm__execute_tool" ] && command -v perl >/dev/null 2>&1; then
93
95
  rt_tf_inner="$(printf '%s' "$rt_tf_cmd" | perl -0ne '
94
96
  if (/--command(?:=|\s+)(?:"((?:[^"\\]|\\.)*)"|\x27([^\x27]*)\x27|(.+))/s) {
@@ -97,15 +99,28 @@ rt_task_flow_context() {
97
99
  ' 2>/dev/null)"
98
100
  [ -n "$rt_tf_inner" ] && rt_tf_cmd="$rt_tf_inner"
99
101
  fi
100
- # Команда заведения задачи не судится вовсе. Она пишет папку задачи и карточку в
101
- # очереди работ, а текст её несёт тело задачи целиком: цитата со знаком «больше»
102
- # подходит под признак записи, путь к коду в прозе тела — под признак пути. Отбитая,
103
- # она отбивается тем самым гардом, который печатает её в тексте своего отказа, и
104
- # завести задачу становится нечем — ни с ветки закрытой задачи, ни с главной. Имя
105
- # команды берётся у профиля дерева: своя копия разошлась бы с ним молча.
102
+ # The task creation command is not judged at all. It writes the task folder and the
103
+ # card in the work queue, and its text carries the whole task body: a quote with the
104
+ # "greater than" sign matches the write sign, a code path in the body's prose matches
105
+ # the path sign. Refused, it is refused by the very guard that prints it in the text
106
+ # of its refusal, and there is nothing left to create a task with — neither from the
107
+ # branch of a closed task nor from the main one. The command name comes from the tree
108
+ # profile: a copy of its own would drift from it silently.
106
109
  case "$rt_tf_cmd" in
107
110
  *"${RT_TASK_NEW_CMD:-npm run task:new}"*) return 1 ;;
108
111
  esac
112
+ # Pruning stale records of finished work is not judged either. Records age by the
113
+ # calendar, and the age check turns red by itself, without an edit in the branch; in
114
+ # the branch where work arrives by merges there is no task folder and must not be,
115
+ # and without a plan the edit is not written — the PR stays red, and the executor has
116
+ # no way out of this pair. The tree profile names the command: not named — no
117
+ # exemption, and everything is as before. The whole command is compared, not a
118
+ # substring: in a chain through `&&` anything at all stands next to the pruning, and a
119
+ # substring exemption would become a hole as wide as the shell.
120
+ if [ -n "${RT_ARCHIVE_PRUNE_CMD:-}" ]; then
121
+ rt_tf_bare="$(printf '%s' "$rt_tf_cmd" | tr -s '[:space:]' ' ' | sed 's/^ //; s/ $//')"
122
+ [ "$rt_tf_bare" = "$RT_ARCHIVE_PRUNE_CMD" ] && return 1
123
+ fi
109
124
  rt_needs rt_shell_writes task-flow-guard || return 1
110
125
  rt_needs rt_shell_paths task-flow-guard || return 1
111
126
  rt_shell_writes "$rt_tf_cmd" || return 1
@@ -115,32 +130,34 @@ rt_task_flow_context() {
115
130
  esac
116
131
  [ -z "$rt_tf_candidates" ] && return 1
117
132
 
118
- # Признак «правка меняет поведение» — путь, а не оценка на глаз: оценку назначает тот, кому
119
- # она мешает, и порог плывёт. Где живёт код приложения, знает профиль: правила, тексты,
120
- # обвязка и зависимости под требование не попадают — иначе разбор задачи нельзя было бы
121
- # вести до заведения ветки.
133
+ # The sign "the edit changes behaviour" is a path, not a judgement by eye: a judgement is
134
+ # made by whoever it hinders, and the threshold drifts. Where application code lives, the
135
+ # profile knows: rules, texts, tooling and dependencies do not fall under the requirement —
136
+ # otherwise the grill of a task could not be conducted before the branch is created.
122
137
  rt_needs rt_is_app_code task-flow-guard || return 1
123
138
 
124
- # Удаление отличается от записи одним: снимаемого может не быть в истории вовсе. Свой
125
- # временный каталог под корнем приложений правкой продукта не бывает — снимать его,
126
- # восстанавливая ради этого замысел на диске, значит исполнять требование, написанное про
127
- # другое действие. Отслеживаемый путь судится по-прежнему: снятый файл кода меняет поведение
128
- # так же, как переписанный.
139
+ # Removal differs from a write in one thing: what is removed may not be in history at all. A
140
+ # temporary directory of one's own under the applications root is never a product edit —
141
+ # removing it, and restoring the plan on disk for that, means carrying out a requirement
142
+ # written about a different action. A tracked path is judged as before: a removed code file
143
+ # changes behaviour just as a rewritten one does.
129
144
  rt_tf_removes=0
130
145
  case "${rt_tf_cmd:-}" in
131
146
  *"rm "*) rt_tf_removes=1 ;;
132
147
  esac
133
- # Каталог правки: ветка и история смотрятся ниже, а спросить историю нужно уже здесь.
148
+ # The directory of the edit: the branch and the history are looked at below, but history has
149
+ # to be asked already here.
134
150
  rt_tf_askdir="$(rt_hook_cwd)"
135
151
  [ -z "$rt_tf_askdir" ] && rt_tf_askdir="${CLAUDE_PROJECT_DIR:-.}"
136
152
 
137
- # Судится каждый названный путь: команда пишет столько файлов, сколько в ней стоит, и одного
138
- # под требованием довольно, чтобы отбить её целиком.
153
+ # Every named path is judged: a command writes as many files as stand in it, and one under
154
+ # the requirement is enough to refuse it whole.
139
155
  RT_TF_PATH=""
140
156
  while IFS= read -r rt_tf_candidate; do
141
157
  [ -z "$rt_tf_candidate" ] && continue
142
- # Снятие того, чего в истории нет, — не правка продукта, а уборка за собой. Спрашивается
143
- # путь, как он назван в команде: приклеенный корень уводит вопрос в чужое дерево.
158
+ # Removing what is not in history is not a product edit but cleaning up after oneself.
159
+ # The path is asked as it is named in the command: a glued-on root takes the question
160
+ # into a foreign tree.
144
161
  if [ "$rt_tf_removes" = 1 ] && git -C "$rt_tf_askdir" rev-parse --is-inside-work-tree >/dev/null 2>&1 &&
145
162
  ! git -C "$rt_tf_askdir" ls-files --error-unmatch -- "$rt_tf_candidate" >/dev/null 2>&1; then
146
163
  continue
@@ -158,19 +175,19 @@ $rt_tf_candidates
158
175
  EOF
159
176
  [ -z "$RT_TF_PATH" ] && return 1
160
177
 
161
- # Ветку смотрим там, где пойдёт правка: у worktree она своя.
178
+ # The branch is looked at where the edit will go: a worktree has one of its own.
162
179
  rt_tf_workdir="$(rt_hook_cwd)"
163
180
  [ -z "$rt_tf_workdir" ] && rt_tf_workdir="${CLAUDE_PROJECT_DIR:-.}"
164
181
  cd "$rt_tf_workdir" 2>/dev/null || return 1
165
182
  git rev-parse --is-inside-work-tree >/dev/null 2>&1 || return 1
166
183
 
167
184
  RT_TF_BRANCH="$(git branch --show-current 2>/dev/null)"
168
- [ -z "$RT_TF_BRANCH" ] && return 1 # detached HEAD — не про наш случай
185
+ [ -z "$RT_TF_BRANCH" ] && return 1 # a detached HEAD is not about this case
169
186
 
170
187
  RT_TF_ROOT="$(git rev-parse --show-toplevel 2>/dev/null)"
171
188
  [ -z "$RT_TF_ROOT" ] && return 1
172
189
 
173
- # Каталог папок задач: у дерева он свой, но имя обычно общее.
190
+ # The task folders directory: each tree has its own, but the name is usually shared.
174
191
  RT_TF_TASKS_DIR="${RT_TASKS_DIR:-docs/tasks}"
175
192
  RT_TF_MAIN_BRANCH="${RT_MAIN_BRANCH:-main}"
176
193
  RT_TF_DIR="$RT_TF_ROOT/$RT_TF_TASKS_DIR/$RT_TF_BRANCH"
@@ -179,9 +196,10 @@ EOF
179
196
  return 0
180
197
  }
181
198
 
182
- # Отказ гарда хода работы: причина первым параметром, законная форма обхода — вторым. Хвост
183
- # дописывается здесь, а не в каждом тексте: пропущенный в одном месте, он читается как «у этого
184
- # отказа ходов нет». Хвост может быть не разложен — тогда его нет, а причина остаётся прежней.
199
+ # The refusal of a work-conduct guard: the reason as the first parameter, the lawful form of
200
+ # bypass as the second. The tail is appended here, not in every text: missed in one place, it
201
+ # reads as "this refusal has no moves". The tail may not be laid out — then there is none, and
202
+ # the reason stays as it was.
185
203
  rt_task_flow_deny() {
186
204
  rt_tf_reason="$1"
187
205
  if command -v rt_deny_tail >/dev/null 2>&1; then
@@ -1,41 +1,44 @@
1
1
  #!/usr/bin/env bash
2
2
  # rt-hook: PreToolUse Edit|Write|MultiEdit|Bash|mcp__webstorm__create_new_file|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_tool
3
- # Требует: hooks/task-flow-context.sh, hooks/task-flow-guard.sh, hooks/deny-tail.sh
4
- # PreToolUse guard for Edit|Write|MultiEdit: код не пишется раньше договорённости о продукте.
3
+ # Requires: hooks/task-flow-context.sh, hooks/task-flow-guard.sh, hooks/deny-tail.sh
4
+ # PreToolUse guard for Edit|Write|MultiEdit: no code is written before the product agreement.
5
5
  #
6
- # Замысел говорит, как работа будет сделана, и молчит о том, о чём договорились с владельцем.
7
- # Договорённость о продукте — единственный текст, который называет обещанное поведение до кода;
8
- # написанная после, она пересказывает состоявшееся решение, а не проверяет его.
6
+ # The plan says how the work will be done and is silent about what was agreed with the owner.
7
+ # The product agreement is the only text that names the promised behaviour before the code;
8
+ # written afterwards, it retells a decision already made instead of checking it.
9
9
  #
10
- # Гард требует одно и ровно одно: замысел называет договорённость строкой `**Драфт:** \`путь\``,
11
- # и названное существует. Папку задачи, сам замысел и объявленное состояние требует
12
- # `task-flow-guard`, и до его отказов этот гард не судит ничего: замысла нет на диске — молчит.
10
+ # The guard demands one thing and exactly one: the plan names the agreement with the line
11
+ # `**Draft:** \`path\``, and what is named exists. The task folder, the plan itself and the
12
+ # declared state are demanded by `task-flow-guard`, and before its refusals this guard judges
13
+ # nothing: no plan on disk — it stays silent.
13
14
  #
14
- # Требования разведены затем, чтобы дерево могло отказаться от одного, сохранив второе. Пока
15
- # оба ехали одним файлом, отказ от требования договорённости снимал заодно требование папки
16
- # задачи и замысла — то есть всё, ради чего гард заводился.
15
+ # The demands are kept apart so that a tree can drop one and keep the other. While both rode in
16
+ # one file, dropping the agreement demand also dropped the demand for the task folder and the
17
+ # plan — that is, everything the guard was made for.
17
18
  #
18
- # Осознанный выход есть: строка `**Поведение:** не меняется — <причина>` в замысле снимает
19
- # требование договорённости. Пустая причина не принимается, как и у `Docs-skip:`.
19
+ # There is a deliberate way out: the line `**Behaviour:** unchanged — <reason>` in the plan
20
+ # lifts the agreement demand. An empty reason is not accepted, same as with `Docs-skip:`.
20
21
  #
21
- # Правило целиком — скил `task-flow`.
22
+ # The whole rule — the `task-flow` rule.
22
23
  #
23
- # FAIL-OPEN: нет jq, не git-репозиторий, битый ввод, чужой инструмент → пропуск. Сломанный
24
- # гард не должен мешать работать.
24
+ # FAIL-OPEN: no jq, not a git repository, broken input, foreign tool → pass. A broken guard must
25
+ # not get in the way of work.
25
26
 
26
- # Своё имя в наблюдениях: отбой пишет общий хвост отказа, а не сам гард.
27
+ # Own name in the observations: the refusal is written by the shared refusal tail, not by the
28
+ # guard itself.
27
29
  RT_GUARD_NAME=task-flow-draft-guard
28
30
 
29
31
  rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
30
32
 
31
- # Разбор вызова — общий у обоих гардов хода работы. Файл может быть не разложен: тогда судить
32
- # нечем, и гард молчит.
33
+ # Parsing the call is shared by both progress guards. The file may not be laid out: then there is
34
+ # nothing to judge with, and the guard stays silent.
33
35
  # shellcheck disable=SC1090
34
36
  [ -f "$rt_hooks_dir/task-flow-context.sh" ] && . "$rt_hooks_dir/task-flow-context.sh"
35
37
  command -v rt_task_flow_context >/dev/null 2>&1 || exit 0
36
38
 
37
- # Общий хвост отказа: два законных хода и законная форма обхода, если она у отказа есть. Файл
38
- # может быть не разложен — тогда хвоста нет, а причина отказа остаётся прежней.
39
+ # The shared refusal tail: two lawful moves and the lawful form of bypass, when the refusal has
40
+ # one. The file may not be laid out — then there is no tail, and the reason for the refusal stays
41
+ # as it was.
39
42
  # shellcheck disable=SC1090
40
43
  [ -f "$rt_hooks_dir/deny-tail.sh" ] && . "$rt_hooks_dir/deny-tail.sh"
41
44
 
@@ -48,28 +51,30 @@ plan="$RT_TF_PLAN"
48
51
 
49
52
  deny() { rt_task_flow_deny "$@"; }
50
53
 
51
- # Замысла нет — это чужое требование, и отказ о нём печатает гард хода работы. Отсюда же уходит
52
- # и работа с разобранной папкой: замысел с диска к этой минуте снят намеренно.
54
+ # No plan — that is another guard's demand, and the refusal about it is printed by the progress
55
+ # guard. Work with a taken-apart folder leaves here too: by this minute the plan has been removed
56
+ # from disk on purpose.
53
57
  [ -f "$plan" ] || exit 0
54
58
 
55
- # Строка обхода: поведение не меняется, договорённость о продукте не нужна. Причина обязана
56
- # стоять — без неё обход становится умолчанием.
57
- if grep -qE '^\*\*Поведение:\*\*[[:space:]]*не меняется[[:space:]]*—[[:space:]]*\S' "$plan" 2>/dev/null; then
59
+ # The bypass line: the behaviour does not change, no product agreement is needed. The reason must
60
+ # be there — without it the bypass becomes the default.
61
+ if grep -qE '^\*\*(Behaviour|Поведение):\*\*[[:space:]]*(unchanged|не меняется)[[:space:]]*—[[:space:]]*\S' "$plan" 2>/dev/null; then
58
62
  exit 0
59
63
  fi
60
64
 
61
- # Договорённость называется одним из двух видов. Первый — отдельный документ в каталоге
62
- # «предложено»: он переезжает в спек домена, когда работа закрывается. Второй — сам спек домена:
63
- # дерево, у которого отдельного каталога нет, пишет договорённость прямо в него, и переезжать там
64
- # нечему — черновик совпадает со спеком с первого дня. Требовать один вид значит навязывать способ
65
- # записи договорённостей вместе с проверкой того, что работа идёт по замыслу: дерево со вторым
66
- # способом отказывается от гарда целиком и остаётся без единственной машинной проверки под правило.
67
- draft="$(sed -n 's/^\*\*Драфт:\*\*[[:space:]]*`\([^`]*\)`.*/\1/p' "$plan" 2>/dev/null | head -1)"
68
- [ -z "$draft" ] && draft="$(sed -n 's/^\*\*Спек:\*\*[[:space:]]*`\([^`]*\)`.*/\1/p' "$plan" 2>/dev/null | head -1)"
65
+ # The agreement is named in one of two forms. The first is a separate document in the "proposed"
66
+ # directory: it moves into the domain spec when the work closes. The second is the domain spec
67
+ # itself: a tree without a separate directory writes the agreement straight into it, and there is
68
+ # nothing to move — the draft matches the spec from day one. Demanding one form would impose the
69
+ # way agreements are written along with the check that the work follows the plan: a tree with
70
+ # the second way drops the guard entirely and is left without the only machine check under the
71
+ # rule.
72
+ draft="$(sed -nE 's/^\*\*(Draft|Драфт):\*\*[[:space:]]*`([^`]*)`.*/\2/p' "$plan" 2>/dev/null | head -1)"
73
+ [ -z "$draft" ] && draft="$(sed -nE 's/^\*\*(Spec|Спек):\*\*[[:space:]]*`([^`]*)`.*/\2/p' "$plan" 2>/dev/null | head -1)"
69
74
 
70
75
  if [ -z "$draft" ]; then
71
- deny "BLOCKED by task-flow: в '${tasks_dir}/${branch}/plan.md' не названа договорённость о продукте. Назови её одной из двух строк: '**Драфт:** \`путь\`' — отдельный документ в docs/specs/<домен>/proposed/<фича>/, либо '**Спек:** \`путь\`' — спек домена, в который договорённость пишется прямо. Правило — скил task-flow." \
72
- "строка '**Поведение:** не меняется — <причина владельца>' в замысле; пустая причина не принимается"
76
+ deny "BLOCKED by task-flow: no product agreement is named in '${tasks_dir}/${branch}/plan.md'. Name it by one of two lines: '**Draft:** \`path\`' — a separate document in docs/specs/<domain>/proposed/<feature>/, or '**Spec:** \`path\`' — the domain spec the agreement is written into directly. The rule is task-flow." \
77
+ "the line '**Behaviour:** unchanged — <the owner reason>' in the plan; an empty reason is not accepted"
73
78
  fi
74
79
 
75
80
  case "$draft" in
@@ -81,22 +86,24 @@ if [ -e "$draft_path" ]; then
81
86
  exit 0
82
87
  fi
83
88
 
84
- # Договорённость, влитая в спек домена, с диска уходит — так и задумано: в главной ветке
85
- # директории «предложено» быть не должно. Но замысел на неё ссылается до конца работы, и без
86
- # этой развилки последний коммит PR запирал бы ветку: ни правки по замечаниям разбора, ни
87
- # записи в журнал изменений после вливания уже не сделать.
89
+ # An agreement merged into the domain spec leaves the disk — by design: the main branch must not
90
+ # hold a "proposed" directory. But the plan refers to it until the work ends, and without this
91
+ # branch the last commit of the PR would lock the branch: neither edits after review remarks nor
92
+ # a changelog entry could be made after the merge.
88
93
  #
89
- # Влитое от незаведённого отличает история ветки: путь, которого в ней никогда не было,
90
- # договорённостью не был. Спросить об этом нечем, кроме git, поэтому нет git — отказ остаётся.
94
+ # The branch history tells a merged agreement from one never created: a path that was never in
95
+ # it was never an agreement. There is nothing to ask about this but git, so no git — the refusal
96
+ # stays.
91
97
  if git -C "$root" log --oneline -1 -- "$draft" 2>/dev/null | grep -q .; then
92
98
  exit 0
93
99
  fi
94
100
 
95
- # Вливание бывает и первым коммитом, который вообще завёл названный путь: черновик писали, не
96
- # коммитя, а в историю уехал уже спек домена. Тогда истории у пути нет, а работа сделана ровно
97
- # так, как велит паттерн закрытия, — и отказ запирал бы ветку на последнем шаге. Признак:
98
- # договорённость названа путём вида `<домен>/proposed/<фича>`, каталог домена в дереве есть, и
99
- # имя фичи в нём встречается. Пока такого спека нет, отказ остаётся прежним.
101
+ # The merge may also be the first commit that created the named path at all: the draft was
102
+ # written without committing, and what went into history was already the domain spec. Then the
103
+ # path has no history, and the work was done exactly as the close pattern says — and the refusal
104
+ # would lock the branch at the last step. The sign: the agreement is named by a path of the form
105
+ # `<domain>/proposed/<feature>`, the domain directory exists in the tree, and the feature name
106
+ # occurs in it. While there is no such spec, the refusal stays as it was.
100
107
  case "$draft" in
101
108
  */proposed/*)
102
109
  domain_dir="${draft%%/proposed/*}"
@@ -109,4 +116,4 @@ case "$draft" in
109
116
  ;;
110
117
  esac
111
118
 
112
- deny "BLOCKED by task-flow: замысел называет договорённость '${draft}', а её на диске нет и в истории ветки не было. Заведи её с образца (docs/specs/_template) или поправь путь в '${tasks_dir}/${branch}/plan.md'. Правило — скил task-flow."
119
+ deny "BLOCKED by task-flow: the plan names the agreement '${draft}', and it is neither on disk nor in the history of the branch. Create it from the sample (docs/specs/_template) or fix the path in '${tasks_dir}/${branch}/plan.md'. The rule is task-flow."