@rt-tools/agent-kit 0.24.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/agents/business-analyst.md +51 -50
- package/assets/agents/conscience.md +37 -35
- package/assets/agents/project-manager.md +49 -48
- package/assets/agents/prose-editor.md +31 -29
- package/assets/agents/qa-engineer.md +50 -48
- package/assets/agents/rules-reviewer.md +63 -58
- package/assets/agents/skill-curator.md +83 -78
- package/assets/agents/spec-critic.md +34 -29
- package/assets/agents/spec-writer.md +35 -32
- package/assets/agents/strict-teacher.md +39 -37
- package/assets/checks/archive-age.mjs +48 -28
- package/assets/checks/archive-prune.mjs +16 -14
- package/assets/checks/board-epics.github.mjs +75 -41
- package/assets/checks/board-folders.mjs +61 -0
- package/assets/checks/board-gh.github.mjs +35 -26
- package/assets/checks/board-long-work.github.mjs +24 -24
- package/assets/checks/board-paths.github.mjs +21 -16
- package/assets/checks/board-runs.github.mjs +45 -43
- package/assets/checks/board-titles.github.mjs +19 -17
- package/assets/checks/board.github.mjs +149 -127
- package/assets/checks/check-archive-age.mjs +23 -19
- package/assets/checks/check-board.github.mjs +172 -164
- package/assets/checks/check-descriptions.mjs +30 -29
- package/assets/checks/check-doc-paths.mjs +91 -88
- package/assets/checks/check-dupes.mjs +84 -80
- package/assets/checks/check-file-size.mjs +74 -71
- package/assets/checks/check-glossary.mjs +47 -37
- package/assets/checks/check-hook-scope.mjs +30 -27
- package/assets/checks/check-lib-layers.mjs +22 -21
- package/assets/checks/check-profile-drift.mjs +48 -43
- package/assets/checks/check-prose-style.mjs +120 -37
- package/assets/checks/check-push-gate.mjs +53 -50
- package/assets/checks/check-reuse.mjs +50 -40
- package/assets/checks/check-schema-drift.mjs +87 -83
- package/assets/checks/check-specs.mjs +155 -134
- package/assets/checks/check-state-next.mjs +66 -52
- package/assets/checks/check-states.mjs +32 -30
- package/assets/checks/check-styles.mjs +52 -51
- package/assets/checks/check-turn-map.mjs +54 -46
- package/assets/checks/lib-boundaries.mjs +32 -30
- package/assets/checks/lib-common.mjs +30 -29
- package/assets/checks/lib-domains.mjs +34 -34
- package/assets/checks/lib-manifests.mjs +17 -15
- package/assets/checks/lib-reexports.mjs +18 -18
- package/assets/checks/rt-kit-checks.config.mjs +174 -142
- package/assets/checks/signals.mjs +43 -39
- package/assets/checks/spec-anchors.mjs +114 -87
- package/assets/checks/spec-common.mjs +128 -84
- package/assets/checks/spec-contract.mjs +30 -30
- package/assets/checks/spec-proposed.mjs +27 -24
- package/assets/checks/spec-scenarios.mjs +51 -28
- package/assets/checks/task-new.github.mjs +85 -56
- package/assets/commands/feedback.md +65 -59
- package/assets/commands/next-session.md +64 -57
- package/assets/commands/skill-curator.md +83 -79
- package/assets/defaults/gate-map.sh +108 -97
- package/assets/defaults/project.sh +225 -185
- package/assets/defaults/shell.sh +73 -68
- package/assets/defaults/turn-map.md +45 -44
- package/assets/docs/GLOSSARY.md +142 -65
- package/assets/hooks/browser-device-id.sh +12 -12
- package/assets/hooks/browser-guard-device-id.sh +30 -28
- package/assets/hooks/browser-guard-no-asking.sh +5 -4
- package/assets/hooks/browser-guard-no-listing.sh +12 -11
- package/assets/hooks/browser-guard-no-other-drivers.sh +48 -42
- package/assets/hooks/browser-guard-require-select.sh +34 -23
- package/assets/hooks/claim-guard.sh +62 -56
- package/assets/hooks/commit-msg.sh +11 -10
- package/assets/hooks/conscience-guard.sh +91 -45
- package/assets/hooks/constitution-index.sh +16 -16
- package/assets/hooks/deny-tail.sh +28 -26
- package/assets/hooks/dev-server-guard.sh +46 -43
- package/assets/hooks/dispatch.sh +60 -46
- package/assets/hooks/docs-guard.sh +100 -91
- package/assets/hooks/exam-guard.sh +105 -93
- package/assets/hooks/git-guard-delivery-conflict.sh +38 -36
- package/assets/hooks/git-guard-delivery-draft.sh +45 -38
- package/assets/hooks/git-guard-delivery-folder.sh +50 -43
- package/assets/hooks/git-guard-delivery-signature.sh +88 -52
- package/assets/hooks/git-guard-delivery.sh +196 -180
- package/assets/hooks/git-guard-main.sh +38 -34
- package/assets/hooks/git-guard-push-tests.sh +99 -87
- package/assets/hooks/glossary-load.sh +23 -22
- package/assets/hooks/grill-gate-ask.sh +12 -11
- package/assets/hooks/grill-gate.sh +94 -87
- package/assets/hooks/guard-note.sh +20 -19
- package/assets/hooks/handoff-entry-guard.sh +26 -24
- package/assets/hooks/handoff-write.sh +74 -67
- package/assets/hooks/hook-input.sh +67 -58
- package/assets/hooks/lint-after-edit.sh +95 -61
- package/assets/hooks/observe.sh +28 -26
- package/assets/hooks/override-write-guard.sh +23 -21
- package/assets/hooks/postmortem-guard.sh +42 -39
- package/assets/hooks/profile-check.sh +22 -20
- package/assets/hooks/proposal-guard.sh +57 -49
- package/assets/hooks/prose-style-guard.sh +19 -17
- package/assets/hooks/qa-dataid-guard.sh +52 -49
- package/assets/hooks/rerun-guard.sh +31 -30
- package/assets/hooks/reuse-first-guard.sh +108 -87
- package/assets/hooks/roles.sh +14 -14
- package/assets/hooks/rule-article.sh +36 -34
- package/assets/hooks/rule-source-guard.sh +47 -42
- package/assets/hooks/skill-gate-layers.sh +59 -57
- package/assets/hooks/skill-gate-rearm.sh +15 -8
- package/assets/hooks/skill-gate.sh +89 -81
- package/assets/hooks/skill-loaded.sh +6 -6
- package/assets/hooks/sql-guard-parse.sh +68 -66
- package/assets/hooks/sql-guard-request.sh +48 -46
- package/assets/hooks/sql-guard-target.sh +57 -51
- package/assets/hooks/sql-guard-write.sh +84 -79
- package/assets/hooks/sql-guard.sh +52 -47
- package/assets/hooks/stand-login-guard.sh +40 -37
- package/assets/hooks/task-context-load.sh +60 -55
- package/assets/hooks/task-flow-context.sh +87 -69
- package/assets/hooks/task-flow-draft-guard.sh +55 -48
- package/assets/hooks/task-flow-guard.sh +67 -64
- package/assets/hooks/turn-entry-load.sh +39 -32
- package/assets/hooks/turn-exit-guard.sh +256 -204
- package/assets/hooks/turn-exit-patterns.sh +53 -0
- package/assets/hooks/utf8.sh +11 -11
- package/assets/hooks/waiting-turn-guard.sh +94 -94
- package/assets/hooks/window-fill-guard.sh +70 -62
- package/assets/hooks/work-start-guard.sh +52 -49
- package/assets/hooks/write-targets.sh +96 -44
- package/assets/laws/autonomous-work.md +29 -27
- package/assets/laws/code-structure.md +31 -30
- package/assets/laws/delivery.md +148 -137
- package/assets/laws/entity-editing.md +52 -50
- package/assets/laws/entity-models.md +14 -13
- package/assets/laws/frontend-application.md +39 -38
- package/assets/laws/lib-imports.md +27 -27
- package/assets/laws/lists.md +31 -29
- package/assets/laws/navigation.md +37 -37
- package/assets/laws/observability.md +41 -40
- package/assets/laws/project-documentation.md +106 -99
- package/assets/laws/reuse-first.md +31 -29
- package/assets/laws/shared-code.md +27 -27
- package/assets/laws/verifiability.md +131 -124
- package/assets/laws/work-conduct.md +250 -244
- package/assets/patterns/admin-lists-screen.md +72 -69
- package/assets/patterns/admin-nav-item.md +51 -46
- package/assets/patterns/angular-patterns-state.md +32 -31
- package/assets/patterns/api-layer-pair.md +33 -31
- package/assets/patterns/autonomous-work-run.md +50 -49
- package/assets/patterns/browser-verification-measure.md +124 -88
- package/assets/patterns/browser-verification-stand.md +169 -157
- package/assets/patterns/component-structure-new.md +51 -42
- package/assets/patterns/dependencies-upgrade.md +55 -39
- package/assets/patterns/doc-style-human.md +55 -37
- package/assets/patterns/doc-style-sweep.md +82 -79
- package/assets/patterns/doc-style-trace.md +87 -81
- package/assets/patterns/doc-style-write.md +130 -122
- package/assets/patterns/entity-aside.md +77 -63
- package/assets/patterns/entity-models-new.md +37 -37
- package/assets/patterns/entity-store.md +33 -33
- package/assets/patterns/git-workflow-commit.azure.md +93 -86
- package/assets/patterns/git-workflow-commit.github.md +152 -141
- package/assets/patterns/git-workflow-commit.gitlab.md +95 -89
- package/assets/patterns/git-workflow-docker.md +165 -147
- package/assets/patterns/git-workflow-freshness.md +45 -45
- package/assets/patterns/git-workflow-merge.md +98 -93
- package/assets/patterns/git-workflow-migration.md +54 -52
- package/assets/patterns/git-workflow-pr-ready.md +57 -56
- package/assets/patterns/git-workflow-pr.azure.md +126 -121
- package/assets/patterns/git-workflow-pr.github.md +179 -175
- package/assets/patterns/git-workflow-pr.gitlab.md +138 -131
- package/assets/patterns/git-workflow-restart.md +35 -31
- package/assets/patterns/git-workflow-secrets.md +80 -73
- package/assets/patterns/git-workflow-stack.md +131 -106
- package/assets/patterns/lib-layers-move.md +62 -53
- package/assets/patterns/lib-layers-new.md +59 -45
- package/assets/patterns/observability-record.md +72 -67
- package/assets/patterns/platform-access-di.md +31 -29
- package/assets/patterns/reuse-first-extend.md +66 -61
- package/assets/patterns/shared-code-new.md +39 -38
- package/assets/patterns/spec-driven-domain.md +161 -151
- package/assets/patterns/spec-driven-rule.md +179 -168
- package/assets/patterns/spec-driven-sweep.md +41 -39
- package/assets/patterns/status-report-table.github.md +37 -36
- package/assets/patterns/styling-bem-component.md +42 -42
- package/assets/patterns/styling-bem-layout.md +39 -34
- package/assets/patterns/styling-bem-sheet.md +59 -58
- package/assets/patterns/task-flow-archive.md +222 -215
- package/assets/patterns/task-flow-close.md +215 -203
- package/assets/patterns/task-flow-handoff.md +154 -145
- package/assets/patterns/task-flow-resume.md +138 -133
- package/assets/patterns/task-flow-start.md +204 -192
- package/assets/patterns/testing-e2e.md +102 -101
- package/assets/patterns/testing-unit.md +77 -70
- package/assets/patterns/ts-procedure.md +32 -29
- package/assets/patterns/turn-entry-map.md +50 -48
- package/assets/pitfalls/agent-kit.md +152 -141
- package/assets/pitfalls/doc-style.md +96 -91
- package/assets/pitfalls/git-workflow.azure.md +49 -46
- package/assets/pitfalls/git-workflow.github.md +264 -234
- package/assets/pitfalls/git-workflow.gitlab.md +49 -45
- package/assets/pitfalls/spec-driven.md +73 -71
- package/assets/pitfalls/styling-bem.md +46 -40
- package/assets/pitfalls/task-flow.md +262 -246
- package/assets/pitfalls/testing.md +99 -92
- package/assets/pitfalls/turn-conduct.md +96 -81
- package/assets/rules/angular-patterns.md +81 -80
- package/assets/rules/api-layer.md +77 -74
- package/assets/rules/autonomous-work.md +75 -74
- package/assets/rules/browser-verification.md +223 -214
- package/assets/rules/component-structure.md +72 -69
- package/assets/rules/dependencies.md +74 -67
- package/assets/rules/deploy-flow.azure.md +118 -108
- package/assets/rules/deploy-flow.github.md +145 -135
- package/assets/rules/deploy-flow.gitlab.md +120 -110
- package/assets/rules/doc-style.md +198 -173
- package/assets/rules/entity-conventions.needs-admin.md +81 -79
- package/assets/rules/entity-models.md +73 -70
- package/assets/rules/git-workflow.azure.md +224 -228
- package/assets/rules/git-workflow.github.md +250 -239
- package/assets/rules/git-workflow.gitlab.md +218 -217
- package/assets/rules/lib-layers.md +85 -86
- package/assets/rules/lists.md +101 -97
- package/assets/rules/navigation.md +78 -78
- package/assets/rules/observability.needs-app.md +165 -153
- package/assets/rules/platform-access.md +76 -75
- package/assets/rules/reuse-first.md +153 -143
- package/assets/rules/shared-code.md +82 -79
- package/assets/rules/spec-driven.md +272 -260
- package/assets/rules/status-report.md +55 -58
- package/assets/rules/styling-bem.md +81 -77
- package/assets/rules/task-flow.md +282 -270
- package/assets/rules/testing.md +224 -209
- package/assets/rules/turn-conduct.md +255 -258
- package/assets/rules/turn-entry.md +92 -87
- package/assets/rules/typescript-conventions.md +94 -88
- package/assets/samples/specs/_template/spec.md +47 -47
- package/assets/samples/tasks/_template/grill.md +20 -20
- package/assets/samples/tasks/_template/plan.md +32 -30
- package/assets/samples/tasks/_template/progress.md +16 -16
- package/assets/skills/agent-kit-extend.md +129 -113
- package/assets/skills/agent-kit.md +235 -211
- package/assets/skills/write-a-skill.md +76 -71
- package/assets/templates/findings.md +19 -19
- package/assets/templates/gate-map.sh +16 -14
- package/assets/templates/implementation.md +28 -27
- package/assets/templates/pattern.md +17 -17
- package/assets/templates/pitfalls.md +6 -6
- package/assets/templates/postmortem.md +24 -23
- package/assets/templates/project.sh +24 -24
- package/assets/templates/proposal.md +62 -60
- package/assets/templates/rule.md +38 -38
- package/assets/workflows/feature.js +46 -46
- package/assets/workflows/plan.js +54 -54
- package/lib/catalog.d.ts +2 -0
- package/lib/catalog.d.ts.map +1 -1
- package/lib/catalog.js +4 -3
- package/lib/catalog.js.map +1 -1
- package/lib/commands.d.ts.map +1 -1
- package/lib/commands.js +5 -2
- package/lib/commands.js.map +1 -1
- package/lib/companion.js +3 -2
- package/lib/companion.js.map +1 -1
- package/lib/enroll.d.ts +7 -1
- package/lib/enroll.d.ts.map +1 -1
- package/lib/enroll.js +12 -3
- package/lib/enroll.js.map +1 -1
- package/lib/plan.d.ts +11 -0
- package/lib/plan.d.ts.map +1 -1
- package/lib/plan.js +10 -1
- package/lib/plan.js.map +1 -1
- package/lib/ship.d.ts +0 -7
- package/lib/ship.d.ts.map +1 -1
- package/lib/ship.js +10 -2
- package/lib/ship.js.map +1 -1
- package/lib/shipment.d.ts.map +1 -1
- package/lib/shipment.js +6 -2
- package/lib/shipment.js.map +1 -1
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +45 -11
- package/lib/sync.js.map +1 -1
- package/package.json +1 -1
- package/rt-tools-agent-kit-0.26.0.tgz +0 -0
- package/rt-tools-agent-kit-0.24.0.tgz +0 -0
|
@@ -1,39 +1,41 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# rt-hook: PreToolUse Edit|Write|MultiEdit|mcp__webstorm__create_new_file|Bash|mcp__webstorm__execute_terminal_command
|
|
3
|
-
#
|
|
4
|
-
#
|
|
3
|
+
# Requires: agents/strict-teacher.md, hooks/roles.sh, hooks/deny-tail.sh, hooks/write-targets.sh
|
|
4
|
+
# Exam guard: no edit goes through until the exam on the loaded rules has been passed this session.
|
|
5
5
|
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
6
|
+
# Why this way. The rules gate demands that a rule be loaded before an edit, and ends there: to
|
|
7
|
+
# the tree, a loaded rule and a read rule cannot be told apart. A rule of four hundred lines goes
|
|
8
|
+
# into the context whole and is carried out selectively — misses happen after the rule was loaded.
|
|
9
|
+
# The examiner role asks, and the guard judges its verdict.
|
|
10
10
|
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
11
|
+
# The role gives its verdict in the first line: "ЭКЗАМЕН: сдано N из 5". Passed means five out of
|
|
12
|
+
# five; any other number means the rule is reread whole and the exam is retaken.
|
|
13
13
|
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
14
|
+
# A copied answer does not count as an exam. The role cannot tell it from knowledge — the guard
|
|
15
|
+
# can: between the questions and the answers there must be no reading of the same rules. The sign
|
|
16
|
+
# is crude and does not hide its boundary: reading a neighbouring rule it counts as copying too.
|
|
17
17
|
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
18
|
+
# The verdict is looked for in every form of the turn record, not in one. The delivery form is
|
|
19
|
+
# chosen by the host: a role running in the background returns its result as a completion notice,
|
|
20
|
+
# and has no record of the "tool result" kind at all. A tree where the role works that way was
|
|
21
|
+
# locked by the guard entirely — five rounds of the exam with a full verdict let no edit through;
|
|
22
|
+
# the analysis is in the incident records.
|
|
22
23
|
#
|
|
23
|
-
#
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
#
|
|
24
|
+
# Two forms are discarded, both on purpose. The assistant's own text is never a verdict: writing
|
|
25
|
+
# the needed line in a reply costs one move. Results of the reading and writing tools are discarded
|
|
26
|
+
# too: echoing the same line or reading a file with it would pass the guard, so forgery would
|
|
27
|
+
# become the only reachable way. What counts is the result of a tool that cannot read or write
|
|
28
|
+
# files — the one the role is launched with.
|
|
28
29
|
#
|
|
29
|
-
#
|
|
30
|
-
#
|
|
31
|
-
#
|
|
30
|
+
# Taken out from under the guard: the tree settings, their overrides and the session handover.
|
|
31
|
+
# The setting that switches the guard off is not locked by this guard — otherwise there is no way
|
|
32
|
+
# out of the refusal at all. Sending cargo to the intake was locked by the same hole: the intake
|
|
33
|
+
# address lives in the same settings.
|
|
32
34
|
#
|
|
33
|
-
# FAIL-OPEN:
|
|
34
|
-
#
|
|
35
|
+
# FAIL-OPEN: no jq, no turn record, a foreign tool → pass. A broken guard must not get in the
|
|
36
|
+
# way of work.
|
|
35
37
|
|
|
36
|
-
#
|
|
38
|
+
# Its own name in observations: the refusal is written by the shared deny tail, not by the guard.
|
|
37
39
|
RT_GUARD_NAME=exam-guard
|
|
38
40
|
|
|
39
41
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
@@ -44,21 +46,21 @@ input="$RT_HOOK_INPUT"
|
|
|
44
46
|
[ -z "$input" ] && exit 0
|
|
45
47
|
command -v jq >/dev/null 2>&1 || exit 0
|
|
46
48
|
|
|
47
|
-
#
|
|
48
|
-
#
|
|
49
|
-
#
|
|
49
|
+
# A role disabled by the tree does not hold the guard: the list of disabled roles lies in the tree
|
|
50
|
+
# settings, and a helper next door reads it. Unreadable settings do not count as disabling — the
|
|
51
|
+
# guard works as before.
|
|
50
52
|
rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
51
53
|
# shellcheck disable=SC1090
|
|
52
54
|
[ -f "$rt_hooks_dir/roles.sh" ] && . "$rt_hooks_dir/roles.sh" 2>/dev/null
|
|
53
55
|
command -v rt_role_off >/dev/null 2>&1 && rt_role_off strict-teacher && exit 0
|
|
54
56
|
|
|
55
|
-
#
|
|
57
|
+
# Write targets are parsed by the shared helper — the same one the edit-location guard uses.
|
|
56
58
|
# shellcheck disable=SC1090
|
|
57
59
|
[ -f "$rt_hooks_dir/write-targets.sh" ] && . "$rt_hooks_dir/write-targets.sh" 2>/dev/null
|
|
58
60
|
command -v rt_write_targets >/dev/null 2>&1 || rt_write_targets() { cat >/dev/null; }
|
|
59
61
|
|
|
60
|
-
#
|
|
61
|
-
#
|
|
62
|
+
# Paths the guard does not judge: the tree settings, their overrides and the session handover
|
|
63
|
+
# directory. Prints "да" if every named target is out from under the guard.
|
|
62
64
|
rt_exam_free_paths() {
|
|
63
65
|
free=1
|
|
64
66
|
while IFS= read -r target; do
|
|
@@ -68,32 +70,33 @@ rt_exam_free_paths() {
|
|
|
68
70
|
*) free=0 ;;
|
|
69
71
|
esac
|
|
70
72
|
done
|
|
71
|
-
[ "$free" = "1" ] && printf '
|
|
73
|
+
[ "$free" = "1" ] && printf 'yes'
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
tool="$(rt_hook_tool)"
|
|
75
|
-
#
|
|
76
|
-
#
|
|
77
|
+
# The second exam is asked when the draft is lifted: the work is over, and by then the delivery
|
|
78
|
+
# rules were read long ago — the whole session passed between their reading and this minute.
|
|
77
79
|
ready=0
|
|
78
80
|
case "$tool" in
|
|
79
81
|
Edit | Write | MultiEdit | mcp__webstorm__create_new_file)
|
|
80
82
|
target="$(printf '%s' "$input" | jq -r '.tool_input.file_path // .tool_input.pathInProject // empty' 2>/dev/null)"
|
|
81
|
-
[ -n "$target" ] && [ "$(printf '%s\n' "$target" | rt_exam_free_paths)" = "
|
|
83
|
+
[ -n "$target" ] && [ "$(printf '%s\n' "$target" | rt_exam_free_paths)" = "yes" ] && exit 0
|
|
82
84
|
;;
|
|
83
85
|
Bash | mcp__webstorm__execute_terminal_command)
|
|
84
86
|
cmd="$(rt_hook_cmd)"
|
|
85
|
-
#
|
|
86
|
-
#
|
|
87
|
-
#
|
|
87
|
+
# Lifting the draft is a client call, not an occurrence of the words: a command that only
|
|
88
|
+
# writes about lifting — a line in the proposals file, a commit body, an incident analysis
|
|
89
|
+
# — was checked the same as the lifting itself, and the refusal came on an attempt to
|
|
90
|
+
# describe this defect.
|
|
88
91
|
if printf '%s' "$cmd" | grep -qE "${RT_CMD_BOUND}(gh[[:space:]]+pr[[:space:]]+ready|glab[[:space:]]+mr[[:space:]]+update[^|;&]*--ready)([[:space:]]|\$)"; then
|
|
89
92
|
ready=1
|
|
90
93
|
else
|
|
91
|
-
#
|
|
92
|
-
#
|
|
93
|
-
#
|
|
94
|
+
# Writing a file through a shell call is judged the same as an edit: an honest path
|
|
95
|
+
# closed while the bypass stays open means the guard holds whoever follows the rules
|
|
96
|
+
# and lets through whoever bypasses them.
|
|
94
97
|
targets="$(printf '%s' "$cmd" | rt_write_targets)"
|
|
95
98
|
[ -z "$targets" ] && exit 0
|
|
96
|
-
[ "$(printf '%s\n' "$targets" | rt_exam_free_paths)" = "
|
|
99
|
+
[ "$(printf '%s\n' "$targets" | rt_exam_free_paths)" = "yes" ] && exit 0
|
|
97
100
|
fi
|
|
98
101
|
;;
|
|
99
102
|
*) exit 0 ;;
|
|
@@ -103,23 +106,23 @@ transcript="$(printf '%s' "$input" | jq -r '.transcript_path // empty' 2>/dev/nu
|
|
|
103
106
|
[ -z "$transcript" ] && exit 0
|
|
104
107
|
[ -f "$transcript" ] || exit 0
|
|
105
108
|
|
|
106
|
-
#
|
|
107
|
-
#
|
|
109
|
+
# The shared deny tail: two lawful moves and the lawful form of bypass, if the refusal has one.
|
|
110
|
+
# The file may not be laid out — then there is no tail, and the reason for the refusal stays.
|
|
108
111
|
# shellcheck disable=SC1090
|
|
109
112
|
[ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
|
|
110
113
|
&& . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
|
|
111
114
|
command -v rt_deny_tail >/dev/null 2>&1 || rt_deny_tail() { :; }
|
|
112
115
|
|
|
113
|
-
#
|
|
116
|
+
# The second way out of the refusal — one that does not require lifting protection.
|
|
114
117
|
#
|
|
115
|
-
#
|
|
116
|
-
#
|
|
117
|
-
#
|
|
118
|
-
#
|
|
118
|
+
# The guard used to name the list of disabled roles in the tree settings as the only way out. The
|
|
119
|
+
# environment the executor works in forbids editing such a list by a mechanism of its own, which
|
|
120
|
+
# the guard knows nothing about: one rule says "get out of here", the other says "not this way",
|
|
121
|
+
# and the work stands with a green suite and the owner's word given.
|
|
119
122
|
#
|
|
120
|
-
#
|
|
121
|
-
#
|
|
122
|
-
#
|
|
123
|
+
# The bypass is declared by the line `Exam-skip: <reason>` in the body of the last commit of the
|
|
124
|
+
# branch: it stays in history and is visible to the owner on the PR page. The reason is mandatory —
|
|
125
|
+
# a placeholder in its place does not count as a bypass, as with the documents guard.
|
|
123
126
|
rt_exam_declared_skip() {
|
|
124
127
|
git -C "${CLAUDE_PROJECT_DIR:-.}" log -1 --format=%B 2>/dev/null \
|
|
125
128
|
| grep -qE '^Exam-skip:[[:space:]]*[^[:space:]<]'
|
|
@@ -127,7 +130,7 @@ rt_exam_declared_skip() {
|
|
|
127
130
|
|
|
128
131
|
deny() {
|
|
129
132
|
if rt_exam_declared_skip; then
|
|
130
|
-
printf '
|
|
133
|
+
printf 'the exam guard: a bypass is declared in the body of the last commit by the line Exam-skip. The call is let through, the record stays in the history.\n' >&2
|
|
131
134
|
exit 0
|
|
132
135
|
fi
|
|
133
136
|
|
|
@@ -139,70 +142,78 @@ deny() {
|
|
|
139
142
|
exit 0
|
|
140
143
|
}
|
|
141
144
|
|
|
142
|
-
#
|
|
145
|
+
# The whole session is judged, not the last turn: the exam is passed once at the start and holds
|
|
146
|
+
# to the end.
|
|
143
147
|
verdict="$(jq -s -r '
|
|
144
148
|
def textof:
|
|
145
149
|
if type == "string" then .
|
|
146
150
|
elif type == "array" then (map(if type == "object" then (.text // "") else tostring end) | join("\n"))
|
|
147
151
|
else tostring end;
|
|
148
152
|
|
|
149
|
-
#
|
|
150
|
-
#
|
|
153
|
+
# The call whose answer is discarded is recognised by its identifier, and the identifier is
|
|
154
|
+
# bound by a name: a dot after a pipe means the list itself, the search over it answers zero
|
|
155
|
+
# on any non-empty list, and every answer of every tool gets muted at once — that is, the
|
|
156
|
+
# verdict is looked for in the host records alone.
|
|
157
|
+
#
|
|
158
|
+
# Tools that read and write files: their result does not count as a verdict — otherwise
|
|
159
|
+
# echoing the same line or reading a file with it passes the guard, and the real verdict
|
|
160
|
+
# does not.
|
|
151
161
|
["Bash", "Read", "Grep", "Glob", "Edit", "Write", "MultiEdit", "NotebookEdit"] as $mute
|
|
152
162
|
| [.[] | select(.type == "assistant") | (.message.content // [])[]
|
|
153
163
|
| select(.type == "tool_use") | select(.name as $n | $mute | index($n) != null) | (.id // "")] as $muted
|
|
154
164
|
|
|
155
165
|
| [ .[]
|
|
156
|
-
#
|
|
157
|
-
#
|
|
166
|
+
# The assistant text is never a verdict: writing the needed line in a reply costs one
|
|
167
|
+
# move.
|
|
158
168
|
| if .type == "assistant" then ""
|
|
159
169
|
elif .type == "user" then
|
|
160
170
|
([ ((.message.content // []) | if type == "array" then .[] else empty end
|
|
161
171
|
| select(.type == "tool_result")
|
|
162
|
-
| select((.tool_use_id // "") | if . == "" then
|
|
172
|
+
| select(((.tool_use_id // "") | if . == "" then null else . end) as $id
|
|
173
|
+
| $id == null or ($muted | index($id)) == null)
|
|
163
174
|
| .content | textof),
|
|
164
175
|
((.message.content // "") | if type == "string" then . else "" end),
|
|
165
|
-
#
|
|
166
|
-
#
|
|
176
|
+
# The call result field: the same record, another form. Discarded only when
|
|
177
|
+
# this result belongs to a reading or writing tool.
|
|
167
178
|
(. as $rec
|
|
168
179
|
| if ($rec.toolUseResult // null) == null then ""
|
|
169
180
|
elif ([($rec.message.content // []) | if type == "array" then .[] else empty end
|
|
170
181
|
| select(.type == "tool_result") | (.tool_use_id // "")]
|
|
171
|
-
| map($muted | index(
|
|
182
|
+
| map(. as $id | $muted | index($id)) | any(. != null)) then ""
|
|
172
183
|
else ($rec.toolUseResult | textof) end)
|
|
173
184
|
] | join("\n"))
|
|
174
|
-
#
|
|
175
|
-
#
|
|
185
|
+
# Host records — the role completion notice and the attachment: the host chooses their
|
|
186
|
+
# form, and they count whole.
|
|
176
187
|
else tostring end ] | join("\n")
|
|
177
|
-
| [scan("ЭКЗАМЕН:[[:space:]]
|
|
178
|
-
| if length == 0 then "
|
|
179
|
-
else (.[-1] | if .[
|
|
188
|
+
| [scan("(ЭКЗАМЕН:[[:space:]]*сдано|EXAM:[[:space:]]*passed)[[:space:]]*([0-9]+)[[:space:]]*(из|of)[[:space:]]*([0-9]+)")]
|
|
189
|
+
| if length == 0 then "none"
|
|
190
|
+
else (.[-1] | if .[1] == .[3] then "passed" else "failed" end)
|
|
180
191
|
end
|
|
181
192
|
' "$transcript" 2>/dev/null)"
|
|
182
193
|
|
|
183
|
-
#
|
|
184
|
-
#
|
|
194
|
+
# The second exam is the one placed after the PR is opened. The first does not replace it: they
|
|
195
|
+
# ask about different things, and the whole work lies between them.
|
|
185
196
|
if [ "$ready" = "1" ]; then
|
|
186
|
-
#
|
|
187
|
-
#
|
|
197
|
+
# Records are brought into one stream in order of appearance: the command and the tool result
|
|
198
|
+
# lie in different fields, and an index from one array means nothing in the other.
|
|
188
199
|
after="$(jq -s -r '
|
|
189
200
|
def textof:
|
|
190
201
|
if type == "string" then .
|
|
191
202
|
elif type == "array" then (map(if type == "object" then (.text // "") else tostring end) | join("\n"))
|
|
192
203
|
else tostring end;
|
|
193
204
|
|
|
194
|
-
#
|
|
195
|
-
#
|
|
196
|
-
#
|
|
197
|
-
#
|
|
198
|
-
#
|
|
205
|
+
# The same set of forms as in the wide selection: the verdict arrives in the form the host
|
|
206
|
+
# chose, and a role running in the background returns it as a completion notice — it has
|
|
207
|
+
# no record of the "tool result" kind. Before, this selection read only the assistant
|
|
208
|
+
# commands and the tool results, and the second exam in such a tree did not count: five
|
|
209
|
+
# rounds with a full verdict let no edit through.
|
|
199
210
|
["Bash", "Read", "Grep", "Glob", "Edit", "Write", "MultiEdit", "NotebookEdit"] as $mute
|
|
200
211
|
| [.[] | select(.type == "assistant") | (.message.content // [])[]
|
|
201
212
|
| select(.type == "tool_use") | select(.name as $n | $mute | index($n) != null) | (.id // "")] as $muted
|
|
202
213
|
|
|
203
|
-
#
|
|
204
|
-
#
|
|
205
|
-
#
|
|
214
|
+
# A record gives two strings: the command — by it the moment of opening the PR is found —
|
|
215
|
+
# and the verdict, checked by the same rules as in the wide selection. The order is the
|
|
216
|
+
# same, so counting from the found command stays correct.
|
|
206
217
|
| [ .[] | {
|
|
207
218
|
cmd: (if .type == "assistant"
|
|
208
219
|
then ([(.message.content // [])[] | select(.type == "tool_use") | (.input.command // "")] | join("\n"))
|
|
@@ -211,41 +222,42 @@ if [ "$ready" = "1" ]; then
|
|
|
211
222
|
elif .type == "user" then
|
|
212
223
|
([ ((.message.content // []) | if type == "array" then .[] else empty end
|
|
213
224
|
| select(.type == "tool_result")
|
|
214
|
-
| select((.tool_use_id // "") | if . == "" then
|
|
225
|
+
| select(((.tool_use_id // "") | if . == "" then null else . end) as $id
|
|
226
|
+
| $id == null or ($muted | index($id)) == null)
|
|
215
227
|
| .content | textof),
|
|
216
228
|
((.message.content // "") | if type == "string" then . else "" end),
|
|
217
229
|
(. as $rec
|
|
218
230
|
| if ($rec.toolUseResult // null) == null then ""
|
|
219
231
|
elif ([($rec.message.content // []) | if type == "array" then .[] else empty end
|
|
220
232
|
| select(.type == "tool_result") | (.tool_use_id // "")]
|
|
221
|
-
| map($muted | index(
|
|
233
|
+
| map(. as $id | $muted | index($id)) | any(. != null)) then ""
|
|
222
234
|
else ($rec.toolUseResult | textof) end)
|
|
223
235
|
] | join("\n"))
|
|
224
236
|
else tostring end)
|
|
225
237
|
} ] as $flow
|
|
226
238
|
| ($flow | map(.cmd | test("pr[[:space:]]+create|mr[[:space:]]+create")) | index(true)) as $opened
|
|
227
|
-
| if $opened == null then "
|
|
239
|
+
| if $opened == null then "no-pr"
|
|
228
240
|
else ($flow[($opened + 1):] | map(.say) | join("\n")
|
|
229
|
-
| [scan("ЭКЗАМЕН:[[:space:]]
|
|
230
|
-
| if length == 0 then "
|
|
231
|
-
elif (.[-1] | .[
|
|
232
|
-
else "
|
|
241
|
+
| [scan("(ЭКЗАМЕН:[[:space:]]*сдано|EXAM:[[:space:]]*passed)[[:space:]]*([0-9]+)[[:space:]]*(из|of)[[:space:]]*([0-9]+)")]
|
|
242
|
+
| if length == 0 then "none"
|
|
243
|
+
elif (.[-1] | .[1] == .[3]) then "passed"
|
|
244
|
+
else "failed" end)
|
|
233
245
|
end
|
|
234
246
|
' "$transcript" 2>/dev/null)"
|
|
235
247
|
case "$after" in
|
|
236
|
-
|
|
248
|
+
passed | no-pr) exit 0 ;;
|
|
237
249
|
*)
|
|
238
|
-
deny "BLOCKED by exam-guard:
|
|
250
|
+
deny "BLOCKED by exam-guard: the draft is lifted after the second exam, and there was none in this session. Call the role strict-teacher with the rules of delivery and with what the task demanded: a whole session passed between reading those rules and lifting the draft. The way out through the list of switched-off roles requires removing the protection, and the runtime may forbid such an edit; the second way out does not require it — declare the bypass by the line «Exam-skip: причина» in the body of the last commit of the branch: it stays in the history and is visible to the owner on the page of the request."
|
|
239
251
|
;;
|
|
240
252
|
esac
|
|
241
253
|
fi
|
|
242
254
|
|
|
243
255
|
case "$verdict" in
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
deny "BLOCKED by exam-guard:
|
|
256
|
+
passed) exit 0 ;;
|
|
257
|
+
failed)
|
|
258
|
+
deny "BLOCKED by exam-guard: the exam on the loaded rules is failed. Read the rule whole again — not the piece that was asked about — and call the role strict-teacher anew. The answer shown gives knowledge of one line, not of the rule. The way out through the list of switched-off roles requires removing the protection, and the runtime may forbid such an edit; the second way out does not require it — the bypass is declared by the line «Exam-skip: причина» in the body of the last commit of the branch."
|
|
247
259
|
;;
|
|
248
260
|
*)
|
|
249
|
-
deny "BLOCKED by exam-guard:
|
|
261
|
+
deny "BLOCKED by exam-guard: there was no exam on the loaded rules in this session. Call the role strict-teacher, hand it the list of loaded rules, answer its questions from memory and return the answers to it — the verdict it gives by the line «ЭКЗАМЕН: сдано N из 5». It counts from the answer of the role in whatever form the host delivered it, but not from the output of the shell and not from your own text: printing that line as an echo does not release the guard. The role was already called and the verdict received — then it arrived in a form the guard does not see: that is a defect of the guard, and an edit of `.claude/rt-kit.json` is taken out from under it. A loaded rule and a read rule are different things, and the price of that difference is paid by the owner."
|
|
250
262
|
;;
|
|
251
263
|
esac
|
|
@@ -1,63 +1,65 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
#
|
|
2
|
+
# A conflicting PR of one's own, for the delivery guard: while at least one handed-over piece of
|
|
3
|
+
# work is marked conflicting, a new one is not taken.
|
|
4
4
|
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
5
|
+
# There is deliberately no `# rt-hook:` line here: the event and the call pattern are declared by
|
|
6
|
+
# the guard itself, while a helper next to it registers as no hook and decides nothing on its own.
|
|
7
|
+
# It is called from the guard, uses the guard's variables and the guard's refusal — the same way as
|
|
8
|
+
# the helpers of the folder and of the signature.
|
|
8
9
|
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
10
|
+
# Why exactly so. The delivery guard stands at three points and at each one demands what is fixable
|
|
11
|
+
# at that minute, while the state of what has already been handed over it asks about nowhere. A
|
|
12
|
+
# conflict arrives into a handed-over PR through someone else's merge, without a single action by
|
|
13
|
+
# its author: a person can no longer merge it, and the PR stands until the author notices. There is
|
|
14
|
+
# nothing to notice it by — the demand to reread one's own open PRs is written as text and rests on
|
|
15
|
+
# memory: two PRs stood conflicting for a whole session, and it was the owner who noticed.
|
|
15
16
|
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
17
|
+
# It is fixable exactly at the minute when the next piece of work is taken: after it there are more
|
|
18
|
+
# conflicts, not fewer — every new PR grows from the same main branch and arrives into the same
|
|
19
|
+
# queue that will have to be caught up with.
|
|
19
20
|
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
#
|
|
21
|
+
# Four commands count as taking work here: creating a task, creating a branch for a task, moving the
|
|
22
|
+
# column into work and opening a PR. Everything a conflict is fixed by — pulling, merging,
|
|
23
|
+
# committing, pushing, switching between branches — goes as before: a guard that refuses the repair
|
|
24
|
+
# would lock the tree shut.
|
|
24
25
|
#
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
#
|
|
26
|
+
# Only an outright "conflicts" is judged. While the hosting computes mergeability it answers with
|
|
27
|
+
# uncertainty — and it computes it again after every edit of the main branch — and reading
|
|
28
|
+
# uncertainty as a conflict would mean refusing work at every fresh tip.
|
|
28
29
|
#
|
|
29
|
-
#
|
|
30
|
+
# FAIL-OPEN: no profile function, no network, no machine account — the tier is skipped.
|
|
30
31
|
|
|
31
32
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
32
|
-
#
|
|
33
|
-
#
|
|
33
|
+
# The helper takes the start of a call from the same place as every guard does. It is sourced here
|
|
34
|
+
# too, although the calling guard has already done so: an empty pattern would turn the sign into a
|
|
35
|
+
# word search over the whole line.
|
|
34
36
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
|
|
35
37
|
|
|
36
38
|
rt_delivery_conflict() {
|
|
37
|
-
#
|
|
38
|
-
#
|
|
39
|
+
# The sign of taking work is read from the text of the command and stands first: the query goes
|
|
40
|
+
# to the network, and paying for it on every shell command is not allowed.
|
|
39
41
|
taking=''
|
|
40
42
|
case "$cmd" in
|
|
41
|
-
*"${task_new}"*) taking='
|
|
43
|
+
*"${task_new}"*) taking='creating a task' ;;
|
|
42
44
|
esac
|
|
43
|
-
#
|
|
44
|
-
#
|
|
45
|
+
# Moving the column is judged together with the name of the work column: a move into review and
|
|
46
|
+
# into closed is the end of the work, not its beginning.
|
|
45
47
|
if [ -z "$taking" ] && [ -n "$task_move" ]; then
|
|
46
48
|
case "$cmd" in
|
|
47
49
|
*"${task_move}"*)
|
|
48
50
|
case "$cmd" in
|
|
49
|
-
*"${RT_BOARD_INPROGRESS_KEY:-in-progress}"*) taking='
|
|
51
|
+
*"${RT_BOARD_INPROGRESS_KEY:-in-progress}"*) taking='moving the column into work' ;;
|
|
50
52
|
esac
|
|
51
53
|
;;
|
|
52
54
|
esac
|
|
53
55
|
fi
|
|
54
56
|
if [ -z "$taking" ] \
|
|
55
|
-
&& printf '%s' "$cmd" | grep -qE '(^|[;&|[:space:]])git[[:space:]]+(checkout[[:space:]]+-b|switch[[:space:]]+-c)[[:space:]]+[A-Za-z]+-[0-9]+'; then
|
|
56
|
-
taking='
|
|
57
|
+
&& printf '%s' "$cmd" | grep -qE '(^|[;&|[:space:]])git[[:space:]]+(checkout([[:space:]]+-[A-Za-z-]+)*[[:space:]]+-b|switch([[:space:]]+-[A-Za-z-]+)*[[:space:]]+-c)[[:space:]]+[A-Za-z]+-[0-9]+'; then
|
|
58
|
+
taking='creating a branch for a task'
|
|
57
59
|
fi
|
|
58
60
|
if [ -z "$taking" ] \
|
|
59
61
|
&& printf '%s' "$cmd" | grep -qE "${RT_CMD_BOUND}(gh[[:space:]]+pr[[:space:]]+create|glab[[:space:]]+mr[[:space:]]+create)([[:space:]]|\$)"; then
|
|
60
|
-
taking='
|
|
62
|
+
taking='opening a request'
|
|
61
63
|
fi
|
|
62
64
|
[ -z "$taking" ] && return 0
|
|
63
65
|
|
|
@@ -75,11 +77,11 @@ ${stuck}
|
|
|
75
77
|
EOF
|
|
76
78
|
[ -z "$listed" ] && return 0
|
|
77
79
|
|
|
78
|
-
deny "BLOCKED: ${taking}
|
|
80
|
+
deny "BLOCKED: ${taking} while a conflicting request of your own stands. What was handed over conflicts with the main branch, and a person cannot merge it:
|
|
79
81
|
|
|
80
82
|
${listed}
|
|
81
83
|
|
|
82
|
-
|
|
84
|
+
The conflict arrives by someone else's merge, without a single action by the author of the request: it stands until it is caught up with. New work does not fix it — it adds one more branch to the queue, growing from the same main and falling behind the same way.
|
|
83
85
|
|
|
84
|
-
|
|
86
|
+
There is one move from here: pull the main branch, merge it into the named branch, resolve the conflict and send it — and only then take new work. What is fixed by what — the pattern git-workflow-freshness."
|
|
85
87
|
}
|