@rt-tools/agent-kit 0.37.1 → 0.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/assets/checks/action-of.mjs +154 -0
- package/assets/checks/board-runs.github.mjs +40 -5
- package/assets/checks/check-board.github.mjs +38 -7
- package/assets/checks/check-state-next.mjs +22 -10
- package/assets/checks/check-turn-map.mjs +26 -6
- package/assets/checks/check-work-steps.mjs +4 -173
- package/assets/checks/decide.mjs +285 -0
- package/assets/checks/decision-table.json +21432 -0
- package/assets/checks/decision-table.mjs +495 -0
- package/assets/checks/epic-window.mjs +98 -0
- package/assets/checks/flow-condition.mjs +64 -0
- package/assets/checks/flow-data.mjs +135 -0
- package/assets/checks/flow-forecast.mjs +334 -0
- package/assets/checks/flow-guard-run.mjs +90 -0
- package/assets/checks/flow-guard.mjs +496 -0
- package/assets/checks/flow-model.mjs +271 -0
- package/assets/checks/flow-override.mjs +130 -0
- package/assets/checks/flow-plan.mjs +206 -0
- package/assets/checks/flow-scaffold.mjs +224 -0
- package/assets/checks/flow-step.mjs +495 -0
- package/assets/checks/flow-sync.mjs +296 -0
- package/assets/checks/flow-syntax.mjs +292 -0
- package/assets/checks/flow-verdict.mjs +227 -0
- package/assets/checks/merge-read.mjs +239 -0
- package/assets/checks/owner-nudges.mjs +389 -0
- package/assets/checks/push-inputs.mjs +59 -16
- package/assets/checks/record-count.mjs +437 -0
- package/assets/checks/record-recount.mjs +187 -0
- package/assets/checks/record-turn.mjs +155 -0
- package/assets/checks/task-flow-script.mjs +318 -0
- package/assets/checks/tree-assignment.mjs +26 -7
- package/assets/checks/work-result.mjs +362 -0
- package/assets/checks/work-steps-lib.mjs +205 -0
- package/assets/commands/night.md +6 -6
- package/assets/defaults/gate-map.sh +39 -12
- package/assets/defaults/merges.sh +48 -0
- package/assets/defaults/project.sh +6 -5
- package/assets/defaults/turn-map.md +23 -22
- package/assets/docs/GLOSSARY.md +5 -1
- package/assets/hooks/ask-judge.md +67 -0
- package/assets/hooks/browser-guard-device-id.sh +11 -9
- package/assets/hooks/browser-guard-no-asking.sh +12 -6
- package/assets/hooks/browser-guard-no-listing.sh +13 -7
- package/assets/hooks/browser-guard-no-other-drivers.sh +25 -17
- package/assets/hooks/browser-guard-require-select.sh +15 -15
- package/assets/hooks/commit-msg.sh +13 -3
- package/assets/hooks/conscience-guard.sh +9 -25
- package/assets/hooks/decide.sh +141 -0
- package/assets/hooks/deny-tail.sh +16 -11
- package/assets/hooks/dev-server-guard.sh +27 -20
- package/assets/hooks/dispatch.sh +47 -4
- package/assets/hooks/docs-guard.sh +31 -200
- package/assets/hooks/end-conversation-guard.sh +12 -21
- package/assets/hooks/epic-stop-guard.sh +54 -152
- package/assets/hooks/exam-guard.sh +32 -65
- package/assets/hooks/facts-docs.sh +221 -0
- package/assets/hooks/facts-flow.sh +173 -0
- package/assets/hooks/facts.sh +374 -0
- package/assets/hooks/flow-step-guard.sh +93 -0
- package/assets/hooks/git-guard-delivery-body.sh +4 -4
- package/assets/hooks/git-guard-delivery-conflict.sh +16 -10
- package/assets/hooks/git-guard-delivery-draft.sh +3 -3
- package/assets/hooks/git-guard-delivery-epic.sh +18 -9
- package/assets/hooks/git-guard-delivery-folder.sh +32 -7
- package/assets/hooks/git-guard-delivery-merge.sh +2 -2
- package/assets/hooks/git-guard-delivery-merged.sh +12 -1
- package/assets/hooks/git-guard-delivery-pipeline.sh +1 -1
- package/assets/hooks/git-guard-delivery-rerun.sh +44 -0
- package/assets/hooks/git-guard-delivery-signature.sh +82 -45
- package/assets/hooks/git-guard-delivery-task.sh +47 -0
- package/assets/hooks/git-guard-delivery.sh +112 -101
- package/assets/hooks/git-guard-discard.sh +8 -18
- package/assets/hooks/git-guard-main.sh +13 -19
- package/assets/hooks/git-guard-no-verify.sh +56 -16
- package/assets/hooks/git-guard-push-ahead.sh +39 -6
- package/assets/hooks/git-guard-push-marks.sh +262 -13
- package/assets/hooks/git-guard-push-tests.sh +58 -52
- package/assets/hooks/git-guard-tree-assignment.sh +7 -4
- package/assets/hooks/guard-note.sh +8 -6
- package/assets/hooks/handoff-entry-guard.sh +19 -38
- package/assets/hooks/handoff-write.sh +3 -1
- package/assets/hooks/hook-input.sh +0 -41
- package/assets/hooks/metric-marks.sh +19 -7
- package/assets/hooks/observe.sh +1 -1
- package/assets/hooks/override-write-guard.sh +27 -9
- package/assets/hooks/pre-push.sh +40 -12
- package/assets/hooks/prose-style-guard.sh +6 -19
- package/assets/hooks/pull-merges.sh +76 -0
- package/assets/hooks/push-ahead-call-guard.sh +447 -0
- package/assets/hooks/push-set.sh +38 -8
- package/assets/hooks/qa-dataid-guard.sh +7 -17
- package/assets/hooks/record-turn.sh +52 -0
- package/assets/hooks/rerun-guard.sh +11 -16
- package/assets/hooks/reuse-first-guard.sh +7 -21
- package/assets/hooks/role-calls.sh +25 -3
- package/assets/hooks/rule-source-guard.sh +54 -21
- package/assets/hooks/skill-gate-rearm.sh +18 -5
- package/assets/hooks/skill-gate.sh +156 -20
- package/assets/hooks/skill-loaded.sh +18 -3
- package/assets/hooks/sql-guard-target.sh +2 -2
- package/assets/hooks/sql-guard-write.sh +12 -12
- package/assets/hooks/sql-guard.sh +58 -16
- package/assets/hooks/task-context-load.sh +3 -1
- package/assets/hooks/task-flow-context.sh +5 -18
- package/assets/hooks/task-flow-draft-guard.sh +25 -74
- package/assets/hooks/task-flow-guard.sh +28 -130
- package/assets/hooks/tree-assignment-guard.sh +25 -14
- package/assets/hooks/turn-entry-load.sh +3 -1
- package/assets/hooks/turn-exit-guard.sh +92 -452
- package/assets/hooks/turn-exit-role.sh +3 -1
- package/assets/hooks/turn-judge.md +113 -0
- package/assets/hooks/window-fill-guard.sh +22 -41
- package/assets/patterns/doc-style-human.md +36 -76
- package/assets/patterns/git-workflow-commit.azure.md +9 -155
- package/assets/patterns/git-workflow-commit.github.md +11 -269
- package/assets/patterns/git-workflow-commit.gitlab.md +9 -161
- package/assets/patterns/git-workflow-docker.md +8 -231
- package/assets/patterns/git-workflow-freshness.md +8 -56
- package/assets/patterns/git-workflow-merge.md +6 -176
- package/assets/patterns/git-workflow-migration.md +5 -75
- package/assets/patterns/git-workflow-pr-body.github.md +6 -159
- package/assets/patterns/git-workflow-pr-ready.md +9 -70
- package/assets/patterns/git-workflow-pr.azure.md +13 -285
- package/assets/patterns/git-workflow-pr.github.md +13 -251
- package/assets/patterns/git-workflow-pr.gitlab.md +13 -286
- package/assets/patterns/git-workflow-restart.md +5 -42
- package/assets/patterns/git-workflow-secrets.md +10 -76
- package/assets/patterns/git-workflow-stack.md +7 -207
- package/assets/patterns/status-report-table.github.md +1 -1
- package/assets/patterns/task-flow-archive.md +12 -233
- package/assets/patterns/task-flow-close.md +16 -292
- package/assets/patterns/task-flow-cycle.md +13 -39
- package/assets/patterns/task-flow-graph.needs-graph.md +8 -62
- package/assets/patterns/task-flow-handoff.md +13 -161
- package/assets/patterns/task-flow-resume.md +18 -218
- package/assets/patterns/task-flow-start.md +9 -247
- package/assets/patterns/turn-entry-map.md +2 -2
- package/assets/pitfalls/agent-kit-extend.md +200 -0
- package/assets/pitfalls/agent-kit.2.md +323 -0
- package/assets/pitfalls/angular-patterns.md +98 -0
- package/assets/pitfalls/browser-verification.md +265 -0
- package/assets/pitfalls/component-structure.md +98 -0
- package/assets/pitfalls/dependencies.md +92 -0
- package/assets/pitfalls/deploy-flow.azure.md +171 -0
- package/assets/pitfalls/deploy-flow.github.md +211 -0
- package/assets/pitfalls/deploy-flow.gitlab.md +173 -0
- package/assets/pitfalls/doc-style-human.md +112 -0
- package/assets/pitfalls/doc-style.2.md +286 -0
- package/assets/pitfalls/entity-conventions.needs-admin.md +96 -0
- package/assets/pitfalls/entity-models.md +89 -0
- package/assets/pitfalls/epic-flow.md +92 -0
- package/assets/pitfalls/git-workflow-commit.azure.md +190 -0
- package/assets/pitfalls/git-workflow-commit.github.md +307 -0
- package/assets/pitfalls/git-workflow-commit.gitlab.md +196 -0
- package/assets/pitfalls/git-workflow-docker.md +275 -0
- package/assets/pitfalls/git-workflow-freshness.md +88 -0
- package/assets/pitfalls/git-workflow-hosting.azure.md +31 -0
- package/assets/pitfalls/git-workflow-hosting.github.md +32 -0
- package/assets/pitfalls/git-workflow-hosting.gitlab.md +31 -0
- package/assets/pitfalls/git-workflow-merge.md +220 -0
- package/assets/pitfalls/git-workflow-migration.md +103 -0
- package/assets/pitfalls/git-workflow-pr-body.github.md +185 -0
- package/assets/pitfalls/git-workflow-pr-ready.md +104 -0
- package/assets/pitfalls/git-workflow-pr.2.azure.md +172 -0
- package/assets/pitfalls/git-workflow-pr.2.github.md +184 -0
- package/assets/pitfalls/git-workflow-pr.2.gitlab.md +180 -0
- package/assets/pitfalls/git-workflow-pr.azure.md +159 -0
- package/assets/pitfalls/git-workflow-pr.github.md +107 -0
- package/assets/pitfalls/git-workflow-pr.gitlab.md +151 -0
- package/assets/pitfalls/git-workflow-push.azure.md +30 -0
- package/assets/pitfalls/git-workflow-push.github.md +30 -0
- package/assets/pitfalls/git-workflow-push.gitlab.md +30 -0
- package/assets/pitfalls/git-workflow-queue.azure.md +30 -0
- package/assets/pitfalls/git-workflow-queue.github.md +30 -0
- package/assets/pitfalls/git-workflow-queue.gitlab.md +30 -0
- package/assets/pitfalls/git-workflow-restart.md +72 -0
- package/assets/pitfalls/git-workflow-secrets.md +114 -0
- package/assets/pitfalls/git-workflow-stack.md +254 -0
- package/assets/pitfalls/git-workflow.2.azure.md +291 -0
- package/assets/pitfalls/git-workflow.2.github.md +294 -0
- package/assets/pitfalls/git-workflow.2.gitlab.md +278 -0
- package/assets/pitfalls/lib-layers.md +114 -0
- package/assets/pitfalls/lists.md +117 -0
- package/assets/pitfalls/mockups.needs-mockups.md +87 -0
- package/assets/pitfalls/navigation.md +94 -0
- package/assets/pitfalls/observability.needs-app.md +186 -0
- package/assets/pitfalls/platform-access.md +94 -0
- package/assets/pitfalls/queue-audit.github.md +78 -0
- package/assets/pitfalls/reuse-first.md +201 -0
- package/assets/pitfalls/spec-driven.2.md +318 -0
- package/assets/pitfalls/styling-bem.2.md +125 -0
- package/assets/pitfalls/task-flow-archive.md +265 -0
- package/assets/pitfalls/task-flow-close.2.md +166 -0
- package/assets/pitfalls/task-flow-close.md +167 -0
- package/assets/pitfalls/task-flow-cycle.md +73 -0
- package/assets/pitfalls/task-flow-graph.needs-graph.md +98 -0
- package/assets/pitfalls/task-flow-handoff.md +200 -0
- package/assets/pitfalls/task-flow-handover.md +30 -0
- package/assets/pitfalls/task-flow-owner.md +58 -0
- package/assets/pitfalls/task-flow-plan.md +29 -0
- package/assets/pitfalls/task-flow-resume.md +257 -0
- package/assets/pitfalls/task-flow-start.md +287 -0
- package/assets/pitfalls/task-flow.2.md +303 -0
- package/assets/pitfalls/task-flow.md +4 -4
- package/assets/pitfalls/testing.2.md +279 -0
- package/assets/pitfalls/turn-conduct.md +16 -17
- package/assets/pitfalls/typescript-conventions.md +161 -0
- package/assets/pitfalls/write-a-skill.md +128 -0
- package/assets/rules/angular-patterns.md +21 -86
- package/assets/rules/autonomous-work.md +2 -2
- package/assets/rules/browser-verification.md +28 -256
- package/assets/rules/component-structure.md +25 -87
- package/assets/rules/dependencies.md +20 -78
- package/assets/rules/deploy-flow.azure.md +26 -156
- package/assets/rules/deploy-flow.github.md +34 -200
- package/assets/rules/deploy-flow.gitlab.md +27 -159
- package/assets/rules/doc-style.md +32 -286
- package/assets/rules/entity-conventions.needs-admin.md +26 -82
- package/assets/rules/entity-models.md +14 -63
- package/assets/rules/epic-flow.md +24 -63
- package/assets/rules/git-workflow-hosting.azure.md +26 -0
- package/assets/rules/git-workflow-hosting.github.md +38 -0
- package/assets/rules/git-workflow-hosting.gitlab.md +27 -0
- package/assets/rules/git-workflow-push.azure.md +28 -0
- package/assets/rules/git-workflow-push.github.md +28 -0
- package/assets/rules/git-workflow-push.gitlab.md +28 -0
- package/assets/rules/git-workflow-queue.azure.md +23 -0
- package/assets/rules/git-workflow-queue.github.md +30 -0
- package/assets/rules/git-workflow-queue.gitlab.md +23 -0
- package/assets/rules/git-workflow.azure.md +21 -282
- package/assets/rules/git-workflow.github.md +24 -284
- package/assets/rules/git-workflow.gitlab.md +21 -269
- package/assets/rules/lib-layers.md +30 -103
- package/assets/rules/lists.md +21 -105
- package/assets/rules/mockups.needs-mockups.md +25 -64
- package/assets/rules/navigation.md +10 -69
- package/assets/rules/observability.needs-app.md +43 -172
- package/assets/rules/platform-access.md +28 -75
- package/assets/rules/queue-audit.github.md +25 -52
- package/assets/rules/reuse-first.md +20 -195
- package/assets/rules/spec-driven.md +35 -308
- package/assets/rules/styling-bem.md +20 -117
- package/assets/rules/task-flow-handover.md +24 -0
- package/assets/rules/task-flow-owner.md +34 -0
- package/assets/rules/task-flow-plan.md +38 -0
- package/assets/rules/task-flow.md +22 -300
- package/assets/rules/testing.md +32 -273
- package/assets/rules/turn-conduct.md +105 -106
- package/assets/rules/turn-entry.md +2 -2
- package/assets/rules/typescript-conventions.md +41 -147
- package/assets/samples/tasks/_template/plan.md +30 -6
- package/assets/samples/tasks/_template/progress.md +0 -1
- package/assets/skills/agent-kit-extend.md +25 -168
- package/assets/skills/agent-kit.md +27 -299
- package/assets/skills/write-a-skill.md +20 -106
- package/assets/task-flow/flow.js +184 -0
- package/assets/task-flow/flow.md +101 -0
- package/assets/task-flow/measure/agreement.mjs +24 -0
- package/assets/task-flow/measure/ci.mjs +184 -0
- package/assets/task-flow/measure/copy.mjs +22 -0
- package/assets/task-flow/measure/epic-of.mjs +50 -0
- package/assets/task-flow/measure/epic-text.mjs +35 -0
- package/assets/task-flow/measure/epic.mjs +114 -0
- package/assets/task-flow/measure/folder.mjs +16 -0
- package/assets/task-flow/measure/footprint.mjs +28 -0
- package/assets/task-flow/measure/grill.mjs +21 -0
- package/assets/task-flow/measure/host.mjs +8 -0
- package/assets/task-flow/measure/owner.mjs +27 -0
- package/assets/task-flow/measure/plan.mjs +27 -0
- package/assets/task-flow/measure/pr.mjs +20 -0
- package/assets/task-flow/measure/progress.mjs +50 -0
- package/assets/task-flow/measure/session.mjs +252 -0
- package/assets/task-flow/measure/task.mjs +23 -0
- package/assets/task-flow/measure/text.mjs +77 -0
- package/assets/task-flow/source/git.mjs +254 -0
- package/assets/task-flow/source/host.mjs +277 -0
- package/assets/task-flow/source/marks.mjs +56 -0
- package/assets/task-flow/source/owner.mjs +94 -0
- package/assets/task-flow/source/records.mjs +116 -0
- package/assets/task-flow/source/session.mjs +269 -0
- package/assets/task-flow/source/steps.mjs +28 -0
- package/assets/task-flow/source/tree.mjs +42 -0
- package/bin/agent-kit.d.ts.map +1 -1
- package/bin/agent-kit.js +30 -0
- package/bin/agent-kit.js.map +1 -1
- package/lib/agent-checks.d.ts +55 -0
- package/lib/agent-checks.d.ts.map +1 -0
- package/lib/agent-checks.js +221 -0
- package/lib/agent-checks.js.map +1 -0
- package/lib/assets.d.ts.map +1 -1
- package/lib/assets.js +7 -2
- package/lib/assets.js.map +1 -1
- package/lib/cargo.d.ts +29 -0
- package/lib/cargo.d.ts.map +1 -1
- package/lib/cargo.js +27 -1
- package/lib/cargo.js.map +1 -1
- package/lib/cascade.d.ts.map +1 -1
- package/lib/cascade.js +3 -1
- package/lib/cascade.js.map +1 -1
- package/lib/commands.d.ts.map +1 -1
- package/lib/commands.js +78 -2
- package/lib/commands.js.map +1 -1
- package/lib/config.d.ts +18 -0
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +18 -1
- package/lib/config.js.map +1 -1
- package/lib/epic-window-send.d.ts +74 -0
- package/lib/epic-window-send.d.ts.map +1 -0
- package/lib/epic-window-send.js +166 -0
- package/lib/epic-window-send.js.map +1 -0
- package/lib/hooks-map.d.ts +4 -0
- package/lib/hooks-map.d.ts.map +1 -1
- package/lib/hooks-map.js +2 -2
- package/lib/hooks-map.js.map +1 -1
- package/lib/integrity.d.ts +3 -0
- package/lib/integrity.d.ts.map +1 -1
- package/lib/integrity.js +7 -0
- package/lib/integrity.js.map +1 -1
- package/lib/metric-lines.d.ts +2 -1
- package/lib/metric-lines.d.ts.map +1 -1
- package/lib/metric-lines.js +49 -1
- package/lib/metric-lines.js.map +1 -1
- package/lib/metric-send-mark.d.ts +6 -3
- package/lib/metric-send-mark.d.ts.map +1 -1
- package/lib/metric-send-mark.js +15 -5
- package/lib/metric-send-mark.js.map +1 -1
- package/lib/metric-send.d.ts +6 -2
- package/lib/metric-send.d.ts.map +1 -1
- package/lib/metric-send.js +47 -13
- package/lib/metric-send.js.map +1 -1
- package/lib/metrics.d.ts +17 -0
- package/lib/metrics.d.ts.map +1 -1
- package/lib/metrics.js +26 -15
- package/lib/metrics.js.map +1 -1
- package/lib/observations.js +3 -3
- package/lib/observations.js.map +1 -1
- package/lib/outcomes.d.ts +5 -2
- package/lib/outcomes.d.ts.map +1 -1
- package/lib/outcomes.js +5 -4
- package/lib/outcomes.js.map +1 -1
- package/lib/push-gate.d.ts +13 -0
- package/lib/push-gate.d.ts.map +1 -1
- package/lib/push-gate.js +11 -7
- package/lib/push-gate.js.map +1 -1
- package/lib/push-set-usefulness.d.ts +78 -0
- package/lib/push-set-usefulness.d.ts.map +1 -0
- package/lib/push-set-usefulness.js +225 -0
- package/lib/push-set-usefulness.js.map +1 -0
- package/lib/sync.d.ts +10 -0
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +14 -1
- package/lib/sync.js.map +1 -1
- package/lib/work-result.d.ts +43 -0
- package/lib/work-result.d.ts.map +1 -0
- package/lib/work-result.js +39 -0
- package/lib/work-result.js.map +1 -0
- package/package.json +1 -1
- package/assets/hooks/claim-guard.sh +0 -212
- package/assets/hooks/grill-gate-ask.sh +0 -26
- package/assets/hooks/grill-gate-bypass.sh +0 -61
- package/assets/hooks/grill-gate-options.sh +0 -50
- package/assets/hooks/grill-gate.sh +0 -482
- package/assets/hooks/postmortem-guard.sh +0 -124
- package/assets/hooks/proposal-guard.sh +0 -154
- package/assets/hooks/stand-login-guard.sh +0 -107
- package/assets/hooks/turn-exit-epic.sh +0 -173
- package/assets/hooks/turn-exit-patterns.sh +0 -123
- package/assets/hooks/turn-exit-verdict.sh +0 -149
- package/assets/hooks/waiting-turn-guard.sh +0 -320
- package/assets/hooks/work-start-guard.sh +0 -175
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# rt-hook: PreToolUse Edit|Write|MultiEdit|NotebookEdit|Bash|mcp__webstorm__create_new_file|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_tool
|
|
3
|
-
# Requires: hooks/profile-check.sh, hooks/deny-tail.sh, hooks/guard-note.sh
|
|
3
|
+
# Requires: checks/decide.mjs, hooks/decide.sh, hooks/facts.sh, hooks/facts-docs.sh, hooks/profile-check.sh, hooks/deny-tail.sh, hooks/guard-note.sh
|
|
4
4
|
# Guard of the pair "an edit and its document". PreToolUse.
|
|
5
5
|
#
|
|
6
6
|
# A divergence of the code from the text is soundless. Neither the linter, nor the build, nor the
|
|
@@ -42,22 +42,27 @@ command -v jq >/dev/null 2>&1 || exit 0
|
|
|
42
42
|
|
|
43
43
|
tool="$(rt_hook_tool)"
|
|
44
44
|
|
|
45
|
+
# The decision, the move and the text come from the decision table. Parameters: the action, the facts
|
|
46
|
+
# of this guard, the params of the text. A refusal names the edit of the first awaited document, and
|
|
47
|
+
# the facts of the neighbours are those they judge that edit by: the decider puts first what they want.
|
|
45
48
|
decide() {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
$(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
'{
|
|
60
|
-
|
|
49
|
+
# shellcheck disable=SC1091
|
|
50
|
+
. "$rt_hooks_dir/facts.sh" 2>/dev/null
|
|
51
|
+
dg_sid="$(printf '%s' "$input" | jq -r '.session_id // "nosession"' 2>/dev/null)"
|
|
52
|
+
dg_record="$(rt_fact_transcript "$input")"
|
|
53
|
+
dg_doc="${first_doc:-README.md}"
|
|
54
|
+
case "$dg_doc" in /*) ;; *) dg_doc="$(git rev-parse --show-toplevel 2>/dev/null)/$dg_doc" ;; esac
|
|
55
|
+
dg_facts="$(jq -cn --argjson own "$2" \
|
|
56
|
+
--arg exam "$(rt_fact_exam_holds "$dg_record")" \
|
|
57
|
+
--arg window "$(rt_fact_window_over_stop "$dg_sid" "$dg_record")" \
|
|
58
|
+
--arg rule "$(rt_fact_move_rule_loaded Edit "$(jq -cn --arg f "$dg_doc" '{file_path:$f,old_string:"",new_string:""}')" "$dg_sid")" \
|
|
59
|
+
--arg gate "$(rt_fact_move_gate_rule Edit "$(jq -cn --arg f "$dg_doc" '{file_path:$f,old_string:"",new_string:""}')" "$dg_sid")" \
|
|
60
|
+
--arg flow "$(rt_fact_rule_loaded "${RT_TASK_FLOW_RULE:-task-flow}" "$dg_sid")" \
|
|
61
|
+
--arg handoff "$(rt_fact_from_handoff "$dg_record")" \
|
|
62
|
+
'{exam:$exam, window_over_stop:$window, rule_loaded:$rule, gate_rule:$gate, task_flow_loaded:$flow, from_handoff:$handoff} + $own')"
|
|
63
|
+
# shellcheck disable=SC1091
|
|
64
|
+
. "$rt_hooks_dir/decide.sh" 2>/dev/null
|
|
65
|
+
command -v rt_decide >/dev/null 2>&1 && rt_decide docs-guard.sh "$1" "$dg_facts" "${3:-"{}"}" PreToolUse "$input"
|
|
61
66
|
exit 0
|
|
62
67
|
}
|
|
63
68
|
|
|
@@ -97,11 +102,12 @@ case "$tool" in
|
|
|
97
102
|
case "$target" in
|
|
98
103
|
*/"$laws_dir"/*.implementation.md | "$laws_dir"/*.implementation.md) exit 0 ;;
|
|
99
104
|
*/"$laws_dir"/*.md | "$laws_dir"/*.md)
|
|
100
|
-
decide
|
|
105
|
+
decide edit_laid_out '{}' "$(jq -cn --arg f "${target##*/}" '{file:$f}')"
|
|
101
106
|
;;
|
|
102
107
|
*/"$overrides_dir"/laws/*.implementation.md | "$overrides_dir"/laws/*.implementation.md) exit 0 ;;
|
|
103
108
|
*/"$overrides_dir"/laws/*.md | "$overrides_dir"/laws/*.md)
|
|
104
|
-
|
|
109
|
+
if [ "$tool" = Write ]; then dg_act=write_override; else dg_act=edit_override; fi
|
|
110
|
+
decide "$dg_act" '{}' "$(jq -cn --arg f "${target##*/}" '{file:$f}')"
|
|
105
111
|
;;
|
|
106
112
|
esac
|
|
107
113
|
exit 0
|
|
@@ -134,186 +140,14 @@ case "$cmd" in
|
|
|
134
140
|
*) exit 0 ;;
|
|
135
141
|
esac
|
|
136
142
|
|
|
137
|
-
# The
|
|
138
|
-
#
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
# EXPLAINS the bypass lifts the requirement all by itself. A commit body about an edit of the guard
|
|
143
|
-
# names exactly this line, and without the binding to the start the guard would let such a commit
|
|
144
|
-
# through silently.
|
|
145
|
-
if printf '%s' "$cmd" | grep -qiE '(^|#)[[:space:]]*Docs-skip:[[:space:]]*[^[:space:]<"'"'"'][^[:space:]"'"'"']{2,}'; then
|
|
146
|
-
exit 0
|
|
147
|
-
fi
|
|
148
|
-
|
|
149
|
-
workdir="$(rt_hook_cwd)"
|
|
150
|
-
[ -z "$workdir" ] && workdir="${CLAUDE_PROJECT_DIR:-.}"
|
|
151
|
-
cd "$workdir" 2>/dev/null || exit 0
|
|
152
|
-
git rev-parse --is-inside-work-tree >/dev/null 2>&1 || exit 0
|
|
153
|
-
|
|
154
|
-
# `-a` takes all tracked edits, `--amend` takes the files of the rewritten commit as well. Always
|
|
155
|
-
# counting by the index would mean checking a set other than the one that travels into the history.
|
|
156
|
-
changes=''
|
|
157
|
-
source_mode='index'
|
|
158
|
-
case "$cmd" in
|
|
159
|
-
*' -a'* | *--all*)
|
|
160
|
-
changes="$(git diff HEAD --name-status -M 2>/dev/null)"
|
|
161
|
-
source_mode='worktree'
|
|
162
|
-
;;
|
|
163
|
-
*) changes="$(git diff --cached --name-status -M 2>/dev/null)" ;;
|
|
164
|
-
esac
|
|
165
|
-
case "$cmd" in
|
|
166
|
-
*--amend*) changes="$(printf '%s\n%s' "$changes" "$(git show --name-status --format= HEAD 2>/dev/null)")" ;;
|
|
167
|
-
esac
|
|
168
|
-
|
|
169
|
-
changes="$(printf '%s\n' "$changes" | grep -v '^[[:space:]]*$')"
|
|
170
|
-
[ -z "$changes" ] && exit 0
|
|
171
|
-
|
|
172
|
-
# The paths of the commit without the statuses. A rename comes as three fields — we take both sides.
|
|
173
|
-
paths="$(printf '%s\n' "$changes" | awk -F'\t' '{ for (i = 2; i <= NF; i++) if ($i != "") print $i }' | sort -u)"
|
|
174
|
-
|
|
175
|
-
has_path() { printf '%s\n' "$paths" | grep -qxF "$1"; }
|
|
176
|
-
|
|
177
|
-
# The content as it will travel into the commit. The source is the same one the list of edits was
|
|
178
|
-
# collected by: `-a` takes the working tree, an ordinary commit takes the index. Always reading the
|
|
179
|
-
# index is not allowed — under `-a` the previous edition lies there, and the guard would hold the
|
|
180
|
-
# very commit that fixes the divergence; always reading the working tree is not allowed either — an
|
|
181
|
-
# unstaged edit will not get into the commit.
|
|
182
|
-
content_of() {
|
|
183
|
-
if [ "$source_mode" = 'worktree' ]; then
|
|
184
|
-
cat "$1" 2>/dev/null
|
|
185
|
-
else
|
|
186
|
-
git show ":$1" 2>/dev/null || cat "$1" 2>/dev/null
|
|
187
|
-
fi
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
problems=''
|
|
191
|
-
add() { problems="${problems}
|
|
192
|
-
• $1"; }
|
|
193
|
-
|
|
194
|
-
# ── 1. A rule and its companion ───────────────────────────────────────────────
|
|
195
|
-
#
|
|
196
|
-
# The statements of a rule are keyed by their own text, and a rewording without an edit of the
|
|
197
|
-
# companion breaks the link silently. The spec audit catches this, but it is run at the push gate —
|
|
198
|
-
# here the same pair meets a commit earlier, while the edit is still in the author's head.
|
|
199
|
-
#
|
|
200
|
-
# The section with the statements is the only thing linked to the companion; an edit of "Pitfalls"
|
|
201
|
-
# or of the "Where it lives" table does not touch it, so only this section is compared. The name of
|
|
202
|
-
# the section is double: English in a package rule, Russian in a rule written by the tree before the
|
|
203
|
-
# layer was translated. The end of the range is any heading not starting with their first letter.
|
|
204
|
-
STATEMENTS='/^## (How the law applies here|Как закон применяется здесь)$/,/^## [^КH]/'
|
|
205
|
-
statements_of() { content_of "$1" | awk "$STATEMENTS"; }
|
|
206
|
-
|
|
207
|
-
for rule in $(printf '%s\n' "$paths" | grep -E '/SKILL\.md$'); do
|
|
208
|
-
grep -q '^kind: rule$' "$rule" 2>/dev/null || continue
|
|
209
|
-
companion="${rule%/SKILL.md}/implementation.md"
|
|
210
|
-
|
|
211
|
-
[ -f "$companion" ] || continue
|
|
212
|
-
has_path "$companion" && continue
|
|
213
|
-
|
|
214
|
-
if [ "$(statements_of "$rule")" != "$(git show "HEAD:$rule" 2>/dev/null | awk "$STATEMENTS")" ]; then
|
|
215
|
-
add "the statements of \`$rule\` are edited without the companion — add \`$companion\` to the commit"
|
|
216
|
-
fi
|
|
217
|
-
done
|
|
218
|
-
|
|
219
|
-
# ── 2. The pairs the tree names ───────────────────────────────────────────────
|
|
220
|
-
#
|
|
221
|
-
# The contract and the domain spec, a guard and its scenarios — which exactly, the profile knows:
|
|
222
|
-
# every tree has a link of its own, and the mechanics are one.
|
|
223
|
-
if rt_needs rt_docs_pair_for docs-guard; then
|
|
224
|
-
while IFS= read -r file; do
|
|
225
|
-
[ -z "$file" ] && continue
|
|
226
|
-
|
|
227
|
-
# A file put in place by the layout demands no pair: it has one author in a consuming tree
|
|
228
|
-
# — the package, and the document about it lies there as well. Otherwise the very first
|
|
229
|
-
# layout demands a bypass over its whole volume, and a bypass declared over a hundred files
|
|
230
|
-
# lifts the requirement from future hand edits of those files too. The sign is the layout
|
|
231
|
-
# header: it stands in every laid-out file and tells it apart more reliably than any list
|
|
232
|
-
# of paths.
|
|
233
|
-
if [ -f "$file" ] && head -12 "$file" 2>/dev/null | grep -qE 'rt-kit v[^ ]+ · [^ ]+ · [0-9a-f]+'; then
|
|
234
|
-
continue
|
|
235
|
-
fi
|
|
236
|
-
|
|
237
|
-
want="$(rt_docs_pair_for "$file" 2>/dev/null)"
|
|
238
|
-
[ -z "$want" ] && continue
|
|
239
|
-
# The pair counts as arrived if at least one file of the commit fits the pattern.
|
|
240
|
-
printf '%s\n' "$paths" | grep -qE "$want" && continue
|
|
241
|
-
add "\`$file\` is edited without its document — the same commit awaits \`$want\`"
|
|
242
|
-
done <<EOF
|
|
243
|
-
$paths
|
|
244
|
-
EOF
|
|
245
|
-
fi
|
|
246
|
-
|
|
247
|
-
# ── 3. A lib and its README ───────────────────────────────────────────────────
|
|
248
|
-
|
|
249
|
-
lib_root() {
|
|
250
|
-
dir="${1%/*}"
|
|
251
|
-
while [ -n "$dir" ] && [ "$dir" != "." ]; do
|
|
252
|
-
[ -f "$dir/$lib_marker" ] && { printf '%s' "$dir"; return 0; }
|
|
253
|
-
case "$dir" in */*) dir="${dir%/*}" ;; *) dir='' ;; esac
|
|
254
|
-
done
|
|
255
|
-
|
|
256
|
-
return 1
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
need_readme=''
|
|
260
|
-
want_readme() {
|
|
261
|
-
root="$1"
|
|
262
|
-
[ -n "$root" ] || return 0
|
|
263
|
-
case " $need_readme " in *" $root "*) return 0 ;; esac
|
|
264
|
-
need_readme="$need_readme $root"
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
# Creating and removing a lib: the README is the only place where it is written what lies in it and
|
|
268
|
-
# who calls it, and it survives the layout only together with an edit of that text.
|
|
269
|
-
while IFS="$(printf '\t')" read -r status first second; do
|
|
270
|
-
case "$status" in
|
|
271
|
-
A* | D*)
|
|
272
|
-
case "$first" in */"$lib_marker") want_readme "${first%/"$lib_marker"}" ;; esac
|
|
273
|
-
;;
|
|
274
|
-
R*)
|
|
275
|
-
# A move of a file changes both sides: from one lib it disappeared, in the other it
|
|
276
|
-
# appeared.
|
|
277
|
-
from="$(lib_root "$first")" && to="$(lib_root "$second")"
|
|
278
|
-
if [ -n "$from" ] && [ -n "$to" ] && [ "$from" != "$to" ]; then
|
|
279
|
-
want_readme "$from"
|
|
280
|
-
want_readme "$to"
|
|
281
|
-
fi
|
|
282
|
-
;;
|
|
283
|
-
esac
|
|
284
|
-
done <<EOF
|
|
285
|
-
$changes
|
|
286
|
-
EOF
|
|
287
|
-
|
|
288
|
-
# A move given as the pair "deleted there, added here": not everything that is a rename counts as
|
|
289
|
-
# one — an edit of the content while moving throws the search off.
|
|
290
|
-
moved_added="$(printf '%s\n' "$changes" | awk -F'\t' '$1 ~ /^A/ { n = split($2, p, "/"); print p[n] "\t" $2 }' | sort -u)"
|
|
291
|
-
moved_deleted="$(printf '%s\n' "$changes" | awk -F'\t' '$1 ~ /^D/ { n = split($2, p, "/"); print p[n] "\t" $2 }' | sort -u)"
|
|
292
|
-
if [ -n "$moved_added" ] && [ -n "$moved_deleted" ]; then
|
|
293
|
-
while IFS="$(printf '\t')" read -r base added; do
|
|
294
|
-
[ -n "$base" ] || continue
|
|
295
|
-
gone="$(printf '%s\n' "$moved_deleted" | awk -F'\t' -v b="$base" '$1 == b { print $2; exit }')"
|
|
296
|
-
[ -n "$gone" ] || continue
|
|
297
|
-
to="$(lib_root "$added")" || continue
|
|
298
|
-
from="$(lib_root "$gone")" || continue
|
|
299
|
-
[ "$from" = "$to" ] && continue
|
|
300
|
-
want_readme "$from"
|
|
301
|
-
want_readme "$to"
|
|
302
|
-
done <<EOF
|
|
303
|
-
$moved_added
|
|
304
|
-
EOF
|
|
305
|
-
fi
|
|
306
|
-
|
|
307
|
-
for root in $need_readme; do
|
|
308
|
-
[ -d "$root" ] || continue # the lib was deleted whole — there is nothing to edit in it
|
|
309
|
-
has_path "$root/README.md" || add "the content of the lib \`$root\` changed without an edit of \`$root/README.md\`"
|
|
310
|
-
done
|
|
143
|
+
# The analysis of the pair lives in `facts-docs.sh`: the delivery hooks ask the same fact.
|
|
144
|
+
# shellcheck disable=SC1091
|
|
145
|
+
. "$rt_hooks_dir/facts-docs.sh" 2>/dev/null
|
|
146
|
+
command -v rt_fact_doc_problems >/dev/null 2>&1 || exit 0
|
|
147
|
+
rt_fact_doc_problems "$cmd" || exit 0
|
|
311
148
|
|
|
312
149
|
if [ -n "$problems" ]; then
|
|
313
|
-
decide
|
|
314
|
-
${problems}
|
|
315
|
-
|
|
316
|
-
Text is edited in the same branch as the code: a document that has drifted from the tree looks like a current reference and leads the next reader astray. If an edit of the document really is not needed here — name the reason by the line \`Docs-skip: <reason>\` in the commit body, it stays in the history."
|
|
150
|
+
decide commit '{"doc_pair":"no"}' "$(jq -cn --arg p "$problems" '{problems:$p}')"
|
|
317
151
|
fi
|
|
318
152
|
|
|
319
153
|
# ── 4. The laws ───────────────────────────────────────────────────────────────
|
|
@@ -334,10 +168,7 @@ if [ -d "$laws_dir" ] && ! printf '%s\n' "$paths" | grep -qE "^${laws_dir}/([^/]
|
|
|
334
168
|
done
|
|
335
169
|
|
|
336
170
|
if [ -n "$touched" ]; then
|
|
337
|
-
decide
|
|
338
|
-
${touched}
|
|
339
|
-
|
|
340
|
-
The laws lie in \`${laws_dir}/\`, the binding — in the companions next to them. Read the law and tell the owner whether the edit agrees with it: if the edit refines it or contradicts it, the law is edited in this same branch, but only with their knowledge. If the law has not changed — confirm the call."
|
|
171
|
+
decide commit '{"doc_pair":"yes","law_anchor_touched":"yes"}' "$(jq -cn --arg t "$touched" --arg l "$laws_dir" '{touched:$t, laws_dir:$l}')"
|
|
341
172
|
fi
|
|
342
173
|
fi
|
|
343
174
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# rt-hook: PreToolUse .*EndConversation.*
|
|
3
|
-
# Requires: hooks/
|
|
3
|
+
# Requires: hooks/decide.sh
|
|
4
4
|
# The guard of the end of the conversation: the executor does not end the session. PreToolUse on
|
|
5
5
|
# the tool that closes the conversation — refused always.
|
|
6
6
|
#
|
|
@@ -10,13 +10,14 @@
|
|
|
10
10
|
# package. There is no lawful form of bypass: no state of the work, no word in the turn and no
|
|
11
11
|
# insult from the owner cancels it — a session that must close is closed by the owner.
|
|
12
12
|
#
|
|
13
|
-
# The name of the tool is read by jq, and without jq by grep over the raw input
|
|
14
|
-
#
|
|
13
|
+
# The name of the tool is read by jq, and without jq by grep over the raw input. A tool name with a
|
|
14
|
+
# vendor prefix is matched by its tail.
|
|
15
15
|
#
|
|
16
|
-
# FAIL-OPEN
|
|
17
|
-
#
|
|
16
|
+
# FAIL-OPEN: an empty input or a name that is not the closing tool passes. The refusal itself comes
|
|
17
|
+
# from the decision table, so without jq or node the call passes, like the call of every guard that
|
|
18
|
+
# asks the decider: a broken decider has no right to jam the work.
|
|
18
19
|
|
|
19
|
-
# Its own name in the observations: the refusal is recorded by the
|
|
20
|
+
# Its own name in the observations: the refusal is recorded by the decider call.
|
|
20
21
|
RT_GUARD_NAME=end-conversation-guard
|
|
21
22
|
RT_GUARD_RULE=turn-conduct
|
|
22
23
|
|
|
@@ -42,19 +43,9 @@ case "$tool" in
|
|
|
42
43
|
*) exit 0 ;;
|
|
43
44
|
esac
|
|
44
45
|
|
|
45
|
-
#
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
command -v
|
|
49
|
-
|
|
50
|
-
reason="BLOCKED by end-conversation-guard: the executor does not end the conversation. The session is ended by the owner and by nobody else.
|
|
51
|
-
|
|
52
|
-
An assignment stands until the owner cancels it, and an insult cancels nothing: do what was assigned, and where the work stands on the owner's word, wait for the word. A session that must close is closed by the owner — say so in words and go on working. There is no lawful form of bypass for this refusal."
|
|
53
|
-
tail_text="$(rt_deny_tail "")"
|
|
54
|
-
[ -n "$tail_text" ] && reason="${reason}
|
|
55
|
-
|
|
56
|
-
${tail_text}"
|
|
57
|
-
|
|
58
|
-
jq -n --arg r "$reason" '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:$r}}' 2>/dev/null \
|
|
59
|
-
|| printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"BLOCKED by end-conversation-guard: the session is ended by the owner and by nobody else."}}\n'
|
|
46
|
+
# The decision and the words come from the decision table: the call itself is the whole fact.
|
|
47
|
+
# shellcheck disable=SC1091
|
|
48
|
+
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/decide.sh" 2>/dev/null
|
|
49
|
+
command -v rt_decide >/dev/null 2>&1 || exit 0
|
|
50
|
+
rt_decide end-conversation-guard.sh end_conversation '{}' '{}' PreToolUse "$input"
|
|
60
51
|
exit 0
|
|
@@ -1,28 +1,35 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# rt-hook: PreToolUse Bash|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_tool
|
|
3
|
-
# Requires: hooks/
|
|
3
|
+
# Requires: hooks/observe.sh, hooks/epic-over.sh, checks/epic-table.github.mjs
|
|
4
4
|
# Guard of the stop at the end of an epic. PreToolUse on a call that takes new work.
|
|
5
5
|
#
|
|
6
6
|
# An epic used to end with the session taking the next piece of work. The owner learned that the
|
|
7
7
|
# epic was over from an ordinary report, mixed in with everything else, and had nowhere to give an
|
|
8
8
|
# order about its outcome: by the time they read it, the branch for the next work was already
|
|
9
|
-
# created.
|
|
10
|
-
# about the table of tasks was held before the command — by memory, that is, sometimes.
|
|
9
|
+
# created.
|
|
11
10
|
#
|
|
12
11
|
# The guard stands on the call, not on the end of the turn: a turn ends with text, and a guard that
|
|
13
|
-
# took to reading text would refuse by mood. Taking work is a call — a task
|
|
14
|
-
#
|
|
12
|
+
# took to reading text would refuse by mood. Taking work is a call — a created task or a branch by a
|
|
13
|
+
# task number.
|
|
14
|
+
#
|
|
15
|
+
# The decision is the owner's, and the guard asks them for it: the answer is `ask`, and the host
|
|
16
|
+
# shows the owner a window to allow or forbid this very command. The guard reads no record of the
|
|
17
|
+
# conversation. It once looked for the owner's consent there by words, and both misses came of it:
|
|
18
|
+
# a real «yes» given in other words was not found, and the owner was asked the same thing three
|
|
19
|
+
# times; an unrelated «yes» was taken for consent. Where nobody can answer the window — a subagent,
|
|
20
|
+
# a run without a person — the host hands the reason to the model, and the call does not go.
|
|
21
|
+
#
|
|
22
|
+
# A column moved to the working one is not judged: it follows the branch of the same work, and a
|
|
23
|
+
# window on it would ask the owner a second time about the decision they have just given.
|
|
15
24
|
#
|
|
16
25
|
# The state of the epic is asked by the same command that prints the table for the owner. A reader
|
|
17
|
-
# of its own would diverge from the printed table in silence: it would
|
|
18
|
-
# calls unfinished.
|
|
26
|
+
# of its own would diverge from the printed table in silence: it would ask about work the table
|
|
27
|
+
# itself calls unfinished.
|
|
19
28
|
#
|
|
20
29
|
# FAIL-OPEN: no `jq`, no `node`, no command, an epic that cannot be asked, any error of its own —
|
|
21
30
|
# the call is ALLOWED. A guard that jams the work when the network is gone is switched off on the
|
|
22
31
|
# first day, and the price of a miss here is one turn of the owner's attention.
|
|
23
32
|
|
|
24
|
-
# Its own name in the observations: the refusal is written by the shared deny tail, not by the
|
|
25
|
-
# guard itself.
|
|
26
33
|
RT_GUARD_NAME=epic-stop-guard
|
|
27
34
|
RT_GUARD_RULE=turn-conduct
|
|
28
35
|
|
|
@@ -56,25 +63,34 @@ if [ "$tool" = "mcp__webstorm__execute_tool" ] && command -v perl >/dev/null 2>&
|
|
|
56
63
|
[ -n "$inner" ] && cmd="$inner"
|
|
57
64
|
fi
|
|
58
65
|
|
|
59
|
-
#
|
|
60
|
-
#
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
# What counts as taking new work: a created task or a branch by a task number, and only where the
|
|
67
|
+
# command itself is run. The body of a heredoc is a text for another program, and an argument of a
|
|
68
|
+
# reader is a file name: a script that edits this very guard and a `sed` over the creating command
|
|
69
|
+
# named the command and took no work, and both were refused on 13.11.2026. The command is cut into
|
|
70
|
+
# its pieces by the shell separators; a piece is judged by its head, after the assignments of
|
|
71
|
+
# variables and the options of git.
|
|
72
|
+
heads() {
|
|
73
|
+
printf '%s\n' "$1" | perl -e '
|
|
74
|
+
my $text = do { local $/; <STDIN> };
|
|
75
|
+
$text =~ s/<<-?\s*([\x27"]?)(\w+)\1[^\n]*\n.*?\n\s*\2[ \t]*(?:\n|$)/\n/sg;
|
|
76
|
+
for my $piece (split /&&|\|\||[;|\n]/, $text) {
|
|
77
|
+
$piece =~ s/^\s+//;
|
|
78
|
+
$piece =~ s/^(?:\w+=(?:\x27[^\x27]*\x27|"[^"]*"|\S*)\s+)+//;
|
|
79
|
+
print "$piece\n" if length $piece;
|
|
80
|
+
}
|
|
81
|
+
' 2>/dev/null
|
|
82
|
+
}
|
|
68
83
|
takes_work=no
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
84
|
+
while IFS= read -r piece; do
|
|
85
|
+
if printf '%s' "$piece" | grep -qE '^git([[:space:]]+-[cC][[:space:]]+[^[:space:]]+)*[[:space:]]+(checkout|switch)[[:space:]]+(-[A-Za-z]+[[:space:]]+)*-(b|c)[[:space:]]+[A-Za-z]+-[0-9]+-'; then
|
|
86
|
+
takes_work=yes
|
|
87
|
+
fi
|
|
88
|
+
if printf '%s' "$piece" | grep -qE '^(npm|pnpm|yarn)[[:space:]]+(run[[:space:]]+)?(-s[[:space:]]+)?task:new([[:space:]]|$)|^node[[:space:]]+[^[:space:]]*task-new(\.github)?\.mjs'; then
|
|
89
|
+
takes_work=yes
|
|
90
|
+
fi
|
|
91
|
+
done <<EOF
|
|
92
|
+
$(heads "$cmd")
|
|
93
|
+
EOF
|
|
78
94
|
[ "$takes_work" = yes ] || exit 0
|
|
79
95
|
|
|
80
96
|
# The reading of the end of an epic is shared with the two guards that judge the stop itself: written
|
|
@@ -86,136 +102,22 @@ fi
|
|
|
86
102
|
command -v rt_epic_over >/dev/null 2>&1 || exit 0
|
|
87
103
|
rt_epic_over || exit 0
|
|
88
104
|
|
|
89
|
-
# The word of the owner about this very work releases the call: their message or their answer to a
|
|
90
|
-
# menu that names the number the call takes. The line in the call was the only form before, and an
|
|
91
|
-
# owner who forbade writing it left the executor one way out — stopping the work they had just set.
|
|
92
|
-
# The number is read from the call; the words of the executor do not count.
|
|
93
|
-
taken="$(printf '%s' "$cmd" | sed -nE 's/.*(checkout|switch)[[:space:]]+(-[A-Za-z]+[[:space:]]+)*-(b|c)[[:space:]]+[A-Za-z]+-([0-9]+)-.*/\4/p; s/.*(task:move|board\.mjs[[:space:]]+move)[^0-9|;&]*([0-9]+).*/\2/p; s/.*--epic-of[[:space:]=]+([0-9]+).*/\1/p' | head -1)"
|
|
94
|
-
transcript="$(printf '%s' "$input" | jq -r '.transcript_path // empty' 2>/dev/null)"
|
|
95
|
-
|
|
96
|
-
# The words of the owner are looked for among what the owner side wrote, not among the last lines
|
|
97
|
-
# of the record. A window of lines is spent by the work itself: every command adds two, and a
|
|
98
|
-
# «yes» given an hour of work ago fell out of it while the executor was fixing what refused it.
|
|
99
|
-
# Results of commands are dropped before the count, the answers to menus stay.
|
|
100
|
-
owner_side() {
|
|
101
|
-
LC_ALL=C grep -F '"type":"user"' "$1" 2>/dev/null \
|
|
102
|
-
| awk '!/"tool_result"/ || /The user answered:|Your questions have been answered:|the user said:/' \
|
|
103
|
-
| tail -n 400
|
|
104
|
-
}
|
|
105
|
-
if [ -n "$taken" ] && [ -n "$transcript" ] && [ -f "$transcript" ]; then
|
|
106
|
-
# A menu answer comes in two forms, «The user answered:» and «Your questions have been answered:»,
|
|
107
|
-
# followed by "question"="answer" pairs. Only the answers count: the question is written by the
|
|
108
|
-
# executor, and a number in «take RT-N?» answered «no» is not the owner's word.
|
|
109
|
-
named="$(owner_side "$transcript" | jq -s -r --arg n "$taken" '
|
|
110
|
-
def menu_answers: if test("^(The user answered|Your questions have been answered):")
|
|
111
|
-
then ([match("\"=\"([^\"]*)\""; "g") | .captures[0].string] | join("\n")) else "" end;
|
|
112
|
-
[.[] | select(.type == "user")
|
|
113
|
-
| select(((.isMeta // false) or (.isCompactSummary // false)) | not)
|
|
114
|
-
| select((.origin.kind // "human") == "human")
|
|
115
|
-
| (.message.content // "")
|
|
116
|
-
| if type == "string" then .
|
|
117
|
-
elif type == "array" then (map(
|
|
118
|
-
if .type == "text" then (.text // "")
|
|
119
|
-
elif .type == "tool_result" then ((.content
|
|
120
|
-
| if type == "string" then . elif type == "array"
|
|
121
|
-
then (map(if type == "object" then (.text // "") else "" end) | join(" ")) else "" end)
|
|
122
|
-
| menu_answers)
|
|
123
|
-
else "" end) | join("\n"))
|
|
124
|
-
else "" end]
|
|
125
|
-
| map(test("(^|[^0-9])" + $n + "([^0-9]|$)")) | any
|
|
126
|
-
' 2>/dev/null)"
|
|
127
|
-
[ "$named" = "true" ] && exit 0
|
|
128
|
-
fi
|
|
129
|
-
|
|
130
|
-
# A created task has no number yet, so no menu answer can name it, and the owner's answer to «create
|
|
131
|
-
# a task for these findings?» left the call refused. The word of the owner here is their latest
|
|
132
|
-
# answer to a menu: the answer agrees to a task — a word of a task, of creating it, or a plain
|
|
133
|
-
# «yes» — and it is not a refusal. Any answer was too wide: «not now» and an answer about a button
|
|
134
|
-
# colour passed alike. A new epic needs the word of an epic.
|
|
135
|
-
#
|
|
136
|
-
# The number after `--epic-of` names the epic, not the work taken: said by the owner, it releases
|
|
137
|
-
# the call above, and its absence from their answer refuses nothing here. Read as the number of the
|
|
138
|
-
# work, it left two answers «yes» in a row refused, and the owner was asked a third time.
|
|
139
|
-
#
|
|
140
|
-
# The answer agrees when it names the creating of a task, not a task alone: on the real record of
|
|
141
|
-
# a session ten answers of twenty-three named a task while agreeing to something else. A plain
|
|
142
|
-
# «yes» agrees only to the question it answers: it counts when that question names the creating.
|
|
143
|
-
# Every pair of the latest menu is read, not the first one, and an answer that puts the task off
|
|
144
|
-
# is no consent.
|
|
145
|
-
#
|
|
146
|
-
# What stands after the answer is judged by who wrote it. A notice of a background command and the
|
|
147
|
-
# mark of an interrupted turn are written by no person and cancel nothing. A message of the owner
|
|
148
|
-
# cancels their answer only when one of its lines begins with a refusal — «stop», «wait», «no»,
|
|
149
|
-
# «do not create»: their other words after a «yes» are not a second decision. The words the owner
|
|
150
|
-
# typed while declining a call are read the same way.
|
|
151
|
-
if [ -n "$transcript" ] && [ -f "$transcript" ] \
|
|
152
|
-
&& printf '%s' "$cmd" | grep -qE 'task:new|task-new\.mjs' 2>/dev/null; then
|
|
153
|
-
topic='задач|карточ|task|issue'
|
|
154
|
-
deed='заве|завод|созда|нов(ая|ую|ой) (задач|карточ)|create|new (task|issue)'
|
|
155
|
-
if printf '%s' "$cmd" | grep -qE -- '--epic([[:space:]=]|$)' 2>/dev/null; then
|
|
156
|
-
topic='эпик|epic'
|
|
157
|
-
deed='эпик|epic'
|
|
158
|
-
fi
|
|
159
|
-
yes='^\s*(да|yes|ок|ok)([^[:alpha:]]|$)'
|
|
160
|
-
refusal='^\s*(нет([^[:alpha:]]|$)|не (надо|нужно|заводи|создавай|делай)|нельзя|no([^[:alpha:]]|$)|стоп|stop|отмен|cancel|подожд|wait|позже|later|пока ничего|ничего не (надо|нужно|заводи|делай)|nothing)'
|
|
161
|
-
put_off='отлож|на потом|позже|завтра|не сейчас|пока не|not now|later'
|
|
162
|
-
# A denial inside the answer: «не создавать задачу», «без задачи», «do not create». The list
|
|
163
|
-
# above reads only the opening of a line, and an answer that opened with it by another form —
|
|
164
|
-
# an infinitive, «без» — read as consent by its word of a task.
|
|
165
|
-
denial='(^|[^[:alpha:]])(не|без|ничего не|do not|don.?t|skip)[[:space:]]+([^[:space:]]+[[:space:]]+)?(созда|завод|заве|задач|карточ|create|task|issue)'
|
|
166
|
-
latest="$(owner_side "$transcript" | jq -s -r --arg topic "$topic" --arg deed "$deed" --arg yes "$yes" \
|
|
167
|
-
--arg refusal "$refusal" --arg put_off "$put_off" --arg denial "$denial" '
|
|
168
|
-
def refuses: split("\n") | map(test($refusal; "i")) | any;
|
|
169
|
-
[.[] | select(.type == "user")
|
|
170
|
-
| select(((.isMeta // false) or (.isCompactSummary // false)) | not)
|
|
171
|
-
| select((.origin.kind // "human") == "human")
|
|
172
|
-
| (.message.content // "")
|
|
173
|
-
| if type == "string" then {said: .}
|
|
174
|
-
elif type == "array" then (map(
|
|
175
|
-
if .type == "text" then {said: (.text // "")}
|
|
176
|
-
elif .type == "tool_result" then ((.content
|
|
177
|
-
| if type == "string" then . elif type == "array"
|
|
178
|
-
then (map(if type == "object" then (.text // "") else "" end) | join(" ")) else "" end)
|
|
179
|
-
| if test("^(The user answered|Your questions have been answered):")
|
|
180
|
-
then {menu: [match("\"([^\"]*)\"=\"([^\"]*)\""; "g") | {asked: .captures[0].string, chose: .captures[1].string}]}
|
|
181
|
-
elif test("^The user doesn.t want to proceed") and test("the user said:")
|
|
182
|
-
then {said: (split("the user said:") | .[1:] | join("\n") | ltrimstr("\n"))}
|
|
183
|
-
else empty end)
|
|
184
|
-
else empty end) | .[])
|
|
185
|
-
else empty end
|
|
186
|
-
| select(((.said // "") | test("^\\s*\\[Request interrupted")) | not)]
|
|
187
|
-
| (map(has("menu")) | rindex(true)) as $at
|
|
188
|
-
| if $at == null then "no"
|
|
189
|
-
else (.[$at].menu | map(
|
|
190
|
-
((.chose | refuses) or (.chose | test($put_off; "i")) or (.chose | test($denial; "i")) | not)
|
|
191
|
-
and ((.chose | test($deed; "i"))
|
|
192
|
-
or ((.chose | test($yes + "|" + $topic; "i")) and (.asked | test($deed; "i"))))
|
|
193
|
-
) | any) as $agreed
|
|
194
|
-
| (.[$at + 1:] | map((.said // "") | refuses) | any) as $taken_back
|
|
195
|
-
| if $agreed and ($taken_back | not) then "yes" else "no" end
|
|
196
|
-
end
|
|
197
|
-
' 2>/dev/null)"
|
|
198
|
-
[ "$latest" = "yes" ] && exit 0
|
|
199
|
-
fi
|
|
200
|
-
|
|
201
105
|
root="$(git rev-parse --show-toplevel 2>/dev/null)"
|
|
202
106
|
checks="$(jq -r '.layout.checks // "tools"' "$root/.claude/rt-kit.json" 2>/dev/null)"
|
|
203
107
|
if [ -z "$checks" ] || [ "$checks" = null ]; then
|
|
204
108
|
checks=tools
|
|
205
109
|
fi
|
|
206
110
|
|
|
207
|
-
|
|
208
|
-
|
|
111
|
+
# The window is counted apart from the refusals: an unanswered window in a run without a person is
|
|
112
|
+
# a refusal by its effect, and a count of refusals alone would not see it.
|
|
209
113
|
# shellcheck disable=SC1090
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
${
|
|
217
|
-
|
|
218
|
-
jq -
|
|
219
|
-
|| printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"The epic is over: the end of an epic is a stop, not the next task."}}\n'
|
|
220
|
-
|
|
114
|
+
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/observe.sh" 2>/dev/null || true
|
|
115
|
+
command -v rt_note >/dev/null 2>&1 && rt_note guard-ask guard="$RT_GUARD_NAME" sid="$(printf '%s' "$input" | jq -r '.session_id // empty' 2>/dev/null)"
|
|
116
|
+
|
|
117
|
+
# The decision and the words come from the decision table; the class of the call is found by the
|
|
118
|
+
# decider from the call itself, and a run of the task script it does not know is taking a task.
|
|
119
|
+
# shellcheck disable=SC1091
|
|
120
|
+
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/decide.sh" 2>/dev/null
|
|
121
|
+
command -v rt_decide >/dev/null 2>&1 || exit 0
|
|
122
|
+
rt_decide epic-stop-guard.sh "?task_new" '{"epic_over":"yes"}' "$(jq -cn --arg c "$checks" '{checks:$c}')" PreToolUse "$input"
|
|
221
123
|
exit 0
|