Skip to content
Merged
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
8 changes: 8 additions & 0 deletions .augment-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
"source": "./plugin_marketplace/code-review",
"category": "code-quality",
"tags": ["code-review", "git", "commands", "agents"]
},
{
"name": "warp",
"description": "Native Warp notifications when Auggie completes tasks or needs input",
"version": "2.0.0",
"source": "./plugin_marketplace/warp",
"category": "productivity",
"tags": ["notifications", "terminal", "warp"]
}
]
}
10 changes: 10 additions & 0 deletions plugin_marketplace/warp/.augment-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "warp",
"description": "Warp terminal integration for Auggie - native notifications, and more to come",
"version": "2.0.0",
"author": {
"name": "Augment Code",
"url": "https://www.augmentcode.com"
},
"homepage": "https://github.com/augmentcode/auggie/tree/main/plugin_marketplace/warp"
}
70 changes: 70 additions & 0 deletions plugin_marketplace/warp/hooks/hooks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"description": "Warp terminal notifications",
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": "${AUGMENT_PLUGIN_ROOT}/scripts/on-session-start.sh"
}
]
}
],
"Stop": [
{
"metadata": {
"includeConversationData": true
},
"hooks": [
{
"type": "command",
"command": "${AUGMENT_PLUGIN_ROOT}/scripts/on-stop.sh"
}
]
}
],
"Notification": [
{
"hooks": [
{
"type": "command",
"command": "${AUGMENT_PLUGIN_ROOT}/scripts/on-notification.sh"
}
]
}
],
"PostToolUse": [
{
"matcher": ".*",
"hooks": [
{
"type": "command",
"command": "${AUGMENT_PLUGIN_ROOT}/scripts/on-post-tool-use.sh"
}
]
}
],
"PreToolUse": [
{
"matcher": ".*",
"hooks": [
{
"type": "command",
"command": "${AUGMENT_PLUGIN_ROOT}/scripts/on-pre-tool-use.sh"
}
]
}
],
"PromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "${AUGMENT_PLUGIN_ROOT}/scripts/on-prompt-submit.sh"
}
]
}
]
}
}
58 changes: 58 additions & 0 deletions plugin_marketplace/warp/scripts/build-payload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash
# Builds a structured JSON notification payload for warp://cli-agent.
#
# Usage: source this file, then call build_payload with event-specific fields.
#
# Example:
# source "$(dirname "${BASH_SOURCE[0]}")/build-payload.sh"
# BODY=$(build_payload "$INPUT" "stop" \
# --arg query "$QUERY" \
# --arg response "$RESPONSE")
#
# The function extracts common fields (session_id, cwd, project) from the
# hook's stdin JSON (passed as $1), then merges any extra jq args you pass.

# The current protocol version this plugin knows how to produce.
PLUGIN_CURRENT_PROTOCOL_VERSION=1

# Negotiate the protocol version with Warp.
# Uses min(plugin_current, warp_declared), falling back to 1 if Warp doesn't advertise a version.
negotiate_protocol_version() {
local warp_version="${WARP_CLI_AGENT_PROTOCOL_VERSION:-1}"
if [ "$warp_version" -lt "$PLUGIN_CURRENT_PROTOCOL_VERSION" ] 2>/dev/null; then
echo "$warp_version"
else
echo "$PLUGIN_CURRENT_PROTOCOL_VERSION"
fi
}

build_payload() {
local input="$1"
local event="$2"
local agent="auggie"
shift 2

local protocol_version
protocol_version=$(negotiate_protocol_version)

# Extract common fields from the hook input
local session_id cwd project
session_id=$(echo "$input" | jq -r '.conversation_id // empty' 2>/dev/null)
cwd=$(echo "$input" | jq -r '.workspace_roots[0] // empty' 2>/dev/null)
project=""
if [ -n "$cwd" ]; then
project=$(basename "$cwd")
fi

# Build the payload: common fields + any extra args passed by the caller.
# Extra args should be jq flag pairs like: --arg key "value" or --argjson key '{"a":1}'
jq -nc \
--argjson v "$protocol_version" \
--arg agent "$agent" \
--arg event "$event" \
--arg session_id "$session_id" \
--arg cwd "$cwd" \
--arg project "$project" \
"$@" \
'{v:$v, agent:$agent, event:$event, session_id:$session_id, cwd:$cwd, project:$project} + $ARGS.named'
}
21 changes: 21 additions & 0 deletions plugin_marketplace/warp/scripts/legacy/on-notification.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
# Hook script for Auggie Notification event
# Sends a Warp notification when Auggie needs user input

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# Opt-in debug logging (set AUGGIE_WARP_DEBUG=1)
if [ -n "${AUGGIE_WARP_DEBUG:-}" ]; then
_LOG="${AUGGIE_WARP_DEBUG_LOG:-/tmp/auggie-warp-debug.log}"
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $(basename "$0") pid=$$ TERM_PROGRAM=${TERM_PROGRAM:-} WARP_PROTO=${WARP_CLI_AGENT_PROTOCOL_VERSION:-} WARP_VER=${WARP_CLIENT_VERSION:-}" >> "$_LOG"
fi

