@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,20 +1,20 @@
1
1
  /**
2
- * Наборы признаков единообразия: что дерево объявило своим и что при этом читается.
2
+ * The sign bundles of uniformity: what the tree declared as its own and what is read alongside it.
3
3
  *
4
- * Признак не лежит в коде проверки. Пакет режет признаки по своим пакетам — у кита свои, у
5
- * хранилища свои, — а дерево называет в настройке проверок те, что берёт. Набор, который дерево
6
- * не назвало, не читается вовсе: признак о готовом из пакета, которого в дереве нет, отвечает
7
- * ложно ровно так же, как имя чужого приложения.
4
+ * A sign does not lie in the check code. The package cuts the signs by its own packages — the kit
5
+ * has its own, the storage has its own — and the tree names in the checks settings the ones it
6
+ * takes. A bundle the tree did not name is not read at all: a sign about ready-made code from a
7
+ * package the tree does not have answers falsely exactly as the name of a foreign application does.
8
8
  *
9
- * Тот же список читает гард на правке. Общий файл — единственное, чем гард на оболочке и
10
- * проверка на JS могут быть связаны: расходиться им нельзя, иначе правка проходит гард и падает
11
- * на гейте.
9
+ * The same list is read by the guard on an edit. The shared file is the only thing that can tie the
10
+ * shell guard and the JS check together: they may not drift apart, otherwise an edit passes the
11
+ * guard and falls at the gate.
12
12
  */
13
13
  import { existsSync, readdirSync, readFileSync } from 'node:fs';
14
14
  import { dirname, join } from 'node:path';
15
15
  import { fileURLToPath } from 'node:url';
16
16
 
17
- /** Наборы лежат рядом с этим файлом: он и сам ресурс пакета, и раскладывается вместе с ними. */
17
+ /** The bundles lie next to this file: it is a package resource itself and is laid out with them. */
18
18
  export const BUNDLES_DIR = join(dirname(fileURLToPath(import.meta.url)), 'signals');
19
19
 
