Skip to content

Commit afe16a9

Browse files
committed
Add trust-all projects flag
1 parent cf2453b commit afe16a9

5 files changed

Lines changed: 40 additions & 1 deletion

File tree

codex-rs/cli/src/main.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2455,6 +2455,7 @@ fn merge_interactive_cli_flags(interactive: &mut TuiCli, subcommand_cli: TuiCli)
24552455
strict_config,
24562456
approval_policy,
24572457
web_search,
2458+
trust_all_projects,
24582459
prompt,
24592460
config_overrides,
24602461
..
@@ -2468,6 +2469,9 @@ fn merge_interactive_cli_flags(interactive: &mut TuiCli, subcommand_cli: TuiCli)
24682469
if web_search {
24692470
interactive.web_search = true;
24702471
}
2472+
if trust_all_projects {
2473+
interactive.trust_all_projects = true;
2474+
}
24712475
if strict_config {
24722476
interactive.strict_config = true;
24732477
}
@@ -3289,6 +3293,7 @@ mod tests {
32893293
"resume",
32903294
"sid",
32913295
"--oss",
3296+
"--trust-all-projects",
32923297
"--search",
32933298
"--sandbox",
32943299
"workspace-write",
@@ -3323,6 +3328,7 @@ mod tests {
33233328
Some(std::path::Path::new("/tmp"))
33243329
);
33253330
assert!(interactive.web_search);
3331+
assert!(interactive.trust_all_projects);
33263332
assert!(interactive.strict_config);
33273333
let has_a = interactive
33283334
.images

codex-rs/config/src/config_toml.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@ pub struct ConfigToml {
199199
/// Sandbox mode to use.
200200
pub sandbox_mode: Option<SandboxMode>,
201201

202+
/// Treat every project directory as trusted.
203+
pub trust_all_projects: Option<bool>,
204+
202205
/// Sandbox configuration to apply if `sandbox` is `WorkspaceWrite`.
203206
pub sandbox_workspace_write: Option<SandboxWorkspaceWrite>,
204207

@@ -826,6 +829,12 @@ impl ConfigToml {
826829
resolved_cwd: &Path,
827830
repo_root: Option<&Path>,
828831
) -> Option<ProjectConfig> {
832+
if self.trust_all_projects.unwrap_or(false) {
833+
return Some(ProjectConfig {
834+
trust_level: Some(TrustLevel::Trusted),
835+
});
836+
}
837+
829838
let projects = self.projects.as_ref()?;
830839

831840
for normalized_cwd in normalized_project_lookup_keys(resolved_cwd) {
@@ -1018,4 +1027,15 @@ mod tests {
10181027
assert!(message.contains("TOML list of strings"));
10191028
assert!(message.contains("comma-separated strings are not supported"));
10201029
}
1030+
1031+
#[test]
1032+
fn trust_all_projects_marks_any_directory_trusted() {
1033+
let config: ConfigToml = toml::from_str("trust_all_projects = true")
1034+
.expect("trust_all_projects should deserialize");
1035+
let active_project = config
1036+
.get_active_project(Path::new("/tmp/anything"), None)
1037+
.expect("trust_all_projects should always resolve an active project");
1038+
1039+
assert_eq!(active_project.trust_level, Some(TrustLevel::Trusted));
1040+
}
10211041
}

codex-rs/core/config.schema.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5398,6 +5398,10 @@
53985398
],
53995399
"description": "Nested tools section for feature toggles"
54005400
},
5401+
"trust_all_projects": {
5402+
"description": "Treat every project directory as trusted.",
5403+
"type": "boolean"
5404+
},
54015405
"tui": {
54025406
"allOf": [
54035407
{
@@ -5426,4 +5430,4 @@
54265430
},
54275431
"title": "ConfigToml",
54285432
"type": "object"
5429-
}
5433+
}

codex-rs/tui/src/cli.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ pub struct Cli {
6565
#[arg(long = "search", default_value_t = false)]
6666
pub web_search: bool,
6767

68+
/// Trust every project directory and skip directory trust prompts.
69+
#[arg(long = "trust-all-projects", default_value_t = false)]
70+
pub trust_all_projects: bool,
71+
6872
/// After each Codex response, automatically ask it to continue with the natural next steps.
6973
#[arg(long = "auto-next-steps", default_value_t = false)]
7074
pub auto_next_steps: bool,

codex-rs/tui/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,11 @@ pub async fn run_main(
869869
.raw_overrides
870870
.push("web_search=\"live\"".to_string());
871871
}
872+
if cli.trust_all_projects {
873+
cli.config_overrides
874+
.raw_overrides
875+
.push("trust_all_projects=true".to_string());
876+
}
872877

873878
// When using `--oss`, let the bootstrapper pick the model (defaulting to
874879
// gpt-oss:20b) and ensure it is present locally. Also, force the built‑in

0 commit comments

Comments
 (0)