Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

feat(cli): move approvals subcommand from hook to config (#2282)

Maximilian Roos64e1b4efb92c
diff --git a/docs/content/config.md b/docs/content/config.md
index f27be8c9f..e734acea7 100644
--- a/docs/content/config.md
+++ b/docs/content/config.md
@@ -473,12 +473,13 @@ Includes shell integration, hooks, and saved state.
Usage: <b><span class=c>wt config</span></b> <span class=c>[OPTIONS]</span> <span class=c>&lt;COMMAND&gt;</span>
<b><span class=g>Commands:</span></b>
- <b><span class=c>shell</span></b> Shell integration setup
- <b><span class=c>create</span></b> Create configuration file
- <b><span class=c>show</span></b> Show configuration files &amp; locations
- <b><span class=c>update</span></b> Update deprecated config settings
- <b><span class=c>plugins</span></b> Plugin management
- <b><span class=c>state</span></b> Manage internal data and cache
+ <b><span class=c>shell</span></b> Shell integration setup
+ <b><span class=c>create</span></b> Create configuration file
+ <b><span class=c>show</span></b> Show configuration files &amp; locations
+ <b><span class=c>update</span></b> Update deprecated config settings
+ <b><span class=c>approvals</span></b> Manage command approvals
+ <b><span class=c>plugins</span></b> Plugin management
+ <b><span class=c>state</span></b> Manage internal data and cache
<b><span class=g>Options:</span></b>
<b><span class=c>-h</span></b>, <b><span class=c>--help</span></b>
@@ -554,6 +555,54 @@ Usage: <b><span class=c>wt config show</span></b> <span class=c>[OPTIONS]</span>
+ trace.log/output.log under .git/wt/logs/)
{% end %}
+## wt config approvals
+
+Manage command approvals.
+
+Project hooks and project aliases prompt for approval on first run to prevent untrusted projects from running arbitrary commands. Approvals from both flows are stored together.
+
+### Examples
+
+Pre-approve all hook and alias commands for current project:
+{{ terminal(cmd="wt config approvals add") }}
+
+Clear approvals for current project:
+{{ terminal(cmd="wt config approvals clear") }}
+
+Clear global approvals:
+{{ terminal(cmd="wt config approvals clear --global") }}
+
+### 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.
+
+### Command reference
+
+{% terminal() %}
+wt config approvals - Manage command approvals
+
+Usage: <b><span class=c>wt config approvals</span></b> <span class=c>[OPTIONS]</span> <span class=c>&lt;COMMAND&gt;</span>
+
+<b><span class=g>Commands:</span></b>
+ <b><span class=c>add</span></b> Store approvals in approvals.toml
+ <b><span class=c>clear</span></b> Clear approved commands from approvals.toml
+
+<b><span class=g>Options:</span></b>
+ <b><span class=c>-h</span></b>, <b><span class=c>--help</span></b>
+ Print help (see a summary with &#39;-h&#39;)
+
+<b><span class=g>Global Options:</span></b>
+ <b><span class=c>-C</span></b><span class=c> &lt;path&gt;</span>
+ Working directory for this command
+
+ <b><span class=c>--config</span></b><span class=c> &lt;path&gt;</span>
+ User config file path
+
+ <b><span class=c>-v</span></b>, <b><span class=c>--verbose</span></b><span class=c>...</span>
+ Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
+ + trace.log/output.log under .git/wt/logs/)
+{% end %}
+
## wt config state
Manage internal data and cache.
diff --git a/docs/content/extending.md b/docs/content/extending.md
index 2b8c72e9a..b6dc70242 100644
--- a/docs/content/extending.md
+++ b/docs/content/extending.md
@@ -42,7 +42,7 @@ Hooks are shell commands that run at key points in the worktree lifecycle. Ten h
Hooks live in two places:
- **User config** (`~/.config/worktrunk/config.toml`) — personal, applies everywhere, trusted
-- **Project config** (`.config/wt.toml`) — shared with the team, requires [approval](@/hook.md#wt-hook-approvals) on first run
+- **Project config** (`.config/wt.toml`) — shared with the team, requires [approval](@/config.md#wt-config-approvals) on first run
Three formats, from simplest to most expressive.
diff --git a/docs/content/faq.md b/docs/content/faq.md
index 5b2d1d356..dc653f8b1 100644
--- a/docs/content/faq.md
+++ b/docs/content/faq.md
@@ -88,7 +88,7 @@ Created by `wt switch <branch>` when switching to a branch that doesn't have a w
| File | Created by | Purpose |
|------|------------|---------|
| `~/.config/worktrunk/config.toml` | `wt config create` | User preferences |
-| `~/.config/worktrunk/approvals.toml` | Approving project commands | Approved hook commands |
+| `~/.config/worktrunk/approvals.toml` | Approving project commands | Approved hook and alias commands |
| `.config/wt.toml` | `wt config create --project` | Project hooks (checked into repo) |
User config location: `$XDG_CONFIG_HOME/worktrunk/` (or `~/.config/worktrunk/`) on Linux/macOS, `%APPDATA%\worktrunk\` on Windows.
@@ -176,7 +176,7 @@ Worktrunk runs `git` commands internally and optionally runs `gh` (GitHub) or `g
3. **LLM commands** (`~/.config/worktrunk/config.toml`) — Commit message generation and [branch summaries](@/llm-commits.md#branch-summaries)
4. **--execute flag** — Explicitly provided commands
-User hooks don't require approval (you defined them). Commands from project hooks require approval on first run. Approved commands are saved to the approvals file (`approvals.toml`). If a command changes, Worktrunk requires new approval.
+User hooks and user aliases don't require approval (you defined them). Commands from project hooks and project aliases require approval on first run. Approved commands are saved to the approvals file (`approvals.toml`). If a command changes, Worktrunk requires new approval.
### Example approval prompt
diff --git a/docs/content/hook.md b/docs/content/hook.md
index 716bec104..2738c574f 100644
--- a/docs/content/hook.md
+++ b/docs/content/hook.md
@@ -64,7 +64,7 @@ Project commands require approval on first run:
- Use `--yes` to bypass prompts — useful for CI and automation
- Use `--no-hooks` to skip hooks
-Manage approvals with `wt hook approvals add` and `wt hook approvals clear`.
+Manage approvals with `wt config approvals add` and `wt config approvals clear`.
# Configuration
@@ -462,7 +462,7 @@ remove-db = "docker stop {{ repo }}-{{ branch | sanitize }}-postgres 2>/dev/null
- [`wt merge`](@/merge.md) — Runs hooks automatically during merge
- [`wt switch`](@/switch.md) — Runs pre-start/post-start hooks on `--create`
-- [`wt config`](@/config.md) — Manage hook approvals
+- [`wt config approvals`](@/config.md#wt-config-approvals) — Manage approvals
- [`wt config state logs`](@/config.md#wt-config-state-logs) — Access background hook logs
## Command reference
@@ -484,57 +484,6 @@ Usage: <b><span class=c>wt hook</span></b> <span class=c>[OPTIONS]</span> <span
<b><span class=c>post-merge</span></b> Run post-merge hooks
<b><span class=c>pre-remove</span></b> Run pre-remove hooks
<b><span class=c>post-remove</span></b> Run post-remove hooks
- <b><span class=c>approvals</span></b> Manage command approvals
-
-<b><span class=g>Options:</span></b>
- <b><span class=c>-h</span></b>, <b><span class=c>--help</span></b>
- Print help (see a summary with &#39;-h&#39;)
-
-<b><span class=g>Global Options:</span></b>
- <b><span class=c>-C</span></b><span class=c> &lt;path&gt;</span>
- Working directory for this command
-
- <b><span class=c>--config</span></b><span class=c> &lt;path&gt;</span>
- User config file path
-
- <b><span class=c>-v</span></b>, <b><span class=c>--verbose</span></b><span class=c>...</span>
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
-{% end %}
-
-# Subcommands
-
-## wt hook approvals
-
-Manage command approvals.
-
-Project hooks require approval on first run to prevent untrusted projects from running arbitrary commands.
-
-### Examples
-
-Pre-approve all commands for current project:
-{{ terminal(cmd="wt hook approvals add") }}
-
-Clear approvals for current project:
-{{ terminal(cmd="wt hook approvals clear") }}
-
-Clear global approvals:
-{{ terminal(cmd="wt hook approvals clear --global") }}
-
-### 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.
-
-### Command reference
-
-{% terminal() %}
-wt hook approvals - Manage command approvals
-
-Usage: <b><span class=c>wt hook approvals</span></b> <span class=c>[OPTIONS]</span> <span class=c>&lt;COMMAND&gt;</span>
-
-<b><span class=g>Commands:</span></b>
- <b><span class=c>add</span></b> Store approvals in approvals.toml
- <b><span class=c>clear</span></b> Clear approved commands from approvals.toml
<b><span class=g>Options:</span></b>
<b><span class=c>-h</span></b>, <b><span class=c>--help</span></b>
diff --git a/skills/worktrunk/reference/config.md b/skills/worktrunk/reference/config.md
index 38763f470..9573ae4e7 100644
--- a/skills/worktrunk/reference/config.md
+++ b/skills/worktrunk/reference/config.md
@@ -476,12 +476,13 @@ Includes shell integration, hooks, and saved state.
Usage: wt config [OPTIONS] <COMMAND>
Commands:
- shell Shell integration setup
- create Create configuration file
- show Show configuration files & locations
- update Update deprecated config settings
- plugins Plugin management
- state Manage internal data and cache
+ shell Shell integration setup
+ create Create configuration file
+ show Show configuration files & locations
+ update Update deprecated config settings
+ approvals Manage command approvals
+ plugins Plugin management
+ state Manage internal data and cache
Options:
-h, --help
@@ -559,6 +560,60 @@ Global Options:
+ trace.log/output.log under .git/wt/logs/)
```
+## wt config approvals
+
+Manage command approvals.
+
+Project hooks and project aliases prompt for approval on first run to prevent untrusted projects from running arbitrary commands. Approvals from both flows are stored together.
+
+### Examples
+
+Pre-approve all hook and alias commands for current project:
+```bash
+$ wt config approvals add
+```
+
+Clear approvals for current project:
+```bash
+$ wt config approvals clear
+```
+
+Clear global approvals:
+```bash
+$ wt config approvals clear --global
+```
+
+### 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.
+
+### Command reference
+
+```
+wt config approvals - Manage command approvals
+
+Usage: wt config approvals [OPTIONS] <COMMAND>
+
+Commands:
+ add Store approvals in approvals.toml
+ clear Clear approved commands from approvals.toml
+
+Options:
+ -h, --help
+ Print help (see a summary with '-h')
+
+Global Options:
+ -C <path>
+ Working directory for this command
+
+ --config <path>
+ User config file path
+
+ -v, --verbose...
+ Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
+ + trace.log/output.log under .git/wt/logs/)
+```
+
## wt config state
Manage internal data and cache.
diff --git a/skills/worktrunk/reference/extending.md b/skills/worktrunk/reference/extending.md
index 44079be5f..fddd98535 100644
--- a/skills/worktrunk/reference/extending.md
+++ b/skills/worktrunk/reference/extending.md
@@ -35,7 +35,7 @@ Hooks are shell commands that run at key points in the worktree lifecycle. Ten h
Hooks live in two places:
- **User config** (`~/.config/worktrunk/config.toml`) — personal, applies everywhere, trusted
-- **Project config** (`.config/wt.toml`) — shared with the team, requires [approval](https://worktrunk.dev/hook/#wt-hook-approvals) on first run
+- **Project config** (`.config/wt.toml`) — shared with the team, requires [approval](https://worktrunk.dev/config/#wt-config-approvals) on first run
Three formats, from simplest to most expressive.
diff --git a/skills/worktrunk/reference/faq.md b/skills/worktrunk/reference/faq.md
index 2a6cdc0fa..5a6dd1e77 100644
--- a/skills/worktrunk/reference/faq.md
+++ b/skills/worktrunk/reference/faq.md
@@ -81,7 +81,7 @@ Created by `wt switch <branch>` when switching to a branch that doesn't have a w
| File | Created by | Purpose |
|------|------------|---------|
| `~/.config/worktrunk/config.toml` | `wt config create` | User preferences |
-| `~/.config/worktrunk/approvals.toml` | Approving project commands | Approved hook commands |
+| `~/.config/worktrunk/approvals.toml` | Approving project commands | Approved hook and alias commands |
| `.config/wt.toml` | `wt config create --project` | Project hooks (checked into repo) |
User config location: `$XDG_CONFIG_HOME/worktrunk/` (or `~/.config/worktrunk/`) on Linux/macOS, `%APPDATA%\worktrunk\` on Windows.
@@ -171,7 +171,7 @@ Worktrunk runs `git` commands internally and optionally runs `gh` (GitHub) or `g
3. **LLM commands** (`~/.config/worktrunk/config.toml`) — Commit message generation and [branch summaries](https://worktrunk.dev/llm-commits/#branch-summaries)
4. **--execute flag** — Explicitly provided commands
-User hooks don't require approval (you defined them). Commands from project hooks require approval on first run. Approved commands are saved to the approvals file (`approvals.toml`). If a command changes, Worktrunk requires new approval.
+User hooks and user aliases don't require approval (you defined them). Commands from project hooks and project aliases require approval on first run. Approved commands are saved to the approvals file (`approvals.toml`). If a command changes, Worktrunk requires new approval.
### Example approval prompt
diff --git a/skills/worktrunk/reference/hook.md b/skills/worktrunk/reference/hook.md
index e3791180b..69cfe7d09 100644
--- a/skills/worktrunk/reference/hook.md
+++ b/skills/worktrunk/reference/hook.md
@@ -55,7 +55,7 @@ Project commands require approval on first run:
- Use `--yes` to bypass prompts — useful for CI and automation
- Use `--no-hooks` to skip hooks
-Manage approvals with `wt hook approvals add` and `wt hook approvals clear`.
+Manage approvals with `wt config approvals add` and `wt config approvals clear`.
# Configuration
@@ -477,63 +477,6 @@ Commands:
post-merge Run post-merge hooks
pre-remove Run pre-remove hooks
post-remove Run post-remove hooks
- approvals Manage command approvals
-
-Options:
- -h, --help
- Print help (see a summary with '-h')
-
-Global Options:
- -C <path>
- Working directory for this command
-
- --config <path>
- User config file path
-
- -v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
-```
-
-# Subcommands
-
-## wt hook approvals
-
-Manage command approvals.
-
-Project hooks require approval on first run to prevent untrusted projects from running arbitrary commands.
-
-### Examples
-
-Pre-approve all commands for current project:
-```bash
-$ wt hook approvals add
-```
-
-Clear approvals for current project:
-```bash
-$ wt hook approvals clear
-```
-
-Clear global approvals:
-```bash
-$ wt hook approvals clear --global
-```
-
-### 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.
-
-### Command reference
-
-```
-wt hook approvals - Manage command approvals
-
-Usage: wt hook approvals [OPTIONS] <COMMAND>
-
-Commands:
- add Store approvals in approvals.toml
- clear Clear approved commands from approvals.toml
Options:
-h, --help
diff --git a/src/cli/config.rs b/src/cli/config.rs
index 34d0947f5..4c8bc7738 100644
--- a/src/cli/config.rs
+++ b/src/cli/config.rs
@@ -336,8 +336,9 @@ Skips gracefully if the statusline is already configured."#
}
// Ordering: user journey — shell (install integration), create (bootstrap
-// config files), show (inspect), update (migrate deprecations), plugins
-// (optional add-ons), state (advanced diagnostics).
+// config files), show (inspect), update (migrate deprecations), approvals
+// (security policy for project commands), plugins (optional add-ons), state
+// (advanced diagnostics).
#[derive(Subcommand)]
pub enum ConfigCommand {
/// Shell integration setup
@@ -431,6 +432,36 @@ $ wt config update --print
print: bool,
},
+ /// Manage command approvals
+ #[command(
+ after_long_help = r#"Project hooks and project aliases prompt for approval on first run to prevent untrusted projects from running arbitrary commands. Approvals from both flows are stored together.
+
+## Examples
+
+Pre-approve all hook and alias commands for current project:
+```console
+$ wt config approvals add
+```
+
+Clear approvals for current project:
+```console
+$ wt config approvals clear
+```
+
+Clear global approvals:
+```console
+$ wt config approvals clear --global
+```
+
+## 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."#
+ )]
+ Approvals {
+ #[command(subcommand)]
+ action: ApprovalsCommand,
+ },
+
/// Plugin management
#[command(
after_long_help = r#"Install and manage Worktrunk plugins for AI coding tools.
diff --git a/src/cli/hook.rs b/src/cli/hook.rs
index d4e6f3f17..f7fa5f8ab 100644
--- a/src/cli/hook.rs
+++ b/src/cli/hook.rs
@@ -6,8 +6,9 @@ use super::config::ApprovalsCommand;
/// Hook subcommands that accept `--var KEY=VALUE` (and the `--KEY=VALUE` shorthand).
///
-/// Excludes `show`, `approvals`, and `run-pipeline`, which don't expand
-/// template variables. `post-create` is the deprecated alias for `pre-start`.
+/// Excludes `show`, `run-pipeline`, and the deprecated `approvals` (now under
+/// `wt config approvals`), which don't expand template variables. `post-create`
+/// is the deprecated alias for `pre-start`.
const HOOK_SUBCOMMANDS_WITH_VARS: &[&str] = &[
"pre-switch",
"post-switch",
@@ -376,8 +377,7 @@ mod tests {
// Ordering: worktree lifecycle phases (switch → start → commit → merge →
// remove), with each phase's `pre-` immediately before its `post-`. `show`
-// first (read-only introspection), `approvals` last (administration). Hidden
-// commands last.
+// first (read-only introspection). Hidden commands last.
/// Run configured hooks
#[derive(Subcommand)]
pub enum HookCommand {
@@ -653,31 +653,8 @@ pub enum HookCommand {
#[command(hide = true, name = "run-pipeline")]
RunPipeline,
- /// Manage command approvals
- #[command(
- after_long_help = r#"Project hooks require approval on first run to prevent untrusted projects from running arbitrary commands.
-
-## Examples
-
-Pre-approve all commands for current project:
-```console
-$ wt hook approvals add
-```
-
-Clear approvals for current project:
-```console
-$ wt hook approvals clear
-```
-
-Clear global approvals:
-```console
-$ wt hook approvals clear --global
-```
-
-## 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."#
- )]
+ /// Deprecated: use `wt config approvals` instead
+ #[command(hide = true)]
Approvals {
#[command(subcommand)]
action: ApprovalsCommand,
diff --git a/src/cli/mod.rs b/src/cli/mod.rs
index 8ae32a3dc..7552d6dc3 100644
--- a/src/cli/mod.rs
+++ b/src/cli/mod.rs
@@ -1203,7 +1203,7 @@ Project commands require approval on first run:
- Use `--yes` to bypass prompts — useful for CI and automation
- Use `--no-hooks` to skip hooks
-Manage approvals with `wt hook approvals add` and `wt hook approvals clear`.
+Manage approvals with `wt config approvals add` and `wt config approvals clear`.
# Configuration
@@ -1610,10 +1610,8 @@ remove-db = "docker stop {{ repo }}-{{ branch | sanitize }}-postgres 2>/dev/null
- [`wt merge`](@/merge.md) — Runs hooks automatically during merge
- [`wt switch`](@/switch.md) — Runs pre-start/post-start hooks on `--create`
-- [`wt config`](@/config.md) — Manage hook approvals
+- [`wt config approvals`](@/config.md#wt-config-approvals) — Manage approvals
- [`wt config state logs`](@/config.md#wt-config-state-logs) — Access background hook logs
-
-<!-- subdoc: approvals -->
"#
)]
Hook {
@@ -2088,6 +2086,7 @@ $ WORKTRUNK_COMMIT__GENERATION__COMMAND="echo 'test: automated commit'" wt merge
| `NO_COLOR` | Disable colored output ([standard](https://no-color.org/)) |
| `CLICOLOR_FORCE` | Force colored output even when not a TTY |
<!-- subdoc: show -->
+<!-- subdoc: approvals -->
<!-- subdoc: state -->"#)]
Config {
#[command(subcommand)]
diff --git a/src/commands/hook_commands.rs b/src/commands/hook_commands.rs
index b1715ff0b..cf47aba64 100644
--- a/src/commands/hook_commands.rs
+++ b/src/commands/hook_commands.rs
@@ -32,7 +32,7 @@ use super::hooks::{
HookCommandSpec, check_name_filter_matched, count_sourced_commands, prepare_background_hooks,
prepare_sourced_steps, run_hook_with_filter, spawn_hook_pipeline,
};
-use super::project_config::collect_commands_for_hooks;
+use super::project_config::{collect_commands_for_aliases, collect_commands_for_hooks};
fn run_filtered_hook(
ctx: &CommandContext,
@@ -388,7 +388,7 @@ pub fn run_hook(
}
}
-/// Handle `wt hook approvals add` command - approve all commands in the project
+/// Handle `wt config approvals add` command - approve all hook and alias commands in the project
pub fn add_approvals(show_all: bool) -> anyhow::Result<()> {
use super::command_approval::approve_command_batch;
@@ -404,9 +404,11 @@ pub fn add_approvals(show_all: bool) -> anyhow::Result<()> {
.load_project_config()?
.ok_or(GitError::ProjectConfigNotFound { config_path })?;
- // Collect all commands from the project config
+ // Collect all commands from the project config: hooks first (lifecycle order),
+ // then aliases (alphabetical via BTreeMap).
let all_hooks: Vec<_> = HookType::iter().collect();
- let commands = collect_commands_for_hooks(&project_config, &all_hooks);
+ let mut commands = collect_commands_for_hooks(&project_config, &all_hooks);
+ commands.extend(collect_commands_for_aliases(&project_config));
if commands.is_empty() {
eprintln!("{}", info_message("No commands configured in project"));
@@ -447,7 +449,7 @@ pub fn add_approvals(show_all: bool) -> anyhow::Result<()> {
Ok(())
}
-/// Handle `wt hook approvals clear` command - clear approved commands
+/// Handle `wt config approvals clear` command - clear approved commands
pub fn clear_approvals(global: bool) -> anyhow::Result<()> {
let mut approvals = Approvals::load().context("Failed to load approvals")?;
diff --git a/src/commands/project_config.rs b/src/commands/project_config.rs
index 0e6fd27c1..6a9b9c925 100644
--- a/src/commands/project_config.rs
+++ b/src/commands/project_config.rs
@@ -43,6 +43,26 @@ pub fn collect_commands_for_hooks(
commands
}
+/// Collect commands for every project-config alias, in `BTreeMap` (alphabetical) order.
+///
+/// Mirrors `approve_alias_commands` in `command_approval.rs`: unnamed steps within
+/// an alias inherit the alias name, so users see a stable label in approval prompts.
+pub fn collect_commands_for_aliases(project_config: &ProjectConfig) -> Vec<ApprovableCommand> {
+ project_config
+ .aliases
+ .iter()
+ .flat_map(|(alias_name, alias_cfg)| {
+ alias_cfg.commands().map(move |cmd| ApprovableCommand {
+ phase: Phase::Alias,
+ command: Command::new(
+ Some(cmd.name.clone().unwrap_or_else(|| alias_name.clone())),
+ cmd.template.clone(),
+ ),
+ })
+ })
+ .collect()
+}
+
#[cfg(test)]
mod tests {
use super::*;
diff --git a/src/git/error.rs b/src/git/error.rs
index cd670895f..1e00a9286 100644
--- a/src/git/error.rs
+++ b/src/git/error.rs
@@ -748,7 +748,7 @@ impl GitError {
}
GitError::NotInteractive => {
- let approvals_cmd = suggest_command("hook", &["approvals", "add"], &[]);
+ let approvals_cmd = suggest_command("config", &["approvals", "add"], &[]);
write!(
f,
"{}\n{}",
diff --git a/src/main.rs b/src/main.rs
index 7c904c085..cb248c77d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -237,10 +237,16 @@ fn handle_hook_command(action: HookCommand) -> anyhow::Result<()> {
&vars,
),
HookCommand::RunPipeline => commands::run_pipeline(),
- HookCommand::Approvals { action } => match action {
- ApprovalsCommand::Add { all } => add_approvals(all),
- ApprovalsCommand::Clear { global } => clear_approvals(global),
- },
+ HookCommand::Approvals { action } => {
+ eprintln!(
+ "{}",
+ warning_message("wt hook approvals is deprecated; use wt config approvals instead")
+ );
+ match action {
+ ApprovalsCommand::Add { all } => add_approvals(all),
+ ApprovalsCommand::Clear { global } => clear_approvals(global),
+ }
+ }
}
}
@@ -502,6 +508,10 @@ fn handle_config_command(action: ConfigCommand) -> anyhow::Result<()> {
ConfigCommand::Create { project } => handle_config_create(project),
ConfigCommand::Show { full, format } => handle_config_show(full, format),
ConfigCommand::Update { yes, print } => handle_config_update(yes, print),
+ ConfigCommand::Approvals { action } => match action {
+ ApprovalsCommand::Add { all } => add_approvals(all),
+ ApprovalsCommand::Clear { global } => clear_approvals(global),
+ },
ConfigCommand::Plugins { action } => handle_plugins_command(action),
ConfigCommand::State { action } => handle_state_command(action),
}
diff --git a/tests/integration_tests/approvals.rs b/tests/integration_tests/approvals.rs
index a735d77cd..932d50f38 100644
--- a/tests/integration_tests/approvals.rs
+++ b/tests/integration_tests/approvals.rs
@@ -12,7 +12,7 @@ use worktrunk::config::Approvals;
fn snapshot_add_approvals(test_name: &str, repo: &TestRepo, args: &[&str]) {
let settings = setup_snapshot_settings(repo);
settings.bind(|| {
- let mut cmd = make_snapshot_cmd(repo, "hook", &[], None);
+ let mut cmd = make_snapshot_cmd(repo, "config", &[], None);
cmd.arg("approvals").arg("add").args(args);
assert_cmd_snapshot!(test_name, cmd);
});
@@ -22,7 +22,7 @@ fn snapshot_add_approvals(test_name: &str, repo: &TestRepo, args: &[&str]) {
fn snapshot_clear_approvals(test_name: &str, repo: &TestRepo, args: &[&str]) {
let settings = setup_snapshot_settings(repo);
settings.bind(|| {
- let mut cmd = make_snapshot_cmd(repo, "hook", &[], None);
+ let mut cmd = make_snapshot_cmd(repo, "config", &[], None);
cmd.arg("approvals").arg("clear").args(args);
assert_cmd_snapshot!(test_name, cmd);
});
@@ -53,6 +53,40 @@ fn test_add_approvals_empty_config(repo: TestRepo) {
snapshot_add_approvals("add_approvals_empty_config", &repo, &[]);
}
+/// `wt hook approvals` is the deprecated alias for `wt config approvals`.
+/// Both `add` and `clear` must emit the deprecation warning and still forward
+/// to the same handler.
+#[rstest]
+#[case::add("add", "hook_approvals_deprecated_add")]
+#[case::clear("clear", "hook_approvals_deprecated_clear")]
+fn test_hook_approvals_emits_deprecation_warning(
+ repo: TestRepo,
+ #[case] action: &str,
+ #[case] snapshot_name: &str,
+) {
+ let settings = setup_snapshot_settings(&repo);
+ settings.bind(|| {
+ let mut cmd = make_snapshot_cmd(&repo, "hook", &[], None);
+ cmd.arg("approvals").arg(action);
+ assert_cmd_snapshot!(snapshot_name, cmd);
+ });
+}
+
+/// 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.
+#[rstest]
+fn test_add_approvals_includes_aliases(repo: TestRepo) {
+ repo.write_project_config(
+ r#"[aliases]
+deploy = "echo deploying {{ branch }}"
+"#,
+ );
+ repo.commit("Add alias-only project config");
+
+ snapshot_add_approvals("add_approvals_includes_aliases", &repo, &[]);
+}
+
// ============================================================================
// clear-approvals tests
// ============================================================================
@@ -137,7 +171,7 @@ fn test_clear_approvals_after_clear(repo: TestRepo) {
.unwrap();
// Clear approvals
- let mut cmd = make_snapshot_cmd(&repo, "hook", &[], None);
+ let mut cmd = make_snapshot_cmd(&repo, "config", &[], None);
cmd.arg("approvals").arg("clear");
cmd.output().unwrap();
@@ -232,7 +266,7 @@ url = "http://localhost:8080"
// bare repository tests
// ============================================================================
-/// Regression test for #1744: `wt hook approvals add` should find project config
+/// Regression test for #1744: `wt config approvals add` should find project config
/// in a bare repo's primary worktree. `config create --project` should place it
/// there (not in the bare repo root), consistent with `ProjectConfig::load`.
#[test]
@@ -254,11 +288,11 @@ fn test_add_approvals_bare_repo_config_in_primary_worktree() {
let settings = setup_temp_snapshot_settings(test.temp_path());
settings.bind(|| {
- // Run `wt hook approvals add --all` from the main worktree
+ // Run `wt config approvals add --all` from the main worktree
let mut cmd = wt_command();
test.configure_wt_cmd(&mut cmd);
cmd.current_dir(&main_worktree)
- .args(["hook", "approvals", "add", "--all"]);
+ .args(["config", "approvals", "add", "--all"]);
assert_cmd_snapshot!("add_approvals_bare_repo_config_in_primary_worktree", cmd);
});
}
@@ -290,21 +324,21 @@ fn test_config_create_project_bare_repo_no_worktrees_errors() {
);
}
-/// `hook approvals add` and `hook list` should error in a bare repo with
+/// `config approvals add` and `hook show` should error in a bare repo with
/// no linked worktrees (project_config_path returns None).
#[test]
fn test_hook_commands_bare_repo_no_worktrees_errors() {
let test = BareRepoTest::new();
- // hook approvals add --all should fail
+ // config approvals add --all should fail
let mut cmd = wt_command();
test.configure_wt_cmd(&mut cmd);
cmd.current_dir(test.bare_repo_path())
- .args(["hook", "approvals", "add", "--all"]);
+ .args(["config", "approvals", "add", "--all"]);
let output = cmd.output().unwrap();
assert!(
!output.status.success(),
- "hook approvals add should fail with no worktrees"
+ "config approvals add should fail with no worktrees"
);
// hook show should fail
diff --git a/tests/integration_tests/completion.rs b/tests/integration_tests/completion.rs
index 8f835e193..baa626cdf 100644
--- a/tests/integration_tests/completion.rs
+++ b/tests/integration_tests/completion.rs
@@ -810,11 +810,10 @@ fn test_complete_hook_subcommands(repo: TestRepo) {
assert!(subcommands.contains(&"post-merge"), "Missing post-merge");
assert!(subcommands.contains(&"pre-remove"), "Missing pre-remove");
assert!(subcommands.contains(&"post-remove"), "Missing post-remove");
- assert!(subcommands.contains(&"approvals"), "Missing approvals");
assert_eq!(
subcommands.len(),
- 12,
- "Should have exactly 12 hook subcommands"
+ 11,
+ "Should have exactly 11 hook subcommands"
);
// Test 2: Partial input "po" - filters to post-* subcommands
diff --git a/tests/integration_tests/help.rs b/tests/integration_tests/help.rs
index 594ee886d..32a33be39 100644
--- a/tests/integration_tests/help.rs
+++ b/tests/integration_tests/help.rs
@@ -78,9 +78,9 @@ fn snapshot_help(test_name: &str, args: &[&str]) {
#[case("help_config_state_logs", "config state logs --help")]
#[case("help_config_state_get", "config state get --help")]
#[case("help_config_state_clear", "config state clear --help")]
-#[case("help_hook_approvals", "hook approvals --help")]
-#[case("help_hook_approvals_add", "hook approvals add --help")]
-#[case("help_hook_approvals_clear", "hook approvals clear --help")]
+#[case("help_config_approvals", "config approvals --help")]
+#[case("help_config_approvals_add", "config approvals add --help")]
+#[case("help_config_approvals_clear", "config approvals clear --help")]
fn test_help(#[case] test_name: &str, #[case] args_str: &str) {
let args: Vec<&str> = if args_str.is_empty() {
vec![]
diff --git a/tests/integration_tests/hook_show.rs b/tests/integration_tests/hook_show.rs
index f366b98e7..dd58f79b7 100644
--- a/tests/integration_tests/hook_show.rs
+++ b/tests/integration_tests/hook_show.rs
@@ -313,7 +313,7 @@ lint = "pre-commit run"
});
}
-/// Test `wt hook clear` when no approvals exist for the project.
+/// Test `wt config approvals clear` when no approvals exist for the project.
#[rstest]
fn test_hook_clear_no_approvals(repo: TestRepo, temp_home: TempDir) {
// Remove origin so project_identifier uses full canonical path
@@ -335,7 +335,7 @@ fn test_hook_clear_no_approvals(repo: TestRepo, temp_home: TempDir) {
let mut cmd = wt_command();
repo.configure_wt_cmd(&mut cmd);
cmd.env("WORKTRUNK_CONFIG_PATH", &config_path);
- cmd.args(["hook", "approvals", "clear"])
+ cmd.args(["config", "approvals", "clear"])
.current_dir(repo.root_path());
set_temp_home_env(&mut cmd, temp_home.path());
@@ -343,7 +343,7 @@ fn test_hook_clear_no_approvals(repo: TestRepo, temp_home: TempDir) {
});
}
-/// Test `wt hook clear` when project has approvals to clear.
+/// Test `wt config approvals clear` when project has approvals to clear.
#[rstest]
fn test_hook_clear_with_approvals(repo: TestRepo, temp_home: TempDir) {
// Remove origin so project_identifier uses full canonical path
@@ -372,7 +372,7 @@ approved-commands = ["cargo build", "cargo test", "npm install"]
let mut cmd = wt_command();
repo.configure_wt_cmd(&mut cmd);
cmd.env("WORKTRUNK_CONFIG_PATH", &config_path);
- cmd.args(["hook", "approvals", "clear"])
+ cmd.args(["config", "approvals", "clear"])
.current_dir(repo.root_path());
set_temp_home_env(&mut cmd, temp_home.path());
diff --git a/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__not_interactive.snap b/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__not_interactive.snap
index 4fc74418e..528a2a48b 100644
--- a/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__not_interactive.snap
+++ b/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__not_interactive.snap
@@ -3,4 +3,4 @@ source: tests/integration_tests/git_error_display.rs
expression: err.to_string()
---
✗ Cannot prompt for approval in non-interactive environment
-↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt hook approvals add
+↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt config approvals add
diff --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.snap
index 198691364..207dd2774 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
@@ -51,4 +51,4 @@ exit_code: 1
○ pre-start:
  echo 'test command'
✗ Cannot prompt for approval in non-interactive environment
-↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt hook approvals add
+↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt config approvals add
diff --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.snap
index f310ede7d..10f6c2f37 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
@@ -14,4 +14,4 @@ exit_code: 1
○ pre-start third:
  echo 'Third command'
✗ Cannot prompt for approval in non-interactive environment
-↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt hook approvals add
+↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt config approvals add
diff --git a/tests/snapshots/integration__integration_tests__approval_ui__approval_multiple_commands.snap b/tests/snapshots/integration__integration_tests__approval_ui__approval_multiple_commands.snap
index 5b7243553..925dd1320 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
@@ -18,4 +18,4 @@ exit_code: 1
○ pre-start pwd:
  cd {{ worktree_path }} && pwd
✗ Cannot prompt for approval in non-interactive environment
-↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt hook approvals add
+↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt config approvals add
diff --git a/tests/snapshots/integration__integration_tests__approval_ui__approval_named_commands.snap b/tests/snapshots/integration__integration_tests__approval_ui__approval_named_commands.snap
index 9c98dbe86..6ed311d11 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
@@ -16,4 +16,4 @@ exit_code: 1
○ pre-start test:
  echo 'Running tests...'
✗ Cannot prompt for approval in non-interactive environment
-↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt hook approvals add
+↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt config approvals add
diff --git a/tests/snapshots/integration__integration_tests__approval_ui__approval_single_command.snap b/tests/snapshots/integration__integration_tests__approval_ui__approval_single_command.snap
index c5281a691..e95555390 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
@@ -12,4 +12,4 @@ exit_code: 1
○ pre-start:
  echo 'Worktree path: {{ worktree_path }}'
✗ Cannot prompt for approval in non-interactive environment
-↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt hook approvals add
+↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt config approvals add
diff --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.snap
index f310ede7d..10f6c2f37 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
@@ -14,4 +14,4 @@ exit_code: 1
○ pre-start third:
  echo 'Third command'
✗ Cannot prompt for approval in non-interactive environment
-↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt hook approvals add
+↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt config approvals add
diff --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.snap
index 883226b1a..bc505b50e 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
○ pre-merge lint:
  echo 'Running project lint'
✗ Cannot prompt for approval in non-interactive environment
-↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt hook approvals add
+↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt config approvals add
diff --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.snap
index 122e4b06c..abaa3329c 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
○ pre-merge test:
  echo 'Running project test'
✗ Cannot prompt for approval in non-interactive environment
-↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt hook approvals add
+↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt config approvals add
diff --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.snap
index e97f16718..b9d5b8388 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
○ post-merge:
  echo 'Post-merge cleanup for {{ branch }}'
✗ Cannot prompt for approval in non-interactive environment
-↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt hook approvals add
+↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt config approvals add
diff --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.snap
index a4439df81..5c85fad11 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
○ pre-merge:
  echo 'Running pre-merge checks on {{ branch }}'
✗ Cannot prompt for approval in non-interactive environment
-↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt hook approvals add
+↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt config approvals add
diff --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.snap
index 5e6cac186..8e878f086 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
@@ -12,4 +12,4 @@ exit_code: 1
○ pre-start:
  echo 'test command' > output.txt
✗ Cannot prompt for approval in non-interactive environment
-↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt hook approvals add
+↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt config approvals add
diff --git a/tests/snapshots/integration__integration_tests__approvals__add_approvals_all_already_approved.snap b/tests/snapshots/integration__integration_tests__approvals__add_approvals_all_already_approved.snap
index b2d68cd26..342158499 100644
--- a/tests/snapshots/integration__integration_tests__approvals__add_approvals_all_already_approved.snap
+++ b/tests/snapshots/integration__integration_tests__approvals__add_approvals_all_already_approved.snap
@@ -3,7 +3,7 @@ source: tests/integration_tests/approvals.rs
info:
program: wt
args:
- - hook
+ - config
- approvals
- add
env:
@@ -51,4 +51,4 @@ exit_code: 1
○ pre-start:
  echo 'test'
✗ Cannot prompt for approval in non-interactive environment
-↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt hook approvals add
+↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt config approvals add
diff --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.snap
index 2badafd42..1023b8957 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
@@ -3,7 +3,7 @@ source: tests/integration_tests/approvals.rs
info:
program: wt
args:
- - hook
+ - config
- approvals
- add
- "--all"
@@ -52,4 +52,4 @@ exit_code: 1
○ pre-start:
  echo 'test'
✗ Cannot prompt for approval in non-interactive environment
-↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt hook approvals add
+↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt config approvals add
diff --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.snap
index 1afe770de..3334139c9 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
@@ -3,7 +3,7 @@ source: tests/integration_tests/approvals.rs
info:
program: wt
args:
- - hook
+ - config
- approvals
- add
- "--all"
@@ -43,4 +43,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 hook approvals add
+↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt config approvals add
diff --git a/tests/snapshots/integration__integration_tests__approvals__add_approvals_empty_config.snap b/tests/snapshots/integration__integration_tests__approvals__add_approvals_empty_config.snap
index 3f5c4f219..8b0c77ce4 100644
--- a/tests/snapshots/integration__integration_tests__approvals__add_approvals_empty_config.snap
+++ b/tests/snapshots/integration__integration_tests__approvals__add_approvals_empty_config.snap
@@ -3,7 +3,7 @@ source: tests/integration_tests/approvals.rs
info:
program: wt
args:
- - hook
+ - config
- approvals
- add
env:
diff --git a/tests/snapshots/integration__integration_tests__approvals__add_approvals_includes_aliases.snap b/tests/snapshots/integration__integration_tests__approvals__add_approvals_includes_aliases.snap
new file mode 100644
index 000000000..2fe8e36df
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__approvals__add_approvals_includes_aliases.snap
@@ -0,0 +1,52 @@
+---
+source: tests/integration_tests/approvals.rs
+info:
+ program: wt
+ args:
+ - config
+ - approvals
+ - add
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ NO_COLOR: ""
+ OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"
+ PATH: "[PATH]"
+ PSModulePath: ""
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"
+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
+ WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_NUSHELL_ENV: "0"
+ WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"
+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: false
+exit_code: 1
+----- stdout -----
+
+----- stderr -----
+▲ origin needs approval to execute 1 command:
+○ alias deploy:
+  echo deploying {{ branch }}
+✗ 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
diff --git a/tests/snapshots/integration__integration_tests__approvals__add_approvals_no_commands.snap b/tests/snapshots/integration__integration_tests__approvals__add_approvals_no_commands.snap
index 3f5c4f219..8b0c77ce4 100644
--- a/tests/snapshots/integration__integration_tests__approvals__add_approvals_no_commands.snap
+++ b/tests/snapshots/integration__integration_tests__approvals__add_approvals_no_commands.snap
@@ -3,7 +3,7 @@ source: tests/integration_tests/approvals.rs
info:
program: wt
args:
- - hook
+ - config
- approvals
- add
env:
diff --git a/tests/snapshots/integration__integration_tests__approvals__add_approvals_no_config.snap b/tests/snapshots/integration__integration_tests__approvals__add_approvals_no_config.snap
index 80bc35a9b..c40e8a040 100644
--- a/tests/snapshots/integration__integration_tests__approvals__add_approvals_no_config.snap
+++ b/tests/snapshots/integration__integration_tests__approvals__add_approvals_no_config.snap
@@ -3,7 +3,7 @@ source: tests/integration_tests/approvals.rs
info:
program: wt
args:
- - hook
+ - config
- approvals
- add
env:
diff --git a/tests/snapshots/integration__integration_tests__approvals__clear_approvals_after_clear.snap b/tests/snapshots/integration__integration_tests__approvals__clear_approvals_after_clear.snap
index bfc14377c..f0033a7f7 100644
--- a/tests/snapshots/integration__integration_tests__approvals__clear_approvals_after_clear.snap
+++ b/tests/snapshots/integration__integration_tests__approvals__clear_approvals_after_clear.snap
@@ -3,7 +3,7 @@ source: tests/integration_tests/approvals.rs
info:
program: wt
args:
- - hook
+ - config
- approvals
- clear
env:
diff --git a/tests/snapshots/integration__integration_tests__approvals__clear_approvals_global_no_approvals.snap b/tests/snapshots/integration__integration_tests__approvals__clear_approvals_global_no_approvals.snap
index e0465dc72..e6bd5ef19 100644
--- a/tests/snapshots/integration__integration_tests__approvals__clear_approvals_global_no_approvals.snap
+++ b/tests/snapshots/integration__integration_tests__approvals__clear_approvals_global_no_approvals.snap
@@ -3,7 +3,7 @@ source: tests/integration_tests/approvals.rs
info:
program: wt
args:
- - hook
+ - config
- approvals
- clear
- "--global"
diff --git a/tests/snapshots/integration__integration_tests__approvals__clear_approvals_global_with_approvals.snap b/tests/snapshots/integration__integration_tests__approvals__clear_approvals_global_with_approvals.snap
index 4df8ecb0e..44ea782db 100644
--- a/tests/snapshots/integration__integration_tests__approvals__clear_approvals_global_with_approvals.snap
+++ b/tests/snapshots/integration__integration_tests__approvals__clear_approvals_global_with_approvals.snap
@@ -3,7 +3,7 @@ source: tests/integration_tests/approvals.rs
info:
program: wt
args:
- - hook
+ - config
- approvals
- clear
- "--global"
diff --git a/tests/snapshots/integration__integration_tests__approvals__clear_approvals_multiple_approvals.snap b/tests/snapshots/integration__integration_tests__approvals__clear_approvals_multiple_approvals.snap
index bfc14377c..f0033a7f7 100644
--- a/tests/snapshots/integration__integration_tests__approvals__clear_approvals_multiple_approvals.snap
+++ b/tests/snapshots/integration__integration_tests__approvals__clear_approvals_multiple_approvals.snap
@@ -3,7 +3,7 @@ source: tests/integration_tests/approvals.rs
info:
program: wt
args:
- - hook
+ - config
- approvals
- clear
env:
diff --git a/tests/snapshots/integration__integration_tests__approvals__clear_approvals_no_approvals.snap b/tests/snapshots/integration__integration_tests__approvals__clear_approvals_no_approvals.snap
index bfc14377c..f0033a7f7 100644
--- a/tests/snapshots/integration__integration_tests__approvals__clear_approvals_no_approvals.snap
+++ b/tests/snapshots/integration__integration_tests__approvals__clear_approvals_no_approvals.snap
@@ -3,7 +3,7 @@ source: tests/integration_tests/approvals.rs
info:
program: wt
args:
- - hook
+ - config
- approvals
- clear
env:
diff --git a/tests/snapshots/integration__integration_tests__approvals__clear_approvals_with_approvals.snap b/tests/snapshots/integration__integration_tests__approvals__clear_approvals_with_approvals.snap
index bfc14377c..f0033a7f7 100644
--- a/tests/snapshots/integration__integration_tests__approvals__clear_approvals_with_approvals.snap
+++ b/tests/snapshots/integration__integration_tests__approvals__clear_approvals_with_approvals.snap
@@ -3,7 +3,7 @@ source: tests/integration_tests/approvals.rs
info:
program: wt
args:
- - hook
+ - config
- approvals
- clear
env:
diff --git a/tests/snapshots/integration__integration_tests__approvals__hook_approvals_deprecated_add.snap b/tests/snapshots/integration__integration_tests__approvals__hook_approvals_deprecated_add.snap
new file mode 100644
index 000000000..a9e2ee910
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__approvals__hook_approvals_deprecated_add.snap
@@ -0,0 +1,50 @@
+---
+source: tests/integration_tests/approvals.rs
+info:
+ program: wt
+ args:
+ - hook
+ - approvals
+ - add
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ NO_COLOR: ""
+ OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"
+ PATH: "[PATH]"
+ PSModulePath: ""
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"
+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
+ WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_NUSHELL_ENV: "0"
+ WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"
+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: false
+exit_code: 1
+----- stdout -----
+
+----- stderr -----
+▲ wt hook approvals is deprecated; use wt config approvals instead
+✗ No project configuration found
+↳ Create a config file at: _REPO_/.config/wt.toml
diff --git a/tests/snapshots/integration__integration_tests__approvals__hook_approvals_deprecated_clear.snap b/tests/snapshots/integration__integration_tests__approvals__hook_approvals_deprecated_clear.snap
new file mode 100644
index 000000000..3b4729f6b
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__approvals__hook_approvals_deprecated_clear.snap
@@ -0,0 +1,49 @@
+---
+source: tests/integration_tests/approvals.rs
+info:
+ program: wt
+ args:
+ - hook
+ - approvals
+ - clear
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ NO_COLOR: ""
+ OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"
+ PATH: "[PATH]"
+ PSModulePath: ""
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"
+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
+ WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_NUSHELL_ENV: "0"
+ WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"
+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+
+----- stderr -----
+▲ wt hook approvals is deprecated; use wt config approvals instead
+○ No approvals to clear for this project
diff --git a/tests/snapshots/integration__integration_tests__help__help_hook_approvals.snap b/tests/snapshots/integration__integration_tests__help__help_config_approvals.snap
similarity index 74%
rename from tests/snapshots/integration__integration_tests__help__help_hook_approvals.snap
rename to tests/snapshots/integration__integration_tests__help__help_config_approvals.snap
index 0c7433151..0cd9ae7b5 100644
--- a/tests/snapshots/integration__integration_tests__help__help_hook_approvals.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_approvals.snap
@@ -3,7 +3,7 @@ source: tests/integration_tests/help.rs
info:
program: wt
args:
- - hook
+ - config
- approvals
- "--help"
env:
@@ -31,9 +31,9 @@ info:
success: true
exit_code: 0
----- stdout -----
-wt hook approvals - Manage command approvals
+wt config approvals - Manage command approvals
-Usage: wt hook approvals [OPTIONS] <COMMAND>
+Usage: wt config approvals [OPTIONS] <COMMAND>
Commands:
add Store approvals in approvals.toml
@@ -53,18 +53,18 @@ Usage: wt hook approvals [OPTIONS] <COMMAND>
-v, --verbose...
Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-Project hooks require approval on first run to prevent untrusted projects from running arbitrary commands.
+Project hooks and project aliases prompt for approval on first run to prevent untrusted projects from running arbitrary commands. Approvals from both flows are stored together.
Examples
-Pre-approve all commands for current project:
-  wt hook approvals add
+Pre-approve all hook and alias commands for current project:
+  wt config approvals add
Clear approvals for current project:
-  wt hook approvals clear
+  wt config approvals clear
Clear global approvals:
-  wt hook approvals clear --global
+  wt config approvals clear --global
How approvals work
diff --git a/tests/snapshots/integration__integration_tests__help__help_hook_approvals_add.snap b/tests/snapshots/integration__integration_tests__help__help_config_approvals_add.snap
similarity index 92%
rename from tests/snapshots/integration__integration_tests__help__help_hook_approvals_add.snap
rename to tests/snapshots/integration__integration_tests__help__help_config_approvals_add.snap
index 2d09b07e7..b3a1d59db 100644
--- a/tests/snapshots/integration__integration_tests__help__help_hook_approvals_add.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_approvals_add.snap
@@ -3,7 +3,7 @@ source: tests/integration_tests/help.rs
info:
program: wt
args:
- - hook
+ - config
- approvals
- add
- "--help"
@@ -32,9 +32,9 @@ info:
success: true
exit_code: 0
----- stdout -----
-wt hook approvals add - Store approvals in approvals.toml
+wt config approvals add - Store approvals in approvals.toml
-Usage: wt hook approvals add [OPTIONS]
+Usage: wt config approvals add [OPTIONS]
Options:
--all
diff --git a/tests/snapshots/integration__integration_tests__help__help_hook_approvals_clear.snap b/tests/snapshots/integration__integration_tests__help__help_config_approvals_clear.snap
similarity index 91%
rename from tests/snapshots/integration__integration_tests__help__help_hook_approvals_clear.snap
rename to tests/snapshots/integration__integration_tests__help__help_config_approvals_clear.snap
index 114252117..405f577dd 100644
--- a/tests/snapshots/integration__integration_tests__help__help_hook_approvals_clear.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_approvals_clear.snap
@@ -3,7 +3,7 @@ source: tests/integration_tests/help.rs
info:
program: wt
args:
- - hook
+ - config
- approvals
- clear
- "--help"
@@ -32,9 +32,9 @@ info:
success: true
exit_code: 0
----- stdout -----
-wt hook approvals clear - Clear approved commands from approvals.toml
+wt config approvals clear - Clear approved commands from approvals.toml
-Usage: wt hook approvals clear [OPTIONS]
+Usage: wt config approvals clear [OPTIONS]
Options:
-g, --global
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_long.snap b/tests/snapshots/integration__integration_tests__help__help_config_long.snap
index 061a616ed..8aac1b594 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_long.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_long.snap
@@ -37,12 +37,13 @@ Includes shell integration, hooks, and saved state.
Usage: wt config [OPTIONS] <COMMAND>
Commands:
- shell Shell integration setup
- create Create configuration file
- show Show configuration files & locations
- update Update deprecated config settings
- plugins Plugin management
- state Manage internal data and cache
+ shell Shell integration setup
+ create Create configuration file
+ show Show configuration files & locations
+ update Update deprecated config settings
+ approvals Manage command approvals
+ plugins Plugin management
+ state Manage internal data and cache
Options:
-h, --help
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_short.snap b/tests/snapshots/integration__integration_tests__help__help_config_short.snap
index 7d1672420..17ebd0fe6 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_short.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_short.snap
@@ -35,12 +35,13 @@ wt config - Manage user & project configs
Usage: wt config [OPTIONS] <COMMAND>
Commands:
- shell Shell integration setup
- create Create configuration file
- show Show configuration files & locations
- update Update deprecated config settings
- plugins Plugin management
- state Manage internal data and cache
+ shell Shell integration setup
+ create Create configuration file
+ show Show configuration files & locations
+ update Update deprecated config settings
+ approvals Manage command approvals
+ plugins Plugin management
+ state Manage internal data and cache
Options:
-h, --help Print help (see more with '--help')
diff --git a/tests/snapshots/integration__integration_tests__hook_show__hook_clear_no_approvals.snap b/tests/snapshots/integration__integration_tests__hook_show__hook_clear_no_approvals.snap
index 5aadc3173..cf0cce326 100644
--- a/tests/snapshots/integration__integration_tests__hook_show__hook_clear_no_approvals.snap
+++ b/tests/snapshots/integration__integration_tests__hook_show__hook_clear_no_approvals.snap
@@ -3,7 +3,7 @@ source: tests/integration_tests/hook_show.rs
info:
program: wt
args:
- - hook
+ - config
- approvals
- clear
env:
diff --git a/tests/snapshots/integration__integration_tests__hook_show__hook_clear_with_approvals.snap b/tests/snapshots/integration__integration_tests__hook_show__hook_clear_with_approvals.snap
index a09dc4d30..6549c2ec5 100644
--- a/tests/snapshots/integration__integration_tests__hook_show__hook_clear_with_approvals.snap
+++ b/tests/snapshots/integration__integration_tests__hook_show__hook_clear_with_approvals.snap
@@ -3,7 +3,7 @@ source: tests/integration_tests/hook_show.rs
info:
program: wt
args:
- - hook
+ - config
- approvals
- clear
env:
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.snap
index e4e6c8da8..2374d02ad 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
○ alias deploy:
  echo deploying
✗ Cannot prompt for approval in non-interactive environment
-↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt hook approvals add
+↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt config approvals add
diff --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.snap
index 616cdc8c1..b0f6cb2d8 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
@@ -48,4 +48,4 @@ exit_code: 1
○ alias deploy:
  echo deploying {{ branch }}
✗ Cannot prompt for approval in non-interactive environment
-↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt hook approvals add
+↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt config approvals add
diff --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.snap
index c756734f4..8e4be955a 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
@@ -48,4 +48,4 @@ exit_code: 1
○ alias deploy:
  echo deploying
✗ Cannot prompt for approval in non-interactive environment
-↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt hook approvals add
+↳ To skip prompts in CI/CD, add --yes; to pre-approve commands, run wt config approvals add