@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,26 +1,28 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Сплошная проверка того, что готовое не обошли.
3
+ * The sweeping check that the ready-made was not bypassed.
4
4
  *
5
- * Гард `reuse-first-guard.sh` судит правку в момент, когда её пишут, и знает только
6
- * добавленный текст. Написанное до него не считает никто: проверка стилей меряет классы,
7
- * линтеры — типы и приёмы, а то, что экран собран нативной кнопкой вместо кнопки кита, не
8
- * видно ни одному из них. Эта проверка отвечает на другой вопрос — «а сколько такого в
9
- * дереве сейчас», — и потому смотрит на файл целиком, а не на правку.
5
+ * The guard `reuse-first-guard.sh` judges an edit at the moment it is written and knows only the
6
+ * added text. What was written before it nobody counts: the styling check measures classes, the
7
+ * linters types and techniques, and that a screen is assembled from a native button instead of the
8
+ * button of the kit is seen by none of them. This check answers another question — «and how much
9
+ * of that is in the tree right now» — and therefore looks at the whole file, not at the edit.
10
10
  *
11
- * Признаки не лежат здесь: они объявлены наборами по пакетам rt-tools, и дерево называет в
12
- * настройке проверок те, что берёт. Тот же список читает гард — расходиться им нельзя, иначе
13
- * правка проходит гард и падает на гейте. Свои признаки дерево дописывает своим файлом.
11
+ * The signs do not lie here: they are declared as bundles per package of rt-tools, and the tree
12
+ * names in the setting of the checks the ones it takes. The same list is read by the guard — they
13
+ * must not diverge, otherwise an edit passes the guard and falls on the gate. Its own signs the
14
+ * tree appends by a file of its own.
14
15
  *
15
- * Отличий от гарда два. Первое: инвентарь кита не читается — гард спрашивает диск, потому что
16
- * отвечает одной правке, а сплошной проверке важно накопленное, и пропавший пакет молча
17
- * обнулял бы сводку. Второе: маркер `native-ok` снимает свою строку и следующую, а не весь файл.
16
+ * There are two differences from the guard. The first: the inventory of the kit is not read — the
17
+ * guard asks the disk because it answers for one edit, while a sweeping check cares about what has
18
+ * piled up, and a missing package would silently zero the digest. The second: the marker
19
+ * `native-ok` takes off its own line and the next one, not the whole file.
18
20
  *
19
- * Накопленное к моменту заведения проверки лежит в tools/reuse-allowlist.json и отказом не
20
- * считается: гейт падает на новом расхождении, а старое остаётся видимым числом в сводке.
21
- * Снимок списка — `node tools/check-reuse.mjs --baseline`.
21
+ * What piled up by the moment the check was started lies in tools/reuse-allowlist.json and does not
22
+ * count as a refusal: the gate falls on a new discrepancy, while the old stays a visible number in
23
+ * the digest. A snapshot of the list — `node tools/check-reuse.mjs --baseline`.
22
24
  *
23
- * Ненулевой код возврата и перечень расхождений.
25
+ * A non-zero exit code and the list of discrepancies.
24
26
  */
25
27
  import { readFileSync, readdirSync } from 'node:fs';
26
28
  import { join } from 'node:path';
@@ -33,15 +35,16 @@ const SOURCE_ROOTS = CONFIG.sourceRoots;
33
35
  const SKIPPED_DIRS = CONFIG.skippedDirs;
34
36
  const BACKEND_ROOTS = CONFIG.backendRoots;
35
37
 
36
- // Нехватка признаков — отказ, а не пустая работа: проверка стоит в гейте пуша, и зелёный ответ
37
- // без единого прочитанного файла неотличим от честного нуля. Отказ печатается строкой, а не
38
- // стеком вызовов: читает его тот, кто настраивает дерево, а не тот, кто правит эту проверку.
38
+ // A shortage of signs is a refusal, not empty work: the check stands in the push gate, and a green
39
+ // answer without a single file read is indistinguishable from an honest zero. The refusal is
40
+ // printed as a line, not as a call stack: it is read by whoever sets up the tree, not by whoever
41
+ // edits this check.
39
42
  let SIGNALS;
40
43
  try {
41
44
  SIGNALS = loadSignals(CONFIG.reuse ?? {}, ROOT);
42
45
  } catch (failure) {
43
46
  console.error(`check-reuse: ${failure.message}`);
44
- console.error('\nПравило единообразия — скил `reuse-first`.');
47
+ console.error('\nThe rule of uniformity is `reuse-first`.');
45
48
  process.exit(1);
46
49
  }
