@rt-tools/agent-kit 0.23.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -2
- package/assets/agents/business-analyst.md +51 -50
- 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-epics.github.mjs +75 -41
- 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 +24 -24
- package/assets/checks/board-paths.github.mjs +21 -16
- package/assets/checks/board-runs.github.mjs +45 -43
- package/assets/checks/board-titles.github.mjs +19 -17
- package/assets/checks/board.github.mjs +150 -128
- package/assets/checks/check-archive-age.mjs +23 -19
- package/assets/checks/check-board.github.mjs +179 -157
- package/assets/checks/check-descriptions.mjs +30 -29
- package/assets/checks/check-doc-paths.mjs +104 -82
- package/assets/checks/check-dupes.mjs +84 -80
- package/assets/checks/check-file-size.mjs +79 -70
- 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 +125 -33
- package/assets/checks/check-push-gate.mjs +53 -50
- package/assets/checks/check-reuse.mjs +50 -40
- package/assets/checks/check-schema-drift.mjs +87 -83
- 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/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 +174 -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/task-new.github.mjs +85 -56
- package/assets/commands/feedback.md +65 -59
- package/assets/commands/next-session.md +64 -57
- package/assets/commands/skill-curator.md +83 -79
- package/assets/defaults/gate-map.sh +115 -91
- package/assets/defaults/project.sh +228 -178
- package/assets/defaults/shell.sh +85 -65
- package/assets/defaults/turn-map.md +45 -44
- package/assets/docs/GLOSSARY.md +142 -65
- package/assets/hooks/browser-device-id.sh +12 -12
- package/assets/hooks/browser-guard-device-id.sh +46 -14
- 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 +11 -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 +46 -43
- package/assets/hooks/dispatch.sh +84 -39
- package/assets/hooks/docs-guard.sh +105 -86
- package/assets/hooks/exam-guard.sh +146 -84
- package/assets/hooks/git-guard-delivery-conflict.sh +38 -36
- package/assets/hooks/git-guard-delivery-draft.sh +85 -0
- package/assets/hooks/git-guard-delivery-folder.sh +50 -43
- package/assets/hooks/git-guard-delivery-signature.sh +88 -52
- package/assets/hooks/git-guard-delivery.sh +207 -253
- package/assets/hooks/git-guard-main.sh +65 -26
- package/assets/hooks/git-guard-push-tests.sh +133 -75
- 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 +26 -24
- package/assets/hooks/handoff-write.sh +74 -67
- package/assets/hooks/hook-input.sh +70 -50
- 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 +19 -17
- package/assets/hooks/qa-dataid-guard.sh +52 -49
- 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 +36 -34
- package/assets/hooks/rule-source-guard.sh +52 -36
- package/assets/hooks/skill-gate-layers.sh +59 -57
- package/assets/hooks/skill-gate-rearm.sh +15 -8
- package/assets/hooks/skill-gate.sh +89 -81
- package/assets/hooks/skill-loaded.sh +6 -6
- package/assets/hooks/sql-guard-parse.sh +68 -66
- package/assets/hooks/sql-guard-request.sh +48 -46
- package/assets/hooks/sql-guard-target.sh +57 -51
- package/assets/hooks/sql-guard-write.sh +84 -79
- package/assets/hooks/sql-guard.sh +52 -47
- package/assets/hooks/stand-login-guard.sh +104 -0
- 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 +256 -204
- package/assets/hooks/turn-exit-patterns.sh +53 -0
- package/assets/hooks/utf8.sh +11 -11
- package/assets/hooks/waiting-turn-guard.sh +94 -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 +115 -30
- package/assets/laws/autonomous-work.md +29 -27
- package/assets/laws/code-structure.md +31 -30
- package/assets/laws/delivery.md +148 -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 -114
- package/assets/laws/work-conduct.md +250 -250
- 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 +143 -67
- package/assets/patterns/browser-verification-stand.md +181 -128
- package/assets/patterns/component-structure-new.md +51 -42
- package/assets/patterns/dependencies-upgrade.md +55 -39
- package/assets/patterns/doc-style-human.md +93 -0
- 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 -75
- package/assets/patterns/git-workflow-commit.github.md +153 -129
- package/assets/patterns/git-workflow-commit.gitlab.md +96 -78
- 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 +99 -86
- 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 +126 -121
- package/assets/patterns/git-workflow-pr.github.md +179 -175
- package/assets/patterns/git-workflow-pr.gitlab.md +138 -131
- 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 +131 -106
- 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 +37 -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 +215 -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 +204 -192
- package/assets/patterns/testing-e2e.md +103 -92
- 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 +152 -141
- package/assets/pitfalls/doc-style.md +96 -91
- package/assets/pitfalls/git-workflow.azure.md +49 -46
- package/assets/pitfalls/git-workflow.github.md +264 -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 +75 -74
- package/assets/rules/browser-verification.md +223 -188
- 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 +209 -148
- 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 +250 -242
- 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 -137
- package/assets/rules/shared-code.md +82 -79
- package/assets/rules/spec-driven.md +272 -260
- package/assets/rules/status-report.md +55 -58
- package/assets/rules/styling-bem.md +83 -72
- package/assets/rules/task-flow.md +282 -270
- package/assets/rules/testing.md +224 -188
- package/assets/rules/turn-conduct.md +255 -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 +236 -222
- 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/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 +68 -4
- 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 +13 -4
- package/lib/enroll.js.map +1 -1
- package/lib/observations.d.ts +10 -1
- package/lib/observations.d.ts.map +1 -1
- package/lib/observations.js +1 -0
- package/lib/observations.js.map +1 -1
- package/lib/override-marks.d.ts +24 -0
- package/lib/override-marks.d.ts.map +1 -0
- package/lib/override-marks.js +98 -0
- package/lib/override-marks.js.map +1 -0
- 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 +0 -7
- package/lib/ship.d.ts.map +1 -1
- package/lib/ship.js +10 -2
- package/lib/ship.js.map +1 -1
- package/lib/shipment.d.ts.map +1 -1
- package/lib/shipment.js +7 -3
- 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.26.0.tgz +0 -0
- package/rt-tools-agent-kit-0.23.0.tgz +0 -0
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* The audit of the length of rule and pattern descriptions.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* A description travels into the system prompt of every session — all of them, as many as
|
|
6
|
+
* the tree has — and that session pays for them whatever it is doing. That is how it differs
|
|
7
|
+
* from the body of the rule: the body the executor reads itself and pays for it with a turn,
|
|
8
|
+
* while the description comes free. Free — as long as it is short.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* It grows by itself: a description is written after the rule and retells its content.
|
|
11
|
+
* No check counted the length, and in the tree where this audit was created forty
|
|
12
|
+
* descriptions out of seventy-four had outgrown the limit.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* A description answers one question — take this rule or not. Everything that answers the
|
|
15
|
+
* question "and what is inside" comes a second time together with the rule itself.
|
|
16
16
|
*
|
|
17
|
-
* FAIL-OPEN:
|
|
17
|
+
* FAIL-OPEN: there is no skills directory in the tree — nothing to check, zero code.
|
|
18
18
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* A description longer than the limit, left deliberately, is named in the list of accepted
|
|
20
|
+
* debt next to it — by the skill name, with a reason. A silent excess and a deliberate one
|
|
21
|
+
* look the same, so the second is named in a list.
|
|
22
22
|
*
|
|
23
|
-
*
|
|
23
|
+
* A non-zero exit code and the list of those over the limit with the numbers.
|
|
24
24
|
*/
|
|
25
25
|
import { existsSync, readFileSync, readdirSync } from 'node:fs';
|
|
26
26
|
import { join } from 'node:path';
|
|
@@ -30,21 +30,22 @@ const SKILLS = join(ROOT, '.claude/skills');
|
|
|
30
30
|
const DEBT = join(ROOT, '.claude/rt-kit/description-debt.json');
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
33
|
+
* The limit of a description length in characters.
|
|
34
34
|
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
35
|
+
* Characters are counted, not bytes: a byte says nothing about the cost of the window, and
|
|
36
|
+
* Cyrillic makes it one and a half times bigger than a character. Three hundred is the owner's
|
|
37
|
+
* number, set from the first measurement.
|
|
37
38
|
*/
|
|
38
39
|
const LIMIT = 300;
|
|
39
40
|
|
|
40
|
-
/**
|
|
41
|
+
/** The description from the header: the `description:` line up to the end of the line. */
|
|
41
42
|
function descriptionOf(text) {
|
|
42
43
|
const match = /^description:\s*(.+)$/m.exec(text);
|
|
43
44
|
|
|
44
45
|
return match === null ? null : match[1].trim();
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
/**
|
|
48
|
+
/** The list of accepted debt: skill name → reason. No file — no debt. */
|
|
48
49
|
function debt() {
|
|
49
50
|
if (!existsSync(DEBT)) {
|
|
50
51
|
return {};
|
|
@@ -59,7 +60,7 @@ function debt() {
|
|
|
59
60
|
|
|
60
61
|
function main() {
|
|
61
62
|
if (!existsSync(SKILLS)) {
|
|
62
|
-
console.log('check-descriptions:
|
|
63
|
+
console.log('check-descriptions: there is no directory of rules — there is nothing to check');
|
|
63
64
|
|
|
64
65
|
return 0;
|
|
65
66
|
}
|
|
@@ -89,7 +90,7 @@ function main() {
|
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
if (Object.hasOwn(accepted, name)) {
|
|
92
|
-
owed.push(`${name}: ${description.length}
|
|
93
|
+
owed.push(`${name}: ${description.length} characters — ${accepted[name]}`);
|
|
93
94
|
continue;
|
|
94
95
|
}
|
|
95
96
|
|
|
@@ -97,25 +98,25 @@ function main() {
|
|
|
97
98
|
}
|
|
98
99
|
|
|
99
100
|
for (const line of owed) {
|
|
100
|
-
console.log(`
|
|
101
|
+
console.log(` debt ${line}`);
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
if (over.length > 0) {
|
|
104
105
|
over.sort((first, second) => second.length - first.length);
|
|
105
|
-
console.log(`check-descriptions:
|
|
106
|
+
console.log(`check-descriptions: longer than the limit ${over.length} of ${counted}, the limit is ${LIMIT} characters\n`);
|
|
106
107
|
|
|
107
108
|
for (const item of over) {
|
|
108
|
-
console.log(` ${item.name}: ${item.length}
|
|
109
|
+
console.log(` ${item.name}: ${item.length} characters, ${item.length - LIMIT} over`);
|
|
109
110
|
}
|
|
110
111
|
|
|
111
|
-
console.log('\
|
|
112
|
-
console.log('
|
|
113
|
-
console.log('
|
|
112
|
+
console.log('\nA description answers one question — load this rule or not. A list of sections');
|
|
113
|
+
console.log('and a retelling of the articles arrive a second time together with the rule itself.');
|
|
114
|
+
console.log('What is left longer on purpose is named in .claude/rt-kit/description-debt.json with a reason.');
|
|
114
115
|
|
|
115
116
|
return 1;
|
|
116
117
|
}
|
|
117
118
|
|
|
118
|
-
console.log(`check-descriptions:
|
|
119
|
+
console.log(`check-descriptions: descriptions ${counted}, all within the limit of ${LIMIT} characters` + (owed.length > 0 ? `, accepted debt ${owed.length}` : ''));
|
|
119
120
|
|
|
120
121
|
return 0;
|
|
121
122
|
}
|
|
@@ -1,80 +1,82 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* The check that the addresses named in the documentation exist.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* A document referring to a file that has disappeared is worse than a missing one: it looks like
|
|
6
|
+
* a working reference and takes the reader into a directory that is not there. This accumulates
|
|
7
|
+
* silently — a rearrangement of the tree fixes the code and breaks the text, and nobody collects
|
|
8
|
+
* the text.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* Only addresses in backticks and outside code blocks count: the blocks hold commands and output,
|
|
11
|
+
* where a path to something built is the result of a build, not a file of the repository. Patterns
|
|
12
|
+
* (`*`, `<…>`, `{…}`) are skipped: that is the form of an address, not an address.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* An address comes in three kinds, and all three are judged alike: a path rooted in the tree, a
|
|
15
|
+
* bare file name and a directory. Half of the "Where this lies" tables are taken by directories,
|
|
16
|
+
* and a check that knows only a string with an extension does not see them at all.
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
18
|
+
* Documents that by their nature speak of what does not exist — plans of the future, the archive
|
|
19
|
+
* and task folders — are taken out of the check. So is portable text: its addresses belong to the
|
|
20
|
+
* tree the rule is laid out into, and in that they are examples, not links.
|
|
21
21
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
22
|
+
* On a second pass the completeness of a directory index is audited: the overview document lists
|
|
23
|
+
* the records in a table, and the reader searches by it, not by walking. This is the reverse side
|
|
24
|
+
* of the same agreement — not only does an address in a text lead to a file, but a file is named
|
|
25
|
+
* in the text people look for it by.
|
|
26
26
|
*
|
|
27
|
-
*
|
|
27
|
+
* A non-zero return code and a list of divergences.
|
|
28
28
|
*/
|
|
29
29
|
import { spawnSync } from 'node:child_process';
|
|
30
30
|
import { existsSync, readFileSync, readdirSync } from 'node:fs';
|
|
31
|
-
import { join } from 'node:path';
|
|
31
|
+
import { join, posix } from 'node:path';
|
|
32
32
|
|
|
33
33
|
import { allowlistOf, CONFIG, ROOT, parseAllowlist } from './rt-kit-checks.config.mjs';
|
|
34
34
|
|
|
35
35
|
const ALLOWLIST = allowlistOf('doc-paths');
|
|
36
|
-
// `worktrees` —
|
|
37
|
-
//
|
|
38
|
-
//
|
|
36
|
+
// `worktrees` — copies of the repository under the agent's directory: their documents describe the
|
|
37
|
+
// layout of their own branch, while the check looks for addresses in the tree of the current one.
|
|
38
|
+
// One abandoned copy gave 73 divergences and a red end-to-end run on a branch that did not start it.
|
|
39
39
|
const SKIPPED_DIRS = CONFIG.skippedDirs;
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
41
|
+
* The archive describes the layout as it was at the moment of writing. Fixing addresses in it means
|
|
42
|
+
* rewriting history after the fact, so it is taken out of the check entirely.
|
|
43
43
|
*/
|
|
44
44
|
const ARCHIVE_DIR = CONFIG.archiveDir;
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
46
|
+
* A task folder describes the progress, and what has been removed it names by name: the findings
|
|
47
|
+
* section lists exactly what is not in the tree. A machine has nothing to tell such a mention from
|
|
48
|
+
* a link by, and the folder lives until the merge — so it is taken out of the check, like the
|
|
49
|
+
* archive.
|
|
49
50
|
*/
|
|
50
51
|
const TASKS_DIR = CONFIG.tasksDir.endsWith('/') ? CONFIG.tasksDir : `${CONFIG.tasksDir}/`;
|
|
51
52
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
53
|
+
* Directories whose index is audited against the content. Nothing else judges a directory taken out
|
|
54
|
+
* of the address check: a record that arrived by a merge of a neighbouring branch stays unnamed,
|
|
55
|
+
* while the reader searches by the index. An index audited by hand diverges again within a day.
|
|
55
56
|
*/
|
|
56
57
|
const INDEXED_DIRS = (CONFIG.indexedDirs ?? []).map((dir) => (dir.endsWith('/') ? dir : `${dir}/`));
|
|
57
58
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
59
|
+
* The sources of portable texts: a rule that is laid out into another tree names the addresses of
|
|
60
|
+
* that tree. A laid-out copy is recognised by its header, and the source carries no header — the
|
|
61
|
+
* layout puts it there — so its directory is named by a setting.
|
|
61
62
|
*/
|
|
62
63
|
const PORTABLE_DIRS = (CONFIG.portableDirs ?? []).map((dir) => (dir.endsWith('/') ? dir : `${dir}/`));
|
|
63
|
-
/**
|
|
64
|
+
/** The header of a laid-out file: the package version, the resource and the sum of the body. */
|
|
64
65
|
const STAMP_LINE = /rt-kit\s+v\S+\s+·\s+\S+\s+·\s+[0-9a-f]{12}/;
|
|
65
|
-
/**
|
|
66
|
+
/** The header stands as the first line of the body, and the body starts after the skill's intro. */
|
|
66
67
|
const STAMP_LOOKAHEAD = 12;
|
|
67
|
-
/**
|
|
68
|
+
/** The extensions by which a bare name counts as a file and not as the name of a record */
|
|
68
69
|
const EXTENSIONS = 'ts|mts|cts|js|mjs|cjs|json|jsonc|scss|css|html|proto|conf|ya?ml|sh|md|sql|txt|xml|svg|webp|png|ico|env|Dockerfile|lock';
|
|
69
70
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
71
|
+
* Any string in backticks is taken: a directory carries no extension, and requiring one in the
|
|
72
|
+
* selection itself would mean not seeing half of the "Where this lies" tables. The sifting is in
|
|
73
|
+
* `looksLikePath`.
|
|
72
74
|
*/
|
|
73
75
|
const PATH_IN_BACKTICKS = /`([^`\n]+?)`/g;
|
|
74
76
|
|
|
75
77
|
const problems = [];
|
|
76
78
|
const indexProblems = [];
|
|
77
|
-
const report = (doc, line, path) => problems.push(`${doc}:${line}:
|
|
79
|
+
const report = (doc, line, path) => problems.push(`${doc}:${line}: no file \`${path}\``);
|
|
78
80
|
|
|
79
81
|
function collectDocs(dir = '.') {
|
|
80
82
|
const entries = readdirSync(join(ROOT, dir), { withFileTypes: true });
|
|
@@ -95,28 +97,27 @@ function collectDocs(dir = '.') {
|
|
|
95
97
|
}
|
|
96
98
|
|
|
97
99
|
/**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
* этот файл не едет.
|
|
100
|
+
* Documents that will not reach the repository: a personal draft lying in the tree and covered by
|
|
101
|
+
* the ignore settings. The check judges the repository, not the desk of whoever started it: a dead
|
|
102
|
+
* link in someone's draft held the push gate, though that file goes into no branch at all.
|
|
102
103
|
*/
|
|
103
104
|
function droppedByGit(docs) {
|
|
104
105
|
if (docs.length === 0) {
|
|
105
106
|
return new Set();
|
|
106
107
|
}
|
|
107
108
|
|
|
108
|
-
// `--stdin`
|
|
109
|
+
// `--stdin` instead of arguments: the list is longer than the command line limit
|
|
109
110
|
const ignored = spawnSync('git', ['check-ignore', '--stdin'], {
|
|
110
111
|
cwd: ROOT,
|
|
111
112
|
encoding: 'utf8',
|
|
112
113
|
input: docs.join('\n'),
|
|
113
114
|
});
|
|
114
115
|
|
|
115
|
-
//
|
|
116
|
+
// No git — there is nothing to judge by, and the check stays stricter than needed
|
|
116
117
|
return new Set((ignored.stdout ?? '').split('\n').filter(Boolean));
|
|
117
118
|
}
|
|
118
119
|
|
|
119
|
-
/**
|
|
120
|
+
/** The top level of the tree: an address rooted in the repository is recognised by it */
|
|
120
121
|
const ROOTED_IN = new Set(
|
|
121
122
|
readdirSync(ROOT, { withFileTypes: true })
|
|
122
123
|
.filter((entry) => entry.isDirectory() && !SKIPPED_DIRS.includes(entry.name))
|
|
@@ -124,10 +125,10 @@ const ROOTED_IN = new Set(
|
|
|
124
125
|
);
|
|
125
126
|
|
|
126
127
|
/**
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
128
|
+
* The tree is asked of the version control system, not walked directory by directory: the agent's
|
|
129
|
+
* and the pipeline's directories start with a dot, and a walk passes them by silently — everything
|
|
130
|
+
* lying in them would read as non-existent. The untracked is taken together with the tracked: a
|
|
131
|
+
* file started by this very branch and not yet added exists no less.
|
|
131
132
|
*/
|
|
132
133
|
function treeOfRepo() {
|
|
133
134
|
const listed = spawnSync('git', ['ls-files', '--cached', '--others', '--exclude-standard'], {
|
|
@@ -157,23 +158,24 @@ function treeOfRepo() {
|
|
|
157
158
|
const TREE = treeOfRepo();
|
|
158
159
|
|
|
159
160
|
/**
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
161
|
+
* Whether this is an address at all. Everything describing a form rather than an address is cut
|
|
162
|
+
* off: patterns, network links, package names, flags and the binding "path:symbol" — that one is
|
|
163
|
+
* judged by the spec audit. After that a candidate comes in two kinds: rooted in the tree and a
|
|
164
|
+
* bare name. A bare name is used for both a file and a directory — both are looked for across the
|
|
165
|
+
* tree, because their address is one and the same, only written short.
|
|
164
166
|
*/
|
|
165
167
|
function looksLikePath(candidate) {
|
|
166
|
-
if (/[*<>{}$|\s]|\.\.\.|…/.test(candidate)) {
|
|
168
|
+
if (/[*<>{}$|\s()[\]'",;=]|\.\.\.|…/.test(candidate)) {
|
|
167
169
|
return false;
|
|
168
170
|
}
|
|
169
171
|
if (/^(https?:|@|~|\/|-)/.test(candidate) || candidate.includes(':')) {
|
|
170
172
|
return false;
|
|
171
173
|
}
|
|
172
|
-
//
|
|
174
|
+
// A directory the check does not walk it does not judge either: what lies there is foreign code, the build and service files
|
|
173
175
|
if (SKIPPED_DIRS.some((dir) => candidate.startsWith(`${dir}/`))) {
|
|
174
176
|
return false;
|
|
175
177
|
}
|
|
176
|
-
//
|
|
178
|
+
// Starts with a dot and stands without a directory — a kind of file, not a file
|
|
177
179
|
if (/^\.[^/]+$/.test(candidate)) {
|
|
178
180
|
return false;
|
|
179
181
|
}
|
|
@@ -182,14 +184,26 @@ function looksLikePath(candidate) {
|
|
|
182
184
|
}
|
|
183
185
|
|
|
184
186
|
/**
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
187
|
+
* Whether such an address is in the tree. A rooted one is asked of the file system: it is named in
|
|
188
|
+
* full, and a miss in it is a miss. A bare name is looked for across the whole tree — among files
|
|
189
|
+
* and among directories: a directory name in a lib's overview document means a directory next to
|
|
190
|
+
* it, not a directory at the root.
|
|
189
191
|
*/
|
|
190
|
-
function existsInTree(candidate) {
|
|
192
|
+
function existsInTree(candidate, fromDir = '') {
|
|
191
193
|
const bare = candidate.replace(/\/$/, '');
|
|
192
194
|
|
|
195
|
+
/**
|
|
196
|
+
* A relative address belongs to the document's directory, not to the tree root: `../routes.ts`
|
|
197
|
+
* from `libs/x/shell/src/shell/README.md` is `libs/x/shell/src/routes.ts`. Without resolving
|
|
198
|
+
* from the directory such an address is looked for across the tree as a string and is never
|
|
199
|
+
* found, that is, the check reddens at every link written the way links are written in markup.
|
|
200
|
+
*/
|
|
201
|
+
if (/^\.{1,2}(\/|$)/.test(bare)) {
|
|
202
|
+
const resolved = posix.normalize(posix.join(fromDir, bare));
|
|
203
|
+
|
|
204
|
+
return resolved.startsWith('..') ? false : existsSync(join(ROOT, resolved));
|
|
205
|
+
}
|
|
206
|
+
|
|
193
207
|
if (ROOTED_IN.has(bare.split('/')[0])) {
|
|
194
208
|
return existsSync(join(ROOT, bare));
|
|
195
209
|
}
|
|
@@ -204,10 +218,11 @@ function existsInTree(candidate) {
|
|
|
204
218
|
}
|
|
205
219
|
|
|
206
220
|
/**
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
221
|
+
* A portable text: one laid out by the package is known by its header, its source by the directory
|
|
222
|
+
* from the settings. The addresses in it belong to the tree the rule is laid out into:
|
|
223
|
+
* `libs/common/util` in a tree that calls its roots otherwise is not a dead link but an example.
|
|
224
|
+
* Judging them here means reddening at a hundred and fifty lines, not one of which is fixed by an
|
|
225
|
+
* edit of this tree.
|
|
211
226
|
*/
|
|
212
227
|
function isPortable(doc) {
|
|
213
228
|
if (PORTABLE_DIRS.some((dir) => doc.startsWith(dir))) {
|
|
@@ -219,15 +234,15 @@ function isPortable(doc) {
|
|
|
219
234
|
.some((line) => STAMP_LINE.test(line));
|
|
220
235
|
}
|
|
221
236
|
|
|
222
|
-
/**
|
|
237
|
+
/** Documents that by their nature speak of what does not exist are taken out of the address check. */
|
|
223
238
|
const isSkipped = (doc) => doc.startsWith(ARCHIVE_DIR) || doc.startsWith(TASKS_DIR) || isPortable(doc);
|
|
224
239
|
|
|
225
240
|
/**
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
241
|
+
* The completeness of a directory index: every record of the directory has a line in the table,
|
|
242
|
+
* every line has a record. The record is the first name in backticks of a table line: the second
|
|
243
|
+
* column holds prose, and there would be nothing to take from there. The directory is asked of the
|
|
244
|
+
* version control system by the same selection as the tree: a draft covered by the ignore settings
|
|
245
|
+
* does not reach the repository and is not needed in the index.
|
|
231
246
|
*/
|
|
232
247
|
function checkIndex(dir) {
|
|
233
248
|
const index = `${dir}README.md`;
|
|
@@ -251,15 +266,16 @@ function checkIndex(dir) {
|
|
|
251
266
|
[...stored]
|
|
252
267
|
.filter((name) => !named.has(name))
|
|
253
268
|
.sort()
|
|
254
|
-
.forEach((name) => indexProblems.push(`${index}:
|
|
269
|
+
.forEach((name) => indexProblems.push(`${index}: the record \`${name}\` lies in the directory and is not named in the table`));
|
|
255
270
|
[...named]
|
|
256
271
|
.filter((name) => !stored.has(name))
|
|
257
272
|
.sort()
|
|
258
|
-
.forEach((name) => indexProblems.push(`${index}:
|
|
273
|
+
.forEach((name) => indexProblems.push(`${index}: the line \`${name}\` is named in the table, and there is no record in the directory`));
|
|
259
274
|
}
|
|
260
275
|
|
|
261
276
|
function checkDoc(doc, allowed) {
|
|
262
277
|
const lines = readFileSync(join(ROOT, doc), 'utf8').split('\n');
|
|
278
|
+
const fromDir = posix.dirname(doc);
|
|
263
279
|
let insideFence = false;
|
|
264
280
|
|
|
265
281
|
lines.forEach((line, index) => {
|
|
@@ -276,23 +292,23 @@ function checkDoc(doc, allowed) {
|
|
|
276
292
|
if (!looksLikePath(candidate) || allowed.has(candidate)) {
|
|
277
293
|
continue;
|
|
278
294
|
}
|
|
279
|
-
if (!existsInTree(candidate)) {
|
|
295
|
+
if (!existsInTree(candidate, fromDir)) {
|
|
280
296
|
report(doc, index + 1, candidate);
|
|
281
297
|
}
|
|
282
298
|
}
|
|
283
299
|
});
|
|
284
300
|
}
|
|
285
301
|
|
|
286
|
-
/**
|
|
302
|
+
/** An index divergence is printed as a list of its own: it is fixed by a line in the table, not by silence. */
|
|
287
303
|
function reportIndex() {
|
|
288
304
|
if (indexProblems.length === 0) {
|
|
289
305
|
return;
|
|
290
306
|
}
|
|
291
307
|
|
|
292
|
-
console.error(`\
|
|
308
|
+
console.error(`\nthe index diverged from the directory, divergences ${indexProblems.length}\n`);
|
|
293
309
|
indexProblems.forEach((problem) => console.error(` ${problem}`));
|
|
294
310
|
console.error(
|
|
295
|
-
'\
|
|
311
|
+
'\nA record is named in the table of the index by the same change that lays it down:\nthe reader searches by the index, not by walking the directory.'
|
|
296
312
|
);
|
|
297
313
|
}
|
|
298
314
|
|
|
@@ -306,10 +322,16 @@ docs.forEach((doc) => checkDoc(doc, allowedPaths));
|
|
|
306
322
|
INDEXED_DIRS.forEach((dir) => checkIndex(dir));
|
|
307
323
|
|
|
308
324
|
if (problems.length > 0) {
|
|
309
|
-
console.error(`check-doc-paths:
|
|
325
|
+
console.error(`check-doc-paths: divergences ${problems.length}\n`);
|
|
310
326
|
problems.forEach((problem) => console.error(` ${problem}`));
|
|
327
|
+
// There are three ways out, and the third is named: the known list holds what is accepted, not
|
|
328
|
+
// the results of a broken check. The former text offered to enter everything doubtful into the
|
|
329
|
+
// list — it taught the bypass the verifiability law forbids; one review gave 51 false refusals
|
|
330
|
+
// out of 264, every one of them on an address that exists.
|
|
311
331
|
console.error(
|
|
312
|
-
`\
|
|
332
|
+
`\nThree moves from here: fix the stale address; enter the name into ${ALLOWLIST} if the document` +
|
|
333
|
+
`\ndescribes what is not created yet; fix the check itself, if it is the one that is wrong — take` +
|
|
334
|
+
`\nthe refusals apart one by one and show the analysis to the owner. What is in dispute is not listed.`
|
|
313
335
|
);
|
|
314
336
|
}
|
|
315
337
|
|
|
@@ -319,4 +341,4 @@ if (problems.length > 0 || indexProblems.length > 0) {
|
|
|
319
341
|
process.exit(1);
|
|
320
342
|
}
|
|
321
343
|
|
|
322
|
-
console.log(`check-doc-paths:
|
|
344
|
+
console.log(`check-doc-paths: documents checked ${docs.length}, no divergences`);
|