File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,10 +11,8 @@ if ! command -v jq &>/dev/null; then
1111 exit 0
1212fi
1313
14- # Use response_preview (current turn, first 500 chars) instead of transcript.
15- # The transcript is written AFTER the Stop hook returns, so transcript-based
16- # extraction is always one turn behind.
17- RESPONSE=$( printf ' %s' " $INPUT " | jq -r ' .response_preview // empty' 2> /dev/null || true)
14+ # Use last_assistant_message (the full text of the current turn's response)
15+ RESPONSE=$( printf ' %s' " $INPUT " | jq -r ' .last_assistant_message // empty' 2> /dev/null || true)
1816
1917if [[ -z " $RESPONSE " ]]; then
2018 printf ' {"decision":"approve"}\n'
Original file line number Diff line number Diff line change @@ -11,12 +11,12 @@ mkdir -p "${CLAUDE_PROJECT_DIR}/.claude"
1111FLAG=" ${CLAUDE_PROJECT_DIR} /.claude/.claudesay-active"
1212trap ' rm -f "$TTY_FILE"; rm -rf "$CLAUDE_PROJECT_DIR"' EXIT
1313
14- # run_stop passes a response_preview string directly, matching the real Stop
15- # hook input. Using response_preview avoids the one-turn delay caused by the
16- # transcript being written AFTER the hook returns.
14+ # run_stop passes a last_assistant_message string directly, matching the
15+ # Stop hook input. Using last_assistant_message avoids the one-turn delay
16+ # caused by the transcript being written AFTER the hook returns.
1717run_stop () {
18- local preview =" $1 "
19- jq -n --arg p " $preview " ' {"response_preview ":$p}' \
18+ local msg =" $1 "
19+ jq -n --arg p " $msg " ' {"last_assistant_message ":$p}' \
2020 | bash " $PLUGIN_ROOT /hooks/scripts/stop.sh"
2121}
2222
@@ -51,7 +51,7 @@ assert_contains "last tag wins" "$parsed" "second msg"
5151> " $TTY_FILE "
5252
5353echo " "
54- echo " === stop.sh: empty response_preview → silent approve ==="
54+ echo " === stop.sh: empty last_assistant_message → silent approve ==="
5555out=$( run_stop ' ' )
5656assert_eq " returns approve on empty preview" " $out " ' {"decision":"approve"}'
5757
You can’t perform that action at this time.
0 commit comments