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 --- internal/tmuxedit/config_agent.go | 2 +- internal/tmuxedit/config_agent_test.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'internal') diff --git a/internal/tmuxedit/config_agent.go b/internal/tmuxedit/config_agent.go index 2773025..e5268fa 100644 --- a/internal/tmuxedit/config_agent.go +++ b/internal/tmuxedit/config_agent.go @@ -23,7 +23,7 @@ func builtinAgents() []Agent { name: "amp", displayName: "Amp", detectPattern: `(?i)(amp|sourcegraph)`, - promptPat: `(?m)>\s*(.+)$`, + promptPat: `(?m)│\s*(.+?)\s*│\s*$`, clearFirst: true, clearKeys: "C-u", newlineKeys: "S-Enter", diff --git a/internal/tmuxedit/config_agent_test.go b/internal/tmuxedit/config_agent_test.go index 7c49c42..d7ad649 100644 --- a/internal/tmuxedit/config_agent_test.go +++ b/internal/tmuxedit/config_agent_test.go @@ -154,7 +154,8 @@ func TestConfigAgent_Amp(t *testing.T) { if !amp.Detect("Amp by Sourcegraph") { t.Error("amp should detect 'Amp by Sourcegraph'") } - got := amp.ExtractPrompt("> fix the bug") + // Amp uses box-drawing TUI format (like cursor), not shell-style > prompt + got := amp.ExtractPrompt("│ fix the bug │") if got != "fix the bug" { t.Errorf("ExtractPrompt() = %q, want %q", got, "fix the bug") } -- cgit v1.2.3