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
41 changes: 41 additions & 0 deletions plugins/amp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# 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 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
```

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
amp plugins list
```

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)

## 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.
80 changes: 80 additions & 0 deletions plugins/amp/warp-notify.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { writeFileSync } from 'node:fs'
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<string, unknown>): void {
if (!shouldUseStructured()) return
const body = JSON.stringify(payload)
try {
writeFileSync('/dev/tty', `\x1b]777;notify;warp://cli-agent;${body}\x07`)
} catch {}
}

function buildPayload(event: string, extra: Record<string, unknown> = {}): Record<string, unknown> {
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,
}))
})
}
42 changes: 42 additions & 0 deletions plugins/cline/README.md
Original file line number Diff line number Diff line change
@@ -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 ~/.cline/hooks
cp plugins/cline/hooks/*.sh ~/.cline/hooks/
chmod +x ~/.cline/hooks/*.sh
```

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

| 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:
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`

The payloads use the same `warp://cli-agent` protocol as the Claude Code plugin.
21 changes: 21 additions & 0 deletions plugins/cline/hooks/PostToolUse.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
# Warp notification on Cline post-tool-use

command -v jq &>/dev/null || exit 0
source "$(dirname "${BASH_SOURCE[0]}")/warp-notify.sh"
should_use_structured || exit 0

read_hook_input
TOOL_NAME=$(echo "$INPUT" | jq -r '.postToolUse.toolName // .tool_result.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}')

warp_notify "$BODY"
27 changes: 27 additions & 0 deletions plugins/cline/hooks/PreToolUse.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
# Warp notification on Cline pre-tool-use (permission request)

command -v jq &>/dev/null || exit 0
source "$(dirname "${BASH_SOURCE[0]}")/warp-notify.sh"
should_use_structured || exit 0

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"

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}')

warp_notify "$BODY"
22 changes: 22 additions & 0 deletions plugins/cline/hooks/TaskComplete.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
# Warp notification on Cline task complete

command -v jq &>/dev/null || exit 0
source "$(dirname "${BASH_SOURCE[0]}")/warp-notify.sh"
should_use_structured || exit 0

read_hook_input
RESPONSE=$(truncate_text "$(echo "$INPUT" | jq -r '.turn.outputText // empty' 2>/dev/null)")

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 "" \
--arg response "$RESPONSE" \
'{v:$v, agent:$agent, event:$event, session_id:$session_id, cwd:$cwd, project:$project, query:$query, response:$response}')

warp_notify "$BODY"
23 changes: 23 additions & 0 deletions plugins/cline/hooks/TaskError.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
# Warp notification on Cline task error

command -v jq &>/dev/null || exit 0
source "$(dirname "${BASH_SOURCE[0]}")/warp-notify.sh"
should_use_structured || exit 0

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 \
--arg agent "cline" \
--arg event "stop" \
--arg session_id "$SESSION_ID" \
--arg cwd "$CWD" \
--arg project "$PROJECT" \
--arg summary "$SUMMARY" \
'{v:$v, agent:$agent, event:$event, session_id:$session_id, cwd:$cwd, project:$project, summary:$summary}')

warp_notify "$BODY"
19 changes: 19 additions & 0 deletions plugins/cline/hooks/TaskStart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
# Warp notification on Cline task start

command -v jq &>/dev/null || exit 0
source "$(dirname "${BASH_SOURCE[0]}")/warp-notify.sh"
should_use_structured || exit 0

read_hook_input

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}')

warp_notify "$BODY"
21 changes: 21 additions & 0 deletions plugins/cline/hooks/UserPromptSubmit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
# Warp notification on Cline user prompt submit

command -v jq &>/dev/null || exit 0
source "$(dirname "${BASH_SOURCE[0]}")/warp-notify.sh"
should_use_structured || exit 0

read_hook_input
QUERY=$(truncate_text "$(echo "$INPUT" | jq -r '.userPromptSubmit.prompt // empty' 2>/dev/null)")

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}')

warp_notify "$BODY"
52 changes: 52 additions & 0 deletions plugins/cline/hooks/warp-notify.sh
Original file line number Diff line number Diff line change
@@ -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
}