@muggleai/works 5.20.0-staging.142 → 5.20.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/dist/plugin/.claude-plugin/plugin.json +1 -1
- package/dist/plugin/.cursor-plugin/plugin.json +1 -1
- package/dist/plugin/hooks/README.md +17 -2
- package/dist/plugin/hooks/hooks.json +4 -88
- package/dist/plugin/scripts/guardrail-build-followthrough-gate.sh +13 -23
- package/dist/plugin/scripts/guardrail-build-router.sh +12 -7
- package/dist/plugin/scripts/guardrail-capability-claim.sh +27 -17
- package/dist/plugin/scripts/guardrail-classify-gate.sh +12 -7
- package/dist/plugin/scripts/guardrail-comment-reply-gate.sh +15 -26
- package/dist/plugin/scripts/guardrail-debug-path-gate.sh +14 -24
- package/dist/plugin/scripts/guardrail-dispatch.sh +34 -0
- package/dist/plugin/scripts/guardrail-e2e-gate.sh +13 -21
- package/dist/plugin/scripts/guardrail-lib.sh +91 -0
- package/dist/plugin/scripts/guardrail-offer-ran.sh +12 -20
- package/dist/plugin/scripts/guardrail-pr-opened.sh +12 -7
- package/dist/plugin/scripts/guardrail-pr-terminal.sh +12 -7
- package/dist/plugin/scripts/guardrail-record-comment-replies.sh +12 -7
- package/dist/plugin/scripts/guardrail-record-stage-read.sh +12 -7
- package/dist/plugin/scripts/guardrail-record-stage-signals.sh +12 -7
- package/dist/plugin/scripts/guardrail-record-tests.sh +12 -7
- package/dist/plugin/scripts/guardrail-report-format.sh +12 -7
- package/dist/plugin/scripts/guardrail-resolve-gate.sh +12 -7
- package/dist/plugin/scripts/guardrail-skill-stages.sh +27 -18
- package/dist/plugin/scripts/guardrail-stage-gate.sh +14 -24
- package/dist/plugin/scripts/guardrail-terminal-gate.sh +13 -20
- package/dist/plugin/scripts/guardrail-walkthrough-gate.sh +14 -22
- package/dist/plugin/scripts/guardrail-walkthrough-heading.sh +12 -7
- package/dist/plugin/scripts/guardrail-watch-gate.sh +14 -25
- package/dist/plugin/scripts/guardrails.mjs +29 -0
- package/dist/release-manifest.json +3 -3
- package/package.json +2 -2
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/.cursor-plugin/plugin.json +1 -1
- package/plugin/hooks/README.md +17 -2
- package/plugin/hooks/hooks.json +4 -88
- package/plugin/scripts/guardrail-build-followthrough-gate.sh +13 -23
- package/plugin/scripts/guardrail-build-router.sh +12 -7
- package/plugin/scripts/guardrail-capability-claim.sh +27 -17
- package/plugin/scripts/guardrail-classify-gate.sh +12 -7
- package/plugin/scripts/guardrail-comment-reply-gate.sh +15 -26
- package/plugin/scripts/guardrail-debug-path-gate.sh +14 -24
- package/plugin/scripts/guardrail-dispatch.sh +34 -0
- package/plugin/scripts/guardrail-e2e-gate.sh +13 -21
- package/plugin/scripts/guardrail-lib.sh +91 -0
- package/plugin/scripts/guardrail-offer-ran.sh +12 -20
- package/plugin/scripts/guardrail-pr-opened.sh +12 -7
- package/plugin/scripts/guardrail-pr-terminal.sh +12 -7
- package/plugin/scripts/guardrail-record-comment-replies.sh +12 -7
- package/plugin/scripts/guardrail-record-stage-read.sh +12 -7
- package/plugin/scripts/guardrail-record-stage-signals.sh +12 -7
- package/plugin/scripts/guardrail-record-tests.sh +12 -7
- package/plugin/scripts/guardrail-report-format.sh +12 -7
- package/plugin/scripts/guardrail-resolve-gate.sh +12 -7
- package/plugin/scripts/guardrail-skill-stages.sh +27 -18
- package/plugin/scripts/guardrail-stage-gate.sh +14 -24
- package/plugin/scripts/guardrail-terminal-gate.sh +13 -20
- package/plugin/scripts/guardrail-walkthrough-gate.sh +14 -22
- package/plugin/scripts/guardrail-walkthrough-heading.sh +12 -7
- package/plugin/scripts/guardrail-watch-gate.sh +14 -25
- package/plugin/scripts/guardrails.mjs +29 -0
|
@@ -10,12 +10,17 @@ set -uo pipefail
|
|
|
10
10
|
# commands keeps Node off the hot path — only a `gh pr create|ready` or
|
|
11
11
|
# `glab mr create|update` even reaches guardrails.mjs, which then confirms the
|
|
12
12
|
# command succeeded and extracts the URL. Degrades to {} so it never blocks.
|
|
13
|
-
payload="$(cat)"
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
guardrail_script_dir="${BASH_SOURCE[0]%/*}"
|
|
15
|
+
[[ $guardrail_script_dir == "${BASH_SOURCE[0]}" ]] && guardrail_script_dir=.
|
|
16
|
+
. "$guardrail_script_dir/guardrail-lib.sh"
|
|
17
|
+
|
|
18
|
+
GUARDRAIL_SUBCOMMAND="pr-opened"
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
guardrail_wants() {
|
|
21
|
+
guardrail_payload_matches 'gh[[:space:]]+pr[[:space:]]+(create|ready)|glab[[:space:]]+mr[[:space:]]+(create|update)'
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
|
|
25
|
+
guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
|
|
26
|
+
fi
|
|
@@ -14,12 +14,17 @@ set -uo pipefail
|
|
|
14
14
|
# dropped it a close+reopen — routine, to re-fire a lost workflow trigger — left
|
|
15
15
|
# the handoff armed on a change that is open again. Degrades to {} so it never
|
|
16
16
|
# blocks.
|
|
17
|
-
payload="$(cat)"
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
guardrail_script_dir="${BASH_SOURCE[0]%/*}"
|
|
19
|
+
[[ $guardrail_script_dir == "${BASH_SOURCE[0]}" ]] && guardrail_script_dir=.
|
|
20
|
+
. "$guardrail_script_dir/guardrail-lib.sh"
|
|
21
|
+
|
|
22
|
+
GUARDRAIL_SUBCOMMAND="pr-terminal"
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
guardrail_wants() {
|
|
25
|
+
guardrail_payload_matches '(merged|closed|reopened) pull request|TERMINAL pr='
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
|
|
29
|
+
guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
|
|
30
|
+
fi
|
|
@@ -17,12 +17,17 @@ set -uo pipefail
|
|
|
17
17
|
# hand-listed set instructs the user to run an echo that can never register,
|
|
18
18
|
# then blocks the turn anyway. Over-matching here only costs a needless spawn.
|
|
19
19
|
# Degrades to {}.
|
|
20
|
-
payload="$(cat)"
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
guardrail_script_dir="${BASH_SOURCE[0]%/*}"
|
|
22
|
+
[[ $guardrail_script_dir == "${BASH_SOURCE[0]}" ]] && guardrail_script_dir=.
|
|
23
|
+
. "$guardrail_script_dir/guardrail-lib.sh"
|
|
24
|
+
|
|
25
|
+
GUARDRAIL_SUBCOMMAND="record-comment-replies"
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
guardrail_wants() {
|
|
28
|
+
guardrail_payload_matches 'reviewThreads|merge_requests/[0-9]+/discussions|comments/[0-9]+/replies|discussions/[A-Za-z0-9_-]+/notes|MUGGLE_[A-Z0-9_]+_SKIP'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
|
|
32
|
+
guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
|
|
33
|
+
fi
|
|
@@ -10,12 +10,17 @@ set -uo pipefail
|
|
|
10
10
|
# never one outside it, so source reads and repo docs return {} in-shell. Both
|
|
11
11
|
# path separators are accepted: a Windows payload carries escaped backslashes.
|
|
12
12
|
# Degrades to {}.
|
|
13
|
-
payload="$(cat)"
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
guardrail_script_dir="${BASH_SOURCE[0]%/*}"
|
|
15
|
+
[[ $guardrail_script_dir == "${BASH_SOURCE[0]}" ]] && guardrail_script_dir=.
|
|
16
|
+
. "$guardrail_script_dir/guardrail-lib.sh"
|
|
17
|
+
|
|
18
|
+
GUARDRAIL_SUBCOMMAND="record-stage-read"
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
guardrail_wants() {
|
|
21
|
+
guardrail_payload_matches '"file_path"[[:space:]]*:[[:space:]]*"[^"]*[/\\]+skills[/\\]+[^"]*\.md"'
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
|
|
25
|
+
guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
|
|
26
|
+
fi
|
|
@@ -12,12 +12,17 @@ set -uo pipefail
|
|
|
12
12
|
# echo that can never register, then blocks the turn anyway. Anchoring the
|
|
13
13
|
# marker to a leading `echo` stays in guardrails.mjs; over-matching here only
|
|
14
14
|
# costs a needless spawn. Degrades to {}.
|
|
15
|
-
payload="$(cat)"
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
guardrail_script_dir="${BASH_SOURCE[0]%/*}"
|
|
17
|
+
[[ $guardrail_script_dir == "${BASH_SOURCE[0]}" ]] && guardrail_script_dir=.
|
|
18
|
+
. "$guardrail_script_dir/guardrail-lib.sh"
|
|
19
|
+
|
|
20
|
+
GUARDRAIL_SUBCOMMAND="record-stage-signals"
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
guardrail_wants() {
|
|
23
|
+
guardrail_payload_matches 'MUGGLE_[A-Z0-9_]+_SKIP|muggle.*(telemetry-event-emit|user-feedback-create)'
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
|
|
27
|
+
guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
|
|
28
|
+
fi
|
|
@@ -20,12 +20,17 @@ set -uo pipefail
|
|
|
20
20
|
# the user to run an echo that could never reach the recorder, then blocked the
|
|
21
21
|
# turn anyway. Anchoring the marker to a leading `echo` stays in guardrails.mjs;
|
|
22
22
|
# over-matching here only costs a needless spawn.
|
|
23
|
-
payload="$(cat)"
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
guardrail_script_dir="${BASH_SOURCE[0]%/*}"
|
|
25
|
+
[[ $guardrail_script_dir == "${BASH_SOURCE[0]}" ]] && guardrail_script_dir=.
|
|
26
|
+
. "$guardrail_script_dir/guardrail-lib.sh"
|
|
27
|
+
|
|
28
|
+
GUARDRAIL_SUBCOMMAND="record-tests"
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
guardrail_wants() {
|
|
31
|
+
guardrail_payload_matches '(pnpm|npm|yarn)[[:space:]]+(run[[:space:]]+)?test|jest|vitest|pytest|go[[:space:]]+test|cargo[[:space:]]+test|muggle.*(execute|test-generation|replay)|muggle-local-telemetry-skill-emit|MUGGLE_[A-Z0-9_]+_SKIP|gh[[:space:]]+pr[[:space:]]+(comment|create|edit)|issues/comments/[0-9]'
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
|
|
35
|
+
guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
|
|
36
|
+
fi
|
|
@@ -16,12 +16,17 @@ set -uo pipefail
|
|
|
16
16
|
# can't be overwritten with hand-written markdown afterwards, and a pre-filter
|
|
17
17
|
# on `gh pr` alone left that bypass wide open. Degrades to {} so it never blocks
|
|
18
18
|
# an unrelated command.
|
|
19
|
-
payload="$(cat)"
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
guardrail_script_dir="${BASH_SOURCE[0]%/*}"
|
|
21
|
+
[[ $guardrail_script_dir == "${BASH_SOURCE[0]}" ]] && guardrail_script_dir=.
|
|
22
|
+
. "$guardrail_script_dir/guardrail-lib.sh"
|
|
23
|
+
|
|
24
|
+
GUARDRAIL_SUBCOMMAND="report-gate"
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
guardrail_wants() {
|
|
27
|
+
guardrail_payload_matches 'gh[[:space:]]+pr[[:space:]]+(comment|create|edit)|issues/comments/[0-9]'
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
|
|
31
|
+
guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
|
|
32
|
+
fi
|
|
@@ -11,12 +11,17 @@ set -uo pipefail
|
|
|
11
11
|
# and `resolved=false` through to guardrails.mjs, which allows both. Cheaper to
|
|
12
12
|
# pay one cold start on the rare inverse call than to encode the boundary twice
|
|
13
13
|
# and have the two drift. Degrades to {} so it never blocks an unrelated command.
|
|
14
|
-
payload="$(cat)"
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
guardrail_script_dir="${BASH_SOURCE[0]%/*}"
|
|
16
|
+
[[ $guardrail_script_dir == "${BASH_SOURCE[0]}" ]] && guardrail_script_dir=.
|
|
17
|
+
. "$guardrail_script_dir/guardrail-lib.sh"
|
|
18
|
+
|
|
19
|
+
GUARDRAIL_SUBCOMMAND="resolve-gate"
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
guardrail_wants() {
|
|
22
|
+
guardrail_payload_matches 'resolveReviewThread|resolved=(true|false)'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
|
|
26
|
+
guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
|
|
27
|
+
fi
|
|
@@ -12,24 +12,33 @@ set -uo pipefail
|
|
|
12
12
|
# input with no skill name, returns {} in-shell. Every key the resolver reads is
|
|
13
13
|
# accepted here — a key matched in one and missed in the other makes the gate
|
|
14
14
|
# dead code on exactly the harness that names it that way. Degrades to {}.
|
|
15
|
-
payload="$(cat)"
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
guardrail_script_dir="${BASH_SOURCE[0]%/*}"
|
|
17
|
+
[[ $guardrail_script_dir == "${BASH_SOURCE[0]}" ]] && guardrail_script_dir=.
|
|
18
|
+
. "$guardrail_script_dir/guardrail-lib.sh"
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
| grep -oE '"(skill|skillName|name|command)"[[:space:]]*:[[:space:]]*"[^"]*"' \
|
|
21
|
-
| sed -E 's/.*:[[:space:]]*"([^"]*)".*/\1/'); do
|
|
22
|
-
# A namespaced invocation (`muggle:muggle-test`) and a slash command
|
|
23
|
-
# (`/muggle-test`) both name the same skill directory.
|
|
24
|
-
skill="${candidate##*:}"
|
|
25
|
-
skill="${skill#/}"
|
|
26
|
-
case "$skill" in
|
|
27
|
-
"" | *[!A-Za-z0-9._-]*) continue ;;
|
|
28
|
-
esac
|
|
29
|
-
if [ -f "$root/skills/$skill/SKILL.md" ]; then
|
|
30
|
-
printf '%s' "$payload" | node "${root}/scripts/guardrails.mjs" skill-stages 2>/dev/null || printf '{}'
|
|
31
|
-
exit 0
|
|
32
|
-
fi
|
|
33
|
-
done
|
|
20
|
+
GUARDRAIL_SUBCOMMAND="skill-stages"
|
|
34
21
|
|
|
35
|
-
|
|
22
|
+
guardrail_wants() {
|
|
23
|
+
local root="${CLAUDE_PLUGIN_ROOT:-${CURSOR_PLUGIN_ROOT:-}}"
|
|
24
|
+
local key_pattern='"(skill|skillName|name|command)"[[:space:]]*:[[:space:]]*"([^"]*)"'
|
|
25
|
+
local remaining="$GUARDRAIL_PAYLOAD"
|
|
26
|
+
local candidate_words candidate skill
|
|
27
|
+
while [[ $remaining =~ $key_pattern ]]; do
|
|
28
|
+
remaining="${remaining#*"${BASH_REMATCH[0]}"}"
|
|
29
|
+
read -r -a candidate_words <<<"${BASH_REMATCH[2]}"
|
|
30
|
+
for candidate in "${candidate_words[@]}"; do
|
|
31
|
+
skill="${candidate##*:}"
|
|
32
|
+
skill="${skill#/}"
|
|
33
|
+
case "$skill" in
|
|
34
|
+
"" | *[!A-Za-z0-9._-]*) continue ;;
|
|
35
|
+
esac
|
|
36
|
+
[[ -f $root/skills/$skill/SKILL.md ]] && return 0
|
|
37
|
+
done
|
|
38
|
+
done
|
|
39
|
+
return 1
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
|
|
43
|
+
guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
|
|
44
|
+
fi
|
|
@@ -14,31 +14,21 @@ set -uo pipefail
|
|
|
14
14
|
# skill declared stages, so the state file is absent or mandatoryStages is empty
|
|
15
15
|
# and we return {} in-shell. The read-vs-declared comparison runs in
|
|
16
16
|
# guardrails.mjs. Degrades to {}.
|
|
17
|
-
payload="$(cat)"
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
[
|
|
21
|
-
|
|
18
|
+
guardrail_script_dir="${BASH_SOURCE[0]%/*}"
|
|
19
|
+
[[ $guardrail_script_dir == "${BASH_SOURCE[0]}" ]] && guardrail_script_dir=.
|
|
20
|
+
. "$guardrail_script_dir/guardrail-lib.sh"
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
# macOS/Linux and on most Git Bash setups; fall back to converting USERPROFILE
|
|
25
|
-
# when HOME doesn't hold the state dir (some Windows shells point HOME elsewhere).
|
|
26
|
-
home="${HOME:-}"
|
|
27
|
-
if [ ! -d "$home/.muggle-ai" ] && command -v cygpath >/dev/null 2>&1 && [ -n "${USERPROFILE:-}" ]; then
|
|
28
|
-
home="$(cygpath -u "$USERPROFILE" 2>/dev/null || printf '%s' "$home")"
|
|
29
|
-
fi
|
|
22
|
+
GUARDRAIL_SUBCOMMAND="stage-gate"
|
|
30
23
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|| grep -q '"stageSkipped": true' "$state_file"; then
|
|
39
|
-
printf '{}'
|
|
40
|
-
exit 0
|
|
41
|
-
fi
|
|
24
|
+
guardrail_wants() {
|
|
25
|
+
guardrail_load_state \
|
|
26
|
+
&& guardrail_state_has '"mandatoryStages"' \
|
|
27
|
+
&& ! guardrail_state_has '"mandatoryStages": []' \
|
|
28
|
+
&& ! guardrail_state_has '"stageReleased": true' \
|
|
29
|
+
&& ! guardrail_state_has '"stageSkipped": true'
|
|
30
|
+
}
|
|
42
31
|
|
|
43
|
-
|
|
44
|
-
|
|
32
|
+
if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
|
|
33
|
+
guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
|
|
34
|
+
fi
|
|
@@ -12,27 +12,20 @@ set -uo pipefail
|
|
|
12
12
|
# only spawns Node when a terminal PR is actually pending. On the overwhelming
|
|
13
13
|
# majority of turns no PR went terminal, so the state file is absent or
|
|
14
14
|
# terminalPending is empty and we return {} in-shell. Degrades to {}.
|
|
15
|
-
payload="$(cat)"
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
[
|
|
19
|
-
|
|
16
|
+
guardrail_script_dir="${BASH_SOURCE[0]%/*}"
|
|
17
|
+
[[ $guardrail_script_dir == "${BASH_SOURCE[0]}" ]] && guardrail_script_dir=.
|
|
18
|
+
. "$guardrail_script_dir/guardrail-lib.sh"
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
# macOS/Linux and on most Git Bash setups; fall back to converting USERPROFILE
|
|
23
|
-
# when HOME doesn't hold the state dir (some Windows shells point HOME elsewhere).
|
|
24
|
-
home="${HOME:-}"
|
|
25
|
-
if [ ! -d "$home/.muggle-ai" ] && command -v cygpath >/dev/null 2>&1 && [ -n "${USERPROFILE:-}" ]; then
|
|
26
|
-
home="$(cygpath -u "$USERPROFILE" 2>/dev/null || printf '%s' "$home")"
|
|
27
|
-
fi
|
|
20
|
+
GUARDRAIL_SUBCOMMAND="terminal-gate"
|
|
28
21
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
fi
|
|
22
|
+
guardrail_wants() {
|
|
23
|
+
guardrail_load_state \
|
|
24
|
+
&& guardrail_state_has '"terminalPending"' \
|
|
25
|
+
&& ! guardrail_state_has '"terminalReleased": true' \
|
|
26
|
+
&& ! guardrail_state_has '"terminalPending": []'
|
|
27
|
+
}
|
|
36
28
|
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
|
|
30
|
+
guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
|
|
31
|
+
fi
|
|
@@ -14,29 +14,21 @@ set -uo pipefail
|
|
|
14
14
|
# or e2eRun is unset, so we return {} in-shell and never pay Node cold-start —
|
|
15
15
|
# which also means the gate's `gh` lookups only ever run on turns that could
|
|
16
16
|
# genuinely owe a walkthrough. Degrades to {}.
|
|
17
|
-
payload="$(cat)"
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
[
|
|
21
|
-
|
|
18
|
+
guardrail_script_dir="${BASH_SOURCE[0]%/*}"
|
|
19
|
+
[[ $guardrail_script_dir == "${BASH_SOURCE[0]}" ]] && guardrail_script_dir=.
|
|
20
|
+
. "$guardrail_script_dir/guardrail-lib.sh"
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
# macOS/Linux and on most Git Bash setups; fall back to converting USERPROFILE
|
|
25
|
-
# when HOME doesn't hold the state dir (some Windows shells point HOME elsewhere).
|
|
26
|
-
home="${HOME:-}"
|
|
27
|
-
if [ ! -d "$home/.muggle-ai" ] && command -v cygpath >/dev/null 2>&1 && [ -n "${USERPROFILE:-}" ]; then
|
|
28
|
-
home="$(cygpath -u "$USERPROFILE" 2>/dev/null || printf '%s' "$home")"
|
|
29
|
-
fi
|
|
22
|
+
GUARDRAIL_SUBCOMMAND="walkthrough-gate"
|
|
30
23
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
exit 0
|
|
39
|
-
fi
|
|
24
|
+
guardrail_wants() {
|
|
25
|
+
guardrail_load_state \
|
|
26
|
+
&& guardrail_state_has '"e2eRun": true' \
|
|
27
|
+
&& ! guardrail_state_has '"walkthroughPosted": true' \
|
|
28
|
+
&& ! guardrail_state_has '"walkthroughReleased": true' \
|
|
29
|
+
&& ! guardrail_state_has '"walkthroughSkipped": true'
|
|
30
|
+
}
|
|
40
31
|
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
|
|
33
|
+
guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
|
|
34
|
+
fi
|
|
@@ -13,12 +13,17 @@ set -uo pipefail
|
|
|
13
13
|
# Must stay synchronous (only a sync PreToolUse hook can deny). The same keyword
|
|
14
14
|
# pre-filter keeps Node off the hot path for ordinary commands, and any failure
|
|
15
15
|
# degrades to {} so an unrelated command is never blocked.
|
|
16
|
-
payload="$(cat)"
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
guardrail_script_dir="${BASH_SOURCE[0]%/*}"
|
|
18
|
+
[[ $guardrail_script_dir == "${BASH_SOURCE[0]}" ]] && guardrail_script_dir=.
|
|
19
|
+
. "$guardrail_script_dir/guardrail-lib.sh"
|
|
20
|
+
|
|
21
|
+
GUARDRAIL_SUBCOMMAND="walkthrough-heading-gate"
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
guardrail_wants() {
|
|
24
|
+
guardrail_payload_matches 'gh[[:space:]]+pr[[:space:]]+(comment|create|edit)|issues/comments/[0-9]'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
|
|
28
|
+
guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
|
|
29
|
+
fi
|
|
@@ -10,32 +10,21 @@ set -uo pipefail
|
|
|
10
10
|
# runs in guardrails.mjs. On the overwhelming majority of turns no PR was opened,
|
|
11
11
|
# so the state file is absent or prsHandled is empty and we return {} in-shell,
|
|
12
12
|
# never paying Node cold-start. Degrades to {}.
|
|
13
|
-
payload="$(cat)"
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
[
|
|
17
|
-
|
|
14
|
+
guardrail_script_dir="${BASH_SOURCE[0]%/*}"
|
|
15
|
+
[[ $guardrail_script_dir == "${BASH_SOURCE[0]}" ]] && guardrail_script_dir=.
|
|
16
|
+
. "$guardrail_script_dir/guardrail-lib.sh"
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
# macOS/Linux and on most Git Bash setups; fall back to converting USERPROFILE
|
|
21
|
-
# when HOME doesn't hold the state dir (some Windows shells point HOME elsewhere).
|
|
22
|
-
home="${HOME:-}"
|
|
23
|
-
if [ ! -d "$home/.muggle-ai" ] && command -v cygpath >/dev/null 2>&1 && [ -n "${USERPROFILE:-}" ]; then
|
|
24
|
-
home="$(cygpath -u "$USERPROFILE" 2>/dev/null || printf '%s' "$home")"
|
|
25
|
-
fi
|
|
18
|
+
GUARDRAIL_SUBCOMMAND="watch-gate"
|
|
26
19
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|| grep -q '"watchReleased": true' "$state_file" \
|
|
35
|
-
|| grep -q '"watchSkipped": true' "$state_file"; then
|
|
36
|
-
printf '{}'
|
|
37
|
-
exit 0
|
|
38
|
-
fi
|
|
20
|
+
guardrail_wants() {
|
|
21
|
+
guardrail_load_state \
|
|
22
|
+
&& guardrail_state_has '"prsHandled"' \
|
|
23
|
+
&& ! guardrail_state_has '"prsHandled": []' \
|
|
24
|
+
&& ! guardrail_state_has '"watchReleased": true' \
|
|
25
|
+
&& ! guardrail_state_has '"watchSkipped": true'
|
|
26
|
+
}
|
|
39
27
|
|
|
40
|
-
|
|
41
|
-
|
|
28
|
+
if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
|
|
29
|
+
guardrail_run_standalone "$GUARDRAIL_SUBCOMMAND"
|
|
30
|
+
fi
|
|
@@ -51,6 +51,7 @@ var CALL_FAILURE_SIGNALS = [
|
|
|
51
51
|
];
|
|
52
52
|
var FORGE_TERMINAL_CMD = /\b(?:gh\s+pr\s+(?:merge|close|reopen)|glab\s+mr\s+(?:merge|close|reopen))\b/;
|
|
53
53
|
var WATCH_TERMINAL_CMD = /pr-watch-(?:loop|arm)\.sh/;
|
|
54
|
+
var MERGED_GATE_OUTPUT_SEPARATOR = "\n\n";
|
|
54
55
|
|
|
55
56
|
// src/guardrails/store/fileLock.ts
|
|
56
57
|
function isProcessAlive(pid) {
|
|
@@ -1425,6 +1426,23 @@ function denyTool(reason, host2) {
|
|
|
1425
1426
|
}
|
|
1426
1427
|
});
|
|
1427
1428
|
}
|
|
1429
|
+
function mergeHookOutputs(gateOutputs, host2) {
|
|
1430
|
+
const parsedOutputs = gateOutputs.flatMap((gateOutput) => {
|
|
1431
|
+
try {
|
|
1432
|
+
return [JSON.parse(gateOutput)];
|
|
1433
|
+
} catch {
|
|
1434
|
+
return [];
|
|
1435
|
+
}
|
|
1436
|
+
});
|
|
1437
|
+
const denyReasons = parsedOutputs.filter((parsed) => parsed.hookSpecificOutput?.permissionDecision === "deny").map((parsed) => parsed.hookSpecificOutput?.permissionDecisionReason ?? "").filter(Boolean);
|
|
1438
|
+
if (denyReasons.length > 0) return denyTool(denyReasons.join(MERGED_GATE_OUTPUT_SEPARATOR), host2);
|
|
1439
|
+
const blockReasons = parsedOutputs.filter((parsed) => parsed.decision === "block").map((parsed) => parsed.reason ?? "").filter(Boolean);
|
|
1440
|
+
if (blockReasons.length > 0) return blockStop(blockReasons.join(MERGED_GATE_OUTPUT_SEPARATOR), host2);
|
|
1441
|
+
const contexts = parsedOutputs.map((parsed) => parsed.hookSpecificOutput?.additionalContext ?? parsed.additional_context ?? "").filter(Boolean);
|
|
1442
|
+
if (contexts.length === 0) return "{}";
|
|
1443
|
+
const hookEventName = parsedOutputs.find((parsed) => parsed.hookSpecificOutput?.hookEventName)?.hookSpecificOutput?.hookEventName;
|
|
1444
|
+
return envelope(hookEventName ?? "", contexts.join(MERGED_GATE_OUTPUT_SEPARATOR), host2);
|
|
1445
|
+
}
|
|
1428
1446
|
|
|
1429
1447
|
// src/guardrails/cli.ts
|
|
1430
1448
|
function readStdin() {
|
|
@@ -1742,7 +1760,18 @@ function capabilityClaimGate() {
|
|
|
1742
1760
|
const reason = `Do not end the turn yet. This turn tells the user that an email- or login-gated flow cannot be tested, reached, or verified \u2014 the one class of blocker Muggle clears. Every managed login profile owns a live inbox, so magic-link and sign-in-link logins, emailed OTPs, email-based 2FA, verification mail, and password resets run end to end with no mail stub and no test-only backdoor; stored credentials and CAPTCHA solving are covered too. Re-read plugin/skills/_shared/identity-and-inbox.md, then correct the claim or run the flow. If the real blocker is SMS/phone OTP, authenticator-app TOTP, or OAuth-only social login, those limits are genuine \u2014 name the one that applies and move on.`;
|
|
1743
1761
|
return blockStop(reason, host);
|
|
1744
1762
|
}
|
|
1763
|
+
function runFiringGates() {
|
|
1764
|
+
const gateOutputs = process.argv.slice(3).map((firingSubcommand) => {
|
|
1765
|
+
try {
|
|
1766
|
+
return (handlers[firingSubcommand] ?? (() => "{}"))();
|
|
1767
|
+
} catch {
|
|
1768
|
+
return "{}";
|
|
1769
|
+
}
|
|
1770
|
+
});
|
|
1771
|
+
return mergeHookOutputs(gateOutputs, host);
|
|
1772
|
+
}
|
|
1745
1773
|
var handlers = {
|
|
1774
|
+
run: runFiringGates,
|
|
1746
1775
|
"pr-opened": prOpened,
|
|
1747
1776
|
"capability-claim-gate": capabilityClaimGate,
|
|
1748
1777
|
"pr-terminal": prTerminal,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"release": "5.18.0",
|
|
3
|
-
"buildId": "run-
|
|
4
|
-
"commitSha": "
|
|
5
|
-
"buildTime": "2026-10-
|
|
3
|
+
"buildId": "run-144-1",
|
|
4
|
+
"commitSha": "f1b437ed8e376b09b87815aa34b40299f63027f2",
|
|
5
|
+
"buildTime": "2026-10-05T21:51:22Z",
|
|
6
6
|
"serviceName": "muggle-ai-works-mcp"
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@muggleai/works",
|
|
3
3
|
"mcpName": "io.github.multiplex-ai/muggle",
|
|
4
|
-
"version": "5.20.0
|
|
4
|
+
"version": "5.20.0",
|
|
5
5
|
"description": "Ship quality products with AI-powered E2E acceptance testing that validates your web app like a real user — from Claude Code and Cursor to PR.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/index.js",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"muggleConfig": {
|
|
55
55
|
"electronAppVersion": "1.10.6",
|
|
56
56
|
"downloadBaseUrl": "https://github.com/multiplex-ai/muggle-ai-works/releases/download",
|
|
57
|
-
"runtimeTargetDefault": "
|
|
57
|
+
"runtimeTargetDefault": "production",
|
|
58
58
|
"checksumsByStream": {
|
|
59
59
|
"production": {
|
|
60
60
|
"win32-x64": "c20acdc2fd7a05039c62f9e5b079e3068d1b3a23a1b3b37b75e2a650b5401de6",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "muggle",
|
|
3
3
|
"description": "Run real-browser end-to-end (E2E) acceptance tests on your web app from any AI coding agent. Generate test scripts from plain English, replay them on localhost, capture screenshots, and validate user flows like signup, checkout, and dashboards. Works across Claude Code, Cursor, Codex, and Windsurf.",
|
|
4
|
-
"version": "5.20.0
|
|
4
|
+
"version": "5.20.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Muggle AI",
|
|
7
7
|
"email": "support@muggle-ai.com"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "muggle",
|
|
3
3
|
"displayName": "Muggle AI",
|
|
4
4
|
"description": "Ship quality products with AI-powered end-to-end (E2E) acceptance testing that validates your web app like a real user — from Claude Code and Cursor to PR.",
|
|
5
|
-
"version": "5.20.0
|
|
5
|
+
"version": "5.20.0",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Muggle AI",
|
|
8
8
|
"email": "support@muggle-ai.com"
|
package/plugin/hooks/README.md
CHANGED
|
@@ -26,9 +26,9 @@ Enforcement is reserved for the handoffs that were being skipped: the E2E accept
|
|
|
26
26
|
|
|
27
27
|
A recorder that *clears* an obligation — a walkthrough posted, a failure diagnosed, a test case classified — records only when the call did not visibly fail (`callOutcome.ts`). Recording from the request alone let a rejected `gh pr comment` mark the walkthrough posted, so the gate went quiet on a PR that never received it.
|
|
28
28
|
|
|
29
|
-
Each guardrail is a
|
|
29
|
+
Each guardrail is a bash gate script in `../scripts/` holding a `guardrail_wants` pre-filter and the `guardrails.mjs` subcommand it feeds; the bundled `../scripts/guardrails.mjs` holds the decision logic (built from `src/guardrails/`, vitest-covered). The busy events — a shell command before and after it runs, and every turn end — register one `guardrail-dispatch.sh` command listing their gates, which reads the payload once, asks every gate's pre-filter in that one process, and starts Node once (`guardrails.mjs run <gates...>`) for just the gates that could fire, merging their responses. Rarer events call a gate script directly. Per-session state in `~/.muggle-ai/guardrails/<session_id>.json` tracks what fired. Any *failure* degrades to `{}` (allow) — a gate blocks only by an explicit, tested decision, never by accident; `guardrail-lib.sh` is the one place that falls back, and `run` isolates gates from each other.
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
Pre-filters are bash builtins only (`guardrail-lib.sh`), so an irrelevant event starts no process at all. A gate that has spent its block budget stamps a `<gate>Released` flag, which its wrapper then pre-filters on — without it a released gate keeps cold-starting Node on every remaining turn end to answer `{}`, and the walkthrough gate keeps making provider calls to do it. That pre-filter is a second, looser copy of what `guardrails.mjs` matches, and it is the one place a guardrail can fail *silently*: a payload it drops — a skip marker, a reopen line, a comment edit — reaches no recorder, and the gate keeps demanding an action the user already took. Over-matching is free; under-matching is a dead escape hatch. `src/test/guardrails/hook-prefilter.test.ts` pins every payload each subcommand acts on against the wrapper guarding it, and derives the skip-marker tokens from source so a new marker is covered the moment it exists.
|
|
32
32
|
|
|
33
33
|
## Guardrails
|
|
34
34
|
|
|
@@ -70,3 +70,18 @@ The nudge counts only slots **this session owns**, and reports the rest as orpha
|
|
|
70
70
|
- Finalized watcher slots (`result.md` present) are pruned 30 days after finalize; their `followup.log` is forensic-only. An **open** slot — a PR watched for any length of time — has no `result.md` and is never touched.
|
|
71
71
|
|
|
72
72
|
Both windows are overridable (`MUGGLE_GUARDRAILS_TTL_DAYS`, `MUGGLE_SLOT_TTL_DAYS`). TTL-gated to once per day via a `~/.cache/muggle/state-gc-checked` marker (the current-session refresh runs every start regardless); silent and best-effort, never blocks session start. Never touches an open slot or the current session's own state.
|
|
73
|
+
|
|
74
|
+
## Footprint caps
|
|
75
|
+
|
|
76
|
+
Every hook here fires on every tool call, prompt or turn end in every open session, so its cost is paid thousands of times a day on the user's machine; on Windows each process start costs 50 ms healthy and seconds under load. The budget is lightweight by construction: one hook command per busy event, and nothing started beyond it when the event is irrelevant. `src/test/guardrails/footprint/` holds CI to it:
|
|
77
|
+
|
|
78
|
+
| Cap | Limit |
|
|
79
|
+
| :-- | :-- |
|
|
80
|
+
| Hook commands per busy slot (PreToolUse/PostToolUse on `Bash` and `Read`, Stop, UserPromptSubmit) | 1 |
|
|
81
|
+
| Programs started beyond each hook's own launch on an irrelevant event | 0 (Stop: 1, a transcript `tail` until the capability-claim gate has nudged; bash cannot seek) |
|
|
82
|
+
| `node`, `gh`, `python` on that path | 0 |
|
|
83
|
+
| Median wall time of one irrelevant firing, Linux/macOS | 100 ms |
|
|
84
|
+
| Hook commands in the whole manifest | 15 |
|
|
85
|
+
| Hook timeout | declared on every hook; 30 s, SessionStart 120 s |
|
|
86
|
+
|
|
87
|
+
Counts are exec counts, so they are identical on every runner. Every count is exact: CI fails when a change exceeds a limit, and also when it beats one until `footprint/constants.ts` is lowered to match, so a gain cannot be given back later.
|