# Read hook input from stdin
INPUT=$(cat)
[ -n "${AUGGIE_WARP_DEBUG:-}" ] && echo "[stdin] $INPUT" >> "${AUGGIE_WARP_DEBUG_LOG:-/tmp/auggie-warp-debug.log}"

# Extract the notification message
MSG=$(echo "$INPUT" | jq -r '.message // "Input needed"' 2>/dev/null)
[ -z "$MSG" ] && MSG="Input needed"

"$SCRIPT_DIR/warp-notify.sh" "Auggie" "$MSG"
21 changes: 21 additions & 0 deletions plugin_marketplace/warp/scripts/legacy/on-session-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
# Hook script for Auggie SessionStart event
# Shows welcome message and Warp detection status

# Opt-in debug logging (set AUGGIE_WARP_DEBUG=1)
if [ -n "${AUGGIE_WARP_DEBUG:-}" ]; then
_LOG="${AUGGIE_WARP_DEBUG_LOG:-/tmp/auggie-warp-debug.log}"
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $(basename "$0") pid=$$ TERM_PROGRAM=${TERM_PROGRAM:-} WARP_PROTO=${WARP_CLI_AGENT_PROTOCOL_VERSION:-} WARP_VER=${WARP_CLIENT_VERSION:-}" >> "$_LOG"
fi

# Check if running in Warp terminal
if [ "$TERM_PROGRAM" = "WarpTerminal" ]; then
# Running in Warp - notifications will work
cat << 'EOF'
{
"systemMessage": "🔔 Warp plugin active. You'll receive native Warp notifications when tasks complete or input is needed."
}
EOF
else
exit 0
fi
55 changes: 55 additions & 0 deletions plugin_marketplace/warp/scripts/legacy/on-stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash
# Hook script for Auggie Stop event
# Sends a Warp notification when Auggie completes a task

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# Opt-in debug logging (set AUGGIE_WARP_DEBUG=1)
if [ -n "${AUGGIE_WARP_DEBUG:-}" ]; then
_LOG="${AUGGIE_WARP_DEBUG_LOG:-/tmp/auggie-warp-debug.log}"
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $(basename "$0") pid=$$ TERM_PROGRAM=${TERM_PROGRAM:-} WARP_PROTO=${WARP_CLI_AGENT_PROTOCOL_VERSION:-} WARP_VER=${WARP_CLIENT_VERSION:-}" >> "$_LOG"
fi

# Read hook input from stdin
INPUT=$(cat)
[ -n "${AUGGIE_WARP_DEBUG:-}" ] && echo "[stdin] $INPUT" >> "${AUGGIE_WARP_DEBUG_LOG:-/tmp/auggie-warp-debug.log}"

# Extract transcript path from the hook input
TRANSCRIPT_PATH=$(echo "$INPUT" | jq -r '.transcript_path // empty' 2>/dev/null)

# Default message
MSG="Task completed"

