From 665801bb8ee673dfba5002c603fda258387d00ce Mon Sep 17 00:00:00 2001 From: fuleinist Date: Sat, 9 May 2026 00:26:13 +0800 Subject: [PATCH] fix(cli): forward --yolo to TUI binary via DEEPSEEK_YOLO env The CLI dispatcher accepted --yolo but only passed it to Exec(TuiPassthroughArgs), not to the plain Run(RunArgs) path used for interactive sessions. Fix: pass DEEPSEEK_YOLO=true env var to the TUI binary. The TUI already reads this env var (matching DEEPSEEK_SANDBOX_MODE pattern) and sets allow_shell + start_in_agent_mode + yolo. Also adds yolo field to CliRuntimeOverrides and ResolvedRuntimeOptions so the flag propagates through the full resolve chain. --- .env.example | 1 + crates/cli/src/lib.rs | 7 +++++++ crates/config/src/lib.rs | 10 ++++++++++ crates/tui/src/config.rs | 5 +++++ crates/tui/src/main.rs | 1 + 5 files changed, 24 insertions(+) diff --git a/.env.example b/.env.example index 5fd9c087..eb28de82 100644 --- a/.env.example +++ b/.env.example @@ -37,6 +37,7 @@ # DEEPSEEK_APPROVAL_POLICY=on-request # DEEPSEEK_SANDBOX_MODE=workspace-write # DEEPSEEK_ALLOW_SHELL=true +# DEEPSEEK_YOLO=true # Optional extension paths # DEEPSEEK_SKILLS_DIR=~/.deepseek/skills diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs index 75dce61a..973b30fe 100644 --- a/crates/cli/src/lib.rs +++ b/crates/cli/src/lib.rs @@ -92,6 +92,9 @@ struct Cli { no_mouse_capture: bool, #[arg(long = "skip-onboarding")] skip_onboarding: bool, + /// YOLO mode: auto-approve all tools + #[arg(long)] + yolo: bool, #[arg(short = 'p', long = "prompt", value_name = "PROMPT")] prompt_flag: Option, #[arg( @@ -425,6 +428,7 @@ fn run() -> Result<()> { telemetry: cli.telemetry, approval_policy: cli.approval_policy.clone(), sandbox_mode: cli.sandbox_mode.clone(), + yolo: Some(cli.yolo), }; let command = cli.command.take(); @@ -1441,6 +1445,9 @@ fn build_tui_command( if let Some(mode) = cli.sandbox_mode.as_ref() { cmd.env("DEEPSEEK_SANDBOX_MODE", mode); } + if cli.yolo { + cmd.env("DEEPSEEK_YOLO", "true"); + } if let Some(api_key) = cli.api_key.as_ref() { cmd.env("DEEPSEEK_API_KEY", api_key); if resolved_runtime.provider == ProviderKind::Openai { diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 4cc2cfba..44ce2f83 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -962,6 +962,9 @@ impl ConfigToml { .clone() .or_else(|| env.sandbox_mode.clone()) .or_else(|| self.sandbox_mode.clone()); + let yolo = cli + .yolo + .or(env.yolo); ResolvedRuntimeOptions { provider, @@ -975,6 +978,7 @@ impl ConfigToml { telemetry, approval_policy, sandbox_mode, + yolo, http_headers, } } @@ -1111,6 +1115,7 @@ pub struct CliRuntimeOverrides { pub telemetry: Option, pub approval_policy: Option, pub sandbox_mode: Option, + pub yolo: Option, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -1146,6 +1151,7 @@ pub struct ResolvedRuntimeOptions { pub telemetry: bool, pub approval_policy: Option, pub sandbox_mode: Option, + pub yolo: Option, pub http_headers: BTreeMap, } @@ -1361,6 +1367,7 @@ struct EnvRuntimeOverrides { telemetry: Option, approval_policy: Option, sandbox_mode: Option, + yolo: Option, http_headers: Option>, deepseek_base_url: Option, nvidia_base_url: Option, @@ -1388,6 +1395,9 @@ impl EnvRuntimeOverrides { .and_then(|v| parse_bool(&v).ok()), approval_policy: std::env::var("DEEPSEEK_APPROVAL_POLICY").ok(), sandbox_mode: std::env::var("DEEPSEEK_SANDBOX_MODE").ok(), + yolo: std::env::var("DEEPSEEK_YOLO") + .ok() + .and_then(|v| parse_bool(&v).ok()), http_headers: std::env::var("DEEPSEEK_HTTP_HEADERS") .ok() .and_then(|value| parse_http_headers(&value).ok()) diff --git a/crates/tui/src/config.rs b/crates/tui/src/config.rs index b4cfb5f5..e126e2fb 100644 --- a/crates/tui/src/config.rs +++ b/crates/tui/src/config.rs @@ -770,6 +770,7 @@ pub struct Config { pub allow_shell: Option, pub approval_policy: Option, pub sandbox_mode: Option, + pub yolo: Option, /// External sandbox backend: `"none"` or `"opensandbox"`. /// When set, exec_shell routes commands through the backend's HTTP API /// instead of spawning a local process. @@ -2163,6 +2164,9 @@ fn apply_env_overrides(config: &mut Config) { if let Ok(value) = std::env::var("DEEPSEEK_SANDBOX_MODE") { config.sandbox_mode = Some(value); } + if let Ok(value) = std::env::var("DEEPSEEK_YOLO") { + config.yolo = Some(value == "1" || value.eq_ignore_ascii_case("true")); + } if let Ok(value) = std::env::var("DEEPSEEK_SANDBOX_BACKEND") { config.sandbox_backend = Some(value); } @@ -2507,6 +2511,7 @@ fn merge_config(base: Config, override_cfg: Config) -> Config { // both — they list `~/global.md` inside the project array. instructions: override_cfg.instructions.or(base.instructions), allow_shell: override_cfg.allow_shell.or(base.allow_shell), + yolo: override_cfg.yolo.or(base.yolo), approval_policy: override_cfg.approval_policy.or(base.approval_policy), sandbox_mode: override_cfg.sandbox_mode.or(base.sandbox_mode), sandbox_backend: override_cfg.sandbox_backend.or(base.sandbox_backend), diff --git a/crates/tui/src/main.rs b/crates/tui/src/main.rs index 6d99848c..ace0bd9e 100644 --- a/crates/tui/src/main.rs +++ b/crates/tui/src/main.rs @@ -5517,6 +5517,7 @@ mod setup_helper_tests { "RUST_LOG", "DEEPSEEK_APPROVAL_POLICY", "DEEPSEEK_SANDBOX_MODE", + "DEEPSEEK_YOLO", ] { assert!( keys.contains(required),