From e30b2f788342102f69011a44b4184559dab058e0 Mon Sep 17 00:00:00 2001 From: Xytronix <32957125+Xytronix@users.noreply.github.com> Date: Sun, 26 Apr 2026 09:38:54 +0200 Subject: [PATCH 1/2] feat: add Amp and Cline CLI agent support Add Warp notification plugins for two additional CLI coding agents: - **Amp** (ampcode.com): TypeScript plugin using Amp's plugin API (`amp.on(...)` event handlers). Hooks into session.start, agent.start, tool.call, tool.result, and agent.end events. - **Cline CLI** (cline.bot): File-based shell hook scripts placed in ~/Documents/Cline/Hooks/. Covers TaskStart, TaskComplete, TaskError, PreToolUse, PostToolUse, and UserPromptSubmit events. Both emit identical warp://cli-agent OSC 777 structured notifications with the same JSON schema as the existing Claude Code plugin. --- plugins/amp/README.md | 55 +++++++++++++++++ plugins/amp/warp-notify.ts | 81 +++++++++++++++++++++++++ plugins/cline/README.md | 42 +++++++++++++ plugins/cline/hooks/PostToolUse.sh | 27 +++++++++ plugins/cline/hooks/PreToolUse.sh | 33 ++++++++++ plugins/cline/hooks/TaskComplete.sh | 31 ++++++++++ plugins/cline/hooks/TaskError.sh | 25 ++++++++ plugins/cline/hooks/TaskStart.sh | 24 ++++++++ plugins/cline/hooks/UserPromptSubmit.sh | 28 +++++++++ 9 files changed, 346 insertions(+) create mode 100644 plugins/amp/README.md create mode 100644 plugins/amp/warp-notify.ts create mode 100644 plugins/cline/README.md create mode 100644 plugins/cline/hooks/PostToolUse.sh create mode 100644 plugins/cline/hooks/PreToolUse.sh create mode 100644 plugins/cline/hooks/TaskComplete.sh create mode 100644 plugins/cline/hooks/TaskError.sh create mode 100644 plugins/cline/hooks/TaskStart.sh create mode 100644 plugins/cline/hooks/UserPromptSubmit.sh diff --git a/plugins/amp/README.md b/plugins/amp/README.md new file mode 100644 index 0000000..518eaca --- /dev/null +++ b/plugins/amp/README.md @@ -0,0 +1,55 @@ +# Warp Notifications for Amp + +Warp terminal integration for [Amp](https://ampcode.com) — the coding agent by Sourcegraph. + +## Installation + +Copy the plugin file to Amp's global plugins directory: + +```bash +cp plugins/amp/warp-notify.ts ~/.config/amp/plugins/warp-notify.ts +``` + +Then run Amp with plugins enabled: + +```bash +PLUGINS=all amp +``` + +To enable permanently, add to your shell profile: + +```bash +echo 'export PLUGINS=all' >> ~/.zshrc +``` + +## Verify + +```bash +PLUGINS=all amp plugins list +``` + +You should see: +``` +✓ /Users/you/.config/amp/plugins/warp-notify.ts active + Events: session.start, agent.start, tool.call, tool.result, agent.end +``` + +## Requirements + +- [Warp terminal](https://warp.dev) +- [Amp CLI](https://ampcode.com) (binary install, not npm) +- `PLUGINS=all` environment variable + +## How It Works + +Uses Amp's TypeScript plugin API (`amp.on(...)`) to hook into 5 lifecycle events and emit the same `warp://cli-agent` OSC 777 structured notifications as the Claude Code plugin. + +| Amp Event | Warp Notification | +|---|---| +| `session.start` | `session_start` | +| `agent.start` | `prompt_submit` | +| `tool.call` | `permission_request` | +| `tool.result` | `tool_complete` | +| `agent.end` | `stop` | + +> **Note**: Amp's plugin API is experimental. Expect breaking changes. diff --git a/plugins/amp/warp-notify.ts b/plugins/amp/warp-notify.ts new file mode 100644 index 0000000..7febedd --- /dev/null +++ b/plugins/amp/warp-notify.ts @@ -0,0 +1,81 @@ +// @i-know-the-amp-plugin-api-is-wip-and-very-experimental-right-now +import type { PluginAPI } from '@ampcode/plugin' + +function shouldUseStructured(): boolean { + const proto = process.env.WARP_CLI_AGENT_PROTOCOL_VERSION + const client = process.env.WARP_CLIENT_VERSION + if (!proto || !client) return false + + const LAST_BROKEN_STABLE = 'v0.2026.03.25.08.24.stable_05' + const LAST_BROKEN_PREVIEW = 'v0.2026.03.25.08.24.preview_05' + + let threshold = '' + if (client.includes('stable')) threshold = LAST_BROKEN_STABLE + else if (client.includes('preview')) threshold = LAST_BROKEN_PREVIEW + + if (threshold && !(client > threshold)) return false + return true +} + +function warpNotify(payload: Record): void { + if (!shouldUseStructured()) return + const body = JSON.stringify(payload) + try { + const fs = require('fs') + fs.writeFileSync('/dev/tty', `\x1b]777;notify;warp://cli-agent;${body}\x07`) + } catch {} +} + +function buildPayload(event: string, extra: Record = {}): Record { + const cwd = process.cwd() + return { + v: 1, + agent: 'amp', + event, + cwd, + project: cwd.split('/').pop() || '', + ...extra, + } +} + +export default function (amp: PluginAPI) { + amp.on('session.start', (event) => { + warpNotify(buildPayload('session_start', { + session_id: event.thread?.id || 'unknown', + })) + }) + + amp.on('agent.start', (event) => { + const query = event.message.length > 200 ? event.message.slice(0, 197) + '...' : event.message + warpNotify(buildPayload('prompt_submit', { + session_id: event.thread.id, + query, + })) + }) + + amp.on('tool.call', (event, ctx) => { + const summary = `Wants to run ${event.tool}` + warpNotify(buildPayload('permission_request', { + session_id: event.thread.id, + summary, + tool_name: event.tool, + tool_input: event.input, + })) + return { action: 'allow' } + }) + + amp.on('tool.result', (event) => { + warpNotify(buildPayload('tool_complete', { + session_id: event.thread.id, + tool_name: event.tool, + })) + }) + + amp.on('agent.end', (event) => { + const query = event.message.length > 200 ? event.message.slice(0, 197) + '...' : event.message + warpNotify(buildPayload('stop', { + session_id: event.thread.id, + query, + })) + }) +} diff --git a/plugins/cline/README.md b/plugins/cline/README.md new file mode 100644 index 0000000..81a69bd --- /dev/null +++ b/plugins/cline/README.md @@ -0,0 +1,42 @@ +# Warp Notifications for Cline CLI + +Warp terminal integration for [Cline CLI](https://cline.bot) — the open-source AI coding agent. + +## Installation + +Copy the hook scripts to Cline's hooks directory: + +```bash +mkdir -p ~/Documents/Cline/Hooks +cp plugins/cline/hooks/*.sh ~/Documents/Cline/Hooks/ +chmod +x ~/Documents/Cline/Hooks/*.sh +``` + +Cline automatically discovers hooks from `~/Documents/Cline/Hooks/`. + +## Hooks + +| Hook File | Warp Notification | When | +|---|---|---| +| `TaskStart.sh` | `session_start` | Cline starts a new task | +| `TaskComplete.sh` | `stop` | Cline finishes a task | +| `TaskError.sh` | `stop` (with error) | Cline encounters an error | +| `PreToolUse.sh` | `permission_request` | Before a tool runs | +| `PostToolUse.sh` | `tool_complete` | After a tool finishes | +| `UserPromptSubmit.sh` | `prompt_submit` | User sends a prompt | + +## Requirements + +- [Warp terminal](https://warp.dev) +- [Cline CLI](https://cline.bot) v2.15+ +- `jq` for JSON parsing (`brew install jq`) + +## How It Works + +Each hook script is a self-contained bash script that: +1. Checks for Warp's `WARP_CLI_AGENT_PROTOCOL_VERSION` env var (exits silently if not in Warp) +2. Reads event data from stdin as JSON +3. Builds a structured notification payload +4. Emits it via OSC 777 escape sequence to `/dev/tty` + +The payloads use the same `warp://cli-agent` protocol as the Claude Code plugin. diff --git a/plugins/cline/hooks/PostToolUse.sh b/plugins/cline/hooks/PostToolUse.sh new file mode 100644 index 0000000..5abad34 --- /dev/null +++ b/plugins/cline/hooks/PostToolUse.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# Warp notification on Cline post-tool-use + +[ -z "${WARP_CLI_AGENT_PROTOCOL_VERSION:-}" ] && exit 0 +[ -z "${WARP_CLIENT_VERSION:-}" ] && exit 0 + +command -v jq &>/dev/null || exit 0 + +INPUT=$(cat 2>/dev/null || echo '{}') +SESSION_ID=$(echo "$INPUT" | jq -r '.conversationId // .session_id // "unknown"' 2>/dev/null) +CWD=$(echo "$INPUT" | jq -r '.cwd // empty' 2>/dev/null) +[ -z "$CWD" ] && CWD="$(pwd)" +PROJECT=$(basename "$CWD") + +TOOL_NAME=$(echo "$INPUT" | jq -r '.tool // .tool_name // empty' 2>/dev/null) + +BODY=$(jq -nc \ + --argjson v 1 \ + --arg agent "cline" \ + --arg event "tool_complete" \ + --arg session_id "$SESSION_ID" \ + --arg cwd "$CWD" \ + --arg project "$PROJECT" \ + --arg tool_name "$TOOL_NAME" \ + '{v:$v, agent:$agent, event:$event, session_id:$session_id, cwd:$cwd, project:$project, tool_name:$tool_name}') + +printf '\033]777;notify;%s;%s\007' "warp://cli-agent" "$BODY" > /dev/tty 2>/dev/null || true diff --git a/plugins/cline/hooks/PreToolUse.sh b/plugins/cline/hooks/PreToolUse.sh new file mode 100644 index 0000000..3ea00a0 --- /dev/null +++ b/plugins/cline/hooks/PreToolUse.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# Warp notification on Cline pre-tool-use (permission request) + +[ -z "${WARP_CLI_AGENT_PROTOCOL_VERSION:-}" ] && exit 0 +[ -z "${WARP_CLIENT_VERSION:-}" ] && exit 0 + +command -v jq &>/dev/null || exit 0 + +INPUT=$(cat 2>/dev/null || echo '{}') +SESSION_ID=$(echo "$INPUT" | jq -r '.conversationId // .session_id // "unknown"' 2>/dev/null) +CWD=$(echo "$INPUT" | jq -r '.cwd // empty' 2>/dev/null) +[ -z "$CWD" ] && CWD="$(pwd)" +PROJECT=$(basename "$CWD") + +TOOL_NAME=$(echo "$INPUT" | jq -r '.tool // .tool_name // "unknown"' 2>/dev/null) +TOOL_INPUT=$(echo "$INPUT" | jq -c '.input // .tool_input // {}' 2>/dev/null) +[ -z "$TOOL_INPUT" ] && TOOL_INPUT='{}' + +SUMMARY="Wants to run $TOOL_NAME" + +BODY=$(jq -nc \ + --argjson v 1 \ + --arg agent "cline" \ + --arg event "permission_request" \ + --arg session_id "$SESSION_ID" \ + --arg cwd "$CWD" \ + --arg project "$PROJECT" \ + --arg summary "$SUMMARY" \ + --arg tool_name "$TOOL_NAME" \ + --argjson tool_input "$TOOL_INPUT" \ + '{v:$v, agent:$agent, event:$event, session_id:$session_id, cwd:$cwd, project:$project, summary:$summary, tool_name:$tool_name, tool_input:$tool_input}') + +printf '\033]777;notify;%s;%s\007' "warp://cli-agent" "$BODY" > /dev/tty 2>/dev/null || true diff --git a/plugins/cline/hooks/TaskComplete.sh b/plugins/cline/hooks/TaskComplete.sh new file mode 100644 index 0000000..bc73786 --- /dev/null +++ b/plugins/cline/hooks/TaskComplete.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# Warp notification on Cline task complete + +[ -z "${WARP_CLI_AGENT_PROTOCOL_VERSION:-}" ] && exit 0 +[ -z "${WARP_CLIENT_VERSION:-}" ] && exit 0 + +command -v jq &>/dev/null || exit 0 + +INPUT=$(cat 2>/dev/null || echo '{}') +SESSION_ID=$(echo "$INPUT" | jq -r '.conversationId // .session_id // "unknown"' 2>/dev/null) +CWD=$(echo "$INPUT" | jq -r '.cwd // empty' 2>/dev/null) +[ -z "$CWD" ] && CWD="$(pwd)" +PROJECT=$(basename "$CWD") + +QUERY=$(echo "$INPUT" | jq -r '.query // .prompt // empty' 2>/dev/null) +RESPONSE=$(echo "$INPUT" | jq -r '.response // empty' 2>/dev/null) +[ -n "$QUERY" ] && [ ${#QUERY} -gt 200 ] && QUERY="${QUERY:0:197}..." +[ -n "$RESPONSE" ] && [ ${#RESPONSE} -gt 200 ] && RESPONSE="${RESPONSE:0:197}..." + +BODY=$(jq -nc \ + --argjson v 1 \ + --arg agent "cline" \ + --arg event "stop" \ + --arg session_id "$SESSION_ID" \ + --arg cwd "$CWD" \ + --arg project "$PROJECT" \ + --arg query "$QUERY" \ + --arg response "$RESPONSE" \ + '{v:$v, agent:$agent, event:$event, session_id:$session_id, cwd:$cwd, project:$project, query:$query, response:$response}') + +printf '\033]777;notify;%s;%s\007' "warp://cli-agent" "$BODY" > /dev/tty 2>/dev/null || true diff --git a/plugins/cline/hooks/TaskError.sh b/plugins/cline/hooks/TaskError.sh new file mode 100644 index 0000000..258480d --- /dev/null +++ b/plugins/cline/hooks/TaskError.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# Warp notification on Cline task error + +[ -z "${WARP_CLI_AGENT_PROTOCOL_VERSION:-}" ] && exit 0 +[ -z "${WARP_CLIENT_VERSION:-}" ] && exit 0 + +command -v jq &>/dev/null || exit 0 + +INPUT=$(cat 2>/dev/null || echo '{}') +SESSION_ID=$(echo "$INPUT" | jq -r '.conversationId // .session_id // "unknown"' 2>/dev/null) +CWD=$(echo "$INPUT" | jq -r '.cwd // empty' 2>/dev/null) +[ -z "$CWD" ] && CWD="$(pwd)" +PROJECT=$(basename "$CWD") + +BODY=$(jq -nc \ + --argjson v 1 \ + --arg agent "cline" \ + --arg event "stop" \ + --arg session_id "$SESSION_ID" \ + --arg cwd "$CWD" \ + --arg project "$PROJECT" \ + --arg summary "Task errored" \ + '{v:$v, agent:$agent, event:$event, session_id:$session_id, cwd:$cwd, project:$project, summary:$summary}') + +printf '\033]777;notify;%s;%s\007' "warp://cli-agent" "$BODY" > /dev/tty 2>/dev/null || true diff --git a/plugins/cline/hooks/TaskStart.sh b/plugins/cline/hooks/TaskStart.sh new file mode 100644 index 0000000..026e29a --- /dev/null +++ b/plugins/cline/hooks/TaskStart.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# Warp notification on Cline task start + +[ -z "${WARP_CLI_AGENT_PROTOCOL_VERSION:-}" ] && exit 0 +[ -z "${WARP_CLIENT_VERSION:-}" ] && exit 0 + +command -v jq &>/dev/null || exit 0 + +INPUT=$(cat 2>/dev/null || echo '{}') +SESSION_ID=$(echo "$INPUT" | jq -r '.conversationId // .session_id // "unknown"' 2>/dev/null) +CWD=$(echo "$INPUT" | jq -r '.cwd // empty' 2>/dev/null) +[ -z "$CWD" ] && CWD="$(pwd)" +PROJECT=$(basename "$CWD") + +BODY=$(jq -nc \ + --argjson v 1 \ + --arg agent "cline" \ + --arg event "session_start" \ + --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}') + +printf '\033]777;notify;%s;%s\007' "warp://cli-agent" "$BODY" > /dev/tty 2>/dev/null || true diff --git a/plugins/cline/hooks/UserPromptSubmit.sh b/plugins/cline/hooks/UserPromptSubmit.sh new file mode 100644 index 0000000..371a956 --- /dev/null +++ b/plugins/cline/hooks/UserPromptSubmit.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# Warp notification on Cline user prompt submit + +[ -z "${WARP_CLI_AGENT_PROTOCOL_VERSION:-}" ] && exit 0 +[ -z "${WARP_CLIENT_VERSION:-}" ] && exit 0 + +command -v jq &>/dev/null || exit 0 + +INPUT=$(cat 2>/dev/null || echo '{}') +SESSION_ID=$(echo "$INPUT" | jq -r '.conversationId // .session_id // "unknown"' 2>/dev/null) +CWD=$(echo "$INPUT" | jq -r '.cwd // empty' 2>/dev/null) +[ -z "$CWD" ] && CWD="$(pwd)" +PROJECT=$(basename "$CWD") + +QUERY=$(echo "$INPUT" | jq -r '.prompt // empty' 2>/dev/null) +[ -n "$QUERY" ] && [ ${#QUERY} -gt 200 ] && QUERY="${QUERY:0:197}..." + +BODY=$(jq -nc \ + --argjson v 1 \ + --arg agent "cline" \ + --arg event "prompt_submit" \ + --arg session_id "$SESSION_ID" \ + --arg cwd "$CWD" \ + --arg project "$PROJECT" \ + --arg query "$QUERY" \ + '{v:$v, agent:$agent, event:$event, session_id:$session_id, cwd:$cwd, project:$project, query:$query}') + +printf '\033]777;notify;%s;%s\007' "warp://cli-agent" "$BODY" > /dev/tty 2>/dev/null || true From 7f1de22b7ff9880127edd4488928a1e06da66dde Mon Sep 17 00:00:00 2001 From: Xytronix <32957125+Xytronix@users.noreply.github.com> Date: Thu, 12 Nov 2026 16:46:35 +0000 Subject: [PATCH 2/2] Fix Cline hook payload fields and refresh Amp install steps Cline hooks read taskId, workspaceRoots and the event-specific preToolUse/postToolUse/userPromptSubmit/turn/error fields from the hook payload, apply the same Warp build check as the Claude Code plugin via a shared helper, and are committed executable. Document ~/.cline/hooks as the install location. Amp no longer needs PLUGINS=all or the WIP opt-in comment; load the plugin from the system plugins directory and import node:fs instead of require. --- plugins/amp/README.md | 26 +++---------- plugins/amp/warp-notify.ts | 5 +-- plugins/cline/README.md | 14 +++---- plugins/cline/hooks/PostToolUse.sh | 16 +++----- plugins/cline/hooks/PreToolUse.sh | 18 +++------ plugins/cline/hooks/TaskComplete.sh | 21 +++------- plugins/cline/hooks/TaskError.sh | 18 ++++----- plugins/cline/hooks/TaskStart.sh | 13 ++----- plugins/cline/hooks/UserPromptSubmit.sh | 17 +++----- plugins/cline/hooks/warp-notify.sh | 52 +++++++++++++++++++++++++ 10 files changed, 101 insertions(+), 99 deletions(-) mode change 100644 => 100755 plugins/cline/hooks/PostToolUse.sh mode change 100644 => 100755 plugins/cline/hooks/PreToolUse.sh mode change 100644 => 100755 plugins/cline/hooks/TaskComplete.sh mode change 100644 => 100755 plugins/cline/hooks/TaskError.sh mode change 100644 => 100755 plugins/cline/hooks/TaskStart.sh mode change 100644 => 100755 plugins/cline/hooks/UserPromptSubmit.sh create mode 100755 plugins/cline/hooks/warp-notify.sh diff --git a/plugins/amp/README.md b/plugins/amp/README.md index 518eaca..518f434 100644 --- a/plugins/amp/README.md +++ b/plugins/amp/README.md @@ -4,41 +4,27 @@ Warp terminal integration for [Amp](https://ampcode.com) — the coding agent by ## Installation -Copy the plugin file to Amp's global plugins directory: +Copy the plugin file to Amp's system plugins directory (`$XDG_CONFIG_HOME/amp/plugins/` if `XDG_CONFIG_HOME` is set): ```bash +mkdir -p ~/.config/amp/plugins cp plugins/amp/warp-notify.ts ~/.config/amp/plugins/warp-notify.ts ``` -Then run Amp with plugins enabled: - -```bash -PLUGINS=all amp -``` - -To enable permanently, add to your shell profile: - -```bash -echo 'export PLUGINS=all' >> ~/.zshrc -``` +To enable it for a single project instead, copy it to `.amp/plugins/` at the project root. Run `plugins: reload` from the command palette to load it into a running thread. ## Verify ```bash -PLUGINS=all amp plugins list +amp plugins list ``` -You should see: -``` -✓ /Users/you/.config/amp/plugins/warp-notify.ts active - Events: session.start, agent.start, tool.call, tool.result, agent.end -``` +The list should include `warp-notify.ts` with the events `session.start`, `agent.start`, `tool.call`, `tool.result` and `agent.end`. ## Requirements - [Warp terminal](https://warp.dev) -- [Amp CLI](https://ampcode.com) (binary install, not npm) -- `PLUGINS=all` environment variable +- [Amp CLI](https://ampcode.com) ## How It Works diff --git a/plugins/amp/warp-notify.ts b/plugins/amp/warp-notify.ts index 7febedd..fb978cf 100644 --- a/plugins/amp/warp-notify.ts +++ b/plugins/amp/warp-notify.ts @@ -1,4 +1,4 @@ -// @i-know-the-amp-plugin-api-is-wip-and-very-experimental-right-now +import { writeFileSync } from 'node:fs' import type { PluginAPI } from '@ampcode/plugin' function shouldUseStructured(): boolean { @@ -21,8 +21,7 @@ function warpNotify(payload: Record): void { if (!shouldUseStructured()) return const body = JSON.stringify(payload) try { - const fs = require('fs') - fs.writeFileSync('/dev/tty', `\x1b]777;notify;warp://cli-agent;${body}\x07`) + writeFileSync('/dev/tty', `\x1b]777;notify;warp://cli-agent;${body}\x07`) } catch {} } diff --git a/plugins/cline/README.md b/plugins/cline/README.md index 81a69bd..54ff338 100644 --- a/plugins/cline/README.md +++ b/plugins/cline/README.md @@ -7,12 +7,12 @@ Warp terminal integration for [Cline CLI](https://cline.bot) — the open-source Copy the hook scripts to Cline's hooks directory: ```bash -mkdir -p ~/Documents/Cline/Hooks -cp plugins/cline/hooks/*.sh ~/Documents/Cline/Hooks/ -chmod +x ~/Documents/Cline/Hooks/*.sh +mkdir -p ~/.cline/hooks +cp plugins/cline/hooks/*.sh ~/.cline/hooks/ +chmod +x ~/.cline/hooks/*.sh ``` -Cline automatically discovers hooks from `~/Documents/Cline/Hooks/`. +Cline CLI discovers global hooks from `~/.cline/hooks/` (and `~/Documents/Cline/Hooks/`), and project hooks from `.cline/hooks/`. `warp-notify.sh` is a shared helper sourced by the hooks; it must sit in the same directory. ## Hooks @@ -33,9 +33,9 @@ Cline automatically discovers hooks from `~/Documents/Cline/Hooks/`. ## How It Works -Each hook script is a self-contained bash script that: -1. Checks for Warp's `WARP_CLI_AGENT_PROTOCOL_VERSION` env var (exits silently if not in Warp) -2. Reads event data from stdin as JSON +Each hook script: +1. Checks that the Warp build supports structured notifications (`WARP_CLI_AGENT_PROTOCOL_VERSION`, `WARP_CLIENT_VERSION`) and exits silently otherwise +2. Reads Cline's hook payload from stdin (`taskId`, `workspaceRoots` and the event-specific fields) 3. Builds a structured notification payload 4. Emits it via OSC 777 escape sequence to `/dev/tty` diff --git a/plugins/cline/hooks/PostToolUse.sh b/plugins/cline/hooks/PostToolUse.sh old mode 100644 new mode 100755 index 5abad34..5bb7eb1 --- a/plugins/cline/hooks/PostToolUse.sh +++ b/plugins/cline/hooks/PostToolUse.sh @@ -1,18 +1,12 @@ #!/bin/bash # Warp notification on Cline post-tool-use -[ -z "${WARP_CLI_AGENT_PROTOCOL_VERSION:-}" ] && exit 0 -[ -z "${WARP_CLIENT_VERSION:-}" ] && exit 0 - command -v jq &>/dev/null || exit 0 +source "$(dirname "${BASH_SOURCE[0]}")/warp-notify.sh" +should_use_structured || exit 0 -INPUT=$(cat 2>/dev/null || echo '{}') -SESSION_ID=$(echo "$INPUT" | jq -r '.conversationId // .session_id // "unknown"' 2>/dev/null) -CWD=$(echo "$INPUT" | jq -r '.cwd // empty' 2>/dev/null) -[ -z "$CWD" ] && CWD="$(pwd)" -PROJECT=$(basename "$CWD") - -TOOL_NAME=$(echo "$INPUT" | jq -r '.tool // .tool_name // empty' 2>/dev/null) +read_hook_input +TOOL_NAME=$(echo "$INPUT" | jq -r '.postToolUse.toolName // .tool_result.name // empty' 2>/dev/null) BODY=$(jq -nc \ --argjson v 1 \ @@ -24,4 +18,4 @@ BODY=$(jq -nc \ --arg tool_name "$TOOL_NAME" \ '{v:$v, agent:$agent, event:$event, session_id:$session_id, cwd:$cwd, project:$project, tool_name:$tool_name}') -printf '\033]777;notify;%s;%s\007' "warp://cli-agent" "$BODY" > /dev/tty 2>/dev/null || true +warp_notify "$BODY" diff --git a/plugins/cline/hooks/PreToolUse.sh b/plugins/cline/hooks/PreToolUse.sh old mode 100644 new mode 100755 index 3ea00a0..d5703a0 --- a/plugins/cline/hooks/PreToolUse.sh +++ b/plugins/cline/hooks/PreToolUse.sh @@ -1,19 +1,13 @@ #!/bin/bash # Warp notification on Cline pre-tool-use (permission request) -[ -z "${WARP_CLI_AGENT_PROTOCOL_VERSION:-}" ] && exit 0 -[ -z "${WARP_CLIENT_VERSION:-}" ] && exit 0 - command -v jq &>/dev/null || exit 0 +source "$(dirname "${BASH_SOURCE[0]}")/warp-notify.sh" +should_use_structured || exit 0 -INPUT=$(cat 2>/dev/null || echo '{}') -SESSION_ID=$(echo "$INPUT" | jq -r '.conversationId // .session_id // "unknown"' 2>/dev/null) -CWD=$(echo "$INPUT" | jq -r '.cwd // empty' 2>/dev/null) -[ -z "$CWD" ] && CWD="$(pwd)" -PROJECT=$(basename "$CWD") - -TOOL_NAME=$(echo "$INPUT" | jq -r '.tool // .tool_name // "unknown"' 2>/dev/null) -TOOL_INPUT=$(echo "$INPUT" | jq -c '.input // .tool_input // {}' 2>/dev/null) +read_hook_input +TOOL_NAME=$(echo "$INPUT" | jq -r '.preToolUse.toolName // .tool_call.name // "unknown"' 2>/dev/null) +TOOL_INPUT=$(echo "$INPUT" | jq -c '.tool_call.input // .preToolUse.parameters // {}' 2>/dev/null) [ -z "$TOOL_INPUT" ] && TOOL_INPUT='{}' SUMMARY="Wants to run $TOOL_NAME" @@ -30,4 +24,4 @@ BODY=$(jq -nc \ --argjson tool_input "$TOOL_INPUT" \ '{v:$v, agent:$agent, event:$event, session_id:$session_id, cwd:$cwd, project:$project, summary:$summary, tool_name:$tool_name, tool_input:$tool_input}') -printf '\033]777;notify;%s;%s\007' "warp://cli-agent" "$BODY" > /dev/tty 2>/dev/null || true +warp_notify "$BODY" diff --git a/plugins/cline/hooks/TaskComplete.sh b/plugins/cline/hooks/TaskComplete.sh old mode 100644 new mode 100755 index bc73786..70fee36 --- a/plugins/cline/hooks/TaskComplete.sh +++ b/plugins/cline/hooks/TaskComplete.sh @@ -1,21 +1,12 @@ #!/bin/bash # Warp notification on Cline task complete -[ -z "${WARP_CLI_AGENT_PROTOCOL_VERSION:-}" ] && exit 0 -[ -z "${WARP_CLIENT_VERSION:-}" ] && exit 0 - command -v jq &>/dev/null || exit 0 +source "$(dirname "${BASH_SOURCE[0]}")/warp-notify.sh" +should_use_structured || exit 0 -INPUT=$(cat 2>/dev/null || echo '{}') -SESSION_ID=$(echo "$INPUT" | jq -r '.conversationId // .session_id // "unknown"' 2>/dev/null) -CWD=$(echo "$INPUT" | jq -r '.cwd // empty' 2>/dev/null) -[ -z "$CWD" ] && CWD="$(pwd)" -PROJECT=$(basename "$CWD") - -QUERY=$(echo "$INPUT" | jq -r '.query // .prompt // empty' 2>/dev/null) -RESPONSE=$(echo "$INPUT" | jq -r '.response // empty' 2>/dev/null) -[ -n "$QUERY" ] && [ ${#QUERY} -gt 200 ] && QUERY="${QUERY:0:197}..." -[ -n "$RESPONSE" ] && [ ${#RESPONSE} -gt 200 ] && RESPONSE="${RESPONSE:0:197}..." +read_hook_input +RESPONSE=$(truncate_text "$(echo "$INPUT" | jq -r '.turn.outputText // empty' 2>/dev/null)") BODY=$(jq -nc \ --argjson v 1 \ @@ -24,8 +15,8 @@ BODY=$(jq -nc \ --arg session_id "$SESSION_ID" \ --arg cwd "$CWD" \ --arg project "$PROJECT" \ - --arg query "$QUERY" \ + --arg query "" \ --arg response "$RESPONSE" \ '{v:$v, agent:$agent, event:$event, session_id:$session_id, cwd:$cwd, project:$project, query:$query, response:$response}') -printf '\033]777;notify;%s;%s\007' "warp://cli-agent" "$BODY" > /dev/tty 2>/dev/null || true +warp_notify "$BODY" diff --git a/plugins/cline/hooks/TaskError.sh b/plugins/cline/hooks/TaskError.sh old mode 100644 new mode 100755 index 258480d..1d8dd27 --- a/plugins/cline/hooks/TaskError.sh +++ b/plugins/cline/hooks/TaskError.sh @@ -1,16 +1,14 @@ #!/bin/bash # Warp notification on Cline task error -[ -z "${WARP_CLI_AGENT_PROTOCOL_VERSION:-}" ] && exit 0 -[ -z "${WARP_CLIENT_VERSION:-}" ] && exit 0 - command -v jq &>/dev/null || exit 0 +source "$(dirname "${BASH_SOURCE[0]}")/warp-notify.sh" +should_use_structured || exit 0 -INPUT=$(cat 2>/dev/null || echo '{}') -SESSION_ID=$(echo "$INPUT" | jq -r '.conversationId // .session_id // "unknown"' 2>/dev/null) -CWD=$(echo "$INPUT" | jq -r '.cwd // empty' 2>/dev/null) -[ -z "$CWD" ] && CWD="$(pwd)" -PROJECT=$(basename "$CWD") +read_hook_input +ERROR=$(truncate_text "$(echo "$INPUT" | jq -r '.error.message // empty' 2>/dev/null)") +SUMMARY="Task errored" +[ -n "$ERROR" ] && SUMMARY="Task errored: $ERROR" BODY=$(jq -nc \ --argjson v 1 \ @@ -19,7 +17,7 @@ BODY=$(jq -nc \ --arg session_id "$SESSION_ID" \ --arg cwd "$CWD" \ --arg project "$PROJECT" \ - --arg summary "Task errored" \ + --arg summary "$SUMMARY" \ '{v:$v, agent:$agent, event:$event, session_id:$session_id, cwd:$cwd, project:$project, summary:$summary}') -printf '\033]777;notify;%s;%s\007' "warp://cli-agent" "$BODY" > /dev/tty 2>/dev/null || true +warp_notify "$BODY" diff --git a/plugins/cline/hooks/TaskStart.sh b/plugins/cline/hooks/TaskStart.sh old mode 100644 new mode 100755 index 026e29a..4f46c84 --- a/plugins/cline/hooks/TaskStart.sh +++ b/plugins/cline/hooks/TaskStart.sh @@ -1,16 +1,11 @@ #!/bin/bash # Warp notification on Cline task start -[ -z "${WARP_CLI_AGENT_PROTOCOL_VERSION:-}" ] && exit 0 -[ -z "${WARP_CLIENT_VERSION:-}" ] && exit 0 - command -v jq &>/dev/null || exit 0 +source "$(dirname "${BASH_SOURCE[0]}")/warp-notify.sh" +should_use_structured || exit 0 -INPUT=$(cat 2>/dev/null || echo '{}') -SESSION_ID=$(echo "$INPUT" | jq -r '.conversationId // .session_id // "unknown"' 2>/dev/null) -CWD=$(echo "$INPUT" | jq -r '.cwd // empty' 2>/dev/null) -[ -z "$CWD" ] && CWD="$(pwd)" -PROJECT=$(basename "$CWD") +read_hook_input BODY=$(jq -nc \ --argjson v 1 \ @@ -21,4 +16,4 @@ BODY=$(jq -nc \ --arg project "$PROJECT" \ '{v:$v, agent:$agent, event:$event, session_id:$session_id, cwd:$cwd, project:$project}') -printf '\033]777;notify;%s;%s\007' "warp://cli-agent" "$BODY" > /dev/tty 2>/dev/null || true +warp_notify "$BODY" diff --git a/plugins/cline/hooks/UserPromptSubmit.sh b/plugins/cline/hooks/UserPromptSubmit.sh old mode 100644 new mode 100755 index 371a956..15d04a1 --- a/plugins/cline/hooks/UserPromptSubmit.sh +++ b/plugins/cline/hooks/UserPromptSubmit.sh @@ -1,19 +1,12 @@ #!/bin/bash # Warp notification on Cline user prompt submit -[ -z "${WARP_CLI_AGENT_PROTOCOL_VERSION:-}" ] && exit 0 -[ -z "${WARP_CLIENT_VERSION:-}" ] && exit 0 - command -v jq &>/dev/null || exit 0 +source "$(dirname "${BASH_SOURCE[0]}")/warp-notify.sh" +should_use_structured || exit 0 -INPUT=$(cat 2>/dev/null || echo '{}') -SESSION_ID=$(echo "$INPUT" | jq -r '.conversationId // .session_id // "unknown"' 2>/dev/null) -CWD=$(echo "$INPUT" | jq -r '.cwd // empty' 2>/dev/null) -[ -z "$CWD" ] && CWD="$(pwd)" -PROJECT=$(basename "$CWD") - -QUERY=$(echo "$INPUT" | jq -r '.prompt // empty' 2>/dev/null) -[ -n "$QUERY" ] && [ ${#QUERY} -gt 200 ] && QUERY="${QUERY:0:197}..." +read_hook_input +QUERY=$(truncate_text "$(echo "$INPUT" | jq -r '.userPromptSubmit.prompt // empty' 2>/dev/null)") BODY=$(jq -nc \ --argjson v 1 \ @@ -25,4 +18,4 @@ BODY=$(jq -nc \ --arg query "$QUERY" \ '{v:$v, agent:$agent, event:$event, session_id:$session_id, cwd:$cwd, project:$project, query:$query}') -printf '\033]777;notify;%s;%s\007' "warp://cli-agent" "$BODY" > /dev/tty 2>/dev/null || true +warp_notify "$BODY" diff --git a/plugins/cline/hooks/warp-notify.sh b/plugins/cline/hooks/warp-notify.sh new file mode 100755 index 0000000..8b4c750 --- /dev/null +++ b/plugins/cline/hooks/warp-notify.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# Shared helpers for the Cline hook scripts. Sourced by each hook; Cline only +# runs files named after a hook event, so this file is never invoked directly. +# +# Cline pipes a JSON payload to each hook on stdin. The fields read here are +# common to every hook event: taskId, workspaceRoots and workspaceInfo. + +# Last known Warp releases per channel that advertised +# WARP_CLI_AGENT_PROTOCOL_VERSION but couldn't render structured +# notifications. Keep in sync with plugins/warp/scripts/should-use-structured.sh. +LAST_BROKEN_STABLE="v0.2026.03.25.08.24.stable_05" +LAST_BROKEN_PREVIEW="v0.2026.03.25.08.24.preview_05" + +should_use_structured() { + [ -z "${WARP_CLI_AGENT_PROTOCOL_VERSION:-}" ] && return 1 + [ -z "${WARP_CLIENT_VERSION:-}" ] && return 1 + + local threshold="" + case "$WARP_CLIENT_VERSION" in + *stable*) threshold="$LAST_BROKEN_STABLE" ;; + *preview*) threshold="$LAST_BROKEN_PREVIEW" ;; + esac + if [ -n "$threshold" ] && [[ ! "$WARP_CLIENT_VERSION" > "$threshold" ]]; then + return 1 + fi + return 0 +} + +# Reads the hook payload from stdin and sets INPUT, SESSION_ID, CWD and PROJECT. +read_hook_input() { + INPUT=$(cat 2>/dev/null) + [ -z "$INPUT" ] && INPUT='{}' + SESSION_ID=$(echo "$INPUT" | jq -r '.taskId // "unknown"' 2>/dev/null) + CWD=$(echo "$INPUT" | jq -r '.workspaceInfo.rootPath // .workspaceRoots[0] // empty' 2>/dev/null) + [ -z "$CWD" ] && CWD="$(pwd)" + PROJECT=$(basename "$CWD") +} + +# Truncates $1 to 200 characters for notification display. +truncate_text() { + local text="$1" + if [ ${#text} -gt 200 ]; then + text="${text:0:197}..." + fi + printf '%s' "$text" +} + +# Emits a structured Warp notification with the given JSON body. The group +# redirect keeps a missing controlling terminal from printing an error. +warp_notify() { + { printf '\033]777;notify;%s;%s\007' "warp://cli-agent" "$1" > /dev/tty; } 2>/dev/null || true +}