# Try to extract prompt and response from the transcript (JSONL format)
if [ -n "$TRANSCRIPT_PATH" ] && [ -f "$TRANSCRIPT_PATH" ]; then
# Get the first user prompt
PROMPT=$(jq -rs '
[.[] | select(.type == "user")] | first | .message.content // empty
' "$TRANSCRIPT_PATH" 2>/dev/null)

# Get the last assistant response
RESPONSE=$(jq -rs '
[.[] | select(.type == "assistant" and .message.content)] | last |
[.message.content[] | select(.type == "text") | .text] | join(" ")
' "$TRANSCRIPT_PATH" 2>/dev/null)

if [ -n "$PROMPT" ] && [ -n "$RESPONSE" ]; then
# Truncate prompt to 50 chars
if [ ${#PROMPT} -gt 50 ]; then
PROMPT="${PROMPT:0:47}..."
fi
# Truncate response to 120 chars
if [ ${#RESPONSE} -gt 120 ]; then
RESPONSE="${RESPONSE:0:117}..."
fi
MSG="\"${PROMPT}\" → ${RESPONSE}"
elif [ -n "$RESPONSE" ]; then
# Fallback to just response if no prompt found
if [ ${#RESPONSE} -gt 175 ]; then
RESPONSE="${RESPONSE:0:172}..."
fi
MSG="$RESPONSE"
fi
fi

"$SCRIPT_DIR/warp-notify.sh" "Auggie" "$MSG"
10 changes: 10 additions & 0 deletions plugin_marketplace/warp/scripts/legacy/warp-notify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
# Warp notification utility using OSC escape sequences
# Usage: warp-notify.sh <title> <body>

TITLE="${1:-Notification}"
BODY="${2:-}"

# OSC 777 format: \033]777;notify;<title>;<body>\007
# Write directly to /dev/tty to ensure it reaches the terminal
printf '\033]777;notify;%s;%s\007' "$TITLE" "$BODY" > /dev/tty 2>/dev/null || true
27 changes: 27 additions & 0 deletions plugin_marketplace/warp/scripts/on-notification.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
# Hook script for Auggie Notification event (idle_prompt only)
# Sends a structured Warp notification when Auggie has been idle

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

source "$SCRIPT_DIR/should-use-structured.sh"

# Legacy fallback for old Warp versions
if ! should_use_structured; then
[ "$TERM_PROGRAM" = "WarpTerminal" ] && exec "$SCRIPT_DIR/legacy/on-notification.sh"
exit 0
fi

source "$SCRIPT_DIR/build-payload.sh"

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

# Extract notification-specific fields
NOTIF_TYPE=$(echo "$INPUT" | jq -r '.notification_type // "unknown"' 2>/dev/null)
MSG=$(echo "$INPUT" | jq -r '.notification_message // "Input needed"' 2>/dev/null)
[ -z "$MSG" ] && MSG="Input needed"

BODY=$(build_payload "$INPUT" "$NOTIF_TYPE" \
--arg summary "$MSG")
"$SCRIPT_DIR/warp-notify.sh" "warp://cli-agent" "$BODY"
25 changes: 25 additions & 0 deletions plugin_marketplace/warp/scripts/on-post-tool-use.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
# Hook script for Auggie PostToolUse event
# Sends a structured Warp notification after a tool call completes,
# transitioning the session status from Blocked back to Running.

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)

TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name // empty' 2>/dev/null)

BODY=$(build_payload "$INPUT" "tool_complete" \
--arg tool_name "$TOOL_NAME")

"$SCRIPT_DIR/warp-notify.sh" "warp://cli-agent" "$BODY"
28 changes: 28 additions & 0 deletions plugin_marketplace/warp/scripts/on-pre-tool-use.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
# Hook script for Auggie PreToolUse event
# Detects when Auggie is waiting for user input (ask-user tool) and sends
# a "permission_request" so Warp shows the stop sign / blocked indicator.

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)

TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name // empty' 2>/dev/null)

# ask-user means the agent is waiting for input (plan mode / permission).
# Send "permission_request" so Warp shows the stop sign instead of "in progress".
if [ "$TOOL_NAME" = "ask-user" ]; then
BODY=$(build_payload "$INPUT" "permission_request" \
--arg tool_name "$TOOL_NAME")
"$SCRIPT_DIR/warp-notify.sh" "warp://cli-agent" "$BODY"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Agent🛡️ on behalf of @augmentmoogi

The permission_request test in tests/test-hooks.sh builds a payload with tool_input.command, but this hook only forwards --arg tool_name "$TOOL_NAME" — never tool_input. The test is exercising build-payload.sh's arg-forwarding generically, not what the hook actually emits, so the asserted tool_input.command field will not appear in real notifications. Either drop tool_input from that test case (since the hook doesn't emit it) or, if you do want Warp to receive the tool input on permission_request, plumb it through here with --argjson tool_input "$(echo "$INPUT" | jq -c '.tool_input // {}')".

fi
28 changes: 28 additions & 0 deletions plugin_marketplace/warp/scripts/on-prompt-submit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
# Hook script for Auggie PromptSubmit event
# Sends a "prompt_submit" Warp notification when the user submits a prompt,
# transitioning the session status from idle/done back to running.

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)

# Extract the user's prompt
QUERY=$(echo "$INPUT" | jq -r '.user_prompt // empty' 2>/dev/null)
if [ -n "$QUERY" ] && [ ${#QUERY} -gt 200 ]; then
QUERY="${QUERY:0:197}..."
fi

BODY=$(build_payload "$INPUT" "prompt_submit" \
--arg query "$QUERY")
"$SCRIPT_DIR/warp-notify.sh" "warp://cli-agent" "$BODY"
Loading