mirror of
https://github.com/openai/codex.git
synced 2026-04-24 22:54:54 +00:00
changes
This commit is contained in:
@@ -27,8 +27,6 @@ use codex_tui::Cli as TuiCli;
|
||||
use codex_tui::ExitReason;
|
||||
use codex_tui::update_action::UpdateAction;
|
||||
use owo_colors::OwoColorize;
|
||||
use std::ffi::OsStr;
|
||||
use std::ffi::OsString;
|
||||
use std::io::IsTerminal;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
@@ -106,12 +104,10 @@ enum Subcommand {
|
||||
Completion(CompletionCommand),
|
||||
|
||||
/// Run commands within a Codex-provided sandbox.
|
||||
#[clap(visible_alias = "debug")]
|
||||
Sandbox(SandboxArgs),
|
||||
|
||||
/// Tooling: helps debug the app server.
|
||||
#[clap(hide = true, name = "debug-app-server")]
|
||||
DebugAppServer(DebugAppServerCommand),
|
||||
/// Debugging tools.
|
||||
Debug(DebugCommand),
|
||||
|
||||
/// Execpolicy tooling.
|
||||
#[clap(hide = true)]
|
||||
@@ -150,6 +146,18 @@ struct CompletionCommand {
|
||||
shell: Shell,
|
||||
}
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
struct DebugCommand {
|
||||
#[command(subcommand)]
|
||||
subcommand: DebugSubcommand,
|
||||
}
|
||||
|
||||
#[derive(Debug, clap::Subcommand)]
|
||||
enum DebugSubcommand {
|
||||
/// Tooling: helps debug the app server.
|
||||
AppServer(DebugAppServerCommand),
|
||||
}
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
struct DebugAppServerCommand {
|
||||
/// Message to send through codex-app-server-test-client send-message-v2.
|
||||
@@ -474,22 +482,6 @@ fn run_debug_app_server_command(cmd: DebugAppServerCommand) -> anyhow::Result<()
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn remap_debug_app_server_args(args: Vec<OsString>) -> Vec<OsString> {
|
||||
if args.get(1).is_some_and(|arg| arg == OsStr::new("debug"))
|
||||
&& args
|
||||
.get(2)
|
||||
.is_some_and(|arg| arg == OsStr::new("app-server"))
|
||||
{
|
||||
let mut remapped = Vec::with_capacity(args.len().saturating_sub(1));
|
||||
remapped.push(args[0].clone());
|
||||
remapped.push(OsString::from("debug-app-server"));
|
||||
remapped.extend(args.into_iter().skip(3));
|
||||
return remapped;
|
||||
}
|
||||
|
||||
args
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Parser, Clone)]
|
||||
struct FeatureToggles {
|
||||
/// Enable a feature (repeatable). Equivalent to `-c features.<name>=true`.
|
||||
@@ -565,13 +557,12 @@ fn main() -> anyhow::Result<()> {
|
||||
}
|
||||
|
||||
async fn cli_main(codex_linux_sandbox_exe: Option<PathBuf>) -> anyhow::Result<()> {
|
||||
let parsed_args = remap_debug_app_server_args(std::env::args_os().collect());
|
||||
let MultitoolCli {
|
||||
config_overrides: mut root_config_overrides,
|
||||
feature_toggles,
|
||||
mut interactive,
|
||||
subcommand,
|
||||
} = MultitoolCli::parse_from(parsed_args);
|
||||
} = MultitoolCli::parse();
|
||||
|
||||
// Fold --enable/--disable into config overrides so they flow to all subcommands.
|
||||
let toggle_overrides = feature_toggles.to_overrides()?;
|
||||
@@ -755,9 +746,11 @@ async fn cli_main(codex_linux_sandbox_exe: Option<PathBuf>) -> anyhow::Result<()
|
||||
.await?;
|
||||
}
|
||||
},
|
||||
Some(Subcommand::DebugAppServer(cmd)) => {
|
||||
run_debug_app_server_command(cmd)?;
|
||||
}
|
||||
Some(Subcommand::Debug(DebugCommand { subcommand })) => match subcommand {
|
||||
DebugSubcommand::AppServer(cmd) => {
|
||||
run_debug_app_server_command(cmd)?;
|
||||
}
|
||||
},
|
||||
Some(Subcommand::Execpolicy(ExecpolicyCommand { sub })) => match sub {
|
||||
ExecpolicySubcommand::Check(cmd) => run_execpolicycheck(cmd)?,
|
||||
},
|
||||
@@ -1045,7 +1038,6 @@ mod tests {
|
||||
use codex_core::protocol::TokenUsage;
|
||||
use codex_protocol::ThreadId;
|
||||
use pretty_assertions::assert_eq;
|
||||
use std::ffi::OsString;
|
||||
|
||||
fn finalize_resume_from_args(args: &[&str]) -> TuiCli {
|
||||
let cli = MultitoolCli::try_parse_from(args).expect("parse");
|
||||
@@ -1357,37 +1349,6 @@ mod tests {
|
||||
assert!(app_server.analytics_default_enabled);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remap_debug_app_server_args_rewrites_app_server_form() {
|
||||
let input = vec![
|
||||
OsString::from("codex"),
|
||||
OsString::from("debug"),
|
||||
OsString::from("app-server"),
|
||||
OsString::from("hello"),
|
||||
OsString::from("world"),
|
||||
];
|
||||
let remapped = remap_debug_app_server_args(input);
|
||||
let expected = vec![
|
||||
OsString::from("codex"),
|
||||
OsString::from("debug-app-server"),
|
||||
OsString::from("hello"),
|
||||
OsString::from("world"),
|
||||
];
|
||||
assert_eq!(remapped, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remap_debug_app_server_args_keeps_legacy_debug_sandbox_form() {
|
||||
let input = vec![
|
||||
OsString::from("codex"),
|
||||
OsString::from("debug"),
|
||||
OsString::from("landlock"),
|
||||
OsString::from("pwd"),
|
||||
];
|
||||
let remapped = remap_debug_app_server_args(input.clone());
|
||||
assert_eq!(remapped, input);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn features_enable_parses_feature_name() {
|
||||
let cli = MultitoolCli::try_parse_from(["codex", "features", "enable", "unified_exec"])
|
||||
|
||||
Reference in New Issue
Block a user