@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
|
@@ -5,122 +5,36 @@ description: Creating a new skill — one with no law above it — a showcase, a
|
|
|
5
5
|
|
|
6
6
|
# How a skill is created
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
short, it declares when to load it, and it does not retell what is already written in the
|
|
10
|
-
neighbouring one.
|
|
8
|
+
Cold part: `pitfalls.md` — the whole text with samples and reasons.
|
|
11
9
|
|
|
12
10
|
## When to use
|
|
13
11
|
|
|
14
|
-
- A skill with no law above it is
|
|
15
|
-
|
|
16
|
-
- A skill has grown, and it is time to split it.
|
|
17
|
-
- The skill exists, but nobody loads it — the declaration needs fixing.
|
|
18
|
-
|
|
19
|
-
**A rule and a pattern do not go here.** A rule stands under a law, a pattern next to a rule,
|
|
20
|
-
and the shape of both is held by the pattern `spec-driven-rule`. A skill without a law is the
|
|
21
|
-
third case, and only it is here.
|
|
12
|
+
- A skill with no law above it is created, has grown, or is not loaded. A rule and a pattern —
|
|
13
|
+
pattern `spec-driven-rule`.
|
|
22
14
|
|
|
23
15
|
## Order
|
|
24
16
|
|
|
25
|
-
1.
|
|
26
|
-
|
|
27
|
-
without this retells the tool's documentation — and the agent knows that anyway.
|
|
28
|
-
2. **Write a draft.** One file. Additional ones — only when the first stops being readable in
|
|
29
|
-
full.
|
|
30
|
-
3. **Show the owner.** A skill acts on all future sessions, and creating it silently is not
|
|
31
|
-
allowed.
|
|
32
|
-
|
|
33
|
-
## When the owner hands over the text
|
|
34
|
-
|
|
35
|
-
A text the owner wrote is carried, not rewritten. Before the first split it lands whole in the
|
|
36
|
-
task folder: a request cut with `[…]` leaves nothing to compare against. Headings keep their case
|
|
37
|
-
and wording, sentences their words, code samples stay whole. What the shape of a skill forces —
|
|
38
|
-
the declaration, "When to use", a link in place of "above" — goes into a list of deviations, one
|
|
39
|
-
line each. Before the first commit a script compares every heading and paragraph of the source
|
|
40
|
-
with the skill files and prints what is missing or changed. A size limit the text does not fit
|
|
41
|
-
splits the text into files, never shortens it.
|
|
42
|
-
|
|
43
|
-
## What is in the file
|
|
44
|
-
|
|
45
|
-
```
|
|
46
|
-
<skill-name>/
|
|
47
|
-
├── SKILL.md # mandatory, and usually the only one
|
|
48
|
-
├── <SOMETHING>.md # a separate file — when SKILL.md stopped being readable in full
|
|
49
|
-
└── scripts/ # ready-made scripts, if the operation is deterministic
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
The preamble between `---` is `name` and `description`, then the title and the sections. The
|
|
53
|
-
first section is "When to use": the agent decides by it, not by the title.
|
|
54
|
-
|
|
55
|
-
## The declaration decides everything
|
|
56
|
-
|
|
57
|
-
`description` is **the only thing the agent sees** when it decides whether to load the skill or
|
|
58
|
-
not. It stands in the system prompt next to the descriptions of all the others, and the choice
|
|
59
|
-
goes by them.
|
|
60
|
-
|
|
61
|
-
It answers two questions: what the skill gives and when to load it. Write in the third person,
|
|
62
|
-
up to three hundred characters: the first sentence — what it does, the second — "Load when…", the
|
|
63
|
-
third — what is not in it and where to look for that. Where the tree has the descriptions check
|
|
64
|
-
laid out, it refuses a longer declaration.
|
|
65
|
-
|
|
66
|
-
```
|
|
67
|
-
✓ Creating a new skill — one with no law above it. Load when asked to create, write or
|
|
68
|
-
rewrite a skill. The shape of a rule and a pattern is not here — that is pattern
|
|
69
|
-
spec-driven-rule.
|
|
17
|
+
1. Ask what is missing. 2. Write one file. 3. Show the owner. An owner's text is carried, not
|
|
18
|
+
rewritten: it lands whole in the task folder, deviations are listed, a script compares it.
|
|
70
19
|
|
|
71
|
-
|
|
72
|
-
```
|
|
20
|
+
## The file
|
|
73
21
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
## Ready-made commands instead of a description
|
|
81
|
-
|
|
82
|
-
A script is put next to the skill when the operation is deterministic — a check, bringing to a
|
|
83
|
-
form, parsing output. Such a thing is cheaper to call than to generate anew, and an error in it
|
|
84
|
-
is seen once, not in every generation.
|
|
85
|
-
|
|
86
|
-
An order of actions that depends on what was found does not become a script: it stays text.
|
|
87
|
-
|
|
88
|
-
## When to split
|
|
89
|
-
|
|
90
|
-
Split when:
|
|
91
|
-
|
|
92
|
-
- the file stopped being readable in full — by experience, that is around a hundred lines;
|
|
93
|
-
- it holds two different subjects, and the second is needed once a month;
|
|
94
|
-
- ready-made code took more room than the explanation of what it is for.
|
|
95
|
-
|
|
96
|
-
Do not split for beauty: two files instead of one cost one extra hop at every reading, and a
|
|
97
|
-
link deeper than one level is not followed at all.
|
|
22
|
+
- **`name` and `description`, then "When to use" first.**
|
|
23
|
+
- **`description` is all the agent sees:** what it gives, "Load when…", which neighbour not to
|
|
24
|
+
load — third person, up to 300 characters.
|
|
25
|
+
- **A deterministic operation becomes a script next to it.**
|
|
26
|
+
- **Split when not readable in full (about a hundred lines); links go one level deep.**
|
|
27
|
+
- **It is named in the gate map or called by another skill or role.**
|
|
98
28
|
|
|
99
29
|
## How a skill does harm
|
|
100
30
|
|
|
101
|
-
- **Retelling the tool's documentation.**
|
|
102
|
-
|
|
103
|
-
- **
|
|
104
|
-
|
|
105
|
-
- **What goes stale together with the code.** A skill naming a version, a number or a file name
|
|
106
|
-
that is edited more often than once a quarter lies silently.
|
|
107
|
-
- **Length.** A skill of three screens stops being read in full and is read up to the first
|
|
108
|
-
familiar section.
|
|
109
|
-
|
|
110
|
-
## Before handing it over
|
|
111
|
-
|
|
112
|
-
- [ ] the declaration has "Load when…" and names the neighbour not to load;
|
|
113
|
-
- [ ] the first section is "When to use";
|
|
114
|
-
- [ ] the file is readable in full in one sitting;
|
|
115
|
-
- [ ] not one line repeats the neighbouring skill;
|
|
116
|
-
- [ ] nothing that goes stale by itself: versions, numbers, dates;
|
|
117
|
-
- [ ] at least one ready-made sample, not only an explanation;
|
|
118
|
-
- [ ] links go one level deep, no deeper;
|
|
119
|
-
- [ ] where the tree has the descriptions check laid out, it is green before the first commit,
|
|
120
|
-
not only before the push.
|
|
31
|
+
- **Retelling the tool's documentation.**
|
|
32
|
+
- **Duplicating a neighbour.**
|
|
33
|
+
- **What goes stale together with the code.**
|
|
34
|
+
- **Length.**
|
|
121
35
|
|
|
122
|
-
##
|
|
36
|
+
## Names and techniques
|
|
123
37
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
38
|
+
- An owner's text over a size limit is split into files, never shortened.
|
|
39
|
+
- A skill has at least one ready-made sample, not only an explanation.
|
|
40
|
+
- The descriptions check is green before the first commit, not only before push.
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
// The task flow as an executable scenario: the data language of `flow-syntax.mjs`, nothing here runs.
|
|
2
|
+
// A state is left when its exit is measured; the first state whose exit is unmet is where the work
|
|
3
|
+
// stands. A release case says when a turn may end before the scenario does. A new fact is a new
|
|
4
|
+
// measurer in `measure/`; a new combination of facts is a line here.
|
|
5
|
+
({
|
|
6
|
+
source: {
|
|
7
|
+
git: { open: {} },
|
|
8
|
+
tree: { open: {} },
|
|
9
|
+
host: { open: {} },
|
|
10
|
+
marks: { open: {} },
|
|
11
|
+
owner: { open: {} },
|
|
12
|
+
session: { open: {} },
|
|
13
|
+
steps: { open: {} },
|
|
14
|
+
records: { open: {} },
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
measure: {
|
|
18
|
+
grill: { written: { git: source.git, tree: source.tree } },
|
|
19
|
+
epic: {
|
|
20
|
+
declared: { git: source.git, host: source.host, tree: source.tree },
|
|
21
|
+
nextTaken: { git: source.git, host: source.host, tree: source.tree },
|
|
22
|
+
mergedMarked: { git: source.git, host: source.host, tree: source.tree },
|
|
23
|
+
finished: { git: source.git, host: source.host, tree: source.tree },
|
|
24
|
+
},
|
|
25
|
+
agreement: { named: { git: source.git, tree: source.tree } },
|
|
26
|
+
task: { taken: { git: source.git, host: source.host } },
|
|
27
|
+
plan: { approved: { git: source.git, marks: source.marks, steps: source.steps, records: source.records } },
|
|
28
|
+
progress: {
|
|
29
|
+
mirrors: { git: source.git, steps: source.steps },
|
|
30
|
+
done: { git: source.git, tree: source.tree, marks: source.marks, steps: source.steps },
|
|
31
|
+
},
|
|
32
|
+
footprint: { touched: { git: source.git } },
|
|
33
|
+
folder: { archived: { git: source.git } },
|
|
34
|
+
pr: { handed: { git: source.git, host: source.host } },
|
|
35
|
+
copy: {
|
|
36
|
+
outsideEpic: { git: source.git, host: source.host, tree: source.tree },
|
|
37
|
+
outOfScenario: { git: source.git, host: source.host, tree: source.tree },
|
|
38
|
+
},
|
|
39
|
+
owner: { interrupted: { owner: source.owner }, nudged: { owner: source.owner } },
|
|
40
|
+
session: {
|
|
41
|
+
wrote: { session: source.session },
|
|
42
|
+
role: { session: source.session },
|
|
43
|
+
menuLost: { session: source.session },
|
|
44
|
+
forbidden: { session: source.session },
|
|
45
|
+
idle: { session: source.session, tree: source.tree },
|
|
46
|
+
unread: { session: source.session },
|
|
47
|
+
waiting: { session: source.session, tree: source.tree },
|
|
48
|
+
hung: { session: source.session, tree: source.tree },
|
|
49
|
+
},
|
|
50
|
+
host: { silent: { host: source.host } },
|
|
51
|
+
// Read by the verdict before the release cases: a CI run nobody watches or a red run nobody read
|
|
52
|
+
// holds the stop, the end of the scenario included.
|
|
53
|
+
ci: { hold: { git: source.git, host: source.host, tree: source.tree, session: source.session, owner: source.owner } },
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
state: {
|
|
57
|
+
request: {
|
|
58
|
+
title: 'просьба-не-разобрана',
|
|
59
|
+
action: 'explore the tree, then ask the questions',
|
|
60
|
+
pattern: 'task-flow-start',
|
|
61
|
+
exit: measure.grill.written,
|
|
62
|
+
},
|
|
63
|
+
epic: {
|
|
64
|
+
title: 'эпик-заведён',
|
|
65
|
+
action: 'take the epic branch from the main branch; the epic card moves with the first task',
|
|
66
|
+
pattern: 'epic-flow-declare',
|
|
67
|
+
exit: measure.epic.declared,
|
|
68
|
+
},
|
|
69
|
+
grill: {
|
|
70
|
+
title: 'разбор-закрыт',
|
|
71
|
+
action: 'write the product agreement, or the reason there is none',
|
|
72
|
+
pattern: 'task-flow-start',
|
|
73
|
+
exit: measure.agreement.named,
|
|
74
|
+
},
|
|
75
|
+
agreement: {
|
|
76
|
+
title: 'договорённость-записана',
|
|
77
|
+
action: 'create the task, the branch from the epic branch, and the folder',
|
|
78
|
+
pattern: 'task-flow-start',
|
|
79
|
+
exit: measure.task.taken,
|
|
80
|
+
},
|
|
81
|
+
taken: {
|
|
82
|
+
title: 'задача-взята',
|
|
83
|
+
action: 'write the plan',
|
|
84
|
+
pattern: 'task-flow-start',
|
|
85
|
+
exit: measure.plan.approved,
|
|
86
|
+
},
|
|
87
|
+
planned: {
|
|
88
|
+
title: 'замысел-записан',
|
|
89
|
+
action: 'do the first stage',
|
|
90
|
+
pattern: 'task-flow-start',
|
|
91
|
+
exit: measure.progress.mirrors,
|
|
92
|
+
},
|
|
93
|
+
stage: {
|
|
94
|
+
title: 'этап-идёт',
|
|
95
|
+
action: 'finish the stage: `step N.M` measures each step and marks it done',
|
|
96
|
+
pattern: 'task-flow-resume',
|
|
97
|
+
exit: measure.progress.done,
|
|
98
|
+
},
|
|
99
|
+
stagesOver: {
|
|
100
|
+
title: 'этапы-кончились',
|
|
101
|
+
action: 'merge the agreement, bring the texts up to date, run the suite',
|
|
102
|
+
pattern: 'task-flow-close',
|
|
103
|
+
exit: measure.footprint.touched,
|
|
104
|
+
},
|
|
105
|
+
reviewOver: {
|
|
106
|
+
title: 'разбор-кончился',
|
|
107
|
+
action: 'take the folder apart by the last commit',
|
|
108
|
+
pattern: 'task-flow-archive',
|
|
109
|
+
exit: measure.folder.archived,
|
|
110
|
+
},
|
|
111
|
+
folderGone: {
|
|
112
|
+
title: 'папка-разобрана',
|
|
113
|
+
action: 'the work queue audit, then open the PR',
|
|
114
|
+
pattern: 'task-flow-close',
|
|
115
|
+
exit: measure.pr.handed,
|
|
116
|
+
},
|
|
117
|
+
handed: {
|
|
118
|
+
title: 'работа-отдана',
|
|
119
|
+
action: 'send the rules review to the background, then take the next task of the epic',
|
|
120
|
+
pattern: 'task-flow-archive',
|
|
121
|
+
exit: measure.epic.nextTaken,
|
|
122
|
+
},
|
|
123
|
+
merged: {
|
|
124
|
+
title: 'влито',
|
|
125
|
+
action: 'merge the PRs of the chain bottom-up, mark the merged tasks by the branch of the next one',
|
|
126
|
+
pattern: 'task-flow-resume',
|
|
127
|
+
exit: measure.epic.mergedMarked,
|
|
128
|
+
},
|
|
129
|
+
epicOver: {
|
|
130
|
+
title: 'задачи-эпика-кончились',
|
|
131
|
+
action: 'open the PR of the epic into the main branch',
|
|
132
|
+
pattern: 'task-flow-close',
|
|
133
|
+
exit: measure.epic.finished,
|
|
134
|
+
end: true,
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
|
|
138
|
+
release: {
|
|
139
|
+
scenarioEnd: {
|
|
140
|
+
when: { any: [measure.epic.finished, { all: [measure.copy.outsideEpic, measure.pr.handed] }] },
|
|
141
|
+
order: 1,
|
|
142
|
+
log: 'the end of the scenario',
|
|
143
|
+
},
|
|
144
|
+
// No typed word stops the work; Esc does, and the turns a notice wakes after it are released.
|
|
145
|
+
interrupted: { when: measure.owner.interrupted, order: 2, log: 'the owner interrupted the turn' },
|
|
146
|
+
// The state «работа-отдана» sends work to the background by its own action and goes on: there
|
|
147
|
+
// the wait releases nothing.
|
|
148
|
+
background: {
|
|
149
|
+
when: { all: [measure.session.waiting, { not: measure.pr.handed }] },
|
|
150
|
+
order: 3,
|
|
151
|
+
log: 'a background task of the session runs',
|
|
152
|
+
},
|
|
153
|
+
noWrite: {
|
|
154
|
+
when: {
|
|
155
|
+
any: [
|
|
156
|
+
measure.copy.outOfScenario,
|
|
157
|
+
{ all: [{ not: measure.session.wrote }, { not: measure.owner.nudged }] },
|
|
158
|
+
],
|
|
159
|
+
},
|
|
160
|
+
order: 4,
|
|
161
|
+
log: 'no write to the tree, or a branch outside the scenario',
|
|
162
|
+
},
|
|
163
|
+
role: { when: measure.session.role, order: 5, log: 'a role session' },
|
|
164
|
+
hostSilent: { when: measure.host.silent, order: 6, log: 'the host did not answer twice' },
|
|
165
|
+
menuLost: { when: measure.session.menuLost, order: 8, log: 'the menu did not reach the owner' },
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
words: {
|
|
169
|
+
nudge: '(?<![\\p{L}])(?<!не )(продолжай|доделывай|работай|делай дальше|работаешь)(?![\\p{L}])|почему (ты )?(стоишь|встал|остановил)|что дальше|дальше\\?|^(ну )?(и )?что там|^ну и\\s*[?!.]|какого .*останов',
|
|
170
|
+
write: [
|
|
171
|
+
'git commit', 'git push', 'git add', 'git merge', 'git rm', 'git mv', 'sed -i', 'perl -pi', 'gh pr', 'npm run task:new', 'pnpm run task:new', 'npm run task:move',
|
|
172
|
+
'pnpm run task:move', 'npm run agent-kit:sync', 'pnpm run agent-kit:sync',
|
|
173
|
+
],
|
|
174
|
+
menu: ['отложить RT-N', 'подскажу путь'],
|
|
175
|
+
legacyBranches: ['RT-3276-conversation-checks', 'RT-3329-task-flow-scenario'],
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
expect: {
|
|
179
|
+
exit: { pattern: '^exit (\\d+)$', compare: 'exit' },
|
|
180
|
+
line: { pattern: '^`(.*)`$', compare: 'line' },
|
|
181
|
+
regex: { pattern: '^/(.*)/$', compare: 'regex' },
|
|
182
|
+
number: { pattern: '^(=|>=|<=) ?(-?\\d+)$', compare: 'number' },
|
|
183
|
+
},
|
|
184
|
+
});
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# The task flow
|
|
2
|
+
|
|
3
|
+
Generated by `flow-sync.mjs` from `flow.js` next to it. `flow-sync.mjs --check` refuses a hand edit:
|
|
4
|
+
the description is edited, and the generator is run.
|
|
5
|
+
|
|
6
|
+
<!-- flow:description -->
|
|
7
|
+
## States
|
|
8
|
+
|
|
9
|
+
| State | Exit | Mandatory action | Pattern |
|
|
10
|
+
| --- | --- | --- | --- |
|
|
11
|
+
| `просьба-не-разобрана` | `measure.grill.written` | explore the tree, then ask the questions | `task-flow-start` |
|
|
12
|
+
| `эпик-заведён` | `measure.epic.declared` | take the epic branch from the main branch; the epic card moves with the first task | `epic-flow-declare` |
|
|
13
|
+
| `разбор-закрыт` | `measure.agreement.named` | write the product agreement, or the reason there is none | `task-flow-start` |
|
|
14
|
+
| `договорённость-записана` | `measure.task.taken` | create the task, the branch from the epic branch, and the folder | `task-flow-start` |
|
|
15
|
+
| `задача-взята` | `measure.plan.approved` | write the plan | `task-flow-start` |
|
|
16
|
+
| `замысел-записан` | `measure.progress.mirrors` | do the first stage | `task-flow-start` |
|
|
17
|
+
| `этап-идёт` | `measure.progress.done` | finish the stage: `step N.M` measures each step and marks it done | `task-flow-resume` |
|
|
18
|
+
| `этапы-кончились` | `measure.footprint.touched` | merge the agreement, bring the texts up to date, run the suite | `task-flow-close` |
|
|
19
|
+
| `разбор-кончился` | `measure.folder.archived` | take the folder apart by the last commit | `task-flow-archive` |
|
|
20
|
+
| `папка-разобрана` | `measure.pr.handed` | the work queue audit, then open the PR | `task-flow-close` |
|
|
21
|
+
| `работа-отдана` | `measure.epic.nextTaken` | send the rules review to the background, then take the next task of the epic | `task-flow-archive` |
|
|
22
|
+
| `влито` | `measure.epic.mergedMarked` | merge the PRs of the chain bottom-up, mark the merged tasks by the branch of the next one | `task-flow-resume` |
|
|
23
|
+
| `задачи-эпика-кончились` | `measure.epic.finished` | open the PR of the epic into the main branch | `task-flow-close` |
|
|
24
|
+
|
|
25
|
+
## Release cases
|
|
26
|
+
|
|
27
|
+
The engine asks the cases in this order, and a met case lets the turn end before the scenario does.
|
|
28
|
+
|
|
29
|
+
| Order | Case | When | Log |
|
|
30
|
+
| --- | --- | --- | --- |
|
|
31
|
+
| 1 | `scenarioEnd` | `any(measure.epic.finished, all(measure.copy.outsideEpic, measure.pr.handed))` | the end of the scenario |
|
|
32
|
+
| 2 | `interrupted` | `measure.owner.interrupted` | the owner interrupted the turn |
|
|
33
|
+
| 3 | `background` | `all(measure.session.waiting, not(measure.pr.handed))` | a background task of the session runs |
|
|
34
|
+
| 4 | `noWrite` | `any(measure.copy.outOfScenario, all(not(measure.session.wrote), not(measure.owner.nudged)))` | no write to the tree, or a branch outside the scenario |
|
|
35
|
+
| 5 | `role` | `measure.session.role` | a role session |
|
|
36
|
+
| 6 | `hostSilent` | `measure.host.silent` | the host did not answer twice |
|
|
37
|
+
| 8 | `menuLost` | `measure.session.menuLost` | the menu did not reach the owner |
|
|
38
|
+
|
|
39
|
+
## Measurers
|
|
40
|
+
|
|
41
|
+
| Measurer | Ports |
|
|
42
|
+
| --- | --- |
|
|
43
|
+
| `measure.grill.written` | `source.git`, `source.tree` |
|
|
44
|
+
| `measure.epic.declared` | `source.git`, `source.host`, `source.tree` |
|
|
45
|
+
| `measure.epic.nextTaken` | `source.git`, `source.host`, `source.tree` |
|
|
46
|
+
| `measure.epic.mergedMarked` | `source.git`, `source.host`, `source.tree` |
|
|
47
|
+
| `measure.epic.finished` | `source.git`, `source.host`, `source.tree` |
|
|
48
|
+
| `measure.agreement.named` | `source.git`, `source.tree` |
|
|
49
|
+
| `measure.task.taken` | `source.git`, `source.host` |
|
|
50
|
+
| `measure.plan.approved` | `source.git`, `source.marks`, `source.steps`, `source.records` |
|
|
51
|
+
| `measure.progress.mirrors` | `source.git`, `source.steps` |
|
|
52
|
+
| `measure.progress.done` | `source.git`, `source.tree`, `source.marks`, `source.steps` |
|
|
53
|
+
| `measure.footprint.touched` | `source.git` |
|
|
54
|
+
| `measure.folder.archived` | `source.git` |
|
|
55
|
+
| `measure.pr.handed` | `source.git`, `source.host` |
|
|
56
|
+
| `measure.copy.outsideEpic` | `source.git`, `source.host`, `source.tree` |
|
|
57
|
+
| `measure.copy.outOfScenario` | `source.git`, `source.host`, `source.tree` |
|
|
58
|
+
| `measure.owner.interrupted` | `source.owner` |
|
|
59
|
+
| `measure.owner.nudged` | `source.owner` |
|
|
60
|
+
| `measure.session.wrote` | `source.session` |
|
|
61
|
+
| `measure.session.role` | `source.session` |
|
|
62
|
+
| `measure.session.menuLost` | `source.session` |
|
|
63
|
+
| `measure.session.forbidden` | `source.session` |
|
|
64
|
+
| `measure.session.idle` | `source.session`, `source.tree` |
|
|
65
|
+
| `measure.session.unread` | `source.session` |
|
|
66
|
+
| `measure.session.waiting` | `source.session`, `source.tree` |
|
|
67
|
+
| `measure.session.hung` | `source.session`, `source.tree` |
|
|
68
|
+
| `measure.host.silent` | `source.host` |
|
|
69
|
+
| `measure.ci.hold` | `source.git`, `source.host`, `source.tree`, `source.session`, `source.owner` |
|
|
70
|
+
|
|
71
|
+
## Sources
|
|
72
|
+
|
|
73
|
+
| Source | Ports |
|
|
74
|
+
| --- | --- |
|
|
75
|
+
| `source.git.open` | none |
|
|
76
|
+
| `source.tree.open` | none |
|
|
77
|
+
| `source.host.open` | none |
|
|
78
|
+
| `source.marks.open` | none |
|
|
79
|
+
| `source.owner.open` | none |
|
|
80
|
+
| `source.session.open` | none |
|
|
81
|
+
| `source.steps.open` | none |
|
|
82
|
+
| `source.records.open` | none |
|
|
83
|
+
|
|
84
|
+
## Words
|
|
85
|
+
|
|
86
|
+
| Key | Words |
|
|
87
|
+
| --- | --- |
|
|
88
|
+
| `nudge` | `(?<![\p{L}])(?<!не )(продолжай\|доделывай\|работай\|делай дальше\|работаешь)(?![\p{L}])\|почему (ты )?(стоишь\|встал\|остановил)\|что дальше\|дальше\?\|^(ну )?(и )?что там\|^ну и\s*[?!.]\|какого .*останов` |
|
|
89
|
+
| `write` | git commit, git push, git add, git merge, git rm, git mv, sed -i, perl -pi, gh pr, npm run task:new, pnpm run task:new, npm run task:move, pnpm run task:move, npm run agent-kit:sync, pnpm run agent-kit:sync |
|
|
90
|
+
| `menu` | отложить RT-N, подскажу путь |
|
|
91
|
+
| `legacyBranches` | RT-3276-conversation-checks, RT-3329-task-flow-scenario |
|
|
92
|
+
|
|
93
|
+
## Expected forms
|
|
94
|
+
|
|
95
|
+
| Form | Expected text | It matches when |
|
|
96
|
+
| --- | --- | --- |
|
|
97
|
+
| `exit` | `^exit (\d+)$` | the command exits with the code of the first group; the output is not compared |
|
|
98
|
+
| `line` | `` ^`(.*)`$ `` | the code is 0 and the last non-empty line of the output equals the first group |
|
|
99
|
+
| `regex` | `^/(.*)/$` | the code is 0 and the last non-empty line matches the first group |
|
|
100
|
+
| `number` | `^(=\|>=\|<=) ?(-?\d+)$` | the code is 0, the last non-empty line is an integer, and its comparison by the first group with the second holds |
|
|
101
|
+
<!-- /flow:description -->
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The measurer «measure.agreement» — exit 3: the grill or the plan of the branch names the directory
|
|
3
|
+
* of the product agreement, found on disk or in the history, or the reason there is none. The forms
|
|
4
|
+
* of the line are those the task folder sample writes: `**Описание фичи:**`, `**Draft:**` and
|
|
5
|
+
* `**Spec:**` with a path, `**Описание фичи:** не нужно — <reason>` and
|
|
6
|
+
* `**Behaviour:** unchanged — <reason>`.
|
|
7
|
+
*/
|
|
8
|
+
import { agreementLines, taskFolder } from './text.mjs';
|
|
9
|
+
|
|
10
|
+
export function named({ git, tree }) {
|
|
11
|
+
return () => {
|
|
12
|
+
const branch = git.branch();
|
|
13
|
+
if (!branch) return false;
|
|
14
|
+
for (const file of ['grill.md', 'plan.md']) {
|
|
15
|
+
const path = `${taskFolder(branch)}/${file}`;
|
|
16
|
+
const text = tree.read(path) ?? git.lastVersion(path);
|
|
17
|
+
if (typeof text !== 'string') continue;
|
|
18
|
+
const { paths, reasons } = agreementLines(text);
|
|
19
|
+
if (reasons.length > 0) return true;
|
|
20
|
+
if (paths.some((p) => tree.exists(p) || git.everExisted(p))) return true;
|
|
21
|
+
}
|
|
22
|
+
return false;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The measurer «measure.ci» — the CI runs the session answers for. The hold is read before the
|
|
3
|
+
* release cases: a turn does not end over a run nobody watches or a red run nobody read.
|
|
4
|
+
*
|
|
5
|
+
* The PRs judged are the open ones whose branch is the current one, the epic branch of the work, or
|
|
6
|
+
* a branch the session pushed in this record — by `git push`, or named by `--head` of `gh pr create`.
|
|
7
|
+
* A task merged into the epic branch moves the head of the epic's PR without any call of the
|
|
8
|
+
* session, so the epic branch is judged too. Only bases the pipeline wakes for are judged: a PR into
|
|
9
|
+
* another base never gets a run, and waiting for one is a dead end.
|
|
10
|
+
*
|
|
11
|
+
* A run on the head of such a PR holds the stop when:
|
|
12
|
+
* - it is running, and no background task of the session that has not ended names its number,
|
|
13
|
+
* the PR number or the head sha — the watch;
|
|
14
|
+
* - it ended red, and no unrefused call after its end names its number or reads the output of a
|
|
15
|
+
* watch of it — the read; a watch call stands before the end and reads nothing;
|
|
16
|
+
* - there is no run yet, and the head was pushed or the PR opened less than `FRESH_MINUTES` ago.
|
|
17
|
+
*
|
|
18
|
+
* No typed word of the owner passes the hold: a running run asks for one background watch, whose
|
|
19
|
+
* notice wakes the session when the run ends, and a red run holds until one call reads it. The
|
|
20
|
+
* owner's Esc does: after it a notice does not put the work back on until the owner writes again.
|
|
21
|
+
*/
|
|
22
|
+
import { epicOfWork } from './epic-of.mjs';
|
|
23
|
+
import { interrupted } from './owner.mjs';
|
|
24
|
+
|
|
25
|
+
/** How long a head without a run holds the stop, in minutes: the hosting shows a run within seconds. */
|
|
26
|
+
export const FRESH_MINUTES = 2;
|
|
27
|
+
|
|
28
|
+
/** The conclusions that are no red: the run passed, or did not need to run. */
|
|
29
|
+
const NOT_RED = new Set(['success', 'skipped', 'neutral']);
|
|
30
|
+
|
|
31
|
+
/** A number or a sha as a whole word of a text: «3472» is not found inside «44884034720». */
|
|
32
|
+
const names = (text, value) =>
|
|
33
|
+
value !== null && value !== undefined && value !== '' && new RegExp(`(?<![\\w./-])${String(value).replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?![\\w-])`).test(text);
|
|
34
|
+
|
|
35
|
+
/** The text of a call that may name a run: its command, or its whole input. */
|
|
36
|
+
const callText = (event) => (typeof event.input?.command === 'string' ? event.input.command : JSON.stringify(event.input ?? {}));
|
|
37
|
+
|
|
38
|
+
/** The arguments of a command tail, with its redirections cut off: `> /tmp/push.log` names no branch. */
|
|
39
|
+
const argsOf = (tail) =>
|
|
40
|
+
tail
|
|
41
|
+
.replace(/\d*&?>>?\s*\S+/g, ' ')
|
|
42
|
+
.trim()
|
|
43
|
+
.split(/\s+/)
|
|
44
|
+
.filter((arg) => arg && !arg.startsWith('-') && !/[<>]/.test(arg));
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A command as the shell splits it into words: a substitution `$(…)` or `\`…\`` is one word, a line
|
|
48
|
+
* continued by a backslash is one line, and a quoted text with a space or a separator in it is one
|
|
49
|
+
* word. The branch of `git push "https://…$(cat t)@…" X` and of `git -c h='!f() { …; }; f' push o X`
|
|
50
|
+
* is X.
|
|
51
|
+
*/
|
|
52
|
+
const QUOTED_WORD = (quoted) => (/[\s;&|]/.test(quoted) ? 'QUOTED' : quoted);
|
|
53
|
+
const flat = (command) => {
|
|
54
|
+
let text = command.replace(/\\\n/g, ' ').replace(/'[^']*'/g, QUOTED_WORD).replace(/`[^`]*`/g, 'SUB');
|
|
55
|
+
for (let before = ''; before !== text; ) [before, text] = [text, text.replace(/\$\([^()]*\)/g, 'SUB')];
|
|
56
|
+
return text.replace(/"[^"]*"/g, QUOTED_WORD);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/** An argument without its quotes: `"RT-1-a"` names RT-1-a. */
|
|
60
|
+
const unquote = (arg) => arg.replace(/^(['"])(.*)\1$/, '$2');
|
|
61
|
+
|
|
62
|
+
/** The tail of a command up to its end: `;`, a pipe, `&&` or a lone `&`, not the `&` of `2>&1`. */
|
|
63
|
+
const TAIL = String.raw`((?:[^;&|\n]|>&|&>)*)`;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The branches the session pushed: { head: the time of the last push }. The time is the result of
|
|
67
|
+
* the call: a push runs the push set for minutes, and the hosting shows the run only after it.
|
|
68
|
+
*/
|
|
69
|
+
export function pushedHeads(events) {
|
|
70
|
+
const heads = new Map();
|
|
71
|
+
const put = (head, at) => {
|
|
72
|
+
if (!head || head.includes('$')) return;
|
|
73
|
+
heads.set(head, Math.max(heads.get(head) ?? -Infinity, Number.isFinite(at) ? at : -Infinity));
|
|
74
|
+
};
|
|
75
|
+
// A push sent to the background ends with the notice of its task, not with the result of its call.
|
|
76
|
+
const ended = new Map(events.filter((e) => e.kind === 'backgroundEnd' && e.id).map((e) => [e.id, e.at]));
|
|
77
|
+
for (const event of events) {
|
|
78
|
+
if (event.kind !== 'call' || event.blocked || event.failed || event.name !== 'Bash') continue;
|
|
79
|
+
const command = flat(event.input?.command ?? '');
|
|
80
|
+
const at = event.input?.run_in_background ? ended.get(event.id) : Number.isFinite(event.doneAt) ? event.doneAt : event.at;
|
|
81
|
+
// `git checkout -b X && git push origin HEAD` pushes X, not the branch the call started on.
|
|
82
|
+
const switched = (index) => [...command.slice(0, index).matchAll(/\bgit\s+(?:checkout\s+-[bB]|switch\s+-[cC])\s+(\S+)/g)].pop()?.[1] ?? event.branch;
|
|
83
|
+
const own = (ref, index) => (!ref || ref === 'HEAD' ? switched(index) : ref);
|
|
84
|
+
for (const match of command.matchAll(new RegExp(String.raw`\bgit\s+(?:-[Cc]\s+\S+\s+)*push\b${TAIL}`, 'g'))) {
|
|
85
|
+
const refspecs = argsOf(match[1]).map(unquote).slice(1);
|
|
86
|
+
if (refspecs.length === 0) put(switched(match.index), at);
|
|
87
|
+
for (const refspec of refspecs) put(own(refspec.replace(/^\+/, '').split(':').pop().replace(/^refs\/heads\//, ''), match.index), at);
|
|
88
|
+
}
|
|
89
|
+
for (const match of command.matchAll(new RegExp(String.raw`\bgh\s+pr\s+(?:create|new)\b${TAIL}`, 'g'))) {
|
|
90
|
+
// `--head owner:branch` names the branch of a fork: the PR list names it without the owner.
|
|
91
|
+
put(own(/(?:--head|-H)[=\s]+['"]?([^\s'"]+)/.exec(match[1])?.[1]?.replace(/^[^:]+:/, ''), match.index), at);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return heads;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** The background tasks of the session that started and have not ended: [{ command, output }]. */
|
|
98
|
+
function openTasks(events) {
|
|
99
|
+
const open = new Map();
|
|
100
|
+
for (const event of events) {
|
|
101
|
+
if (event.kind === 'background') open.set(event.id, event);
|
|
102
|
+
else if (event.kind === 'backgroundEnd') {
|
|
103
|
+
if (event.id) open.delete(event.id);
|
|
104
|
+
else for (const [id, task] of open) if (event.task && task.task === event.task) open.delete(id);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return [...open.values()];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* A background task watches the run: its command calls the hosting client and names the run, the PR
|
|
112
|
+
* or the head. A log file named after the PR is no watch.
|
|
113
|
+
*/
|
|
114
|
+
const watches = (task, run, pr) =>
|
|
115
|
+
typeof task.command === 'string' &&
|
|
116
|
+
/\bgh\b[\s\S]*\bwatch\b/.test(task.command) &&
|
|
117
|
+
(names(task.command, run?.id) ||
|
|
118
|
+
names(task.command, pr.number) ||
|
|
119
|
+
names(task.command, pr.head) ||
|
|
120
|
+
(pr.headRefOid && task.command.includes(pr.headRefOid.slice(0, 7))));
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* A command after the end of the run that a hook did not refuse and that did not fail names it, or a
|
|
124
|
+
* read of the output of a watch of it. An edit of a text that names the run reads nothing.
|
|
125
|
+
*/
|
|
126
|
+
function wasRead(events, run, pr) {
|
|
127
|
+
const outputs = new Set(events.filter((e) => e.kind === 'background' && e.output && watches(e, run, pr)).map((e) => e.output));
|
|
128
|
+
return events.some(
|
|
129
|
+
(event) =>
|
|
130
|
+
event.kind === 'call' &&
|
|
131
|
+
!event.blocked &&
|
|
132
|
+
!event.failed &&
|
|
133
|
+
Number.isFinite(event.at) &&
|
|
134
|
+
event.at > run.endedAt &&
|
|
135
|
+
((event.name === 'Bash' && /\bgh\b/.test(callText(event)) && names(callText(event), run.id)) ||
|
|
136
|
+
(event.name === 'Bash' && [...outputs].some((output) => callText(event).includes(output))) ||
|
|
137
|
+
(event.name === 'Read' && outputs.has(event.input?.file_path))),
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** A base the pipeline wakes for: a name of the list, or a mask with `*`. */
|
|
142
|
+
const wakes = (bases, base) =>
|
|
143
|
+
bases === null || bases.some((name) => (name.includes('*') ? new RegExp(`^${name.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*+/g, '.*')}$`).test(base) : name === base));
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* The hold: { kind: 'running' | 'red' | 'fresh', pr, run, file }, or false. `pr` — { number, head,
|
|
147
|
+
* headRefOid, base }; `run` — { id, attempt, conclusion, endedAt }, null for a fresh head; `file` —
|
|
148
|
+
* the pipeline file.
|
|
149
|
+
*/
|
|
150
|
+
export function hold({ git, host, tree, session, owner }) {
|
|
151
|
+
return (data) => {
|
|
152
|
+
if (owner && interrupted({ owner })(data)) return false;
|
|
153
|
+
const events = session.events();
|
|
154
|
+
const pushes = pushedHeads(events);
|
|
155
|
+
const heads = new Set(pushes.keys());
|
|
156
|
+
const branch = git.branch();
|
|
157
|
+
if (branch) heads.add(branch);
|
|
158
|
+
let epic = null;
|
|
159
|
+
try {
|
|
160
|
+
epic = epicOfWork({ git, host, tree })?.branch ?? null;
|
|
161
|
+
} catch (error) {
|
|
162
|
+
if (error?.name !== 'HostSilent') throw error;
|
|
163
|
+
}
|
|
164
|
+
if (epic) heads.add(epic);
|
|
165
|
+
const { bases, file } = host.pipeline();
|
|
166
|
+
if (Array.isArray(bases) && bases.length === 0) return false;
|
|
167
|
+
const pulls = host.openPulls().filter((p) => heads.has(p.head) && wakes(bases, p.base));
|
|
168
|
+
if (pulls.length === 0) return false;
|
|
169
|
+
const now = typeof session.now === 'function' ? session.now() : Date.now();
|
|
170
|
+
const tasks = openTasks(events);
|
|
171
|
+
for (const pr of pulls) {
|
|
172
|
+
const runs = host.runs(pr.headRefOid);
|
|
173
|
+
const red = runs.find((run) => run.status === 'completed' && !NOT_RED.has(run.conclusion) && !wasRead(events, run, pr));
|
|
174
|
+
if (red) return { kind: 'red', pr, run: red, file };
|
|
175
|
+
const running = runs.find((run) => run.status !== 'completed');
|
|
176
|
+
if (running && !tasks.some((task) => watches(task, running, pr))) return { kind: 'running', pr, run: running, file };
|
|
177
|
+
if (runs.length === 0) {
|
|
178
|
+
const since = Math.max(pushes.get(pr.head) ?? -Infinity, Number.isFinite(pr.createdAt) ? pr.createdAt : -Infinity);
|
|
179
|
+
if (now - since < FRESH_MINUTES * 60_000 && !tasks.some((task) => watches(task, null, pr))) return { kind: 'fresh', pr, run: null, file };
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return false;
|
|
183
|
+
};
|
|
184
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The measurer «measure.copy» — where the working copy stands against the scenario.
|
|
3
|
+
*
|
|
4
|
+
* outsideEpic — the work has no epic: the task card names none, or the copy of a branch without a
|
|
5
|
+
* task number leads no live epic. Outside an epic the scenario ends at exit 10.
|
|
6
|
+
*
|
|
7
|
+
* outOfScenario — the branch carries no task number, the copy leads no live epic, and no draft folder
|
|
8
|
+
* lies in the working copy: the engine has nothing to name as the next step. A draft keeps the copy
|
|
9
|
+
* in the scenario, measured by states 1–4.
|
|
10
|
+
*/
|
|
11
|
+
import { epicOfWork, workTask } from './epic-of.mjs';
|
|
12
|
+
|
|
13
|
+
export function outsideEpic({ git, host, tree }) {
|
|
14
|
+
return () => epicOfWork({ git, host, tree }) === null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function outOfScenario({ git, host, tree }) {
|
|
18
|
+
return () =>
|
|
19
|
+
workTask({ git, tree }) === null &&
|
|
20
|
+
epicOfWork({ git, host, tree }) === null &&
|
|
21
|
+
!tree.list('docs/tasks').some((name) => name.startsWith('_draft-'));
|
|
22
|
+
}
|