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
2 changes: 1 addition & 1 deletion plugins/warp/scripts/on-permission-request.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ TOOL_INPUT=$(echo "$INPUT" | jq -c '.tool_input // {}' 2>/dev/null)
[ -z "$TOOL_INPUT" ] && TOOL_INPUT='{}'

# Build a human-readable summary
TOOL_PREVIEW=$(echo "$INPUT" | jq -r '(.tool_input | if .command then .command elif .file_path then .file_path else (tostring | .[0:80]) end) // ""' 2>/dev/null)
TOOL_PREVIEW=$(echo "$INPUT" | jq -r '(.tool_input | if .command then .command elif .file_path then .file_path elif .questions then (.questions[0].question // "") else (tostring | .[0:80]) end) // ""' 2>/dev/null)
SUMMARY="Wants to run $TOOL_NAME"
if [ -n "$TOOL_PREVIEW" ]; then
if [ ${#TOOL_PREVIEW} -gt 120 ]; then
Expand Down
30 changes: 30 additions & 0 deletions plugins/warp/tests/test-hooks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,36 @@ unset CLAUDE_CODE_VERSION

HOOK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../scripts" && pwd)"

echo ""
echo "=== Permission request preview ==="

# Runs on-permission-request.sh end to end and pulls .summary back out of the
# OSC sequence, so the jq preview expression is covered by the suite.
permission_summary() {
echo "$1" | WARP_CLI_AGENT_PROTOCOL_VERSION=1 \
WARP_CLIENT_VERSION="v9999.99.99.99.99.stable_99" \
CLAUDE_CODE_VERSION="9999.0.0" \
bash "$HOOK_DIR/on-permission-request.sh" 2>/dev/null |
jq -r '.terminalSequence // empty' |
sed 's/^.*warp:\/\/cli-agent;//' | tr -d '\007' |
jq -r '.summary // empty'
}

echo ""
echo "--- Tool preview ---"

assert_eq "Bash shows the command" "Wants to run Bash: git push origin main" \
"$(permission_summary '{"tool_name":"Bash","tool_input":{"command":"git push origin main"}}')"

assert_eq "Write shows the path" "Wants to run Write: /tmp/a.txt" \
"$(permission_summary '{"tool_name":"Write","tool_input":{"file_path":"/tmp/a.txt","content":"hi"}}')"

assert_eq "AskUserQuestion shows the question" "Wants to run AskUserQuestion: Deploy now or wait?" \
"$(permission_summary '{"tool_name":"AskUserQuestion","tool_input":{"questions":[{"question":"Deploy now or wait?","header":"Deploy"}]}}')"

assert_eq "unknown tool falls back to the raw input" 'Wants to run WebFetch: {"url":"https://example.com"}' \
"$(permission_summary '{"tool_name":"WebFetch","tool_input":{"url":"https://example.com"}}')"

echo ""
echo "=== Routing ==="

Expand Down