@spardutti/claude-skills 2.60.0 → 2.60.1
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/hooks/skill-flags-record.sh +32 -25
- package/package.json +1 -1
|
@@ -6,38 +6,45 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
|
6
6
|
PROJECT_DIR="$(dirname "$(dirname "$SCRIPT_DIR")")"
|
|
7
7
|
TRANSCRIPT=$(printf '%s' "$INPUT" | grep -o '"agent_transcript_path":"[^"]*"' | head -1 | sed 's/.*:"//; s/"$//')
|
|
8
8
|
|
|
9
|
+
# A named agent reports its name as agent_type; the meta file beside its transcript keeps the type.
|
|
10
|
+
TYPES="$INPUT"
|
|
11
|
+
[ -f "${TRANSCRIPT%.jsonl}.meta.json" ] && TYPES="$TYPES$(tr -d '\n' < "${TRANSCRIPT%.jsonl}.meta.json")"
|
|
12
|
+
AUDIT=0
|
|
13
|
+
case "$TYPES" in *'"agent_type":"gauntlet-skills"'*|*'"agentType":"gauntlet-skills"'*) AUDIT=1 ;; esac
|
|
14
|
+
|
|
9
15
|
# The SubagentHandback tool carries the report and leaves last_assistant_message empty.
|
|
10
16
|
handback() {
|
|
11
17
|
node -e 'for (const s of require("fs").readFileSync(process.argv[1], "utf8").trim().split("\n").reverse()) {
|
|
12
18
|
let c; try { c = JSON.parse(s).message; } catch { continue; }
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const t = h ? h.input?.message : c.content.filter((x) => x.type === "text").map((x) => x.text).join("");
|
|
16
|
-
if (t) { process.stdout.write(JSON.stringify(t).slice(1, -1)); break; }
|
|
19
|
+
const h = Array.isArray(c?.content) && c.content.find((x) => x.type === "tool_use" && x.name === "SubagentHandback");
|
|
20
|
+
if (h?.input?.message) { process.stdout.write(JSON.stringify(h.input.message).slice(1, -1)); break; }
|
|
17
21
|
}' "$1" 2>/dev/null
|
|
18
22
|
}
|
|
19
23
|
|
|
24
|
+
record() { # record <reply, JSON-escaped>
|
|
25
|
+
local reply="$1" log model cwd branch step
|
|
26
|
+
if [ "$AUDIT" = 1 ]; then log=skill-flags.jsonl
|
|
27
|
+
else case "$reply" in *'\"failure_scenario\"'*) log=review-findings.jsonl ;; *) return ;; esac; fi
|
|
28
|
+
model=""
|
|
29
|
+
[ -f "$TRANSCRIPT" ] && model=$(grep -o '"model":"[^"]*"' "$TRANSCRIPT" | tail -1 | sed 's/.*:"//; s/"$//')
|
|
30
|
+
. "$SCRIPT_DIR/gate-config.sh" 2>/dev/null || return
|
|
31
|
+
cwd=$(json_field "$INPUT" cwd)
|
|
32
|
+
# A review run in a worktree belongs to the worktree's branch, not the main folder's.
|
|
33
|
+
branch=$(git -C "${cwd:-$PROJECT_DIR}" branch --show-current 2>/dev/null | json_string)
|
|
34
|
+
printf '{"ts":"%s","branch":"%s","model":"%s","reply":"%s"}\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" "$branch" "$model" "$reply" \
|
|
35
|
+
>> "$(diary_dir "$SCRIPT_DIR")/$log"
|
|
36
|
+
case "$log" in skill-flags.jsonl) step=audit ;; *) step=review ;; esac
|
|
37
|
+
SHIP_LOG_ROOT="${cwd:-$PROJECT_DIR}" node "$SCRIPT_DIR/ship-log.mjs" step "$step" end >/dev/null 2>&1
|
|
38
|
+
}
|
|
39
|
+
|
|
20
40
|
# Kept JSON-escaped as it arrived, so the line stays valid JSON without a parser.
|
|
21
41
|
REPLY=$(printf '%s' "$INPUT" | sed -nE 's/.*"last_assistant_message":"(([^"\\]|\\.)*)".*/\1/p')
|
|
22
|
-
[ -
|
|
23
|
-
[ -
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
MODEL=""
|
|
31
|
-
[ -f "$TRANSCRIPT" ] && MODEL=$(grep -o '"model":"[^"]*"' "$TRANSCRIPT" | tail -1 | sed 's/.*:"//; s/"$//')
|
|
32
|
-
|
|
33
|
-
. "$SCRIPT_DIR/gate-config.sh" 2>/dev/null || exit 0
|
|
34
|
-
CWD=$(json_field "$INPUT" cwd)
|
|
35
|
-
# A review run in a worktree belongs to the worktree's branch, not the main folder's.
|
|
36
|
-
BRANCH=$(git -C "${CWD:-$PROJECT_DIR}" branch --show-current 2>/dev/null | json_string)
|
|
37
|
-
printf '{"ts":"%s","branch":"%s","model":"%s","reply":"%s"}\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" "$BRANCH" "$MODEL" "$REPLY" \
|
|
38
|
-
>> "$(diary_dir "$SCRIPT_DIR")/$LOG"
|
|
39
|
-
|
|
40
|
-
case "$LOG" in skill-flags.jsonl) STEP=audit ;; *) STEP=review ;; esac
|
|
41
|
-
SHIP_LOG_ROOT="${CWD:-$PROJECT_DIR}" node "$SCRIPT_DIR/ship-log.mjs" step "$STEP" end >/dev/null 2>&1
|
|
42
|
-
|
|
42
|
+
if [ -n "$REPLY" ]; then record "$REPLY"; exit 0; fi
|
|
43
|
+
[ -f "$TRANSCRIPT" ] || exit 0
|
|
44
|
+
|
|
45
|
+
# Measured: the hook fires before the handback reaches the transcript, so wait off the hot path.
|
|
46
|
+
( for _ in $(seq 1 40); do
|
|
47
|
+
r=$(handback "$TRANSCRIPT"); [ -n "$r" ] && { record "$r"; exit 0; }
|
|
48
|
+
sleep 0.25
|
|
49
|
+
done ) </dev/null >/dev/null 2>&1 &
|
|
43
50
|
exit 0
|