summaryrefslogtreecommitdiff
path: root/internal/tmuxedit/config_agent.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-07-02 09:38:04 +0300
committerPaul Buetow <paul@buetow.org>2026-07-02 09:38:04 +0300
commita68228bfa12f4d8a51fe53e244fcd2e66c1ef692 (patch)
tree94e257b21b93419fef655c9813f68190204c3d0d /internal/tmuxedit/config_agent.go
parent9f0e96ce62339ddefa8771891e0864ede9af5064 (diff)
Remove hexai-tmux-edit popup editor featurev0.42.0
The tmux popup editor and its per-agent detection (Cursor/Amp/Aider) added maintenance surface without enough use to justify it; Codex and Claude Code already support external-editor mode natively via Ctrl+G. Drops internal/tmuxedit, cmd/hexai-tmux-edit, the [tmux_edit] config schema, the Mage build target, and all related docs/README mentions. Bump version to 0.42.0. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Diffstat (limited to 'internal/tmuxedit/config_agent.go')
-rw-r--r--internal/tmuxedit/config_agent.go135
1 files changed, 0 insertions, 135 deletions
diff --git a/internal/tmuxedit/config_agent.go b/internal/tmuxedit/config_agent.go
deleted file mode 100644
index 0c52c3d..0000000
--- a/internal/tmuxedit/config_agent.go
+++ /dev/null
@@ -1,135 +0,0 @@
-package tmuxedit
-
-import (
- "strings"
-
- "codeberg.org/snonux/hexai/internal/appconfig"
-)
-
-// configAgent uses baseAgent defaults for all operations. It serves
-// user-defined agents from TOML config and simple built-ins (amp, aider)
-// that don't need specialized extraction or clearing logic.
-type configAgent struct{ baseAgent }
-
-// builtinAgents returns the default set of agent implementations. Order
-// matters: agents with distinctive UI elements (box-drawing, etc.) are
-// checked first to avoid false positives from model names like "Claude
-// 4.5 Sonnet" appearing in other agents' panes.
-// Claude Code is not included here: it now supports opening the prompt
-// in an external editor natively via Ctrl+G (like OpenAI Codex CLI).
-func builtinAgents() []Agent {
- return []Agent{
- newCursorAgent(),
- &configAgent{baseAgent{
- name: "amp",
- displayName: "Amp",
- detectPattern: `(?i)(amp|sourcegraph)`,
- promptPat: `(?m)│\s*(.+?)\s*│\s*$`,
- clearFirst: true,
- clearKeys: "C-u",
- newlineKeys: "S-Enter",
- submitKeys: "Enter",
- }},
- &configAgent{baseAgent{
- name: "aider",
- displayName: "Aider",
- detectPattern: `(?i)aider`,
- promptPat: `(?m)>\s*(.+)$`,
- clearFirst: true,
- clearKeys: "C-u",
- newlineKeys: "",
- submitKeys: "Enter",
- }},
- }
-}
-
-// genericAgent returns a fallback agent with no detection or prompt extraction.
-// The user gets a blank editor and text is sent verbatim.
-func genericAgent() Agent {
- return &configAgent{baseAgent{
- name: "generic",
- displayName: "Generic",
- newlineKeys: "",
- submitKeys: "Enter",
- }}
-}
-
-// resolveAgents merges built-in agent defaults with user-provided overrides
-// from config. Agents are matched by name (case-insensitive); user config
-// wins field-by-field over builtins. The Configurable interface provides
-// access to baseAgent fields for merging.
-func resolveAgents(cfgAgents []appconfig.TmuxEditAgentCfg) []Agent {
- agents := builtinAgents()
- for _, ca := range cfgAgents {
- merged := false
- for i, a := range agents {
- if !strings.EqualFold(a.Name(), ca.Name) {
- continue
- }
- if c, ok := a.(Configurable); ok {
- mergeAgentConfig(c.Base(), ca)
- }
- merged = true
- _ = i // index not needed; we modify through the pointer
- break
- }
- if !merged {
- agents = append(agents, agentFromConfig(ca))
- }
- }
- return agents
-}
-
-// mergeAgentConfig overrides fields in base with non-zero values from cfg.
-// It modifies the baseAgent in place via pointer.
-func mergeAgentConfig(base *baseAgent, cfg appconfig.TmuxEditAgentCfg) {
- if s := strings.TrimSpace(cfg.DisplayName); s != "" {
- base.displayName = s
- }
- if s := strings.TrimSpace(cfg.DetectPattern); s != "" {
- base.detectPattern = s
- }
- if s := strings.TrimSpace(cfg.SectionPattern); s != "" {
- base.sectionPat = s
- }
- if s := strings.TrimSpace(cfg.PromptPattern); s != "" {
- base.promptPat = s
- }
- if len(cfg.StripPatterns) > 0 {
- base.stripPatterns = cfg.StripPatterns
- }
- if cfg.ClearFirst != nil {
- base.clearFirst = *cfg.ClearFirst
- }
- if s := strings.TrimSpace(cfg.ClearKeys); s != "" {
- base.clearKeys = s
- }
- if s := strings.TrimSpace(cfg.NewlineKeys); s != "" {
- base.newlineKeys = s
- }
- if s := strings.TrimSpace(cfg.SubmitKeys); s != "" {
- base.submitKeys = s
- }
-}
-
-// agentFromConfig creates a new configAgent from a user config entry.
-func agentFromConfig(cfg appconfig.TmuxEditAgentCfg) Agent {
- b := baseAgent{
- name: strings.TrimSpace(cfg.Name),
- displayName: strings.TrimSpace(cfg.DisplayName),
- detectPattern: strings.TrimSpace(cfg.DetectPattern),
- sectionPat: strings.TrimSpace(cfg.SectionPattern),
- promptPat: strings.TrimSpace(cfg.PromptPattern),
- stripPatterns: cfg.StripPatterns,
- clearKeys: strings.TrimSpace(cfg.ClearKeys),
- newlineKeys: strings.TrimSpace(cfg.NewlineKeys),
- submitKeys: strings.TrimSpace(cfg.SubmitKeys),
- }
- if cfg.ClearFirst != nil {
- b.clearFirst = *cfg.ClearFirst
- }
- if b.displayName == "" {
- b.displayName = b.name
- }
- return &configAgent{b}
-}