@rt-tools/agent-kit 0.37.1 → 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-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 +21365 -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 +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/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 +410 -0
- package/assets/checks/record-recount.mjs +187 -0
- package/assets/checks/record-turn.mjs +155 -0
- 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/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 +21 -22
- package/assets/docs/GLOSSARY.md +5 -1
- 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 -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 +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 +15 -4
- package/assets/hooks/git-guard-push-marks.sh +53 -1
- package/assets/hooks/git-guard-push-tests.sh +30 -51
- 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 +14 -10
- package/assets/hooks/prose-style-guard.sh +6 -19
- package/assets/hooks/pull-merges.sh +76 -0
- package/assets/hooks/push-set.sh +11 -4
- 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 +103 -0
- package/assets/hooks/window-fill-guard.sh +22 -41
- 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.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/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/navigation.md +94 -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 +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 +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/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/navigation.md +10 -69
- 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 +100 -104
- 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/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.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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# rt-hook: PreToolUse Bash|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_tool
|
|
3
|
-
# Requires: hooks/git-guard-delivery-merged.sh, hooks/git-guard-delivery-folder.sh,hooks/git-guard-delivery-epic.sh, hooks/git-guard-delivery-pipeline.sh, hooks/git-guard-tree-assignment.sh, hooks/git-guard-delivery-conflict.sh, hooks/profile-check.sh, hooks/deny-tail.sh, hooks/guard-note.sh
|
|
3
|
+
# Requires: hooks/git-guard-delivery-merged.sh, hooks/git-guard-delivery-task.sh, hooks/git-guard-delivery-folder.sh,hooks/git-guard-delivery-epic.sh, hooks/git-guard-delivery-pipeline.sh, hooks/git-guard-tree-assignment.sh, hooks/git-guard-delivery-conflict.sh, hooks/git-guard-delivery-rerun.sh, hooks/profile-check.sh, hooks/deny-tail.sh, hooks/guard-note.sh
|
|
4
4
|
# Delivery guard. PreToolUse on creating a branch, on the push and on opening a PR.
|
|
5
5
|
#
|
|
6
6
|
# The delivery law demands three things nothing usually checks: an edit starts from a task visible
|
|
@@ -84,6 +84,8 @@ root="${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}"
|
|
|
84
84
|
# the `_default` suffix. Neither one nor the other — the hook lets through: an empty guard is
|
|
85
85
|
# better than a guard that refuses at random.
|
|
86
86
|
rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
87
|
+
# shellcheck disable=SC1091
|
|
88
|
+
[ -f "$rt_hooks_dir/facts.sh" ] && . "$rt_hooks_dir/facts.sh"
|
|
87
89
|
for profile in "$rt_hooks_dir/../rt-kit/defaults/project.sh" "$rt_hooks_dir/../defaults/project.sh" "$root/.claude/rt-kit/defaults/project.sh" "$root/.claude/rt-kit/project.sh"; do
|
|
88
90
|
# shellcheck disable=SC1090
|
|
89
91
|
[ -f "$profile" ] && . "$profile" 2>/dev/null
|
|
@@ -101,6 +103,10 @@ title_re="${RT_TASK_TITLE_RE:-^\[[A-Za-z]+-[0-9]+\][[:space:]]+[^[:space:]]}"
|
|
|
101
103
|
task_new="${RT_TASK_NEW_CMD:-npm run task:new}"
|
|
102
104
|
board_check="${RT_BOARD_CHECK_CMD:-npm run check:board}"
|
|
103
105
|
task_move="${RT_TASK_MOVE_CMD:-npm run task:move}"
|
|
106
|
+
# A refusal whose fix ends with a push names the run ahead before it: the push guard refuses a push
|
|
107
|
+
# while the heavy steps of the tree have no green mark, and a refusal naming a bare push would lead
|
|
108
|
+
# into that second refusal.
|
|
109
|
+
ahead_cmd="bash ${rt_hooks_dir#"$PWD"/}/git-guard-push-ahead.sh"
|
|
104
110
|
# The first column of the work queue is the one a task leaves when it is taken. It has no default:
|
|
105
111
|
# a tree names its columns in its own words, and an invented name would match nothing and would
|
|
106
112
|
# silently switch the check off.
|
|
@@ -137,49 +143,65 @@ main_branch="${RT_MAIN_BRANCH:-main}"
|
|
|
137
143
|
# requirement by itself.
|
|
138
144
|
folder_skip_re='(^|#)[[:space:]]*Task-folder-skip:[[:space:]]*[^[:space:]<"'"'"'][^[:space:]"'"'"']{2,}'
|
|
139
145
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
[ -n "${rt_delivery_neighbour_note:-}" ] && reason="${reason}
|
|
153
|
-
|
|
154
|
-
${rt_delivery_neighbour_note}"
|
|
155
|
-
rt_delivery_said=1
|
|
156
|
-
|
|
157
|
-
jq -n --arg r "$reason" '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:$r}}' 2>/dev/null \
|
|
158
|
-
|| printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"The delivery guard."}}\n'
|
|
159
|
-
exit 0
|
|
146
|
+
# The facts of the state, as the decision table names them. What the hook did not find wrong keeps its
|
|
147
|
+
# lawful value from `delivery_lawful`; a check that finds a miss records the fact with the value of
|
|
148
|
+
# the miss. The facts the table reads apart from the miss — whether the task belongs to an epic,
|
|
149
|
+
# whether the folder lies in the branch — are recorded by the check that learns them.
|
|
150
|
+
delivery_lawful='{"own_pr_conflicting":"no","branch_is_main":"no","branch_is_task_branch":"yes","branch_has_main_tip":"yes","task_exists":"yes","task_open":"yes","task_on_board":"yes","task_assigned":"yes","task_title_numbered":"yes","task_column_taken":"yes","copy_assignment":"ok","assigned_epic_open":"yes","origin_main_fresh":"yes","worktree_email_declared":"yes","commits_signed_declared":"yes","archive_gained":"yes","draft_spec_merged":"yes","epic_folders_left":"no","pr_tip_run":"green","pr_conflicting":"no","pr_reviewed":"yes","task_in_epic":"no","task_folder_in_branch":"no","branch_pr_merged":"no","epic_branch":"one","epic_has_main_tip":"yes","branch_has_epic_tip":"yes","steps_remeasured":"yes"}'
|
|
151
|
+
delivery_facts='{}'
|
|
152
|
+
# The class of the call when a check finds the miss in the call itself — the title, the base, the
|
|
153
|
+
# body: the table keeps such a miss as the action, not as a fact. The first class found stands.
|
|
154
|
+
delivery_class=''
|
|
155
|
+
|
|
156
|
+
fact() {
|
|
157
|
+
delivery_facts="$(printf '%s' "$delivery_facts" | jq -c --arg k "$1" --arg v "$2" '. + {($k): $v}' 2>/dev/null || printf '%s' "$delivery_facts")"
|
|
160
158
|
}
|
|
161
159
|
|
|
162
|
-
#
|
|
163
|
-
# miss makes them fixed one at a time — the base, a repeat, the title, another repeat, the task —
|
|
164
|
-
# although everything that did not come together is known already on the first round. Readiness for
|
|
165
|
-
# delivery is one state, and it is named whole.
|
|
160
|
+
# Misses pile up and are named at once: readiness for delivery is one state, named whole.
|
|
166
161
|
faults=''
|
|
167
162
|
|
|
168
|
-
|
|
163
|
+
# unmet <fact> <value> <words> — a miss of the state; `unmet_class <action> <words>` — of the call
|
|
164
|
+
unmet() {
|
|
165
|
+
fact "$1" "$2"
|
|
169
166
|
faults="${faults}${faults:+
|
|
170
|
-
}— $
|
|
167
|
+
}— $3"
|
|
168
|
+
}
|
|
169
|
+
unmet_class() {
|
|
170
|
+
[ -n "$delivery_class" ] || delivery_class="$1"
|
|
171
|
+
faults="${faults}${faults:+
|
|
172
|
+
}— $2"
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
# refuse <action> [params] [bypass] — the decision and its text come from the table.
|
|
176
|
+
refuse() {
|
|
177
|
+
_sid="$(printf '%s' "$input" | jq -r '.session_id // "nosession"' 2>/dev/null)"
|
|
178
|
+
_record="$(rt_fact_transcript "$input")"
|
|
179
|
+
problems=''
|
|
180
|
+
# shellcheck disable=SC1091
|
|
181
|
+
[ -f "$rt_hooks_dir/facts-docs.sh" ] && . "$rt_hooks_dir/facts-docs.sh" 2>/dev/null
|
|
182
|
+
_pair=yes
|
|
183
|
+
command -v rt_fact_doc_problems >/dev/null 2>&1 && rt_fact_doc_problems 'git commit -m wip' && [ -n "$problems" ] && _pair=no
|
|
184
|
+
_facts="$(jq -cn --argjson lawful "$delivery_lawful" --argjson found "$delivery_facts" \
|
|
185
|
+
--arg r "$(rt_fact_rule_loaded "${RT_GUARD_RULE:-git-workflow}" "$_sid")" --arg d "$_pair" \
|
|
186
|
+
--arg e "$(rt_fact_exam_holds "$_record")" --arg w "$(rt_fact_window_over_stop "$_sid" "$_record")" \
|
|
187
|
+
'$lawful + {rule_loaded:$r, doc_pair:$d, exam:$e, window_over_stop:$w} + $found')"
|
|
188
|
+
_params="$(jq -cn --argjson own "${2:-"{}"}" --arg f "$faults" --arg p "$problems" --arg b "${3:-}" \
|
|
189
|
+
--arg a "${rt_delivery_neighbour_note:-}" --arg h "${ahead_cmd:-bash git-guard-push-ahead.sh}" \
|
|
190
|
+
'{faults:$f, problems:$p, bypass:$b, after:$a, ahead_cmd:$h} + $own')"
|
|
191
|
+
rt_delivery_said=1
|
|
192
|
+
# shellcheck disable=SC1091
|
|
193
|
+
. "$rt_hooks_dir/decide.sh" 2>/dev/null
|
|
194
|
+
command -v rt_decide >/dev/null 2>&1 || exit 0
|
|
195
|
+
# A class with no row for these misses is decided by the plain action named after «>».
|
|
196
|
+
rt_decide git-guard-delivery.sh "$1${delivery_base:+>$delivery_base}" "$_facts" "$_params"
|
|
197
|
+
exit 0
|
|
171
198
|
}
|
|
172
199
|
|
|
173
|
-
# The conditions about the task folder
|
|
174
|
-
# subject of its own, a bypass of its own and a record of its own in the archive, and together with
|
|
175
|
-
# the command parsing and the work queue they outgrew the length limit. It is sourced after `deny`
|
|
176
|
-
# and `fault` — both are called from inside it.
|
|
200
|
+
# The conditions about the task folder live in a neighbouring file, sourced after `refuse`.
|
|
177
201
|
# shellcheck disable=SC1090
|
|
178
202
|
[ -f "$rt_hooks_dir/git-guard-delivery-folder.sh" ] && . "$rt_hooks_dir/git-guard-delivery-folder.sh" 2>/dev/null
|
|
179
203
|
|
|
180
|
-
# The epic of a task:
|
|
181
|
-
# there the base of a new branch is judged, and with an epic it is judged against the branch of the
|
|
182
|
-
# epic. No helper — the epic is not judged, and the base is asked against the main branch as before.
|
|
204
|
+
# The epic of a task: a new branch's base is judged against the epic branch, without it — main.
|
|
183
205
|
# shellcheck disable=SC1090
|
|
184
206
|
[ -f "$rt_hooks_dir/git-guard-delivery-epic.sh" ] && . "$rt_hooks_dir/git-guard-delivery-epic.sh" 2>/dev/null
|
|
185
207
|
|
|
@@ -188,7 +210,7 @@ fault() {
|
|
|
188
210
|
[ -f "$rt_hooks_dir/git-guard-delivery-tree.sh" ] && . "$rt_hooks_dir/git-guard-delivery-tree.sh" 2>/dev/null
|
|
189
211
|
command -v rt_delivery_branch_form_ok >/dev/null 2>&1 || rt_delivery_branch_form_ok() { rt_task_branch_ok "$1"; }
|
|
190
212
|
command -v rt_delivery_task_state >/dev/null 2>&1 || rt_delivery_task_state() { (cd "$root" && rt_task_state "$1"); }
|
|
191
|
-
command -v rt_delivery_current_branch >/dev/null 2>&1 || rt_delivery_current_branch() {
|
|
213
|
+
command -v rt_delivery_current_branch >/dev/null 2>&1 || rt_delivery_current_branch() { rt_fact_branch; }
|
|
192
214
|
|
|
193
215
|
# A conflicting PR of one's own: the same technique as with the folder and the signature. The helper
|
|
194
216
|
# is called before all the tiers below and judges not the readiness of this work but the right to
|
|
@@ -199,50 +221,19 @@ command -v rt_delivery_current_branch >/dev/null 2>&1 || rt_delivery_current_bra
|
|
|
199
221
|
command -v rt_delivery_note_out >/dev/null 2>&1 && trap rt_delivery_note_out EXIT
|
|
200
222
|
command -v rt_delivery_conflict >/dev/null 2>&1 && rt_delivery_conflict
|
|
201
223
|
|
|
202
|
-
# The refusal on what has piled up
|
|
203
|
-
|
|
224
|
+
# The refusal on what has piled up, for the action of the call: the class a check found in the call
|
|
225
|
+
# itself stands first. Empty — the calling side goes on.
|
|
226
|
+
refuse_unmet() {
|
|
204
227
|
[ -z "$faults" ] && return 0
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
${faults}"
|
|
228
|
+
delivery_base="$1"
|
|
229
|
+
refuse "${delivery_class:-$1}"
|
|
209
230
|
}
|
|
210
231
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
# requirement here would refuse the very first command of the work together with the one that
|
|
217
|
-
# lifts it.
|
|
218
|
-
judge_column="${3:-no}"
|
|
219
|
-
rt_needs rt_task_state git-guard-delivery || return 0
|
|
220
|
-
state="$(rt_delivery_task_state "$number" 2>/dev/null)" || return 0
|
|
221
|
-
[ -z "$state" ] && return 0
|
|
222
|
-
|
|
223
|
-
printf '%s' "$state" | jq -e '.exists' >/dev/null 2>&1 \
|
|
224
|
-
|| fault "${where} refers to the task #${number}, which does not exist. Check the number or create the task — ${task_new}."
|
|
225
|
-
printf '%s' "$state" | jq -e '.open' >/dev/null 2>&1 \
|
|
226
|
-
|| fault "the task #${number} is closed, and a task has one branch. Work behind a closed task is created as a new task — ${task_new}."
|
|
227
|
-
printf '%s' "$state" | jq -e '.onBoard' >/dev/null 2>&1 \
|
|
228
|
-
|| fault "the task #${number} is not in the work queue — the edit behind it is invisible. The queue is not bound to the repository and does not take a task by itself; add it and check — ${board_check}."
|
|
229
|
-
printf '%s' "$state" | jq -e '.assigned' >/dev/null 2>&1 \
|
|
230
|
-
|| fault "the task #${number} has no assignee — by the work queue there is no seeing who took it. Set the assignee${task_bot:+: }${task_bot}."
|
|
231
|
-
printf '%s' "$state" | jq -e '.numbered' >/dev/null 2>&1 \
|
|
232
|
-
|| fault "the title of the task #${number} does not start with its number — one work would have to be recognised by the text of the title. Fix the title and check the queue — ${board_check}."
|
|
233
|
-
|
|
234
|
-
# The task column. The work queue answer has been giving it for a long time, and nobody read it:
|
|
235
|
-
# the column was judged only by the queue audit, that is, already after the PR is opened. A task
|
|
236
|
-
# left in the first column reads through the queue as not taken — while the work is done and put
|
|
237
|
-
# out.
|
|
238
|
-
if [ -n "$backlog_column" ] && [ "$judge_column" = "yes" ]; then
|
|
239
|
-
column="$(printf '%s' "$state" | jq -r '.status // empty' 2>/dev/null)"
|
|
240
|
-
[ "$column" = "$backlog_column" ] \
|
|
241
|
-
&& fault "the task #${number} stands in the column «${column}» — by the work queue it is not taken, though the work on it is going. Move it: ${task_move}."
|
|
242
|
-
fi
|
|
243
|
-
|
|
244
|
-
return 0
|
|
245
|
-
}
|
|
232
|
+
# The task checks live in a helper next door — `git-guard-delivery-task.sh`. No helper — the task is
|
|
233
|
+
# not judged, and the work goes on.
|
|
234
|
+
# shellcheck disable=SC1090
|
|
235
|
+
[ -f "$rt_hooks_dir/git-guard-delivery-task.sh" ] && . "$rt_hooks_dir/git-guard-delivery-task.sh" 2>/dev/null
|
|
236
|
+
command -v check_task >/dev/null 2>&1 || check_task() { :; }
|
|
246
237
|
|
|
247
238
|
# The signature of a new branch and of a push live in one helper, so it is sourced before both.
|
|
248
239
|
# shellcheck disable=SC1090
|
|
@@ -261,15 +252,20 @@ if [ -n "$branch_arg" ]; then
|
|
|
261
252
|
# not a deliberate task-less branch. Caught before the first commit.
|
|
262
253
|
# The number is extracted by the profile: with its own regex the branch `feat/88-slug` gave no
|
|
263
254
|
# number at all.
|
|
255
|
+
#
|
|
256
|
+
# The name is one fault among the others, not a refusal of its own: refused alone, a fixed name
|
|
257
|
+
# met the task checks only on the second call, and the first refusal named a branch the second
|
|
258
|
+
# one refused again.
|
|
264
259
|
number_arg="$(rt_task_branch_number "$branch_arg")"
|
|
265
260
|
if [ -n "$number_arg" ]; then
|
|
266
261
|
rt_delivery_branch_form_ok "$branch_arg" \
|
|
267
|
-
||
|
|
262
|
+
|| unmet_class branch_create_bad_name "the branch name «${branch_arg}» is not of the form accepted here. The branch number is the same as the number of the task and of the title of the merge request."
|
|
268
263
|
state=''
|
|
269
264
|
check_task "$number_arg" "the branch «${branch_arg}»"
|
|
270
265
|
# The epic of the task: with one, the base is judged against the branch of the epic, and the
|
|
271
266
|
# freshness of the main branch moves there too — see `git-guard-delivery-epic.sh`.
|
|
272
267
|
epic_arg="$(printf '%s' "$state" | jq -r '.epic // empty' 2>/dev/null)"
|
|
268
|
+
[ -n "$epic_arg" ] && fact task_in_epic yes
|
|
273
269
|
|
|
274
270
|
# The delivery conditions already known here are checked here. After the work is done, the
|
|
275
271
|
# base is fixed by a merge with conflict resolution, and the commit signature by rewriting
|
|
@@ -280,30 +276,29 @@ if [ -n "$branch_arg" ]; then
|
|
|
280
276
|
# base fresh — `git checkout -b <branch> origin/<main>` — would be forbidden.
|
|
281
277
|
base_arg="$(printf '%s' "$cmd" | sed -nE 's/.*git[[:space:]]+(checkout([[:space:]]+-[A-Za-z-]+)*[[:space:]]+-b|switch([[:space:]]+-[A-Za-z-]+)*[[:space:]]+-c)[[:space:]]+[^[:space:];&|]+[[:space:]]+([^[:space:];&|-][^[:space:];&|]*).*/\4/p' | head -1)"
|
|
282
278
|
base_ref="${base_arg:-HEAD}"
|
|
283
|
-
command -v
|
|
279
|
+
command -v rt_assignment_unmet >/dev/null 2>&1 && rt_assignment_unmet "$epic_arg" "the branch «${branch_arg}»"
|
|
284
280
|
if [ -n "$epic_arg" ] && command -v rt_epic_base >/dev/null 2>&1; then
|
|
285
281
|
rt_epic_base "$epic_arg" "$base_ref" "$branch_arg"
|
|
286
282
|
elif git rev-parse --verify --quiet "refs/remotes/origin/${main_branch}" >/dev/null 2>&1 \
|
|
287
283
|
&& git rev-parse --verify --quiet "$base_ref" >/dev/null 2>&1 \
|
|
288
284
|
&& ! git merge-base --is-ancestor "origin/${main_branch}" "$base_ref" 2>/dev/null; then
|
|
289
285
|
behind="$(git rev-list --count "${base_ref}..origin/${main_branch}" 2>/dev/null)"
|
|
290
|
-
|
|
286
|
+
unmet_class branch_create_stale_base "the branch will grow from a base that does not carry the tip of «${main_branch}» — it has moved ahead by ${behind:-several} commits. Take a fresh base: git fetch origin && git checkout -b ${branch_arg} origin/${main_branch}."
|
|
291
287
|
fi
|
|
292
288
|
|
|
293
289
|
# The second tier: the local reference to the main branch could itself have gone stale, and
|
|
294
290
|
# then the silence of the first tier means "the base is not older than my reference", not
|
|
295
291
|
# "the base is fresh". No answer — the tier stays silent, as everywhere the guard goes to
|
|
296
292
|
# the network.
|
|
297
|
-
remote_head="$(
|
|
298
|
-
git ls-remote origin "refs/heads/${main_branch}" 2>/dev/null | cut -f1)"
|
|
293
|
+
remote_head="$(rt_fact_remote_head "$main_branch")"
|
|
299
294
|
local_head="$(git rev-parse --verify --quiet "refs/remotes/origin/${main_branch}" 2>/dev/null)"
|
|
300
295
|
if [ -n "$remote_head" ] && [ -n "$local_head" ] && [ "$remote_head" != "$local_head" ]; then
|
|
301
|
-
|
|
296
|
+
unmet origin_main_fresh no "your ref origin/${main_branch} lags behind the remote one — ${local_head:0:8} against ${remote_head:0:8}. The branch will grow from yesterday tree, and the owner sees that at the opening of the request. Pull and repeat: git fetch origin."
|
|
302
297
|
fi
|
|
303
298
|
|
|
304
299
|
command -v rt_delivery_branch_signature >/dev/null 2>&1 && rt_delivery_branch_signature
|
|
305
300
|
|
|
306
|
-
|
|
301
|
+
refuse_unmet branch_create
|
|
307
302
|
fi
|
|
308
303
|
# A branch without a number is lawful and lives locally: no PR opens from it.
|
|
309
304
|
exit 0
|
|
@@ -338,7 +333,7 @@ if printf '%s' "$cmd" | grep -qE "${RT_CMD_BOUND}(gh[[:space:]]+pr[[:space:]]+me
|
|
|
338
333
|
# The run on the tip goes first: the folder tier below leaves the guard early on many paths.
|
|
339
334
|
[ -f "$rt_hooks_dir/git-guard-delivery-merge.sh" ] && . "$rt_hooks_dir/git-guard-delivery-merge.sh" 2>/dev/null
|
|
340
335
|
command -v rt_delivery_merge_run >/dev/null 2>&1 && rt_delivery_merge_run
|
|
341
|
-
|
|
336
|
+
refuse_unmet pr_merge
|
|
342
337
|
rt_delivery_merge_folder
|
|
343
338
|
fi
|
|
344
339
|
|
|
@@ -354,8 +349,16 @@ branch="$(rt_delivery_current_branch)"
|
|
|
354
349
|
|
|
355
350
|
# A local branch without a number is lawful, and a PR from it is not: an edit that travels to the
|
|
356
351
|
# main branch starts from a task. This is the only place where a task-less branch runs into a wall.
|
|
357
|
-
|
|
358
|
-
|
|
352
|
+
#
|
|
353
|
+
# The move named here takes work, and the assignment of the copy judges every such move: with no
|
|
354
|
+
# assignment the creation of the task is refused in its turn. So the assignment is asked here too,
|
|
355
|
+
# and what it lacks is named before the creation.
|
|
356
|
+
if ! rt_delivery_branch_form_ok "$branch"; then
|
|
357
|
+
command -v rt_assignment_unmet >/dev/null 2>&1 && rt_assignment_unmet '' 'a new task'
|
|
358
|
+
fact branch_is_task_branch no
|
|
359
|
+
refuse pr_create "$(jq -cn --arg b "$branch" --arg t "$task_new" --arg f "${faults:+ Before the creation:
|
|
360
|
+
${faults}}" '{branch_name:$b, task_new:$t, before:$f}')"
|
|
361
|
+
fi
|
|
359
362
|
|
|
360
363
|
number="$(rt_task_branch_number "$branch")"
|
|
361
364
|
|
|
@@ -365,6 +368,14 @@ number="$(rt_task_branch_number "$branch")"
|
|
|
365
368
|
state=''
|
|
366
369
|
check_task "$number" "the request from the branch «${branch}»" yes
|
|
367
370
|
epic_pull="$(printf '%s' "$state" | jq -r '.epic // empty' 2>/dev/null)"
|
|
371
|
+
[ -n "$epic_pull" ] && fact task_in_epic yes
|
|
372
|
+
# A fault that names the creation of a task or the move of its column names a move that takes work,
|
|
373
|
+
# and the assignment of the copy judges every such move. Its lack is named in the same list.
|
|
374
|
+
case "$faults" in
|
|
375
|
+
*"$task_new"* | *"$task_move"*)
|
|
376
|
+
command -v rt_assignment_unmet >/dev/null 2>&1 && rt_assignment_unmet '' 'the work the fixes above take'
|
|
377
|
+
;;
|
|
378
|
+
esac
|
|
368
379
|
# The branch of an epic itself: its request goes into the main branch, and it opens only when the
|
|
369
380
|
# folders of all its tasks are taken apart.
|
|
370
381
|
command -v rt_epic_own_pull >/dev/null 2>&1 && rt_epic_own_pull "$state"
|
|
@@ -384,7 +395,7 @@ fi
|
|
|
384
395
|
|
|
385
396
|
if [ -n "$title" ]; then
|
|
386
397
|
printf '%s' "$title" | grep -qE "$title_re" \
|
|
387
|
-
||
|
|
398
|
+
|| unmet_class pr_create_bad_title "the title of the request does not start with the number of the task. In the list of requests the body is invisible, and the line of the link lives exactly there — without the number in the title the PR cannot be matched to the task."
|
|
388
399
|
# The number is extracted from the part of the title the form itself recognised, not by a second
|
|
389
400
|
# regex next to it. The own regex knows only the package form: a tree that paved the form over
|
|
390
401
|
# with its own got an empty number — and the check of the title number against the branch number
|
|
@@ -393,7 +404,7 @@ if [ -n "$title" ]; then
|
|
|
393
404
|
title_number="$(printf '%s' "$title_matched" | grep -oE '[A-Za-z]+-[0-9]+' | head -1 | sed -E 's/^[A-Za-z]+-//')"
|
|
394
405
|
if [ -n "$number" ] && [ -n "$title_number" ]; then
|
|
395
406
|
[ "$title_number" = "$number" ] \
|
|
396
|
-
||
|
|
407
|
+
|| unmet_class pr_create_wrong_number "the title of the request carries the number ${title_number}, the branch — ${number}. The task, the branch and the PR carry one and the same number."
|
|
397
408
|
fi
|
|
398
409
|
fi
|
|
399
410
|
|
|
@@ -412,13 +423,12 @@ if [ -n "$epic_pull" ] && command -v rt_epic_pull_base >/dev/null 2>&1; then
|
|
|
412
423
|
elif git rev-parse --verify --quiet "refs/remotes/origin/${main_branch}" >/dev/null 2>&1 \
|
|
413
424
|
&& ! git merge-base --is-ancestor "origin/${main_branch}" HEAD 2>/dev/null; then
|
|
414
425
|
behind="$(git rev-list --count "HEAD..origin/${main_branch}" 2>/dev/null)"
|
|
415
|
-
|
|
426
|
+
unmet branch_has_main_tip no "«${main_branch}» has moved ahead by ${behind:-several} commits and is not merged into the branch. A PR from a diverged branch shows the reviewer the edit mixed with someone else, and the checks on it run from a stale base. Merge it in and repeat: git fetch origin && git merge origin/${main_branch} — the order and the resolving of the conflict are in the pattern git-workflow-merge."
|
|
416
427
|
fi
|
|
417
428
|
|
|
418
429
|
# The second tier: the local reference could itself have gone stale. No answer — the tier stays
|
|
419
430
|
# silent.
|
|
420
|
-
remote_main="$(
|
|
421
|
-
git ls-remote origin "refs/heads/${main_branch}" 2>/dev/null | cut -f1)"
|
|
431
|
+
remote_main="$(rt_fact_remote_head "$main_branch")"
|
|
422
432
|
local_main="$(git rev-parse --verify --quiet "refs/remotes/origin/${main_branch}" 2>/dev/null)"
|
|
423
433
|
if [ -n "$remote_main" ] && [ -n "$local_main" ] && [ "$remote_main" != "$local_main" ]; then
|
|
424
434
|
# The age of the reference is what the executor does not see at all, and it is exactly what
|
|
@@ -430,7 +440,7 @@ if [ -n "$remote_main" ] && [ -n "$local_main" ] && [ "$remote_main" != "$local_
|
|
|
430
440
|
if [ -n "$fetched_at" ]; then
|
|
431
441
|
age=" The last git fetch was $(( ( $(date +%s) - fetched_at ) / 60 )) min ago."
|
|
432
442
|
fi
|
|
433
|
-
|
|
443
|
+
unmet origin_main_fresh no "your ref origin/${main_branch} lags behind the remote one — ${local_main:0:8} against ${remote_main:0:8}.${age} The guard compares the branch with what lies in the tree, so silence of the first tier means «the ref is not older than the branch», not «the main branch is merged in». Merge it in and repeat: git fetch origin && git merge origin/${main_branch}."
|
|
434
444
|
fi
|
|
435
445
|
|
|
436
446
|
# The identity of the call. The hosting client holds two accounts — the logged-in one and the one
|
|
@@ -454,7 +464,7 @@ command -v rt_pull_token_login >/dev/null 2>&1 && token_login="$(rt_pull_token_l
|
|
|
454
464
|
|
|
455
465
|
if [ -n "$token_login" ]; then
|
|
456
466
|
if [ -n "$pull_reviewer" ] && [ "$token_login" = "$pull_reviewer" ]; then
|
|
457
|
-
|
|
467
|
+
unmet_class pr_create_self_review "the request would be opened by the account «${token_login}», and the same one is named as its reviewer. The hosting accepts such a review request and silently does not create it, and the author of a request cannot be changed — it is fixed only by reopening. Open it by another account${pull_token_hint:+, substituting the token: ${pull_token_hint} …}, or name another reviewer."
|
|
458
468
|
elif [ -n "$task_bot" ] && [ "$token_login" != "$task_bot" ]; then
|
|
459
469
|
# Not a refusal: the reviewer is somebody else, and the review will be created. But silence
|
|
460
470
|
# about a foreign account is indistinguishable from a check that did not fire at all.
|
|
@@ -464,7 +474,7 @@ elif [ -n "$pull_token_var" ] \
|
|
|
464
474
|
&& ! printf '%s' "$cmd" | grep -qE "(^|[;&|(]|&&|\|\||[[:space:]])${pull_token_var}="; then
|
|
465
475
|
# There is nothing to learn the author by — no helper, or an empty answer from it. Then the only
|
|
466
476
|
# lawful call is the one that names the account in its own text.
|
|
467
|
-
|
|
477
|
+
unmet_class pr_create_self_review "who will open the request cannot be learned: the hosting was not asked, and the command carries no substitution of «${pull_token_var}». Opened by the logged-in account, the request may come out from the very person named as its reviewer, and that is fixed only by reopening.${pull_token_hint:+ Substitute the token: ${pull_token_hint} …}"
|
|
468
478
|
fi
|
|
469
479
|
|
|
470
480
|
# The body of the request: the section about the remaining step and the line that closes the task.
|
|
@@ -473,15 +483,16 @@ fi
|
|
|
473
483
|
[ -f "$rt_hooks_dir/git-guard-delivery-body.sh" ] && . "$rt_hooks_dir/git-guard-delivery-body.sh" 2>/dev/null
|
|
474
484
|
command -v rt_delivery_pull_body >/dev/null 2>&1 && rt_delivery_pull_body
|
|
475
485
|
|
|
476
|
-
# The task folder is taken apart before the PR opens
|
|
477
|
-
#
|
|
478
|
-
# travelled into the main branch without being taken apart. After the cleanup the progress guard
|
|
479
|
-
# takes the plan from the branch history.
|
|
486
|
+
# The task folder is taken apart before the PR opens: the owner merges on green, with no room left
|
|
487
|
+
# for a closing commit. After the cleanup the progress guard takes the plan from the branch history.
|
|
480
488
|
rt_delivery_open_folder
|
|
489
|
+
# Every done step is measured once more: a mark written past the engine stops here.
|
|
490
|
+
# shellcheck disable=SC1090
|
|
491
|
+
[ -f "$rt_hooks_dir/git-guard-delivery-rerun.sh" ] && . "$rt_hooks_dir/git-guard-delivery-rerun.sh" 2>/dev/null
|
|
492
|
+
command -v rt_delivery_rerun >/dev/null 2>&1 && rt_delivery_rerun
|
|
481
493
|
|
|
482
|
-
# Everything that did not come together is named here
|
|
483
|
-
|
|
484
|
-
deny_faults
|
|
494
|
+
# Everything that did not come together is named here at once, not one condition per call.
|
|
495
|
+
refuse_unmet pr_create
|
|
485
496
|
command -v rt_delivery_open_handover >/dev/null 2>&1 && rt_delivery_open_handover "$cmd" "$branch"
|
|
486
497
|
|
|
487
498
|
exit 0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# rt-hook: PreToolUse Bash|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_tool
|
|
3
|
-
# Requires: hooks/deny-tail.sh, hooks/guard-note.sh
|
|
3
|
+
# Requires: checks/decide.mjs, hooks/decide.sh, hooks/facts.sh, hooks/deny-tail.sh, hooks/guard-note.sh
|
|
4
4
|
# Guard of the working tree. PreToolUse on a git command that throws uncommitted edits away.
|
|
5
5
|
#
|
|
6
6
|
# `git reset --hard`, `git checkout -- <path>`, `git restore <path>` and `git clean -f` erase what
|
|
@@ -125,21 +125,11 @@ files="$(printf '%s\n' "$changed" | sed 's/^...//' | head -20 | sed 's/^/ /')
|
|
|
125
125
|
… and $((count - 20)) more"
|
|
126
126
|
what="$(printf '%s\n' "$hits" | sort -u | paste -sd ',' - | sed 's/,/, /g')"
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
$
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
&& . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
|
|
136
|
-
command -v rt_deny_tail >/dev/null 2>&1 || rt_deny_tail() { :; }
|
|
137
|
-
deny_tail_text="$(rt_deny_tail 'the comment `# discard: <reason>` in the same command, the erased files named in the reason')"
|
|
138
|
-
[ -n "$deny_tail_text" ] && reason="${reason}
|
|
139
|
-
|
|
140
|
-
${deny_tail_text}"
|
|
141
|
-
|
|
142
|
-
jq -n --arg r "$reason" '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:$r}}' 2>/dev/null \
|
|
143
|
-
|| printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"A discarding git command on a dirty working tree is refused. Commit or name the edits first."}}\n'
|
|
144
|
-
|
|
128
|
+
# The decision and its text come from the decision table; the hook names the state and the files.
|
|
129
|
+
params="$(jq -cn --arg w "$what" --arg c "$count" --arg f "$files" \
|
|
130
|
+
--arg b 'the comment `# discard: <reason>` in the same command, the erased files named in the reason' \
|
|
131
|
+
'{what:$w, count:$c, files:$f, bypass:$b}')"
|
|
132
|
+
# shellcheck disable=SC1091
|
|
133
|
+
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/decide.sh" 2>/dev/null
|
|
134
|
+
command -v rt_decide >/dev/null 2>&1 && rt_decide git-guard-discard.sh discard '{"tree_dirty":"yes"}' "$params"
|
|
145
135
|
exit 0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# rt-hook: PreToolUse Bash|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_tool
|
|
3
|
-
# Requires: hooks/deny-tail.sh, hooks/guard-note.sh
|
|
3
|
+
# Requires: checks/decide.mjs, hooks/decide.sh, hooks/facts.sh, hooks/deny-tail.sh, hooks/guard-note.sh
|
|
4
4
|
# Guard of the main branch. PreToolUse on a commit call.
|
|
5
5
|
#
|
|
6
6
|
# A commit into the main branch bypasses the branch, the PR and the review, while delivery is built
|
|
@@ -97,7 +97,9 @@ cd "$workdir" 2>/dev/null || exit 0
|
|
|
97
97
|
|
|
98
98
|
git rev-parse --is-inside-work-tree >/dev/null 2>&1 || exit 0
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
# shellcheck disable=SC1091
|
|
101
|
+
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/facts.sh" 2>/dev/null
|
|
102
|
+
branch="$(rt_fact_branch)"
|
|
101
103
|
[ -z "$branch" ] && exit 0 # a detached HEAD is not about this case
|
|
102
104
|
|
|
103
105
|
# The name is read from the tree's own profile — the one the commit runs in — as the other delivery
|
|
@@ -113,7 +115,7 @@ declared="$(
|
|
|
113
115
|
)"
|
|
114
116
|
|
|
115
117
|
default="$declared"
|
|
116
|
-
[ -z "$default" ] && default="$(
|
|
118
|
+
[ -z "$default" ] && default="$(rt_fact_default_branch)"
|
|
117
119
|
if [ -z "$default" ]; then
|
|
118
120
|
for candidate in main master; do
|
|
119
121
|
if git show-ref --verify --quiet "refs/remotes/origin/$candidate" 2>/dev/null; then
|
|
@@ -126,20 +128,12 @@ fi
|
|
|
126
128
|
|
|
127
129
|
[ "$branch" = "$default" ] || exit 0
|
|
128
130
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
command -v
|
|
137
|
-
deny_tail_text="$(rt_deny_tail "")"
|
|
138
|
-
[ -n "$deny_tail_text" ] && reason="${reason}
|
|
139
|
-
|
|
140
|
-
${deny_tail_text}"
|
|
141
|
-
|
|
142
|
-
jq -n --arg r "$reason" '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:$r}}' 2>/dev/null \
|
|
143
|
-
|| printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"A commit into the main branch is refused. Create a branch."}}\n'
|
|
144
|
-
|
|
131
|
+
# The decision and its text come from the decision table. Whether the rule of delivery is loaded is
|
|
132
|
+
# a fact of the state as the table writes it; an unloaded rule is refused first by the rules gate.
|
|
133
|
+
sid="$(printf '%s' "$RT_HOOK_INPUT" | jq -r '.session_id // "nosession"' 2>/dev/null)"
|
|
134
|
+
facts="$(jq -cn --arg r "$(rt_fact_rule_loaded git-workflow "$sid")" '{rule_loaded:$r, branch_is_main:"yes"}')"
|
|
135
|
+
params="$(jq -cn --arg m "$default" '{main_branch:$m}')"
|
|
136
|
+
# shellcheck disable=SC1091
|
|
137
|
+
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/decide.sh" 2>/dev/null
|
|
138
|
+
command -v rt_decide >/dev/null 2>&1 && rt_decide git-guard-main.sh "?commit" "$facts" "$params"
|
|
145
139
|
exit 0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# rt-hook: PreToolUse Bash|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_tool
|
|
3
|
-
# Requires: hooks/deny-tail.sh, hooks/guard-note.sh
|
|
3
|
+
# Requires: checks/decide.mjs, hooks/decide.sh, hooks/facts.sh, hooks/facts-docs.sh, hooks/git-guard-delivery-signature.sh, hooks/deny-tail.sh, hooks/guard-note.sh
|
|
4
4
|
# Guard of the commit hooks. PreToolUse on a git commit or push that skips the tree's git hooks.
|
|
5
5
|
#
|
|
6
6
|
# The commit hooks check the message, the formatting and the document pair; the push gate does not
|
|
@@ -124,20 +124,60 @@ hits="$(printf '%s\n' "$cmd" | awk -v sq="'" '
|
|
|
124
124
|
|
|
125
125
|
what="$(printf '%s\n' "$hits" | sed 's/^/git /' | paste -sd ',' - | sed 's/,/, /g')"
|
|
126
126
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
#
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
127
|
+
# The decision, the move and the text come from the decision table. The same command without the skip
|
|
128
|
+
# meets the other delivery guards, and the refusal names what they refuse it for first: a commit on
|
|
129
|
+
# the main branch, a commit while the contribution carries a foreign signature, the document pair and
|
|
130
|
+
# the exam the commit waits for, a push while the heavy steps have no green mark. The hook gathers the
|
|
131
|
+
# facts of that state; the decider composes the words.
|
|
132
|
+
rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
133
|
+
# shellcheck disable=SC1091
|
|
134
|
+
. "$rt_hooks_dir/facts.sh" 2>/dev/null
|
|
135
|
+
command -v rt_fact_branch >/dev/null 2>&1 || exit 0
|
|
136
|
+
sid="$(printf '%s' "$input" | jq -r '.session_id // "nosession"' 2>/dev/null)"
|
|
137
|
+
record="$(rt_fact_transcript "$input")"
|
|
138
|
+
main_branch=main
|
|
139
|
+
on_main=no
|
|
140
|
+
signed=yes
|
|
141
|
+
signature=''
|
|
142
|
+
doc_pair=yes
|
|
143
|
+
problems=''
|
|
144
|
+
workdir="$(rt_hook_cwd)"
|
|
145
|
+
[ -z "$workdir" ] && workdir="${CLAUDE_PROJECT_DIR:-.}"
|
|
146
|
+
if cd "$workdir" 2>/dev/null && git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
|
147
|
+
root="${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}"
|
|
148
|
+
for profile in "$rt_hooks_dir/../rt-kit/defaults/project.sh" "$rt_hooks_dir/../defaults/project.sh" "$root/.claude/rt-kit/defaults/project.sh" "$root/.claude/rt-kit/project.sh"; do
|
|
149
|
+
# shellcheck disable=SC1090
|
|
150
|
+
[ -f "$profile" ] && . "$profile" >/dev/null 2>&1 </dev/null
|
|
151
|
+
done
|
|
152
|
+
commit_email="${RT_COMMIT_EMAIL:-}"
|
|
153
|
+
main_branch="${RT_MAIN_BRANCH:-main}"
|
|
154
|
+
if printf '%s\n' "$hits" | grep -q '^commit'; then
|
|
155
|
+
plain="$(printf '%s' "$cmd" | sed -E 's/[[:space:]](--no-verify|--no-verif|--no-veri|-n)([[:space:]]|$)/ /g')"
|
|
156
|
+
if [ "$(rt_fact_branch)" = "$main_branch" ]; then
|
|
157
|
+
on_main=yes
|
|
158
|
+
else
|
|
159
|
+
# shellcheck disable=SC1091
|
|
160
|
+
[ -f "$rt_hooks_dir/git-guard-delivery-signature.sh" ] && . "$rt_hooks_dir/git-guard-delivery-signature.sh" 2>/dev/null
|
|
161
|
+
command -v rt_signature_commit_note >/dev/null 2>&1 && signature="$(rt_signature_commit_note)"
|
|
162
|
+
[ -n "$signature" ] && signed=no
|
|
163
|
+
# shellcheck disable=SC1091
|
|
164
|
+
[ -f "$rt_hooks_dir/facts-docs.sh" ] && . "$rt_hooks_dir/facts-docs.sh" 2>/dev/null
|
|
165
|
+
if command -v rt_fact_doc_problems >/dev/null 2>&1 && rt_fact_doc_problems "$plain"; then
|
|
166
|
+
[ -n "$problems" ] && doc_pair=no
|
|
167
|
+
fi
|
|
168
|
+
fi
|
|
169
|
+
fi
|
|
170
|
+
fi
|
|
142
171
|
|
|
172
|
+
action=push_skip_hooks
|
|
173
|
+
printf '%s\n' "$hits" | grep -q '^commit' && action=commit_skip_hooks
|
|
174
|
+
facts="$(jq -cn --arg r "$(rt_fact_rule_loaded git-workflow "$sid")" --arg m "$on_main" --arg s "$signed" --arg d "$doc_pair" \
|
|
175
|
+
--arg e "$(rt_fact_exam_holds "$record")" --arg w "$(rt_fact_window_over_stop "$sid" "$record")" \
|
|
176
|
+
'{rule_loaded:$r, branch_is_main:$m, commits_signed_declared:$s, doc_pair:$d, exam:$e, window_over_stop:$w}')"
|
|
177
|
+
params="$(jq -cn --arg w "$what" --arg m "$main_branch" --arg s "$signature" --arg p "$problems" \
|
|
178
|
+
--arg a "bash ${rt_hooks_dir#"$PWD"/}/git-guard-push-ahead.sh" \
|
|
179
|
+
'{what:$w, main_branch:$m, signature:$s, problems:$p, ahead_cmd:$a}')"
|
|
180
|
+
# shellcheck disable=SC1091
|
|
181
|
+
. "$rt_hooks_dir/decide.sh" 2>/dev/null
|
|
182
|
+
command -v rt_decide >/dev/null 2>&1 && rt_decide git-guard-no-verify.sh "$action" "$facts" "$params"
|
|
143
183
|
exit 0
|