@rt-tools/agent-kit 0.37.1 → 0.39.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 +5 -5
- package/assets/checks/action-of.mjs +154 -0
- package/assets/checks/board-runs.github.mjs +40 -5
- package/assets/checks/check-board.github.mjs +38 -7
- package/assets/checks/check-state-next.mjs +22 -10
- package/assets/checks/check-turn-map.mjs +26 -6
- package/assets/checks/check-work-steps.mjs +4 -173
- package/assets/checks/decide.mjs +285 -0
- package/assets/checks/decision-table.json +21432 -0
- package/assets/checks/decision-table.mjs +495 -0
- package/assets/checks/epic-window.mjs +98 -0
- package/assets/checks/flow-condition.mjs +64 -0
- package/assets/checks/flow-data.mjs +135 -0
- package/assets/checks/flow-forecast.mjs +334 -0
- package/assets/checks/flow-guard-run.mjs +90 -0
- package/assets/checks/flow-guard.mjs +496 -0
- package/assets/checks/flow-model.mjs +271 -0
- package/assets/checks/flow-override.mjs +130 -0
- package/assets/checks/flow-plan.mjs +206 -0
- package/assets/checks/flow-scaffold.mjs +224 -0
- package/assets/checks/flow-step.mjs +495 -0
- package/assets/checks/flow-sync.mjs +296 -0
- package/assets/checks/flow-syntax.mjs +292 -0
- package/assets/checks/flow-verdict.mjs +227 -0
- package/assets/checks/merge-read.mjs +239 -0
- package/assets/checks/owner-nudges.mjs +389 -0
- package/assets/checks/push-inputs.mjs +59 -16
- package/assets/checks/record-count.mjs +437 -0
- package/assets/checks/record-recount.mjs +187 -0
- package/assets/checks/record-turn.mjs +155 -0
- package/assets/checks/task-flow-script.mjs +318 -0
- package/assets/checks/tree-assignment.mjs +26 -7
- package/assets/checks/work-result.mjs +362 -0
- package/assets/checks/work-steps-lib.mjs +205 -0
- package/assets/commands/night.md +6 -6
- package/assets/defaults/gate-map.sh +39 -12
- package/assets/defaults/merges.sh +48 -0
- package/assets/defaults/project.sh +6 -5
- package/assets/defaults/turn-map.md +23 -22
- package/assets/docs/GLOSSARY.md +5 -1
- package/assets/hooks/ask-judge.md +67 -0
- package/assets/hooks/browser-guard-device-id.sh +11 -9
- package/assets/hooks/browser-guard-no-asking.sh +12 -6
- package/assets/hooks/browser-guard-no-listing.sh +13 -7
- package/assets/hooks/browser-guard-no-other-drivers.sh +25 -17
- package/assets/hooks/browser-guard-require-select.sh +15 -15
- package/assets/hooks/commit-msg.sh +13 -3
- package/assets/hooks/conscience-guard.sh +9 -25
- package/assets/hooks/decide.sh +141 -0
- package/assets/hooks/deny-tail.sh +16 -11
- package/assets/hooks/dev-server-guard.sh +27 -20
- package/assets/hooks/dispatch.sh +47 -4
- package/assets/hooks/docs-guard.sh +31 -200
- package/assets/hooks/end-conversation-guard.sh +12 -21
- package/assets/hooks/epic-stop-guard.sh +54 -152
- package/assets/hooks/exam-guard.sh +32 -65
- package/assets/hooks/facts-docs.sh +221 -0
- package/assets/hooks/facts-flow.sh +173 -0
- package/assets/hooks/facts.sh +374 -0
- package/assets/hooks/flow-step-guard.sh +93 -0
- package/assets/hooks/git-guard-delivery-body.sh +4 -4
- package/assets/hooks/git-guard-delivery-conflict.sh +16 -10
- package/assets/hooks/git-guard-delivery-draft.sh +3 -3
- package/assets/hooks/git-guard-delivery-epic.sh +18 -9
- package/assets/hooks/git-guard-delivery-folder.sh +32 -7
- package/assets/hooks/git-guard-delivery-merge.sh +2 -2
- package/assets/hooks/git-guard-delivery-merged.sh +12 -1
- package/assets/hooks/git-guard-delivery-pipeline.sh +1 -1
- package/assets/hooks/git-guard-delivery-rerun.sh +44 -0
- package/assets/hooks/git-guard-delivery-signature.sh +82 -45
- package/assets/hooks/git-guard-delivery-task.sh +47 -0
- package/assets/hooks/git-guard-delivery.sh +112 -101
- package/assets/hooks/git-guard-discard.sh +8 -18
- package/assets/hooks/git-guard-main.sh +13 -19
- package/assets/hooks/git-guard-no-verify.sh +56 -16
- package/assets/hooks/git-guard-push-ahead.sh +39 -6
- package/assets/hooks/git-guard-push-marks.sh +262 -13
- package/assets/hooks/git-guard-push-tests.sh +58 -52
- package/assets/hooks/git-guard-tree-assignment.sh +7 -4
- package/assets/hooks/guard-note.sh +8 -6
- package/assets/hooks/handoff-entry-guard.sh +19 -38
- package/assets/hooks/handoff-write.sh +3 -1
- package/assets/hooks/hook-input.sh +0 -41
- package/assets/hooks/metric-marks.sh +19 -7
- package/assets/hooks/observe.sh +1 -1
- package/assets/hooks/override-write-guard.sh +27 -9
- package/assets/hooks/pre-push.sh +40 -12
- package/assets/hooks/prose-style-guard.sh +6 -19
- package/assets/hooks/pull-merges.sh +76 -0
- package/assets/hooks/push-ahead-call-guard.sh +447 -0
- package/assets/hooks/push-set.sh +38 -8
- package/assets/hooks/qa-dataid-guard.sh +7 -17
- package/assets/hooks/record-turn.sh +52 -0
- package/assets/hooks/rerun-guard.sh +11 -16
- package/assets/hooks/reuse-first-guard.sh +7 -21
- package/assets/hooks/role-calls.sh +25 -3
- package/assets/hooks/rule-source-guard.sh +54 -21
- package/assets/hooks/skill-gate-rearm.sh +18 -5
- package/assets/hooks/skill-gate.sh +156 -20
- package/assets/hooks/skill-loaded.sh +18 -3
- package/assets/hooks/sql-guard-target.sh +2 -2
- package/assets/hooks/sql-guard-write.sh +12 -12
- package/assets/hooks/sql-guard.sh +58 -16
- package/assets/hooks/task-context-load.sh +3 -1
- package/assets/hooks/task-flow-context.sh +5 -18
- package/assets/hooks/task-flow-draft-guard.sh +25 -74
- package/assets/hooks/task-flow-guard.sh +28 -130
- package/assets/hooks/tree-assignment-guard.sh +25 -14
- package/assets/hooks/turn-entry-load.sh +3 -1
- package/assets/hooks/turn-exit-guard.sh +92 -452
- package/assets/hooks/turn-exit-role.sh +3 -1
- package/assets/hooks/turn-judge.md +113 -0
- package/assets/hooks/window-fill-guard.sh +22 -41
- package/assets/patterns/doc-style-human.md +36 -76
- package/assets/patterns/git-workflow-commit.azure.md +9 -155
- package/assets/patterns/git-workflow-commit.github.md +11 -269
- package/assets/patterns/git-workflow-commit.gitlab.md +9 -161
- package/assets/patterns/git-workflow-docker.md +8 -231
- package/assets/patterns/git-workflow-freshness.md +8 -56
- package/assets/patterns/git-workflow-merge.md +6 -176
- package/assets/patterns/git-workflow-migration.md +5 -75
- package/assets/patterns/git-workflow-pr-body.github.md +6 -159
- package/assets/patterns/git-workflow-pr-ready.md +9 -70
- package/assets/patterns/git-workflow-pr.azure.md +13 -285
- package/assets/patterns/git-workflow-pr.github.md +13 -251
- package/assets/patterns/git-workflow-pr.gitlab.md +13 -286
- package/assets/patterns/git-workflow-restart.md +5 -42
- package/assets/patterns/git-workflow-secrets.md +10 -76
- package/assets/patterns/git-workflow-stack.md +7 -207
- package/assets/patterns/status-report-table.github.md +1 -1
- package/assets/patterns/task-flow-archive.md +12 -233
- package/assets/patterns/task-flow-close.md +16 -292
- package/assets/patterns/task-flow-cycle.md +13 -39
- package/assets/patterns/task-flow-graph.needs-graph.md +8 -62
- package/assets/patterns/task-flow-handoff.md +13 -161
- package/assets/patterns/task-flow-resume.md +18 -218
- package/assets/patterns/task-flow-start.md +9 -247
- package/assets/patterns/turn-entry-map.md +2 -2
- package/assets/pitfalls/agent-kit-extend.md +200 -0
- package/assets/pitfalls/agent-kit.2.md +323 -0
- package/assets/pitfalls/angular-patterns.md +98 -0
- package/assets/pitfalls/browser-verification.md +265 -0
- package/assets/pitfalls/component-structure.md +98 -0
- package/assets/pitfalls/dependencies.md +92 -0
- package/assets/pitfalls/deploy-flow.azure.md +171 -0
- package/assets/pitfalls/deploy-flow.github.md +211 -0
- package/assets/pitfalls/deploy-flow.gitlab.md +173 -0
- package/assets/pitfalls/doc-style-human.md +112 -0
- package/assets/pitfalls/doc-style.2.md +286 -0
- package/assets/pitfalls/entity-conventions.needs-admin.md +96 -0
- package/assets/pitfalls/entity-models.md +89 -0
- package/assets/pitfalls/epic-flow.md +92 -0
- package/assets/pitfalls/git-workflow-commit.azure.md +190 -0
- package/assets/pitfalls/git-workflow-commit.github.md +307 -0
- package/assets/pitfalls/git-workflow-commit.gitlab.md +196 -0
- package/assets/pitfalls/git-workflow-docker.md +275 -0
- package/assets/pitfalls/git-workflow-freshness.md +88 -0
- package/assets/pitfalls/git-workflow-hosting.azure.md +31 -0
- package/assets/pitfalls/git-workflow-hosting.github.md +32 -0
- package/assets/pitfalls/git-workflow-hosting.gitlab.md +31 -0
- package/assets/pitfalls/git-workflow-merge.md +220 -0
- package/assets/pitfalls/git-workflow-migration.md +103 -0
- package/assets/pitfalls/git-workflow-pr-body.github.md +185 -0
- package/assets/pitfalls/git-workflow-pr-ready.md +104 -0
- package/assets/pitfalls/git-workflow-pr.2.azure.md +172 -0
- package/assets/pitfalls/git-workflow-pr.2.github.md +184 -0
- package/assets/pitfalls/git-workflow-pr.2.gitlab.md +180 -0
- package/assets/pitfalls/git-workflow-pr.azure.md +159 -0
- package/assets/pitfalls/git-workflow-pr.github.md +107 -0
- package/assets/pitfalls/git-workflow-pr.gitlab.md +151 -0
- package/assets/pitfalls/git-workflow-push.azure.md +30 -0
- package/assets/pitfalls/git-workflow-push.github.md +30 -0
- package/assets/pitfalls/git-workflow-push.gitlab.md +30 -0
- package/assets/pitfalls/git-workflow-queue.azure.md +30 -0
- package/assets/pitfalls/git-workflow-queue.github.md +30 -0
- package/assets/pitfalls/git-workflow-queue.gitlab.md +30 -0
- package/assets/pitfalls/git-workflow-restart.md +72 -0
- package/assets/pitfalls/git-workflow-secrets.md +114 -0
- package/assets/pitfalls/git-workflow-stack.md +254 -0
- package/assets/pitfalls/git-workflow.2.azure.md +291 -0
- package/assets/pitfalls/git-workflow.2.github.md +294 -0
- package/assets/pitfalls/git-workflow.2.gitlab.md +278 -0
- package/assets/pitfalls/lib-layers.md +114 -0
- package/assets/pitfalls/lists.md +117 -0
- package/assets/pitfalls/mockups.needs-mockups.md +87 -0
- package/assets/pitfalls/navigation.md +94 -0
- package/assets/pitfalls/observability.needs-app.md +186 -0
- package/assets/pitfalls/platform-access.md +94 -0
- package/assets/pitfalls/queue-audit.github.md +78 -0
- package/assets/pitfalls/reuse-first.md +201 -0
- package/assets/pitfalls/spec-driven.2.md +318 -0
- package/assets/pitfalls/styling-bem.2.md +125 -0
- package/assets/pitfalls/task-flow-archive.md +265 -0
- package/assets/pitfalls/task-flow-close.2.md +166 -0
- package/assets/pitfalls/task-flow-close.md +167 -0
- package/assets/pitfalls/task-flow-cycle.md +73 -0
- package/assets/pitfalls/task-flow-graph.needs-graph.md +98 -0
- package/assets/pitfalls/task-flow-handoff.md +200 -0
- package/assets/pitfalls/task-flow-handover.md +30 -0
- package/assets/pitfalls/task-flow-owner.md +58 -0
- package/assets/pitfalls/task-flow-plan.md +29 -0
- package/assets/pitfalls/task-flow-resume.md +257 -0
- package/assets/pitfalls/task-flow-start.md +287 -0
- package/assets/pitfalls/task-flow.2.md +303 -0
- package/assets/pitfalls/task-flow.md +4 -4
- package/assets/pitfalls/testing.2.md +279 -0
- package/assets/pitfalls/turn-conduct.md +16 -17
- package/assets/pitfalls/typescript-conventions.md +161 -0
- package/assets/pitfalls/write-a-skill.md +128 -0
- package/assets/rules/angular-patterns.md +21 -86
- package/assets/rules/autonomous-work.md +2 -2
- package/assets/rules/browser-verification.md +28 -256
- package/assets/rules/component-structure.md +25 -87
- package/assets/rules/dependencies.md +20 -78
- package/assets/rules/deploy-flow.azure.md +26 -156
- package/assets/rules/deploy-flow.github.md +34 -200
- package/assets/rules/deploy-flow.gitlab.md +27 -159
- package/assets/rules/doc-style.md +32 -286
- package/assets/rules/entity-conventions.needs-admin.md +26 -82
- package/assets/rules/entity-models.md +14 -63
- package/assets/rules/epic-flow.md +24 -63
- package/assets/rules/git-workflow-hosting.azure.md +26 -0
- package/assets/rules/git-workflow-hosting.github.md +38 -0
- package/assets/rules/git-workflow-hosting.gitlab.md +27 -0
- package/assets/rules/git-workflow-push.azure.md +28 -0
- package/assets/rules/git-workflow-push.github.md +28 -0
- package/assets/rules/git-workflow-push.gitlab.md +28 -0
- package/assets/rules/git-workflow-queue.azure.md +23 -0
- package/assets/rules/git-workflow-queue.github.md +30 -0
- package/assets/rules/git-workflow-queue.gitlab.md +23 -0
- package/assets/rules/git-workflow.azure.md +21 -282
- package/assets/rules/git-workflow.github.md +24 -284
- package/assets/rules/git-workflow.gitlab.md +21 -269
- package/assets/rules/lib-layers.md +30 -103
- package/assets/rules/lists.md +21 -105
- package/assets/rules/mockups.needs-mockups.md +25 -64
- package/assets/rules/navigation.md +10 -69
- package/assets/rules/observability.needs-app.md +43 -172
- package/assets/rules/platform-access.md +28 -75
- package/assets/rules/queue-audit.github.md +25 -52
- package/assets/rules/reuse-first.md +20 -195
- package/assets/rules/spec-driven.md +35 -308
- package/assets/rules/styling-bem.md +20 -117
- package/assets/rules/task-flow-handover.md +24 -0
- package/assets/rules/task-flow-owner.md +34 -0
- package/assets/rules/task-flow-plan.md +38 -0
- package/assets/rules/task-flow.md +22 -300
- package/assets/rules/testing.md +32 -273
- package/assets/rules/turn-conduct.md +105 -106
- package/assets/rules/turn-entry.md +2 -2
- package/assets/rules/typescript-conventions.md +41 -147
- package/assets/samples/tasks/_template/plan.md +30 -6
- package/assets/samples/tasks/_template/progress.md +0 -1
- package/assets/skills/agent-kit-extend.md +25 -168
- package/assets/skills/agent-kit.md +27 -299
- package/assets/skills/write-a-skill.md +20 -106
- package/assets/task-flow/flow.js +184 -0
- package/assets/task-flow/flow.md +101 -0
- package/assets/task-flow/measure/agreement.mjs +24 -0
- package/assets/task-flow/measure/ci.mjs +184 -0
- package/assets/task-flow/measure/copy.mjs +22 -0
- package/assets/task-flow/measure/epic-of.mjs +50 -0
- package/assets/task-flow/measure/epic-text.mjs +35 -0
- package/assets/task-flow/measure/epic.mjs +114 -0
- package/assets/task-flow/measure/folder.mjs +16 -0
- package/assets/task-flow/measure/footprint.mjs +28 -0
- package/assets/task-flow/measure/grill.mjs +21 -0
- package/assets/task-flow/measure/host.mjs +8 -0
- package/assets/task-flow/measure/owner.mjs +27 -0
- package/assets/task-flow/measure/plan.mjs +27 -0
- package/assets/task-flow/measure/pr.mjs +20 -0
- package/assets/task-flow/measure/progress.mjs +50 -0
- package/assets/task-flow/measure/session.mjs +252 -0
- package/assets/task-flow/measure/task.mjs +23 -0
- package/assets/task-flow/measure/text.mjs +77 -0
- package/assets/task-flow/source/git.mjs +254 -0
- package/assets/task-flow/source/host.mjs +277 -0
- package/assets/task-flow/source/marks.mjs +56 -0
- package/assets/task-flow/source/owner.mjs +94 -0
- package/assets/task-flow/source/records.mjs +116 -0
- package/assets/task-flow/source/session.mjs +269 -0
- package/assets/task-flow/source/steps.mjs +28 -0
- package/assets/task-flow/source/tree.mjs +42 -0
- package/bin/agent-kit.d.ts.map +1 -1
- package/bin/agent-kit.js +30 -0
- package/bin/agent-kit.js.map +1 -1
- package/lib/agent-checks.d.ts +55 -0
- package/lib/agent-checks.d.ts.map +1 -0
- package/lib/agent-checks.js +221 -0
- package/lib/agent-checks.js.map +1 -0
- package/lib/assets.d.ts.map +1 -1
- package/lib/assets.js +7 -2
- package/lib/assets.js.map +1 -1
- package/lib/cargo.d.ts +29 -0
- package/lib/cargo.d.ts.map +1 -1
- package/lib/cargo.js +27 -1
- package/lib/cargo.js.map +1 -1
- package/lib/cascade.d.ts.map +1 -1
- package/lib/cascade.js +3 -1
- package/lib/cascade.js.map +1 -1
- package/lib/commands.d.ts.map +1 -1
- package/lib/commands.js +78 -2
- package/lib/commands.js.map +1 -1
- package/lib/config.d.ts +18 -0
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +18 -1
- package/lib/config.js.map +1 -1
- package/lib/epic-window-send.d.ts +74 -0
- package/lib/epic-window-send.d.ts.map +1 -0
- package/lib/epic-window-send.js +166 -0
- package/lib/epic-window-send.js.map +1 -0
- package/lib/hooks-map.d.ts +4 -0
- package/lib/hooks-map.d.ts.map +1 -1
- package/lib/hooks-map.js +2 -2
- package/lib/hooks-map.js.map +1 -1
- package/lib/integrity.d.ts +3 -0
- package/lib/integrity.d.ts.map +1 -1
- package/lib/integrity.js +7 -0
- package/lib/integrity.js.map +1 -1
- package/lib/metric-lines.d.ts +2 -1
- package/lib/metric-lines.d.ts.map +1 -1
- package/lib/metric-lines.js +49 -1
- package/lib/metric-lines.js.map +1 -1
- package/lib/metric-send-mark.d.ts +6 -3
- package/lib/metric-send-mark.d.ts.map +1 -1
- package/lib/metric-send-mark.js +15 -5
- package/lib/metric-send-mark.js.map +1 -1
- package/lib/metric-send.d.ts +6 -2
- package/lib/metric-send.d.ts.map +1 -1
- package/lib/metric-send.js +47 -13
- package/lib/metric-send.js.map +1 -1
- package/lib/metrics.d.ts +17 -0
- package/lib/metrics.d.ts.map +1 -1
- package/lib/metrics.js +26 -15
- package/lib/metrics.js.map +1 -1
- package/lib/observations.js +3 -3
- package/lib/observations.js.map +1 -1
- package/lib/outcomes.d.ts +5 -2
- package/lib/outcomes.d.ts.map +1 -1
- package/lib/outcomes.js +5 -4
- package/lib/outcomes.js.map +1 -1
- package/lib/push-gate.d.ts +13 -0
- package/lib/push-gate.d.ts.map +1 -1
- package/lib/push-gate.js +11 -7
- package/lib/push-gate.js.map +1 -1
- package/lib/push-set-usefulness.d.ts +78 -0
- package/lib/push-set-usefulness.d.ts.map +1 -0
- package/lib/push-set-usefulness.js +225 -0
- package/lib/push-set-usefulness.js.map +1 -0
- package/lib/sync.d.ts +10 -0
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +14 -1
- package/lib/sync.js.map +1 -1
- package/lib/work-result.d.ts +43 -0
- package/lib/work-result.d.ts.map +1 -0
- package/lib/work-result.js +39 -0
- package/lib/work-result.js.map +1 -0
- package/package.json +1 -1
- package/assets/hooks/claim-guard.sh +0 -212
- package/assets/hooks/grill-gate-ask.sh +0 -26
- package/assets/hooks/grill-gate-bypass.sh +0 -61
- package/assets/hooks/grill-gate-options.sh +0 -50
- package/assets/hooks/grill-gate.sh +0 -482
- package/assets/hooks/postmortem-guard.sh +0 -124
- package/assets/hooks/proposal-guard.sh +0 -154
- package/assets/hooks/stand-login-guard.sh +0 -107
- package/assets/hooks/turn-exit-epic.sh +0 -173
- package/assets/hooks/turn-exit-patterns.sh +0 -123
- package/assets/hooks/turn-exit-verdict.sh +0 -149
- package/assets/hooks/waiting-turn-guard.sh +0 -320
- package/assets/hooks/work-start-guard.sh +0 -175
package/README.md
CHANGED
|
@@ -27,7 +27,8 @@ npx agent-kit sync # разложить выбранное в docs/constitu
|
|
|
27
27
|
npx agent-kit doctor # что разложено, что отстало, чего не хватает
|
|
28
28
|
npx agent-kit adopt # отдать пакету файлы, лежащие на его путях не от него
|
|
29
29
|
npx agent-kit stats # чем пользовались, чем ни разу, обо что спотыкались
|
|
30
|
-
npx agent-kit metrics # отказы,
|
|
30
|
+
npx agent-kit metrics # отказы, результат работы, «Проверки набора», мёртвые правила; --day 2026-11-13 — за день
|
|
31
|
+
npx agent-kit recount --days 21 # пересчитать прошлые дни по записям разговоров
|
|
31
32
|
npx agent-kit send # отправить числа по дням: проверки и сессии делают это сами
|
|
32
33
|
npx agent-kit cost # сколько весит вход в работу, одно правило и весь слой
|
|
33
34
|
```
|
|
@@ -132,8 +133,8 @@ npx agent-kit init --host gitlab # или спросит, если запу
|
|
|
132
133
|
Закон и правило, которых никто не открывает, не действуют, поэтому пакет везёт и хуки, которые
|
|
133
134
|
их зовут.
|
|
134
135
|
|
|
135
|
-
|
|
136
|
-
`skill-loaded.sh` записывает загрузку, `skill-gate-rearm.sh`
|
|
136
|
+
**Проверка правил.** `skill-gate.sh` кладёт правило в сессию и пропускает правку; отказывает, если правило длиннее `RT_GATE_CONTEXT_LIMIT` (10 000 знаков), правила не помещаются вместе или не прочиталось.
|
|
137
|
+
`skill-loaded.sh` записывает загрузку, `skill-gate-rearm.sh` снова включает проверку после сжатия
|
|
137
138
|
контекста, `constitution-index.sh` печатает указатель законов на старте сессии.
|
|
138
139
|
|
|
139
140
|
**Сторожевые хуки.** Главная ветка, поставка, документ в одном коммите с правкой, проверки
|
|
@@ -452,8 +453,7 @@ PR влит, и вливанием в текущую ветку во всех п
|
|
|
452
453
|
умолчание, а не отказ, — проверка, которой в дереве нечего сверять, молчит.
|
|
453
454
|
|
|
454
455
|
Проверки, чей ход зависит от хостинга, лежат видами: `board`, `check-board` и `task-new`
|
|
455
|
-
приезжают в дерево под общими именами, а разговаривают с
|
|
456
|
-
при `init`.
|
|
456
|
+
приезжают в дерево под общими именами, а разговаривают с хостингом, выбранным при `init`.
|
|
457
457
|
|
|
458
458
|
## Раскладка и право на запуск
|
|
459
459
|
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The action of a call: the class the decision table knows a tool call by.
|
|
3
|
+
*
|
|
4
|
+
* A row of the table is keyed by its hook, its action and the facts. A guard that judges one kind of
|
|
5
|
+
* call names its action itself; a guard that judges every edit — the window fill, the handover entry,
|
|
6
|
+
* the exam — sees an edit of code, of a plan or of an override alike, and its rows differ only by the
|
|
7
|
+
* action. If such a guard named one action for all of them, a row of the table could be flipped with
|
|
8
|
+
* no effect on the guard, and the table would describe a decision nobody takes.
|
|
9
|
+
*
|
|
10
|
+
* So the action is computed from the call, here, once: every class the call fits, the most specific
|
|
11
|
+
* first. The decider takes the first one the hook has a row for.
|
|
12
|
+
*
|
|
13
|
+
* Content decides some classes: a template whose button has no anchor, a document with officialese.
|
|
14
|
+
* They are asked of the same analyses the content guards run, not of copies of them.
|
|
15
|
+
*/
|
|
16
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
17
|
+
import { isAbsolute, join } from 'node:path';
|
|
18
|
+
|
|
19
|
+
import { checkProse } from './check-prose-style.mjs';
|
|
20
|
+
|
|
21
|
+
const SHELL_TOOLS = new Set(['Bash', 'mcp__webstorm__execute_terminal_command']);
|
|
22
|
+
const EDIT_TOOLS = new Set(['Edit', 'Write', 'MultiEdit', 'mcp__webstorm__create_new_file']);
|
|
23
|
+
|
|
24
|
+
/** A shell command that writes into a progress or a plan file. */
|
|
25
|
+
const SHELL_WRITES_FLOW = /(progress|plan)\.md/;
|
|
26
|
+
const SHELL_WRITE = /(>>?|\btee\b|\bsed\s+-i|\bperl\s+-[a-z]*i)/;
|
|
27
|
+
|
|
28
|
+
/** The layout header within the first twelve lines — the sign the source guard reads. */
|
|
29
|
+
const LAYOUT_HEADER = /^\s*(<!--|\/\/|#|\/\*|\*)\s*rt-kit v\S+ · \S+ · [0-9a-f]+/m;
|
|
30
|
+
|
|
31
|
+
function laidOut(path) {
|
|
32
|
+
try {
|
|
33
|
+
return existsSync(path) && LAYOUT_HEADER.test(readFileSync(path, 'utf8').split('\n', 12).join('\n'));
|
|
34
|
+
} catch {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function proseDirty(text) {
|
|
40
|
+
try {
|
|
41
|
+
return checkProse(text).length > 0;
|
|
42
|
+
} catch {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function shellClasses(c) {
|
|
48
|
+
const out = [];
|
|
49
|
+
const has = (re) => re.test(c);
|
|
50
|
+
if (has(/\bgh\s+run\s+rerun\b/)) out.push('rerun_run');
|
|
51
|
+
if (has(/\bgit\s+(reset\s+--hard|checkout\s+--\s|clean\s+-[a-z]*f|restore\b)/)) out.push('discard');
|
|
52
|
+
if (has(/\bgit\s+add\s+[^;&|]*docs\/tasks\//) && has(/\bgit\s+commit\b/)) out.push('commit_folder');
|
|
53
|
+
if (has(/\bgit\s+commit\b[^;&|]*--amend\b/)) out.push('amend_signature');
|
|
54
|
+
if (has(/\bgit\s+commit\b[^;&|]*--no-verify\b/)) out.push('commit_skip_hooks');
|
|
55
|
+
if (has(/\bgit\s+commit\b/)) out.push('commit');
|
|
56
|
+
if (has(/\bgit\s+push\b[^;&|]*--no-verify\b/)) out.push('push_skip_hooks');
|
|
57
|
+
if (has(/\bgit\s+push\b[^]*&&[^]*\bgit\s+push\b/)) out.push('push_multi');
|
|
58
|
+
if (has(/\bgit\s+(checkout|switch)\s+[^&;|]*&&\s*git\s+push\b/)) out.push('push_switch');
|
|
59
|
+
if (has(/\bcd\s+[^&;|]*&&\s*git\s+push\b/)) out.push('push_second_copy');
|
|
60
|
+
if (has(/\bgit\s+push\b/)) out.push('push');
|
|
61
|
+
const created = c.match(/\bgit\s+(?:checkout\s+-b|switch\s+-c)\s+(\S+)(?:\s+([^\s;&|]+))?/);
|
|
62
|
+
if (created) {
|
|
63
|
+
const [, name, base] = created;
|
|
64
|
+
const task = /^[A-Z]+-\d+-/.test(name);
|
|
65
|
+
if (task && /[A-Z]/.test(name.replace(/^[A-Z]+-\d+-/, ''))) out.push('branch_create_bad_name');
|
|
66
|
+
if (task && !(base ?? '').startsWith('origin/')) out.push('branch_create_stale_base');
|
|
67
|
+
if (!task) out.push('branch_create_local');
|
|
68
|
+
}
|
|
69
|
+
if (has(/\bgit\s+(checkout\s+-b|switch\s+-c|branch\s+[^-])/)) out.push('branch_create');
|
|
70
|
+
if (has(/\bgh\s+pr\s+create\b/)) out.push('pr_create');
|
|
71
|
+
if (has(/\bgh\s+pr\s+ready\b/)) out.push('pr_ready');
|
|
72
|
+
if (has(/\bgh\s+pr\s+merge\b/)) out.push('pr_merge');
|
|
73
|
+
if (has(/\bgh\s+pr\s+edit\b[^;&|]*reviewer/)) out.push('set_reviewer');
|
|
74
|
+
if (has(/\btask:new\b/)) out.push('new_task', 'task_new');
|
|
75
|
+
if (has(/\btask:move\b/)) out.push('task_move');
|
|
76
|
+
if (has(/\bgit\s+merge\b/)) out.push('merge_base');
|
|
77
|
+
if (has(SHELL_WRITES_FLOW) && has(SHELL_WRITE)) out.push('shell_write_progress');
|
|
78
|
+
if (has(/(^|[;&|]\s*)cp\s/)) out.push('copy_template');
|
|
79
|
+
if (has(/\bprisma\s+migrate\s+reset\b/)) out.push('db_reset');
|
|
80
|
+
if (has(/\bprisma\s+migrate\s+(deploy|dev)\b/)) out.push('migrate');
|
|
81
|
+
if (has(/\bcurl\b[^;&|]*\b(localhost|127\.0\.0\.1)\b/)) out.push('check_stand');
|
|
82
|
+
if (has(/\brun\s+serve:|\bnx\s+serve\b|\bng\s+serve\b/)) out.push('raise_dev_server');
|
|
83
|
+
if (has(/\bhttp\.server\b|\bnpx\s+(serve|http-server)\b/)) out.push('raise_static');
|
|
84
|
+
return out;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function editClasses(tool, input, cwd) {
|
|
88
|
+
const raw = input.file_path ?? input.pathInProject ?? '';
|
|
89
|
+
const path = raw && !isAbsolute(raw) && cwd ? join(cwd, raw) : raw;
|
|
90
|
+
const added = `${input.new_string ?? ''}${input.content ?? ''}${(input.edits ?? []).map((e) => e.new_string ?? '').join('\n')}`;
|
|
91
|
+
const removed = `${input.old_string ?? ''}${(input.edits ?? []).map((e) => e.old_string ?? '').join('\n')}`;
|
|
92
|
+
const write = tool === 'Write' || tool === 'mcp__webstorm__create_new_file';
|
|
93
|
+
const out = [];
|
|
94
|
+
const at = (re) => re.test(path);
|
|
95
|
+
if (at(/\.git\/rt-kit\/steps\//)) out.push('write_marks');
|
|
96
|
+
if (at(/\/\.claude\/handoff\//)) out.push('write_handover');
|
|
97
|
+
if (at(/\/docs\/tasks\/[^/]+\/progress\.md$/)) {
|
|
98
|
+
if (/- \[x\]/.test(added) || /- \[x\]/.test(removed)) out.push('mark_step_done');
|
|
99
|
+
if (/`[а-яё]+(-[а-яё]+)+`/.test(added + removed)) out.push('set_state');
|
|
100
|
+
out.push('edit_progress');
|
|
101
|
+
}
|
|
102
|
+
if (at(/\/docs\/tasks\/[^/]+\/plan\.md$/)) out.push('edit_plan');
|
|
103
|
+
if (at(/\/docs\/plans\/[^/]+\.md$/)) out.push(/отложено/.test(added + removed) ? 'defer_task' : 'edit_plan');
|
|
104
|
+
if (at(/\/assets\/task-flow\/|\/flow-[a-z-]+\.mjs$|\/task-flow-script\.mjs$/)) out.push('edit_flow_description');
|
|
105
|
+
if (at(/\/\.claude\/rt-kit\/observations\//)) out.push('edit_observations');
|
|
106
|
+
if (at(/\/\.claude\/rt-kit\.json$/)) out.push('edit_rtkit_send');
|
|
107
|
+
if (at(/\/\.claude\/rt-kit\/overrides\//)) out.push(...(write ? ['write_override', 'edit_override'] : ['edit_override']));
|
|
108
|
+
if (write && at(/\/docs\/specs\/.+\/proposed\//)) out.push('write_agreement');
|
|
109
|
+
if (at(/\/projects\/[^/]+\/(src|assets)\/(laws|rules|patterns)\//)) out.push('edit_source');
|
|
110
|
+
if (laidOut(path)) out.push('edit_laid_out');
|
|
111
|
+
if (at(/\.html$/)) {
|
|
112
|
+
if (/<(button|a)\b(?![^>]*qa-dataid)[^>]*>/.test(added)) out.push('template_no_anchor');
|
|
113
|
+
if (/<(input|select|textarea)\b/.test(added)) out.push('template_own_primitive');
|
|
114
|
+
out.push('edit_template');
|
|
115
|
+
}
|
|
116
|
+
if (at(/\.md$/)) {
|
|
117
|
+
if (proseDirty(added)) out.push('write_dirty_md');
|
|
118
|
+
out.push('edit_doc');
|
|
119
|
+
}
|
|
120
|
+
if (at(/\.(ts|js|mjs|cjs|tsx|jsx|scss|css|json|sh)$/)) out.push('edit_code');
|
|
121
|
+
return out;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Every class the call fits, the most specific first, and `work_call` last: any call of work. The
|
|
126
|
+
* input is the hook input as the host gives it.
|
|
127
|
+
*/
|
|
128
|
+
export function actionsOf(hookInput) {
|
|
129
|
+
const tool = hookInput?.tool_name ?? '';
|
|
130
|
+
const input = hookInput?.tool_input ?? {};
|
|
131
|
+
const out = [];
|
|
132
|
+
if ((hookInput?.hook_event_name ?? '') === 'Stop' || (hookInput?.hook_event_name ?? '') === 'SubagentStop') return ['end_turn'];
|
|
133
|
+
if (tool === 'EndConversation') out.push('end_conversation');
|
|
134
|
+
if (tool === 'Agent' && input.subagent_type === 'strict-teacher') out.push('call_teacher');
|
|
135
|
+
if (tool === 'mcp__claude-in-chrome__select_browser') out.push('select_pinned', 'select_other');
|
|
136
|
+
if (tool === 'mcp__claude-in-chrome__list_connected_browsers') out.push('list_browsers');
|
|
137
|
+
if (tool.startsWith('mcp__claude-in-chrome__')) out.push('browser_call');
|
|
138
|
+
if (/^mcp__(playwright|puppeteer|chrome-devtools|Claude_Browser)__/.test(tool)) out.push('other_driver');
|
|
139
|
+
if (tool === 'mcp__webstorm__execute_run_configuration') out.push(/package\.json$/.test(input.filePath ?? '') ? 'run_manifest_script' : 'run_config_serve');
|
|
140
|
+
if (SHELL_TOOLS.has(tool)) out.push(...shellClasses(String(input.command ?? '')));
|
|
141
|
+
if (EDIT_TOOLS.has(tool)) out.push(...editClasses(tool, input, hookInput?.cwd ?? ''));
|
|
142
|
+
out.push('work_call');
|
|
143
|
+
return out;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Every class of the call the hook has a row for, the most specific first. */
|
|
147
|
+
export function knownActionsOf(hookInput, known) {
|
|
148
|
+
return actionsOf(hookInput).filter((a) => known.has(a));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** The first class of the call the hook has a row for, or null. */
|
|
152
|
+
export function actionOf(hookInput, known) {
|
|
153
|
+
return actionsOf(hookInput).find((a) => known.has(a)) ?? null;
|
|
154
|
+
}
|
|
@@ -45,6 +45,8 @@ export function runsOnHead(sha, options) {
|
|
|
45
45
|
* neighbouring check of the last rollout.
|
|
46
46
|
*
|
|
47
47
|
* Returns `null` if there were no rollouts at all: that is not a discrepancy but nothing to compare.
|
|
48
|
+
* A comparison the host refused returns the rollout with `behind: null` and the words of the host in
|
|
49
|
+
* `refused`: the caller prints a note and goes on to the lines after it.
|
|
48
50
|
*/
|
|
49
51
|
export function deployLag(workflow, mainBranch, options) {
|
|
50
52
|
const runs = gh(
|
|
@@ -63,11 +65,44 @@ export function deployLag(workflow, mainBranch, options) {
|
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
const run = JSON.parse(last);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
try {
|
|
69
|
+
return { sha: run.sha, at: run.at, behind: commitsBehind(run.sha, mainBranch, options) };
|
|
70
|
+
} catch (error) {
|
|
71
|
+
const words = String(error.stderr ?? error.message ?? '').trim();
|
|
72
|
+
if (!(error instanceof Error) || !COMPARISON_REFUSED.test(words)) {
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
return { sha: run.sha, at: run.at, behind: null, refused: words.split('\n')[0] };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The refusal of the host to compare: it could not build the answer in time. The GraphQL comparison
|
|
81
|
+
* says so by «This may be the result of a timeout», which the reader of the host takes for a network
|
|
82
|
+
* failure by its word «timeout». The words «Something went wrong while executing your query» alone
|
|
83
|
+
* are not enough: the host says them for a commit that is gone as well, measured on 21.11, and such a
|
|
84
|
+
* commit must break the audit, not leave it green. Only the timeout is a note. Another failure — a
|
|
85
|
+
* 422, a 500, a refusal by rights (HTTP 403), a commit that is gone — breaks the audit.
|
|
86
|
+
*/
|
|
87
|
+
const COMPARISON_REFUSED = /result of a timeout/i;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* How many commits the main branch holds past the rolled-out one.
|
|
91
|
+
*
|
|
92
|
+
* Asked by the GraphQL comparison, which counts commits and builds no diff. The REST comparison
|
|
93
|
+
* builds the diff of the whole even for a page of one commit — 300 files on 21.11 — and at a lag of
|
|
94
|
+
* hundreds of commits the host refused it with 422 twice in a row before the PR of a task.
|
|
95
|
+
*/
|
|
96
|
+
function commitsBehind(sha, mainBranch, options) {
|
|
97
|
+
const query =
|
|
98
|
+
`query{repository(owner:"${OWNER}",name:"${REPO}"){` +
|
|
99
|
+
`ref(qualifiedName:"refs/heads/${mainBranch}"){compare(headRef:"${sha}"){behindBy}}}}`;
|
|
100
|
+
const answer = gh(['api', 'graphql', '-f', `query=${query}`, '--jq', '.data.repository.ref.compare.behindBy'], options);
|
|
101
|
+
const behind = Number(String(answer).trim());
|
|
102
|
+
if (String(answer).trim() === '' || !Number.isFinite(behind)) {
|
|
103
|
+
throw new Error(`the comparison of «${mainBranch}» with ${sha.slice(0, 8)} returned no number: ${String(answer).trim() || 'empty'}`);
|
|
104
|
+
}
|
|
105
|
+
return behind;
|
|
71
106
|
}
|
|
72
107
|
|
|
73
108
|
/**
|
|
@@ -316,21 +316,32 @@ try {
|
|
|
316
316
|
// Production is audited against the main branch by the last successful rollout. A task leaves the
|
|
317
317
|
// queue by a merge, but a merge is not yet production: where the rollout is started by hand, any
|
|
318
318
|
// number of commits may lie between them, and there is nowhere to notice this from.
|
|
319
|
+
let productionOffline = false;
|
|
320
|
+
let hostFailed = false;
|
|
319
321
|
if (!offline && DEPLOY_WORKFLOW) {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
+
const token = botToken() ?? undefined;
|
|
323
|
+
productionStep(() => {
|
|
322
324
|
const lag = deployLag(DEPLOY_WORKFLOW, MAIN_BRANCH, { token });
|
|
323
325
|
if (lag === null) {
|
|
324
326
|
report(`there was not a single rollout by «${DEPLOY_WORKFLOW}» — there is nothing to compare production against`);
|
|
327
|
+
} else if (lag.refused) {
|
|
328
|
+
// The host could not compare: a note, not a divergence — nothing was judged.
|
|
329
|
+
console.log(
|
|
330
|
+
`check-board: production was not compared with «${MAIN_BRANCH}» — the last rollout is ` +
|
|
331
|
+
`${lag.sha.slice(0, 8)} of ${String(lag.at).slice(0, 10)}, the host answered: ${lag.refused}`
|
|
332
|
+
);
|
|
325
333
|
} else if (lag.behind > 0) {
|
|
326
334
|
report(
|
|
327
335
|
`production lags «${MAIN_BRANCH}» by ${lag.behind} commits: the last rollout is ${lag.sha.slice(0, 8)} of ${String(lag.at).slice(0, 10)}`
|
|
328
336
|
);
|
|
329
337
|
}
|
|
338
|
+
});
|
|
330
339
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
340
|
+
// Why production fell behind, the lag does not say: it is counted by the last SUCCESSFUL
|
|
341
|
+
// rollout, and "not started" and "failed" look the same through it. They lead to different
|
|
342
|
+
// things — the first is started, the second is read by its output and fixed. It is asked in a
|
|
343
|
+
// step of its own: a lag the host could not measure does not hide a rollout that fell.
|
|
344
|
+
productionStep(() => {
|
|
334
345
|
const deploy = lastDeploy(DEPLOY_WORKFLOW, { token });
|
|
335
346
|
if (deploy.verdict === 'failure') {
|
|
336
347
|
report(
|
|
@@ -338,12 +349,28 @@ if (!offline && DEPLOY_WORKFLOW) {
|
|
|
338
349
|
`the main branch is ahead of production, and merges on top will travel the same way — ${deploy.url}`
|
|
339
350
|
);
|
|
340
351
|
}
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* One request about production. No connection is a note, said once: the next step would only
|
|
357
|
+
* repeat it. Any other failure is a line of its own and the exit code 1, not a stack — and the audit
|
|
358
|
+
* goes on: what the queue and the next steps have judged is printed, not thrown away with it.
|
|
359
|
+
*/
|
|
360
|
+
function productionStep(step) {
|
|
361
|
+
if (productionOffline) {
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
try {
|
|
365
|
+
step();
|
|
341
366
|
} catch (error) {
|
|
342
367
|
if (error instanceof OfflineError) {
|
|
343
368
|
console.log(`check-board: production was not checked — ${error.message}`);
|
|
344
|
-
|
|
345
|
-
|
|
369
|
+
productionOffline = true;
|
|
370
|
+
return;
|
|
346
371
|
}
|
|
372
|
+
console.error(`check-board: production was not checked, the host failed — ${String(error.message ?? error)}`);
|
|
373
|
+
hostFailed = true;
|
|
347
374
|
}
|
|
348
375
|
}
|
|
349
376
|
|
|
@@ -420,6 +447,10 @@ if (problems.length > 0) {
|
|
|
420
447
|
process.exit(1);
|
|
421
448
|
}
|
|
422
449
|
|
|
450
|
+
if (hostFailed) {
|
|
451
|
+
process.exit(1);
|
|
452
|
+
}
|
|
453
|
+
|
|
423
454
|
if (offline) {
|
|
424
455
|
process.exit(0);
|
|
425
456
|
}
|
|
@@ -101,21 +101,33 @@ function sectionsOf(pattern) {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
const sections = [];
|
|
104
|
+
|
|
105
|
+
// A pattern split into a hot index and a cold part keeps every state heading hot, while the body
|
|
106
|
+
// of a section, its move line included, may stand in the cold part under the same heading. The
|
|
107
|
+
// cold part adds moves to the sections of the index and declares none of its own; its second file
|
|
108
|
+
// continues the section the first one broke off in.
|
|
109
|
+
const cold = ['pitfalls.md', 'pitfalls-2.md'].map((name) => join(SKILLS, pattern, name)).filter((path) => existsSync(path));
|
|
110
|
+
|
|
104
111
|
let current = null;
|
|
105
112
|
|
|
106
|
-
for (const
|
|
107
|
-
|
|
113
|
+
for (const path of [file, ...cold]) {
|
|
114
|
+
if (!path.endsWith('pitfalls-2.md')) current = null;
|
|
108
115
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
116
|
+
for (const line of readFileSync(path, 'utf8').split('\n')) {
|
|
117
|
+
const heading = line.match(/^#+\s+(?:State|Состояние)\s+`([^`]+)`/);
|
|
118
|
+
|
|
119
|
+
if (heading) {
|
|
120
|
+
const text = line.replace(/^#+\s+/, '');
|
|
121
|
+
current = path === file ? { name: heading[1], heading: text, moves: [] } : (sections.find((one) => one.heading === text) ?? null);
|
|
122
|
+
if (path === file) sections.push(current);
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
114
125
|
|
|
115
|
-
|
|
126
|
+
const marker = current ? markerOf(line) : undefined;
|
|
116
127
|
|
|
117
|
-
|
|
118
|
-
|
|
128
|
+
if (marker) {
|
|
129
|
+
current.moves.push(line.slice(marker.length).trim());
|
|
130
|
+
}
|
|
119
131
|
}
|
|
120
132
|
}
|
|
121
133
|
|
|
@@ -12,10 +12,11 @@
|
|
|
12
12
|
* the map. The session then gets the map, does not find its state in it and goes to read the rule —
|
|
13
13
|
* that is, the map works exactly up to the first new state.
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
* the size
|
|
17
|
-
* the states
|
|
18
|
-
* the exits
|
|
15
|
+
* Four things are checked:
|
|
16
|
+
* the size — the bytes of the laid-out map against the declared limit;
|
|
17
|
+
* the states — the names from the table of the rule against the names in the map, both ways;
|
|
18
|
+
* the exits — both ends of a turn are named: the end of the scenario and the owner's Esc;
|
|
19
|
+
* the old exits — none of the former exits is named as an item of the map.
|
|
19
20
|
*
|
|
20
21
|
* FAIL-OPEN: there is no map in the tree — nothing to check, a zero code. The tree may leave it
|
|
21
22
|
* unlaid. An empty table of states in the map counts as a refusal: that is not «there is nothing
|
|
@@ -87,10 +88,21 @@ function statesOf(text, { listed: readListed = false } = {}) {
|
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
/**
|
|
90
|
-
* The
|
|
91
|
-
* package, the Russian one is held by a tree whose map is
|
|
91
|
+
* The ends of a turn: the scenario is over, or the owner pressed Esc. Each has two
|
|
92
|
+
* names: the English one is brought by the package, the Russian one is held by a tree whose map is
|
|
93
|
+
* still its own. Either of the two is enough.
|
|
92
94
|
*/
|
|
93
95
|
const EXITS = [
|
|
96
|
+
['the end of the scenario', 'конец сценария'],
|
|
97
|
+
['the owner interrupted the turn', 'прерывание владельца'],
|
|
98
|
+
];
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The former exits of a turn. A question, a guard's refusal, a filled window and handed-over work no
|
|
102
|
+
* longer end a turn: the exit guard holds it until the scenario is over. A map that still names one of
|
|
103
|
+
* them as an item tells the session to stop where the guard returns it. An item is a bold name.
|
|
104
|
+
*/
|
|
105
|
+
const OLD_EXITS = [
|
|
94
106
|
['a question to the owner', 'вопрос владельцу'],
|
|
95
107
|
['a guard refusal', 'отказ гарда'],
|
|
96
108
|
['the window filled', 'заполненное окно'],
|
|
@@ -148,6 +160,14 @@ function main() {
|
|
|
148
160
|
}
|
|
149
161
|
}
|
|
150
162
|
|
|
163
|
+
for (const names of OLD_EXITS) {
|
|
164
|
+
const named = names.find((name) => text.includes(`**${name}`));
|
|
165
|
+
|
|
166
|
+
if (named) {
|
|
167
|
+
faults.push(`the map names the old exit «${named}»: a turn no longer ends by it`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
151
171
|
if (faults.length > 0) {
|
|
152
172
|
console.log(`check-turn-map: divergences ${faults.length}, size ${bytes} bytes at a limit of ${LIMIT_BYTES}\n`);
|
|
153
173
|
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
* the names — copied from the plan word for word, not reworded;
|
|
13
13
|
* the marks — exactly one step going on right now, while any step is not done yet.
|
|
14
14
|
*
|
|
15
|
-
* The
|
|
16
|
-
*
|
|
15
|
+
* The parsing of both lists lives in `work-steps-lib.mjs`: the engine of the task flow reads the
|
|
16
|
+
* same steps, and two parsers of one format diverge silently.
|
|
17
17
|
*
|
|
18
18
|
* FAIL-OPEN: no task folder, no plan in it, or a plan that names no steps — a zero code. A tree
|
|
19
19
|
* that has not started writing steps is not refused: the requirement arrives with the sample of the
|
|
@@ -24,183 +24,14 @@
|
|
|
24
24
|
*
|
|
25
25
|
* A non-zero exit code and the list of divergences.
|
|
26
26
|
*/
|
|
27
|
-
import { existsSync,
|
|
27
|
+
import { existsSync, readdirSync } from 'node:fs';
|
|
28
28
|
import { join } from 'node:path';
|
|
29
29
|
|
|
30
30
|
import { CONFIG, ROOT } from './rt-kit-checks.config.mjs';
|
|
31
|
+
import { judge } from './work-steps-lib.mjs';
|
|
31
32
|
|
|
32
33
|
const TASKS = CONFIG.tasksDir ? join(ROOT, CONFIG.tasksDir) : '';
|
|
33
34
|
|
|
34
|
-
/** The heading the steps of the progress lie under. */
|
|
35
|
-
const STEPS_HEADING = /^##\s+(?:Steps|Шаги)\s*$/;
|
|
36
|
-
/** The heading the stages of the plan lie under. */
|
|
37
|
-
const STAGES_HEADING = /^##\s+(?:Stages|Этапы)\s*$/;
|
|
38
|
-
/** A stage heading: the number stands before the dot, the name after it. */
|
|
39
|
-
const STAGE_HEADING = /^###\s+(\d+)\.\s+(.+?)\s*$/;
|
|
40
|
-
/** The opening of the step list inside a stage. */
|
|
41
|
-
const STEPS_OPENING = /^-\s+\*\*(?:Steps|Шаги):\*\*\s*$/;
|
|
42
|
-
/** A step of the plan: an indented ordinal and the name. */
|
|
43
|
-
const PLAN_STEP = /^\s+(\d+)\.\s+(.+?)\s*$/;
|
|
44
|
-
/** Another key of the stage: it closes the step list. */
|
|
45
|
-
const STAGE_KEY = /^-\s+\*\*/;
|
|
46
|
-
/** A step of the progress: the mark, the number of the stage, the number of the step, the name. */
|
|
47
|
-
const PROGRESS_STEP = /^-\s+\[([x>\s])\]\s+(\d+)\.(\d+)\s+(.+?)\s*$/;
|
|
48
|
-
/**
|
|
49
|
-
* A name left as the sample wrote it. The sample of a task folder carries step names in angle
|
|
50
|
-
* brackets, and a folder just copied from it holds them on both sides — with different words, so
|
|
51
|
-
* every fresh folder would be red before a line of work is done in it. The sample directory itself
|
|
52
|
-
* is judged by the same sign and needs no name of its own here.
|
|
53
|
-
*/
|
|
54
|
-
const BLANK_NAME = /^<.+>$/;
|
|
55
|
-
|
|
56
|
-
/** The mark of a step that is done. */
|
|
57
|
-
const DONE = 'x';
|
|
58
|
-
/** The mark of the step going on right now. */
|
|
59
|
-
const CURRENT = '>';
|
|
60
|
-
|
|
61
|
-
/** The steps of the plan: the number «<stage>.<step>» and the name, in the order they are written. */
|
|
62
|
-
function stepsOfPlan(text) {
|
|
63
|
-
const steps = [];
|
|
64
|
-
let stage = null;
|
|
65
|
-
let inside = false;
|
|
66
|
-
let listing = false;
|
|
67
|
-
|
|
68
|
-
for (const line of text.split('\n')) {
|
|
69
|
-
if (STAGES_HEADING.test(line)) {
|
|
70
|
-
inside = true;
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (inside && /^##\s+/.test(line)) {
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (!inside) {
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const heading = line.match(STAGE_HEADING);
|
|
83
|
-
|
|
84
|
-
if (heading) {
|
|
85
|
-
stage = heading[1];
|
|
86
|
-
listing = false;
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (STEPS_OPENING.test(line)) {
|
|
91
|
-
listing = true;
|
|
92
|
-
continue;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (!listing) {
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const step = line.match(PLAN_STEP);
|
|
100
|
-
|
|
101
|
-
if (step) {
|
|
102
|
-
steps.push({ number: `${stage}.${step[1]}`, name: step[2] });
|
|
103
|
-
continue;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (STAGE_KEY.test(line) || line.trim() === '') {
|
|
107
|
-
listing = line.trim() === '' ? listing : false;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return steps;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/** The steps of the progress: the number, the name and the mark, in the order they are written. */
|
|
115
|
-
function stepsOfProgress(text) {
|
|
116
|
-
const steps = [];
|
|
117
|
-
let inside = false;
|
|
118
|
-
|
|
119
|
-
for (const line of text.split('\n')) {
|
|
120
|
-
if (STEPS_HEADING.test(line)) {
|
|
121
|
-
inside = true;
|
|
122
|
-
continue;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (inside && /^##\s+/.test(line)) {
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (!inside) {
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const step = line.match(PROGRESS_STEP);
|
|
134
|
-
|
|
135
|
-
if (step) {
|
|
136
|
-
steps.push({ mark: step[1].trim() || ' ', number: `${step[2]}.${step[3]}`, name: step[4] });
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return { steps, declared: inside };
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/** What is wrong with one task folder. An empty list means it matches. */
|
|
144
|
-
function judge(folder) {
|
|
145
|
-
const plan = join(folder, 'plan.md');
|
|
146
|
-
const progress = join(folder, 'progress.md');
|
|
147
|
-
|
|
148
|
-
if (!existsSync(plan) || !existsSync(progress)) {
|
|
149
|
-
return [];
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
const planned = stepsOfPlan(readFileSync(plan, 'utf8'));
|
|
153
|
-
const { steps: marked, declared } = stepsOfProgress(readFileSync(progress, 'utf8'));
|
|
154
|
-
|
|
155
|
-
if (planned.some((step) => BLANK_NAME.test(step.name))) {
|
|
156
|
-
return [];
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (planned.length === 0) {
|
|
160
|
-
return declared && marked.length > 0
|
|
161
|
-
? ['the progress carries a list of steps, and the plan names none: the list was written from the head']
|
|
162
|
-
: [];
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (!declared) {
|
|
166
|
-
return [`the plan names ${planned.length} steps, and the progress carries no section of steps`];
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
const problems = [];
|
|
170
|
-
|
|
171
|
-
if (marked.length !== planned.length) {
|
|
172
|
-
problems.push(`the plan names ${planned.length} steps, the progress ${marked.length}`);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
for (let index = 0; index < Math.min(planned.length, marked.length); index += 1) {
|
|
176
|
-
if (planned[index].number !== marked[index].number) {
|
|
177
|
-
problems.push(`step ${index + 1} in a row: the plan calls it «${planned[index].number}», the progress «${marked[index].number}»`);
|
|
178
|
-
continue;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (planned[index].name !== marked[index].name) {
|
|
182
|
-
problems.push(`step ${planned[index].number}: the name in the progress is not the name in the plan — «${marked[index].name}»`);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const current = marked.filter((step) => step.mark === CURRENT);
|
|
187
|
-
const left = marked.filter((step) => step.mark !== DONE);
|
|
188
|
-
|
|
189
|
-
if (left.length > 0 && current.length !== 1) {
|
|
190
|
-
problems.push(
|
|
191
|
-
current.length === 0
|
|
192
|
-
? `${left.length} steps are not done, and none is marked as going on right now`
|
|
193
|
-
: `${current.length} steps are marked as going on right now, and there is only ever one`,
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if (left.length === 0 && current.length > 0) {
|
|
198
|
-
problems.push('every step is done, and one is still marked as going on right now');
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
return problems;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
35
|
if (!TASKS || !existsSync(TASKS)) {
|
|
205
36
|
console.log('check-work-steps: the tree has no task folders — there is nothing to check');
|
|
206
37
|
process.exit(0);
|