Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions plugins/warp/hooks/hooks.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@
}
]
}
],
"PreToolUse": [
{
"matcher": "AskUserQuestion",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/scripts/on-ask-user-question.sh"
}
]
}
]
}
}
32 changes: 32 additions & 0 deletions plugins/warp/scripts/on-ask-user-question.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
# Hook script for Claude Code PreToolUse event on AskUserQuestion
# Sends a structured Warp notification when Claude asks the user a question,
# transitioning the session status to Blocked until the user answers.

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/should-use-structured.sh"

# No legacy equivalent for this hook
if ! should_use_structured; then
exit 0
fi

source "$SCRIPT_DIR/build-payload.sh"

# Read hook input from stdin
INPUT=$(cat)

# AskUserQuestion supports 1-4 questions. Surface the first question's text as
# the notification summary; if Claude asks more than one in the same call,
# answering any of them unblocks the session.
SUMMARY=$(echo "$INPUT" | jq -r '.tool_input.questions[0].question // "Claude is asking a question"' 2>/dev/null)

# Truncate for notification display
if [ -n "$SUMMARY" ] && [ ${#SUMMARY} -gt 200 ]; then
SUMMARY="${SUMMARY:0:197}..."
fi

BODY=$(build_payload "$INPUT" "question_asked" \
--arg summary "$SUMMARY")

"$SCRIPT_DIR/warp-notify.sh" "warp://cli-agent" "$BODY"
2 changes: 1 addition & 1 deletion plugins/warp/tests/test-hooks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ assert_eq "legacy Warp shows active message" \
echo ""
echo "--- Modern-only hooks exit silently without protocol version ---"

for HOOK in on-permission-request.sh on-prompt-submit.sh on-post-tool-use.sh; do
for HOOK in on-permission-request.sh on-prompt-submit.sh on-post-tool-use.sh on-ask-user-question.sh; do
echo '{}' | bash "$HOOK_DIR/$HOOK" 2>/dev/null
assert_eq "$HOOK exits 0 without protocol version" "0" "$?"
done
Expand Down