@rt-tools/agent-kit 0.24.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/agents/business-analyst.md +51 -50
- package/assets/agents/cargo-writer.md +54 -0
- package/assets/agents/conscience.md +37 -35
- package/assets/agents/project-manager.md +49 -48
- package/assets/agents/prose-editor.md +31 -29
- package/assets/agents/qa-engineer.md +50 -48
- package/assets/agents/rules-reviewer.md +63 -58
- package/assets/agents/skill-curator.md +83 -78
- package/assets/agents/spec-critic.md +34 -29
- package/assets/agents/spec-writer.md +35 -32
- package/assets/agents/strict-teacher.md +39 -37
- package/assets/checks/archive-age.mjs +48 -28
- package/assets/checks/archive-prune.mjs +16 -14
- package/assets/checks/board-epic-link.github.mjs +29 -0
- package/assets/checks/board-epics.github.mjs +286 -49
- package/assets/checks/board-folders.mjs +61 -0
- package/assets/checks/board-gh.github.mjs +35 -26
- package/assets/checks/board-long-work.github.mjs +29 -25
- package/assets/checks/board-paths.github.mjs +21 -16
- package/assets/checks/board-pull-state.github.mjs +168 -0
- package/assets/checks/board-runs.github.mjs +45 -43
- package/assets/checks/board-task-dirs.github.mjs +98 -0
- package/assets/checks/board-titles.github.mjs +19 -17
- package/assets/checks/board.github.mjs +133 -194
- package/assets/checks/check-archive-age.mjs +23 -19
- package/assets/checks/check-board.github.mjs +131 -263
- package/assets/checks/check-descriptions.mjs +30 -29
- package/assets/checks/check-doc-paths.mjs +91 -88
- package/assets/checks/check-dupes.mjs +84 -80
- package/assets/checks/check-file-size.mjs +74 -71
- package/assets/checks/check-glossary.mjs +47 -37
- package/assets/checks/check-hook-scope.mjs +30 -27
- package/assets/checks/check-lib-layers.mjs +22 -21
- package/assets/checks/check-profile-drift.mjs +48 -43
- package/assets/checks/check-prose-style.mjs +138 -39
- package/assets/checks/check-push-gate.mjs +53 -50
- package/assets/checks/check-reuse.mjs +50 -40
- package/assets/checks/check-schema-drift.mjs +104 -84
- package/assets/checks/check-specs.mjs +155 -134
- package/assets/checks/check-state-next.mjs +66 -52
- package/assets/checks/check-states.mjs +32 -30
- package/assets/checks/check-styles.mjs +52 -51
- package/assets/checks/check-turn-map.mjs +54 -46
- package/assets/checks/epic-table.github.mjs +268 -0
- package/assets/checks/lib-boundaries.mjs +32 -30
- package/assets/checks/lib-common.mjs +30 -29
- package/assets/checks/lib-domains.mjs +34 -34
- package/assets/checks/lib-manifests.mjs +17 -15
- package/assets/checks/lib-reexports.mjs +18 -18
- package/assets/checks/rt-kit-checks.config.mjs +187 -142
- package/assets/checks/signals.mjs +43 -39
- package/assets/checks/spec-anchors.mjs +114 -87
- package/assets/checks/spec-common.mjs +128 -84
- package/assets/checks/spec-contract.mjs +30 -30
- package/assets/checks/spec-proposed.mjs +27 -24
- package/assets/checks/spec-scenarios.mjs +51 -28
- package/assets/checks/specs-for.mjs +214 -0
- package/assets/checks/task-new.github.mjs +315 -61
- package/assets/commands/feedback.md +65 -59
- package/assets/commands/next-session.md +64 -57
- package/assets/commands/night.md +115 -0
- package/assets/commands/skill-curator.md +83 -79
- package/assets/defaults/gate-map.sh +108 -97
- package/assets/defaults/project.sh +232 -185
- package/assets/defaults/shell.sh +73 -68
- package/assets/defaults/turn-map.md +47 -44
- package/assets/docs/GLOSSARY.md +142 -65
- package/assets/hooks/browser-device-id.sh +16 -12
- package/assets/hooks/browser-guard-device-id.sh +34 -28
- package/assets/hooks/browser-guard-no-asking.sh +5 -4
- package/assets/hooks/browser-guard-no-listing.sh +12 -11
- package/assets/hooks/browser-guard-no-other-drivers.sh +48 -42
- package/assets/hooks/browser-guard-require-select.sh +34 -23
- package/assets/hooks/claim-guard.sh +62 -56
- package/assets/hooks/commit-msg.sh +14 -10
- package/assets/hooks/conscience-guard.sh +91 -45
- package/assets/hooks/constitution-index.sh +16 -16
- package/assets/hooks/deny-tail.sh +28 -26
- package/assets/hooks/dev-server-guard.sh +50 -43
- package/assets/hooks/dispatch.sh +60 -46
- package/assets/hooks/docs-guard.sh +100 -91
- package/assets/hooks/epic-over.sh +49 -0
- package/assets/hooks/epic-stop-guard.sh +108 -0
- package/assets/hooks/exam-guard.sh +105 -93
- package/assets/hooks/git-guard-delivery-conflict.sh +41 -36
- package/assets/hooks/git-guard-delivery-draft.sh +48 -38
- package/assets/hooks/git-guard-delivery-epic.sh +167 -0
- package/assets/hooks/git-guard-delivery-folder.sh +50 -43
- package/assets/hooks/git-guard-delivery-signature.sh +119 -53
- package/assets/hooks/git-guard-delivery.sh +223 -183
- package/assets/hooks/git-guard-main.sh +38 -34
- package/assets/hooks/git-guard-push-tests.sh +99 -87
- package/assets/hooks/glossary-load.sh +23 -22
- package/assets/hooks/grill-gate-ask.sh +12 -11
- package/assets/hooks/grill-gate.sh +94 -87
- package/assets/hooks/guard-note.sh +20 -19
- package/assets/hooks/handoff-entry-guard.sh +45 -25
- package/assets/hooks/handoff-write.sh +74 -67
- package/assets/hooks/hook-input.sh +67 -58
- package/assets/hooks/lint-after-edit.sh +95 -61
- package/assets/hooks/observe.sh +28 -26
- package/assets/hooks/override-write-guard.sh +23 -21
- package/assets/hooks/postmortem-guard.sh +42 -39
- package/assets/hooks/profile-check.sh +22 -20
- package/assets/hooks/proposal-guard.sh +57 -49
- package/assets/hooks/prose-style-guard.sh +49 -24
- package/assets/hooks/qa-dataid-guard.sh +83 -58
- package/assets/hooks/rerun-guard.sh +31 -30
- package/assets/hooks/reuse-first-guard.sh +108 -87
- package/assets/hooks/roles.sh +14 -14
- package/assets/hooks/rule-article.sh +39 -34
- package/assets/hooks/rule-source-guard.sh +47 -42
- package/assets/hooks/skill-gate-layers.sh +63 -57
- package/assets/hooks/skill-gate-rearm.sh +15 -8
- package/assets/hooks/skill-gate.sh +89 -81
- package/assets/hooks/skill-loaded.sh +10 -6
- package/assets/hooks/sql-guard-parse.sh +71 -66
- package/assets/hooks/sql-guard-request.sh +51 -46
- package/assets/hooks/sql-guard-target.sh +60 -51
- package/assets/hooks/sql-guard-write.sh +87 -79
- package/assets/hooks/sql-guard.sh +52 -47
- package/assets/hooks/stand-login-guard.sh +43 -37
- package/assets/hooks/task-context-load.sh +60 -55
- package/assets/hooks/task-flow-context.sh +87 -69
- package/assets/hooks/task-flow-draft-guard.sh +55 -48
- package/assets/hooks/task-flow-guard.sh +67 -64
- package/assets/hooks/turn-entry-load.sh +39 -32
- package/assets/hooks/turn-exit-guard.sh +260 -204
- package/assets/hooks/turn-exit-patterns.sh +63 -0
- package/assets/hooks/utf8.sh +14 -11
- package/assets/hooks/waiting-turn-guard.sh +104 -94
- package/assets/hooks/window-fill-guard.sh +70 -62
- package/assets/hooks/work-start-guard.sh +52 -49
- package/assets/hooks/write-targets.sh +99 -44
- package/assets/laws/autonomous-work.md +29 -27
- package/assets/laws/code-structure.md +31 -30
- package/assets/laws/delivery.md +170 -137
- package/assets/laws/entity-editing.md +52 -50
- package/assets/laws/entity-models.md +14 -13
- package/assets/laws/frontend-application.md +39 -38
- package/assets/laws/lib-imports.md +27 -27
- package/assets/laws/lists.md +31 -29
- package/assets/laws/navigation.md +37 -37
- package/assets/laws/observability.md +41 -40
- package/assets/laws/project-documentation.md +106 -99
- package/assets/laws/reuse-first.md +31 -29
- package/assets/laws/shared-code.md +27 -27
- package/assets/laws/verifiability.md +131 -124
- package/assets/laws/work-conduct.md +250 -244
- package/assets/patterns/admin-lists-screen.md +72 -69
- package/assets/patterns/admin-nav-item.md +51 -46
- package/assets/patterns/angular-patterns-state.md +32 -31
- package/assets/patterns/api-layer-pair.md +33 -31
- package/assets/patterns/autonomous-work-run.md +50 -49
- package/assets/patterns/browser-verification-measure.md +124 -88
- package/assets/patterns/browser-verification-stand.md +169 -157
- package/assets/patterns/component-structure-new.md +51 -42
- package/assets/patterns/dependencies-upgrade.md +55 -39
- package/assets/patterns/doc-style-human.md +55 -37
- package/assets/patterns/doc-style-sweep.md +82 -79
- package/assets/patterns/doc-style-trace.md +87 -81
- package/assets/patterns/doc-style-write.md +130 -122
- package/assets/patterns/entity-aside.md +77 -63
- package/assets/patterns/entity-models-new.md +37 -37
- package/assets/patterns/entity-store.md +33 -33
- package/assets/patterns/git-workflow-commit.azure.md +94 -87
- package/assets/patterns/git-workflow-commit.github.md +160 -142
- package/assets/patterns/git-workflow-commit.gitlab.md +96 -90
- package/assets/patterns/git-workflow-docker.md +165 -147
- package/assets/patterns/git-workflow-freshness.md +45 -45
- package/assets/patterns/git-workflow-merge.md +102 -94
- package/assets/patterns/git-workflow-migration.md +54 -52
- package/assets/patterns/git-workflow-pr-ready.md +57 -56
- package/assets/patterns/git-workflow-pr.azure.md +127 -122
- package/assets/patterns/git-workflow-pr.github.md +186 -177
- package/assets/patterns/git-workflow-pr.gitlab.md +139 -132
- package/assets/patterns/git-workflow-restart.md +35 -31
- package/assets/patterns/git-workflow-secrets.md +80 -73
- package/assets/patterns/git-workflow-stack.md +136 -107
- package/assets/patterns/lib-layers-move.md +62 -53
- package/assets/patterns/lib-layers-new.md +59 -45
- package/assets/patterns/observability-record.md +72 -67
- package/assets/patterns/platform-access-di.md +31 -29
- package/assets/patterns/reuse-first-extend.md +66 -61
- package/assets/patterns/shared-code-new.md +39 -38
- package/assets/patterns/spec-driven-domain.md +161 -151
- package/assets/patterns/spec-driven-rule.md +179 -168
- package/assets/patterns/spec-driven-sweep.md +41 -39
- package/assets/patterns/status-report-table.github.md +48 -36
- package/assets/patterns/styling-bem-component.md +42 -42
- package/assets/patterns/styling-bem-layout.md +39 -34
- package/assets/patterns/styling-bem-sheet.md +59 -58
- package/assets/patterns/task-flow-archive.md +222 -215
- package/assets/patterns/task-flow-close.md +234 -203
- package/assets/patterns/task-flow-handoff.md +154 -145
- package/assets/patterns/task-flow-resume.md +138 -133
- package/assets/patterns/task-flow-start.md +228 -202
- package/assets/patterns/testing-e2e.md +102 -101
- package/assets/patterns/testing-unit.md +77 -70
- package/assets/patterns/ts-procedure.md +32 -29
- package/assets/patterns/turn-entry-map.md +50 -48
- package/assets/pitfalls/agent-kit.md +172 -142
- package/assets/pitfalls/doc-style.md +96 -91
- package/assets/pitfalls/git-workflow.azure.md +49 -46
- package/assets/pitfalls/git-workflow.github.md +270 -234
- package/assets/pitfalls/git-workflow.gitlab.md +49 -45
- package/assets/pitfalls/spec-driven.md +73 -71
- package/assets/pitfalls/styling-bem.md +46 -40
- package/assets/pitfalls/task-flow.md +262 -246
- package/assets/pitfalls/testing.md +99 -92
- package/assets/pitfalls/turn-conduct.md +96 -81
- package/assets/rules/angular-patterns.md +81 -80
- package/assets/rules/api-layer.md +77 -74
- package/assets/rules/autonomous-work.md +87 -74
- package/assets/rules/browser-verification.md +223 -214
- package/assets/rules/component-structure.md +72 -69
- package/assets/rules/dependencies.md +74 -67
- package/assets/rules/deploy-flow.azure.md +118 -108
- package/assets/rules/deploy-flow.github.md +145 -135
- package/assets/rules/deploy-flow.gitlab.md +120 -110
- package/assets/rules/doc-style.md +201 -173
- package/assets/rules/entity-conventions.needs-admin.md +81 -79
- package/assets/rules/entity-models.md +73 -70
- package/assets/rules/git-workflow.azure.md +224 -228
- package/assets/rules/git-workflow.github.md +268 -239
- package/assets/rules/git-workflow.gitlab.md +218 -217
- package/assets/rules/lib-layers.md +85 -86
- package/assets/rules/lists.md +101 -97
- package/assets/rules/navigation.md +78 -78
- package/assets/rules/observability.needs-app.md +165 -153
- package/assets/rules/platform-access.md +76 -75
- package/assets/rules/reuse-first.md +153 -143
- package/assets/rules/shared-code.md +82 -79
- package/assets/rules/spec-driven.md +279 -260
- package/assets/rules/status-report.md +62 -58
- package/assets/rules/styling-bem.md +81 -77
- package/assets/rules/task-flow.md +303 -270
- package/assets/rules/testing.md +224 -209
- package/assets/rules/turn-conduct.md +262 -258
- package/assets/rules/turn-entry.md +92 -87
- package/assets/rules/typescript-conventions.md +94 -88
- package/assets/samples/specs/_template/spec.md +47 -47
- package/assets/samples/tasks/_template/grill.md +20 -20
- package/assets/samples/tasks/_template/plan.md +32 -30
- package/assets/samples/tasks/_template/progress.md +16 -16
- package/assets/skills/agent-kit-extend.md +129 -113
- package/assets/skills/agent-kit.md +259 -233
- package/assets/skills/write-a-skill.md +76 -71
- package/assets/templates/findings.md +19 -19
- package/assets/templates/gate-map.sh +16 -14
- package/assets/templates/implementation.md +28 -27
- package/assets/templates/pattern.md +17 -17
- package/assets/templates/pitfalls.md +6 -6
- package/assets/templates/postmortem.md +24 -23
- package/assets/templates/project.sh +24 -24
- package/assets/templates/proposal.md +62 -60
- package/assets/templates/rule.md +38 -38
- package/assets/workflows/feature.js +46 -46
- package/assets/workflows/plan.js +54 -54
- package/bin/agent-kit.d.ts.map +1 -1
- package/bin/agent-kit.js +8 -1
- package/bin/agent-kit.js.map +1 -1
- package/lib/cargo-prose.d.ts +41 -0
- package/lib/cargo-prose.d.ts.map +1 -0
- package/lib/cargo-prose.js +88 -0
- package/lib/cargo-prose.js.map +1 -0
- package/lib/cargo.d.ts +12 -1
- package/lib/cargo.d.ts.map +1 -1
- package/lib/cargo.js +8 -2
- package/lib/cargo.js.map +1 -1
- package/lib/catalog.d.ts +2 -0
- package/lib/catalog.d.ts.map +1 -1
- package/lib/catalog.js +4 -3
- package/lib/catalog.js.map +1 -1
- package/lib/commands.d.ts.map +1 -1
- package/lib/commands.js +5 -2
- package/lib/commands.js.map +1 -1
- package/lib/companion.js +3 -2
- package/lib/companion.js.map +1 -1
- package/lib/enroll.d.ts +7 -1
- package/lib/enroll.d.ts.map +1 -1
- package/lib/enroll.js +12 -3
- package/lib/enroll.js.map +1 -1
- package/lib/fate.d.ts +29 -0
- package/lib/fate.d.ts.map +1 -0
- package/lib/fate.js +147 -0
- package/lib/fate.js.map +1 -0
- package/lib/override-marks.d.ts +7 -0
- package/lib/override-marks.d.ts.map +1 -1
- package/lib/override-marks.js +14 -0
- package/lib/override-marks.js.map +1 -1
- package/lib/plan.d.ts +11 -0
- package/lib/plan.d.ts.map +1 -1
- package/lib/plan.js +10 -1
- package/lib/plan.js.map +1 -1
- package/lib/ship.d.ts +29 -9
- package/lib/ship.d.ts.map +1 -1
- package/lib/ship.js +44 -2
- package/lib/ship.js.map +1 -1
- package/lib/shipment.d.ts.map +1 -1
- package/lib/shipment.fixture.d.ts +8 -1
- package/lib/shipment.fixture.d.ts.map +1 -1
- package/lib/shipment.fixture.js +9 -0
- package/lib/shipment.fixture.js.map +1 -1
- package/lib/shipment.js +38 -5
- package/lib/shipment.js.map +1 -1
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +45 -11
- package/lib/sync.js.map +1 -1
- package/package.json +1 -1
- package/rt-tools-agent-kit-0.27.0.tgz +0 -0
- package/rt-tools-agent-kit-0.24.0.tgz +0 -0
|
@@ -1,39 +1,41 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
#
|
|
2
|
+
# Shared parsing for the work-conduct guards. NOT a guard: it has no `rt-hook:` declaration and
|
|
3
|
+
# is not attached to any agent event. The guards themselves source it — the same way they source
|
|
4
|
+
# the shared refusal tail.
|
|
5
5
|
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
6
|
+
# Why it exists. The work-conduct requirements are kept by two guards — the task folder with the
|
|
7
|
+
# plan and the state by one, the product agreement by the other — and both parse the same things:
|
|
8
|
+
# which path the call writes, whether it is application code, in which branch the edit goes and
|
|
9
|
+
# where the task folder lies. Laid out twice, this parsing drifts silently: an edit to one guard
|
|
10
|
+
# fixes half of the cases, and that shows only where the other guard kept silent.
|
|
11
11
|
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
12
|
+
# WHAT IT DOES. Reads the input, loads the tree profile, takes the paths out of the call, picks
|
|
13
|
+
# the first application-code path among them, moves into the working directory of the edit and
|
|
14
|
+
# names the branch, the root, the task folders directory, the folder itself and the plan in it.
|
|
15
15
|
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
16
|
+
# WHAT IT DOES NOT DO. It judges nothing and refuses nothing: the branch name, the presence of
|
|
17
|
+
# the folder, the work state and the agreement are the business of the guards themselves, and the
|
|
18
|
+
# refusal is printed by the one whose requirement it is.
|
|
18
19
|
#
|
|
19
|
-
# FAIL-OPEN:
|
|
20
|
-
#
|
|
20
|
+
# FAIL-OPEN: no jq, not a git repository, broken input, a foreign tool, no profile function →
|
|
21
|
+
# the answer is "nothing to judge". Broken parsing must not get in the way of work.
|
|
21
22
|
|
|
22
|
-
#
|
|
23
|
-
#
|
|
23
|
+
# Parsing the call. Returns 0 and sets the variables if the edit touches application code in a
|
|
24
|
+
# branch with history; otherwise a non-zero code, and the guard exits silently.
|
|
24
25
|
#
|
|
25
|
-
# RT_TF_PATH —
|
|
26
|
-
# RT_TF_BRANCH —
|
|
27
|
-
# RT_TF_ROOT —
|
|
28
|
-
# RT_TF_TASKS_DIR —
|
|
29
|
-
# RT_TF_MAIN_BRANCH —
|
|
30
|
-
# RT_TF_DIR —
|
|
31
|
-
# RT_TF_PLAN —
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
-
#
|
|
26
|
+
# RT_TF_PATH — the application-code path because of which the guard judges at all
|
|
27
|
+
# RT_TF_BRANCH — the current branch of the edit's working directory
|
|
28
|
+
# RT_TF_ROOT — the root of the working tree
|
|
29
|
+
# RT_TF_TASKS_DIR — the task folders directory, as the tree names it
|
|
30
|
+
# RT_TF_MAIN_BRANCH — the main branch of the tree
|
|
31
|
+
# RT_TF_DIR — the folder of this task
|
|
32
|
+
# RT_TF_PLAN — the plan in it
|
|
33
|
+
# The laid-out rules layer is judged on a par with application code. No code path covers it — it
|
|
34
|
+
# lies in the laws directory, in the agent directory and among the checks — and a hundred and
|
|
35
|
+
# fifty of its files landed without a single response from the guard; it refused two turns later,
|
|
36
|
+
# on a write into the task folder. The sign is the same one by which the layer finds the rules
|
|
37
|
+
# gate: the layout header at the top of the file. The package resource the layout comes from
|
|
38
|
+
# carries no header and is still judged by its path.
|
|
37
39
|
rt_tf_laid_out() {
|
|
38
40
|
[ -f "$1" ] || return 1
|
|
39
41
|
head -n 3 "$1" 2>/dev/null | grep -q 'rt-kit v[^[:space:]]* ·'
|
|
@@ -52,8 +54,8 @@ rt_task_flow_context() {
|
|
|
52
54
|
[ -z "$RT_HOOK_INPUT" ] && return 1
|
|
53
55
|
command -v jq >/dev/null 2>&1 || return 1
|
|
54
56
|
|
|
55
|
-
#
|
|
56
|
-
#
|
|
57
|
+
# The tree profile: the package default first, the project override on top of it if there is
|
|
58
|
+
# one. Read before the path parsing: it is the profile that takes paths out of a shell command.
|
|
57
59
|
for rt_tf_profile in \
|
|
58
60
|
"$rt_tf_hooks_dir/../rt-kit/defaults/project.sh" \
|
|
59
61
|
"$rt_tf_hooks_dir/../defaults/project.sh" \
|
|
@@ -63,8 +65,8 @@ rt_task_flow_context() {
|
|
|
63
65
|
[ -f "$rt_tf_profile" ] && . "$rt_tf_profile" 2>/dev/null
|
|
64
66
|
done
|
|
65
67
|
|
|
66
|
-
#
|
|
67
|
-
#
|
|
68
|
+
# A word about a missing profile function: a hook that exited silently cannot be told from a
|
|
69
|
+
# working one. The file may not be laid out — then the old behaviour, the silent one, stays.
|
|
68
70
|
# shellcheck disable=SC1090
|
|
69
71
|
[ -f "$rt_tf_hooks_dir/profile-check.sh" ] && . "$rt_tf_hooks_dir/profile-check.sh"
|
|
70
72
|
command -v rt_needs >/dev/null 2>&1 || rt_needs() { command -v "$1" >/dev/null 2>&1; }
|
|
@@ -72,23 +74,23 @@ rt_task_flow_context() {
|
|
|
72
74
|
rt_tf_tool="$(rt_hook_tool)"
|
|
73
75
|
rt_tf_candidates=""
|
|
74
76
|
case "$rt_tf_tool" in
|
|
75
|
-
#
|
|
76
|
-
#
|
|
77
|
+
# The editor tool creates a file with the same two pieces of data, only under different
|
|
78
|
+
# names — without this branch an edit would pass the guard by switching the tool.
|
|
77
79
|
Edit | Write | MultiEdit | mcp__webstorm__create_new_file)
|
|
78
80
|
rt_tf_candidates="$(printf '%s' "$RT_HOOK_INPUT" | jq -r '.tool_input.file_path // .tool_input.pathInProject // empty' 2>/dev/null)"
|
|
79
81
|
;;
|
|
80
|
-
#
|
|
81
|
-
#
|
|
82
|
-
# heredoc.
|
|
82
|
+
# The second tier: the same edit, made by a shell command. Without it the guard's refusal
|
|
83
|
+
# is bypassed by switching not the tool but the way of writing — a redirect, `sed -i`, an
|
|
84
|
+
# interpreter with a heredoc.
|
|
83
85
|
#
|
|
84
|
-
#
|
|
85
|
-
#
|
|
86
|
-
#
|
|
86
|
+
# The IDE terminal runs the same command line and puts it into the same field: without
|
|
87
|
+
# these two names the guard would stand declared on them and let them through silently —
|
|
88
|
+
# a state worse than undeclared, because from outside it looks closed.
|
|
87
89
|
Bash | mcp__webstorm__execute_terminal_command | mcp__webstorm__execute_tool)
|
|
88
90
|
rt_tf_cmd="$(rt_hook_cmd)"
|
|
89
91
|
[ -z "$rt_tf_cmd" ] && return 1
|
|
90
|
-
#
|
|
91
|
-
#
|
|
92
|
+
# The universal runner hides the real command in a nested string: without parsing it
|
|
93
|
+
# the path stands behind a quote, and no pattern reaches it.
|
|
92
94
|
if [ "$rt_tf_tool" = "mcp__webstorm__execute_tool" ] && command -v perl >/dev/null 2>&1; then
|
|
93
95
|
rt_tf_inner="$(printf '%s' "$rt_tf_cmd" | perl -0ne '
|
|
94
96
|
if (/--command(?:=|\s+)(?:"((?:[^"\\]|\\.)*)"|\x27([^\x27]*)\x27|(.+))/s) {
|
|
@@ -97,15 +99,28 @@ rt_task_flow_context() {
|
|
|
97
99
|
' 2>/dev/null)"
|
|
98
100
|
[ -n "$rt_tf_inner" ] && rt_tf_cmd="$rt_tf_inner"
|
|
99
101
|
fi
|
|
100
|
-
#
|
|
101
|
-
#
|
|
102
|
-
#
|
|
103
|
-
#
|
|
104
|
-
#
|
|
105
|
-
#
|
|
102
|
+
# The task creation command is not judged at all. It writes the task folder and the
|
|
103
|
+
# card in the work queue, and its text carries the whole task body: a quote with the
|
|
104
|
+
# "greater than" sign matches the write sign, a code path in the body's prose matches
|
|
105
|
+
# the path sign. Refused, it is refused by the very guard that prints it in the text
|
|
106
|
+
# of its refusal, and there is nothing left to create a task with — neither from the
|
|
107
|
+
# branch of a closed task nor from the main one. The command name comes from the tree
|
|
108
|
+
# profile: a copy of its own would drift from it silently.
|
|
106
109
|
case "$rt_tf_cmd" in
|
|
107
110
|
*"${RT_TASK_NEW_CMD:-npm run task:new}"*) return 1 ;;
|
|
108
111
|
esac
|
|
112
|
+
# Pruning stale records of finished work is not judged either. Records age by the
|
|
113
|
+
# calendar, and the age check turns red by itself, without an edit in the branch; in
|
|
114
|
+
# the branch where work arrives by merges there is no task folder and must not be,
|
|
115
|
+
# and without a plan the edit is not written — the PR stays red, and the executor has
|
|
116
|
+
# no way out of this pair. The tree profile names the command: not named — no
|
|
117
|
+
# exemption, and everything is as before. The whole command is compared, not a
|
|
118
|
+
# substring: in a chain through `&&` anything at all stands next to the pruning, and a
|
|
119
|
+
# substring exemption would become a hole as wide as the shell.
|
|
120
|
+
if [ -n "${RT_ARCHIVE_PRUNE_CMD:-}" ]; then
|
|
121
|
+
rt_tf_bare="$(printf '%s' "$rt_tf_cmd" | tr -s '[:space:]' ' ' | sed 's/^ //; s/ $//')"
|
|
122
|
+
[ "$rt_tf_bare" = "$RT_ARCHIVE_PRUNE_CMD" ] && return 1
|
|
123
|
+
fi
|
|
109
124
|
rt_needs rt_shell_writes task-flow-guard || return 1
|
|
110
125
|
rt_needs rt_shell_paths task-flow-guard || return 1
|
|
111
126
|
rt_shell_writes "$rt_tf_cmd" || return 1
|
|
@@ -115,32 +130,34 @@ rt_task_flow_context() {
|
|
|
115
130
|
esac
|
|
116
131
|
[ -z "$rt_tf_candidates" ] && return 1
|
|
117
132
|
|
|
118
|
-
#
|
|
119
|
-
#
|
|
120
|
-
#
|
|
121
|
-
#
|
|
133
|
+
# The sign "the edit changes behaviour" is a path, not a judgement by eye: a judgement is
|
|
134
|
+
# made by whoever it hinders, and the threshold drifts. Where application code lives, the
|
|
135
|
+
# profile knows: rules, texts, tooling and dependencies do not fall under the requirement —
|
|
136
|
+
# otherwise the grill of a task could not be conducted before the branch is created.
|
|
122
137
|
rt_needs rt_is_app_code task-flow-guard || return 1
|
|
123
138
|
|
|
124
|
-
#
|
|
125
|
-
#
|
|
126
|
-
#
|
|
127
|
-
#
|
|
128
|
-
#
|
|
139
|
+
# Removal differs from a write in one thing: what is removed may not be in history at all. A
|
|
140
|
+
# temporary directory of one's own under the applications root is never a product edit —
|
|
141
|
+
# removing it, and restoring the plan on disk for that, means carrying out a requirement
|
|
142
|
+
# written about a different action. A tracked path is judged as before: a removed code file
|
|
143
|
+
# changes behaviour just as a rewritten one does.
|
|
129
144
|
rt_tf_removes=0
|
|
130
145
|
case "${rt_tf_cmd:-}" in
|
|
131
146
|
*"rm "*) rt_tf_removes=1 ;;
|
|
132
147
|
esac
|
|
133
|
-
#
|
|
148
|
+
# The directory of the edit: the branch and the history are looked at below, but history has
|
|
149
|
+
# to be asked already here.
|
|
134
150
|
rt_tf_askdir="$(rt_hook_cwd)"
|
|
135
151
|
[ -z "$rt_tf_askdir" ] && rt_tf_askdir="${CLAUDE_PROJECT_DIR:-.}"
|
|
136
152
|
|
|
137
|
-
#
|
|
138
|
-
#
|
|
153
|
+
# Every named path is judged: a command writes as many files as stand in it, and one under
|
|
154
|
+
# the requirement is enough to refuse it whole.
|
|
139
155
|
RT_TF_PATH=""
|
|
140
156
|
while IFS= read -r rt_tf_candidate; do
|
|
141
157
|
[ -z "$rt_tf_candidate" ] && continue
|
|
142
|
-
#
|
|
143
|
-
#
|
|
158
|
+
# Removing what is not in history is not a product edit but cleaning up after oneself.
|
|
159
|
+
# The path is asked as it is named in the command: a glued-on root takes the question
|
|
160
|
+
# into a foreign tree.
|
|
144
161
|
if [ "$rt_tf_removes" = 1 ] && git -C "$rt_tf_askdir" rev-parse --is-inside-work-tree >/dev/null 2>&1 &&
|
|
145
162
|
! git -C "$rt_tf_askdir" ls-files --error-unmatch -- "$rt_tf_candidate" >/dev/null 2>&1; then
|
|
146
163
|
continue
|
|
@@ -158,19 +175,19 @@ $rt_tf_candidates
|
|
|
158
175
|
EOF
|
|
159
176
|
[ -z "$RT_TF_PATH" ] && return 1
|
|
160
177
|
|
|
161
|
-
#
|
|
178
|
+
# The branch is looked at where the edit will go: a worktree has one of its own.
|
|
162
179
|
rt_tf_workdir="$(rt_hook_cwd)"
|
|
163
180
|
[ -z "$rt_tf_workdir" ] && rt_tf_workdir="${CLAUDE_PROJECT_DIR:-.}"
|
|
164
181
|
cd "$rt_tf_workdir" 2>/dev/null || return 1
|
|
165
182
|
git rev-parse --is-inside-work-tree >/dev/null 2>&1 || return 1
|
|
166
183
|
|
|
167
184
|
RT_TF_BRANCH="$(git branch --show-current 2>/dev/null)"
|
|
168
|
-
[ -z "$RT_TF_BRANCH" ] && return 1 # detached HEAD
|
|
185
|
+
[ -z "$RT_TF_BRANCH" ] && return 1 # a detached HEAD is not about this case
|
|
169
186
|
|
|
170
187
|
RT_TF_ROOT="$(git rev-parse --show-toplevel 2>/dev/null)"
|
|
171
188
|
[ -z "$RT_TF_ROOT" ] && return 1
|
|
172
189
|
|
|
173
|
-
#
|
|
190
|
+
# The task folders directory: each tree has its own, but the name is usually shared.
|
|
174
191
|
RT_TF_TASKS_DIR="${RT_TASKS_DIR:-docs/tasks}"
|
|
175
192
|
RT_TF_MAIN_BRANCH="${RT_MAIN_BRANCH:-main}"
|
|
176
193
|
RT_TF_DIR="$RT_TF_ROOT/$RT_TF_TASKS_DIR/$RT_TF_BRANCH"
|
|
@@ -179,9 +196,10 @@ EOF
|
|
|
179
196
|
return 0
|
|
180
197
|
}
|
|
181
198
|
|
|
182
|
-
#
|
|
183
|
-
#
|
|
184
|
-
#
|
|
199
|
+
# The refusal of a work-conduct guard: the reason as the first parameter, the lawful form of
|
|
200
|
+
# bypass as the second. The tail is appended here, not in every text: missed in one place, it
|
|
201
|
+
# reads as "this refusal has no moves". The tail may not be laid out — then there is none, and
|
|
202
|
+
# the reason stays as it was.
|
|
185
203
|
rt_task_flow_deny() {
|
|
186
204
|
rt_tf_reason="$1"
|
|
187
205
|
if command -v rt_deny_tail >/dev/null 2>&1; then
|
|
@@ -1,41 +1,44 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# rt-hook: PreToolUse Edit|Write|MultiEdit|Bash|mcp__webstorm__create_new_file|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_tool
|
|
3
|
-
#
|
|
4
|
-
# PreToolUse guard for Edit|Write|MultiEdit:
|
|
3
|
+
# Requires: hooks/task-flow-context.sh, hooks/task-flow-guard.sh, hooks/deny-tail.sh
|
|
4
|
+
# PreToolUse guard for Edit|Write|MultiEdit: no code is written before the product agreement.
|
|
5
5
|
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
6
|
+
# The plan says how the work will be done and is silent about what was agreed with the owner.
|
|
7
|
+
# The product agreement is the only text that names the promised behaviour before the code;
|
|
8
|
+
# written afterwards, it retells a decision already made instead of checking it.
|
|
9
9
|
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
# `task-flow-guard`,
|
|
10
|
+
# The guard demands one thing and exactly one: the plan names the agreement with the line
|
|
11
|
+
# `**Draft:** \`path\``, and what is named exists. The task folder, the plan itself and the
|
|
12
|
+
# declared state are demanded by `task-flow-guard`, and before its refusals this guard judges
|
|
13
|
+
# nothing: no plan on disk — it stays silent.
|
|
13
14
|
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
15
|
+
# The demands are kept apart so that a tree can drop one and keep the other. While both rode in
|
|
16
|
+
# one file, dropping the agreement demand also dropped the demand for the task folder and the
|
|
17
|
+
# plan — that is, everything the guard was made for.
|
|
17
18
|
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
19
|
+
# There is a deliberate way out: the line `**Behaviour:** unchanged — <reason>` in the plan
|
|
20
|
+
# lifts the agreement demand. An empty reason is not accepted, same as with `Docs-skip:`.
|
|
20
21
|
#
|
|
21
|
-
#
|
|
22
|
+
# The whole rule — the `task-flow` rule.
|
|
22
23
|
#
|
|
23
|
-
# FAIL-OPEN:
|
|
24
|
-
#
|
|
24
|
+
# FAIL-OPEN: no jq, not a git repository, broken input, foreign tool → pass. A broken guard must
|
|
25
|
+
# not get in the way of work.
|
|
25
26
|
|
|
26
|
-
#
|
|
27
|
+
# Own name in the observations: the refusal is written by the shared refusal tail, not by the
|
|
28
|
+
# guard itself.
|
|
27
29
|
RT_GUARD_NAME=task-flow-draft-guard
|
|
28
30
|
|
|
29
31
|
rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
30
32
|
|
|
31
|
-
#
|
|
32
|
-
#
|
|
33
|
+
# Parsing the call is shared by both progress guards. The file may not be laid out: then there is
|
|
34
|
+
# nothing to judge with, and the guard stays silent.
|
|
33
35
|
# shellcheck disable=SC1090
|
|
34
36
|
[ -f "$rt_hooks_dir/task-flow-context.sh" ] && . "$rt_hooks_dir/task-flow-context.sh"
|
|
35
37
|
command -v rt_task_flow_context >/dev/null 2>&1 || exit 0
|
|
36
38
|
|
|
37
|
-
#
|
|
38
|
-
#
|
|
39
|
+
# The shared refusal tail: two lawful moves and the lawful form of bypass, when the refusal has
|
|
40
|
+
# one. The file may not be laid out — then there is no tail, and the reason for the refusal stays
|
|
41
|
+
# as it was.
|
|
39
42
|
# shellcheck disable=SC1090
|
|
40
43
|
[ -f "$rt_hooks_dir/deny-tail.sh" ] && . "$rt_hooks_dir/deny-tail.sh"
|
|
41
44
|
|
|
@@ -48,28 +51,30 @@ plan="$RT_TF_PLAN"
|
|
|
48
51
|
|
|
49
52
|
deny() { rt_task_flow_deny "$@"; }
|
|
50
53
|
|
|
51
|
-
#
|
|
52
|
-
#
|
|
54
|
+
# No plan — that is another guard's demand, and the refusal about it is printed by the progress
|
|
55
|
+
# guard. Work with a taken-apart folder leaves here too: by this minute the plan has been removed
|
|
56
|
+
# from disk on purpose.
|
|
53
57
|
[ -f "$plan" ] || exit 0
|
|
54
58
|
|
|
55
|
-
#
|
|
56
|
-
#
|
|
57
|
-
if grep -qE '
|
|
59
|
+
# The bypass line: the behaviour does not change, no product agreement is needed. The reason must
|
|
60
|
+
# be there — without it the bypass becomes the default.
|
|
61
|
+
if grep -qE '^\*\*(Behaviour|Поведение):\*\*[[:space:]]*(unchanged|не меняется)[[:space:]]*—[[:space:]]*\S' "$plan" 2>/dev/null; then
|
|
58
62
|
exit 0
|
|
59
63
|
fi
|
|
60
64
|
|
|
61
|
-
#
|
|
62
|
-
#
|
|
63
|
-
#
|
|
64
|
-
#
|
|
65
|
-
#
|
|
66
|
-
#
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
# The agreement is named in one of two forms. The first is a separate document in the "proposed"
|
|
66
|
+
# directory: it moves into the domain spec when the work closes. The second is the domain spec
|
|
67
|
+
# itself: a tree without a separate directory writes the agreement straight into it, and there is
|
|
68
|
+
# nothing to move — the draft matches the spec from day one. Demanding one form would impose the
|
|
69
|
+
# way agreements are written along with the check that the work follows the plan: a tree with
|
|
70
|
+
# the second way drops the guard entirely and is left without the only machine check under the
|
|
71
|
+
# rule.
|
|
72
|
+
draft="$(sed -nE 's/^\*\*(Draft|Драфт):\*\*[[:space:]]*`([^`]*)`.*/\2/p' "$plan" 2>/dev/null | head -1)"
|
|
73
|
+
[ -z "$draft" ] && draft="$(sed -nE 's/^\*\*(Spec|Спек):\*\*[[:space:]]*`([^`]*)`.*/\2/p' "$plan" 2>/dev/null | head -1)"
|
|
69
74
|
|
|
70
75
|
if [ -z "$draft" ]; then
|
|
71
|
-
deny "BLOCKED by task-flow:
|
|
72
|
-
"
|
|
76
|
+
deny "BLOCKED by task-flow: no product agreement is named in '${tasks_dir}/${branch}/plan.md'. Name it by one of two lines: '**Draft:** \`path\`' — a separate document in docs/specs/<domain>/proposed/<feature>/, or '**Spec:** \`path\`' — the domain spec the agreement is written into directly. The rule is task-flow." \
|
|
77
|
+
"the line '**Behaviour:** unchanged — <the owner reason>' in the plan; an empty reason is not accepted"
|
|
73
78
|
fi
|
|
74
79
|
|
|
75
80
|
case "$draft" in
|
|
@@ -81,22 +86,24 @@ if [ -e "$draft_path" ]; then
|
|
|
81
86
|
exit 0
|
|
82
87
|
fi
|
|
83
88
|
|
|
84
|
-
#
|
|
85
|
-
#
|
|
86
|
-
#
|
|
87
|
-
#
|
|
89
|
+
# An agreement merged into the domain spec leaves the disk — by design: the main branch must not
|
|
90
|
+
# hold a "proposed" directory. But the plan refers to it until the work ends, and without this
|
|
91
|
+
# branch the last commit of the PR would lock the branch: neither edits after review remarks nor
|
|
92
|
+
# a changelog entry could be made after the merge.
|
|
88
93
|
#
|
|
89
|
-
#
|
|
90
|
-
#
|
|
94
|
+
# The branch history tells a merged agreement from one never created: a path that was never in
|
|
95
|
+
# it was never an agreement. There is nothing to ask about this but git, so no git — the refusal
|
|
96
|
+
# stays.
|
|
91
97
|
if git -C "$root" log --oneline -1 -- "$draft" 2>/dev/null | grep -q .; then
|
|
92
98
|
exit 0
|
|
93
99
|
fi
|
|
94
100
|
|
|
95
|
-
#
|
|
96
|
-
#
|
|
97
|
-
#
|
|
98
|
-
#
|
|
99
|
-
#
|
|
101
|
+
# The merge may also be the first commit that created the named path at all: the draft was
|
|
102
|
+
# written without committing, and what went into history was already the domain spec. Then the
|
|
103
|
+
# path has no history, and the work was done exactly as the close pattern says — and the refusal
|
|
104
|
+
# would lock the branch at the last step. The sign: the agreement is named by a path of the form
|
|
105
|
+
# `<domain>/proposed/<feature>`, the domain directory exists in the tree, and the feature name
|
|
106
|
+
# occurs in it. While there is no such spec, the refusal stays as it was.
|
|
100
107
|
case "$draft" in
|
|
101
108
|
*/proposed/*)
|
|
102
109
|
domain_dir="${draft%%/proposed/*}"
|
|
@@ -109,4 +116,4 @@ case "$draft" in
|
|
|
109
116
|
;;
|
|
110
117
|
esac
|
|
111
118
|
|
|
112
|
-
deny "BLOCKED by task-flow:
|
|
119
|
+
deny "BLOCKED by task-flow: the plan names the agreement '${draft}', and it is neither on disk nor in the history of the branch. Create it from the sample (docs/specs/_template) or fix the path in '${tasks_dir}/${branch}/plan.md'. The rule is task-flow."
|