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/tmux.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'docs/tmux.md') diff --git a/docs/tmux.md b/docs/tmux.md index ae84ce2..1ece4c7 100644 --- a/docs/tmux.md +++ b/docs/tmux.md @@ -91,6 +91,12 @@ Then press `prefix + e` in any pane running an AI agent. Hexai auto-detects the See the [configuration guide](configuration.md) for customizing popup dimensions and agent patterns, or the [usage guide](usage.md) for the full workflow description. -**Vim mode recommended**: For best results, run both Cursor Agent and Claude Code in vim mode. Claude Code's `C-u` clear relies on readline/vim insert-mode behavior, and Cursor's prompt clearing works most reliably in its default input mode. The popup editor uses `$EDITOR` (or `$HEXAI_EDITOR`), so your normal vim/neovim setup is used for composing prompts. +**Input mode notes**: Each agent uses different clearing methods based on their input handling: +- **Claude Code**: Uses Vi/Vim keybindings (`Escape gg C-v G d i`), so vim mode is recommended +- **Cursor**: Uses simple backspace clearing (`End BSpace*200`), works in default mode +- **Amp**: Uses Emacs/readline keybindings (`C-u`), works in TUI mode +- **Aider**: Uses Emacs/readline keybindings (`C-u`) + +The popup editor uses `$EDITOR` (or `$HEXAI_EDITOR`), so your normal vim/neovim setup is used for composing prompts. **Note**: Agent detection and prompt extraction rely on regex patterns matched against each agent's terminal UI (box-drawing characters, prompt symbols, status text). When agents update their TUI layout, these patterns may need adjustment. You can override patterns per-agent in `[[tmux_edit.agents]]` config without code changes -- see the [configuration guide](configuration.md). -- cgit v1.2.3