20
20
  export function bundleNames() {
@@ -29,10 +29,10 @@ export function bundleNames() {
29
29
  }
30
30
 
31
31
  /**
32
- * Разбор набора: шапка раскладки снимается до JSON.
32
+ * Parsing a bundle: the layout header is stripped before the JSON.
33
33
  *
34
- * Раскладка ставит её первой строкой и комментирует незнакомое расширение решёткой — в JSON
35
- * комментария нет, и без снятия разбор падает на первом же символе.
34
+ * The layout puts it as the first line and comments an unknown extension out with a hash — JSON has
35
+ * no comment, and without stripping it the parse falls on the very first character.
36
36
  */
37
37
  function parseSignals(text) {
38
38
  return JSON.parse(text.replace(/^#[^\n]*\n/, '')).signals ?? [];
@@ -41,32 +41,36 @@ function parseSignals(text) {
41
41
  function readBundle(name) {
42
42
  const path = join(BUNDLES_DIR, `${name}.json`);
43
43
  if (!existsSync(path)) {
44
- const known = bundleNames().join(', ') || 'ни одного';
45
- throw new Error(`набор признаков «${name}» при пакете не найден; есть: ${known}`);
44
+ const known = bundleNames().join(', ') || 'none';
45
+ throw new Error(`the bundle of signs «${name}» is not found at the package; there are: ${known}`);
46
46
  }
47
47
 
48
48
  return parseSignals(readFileSync(path, 'utf8'));
49
49
  }
50
50
 
51
- /** Признак, ищущий нативный тег: `<input\\b`, `<textarea\\b`, `<select\\b`. */
51
+ /** A sign that looks for a native tag: `<input\\b`, `<textarea\\b`, `<select\\b`. */
52
52
  const NATIVE_TAG = /^<([a-z]+)\\b$/;
53
53
 
54
- /** Спецзнаки выражения в имени директивы: имя приходит из настройки дерева, а не из кода. */
54
+ /**
55
+ * Expression special characters in a directive name: the name comes from the tree settings,
56
+ * not from the code.
57
+ */
55
58
  function escaped(name) {
56
59
  return name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
57
60
  }
58
61
 
59
62
  /**
60
- * Директивы своей дизайн-системы вычёркиваются из признаков нативных тегов.
63
+ * The directives of the tree's own design system are struck out of the native-tag signs.
61
64
  *
62
- * Источник вида в дереве бывает не один: панель владельца собирается набором кита, публичный
63
- * сайт — своей системой, и закон о единообразии разводит их по приложениям. Директива такой
64
- * системы стоит на нативном теге ровно так же, как директива кнопки кита, — и признак кнопки её
65
- * уже вырезает своим `strip`, а признаки поля, области текста и списка не вырезают ничего: форма,
66
- * собранная из готового своего, числится расхождением целиком, пять полей из пяти.
65
+ * A tree can have more than one source of look: the owner panel is assembled from the kit set, the
66
+ * public site from its own system, and the law on application uniformity separates them by
67
+ * application. A directive of such a system stands on a native tag exactly as a kit button
68
+ * directive does — and the button sign already cuts it out with its `strip`, while the signs of the
69
+ * field, the text area and the list cut out nothing: a form assembled from one's own ready-made
70
+ * counts as a discrepancy entirely, five fields out of five.
67
71
  *
68
- * Список директив называет дерево — ключом `reuse.kitDirectives`. Не назвало — не вырезается
69
- * ничего, и дерево с одним источником вида ведёт себя как прежде.
72
+ * The list of directives is named by the tree — by the key `reuse.kitDirectives`. If it named none,
73
+ * nothing is cut out, and a tree with a single source of look behaves as before.
70
74
  */
71
75
  export function withKitDirectives(signals, directives) {
72
76
  const names = (directives ?? []).filter(Boolean).map(escaped);
@@ -89,19 +93,19 @@ export function withKitDirectives(signals, directives) {
89
93
  }
90
94
 
91
95
  /**
92
- * Признаки объявленных наборов, а поверх них — свои признаки дерева.
96
+ * The signs of the declared bundles, and on top of them the tree's own signs.
93
97
  *
94
- * Совпавший ключ замещает пакетный: дерево вправе сказать о своём готовом точнее, чем пакет,
95
- * который его не видел. Файла своих признаков может не быть — это не отказ: пропуск дешевле
96
- * остановки работы, и объявляют его раньше, чем заводят.
98
+ * A matching key replaces the package one: the tree has the right to speak of its own ready-made
99
+ * more precisely than a package that has not seen it. The file of own signs may be absent — that is
100
+ * not a refusal: a skip is cheaper than stopping the work, and it is declared before it is created.
97
101
  *
98
- * А вот пустой итог — отказ. Проверка стоит в гейте пуша и отвечает «расхождений 0 в 0
99
- * признаках» с нулевым кодом: она объявляет успех, не прочитав ни одного файла, и отличить это
100
- * от честного нуля по выводу нельзя — число признаков стоит в той же строке, что и число
101
- * расхождений, и читается как подробность. При переезде с редакции, где признаки лежали в самой
102
- * проверке, настройка не заведена ещё ни у кого: первый же прогон после обновления врёт молча у
103
- * всех потребителей сразу. Судится итог, а не список наборов: дерево, ведущее только свои
104
- * признаки, наборов пакета не берёт законно.
102
+ * An empty result, though, is a refusal. The check stands in the push gate and answers
103
+ * "discrepancies 0 out of 0 signs" with a zero exit code: it declares success without having read a
104
+ * single file, and by the output that cannot be told from an honest zero — the number of signs
105
+ * stands in the same line as the number of discrepancies and reads as a detail. When moving from an
106
+ * edition where the signs lay in the check itself, no one has the setting yet: the very first run
107
+ * after the upgrade lies silently for every consumer at once. The result is judged, not the list of
108
+ * bundles: a tree that keeps only its own signs lawfully takes no package bundles.
105
109
  */
106
110
  export function loadSignals(config, root) {
107
111
  const declared = config.bundles ?? [];
@@ -116,11 +120,11 @@ export function loadSignals(config, root) {
116
120
  }
117
121
 
118
122
  if (byKey.size === 0) {
119
- const known = bundleNames().join(', ') || 'ни одного';
123
+ const known = bundleNames().join(', ') || 'none';
120
124
  throw new Error(
121
- `признаков не объявлено ни одного: ни набора в «reuse.bundles», ни своего файла признаков. ` +
122
- `Проверка прошла бы, не прочитав ни одного файла, и зелёный ответ означал бы только это. ` +
123
- `Наборы при пакете: ${known}; свои признаки называются полем «reuse.signals».`
125
+ `not a single sign is declared: neither a bundle in «reuse.bundles» nor a signs file of the tree. ` +
126
+ `The check would pass without reading a single file, and a green answer would mean only that. ` +
127
+ `The bundles at the package: ${known}; signs of the tree are named by the field «reuse.signals».`
124
128
  );
125
129
  }
126
130
 
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Привязка правила к коду и законы, которые применяет спек.
2
+ * The binding of a rule to code and the laws a spec applies.
3
3
  *
4
- * Правило живёт в спеке, привязка — в компаньоне рядом; ключ связи — сам текст правила.
5
- * Здесь же разбирается мёртвая привязка: символ, объявленный в своём файле и больше нигде не
6
- * встречающийся, местом исполнения правила не считается.
4
+ * The rule lives in the spec, the binding in the companion next to it; the key of the link is the
5
+ * text of the rule itself. Dead bindings are handled here too: a symbol declared in its own file
6
+ * and met nowhere else is not counted as the place where the rule is carried out.
7
7
  */
8
8
  import {
9
9
  ANCHOR,
@@ -20,33 +20,41 @@ import {
20
20
  walk,
21
21
  } from './spec-common.mjs';
22
22
 
23
- // ── 1. Якоря правил ────────────────────────────────────────────────────────────
23
+ // ── 1. Rule anchors ────────────────────────────────────────────────────────────
24
24
 
25
25
  const escapeForRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\-]/g, '\\$&');
26
26
 
27
27
  /**
28
- * Символ ищется как слово: подстрока дала бы ложное совпадение на префиксе.
28
+ * The symbol is searched as a word: a substring would give a false match on a prefix.
29
29
  *
30
- * Границы слова считаются буквой любого алфавита, а не `\b`: он в JavaScript знает буквой
31
- * только латиницу, и `\bСемья\b` не совпадает ни разу — привязка на русском слове читалась
32
- * как ведущая в файл, где этого слова нет, при том что слово стоит там первой же строкой.
30
+ * Word boundaries are letters of any alphabet, not `\b`: in JavaScript that one knows only Latin
31
+ * letters, and `\bСемья\b` never matches — a binding on a Russian word read as leading into a file
32
+ * where the word is absent, while the word stands there on the very first line.
33
33
  */
34
34
  function fileHasSymbol(path, symbol) {
35
- // Дефис здесь не экранируется: вне класса символов он ничего не значит, а под флагом `u`
36
- // лишнее экранирование — уже отказ разбора. Общий экранировщик его защищает, потому что
37
- // рассчитан и на класс тоже, и `task-flow` роняло всю сверку целиком.
35
+ // A line number is not searched as a word: it is a place, not a name. It matches when the file
36
+ // has that many lines — otherwise a binding on markup would read as leading into nothing.
37
+ if (/^\d+$/.test(symbol)) {
38
+ const line = Number(symbol);
39
+
40
+ return line > 0 && line <= read(path).split('\n').length;
41
+ }
42
+
43
+ // The hyphen is not escaped here: outside a character class it means nothing, and under the `u`
44
+ // flag a needless escape is a parse failure. The shared escaper protects it because it is meant
45
+ // for a class too, and `task-flow` brought the whole audit down.
38
46
  const word = symbol.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
39
47
  return new RegExp(`(?<![\\p{L}\\p{N}_])${word}(?![\\p{L}\\p{N}_])`, 'u').test(read(path));
40
48
  }
41
49
 
42
50
  /**
43
- * Привязки, у которых остаётся выяснить, зовёт ли символ хоть кто-нибудь. Копятся
44
- * в один список и разбираются одним проходом по исходникам: обходить `apps` и
45
- * `libs` на каждую из пятисот привязок было бы полтысячи обходов.
51
+ * Bindings for which it remains to find out whether anyone calls the symbol. They pile up
52
+ * into one list and are handled by one pass over the sources: walking `apps` and `libs`
53
+ * for each of five hundred bindings would be five hundred walks.
46
54
  */
47
55
  const traced = [];
48
56
 
49
- /** Жирное начало пункта — ключ, по которому правило находит свою строку привязки. */
57
+ /** The bold start of a bullet is the key by which the rule finds its binding line. */
50
58
  function ruleHeadOf(bulletText) {
51
59
  const bold = bulletText.match(/\*\*(.+?)\*\*/s);
52
60
 
@@ -54,71 +62,88 @@ function ruleHeadOf(bulletText) {
54
62
  }
55
63
 
56
64
  /**
57
- * Правила живут в `spec.md`, привязка к коду — в `implementation.md` рядом. Разделены
58
- * потому, что спек описывает продукт и читается без знания устройства, а привязка
59
- * устаревает при каждом переименовании.
65
+ * Rules live in `spec.md`, the binding to code in `implementation.md` next to it. They are
66
+ * separated because the spec describes the product and is read without knowing the internals,
67
+ * while the binding goes stale on every rename.
60
68
  *
61
- * Ключ связи — сам текст правила, а не отдельный идентификатор: тогда правку формулировки
62
- * невозможно сделать, забыв про привязку, — строка перестанет находиться.
69
+ * The key of the link is the text of the rule itself, not a separate identifier: then a wording
70
+ * edit cannot be made while forgetting the binding — the line stops being found.
63
71
  *
64
- * Заголовок раздела приходит доводом: у спека это `## Правила`, у закона — `## Статьи`.
65
- * Одно слово в двух смыслах развели именно здесь: «правило» — слой между законом и скилом,
66
- * а внутри закона живут статьи.
72
+ * The section heading arrives as an argument: for a spec it is `## Rules`, for a law
73
+ * `## Articles`. One word in two meanings was split apart exactly here: "rule" is the layer between
74
+ * a law and a pattern, and inside a law live articles.
67
75
  */
68
76
  /**
69
- * Строки таблицы привязок компаньона.
77
+ * The rows of the companion's binding table.
70
78
  *
71
- * Компаньон правила держит три таблицы: чем вещи правила названы в этом дереве, где лежат
72
- * механизмы и где исполняется каждая статья. Привязки — только третья, и берётся она по имени
73
- * раздела, а не по месту в файле. Пока читался весь файл, строки первых двух попадали в список
74
- * наравне с настоящими и тут же объявлялись расхождением: статьи с таким текстом в правиле нет
75
- * и быть не может. Две трети перечня в дереве были ими, и правильно дописанная строка «Где это
76
- * лежит» отвечала отказом.
79
+ * A rule's companion holds three tables: what the rule's things are called in this tree, where
80
+ * the mechanisms lie and where each article is carried out. Bindings are only the third one, and
81
+ * it is taken by section name, not by position in the file. While the whole file was read, rows
82
+ * of the first two landed in the list alongside the real ones and were at once declared a
83
+ * discrepancy: there is no article with such text in the rule and cannot be. Two thirds of the
84
+ * listing in the tree were these, and a correctly added "Where it lies" row was answered with
85
+ * a refusal.
77
86
  *
78
- * У компаньона спека домена раздела нет: там таблица одна, и сужать нечего — такой зовёт без
79
- * имени раздела. У правила раздел стоит в образце компаньона, поэтому его отсутствие — отказ:
80
- * молча прочесть вместо него весь файл значило бы вернуть тот же дефект.
87
+ * A domain spec's companion has no such section: the table there is the only one, and there is
88
+ * nothing to narrow — such a caller comes without a section name. For a rule the section stands
89
+ * in the companion template, so its absence is a refusal: silently reading the whole file instead
90
+ * would bring the same defect back.
81
91
  */
82
92
  function rowsOfMap(specFile, mapFile, mapHeading) {
83
93
  const text = read(mapFile);
84
- if (!mapHeading) {
94
+ if (!mapHeading || (Array.isArray(mapHeading) && !mapHeading.length)) {
85
95
  return text.split('\n');
86
96
  }
87
97
  const section = sectionOf(text, mapHeading);
88
98
  if (!section.length) {
89
- report(mapFile, `нет раздела \`${mapHeading}\` — привязкам правила негде лежать`);
99
+ // The section is read under either of its names, and the refusal names the first — the one
100
+ // a new companion is written by.
101
+ const named = Array.isArray(mapHeading) ? mapHeading[0] : mapHeading;
102
+ report(mapFile, `there is no section \`${named}\` — the bindings of the rule have nowhere to lie`);
90
103
  }
91
104
 
92
105
  return section;
93
106
  }
94
107
 
95
- function checkRuleImplementation(specFile, text, mapFile, heading = '## Правила', mapHeading = '') {
96
- const bullets = bulletsOf(sectionOf(text, heading));
108
+ function checkRuleImplementation(specFile, text, mapFile, heading = ['## Rules', '## Правила'], mapHeading = '') {
109
+ const lines = sectionOf(text, heading);
110
+ const bullets = bulletsOf(lines);
97
111
  if (!bullets.length) {
98
- report(specFile, `в разделе \`${heading}\` нет ни одного пункта`);
112
+ // The refusal names what stands in the section instead of bullets: without that the author
113
+ // shuffles markup at random — a table before the list and subheadings gave one and the
114
+ // same refusal.
115
+ const first = lines.find((line) => line.trim());
116
+ const instead = bullets.stoppedAt
117
+ ? `, the list ended at the line \`${bullets.stoppedAt.trim().slice(0, 60)}\``
118
+ : first
119
+ ? `, the first one is \`${first.trim().slice(0, 60)}\``
120
+ : '';
121
+ report(specFile, `the section \`${Array.isArray(heading) ? heading[0] : heading}\` carries no item at all${instead}`);
99
122
 
100
123
  return;
101
124
  }
102
125
 
103
126
  if (!exists(mapFile)) {
104
- report(specFile, `нет файла \`${mapFile.split('/').pop()}\` рядом — правилам не к чему привязаться`);
127
+ report(specFile, `there is no file \`${mapFile.split('/').pop()}\` next to it — the statements have nothing to bind to`);
105
128
 
106
129
  return;
107
130
  }
108
131
 
109
132
  const rows = new Map();
110
133
  for (const line of rowsOfMap(specFile, mapFile, mapHeading)) {
111
- // Привязка записывается двумя формами, и читаются обе. Таблица — прежняя; список — та,
112
- // ради которой из компаньонов уходят пробелы выравнивания: форматтер добивает столбцы до
113
- // общей ширины, и в компаньонах дерева это 120 017 знаков из 328 738, то есть 37%.
114
- // Связь при этом не меняется: она идёт по тексту утверждения, а не по форме строки.
134
+ // A binding is written in two forms, and both are read. The table is the old one; the list
135
+ // is the one for whose sake alignment spaces leave the companions: the formatter pads the
136
+ // columns to a common width, and in the tree's companions that is 120 017 characters out
137
+ // of 328 738, that is 37%. The link does not change with it: it goes by the text of the
138
+ // statement, not by the shape of the line.
115
139
  const cells = line.match(/^\|([^|]+)\|([^|]*)\|\s*$/) ?? line.match(/^-\s+\*\*(.+?)\*\*\s+—\s+(.*)$/);
116
140
  if (!cells) {
117
141
  continue;
118
142
  }
119
143
  const head = cells[1].replace(/\s+/g, ' ').trim();
120
- // Шапка таблицы: у спека колонка называется «Правило», у закона — «Статья».
121
- if (!head || head === 'Правило' || head === 'Статья' || /^-+$/.test(head)) {
144
+ // The table header: for a spec the column is called «Rule», for a law «Article»; a
145
+ // companion written before the layer was translated names them in the owner's language.
146
+ if (!head || ['Rule', 'Article', 'Правило', 'Статья'].includes(head) || /^-+$/.test(head)) {
122
147
  continue;
123
148
  }
124
149
  const cell = cells[2].trim();
@@ -132,15 +157,15 @@ function checkRuleImplementation(specFile, text, mapFile, heading = '## Прав
132
157
  for (const bullet of bullets) {
133
158
  const head = ruleHeadOf(bullet.text);
134
159
  if (!head) {
135
- report(specFile, `правило без жирного начала: «${bullet.text.replace(/^-\s+/, '').slice(0, 60)}…»`);
160
+ report(specFile, `a statement without a bold opening: «${bullet.text.replace(/^-\s+/, '').slice(0, 60)}…»`);
136
161
  continue;
137
162
  }
138
163
  const row = rows.get(head);
139
164
  if (!row) {
140
165
  report(
141
166
  mapFile,
142
- `правило без привязки: «${head.slice(0, 60)}…» — допиши строку с \`файл:символ\`, ` +
143
- 'вердиктом «Не исполняется» с причиной либо перенеси правило в «Открытые вопросы» закона как Q-<буква>-<номер>'
167
+ `a statement without a binding: «${head.slice(0, 60)}…» — add a line with \`file:symbol\`, ` +
168
+ 'a verdict «Not carried out» with a reason, or move the statement into «Open questions» of the law as Q-<letter>-<number>'
144
169
  );
145
170
  continue;
146
171
  }
@@ -148,44 +173,44 @@ function checkRuleImplementation(specFile, text, mapFile, heading = '## Прав
148
173
  if (!row.anchors.length && !row.verdict) {
149
174
  report(
150
175
  mapFile,
151
- `у правила «${head.slice(0, 60)}…» пустая привязка — поставь \`файл:символ\` ` +
152
- 'либо вердикт «Не исполняется», «Не применимо», «Не проверяется» с причиной'
176
+ `the statement «${head.slice(0, 60)}…» has an empty binding — put \`file:symbol\` ` +
177
+ 'or the verdict «Not carried out», «Not applicable», «Not checked» with a reason'
153
178
  );
154
179
  }
155
180
  for (const [, path, symbol] of row.anchors) {
156
181
  if (!exists(path)) {
157
- report(mapFile, `привязка ведёт в никуда: нет файла \`${path}\``);
182
+ report(mapFile, `the binding leads nowhere: there is no file \`${path}\``);
158
183
  } else if (!fileHasSymbol(path, symbol)) {
159
- report(mapFile, `привязка не сходится: в \`${path}\` нет \`${symbol}\``);
184
+ report(mapFile, `the binding does not match: \`${path}\` carries no \`${symbol}\``);
160
185
  } else {
161
186
  traced.push({ mapFile, path, symbol });
162
187
  }
163
188
  }
164
189
  }
165
190
 
166
- // Обратная сторона: строка, под которой правила больше нет, — след переименования.
167
- // Без неё привязка копится и начинает описывать несуществующие обещания
191
+ // The reverse side: a row under which there is no rule any more is the trace of a rename.
192
+ // Without this the binding piles up and starts describing promises that do not exist
168
193
  for (const [head, row] of rows) {
169
194
  if (!row.used) {
170
- report(mapFile, `привязка без пункта: «${head.slice(0, 60)}…» — в \`${specFile}\` такого пункта нет`);
195
+ report(mapFile, `a binding without an item: «${head.slice(0, 60)}…» — \`${specFile}\` carries no such item`);
171
196
  }
172
197
  }
173
198
  }
174
199
 
175
- // ── 5. Мёртвые привязки ───────────────────────────────────────────────────────
200
+ // ── 5. Dead bindings ──────────────────────────────────────────────────────────
176
201
 
177
202
  /**
178
- * Код без комментариев. Упоминание символа в пояснении вызовом не является, а
179
- * пояснений у мёртвого кода как раз обычно больше, чем у живого.
203
+ * Code without comments. A symbol named in an explanation is called by nobody, and dead code
204
+ * usually has more explanations than live code does.
180
205
  */
181
206
  const codeOf = (text) => text.replace(/\/\*[\s\S]*?\*\//g, ' ').replace(/(^|[^:`'"])\/\/.*$/gm, '$1');
182
207
 
183
208
  const DECLARATION_MODIFIERS = '(?:export|declare|abstract|public|private|protected|static|readonly|override|async|accessor)';
184
209
 
185
210
  /**
186
- * Объявлен ли символ здесь. Проверка идёт только по объявлениям: привязка к
187
- * чужому полю (`HttpStatus.SERVICE_UNAVAILABLE`), ключу словаря или содержимому
188
- * строки законна и встречается ровно один раз по своей природе.
211
+ * Whether the symbol is declared here. The check goes by declarations only: a binding to
212
+ * someone else's field (`HttpStatus.SERVICE_UNAVAILABLE`), a dictionary key or the contents
213
+ * of a string is lawful and by its nature is met exactly once.
189
214
  */
190
215
  function fileDeclaresSymbol(code, symbol) {
191
216
  const escaped = escapeForRegExp(symbol);
@@ -197,9 +222,9 @@ function fileDeclaresSymbol(code, symbol) {
197
222
  }
198
223
 
199
224
  /**
200
- * Файлы, в которых встречается каждый символ. Дефис берётся в токен целиком ради
201
- * атрибутов разметки, а части такого токена добавляются отдельно: иначе
202
- * `resolving` внутри `data-resolving` перестал бы находиться.
225
+ * The files in which each symbol is met. A hyphen is taken into the token whole for the sake
226
+ * of markup attributes, and the parts of such a token are added separately: otherwise
227
+ * `resolving` inside `data-resolving` would stop being found.
203
228
  */
204
229
  function symbolOwners() {
205
230
  const owners = new Map();
@@ -214,9 +239,10 @@ function symbolOwners() {
214
239
 
215
240
  for (const file of SOURCE_ROOTS.flatMap((root) => walk(root, (name) => name.endsWith('.ts') || name.endsWith('.html')))) {
216
241
  const text = file.endsWith('.ts') ? codeOf(read(file)) : read(file);
217
- // Решётка входит в токен: приватное поле класса объявлено с ней, и якорь на него иначе
218
- // не попадал бы в перечень владельцев ни разу. Имя без решётки помнится наравне с ним
219
- // самим — привязки прежней формы остаются зелёными, и переходить разом не приходится.
242
+ // The hash is part of the token: a private class field is declared with it, and an anchor
243
+ // on it would otherwise never land in the owners listing. The name without the hash is
244
+ // remembered alongside the name itself — bindings of the old form stay green, and there is
245
+ // no need to switch all at once.
220
246
  for (const [token] of text.matchAll(/#?[A-Za-z_][\w-]*/g)) {
221
247
  remember(token, file);
222
248
  if (token.startsWith('#')) {
@@ -232,8 +258,8 @@ function symbolOwners() {
232
258
  }
233
259
 
234
260
  /**
235
- * Символ, объявленный в своём файле и больше нигде не встречающийся, ничего не
236
- * исполняет: правило, привязанное к нему, описывает намерение.
261
+ * A symbol declared in its own file and met nowhere else carries nothing out: a rule bound
262
+ * to it describes an intention.
237
263
  */
238
264
  function checkTracedAnchors() {
239
265
  const code = new Map();
@@ -252,8 +278,8 @@ function checkTracedAnchors() {
252
278
 
253
279
  const owners = symbolOwners();
254
280
  for (const { mapFile, path, symbol } of declared) {
255
- // Граница слова ставится только там, где она есть: перед решёткой её нет, и образец с
256
- // ней давал бы ноль вхождений у всякого приватного имени.
281
+ // A word boundary is placed only where one exists: there is none before a hash, and a
282
+ // pattern with it would give zero occurrences for every private name.
257
283
  const bound = symbol.startsWith('#')
258
284
  ? `${escapeForRegExp(symbol)}\\b`
259
285
  : `\\b${escapeForRegExp(symbol)}\\b`;
@@ -262,35 +288,36 @@ function checkTracedAnchors() {
262
288
  if (here + elsewhere < 2) {
263
289
  report(
264
290
  mapFile,
265
- `привязка ведёт в мёртвый код: \`${symbol}\` объявлен в \`${path}\` и больше нигде не встречается — ` +
266
- 'либо правило исполняется в другом месте, либо ему место в «Открытых вопросах» закона как Q-<буква>-<номер>'
291
+ `the binding leads into dead code: \`${symbol}\` is declared in \`${path}\` and met nowhere else — ` +
292
+ 'either the statement is carried out elsewhere, or its place is in «Open questions» of the law as Q-<letter>-<number>'
267
293
  );
268
294
  }
269
295
  }
270
296
  }
271
297
 
272
- // ── 1a. Законы, которые применяет спек ────────────────────────────────────────
298
+ // ── 1a. The laws a spec applies ───────────────────────────────────────────────
273
299
 
274
300
  /**
275
- * Связь «закон — правило» и «правило — паттерн» сверяется в обе стороны, а спек до сих пор
276
- * говорил только о домене. Закон при этом он применял: ссылки на `docs/constitution/…`
277
- * лежали внутри строки зависимостей и посреди текста, и по закону нельзя было узнать, какие
278
- * домены на нём стоят, — только грепом.
301
+ * The link "law — rule" and "rule — pattern" is audited both ways, while a spec so far spoke
302
+ * only of its domain. Yet it applied a law: links to `docs/constitution/…` lay inside the
303
+ * dependencies line and in the middle of the text, and from a law there was no way to learn
304
+ * which domains stand on it — only by grep.
279
305
  *
280
- * Отсюда строка `**Законы:**` в шапке и сверка обеих сторон: закон, названный в тексте, но не
281
- * объявленный, и объявленный закон, которого нет.
306
+ * Hence the `**Законы:**` line in the header and an audit of both sides: a law named in the
307
+ * text but not declared, and a declared law that does not exist.
282
308
  */
283
- const SPEC_LAWS = /^\*\*Законы:\*\*\s*(.+)$/;
309
+ const SPEC_LAWS = /^\*\*(?:Laws|Законы):\*\*\s*(.+)$/;
284
310
  /**
285
- * Ссылка на закон где угодно в тексте спека — по ней считается вторая сторона связи. Слой в
286
- * пути необязателен: законы приложения лежат в `application/`, а называются так же.
311
+ * A link to a law anywhere in the spec text — by it the second side of the link is counted.
312
+ * The layer in the path is optional: application laws lie in `application/` and are named
313
+ * the same way.
287
314
  */
288
315
  const LAW_REFERENCE = new RegExp(`\`${CONSTITUTION_DIR}/(?:application/)?([a-z-]+)\\.md\``, 'g');
289
316
 
290
317
  function checkSpecLaws(file, text, laws) {
291
318
  const line = text.split('\n').find((candidate) => SPEC_LAWS.test(candidate));
292
319
  if (!line) {
293
- report(file, 'в шапке нет строки `**Законы:**` — не видно, какие законы домен применяет');
320
+ report(file, 'the header carries no line `**Laws:**` — there is no seeing which laws the domain applies');
294
321
 
295
322
  return;
296
323
  }
@@ -298,13 +325,13 @@ function checkSpecLaws(file, text, laws) {
298
325
  const declared = new Set([...line.match(SPEC_LAWS)[1].matchAll(BACKTICKED)].map(([, name]) => name));
299
326
  for (const name of declared) {
300
327
  if (!laws.has(name)) {
301
- report(file, `в строке \`**Законы:**\` назван \`${name}\`, а закона с таким именем нет ни в одном слое`);
328
+ report(file, `the line \`**Laws:**\` names \`${name}\`, and there is no law of that name in any layer`);
302
329
  }
303
330
  }
304
331
 
305
332
  for (const [, name] of text.matchAll(LAW_REFERENCE)) {
306
333
  if (!declared.has(name)) {
307
- report(file, `закон \`${name}\` назван в тексте, но не объявлен в строке \`**Законы:**\``);
334
+ report(file, `the law \`${name}\` is named in the text and is not declared in the line \`**Laws:**\``);
308
335
  }
309
336
  }
310
337
  }