File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6262 }
6363 ]
6464 }
65+ ],
66+ "PreToolUse" : [
67+ {
68+ "matcher" : " AskUserQuestion" ,
69+ "hooks" : [
70+ {
71+ "type" : " command" ,
72+ "command" : " ${CLAUDE_PLUGIN_ROOT}/scripts/on-ask-user-question.sh"
73+ }
74+ ]
75+ }
6576 ]
6677 }
6778}
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # Hook script for Claude Code PreToolUse event on AskUserQuestion
3+ # Sends a structured Warp notification when Claude asks the user a question,
4+ # transitioning the session status to Blocked until the user answers.
5+
6+ SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
7+ source " $SCRIPT_DIR /should-use-structured.sh"
8+
9+ # No legacy equivalent for this hook
10+ if ! should_use_structured; then
11+ exit 0
12+ fi
13+
14+ source " $SCRIPT_DIR /build-payload.sh"
15+
16+ # Read hook input from stdin
17+ INPUT=$( cat)
18+
19+ # AskUserQuestion supports 1-4 questions. Surface the first question's text as
20+ # the notification summary; if Claude asks more than one in the same call,
21+ # answering any of them unblocks the session.
22+ SUMMARY=$( echo " $INPUT " | jq -r ' .tool_input.questions[0].question // "Claude is asking a question"' 2> /dev/null)
23+
24+ # Truncate for notification display
25+ if [ -n " $SUMMARY " ] && [ ${# SUMMARY} -gt 200 ]; then
26+ SUMMARY=" ${SUMMARY: 0: 197} ..."
27+ fi
28+
29+ BODY=$( build_payload " $INPUT " " question_asked" \
30+ --arg summary " $SUMMARY " )
31+
32+ " $SCRIPT_DIR /warp-notify.sh" " warp://cli-agent" " $BODY "
Original file line number Diff line number Diff line change @@ -218,7 +218,7 @@ assert_eq "legacy Warp shows active message" \
218218echo " "
219219echo " --- Modern-only hooks exit silently without protocol version ---"
220220
221- for HOOK in on-permission-request.sh on-prompt-submit.sh on-post-tool-use.sh; do
221+ for HOOK in on-permission-request.sh on-prompt-submit.sh on-post-tool-use.sh on-ask-user-question.sh ; do
222222 echo ' {}' | bash " $HOOK_DIR /$HOOK " 2> /dev/null
223223 assert_eq " $HOOK exits 0 without protocol version" " 0" " $? "
224224done
You can’t perform that action at this time.
0 commit comments