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
12 changes: 12 additions & 0 deletions plugins/warp/scripts/build-payload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ negotiate_protocol_version() {
fi
}

# Notification bodies are shown as plain text, so markdown syntax from the
# agent's reply appears literally. Removes the common markers and folds
# newlines into spaces. Underscores are left alone so identifiers like
# __init__ survive.
strip_markdown() {
jq -rn --arg s "$1" '$s
| gsub("(?m)^\\s*(#+|[-*+]|\\d+\\.)\\s+"; "")
| gsub("\\*\\*|`"; "")
| gsub("\\[(?<t>[^\\]]+)\\]\\([^)]*\\)"; "\(.t)")
| gsub("\\s*\\n+\\s*"; " ")'
}

build_payload() {
local input="$1"
local event="$2"
Expand Down
1 change: 1 addition & 0 deletions plugins/warp/scripts/on-stop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ if [ -n "$TRANSCRIPT_PATH" ] && [ -f "$TRANSCRIPT_PATH" ]; then
[.[] | select(.type == "assistant" and .message.content)] | last |
[.message.content[] | select(.type == "text") | .text] | join(" ")
' "$TRANSCRIPT_PATH" 2>/dev/null)
RESPONSE=$(strip_markdown "$RESPONSE")

# Truncate for notification display
if [ -n "$QUERY" ] && [ ${#QUERY} -gt 200 ]; then
Expand Down
10 changes: 10 additions & 0 deletions plugins/warp/tests/test-hooks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,16 @@ assert_eq "legacy Warp shows active message" \
"🔔 Warp plugin active. You'll receive native Warp notifications when tasks complete or input is needed." \
"$SYS_MSG"

echo ""
echo "--- Markdown is stripped from notification text ---"
assert_eq "bold and code removed" "Use master now" "$(strip_markdown 'Use **`master`** now')"
assert_eq "headings and bullets removed, newlines folded" "Title one two" "$(strip_markdown $'## Title\n\n- one\n* two')"
assert_eq "numbered list removed" "first second" "$(strip_markdown $'1. first\n2. second')"
assert_eq "link keeps its text" "see the docs" "$(strip_markdown 'see [the docs](https://example.com)')"
assert_eq "underscores kept" "call __init__ and snake_case" "$(strip_markdown 'call __init__ and snake_case')"
assert_eq "plain text unchanged" 'It means greeting. Use: printf("hello")' "$(strip_markdown 'It means greeting. Use: printf("hello")')"
assert_eq "empty input" "" "$(strip_markdown '')"

echo ""
echo "--- Modern-only hooks exit silently without protocol version ---"

Expand Down