@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,33 +1,37 @@
1
1
  #!/usr/bin/env bash
2
2
  # rt-hook: PreCompact .*
3
- # Требует: hooks/profile-check.sh
4
- # Передача захода пишется перед сжатием контекста, а не рукой исполнителя.
3
+ # Requires: hooks/profile-check.sh
4
+ # The session handover is written before the context is compacted, not by the hand of the executor.
5
5
  #
6
- # Заход кончается двумя способами: исполнитель доводит работу до точки и пишет передачу сам —
7
- # либо контекст переполняется, и сжатие приходит от инструмента. Второй случай раньше терял
8
- # передачу целиком: писать её в этот момент уже некому, а после сжатия пересказывать нечего.
9
- # Ночью, когда напомнить некому, так кончается каждый заход.
6
+ # A session ends in two ways: the executor brings the work to a point and writes the handover
7
+ # himself — or the context overflows and the compaction comes from the tool. The second case used to
8
+ # lose the handover entirely: at that moment there is nobody left to write it, and after the
9
+ # compaction there is nothing to retell. At night, when there is nobody to remind, every session
10
+ # ends that way.
10
11
  #
11
- # Хук собирает передачу из того, что лежит на диске: ход работы даёт состояние и следующий шаг,
12
- # дерево — ветку, незакоммиченное и коммиты сверх главной. Ничего от себя он не добавляет:
13
- # передача пересказывает записанное, а не заменяет его.
12
+ # The hook assembles the handover from what lies on disk: the progress gives the state and the next
13
+ # step, the tree gives the branch, the uncommitted and the commits over the main one. It adds
14
+ # nothing of its own: a handover retells what is written down, it does not replace it.
14
15
  #
15
- # Кладётся она разделом в ход работы задачи — туда же, где лежит состояние. Свой файл вне дерева
16
- # передачу теряет при переходе на другую машину: каталог закрыт от истории, и работу, оборванную
17
- # заполнением окна, оттуда не подхватить — состояние есть в ходе работы, а особенности захода,
18
- # следующий шаг и то, чего делать не надо, остаются на прежней машине. Второй записи об одном и
19
- # том же при этом не заводится: раздел живёт в том же файле, что и «Где стоим», и уезжает в
20
- # ветку тем же коммитом. Коммитит его исполнитель — хук не знает, что ещё лежит в индексе.
16
+ # It is put as a section into the progress of the task — where the state lies too. A file of its own
17
+ # outside the tree loses the handover on a move to another machine: the directory is closed off from
18
+ # the history, and work broken off by a filled window cannot be picked up from there — the state is
19
+ # in the progress, while the particulars of the session, the next step and what must not be done
20
+ # stay on the previous machine. No second record about one and the same thing appears: the section
21
+ # lives in the same file as "Where we stand" and travels into the branch with the same commit. The
22
+ # executor commits it — the hook does not know what else lies in the index.
21
23
  #
22
- # Файл вне дерева остаётся запасным путём: у работы без папки задачи — на отсоединённой голове,
23
- # на ветке без заведённой задачи — разделу лечь некуда, а молчание здесь стоит захода целиком.
24
+ # A file outside the tree stays the fallback path: for work without a task folder — on a detached
25
+ # head, on a branch without a created task — there is nowhere for the section to lie, while silence
26
+ # here costs a whole session.
24
27
  #
25
- # Написанное руками не затирается молча: файл один, и последняя запись побеждает. Исполнитель,
26
- # закрывающий заход по правилу, пишет поверх — его передача полнее, потому что он знает то,
27
- # чего на диске нет.
28
+ # What is written by hand is not overwritten silently: there is one file, and the last write wins.
29
+ # An executor who closes the session by the rule writes over it — his handover is fuller, because he
30
+ # knows what is not on disk.
28
31
  #
29
- # FAIL-OPEN: нет разборщика, пустой ввод, не репозиторий, нет каталога передачи — хук выходит
30
- # нулём и молчит. Сжатие он не отбивает никогда: остановленное сжатие оставит заход без места.
32
+ # FAIL-OPEN: no parser, empty input, not a repository, no handover directory — the hook exits with
33
+ # zero and stays silent. It never refuses the compaction: a stopped compaction leaves the session
34
+ # without room.
31
35
 
