From 944838bb0f753a0920ddb2f506758c410ed7ca43 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 8 Feb 2026 17:33:04 +0200 Subject: Fix amp agent prompt extraction to use TUI box pattern MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Amp CLI runs in TUI mode with box-drawing UI (│ text │) similar to Cursor, not shell-style (> prompt). Updated prompt pattern from `(?m)>\s*(.+)$` to `(?m)│\s*(.+?)\s*│\s*$` to correctly extract text from amp's box UI. Changes: - internal/tmuxedit/config_agent.go: Update amp promptPat to box pattern - internal/tmuxedit/config_agent_test.go: Update test to use box format - docs/usage.md: Document detection order and clear methods for all agents - docs/tmux.md: Clarify input mode handling (Vim vs Emacs/readline) - config.toml.example: Add detailed agent descriptions and patterns - prompts/tmux-edit-integration-tests.md: Add test status, mock editor best practices Integration tests verified: - Amp detection: amp/sourcegraph keywords - Prompt extraction: "hello world test" correctly captured - End-to-end workflow: text modification and sending works - Multi-line support: all lines delivered correctly - All unit tests pass (67/67) - Coverage: 80.9% (meets requirement) - Cursor and Claude implementations unchanged Co-authored-by: Cursor --- docs/usage.md | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'docs/usage.md') diff --git a/docs/usage.md b/docs/usage.md index 9a6d9ed..8c2d0a6 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -159,11 +159,22 @@ This is useful when working with AI CLI agents (Claude Code, Cursor, Amp, Aider, ### Supported agents -Built-in agent detection (auto-detected from pane content): -- **Claude Code** -- detects "claude" or "anthropic" in pane -- **Cursor** -- detects "cursor" in pane, strips "INSERT"/"Add a follow-up" -- **Amp** -- detects "amp" or "sourcegraph" in pane -- **Aider** -- detects "aider" in pane +Built-in agent detection (auto-detected from pane content, checked in order): + +1. **Cursor** -- detects box-drawing UI `│ →` or footer `/ commands · @ files` + - Clears with: `End BSpace*200` (backspace method) + - Prompt pattern: Extracts from last `│...│` box +2. **Claude Code** -- detects `❯` prompt symbol, "claude code", or "anthropic" + - Clears with: `Escape gg C-v G d i` (Vi/Vim style) + - Prompt pattern: Extracts from last section between `─────` rules +3. **Amp** -- detects "amp" or "sourcegraph" in pane (TUI mode) + - Clears with: `C-u` (Emacs/readline style) + - Prompt pattern: Extracts from `│...│` box UI (similar to Cursor) +4. **Aider** -- detects "aider" in pane + - Clears with: `C-u` (Emacs/readline style) + - Prompt pattern: Shell-style `> prompt` + +**Detection order matters**: Cursor and Claude are checked first to avoid false positives. For example, Cursor may display "Claude 4.5 Sonnet" as its model name, but Cursor's distinctive `│ →` box UI is matched first. Additional agents can be added via `[tmux_edit.agents]` in config.toml without code changes. -- cgit v1.2.3