@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,49 +1,48 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* The check that a domain spec has not diverged from the code.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* текст с фактом, а не с другим текстом.
|
|
5
|
+
* The first edition audited only the scenario identifiers against test titles. A swarm review
|
|
6
|
+
* found eleven divergences from the code in a spec one day old, and the check was green on all
|
|
7
|
+
* of them: a matching identifier says neither that a rule is carried out somewhere nor that the
|
|
8
|
+
* test checks what was promised. Hence the five mechanisms below — each audits a text against a
|
|
9
|
+
* fact, not against another text.
|
|
11
10
|
*
|
|
12
|
-
* 1.
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
11
|
+
* 1. THE BINDING OF A RULE TO CODE. Lives in `implementation.md` next to the spec: the table
|
|
12
|
+
* "rule → `file:symbol`". Audited both ways — a rule without a line and a line without a
|
|
13
|
+
* rule — and it requires the file to be there and the symbol to occur in it. A rule wider
|
|
14
|
+
* than its binding cannot be written this way: "the ceiling of the sum at the intake of a
|
|
15
|
+
* request" would not have passed, because the symbol lives in the procedure of the owner's
|
|
16
|
+
* decision, and four discount mechanics that were never started would have found no binding
|
|
17
|
+
* at all. The key of the link is the text of the rule itself, so it cannot be reworded while
|
|
18
|
+
* the binding is left unfixed. A rule without a binding is an intention, and it is written as
|
|
19
|
+
* an open question of a law — `Q-<law letter>-<number>`.
|
|
21
20
|
*
|
|
22
|
-
* 2.
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
21
|
+
* 2. THE CONTRACT AGAINST THE DECORATORS. The table of procedures is audited against what is
|
|
22
|
+
* declared in the domain's `*.procedure.ts`: `@RequiresPermission` / `@PublicProcedure` and
|
|
23
|
+
* the method descriptor. Both ways — otherwise a procedure the domain serves but forgot to
|
|
24
|
+
* describe stays visible only in the decorator.
|
|
26
25
|
*
|
|
27
|
-
* 3.
|
|
28
|
-
*
|
|
29
|
-
*
|
|
26
|
+
* 3. A REFUSAL CODE WITH A THROW SITE. A code is accepted only if `Code.X` is really thrown
|
|
27
|
+
* somewhere in the libs of the domain. The codes were written out by the plan, and on one
|
|
28
|
+
* path the promised `NotFound` was thrown by nobody.
|
|
30
29
|
*
|
|
31
|
-
* 4.
|
|
32
|
-
*
|
|
33
|
-
*
|
|
30
|
+
* 4. THE LEVEL OF A BINDING. A scenario whose test goes a way other than the user's, or checks
|
|
31
|
+
* part of what was promised, is marked `Coverage: partial` and goes into the debts, not
|
|
32
|
+
* into the coverage. Otherwise a green digest means less than it seems.
|
|
34
33
|
*
|
|
35
|
-
* 5.
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
34
|
+
* 5. A DEAD BINDING. The presence of a symbol is not enough: a symbol declared and called by
|
|
35
|
+
* nobody passed the check straight through. That is how five rules about editing a record
|
|
36
|
+
* turned out to be bound to a mechanism of the shared aside base that no screen calls. A
|
|
37
|
+
* symbol declared in a file and occurring nowhere else does not count as the place where a
|
|
38
|
+
* rule is carried out.
|
|
40
39
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
40
|
+
* Each mechanism lives in a module of its own alongside: bindings and laws — `spec-anchors.mjs`,
|
|
41
|
+
* the contract and the refusal codes — `spec-contract.mjs`, scenarios and coverage —
|
|
42
|
+
* `spec-scenarios.mjs`, the common reading of the tree — `spec-common.mjs`. What is left here is
|
|
43
|
+
* the run: it walks the domains and puts what it found into one list.
|
|
45
44
|
*
|
|
46
|
-
*
|
|
45
|
+
* A non-zero return code and a list of divergences.
|
|
47
46
|
*/
|
|
48
47
|
import { readdirSync } from 'node:fs';
|
|
49
48
|
import { dirname, join } from 'node:path';
|
|
@@ -55,7 +54,7 @@ import { checkContract, checkRefusalCodes, procedureRootsOf } from './spec-contr
|
|
|
55
54
|
import { proposedGroups, staleProposed } from './spec-proposed.mjs';
|
|
56
55
|
import { collectReferences, parseScenarios, promisesScreen } from './spec-scenarios.mjs';
|
|
57
56
|
|
|
58
|
-
// ──
|
|
57
|
+
// ── run ───────────────────────────────────────────────────────────────────────
|
|
59
58
|
|
|
60
59
|
function checkSpecHeadings(file, text) {
|
|
61
60
|
const headings = new Set(
|
|
@@ -65,8 +64,10 @@ function checkSpecHeadings(file, text) {
|
|
|
65
64
|
.map((line) => line.trimEnd())
|
|
66
65
|
);
|
|
67
66
|
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
// A section is mandatory under either of its names, and the refusal names the first — the one a
|
|
68
|
+
// new spec is written by.
|
|
69
|
+
REQUIRED_HEADINGS.filter((names) => !names.some((name) => headings.has(name))).forEach(([required]) =>
|
|
70
|
+
report(file, `no mandatory section \`${required}\``)
|
|
70
71
|
);
|
|
71
72
|
}
|
|
72
73
|
|
|
@@ -75,32 +76,33 @@ const scenarios = [];
|
|
|
75
76
|
const byId = new Map();
|
|
76
77
|
|
|
77
78
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
79
|
+
* The names of the laws and the path to each. There are two layers: the common one lies at the
|
|
80
|
+
* root of `docs/constitution/`, the application laws in `application/` under it. The name is taken
|
|
81
|
+
* without the directory, because a law is named the same everywhere: neither `law:` in a rule's
|
|
82
|
+
* front matter nor `**Laws:**` in a spec knows which layer it is in, and a move between layers
|
|
83
|
+
* rewrites none of those lines.
|
|
82
84
|
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
85
|
+
* Hence the requirement: law names are unique across the whole constitution tree. Two files with
|
|
86
|
+
* one name in different layers would be named by the same `law:` line, and the rule would go to
|
|
87
|
+
* whichever of them was walked first.
|
|
86
88
|
*/
|
|
87
89
|
const laws = new Map();
|
|
88
90
|
for (const file of walk(CONSTITUTION_DIR, (name) => name.endsWith('.md'))) {
|
|
89
91
|
const name = file.slice(file.lastIndexOf('/') + 1, -'.md'.length);
|
|
90
92
|
if (laws.has(name)) {
|
|
91
|
-
report(file,
|
|
93
|
+
report(file, `a law of that name already exists — \`${laws.get(name)}\`; law names are unique across both layers`);
|
|
92
94
|
continue;
|
|
93
95
|
}
|
|
94
96
|
laws.set(name, file);
|
|
95
97
|
}
|
|
96
98
|
|
|
97
99
|
/**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
100
|
+
* The directories that describe a subject: the domain itself and its subdomains. A subdomain is
|
|
101
|
+
* started when a domain has grown so large that reading it whole for one detail costs more than
|
|
102
|
+
* finding that detail; it is arranged the same way — three files and a scenario prefix of its own.
|
|
101
103
|
*
|
|
102
|
-
* `proposed/`
|
|
103
|
-
*
|
|
104
|
+
* `proposed/` is not a subject: it is a product agreement written before the code, and its
|
|
105
|
+
* scenarios live in the numbering of the spec it will merge into.
|
|
104
106
|
*/
|
|
105
107
|
function collectSpecDirs(base) {
|
|
106
108
|
const found = [base];
|
|
@@ -120,30 +122,30 @@ function collectSpecDirs(base) {
|
|
|
120
122
|
return found;
|
|
121
123
|
}
|
|
122
124
|
|
|
123
|
-
/**
|
|
125
|
+
/** A scenario prefix belongs to one spec across the whole tree. */
|
|
124
126
|
const prefixOwners = new Map();
|
|
125
127
|
|
|
126
128
|
for (const domain of domains) {
|
|
127
129
|
const base = `${SPECS_DIR}/${domain}`;
|
|
128
130
|
for (const dir of collectSpecDirs(base)) {
|
|
129
|
-
//
|
|
130
|
-
//
|
|
131
|
+
// A spec that has only `proposed/` does not exist yet: it itself is absent until the
|
|
132
|
+
// feature is rolled out
|
|
131
133
|
if (exists(`${dir}/proposed`) && !exists(`${dir}/spec.md`)) {
|
|
132
134
|
continue;
|
|
133
135
|
}
|
|
134
|
-
const what = dir === base ? '
|
|
136
|
+
const what = dir === base ? 'the domain' : 'the subdomain';
|
|
135
137
|
['spec.md', 'scenarios.md']
|
|
136
138
|
.filter((name) => !exists(`${dir}/${name}`))
|
|
137
|
-
.forEach((name) => report(dir,
|
|
139
|
+
.forEach((name) => report(dir, `no file \`${name}\` — ${what} is described by half`));
|
|
138
140
|
}
|
|
139
141
|
|
|
140
|
-
//
|
|
141
|
-
//
|
|
142
|
-
//
|
|
142
|
+
// Feature specs from `proposed/` are checked on a par with the domain spec: they are the
|
|
143
|
+
// product agreement the code is written by, not a draft. The three audits against the code
|
|
144
|
+
// do not apply to them — there is no code yet to audit against
|
|
143
145
|
for (const specFile of walk(base, (name) => name === 'spec.md')) {
|
|
144
146
|
const text = read(specFile);
|
|
145
147
|
checkSpecHeadings(specFile, text);
|
|
146
|
-
//
|
|
148
|
+
// A spec declares its laws in `proposed/` as well: the product agreement exists before the code
|
|
147
149
|
checkSpecLaws(specFile, text, laws);
|
|
148
150
|
if (specFile.includes('/proposed/')) {
|
|
149
151
|
continue;
|
|
@@ -156,11 +158,11 @@ for (const domain of domains) {
|
|
|
156
158
|
|
|
157
159
|
const found = walk(base, (name) => name === 'scenarios.md').flatMap(parseScenarios);
|
|
158
160
|
|
|
159
|
-
//
|
|
160
|
-
//
|
|
161
|
-
//
|
|
162
|
-
//
|
|
163
|
-
//
|
|
161
|
+
// The prefix belongs to the domain together with its subdomains, not to a separate directory.
|
|
162
|
+
// A domain is split when its spec has outgrown the length limit, and the scenarios move into
|
|
163
|
+
// the subdomains unchanged: the number is the only thing binding a scenario to a test title,
|
|
164
|
+
// and a numbering of its own for each subdomain would mean recounting every number at once.
|
|
165
|
+
// Two prefixes in one spec still mean the subject is described twice.
|
|
164
166
|
const prefixesOf = new Map();
|
|
165
167
|
for (const scenario of found) {
|
|
166
168
|
const dir = dirname(scenario.file);
|
|
@@ -172,17 +174,17 @@ for (const domain of domains) {
|
|
|
172
174
|
|
|
173
175
|
for (const [dir, prefixes] of prefixesOf) {
|
|
174
176
|
if (prefixes.size > 1) {
|
|
175
|
-
report(dir,
|
|
177
|
+
report(dir, `the spec carries more than one scenario prefix: ${[...prefixes].sort().join(', ')}`);
|
|
176
178
|
}
|
|
177
|
-
//
|
|
178
|
-
//
|
|
179
|
+
// A product agreement is numbered together with the spec it will merge into: the
|
|
180
|
+
// identifiers survive the move, and the prefix does not become taken because of it
|
|
179
181
|
if (dir.includes('/proposed/')) {
|
|
180
182
|
continue;
|
|
181
183
|
}
|
|
182
184
|
for (const prefix of prefixes) {
|
|
183
185
|
const owner = prefixOwners.get(prefix);
|
|
184
186
|
if (owner && owner !== base) {
|
|
185
|
-
report(dir,
|
|
187
|
+
report(dir, `the prefix \`SC-${prefix}\` is already taken — \`${owner}\`; by the number there is no seeing whose scenario it is`);
|
|
186
188
|
continue;
|
|
187
189
|
}
|
|
188
190
|
prefixOwners.set(prefix, base);
|
|
@@ -192,36 +194,50 @@ for (const domain of domains) {
|
|
|
192
194
|
scenarios.push(...found);
|
|
193
195
|
}
|
|
194
196
|
|
|
195
|
-
//
|
|
196
|
-
//
|
|
197
|
-
//
|
|
198
|
-
//
|
|
197
|
+
// A law knows nothing about the project: no paths, no file names, no bindings. It only declares
|
|
198
|
+
// articles, and everything else is the business of the rules that refer to it. So a law has no
|
|
199
|
+
// sidecar with bindings and cannot have one: a file with `libs/...` paths lying next to a law
|
|
200
|
+
// would bind the law to this project.
|
|
199
201
|
//
|
|
200
|
-
//
|
|
201
|
-
//
|
|
202
|
-
//
|
|
203
|
-
|
|
202
|
+
// "Open questions" is taken out from here: the check saw the heading and not the questions under
|
|
203
|
+
// it, and an empty section passed it just as a filled one did. A law with everything settled wrote
|
|
204
|
+
// that line for the sake of the line.
|
|
205
|
+
//
|
|
206
|
+
// The section has two names: an English one in a package law, a Russian one in a law the tree
|
|
207
|
+
// wrote before the layer was translated. Both mean one thing, and the check accepts either.
|
|
208
|
+
const LAW_HEADINGS = [['## Articles', '## Статьи']];
|
|
204
209
|
|
|
205
210
|
for (const file of walk(CONSTITUTION_DIR, (name) => name.endsWith('.md'))) {
|
|
206
211
|
const text = read(file);
|
|
207
|
-
|
|
208
|
-
|
|
212
|
+
const lines = text.split('\n').map((line) => line.trimEnd());
|
|
213
|
+
LAW_HEADINGS.filter((names) => !names.some((heading) => lines.includes(heading))).forEach((names) =>
|
|
214
|
+
report(file, `no section \`${names[0]}\` (or \`${names[1]}\`)`)
|
|
209
215
|
);
|
|
210
216
|
if (/`[\w./-]+\.(ts|mjs|js|sh|scss|html|json|proto|conf|yml|md)[:`]/.test(text)) {
|
|
211
|
-
report(file, '
|
|
217
|
+
report(file, 'the law names a project file — paths and bindings belong in a rule, not here');
|
|
212
218
|
}
|
|
213
219
|
}
|
|
214
220
|
|
|
215
|
-
//
|
|
216
|
-
//
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
221
|
+
// A rule is a skill with `kind: rule` in its front matter. It is the one that knows about the
|
|
222
|
+
// project: names, paths, links. The binding of its statements to the code lives in
|
|
223
|
+
// `implementation.md` next to the skill.
|
|
224
|
+
// The section has two names: an English one in a package rule, a Russian one in a rule the tree
|
|
225
|
+
// wrote before the layer was translated. The one that stands in the file is taken.
|
|
226
|
+
const RULE_HEADINGS = ['## How the law applies here', '## Как закон применяется здесь'];
|
|
227
|
+
const ruleHeadingOf = (text) => RULE_HEADINGS.find((heading) => text.split('\n').some((line) => line.trimEnd() === heading)) ?? RULE_HEADINGS[0];
|
|
228
|
+
/**
|
|
229
|
+
* The companion section of a rule where the bindings lie; its other tables name the tree's names.
|
|
230
|
+
* Two names again: the companion is written by the tree, and a tree translates its companions one
|
|
231
|
+
* rule at a time. The one that stands in the file is taken.
|
|
232
|
+
*/
|
|
233
|
+
const MAP_HEADINGS = ['## Where the articles are carried out', '## Где исполняются статьи'];
|
|
234
|
+
const mapHeadingOf = (text) =>
|
|
235
|
+
MAP_HEADINGS.find((heading) => text.split('\n').some((line) => line.trimEnd() === heading)) ?? MAP_HEADINGS[0];
|
|
220
236
|
|
|
221
237
|
/**
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
238
|
+
* The front matter of a skill — the first block between `---`. Only it is read: the pattern that
|
|
239
|
+
* teaches how to start a rule shows a rule's front matter as an example in a fence, and a search
|
|
240
|
+
* over the whole text would take that example for a real declaration.
|
|
225
241
|
*/
|
|
226
242
|
function frontMatterOf(text) {
|
|
227
243
|
const found = text.match(/^---\n([\s\S]*?)\n---/);
|
|
@@ -229,7 +245,7 @@ function frontMatterOf(text) {
|
|
|
229
245
|
return found ? found[1] : '';
|
|
230
246
|
}
|
|
231
247
|
|
|
232
|
-
/**
|
|
248
|
+
/** The rules and patterns found in the skills tree: both sides of the link are counted by them. */
|
|
233
249
|
const ruled = new Set();
|
|
234
250
|
const patterned = new Set();
|
|
235
251
|
const nameOf = (head) => (head.match(/^name:\s*(\S+)/m) || [])[1] || '';
|
|
@@ -242,9 +258,9 @@ for (const file of walk('.claude/skills', (name) => name === 'SKILL.md')) {
|
|
|
242
258
|
if (kind === 'pattern') {
|
|
243
259
|
const rule = (head.match(/^rule:\s*(\S+)/m) || [])[1];
|
|
244
260
|
if (!rule) {
|
|
245
|
-
report(file, '
|
|
261
|
+
report(file, 'the pattern declared no rule — add `rule:` to the header');
|
|
246
262
|
} else if (!exists(`.claude/skills/${rule}/SKILL.md`)) {
|
|
247
|
-
report(file,
|
|
263
|
+
report(file, `the pattern declared the rule \`${rule}\`, and there is no rule of that name`);
|
|
248
264
|
} else {
|
|
249
265
|
patterned.add(rule);
|
|
250
266
|
}
|
|
@@ -257,38 +273,41 @@ for (const file of walk('.claude/skills', (name) => name === 'SKILL.md')) {
|
|
|
257
273
|
|
|
258
274
|
const law = (head.match(/^law:\s*(\S+)/m) || [])[1];
|
|
259
275
|
if (!law) {
|
|
260
|
-
report(file, '
|
|
276
|
+
report(file, 'the rule declared no law — add `law:` to the header');
|
|
261
277
|
} else if (!laws.has(law)) {
|
|
262
|
-
report(file,
|
|
278
|
+
report(file, `the rule declared the law \`${law}\`, and there is no law of that name in any layer`);
|
|
263
279
|
} else {
|
|
264
280
|
ruled.add(law);
|
|
265
281
|
}
|
|
266
|
-
|
|
282
|
+
const mapFile = `${dirname(file)}/implementation.md`;
|
|
283
|
+
|
|
284
|
+
checkRuleImplementation(file, text, mapFile, ruleHeadingOf(text), mapHeadingOf(read(mapFile)));
|
|
267
285
|
|
|
268
286
|
const name = nameOf(head);
|
|
269
287
|
if (name && name !== file.slice('.claude/skills/'.length, -'/SKILL.md'.length)) {
|
|
270
|
-
report(file,
|
|
288
|
+
report(file, `the name in the header (\`${name}\`) does not match the directory of the rule`);
|
|
271
289
|
}
|
|
272
290
|
}
|
|
273
291
|
|
|
274
|
-
//
|
|
275
|
-
//
|
|
276
|
-
//
|
|
277
|
-
|
|
292
|
+
// A proposed law requires no rule: the agreement is written before the code, there is nothing to
|
|
293
|
+
// bind it to, and requiring a rule would force starting one with anchors into places that do not
|
|
294
|
+
// exist. The sign stands as a status line in the law itself, not as a list of exceptions next to
|
|
295
|
+
// the check.
|
|
296
|
+
const isProposedLaw = (file) => /^\*\*(?:Status:\*\*\s*proposed|Статус:\*\*\s*предложен)/m.test(read(file));
|
|
278
297
|
|
|
279
|
-
//
|
|
280
|
-
//
|
|
281
|
-
//
|
|
298
|
+
// The reverse sides of the link. A law without a rule reads as an agreement this project does not
|
|
299
|
+
// apply; a rule without a pattern leaves ready-made code where it does not belong — in the rule
|
|
300
|
+
// itself, which is read at every edit.
|
|
282
301
|
[...laws]
|
|
283
302
|
.filter(([law, file]) => !ruled.has(law) && !isProposedLaw(file))
|
|
284
|
-
.forEach(([, file]) => report(file, '
|
|
303
|
+
.forEach(([, file]) => report(file, 'the law has no rule at all — create one with `law:` pointing at it'));
|
|
285
304
|
|
|
286
305
|
/**
|
|
287
|
-
*
|
|
306
|
+
* The names of the patterns the tree skipped at layout: the `skip` key in the project settings.
|
|
288
307
|
*
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
308
|
+
* A skip is the tree's choice, not forgotten work: the rule about backend procedures is laid out
|
|
309
|
+
* into a tree that has no backend at all. Requiring a pattern there means requiring a file with
|
|
310
|
+
* nothing to say — and the only way to go green becomes lifting the skip.
|
|
292
311
|
*/
|
|
293
312
|
const skippedPatterns = () => {
|
|
294
313
|
const path = '.claude/rt-kit.json';
|
|
@@ -305,12 +324,14 @@ const skippedPatterns = () => {
|
|
|
305
324
|
};
|
|
306
325
|
|
|
307
326
|
/**
|
|
308
|
-
*
|
|
309
|
-
*
|
|
327
|
+
* The "Patterns" section of the rule itself is the only place where the link is visible without a
|
|
328
|
+
* pattern file: a skipped file is not in the tree, and there is nobody to ask for the `rule:`
|
|
329
|
+
* field in it.
|
|
310
330
|
*/
|
|
311
|
-
//
|
|
312
|
-
//
|
|
313
|
-
|
|
331
|
+
// The `m` flag is deliberately absent here: with it `$` means the end of a line, and the section
|
|
332
|
+
// ends at the very first newline — empty. So the start of the heading is found by a pair of its
|
|
333
|
+
// own, not by an anchor.
|
|
334
|
+
const PATTERNS_HEADING = /(?:^|\n)## (?:Patterns|Паттерны)\n([\s\S]*?)(?=\n## |$)/;
|
|
314
335
|
const patternsNamedBy = (text) => [...(text.match(PATTERNS_HEADING)?.[1] ?? '').matchAll(/^-\s+`([\w-]+)`/gm)].map(([, found]) => found);
|
|
315
336
|
|
|
316
337
|
const skipped = skippedPatterns();
|
|
@@ -328,7 +349,7 @@ for (const file of walk('.claude/skills', (name) => name === 'SKILL.md')) {
|
|
|
328
349
|
continue;
|
|
329
350
|
}
|
|
330
351
|
|
|
331
|
-
report(file, '
|
|
352
|
+
report(file, 'the rule has no pattern at all — create one with `rule:` pointing at it');
|
|
332
353
|
}
|
|
333
354
|
|
|
334
355
|
checkTracedAnchors();
|
|
@@ -336,7 +357,7 @@ checkTracedAnchors();
|
|
|
336
357
|
for (const scenario of scenarios) {
|
|
337
358
|
const seen = byId.get(scenario.id);
|
|
338
359
|
if (seen) {
|
|
339
|
-
report(`${scenario.file}:${scenario.line}`,
|
|
360
|
+
report(`${scenario.file}:${scenario.line}`, `the identifier ${scenario.id} is already taken (${seen.file}:${seen.line})`);
|
|
340
361
|
continue;
|
|
341
362
|
}
|
|
342
363
|
byId.set(scenario.id, scenario);
|
|
@@ -351,7 +372,7 @@ for (const scenario of byId.values()) {
|
|
|
351
372
|
const places = references.get(scenario.id) ?? [];
|
|
352
373
|
const hasTest = places.length > 0;
|
|
353
374
|
if (scenario.uncovered && hasTest) {
|
|
354
|
-
report(`${scenario.file}:${scenario.line}`, `${scenario.id}
|
|
375
|
+
report(`${scenario.file}:${scenario.line}`, `${scenario.id} is marked «Not covered», and there is a test for it (${places[0].place})`);
|
|
355
376
|
continue;
|
|
356
377
|
}
|
|
357
378
|
if (scenario.uncovered) {
|
|
@@ -359,21 +380,21 @@ for (const scenario of byId.values()) {
|
|
|
359
380
|
continue;
|
|
360
381
|
}
|
|
361
382
|
if (!hasTest) {
|
|
362
|
-
report(`${scenario.file}:${scenario.line}`, `${scenario.id}
|
|
383
|
+
report(`${scenario.file}:${scenario.line}`, `${scenario.id} is mentioned in no test and is not marked «Not covered»`);
|
|
363
384
|
continue;
|
|
364
385
|
}
|
|
365
386
|
if (scenario.partial) {
|
|
366
387
|
partial.push(scenario);
|
|
367
388
|
continue;
|
|
368
389
|
}
|
|
369
|
-
//
|
|
370
|
-
//
|
|
371
|
-
if (promisesScreen(scenario.promise) && !places.some(({ screen, off }) => screen && !off)) {
|
|
390
|
+
// A promise given to the user is closed by a test that goes the user's way. A unit test checks
|
|
391
|
+
// the same computation past the screen: it is right and it is not coverage of the scenario
|
|
392
|
+
if (promisesScreen(scenario.promise, scenario.body) && !places.some(({ screen, off }) => screen && !off)) {
|
|
372
393
|
const off = places.some(({ screen }) => screen);
|
|
373
394
|
report(
|
|
374
395
|
`${scenario.file}:${scenario.line}`,
|
|
375
|
-
`${scenario.id}
|
|
376
|
-
`(${places[0].place}) —
|
|
396
|
+
`${scenario.id} promises what a person sees, and ${off ? 'the end-to-end test for it is switched off by an environment variable' : 'only a unit test checks it'} ` +
|
|
397
|
+
`(${places[0].place}) — either the test goes the path of the user, or the scenario needs the mark «Покрытие: частичное»`
|
|
377
398
|
);
|
|
378
399
|
continue;
|
|
379
400
|
}
|
|
@@ -382,39 +403,39 @@ for (const scenario of byId.values()) {
|
|
|
382
403
|
|
|
383
404
|
for (const [id, places] of references) {
|
|
384
405
|
if (!byId.has(id)) {
|
|
385
|
-
report(places[0].place,
|
|
406
|
+
report(places[0].place, `the test refers to ${id}, and \`${SPECS_DIR}\` carries no such scenario`);
|
|
386
407
|
}
|
|
387
408
|
}
|
|
388
409
|
|
|
389
410
|
if (problems.length > 0) {
|
|
390
|
-
console.error(`check-specs:
|
|
411
|
+
console.error(`check-specs: divergences ${problems.length}\n`);
|
|
391
412
|
problems.forEach((problem) => console.error(` ${problem}`));
|
|
392
|
-
console.error('\
|
|
413
|
+
console.error('\nThe rules of working with specs are `spec-driven`.');
|
|
393
414
|
process.exit(1);
|
|
394
415
|
}
|
|
395
416
|
|
|
396
417
|
console.log(
|
|
397
|
-
`check-specs:
|
|
398
|
-
|
|
418
|
+
`check-specs: domains ${domains.length}, scenarios ${byId.size} — ` +
|
|
419
|
+
`covered ${covered}, partial ${partial.length}, without tests ${uncovered.length}`
|
|
399
420
|
);
|
|
400
421
|
|
|
401
422
|
const debts = [...partial, ...uncovered];
|
|
402
423
|
if (debts.length > 0) {
|
|
403
|
-
console.log('\
|
|
404
|
-
partial.forEach((scenario) => console.log(`
|
|
405
|
-
uncovered.forEach((scenario) => console.log(`
|
|
424
|
+
console.log('\nDebts — the coverage is not complete:');
|
|
425
|
+
partial.forEach((scenario) => console.log(` partial ${scenario.id} — ${scenario.title} (${scenario.file}:${scenario.line})`));
|
|
426
|
+
uncovered.forEach((scenario) => console.log(` no test ${scenario.id} — ${scenario.title} (${scenario.file}:${scenario.line})`));
|
|
406
427
|
}
|
|
407
428
|
|
|
408
429
|
const proposed = proposedGroups(byId.values(), references);
|
|
409
430
|
|
|
410
431
|
const ripe = [...proposed].filter(([, group]) => group.total > 0 && group.total === group.ready);
|
|
411
432
|
if (ripe.length > 0) {
|
|
412
|
-
console.log('\
|
|
413
|
-
ripe.forEach(([dir, group]) => console.log(` ${dir} —
|
|
433
|
+
console.log('\nTime to merge — the scenarios are closed by tests, the agreement awaits the move into the domain spec:');
|
|
434
|
+
ripe.forEach(([dir, group]) => console.log(` ${dir} — scenarios ${group.total}`));
|
|
414
435
|
}
|
|
415
436
|
|
|
416
437
|
const stale = staleProposed([...proposed.keys()]);
|
|
417
438
|
if (stale.length > 0) {
|
|
418
|
-
console.log('\
|
|
419
|
-
stale.forEach((record) => console.log(` ${record.dir} — ${Math.floor(record.ageDays)}
|
|
439
|
+
console.log('\nWaiting longer than a month — the binding in the agreement ages together with the code it points at:');
|
|
440
|
+
stale.forEach((record) => console.log(` ${record.dir} — ${Math.floor(record.ageDays)} days without edits`));
|
|
420
441
|
}
|