32
36
  . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
33
37
  . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
@@ -50,9 +54,10 @@ workdir="$(rt_hook_cwd)"
50
54
  cd "$workdir" 2>/dev/null || exit 0
51
55
  git rev-parse --is-inside-work-tree >/dev/null 2>&1 || exit 0
52
56
 
53
- # Пустое имя ветки хук не останавливает. На отсоединённой голове имени нет, а всё, что едет в
54
- # передачу, лежит в дереве и доступно целиком: имя нужно только файлу. Прежний выход нулём был
55
- # полным молчанием — сжатие приходило без передачи, и заход после него начинал с пустого места.
57
+ # An empty branch name does not stop the hook. On a detached head there is no name, and everything
58
+ # that goes into the handover lies in the tree and is available in full: the name is needed only by
59
+ # the file. The former exit with zero was complete silence — the compaction came without a handover,
60
+ # and the session after it started from an empty place.
56
61
  branch="$(git branch --show-current 2>/dev/null)"
57
62
  head_name=""
58
63
  if [ -z "$branch" ]; then
@@ -70,93 +75,95 @@ tasks_dir="${RT_TASKS_DIR:-docs/tasks}"
70
75
  mkdir -p "$root/$handoff_dir" 2>/dev/null || exit 0
71
76
  [ -d "$root/$handoff_dir" ] || exit 0
72
77
 
73
- # Ручное сжатие от автоматического отличается одним: при ручном исполнитель у клавиатуры и
74
- # может дописать передачу сам. Пишется она в обоих случаях — заход, сжатый руками, теряет
75
- # контекст ровно так же.
78
+ # Manual compaction differs from automatic in one thing: at a manual one the executor is at the
79
+ # keyboard and can add to the handover himself. It is written in both cases — a session compacted by
80
+ # hand loses the context in exactly the same way.
76
81
  trigger="$(printf '%s' "$input" | jq -r '.trigger // "auto"' 2>/dev/null)"
77
82
  [ -z "$trigger" ] && trigger='auto'
78
83
 
79
- # Файл передачи ищут по имени ветки; голове без имени он называется её коротким снимком.
84
+ # The handover file is looked for by the branch name; for a head without a name it is named by its
85
+ # short snapshot.
80
86
  handoff_name="$branch"
81
87
  [ -z "$handoff_name" ] && handoff_name="$head_name"
82
88
 
83
89
  progress=""
84
90
  [ -n "$branch" ] && progress="$root/$tasks_dir/$branch/progress.md"
85
91
 
86
- # Строка раздела «Где стоим» по её названию. Пусто — работа идёт вне папки задачи, и выдумывать
87
- # за неё состояние нельзя: в передаче тогда стоит то, что известно дереву.
92
+ # A line of the "Where we stand" section by its name. Empty — the work goes outside a task folder,
93
+ # and the state must not be invented for it: the handover then holds what the tree knows.
88
94
  line_of() {
89
95
  [ -f "$progress" ] || return 0
90
- sed -n "s/^[[:space:]]*[-*][[:space:]]*\*\*$1:\*\*[[:space:]]*\(.*\)/\1/p" "$progress" 2>/dev/null | head -1
96
+ sed -nE "s/^[[:space:]]*[-*][[:space:]]*\*\*($1):\*\*[[:space:]]*(.*)/\2/p" "$progress" 2>/dev/null | head -1
91
97
  }
92
98
 
93
- state="$(line_of 'Состояние')"
94
- stage="$(line_of 'Этап')"
95
- next_step="$(line_of 'Следующий шаг')"
99
+ state="$(line_of 'State|Состояние')"
100
+ stage="$(line_of 'Stage|Этап')"
101
+ next_step="$(line_of 'Next step|Следующий шаг')"
96
102
  pull="$(line_of 'PR')"
97
103
 
