From 5fa5cbcc82a87b427544177f1439b2694dd21447 Mon Sep 17 00:00:00 2001 From: Niju Vijayakumar Date: Thu, 21 May 2026 12:06:07 +1000 Subject: [PATCH 1/3] fix: align cwd flag names --- src/cortex-cli/src/acp_cmd.rs | 10 +++++++++- src/cortex-cli/src/cli/args.rs | 21 ++++++++++++++++++++- src/cortex-cli/src/shell_cmd.rs | 13 ++++++++++++- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/cortex-cli/src/acp_cmd.rs b/src/cortex-cli/src/acp_cmd.rs index ff6a586c2..d91d6a577 100644 --- a/src/cortex-cli/src/acp_cmd.rs +++ b/src/cortex-cli/src/acp_cmd.rs @@ -14,7 +14,7 @@ use std::path::PathBuf; #[command(about = "Start an ACP (Agent Client Protocol) server for IDE integration")] pub struct AcpCli { /// Working directory for the session. - #[arg(long = "cwd", short = 'C', value_name = "DIR")] + #[arg(long = "cwd", alias = "cd", short = 'C', value_name = "DIR")] pub cwd: Option, /// Port to listen on (default: random available port). @@ -161,6 +161,14 @@ mod tests { assert_eq!(cli.cwd, Some(PathBuf::from("/home/user/project"))); } + #[test] + fn test_acp_cli_cwd_cd_alias() { + let cli = AcpCli::try_parse_from(["acp", "--cd", "/home/user/project"]) + .expect("should parse --cd alias"); + + assert_eq!(cli.cwd, Some(PathBuf::from("/home/user/project"))); + } + #[test] fn test_acp_cli_cwd_short_option() { let cli = AcpCli::try_parse_from(["acp", "-C", "/tmp/test"]).expect("should parse"); diff --git a/src/cortex-cli/src/cli/args.rs b/src/cortex-cli/src/cli/args.rs index 641d63a4a..6d04c692c 100644 --- a/src/cortex-cli/src/cli/args.rs +++ b/src/cortex-cli/src/cli/args.rs @@ -189,7 +189,8 @@ pub struct InteractiveArgs { /// Tell the agent to use the specified directory as its working root #[arg( - long = "cd", + long = "cwd", + alias = "cd", short = 'C', value_name = "DIR", help_heading = "Workspace" @@ -1106,11 +1107,29 @@ mod tests { #[test] fn test_cli_cwd_long() { + let cli = + Cli::try_parse_from(["cortex", "--cwd", "/tmp/project"]).expect("should parse --cwd"); + assert_eq!(cli.interactive.cwd, Some(PathBuf::from("/tmp/project"))); + } + + #[test] + fn test_cli_cwd_cd_alias() { let cli = Cli::try_parse_from(["cortex", "--cd", "/tmp/project"]).expect("should parse --cd"); assert_eq!(cli.interactive.cwd, Some(PathBuf::from("/tmp/project"))); } + #[test] + fn test_cli_cwd_help_uses_canonical_name() { + use clap::CommandFactory; + + let mut cmd = Cli::command(); + let help = cmd.render_long_help().to_string(); + + assert!(help.contains("--cwd ")); + assert!(!help.contains("--cd ")); + } + #[test] fn test_cli_add_dir() { let cli = Cli::try_parse_from(["cortex", "--add-dir", "/extra/dir"]) diff --git a/src/cortex-cli/src/shell_cmd.rs b/src/cortex-cli/src/shell_cmd.rs index 075dec0a8..ff5a3be62 100644 --- a/src/cortex-cli/src/shell_cmd.rs +++ b/src/cortex-cli/src/shell_cmd.rs @@ -20,7 +20,7 @@ pub struct ShellCli { pub model: Option, /// Working directory override - #[arg(long = "cwd", short = 'C')] + #[arg(long = "cwd", alias = "cd", short = 'C')] pub cwd: Option, /// Configuration profile from config.toml @@ -188,6 +188,17 @@ mod tests { ); } + #[test] + fn test_shell_cli_cwd_cd_alias() { + let cli = ShellCli::parse_from(["shell", "--cd", "/home/user/workspace"]); + + assert_eq!( + cli.cwd, + Some(PathBuf::from("/home/user/workspace")), + "CWD should be set via --cd alias" + ); + } + #[test] fn test_shell_cli_cwd_relative_path() { let cli = ShellCli::parse_from(["shell", "--cwd", "relative/path"]); From 7fef316ff2fe353641ea812beef807bce8547ae1 Mon Sep 17 00:00:00 2001 From: Niju Vijayakumar Date: Thu, 21 May 2026 12:06:20 +1000 Subject: [PATCH 2/3] test: fix cli test imports --- src/cortex-cli/src/agent_cmd/tests.rs | 5 ++--- src/cortex-cli/src/utils/notification.rs | 3 +++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cortex-cli/src/agent_cmd/tests.rs b/src/cortex-cli/src/agent_cmd/tests.rs index e2ff07f9f..18f7ba753 100644 --- a/src/cortex-cli/src/agent_cmd/tests.rs +++ b/src/cortex-cli/src/agent_cmd/tests.rs @@ -3,10 +3,9 @@ #[cfg(test)] mod tests { use crate::agent_cmd::cli::{CopyArgs, ExportArgs}; - use crate::agent_cmd::loader::{ - load_builtin_agents, parse_frontmatter, read_file_with_encoding, - }; + use crate::agent_cmd::loader::{load_builtin_agents, parse_frontmatter}; use crate::agent_cmd::types::AgentMode; + use crate::utils::file::read_file_with_encoding; #[test] fn test_read_file_with_utf8() { diff --git a/src/cortex-cli/src/utils/notification.rs b/src/cortex-cli/src/utils/notification.rs index 4656e2234..0c852a34e 100644 --- a/src/cortex-cli/src/utils/notification.rs +++ b/src/cortex-cli/src/utils/notification.rs @@ -31,6 +31,9 @@ pub enum NotificationUrgency { /// # Returns /// `Ok(())` on success (or silent failure if notifications unavailable). pub fn send_notification(title: &str, body: &str, urgency: NotificationUrgency) -> Result<()> { + #[cfg(not(target_os = "linux"))] + let _ = urgency; + #[cfg(target_os = "macos")] { send_notification_macos(title, body)?; From 6a0e44ae418123db2923394df2b7de98452ef010 Mon Sep 17 00:00:00 2001 From: Niju Vijayakumar Date: Thu, 21 May 2026 12:06:31 +1000 Subject: [PATCH 3/3] fix: gate editor fallback by platform --- src/cortex-tui/src/external_editor.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cortex-tui/src/external_editor.rs b/src/cortex-tui/src/external_editor.rs index 7aa545bc0..0c5220e70 100644 --- a/src/cortex-tui/src/external_editor.rs +++ b/src/cortex-tui/src/external_editor.rs @@ -131,7 +131,8 @@ pub fn get_editor() -> Result { } } - // Fallback + // Fallback for Linux and other Unix-like targets. + #[cfg(not(any(target_os = "windows", target_os = "macos")))] Ok("vi".to_string()) }