Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
feat(approvals): let `wt config approvals add --yes` record approvals without a TTY (#3819)
Maximilian Roos92dfb686bbd0
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 2bfa983a0..18334de5f 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -4,6 +4,8 @@### Improved+- **`wt config approvals add --yes` records approvals without a terminal**: the command refused every non-interactive run, so a container that had just cloned a project could only pre-approve it by hand-writing `approvals.toml` from `wt config approvals list --format=json`. `--yes` now lists what it trusts and writes it. A save it cannot make fails the command rather than warning and exiting 0, since the record is all `add` produces — a change that applies to the interactive run too.+- **`remote_repo` names the repository as the remote spells it**: `repo` is the directory on disk, so a renamed clone reports the new name. `{{ remote_repo }}` takes it from the primary remote's URL, available everywhere `owner` is and unset when no remote parses. ([#3745](https://github.com/max-sixty/worktrunk/pull/3745), thanks @canac)## 0.73.0diff --git a/docs/content/config.md b/docs/content/config.mdindex cac68812d..1db49d161 100644--- a/docs/content/config.md+++ b/docs/content/config.md@@ -816,6 +816,9 @@ List commands and their approval status for current project:Pre-approve all hook and alias commands for current project:{{ terminal(cmd="wt config approvals add") }}+Pre-approve without prompting, for a container or CI job:+{{ terminal(cmd="wt config approvals add --yes") }}+Clear approvals for current project:{{ terminal(cmd="wt config approvals clear") }}@@ -830,7 +833,9 @@ Check whether an unattended run would stop for approval:### How approvals work-Approved commands are saved to `~/.config/worktrunk/approvals.toml`. Re-approval is required when the command template changes or the project moves. Use `--yes` to bypass prompts in CI.+Approved commands are saved to `~/.config/worktrunk/approvals.toml`. Re-approval is required when the command template changes or the project moves.++`--yes` bypasses the prompt, and what it leaves behind depends on the command it is passed to. On a command that runs project commands it grants consent for that run alone and records nothing, so the next run asks again. On `wt config approvals add` the record is the whole point, so the approvals are written — which is how an unattended environment pre-approves a project it has just cloned.### Reading approval statediff --git a/docs/static/.well-known/agent-skills/index.json b/docs/static/.well-known/agent-skills/index.jsonindex c5645fa75..52fa9a489 100644--- a/docs/static/.well-known/agent-skills/index.json+++ b/docs/static/.well-known/agent-skills/index.json@@ -6,7 +6,7 @@"type": "skill-md","description": "Guidance for Worktrunk (the `wt` CLI) — git worktree management, hooks, and config. Load when editing .config/wt.toml or ~/.config/worktrunk/config.toml; adding, modifying, or debugging hooks (post-merge, post-start, pre-commit, pre-merge, post-switch, etc.); configuring commit message generation or command aliases; or troubleshooting wt behavior. Also answers general worktrunk/wt questions.","url": "./worktrunk/SKILL.md",- "digest": "sha256:0a217b6b0a30588569bf97d5ad828d07aaf8241c67e2855ef461233098ec8c53"+ "digest": "sha256:3fc6de776a7db9b9f1f65e8312cf85baa8f9008c1c00144aa319cb8ac0d04af7"}]}diff --git a/plugins/worktrunk/skills/worktrunk/SKILL.md b/plugins/worktrunk/skills/worktrunk/SKILL.mdindex 3c538ccf4..792ea0628 100644--- a/plugins/worktrunk/skills/worktrunk/SKILL.md+++ b/plugins/worktrunk/skills/worktrunk/SKILL.md@@ -118,14 +118,14 @@ Agents running `wt merge`, `wt switch`, or other commands that trigger hooks wil○ post-merge install:cargo install --path .✗ Cannot prompt for approval in non-interactive environment-↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt config approvals add+↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt config approvals add --yes```The resolution is for the user to make the trust decision themselves:- **`wt config approvals add`** — interactive prompt where the user reviews each command before it is stored to `~/.config/worktrunk/approvals.toml`. Run once per project; the approval persists across invocations until the command template changes or the project moves. This is the path to recommend — the user reviews and consents to exactly the commands that will run.-**When invoked as an agent, stop and escalate to the user.** Approving a project's hooks is a security decision about whether this repository should be trusted to run arbitrary commands on the user's machine — that decision belongs to the user, not the agent. Tell the user to run `wt config approvals add` and let them review the commands. Do not run `--yes` on the user's behalf: it skips the approval gate for that invocation, so reaching for it to unblock a command defeats the protection. `--yes` exists for CI/CD pipelines that already control their own hook contents; it is not a shortcut for an interactive agent to silence an approval prompt.+**When invoked as an agent, stop and escalate to the user.** Approving a project's hooks is a security decision about whether this repository should be trusted to run arbitrary commands on the user's machine — that decision belongs to the user, not the agent. Tell the user to run `wt config approvals add` and let them review the commands. Do not reach for either `--yes` on the user's behalf: on the blocked command it skips the gate for that invocation, and `wt config approvals add --yes` records every command the project declares with nobody reading them. Both exist for CI/CD pipelines and containers that already control their own hook contents; neither is a shortcut for an interactive agent to silence an approval prompt.## Advanced: agent handoffsdiff --git a/plugins/worktrunk/skills/worktrunk/reference/config.md b/plugins/worktrunk/skills/worktrunk/reference/config.mdindex f4641dbe2..5a4468283 100644--- a/plugins/worktrunk/skills/worktrunk/reference/config.md+++ b/plugins/worktrunk/skills/worktrunk/reference/config.md@@ -824,6 +824,11 @@ Pre-approve all hook and alias commands for current project:$ wt config approvals add```+Pre-approve without prompting, for a container or CI job:+```bash+$ wt config approvals add --yes+```+Clear approvals for current project:```bash$ wt config approvals clear@@ -846,7 +851,9 @@ $ wt config approvals list --format=json | jq -r .state### How approvals work-Approved commands are saved to `~/.config/worktrunk/approvals.toml`. Re-approval is required when the command template changes or the project moves. Use `--yes` to bypass prompts in CI.+Approved commands are saved to `~/.config/worktrunk/approvals.toml`. Re-approval is required when the command template changes or the project moves.++`--yes` bypasses the prompt, and what it leaves behind depends on the command it is passed to. On a command that runs project commands it grants consent for that run alone and records nothing, so the next run asks again. On `wt config approvals add` the record is the whole point, so the approvals are written — which is how an unattended environment pre-approves a project it has just cloned.### Reading approval statediff --git a/skills/worktrunk/SKILL.md b/skills/worktrunk/SKILL.mdindex 3c538ccf4..792ea0628 100644--- a/skills/worktrunk/SKILL.md+++ b/skills/worktrunk/SKILL.md@@ -118,14 +118,14 @@ Agents running `wt merge`, `wt switch`, or other commands that trigger hooks wil○ post-merge install:cargo install --path .✗ Cannot prompt for approval in non-interactive environment-↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt config approvals add+↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt config approvals add --yes```The resolution is for the user to make the trust decision themselves:- **`wt config approvals add`** — interactive prompt where the user reviews each command before it is stored to `~/.config/worktrunk/approvals.toml`. Run once per project; the approval persists across invocations until the command template changes or the project moves. This is the path to recommend — the user reviews and consents to exactly the commands that will run.-**When invoked as an agent, stop and escalate to the user.** Approving a project's hooks is a security decision about whether this repository should be trusted to run arbitrary commands on the user's machine — that decision belongs to the user, not the agent. Tell the user to run `wt config approvals add` and let them review the commands. Do not run `--yes` on the user's behalf: it skips the approval gate for that invocation, so reaching for it to unblock a command defeats the protection. `--yes` exists for CI/CD pipelines that already control their own hook contents; it is not a shortcut for an interactive agent to silence an approval prompt.+**When invoked as an agent, stop and escalate to the user.** Approving a project's hooks is a security decision about whether this repository should be trusted to run arbitrary commands on the user's machine — that decision belongs to the user, not the agent. Tell the user to run `wt config approvals add` and let them review the commands. Do not reach for either `--yes` on the user's behalf: on the blocked command it skips the gate for that invocation, and `wt config approvals add --yes` records every command the project declares with nobody reading them. Both exist for CI/CD pipelines and containers that already control their own hook contents; neither is a shortcut for an interactive agent to silence an approval prompt.## Advanced: agent handoffsdiff --git a/skills/worktrunk/reference/config.md b/skills/worktrunk/reference/config.mdindex f4641dbe2..5a4468283 100644--- a/skills/worktrunk/reference/config.md+++ b/skills/worktrunk/reference/config.md@@ -824,6 +824,11 @@ Pre-approve all hook and alias commands for current project:$ wt config approvals add```+Pre-approve without prompting, for a container or CI job:+```bash+$ wt config approvals add --yes+```+Clear approvals for current project:```bash$ wt config approvals clear@@ -846,7 +851,9 @@ $ wt config approvals list --format=json | jq -r .state### How approvals work-Approved commands are saved to `~/.config/worktrunk/approvals.toml`. Re-approval is required when the command template changes or the project moves. Use `--yes` to bypass prompts in CI.+Approved commands are saved to `~/.config/worktrunk/approvals.toml`. Re-approval is required when the command template changes or the project moves.++`--yes` bypasses the prompt, and what it leaves behind depends on the command it is passed to. On a command that runs project commands it grants consent for that run alone and records nothing, so the next run asks again. On `wt config approvals add` the record is the whole point, so the approvals are written — which is how an unattended environment pre-approves a project it has just cloned.### Reading approval statediff --git a/src/cli/config.rs b/src/cli/config.rsindex dc1466637..ee7076676 100644--- a/src/cli/config.rs+++ b/src/cli/config.rs@@ -261,7 +261,15 @@ $ wt config approvals list --format=json | jq -r .stateafter_long_help = r#"Prompts for approval of all project commands and saves them to approvals.toml.By default, shows only unapproved commands. Use `--all` to review all commands-including previously approved ones."#+including previously approved ones.++`--yes` writes the approvals without prompting, which is how a container or CI job pre-approves a project it has just cloned. It trusts every command the project config declares, including one whose template changed since an earlier approval. A caller that wants to look before granting them can list those first — see [Reading approval state](@/config.md#reading-approval-state).++## Examples++```console+$ wt config approvals add --yes+```"#)]Add {/// Show all commands@@ -571,6 +579,11 @@ Pre-approve all hook and alias commands for current project:$ wt config approvals add```+Pre-approve without prompting, for a container or CI job:+```console+$ wt config approvals add --yes+```+Clear approvals for current project:```console$ wt config approvals clear@@ -593,7 +606,9 @@ $ wt config approvals list --format=json | jq -r .state## How approvals work-Approved commands are saved to `~/.config/worktrunk/approvals.toml`. Re-approval is required when the command template changes or the project moves. Use `--yes` to bypass prompts in CI.+Approved commands are saved to `~/.config/worktrunk/approvals.toml`. Re-approval is required when the command template changes or the project moves.++`--yes` bypasses the prompt, and what it leaves behind depends on the command it is passed to. On a command that runs project commands it grants consent for that run alone and records nothing, so the next run asks again. On `wt config approvals add` the record is the whole point, so the approvals are written — which is how an unattended environment pre-approves a project it has just cloned.## Reading approval statediff --git a/src/commands/command_approval.rs b/src/commands/command_approval.rsindex 4ce872e53..84016529b 100644--- a/src/commands/command_approval.rs+++ b/src/commands/command_approval.rs@@ -39,6 +39,11 @@ use super::project_config::{ApprovableCommand, Phase, collect_commands_for_hooks/// Shows command templates to the user (what gets saved to config), not expanded values./// This ensures users see exactly what they're approving.///+/// `yes` grants consent for this invocation alone: nothing is recorded, so the+/// next run asks again. Recording without a prompt is `wt config approvals+/// add --yes`'s job ([`crate::commands::add_approvals`]), which doesn't pass+/// through this gate.+////// # Parameters/// - `commands_already_filtered`: If true, commands list is pre-filtered; skip filtering by approval statuspub fn approve_command_batch(@@ -70,7 +75,9 @@ pub fn approve_command_batch(return Ok(false);}- // Only save approvals when interactively approved, not when using --yes+ // Only save approvals when interactively approved, not when using --yes.+ // A failed save costs one more prompt next run, not the command the user+ // actually ran, so it warns rather than errors.if !yes {let mut fresh_approvals = Approvals::load().context("Failed to load approvals")?;let commands: Vec<String> = needs_approval@@ -95,30 +102,56 @@ pub fn approve_command_batch(Ok(true)}-fn prompt_for_batch_approval(- commands: &[&ApprovableCommand],- project_id: &str,-) -> anyhow::Result<bool> {- // Extract just the directory name for display- let project_name = Path::new(project_id)+/// The project's directory name, which is what a user recognizes; the full+/// identifier is a path or a remote URL.+fn display_project_name(project_id: &str) -> &str {+ Path::new(project_id).file_name().and_then(|n| n.to_str())- .unwrap_or(project_id);- let count = commands.len();- let plural = if count == 1 { "" } else { "s" };-- eprintln!(- "{}",- cformat!(- "{WARNING_SYMBOL} <yellow><bold>{project_name}</> needs approval to execute <bold>{count}</> command{plural}:</>"- )- );+ .unwrap_or(project_id)+}+/// The batch as the user sees it: a header, then each command's label and its+/// template. Shared by the prompt and by `--yes` on `wt config approvals add`.+fn print_command_batch(header: &str, commands: &[&ApprovableCommand]) {+ eprintln!("{header}");for cmd in commands {// Uses INFO_SYMBOL (○) since this is a preview, not active executioneprintln!("{} {}", INFO_SYMBOL, cmd.label());eprintln!("{}", cmd.format_template());}+}++/// The batch `wt config approvals add --yes` is about to trust. Nothing is+/// being asked, but the batch still prints: it is the record of what an+/// unattended run just approved. Lives beside [`prompt_for_batch_approval`]+/// so the two headers stay parallel.+pub fn announce_batch_approval(commands: &[&ApprovableCommand], project_id: &str) {+ let project_name = display_project_name(project_id);+ let count = commands.len();+ let plural = if count == 1 { "" } else { "s" };+ print_command_batch(+ &cformat!(+ "{WARNING_SYMBOL} <yellow>Approving <bold>{count}</> command{plural} for <bold>{project_name}</> (--yes):</>"+ ),+ commands,+ );+}++pub fn prompt_for_batch_approval(+ commands: &[&ApprovableCommand],+ project_id: &str,+) -> anyhow::Result<bool> {+ let project_name = display_project_name(project_id);+ let count = commands.len();+ let plural = if count == 1 { "" } else { "s" };++ print_command_batch(+ &cformat!(+ "{WARNING_SYMBOL} <yellow><bold>{project_name}</> needs approval to execute <bold>{count}</> command{plural}:</>"+ ),+ commands,+ );// Check if stdin is a TTY before attempting to prompt// This happens AFTER showing the commands so they appear in CI/CD logsdiff --git a/src/commands/config/approvals.rs b/src/commands/config/approvals.rsindex 9ffcdc78c..1c8b6b345 100644--- a/src/commands/config/approvals.rs+++ b/src/commands/config/approvals.rs@@ -19,7 +19,7 @@ use worktrunk::styling::{};use crate::cli::SwitchFormat;-use crate::commands::command_approval::approve_command_batch;+use crate::commands::command_approval::{announce_batch_approval, prompt_for_batch_approval};use crate::commands::project_config::{ApprovableCommand, collect_commands_for_aliases, collect_commands_for_hooks,};@@ -189,10 +189,17 @@ pub fn list_approvals(format: SwitchFormat) -> anyhow::Result<()> {}/// Handle `wt config approvals add` command - approve all hook and alias commands in the project-pub fn add_approvals(show_all: bool) -> anyhow::Result<()> {+///+/// `yes` skips the review prompt, which is what makes the command usable+/// unattended: the approvals are still written, so an orchestrator can+/// pre-approve a project's commands before any `wt` run that would execute+/// them. Templates edited since an earlier approval are re-approved without+/// comment — read `wt config approvals list --format=json`'s `stale` first to+/// see them.+pub fn add_approvals(show_all: bool, yes: bool) -> anyhow::Result<()> {let repo = Repository::current()?;let project_id = repo.project_identifier()?;- let approvals = Approvals::load().context("Failed to load approvals")?;+ let mut approvals = Approvals::load().context("Failed to load approvals")?;let project_config = require_project_config(&repo)?;let commands = collect_approvable_commands(&project_config);@@ -219,20 +226,33 @@ pub fn add_approvals(show_all: bool) -> anyhow::Result<()> {commands};- // Call the approval prompt (yes=false to require interactive approval and save)- // When show_all=true, we've already included all commands in commands_to_approve- // When show_all=false, we've already filtered to unapproved commands- // So we pass skip_approval_filter=true to prevent double-filtering- let approved =- approve_command_batch(&commands_to_approve, &project_id, &approvals, false, true)?;-- // Show result- if approved {- eprintln!("{}", success_message("Commands approved & saved to config"));+ // Unlike the execution gate (`approve_command_batch`), whose `--yes`+ // consents to one run and records nothing, the record is this command's+ // product: it saves on either path, and a failed save fails the command —+ // an orchestrator that pre-approves and reads only the exit code would+ // otherwise walk into the prompt it just paid to avoid.+ let batch: Vec<&_> = commands_to_approve.iter().collect();+ let approved = if yes {+ announce_batch_approval(&batch, &project_id);+ true} else {+ prompt_for_batch_approval(&batch, &project_id)?+ };++ if !approved {eprintln!("{}", info_message("Commands declined"));+ return Ok(());}+ let templates: Vec<String> = commands_to_approve+ .iter()+ .map(|cmd| cmd.command.template.clone())+ .collect();+ approvals+ .approve_commands(project_id, templates, &require_approvals_path()?)+ .context("Failed to save command approval")?;++ eprintln!("{}", success_message("Commands approved & saved to config"));Ok(())}diff --git a/src/git/error.rs b/src/git/error.rsindex a557938f5..55adf4877 100644--- a/src/git/error.rs+++ b/src/git/error.rs@@ -1385,7 +1385,11 @@ impl GitError {GitError::NotInteractive => {let title = self.title();- let approvals_cmd = suggest_command("config", &["approvals", "add"], &[]);+ // The pre-approval route is itself unattended, so it carries+ // `--yes` — a hint reached in CI must name a command that runs+ // there. Raised from `wt config approvals add` itself, that+ // suggestion is the exact fix: append the flag.+ let approvals_cmd = suggest_command("config approvals add", &[], &["--yes"]);write!(f,"{}\n{}",diff --git a/src/main.rs b/src/main.rsindex 0a750665c..848afb523 100644--- a/src/main.rs+++ b/src/main.rs@@ -165,7 +165,7 @@ fn handle_hook_command(action: HookCommand, yes: bool) -> anyhow::Result<()> {);match action {ApprovalsCommand::List { format } => list_approvals(format),- ApprovalsCommand::Add { all } => add_approvals(all),+ ApprovalsCommand::Add { all } => add_approvals(all, yes),ApprovalsCommand::Clear { global, stale } => clear_approvals(global, stale),}}@@ -641,7 +641,7 @@ fn handle_config_command(action: ConfigCommand, yes: bool) -> anyhow::Result<()>ConfigCommand::Update { print } => handle_config_update(yes, print),ConfigCommand::Approvals { action } => match action {ApprovalsCommand::List { format } => list_approvals(format),- ApprovalsCommand::Add { all } => add_approvals(all),+ ApprovalsCommand::Add { all } => add_approvals(all, yes),ApprovalsCommand::Clear { global, stale } => clear_approvals(global, stale),},ConfigCommand::Alias { action } => match action {diff --git a/src/styling/suggest.rs b/src/styling/suggest.rsindex 48a2e07b9..c8520b594 100644--- a/src/styling/suggest.rs+++ b/src/styling/suggest.rs@@ -47,7 +47,9 @@ use std::path::Path;////// # Arguments///-/// * `subcommand` - The subcommand name (e.g., "remove", "switch", "merge")+/// * `subcommand` - The subcommand name (e.g., "remove", "switch", "merge").+/// A nested subcommand is written out in full here ("config approvals add"),+/// so that any flags land after it rather than mid-path./// * `args` - Positional arguments (branch names, paths, etc.)/// * `flags` - Additional flags to suggest (e.g., "--force", "-D")///diff --git a/tests/integration_tests/approval_save.rs b/tests/integration_tests/approval_save.rsindex 52153467f..ce85886da 100644--- a/tests/integration_tests/approval_save.rs+++ b/tests/integration_tests/approval_save.rs@@ -509,9 +509,10 @@ fn test_truly_concurrent_approve_with_threads() {////// This tests the lower-level `approve_command()` method fails when permissions-/// are denied. The higher-level `approve_command_batch()` catches this error and-/// displays a warning (see src/commands/command_approval.rs:82-85), allowing-/// commands to execute even when the approval can't be saved.+/// are denied. On an execution path the higher-level `approve_command_batch()`+/// catches this error and displays a warning, allowing commands to execute even+/// when the approval can't be saved; `wt config approvals add` instead+/// propagates it, since the record is all that command produces.////// TODO: Find a way to test permission errors without skipping when running as root./// Currently skips in containerized environments (Claude Code web, Docker) where@@ -575,14 +576,11 @@ fn test_permission_error_prevents_save() {"Expected save to fail due to permissions, but it succeeded");- // In the actual code (approve_command_batch), when this error occurs:- // 1. It's caught with `if let Err(e) = fresh_config.save()`- // 2. Warning is printed: "🟡 Failed to save command approval: {error}"- // 3. Hint is printed: "💡 Approval will be requested again next time."- // 4. Function returns Ok(true) - execution continues!- //- // The approval succeeds (commands execute) even though saving failed.- // This test verifies the save operation correctly fails with permission errors.+ // This test verifies the save operation correctly fails with permission+ // errors. What `approve_command_batch` does with that failure is covered by+ // `test_add_approvals_yes_fails_when_approvals_cannot_be_saved`+ // (propagates, for `wt config approvals add`) and by the warning path it+ // takes for a command that merely runs project commands.}#[test]diff --git a/tests/integration_tests/approvals.rs b/tests/integration_tests/approvals.rsindex 7294af970..4a760ca1c 100644--- a/tests/integration_tests/approvals.rs+++ b/tests/integration_tests/approvals.rs@@ -1,9 +1,9 @@//! Integration tests for the `wt config approvals` subcommandsuse crate::common::{- BareRepoTest, TestRepo, TestRepoBase, make_snapshot_cmd, repo, set_temp_home_env,- setup_snapshot_settings, setup_snapshot_settings_with_home, setup_temp_snapshot_settings,- temp_home, wt_command,+ BareRepoTest, TestRepo, TestRepoBase, make_snapshot_cmd, make_snapshot_cmd_with_global_flags,+ repo, set_temp_home_env, setup_snapshot_settings, setup_snapshot_settings_with_home,+ setup_temp_snapshot_settings, temp_home, wt_command,};use insta_cmd::assert_cmd_snapshot;use rstest::rstest;@@ -179,6 +179,73 @@ fn test_hook_approvals_emits_deprecation_warning(});}+/// `--yes` is what makes `add` usable unattended: with no terminal to prompt+/// on it lists what it trusts and writes the approvals. The flag is global, so+/// it records the same thing on either side of the subcommand.+#[rstest]+fn test_add_approvals_yes_records_without_a_terminal(repo: TestRepo) {+ repo.run_git(&["remote", "remove", "origin"]);+ repo.write_project_config(+ r#"pre-merge = "cargo test"++[aliases]+deploy = "echo deploying"+"#,+ );+ repo.commit("Add config");++ snapshot_add_approvals("add_approvals_yes", &repo, &["--yes"]);++ let recorded = fs::read_to_string(repo.test_approvals_path()).unwrap();+ assert!(recorded.contains("cargo test"), "{recorded}");+ assert!(recorded.contains("echo deploying"), "{recorded}");++ // Same run again from the global flag position, which reaches the command+ // through clap's global `--yes` rather than the subcommand's own parse.+ fs::remove_file(repo.test_approvals_path()).unwrap();+ let output = make_snapshot_cmd_with_global_flags(&repo, "config", &[], None, &["--yes"])+ .args(["approvals", "add"])+ .output()+ .unwrap();+ assert!(output.status.success(), "{output:?}");+ assert_eq!(+ fs::read_to_string(repo.test_approvals_path()).unwrap(),+ recorded+ );+}++/// The record is all `add` produces, so a write it cannot make fails the+/// command. A warning plus exit 0 would leave an orchestrator that pre-approves+/// and reads the exit code walking into the prompt it just paid to avoid.+#[rstest]+fn test_add_approvals_yes_fails_when_approvals_cannot_be_saved(repo: TestRepo) {+ repo.write_project_config(r#"pre-merge = "cargo test""#);+ repo.commit("Add config");++ // A regular file where the approvals directory would go: creating the+ // parent fails on every platform, with no permission bits involved.+ let blocker = repo.test_approvals_path().with_file_name("blocker");+ fs::write(&blocker, "").unwrap();++ let output = repo+ .wt_command()+ .args(["config", "approvals", "add", "--yes"])+ .env("WORKTRUNK_APPROVALS_PATH", blocker.join("approvals.toml"))+ .output()+ .unwrap();++ assert!(!output.status.success(), "{output:?}");+ let stderr = String::from_utf8_lossy(&output.stderr);+ assert!(+ stderr.contains("Failed to save command approval"),+ "{stderr}"+ );+ assert!(+ !stderr.contains("Commands approved"),+ "a failed write must not report success: {stderr}"+ );+}+/// Regression: `wt config approvals add` must walk project aliases as well as/// hooks. With only an alias declared (no hook commands), the alias should/// appear in the approval batch.diff --git a/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__command_errors.snap b/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__command_errors.snapindex 83ff26863..094d598f7 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__command_errors.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__command_errors.snap@@ -5,7 +5,7 @@ expression: render_cases(cases)## non-interactive[31m✗[39m [31mCannot prompt for approval in non-interactive environment[39m-[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add[24m[22m+[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add --yes[24m[22m## LLM command faileddiff --git a/tests/snapshots/integration__integration_tests__approval_ui__approval_fails_in_non_tty.snap b/tests/snapshots/integration__integration_tests__approval_ui__approval_fails_in_non_tty.snapindex 9f46d4ef7..7a3a73b59 100644--- a/tests/snapshots/integration__integration_tests__approval_ui__approval_fails_in_non_tty.snap+++ b/tests/snapshots/integration__integration_tests__approval_ui__approval_fails_in_non_tty.snap@@ -8,12 +8,23 @@ info:- test-non-ttyenv:APPDATA: "[TEST_CONFIG_HOME]"+ CLAUDE_CONFIG_DIR: "[TEST_CLAUDE_CONFIG]"CLICOLOR_FORCE: "1"COLUMNS: "500"+ GIT_ALLOW_PROTOCOL: fileGIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"+ GIT_AUTHOR_EMAIL: [email protected]+ GIT_AUTHOR_NAME: Test UserGIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"- GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"- GIT_CONFIG_SYSTEM: /dev/null+ GIT_COMMITTER_EMAIL: [email protected]+ GIT_COMMITTER_NAME: Test User+ GIT_CONFIG_COUNT: "2"+ GIT_CONFIG_GLOBAL: /nonexistent/wt/gitconfig+ GIT_CONFIG_KEY_0: user.useConfigOnly+ GIT_CONFIG_KEY_1: rerere.enabled+ GIT_CONFIG_SYSTEM: /nonexistent/wt/gitconfig+ GIT_CONFIG_VALUE_0: "true"+ GIT_CONFIG_VALUE_1: "false"GIT_TERMINAL_PROMPT: "0"HOME: "[TEST_HOME]"LANG: C@@ -36,8 +47,10 @@ info:WORKTRUNK_TEST_MOCK_CONFIG_DIR: "[TEST_MOCK_CONFIG]"WORKTRUNK_TEST_NUSHELL_ENV: "0"WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"+ WORKTRUNK_TEST_PARENT_SHELL: ""WORKTRUNK_TEST_POWERSHELL_ENV: "0"WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"+ WORKTRUNK_TEST_PROBE_TIMEOUT_MS: "60000"WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"WORKTRUNK_TEST_ZSH_INSTALLED: "0"XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"@@ -51,4 +64,4 @@ exit_code: 1[2m○[22m pre-start:[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'test command'[0m[31m✗[39m [31mCannot prompt for approval in non-interactive environment[39m-[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add[24m[22m+[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add --yes[24m[22mdiff --git a/tests/snapshots/integration__integration_tests__approval_ui__approval_mixed_approved_unapproved.snap b/tests/snapshots/integration__integration_tests__approval_ui__approval_mixed_approved_unapproved.snapindex 40c291a9a..63f614d22 100644--- a/tests/snapshots/integration__integration_tests__approval_ui__approval_mixed_approved_unapproved.snap+++ b/tests/snapshots/integration__integration_tests__approval_ui__approval_mixed_approved_unapproved.snap@@ -12,4 +12,4 @@ exit_code: 1[2m○[22m pre-start [1mthird[22m:[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Third command'[0m[31m✗[39m [31mCannot prompt for approval in non-interactive environment[39m-[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add[24m[22m+[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add --yes[24m[22mdiff --git a/tests/snapshots/integration__integration_tests__approval_ui__approval_multiple_commands.snap b/tests/snapshots/integration__integration_tests__approval_ui__approval_multiple_commands.snapindex 612802f70..57fc638c2 100644--- a/tests/snapshots/integration__integration_tests__approval_ui__approval_multiple_commands.snap+++ b/tests/snapshots/integration__integration_tests__approval_ui__approval_multiple_commands.snap@@ -16,4 +16,4 @@ exit_code: 1[2m○[22m pre-start [1mpwd[22m:[107m [0m [2m[0m[2m[34mcd[0m[2m [0m[2m[32m{{[0m[2m worktree_path [0m[2m[32m}}[0m[2m [0m[2m[36m&&[0m[2m [0m[2m[34mpwd[0m[31m✗[39m [31mCannot prompt for approval in non-interactive environment[39m-[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add[24m[22m+[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add --yes[24m[22mdiff --git a/tests/snapshots/integration__integration_tests__approval_ui__approval_named_commands.snap b/tests/snapshots/integration__integration_tests__approval_ui__approval_named_commands.snapindex 2aa9ee956..ee44ad364 100644--- a/tests/snapshots/integration__integration_tests__approval_ui__approval_named_commands.snap+++ b/tests/snapshots/integration__integration_tests__approval_ui__approval_named_commands.snap@@ -14,4 +14,4 @@ exit_code: 1[2m○[22m pre-start [1mtest[22m:[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Running tests...'[0m[31m✗[39m [31mCannot prompt for approval in non-interactive environment[39m-[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add[24m[22m+[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add --yes[24m[22mdiff --git a/tests/snapshots/integration__integration_tests__approval_ui__approval_single_command.snap b/tests/snapshots/integration__integration_tests__approval_ui__approval_single_command.snapindex 057f3a00c..59d05cff4 100644--- a/tests/snapshots/integration__integration_tests__approval_ui__approval_single_command.snap+++ b/tests/snapshots/integration__integration_tests__approval_ui__approval_single_command.snap@@ -10,4 +10,4 @@ exit_code: 1[2m○[22m pre-start:[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Worktree path: {{ worktree_path }}'[0m[31m✗[39m [31mCannot prompt for approval in non-interactive environment[39m-[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add[24m[22m+[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add --yes[24m[22mdiff --git a/tests/snapshots/integration__integration_tests__approval_ui__decline_approval_skips_only_unapproved.snap b/tests/snapshots/integration__integration_tests__approval_ui__decline_approval_skips_only_unapproved.snapindex 40c291a9a..63f614d22 100644--- a/tests/snapshots/integration__integration_tests__approval_ui__decline_approval_skips_only_unapproved.snap+++ b/tests/snapshots/integration__integration_tests__approval_ui__decline_approval_skips_only_unapproved.snap@@ -12,4 +12,4 @@ exit_code: 1[2m○[22m pre-start [1mthird[22m:[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Third command'[0m[31m✗[39m [31mCannot prompt for approval in non-interactive environment[39m-[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add[24m[22m+[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add --yes[24m[22mdiff --git a/tests/snapshots/integration__integration_tests__approval_ui__project_prefix_all_requires_approval.snap b/tests/snapshots/integration__integration_tests__approval_ui__project_prefix_all_requires_approval.snapindex c4cd11d42..df1d66cfe 100644--- a/tests/snapshots/integration__integration_tests__approval_ui__project_prefix_all_requires_approval.snap+++ b/tests/snapshots/integration__integration_tests__approval_ui__project_prefix_all_requires_approval.snap@@ -12,4 +12,4 @@ exit_code: 1[2m○[22m pre-merge [1mlint[22m:[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Running project lint'[0m[31m✗[39m [31mCannot prompt for approval in non-interactive environment[39m-[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add[24m[22m+[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add --yes[24m[22mdiff --git a/tests/snapshots/integration__integration_tests__approval_ui__project_prefix_requires_approval.snap b/tests/snapshots/integration__integration_tests__approval_ui__project_prefix_requires_approval.snapindex 81c9c7852..e244cfbea 100644--- a/tests/snapshots/integration__integration_tests__approval_ui__project_prefix_requires_approval.snap+++ b/tests/snapshots/integration__integration_tests__approval_ui__project_prefix_requires_approval.snap@@ -10,4 +10,4 @@ exit_code: 1[2m○[22m pre-merge [1mtest[22m:[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Running project test'[0m[31m✗[39m [31mCannot prompt for approval in non-interactive environment[39m-[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add[24m[22m+[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add --yes[24m[22mdiff --git a/tests/snapshots/integration__integration_tests__approval_ui__run_hook_post_merge_requires_approval.snap b/tests/snapshots/integration__integration_tests__approval_ui__run_hook_post_merge_requires_approval.snapindex de43fc567..de60e2180 100644--- a/tests/snapshots/integration__integration_tests__approval_ui__run_hook_post_merge_requires_approval.snap+++ b/tests/snapshots/integration__integration_tests__approval_ui__run_hook_post_merge_requires_approval.snap@@ -10,4 +10,4 @@ exit_code: 1[2m○[22m post-merge:[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Post-merge cleanup for {{ branch }}'[0m[31m✗[39m [31mCannot prompt for approval in non-interactive environment[39m-[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add[24m[22m+[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add --yes[24m[22mdiff --git a/tests/snapshots/integration__integration_tests__approval_ui__run_hook_pre_merge_requires_approval.snap b/tests/snapshots/integration__integration_tests__approval_ui__run_hook_pre_merge_requires_approval.snapindex a2064ced3..724d3eefe 100644--- a/tests/snapshots/integration__integration_tests__approval_ui__run_hook_pre_merge_requires_approval.snap+++ b/tests/snapshots/integration__integration_tests__approval_ui__run_hook_pre_merge_requires_approval.snap@@ -10,4 +10,4 @@ exit_code: 1[2m○[22m pre-merge:[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Running pre-merge checks on {{ branch }}'[0m[31m✗[39m [31mCannot prompt for approval in non-interactive environment[39m-[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add[24m[22m+[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add --yes[24m[22mdiff --git a/tests/snapshots/integration__integration_tests__approval_ui__yes_does_not_save_approvals_second_run.snap b/tests/snapshots/integration__integration_tests__approval_ui__yes_does_not_save_approvals_second_run.snapindex 78d440463..a883ab9da 100644--- a/tests/snapshots/integration__integration_tests__approval_ui__yes_does_not_save_approvals_second_run.snap+++ b/tests/snapshots/integration__integration_tests__approval_ui__yes_does_not_save_approvals_second_run.snap@@ -10,4 +10,4 @@ exit_code: 1[2m○[22m pre-start:[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'test command'[0m[2m [0m[2m[36m>[0m[2m output.txt[0m[31m✗[39m [31mCannot prompt for approval in non-interactive environment[39m-[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add[24m[22m+[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add --yes[24m[22mdiff --git a/tests/snapshots/integration__integration_tests__approvals__add_approvals_all_none_approved.snap b/tests/snapshots/integration__integration_tests__approvals__add_approvals_all_none_approved.snapindex 64c30b611..cfecaa6c8 100644--- a/tests/snapshots/integration__integration_tests__approvals__add_approvals_all_none_approved.snap+++ b/tests/snapshots/integration__integration_tests__approvals__add_approvals_all_none_approved.snap@@ -9,12 +9,23 @@ info:- "--all"env:APPDATA: "[TEST_CONFIG_HOME]"+ CLAUDE_CONFIG_DIR: "[TEST_CLAUDE_CONFIG]"CLICOLOR_FORCE: "1"COLUMNS: "500"+ GIT_ALLOW_PROTOCOL: fileGIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"+ GIT_AUTHOR_EMAIL: [email protected]+ GIT_AUTHOR_NAME: Test UserGIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"- GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"- GIT_CONFIG_SYSTEM: /dev/null+ GIT_COMMITTER_EMAIL: [email protected]+ GIT_COMMITTER_NAME: Test User+ GIT_CONFIG_COUNT: "2"+ GIT_CONFIG_GLOBAL: /nonexistent/wt/gitconfig+ GIT_CONFIG_KEY_0: user.useConfigOnly+ GIT_CONFIG_KEY_1: rerere.enabled+ GIT_CONFIG_SYSTEM: /nonexistent/wt/gitconfig+ GIT_CONFIG_VALUE_0: "true"+ GIT_CONFIG_VALUE_1: "false"GIT_TERMINAL_PROMPT: "0"HOME: "[TEST_HOME]"LANG: C@@ -37,8 +48,10 @@ info:WORKTRUNK_TEST_MOCK_CONFIG_DIR: "[TEST_MOCK_CONFIG]"WORKTRUNK_TEST_NUSHELL_ENV: "0"WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"+ WORKTRUNK_TEST_PARENT_SHELL: ""WORKTRUNK_TEST_POWERSHELL_ENV: "0"WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"+ WORKTRUNK_TEST_PROBE_TIMEOUT_MS: "60000"WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"WORKTRUNK_TEST_ZSH_INSTALLED: "0"XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"@@ -52,4 +65,4 @@ exit_code: 1[2m○[22m pre-start:[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'test'[0m[31m✗[39m [31mCannot prompt for approval in non-interactive environment[39m-[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add[24m[22m+[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add --yes[24m[22mdiff --git a/tests/snapshots/integration__integration_tests__approvals__add_approvals_bare_repo_config_in_primary_worktree.snap b/tests/snapshots/integration__integration_tests__approvals__add_approvals_bare_repo_config_in_primary_worktree.snapindex 308ead37c..964a96f7a 100644--- a/tests/snapshots/integration__integration_tests__approvals__add_approvals_bare_repo_config_in_primary_worktree.snap+++ b/tests/snapshots/integration__integration_tests__approvals__add_approvals_bare_repo_config_in_primary_worktree.snap@@ -9,10 +9,20 @@ info:- "--all"env:COLUMNS: "500"+ GIT_ALLOW_PROTOCOL: fileGIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"+ GIT_AUTHOR_EMAIL: [email protected]+ GIT_AUTHOR_NAME: Test UserGIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"- GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"- GIT_CONFIG_SYSTEM: /dev/null+ GIT_COMMITTER_EMAIL: [email protected]+ GIT_COMMITTER_NAME: Test User+ GIT_CONFIG_COUNT: "2"+ GIT_CONFIG_GLOBAL: /nonexistent/wt/gitconfig+ GIT_CONFIG_KEY_0: user.useConfigOnly+ GIT_CONFIG_KEY_1: rerere.enabled+ GIT_CONFIG_SYSTEM: /nonexistent/wt/gitconfig+ GIT_CONFIG_VALUE_0: "true"+ GIT_CONFIG_VALUE_1: "false"GIT_TERMINAL_PROMPT: "0"LANG: CLC_ALL: C@@ -30,8 +40,10 @@ info:WORKTRUNK_TEST_GEMINI_INSTALLED: "0"WORKTRUNK_TEST_NUSHELL_ENV: "0"WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"+ WORKTRUNK_TEST_PARENT_SHELL: ""WORKTRUNK_TEST_POWERSHELL_ENV: "0"WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"+ WORKTRUNK_TEST_PROBE_TIMEOUT_MS: "60000"WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"WORKTRUNK_TEST_ZSH_INSTALLED: "0"---@@ -44,4 +56,4 @@ exit_code: 1○ pre-start:echo 'hello'✗ Cannot prompt for approval in non-interactive environment-↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt config approvals add+↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt config approvals add --yesdiff --git a/tests/snapshots/integration__integration_tests__approvals__add_approvals_includes_aliases.snap b/tests/snapshots/integration__integration_tests__approvals__add_approvals_includes_aliases.snapindex 2e766ae26..de8be55f6 100644--- a/tests/snapshots/integration__integration_tests__approvals__add_approvals_includes_aliases.snap+++ b/tests/snapshots/integration__integration_tests__approvals__add_approvals_includes_aliases.snap@@ -8,12 +8,23 @@ info:- addenv:APPDATA: "[TEST_CONFIG_HOME]"+ CLAUDE_CONFIG_DIR: "[TEST_CLAUDE_CONFIG]"CLICOLOR_FORCE: "1"COLUMNS: "500"+ GIT_ALLOW_PROTOCOL: fileGIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"+ GIT_AUTHOR_EMAIL: [email protected]+ GIT_AUTHOR_NAME: Test UserGIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"- GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"- GIT_CONFIG_SYSTEM: /dev/null+ GIT_COMMITTER_EMAIL: [email protected]+ GIT_COMMITTER_NAME: Test User+ GIT_CONFIG_COUNT: "2"+ GIT_CONFIG_GLOBAL: /nonexistent/wt/gitconfig+ GIT_CONFIG_KEY_0: user.useConfigOnly+ GIT_CONFIG_KEY_1: rerere.enabled+ GIT_CONFIG_SYSTEM: /nonexistent/wt/gitconfig+ GIT_CONFIG_VALUE_0: "true"+ GIT_CONFIG_VALUE_1: "false"GIT_TERMINAL_PROMPT: "0"HOME: "[TEST_HOME]"LANG: C@@ -36,8 +47,10 @@ info:WORKTRUNK_TEST_MOCK_CONFIG_DIR: "[TEST_MOCK_CONFIG]"WORKTRUNK_TEST_NUSHELL_ENV: "0"WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"+ WORKTRUNK_TEST_PARENT_SHELL: ""WORKTRUNK_TEST_POWERSHELL_ENV: "0"WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"+ WORKTRUNK_TEST_PROBE_TIMEOUT_MS: "60000"WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"WORKTRUNK_TEST_ZSH_INSTALLED: "0"XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"@@ -51,4 +64,4 @@ exit_code: 1[2m○[22m alias [1mdeploy[22m:[107m [0m [2m[0m[2m[34mecho[0m[2m deploying [0m[2m[32m{{[0m[2m branch [0m[2m[32m}}[0m[31m✗[39m [31mCannot prompt for approval in non-interactive environment[39m-[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add[24m[22m+[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add --yes[24m[22mdiff --git a/tests/snapshots/integration__integration_tests__approvals__add_approvals_yes.snap b/tests/snapshots/integration__integration_tests__approvals__add_approvals_yes.snapnew file mode 100644index 000000000..357ea650d--- /dev/null+++ b/tests/snapshots/integration__integration_tests__approvals__add_approvals_yes.snap@@ -0,0 +1,69 @@+---+source: tests/integration_tests/approvals.rs+info:+ program: wt+ args:+ - config+ - approvals+ - add+ - "--yes"+ env:+ APPDATA: "[TEST_CONFIG_HOME]"+ CLAUDE_CONFIG_DIR: "[TEST_CLAUDE_CONFIG]"+ CLICOLOR_FORCE: "1"+ COLUMNS: "500"+ GIT_ALLOW_PROTOCOL: file+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"+ GIT_AUTHOR_EMAIL: [email protected]+ GIT_AUTHOR_NAME: Test User+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"+ GIT_COMMITTER_EMAIL: [email protected]+ GIT_COMMITTER_NAME: Test User+ GIT_CONFIG_COUNT: "2"+ GIT_CONFIG_GLOBAL: /nonexistent/wt/gitconfig+ GIT_CONFIG_KEY_0: user.useConfigOnly+ GIT_CONFIG_KEY_1: rerere.enabled+ GIT_CONFIG_SYSTEM: /nonexistent/wt/gitconfig+ GIT_CONFIG_VALUE_0: "true"+ GIT_CONFIG_VALUE_1: "false"+ GIT_TERMINAL_PROMPT: "0"+ HOME: "[TEST_HOME]"+ LANG: C+ LC_ALL: C+ LLVM_PROFILE_FILE: "[LLVM_PROFILE_FILE]"+ OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"+ PATH: "[PATH]"+ TERM: alacritty+ USERPROFILE: "[TEST_HOME]"+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+ WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"+ WORKTRUNK_TEST_BASH_INSTALLED: "0"+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"+ WORKTRUNK_TEST_CODEX_INSTALLED: "0"+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"+ WORKTRUNK_TEST_EPOCH: "1735776000"+ WORKTRUNK_TEST_FISH_INSTALLED: "0"+ WORKTRUNK_TEST_GEMINI_INSTALLED: "0"+ WORKTRUNK_TEST_MOCK_CONFIG_DIR: "[TEST_MOCK_CONFIG]"+ WORKTRUNK_TEST_NUSHELL_ENV: "0"+ WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"+ WORKTRUNK_TEST_PARENT_SHELL: ""+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"+ WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"+ WORKTRUNK_TEST_PROBE_TIMEOUT_MS: "60000"+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"+ WORKTRUNK_TEST_ZSH_INSTALLED: "0"+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"+---+success: true+exit_code: 0+----- stdout -----++----- stderr -----+[33m▲[39m [33mApproving [1m2[22m commands for [1mrepo[22m (--yes):[39m+[2m○[22m pre-merge:+[107m [0m [2m[0m[2m[34mcargo[0m[2m test[0m+[2m○[22m alias [1mdeploy[22m:+[107m [0m [2m[0m[2m[34mecho[0m[2m deploying[0m+[32m✓[39m [32mCommands approved & saved to config[39mdiff --git a/tests/snapshots/integration__integration_tests__help__help_config_approvals.snap b/tests/snapshots/integration__integration_tests__help__help_config_approvals.snapindex 2ec6232ff..aa57b17fd 100644--- a/tests/snapshots/integration__integration_tests__help__help_config_approvals.snap+++ b/tests/snapshots/integration__integration_tests__help__help_config_approvals.snap@@ -36,6 +36,7 @@ info:WORKTRUNK_TEST_PARENT_SHELL: ""WORKTRUNK_TEST_POWERSHELL_ENV: "0"WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"+ WORKTRUNK_TEST_PROBE_TIMEOUT_MS: "60000"WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"WORKTRUNK_TEST_ZSH_INSTALLED: "0"---@@ -81,6 +82,9 @@ List commands and their approval status for current project:Pre-approve all hook and alias commands for current project:[107m [0m [2m[0m[2m[34mwt[0m[2m config approvals add[0m+Pre-approve without prompting, for a container or CI job:+[107m [0m [2m[0m[2m[34mwt[0m[2m config approvals add [0m[2m[36m--yes[0m+Clear approvals for current project:[107m [0m [2m[0m[2m[34mwt[0m[2m config approvals clear[0m@@ -95,7 +99,9 @@ Check whether an unattended run would stop for approval:[1m[32mHow approvals work[0m-Approved commands are saved to [2m~/.config/worktrunk/approvals.toml[0m. Re-approval is required when the command template changes or the project moves. Use [2m--yes[0m to bypass prompts in CI.+Approved commands are saved to [2m~/.config/worktrunk/approvals.toml[0m. Re-approval is required when the command template changes or the project moves.++[2m--yes[0m bypasses the prompt, and what it leaves behind depends on the command it is passed to. On a command that runs project commands it grants consent for that run alone and records nothing, so the next run asks again. On [2mwt config approvals add[0m the record is the whole point, so the approvals are written — which is how an unattended environment pre-approves a project it has just cloned.[1m[32mReading approval state[0mdiff --git a/tests/snapshots/integration__integration_tests__help__help_config_approvals_add.snap b/tests/snapshots/integration__integration_tests__help__help_config_approvals_add.snapindex 84344925a..7e0571d7b 100644--- a/tests/snapshots/integration__integration_tests__help__help_config_approvals_add.snap+++ b/tests/snapshots/integration__integration_tests__help__help_config_approvals_add.snap@@ -10,6 +10,14 @@ info:env:CLICOLOR_FORCE: "1"COLUMNS: "500"+ GIT_ALLOW_PROTOCOL: file+ GIT_CONFIG_COUNT: "2"+ GIT_CONFIG_GLOBAL: /nonexistent/wt/gitconfig+ GIT_CONFIG_KEY_0: user.useConfigOnly+ GIT_CONFIG_KEY_1: rerere.enabled+ GIT_CONFIG_SYSTEM: /nonexistent/wt/gitconfig+ GIT_CONFIG_VALUE_0: "true"+ GIT_CONFIG_VALUE_1: "false"LANG: CLC_ALL: CLLVM_PROFILE_FILE: "[LLVM_PROFILE_FILE]"@@ -26,8 +34,10 @@ info:WORKTRUNK_TEST_GEMINI_INSTALLED: "0"WORKTRUNK_TEST_NUSHELL_ENV: "0"WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"+ WORKTRUNK_TEST_PARENT_SHELL: ""WORKTRUNK_TEST_POWERSHELL_ENV: "0"WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"+ WORKTRUNK_TEST_PROBE_TIMEOUT_MS: "60000"WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"WORKTRUNK_TEST_ZSH_INSTALLED: "0"---@@ -66,4 +76,10 @@ Prompts for approval of all project commands and saves them to approvals.toml.By default, shows only unapproved commands. Use [2m--all[0m to review all commandsincluding previously approved ones.+[2m--yes[0m writes the approvals without prompting, which is how a container or CI job pre-approves a project it has just cloned. It trusts every command the project config declares, including one whose template changed since an earlier approval. A caller that wants to look before granting them can list those first — see Reading approval state.++[1m[32mExamples[0m++[107m [0m [2m[0m[2m[34mwt[0m[2m config approvals add [0m[2m[36m--yes[0m+----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__step_alias__alias_approval_decline.snap b/tests/snapshots/integration__integration_tests__step_alias__alias_approval_decline.snapindex 27bb66a4f..1565dcaef 100644--- a/tests/snapshots/integration__integration_tests__step_alias__alias_approval_decline.snap+++ b/tests/snapshots/integration__integration_tests__step_alias__alias_approval_decline.snap@@ -10,4 +10,4 @@ exit_code: 1[2m○[22m alias [1mdeploy[22m:[107m [0m [2m[0m[2m[34mecho[0m[2m deploying[0m[31m✗[39m [31mCannot prompt for approval in non-interactive environment[39m-[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add[24m[22m+[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add --yes[24m[22mdiff --git a/tests/snapshots/integration__integration_tests__step_alias__alias_approval_project_config_prompts.snap b/tests/snapshots/integration__integration_tests__step_alias__alias_approval_project_config_prompts.snapindex 216872ec8..a6e3627d2 100644--- a/tests/snapshots/integration__integration_tests__step_alias__alias_approval_project_config_prompts.snap+++ b/tests/snapshots/integration__integration_tests__step_alias__alias_approval_project_config_prompts.snap@@ -7,12 +7,23 @@ info:- deployenv:APPDATA: "[TEST_CONFIG_HOME]"+ CLAUDE_CONFIG_DIR: "[TEST_CLAUDE_CONFIG]"CLICOLOR_FORCE: "1"COLUMNS: "500"+ GIT_ALLOW_PROTOCOL: fileGIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"+ GIT_AUTHOR_EMAIL: [email protected]+ GIT_AUTHOR_NAME: Test UserGIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"- GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"- GIT_CONFIG_SYSTEM: /dev/null+ GIT_COMMITTER_EMAIL: [email protected]+ GIT_COMMITTER_NAME: Test User+ GIT_CONFIG_COUNT: "2"+ GIT_CONFIG_GLOBAL: /nonexistent/wt/gitconfig+ GIT_CONFIG_KEY_0: user.useConfigOnly+ GIT_CONFIG_KEY_1: rerere.enabled+ GIT_CONFIG_SYSTEM: /nonexistent/wt/gitconfig+ GIT_CONFIG_VALUE_0: "true"+ GIT_CONFIG_VALUE_1: "false"GIT_TERMINAL_PROMPT: "0"HOME: "[TEST_HOME]"LANG: C@@ -35,8 +46,10 @@ info:WORKTRUNK_TEST_MOCK_CONFIG_DIR: "[TEST_MOCK_CONFIG]"WORKTRUNK_TEST_NUSHELL_ENV: "0"WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"+ WORKTRUNK_TEST_PARENT_SHELL: ""WORKTRUNK_TEST_POWERSHELL_ENV: "0"WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"+ WORKTRUNK_TEST_PROBE_TIMEOUT_MS: "60000"WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"WORKTRUNK_TEST_ZSH_INSTALLED: "0"XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"@@ -50,4 +63,4 @@ exit_code: 1[2m○[22m alias [1mdeploy[22m:[107m [0m [2m[0m[2m[34mecho[0m[2m deploying [0m[2m[32m{{[0m[2m branch [0m[2m[32m}}[0m[31m✗[39m [31mCannot prompt for approval in non-interactive environment[39m-[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add[24m[22m+[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add --yes[24m[22mdiff --git a/tests/snapshots/integration__integration_tests__step_alias__alias_approval_yes_second_run_prompts.snap b/tests/snapshots/integration__integration_tests__step_alias__alias_approval_yes_second_run_prompts.snapindex 5e2efb8d3..220471c35 100644--- a/tests/snapshots/integration__integration_tests__step_alias__alias_approval_yes_second_run_prompts.snap+++ b/tests/snapshots/integration__integration_tests__step_alias__alias_approval_yes_second_run_prompts.snap@@ -7,12 +7,23 @@ info:- deployenv:APPDATA: "[TEST_CONFIG_HOME]"+ CLAUDE_CONFIG_DIR: "[TEST_CLAUDE_CONFIG]"CLICOLOR_FORCE: "1"COLUMNS: "500"+ GIT_ALLOW_PROTOCOL: fileGIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"+ GIT_AUTHOR_EMAIL: [email protected]+ GIT_AUTHOR_NAME: Test UserGIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"- GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"- GIT_CONFIG_SYSTEM: /dev/null+ GIT_COMMITTER_EMAIL: [email protected]+ GIT_COMMITTER_NAME: Test User+ GIT_CONFIG_COUNT: "2"+ GIT_CONFIG_GLOBAL: /nonexistent/wt/gitconfig+ GIT_CONFIG_KEY_0: user.useConfigOnly+ GIT_CONFIG_KEY_1: rerere.enabled+ GIT_CONFIG_SYSTEM: /nonexistent/wt/gitconfig+ GIT_CONFIG_VALUE_0: "true"+ GIT_CONFIG_VALUE_1: "false"GIT_TERMINAL_PROMPT: "0"HOME: "[TEST_HOME]"LANG: C@@ -35,8 +46,10 @@ info:WORKTRUNK_TEST_MOCK_CONFIG_DIR: "[TEST_MOCK_CONFIG]"WORKTRUNK_TEST_NUSHELL_ENV: "0"WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"+ WORKTRUNK_TEST_PARENT_SHELL: ""WORKTRUNK_TEST_POWERSHELL_ENV: "0"WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"+ WORKTRUNK_TEST_PROBE_TIMEOUT_MS: "60000"WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"WORKTRUNK_TEST_ZSH_INSTALLED: "0"XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"@@ -50,4 +63,4 @@ exit_code: 1[2m○[22m alias [1mdeploy[22m:[107m [0m [2m[0m[2m[34mecho[0m[2m deploying[0m[31m✗[39m [31mCannot prompt for approval in non-interactive environment[39m-[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add[24m[22m+[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add --yes[24m[22mdiff --git a/tests/snapshots/integration__integration_tests__step_alias__alias_help_flag_after_double_dash_forwards.snap b/tests/snapshots/integration__integration_tests__step_alias__alias_help_flag_after_double_dash_forwards.snapindex 3e1485d3b..69005b322 100644--- a/tests/snapshots/integration__integration_tests__step_alias__alias_help_flag_after_double_dash_forwards.snap+++ b/tests/snapshots/integration__integration_tests__step_alias__alias_help_flag_after_double_dash_forwards.snap@@ -8,12 +8,23 @@ info:- "--help"env:APPDATA: "[TEST_CONFIG_HOME]"+ CLAUDE_CONFIG_DIR: "[TEST_CLAUDE_CONFIG]"CLICOLOR_FORCE: "1"COLUMNS: "500"+ GIT_ALLOW_PROTOCOL: fileGIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"+ GIT_AUTHOR_EMAIL: [email protected]+ GIT_AUTHOR_NAME: Test UserGIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"- GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"- GIT_CONFIG_SYSTEM: /dev/null+ GIT_COMMITTER_EMAIL: [email protected]+ GIT_COMMITTER_NAME: Test User+ GIT_CONFIG_COUNT: "2"+ GIT_CONFIG_GLOBAL: /nonexistent/wt/gitconfig+ GIT_CONFIG_KEY_0: user.useConfigOnly+ GIT_CONFIG_KEY_1: rerere.enabled+ GIT_CONFIG_SYSTEM: /nonexistent/wt/gitconfig+ GIT_CONFIG_VALUE_0: "true"+ GIT_CONFIG_VALUE_1: "false"GIT_TERMINAL_PROMPT: "0"HOME: "[TEST_HOME]"LANG: C@@ -36,8 +47,10 @@ info:WORKTRUNK_TEST_MOCK_CONFIG_DIR: "[TEST_MOCK_CONFIG]"WORKTRUNK_TEST_NUSHELL_ENV: "0"WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"+ WORKTRUNK_TEST_PARENT_SHELL: ""WORKTRUNK_TEST_POWERSHELL_ENV: "0"WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"+ WORKTRUNK_TEST_PROBE_TIMEOUT_MS: "60000"WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"WORKTRUNK_TEST_ZSH_INSTALLED: "0"XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"@@ -51,4 +64,4 @@ exit_code: 1[2m○[22m alias [1mdeploy[22m:[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m{{[0m[2m args [0m[2m[32m}}[0m[31m✗[39m [31mCannot prompt for approval in non-interactive environment[39m-[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add[24m[22m+[2m↳[22m [2mTo skip prompts in CI/CD, add [4m--yes[24m; to pre-approve commands, run [4mwt config approvals add --yes[24m[22m