diff --git a/packages/tui-rs/src/cli_commands.rs b/packages/tui-rs/src/cli_commands.rs index ebb5de93f..46842adf4 100644 --- a/packages/tui-rs/src/cli_commands.rs +++ b/packages/tui-rs/src/cli_commands.rs @@ -13,6 +13,8 @@ use anyhow::{bail, Context, Result}; use crate::session::{ExportFormat, ExportOptions, SessionManager}; use crate::session_transfer::{export_portable_session, import_portable_session, PortableFormat}; +const ANTHROPIC_OAUTH_REMOVED_MESSAGE: &str = "Anthropic OAuth login has been removed. Set ANTHROPIC_API_KEY to use Anthropic models, or run `maestro codex login` for the default Codex flow."; + /// Dispatch a top-level CLI helper subcommand. /// /// `args` is the token stream after the program name, e.g. @@ -50,6 +52,10 @@ pub async fn run_cli_command(args: &[String]) -> Result { "update" => crate::update_cli::run_update(&args[1..]).await, "modes" => crate::mode_cli::run_modes(&args[1..]).await, "painter" => crate::painter_cli::run_painter(&args[1..]), + "anthropic" => { + eprintln!("{ANTHROPIC_OAUTH_REMOVED_MESSAGE}"); + Ok(1) + } other => bail!("unknown command: {other}"), } } @@ -779,4 +785,16 @@ mod tests { 1 ); } + + #[tokio::test] + async fn anthropic_command_reports_removed_oauth_flow() { + assert!(ANTHROPIC_OAUTH_REMOVED_MESSAGE.contains("ANTHROPIC_API_KEY")); + assert!(ANTHROPIC_OAUTH_REMOVED_MESSAGE.contains("maestro codex login")); + assert_eq!( + run_cli_command(&argv(&["anthropic", "status"])) + .await + .expect("anthropic command"), + 1 + ); + } } diff --git a/packages/tui-rs/src/main.rs b/packages/tui-rs/src/main.rs index 40523ae9c..86934425c 100644 --- a/packages/tui-rs/src/main.rs +++ b/packages/tui-rs/src/main.rs @@ -46,9 +46,21 @@ use maestro_tui::hosted_runner_cli::run_hosted_runner_cli_from_env; // HELPER FUNCTIONS // ───────────────────────────────────────────────────────────────────────────── -const NATIVE_UTILITY_COMMANDS: [&str; 13] = [ - "sessions", "cost", "stats", "models", "status", "hooks", "export", "import", "update", - "skill", "modes", "agents", "painter", +const NATIVE_UTILITY_COMMANDS: [&str; 14] = [ + "sessions", + "cost", + "stats", + "models", + "status", + "hooks", + "export", + "import", + "update", + "skill", + "modes", + "agents", + "painter", + "anthropic", ]; const GLOBAL_FLAGS_WITH_VALUES: [&str; 26] = [ diff --git a/src/cli/commands/anthropic.ts b/src/cli/commands/anthropic.ts deleted file mode 100644 index c761a031f..000000000 --- a/src/cli/commands/anthropic.ts +++ /dev/null @@ -1,10 +0,0 @@ -import chalk from "chalk"; - -export async function handleAnthropicCommand(): Promise { - console.error( - chalk.red( - "Anthropic OAuth login has been removed. Set ANTHROPIC_API_KEY to use Anthropic models, or run `maestro codex login` for the default Codex flow.", - ), - ); - process.exit(1); -} diff --git a/src/cli/direct-runtime-command.ts b/src/cli/direct-runtime-command.ts index 60ec07669..997b45650 100644 --- a/src/cli/direct-runtime-command.ts +++ b/src/cli/direct-runtime-command.ts @@ -2,6 +2,7 @@ import { isStartupTelemetryRequested } from "./instant-exit.js"; const NATIVE_UTILITY_COMMANDS = new Set([ "agents", + "anthropic", "cost", "export", "hooks", diff --git a/src/main.ts b/src/main.ts index 19041246a..277234e9d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1091,14 +1091,6 @@ export async function main(args: string[]) { return; } - if (parsed.command === "anthropic") { - const { handleAnthropicCommand } = await import( - "./cli/commands/anthropic.js" - ); - await handleAnthropicCommand(); - return; - } - if (parsed.command === "cost") { console.error(chalk.red(`Unknown cost subcommand: ${parsed.subcommand}`)); console.log(chalk.dim("\nAvailable commands:")); diff --git a/test/cli-runtime.test.ts b/test/cli-runtime.test.ts index 59366c843..5e8100e3a 100644 --- a/test/cli-runtime.test.ts +++ b/test/cli-runtime.test.ts @@ -123,6 +123,10 @@ describe("cli-runtime direct command dispatch", () => { ); const cases: Array<[string[], string[]]> = [ + [ + ["anthropic", "status"], + ["anthropic", "status"], + ], [ ["painter", "show", "image.png"], ["painter", "show", "image.png"], diff --git a/test/cli/anthropic-command.test.ts b/test/cli/anthropic-command.test.ts deleted file mode 100644 index 4fc6d3a29..000000000 --- a/test/cli/anthropic-command.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { describe, expect, it, vi } from "vitest"; -import { handleAnthropicCommand } from "../../src/cli/commands/anthropic.js"; - -describe("anthropic CLI command", () => { - it("reports that Anthropic OAuth login has been removed", async () => { - const error = vi.spyOn(console, "error").mockImplementation(() => {}); - const exit = vi.spyOn(process, "exit").mockImplementation(() => { - throw new Error("process.exit called"); - }); - - await expect(handleAnthropicCommand("status")).rejects.toThrow( - "process.exit called", - ); - - expect(exit).toHaveBeenCalledWith(1); - expect(error).toHaveBeenCalledWith( - expect.stringContaining("Anthropic OAuth login has been removed"), - ); - - error.mockRestore(); - exit.mockRestore(); - }); -});