@rt-tools/agent-kit 0.26.0 → 0.28.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/cargo-writer.md +54 -0
- package/assets/checks/board-epic-link.github.mjs +29 -0
- package/assets/checks/board-epic-plan.github.mjs +86 -0
- package/assets/checks/board-epics.github.mjs +217 -69
- package/assets/checks/board-long-work.github.mjs +5 -1
- package/assets/checks/board-pull-state.github.mjs +163 -0
- package/assets/checks/board-task-dirs.github.mjs +98 -0
- package/assets/checks/board.github.mjs +8 -91
- package/assets/checks/check-board.github.mjs +25 -165
- package/assets/checks/check-glossary.mjs +10 -2
- package/assets/checks/check-lib-layers.mjs +24 -1
- package/assets/checks/check-prose-style.mjs +19 -3
- package/assets/checks/check-reuse.mjs +26 -2
- package/assets/checks/check-schema-drift.mjs +19 -3
- package/assets/checks/check-specs.mjs +8 -1
- package/assets/checks/epic-table.github.mjs +268 -0
- package/assets/checks/lib-boundaries.mjs +2 -2
- package/assets/checks/lib-common.mjs +46 -0
- package/assets/checks/lib-manifests.mjs +18 -13
- package/assets/checks/rt-kit-checks.config.mjs +19 -0
- package/assets/checks/signals.mjs +39 -5
- package/assets/checks/spec-anchors.mjs +48 -4
- package/assets/checks/spec-common.mjs +40 -6
- package/assets/checks/spec-contract.mjs +33 -7
- package/assets/checks/spec-scenarios.mjs +24 -1
- package/assets/checks/specs-for.mjs +214 -0
- package/assets/checks/task-new.github.mjs +237 -6
- package/assets/commands/night.md +115 -0
- package/assets/defaults/gate-map.sh +20 -5
- package/assets/defaults/project.sh +13 -0
- package/assets/defaults/turn-map.md +3 -1
- package/assets/docs/GLOSSARY.md +22 -22
- package/assets/hooks/browser-device-id.sh +4 -0
- package/assets/hooks/browser-guard-device-id.sh +4 -0
- package/assets/hooks/commit-msg.sh +3 -0
- package/assets/hooks/dev-server-guard.sh +64 -31
- package/assets/hooks/epic-over.sh +49 -0
- package/assets/hooks/epic-stop-guard.sh +108 -0
- package/assets/hooks/exam-guard.sh +10 -10
- package/assets/hooks/git-guard-delivery-conflict.sh +56 -1
- package/assets/hooks/git-guard-delivery-draft.sh +10 -6
- package/assets/hooks/git-guard-delivery-epic.sh +167 -0
- package/assets/hooks/git-guard-delivery-signature.sh +32 -2
- package/assets/hooks/git-guard-delivery-tree.sh +50 -0
- package/assets/hooks/git-guard-delivery.sh +71 -27
- package/assets/hooks/git-guard-discard.sh +144 -0
- package/assets/hooks/git-guard-push-tests.sh +36 -16
- package/assets/hooks/handoff-entry-guard.sh +20 -2
- package/assets/hooks/prose-style-guard.sh +31 -8
- package/assets/hooks/qa-dataid-guard.sh +33 -11
- package/assets/hooks/reuse-first-guard.sh +29 -4
- package/assets/hooks/rule-article.sh +3 -0
- package/assets/hooks/rule-source-guard.sh +17 -2
- package/assets/hooks/skill-gate-layers.sh +4 -0
- package/assets/hooks/skill-gate.sh +7 -0
- package/assets/hooks/skill-loaded.sh +4 -0
- package/assets/hooks/sql-guard-parse.sh +3 -0
- package/assets/hooks/sql-guard-request.sh +3 -0
- package/assets/hooks/sql-guard-target.sh +3 -0
- package/assets/hooks/sql-guard-write.sh +21 -2
- package/assets/hooks/stand-login-guard.sh +3 -0
- package/assets/hooks/turn-exit-guard.sh +55 -67
- package/assets/hooks/turn-exit-patterns.sh +28 -1
- package/assets/hooks/turn-exit-verdict.sh +84 -0
- package/assets/hooks/utf8.sh +3 -0
- package/assets/hooks/waiting-turn-guard.sh +11 -1
- package/assets/hooks/write-targets.sh +3 -0
- package/assets/laws/delivery.md +37 -7
- package/assets/laws/verifiability.md +22 -4
- package/assets/patterns/git-workflow-commit.azure.md +1 -1
- package/assets/patterns/git-workflow-commit.github.md +9 -2
- package/assets/patterns/git-workflow-commit.gitlab.md +1 -1
- package/assets/patterns/git-workflow-merge.md +8 -5
- package/assets/patterns/git-workflow-pr.azure.md +1 -1
- package/assets/patterns/git-workflow-pr.github.md +44 -18
- package/assets/patterns/git-workflow-pr.gitlab.md +1 -1
- package/assets/patterns/git-workflow-stack.md +32 -9
- package/assets/patterns/status-report-table.github.md +11 -0
- package/assets/patterns/task-flow-close.md +96 -90
- package/assets/patterns/task-flow-start.md +40 -26
- package/assets/patterns/ts-procedure.md +6 -0
- package/assets/pitfalls/agent-kit.md +19 -0
- package/assets/pitfalls/git-workflow.github.md +44 -0
- package/assets/pitfalls/task-flow.md +25 -23
- package/assets/rules/autonomous-work.md +15 -3
- package/assets/rules/browser-verification.md +8 -0
- package/assets/rules/deploy-flow.github.md +6 -0
- package/assets/rules/doc-style.md +13 -4
- package/assets/rules/git-workflow.azure.md +10 -0
- package/assets/rules/git-workflow.github.md +144 -126
- package/assets/rules/git-workflow.gitlab.md +10 -0
- package/assets/rules/lib-layers.md +11 -0
- package/assets/rules/spec-driven.md +17 -1
- package/assets/rules/status-report.md +7 -0
- package/assets/rules/task-flow.md +78 -54
- package/assets/rules/testing.md +7 -0
- package/assets/rules/turn-conduct.md +30 -3
- package/assets/samples/tasks/_template/plan.md +4 -1
- package/assets/skills/agent-kit.md +40 -25
- package/bin/agent-kit.d.ts.map +1 -1
- package/bin/agent-kit.js +9 -2
- package/bin/agent-kit.js.map +1 -1
- package/lib/cargo-prose.d.ts +41 -0
- package/lib/cargo-prose.d.ts.map +1 -0
- package/lib/cargo-prose.js +88 -0
- package/lib/cargo-prose.js.map +1 -0
- package/lib/cargo.d.ts +12 -1
- package/lib/cargo.d.ts.map +1 -1
- package/lib/cargo.js +8 -2
- package/lib/cargo.js.map +1 -1
- package/lib/commands.d.ts +1 -1
- package/lib/commands.d.ts.map +1 -1
- package/lib/commands.js +59 -2
- package/lib/commands.js.map +1 -1
- package/lib/fate.d.ts +29 -0
- package/lib/fate.d.ts.map +1 -0
- package/lib/fate.js +147 -0
- package/lib/fate.js.map +1 -0
- package/lib/hooks-map.d.ts +5 -0
- package/lib/hooks-map.d.ts.map +1 -1
- package/lib/hooks-map.js +9 -3
- package/lib/hooks-map.js.map +1 -1
- package/lib/override-marks.d.ts +7 -0
- package/lib/override-marks.d.ts.map +1 -1
- package/lib/override-marks.js +14 -0
- package/lib/override-marks.js.map +1 -1
- package/lib/plan.d.ts +2 -0
- package/lib/plan.d.ts.map +1 -1
- package/lib/plan.js +8 -0
- package/lib/plan.js.map +1 -1
- package/lib/proposals.d.ts +25 -0
- package/lib/proposals.d.ts.map +1 -1
- package/lib/proposals.js +43 -1
- package/lib/proposals.js.map +1 -1
- package/lib/ship.d.ts +29 -2
- package/lib/ship.d.ts.map +1 -1
- package/lib/ship.js +34 -0
- package/lib/ship.js.map +1 -1
- package/lib/shipment.d.ts.map +1 -1
- package/lib/shipment.fixture.d.ts +8 -1
- package/lib/shipment.fixture.d.ts.map +1 -1
- package/lib/shipment.fixture.js +9 -0
- package/lib/shipment.fixture.js.map +1 -1
- package/lib/shipment.js +40 -14
- package/lib/shipment.js.map +1 -1
- package/package.json +1 -1
- package/rt-tools-agent-kit-0.28.0.tgz +0 -0
- package/rt-tools-agent-kit-0.26.0.tgz +0 -0
|
@@ -66,6 +66,24 @@ case "$cmd" in
|
|
|
66
66
|
*--dry-run*) exit 0 ;;
|
|
67
67
|
esac
|
|
68
68
|
|
|
69
|
+
# The refusal of this gate. The shared deny tail — the two lawful moves and the lawful form of a
|
|
70
|
+
# bypass — may not be laid out; then there is no tail, and the reason stays as it was.
|
|
71
|
+
push_deny() {
|
|
72
|
+
reason="$1"
|
|
73
|
+
# shellcheck disable=SC1090
|
|
74
|
+
[ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
|
|
75
|
+
&& . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
|
|
76
|
+
command -v rt_deny_tail >/dev/null 2>&1 || rt_deny_tail() { :; }
|
|
77
|
+
deny_tail_text="$(rt_deny_tail "")"
|
|
78
|
+
[ -n "$deny_tail_text" ] && reason="${reason}
|
|
79
|
+
|
|
80
|
+
${deny_tail_text}"
|
|
81
|
+
|
|
82
|
+
jq -n --arg r "$reason" '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:$r}}' 2>/dev/null \
|
|
83
|
+
|| printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"The checks before the push did not pass."}}\n'
|
|
84
|
+
exit 0
|
|
85
|
+
}
|
|
86
|
+
|
|
69
87
|
# A branch switch in the same command is refused whole.
|
|
70
88
|
#
|
|
71
89
|
# The guard is a parse of the command BEFORE it runs: it runs the set in the tree that lies there
|
|
@@ -79,22 +97,7 @@ esac
|
|
|
79
97
|
# does not fall here: a fresh branch has the same tree as it had.
|
|
80
98
|
if printf '%s' "$cmd" | grep -qE "${RT_CMD_BOUND}git[[:space:]]+(checkout|switch)[[:space:]]+" &&
|
|
81
99
|
! printf '%s' "$cmd" | grep -qE 'git[[:space:]]+(checkout([[:space:]]+-[A-Za-z-]+)*[[:space:]]+-b|switch([[:space:]]+-[A-Za-z-]+)*[[:space:]]+-c)([[:space:]]|$)'; then
|
|
82
|
-
|
|
83
|
-
# The shared deny tail: the two lawful moves and the lawful form of bypass, if the refusal has
|
|
84
|
-
# one. The file may not be laid out — then there is no tail, and the reason for the refusal
|
|
85
|
-
# stays as it was.
|
|
86
|
-
# shellcheck disable=SC1090
|
|
87
|
-
[ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
|
|
88
|
-
&& . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
|
|
89
|
-
command -v rt_deny_tail >/dev/null 2>&1 || rt_deny_tail() { :; }
|
|
90
|
-
deny_tail_text="$(rt_deny_tail "")"
|
|
91
|
-
[ -n "$deny_tail_text" ] && reason="${reason}
|
|
92
|
-
|
|
93
|
-
${deny_tail_text}"
|
|
94
|
-
|
|
95
|
-
jq -n --arg r "$reason" '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:$r}}' 2>/dev/null \
|
|
96
|
-
|| printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"Switching the branch and pushing by one command."}}\n'
|
|
97
|
-
exit 0
|
|
100
|
+
push_deny "BLOCKED: switching the branch and pushing by one command. The gate set runs on the tree that lies there at the minute the command is parsed — that is, on the FORMER branch, not the one that leaves for the hosting. A green set then reads as a check of what left, though it checked something else. Split the calls: switch first, then push by a separate command."
|
|
98
101
|
fi
|
|
99
102
|
|
|
100
103
|
workdir="$(rt_hook_cwd)"
|
|
@@ -103,6 +106,23 @@ cd "$workdir" 2>/dev/null || exit 0
|
|
|
103
106
|
git rev-parse --is-inside-work-tree >/dev/null 2>&1 || exit 0
|
|
104
107
|
[ -f package.json ] || exit 0
|
|
105
108
|
|
|
109
|
+
# Sending from a second working copy is refused whole.
|
|
110
|
+
#
|
|
111
|
+
# The second copy is taken for reading: the merge of the main branch goes on it while the session's
|
|
112
|
+
# copy holds someone else's uncommitted work. A call made from there is judged by the copy the
|
|
113
|
+
# session stands in — that is, by a foreign tree: its stale archive and its half-written spec refuse
|
|
114
|
+
# the call, while the contribution actually leaving is never checked at all.
|
|
115
|
+
moved="$(printf '%s' "$cmd" | sed -nE 's/.*(^|[;&|[:space:]])cd[[:space:]]+([^[:space:];&|]+).*/\2/p' | head -1)"
|
|
116
|
+
moved="${moved%\'}"; moved="${moved#\'}"
|
|
117
|
+
moved="${moved%\"}"; moved="${moved#\"}"
|
|
118
|
+
if [ -n "$moved" ] && [ -d "$moved" ]; then
|
|
119
|
+
moved_root="$(git -C "$moved" rev-parse --show-toplevel 2>/dev/null)"
|
|
120
|
+
here_root="$(git rev-parse --show-toplevel 2>/dev/null)"
|
|
121
|
+
if [ -n "$moved_root" ] && [ -n "$here_root" ] && [ "$moved_root" != "$here_root" ]; then
|
|
122
|
+
push_deny "BLOCKED: the call goes from a second working copy — «${moved_root}», while the session stands in «${here_root}». The gate set runs where the session was started, not where the call was made: someone else's uncommitted work refuses it, and the contribution actually leaving passes unchecked. The second copy is for reading; bring the result of the merge back and send from the copy the session stands in."
|
|
123
|
+
fi
|
|
124
|
+
fi
|
|
125
|
+
|
|
106
126
|
# The tree profile: first the package default, over it the project override, if there is one. A
|
|
107
127
|
# function declared in the override replaces the default whole and may call it back by the
|
|
108
128
|
# `_default` suffix. There is neither — the hook passes: an empty guard is better than a guard
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# rt-hook: PreToolUse Edit|Write|MultiEdit
|
|
3
|
-
# Requires: rules/task-flow.md, hooks/deny-tail.sh
|
|
2
|
+
# rt-hook: PreToolUse Edit|Write|MultiEdit|Bash|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_tool
|
|
3
|
+
# Requires: rules/task-flow.md, hooks/deny-tail.sh, hooks/write-targets.sh
|
|
4
4
|
# Handover entry guard: a session started from a handover edits no file until the work-conduct rule
|
|
5
5
|
# is loaded.
|
|
6
6
|
#
|
|
@@ -26,9 +26,27 @@ input="$RT_HOOK_INPUT"
|
|
|
26
26
|
[ -z "$input" ] && exit 0
|
|
27
27
|
command -v jq >/dev/null 2>&1 || exit 0
|
|
28
28
|
|
|
29
|
+
rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
30
|
+
|
|
31
|
+
# The write targets are taken by the shared parse: the same sign serves the guard of the place of an
|
|
32
|
+
# edit, and two copies of it would let through different shapes of a write. No file — a silent
|
|
33
|
+
# default remains, so that the guard does not break on an incomplete layout.
|
|
34
|
+
# shellcheck disable=SC1090
|
|
35
|
+
[ -f "$rt_hooks_dir/write-targets.sh" ] && . "$rt_hooks_dir/write-targets.sh" 2>/dev/null
|
|
36
|
+
command -v rt_write_targets >/dev/null 2>&1 || rt_write_targets() { cat >/dev/null; }
|
|
37
|
+
|
|
29
38
|
tool="$(rt_hook_tool)"
|
|
30
39
|
case "$tool" in
|
|
31
40
|
Edit | Write | MultiEdit) ;;
|
|
41
|
+
# A write by a shell command is the same edit of a file: the same session with the name of the
|
|
42
|
+
# shell instead of the name of the edit worked past the rule whole. A command that writes
|
|
43
|
+
# nothing the guard does not wake: it must not get in the way of reading the tree, which is
|
|
44
|
+
# exactly what the order of entry begins with.
|
|
45
|
+
Bash | mcp__webstorm__execute_terminal_command | mcp__webstorm__execute_tool)
|
|
46
|
+
cmd="$(rt_hook_cmd)"
|
|
47
|
+
[ -z "$cmd" ] && exit 0
|
|
48
|
+
[ -n "$(printf '%s' "$cmd" | rt_write_targets)" ] || exit 0
|
|
49
|
+
;;
|
|
32
50
|
*) exit 0 ;;
|
|
33
51
|
esac
|
|
34
52
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# rt-hook: PreToolUse Edit|Write|MultiEdit
|
|
3
|
-
# Requires: checks/check-prose-style.mjs, hooks/deny-tail.sh
|
|
2
|
+
# rt-hook: PreToolUse Edit|Write|MultiEdit|Bash|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_tool
|
|
3
|
+
# Requires: checks/check-prose-style.mjs, hooks/deny-tail.sh, hooks/write-targets.sh
|
|
4
4
|
# Prose guard: officialese and words that are not written in this tree do not reach the file.
|
|
5
5
|
#
|
|
6
6
|
# The rule about texts demands plain words, and this was held only by the memory of whoever writes:
|
|
@@ -11,6 +11,11 @@
|
|
|
11
11
|
# separate piece of work, and refusing an edit of a neighbouring line because of it would make the
|
|
12
12
|
# guard bypassed out of necessity.
|
|
13
13
|
#
|
|
14
|
+
# A write by a shell command is judged the same as one by the edit tool: the same text with the name
|
|
15
|
+
# of the shell instead of the name of the edit gave silence, and a document written by a heredoc
|
|
16
|
+
# went past the wording convention whole. The path is taken by the shared parse of write targets,
|
|
17
|
+
# and the new text is the body of the command — the written text stands inside it.
|
|
18
|
+
#
|
|
14
19
|
# FAIL-OPEN: no node, no check, a foreign tool, not `.md` → pass.
|
|
15
20
|
|
|
16
21
|
# Its own name in the observations: the refusal is recorded by the shared deny tail, not by the
|
|
@@ -26,13 +31,34 @@ input="$RT_HOOK_INPUT"
|
|
|
26
31
|
command -v jq >/dev/null 2>&1 || exit 0
|
|
27
32
|
command -v node >/dev/null 2>&1 || exit 0
|
|
28
33
|
|
|
34
|
+
rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
35
|
+
|
|
36
|
+
# The write targets are taken by the shared parse: the same sign serves the guard of the place of an
|
|
37
|
+
# edit, and two copies of it would let through different shapes of a write. No file — a silent
|
|
38
|
+
# default remains, so that the guard does not break on an incomplete layout.
|
|
39
|
+
# shellcheck disable=SC1090
|
|
40
|
+
[ -f "$rt_hooks_dir/write-targets.sh" ] && . "$rt_hooks_dir/write-targets.sh" 2>/dev/null
|
|
41
|
+
command -v rt_write_targets >/dev/null 2>&1 || rt_write_targets() { cat >/dev/null; }
|
|
42
|
+
|
|
29
43
|
tool="$(rt_hook_tool)"
|
|
30
44
|
case "$tool" in
|
|
31
|
-
Edit | Write | MultiEdit)
|
|
45
|
+
Edit | Write | MultiEdit)
|
|
46
|
+
path="$(rt_hook_file)"
|
|
47
|
+
added="$(printf '%s' "$input" | jq -r '.tool_input.new_string // .tool_input.content // ([.tool_input.edits[]?.new_string] | join("\n")) // empty' 2>/dev/null)"
|
|
48
|
+
;;
|
|
49
|
+
Bash | mcp__webstorm__execute_terminal_command | mcp__webstorm__execute_tool)
|
|
50
|
+
cmd="$(rt_hook_cmd)"
|
|
51
|
+
[ -z "$cmd" ] && exit 0
|
|
52
|
+
# The first document among the write targets. A command writing several is judged by one of
|
|
53
|
+
# them: the text is one for the whole command, and a second refusal would repeat the first.
|
|
54
|
+
path="$(printf '%s' "$cmd" | rt_write_targets | grep -m1 '\.md$')"
|
|
55
|
+
# The new text is the body of the command: the written text stands inside it, and the
|
|
56
|
+
# findings of the check name the very lines that go into the file.
|
|
57
|
+
added="$cmd"
|
|
58
|
+
;;
|
|
32
59
|
*) exit 0 ;;
|
|
33
60
|
esac
|
|
34
61
|
|
|
35
|
-
path="$(rt_hook_file)"
|
|
36
62
|
case "$path" in
|
|
37
63
|
*.md) ;;
|
|
38
64
|
*) exit 0 ;;
|
|
@@ -41,13 +67,10 @@ esac
|
|
|
41
67
|
# The archive and the task folders are not judged: the archive is not edited at all, and the
|
|
42
68
|
# progress is written in haste and lives until the merge.
|
|
43
69
|
case "$path" in
|
|
44
|
-
*/docs/archive/* | */docs/tasks/*) exit 0 ;;
|
|
70
|
+
*/docs/archive/* | */docs/tasks/* | docs/archive/* | docs/tasks/*) exit 0 ;;
|
|
45
71
|
esac
|
|
46
72
|
|
|
47
|
-
added="$(printf '%s' "$input" | jq -r '.tool_input.new_string // .tool_input.content // ([.tool_input.edits[]?.new_string] | join("\n")) // empty' 2>/dev/null)"
|
|
48
73
|
[ -z "$added" ] && exit 0
|
|
49
|
-
|
|
50
|
-
rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
51
74
|
check=""
|
|
52
75
|
for candidate in "$rt_hooks_dir/../checks/check-prose-style.mjs" "$rt_hooks_dir/../rt-kit/checks/check-prose-style.mjs" "${CLAUDE_PROJECT_DIR:-.}/tools/check-prose-style.mjs"; do
|
|
53
76
|
[ -f "$candidate" ] && check="$candidate" && break
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# rt-hook: PreToolUse Edit|Write|MultiEdit|mcp__webstorm__create_new_file
|
|
3
|
-
# Requires: hooks/profile-check.sh, hooks/deny-tail.sh
|
|
2
|
+
# rt-hook: PreToolUse Edit|Write|MultiEdit|mcp__webstorm__create_new_file|Bash|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_tool
|
|
3
|
+
# Requires: hooks/profile-check.sh, hooks/deny-tail.sh, hooks/write-targets.sh
|
|
4
4
|
# Anchor guard for end-to-end tests. PreToolUse on a markup edit.
|
|
5
5
|
#
|
|
6
6
|
# Specs address elements only through this attribute. Styling classes change together with the
|
|
@@ -38,15 +38,33 @@ input="$RT_HOOK_INPUT"
|
|
|
38
38
|
command -v jq >/dev/null 2>&1 || exit 0
|
|
39
39
|
command -v perl >/dev/null 2>&1 || exit 0
|
|
40
40
|
|
|
41
|
+
rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
42
|
+
|
|
43
|
+
# The write targets are taken by the shared parse: the same sign serves the guard of the place of an
|
|
44
|
+
# edit, and two copies of it would let through different shapes of a write. No file — a silent
|
|
45
|
+
# default remains, so that the guard does not break on an incomplete layout.
|
|
46
|
+
# shellcheck disable=SC1090
|
|
47
|
+
[ -f "$rt_hooks_dir/write-targets.sh" ] && . "$rt_hooks_dir/write-targets.sh" 2>/dev/null
|
|
48
|
+
command -v rt_write_targets >/dev/null 2>&1 || rt_write_targets() { cat >/dev/null; }
|
|
49
|
+
|
|
41
50
|
tool="$(rt_hook_tool)"
|
|
51
|
+
cmd=""
|
|
42
52
|
case "$tool" in
|
|
43
53
|
# The IDE tool creates a file from the same two pieces of data, only names them differently —
|
|
44
54
|
# without this branch markup was created past all the checks.
|
|
45
|
-
Edit | Write | MultiEdit | mcp__webstorm__create_new_file)
|
|
55
|
+
Edit | Write | MultiEdit | mcp__webstorm__create_new_file)
|
|
56
|
+
path="$(printf '%s' "$input" | jq -r '.tool_input.file_path // .tool_input.pathInProject // empty' 2>/dev/null)"
|
|
57
|
+
;;
|
|
58
|
+
# Markup written by a shell command is judged the same: the same text with the name of the shell
|
|
59
|
+
# instead of the name of the edit gave silence, and a screen written by a heredoc got into the
|
|
60
|
+
# tree without a single anchor.
|
|
61
|
+
Bash | mcp__webstorm__execute_terminal_command | mcp__webstorm__execute_tool)
|
|
62
|
+
cmd="$(rt_hook_cmd)"
|
|
63
|
+
[ -z "$cmd" ] && exit 0
|
|
64
|
+
path="$(printf '%s' "$cmd" | rt_write_targets | grep -m1 '\.html$')"
|
|
65
|
+
;;
|
|
46
66
|
*) exit 0 ;;
|
|
47
67
|
esac
|
|
48
|
-
|
|
49
|
-
path="$(printf '%s' "$input" | jq -r '.tool_input.file_path // .tool_input.pathInProject // empty' 2>/dev/null)"
|
|
50
68
|
# The path from the IDE arrives relative to the tree root, while all the samples below are
|
|
51
69
|
# written from the application directory. Bring it to one form once, so the rules do not double.
|
|
52
70
|
case "$path" in
|
|
@@ -59,7 +77,6 @@ case "$path" in
|
|
|
59
77
|
esac
|
|
60
78
|
|
|
61
79
|
# The tree profile: first the package default, over it the project override, if there is one.
|
|
62
|
-
rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
63
80
|
for profile in "$rt_hooks_dir/../rt-kit/defaults/project.sh" "$rt_hooks_dir/../defaults/project.sh" "${CLAUDE_PROJECT_DIR:-.}/.claude/rt-kit/defaults/project.sh" "${CLAUDE_PROJECT_DIR:-.}/.claude/rt-kit/project.sh"; do
|
|
64
81
|
# shellcheck disable=SC1090
|
|
65
82
|
[ -f "$profile" ] && . "$profile" 2>/dev/null
|
|
@@ -83,11 +100,16 @@ if [ -n "${RT_QA_SKIP_RE:-}" ] && printf '%s' "$path" | grep -qE "$RT_QA_SKIP_RE
|
|
|
83
100
|
fi
|
|
84
101
|
|
|
85
102
|
# Only the NEW text is checked: what already lay in the file was not created by this edit, and
|
|
86
|
-
# demanding an anchor from someone else's line means refusing the edit of a neighbouring one.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
103
|
+
# demanding an anchor from someone else's line means refusing the edit of a neighbouring one. For a
|
|
104
|
+
# shell command the new text is the body of the command: the written markup stands inside it.
|
|
105
|
+
if [ -n "$cmd" ]; then
|
|
106
|
+
added="$cmd"
|
|
107
|
+
else
|
|
108
|
+
added="$(printf '%s' "$input" | jq -r '
|
|
109
|
+
[ .tool_input.content?, .tool_input.text?, .tool_input.new_string?, (.tool_input.edits[]?.new_string) ]
|
|
110
|
+
| map(select(. != null)) | join("\n")
|
|
111
|
+
' 2>/dev/null)"
|
|
112
|
+
fi
|
|
91
113
|
[ -z "$added" ] && exit 0
|
|
92
114
|
|
|
93
115
|
decorative="$(rt_needs rt_qa_decorative qa-dataid-guard && rt_qa_decorative 2>/dev/null)"
|
|
@@ -200,7 +200,10 @@ rt_bundles=''
|
|
|
200
200
|
rt_own_signals=''
|
|
201
201
|
rt_backend_roots=''
|
|
202
202
|
if [ -f "$rt_checks_json" ]; then
|
|
203
|
-
|
|
203
|
+
# A bundle is declared either by the name alone or by a pair of the name and the area of the
|
|
204
|
+
# tree. Both forms are read into one shape — the name, a tab, the area as a list: further on the
|
|
205
|
+
# area goes onto the sign itself, and there it is read the same way the full check reads it.
|
|
206
|
+
rt_bundles="$(jq -r '.reuse.bundles[]? | if type == "object" then "\(.name // "")\t\((.roots // []) | if type == "string" then [.] else . end | tojson)" else "\(.)\t[]" end' "$rt_checks_json" 2>/dev/null)"
|
|
204
207
|
own="$(jq -r '.reuse.signals // empty' "$rt_checks_json" 2>/dev/null)"
|
|
205
208
|
[ -n "$own" ] && rt_own_signals="${CLAUDE_PROJECT_DIR:-.}/$own"
|
|
206
209
|
# By the same key the full check reads them: a second declaration of the same roots would
|
|
@@ -219,10 +222,15 @@ signals_json() {
|
|
|
219
222
|
[ -n "$rt_signals_dir" ] || return 0
|
|
220
223
|
[ -d "$rt_signals_dir" ] || return 0
|
|
221
224
|
# The layout header is stripped before parsing: JSON has no comment, and the parse falls on it.
|
|
222
|
-
|
|
225
|
+
while IFS="$(printf '\t')" read -r name roots; do
|
|
226
|
+
[ -z "$name" ] && continue
|
|
223
227
|
file="$rt_signals_dir/$name.json"
|
|
224
|
-
[ -f "$file" ]
|
|
225
|
-
|
|
228
|
+
[ -f "$file" ] || continue
|
|
229
|
+
grep -v '^# rt-kit ' "$file" \
|
|
230
|
+
| jq -c --argjson roots "${roots:-[]}" '.signals[]? | if ($roots | length) > 0 then .roots = $roots else . end' 2>/dev/null
|
|
231
|
+
done <<BUNDLES
|
|
232
|
+
$rt_bundles
|
|
233
|
+
BUNDLES
|
|
226
234
|
[ -n "$rt_own_signals" ] && [ -f "$rt_own_signals" ] && grep -v '^# rt-kit ' "$rt_own_signals" | jq -c '.signals[]?' 2>/dev/null
|
|
227
235
|
}
|
|
228
236
|
|
|
@@ -254,6 +262,23 @@ while IFS= read -r signal; do
|
|
|
254
262
|
[ -n "$skip_backend" ] && continue
|
|
255
263
|
fi
|
|
256
264
|
|
|
265
|
+
# The area of the tree the bundle was declared with. A tree has more than one source of look
|
|
266
|
+
# oftener than one, and a sign of the first answers falsely over the second: an application
|
|
267
|
+
# assembled from another set of ready-made code drops out of the judging by the declaration.
|
|
268
|
+
# The full check reads the same field — they must not diverge. The boundary is judged by the
|
|
269
|
+
# directory: `apps/admin` must not take in `apps/administration`.
|
|
270
|
+
roots="$(printf '%s' "$signal" | jq -r '.roots[]? // empty' 2>/dev/null)"
|
|
271
|
+
if [ -n "$roots" ]; then
|
|
272
|
+
inside=''
|
|
273
|
+
while IFS= read -r area; do
|
|
274
|
+
[ -z "$area" ] && continue
|
|
275
|
+
case "$rel_path" in "$area" | "$area"/*) inside=1 ;; esac
|
|
276
|
+
done <<AREAS
|
|
277
|
+
$roots
|
|
278
|
+
AREAS
|
|
279
|
+
[ -z "$inside" ] && continue
|
|
280
|
+
fi
|
|
281
|
+
|
|
257
282
|
# The name pattern is checked against the path from the root of the tree, not against the file
|
|
258
283
|
# name: the layers the sign separates call their files alike, and by name they are
|
|
259
284
|
# indistinguishable. The full check checks against the path — they must not diverge.
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
# Parsing the applicability sign of a rule article. A helper: it declares no event of its own, and
|
|
3
3
|
# is sourced by whoever needs the text of an article — the rules gate in its refusal.
|
|
4
4
|
#
|
|
5
|
+
# NOT a guard: it has no `rt-hook:` declaration and hooks into no agent event. The rules gate
|
|
6
|
+
# sources it: an article says whether it applies itself, and the parsing of that lives here.
|
|
7
|
+
#
|
|
5
8
|
# A rule weighs from twenty to sixty kilobytes, while one of its articles covers a particular edit.
|
|
6
9
|
# A refusal that calls the whole rule pays the full price of the rule for the decision — and teaches
|
|
7
10
|
# the wrong thing: it is cheaper to read nothing extra, that is, to work less well explored.
|
|
@@ -123,12 +123,27 @@ while IFS= read -r candidate; do
|
|
|
123
123
|
continue
|
|
124
124
|
fi
|
|
125
125
|
|
|
126
|
+
# The override merges by the section «## », and that promise is true only of a text: a law, a
|
|
127
|
+
# rule, a pattern, a skill. A shell script and a check file have no sections at all, and the
|
|
128
|
+
# executor sent to write an override there finds nothing to merge — and learns it not from the
|
|
129
|
+
# guard but from the next layout, that is, latest of all. A promise true of a third of the
|
|
130
|
+
# cases is worse than none: people go and work by it.
|
|
131
|
+
case "$resource" in
|
|
132
|
+
*.md) override_way="an edit true only to this tree goes to the override .claude/rt-kit/overrides/${resource} — it merges by the section «## » and outlives the layout" ;;
|
|
133
|
+
*) override_way="there is no override by sections for a resource of this kind: it has no «## » sections at all, and the edit goes into the package itself" ;;
|
|
134
|
+
esac
|
|
135
|
+
|
|
126
136
|
if [ -n "$sources" ] && [ -f "$root/$sources/$resource" ]; then
|
|
127
137
|
deny "BLOCKED by rule-source-guard: «${candidate#"$root"/}» is laid out by the package, and an edit in its place is lost on the next layout — and until then the layout refuses this file whole, and the price is paid by whoever edits a neighbouring resource that day. The resource is «${resource}». Edit the source: ${sources}/${resource} — then build the package and lay it out." \
|
|
128
|
-
"
|
|
138
|
+
"$override_way"
|
|
129
139
|
fi
|
|
130
140
|
|
|
131
|
-
|
|
141
|
+
case "$resource" in
|
|
142
|
+
*.md) where="Edit the override: .claude/rt-kit/overrides/${resource} — it merges by the section «## » and outlives the layout." ;;
|
|
143
|
+
*) where="A resource of this kind has no override by sections — it has no «## » sections at all. The edit goes into the package itself and arrives here by a new edition." ;;
|
|
144
|
+
esac
|
|
145
|
+
|
|
146
|
+
deny "BLOCKED by rule-source-guard: «${candidate#"$root"/}» is laid out by the package @rt-tools/agent-kit, and an edit in its place is lost on the next layout. The resource is «${resource}». ${where}" \
|
|
132
147
|
"what is true of any tree is edited in the package itself and arrives here by a new edition"
|
|
133
148
|
done <<EOF
|
|
134
149
|
$candidates
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# Layers of the rules gate: requirements that come ON TOP of the domain one.
|
|
3
3
|
#
|
|
4
|
+
# NOT a guard: it has no `rt-hook:` declaration and hooks into no agent event. The rules gate
|
|
5
|
+
# sources it: the layers over the domain rule are a dozen and a half, and together they do not fit
|
|
6
|
+
# into a map read whole.
|
|
7
|
+
#
|
|
4
8
|
# The domain rule is chosen once by the file path — an edit has one subject, and there is one
|
|
5
9
|
# rule for it. There are a dozen and a half layers on top of it: access to the runtime is visible
|
|
6
10
|
# only in the text of the edit, observability comes together with the domain rather than instead
|
|
@@ -8,6 +8,13 @@
|
|
|
8
8
|
# and after the rule is loaded the same area passes silently — there are no repeats, and it costs
|
|
9
9
|
# almost nothing.
|
|
10
10
|
#
|
|
11
|
+
# One thing does cancel the mark, and on purpose: compaction or clearing of the session window.
|
|
12
|
+
# `hooks/skill-gate-rearm.sh` removes the record then, and every area asks for its rule once more.
|
|
13
|
+
# The mark says "the rule is in the window", not "the rule was once read": after the compaction the
|
|
14
|
+
# text is gone from the window, and a gate that kept letting through would be letting the session
|
|
15
|
+
# work from a retelling. The re-arming is told to the session in words, so that it is not read as
|
|
16
|
+
# breakage.
|
|
17
|
+
#
|
|
11
18
|
# The "file — rule" map lives not here but in two files next door, and that is not duplication.
|
|
12
19
|
# The default — `.claude/rt-kit/defaults/gate-map.sh` — is carried by the package: the trees of
|
|
13
20
|
# this workshop are built alike, and rewriting one and the same map in each of them anew would
|
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
# tell about its past calls. So the load is recorded here, per session.
|
|
7
7
|
#
|
|
8
8
|
# The hook only observes: it always passes and refuses nothing.
|
|
9
|
+
#
|
|
10
|
+
# FAIL-OPEN: no input, no name of the rule, no way to write the record — the call goes through. The
|
|
11
|
+
# record is a note for the gate, not a permission: a rule not written down is demanded a second
|
|
12
|
+
# time, and that costs one refusal, not the work.
|
|
9
13
|
|
|
10
14
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
11
15
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
# Parsing a command for the storage guard: bringing it to one shape, cutting it into segments and
|
|
3
3
|
# answering the question whether the segment delivers SQL to the server.
|
|
4
4
|
#
|
|
5
|
+
# NOT a guard: it has no `rt-hook:` declaration and hooks into no agent event. The storage guard
|
|
6
|
+
# sources it — the parsing of the request, moved out when the guard reached its length limit.
|
|
7
|
+
#
|
|
5
8
|
# There is deliberately no `# rt-hook:` line here: the event and the call pattern are declared by the
|
|
6
9
|
# guard itself, and a helper next to it is not registered as a hook and decides nothing alone.
|
|
7
10
|
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
# The request from the input of the storage guard: what exactly will go to the server and through
|
|
3
3
|
# what.
|
|
4
4
|
#
|
|
5
|
+
# NOT a guard: it has no `rt-hook:` declaration and hooks into no agent event. The storage guard
|
|
6
|
+
# sources it — one tier of its verdict, moved out when the guard reached its length limit.
|
|
7
|
+
#
|
|
5
8
|
# There is deliberately no `# rt-hook:` line here: the event and the call pattern are declared by the
|
|
6
9
|
# guard itself, and a helper next to it is not registered as a hook and decides nothing alone.
|
|
7
10
|
#
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
# The request's target for the storage guard: the production database, a throwaway check
|
|
3
3
|
# database or something else — and what is allowed on production.
|
|
4
4
|
#
|
|
5
|
+
# NOT a guard: it has no `rt-hook:` declaration and hooks into no agent event. The storage guard
|
|
6
|
+
# sources it — one tier of its verdict, moved out when the guard reached its length limit.
|
|
7
|
+
#
|
|
5
8
|
# There is no `# rt-hook:` line here on purpose: the event and the call sample are declared by the
|
|
6
9
|
# guard itself, and the helper next to it is not registered as a hook and decides nothing alone.
|
|
7
10
|
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
# The write part of the storage guard: what counts as a write, what in it is destructive for
|
|
3
3
|
# certain, where migrations go and by what a query addresses rows.
|
|
4
4
|
#
|
|
5
|
+
# NOT a guard: it has no `rt-hook:` declaration and hooks into no agent event. The storage guard
|
|
6
|
+
# sources it — one tier of its verdict, moved out when the guard reached its length limit.
|
|
7
|
+
#
|
|
5
8
|
# There is deliberately no `# rt-hook:` line here: the event and the call pattern are declared by
|
|
6
9
|
# the guard itself, while a helper next to it registers no hook and decides nothing on its own.
|
|
7
10
|
|
|
@@ -46,6 +49,16 @@ PIPE_EOF
|
|
|
46
49
|
# The exception acts PER SEGMENT. While it was checked over the whole command, one mention of
|
|
47
50
|
# `pg_dump` anywhere in the chain was enough for `-f` to stop counting as a write in all the
|
|
48
51
|
# other calls: `pg_dump … > /dev/null && psql -d app -f /tmp/x.sql` passed silently.
|
|
52
|
+
sql_delivers_file && is_write="yes"
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
# A file poured into the client names not a single SQL verb, and its content the guard does not see
|
|
56
|
+
# — so this is a write by definition. It stands in a function of its own because the answer is
|
|
57
|
+
# needed by two places: the common detection of a write above, and the early exit on a local
|
|
58
|
+
# migration below. While the loop stood in the first alone, the chain `prisma migrate deploy &&
|
|
59
|
+
# psql -d app -f fix.sql` passed silently: the exit counted a second write only by SQL verbs and by
|
|
60
|
+
# the commands that feed the pipe.
|
|
61
|
+
sql_delivers_file() {
|
|
49
62
|
while IFS= read -r seg; do
|
|
50
63
|
[ -z "$seg" ] && continue
|
|
51
64
|
# The word boundary is mandatory: `-f /tmp/pg_dump-restore.sql` is loading a dump, not
|
|
@@ -59,12 +72,13 @@ PIPE_EOF
|
|
|
59
72
|
seg_tail="$(printf '%s' "$seg" | perl -0pe 's{^.*?(?<![[:alnum:]_./-])(psql|pg_restore|prisma)(?=\s|$)}{$1}s' 2>/dev/null)"
|
|
60
73
|
[ -z "$seg_tail" ] && seg_tail="$seg"
|
|
61
74
|
if printf '%s' "$seg_tail" | grep -qE '(^|[[:space:]])(-f|--file)([[:space:]]|=)|<[[:space:]]*[^[:space:]|<]+\.(sql|dump)'; then
|
|
62
|
-
|
|
63
|
-
break
|
|
75
|
+
return 0
|
|
64
76
|
fi
|
|
65
77
|
done <<EOF
|
|
66
78
|
$segments
|
|
67
79
|
EOF
|
|
80
|
+
|
|
81
|
+
return 1
|
|
68
82
|
}
|
|
69
83
|
|
|
70
84
|
# --- destructive for certain ------------------------------------------------------------
|
|
@@ -175,6 +189,11 @@ sql_check_migrations() {
|
|
|
175
189
|
done <<MIGRATE_PIPE_EOF
|
|
176
190
|
$(client_segments)
|
|
177
191
|
MIGRATE_PIPE_EOF
|
|
192
|
+
# A file poured into the client is judged by the same sign as everywhere else. Its
|
|
193
|
+
# own set of signs here was narrower than the common one by exactly this, and the
|
|
194
|
+
# second link of `prisma migrate deploy && psql -d app -f fix.sql` fell out of the
|
|
195
|
+
# check whole: the guard sees neither the file nor its content.
|
|
196
|
+
sql_delivers_file && other_write="yes"
|
|
178
197
|
[ -z "$other_write" ] && exit 0
|
|
179
198
|
;;
|
|
180
199
|
'')
|
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
#
|
|
25
25
|
# On an error the guard passes: on a failure, a missing turn record and a repeated call the turn is
|
|
26
26
|
# ALLOWED. A broken guard must not block the conversation.
|
|
27
|
+
#
|
|
28
|
+
# FAIL-OPEN: no input, no jq, an already active turn — the turn ends as it did. A guard of the end
|
|
29
|
+
# of a turn that refuses on doubt leaves the session with no lawful end at all.
|
|
27
30
|
|
|
28
31
|
# The guard's name for the observations: it is written by the shared deny tail.
|
|
29
32
|
RT_GUARD_NAME=stand-login-guard
|