@rt-tools/agent-kit 0.24.0 → 0.27.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.
- package/assets/agents/business-analyst.md +51 -50
- package/assets/agents/cargo-writer.md +54 -0
- package/assets/agents/conscience.md +37 -35
- package/assets/agents/project-manager.md +49 -48
- package/assets/agents/prose-editor.md +31 -29
- package/assets/agents/qa-engineer.md +50 -48
- package/assets/agents/rules-reviewer.md +63 -58
- package/assets/agents/skill-curator.md +83 -78
- package/assets/agents/spec-critic.md +34 -29
- package/assets/agents/spec-writer.md +35 -32
- package/assets/agents/strict-teacher.md +39 -37
- package/assets/checks/archive-age.mjs +48 -28
- package/assets/checks/archive-prune.mjs +16 -14
- package/assets/checks/board-epic-link.github.mjs +29 -0
- package/assets/checks/board-epics.github.mjs +286 -49
- package/assets/checks/board-folders.mjs +61 -0
- package/assets/checks/board-gh.github.mjs +35 -26
- package/assets/checks/board-long-work.github.mjs +29 -25
- package/assets/checks/board-paths.github.mjs +21 -16
- package/assets/checks/board-pull-state.github.mjs +168 -0
- package/assets/checks/board-runs.github.mjs +45 -43
- package/assets/checks/board-task-dirs.github.mjs +98 -0
- package/assets/checks/board-titles.github.mjs +19 -17
- package/assets/checks/board.github.mjs +133 -194
- package/assets/checks/check-archive-age.mjs +23 -19
- package/assets/checks/check-board.github.mjs +131 -263
- package/assets/checks/check-descriptions.mjs +30 -29
- package/assets/checks/check-doc-paths.mjs +91 -88
- package/assets/checks/check-dupes.mjs +84 -80
- package/assets/checks/check-file-size.mjs +74 -71
- package/assets/checks/check-glossary.mjs +47 -37
- package/assets/checks/check-hook-scope.mjs +30 -27
- package/assets/checks/check-lib-layers.mjs +22 -21
- package/assets/checks/check-profile-drift.mjs +48 -43
- package/assets/checks/check-prose-style.mjs +138 -39
- package/assets/checks/check-push-gate.mjs +53 -50
- package/assets/checks/check-reuse.mjs +50 -40
- package/assets/checks/check-schema-drift.mjs +104 -84
- package/assets/checks/check-specs.mjs +155 -134
- package/assets/checks/check-state-next.mjs +66 -52
- package/assets/checks/check-states.mjs +32 -30
- package/assets/checks/check-styles.mjs +52 -51
- package/assets/checks/check-turn-map.mjs +54 -46
- package/assets/checks/epic-table.github.mjs +268 -0
- package/assets/checks/lib-boundaries.mjs +32 -30
- package/assets/checks/lib-common.mjs +30 -29
- package/assets/checks/lib-domains.mjs +34 -34
- package/assets/checks/lib-manifests.mjs +17 -15
- package/assets/checks/lib-reexports.mjs +18 -18
- package/assets/checks/rt-kit-checks.config.mjs +187 -142
- package/assets/checks/signals.mjs +43 -39
- package/assets/checks/spec-anchors.mjs +114 -87
- package/assets/checks/spec-common.mjs +128 -84
- package/assets/checks/spec-contract.mjs +30 -30
- package/assets/checks/spec-proposed.mjs +27 -24
- package/assets/checks/spec-scenarios.mjs +51 -28
- package/assets/checks/specs-for.mjs +214 -0
- package/assets/checks/task-new.github.mjs +315 -61
- package/assets/commands/feedback.md +65 -59
- package/assets/commands/next-session.md +64 -57
- package/assets/commands/night.md +115 -0
- package/assets/commands/skill-curator.md +83 -79
- package/assets/defaults/gate-map.sh +108 -97
- package/assets/defaults/project.sh +232 -185
- package/assets/defaults/shell.sh +73 -68
- package/assets/defaults/turn-map.md +47 -44
- package/assets/docs/GLOSSARY.md +142 -65
- package/assets/hooks/browser-device-id.sh +16 -12
- package/assets/hooks/browser-guard-device-id.sh +34 -28
- package/assets/hooks/browser-guard-no-asking.sh +5 -4
- package/assets/hooks/browser-guard-no-listing.sh +12 -11
- package/assets/hooks/browser-guard-no-other-drivers.sh +48 -42
- package/assets/hooks/browser-guard-require-select.sh +34 -23
- package/assets/hooks/claim-guard.sh +62 -56
- package/assets/hooks/commit-msg.sh +14 -10
- package/assets/hooks/conscience-guard.sh +91 -45
- package/assets/hooks/constitution-index.sh +16 -16
- package/assets/hooks/deny-tail.sh +28 -26
- package/assets/hooks/dev-server-guard.sh +50 -43
- package/assets/hooks/dispatch.sh +60 -46
- package/assets/hooks/docs-guard.sh +100 -91
- package/assets/hooks/epic-over.sh +49 -0
- package/assets/hooks/epic-stop-guard.sh +108 -0
- package/assets/hooks/exam-guard.sh +105 -93
- package/assets/hooks/git-guard-delivery-conflict.sh +41 -36
- package/assets/hooks/git-guard-delivery-draft.sh +48 -38
- package/assets/hooks/git-guard-delivery-epic.sh +167 -0
- package/assets/hooks/git-guard-delivery-folder.sh +50 -43
- package/assets/hooks/git-guard-delivery-signature.sh +119 -53
- package/assets/hooks/git-guard-delivery.sh +223 -183
- package/assets/hooks/git-guard-main.sh +38 -34
- package/assets/hooks/git-guard-push-tests.sh +99 -87
- package/assets/hooks/glossary-load.sh +23 -22
- package/assets/hooks/grill-gate-ask.sh +12 -11
- package/assets/hooks/grill-gate.sh +94 -87
- package/assets/hooks/guard-note.sh +20 -19
- package/assets/hooks/handoff-entry-guard.sh +45 -25
- package/assets/hooks/handoff-write.sh +74 -67
- package/assets/hooks/hook-input.sh +67 -58
- package/assets/hooks/lint-after-edit.sh +95 -61
- package/assets/hooks/observe.sh +28 -26
- package/assets/hooks/override-write-guard.sh +23 -21
- package/assets/hooks/postmortem-guard.sh +42 -39
- package/assets/hooks/profile-check.sh +22 -20
- package/assets/hooks/proposal-guard.sh +57 -49
- package/assets/hooks/prose-style-guard.sh +49 -24
- package/assets/hooks/qa-dataid-guard.sh +83 -58
- package/assets/hooks/rerun-guard.sh +31 -30
- package/assets/hooks/reuse-first-guard.sh +108 -87
- package/assets/hooks/roles.sh +14 -14
- package/assets/hooks/rule-article.sh +39 -34
- package/assets/hooks/rule-source-guard.sh +47 -42
- package/assets/hooks/skill-gate-layers.sh +63 -57
- package/assets/hooks/skill-gate-rearm.sh +15 -8
- package/assets/hooks/skill-gate.sh +89 -81
- package/assets/hooks/skill-loaded.sh +10 -6
- package/assets/hooks/sql-guard-parse.sh +71 -66
- package/assets/hooks/sql-guard-request.sh +51 -46
- package/assets/hooks/sql-guard-target.sh +60 -51
- package/assets/hooks/sql-guard-write.sh +87 -79
- package/assets/hooks/sql-guard.sh +52 -47
- package/assets/hooks/stand-login-guard.sh +43 -37
- package/assets/hooks/task-context-load.sh +60 -55
- package/assets/hooks/task-flow-context.sh +87 -69
- package/assets/hooks/task-flow-draft-guard.sh +55 -48
- package/assets/hooks/task-flow-guard.sh +67 -64
- package/assets/hooks/turn-entry-load.sh +39 -32
- package/assets/hooks/turn-exit-guard.sh +260 -204
- package/assets/hooks/turn-exit-patterns.sh +63 -0
- package/assets/hooks/utf8.sh +14 -11
- package/assets/hooks/waiting-turn-guard.sh +104 -94
- package/assets/hooks/window-fill-guard.sh +70 -62
- package/assets/hooks/work-start-guard.sh +52 -49
- package/assets/hooks/write-targets.sh +99 -44
- package/assets/laws/autonomous-work.md +29 -27
- package/assets/laws/code-structure.md +31 -30
- package/assets/laws/delivery.md +170 -137
- package/assets/laws/entity-editing.md +52 -50
- package/assets/laws/entity-models.md +14 -13
- package/assets/laws/frontend-application.md +39 -38
- package/assets/laws/lib-imports.md +27 -27
- package/assets/laws/lists.md +31 -29
- package/assets/laws/navigation.md +37 -37
- package/assets/laws/observability.md +41 -40
- package/assets/laws/project-documentation.md +106 -99
- package/assets/laws/reuse-first.md +31 -29
- package/assets/laws/shared-code.md +27 -27
- package/assets/laws/verifiability.md +131 -124
- package/assets/laws/work-conduct.md +250 -244
- package/assets/patterns/admin-lists-screen.md +72 -69
- package/assets/patterns/admin-nav-item.md +51 -46
- package/assets/patterns/angular-patterns-state.md +32 -31
- package/assets/patterns/api-layer-pair.md +33 -31
- package/assets/patterns/autonomous-work-run.md +50 -49
- package/assets/patterns/browser-verification-measure.md +124 -88
- package/assets/patterns/browser-verification-stand.md +169 -157
- package/assets/patterns/component-structure-new.md +51 -42
- package/assets/patterns/dependencies-upgrade.md +55 -39
- package/assets/patterns/doc-style-human.md +55 -37
- package/assets/patterns/doc-style-sweep.md +82 -79
- package/assets/patterns/doc-style-trace.md +87 -81
- package/assets/patterns/doc-style-write.md +130 -122
- package/assets/patterns/entity-aside.md +77 -63
- package/assets/patterns/entity-models-new.md +37 -37
- package/assets/patterns/entity-store.md +33 -33
- package/assets/patterns/git-workflow-commit.azure.md +94 -87
- package/assets/patterns/git-workflow-commit.github.md +160 -142
- package/assets/patterns/git-workflow-commit.gitlab.md +96 -90
- package/assets/patterns/git-workflow-docker.md +165 -147
- package/assets/patterns/git-workflow-freshness.md +45 -45
- package/assets/patterns/git-workflow-merge.md +102 -94
- package/assets/patterns/git-workflow-migration.md +54 -52
- package/assets/patterns/git-workflow-pr-ready.md +57 -56
- package/assets/patterns/git-workflow-pr.azure.md +127 -122
- package/assets/patterns/git-workflow-pr.github.md +186 -177
- package/assets/patterns/git-workflow-pr.gitlab.md +139 -132
- package/assets/patterns/git-workflow-restart.md +35 -31
- package/assets/patterns/git-workflow-secrets.md +80 -73
- package/assets/patterns/git-workflow-stack.md +136 -107
- package/assets/patterns/lib-layers-move.md +62 -53
- package/assets/patterns/lib-layers-new.md +59 -45
- package/assets/patterns/observability-record.md +72 -67
- package/assets/patterns/platform-access-di.md +31 -29
- package/assets/patterns/reuse-first-extend.md +66 -61
- package/assets/patterns/shared-code-new.md +39 -38
- package/assets/patterns/spec-driven-domain.md +161 -151
- package/assets/patterns/spec-driven-rule.md +179 -168
- package/assets/patterns/spec-driven-sweep.md +41 -39
- package/assets/patterns/status-report-table.github.md +48 -36
- package/assets/patterns/styling-bem-component.md +42 -42
- package/assets/patterns/styling-bem-layout.md +39 -34
- package/assets/patterns/styling-bem-sheet.md +59 -58
- package/assets/patterns/task-flow-archive.md +222 -215
- package/assets/patterns/task-flow-close.md +234 -203
- package/assets/patterns/task-flow-handoff.md +154 -145
- package/assets/patterns/task-flow-resume.md +138 -133
- package/assets/patterns/task-flow-start.md +228 -202
- package/assets/patterns/testing-e2e.md +102 -101
- package/assets/patterns/testing-unit.md +77 -70
- package/assets/patterns/ts-procedure.md +32 -29
- package/assets/patterns/turn-entry-map.md +50 -48
- package/assets/pitfalls/agent-kit.md +172 -142
- package/assets/pitfalls/doc-style.md +96 -91
- package/assets/pitfalls/git-workflow.azure.md +49 -46
- package/assets/pitfalls/git-workflow.github.md +270 -234
- package/assets/pitfalls/git-workflow.gitlab.md +49 -45
- package/assets/pitfalls/spec-driven.md +73 -71
- package/assets/pitfalls/styling-bem.md +46 -40
- package/assets/pitfalls/task-flow.md +262 -246
- package/assets/pitfalls/testing.md +99 -92
- package/assets/pitfalls/turn-conduct.md +96 -81
- package/assets/rules/angular-patterns.md +81 -80
- package/assets/rules/api-layer.md +77 -74
- package/assets/rules/autonomous-work.md +87 -74
- package/assets/rules/browser-verification.md +223 -214
- package/assets/rules/component-structure.md +72 -69
- package/assets/rules/dependencies.md +74 -67
- package/assets/rules/deploy-flow.azure.md +118 -108
- package/assets/rules/deploy-flow.github.md +145 -135
- package/assets/rules/deploy-flow.gitlab.md +120 -110
- package/assets/rules/doc-style.md +201 -173
- package/assets/rules/entity-conventions.needs-admin.md +81 -79
- package/assets/rules/entity-models.md +73 -70
- package/assets/rules/git-workflow.azure.md +224 -228
- package/assets/rules/git-workflow.github.md +268 -239
- package/assets/rules/git-workflow.gitlab.md +218 -217
- package/assets/rules/lib-layers.md +85 -86
- package/assets/rules/lists.md +101 -97
- package/assets/rules/navigation.md +78 -78
- package/assets/rules/observability.needs-app.md +165 -153
- package/assets/rules/platform-access.md +76 -75
- package/assets/rules/reuse-first.md +153 -143
- package/assets/rules/shared-code.md +82 -79
- package/assets/rules/spec-driven.md +279 -260
- package/assets/rules/status-report.md +62 -58
- package/assets/rules/styling-bem.md +81 -77
- package/assets/rules/task-flow.md +303 -270
- package/assets/rules/testing.md +224 -209
- package/assets/rules/turn-conduct.md +262 -258
- package/assets/rules/turn-entry.md +92 -87
- package/assets/rules/typescript-conventions.md +94 -88
- package/assets/samples/specs/_template/spec.md +47 -47
- package/assets/samples/tasks/_template/grill.md +20 -20
- package/assets/samples/tasks/_template/plan.md +32 -30
- package/assets/samples/tasks/_template/progress.md +16 -16
- package/assets/skills/agent-kit-extend.md +129 -113
- package/assets/skills/agent-kit.md +259 -233
- package/assets/skills/write-a-skill.md +76 -71
- package/assets/templates/findings.md +19 -19
- package/assets/templates/gate-map.sh +16 -14
- package/assets/templates/implementation.md +28 -27
- package/assets/templates/pattern.md +17 -17
- package/assets/templates/pitfalls.md +6 -6
- package/assets/templates/postmortem.md +24 -23
- package/assets/templates/project.sh +24 -24
- package/assets/templates/proposal.md +62 -60
- package/assets/templates/rule.md +38 -38
- package/assets/workflows/feature.js +46 -46
- package/assets/workflows/plan.js +54 -54
- package/bin/agent-kit.d.ts.map +1 -1
- package/bin/agent-kit.js +8 -1
- package/bin/agent-kit.js.map +1 -1
- package/lib/cargo-prose.d.ts +41 -0
- package/lib/cargo-prose.d.ts.map +1 -0
- package/lib/cargo-prose.js +88 -0
- package/lib/cargo-prose.js.map +1 -0
- package/lib/cargo.d.ts +12 -1
- package/lib/cargo.d.ts.map +1 -1
- package/lib/cargo.js +8 -2
- package/lib/cargo.js.map +1 -1
- package/lib/catalog.d.ts +2 -0
- package/lib/catalog.d.ts.map +1 -1
- package/lib/catalog.js +4 -3
- package/lib/catalog.js.map +1 -1
- package/lib/commands.d.ts.map +1 -1
- package/lib/commands.js +5 -2
- package/lib/commands.js.map +1 -1
- package/lib/companion.js +3 -2
- package/lib/companion.js.map +1 -1
- package/lib/enroll.d.ts +7 -1
- package/lib/enroll.d.ts.map +1 -1
- package/lib/enroll.js +12 -3
- package/lib/enroll.js.map +1 -1
- package/lib/fate.d.ts +29 -0
- package/lib/fate.d.ts.map +1 -0
- package/lib/fate.js +147 -0
- package/lib/fate.js.map +1 -0
- package/lib/override-marks.d.ts +7 -0
- package/lib/override-marks.d.ts.map +1 -1
- package/lib/override-marks.js +14 -0
- package/lib/override-marks.js.map +1 -1
- package/lib/plan.d.ts +11 -0
- package/lib/plan.d.ts.map +1 -1
- package/lib/plan.js +10 -1
- package/lib/plan.js.map +1 -1
- package/lib/ship.d.ts +29 -9
- package/lib/ship.d.ts.map +1 -1
- package/lib/ship.js +44 -2
- package/lib/ship.js.map +1 -1
- package/lib/shipment.d.ts.map +1 -1
- package/lib/shipment.fixture.d.ts +8 -1
- package/lib/shipment.fixture.d.ts.map +1 -1
- package/lib/shipment.fixture.js +9 -0
- package/lib/shipment.fixture.js.map +1 -1
- package/lib/shipment.js +38 -5
- package/lib/shipment.js.map +1 -1
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +45 -11
- package/lib/sync.js.map +1 -1
- package/package.json +1 -1
- package/rt-tools-agent-kit-0.27.0.tgz +0 -0
- 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
|
-
*
|
|
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
|
-
*
|
|
32
|
+
* Parsing a bundle: the layout header is stripped before the JSON.
|
|
33
33
|
*
|
|
34
|
-
*
|
|
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(
|
|
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
|
-
/**
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
*
|
|
31
|
-
*
|
|
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
|
-
//
|
|
36
|
-
//
|
|
37
|
-
|
|
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
|
-
*
|
|
45
|
-
*
|
|
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
|
-
*
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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,
|
|
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
|
-
//
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
143
|
-
'
|
|
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
|
-
|
|
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,
|
|
182
|
+
report(mapFile, `the binding leads nowhere: there is no file \`${path}\``);
|
|
158
183
|
} else if (!fileHasSymbol(path, symbol)) {
|
|
159
|
-
report(mapFile,
|
|
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,
|
|
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
|
-
*
|
|
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`
|
|
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
|
-
|
|
266
|
-
'
|
|
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
|
-
*
|
|
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 =
|
|
309
|
+
const SPEC_LAWS = /^\*\*(?:Laws|Законы):\*\*\s*(.+)$/;
|
|
284
310
|
/**
|
|
285
|
-
*
|
|
286
|
-
*
|
|
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,
|
|
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,
|
|
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
|
}
|