98
104
  uncommitted="$(git status --short 2>/dev/null | head -20)"
99
- [ -z "$uncommitted" ] && uncommitted='нет'
105
+ [ -z "$uncommitted" ] && uncommitted='none'
100
106
 
101
107
  ahead="$(git log --oneline origin/main..HEAD 2>/dev/null | head -20)"
102
- [ -z "$ahead" ] && ahead='нет коммитов сверх главной'
108
+ [ -z "$ahead" ] && ahead='no commits over the main branch'
103
109
 
104
110
  target="$root/$handoff_dir/$handoff_name.md"
105
111
 
106
- # Заголовок раздела в ходе работы: по нему прежняя передача и находится.
107
- section='## Передача захода'
112
+ # The heading of the section in the progress: the previous handover is found by it.
113
+ section='## Handover of the session'
108
114
 
109
- # Собирается передача во временный файл: и раздел, и запасной путь пишут одно и то же, и второй
110
- # сборки для второго места не заводится.
115
+ # The handover is assembled into a temporary file: the section and the fallback path write one and
116
+ # the same thing, and no second assembly is made for the second place.
111
117
  scratch="$(mktemp 2>/dev/null)" || exit 0
112
118
 
113
119
  {
114
- printf 'Собрана хуком перед сжатием контекста (%s).\n\n' "$trigger"
115
- printf '**Рабочее дерево:** %s\n' "$root"
120
+ printf 'Put together by a hook before the compaction of the context (%s).\n\n' "$trigger"
121
+ printf '**Working tree:** %s\n' "$root"
116
122
  if [ -n "$branch" ]; then
117
- printf '**Ветка:** %s\n\n' "$branch"
123
+ printf '**Branch:** %s\n\n' "$branch"
118
124
  else
119
- printf '**Ветка:** имени нет — отсоединённая голова %s\n\n' "$head_name"
125
+ printf '**Branch:** no name — a detached head %s\n\n' "$head_name"
120
126
  fi
121
127
 
122
128
  if [ -n "$state" ]; then
123
- printf '### Где стоим на минуту сжатия\n\n'
124
- printf -- '- **Состояние:** %s\n' "$state"
125
- [ -n "$stage" ] && printf -- '- **Этап:** %s\n' "$stage"
126
- [ -n "$next_step" ] && printf -- '- **Следующий шаг:** %s\n' "$next_step"
129
+ printf '### Where we stand at the minute of the compaction\n\n'
130
+ printf -- '- **State:** %s\n' "$state"
131
+ [ -n "$stage" ] && printf -- '- **Stage:** %s\n' "$stage"
132
+ [ -n "$next_step" ] && printf -- '- **Next step:** %s\n' "$next_step"
127
133
  [ -n "$pull" ] && printf -- '- **PR:** %s\n' "$pull"
128
- printf '\nХод работы целиком — `%s/%s/progress.md`; замысел рядом с ним.\n\n' "$tasks_dir" "$branch"
134
+ printf '\nThe progress in full — `%s/%s/progress.md`; the plan lies next to it.\n\n' "$tasks_dir" "$branch"
129
135
  elif [ -z "$branch" ]; then
130
- printf '### Где стоим на минуту сжатия\n\nИмени у головы нет, папки задачи при ней тоже: состояние работы взять неоткуда. Читающая сторона ищет передачу по имени ветки, а не найдя его — по последней записи каталога.\n\n'
136
+ printf '### Where we stand at the minute of the compaction\n\nThe head has no name and no task folder next to it: there is nowhere to take the state of the work from. The reading side looks for the handover by the branch name, and failing that — by the last record of the directory.\n\n'
131
137
  else
132
- printf '### Где стоим на минуту сжатия\n\nПапки задачи у этой ветки нет: состояние работы взять неоткуда.\n\n'
138
+ printf '### Where we stand at the minute of the compaction\n\nThis branch has no task folder: there is nowhere to take the state of the work from.\n\n'
133
139
  fi
134
140
 
135
- printf '### Незакоммиченное\n\n```\n%s\n```\n\n' "$uncommitted"
136
- printf '### Коммиты сверх главной\n\n```\n%s\n```\n\n' "$ahead"
137
- printf 'Написана хуком перед сжатием контекста. Всё, что здесь стоит, проверяется деревом:\n'
138
- printf 'передача пересказывает записанное и описывает минуту, когда её собрали.\n'
141
+ printf '### Uncommitted\n\n```\n%s\n```\n\n' "$uncommitted"
142
+ printf '### Commits over the main branch\n\n```\n%s\n```\n\n' "$ahead"
143
+ printf 'Written by a hook before the compaction of the context. Everything standing here is checked\n'
144
+ printf 'against the tree: a handover retells what was written and describes the minute it was put together.\n'
139
145
  } > "$scratch" 2>/dev/null
