From 908de632b30a225ed519b4c9c670a3f7b519c346 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Thu, 4 Jun 2026 12:40:02 -0400 Subject: [PATCH] Restore Windows PowerShell parser API --- codex-rs/shell-command/src/command_safety/mod.rs | 3 +++ codex-rs/shell-command/src/powershell.rs | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/codex-rs/shell-command/src/command_safety/mod.rs b/codex-rs/shell-command/src/command_safety/mod.rs index d78fe0327f..3ed7165d93 100644 --- a/codex-rs/shell-command/src/command_safety/mod.rs +++ b/codex-rs/shell-command/src/command_safety/mod.rs @@ -1,6 +1,9 @@ #[cfg(windows)] mod powershell_parser; +#[cfg(windows)] +pub(crate) use powershell_parser::try_parse_powershell_ast_commands; + pub mod is_dangerous_command; pub mod is_safe_command; #[cfg(windows)] diff --git a/codex-rs/shell-command/src/powershell.rs b/codex-rs/shell-command/src/powershell.rs index fbd35477f1..9b1b2dc4cc 100644 --- a/codex-rs/shell-command/src/powershell.rs +++ b/codex-rs/shell-command/src/powershell.rs @@ -2,6 +2,8 @@ use std::path::PathBuf; use codex_utils_absolute_path::AbsolutePathBuf; +#[cfg(windows)] +use crate::command_safety::try_parse_powershell_ast_commands; use crate::shell_detect::ShellType; use crate::shell_detect::detect_shell_type; @@ -69,6 +71,14 @@ pub fn extract_powershell_command(command: &[String]) -> Option<(&str, &str)> { None } +#[cfg(windows)] +pub fn parse_powershell_command_into_plain_commands( + command: &[String], +) -> Option>> { + let (executable, script) = extract_powershell_command(command)?; + try_parse_powershell_ast_commands(executable, script) +} + /// This function attempts to find a powershell.exe executable on the system. pub fn try_find_powershell_executable_blocking() -> Option { try_find_powershellish_executable_in_path(&["powershell.exe"])