Add cmux support to agent-cli dev#589
Conversation
cmux (https://cmux.dev) is a Ghostty-based macOS terminal organized as workspaces with tabs, controlled via a Unix socket through its bundled CLI. agent-cli dev maps repos to cmux workspaces: each repo gets a workspace named after it (created on demand), and each worktree launch opens a new tab inside that workspace, named after the branch, running the agent in the worktree directory. - New Cmux terminal adapter (detect via CMUX_WORKSPACE_ID/CMUX_SURFACE_ID) - Auto-detected when running inside cmux; tmux/zellij still win as innermost - --multiplexer cmux supported on dev new and dev agent (socket-based, works from any terminal) - Success summary shows the cmux workspace; tmux attach hint no longer printed for non-tmux handles - Tests document the cmux CLI evidence (help text + live verification against cmux 0.64.14)
Greptile SummaryThis PR adds
Confidence Score: 5/5Safe to merge — the adapter is well-isolated, all three previously-raised blocking issues have been addressed, and the test suite passes with 1411 tests. All previously-raised issues (silent No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant LC as launch_agent()
participant LT as _launch_in_terminal()
participant LC2 as _launch_in_cmux()
participant CX as Cmux adapter
participant CLI as cmux CLI
LC->>LT: "terminal.name == "cmux""
LT->>LC2: path, agent, terminal, full_cmd, tab_name, repo_root
LC2->>CX: "open_in_workspace(path, cmd, tab_name, workspace_name=repo_root.name)"
CX->>CLI: workspace list --json
CLI-->>CX: "{"workspaces": [...]}"
alt workspace already exists
CX->>CLI: new-surface --workspace workspace:N
CLI-->>CX: OK surface:M pane:P workspace:N
CX->>CLI: rename-tab --workspace workspace:N --surface surface:M --title tab_name
CX->>CLI: "send --workspace workspace:N --surface surface:M -- "cd /path && cmd\n""
alt send succeeds
CLI-->>CX: OK surface:M workspace:N
CX-->>LC2: "TerminalHandle(handle=surface:M, session_name=workspace_name)"
else send fails
CLI-->>CX: CalledProcessError
CX->>CLI: close-surface --workspace workspace:N --surface surface:M
CX-->>LC2: None
end
else workspace not found
CX->>CLI: workspace create --name repo --cwd /path --command cmd
CLI-->>CX: OK workspace:N
CX->>CLI: workspace-action --action set-color --workspace workspace:N --color Color
CX->>CLI: rename-tab --workspace workspace:N --title tab_name
CX-->>LC2: "TerminalHandle(handle=workspace:N, session_name=workspace_name)"
end
LC2-->>LT: TerminalHandle or None
LT-->>LC: (success, handle)
Reviews (4): Last reviewed commit: "Fix cmux tests on Windows by computing e..." | Re-trigger Greptile |
cmux is a terminal, not a multiplexer: it is used when auto-detected (via CMUX_WORKSPACE_ID/CMUX_SURFACE_ID), like other GUI terminals.
Review fixes: - A failed `send` now closes the idle tab and reports failure instead of returning a handle for a tab where the agent never started - A failed `workspace list` aborts immediately instead of falling through to a doomed (or duplicating) `workspace create` - open_new_tab resolves the main repo root so the generic Terminal interface keeps the one-workspace-per-repo invariant for worktrees New: workspaces get a deterministic color on creation (sha256 of the workspace name mapped onto cmux's 16 named colors), so each repo always gets the same color. Existing workspaces are left untouched.
Path('/some/path') stringifies with backslashes on Windows, so the
hardcoded POSIX argv strings did not match.
Summary
Adds cmux (Ghostty-based macOS terminal for AI coding agents, controlled via a Unix socket through its bundled CLI) as a supported terminal for
agent-cli dev.The repo↔cmux mapping: one workspace per repository name, one tab per worktree.
cmux workspace create --name <repo> --cwd <worktree> --command <agent-cmd>creates the workspace with the agent running in its first tab.cmux new-surface --workspace <ref>opens a tab in the existing workspace (matched by title viacmux workspace list --json),rename-tabnames it after the branch, andcmux sendtypescd <worktree> && <agent-cmd>plus Enter. New surfaces don't accept cwd/command flags, so typing into the shell is the supported route; the terminal buffers the input until the shell is ready (verified live).Changes
Cmuxterminal adapter (agent_cli/dev/terminals/cmux.py), detected via theCMUX_WORKSPACE_ID/CMUX_SURFACE_IDenv vars that cmux auto-sets in its terminals--multiplexerinvolvementcmux Workspace: <repo>; the tmuxAttach:hint is no longer printed for non-tmux handlesTesting
pytest: 1411 passed, 4 skippedpre-commit run --all-files: passes (jscpd fails locally on a clean tree due to a missing platform binary, unrelated)dev newin a scratch repo created the repo-named workspace with a branch-named tab running Claude in the worktree; seconddev newreused the workspace and added a second tab whose agent started in the second worktree's directory