140
146
 
141
147
  [ -s "$scratch" ] || exit 0
142
148
 
143
- # Есть ход работы — передача ложится его разделом, и прежний такой раздел заменяется целиком:
144
- # дописанный вторым, он оставил бы в одном файле две правды об одной работе.
149
+ # There is a progress — the handover lies as its section, and a previous section of that kind is
150
+ # replaced entirely: appended as a second one, it would leave two truths about one work in one file.
145
151
  if [ -n "$progress" ] && [ -f "$progress" ]; then
146
152
  kept="$scratch.kept"
147
- # Сравнение идёт байтами. Под локалью с национальными настройками `awk` этой системы считает
148
- # разные кириллические строки равными — «## Где стоим» совпадало с «## Передача захода», — и
149
- # выемка прежнего раздела сносила состояние работы вместе с ним. Виден промах только там, где
150
- # локаль объявлена: у исполнителя с `C.UTF-8` набор зелёный, на прогоне конвейера — красный.
151
- LC_ALL=C awk -v mark="$section" '
152
- $0 == mark { skip = 1; next }
153
- skip && /^## / && $0 != mark { skip = 0 }
153
+ # The comparison goes by bytes. Under a locale with national settings the `awk` of this system
154
+ # counts different Cyrillic strings equal — the heading of "Where we stand" matched the heading
155
+ # of the handover section — and cutting out the previous section removed the work state along
156
+ # with it. The miss is visible only where the locale is declared: for an executor with `C.UTF-8`
157
+ # the suite is green, on the pipeline run — red.
158
+ LC_ALL=C awk -v mark="$section" -v old='## Передача захода' '
159
+ $0 == mark || $0 == old { skip = 1; next }
160
+ skip && /^## / && $0 != mark && $0 != old { skip = 0 }
154
161
  !skip { print }
155
162
  ' "$progress" > "$kept" 2>/dev/null || { rm -f "$scratch" "$kept"; exit 0; }
156
163
 
