File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4242 }
4343 ]
4444 }
45+ ],
46+ "UserPromptSubmit" : [
47+ {
48+ "hooks" : [
49+ {
50+ "type" : " command" ,
51+ "command" : " ${CLAUDE_PLUGIN_ROOT}/scripts/on-prompt-submit.sh"
52+ }
53+ ]
54+ }
55+ ],
56+ "PostToolUse" : [
57+ {
58+ "hooks" : [
59+ {
60+ "type" : " command" ,
61+ "command" : " ${CLAUDE_PLUGIN_ROOT}/scripts/on-post-tool-use.sh"
62+ }
63+ ]
64+ }
4565 ]
4666 }
4767}
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # Hook script for Claude Code PostToolUse event
3+ # Sends a structured Warp notification after a tool call completes,
4+ # transitioning the session status from Blocked back to Running.
5+
6+ SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
7+ source " $SCRIPT_DIR /build-payload.sh"
8+
9+ # Read hook input from stdin
10+ INPUT=$( cat)
11+
12+ TOOL_NAME=$( echo " $INPUT " | jq -r ' .tool_name // empty' 2> /dev/null)
13+
14+ BODY=$( build_payload " $INPUT " " tool_complete" \
15+ --arg tool_name " $TOOL_NAME " )
16+
17+ " $SCRIPT_DIR /warp-notify.sh" " warp://cli-agent" " $BODY "
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # Hook script for Claude Code UserPromptSubmit event
3+ # Sends a structured Warp notification when the user submits a prompt,
4+ # transitioning the session status from idle/blocked back to running.
5+
6+ SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
7+ source " $SCRIPT_DIR /build-payload.sh"
8+
9+ # Read hook input from stdin
10+ INPUT=$( cat)
11+
12+ # Extract the user's prompt
13+ QUERY=$( echo " $INPUT " | jq -r ' .prompt // empty' 2> /dev/null)
14+ if [ -n " $QUERY " ] && [ ${# QUERY} -gt 200 ]; then
15+ QUERY=" ${QUERY: 0: 197} ..."
16+ fi
17+
18+ BODY=$( build_payload " $INPUT " " prompt_submit" \
19+ --arg query " $QUERY " )
20+
21+ " $SCRIPT_DIR /warp-notify.sh" " warp://cli-agent" " $BODY "
Original file line number Diff line number Diff line change @@ -15,20 +15,3 @@ PLUGIN_VERSION=$(jq -r '.version // "unknown"' "$SCRIPT_DIR/../.claude-plugin/pl
1515BODY=$( build_payload " $INPUT " " session_start" \
1616 --arg plugin_version " $PLUGIN_VERSION " )
1717" $SCRIPT_DIR /warp-notify.sh" " warp://cli-agent" " $BODY "
18-
19- # Output system message for the Claude Code UI
20- if [ " $TERM_PROGRAM " = " WarpTerminal" ]; then
21- # Running in Warp - notifications will work
22- cat << EOF
23- {
24- "systemMessage": "🔔 Warp plugin v${PLUGIN_VERSION} active. You'll receive native Warp notifications when tasks complete or input is needed."
25- }
26- EOF
27- else
28- # Not running in Warp - suggest installing
29- cat << EOF
30- {
31- "systemMessage": "ℹ️ Warp plugin v${PLUGIN_VERSION} installed but you're not running in Warp terminal. Install Warp (https://warp.dev) to get native notifications when Claude completes tasks or needs input."
32- }
33- EOF
34- fi
Original file line number Diff line number Diff line change @@ -22,10 +22,20 @@ sleep 0.3
2222QUERY=" "
2323RESPONSE=" "
2424if [ -n " $TRANSCRIPT_PATH " ] && [ -f " $TRANSCRIPT_PATH " ]; then
25- # Get the last user prompt (most recent turn, not the first in the session)
26- # .message.content can be a string or an array of {type, text} objects
25+ # Get the last human prompt from the transcript.
26+ # "user" type messages include both human prompts and tool-result messages.
27+ # Human prompts have content that is either a plain string or an array
28+ # containing {type:"text"} blocks. Tool-result messages have content arrays
29+ # containing only {type:"tool_result"} blocks. We filter to messages that
30+ # have at least one "text" block (or are a plain string).
2731 QUERY=$( jq -rs '
28- [.[] | select(.type == "user")] | last |
32+ [
33+ .[] | select(.type == "user") |
34+ if .message.content | type == "string" then .
35+ elif [.message.content[] | select(.type == "text")] | length > 0 then .
36+ else empty
37+ end
38+ ] | last |
2939 if .message.content | type == "array"
3040 then [.message.content[] | select(.type == "text") | .text] | join(" ")
3141 else .message.content // empty
You can’t perform that action at this time.
0 commit comments