Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 3 additions & 25 deletions cmux-tui/crates/cmux-tui/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ mod fix_command;
mod frontend_browser;
#[cfg(unix)]
mod host_mount;
mod internal;
mod launch_credential;
mod lifecycle;
// Like the other scopes its dispatch is in (`run`, `#[cfg(unix)]`): Unix only.
Expand Down Expand Up @@ -747,34 +748,11 @@ fn parse_command(
}

fn unknown_scope(scope: &str, surface: Surface) -> UsageError {
let suggestion = classic_command(scope).or_else(|| suggestion(scope, surface.scopes()));
let suggestion = internal::classic_verbs::resource_command(scope)
.or_else(|| suggestion(scope, surface.scopes()));
UsageError::new(crate::localization::catalog().local_server.unknown_scope(scope, suggestion))
}

/// The resource command for a classic cmux verb that agents still run from older
/// skills (tests/tool-evals r3h: GPT 6 Astra tried `rename-workspace`,
/// `workspace-action --action rename` and `list-workspaces` before the MCP tools).
fn classic_command(scope: &str) -> Option<&'static str> {
Some(match scope {
"list-workspaces" => "cmux workspace list",
"new-workspace" => "cmux workspace create --name <name>",
"rename-workspace" => "cmux workspace current rename <name>",
"workspace-action" => {
"cmux workspace current rename <name>` or `cmux workspace current update"
}
"select-workspace" => "cmux workspace <workspace> focus",
"close-workspace" => "cmux workspace <workspace> close",
"list-surfaces" | "list-pane-surfaces" => "cmux tab list",
"new-surface" => "cmux tab create terminal",
"new-pane" | "new-split" => "cmux pane current split --right",
"rename-tab" | "rename-surface" | "tab-action" => "cmux tab <tab> rename <name>",
"close-surface" => "cmux tab <tab> close",
"send" | "send-text" => "cmux terminal <terminal> write --text <text>",
"read-screen" | "capture-pane" => "cmux terminal <terminal> screen read",
_ => return None,
})
}

/// A `cmux-tui` scope named through `cmux`, which refuses it by name
/// instead of calling it unknown.
fn not_in_cmux(scope: &str) -> UsageError {
Expand Down
7 changes: 7 additions & 0 deletions cmux-tui/crates/cmux-tui/src/cli/internal.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//! Words the public CLI recognizes only to send people away from them.
//!
//! Code here matches legacy input and never prints it as cmux vocabulary, so
//! it sits under `internal/`, outside the resource-v2 public boundary scan
//! (`cmux-tui/scripts/check-resource-api-boundary.py`).

pub(super) mod classic_verbs;
25 changes: 25 additions & 0 deletions cmux-tui/crates/cmux-tui/src/cli/internal/classic_verbs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//! Classic cmux verbs and the resource commands that replace them.

/// The resource command for a classic cmux verb that agents still run from older
/// skills (tests/tool-evals r3h: GPT 6 Astra tried `rename-workspace`,
/// `workspace-action --action rename` and `list-workspaces` before the MCP tools).
pub(in crate::cli) fn resource_command(scope: &str) -> Option<&'static str> {
Some(match scope {
"list-workspaces" => "cmux workspace list",
"new-workspace" => "cmux workspace create --name <name>",
"rename-workspace" => "cmux workspace current rename <name>",
"workspace-action" => {
"cmux workspace current rename <name>` or `cmux workspace current update"
}
"select-workspace" => "cmux workspace <workspace> focus",
"close-workspace" => "cmux workspace <workspace> close",
"list-surfaces" | "list-pane-surfaces" => "cmux tab list",
"new-surface" => "cmux tab create terminal",
"new-pane" | "new-split" => "cmux pane current split --right",
"rename-tab" | "rename-surface" | "tab-action" => "cmux tab <tab> rename <name>",
"close-surface" => "cmux tab <tab> close",
"send" | "send-text" => "cmux terminal <terminal> write --text <text>",
"read-screen" | "capture-pane" => "cmux terminal <terminal> screen read",
_ => return None,
})
}
5 changes: 5 additions & 0 deletions cmux-tui/crates/cmux-tui/tests/cmux_surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ fn a_classic_verb_names_its_resource_command() {
),
(&["list-workspaces"][..], "cmux workspace list"),
(&["send", "ls"][..], "cmux terminal <terminal> write --text <text>"),
(&["list-surfaces"][..], "cmux tab list"),
(&["list-pane-surfaces"][..], "cmux tab list"),
(&["new-surface"][..], "cmux tab create terminal"),
(&["rename-surface", "x"][..], "cmux tab <tab> rename <name>"),
(&["close-surface"][..], "cmux tab <tab> close"),
] {
let output = names.run("cmux", args);
let stderr = text(&output.stderr);
Expand Down
Loading