add trust hooks CLI flag

This commit is contained in:
Abhinav Vedmala
2026-05-08 11:53:06 -04:00
parent 163eac9306
commit 9f82e113cd
13 changed files with 166 additions and 10 deletions

View File

@@ -47,6 +47,10 @@ pub struct SharedCliOptions {
)]
pub dangerously_bypass_approvals_and_sandbox: bool,
/// Run enabled hooks without requiring persisted hook trust for this invocation.
#[arg(long = "trust-hooks", default_value_t = false)]
pub trust_hooks: bool,
/// Tell the agent to use the specified directory as its working root.
#[clap(long = "cd", short = 'C', value_name = "DIR")]
pub cwd: Option<PathBuf>,
@@ -68,6 +72,7 @@ impl SharedCliOptions {
config_profile,
sandbox_mode,
dangerously_bypass_approvals_and_sandbox,
trust_hooks,
cwd,
add_dir,
} = self;
@@ -79,6 +84,7 @@ impl SharedCliOptions {
config_profile: root_config_profile,
sandbox_mode: root_sandbox_mode,
dangerously_bypass_approvals_and_sandbox: root_dangerously_bypass_approvals_and_sandbox,
trust_hooks: root_trust_hooks,
cwd: root_cwd,
add_dir: root_add_dir,
} = root;
@@ -102,6 +108,9 @@ impl SharedCliOptions {
*dangerously_bypass_approvals_and_sandbox =
*root_dangerously_bypass_approvals_and_sandbox;
}
if !*trust_hooks {
*trust_hooks = *root_trust_hooks;
}
if cwd.is_none() {
cwd.clone_from(root_cwd);
}
@@ -128,6 +137,7 @@ impl SharedCliOptions {
config_profile,
sandbox_mode,
dangerously_bypass_approvals_and_sandbox,
trust_hooks,
cwd,
add_dir,
} = subcommand;
@@ -149,6 +159,9 @@ impl SharedCliOptions {
self.dangerously_bypass_approvals_and_sandbox =
dangerously_bypass_approvals_and_sandbox;
}
if trust_hooks {
self.trust_hooks = true;
}
if let Some(cwd) = cwd {
self.cwd = Some(cwd);
}