157
164
  {
158
- # Хвостовые пустые строки прежнего текста снимаются: раздел приписывается к нему через
159
- # одну пустую строку, а не через сколько их там осталось.
165
+ # The trailing blank lines of the previous text are removed: the section is appended to it
166
+ # through one blank line, not through however many were left there.
160
167
  awk 'BEGIN { blanks = 0 }
161
168
  { if ($0 ~ /^[[:space:]]*$/) { blanks++; next }
162
169
  while (blanks > 0) { print ""; blanks-- }
@@ -1,26 +1,29 @@
1
1
  #!/usr/bin/env bash
2
- # Общее чтение ввода хука. НЕ гард: объявления `rt-hook:` у него нет, к событиям агента он не
3
- # подключается. Его источают сами гарды — тем же приёмом, каким они источают общий хвост отказа.
2
+ # Shared reading of the hook input. NOT a guard: it has no `rt-hook:` declaration and does not
3
+ # subscribe to the agent events. The guards source it themselves — by the same technique they source
4
+ # the shared refusal tail.
4
5
  #
5
- # Зачем он есть. Ввод приходит одним объектом, и каждому гарду из него нужны те же поля: имя
6
- # инструмента, командная строка, путь правки, рабочий каталог. Пока каждый доставал их сам, один
7
- # вызов агента стоил больше сотни разборов одного и того же текста — по шесть-семь на гард,
8
- # восемнадцать гардов на событие. Разбор стоит шесть миллисекунд, запуск оболочки — пять.
6
+ # Why it exists. The input arrives as one object, and every guard needs the same fields from it: the
7
+ # tool name, the command line, the edit path, the working directory. While each of them pulled these
8
+ # out on its own, one agent call cost more than a hundred parses of one and the same text — six or
9
+ # seven per guard, eighteen guards per event. A parse costs six milliseconds, a shell start — five.
9
10
  #
10
- # Как это работает. Диспетчер разбирает ввод однажды и кладёт поля в окружение. Гард спрашивает
11
- # их отсюда: есть в окружении — берёт готовое, нет — разбирает сам. Второе — это прямой вызов:
12
- # так гарды зовут наборы сценариев, и работать они обязаны и без диспетчера.
11
+ # How it works. The dispatcher parses the input once and puts the fields into the environment. The
12
+ # guard asks for them here: present in the environment — it takes what is ready, absent — it parses
13
+ # itself. The second is the direct call: that is how the guards are called by the scenario suites,
14
+ # and they must work without the dispatcher too.
13
15
  #
14
- # ПОЧЕМУ ЧТЕНИЕ ПОТОКА — ОТДЕЛЬНАЯ КОМАНДА, А НЕ ЗНАЧЕНИЕ. Подстановка команд исполняется в
15
- # подоболочке, и всё, что она запомнила, умирает вместе с ней: первый вызов вычитал бы поток, а
16
- # второй получил бы пустоту — и гард пропустил бы вызов, который обязан был отбить. Поэтому поток
17
- # читается командой `rt_hook_read`, кладущей ввод в переменную текущей оболочки, а не функцией,
18
- # возвращающей его через подстановку.
16
+ # WHY READING THE STREAM IS A SEPARATE COMMAND AND NOT A VALUE. Command substitution runs in a
17
+ # subshell, and everything it remembered dies with it: the first call would read the stream out, and
18
+ # the second would get emptiness — and the guard would let through a call it was obliged to refuse.
19
+ # So the stream is read by the command `rt_hook_read`, which puts the input into a variable of the
20
+ # current shell, not by a function that returns it through substitution.
19
21
  #
20
- # ОТКАЗ В ПОЛЬЗУ РАБОТЫ: нет разборщика, битый ввод, пустое поле — пустая строка. Сломанное
21
- # чтение не имеет права заклинить работу: гард на пустом поле выходит нулём.
22
+ # FAIL-OPEN, IN FAVOUR OF WORK: no parser, broken input, an empty field — an empty string. Broken
23
+ # reading has no right to jam the work: on an empty field the guard exits with zero.
22
24
 
23
- # Читает ввод в `RT_HOOK_INPUT`, если его там ещё нет. Зовётся командой, а не подстановкой.
25
+ # Reads the input into `RT_HOOK_INPUT`, if it is not there yet. Called as a command, not as a
26
+ # substitution.
24
27
  rt_hook_read() {
25
28
  [ -n "${RT_HOOK_INPUT:-}" ] && return 0
26
29
 
@@ -29,15 +32,17 @@ rt_hook_read() {
29
32
  return 0
30
33
  }
31
34
 
32
- # Поле ввода по имени переменной и пути в объекте: `rt_hook_field RT_HOOK_TOOL '.tool_name'`.
33
- # Переменная окружения главнее разбора — её кладёт диспетчер, разобравший ввод один раз.
35
+ # An input field by variable name and path in the object: `rt_hook_field RT_HOOK_TOOL '.tool_name'`.
36
+ # The environment variable outranks parsing — it is put there by the dispatcher, which parsed the
37
+ # input once.
34
38
  rt_hook_field() {
35
39
  local name="$1" path="$2"
36
40
 
37
- # Готовому верят только по признаку разбора, а не по тому, что переменная объявлена. Пустая
38
- # переменная в окружении означает «поля нет», и без признака она неотличима от «поле есть и
39
- # оно пустое»: гард переставал разбирать ввод и пропускал вызовы, которые обязан был отбить.
40
- # Наборы поймали это шестнадцатью провалами — окружение прогона несло пустые значения.
41
+ # What is ready is trusted only by the sign of parsing, not by the fact that the variable is
42
+ # declared. An empty variable in the environment means "there is no field", and without the sign
43
+ # it is indistinguishable from "the field is there and it is empty": the guard stopped parsing
44
+ # the input and let through calls it was obliged to refuse. The suites caught this with sixteen
45
+ # failures — the run environment carried empty values.
41
46
  if [ "${RT_HOOK_PARSED:-}" = '1' ] && [ -n "${!name+x}" ]; then
42
47
  printf '%s' "${!name}"
43
48
  return 0
@@ -47,44 +52,59 @@ rt_hook_field() {
47
52
  printf '%s' "$RT_HOOK_INPUT" | jq -r "${path} // empty" 2>/dev/null
48
53
  }
49
54
 
50
- # НАЧАЛО ВЫЗОВА В КОМАНДНОЙ СТРОКЕ. Приставка образца, которым гард узнаёт свой вызов: команда
51
- # стоит в начале строки, за разделителем — и после любого числа присваиваний переменных
52
- # окружения перед её именем.
55
+ # THE START OF A CALL IN THE COMMAND LINE. The prefix of the pattern by which a guard recognises its
56
+ # own call: the command stands at the start of the line, after a separator — and after any number of
57
+ # environment variable assignments before its name.
53
58
  #
54
- # Присваивания входят сюда потому, что вызов с ними — обычная форма, и часть набора требует её
55
- # прямо: личность вызова, открывающего заявку, видна из команды только явной подстановкой
56
- # токена. Признак, не знавший о присваиваниях, на этой форме слепнул молча — он не отказывал и
57
- # не предупреждал, он не считал вызов вызовом, и весь предмет гарда оставался несудимым. Так
58
- # прошли мимо своих гардов пуш, открытие заявки, снятие черновика и слияние: коммит с чужой
59
- # подписью уехал в главную ветку, а запрет на слияние агентом снимался подстановкой токена.
59
+ # Assignments belong here because a call with them is the ordinary form, and part of the suite
60
+ # demands it outright: the identity of the call that opens a PR is visible from the command only by
61
+ # an explicit substitution of the token. A sign that knew nothing of assignments went blind on this
62
+ # form silently — it did not refuse and did not warn, it did not count the call as a call, and the
63
+ # whole subject of the guard stayed unjudged. That is how the push, the opening of a PR, taking off
64
+ # the draft and the merge went past their own guards: a commit with a foreign signature went into
65
+ # the main branch, and the ban on a merge by the agent was lifted by substituting the token.
60
66
  #
61
- # Значение присваивания берётся без пробелов: `ИМЯ="a b"` в кавычках сюда не подпадает, и вызов
62
- # за ним останется несудимым. Пробел внутри значения перед вызовом встречается редко, а
63
- # образец, разбирающий кавычки, ошибается в другую сторону — считает вызовом то, что им не
64
- # является. Признак обязан ошибаться в сторону лишнего срабатывания: гард, не узнавший вызов,
65
- # молчит и выглядит исправным, а сработавший на лишнем виден сразу и правится.
67
+ # The value of an assignment comes in three kinds: without spaces, as a substitution `$( … )` and in
68
+ # quotes. Before, only the first was accepted, while PRs are opened by the command
69
+ # `GH_TOKEN=$(cat <file>) gh pr create …` — the path in the substitution holds a space, and the
70
+ # delivery guard did not check such a command: neither the branch number, nor the body of the PR,
71
+ # nor the taking apart of the task folder. The silence of a guard is indistinguishable from a
72
+ # permission.
66
73
  #
67
- # Само по себе присваивание вызовом не считается: за ним обязано стоять имя команды.
74
+ # A substitution is taken up to the first closing bracket, a quoted string — up to the closing quote
75
+ # of the same kind. Nested brackets and quotes the pattern does not parse: the sign stays a pattern,
76
+ # not a shell parser. The sign must err on the side of firing too often: a guard that did not
77
+ # recognise a call stays silent and looks sound; one that fired an extra time is visible at once and
78
+ # gets fixed.
68
79
  #
69
- # Объявлено это одним местом, а не литералом в каждом гарде: разойдясь, копии чинятся по одной
70
- # и молчат о том, что остальные остались слепыми.
71
- RT_CMD_BOUND='(^|[;&|(]|&&|\|\|)[[:space:]]*([A-Za-z_][A-Za-z0-9_]*=[^[:space:]]*[[:space:]]+)*'
80
+ # An assignment by itself does not count as a call: a command name must stand after it.
81
+ #
82
+ # A directory before the name is the same command. A client whose own name is taken by a shell alias
83
+ # is called by the full path, and a sign that knew only the bare name did not recognise such a call
84
+ # at all: the guard exited with zero, and its silence is indistinguishable from a permission. That
85
+ # is how PRs went out opened not by the machine record. A path part does not cross a space, so it
86
+ # stays inside one word and glues nothing extra to the call.
87
+ #
88
+ # This is declared in a SINGLE place, not as a literal in every guard: having diverged, the copies
89
+ # are fixed one at a time and say nothing about the rest staying blind.
90
+ RT_CMD_BOUND='(^|[;&|(]|&&|\|\|)[[:space:]]*([A-Za-z_][A-Za-z0-9_]*=([^[:space:]]*|\$\([^)]*\)|"[^"]*"|'"'"'[^'"'"']*'"'"')[[:space:]]+)*([^[:space:]]*/)?'
72
91
 
73
- # Поля, которые спрашивают все гарды.
92
+ # The fields that all guards ask for.
74
93
  rt_hook_tool() { rt_hook_field RT_HOOK_TOOL '.tool_name'; }
75
94
  rt_hook_cmd() { rt_hook_field RT_HOOK_CMD '.tool_input.command'; }
76
95
  rt_hook_file() { rt_hook_field RT_HOOK_FILE '.tool_input.file_path'; }
77
96
  rt_hook_cwd() { rt_hook_field RT_HOOK_CWD '.cwd'; }
78
97
 
79
- # ЖДЁТ ПОСЛЕДНИЙ ТЕКСТ ХОДА В ЗАПИСИ. Гарды завершения судят то, что сказано владельцу, а запись
80
- # хода на этот момент бывает неполна: текст ответа ложится в файл не раньше, чем хост позовёт
81
- # хук, и гард читает ход, у которого текста нет вовсе. Молчит он при этом честно — и снаружи
82
- # неотличим от гарда, который посмотрел и пропустил. Ровно так ход, поставивший работу в
83
- # зависимость от слова владельца, ушёл мимо трёх гардов сразу, а тот же ход, поданный им
84
- # повторно, был отбит.
98
+ # WAITS FOR THE LAST TEXT OF THE TURN IN THE RECORD. The guards of the ending judge what was said
99
+ # to the owner, while the record of the turn at that moment happens to be incomplete: the text of
100
+ # the reply lands in the file no earlier than the host calls the hook, and the guard reads a turn
101
+ # that has no text at all. It stays silent honestly — and from the outside it is indistinguishable
102
+ # from a guard that looked and let through. Exactly so a turn that put the work into dependence on
103
+ # the word of the owner went past three guards at once, while the same turn, fed to them a second
104
+ # time, was refused.
85
105
  #
86
- # Ждём короткими попытками: файл дописывается за миллисекунды, а ход и без того кончается не
87
- # мгновенно. Дождались — ноль; текста так и нет — единица, и решает уже гард.
106
+ # We wait in short attempts: the file is written up in milliseconds, and a turn does not end
107
+ # instantly anyway. Waited it out — zero; still no text — one, and the guard decides from there.
88
108
  rt_turn_has_text() {
89
109
  local transcript="$1" tries="${2:-20}" got
90
110