@rt-tools/agent-kit 0.37.0 → 0.38.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-pull-state.github.mjs +82 -13
- package/assets/checks/board-runs.github.mjs +40 -5
- package/assets/checks/board.github.mjs +1 -1
- package/assets/checks/check-board.github.mjs +58 -19
- package/assets/checks/check-specs.mjs +2 -2
- 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 +21365 -0
- package/assets/checks/decision-table.mjs +495 -0
- package/assets/checks/epic-table.github.mjs +4 -3
- package/assets/checks/epic-window.mjs +98 -0
- package/assets/checks/flow-condition.mjs +64 -0
- package/assets/checks/flow-data.mjs +136 -0
- package/assets/checks/flow-forecast.mjs +330 -0
- package/assets/checks/flow-guard-run.mjs +90 -0
- package/assets/checks/flow-guard.mjs +294 -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 +365 -0
- package/assets/checks/flow-sync.mjs +296 -0
- package/assets/checks/flow-syntax.mjs +292 -0
- package/assets/checks/flow-verdict.mjs +112 -0
- package/assets/checks/lib-common.mjs +10 -2
- package/assets/checks/lib-domains.mjs +1 -1
- package/assets/checks/lib-manifests.mjs +34 -2
- package/assets/checks/merge-read.mjs +239 -0
- package/assets/checks/owner-nudges.mjs +389 -0
- package/assets/checks/push-inputs.mjs +444 -0
- package/assets/checks/push-trace.mjs +108 -0
- package/assets/checks/record-count.mjs +410 -0
- package/assets/checks/record-recount.mjs +187 -0
- package/assets/checks/record-turn.mjs +155 -0
- package/assets/checks/rt-kit-checks.config.mjs +17 -2
- package/assets/checks/spec-anchors.mjs +4 -4
- package/assets/checks/spec-contract.mjs +5 -5
- package/assets/checks/task-flow-script.mjs +292 -0
- package/assets/checks/tree-assignment.mjs +26 -7
- package/assets/checks/work-result.mjs +281 -0
- package/assets/checks/work-steps-lib.mjs +205 -0
- package/assets/commands/next-session.md +3 -1
- package/assets/commands/night.md +28 -18
- package/assets/defaults/gate-map.sh +39 -12
- package/assets/defaults/merges.sh +48 -0
- package/assets/defaults/project.sh +43 -13
- package/assets/defaults/push.sh +23 -0
- package/assets/defaults/turn-map.md +24 -21
- package/assets/docs/GLOSSARY.md +6 -2
- package/assets/hooks/ask-judge.md +65 -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 -105
- 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 +308 -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 +32 -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 +46 -5
- package/assets/hooks/git-guard-push-marks.sh +227 -31
- package/assets/hooks/git-guard-push-tests.sh +51 -53
- 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 +20 -39
- 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 +20 -10
- package/assets/hooks/prose-style-guard.sh +6 -19
- package/assets/hooks/pull-merges.sh +76 -0
- package/assets/hooks/push-set.sh +39 -7
- 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 +20 -22
- package/assets/hooks/task-flow-draft-guard.sh +25 -74
- package/assets/hooks/task-flow-guard.sh +28 -129
- 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 +47 -0
- package/assets/hooks/turn-judge.md +103 -0
- package/assets/hooks/window-fill-guard.sh +22 -41
- package/assets/laws/work-conduct.md +9 -8
- package/assets/patterns/autonomous-work-run.md +35 -10
- package/assets/patterns/browser-verification-measure.md +10 -20
- package/assets/patterns/browser-verification-stand.md +30 -42
- package/assets/patterns/doc-style-human.md +0 -6
- package/assets/patterns/doc-style-sweep.md +7 -7
- package/assets/patterns/doc-style-trace.md +5 -4
- package/assets/patterns/doc-style-write.md +7 -7
- package/assets/patterns/epic-flow-declare.md +15 -8
- 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 +9 -56
- package/assets/patterns/git-workflow-merge.md +7 -174
- package/assets/patterns/git-workflow-migration.md +5 -73
- package/assets/patterns/git-workflow-pr-body.github.md +6 -159
- package/assets/patterns/git-workflow-pr-ready.md +9 -69
- package/assets/patterns/git-workflow-pr.azure.md +14 -220
- package/assets/patterns/git-workflow-pr.github.md +13 -253
- package/assets/patterns/git-workflow-pr.gitlab.md +14 -241
- package/assets/patterns/git-workflow-restart.md +5 -41
- package/assets/patterns/git-workflow-secrets.md +10 -76
- package/assets/patterns/git-workflow-stack.md +9 -205
- package/assets/patterns/lib-layers-new.md +7 -3
- package/assets/patterns/queue-audit-read.github.md +9 -3
- package/assets/patterns/spec-driven-domain.md +50 -48
- package/assets/patterns/spec-driven-rule.md +18 -19
- package/assets/patterns/status-report-table.github.md +2 -2
- package/assets/patterns/task-flow-archive.md +15 -256
- package/assets/patterns/task-flow-close.md +16 -291
- package/assets/patterns/task-flow-cycle.md +13 -39
- package/assets/patterns/task-flow-graph.needs-graph.md +8 -58
- package/assets/patterns/task-flow-handoff.md +13 -161
- package/assets/patterns/task-flow-resume.md +19 -183
- package/assets/patterns/task-flow-start.md +9 -248
- package/assets/patterns/testing-e2e.md +14 -18
- package/assets/patterns/testing-unit.md +9 -13
- package/assets/patterns/turn-entry-map.md +15 -5
- 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/autonomous-work.md +15 -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.2.md +286 -0
- package/assets/pitfalls/doc-style.md +3 -3
- package/assets/pitfalls/entity-conventions.needs-admin.md +96 -0
- package/assets/pitfalls/entity-models.md +89 -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/git-workflow.github.md +5 -9
- package/assets/pitfalls/lib-layers.md +114 -0
- package/assets/pitfalls/lists.md +117 -0
- package/assets/pitfalls/navigation.md +94 -0
- package/assets/pitfalls/reuse-first.md +201 -0
- package/assets/pitfalls/spec-driven.2.md +318 -0
- package/assets/pitfalls/spec-driven.md +9 -7
- package/assets/pitfalls/styling-bem.2.md +125 -0
- package/assets/pitfalls/task-flow-archive.md +264 -0
- package/assets/pitfalls/task-flow-close.2.md +165 -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 +29 -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 +18 -29
- package/assets/pitfalls/testing.2.md +279 -0
- package/assets/pitfalls/testing.md +11 -12
- package/assets/pitfalls/turn-conduct.md +17 -18
- 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 +37 -29
- package/assets/rules/browser-verification.md +28 -251
- package/assets/rules/component-structure.md +25 -87
- package/assets/rules/dependencies.md +20 -78
- package/assets/rules/deploy-flow.azure.md +27 -134
- package/assets/rules/deploy-flow.github.md +34 -196
- package/assets/rules/deploy-flow.gitlab.md +28 -137
- package/assets/rules/doc-style.md +32 -282
- package/assets/rules/entity-conventions.needs-admin.md +26 -82
- package/assets/rules/entity-models.md +14 -63
- package/assets/rules/epic-flow.md +5 -3
- 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 -264
- package/assets/rules/git-workflow.github.md +24 -285
- package/assets/rules/git-workflow.gitlab.md +21 -258
- package/assets/rules/lib-layers.md +30 -103
- package/assets/rules/lists.md +21 -105
- package/assets/rules/navigation.md +10 -69
- package/assets/rules/queue-audit.github.md +5 -3
- package/assets/rules/reuse-first.md +20 -195
- package/assets/rules/spec-driven.md +35 -316
- package/assets/rules/status-report.md +5 -3
- 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 -289
- package/assets/rules/testing.md +32 -270
- package/assets/rules/turn-conduct.md +109 -111
- 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 +188 -0
- package/assets/task-flow/flow.md +102 -0
- package/assets/task-flow/measure/agreement.mjs +24 -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 +20 -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 +175 -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 +86 -0
- package/assets/task-flow/source/host.mjs +172 -0
- package/assets/task-flow/source/marks.mjs +56 -0
- package/assets/task-flow/source/owner.mjs +74 -0
- package/assets/task-flow/source/records.mjs +116 -0
- package/assets/task-flow/source/session.mjs +232 -0
- package/assets/task-flow/source/steps.mjs +28 -0
- package/assets/task-flow/source/tree.mjs +42 -0
- package/assets/templates/rule.md +2 -2
- 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 +209 -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-prose.d.ts +2 -1
- package/lib/cargo-prose.d.ts.map +1 -1
- package/lib/cargo-prose.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/companion.d.ts +0 -5
- package/lib/companion.d.ts.map +1 -1
- package/lib/companion.js +1 -1
- package/lib/companion.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/cost.d.ts +0 -8
- package/lib/cost.d.ts.map +1 -1
- package/lib/cost.js +4 -4
- package/lib/cost.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 -12
- package/lib/hooks-map.d.ts.map +1 -1
- package/lib/hooks-map.js +4 -27
- 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-cargo.d.ts +1 -5
- package/lib/observations-cargo.d.ts.map +1 -1
- package/lib/observations-cargo.js +2 -2
- package/lib/observations-cargo.js.map +1 -1
- package/lib/observations.d.ts +0 -2
- package/lib/observations.d.ts.map +1 -1
- package/lib/observations.js +3 -3
- package/lib/observations.js.map +1 -1
- package/lib/order.d.ts +0 -2
- package/lib/order.d.ts.map +1 -1
- package/lib/order.js +0 -4
- package/lib/order.js.map +1 -1
- package/lib/outcomes.d.ts +7 -9
- package/lib/outcomes.d.ts.map +1 -1
- package/lib/outcomes.js +8 -7
- package/lib/outcomes.js.map +1 -1
- package/lib/proposals.d.ts +0 -1
- package/lib/proposals.d.ts.map +1 -1
- package/lib/proposals.js +1 -1
- package/lib/proposals.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/shipment.d.ts +2 -11
- package/lib/shipment.d.ts.map +1 -1
- package/lib/shipment.fixture.d.ts +0 -3
- package/lib/shipment.fixture.d.ts.map +1 -1
- package/lib/shipment.fixture.js +3 -3
- package/lib/shipment.fixture.js.map +1 -1
- package/lib/shipment.js +2 -2
- package/lib/shipment.js.map +1 -1
- 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/traits.d.ts +0 -3
- package/lib/traits.d.ts.map +1 -1
- package/lib/traits.js +2 -2
- package/lib/traits.js.map +1 -1
- package/lib/variants.d.ts +0 -1
- package/lib/variants.d.ts.map +1 -1
- package/lib/variants.js +1 -1
- package/lib/variants.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/checks/signals/ui-kit.json +0 -11
- 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
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* The count of one turn of a session record, written as observations. The hook at the end of a turn
|
|
4
|
+
* and at the end of a session calls it; so does the recount of a past day.
|
|
5
|
+
*
|
|
6
|
+
* node record-turn.mjs --record <session.jsonl> --observations <dir> --mark <file> --sid <sign>
|
|
7
|
+
* [--patterns <correction patterns>] [--version <v>] [--now <ISO>]
|
|
8
|
+
*
|
|
9
|
+
* It reads the record from the offset its mark keeps, turns the new entries into the events of
|
|
10
|
+
* `record-count.mjs` and appends each as an observation line to the file of the day of its moment:
|
|
11
|
+
* `{"t":<moment>,"ev":"record-<event>",...,"sid":<sign>}`. The words of the owner leave no text: a word
|
|
12
|
+
* carries only its kind and whether the set of correction patterns matched it.
|
|
13
|
+
*
|
|
14
|
+
* An unfinished last line — the harness writes the record while the hook runs — is left for the next
|
|
15
|
+
* count: the mark stays before it. A line in the middle that does not parse is skipped and counted
|
|
16
|
+
* (`record-skip`). A record that cannot be read writes `record-broken` and changes no mark. The count
|
|
17
|
+
* never fails the turn: every path exits with zero.
|
|
18
|
+
*
|
|
19
|
+
* Taking a task is the first moment a session stands on the branch of the task: the first entry of
|
|
20
|
+
* the session with that branch writes `{"ev":"task-taken","task":<key>}`. The mark keeps the tasks
|
|
21
|
+
* the session already took, so a later turn on the same branch writes no second taking.
|
|
22
|
+
*/
|
|
23
|
+
import { appendFileSync, existsSync, mkdirSync, openSync, readFileSync, readSync, closeSync, statSync, writeFileSync } from 'node:fs';
|
|
24
|
+
import { dirname, join } from 'node:path';
|
|
25
|
+
|
|
26
|
+
import { eventsOf, ownerWords, taskOf } from './record-count.mjs';
|
|
27
|
+
|
|
28
|
+
const option = (argv, name) => {
|
|
29
|
+
const at = argv.indexOf(name);
|
|
30
|
+
return at >= 0 ? argv[at + 1] : undefined;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/** A value fit for an observation: no path, only a name, trimmed. */
|
|
34
|
+
const clean = (value) => (value === undefined || value === null ? '' : String(value).includes('/') ? '' : String(value).replace(/[^A-Za-z0-9._:-]/g, '').slice(0, 48));
|
|
35
|
+
|
|
36
|
+
const readMark = (file) => {
|
|
37
|
+
try {
|
|
38
|
+
return JSON.parse(readFileSync(file, 'utf8'));
|
|
39
|
+
} catch {
|
|
40
|
+
return { offset: 0 };
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** The whole lines of a record from an offset: the parsed entries, the skipped count and the new offset. */
|
|
45
|
+
export function readFrom(file, offset) {
|
|
46
|
+
const size = statSync(file).size;
|
|
47
|
+
if (size <= offset) return { entries: [], skipped: 0, offset: Math.min(offset, size) };
|
|
48
|
+
const fd = openSync(file, 'r');
|
|
49
|
+
const buffer = Buffer.alloc(size - offset);
|
|
50
|
+
try {
|
|
51
|
+
readSync(fd, buffer, 0, buffer.length, offset);
|
|
52
|
+
} finally {
|
|
53
|
+
closeSync(fd);
|
|
54
|
+
}
|
|
55
|
+
const end = buffer.lastIndexOf(0x0a);
|
|
56
|
+
if (end < 0) return { entries: [], skipped: 0, offset };
|
|
57
|
+
const entries = [];
|
|
58
|
+
let skipped = 0;
|
|
59
|
+
for (const line of buffer.subarray(0, end).toString('utf8').split('\n')) {
|
|
60
|
+
if (!line.trim()) continue;
|
|
61
|
+
try {
|
|
62
|
+
entries.push(JSON.parse(line));
|
|
63
|
+
} catch {
|
|
64
|
+
skipped += 1;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return { entries, skipped, offset: offset + end + 1 };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** A task key of a branch: the taking is written only for a branch that names a task. */
|
|
71
|
+
const TASK_KEY = /^[A-Z]+-\d+$/;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The takings of tasks in some entries: the first entry of each task the session stands on, not
|
|
75
|
+
* counting the tasks of `seen`. The set is filled with what is found.
|
|
76
|
+
*/
|
|
77
|
+
export function takingsOf(entries, seen = new Set()) {
|
|
78
|
+
const out = [];
|
|
79
|
+
for (const entry of entries) {
|
|
80
|
+
const at = entry?.timestamp;
|
|
81
|
+
const task = taskOf(entry?.gitBranch);
|
|
82
|
+
if (!at || entry?.isSidechain || !task || !TASK_KEY.test(task) || seen.has(task)) continue;
|
|
83
|
+
seen.add(task);
|
|
84
|
+
out.push({ at, task });
|
|
85
|
+
}
|
|
86
|
+
return out;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** The observation lines of the events of some entries, by the day of their moment. */
|
|
90
|
+
export function observationsOf(entries, { sid, patterns, version, seen = new Set() }) {
|
|
91
|
+
const pattern = patterns ? new RegExp(patterns, 'iu') : null;
|
|
92
|
+
const corrected = new Set(
|
|
93
|
+
pattern ? ownerWords(entries).filter((w) => pattern.test(w.text)).map((w) => `${w.session}|${w.at}|${w.kind}`) : [],
|
|
94
|
+
);
|
|
95
|
+
const byDay = new Map();
|
|
96
|
+
for (const e of eventsOf(entries)) {
|
|
97
|
+
const line = { t: e.at, ev: `record-${e.ev}` };
|
|
98
|
+
const task = clean(taskOf(e.branch));
|
|
99
|
+
if (task) line.task = task;
|
|
100
|
+
for (const key of ['kind', 'check', 'tool']) if (e[key] !== undefined && e[key] !== null) line[key] = clean(e[key]);
|
|
101
|
+
if (e.ev === 'ask' && e.reask) line.reask = '1';
|
|
102
|
+
if (e.ev === 'change' && e.analysis) line.analysis = '1';
|
|
103
|
+
if (e.ev === 'menu' && e.answered) line.answered = clean(e.answered);
|
|
104
|
+
if (e.ev === 'word' && corrected.has(`${e.session}|${e.at}|${e.kind}`)) line.corr = '1';
|
|
105
|
+
line.sid = sid;
|
|
106
|
+
if (version) line.v = version;
|
|
107
|
+
const day = e.at.slice(0, 10);
|
|
108
|
+
if (!byDay.has(day)) byDay.set(day, []);
|
|
109
|
+
byDay.get(day).push(JSON.stringify(line));
|
|
110
|
+
}
|
|
111
|
+
for (const taking of takingsOf(entries, seen)) {
|
|
112
|
+
const day = taking.at.slice(0, 10);
|
|
113
|
+
if (!byDay.has(day)) byDay.set(day, []);
|
|
114
|
+
byDay.get(day).push(JSON.stringify({ t: taking.at, ev: 'task-taken', task: clean(taking.task), sid, ...(version ? { v: version } : {}) }));
|
|
115
|
+
}
|
|
116
|
+
return byDay;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function main(argv) {
|
|
120
|
+
const record = option(argv, '--record');
|
|
121
|
+
const dir = option(argv, '--observations');
|
|
122
|
+
const markFile = option(argv, '--mark');
|
|
123
|
+
const sid = clean(option(argv, '--sid'));
|
|
124
|
+
const version = clean(option(argv, '--version'));
|
|
125
|
+
const now = option(argv, '--now') ?? new Date().toISOString();
|
|
126
|
+
if (!dir || !markFile) return 0;
|
|
127
|
+
const note = (ev, extra = {}) => {
|
|
128
|
+
try {
|
|
129
|
+
mkdirSync(dir, { recursive: true });
|
|
130
|
+
appendFileSync(join(dir, `${now.slice(0, 10)}.jsonl`), `${JSON.stringify({ t: now, ev, ...extra, sid, ...(version ? { v: version } : {}) })}\n`);
|
|
131
|
+
} catch {
|
|
132
|
+
// The count never fails the turn.
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
if (!record || !existsSync(record)) {
|
|
136
|
+
note('record-broken');
|
|
137
|
+
return 0;
|
|
138
|
+
}
|
|
139
|
+
try {
|
|
140
|
+
const mark = readMark(markFile);
|
|
141
|
+
const read = readFrom(record, Number(mark.offset) || 0);
|
|
142
|
+
const seen = new Set(Array.isArray(mark.taken) ? mark.taken : []);
|
|
143
|
+
const byDay = observationsOf(read.entries, { sid, patterns: option(argv, '--patterns'), version, seen });
|
|
144
|
+
mkdirSync(dir, { recursive: true });
|
|
145
|
+
for (const [day, lines] of byDay) appendFileSync(join(dir, `${day}.jsonl`), `${lines.join('\n')}\n`);
|
|
146
|
+
if (read.skipped > 0) note('record-skip', { n: String(read.skipped) });
|
|
147
|
+
mkdirSync(dirname(markFile), { recursive: true });
|
|
148
|
+
writeFileSync(markFile, JSON.stringify({ offset: read.offset, taken: [...seen] }));
|
|
149
|
+
} catch {
|
|
150
|
+
note('record-broken');
|
|
151
|
+
}
|
|
152
|
+
return 0;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (process.argv[1] && import.meta.url === new URL(`file://${process.argv[1]}`).href) process.exit(main(process.argv.slice(2)));
|
|
@@ -46,8 +46,23 @@ const DEFAULTS = {
|
|
|
46
46
|
* while the width stood at six.
|
|
47
47
|
*/
|
|
48
48
|
scenarioPrefixWidth: [2, 10],
|
|
49
|
-
/**
|
|
50
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Where never to go: the build, the dependencies, the generated. `graphify-out` is the code graph
|
|
51
|
+
* of a tree with the trait `graph`: it lies inside a project and a lib root, and a walk that went
|
|
52
|
+
* in read its page as markup and its cache as a lib without layers.
|
|
53
|
+
*/
|
|
54
|
+
skippedDirs: [
|
|
55
|
+
'node_modules',
|
|
56
|
+
'dist',
|
|
57
|
+
'.git',
|
|
58
|
+
'.nx',
|
|
59
|
+
'tmp',
|
|
60
|
+
'coverage',
|
|
61
|
+
'worktrees',
|
|
62
|
+
'gen',
|
|
63
|
+
'generated',
|
|
64
|
+
'graphify-out',
|
|
65
|
+
],
|
|
51
66
|
/** Where the project texts lie. */
|
|
52
67
|
docsDir: 'docs',
|
|
53
68
|
/** What is set aside: the checks stay silent about it — it describes the past, not the tree. */
|
|
@@ -172,7 +172,7 @@ function checkRuleImplementation(specFile, text, mapFile, heading = ['## Rules',
|
|
|
172
172
|
report(
|
|
173
173
|
mapFile,
|
|
174
174
|
`a statement without a binding: «${head.slice(0, 60)}…» — add a line with \`file:symbol\`, ` +
|
|
175
|
-
'a verdict «Not carried out» with a reason, or move the statement into «Open questions
|
|
175
|
+
'a verdict «Not carried out» with a reason, or move the statement into «Open questions»: Q-<law letters>-<number> in a law, Q-<number> in a spec'
|
|
176
176
|
);
|
|
177
177
|
continue;
|
|
178
178
|
}
|
|
@@ -348,9 +348,9 @@ function checkTracedAnchors() {
|
|
|
348
348
|
mapFile,
|
|
349
349
|
others.length > elsewhere
|
|
350
350
|
? `the binding leads into code called by a test alone: \`${symbol}\` is declared in \`${path}\` and outside tests is met nowhere — ` +
|
|
351
|
-
'a test is not a call from the application; either the statement is carried out elsewhere, or its place is in «Open questions
|
|
351
|
+
'a test is not a call from the application; either the statement is carried out elsewhere, or its place is in «Open questions»: Q-<law letters>-<number> in a law, Q-<number> in a spec'
|
|
352
352
|
: `the binding leads into dead code: \`${symbol}\` is declared in \`${path}\` and met nowhere else — ` +
|
|
353
|
-
'either the statement is carried out elsewhere, or its place is in «Open questions
|
|
353
|
+
'either the statement is carried out elsewhere, or its place is in «Open questions»: Q-<law letters>-<number> in a law, Q-<number> in a spec'
|
|
354
354
|
);
|
|
355
355
|
}
|
|
356
356
|
}
|
|
@@ -364,7 +364,7 @@ function checkTracedAnchors() {
|
|
|
364
364
|
* dependencies line and in the middle of the text, and from a law there was no way to learn
|
|
365
365
|
* which domains stand on it — only by grep.
|
|
366
366
|
*
|
|
367
|
-
* Hence the
|
|
367
|
+
* Hence the `**Laws:**` line in the header and an audit of both sides: a law named in the
|
|
368
368
|
* text but not declared, and a declared law that does not exist.
|
|
369
369
|
*/
|
|
370
370
|
const SPEC_LAWS = /^\*\*(?:Laws|Законы):\*\*\s*(.+)$/;
|
|
@@ -102,12 +102,12 @@ function contractRows(text) {
|
|
|
102
102
|
|
|
103
103
|
function checkContract(file, text, roots) {
|
|
104
104
|
if (roots === null) {
|
|
105
|
-
report(file, 'the header carries no line
|
|
105
|
+
report(file, 'the header carries no line `**Procedures:**` — there is nothing to check the table of «Contract» against the decorators with');
|
|
106
106
|
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
109
109
|
if (roots === UNPARSED) {
|
|
110
|
-
report(file, 'the line
|
|
110
|
+
report(file, 'the line `**Procedures:**` names no root in backticks: the roots are written as paths, and the absence of procedures is said by the word «none». As it stands, the table of «Contract» is checked against nothing');
|
|
111
111
|
|
|
112
112
|
return;
|
|
113
113
|
}
|
|
@@ -118,7 +118,7 @@ function checkContract(file, text, roots) {
|
|
|
118
118
|
for (const row of rows) {
|
|
119
119
|
const found = declared.get(row.short.toLowerCase());
|
|
120
120
|
if (!found) {
|
|
121
|
-
report(file,
|
|
121
|
+
report(file, `«Contract» carries \`${row.name}\`, and there is no procedure with such a method in ${roots.join(', ')}`);
|
|
122
122
|
continue;
|
|
123
123
|
}
|
|
124
124
|
described.add(row.short.toLowerCase());
|
|
@@ -134,7 +134,7 @@ function checkContract(file, text, roots) {
|
|
|
134
134
|
if (!described.has(key)) {
|
|
135
135
|
report(
|
|
136
136
|
file,
|
|
137
|
-
`the procedure \`${found.service}.${found.method}\` (${found.file}) belongs to the domain, ` + 'and the table of
|
|
137
|
+
`the procedure \`${found.service}.${found.method}\` (${found.file}) belongs to the domain, ` + 'and the table of «Contract» does not carry it'
|
|
138
138
|
);
|
|
139
139
|
}
|
|
140
140
|
}
|
|
@@ -175,7 +175,7 @@ function checkRefusalCodes(file, text, roots) {
|
|
|
175
175
|
for (const bullet of bullets) {
|
|
176
176
|
const code = (bullet.text.match(/`([A-Za-z]\w*)`/) || [])[1];
|
|
177
177
|
if (!code) {
|
|
178
|
-
report(file,
|
|
178
|
+
report(file, `«Refusal codes» carries a line without a code in backticks: «${bullet.text.slice(0, 60)}…»`);
|
|
179
179
|
continue;
|
|
180
180
|
}
|
|
181
181
|
if (!thrown.has(code)) {
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* The engine of the task flow: reads the description `flow.js` through the model and answers about
|
|
4
|
+
* the scenario. The description lies next to the engine as `task-flow/flow.js` where the engine is
|
|
5
|
+
* laid out, and as `../task-flow/flow.js` in the package; `--flow <path>` names another one.
|
|
6
|
+
*
|
|
7
|
+
* node task-flow-script.mjs states the states of the scenario in their order, a line each:
|
|
8
|
+
* `<n>. <title> — <action> (<pattern>)`
|
|
9
|
+
* node task-flow-script.mjs measure the measured state of the checked-out branch, its action and
|
|
10
|
+
* the exits read up to it; `--json` prints one object with
|
|
11
|
+
* `state`, `index`, `reason`, `exits`, `action`, `pattern`
|
|
12
|
+
* node task-flow-script.mjs step N.M runs the check of that step of the plan, prints
|
|
13
|
+
* `ожидалось … · получено … · совпало|не совпало` and writes the
|
|
14
|
+
* mark of a matched step; exits 0 on a match, 1 otherwise
|
|
15
|
+
* node task-flow-script.mjs step --done the same for every step the progress marks done
|
|
16
|
+
* node task-flow-script.mjs step --done --pr the rerun before a PR opens: a taken-apart folder
|
|
17
|
+
* comes back from the history for the run, a check that
|
|
18
|
+
* changes a tracked file does not match
|
|
19
|
+
* node task-flow-script.mjs plan-check <plan.md> names every check of the plan in no known
|
|
20
|
+
* form or that is a command of the work; exits 1 on any
|
|
21
|
+
* node task-flow-script.mjs plan-red runs every check of the plan of the branch and writes the
|
|
22
|
+
* approval mark when all are red and the owner approved after
|
|
23
|
+
* both roles; the record of the conversation is named by
|
|
24
|
+
* `RT_FLOW_TRANSCRIPT`
|
|
25
|
+
* node task-flow-script.mjs guard reads the input of a hook before Edit, Write, MultiEdit or a
|
|
26
|
+
* shell command from stdin and prints the reason of a refusal,
|
|
27
|
+
* or nothing — the hook `flow-step-guard.sh` calls it
|
|
28
|
+
*
|
|
29
|
+
* The tree override `.claude/rt-kit/overrides/task-flow/flow.js` is merged with the description
|
|
30
|
+
* key by key when it lies in the tree and no `--flow` is named; `--override <path>` names another
|
|
31
|
+
* one. `measure` prints every key the override removed, with its reason.
|
|
32
|
+
*
|
|
33
|
+
* A description that does not build is named with its reason, and the engine exits 1: a scenario
|
|
34
|
+
* read from a broken description would measure what nobody wrote.
|
|
35
|
+
*/
|
|
36
|
+
import { spawnSync } from 'node:child_process';
|
|
37
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
38
|
+
import { homedir } from 'node:os';
|
|
39
|
+
import { dirname, join } from 'node:path';
|
|
40
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
41
|
+
|
|
42
|
+
import { evaluateCondition } from './flow-condition.mjs';
|
|
43
|
+
import { runForecast } from './flow-forecast.mjs';
|
|
44
|
+
import { judgeCall } from './flow-guard.mjs';
|
|
45
|
+
import { callOf, guardContext } from './flow-guard-run.mjs';
|
|
46
|
+
import { isWriteCommand, saysStop } from './flow-data.mjs';
|
|
47
|
+
import { FlowModelError, buildModel } from './flow-model.mjs';
|
|
48
|
+
import { overridePath, removedLines } from './flow-override.mjs';
|
|
49
|
+
import { planProblems, readRecord, runPlanRed } from './flow-plan.mjs';
|
|
50
|
+
import { runStepCommand } from './flow-step.mjs';
|
|
51
|
+
import { FlowSyntaxError } from './flow-syntax.mjs';
|
|
52
|
+
import { currentStep, holdReason, menuCause, releaseCase } from './flow-verdict.mjs';
|
|
53
|
+
|
|
54
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
55
|
+
|
|
56
|
+
/** Where the description lies: next to the laid-out engine, or in the package. */
|
|
57
|
+
export function flowPath(given) {
|
|
58
|
+
if (given) return given;
|
|
59
|
+
const laid = join(HERE, 'task-flow', 'flow.js');
|
|
60
|
+
return existsSync(laid) ? laid : join(HERE, '..', 'task-flow', 'flow.js');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The lines of `states`. */
|
|
64
|
+
export function stateLines(model) {
|
|
65
|
+
return model.states.map((s, i) => `${i + 1}. ${s.title} — ${s.action ?? ''} (${s.pattern ?? ''})`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** A read the hosting did not answer twice: the error a source throws carries this name. */
|
|
69
|
+
const SILENT = 'HostSilent';
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The measured state: the first state whose exit is known to be unmet. An exit the hosting could not
|
|
73
|
+
* answer is unknown and is passed over, and the exits after it are measured. With no unmet exit and
|
|
74
|
+
* an unknown one, the measured state is the first unknown, and the reason is the silent hosting.
|
|
75
|
+
* With every exit met, the scenario is over.
|
|
76
|
+
*
|
|
77
|
+
* `read(name)` answers a measurer result by its reference and may throw `HostSilent`; a result is
|
|
78
|
+
* read once per measurement. Returns `{ state, index, reason, exits }`, `exits` mapping a state key
|
|
79
|
+
* to `true`, `false` or `'unknown'`.
|
|
80
|
+
*/
|
|
81
|
+
export function measureStates(model, read) {
|
|
82
|
+
const cache = new Map();
|
|
83
|
+
const measured = (name) => {
|
|
84
|
+
if (!cache.has(name)) cache.set(name, read(name));
|
|
85
|
+
return cache.get(name);
|
|
86
|
+
};
|
|
87
|
+
const exits = {};
|
|
88
|
+
let firstUnknown = null;
|
|
89
|
+
for (const [index, state] of model.states.entries()) {
|
|
90
|
+
let met;
|
|
91
|
+
try {
|
|
92
|
+
met = evaluateCondition(state.exit, measured);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
if (error?.name !== SILENT) throw error;
|
|
95
|
+
exits[state.key] = 'unknown';
|
|
96
|
+
firstUnknown ??= index;
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
exits[state.key] = met;
|
|
100
|
+
if (!met) return { state: state.title, index: index + 1, reason: null, exits };
|
|
101
|
+
}
|
|
102
|
+
if (firstUnknown !== null) {
|
|
103
|
+
return { state: model.states[firstUnknown].title, index: firstUnknown + 1, reason: 'the hosting did not answer twice', exits };
|
|
104
|
+
}
|
|
105
|
+
return { state: null, index: model.states.length + 1, reason: 'the end of the scenario', exits };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* The sources of a description by name. Every module is loaded first; a source is opened when it is
|
|
110
|
+
* first asked for, so a source not written yet throws only where it is needed. `given` maps a source
|
|
111
|
+
* name to an opened source and replaces its module.
|
|
112
|
+
*/
|
|
113
|
+
export async function openSources(model, base, given = {}) {
|
|
114
|
+
const modules = {};
|
|
115
|
+
for (const s of model.sources) {
|
|
116
|
+
if (!(s.entry in given)) modules[s.entry] = await import(pathToFileURL(join(base, s.file)).href);
|
|
117
|
+
}
|
|
118
|
+
const opened = { ...given };
|
|
119
|
+
return (name) => {
|
|
120
|
+
if (!(name in opened)) opened[name] = modules[name].open();
|
|
121
|
+
return opened[name];
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* The reader of measurer results over the sources of a description. Every module is loaded first,
|
|
127
|
+
* so the measurement itself stays synchronous.
|
|
128
|
+
*/
|
|
129
|
+
export async function openReaders(model, base, given = {}) {
|
|
130
|
+
const source = await openSources(model, base, given);
|
|
131
|
+
const modules = {};
|
|
132
|
+
for (const m of model.measures) modules[m.entry] = await import(pathToFileURL(join(base, m.file)).href);
|
|
133
|
+
const data = { words: model.words, expect: model.expect, rules: { saysStop, isWriteCommand } };
|
|
134
|
+
const caps = new Map(model.measures.map((m) => [m.entry, m.caps]));
|
|
135
|
+
return (name) => {
|
|
136
|
+
const [, entry, cap] = name.split('.');
|
|
137
|
+
const ports = Object.fromEntries(Object.entries(caps.get(entry)[cap]).map(([port, ref]) => [port, source(ref.path[1])]));
|
|
138
|
+
return modules[entry][cap](ports)(data);
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const MARK = { true: 'met', false: 'unmet', unknown: 'unknown' };
|
|
143
|
+
|
|
144
|
+
/** The lines of `measure`: the measured state, what it waits for and the exits read. */
|
|
145
|
+
export function measureLines(model, result) {
|
|
146
|
+
const total = model.states.length;
|
|
147
|
+
const lines = [];
|
|
148
|
+
if (result.state === null) lines.push(`state: the end of the scenario (${total} of ${total} met)`);
|
|
149
|
+
else {
|
|
150
|
+
const state = model.states[result.index - 1];
|
|
151
|
+
lines.push(`state: ${result.state} (${result.index} of ${total})`);
|
|
152
|
+
lines.push(`next: ${state.action ?? ''} (${state.pattern ?? ''})`);
|
|
153
|
+
if (result.reason) lines.push(`reason: ${result.reason}`);
|
|
154
|
+
}
|
|
155
|
+
for (const [i, s] of model.states.entries()) {
|
|
156
|
+
if (!(s.key in result.exits)) break;
|
|
157
|
+
lines.push(` ${i + 1}. ${s.title}: ${MARK[String(result.exits[s.key])]}`);
|
|
158
|
+
}
|
|
159
|
+
return lines;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** The JSON of `measure --json`: the measured state with its action and pattern. */
|
|
163
|
+
export function measureJson(model, result) {
|
|
164
|
+
const state = result.state === null ? null : model.states[result.index - 1];
|
|
165
|
+
return { ...result, action: state?.action ?? null, pattern: state?.pattern ?? null };
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const USAGE = 'usage: node task-flow-script.mjs states | measure [--json] | step <N.M>|--done [--pr] | plan-check <plan.md> | plan-red | guard | verdict | forecast --days N [--until <date>] [--per-mille] [--guard] [--flow <flow.js>]';
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* What the guard guards: where the task folders and the epic plans lie, the tree override, and the
|
|
172
|
+
* description with its engine — in the package and laid out.
|
|
173
|
+
*/
|
|
174
|
+
export const GUARD_SETTINGS = {
|
|
175
|
+
tasksDir: process.env.RT_FLOW_TASKS_DIR || 'docs/tasks',
|
|
176
|
+
plansDir: process.env.RT_FLOW_PLANS_DIR || 'docs/plans',
|
|
177
|
+
overridePath: '.claude/rt-kit/overrides/task-flow/flow.js',
|
|
178
|
+
protectedPaths: [
|
|
179
|
+
'^projects/agent-kit/assets/task-flow/',
|
|
180
|
+
'^tools/task-flow/',
|
|
181
|
+
'(?:^|/)task-flow-script\\.mjs$',
|
|
182
|
+
'^projects/agent-kit/assets/checks/flow-[\\w-]+\\.mjs$',
|
|
183
|
+
'^tools/flow-[\\w-]+\\.mjs$',
|
|
184
|
+
],
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
/** The verdict of the guard on the hook input from stdin: the reason of a refusal, or null. */
|
|
188
|
+
async function runGuard(model, base) {
|
|
189
|
+
const input = JSON.parse(readFileSync(0, 'utf8') || '{}');
|
|
190
|
+
const root = spawnSync('git', ['rev-parse', '--show-toplevel'], { encoding: 'utf8' }).stdout?.trim();
|
|
191
|
+
if (!root) return null;
|
|
192
|
+
const call = callOf(input, root);
|
|
193
|
+
if (!call) return null;
|
|
194
|
+
if (input.transcript_path) process.env.RT_FLOW_TRANSCRIPT = input.transcript_path;
|
|
195
|
+
const source = await openSources(model, base);
|
|
196
|
+
const readers = await openReaders(model, base);
|
|
197
|
+
const measure = () => measureStates(model, readers).index;
|
|
198
|
+
const ctx = guardContext({ root, model, marks: source('marks'), owner: source('owner'), measure, settings: GUARD_SETTINGS });
|
|
199
|
+
return judgeCall(call, ctx);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* The verdict at the end of a turn on the Stop input from stdin: `{ release: <log> }` or
|
|
204
|
+
* `{ block: <reason> }` as one JSON line.
|
|
205
|
+
*/
|
|
206
|
+
async function runVerdict(model, base) {
|
|
207
|
+
const input = JSON.parse(readFileSync(0, 'utf8') || '{}');
|
|
208
|
+
if (input.transcript_path) process.env.RT_FLOW_TRANSCRIPT = input.transcript_path;
|
|
209
|
+
if (input.agent_type) process.env.RT_FLOW_AGENT = input.agent_type;
|
|
210
|
+
const read = await openReaders(model, base);
|
|
211
|
+
const cache = new Map();
|
|
212
|
+
const measured = (name) => {
|
|
213
|
+
if (!cache.has(name)) cache.set(name, read(name));
|
|
214
|
+
return cache.get(name);
|
|
215
|
+
};
|
|
216
|
+
const result = measureStates(model, measured);
|
|
217
|
+
const released = releaseCase(model, measured, result);
|
|
218
|
+
if (released) return { release: released.log ?? released.key };
|
|
219
|
+
const root = spawnSync('git', ['rev-parse', '--show-toplevel'], { encoding: 'utf8' }).stdout?.trim();
|
|
220
|
+
const branch = spawnSync('git', ['rev-parse', '--abbrev-ref', 'HEAD'], { encoding: 'utf8' }).stdout?.trim();
|
|
221
|
+
const progress = join(root ?? '.', GUARD_SETTINGS.tasksDir, branch ?? '', 'progress.md');
|
|
222
|
+
const step = currentStep(existsSync(progress) ? readFileSync(progress, 'utf8') : null);
|
|
223
|
+
const task = branch?.match(/^[A-Z]+-(\d+)-/)?.[1] ?? null;
|
|
224
|
+
return { block: holdReason(model, result, step, { cause: menuCause(measured), task }) };
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const COMMANDS = ['states', 'measure', 'step', 'plan-check', 'plan-red', 'guard', 'verdict', 'forecast'];
|
|
228
|
+
/** The commands the hooks call: they judge by the package description when the override breaks. */
|
|
229
|
+
const HOOK_COMMANDS = ['guard', 'verdict'];
|
|
230
|
+
|
|
231
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
232
|
+
const args = process.argv.slice(2);
|
|
233
|
+
const at = args.indexOf('--flow');
|
|
234
|
+
const given = at >= 0 ? args.splice(at, 2)[1] : undefined;
|
|
235
|
+
const atOverride = args.indexOf('--override');
|
|
236
|
+
const overrideGiven = atOverride >= 0 ? args.splice(atOverride, 2)[1] : undefined;
|
|
237
|
+
const json = args.includes('--json');
|
|
238
|
+
const [command, target] = args.filter((a) => a !== '--json');
|
|
239
|
+
if (!COMMANDS.includes(command) || ((command === 'step' || command === 'plan-check') && !target)) {
|
|
240
|
+
console.error(USAGE);
|
|
241
|
+
process.exit(2);
|
|
242
|
+
}
|
|
243
|
+
try {
|
|
244
|
+
const path = flowPath(given);
|
|
245
|
+
const override = overridePath(overrideGiven, given);
|
|
246
|
+
let model;
|
|
247
|
+
try {
|
|
248
|
+
model = buildModel(path, { override });
|
|
249
|
+
} catch (error) {
|
|
250
|
+
// A broken override does not lift the hooks: the guard protects the override itself, and
|
|
251
|
+
// the exit check must not release a turn because a tree file does not build.
|
|
252
|
+
if (!override || !HOOK_COMMANDS.includes(command)) throw error;
|
|
253
|
+
console.error(`task-flow-script: the override does not build, the hook judges by the package description — ${error.message}`);
|
|
254
|
+
model = buildModel(path);
|
|
255
|
+
}
|
|
256
|
+
if (command === 'states') console.log(stateLines(model).join('\n'));
|
|
257
|
+
else if (command === 'step') {
|
|
258
|
+
const source = await openSources(model, dirname(path));
|
|
259
|
+
const sources = { git: source('git'), steps: source('steps'), marks: source('marks'), owner: source('owner') };
|
|
260
|
+
process.exit(await runStepCommand(sources, model, target, process.argv.includes('--pr') ? '--pr' : ''));
|
|
261
|
+
} else if (command === 'plan-check') {
|
|
262
|
+
const source = await openSources(model, dirname(path));
|
|
263
|
+
const problems = planProblems(readFileSync(target, 'utf8'), source('steps'), model);
|
|
264
|
+
for (const problem of problems) console.log(`plan-check: ${problem}`);
|
|
265
|
+
process.exit(problems.length > 0 ? 1 : 0);
|
|
266
|
+
} else if (command === 'verdict') {
|
|
267
|
+
console.log(JSON.stringify(await runVerdict(model, dirname(path))));
|
|
268
|
+
} else if (command === 'guard') {
|
|
269
|
+
console.log((await runGuard(model, dirname(path))) ?? '');
|
|
270
|
+
} else if (command === 'forecast') {
|
|
271
|
+
const tree = dirname(spawnSync('git', ['rev-parse', '--path-format=absolute', '--git-common-dir'], { encoding: 'utf8' }).stdout.trim());
|
|
272
|
+
const root = process.env.RT_FLOW_RECORDS || join(homedir(), '.claude', 'projects');
|
|
273
|
+
const argv = process.argv.slice(3).filter((arg, index, all) => arg !== '--flow' && all[index - 1] !== '--flow');
|
|
274
|
+
console.log(await runForecast({ argv, model, base: dirname(path), openReaders, tree, root, settings: GUARD_SETTINGS }));
|
|
275
|
+
} else if (command === 'plan-red') {
|
|
276
|
+
const source = await openSources(model, dirname(path));
|
|
277
|
+
const sources = { git: source('git'), steps: source('steps'), marks: source('marks') };
|
|
278
|
+
process.exit(runPlanRed(sources, model, readRecord(process.env.RT_FLOW_TRANSCRIPT)));
|
|
279
|
+
} else {
|
|
280
|
+
const result = measureStates(model, await openReaders(model, dirname(path)));
|
|
281
|
+
console.log(json ? JSON.stringify(measureJson(model, result)) : [...measureLines(model, result), ...removedLines(model)].join('\n'));
|
|
282
|
+
}
|
|
283
|
+
} catch (error) {
|
|
284
|
+
if (error instanceof FlowSyntaxError) {
|
|
285
|
+
console.log(`flow syntax: ${error.message}`);
|
|
286
|
+
process.exit(1);
|
|
287
|
+
}
|
|
288
|
+
if (!(error instanceof FlowModelError)) throw error;
|
|
289
|
+
console.log(`flow model: ${error.message}`);
|
|
290
|
+
process.exit(1);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
@@ -99,32 +99,40 @@ const OWNER_WORD =
|
|
|
99
99
|
* A tree that declares no assignments is not judged: it has nothing to divide.
|
|
100
100
|
*/
|
|
101
101
|
export function assignmentFault(epic, root = ROOT) {
|
|
102
|
+
return assignmentUnmet(epic, root).text;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The same answer with its kind, as the decision table names the fact `copy_assignment`: `ok`,
|
|
107
|
+
* `unnamed`, `no_row`, `dash` or `foreign`.
|
|
108
|
+
*/
|
|
109
|
+
export function assignmentUnmet(epic, root = ROOT) {
|
|
102
110
|
if (!CONFIG.assignmentsFile) {
|
|
103
|
-
return '';
|
|
111
|
+
return { kind: 'ok', text: '' };
|
|
104
112
|
}
|
|
105
113
|
|
|
106
114
|
const key = CONFIG.board?.taskKey ?? '';
|
|
107
115
|
const name = treeName(root);
|
|
108
116
|
|
|
109
117
|
if (name === null) {
|
|
110
|
-
return `this working copy names itself in no way — write its short name into ${CONFIG.treeNameFile}, and the assignment table will find its row
|
|
118
|
+
return { kind: 'unnamed', text: `this working copy names itself in no way — write its short name into ${CONFIG.treeNameFile}, and the assignment table will find its row` };
|
|
111
119
|
}
|
|
112
120
|
|
|
113
121
|
const row = assignmentOf(root);
|
|
114
122
|
|
|
115
123
|
if (row === null) {
|
|
116
|
-
return `the table ${CONFIG.assignmentsFile} holds no row for the copy «${name}». Ask the owner what this copy leads; work is not taken by guesswork. ${OWNER_WORD}
|
|
124
|
+
return { kind: 'no_row', text: `the table ${CONFIG.assignmentsFile} holds no row for the copy «${name}». Ask the owner what this copy leads; work is not taken by guesswork. ${OWNER_WORD}` };
|
|
117
125
|
}
|
|
118
126
|
|
|
119
127
|
if (row.epic === null) {
|
|
120
|
-
return `no epic is assigned to the copy «${name}» — the row in ${CONFIG.assignmentsFile} holds a dash. Ask the owner what to take; an epic chosen by oneself is not an order. ${OWNER_WORD}
|
|
128
|
+
return { kind: 'dash', text: `no epic is assigned to the copy «${name}» — the row in ${CONFIG.assignmentsFile} holds a dash. Ask the owner what to take; an epic chosen by oneself is not an order. ${OWNER_WORD}` };
|
|
121
129
|
}
|
|
122
130
|
|
|
123
131
|
if (epic !== null && epic !== undefined && String(epic) !== '' && Number(epic) !== row.epic) {
|
|
124
|
-
return `the copy «${name}» leads the epic ${key}-${row.epic}, and this work belongs to ${key}-${epic}. Someone else's epic is not taken by one's own decision: the owner moves the assignment. ${OWNER_WORD}
|
|
132
|
+
return { kind: 'foreign', text: `the copy «${name}» leads the epic ${key}-${row.epic}, and this work belongs to ${key}-${epic}. Someone else's epic is not taken by one's own decision: the owner moves the assignment. ${OWNER_WORD}` };
|
|
125
133
|
}
|
|
126
134
|
|
|
127
|
-
return '';
|
|
135
|
+
return { kind: 'ok', text: '' };
|
|
128
136
|
}
|
|
129
137
|
|
|
130
138
|
/**
|
|
@@ -141,7 +149,18 @@ if (process.argv[1] && import.meta.url === new URL(`file://${process.argv[1]}`).
|
|
|
141
149
|
// given, the queue says whether it is still alive.
|
|
142
150
|
const row = assignmentOf();
|
|
143
151
|
|
|
144
|
-
console.log
|
|
152
|
+
// Printed as a string: `console.log` colours a number when FORCE_COLOR is set — the task
|
|
153
|
+
// runner sets it — and the caller then reads escape codes in place of the number.
|
|
154
|
+
console.log(String(row?.epic ?? ''));
|
|
155
|
+
process.exit(0);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const unmet = process.argv.indexOf('--unmet');
|
|
159
|
+
|
|
160
|
+
if (unmet !== -1) {
|
|
161
|
+
// The kind and the text as one line of JSON, for a guard that hands the kind to the decision
|
|
162
|
+
// table as a fact and the text to the refusal.
|
|
163
|
+
console.log(JSON.stringify(assignmentUnmet(process.argv[unmet + 1] ?? '')));
|
|
145
164
|
process.exit(0);
|
|
146
165
|
}
|
|
147
166
|
|