47
50
 
@@ -50,12 +53,13 @@ function count(text, expression) {
50
53
  }
51
54
 
52
55
  /**
53
- * Сколько раз признак виден в тексте.
56
+ * How many times the sign is seen in the text.
54
57
  *
55
- * `strip` вычёркивает предписанный вариант до счёта: у кнопки кита та же подстрока `<button`, и
56
- * без вычёркивания она считалась бы нарушением сама по себе. `all` требует совпадения всех
57
- * образцов разом — так описан хост, растянутый на весь экран. `cancel` гасит признак целиком:
58
- * основа уже унаследована, готовое уже позвано.
58
+ * `strip` crosses out the prescribed variant before the count: the button of the kit has the same
59
+ * substring `<button`, and without the crossing out it would count as a violation by itself. `all`
60
+ * demands a match of every template at once — that is how a host stretched over the whole screen is
61
+ * described. `cancel` puts the sign out whole: the base is already inherited, the ready-made is
62
+ * already called.
59
63
  */
60
64
  function found(signal, text) {
61
65
  const body = signal.strip ? text.replace(new RegExp(signal.strip, 'gs'), '') : text;
@@ -89,17 +93,18 @@ function collectFiles(dir) {
89
93
  return files;
90
94
  }
91
95
 
92
- /** Тесты, storybook и сквозные тесты не судятся: там нативное уместно */
96
+ /** Tests, storybook and end-to-end tests are not judged: the native is fitting there */
93
97
  function judged(path) {
94
98
  return !/\.stories\.(ts|html)$|\.spec\.ts$|\/site-e2e\/|\/admin-e2e\//.test(path);
95
99
  }
96
100
 
97
101
  /**
98
- * Маркер — осознанное отступление, названное автором. Снимается строка, где он стоит, и та, что
99
- * идёт следом: в разметке маркер ставится комментарием над кодом, потому что форматировщик
100
- * разносит длинный тег по строкам и уводит первый атрибут со строки имени тега — признак считает
101
- * имя тега, а маркер оказывается ниже. Дальше следующей строки маркер не достаёт: весь файл он
102
- * не гасит, иначе один разрешённый случай прикрывал бы соседние.
102
+ * The marker is a deliberate deviation named by the author. The line where it stands is taken off,
103
+ * and the one that follows it: in markup the marker is put as a comment above the code, because the
104
+ * formatter spreads a long tag over lines and takes the first attribute off the line of the tag
105
+ * name — the sign counts the tag name, and the marker ends up below. Further than the next line the
106
+ * marker does not reach: it does not put out the whole file, otherwise one allowed case would cover
107
+ * its neighbours.
103
108
  */
104
109
  function withoutMarked(text) {
105
110
  const lines = text.split('\n');
@@ -117,7 +122,11 @@ for (const root of SOURCE_ROOTS) {
117
122
  const text = withoutMarked(readFileSync(join(ROOT, path), 'utf8'));
118
123
  for (const signal of SIGNALS) {
119
124
  const skipped = signal.skipBackendRoots && BACKEND_ROOTS.some((root) => path.startsWith(root));
120
- if (!path.endsWith(signal.ext) || skipped || (signal.onlyNamed && !new RegExp(signal.onlyNamed).test(path))) {
125
+ // `exceptNamed` is the reverse side of `onlyNamed`: a tree that writes the ready-made
126
+ // itself takes the folders of the source of that ready-made out from under the sign,
127
+ // not the bundle whole.
128
+ const excluded = signal.exceptNamed && new RegExp(signal.exceptNamed).test(path);
129
+ if (!path.endsWith(signal.ext) || skipped || excluded || (signal.onlyNamed && !new RegExp(signal.onlyNamed).test(path))) {
121
130
  continue;
122
131
  }
123
132
  const times = found(signal, text);
@@ -137,21 +146,22 @@ if (process.argv.includes('--baseline')) {
137
146
  }
138
147
 
139
148
  const problems = [
140
- // Готовое названо оговоркой намеренно: признак судит тег, а место показа — нет. Замена своего
141
- // абзаца отказа на готовый компонент того же экрана закрывает признак и оставляет нарушение
142
- // на месте — так починили тринадцать шаблонов сразу. Строка вывода — измерение, а не задание.
143
- ...fresh.map((finding) => `${finding.key} — готовое (если место показа верно): ${finding.instead}`),
144
- ...stale.map((key) => `${key}: значится в ${ALLOWLIST}, а в дереве такого расхождения больше нет — строку поправить или убрать`),
149
+ // The ready-made is named with a reservation on purpose: the sign judges the tag, and the place
150
+ // of showing it does not. Replacing one's own paragraph of a refusal with a ready-made component
151
+ // of the same screen closes the sign and leaves the violation in place — thirteen templates were
152
+ // repaired that way at once. The output line is a measurement, not an instruction.
153
+ ...fresh.map((finding) => `${finding.key} — the ready-made (if the place of use is right): ${finding.instead}`),
154
+ ...stale.map((key) => `${key}: listed in ${ALLOWLIST}, and the tree carries no such divergence any more — fix the line or remove it`),
145
155
  ];
146
156
 
147
157
  if (problems.length > 0) {
148
- console.error(`check-reuse: расхождений ${problems.length}\n`);
158
+ console.error(`check-reuse: divergences ${problems.length}\n`);
149
159
  problems.forEach((problem) => console.error(` ${problem}`));
150
- console.error('\nПравило единообразия — скил `reuse-first`.');
160
+ console.error('\nThe rule of uniformity is `reuse-first`.');
151
161
  process.exit(1);
152
162
  }
153
163
 
154
164
  const places = findings.reduce((sum, finding) => sum + Number(finding.key.match(/×(\d+)/)[1]), 0);
155
165
  console.log(
156
- `check-reuse: мест, где готовое обошли, ${places} в ${findings.length} признаках — принято ${findings.length - debt.size}, долг ${debt.size}, новых нет`
166
+ `check-reuse: places where the ready-made was bypassed: ${places} in ${findings.length} signs — accepted ${findings.length - debt.size}, debt ${debt.size}, no new ones`
157
167
  );
@@ -1,22 +1,22 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Проверка того, что миграции и `prisma/schema.prisma` описывают одну и ту же базу.
3
+ * The check that the migrations and `prisma/schema.prisma` describe one and the same database.
4
4
  *
5
- * Расхождение между ними не видит ни линт, ни сборка: оно живёт не в коде, а между
6
- * схемой и SQL. Так в главную ветку уехала миграция, создававшая два индекса,
7
- * которых схема не объявляла, — выкатка упала уже в конвейере.
5
+ * Neither the linter nor the build sees a divergence between them: it lives not in the code but
6
+ * between the schema and the SQL. That is how a migration creating two indexes the schema did not
7
+ * declare went into the main branch — the rollout fell already in the pipeline.
8
8
  *
9
- * Меряются именно миграции, а не база того, кто запускает проверку. База
10
- * разработчика законно несёт след любой недоделанной ветки: одна такая держала
11
- * пуш чужой правки четырьмя таблицами и восемью колонками, которых в схеме
12
- * главной ветки нет, — при том что миграции со схемой сходились.
9
+ * What is measured is the migrations, not the database of whoever runs the check. A developer's
10
+ * database lawfully carries the trace of any unfinished branch: one such held the push of someone
11
+ * else's edit with four tables and eight columns that the schema of the main branch does not
12
+ * have — while the migrations and the schema agreed.
13
13
  *
14
- * Поэтому миграции накатываются на одноразовую теневую базу и сравнивается она.
15
- * Теневая база заводится на каждый прогон и сносится после: оставленная между
16
- * прогонами, она сама накопит след ветки с миграцией, и проверка снова начнёт
17
- * судить о состоянии машины вместо репозитория.
14
+ * So the migrations are applied to a one-off shadow database, and it is that one which is
15
+ * compared. The shadow database is started for every run and torn down after: left between runs,
16
+ * it will itself accumulate the trace of a branch with a migration, and the check will again start
17
+ * judging the state of the machine instead of the repository.
18
18
  *
19
- * Ненулевой код возврата и объяснение расхождения.
19
+ * A non-zero return code and an explanation of the divergence.
20
20
  */
21
21
  import { spawnSync } from 'node:child_process';
22
22
  import { existsSync, readFileSync } from 'node:fs';
@@ -24,16 +24,16 @@ import { join } from 'node:path';
24
24
  import process from 'node:process';
25
25
  import { CONFIG, ROOT } from './rt-kit-checks.config.mjs';
26
26
 
27
- /** Суффикс теневой базы: по нему видно, что сносится именно она, а не чья-то рабочая */
27
+ /** The suffix of the shadow database: by it one sees that it is the shadow being torn down, not somebody's working base */
28
28
  const SHADOW_SUFFIX = '_gate_shadow';
29
29
 
30
30
  /**
31
- * Признаки боевой базы — те же, что у `sql-guard`. Схема на проде меняется только
32
- * выкаткой, и проверка туда не ходит ни читать, ни писать.
31
+ * The signs of the production database — the same as in `sql-guard`. The schema in production
32
+ * changes only by a rollout, and the check goes there neither to read nor to write.
33
33
  */
34
34
  const PRODUCTION_MARKS = CONFIG.productionMarks ?? [];
35
35
 
36
- /** Сервер жив, но базы нет; сервера нет вовсе — оба означают «проверять негде» */
36
+ /** The server is alive but the database is not there; there is no server at all — both mean "nowhere to check" */
37
37
  const SERVER_DOWN_CODES = ['ECONNREFUSED', 'ENOTFOUND', 'EHOSTUNREACH', 'ETIMEDOUT'];
38
38
 
39
39
  function databaseUrl() {
@@ -58,7 +58,7 @@ function databaseUrl() {
58
58
  : '';
59
59
  }
60
60
 
61
- /** Адрес теневой базы и адрес служебной, из которой она заводится и сносится */
61
+ /** The address of the shadow database and the address of the service one it is started and torn down from */
62
62
  function shadowAddresses(url) {
63
63
  const parsed = new URL(url);
64
64
  const name = decodeURIComponent(parsed.pathname.replace(/^\//, ''));
@@ -67,36 +67,38 @@ function shadowAddresses(url) {
67
67
  const shadow = new URL(url);
68
68
  shadow.pathname = `/${encodeURIComponent(shadowName)}`;
69
69
 
70
- // Завести и снести базу можно только из другой базы того же сервера; `postgres`
71
- // есть всегда, а рабочая для этого не годится — снос идёт при живых к ней
72
- // подключениях.
70
+ // A database can be started and torn down only from another database of the same server;
71
+ // `postgres` is always there, and the working one will not do for this — the teardown happens
72
+ // while connections to it are alive.
73
73
  const service = new URL(url);
74
74
  service.pathname = '/postgres';
75
75
 
76
76
  return { shadowName, shadowUrl: shadow.toString(), serviceUrl: service.toString() };
77
77
  }
78
78
 
79
- // Код, которым проверка объявляет, что смотреть было не на что. Прежде каждый такой выход был
80
- // нулём: строка о пропуске уходила в вывод, а в сводке гейта пуша ноль стоял рядом с
81
- // пройденными проверками и ничем от них не отличался — набор читался как проверенный целиком.
82
- // Число знает и гард пуша: он называет пропущенное вслух, не отбивая пуш, потому что проверка,
83
- // которой нечего смотреть, поломкой не является.
79
+ // The code by which the check declares that there was nothing to look at. Formerly every such exit
80
+ // was a zero: the line about the skip went to the output, and in the digest of the push gate the
81
+ // zero stood next to the checks that had passed and differed from them in nothing — the set read
82
+ // as checked in full. The push guard knows the number too: it names what was skipped out loud
83
+ // without refusing the push, because a check with nothing to look at is not a breakage.
84
84
  const SKIP = Number(process.env.RT_SKIP_CODE ?? 7);
85
85
 
86
86
  /**
87
- * Тронула ли ветка хранилище — схему либо каталог миграций.
87
+ * Whether the branch touched the storage — the schema or the migrations directory.
88
88
  *
89
- * Пропуск проверки законен ровно до этой черты. База на машине разработчика бывает погашена
90
- * буднично, и отбивать за это пуш документации не за что; но ветка, правившая миграции, без
91
- * прогона цепочки уезжает в главную вслепую — и падает не у неё, а на выкатке. Так и упал прод:
92
- * пять полей появились в схеме без миграций, часть страниц стала отвечать «не найдено», полчаса
93
- * недоступности, чинили откатом. Гейт при этом был зелёным: проверка вернула код пропуска.
89
+ * Skipping the check is lawful exactly up to this line. A database on a developer's machine is shut
90
+ * down as a matter of routine, and there is nothing in that to refuse a push of documentation for;
91
+ * but a branch that edited the migrations goes into main blind without a run of the chain — and
92
+ * falls not there but at the rollout. That is how production fell: five fields appeared in the
93
+ * schema without migrations, some pages started answering "not found", half an hour of downtime,
94
+ * fixed by a rollback. The gate was green all the while: the check returned the skip code.
94
95
  *
95
- * Смотрятся обе стороны — незакоммиченное в рабочем дереве и вклад ветки от главной. Одного
96
- * вклада мало: правка, ещё не попавшая в коммит, уходит тем же пушем следом.
96
+ * Both sides are looked at — what is uncommitted in the working tree and the branch's contribution
97
+ * from main. The contribution alone is not enough: an edit that has not reached a commit yet goes
98
+ * out with the same push right after.
97
99
  *
98
- * ОТКАЗ В ПОЛЬЗУ РАБОТЫ: нет git, нет главной ветки, вызов упал — считается, что не тронула.
99
- * Проверка, отбивающая пуш по своей слепоте, хуже пропуска: чинить в ней нечего.
100
+ * FAIL-OPEN: no git, no main branch, the call fell — it counts as not touched. A check that refuses
101
+ * a push out of its own blindness is worse than a skip: there is nothing in it to fix.
100
102
  */
101
103
  function touchedStorage() {
102
104
  const paths = [CONFIG.schemaFile, CONFIG.migrationsDir].filter(Boolean);
@@ -110,8 +112,8 @@ function touchedStorage() {
110
112
  return out.status === 0 ? (out.stdout ?? '') : '';
111
113
  };
112
114
 
113
- // Главная ветка берётся удалённой ссылкой: локальная — снимок последнего подтягивания, и
114
- // вклад, посчитанный от неё, врёт ровно в ту сторону, где проверка молчит.
115
+ // The main branch is taken by the remote ref: the local one is a snapshot of the last pull, and
116
+ // a contribution counted from it lies exactly in the direction where the check stays silent.
115
117
  const main = CONFIG.mainBranch ?? 'main';
116
118
  const base = [`origin/${main}`, main].find((ref) => git(['rev-parse', '--verify', '--quiet', ref]).trim()) ?? '';
117
119
 
@@ -129,18 +131,18 @@ function prisma(args, url) {
129
131
  }
130
132
 
131
133
  async function withServiceClient(serviceUrl, run) {
132
- // Клиент базы подтягивается на месте, а не импортом сверху: дерево без хранилища этого
133
- // пакета в зависимостях не держит, и статический импорт ронял бы проверку до того, как она
134
- // успеет сказать, что сверять здесь нечего.
134
+ // The database client is pulled in on the spot, not by an import at the top: a tree without
135
+ // storage does not keep this package in its dependencies, and a static import would drop the
136
+ // check before it managed to say that there is nothing here to audit.
135
137
  const pg = (await import('pg')).default;
136
138
  const client = new pg.Client({ connectionString: serviceUrl });
137
139
  try {
138
140
  await client.connect();
139
141
  } catch (error) {
140
- // Погашенный докер — обычное состояние машины, а не повод не дать запушить
141
- // документацию.
142
+ // Docker shut down is an ordinary state of the machine, not a reason to keep documentation
143
+ // from being pushed.
142
144
  if (SERVER_DOWN_CODES.includes(error?.code)) {
143
- return unavailable('база недоступна');
145
+ return unavailable('the database is unavailable');
144
146
  }
145
147
  throw error;
146
148
  }
@@ -153,54 +155,56 @@ async function withServiceClient(serviceUrl, run) {
153
155
  }
154
156
 
155
157
  /**
156
- * Ответ на «проверять негде»: пропуск либо отказ — смотря тронула ли ветка хранилище.
158
+ * The answer to "nowhere to check": a skip or a refusal — depending on whether the branch touched
159
+ * the storage.
157
160
  *
158
- * Отказ называет, чем поднять базу. Сказанное только «негде» исполнитель читает как разрешение:
159
- * поднимать её он не обязан, а гейт зелёный.
161
+ * The refusal names what to raise the database with. "Nowhere" said on its own the executor reads
162
+ * as a permission: raising it is not his duty, and the gate is green.
160
163
  */
161
164
  function unavailable(why) {
162
165
  if (!touchedStorage()) {
163
- console.log(`check-schema-drift: ${why} — сверять негде`);
166
+ console.log(`check-schema-drift: ${why} — there is nowhere to check`);
164
167
 
165
168
  return SKIP;
166
169
  }
167
170
 
168
- console.error(`check-schema-drift: ${why}, а ветка правила схему или миграции — сверять негде, но было чем\n`);
171
+ console.error(`check-schema-drift: ${why}, and the branch edited the schema or the migrations — there is nowhere to check, though there was something to check\n`);
169
172
  console.error(
170
- 'Цепочка миграций на пустом хранилище — единственное место, где виден их настоящий порядок:\n' +
171
- 'метку времени ставит момент создания, и миграция из ветки, начатой раньше, встаёт перед той,\n' +
172
- 'от которой зависит. На развёрнутом хранилище разработчика она ложится, на чистом падает — и\n' +
173
- 'видно это в первый раз на выкатке.\n\n' +
174
- 'Подними базу и повтори; когда её под рукой нет, цепочка гоняется на одноразовом контейнере —\n' +
175
- 'готовые команды в паттерне `git-workflow-migration`.'
173
+ 'The chain of migrations on an empty storage is the only place where their true order shows:\n' +
174
+ 'the timestamp is set by the minute of creation, and a migration from a branch started earlier\n' +
175
+ 'stands before the one it depends on. On the deployed storage of a developer it applies, on a\n' +
176
+ 'clean one it fails — and that shows for the first time at the rollout.\n\n' +
177
+ 'Raise the database and repeat; when it is not at hand, the chain runs on a one-off container —\n' +
178
+ 'the ready-made commands are in the pattern `git-workflow-migration`.'
176
179
  );
177
180
 
178
181
  return 1;
179
182
  }
180
183
 
181
184
  async function main() {
182
- // Незаданное имя спрашивается отдельно от несуществующего файла. Склеенное с корнем, пустое
183
- // имя даёт сам корень — а он есть всегда, и проверка шла дальше, будто схема на месте.
184
- // Дерево без хранилища так и говорит: имени нет, сверять нечего.
185
+ // A name that is not set is asked about separately from a file that does not exist. Glued to
186
+ // the root, an empty name gives the root itself — and the root is always there, so the check
187
+ // went on as if the schema were in place. A tree without storage says just that: there is no
188
+ // name, there is nothing to audit.
185
189
  if (!CONFIG.schemaFile) {
186
- console.log('check-schema-drift: имя файла схемы не задано — сверять нечего');
190
+ console.log('check-schema-drift: the schema file name is not set — there is nothing to check');
187
191
 
188
192
  return SKIP;
189
193
  }
190
194
 
191
195
  if (!existsSync(join(ROOT, CONFIG.schemaFile))) {
192
- console.log('check-schema-drift: схемы нет — сверять нечего');
196
+ console.log('check-schema-drift: there is no schema — there is nothing to check');
193
197
 
194
198
  return SKIP;
195
199
  }
196
200
 
197
201
  const url = databaseUrl();
198
202
  if (!url) {
199
- return unavailable('адрес базы не задан');
203
+ return unavailable('the database address is not set');
200
204
  }
201
205
 
202
206
  if (PRODUCTION_MARKS.some((mark) => url.includes(mark))) {
203
- console.log('check-schema-drift: адрес боевой — проверка туда не ходит');
207
+ console.log('check-schema-drift: the address is production — the check does not go there');
204
208
 
205
209
  return SKIP;
206
210
  }
@@ -208,46 +212,46 @@ async function main() {
208
212
  const { shadowName, shadowUrl, serviceUrl } = shadowAddresses(url);
209
213
 
210
214
  return withServiceClient(serviceUrl, async (client) => {
211
- // Идентификатор в кавычках: имя базы выведено из адреса, а не из текста запроса
215
+ // The identifier is quoted: the database name comes from the address, not from the text of the query
212
216
  const quoted = `"${shadowName.replace(/"/g, '""')}"`;
213
217
  await client.query(`DROP DATABASE IF EXISTS ${quoted}`);
214
218
 
215
219
  try {
216
- // Базу заводит сам `migrate deploy`: своей команды создания не нужно
220
+ // `migrate deploy` starts the database itself: no creation command of our own is needed
217
221
  const deploy = prisma(['migrate', 'deploy'], shadowUrl);
218
222
  if (deploy.status !== 0) {
219
- console.error('check-schema-drift: миграции не накатываются на чистую базу\n');
223
+ console.error('check-schema-drift: the migrations do not apply to a clean database\n');
220
224
  console.error(`${deploy.stdout ?? ''}${deploy.stderr ?? ''}`);
221
225
 
222
226
  return 1;
223
227
  }
224
228
 
225
- // `--exit-code`: 0 — расхождений нет, 2 — есть, прочее — сбой самой команды
229
+ // `--exit-code`: 0 — no divergences, 2 — there are some, anything else — a failure of the command itself
226
230
  const diff = prisma(
227
231
  ['migrate', 'diff', '--from-config-datasource', '--to-schema', CONFIG.schemaFile, '--exit-code'],
228
232
  shadowUrl
229
233
  );
230
234
  if (diff.status === 2) {
231
- console.error('check-schema-drift: миграции и схема описывают разные базы\n');
235
+ console.error('check-schema-drift: the migrations and the schema describe different databases\n');
232
236
  console.error(`${diff.stdout ?? ''}${diff.stderr ?? ''}`);
233
237
  console.error(
234
- '\nЛибо схема правлена без миграции, либо миграция создаёт то, чего схема не объявляет.\nКак писать миграцию — паттерн `git-workflow-migration`.'
238
+ '\nEither the schema was edited without a migration, or the migration creates what the schema does not declare.\nHow a migration is written — the pattern `git-workflow-migration`.'
235
239
  );
236
240
 
237
241
  return 1;
238
242
  }
239
243
  if (diff.status !== 0) {
240
- // Ни «сошлось», ни «разошлось» — сама команда сравнения не отработала. Пропуск
241
- // здесь неотличим от сошедшихся миграций, и именно им проверка молчала о пустом
242
- // имени схемы: с ним она звала сравнение без обязательного довода, а отказ
243
- // читался зелёным гейтом.
244
- console.error('check-schema-drift: сравнение не отработало\n');
244
+ // Neither "agreed" nor "diverged" — the comparison command itself did not work. A
245
+ // skip here is indistinguishable from migrations that agreed, and it was by exactly
246
+ // that the check stayed silent about an empty schema name: with it the check called
247
+ // the comparison without a required argument, and the refusal read as a green gate.
248
+ console.error('check-schema-drift: the comparison did not work out\n');
245
249
  console.error(`${diff.stdout ?? ''}${diff.stderr ?? ''}`);
246
250
 
247
251
  return 1;
248
252
  }
249
253
 
250
- console.log('check-schema-drift: миграции и схема сошлись');
254
+ console.log('check-schema-drift: the migrations and the schema match');
251
255
 
252
256
  return 0;
253
257
  } finally {
@@ -259,16 +263,16 @@ async function main() {
259
263
  main().then(
260
264
  (code) => process.exit(code),
261
265
  (error) => {
262
- // Сломанная обвязка — не пропуск, а отказ. «Проверять негде» проверка говорит сама и
263
- // раньше: нет схемы, нет адреса, адрес боевой, сервер не отвечает — всё это законные
264
- // выходы нулём, и каждый назван своей строкой. Сюда доходит то, чего она не предвидела,
265
- // и молчаливый ноль здесь означает «гейт зелен, потому что сверять не получилось».
266
- // Отличить его от «сверено и сошлось» нечем: за таким нулём проверка простояла
267
- // выключенной, пока её не позвали руками.
268
- console.error(`check-schema-drift: проверка не отработала — ${error?.message ?? error}\n`);
266
+ // A broken harness is not a skip but a refusal. "Nowhere to check" the check says itself and
267
+ // earlier: no schema, no address, a production address, the server does not answer — all of
268
+ // these are lawful exits with a zero, and each is named by a line of its own. What reaches
269
+ // here is what the check did not foresee, and a silent zero here means "the gate is green
270
+ // because the audit did not work out". There is nothing to tell it from "audited and
271
+ // agreed": behind such a zero the check stood switched off until it was called by hand.
272
+ console.error(`check-schema-drift: the check did not work out — ${error?.message ?? error}\n`);
269
273
  console.error(
270
- 'Это отказ самой проверки, а не расхождение схемы. Почини обвязку: недостающий пакет ставится в корень,\n' +
271
- 'пустое имя схемы или каталога миграций задаётся в настройке проверок дерева.'
274
+ 'This is a refusal of the check itself, not a divergence of the schema. Fix the harness: a missing package is installed at the root,\n' +
275
+ 'an empty name of the schema or of the migrations directory is set in the checks config of the tree.'
272
276
  );
273
277
  process.exit(1);
274
278
  }