From d44f4205fb93ca1f602a21f110d795bd499a1e07 Mon Sep 17 00:00:00 2001 From: Michael Bolin Date: Tue, 10 Feb 2026 17:03:46 -0800 Subject: [PATCH] chore: rename codex-command to codex-shell-command (#11378) This addresses some post-merge feedback on https://github.com/openai/codex/pull/11361: - crate rename - reuse `detect_shell_type()` utility --- codex-rs/Cargo.lock | 42 +++++++++---------- codex-rs/Cargo.toml | 4 +- codex-rs/core/Cargo.toml | 2 +- codex-rs/core/src/lib.rs | 11 ++--- codex-rs/core/src/shell.rs | 22 +--------- codex-rs/core/src/shell_detect.rs | 24 +++++++++++ .../{command => shell-command}/BUILD.bazel | 4 +- .../{command => shell-command}/Cargo.toml | 2 +- .../{command => shell-command}/src/bash.rs | 0 .../command_safety/is_dangerous_command.rs | 0 .../src/command_safety/is_safe_command.rs | 0 .../src/command_safety/mod.rs | 0 .../src/command_safety/powershell_parser.ps1 | 0 .../windows_dangerous_commands.rs | 0 .../command_safety/windows_safe_commands.rs | 0 .../{command => shell-command}/src/lib.rs | 0 .../src/parse_command.rs | 0 .../src/powershell.rs | 0 .../src/shell_detect.rs | 0 19 files changed, 58 insertions(+), 53 deletions(-) create mode 100644 codex-rs/core/src/shell_detect.rs rename codex-rs/{command => shell-command}/BUILD.bazel (64%) rename codex-rs/{command => shell-command}/Cargo.toml (95%) rename codex-rs/{command => shell-command}/src/bash.rs (100%) rename codex-rs/{command => shell-command}/src/command_safety/is_dangerous_command.rs (100%) rename codex-rs/{command => shell-command}/src/command_safety/is_safe_command.rs (100%) rename codex-rs/{command => shell-command}/src/command_safety/mod.rs (100%) rename codex-rs/{command => shell-command}/src/command_safety/powershell_parser.ps1 (100%) rename codex-rs/{command => shell-command}/src/command_safety/windows_dangerous_commands.rs (100%) rename codex-rs/{command => shell-command}/src/command_safety/windows_safe_commands.rs (100%) rename codex-rs/{command => shell-command}/src/lib.rs (100%) rename codex-rs/{command => shell-command}/src/parse_command.rs (100%) rename codex-rs/{command => shell-command}/src/powershell.rs (100%) rename codex-rs/{command => shell-command}/src/shell_detect.rs (100%) diff --git a/codex-rs/Cargo.lock b/codex-rs/Cargo.lock index a6a5e7710..2c6a8904d 100644 --- a/codex-rs/Cargo.lock +++ b/codex-rs/Cargo.lock @@ -1623,26 +1623,6 @@ dependencies = [ "thiserror 2.0.18", ] -[[package]] -name = "codex-command" -version = "0.0.0" -dependencies = [ - "anyhow", - "base64 0.22.1", - "codex-protocol", - "codex-utils-absolute-path", - "once_cell", - "pretty_assertions", - "regex", - "serde", - "serde_json", - "shlex", - "tree-sitter", - "tree-sitter-bash", - "url", - "which", -] - [[package]] name = "codex-common" version = "0.0.0" @@ -1680,7 +1660,6 @@ dependencies = [ "codex-arg0", "codex-async-utils", "codex-client", - "codex-command", "codex-core", "codex-execpolicy", "codex-file-search", @@ -1691,6 +1670,7 @@ dependencies = [ "codex-otel", "codex-protocol", "codex-rmcp-client", + "codex-shell-command", "codex-state", "codex-utils-absolute-path", "codex-utils-cargo-bin", @@ -2209,6 +2189,26 @@ dependencies = [ "tracing", ] +[[package]] +name = "codex-shell-command" +version = "0.0.0" +dependencies = [ + "anyhow", + "base64 0.22.1", + "codex-protocol", + "codex-utils-absolute-path", + "once_cell", + "pretty_assertions", + "regex", + "serde", + "serde_json", + "shlex", + "tree-sitter", + "tree-sitter-bash", + "url", + "which", +] + [[package]] name = "codex-state" version = "0.0.0" diff --git a/codex-rs/Cargo.toml b/codex-rs/Cargo.toml index 101023f4a..e7b30353f 100644 --- a/codex-rs/Cargo.toml +++ b/codex-rs/Cargo.toml @@ -16,7 +16,7 @@ members = [ "cloud-tasks-client", "cli", "common", - "command", + "shell-command", "core", "hooks", "secrets", @@ -83,7 +83,7 @@ codex-chatgpt = { path = "chatgpt" } codex-cli = { path = "cli"} codex-client = { path = "codex-client" } codex-common = { path = "common" } -codex-command = { path = "command" } +codex-shell-command = { path = "shell-command" } codex-core = { path = "core" } codex-hooks = { path = "hooks" } codex-secrets = { path = "secrets" } diff --git a/codex-rs/core/Cargo.toml b/codex-rs/core/Cargo.toml index 2a86148c4..e84f61725 100644 --- a/codex-rs/core/Cargo.toml +++ b/codex-rs/core/Cargo.toml @@ -33,7 +33,7 @@ codex-app-server-protocol = { workspace = true } codex-apply-patch = { workspace = true } codex-async-utils = { workspace = true } codex-client = { workspace = true } -codex-command = { workspace = true } +codex-shell-command = { workspace = true } codex-execpolicy = { workspace = true } codex-file-search = { workspace = true } codex-git = { workspace = true } diff --git a/codex-rs/core/src/lib.rs b/codex-rs/core/src/lib.rs index 8ee229c02..4479e24c3 100644 --- a/codex-rs/core/src/lib.rs +++ b/codex-rs/core/src/lib.rs @@ -56,6 +56,7 @@ mod proposed_plan_parser; mod sandbox_tags; pub mod sandboxing; mod session_prefix; +mod shell_detect; mod stream_events_utils; mod tagged_block_parser; mod text_encoding; @@ -129,11 +130,11 @@ mod state; mod tasks; mod user_shell_command; pub mod util; -pub use codex_command::bash; -pub use codex_command::is_dangerous_command; -pub use codex_command::is_safe_command; -pub use codex_command::parse_command; -pub use codex_command::powershell; +pub use codex_shell_command::bash; +pub use codex_shell_command::is_dangerous_command; +pub use codex_shell_command::is_safe_command; +pub use codex_shell_command::parse_command; +pub use codex_shell_command::powershell; pub use apply_patch::CODEX_APPLY_PATCH_ARG1; pub use client::X_CODEX_TURN_METADATA_HEADER; diff --git a/codex-rs/core/src/shell.rs b/codex-rs/core/src/shell.rs index 6cde28d2f..e4a1faf79 100644 --- a/codex-rs/core/src/shell.rs +++ b/codex-rs/core/src/shell.rs @@ -1,3 +1,4 @@ +use crate::shell_detect::detect_shell_type; use crate::shell_snapshot::ShellSnapshot; use serde::Deserialize; use serde::Serialize; @@ -244,27 +245,6 @@ pub fn get_shell(shell_type: ShellType, path: Option<&PathBuf>) -> Option } } -pub fn detect_shell_type(shell_path: &PathBuf) -> Option { - match shell_path.as_os_str().to_str() { - Some("zsh") => Some(ShellType::Zsh), - Some("sh") => Some(ShellType::Sh), - Some("cmd") => Some(ShellType::Cmd), - Some("bash") => Some(ShellType::Bash), - Some("pwsh") => Some(ShellType::PowerShell), - Some("powershell") => Some(ShellType::PowerShell), - _ => { - let shell_name = shell_path.file_stem(); - if let Some(shell_name) = shell_name - && shell_name != shell_path - { - detect_shell_type(&PathBuf::from(shell_name)) - } else { - None - } - } - } -} - pub fn default_user_shell() -> Shell { default_user_shell_from_path(get_user_shell_path()) } diff --git a/codex-rs/core/src/shell_detect.rs b/codex-rs/core/src/shell_detect.rs new file mode 100644 index 000000000..3595ab346 --- /dev/null +++ b/codex-rs/core/src/shell_detect.rs @@ -0,0 +1,24 @@ +use crate::shell::ShellType; +use std::path::Path; +use std::path::PathBuf; + +pub(crate) fn detect_shell_type(shell_path: &PathBuf) -> Option { + match shell_path.as_os_str().to_str() { + Some("zsh") => Some(ShellType::Zsh), + Some("sh") => Some(ShellType::Sh), + Some("cmd") => Some(ShellType::Cmd), + Some("bash") => Some(ShellType::Bash), + Some("pwsh") => Some(ShellType::PowerShell), + Some("powershell") => Some(ShellType::PowerShell), + _ => { + let shell_name = shell_path.file_stem(); + if let Some(shell_name) = shell_name { + let shell_name_path = Path::new(shell_name); + if shell_name_path != Path::new(shell_path) { + return detect_shell_type(&shell_name_path.to_path_buf()); + } + } + None + } + } +} diff --git a/codex-rs/command/BUILD.bazel b/codex-rs/shell-command/BUILD.bazel similarity index 64% rename from codex-rs/command/BUILD.bazel rename to codex-rs/shell-command/BUILD.bazel index d1d0fd34a..41f2f53f3 100644 --- a/codex-rs/command/BUILD.bazel +++ b/codex-rs/shell-command/BUILD.bazel @@ -1,7 +1,7 @@ load("//:defs.bzl", "codex_rust_crate") codex_rust_crate( - name = "command", - crate_name = "codex_command", + name = "shell-command", + crate_name = "codex_shell_command", compile_data = ["src/command_safety/powershell_parser.ps1"], ) diff --git a/codex-rs/command/Cargo.toml b/codex-rs/shell-command/Cargo.toml similarity index 95% rename from codex-rs/command/Cargo.toml rename to codex-rs/shell-command/Cargo.toml index 61e386869..2df9843f0 100644 --- a/codex-rs/command/Cargo.toml +++ b/codex-rs/shell-command/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "codex-command" +name = "codex-shell-command" version.workspace = true edition.workspace = true license.workspace = true diff --git a/codex-rs/command/src/bash.rs b/codex-rs/shell-command/src/bash.rs similarity index 100% rename from codex-rs/command/src/bash.rs rename to codex-rs/shell-command/src/bash.rs diff --git a/codex-rs/command/src/command_safety/is_dangerous_command.rs b/codex-rs/shell-command/src/command_safety/is_dangerous_command.rs similarity index 100% rename from codex-rs/command/src/command_safety/is_dangerous_command.rs rename to codex-rs/shell-command/src/command_safety/is_dangerous_command.rs diff --git a/codex-rs/command/src/command_safety/is_safe_command.rs b/codex-rs/shell-command/src/command_safety/is_safe_command.rs similarity index 100% rename from codex-rs/command/src/command_safety/is_safe_command.rs rename to codex-rs/shell-command/src/command_safety/is_safe_command.rs diff --git a/codex-rs/command/src/command_safety/mod.rs b/codex-rs/shell-command/src/command_safety/mod.rs similarity index 100% rename from codex-rs/command/src/command_safety/mod.rs rename to codex-rs/shell-command/src/command_safety/mod.rs diff --git a/codex-rs/command/src/command_safety/powershell_parser.ps1 b/codex-rs/shell-command/src/command_safety/powershell_parser.ps1 similarity index 100% rename from codex-rs/command/src/command_safety/powershell_parser.ps1 rename to codex-rs/shell-command/src/command_safety/powershell_parser.ps1 diff --git a/codex-rs/command/src/command_safety/windows_dangerous_commands.rs b/codex-rs/shell-command/src/command_safety/windows_dangerous_commands.rs similarity index 100% rename from codex-rs/command/src/command_safety/windows_dangerous_commands.rs rename to codex-rs/shell-command/src/command_safety/windows_dangerous_commands.rs diff --git a/codex-rs/command/src/command_safety/windows_safe_commands.rs b/codex-rs/shell-command/src/command_safety/windows_safe_commands.rs similarity index 100% rename from codex-rs/command/src/command_safety/windows_safe_commands.rs rename to codex-rs/shell-command/src/command_safety/windows_safe_commands.rs diff --git a/codex-rs/command/src/lib.rs b/codex-rs/shell-command/src/lib.rs similarity index 100% rename from codex-rs/command/src/lib.rs rename to codex-rs/shell-command/src/lib.rs diff --git a/codex-rs/command/src/parse_command.rs b/codex-rs/shell-command/src/parse_command.rs similarity index 100% rename from codex-rs/command/src/parse_command.rs rename to codex-rs/shell-command/src/parse_command.rs diff --git a/codex-rs/command/src/powershell.rs b/codex-rs/shell-command/src/powershell.rs similarity index 100% rename from codex-rs/command/src/powershell.rs rename to codex-rs/shell-command/src/powershell.rs diff --git a/codex-rs/command/src/shell_detect.rs b/codex-rs/shell-command/src/shell_detect.rs similarity index 100% rename from codex-rs/command/src/shell_detect.rs rename to codex-rs/shell-command/src/shell_detect.rs