Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
feat: Add user-level hooks that run for all repositories, add `wt hook show` (#118)
Maximilian Roosb2048db58a33
diff --git a/CLAUDE.md b/CLAUDE.mdindex 9f85c2684..af5e69649 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -552,11 +552,12 @@ let lines: Vec<_> = reader.lines().collect();All background operation logs are centralized in `.git/wt-logs/` (main worktree's git directory):-- **Post-start commands**: `{branch}-post-start-{command}.log`+- **Post-start commands**: `{branch}-{source}-post-start-{command}.log` (source is `user` or `project`)- **Background removal**: `{branch}-remove.log`Examples (where command names are from config):-- `feature-post-start-npm.log`+- `feature-user-post-start-npm.log`+- `feature-project-post-start-build.log`- `bugfix-remove.log`### Log Behaviordiff --git a/dev/wt.example.toml b/dev/wt.example.tomlindex 43f5d2479..474042ba5 100644--- a/dev/wt.example.toml+++ b/dev/wt.example.toml@@ -33,7 +33,7 @@# Use for: uv sync, npm install, bundle install, build, dev servers, file watchers,# downloading assets too large for git (images, ML models, binaries), long-running tasks# The worktree switch completes immediately, these run in parallel-# Output is logged to .git/wt-logs/{branch}-post-start-{name}.log+# Output is logged to .git/wt-logs/{branch}-{source}-post-start-{name}.log (source: user/project)## Format options:# 1. Single string:diff --git a/docs/content/config.md b/docs/content/config.mdindex 787428bf4..0bbd8a1d0 100644--- a/docs/content/config.md+++ b/docs/content/config.md@@ -100,7 +100,7 @@ stage = "all" # "all" (default), "tracked", or "none"squash = false # Preserve individual commits (--no-squash)commit = false # Skip committing uncommitted changes (--no-commit)remove = false # Keep worktree after merge (--no-remove)-verify = false # Skip project hooks (--no-verify)+verify = false # Skip hooks (--no-verify)```### LLM commit messages@@ -129,6 +129,22 @@ approved-commands = [Manage approvals with `wt config approvals add` to review and pre-approve commands, and `wt config approvals clear` to reset (add `--global` to clear all projects).+### User hooks++Personal hooks that run for all repositories. Use the same syntax as project hooks:++```toml+[post-create]+setup = "echo 'Setting up worktree...'"++[pre-merge]+notify = "notify-send 'Merging {{ branch }}'"+```++User hooks run before project hooks and don't require approval. Skip with `--no-verify`.++See [wt hook](@/hook.md#user-hooks) for complete documentation.+## Project configThe project config defines lifecycle hooks — commands that run at specific points during worktree operations. This file is checked into version control and shared across the team.@@ -452,7 +468,7 @@ With `--project`, creates `.config/wt.toml` in the current repository:# Use for: uv sync, npm install, bundle install, build, dev servers, file watchers,# downloading assets too large for git (images, ML models, binaries), long-running tasks# The worktree switch completes immediately, these run in parallel-# Output is logged to .git/wt-logs/{branch}-post-start-{name}.log+# Output is logged to .git/wt-logs/{branch}-{source}-post-start-{name}.log (source: user/project)## Format options:# 1. Single string:diff --git a/docs/content/hook.md b/docs/content/hook.mdindex 771d61c8b..13eb2e9c4 100644--- a/docs/content/hook.md+++ b/docs/content/hook.md@@ -8,13 +8,15 @@ group = "Commands"<!-- ⚠️ AUTO-GENERATED from `wt hook --help-page` — edit cli.rs to update -->-Run project-defined lifecycle hooks from `.config/wt.toml`.+Run hooks independently of normal worktree operations.-Hooks are commands that run automatically during worktree operations (`wt switch --create`, `wt merge`, `wt remove`). Use `wt hook` to run them manually for testing or CI.+Hooks normally run automatically during `wt switch --create`, `wt merge`, and `wt remove`. This command runs them on demand — useful for testing hooks during development, running in CI pipelines, or re-running after a failure.++Both user hooks (from `~/.config/worktrunk/config.toml`) and project hooks (from `.config/wt.toml`) are supported.```bash-wt hook pre-merge # Run pre-merge hooks (for testing)-wt hook pre-merge --force # Run in CI (skip approval prompts)+wt hook pre-merge # Run pre-merge hooks+wt hook pre-merge --force # Skip approval prompts (for CI)```## Hook types@@ -56,7 +58,7 @@ build = "npm run build"server = "npm run dev"```-Output logged to `.git/wt-logs/{branch}-post-start-{name}.log`.+Output logged to `.git/wt-logs/{branch}-{source}-post-start-{name}.log` (source is `user` or `project`).### pre-commit@@ -141,6 +143,7 @@ Hooks can use template variables that expand at runtime:| `{{ commit }}` | a1b2c3d4e5f6... | Full HEAD commit SHA || `{{ short_commit }}` | a1b2c3d | Short HEAD commit SHA || `{{ remote }}` | origin | Primary remote name |+| `{{ remote_url }}` | [email protected]:user/repo.git | Remote URL || `{{ upstream }}` | origin/feature | Upstream tracking branch || `{{ target }}` | main | Target branch (merge hooks only) |@@ -172,10 +175,59 @@ Project commands require approval on first run:- Approvals are saved to user config (`~/.config/worktrunk/config.toml`)- If a command changes, new approval is required- Use `--force` to bypass prompts (useful for CI/automation)-- Use `--no-verify` to skip all project hooks+- Use `--no-verify` to skip hooksManage approvals with `wt config approvals add` and `wt config approvals clear`.+## User hooks++Define hooks in `~/.config/worktrunk/config.toml` to run for all repositories. User hooks run before project hooks and don't require approval.++```toml+# ~/.config/worktrunk/config.toml+[post-create]+setup = "echo 'Setting up worktree...'"++[pre-merge]+notify = "notify-send 'Merging {{ branch }}'"+```++User hooks support the same hook types and template variables as project hooks.++**Key differences from project hooks:**++| Aspect | Project hooks | User hooks |+|--------|--------------|------------|+| Location | `.config/wt.toml` | `~/.config/worktrunk/config.toml` |+| Scope | Single repository | All repositories |+| Approval | Required | Not required |+| Execution order | After user hooks | Before project hooks |++Skip hooks with `--no-verify`.++**Use cases:**+- Personal notifications or logging+- Editor/IDE integration+- Repository-agnostic setup tasks+- Filtering by repository using JSON context++**Filtering by repository:**++User hooks receive JSON context on stdin, enabling repository-specific behavior:++```toml+# ~/.config/worktrunk/config.toml+[post-create]+gitlab-setup = """+python3 -c '+import json, sys, subprocess+ctx = json.load(sys.stdin)+if "gitlab" in ctx.get("remote", ""):+ subprocess.run(["glab", "mr", "create", "--fill"])+'+"""+```+## Examples### Node.js / TypeScript@@ -296,11 +348,12 @@ env = "cp {{ repo_root }}/.env.local .env"## Command reference```-wt hook - Run project hooks+wt hook - Run hooks independentlyUsage: wt hook [OPTIONS] <COMMAND>Commands:+ show Show configured hookspost-create Run post-create hookspost-start Run post-start hookspre-commit Run pre-commit hooksdiff --git a/docs/content/merge.md b/docs/content/merge.mdindex 7d8a955a6..36a10375e 100644--- a/docs/content/merge.md+++ b/docs/content/merge.md@@ -90,7 +90,7 @@ Options:Keep worktree after merge--no-verify- Skip all project hooks+ Skip hooks-f, --forceSkip approval promptsdiff --git a/docs/content/remove.md b/docs/content/remove.mdindex eacfff924..dd2e76f45 100644--- a/docs/content/remove.md+++ b/docs/content/remove.md@@ -87,7 +87,10 @@ Options:Run removal in foreground--no-verify- Skip pre-remove hooks+ Skip hooks++ --force+ Skip approval prompts-h, --helpPrint help (see a summary with '-h')diff --git a/docs/content/step.md b/docs/content/step.mdindex b0f0120ad..f7a4f66f7 100644--- a/docs/content/step.md+++ b/docs/content/step.md@@ -38,7 +38,7 @@ wt step push## See also- [wt merge](@/merge.md) — Runs commit → squash → rebase → hooks → push → cleanup automatically-- [wt hook](@/hook.md) — Run project-defined lifecycle hooks+- [wt hook](@/hook.md) — Run hooks independently---diff --git a/docs/content/switch.md b/docs/content/switch.mdindex b78d0dcd2..f5a73d295 100644--- a/docs/content/switch.md+++ b/docs/content/switch.md@@ -104,7 +104,7 @@ Options:Skip approval prompts--no-verify- Skip all project hooks+ Skip hooks-h, --helpPrint help (see a summary with '-h')diff --git a/src/cli.rs b/src/cli.rsindex 67bf7e5ba..52f30e6b3 100644--- a/src/cli.rs+++ b/src/cli.rs@@ -590,7 +590,7 @@ pub enum StepCommand {#[arg(short, long)]force: bool,- /// Skip pre-commit hooks+ /// Skip hooks#[arg(long = "no-verify", action = clap::ArgAction::SetFalse, default_value_t = true)]verify: bool,@@ -616,7 +616,7 @@ pub enum StepCommand {#[arg(short, long)]force: bool,- /// Skip pre-commit hooks+ /// Skip hooks#[arg(long = "no-verify", action = clap::ArgAction::SetFalse, default_value_t = true)]verify: bool,@@ -651,9 +651,23 @@ pub enum StepCommand {},}-/// Run project hooks+/// Run hooks independently#[derive(Subcommand)]pub enum HookCommand {+ /// Show configured hooks+ ///+ /// Lists all hooks from user config and project config with their commands.+ /// Project hooks show approval status (❓ = needs approval).+ Show {+ /// Hook type to show (default: all)+ #[arg(value_parser = ["post-create", "post-start", "pre-commit", "pre-merge", "post-merge", "pre-remove"])]+ hook_type: Option<String>,++ /// Show expanded commands with current variables+ #[arg(long)]+ expanded: bool,+ },+/// Run post-create hooks////// Executes blocking commands after worktree creation.@@ -849,7 +863,7 @@ stage = "all" # "all" (default), "tracked", or "none"squash = false # Preserve individual commits (--no-squash)commit = false # Skip committing uncommitted changes (--no-commit)remove = false # Keep worktree after merge (--no-remove)-verify = false # Skip project hooks (--no-verify)+verify = false # Skip hooks (--no-verify)```### LLM commit messages@@ -878,6 +892,22 @@ approved-commands = [Manage approvals with `wt config approvals add` to review and pre-approve commands, and `wt config approvals clear` to reset (add `--global` to clear all projects).+### User hooks++Personal hooks that run for all repositories. Use the same syntax as project hooks:++```toml+[post-create]+setup = "echo 'Setting up worktree...'"++[pre-merge]+notify = "notify-send 'Merging {{ branch }}'"+```++User hooks run before project hooks and don't require approval. Skip with `--no-verify`.++See [wt hook](@/hook.md#user-hooks) for complete documentation.+## Project configThe project config defines lifecycle hooks — commands that run at specific points during worktree operations. This file is checked into version control and shared across the team.@@ -1005,7 +1035,7 @@ wt step push## See also- [wt merge](@/merge.md) — Runs commit → squash → rebase → hooks → push → cleanup automatically-- [wt hook](@/hook.md) — Run project-defined lifecycle hooks+- [wt hook](@/hook.md) — Run hooks independently"#)]Step {@@ -1013,16 +1043,18 @@ wt step pushaction: StepCommand,},- /// Run project hooks+ /// Run hooks independently#[command(name = "hook",- after_long_help = r#"Run project-defined lifecycle hooks from `.config/wt.toml`.+ after_long_help = r#"Run hooks independently of normal worktree operations.-Hooks are commands that run automatically during worktree operations (`wt switch --create`, `wt merge`, `wt remove`). Use `wt hook` to run them manually for testing or CI.+Hooks normally run automatically during `wt switch --create`, `wt merge`, and `wt remove`. This command runs them on demand — useful for testing hooks during development, running in CI pipelines, or re-running after a failure.++Both user hooks (from `~/.config/worktrunk/config.toml`) and project hooks (from `.config/wt.toml`) are supported.```console-wt hook pre-merge # Run pre-merge hooks (for testing)-wt hook pre-merge --force # Run in CI (skip approval prompts)+wt hook pre-merge # Run pre-merge hooks+wt hook pre-merge --force # Skip approval prompts (for CI)```## Hook types@@ -1064,7 +1096,7 @@ build = "npm run build"server = "npm run dev"```-Output logged to `.git/wt-logs/{branch}-post-start-{name}.log`.+Output logged to `.git/wt-logs/{branch}-{source}-post-start-{name}.log` (source is `user` or `project`).### pre-commit@@ -1149,6 +1181,7 @@ Hooks can use template variables that expand at runtime:| `{{ commit }}` | a1b2c3d4e5f6... | Full HEAD commit SHA || `{{ short_commit }}` | a1b2c3d | Short HEAD commit SHA || `{{ remote }}` | origin | Primary remote name |+| `{{ remote_url }}` | [email protected]:user/repo.git | Remote URL || `{{ upstream }}` | origin/feature | Upstream tracking branch || `{{ target }}` | main | Target branch (merge hooks only) |@@ -1180,10 +1213,59 @@ Project commands require approval on first run:- Approvals are saved to user config (`~/.config/worktrunk/config.toml`)- If a command changes, new approval is required- Use `--force` to bypass prompts (useful for CI/automation)-- Use `--no-verify` to skip all project hooks+- Use `--no-verify` to skip hooksManage approvals with `wt config approvals add` and `wt config approvals clear`.+## User hooks++Define hooks in `~/.config/worktrunk/config.toml` to run for all repositories. User hooks run before project hooks and don't require approval.++```toml+# ~/.config/worktrunk/config.toml+[post-create]+setup = "echo 'Setting up worktree...'"++[pre-merge]+notify = "notify-send 'Merging {{ branch }}'"+```++User hooks support the same hook types and template variables as project hooks.++**Key differences from project hooks:**++| Aspect | Project hooks | User hooks |+|--------|--------------|------------|+| Location | `.config/wt.toml` | `~/.config/worktrunk/config.toml` |+| Scope | Single repository | All repositories |+| Approval | Required | Not required |+| Execution order | After user hooks | Before project hooks |++Skip hooks with `--no-verify`.++**Use cases:**+- Personal notifications or logging+- Editor/IDE integration+- Repository-agnostic setup tasks+- Filtering by repository using JSON context++**Filtering by repository:**++User hooks receive JSON context on stdin, enabling repository-specific behavior:++```toml+# ~/.config/worktrunk/config.toml+[post-create]+gitlab-setup = """+python3 -c '+import json, sys, subprocess+ctx = json.load(sys.stdin)+if "gitlab" in ctx.get("remote", ""):+ subprocess.run(["glab", "mr", "create", "--fill"])+'+"""+```+## Examples### Node.js / TypeScript@@ -1620,7 +1702,7 @@ wt switch --create fix --base=@ # Branch from current HEAD#[arg(short = 'f', long)]force: bool,- /// Skip all project hooks+ /// Skip hooks#[arg(long = "no-verify", action = clap::ArgAction::SetFalse, default_value_t = true)]verify: bool,},@@ -1700,9 +1782,13 @@ Arguments resolve by path first, then branch name. [Shortcuts](@/switch.md#short#[arg(long = "no-background", action = clap::ArgAction::SetFalse, default_value_t = true)]background: bool,- /// Skip pre-remove hooks+ /// Skip hooks#[arg(long = "no-verify", action = clap::ArgAction::SetFalse, default_value_t = true)]verify: bool,++ /// Skip approval prompts+ #[arg(long)]+ force: bool,},/// Merge worktree into target branch@@ -1795,11 +1881,11 @@ Use `--no-commit` to skip all git operations (steps 1-2) and only run hooks and#[arg(long = "no-remove", overrides_with = "remove")]no_remove: bool,- /// Force running project hooks+ /// Force running hooks#[arg(long, overrides_with = "no_verify", hide = true)]verify: bool,- /// Skip all project hooks+ /// Skip hooks#[arg(long = "no-verify", overrides_with = "verify")]no_verify: bool,diff --git a/src/commands/command_approval.rs b/src/commands/command_approval.rsindex 3e7801fe0..5d4ce8813 100644--- a/src/commands/command_approval.rs+++ b/src/commands/command_approval.rs@@ -1,12 +1,29 @@//! Command approval and execution utilities//!//! Shared helpers for approving commands declared in project configuration.+//!+//! # "Approve at the Gate" Pattern+//!+//! Commands that run hooks should approve all project commands **upfront** before any execution:+//!+//! ```text+//! User runs command+//! ↓+//! approve_hooks() ← Single approval prompt+//! ↓+//! Execute hooks (approval already done)+//! ```+//!+//! This ensures approval happens exactly once at the command entry point,+//! eliminating the need to thread `auto_trust` through execution layers.+use super::project_config::collect_commands_for_hooks;+use super::repository_ext::RepositoryCliExt;use crate::output;use anyhow::Context;use color_print::cformat;use worktrunk::config::{Command, WorktrunkConfig};-use worktrunk::git::GitError;+use worktrunk::git::{GitError, HookType};use worktrunk::styling::{INFO_EMOJI, PROMPT_EMOJI, WARNING_EMOJI, eprint, eprintln, format_bash_with_gutter,hint_message, stderr, warning_message,@@ -133,3 +150,69 @@ fn prompt_for_batch_approval(commands: &[&Command], project_id: &str) -> anyhow:Ok(response.trim().eq_ignore_ascii_case("y"))}++/// Collect project commands for hooks and request batch approval with template expansion.+///+/// This is the "gate" function that should be called at command entry points+/// (like `wt remove`, `wt switch --create`, `wt merge`) before any hooks execute.+/// It expands template variables before showing the approval prompt, so users see+/// the actual commands that will run (e.g., with actual branch names) instead of+/// template placeholders.+///+/// # Parameters+/// - `ctx`: Command context providing template variables (branch, worktree, etc.)+/// - `hook_types`: Which hook types to collect commands for+/// - `extra_vars`: Additional template variables+///+/// # Example+///+/// ```ignore+/// let ctx = CommandContext::new(&repo, &config, &branch, &worktree_path, &repo_root, force);+/// let approved = approve_hooks(+/// &ctx,+/// &[HookType::PostCreate, HookType::PostStart],+/// &[],+/// )?;+/// ```+pub fn approve_hooks(+ ctx: &super::command_executor::CommandContext<'_>,+ hook_types: &[HookType],+ extra_vars: &[(&str, &str)],+) -> anyhow::Result<bool> {+ approve_hooks_filtered(ctx, hook_types, extra_vars, None)+}++/// Like `approve_hooks` but with optional name filter for targeted hook approval.+///+/// When `name_filter` is provided, only commands matching that name are shown+/// in the approval prompt. This is used by `wt hook <type> --name <name>` to+/// approve only the targeted hook rather than all hooks of that type.+pub fn approve_hooks_filtered(+ ctx: &super::command_executor::CommandContext<'_>,+ hook_types: &[HookType],+ extra_vars: &[(&str, &str)],+ name_filter: Option<&str>,+) -> anyhow::Result<bool> {+ let project_config = match ctx.repo.load_project_config()? {+ Some(cfg) => cfg,+ None => return Ok(true), // No project config = no commands to approve+ };++ let mut commands = collect_commands_for_hooks(&project_config, hook_types);++ // Apply name filter before approval to only prompt for targeted commands+ if let Some(name) = name_filter {+ commands.retain(|cmd| cmd.name.as_deref() == Some(name));+ }++ if commands.is_empty() {+ return Ok(true);+ }++ // Expand templates with the provided context+ let expanded =+ super::command_executor::expand_commands_for_approval(&commands, ctx, extra_vars)?;++ let project_id = ctx.repo.project_identifier()?;+ approve_command_batch(&expanded, &project_id, ctx.config, ctx.force, false)+}diff --git a/src/commands/command_executor.rs b/src/commands/command_executor.rsindex 03db49fec..938502aab 100644--- a/src/commands/command_executor.rs+++ b/src/commands/command_executor.rs@@ -1,11 +1,10 @@use std::collections::HashMap;use std::path::Path;+use worktrunk::HookType;use worktrunk::config::{- Command, CommandConfig, CommandPhase, WorktrunkConfig, expand_template, sanitize_branch_name,+ Command, CommandConfig, WorktrunkConfig, expand_template, sanitize_branch_name,};-use worktrunk::git::{Repository, WorktrunkError};--use super::command_approval::approve_command_batch;+use worktrunk::git::Repository;#[derive(Debug)]pub struct PreparedCommand {@@ -48,7 +47,7 @@ impl<'a> CommandContext<'a> {////// The resulting HashMap is passed to hook commands as JSON on stdin,/// and used directly for template variable expansion.-fn build_hook_context(+pub fn build_hook_context(ctx: &CommandContext<'_>,extra_vars: &[(&str, &str)],) -> HashMap<String, String> {@@ -85,7 +84,11 @@ fn build_hook_context(}if let Ok(remote) = ctx.repo.primary_remote() {- map.insert("remote".into(), remote);+ map.insert("remote".into(), remote.clone());+ // Add remote URL for conditional hook execution (e.g., GitLab vs GitHub)+ if let Ok(url) = ctx.repo.run_command(&["remote", "get-url", &remote]) {+ map.insert("remote_url".into(), url.trim().into());+ }if let Ok(Some(upstream)) = ctx.repo.upstream_branch(ctx.branch) {map.insert("upstream".into(), upstream);}@@ -161,54 +164,72 @@ fn expand_commands(Ok(result)}-/// Prepare project commands for execution with approval+/// Expand commands for approval display (public version for gate approval)+///+/// Returns commands with their `expanded` field filled in, showing actual values+/// instead of template placeholders.+pub fn expand_commands_for_approval(+ commands: &[Command],+ ctx: &CommandContext<'_>,+ extra_vars: &[(&str, &str)],+) -> anyhow::Result<Vec<Command>> {+ let expanded = expand_commands(commands, ctx, extra_vars)?;+ Ok(expanded.into_iter().map(|(cmd, _json)| cmd).collect())+}++/// Prepare project commands for execution////// This function:/// 1. Expands command templates with context variables-/// 2. Requests user approval for unapproved commands (unless auto_trust or force)-/// 3. Returns prepared commands ready for execution, each with JSON context for stdin+/// 2. Returns prepared commands ready for execution, each with JSON context for stdin///-/// Returns `Err(WorktrunkError::CommandNotApproved)` if the user declines approval.+/// Note: Approval is handled at the gate (command entry point), not here.pub fn prepare_project_commands(command_config: &CommandConfig,ctx: &CommandContext<'_>,- auto_trust: bool,extra_vars: &[(&str, &str)],- phase: CommandPhase,+ hook_type: HookType,) -> anyhow::Result<Vec<PreparedCommand>> {- let commands = command_config.commands_with_phase(phase);+ let commands = command_config.commands_with_phase(hook_type);if commands.is_empty() {return Ok(Vec::new());}- let project_id = ctx.repo.project_identifier()?;-- // Expand commands before approval for transparencylet expanded_with_json = expand_commands(&commands, ctx, extra_vars)?;- // Extract just the commands for approval- let expanded_commands: Vec<_> = expanded_with_json- .iter()- .map(|(cmd, _)| cmd.clone())- .collect();+ Ok(expanded_with_json+ .into_iter()+ .map(|(cmd, context_json)| PreparedCommand {+ name: cmd.name,+ expanded: cmd.expanded,+ context_json,+ })+ .collect())+}- // Flush stdout before prompting on stderr to ensure correct output ordering- // This prevents the approval prompt from appearing before previous success messages- crate::output::flush()?;-- // Approve using expanded commands (which have both template and expanded forms)- if !auto_trust- && !approve_command_batch(- &expanded_commands,- &project_id,- ctx.config,- ctx.force,- false,- )?- {- return Err(WorktrunkError::CommandNotApproved.into());+/// Prepare user hooks for execution without approval+///+/// Unlike project commands, user hooks don't require approval because they're+/// defined in the user's own config file. The user implicitly approves them+/// by adding them to their config.+///+/// This function:+/// 1. Expands command templates with context variables+/// 2. Returns prepared commands ready for execution, each with JSON context for stdin+pub fn prepare_user_commands(+ command_config: &CommandConfig,+ ctx: &CommandContext<'_>,+ extra_vars: &[(&str, &str)],+ hook_type: HookType,+) -> anyhow::Result<Vec<PreparedCommand>> {+ let commands = command_config.commands_with_phase(hook_type);+ if commands.is_empty() {+ return Ok(Vec::new());}+ // Expand commands (no approval needed for user hooks)+ let expanded_with_json = expand_commands(&commands, ctx, extra_vars)?;+Ok(expanded_with_json.into_iter().map(|(cmd, context_json)| PreparedCommand {diff --git a/src/commands/commit.rs b/src/commands/commit.rsindex 3ab67e3a5..01aef77f7 100644--- a/src/commands/commit.rs+++ b/src/commands/commit.rs@@ -1,11 +1,12 @@use anyhow::Context;use color_print::cformat;+use worktrunk::HookType;use worktrunk::config::CommitGenerationConfig;use worktrunk::git::Repository;use worktrunk::styling::{format_with_gutter, hint_message, progress_message, success_message};use super::command_executor::CommandContext;-use super::hooks::HookPipeline;+use super::hooks::{HookFailureStrategy, HookPipeline, HookSource};use super::repository_ext::RepositoryCliExt;// Re-export StageMode from config for use by CLI@@ -17,7 +18,6 @@ pub struct CommitOptions<'a> {pub target_branch: Option<&'a str>,pub no_verify: bool,pub stage_mode: StageMode,- pub auto_trust: bool,pub warn_about_untracked: bool,pub show_no_squash_note: bool,}@@ -30,7 +30,6 @@ impl<'a> CommitOptions<'a> {target_branch: None,no_verify: false,stage_mode: StageMode::All,- auto_trust: false,warn_about_untracked: true,show_no_squash_note: false,}@@ -139,18 +138,44 @@ impl<'a> CommitGenerator<'a> {impl CommitOptions<'_> {pub fn commit(self) -> anyhow::Result<()> {let project_config = self.ctx.repo.load_project_config()?;- let has_pre_commit = project_config+ let user_hooks_exist = self.ctx.config.pre_commit.is_some();+ let project_hooks_exist = project_config.as_ref().map(|c| c.pre_commit.is_some()).unwrap_or(false);+ let any_hooks_exist = user_hooks_exist || project_hooks_exist;- if self.no_verify && has_pre_commit {+ // Show skip message+ if self.no_verify && any_hooks_exist {crate::output::print(hint_message(cformat!(- "Skipping pre-commit hook (<bright-black>--no-verify</>)"+ "Skipping pre-commit hooks (<bright-black>--no-verify</>)")))?;- } else if let Some(ref config) = project_config {+ }++ if !self.no_verify {let pipeline = HookPipeline::new(*self.ctx);- pipeline.run_pre_commit(config, self.target_branch, self.auto_trust, None)?;+ let extra_vars: Vec<(&str, &str)> = self+ .target_branch+ .into_iter()+ .map(|target| ("target", target))+ .collect();++ // Run user pre-commit hooks first (no approval required)+ if let Some(user_config) = &self.ctx.config.pre_commit {+ pipeline.run_sequential(+ user_config,+ HookType::PreCommit,+ HookSource::User,+ &extra_vars,+ HookFailureStrategy::FailFast,+ None,+ )?;+ }++ // Then run project pre-commit hooks (require approval)+ if let Some(ref config) = project_config {+ pipeline.run_pre_commit(config, self.target_branch, None)?;+ }}if self.warn_about_untracked && self.stage_mode == StageMode::All {diff --git a/src/commands/hooks.rs b/src/commands/hooks.rsindex 2e3eba6bf..d906dc4e2 100644--- a/src/commands/hooks.rs+++ b/src/commands/hooks.rs@@ -1,10 +1,26 @@+// TODO(hook-naming): Refine hook display and filtering when user and project have same name+//+// Current behavior with `wt hook pre-merge foo`:+// - Both user's "foo" and project's "foo" run (name filter applied to each source separately)+// - Output: "Running user pre-merge foo:" then "Running project pre-merge foo:"+//+// Alternative approaches to consider:+// 1. Show source in name: "Running pre-merge user:foo" / "Running pre-merge project:foo"+// 2. Allow filtering by source: `wt hook pre-merge user:foo` runs only user's foo+// 3. Current approach: always show "user"/"project" prefix, filter runs both+//+// The source prefix in filtering (option 2) would need to be used elsewhere too to justify+// the syntax. Current behavior is reasonable but worth revisiting if users find it confusing.+use color_print::cformat;use worktrunk::HookType;-use worktrunk::config::{CommandConfig, CommandPhase, ProjectConfig};-use worktrunk::git::{GitError, WorktrunkError};+use worktrunk::config::{CommandConfig, ProjectConfig};+use worktrunk::git::WorktrunkError;use worktrunk::styling::{format_bash_with_gutter, progress_message, warning_message};-use super::command_executor::{CommandContext, PreparedCommand, prepare_project_commands};+use super::command_executor::{+ CommandContext, PreparedCommand, prepare_project_commands, prepare_user_commands,+};use crate::commands::process::spawn_detached;use crate::output::execute_command_in_worktree;@@ -17,7 +33,33 @@ pub enum HookFailureStrategy {Warn,}-/// Helper for preparing and executing project hook commands.+/// Distinguishes between user hooks and project hooks for command preparation.+///+/// Approval for project hooks is handled at the gate (command entry point),+/// not during hook execution.+pub enum HookSource {+ /// User hooks from ~/.config/worktrunk/config.toml (no approval required)+ User,+ /// Project hooks from .worktrunk.toml (approval handled at gate)+ Project,+}++impl HookSource {+ /// Returns the label prefix for this source+ fn label_prefix(&self) -> &'static str {+ match self {+ HookSource::User => "user",+ HookSource::Project => "project",+ }+ }++ /// Format a label for display: "user pre-merge" or "project pre-merge"+ fn format_label(&self, hook_type: HookType) -> String {+ format!("{} {}", self.label_prefix(), hook_type)+ }+}++/// Helper for preparing and executing hook commands.pub struct HookPipeline<'a> {ctx: CommandContext<'a>,}@@ -30,65 +72,62 @@ impl<'a> HookPipeline<'a> {fn prepare_commands(&self,command_config: &CommandConfig,- phase: CommandPhase,- auto_trust: bool,+ hook_type: HookType,+ source: &HookSource,extra_vars: &[(&str, &str)],name_filter: Option<&str>,) -> anyhow::Result<Vec<PreparedCommand>> {- let commands =- prepare_project_commands(command_config, &self.ctx, auto_trust, extra_vars, phase)?;+ let commands = match source {+ HookSource::User => {+ prepare_user_commands(command_config, &self.ctx, extra_vars, hook_type)?+ }+ HookSource::Project => {+ prepare_project_commands(command_config, &self.ctx, extra_vars, hook_type)?+ }+ };+ Ok(Self::filter_by_name(commands, name_filter))+ }- // Filter by name if specified+ /// Filter commands by name (returns empty vec if name not found - caller decides if that's an error)+ fn filter_by_name(+ commands: Vec<PreparedCommand>,+ name_filter: Option<&str>,+ ) -> Vec<PreparedCommand> {match name_filter {- Some(name) => {- // Collect available names before consuming the iterator- let available: Vec<String> =- commands.iter().filter_map(|cmd| cmd.name.clone()).collect();-- let filtered: Vec<_> = commands- .into_iter()- .filter(|cmd| cmd.name.as_deref() == Some(name))- .collect();-- if filtered.is_empty() {- return Err(GitError::HookCommandNotFound {- name: name.to_string(),- available,- }- .into());- }-- Ok(filtered)- }- None => Ok(commands),+ Some(name) => commands+ .into_iter()+ .filter(|cmd| cmd.name.as_deref() == Some(name))+ .collect(),+ None => commands,}}/// Run hook commands sequentially, using the provided failure strategy.- #[allow(clippy::too_many_arguments)]+ /// Returns the number of commands that were run.pub fn run_sequential(&self,command_config: &CommandConfig,- phase: CommandPhase,- auto_trust: bool,- extra_vars: &[(&str, &str)],- label_prefix: &str,hook_type: HookType,+ source: HookSource,+ extra_vars: &[(&str, &str)],failure_strategy: HookFailureStrategy,name_filter: Option<&str>,- ) -> anyhow::Result<()> {+ ) -> anyhow::Result<usize> {let commands =- self.prepare_commands(command_config, phase, auto_trust, extra_vars, name_filter)?;+ self.prepare_commands(command_config, hook_type, &source, extra_vars, name_filter)?;if commands.is_empty() {- return Ok(());+ return Ok(0);}+ let command_count = commands.len();// Track first failure for Warn strategy (to propagate exit code after all commands run)let mut first_failure: Option<(String, Option<String>, i32)> = None;+ let label_prefix = source.format_label(hook_type);+for prepared in commands {let label =- crate::commands::format_command_label(label_prefix, prepared.name.as_deref());+ crate::commands::format_command_label(&label_prefix, prepared.name.as_deref());crate::output::print(progress_message(format!("{label}:")))?;crate::output::gutter(format_bash_with_gutter(&prepared.expanded, ""))?;@@ -153,34 +192,38 @@ impl<'a> HookPipeline<'a> {.into());}- Ok(())+ Ok(command_count)}/// Spawn hook commands in the background (used for post-start hooks).- #[allow(clippy::too_many_arguments)]- pub fn spawn_detached(+ pub fn spawn_background(&self,command_config: &CommandConfig,- phase: CommandPhase,- auto_trust: bool,+ hook_type: HookType,+ source: HookSource,extra_vars: &[(&str, &str)],- label_prefix: &str,name_filter: Option<&str>,) -> anyhow::Result<()> {let commands =- self.prepare_commands(command_config, phase, auto_trust, extra_vars, name_filter)?;+ self.prepare_commands(command_config, hook_type, &source, extra_vars, name_filter)?;if commands.is_empty() {return Ok(());}+ // Derive operation name from hook type (e.g., "post-start")+ let operation_prefix = hook_type.to_string();+ let label_prefix = source.format_label(hook_type);+for prepared in commands {let label =- crate::commands::format_command_label(label_prefix, prepared.name.as_deref());+ crate::commands::format_command_label(&label_prefix, prepared.name.as_deref());crate::output::print(progress_message(format!("{label}:")))?;crate::output::gutter(format_bash_with_gutter(&prepared.expanded, ""))?;let name = prepared.name.as_deref().unwrap_or("cmd");- let operation = format!("post-start-{}", name);+ // Include source in operation name to prevent log file collisions between+ // user and project hooks with the same name+ let operation = format!("{}-{}-{}", source.label_prefix(), operation_prefix, name);if let Err(err) = spawn_detached(self.ctx.repo,self.ctx.worktree_path,@@ -206,7 +249,6 @@ impl<'a> HookPipeline<'a> {&self,project_config: &ProjectConfig,target_branch: Option<&str>,- auto_trust: bool,name_filter: Option<&str>,) -> anyhow::Result<()> {let Some(pre_commit_config) = &project_config.pre_commit else {@@ -220,13 +262,12 @@ impl<'a> HookPipeline<'a> {self.run_sequential(pre_commit_config,- CommandPhase::PreCommit,- auto_trust,- &extra_vars,- "pre-commit",HookType::PreCommit,+ HookSource::Project,+ &extra_vars,HookFailureStrategy::FailFast,name_filter,- )+ )?;+ Ok(())}}diff --git a/src/commands/merge.rs b/src/commands/merge.rsindex dd7ad2936..353b677f6 100644--- a/src/commands/merge.rs+++ b/src/commands/merge.rs@@ -1,13 +1,13 @@use worktrunk::HookType;-use worktrunk::config::{Command, CommandPhase, ProjectConfig};+use worktrunk::config::{Command, ProjectConfig};use worktrunk::git::Repository;use worktrunk::styling::info_message;use super::command_approval::approve_command_batch;-use super::command_executor::CommandContext;+use super::command_executor::{CommandContext, expand_commands_for_approval};use super::commit::CommitOptions;use super::context::CommandEnv;-use super::hooks::{HookFailureStrategy, HookPipeline};+use super::hooks::{HookFailureStrategy, HookPipeline, HookSource};use super::project_config::collect_commands_for_hooks;use super::repository_ext::RepositoryCliExt;use super::worktree::{MergeOperations, RemoveResult, handle_push};@@ -27,6 +27,7 @@ struct MergeCommandCollector<'a> {repo: &'a Repository,no_commit: bool,no_verify: bool,+ will_remove: bool,}/// Commands collected for batch approval with their project identifier@@ -59,6 +60,9 @@ impl<'a> MergeCommandCollector<'a> {if !self.no_verify {hooks.push(HookType::PreMerge);hooks.push(HookType::PostMerge);+ if self.will_remove {+ hooks.push(HookType::PreRemove);+ }}all_commands.extend(collect_commands_for_hooks(&project_config, &hooks));@@ -110,17 +114,26 @@ pub fn handle_merge(repo,no_commit: !commit,no_verify: !verify,+ will_remove: remove_effective,}.collect()?;- // Approve all commands in a single batch- // Commands collected here are not yet expanded - expansion happens later in prepare_project_commands- let approved = approve_command_batch(&all_commands, &project_id, config, force, false)?;+ // Expand commands for approval display (shows actual values instead of templates)+ let ctx = env.context(force);+ let expanded =+ expand_commands_for_approval(&all_commands, &ctx, &[("target", &target_branch)])?;- // If commands were declined, show message explaining that merge continues anyway- if !approved {+ // Approve all expanded commands in a single batch+ let approved = approve_command_batch(&expanded, &project_id, config, force, false)?;++ // If commands were declined, skip hooks but continue with merge+ // Shadow verify to gate all subsequent hook execution on approval+ let verify = if !approved {crate::output::print(info_message("Commands declined, continuing merge"))?;- }+ false+ } else {+ verify+ };// Handle uncommitted changes (skip if --no-commit) - track whether commit occurredlet committed = if commit && repo.is_dirty()? {@@ -132,7 +145,6 @@ pub fn handle_merge(options.target_branch = Some(&target_branch);options.no_verify = !verify;options.stage_mode = stage_mode;- options.auto_trust = true;options.warn_about_untracked = stage_mode == super::commit::StageMode::All;options.show_no_squash_note = true;@@ -149,8 +161,7 @@ pub fn handle_merge(super::standalone::handle_squash(Some(&target_branch),force,- !verify,- true,+ !verify, // skip_pre_commit when !verifystage_mode)?,super::standalone::SquashResult::Squashed@@ -171,9 +182,10 @@ pub fn handle_merge(// Run pre-merge checks unless --no-verify was specified// Do this after commit/squash/rebase to validate the final state that will be pushed- if verify && let Some(project_config) = repo.load_project_config()? {+ if verify {let ctx = env.context(force);- run_pre_merge_commands(&project_config, &ctx, &target_branch, true, None)?;+ let project_config = repo.load_project_config()?.unwrap_or_default();+ run_pre_merge_commands(&project_config, &ctx, &target_branch, None)?;}// Fast-forward push to target branch with commit/squash/rebase info for consolidated message@@ -210,8 +222,9 @@ pub fn handle_merge(force_delete: false,target_branch: Some(target_branch.clone()),};- // Run hooks during merge removal (verify=true)- crate::output::handle_remove_output(&remove_result, Some(¤t_branch), true, true)?;+ // Run hooks during merge removal (pass through verify flag)+ // Approval was handled at the gate (MergeCommandCollector)+ crate::output::handle_remove_output(&remove_result, Some(¤t_branch), true, verify)?;} else {// Print comprehensive summary (worktree preserved)// Priority: main worktree > on target > --no-remove flag@@ -239,7 +252,7 @@ pub fn handle_merge(&destination_repo_root,force,);- execute_post_merge_commands(&ctx, &target_branch, true, None)?;+ execute_post_merge_commands(&ctx, &target_branch, None)?;}Ok(())@@ -259,100 +272,209 @@ fn handle_merge_summary_output(reason: PreserveReason) -> anyhow::Result<()> {}/// Run pre-merge commands sequentially (blocking, fail-fast)///-/// # Security Note-/// `auto_trust`: When true, skip approval prompts (commands already approved in `wt merge`'s batch).-/// When false, require approval (standalone `wt step hook` execution).+/// Runs user hooks first, then project hooks.+/// Approval is handled at the gate (command entry point).pub fn run_pre_merge_commands(project_config: &ProjectConfig,ctx: &CommandContext,target_branch: &str,- auto_trust: bool,name_filter: Option<&str>,) -> anyhow::Result<()> {- let Some(pre_merge_config) = &project_config.pre_merge else {- return Ok(());- };-let pipeline = HookPipeline::new(*ctx);+ let extra_vars = [("target", target_branch)];+ let mut total_commands_run = 0;++ // Run user hooks first (no approval required)+ if let Some(user_config) = &ctx.config.pre_merge {+ total_commands_run += pipeline.run_sequential(+ user_config,+ HookType::PreMerge,+ HookSource::User,+ &extra_vars,+ HookFailureStrategy::FailFast,+ name_filter,+ )?;+ }- pipeline.run_sequential(- pre_merge_config,- CommandPhase::PreMerge,- auto_trust,- &[("target", target_branch)],- "pre-merge",- HookType::PreMerge,- HookFailureStrategy::FailFast,- name_filter,- )+ // Then run project hooks (require approval)+ if let Some(pre_merge_config) = &project_config.pre_merge {+ total_commands_run += pipeline.run_sequential(+ pre_merge_config,+ HookType::PreMerge,+ HookSource::Project,+ &extra_vars,+ HookFailureStrategy::FailFast,+ name_filter,+ )?;+ }++ // If name filter was provided but no commands matched, error with available names+ if let Some(name) = name_filter+ && total_commands_run == 0+ {+ let mut available = Vec::new();+ if let Some(config) = &ctx.config.pre_merge {+ available.extend(+ config+ .commands()+ .iter()+ .filter_map(|c| c.name.as_ref().map(|n| format!("user:{n}"))),+ );+ }+ if let Some(config) = &project_config.pre_merge {+ available.extend(+ config+ .commands()+ .iter()+ .filter_map(|c| c.name.as_ref().map(|n| format!("project:{n}"))),+ );+ }+ return Err(worktrunk::git::GitError::HookCommandNotFound {+ name: name.to_string(),+ available,+ }+ .into());+ }++ Ok(())}/// Execute post-merge commands sequentially in the main worktree (blocking)///-/// # Security Note-/// `auto_trust`: When true, skip approval prompts (commands already approved in `wt merge`'s batch).-/// When false, require approval (standalone `wt step hook` execution).+/// Runs user hooks first, then project hooks.+/// Approval is handled at the gate (command entry point).pub fn execute_post_merge_commands(ctx: &CommandContext,target_branch: &str,- auto_trust: bool,name_filter: Option<&str>,) -> anyhow::Result<()> {- // Load project config from the main worktree path directly- let project_config = match ctx.repo.load_project_config()? {- Some(cfg) => cfg,- None => return Ok(()),- };+ let pipeline = HookPipeline::new(*ctx);+ let extra_vars = [("target", target_branch)];+ let mut total_commands_run = 0;++ // Run user hooks first (no approval required)+ if let Some(user_config) = &ctx.config.post_merge {+ total_commands_run += pipeline.run_sequential(+ user_config,+ HookType::PostMerge,+ HookSource::User,+ &extra_vars,+ HookFailureStrategy::Warn,+ name_filter,+ )?;+ }- let Some(post_merge_config) = &project_config.post_merge else {- return Ok(());- };+ // Then run project hooks (require approval)+ // Load project config from the main worktree path directly+ let project_config = ctx.repo.load_project_config()?;++ if let Some(post_merge_config) = project_config.as_ref().and_then(|c| c.post_merge.as_ref()) {+ total_commands_run += pipeline.run_sequential(+ post_merge_config,+ HookType::PostMerge,+ HookSource::Project,+ &extra_vars,+ HookFailureStrategy::Warn,+ name_filter,+ )?;+ }- let pipeline = HookPipeline::new(*ctx);+ // If name filter was provided but no commands matched, error with available names+ if let Some(name) = name_filter+ && total_commands_run == 0+ {+ let mut available = Vec::new();+ if let Some(config) = &ctx.config.post_merge {+ available.extend(+ config+ .commands()+ .iter()+ .filter_map(|c| c.name.as_ref().map(|n| format!("user:{n}"))),+ );+ }+ if let Some(config) = project_config.as_ref().and_then(|c| c.post_merge.as_ref()) {+ available.extend(+ config+ .commands()+ .iter()+ .filter_map(|c| c.name.as_ref().map(|n| format!("project:{n}"))),+ );+ }+ return Err(worktrunk::git::GitError::HookCommandNotFound {+ name: name.to_string(),+ available,+ }+ .into());+ }- pipeline.run_sequential(- post_merge_config,- CommandPhase::PostMerge,- auto_trust,- &[("target", target_branch)],- "post-merge",- HookType::PostMerge,- HookFailureStrategy::Warn,- name_filter,- )+ Ok(())}/// Execute pre-remove commands sequentially in the worktree (blocking)///+/// Runs user hooks first, then project hooks./// Runs before a worktree is removed. Non-zero exit aborts the removal.-///-/// # Arguments-/// * `ctx` - Command context pointing to the worktree being removed-/// * `auto_trust` - When true, skip approval prompts+/// Approval is handled at the gate (command entry point).pub fn execute_pre_remove_commands(ctx: &CommandContext,- auto_trust: bool,name_filter: Option<&str>,) -> anyhow::Result<()> {- let project_config = match ctx.repo.load_project_config()? {- Some(cfg) => cfg,- None => return Ok(()),- };+ let pipeline = HookPipeline::new(*ctx);+ let mut total_commands_run = 0;++ // Run user hooks first (no approval required)+ if let Some(user_config) = &ctx.config.pre_remove {+ total_commands_run += pipeline.run_sequential(+ user_config,+ HookType::PreRemove,+ HookSource::User,+ &[],+ HookFailureStrategy::FailFast,+ name_filter,+ )?;+ }- let Some(pre_remove_config) = &project_config.pre_remove else {- return Ok(());- };+ // Then run project hooks (require approval)+ let project_config = ctx.repo.load_project_config()?;++ if let Some(pre_remove_config) = project_config.as_ref().and_then(|c| c.pre_remove.as_ref()) {+ total_commands_run += pipeline.run_sequential(+ pre_remove_config,+ HookType::PreRemove,+ HookSource::Project,+ &[],+ HookFailureStrategy::FailFast,+ name_filter,+ )?;+ }- let pipeline = HookPipeline::new(*ctx);+ // If name filter was provided but no commands matched, error with available names+ if let Some(name) = name_filter+ && total_commands_run == 0+ {+ let mut available = Vec::new();+ if let Some(config) = &ctx.config.pre_remove {+ available.extend(+ config+ .commands()+ .iter()+ .filter_map(|c| c.name.as_ref().map(|n| format!("user:{n}"))),+ );+ }+ if let Some(config) = project_config.as_ref().and_then(|c| c.pre_remove.as_ref()) {+ available.extend(+ config+ .commands()+ .iter()+ .filter_map(|c| c.name.as_ref().map(|n| format!("project:{n}"))),+ );+ }+ return Err(worktrunk::git::GitError::HookCommandNotFound {+ name: name.to_string(),+ available,+ }+ .into());+ }- pipeline.run_sequential(- pre_remove_config,- CommandPhase::PreRemove,- auto_trust,- &[],- "pre-remove",- HookType::PreRemove,- HookFailureStrategy::FailFast,- name_filter,- )+ Ok(())}diff --git a/src/commands/mod.rs b/src/commands/mod.rsindex 393eb67ec..6e4aacc8d 100644--- a/src/commands/mod.rs+++ b/src/commands/mod.rs@@ -17,6 +17,7 @@ pub mod standalone;pub mod statusline;pub mod worktree;+pub use command_approval::approve_hooks;pub use config::{handle_cache_clear, handle_cache_refresh, handle_cache_show, handle_config_create,handle_config_show, handle_var_clear, handle_var_get, handle_var_set,@@ -30,12 +31,12 @@ pub use merge::{execute_pre_remove_commands, handle_merge};#[cfg(unix)]pub use select::handle_select;pub use standalone::{- RebaseResult, SquashResult, handle_rebase, handle_squash, handle_standalone_add_approvals,- handle_standalone_clear_approvals, handle_standalone_commit, handle_standalone_run_hook,+ RebaseResult, SquashResult, add_approvals, clear_approvals, handle_hook_show, handle_rebase,+ handle_squash, run_hook, step_commit,};pub use worktree::{- handle_remove, handle_remove_by_path, handle_remove_current, handle_switch,- resolve_worktree_path_first,+ compute_worktree_path, handle_remove, handle_remove_by_path, handle_remove_current,+ handle_switch, resolve_worktree_path_first,};// Re-export Shell from the canonical locationdiff --git a/src/commands/standalone.rs b/src/commands/standalone.rsindex bc3510b0c..bcb10d851 100644--- a/src/commands/standalone.rs+++ b/src/commands/standalone.rs@@ -1,11 +1,16 @@use anyhow::Context;use color_print::cformat;+use std::fmt::Write as _;use worktrunk::HookType;+use worktrunk::config::{CommandConfig, ProjectConfig, WorktrunkConfig};use worktrunk::git::Repository;+use worktrunk::path::format_path_for_display;use worktrunk::styling::{- format_with_gutter, hint_message, info_message, progress_message, success_message,+ HINT_EMOJI, INFO_EMOJI, PROMPT_EMOJI, format_bash_with_gutter, format_with_gutter,+ hint_message, info_message, progress_message, success_message,};+use super::command_executor::CommandContext;use super::commit::{CommitGenerator, CommitOptions};use super::context::CommandEnv;use super::hooks::HookPipeline;@@ -16,46 +21,87 @@ use super::project_config::collect_commands_for_hooks;use super::repository_ext::RepositoryCliExt;/// Handle `wt hook` command-pub fn handle_standalone_run_hook(- hook_type: HookType,- force: bool,- name_filter: Option<&str>,-) -> anyhow::Result<()> {+///+/// When explicitly invoking hooks, ALL hooks run (both user and project).+/// There's no skip flag - if you explicitly run hooks, all configured hooks run.+pub fn run_hook(hook_type: HookType, force: bool, name_filter: Option<&str>) -> anyhow::Result<()> {+ use super::command_approval::approve_hooks_filtered;+// Derive context from current environmentlet env = CommandEnv::for_action(&format!("run {hook_type} hook"))?;let repo = &env.repo;let ctx = env.context(force);- // Load project config (show helpful error if missing)- let project_config = repo.require_project_config()?;+ // Load project config (optional - user hooks can run without project config)+ let project_config = repo.load_project_config()?;++ // "Approve at the Gate": approve project hooks upfront+ // Get extra vars for template expansion based on hook type+ // For wt hook pre-merge/post-merge, use current branch as target (not default branch)+ // because we're testing hooks in the context of the current worktree+ let default_branch = repo.default_branch().ok();+ let extra_vars: Vec<(&str, &str)> = match hook_type {+ HookType::PreCommit => {+ // Pre-commit uses default branch as target (for comparison context)+ default_branch+ .as_deref()+ .into_iter()+ .map(|t| ("target", t))+ .collect()+ }+ HookType::PreMerge | HookType::PostMerge => {+ // Pre-merge and post-merge use current branch as target for testing+ vec![("target", env.branch.as_str())]+ }+ _ => Vec::new(),+ };+ // Pass name_filter to only approve the targeted hook, not all hooks of this type+ let approved = approve_hooks_filtered(&ctx, &[hook_type], &extra_vars, name_filter)?;+ // If declined, return early - the whole point of `wt hook` is to run hooks+ if !approved {+ crate::output::print(worktrunk::styling::info_message("Commands declined"))?;+ return Ok(());+ }// TODO: Add support for custom variable overrides (e.g., --var key=value)// This would allow testing hooks with different contexts without being in that context+ // Helper to get user hook config+ macro_rules! user_hook {+ ($field:ident) => {+ ctx.config.$field.as_ref()+ };+ }+// Execute the hook based on typematch hook_type {HookType::PostCreate => {- check_hook_configured(&project_config.post_create, hook_type)?;+ let user_config = user_hook!(post_create);+ let project_config = project_config.as_ref().and_then(|c| c.post_create.as_ref());run_hook_with_filter(&ctx,- &project_config.post_create,+ user_config,+ project_config,hook_type,&[],name_filter,)}HookType::PostStart => {- check_hook_configured(&project_config.post_start, hook_type)?;+ let user_config = user_hook!(post_start);+ let project_config = project_config.as_ref().and_then(|c| c.post_start.as_ref());run_hook_with_filter(&ctx,- &project_config.post_start,+ user_config,+ project_config,hook_type,&[],name_filter,)}HookType::PreCommit => {- check_hook_configured(&project_config.pre_commit, hook_type)?;+ let user_config = user_hook!(pre_commit);+ let project_config = project_config.as_ref().and_then(|c| c.pre_commit.as_ref());// Pre-commit hook can optionally use target branch contextlet target_branch = repo.default_branch().ok();let extra_vars: Vec<(&str, &str)> = target_branch@@ -65,93 +111,144 @@ pub fn handle_standalone_run_hook(.collect();run_hook_with_filter(&ctx,- &project_config.pre_commit,+ user_config,+ project_config,hook_type,&extra_vars,name_filter,)}HookType::PreMerge => {- check_hook_configured(&project_config.pre_merge, hook_type)?;- // Use current branch as target - when running standalone, the "target"- // represents what branch we're on (vs. in `wt merge` where it's the- // branch being merged into)- run_pre_merge_commands(&project_config, &ctx, &env.branch, false, name_filter)+ // pre-merge, post-merge, pre-remove use functions from merge.rs+ // which already handle user hooks (approval already happened at gate)+ // Use current branch as target (matches approval prompt for wt hook)+ let project_cfg = project_config.unwrap_or_default();+ run_pre_merge_commands(&project_cfg, &ctx, &env.branch, name_filter)}HookType::PostMerge => {- check_hook_configured(&project_config.post_merge, hook_type)?;- // Use current branch as target - when running standalone, the "target"- // represents what branch we're on (vs. in `wt merge` where it's the- // branch being merged into)- execute_post_merge_commands(&ctx, &env.branch, false, name_filter)- }- HookType::PreRemove => {- check_hook_configured(&project_config.pre_remove, hook_type)?;- execute_pre_remove_commands(&ctx, false, name_filter)+ // Use current branch as target (matches approval prompt for wt hook)+ execute_post_merge_commands(&ctx, &env.branch, name_filter)}+ HookType::PreRemove => execute_pre_remove_commands(&ctx, name_filter),}}-/// Run a hook with optional name filter (used by standalone hook commands)+/// Run user and project hooks with optional name filter (used by standalone hook commands)+///+/// Runs user hooks first, then project hooks.+/// Returns an error if no hooks are configured for this hook type.fn run_hook_with_filter(ctx: &super::command_executor::CommandContext,- config: &Option<worktrunk::config::CommandConfig>,+ user_config: Option<&worktrunk::config::CommandConfig>,+ project_config: Option<&worktrunk::config::CommandConfig>,hook_type: HookType,extra_vars: &[(&str, &str)],name_filter: Option<&str>,) -> anyhow::Result<()> {- use super::hooks::{HookFailureStrategy, HookPipeline};- use worktrunk::config::CommandPhase;+ use super::hooks::{HookFailureStrategy, HookPipeline, HookSource};- let Some(command_config) = config else {- return Ok(());- };+ // Check at least one hook is configured+ if user_config.is_none() && project_config.is_none() {+ return Err(worktrunk::git::GitError::Other {+ message: format!("No {hook_type} hook configured (neither user nor project)"),+ }+ .into());+ }let pipeline = HookPipeline::new(*ctx);- let phase = match hook_type {- HookType::PostCreate => CommandPhase::PostCreate,- HookType::PostStart => CommandPhase::PostStart,- HookType::PreCommit => CommandPhase::PreCommit,- HookType::PreMerge => CommandPhase::PreMerge,- HookType::PostMerge => CommandPhase::PostMerge,- HookType::PreRemove => CommandPhase::PreRemove,- };- let label = hook_type.to_string().to_lowercase().replace(' ', "-");-- pipeline.run_sequential(- command_config,- phase,- false, // auto_trust=false, require approval for standalone- extra_vars,- &label,- hook_type,- HookFailureStrategy::FailFast,- name_filter,- )-}+ let mut total_commands_run = 0;++ // Run user hooks first (no approval required)+ if let Some(config) = user_config {+ total_commands_run += pipeline.run_sequential(+ config,+ hook_type,+ HookSource::User,+ extra_vars,+ HookFailureStrategy::FailFast,+ name_filter,+ )?;+ }-fn check_hook_configured<T>(hook: &Option<T>, hook_type: HookType) -> anyhow::Result<()> {- if hook.is_none() {- return Err(worktrunk::git::GitError::Other {- message: format!("No {hook_type} hook configured"),+ // Then run project hooks (approval already happened at gate)+ if let Some(config) = project_config {+ total_commands_run += pipeline.run_sequential(+ config,+ hook_type,+ HookSource::Project,+ extra_vars,+ HookFailureStrategy::FailFast,+ name_filter,+ )?;+ }++ // If name filter was provided but no commands matched, error with available names+ if let Some(name) = name_filter+ && total_commands_run == 0+ {+ let mut available = Vec::new();+ if let Some(config) = user_config {+ available.extend(+ config+ .commands()+ .iter()+ .filter_map(|c| c.name.as_ref().map(|n| format!("user:{n}"))),+ );+ }+ if let Some(config) = project_config {+ available.extend(+ config+ .commands()+ .iter()+ .filter_map(|c| c.name.as_ref().map(|n| format!("project:{n}"))),+ );+ }+ return Err(worktrunk::git::GitError::HookCommandNotFound {+ name: name.to_string(),+ available,}.into());}+Ok(())}/// Handle `wt step commit` command-pub fn handle_standalone_commit(+pub fn step_commit(force: bool,no_verify: bool,stage_mode: super::commit::StageMode,) -> anyhow::Result<()> {+ use super::command_approval::approve_hooks;+let env = CommandEnv::for_action("commit")?;let ctx = env.context(force);++ // "Approve at the Gate": approve pre-commit hooks upfront (unless --no-verify)+ // Shadow no_verify: if user declines approval, skip hooks but continue commit+ let no_verify = if !no_verify {+ let target_branch = env.repo.default_branch().ok();+ let extra_vars: Vec<(&str, &str)> = target_branch+ .as_deref()+ .into_iter()+ .map(|t| ("target", t))+ .collect();+ let approved = approve_hooks(&ctx, &[HookType::PreCommit], &extra_vars)?;+ if !approved {+ crate::output::print(worktrunk::styling::info_message(+ "Commands declined, committing without hooks",+ ))?;+ true // Skip hooks+ } else {+ false // Run hooks+ }+ } else {+ true // --no-verify was passed+ };+let mut options = CommitOptions::new(&ctx);options.no_verify = no_verify;options.stage_mode = stage_mode;- options.auto_trust = false;options.show_no_squash_note = false;// Only warn about untracked if we're staging alloptions.warn_about_untracked = stage_mode == super::commit::StageMode::All;@@ -175,13 +272,12 @@ pub enum SquashResult {/// Handle shared squash workflow (used by `wt step squash` and `wt merge`)////// # Arguments-/// * `auto_trust` - If true, skip approval prompts for pre-commit commands (already approved in batch)+/// * `skip_pre_commit` - If true, skip all pre-commit hooks (both user and project)/// * `stage_mode` - What to stage before committing (All or Tracked; None not supported for squash)pub fn handle_squash(target: Option<&str>,force: bool,skip_pre_commit: bool,- auto_trust: bool,stage_mode: super::commit::StageMode,) -> anyhow::Result<SquashResult> {use super::commit::StageMode;@@ -211,19 +307,40 @@ pub fn handle_squash(}}- // Run pre-commit hook unless explicitly skipped+ // Run pre-commit hooks unless explicitly skippedlet project_config = repo.load_project_config()?;- let has_pre_commit = project_config+ let has_project_pre_commit = project_config.as_ref().map(|c| c.pre_commit.is_some()).unwrap_or(false);+ let has_user_pre_commit = ctx.config.pre_commit.is_some();+ let has_any_pre_commit = has_project_pre_commit || has_user_pre_commit;- if skip_pre_commit && has_pre_commit {+ if skip_pre_commit && has_any_pre_commit {crate::output::print(hint_message(cformat!(- "Skipping pre-commit hook (<bright-black>--no-verify</>)"+ "Skipping pre-commit hooks (<bright-black>--no-verify</>)")))?;- } else if let Some(ref config) = project_config {- HookPipeline::new(ctx).run_pre_commit(config, Some(&target_branch), auto_trust, None)?;+ }++ let pipeline = HookPipeline::new(ctx);+ let extra_vars = [("target", target_branch.as_str())];++ // Run user pre-commit hooks first (unless skipped)+ if !skip_pre_commit && let Some(user_config) = &ctx.config.pre_commit {+ use super::hooks::{HookFailureStrategy, HookSource};+ pipeline.run_sequential(+ user_config,+ HookType::PreCommit,+ HookSource::User,+ &extra_vars,+ HookFailureStrategy::FailFast,+ None,+ )?;+ }++ // Then run project pre-commit hooks (unless skipped)+ if !skip_pre_commit && let Some(ref config) = project_config {+ pipeline.run_pre_commit(config, Some(&target_branch), None)?;}// Get merge base with target branch@@ -443,7 +560,7 @@ pub fn handle_rebase(target: Option<&str>) -> anyhow::Result<RebaseResult> {}/// Handle `wt config approvals add` command - approve all commands in the project-pub fn handle_standalone_add_approvals(force: bool, show_all: bool) -> anyhow::Result<()> {+pub fn add_approvals(force: bool, show_all: bool) -> anyhow::Result<()> {use super::command_approval::approve_command_batch;use worktrunk::config::WorktrunkConfig;@@ -509,7 +626,7 @@ pub fn handle_standalone_add_approvals(force: bool, show_all: bool) -> anyhow::R}/// Handle `wt config approvals clear` command - clear approved commands-pub fn handle_standalone_clear_approvals(global: bool) -> anyhow::Result<()> {+pub fn clear_approvals(global: bool) -> anyhow::Result<()> {use worktrunk::config::WorktrunkConfig;let mut config = WorktrunkConfig::load().context("Failed to load config")?;@@ -562,3 +679,267 @@ pub fn handle_standalone_clear_approvals(global: bool) -> anyhow::Result<()> {Ok(())}++/// Handle `wt hook show` command - display configured hooks+pub fn handle_hook_show(hook_type_filter: Option<&str>, expanded: bool) -> anyhow::Result<()> {+ use crate::help_pager::show_help_in_pager;++ let repo = Repository::current();+ let config = WorktrunkConfig::load().context("Failed to load user config")?;+ let project_config = repo.load_project_config()?;+ let project_id = repo.project_identifier().ok();++ // Parse hook type filter if provided+ let filter: Option<HookType> = hook_type_filter.map(|s| match s {+ "post-create" => HookType::PostCreate,+ "post-start" => HookType::PostStart,+ "pre-commit" => HookType::PreCommit,+ "pre-merge" => HookType::PreMerge,+ "post-merge" => HookType::PostMerge,+ "pre-remove" => HookType::PreRemove,+ _ => unreachable!("clap validates hook type"),+ });++ // Build context for template expansion (only used if --expanded)+ // Need to keep CommandEnv alive for the lifetime of ctx+ let env = if expanded {+ Some(CommandEnv::for_action("show hooks")?)+ } else {+ None+ };+ let ctx = env.as_ref().map(|e| e.context(false));++ let mut output = String::new();++ // Render user hooks+ render_user_hooks(&mut output, &config, filter, ctx.as_ref())?;+ output.push('\n');++ // Render project hooks+ render_project_hooks(+ &mut output,+ &repo,+ project_config.as_ref(),+ &config,+ project_id.as_deref(),+ filter,+ ctx.as_ref(),+ )?;++ // Display through pager (fall back to stderr if pager unavailable)+ if show_help_in_pager(&output).is_err() {+ worktrunk::styling::eprintln!("{}", output);+ }++ Ok(())+}++/// Render user hooks section+fn render_user_hooks(+ out: &mut String,+ config: &WorktrunkConfig,+ filter: Option<HookType>,+ ctx: Option<&CommandContext>,+) -> anyhow::Result<()> {+ let config_path = worktrunk::config::get_config_path();++ writeln!(+ out,+ "{}",+ cformat!(+ "{INFO_EMOJI} User Hooks: <bold>{}</>",+ config_path+ .as_ref()+ .map(|p| format_path_for_display(p))+ .unwrap_or_else(|| "(not found)".to_string())+ )+ )?;++ // Collect all user hooks+ let hooks = [+ (HookType::PostCreate, &config.post_create),+ (HookType::PostStart, &config.post_start),+ (HookType::PreCommit, &config.pre_commit),+ (HookType::PreMerge, &config.pre_merge),+ (HookType::PostMerge, &config.post_merge),+ (HookType::PreRemove, &config.pre_remove),+ ];++ let mut has_any = false;+ for (hook_type, hook_config) in hooks {+ // Apply filter if specified+ if let Some(f) = filter+ && f != hook_type+ {+ continue;+ }++ if let Some(cfg) = hook_config {+ has_any = true;+ render_hook_commands(out, hook_type, cfg, None, ctx)?;+ }+ }++ if !has_any {+ writeln!(+ out,+ "{}",+ cformat!("{HINT_EMOJI} <dim>(none configured)</>")+ )?;+ }++ Ok(())+}++/// Render project hooks section+fn render_project_hooks(+ out: &mut String,+ repo: &Repository,+ project_config: Option<&ProjectConfig>,+ user_config: &WorktrunkConfig,+ project_id: Option<&str>,+ filter: Option<HookType>,+ ctx: Option<&CommandContext>,+) -> anyhow::Result<()> {+ let repo_root = repo.worktree_root()?;+ let config_path = repo_root.join(".config").join("wt.toml");++ writeln!(+ out,+ "{}",+ cformat!(+ "{INFO_EMOJI} Project Hooks: <bold>{}</>",+ format_path_for_display(&config_path)+ )+ )?;++ let Some(config) = project_config else {+ writeln!(out, "{}", cformat!("{HINT_EMOJI} <dim>(not found)</>"))?;+ return Ok(());+ };++ // Collect all project hooks+ let hooks = [+ (HookType::PostCreate, &config.post_create),+ (HookType::PostStart, &config.post_start),+ (HookType::PreCommit, &config.pre_commit),+ (HookType::PreMerge, &config.pre_merge),+ (HookType::PostMerge, &config.post_merge),+ (HookType::PreRemove, &config.pre_remove),+ ];++ let mut has_any = false;+ for (hook_type, hook_config) in hooks {+ // Apply filter if specified+ if let Some(f) = filter+ && f != hook_type+ {+ continue;+ }++ if let Some(cfg) = hook_config {+ has_any = true;+ render_hook_commands(out, hook_type, cfg, Some((user_config, project_id)), ctx)?;+ }+ }++ if !has_any {+ writeln!(+ out,+ "{}",+ cformat!("{HINT_EMOJI} <dim>(none configured)</>")+ )?;+ }++ Ok(())+}++/// Render commands for a single hook type+fn render_hook_commands(+ out: &mut String,+ hook_type: HookType,+ config: &CommandConfig,+ // For project hooks: (user_config, project_id) to check approval status+ approval_context: Option<(&WorktrunkConfig, Option<&str>)>,+ ctx: Option<&CommandContext>,+) -> anyhow::Result<()> {+ let commands = config.commands();+ if commands.is_empty() {+ return Ok(());+ }++ for cmd in commands {+ // Build label: "hook-type name:" or "hook-type:"+ let label = match &cmd.name {+ Some(name) => cformat!("{hook_type} <bold>{name}</>:"),+ None => format!("{hook_type}:"),+ };++ // Check approval status for project hooks+ let needs_approval = if let Some((user_config, Some(project_id))) = approval_context {+ !user_config.is_command_approved(project_id, &cmd.template)+ } else {+ false+ };++ // Use ❓ for needs approval, ⚪ for approved/user hooks+ let (emoji, suffix) = if needs_approval {+ (PROMPT_EMOJI, cformat!(" <dim>(requires approval)</>"))+ } else {+ (INFO_EMOJI, String::new())+ };++ writeln!(out, "{emoji} {label}{suffix}")?;++ // Show template or expanded command+ let command_text = if let Some(command_ctx) = ctx {+ // Expand template with current context+ expand_command_template(&cmd.template, command_ctx, hook_type)+ } else {+ cmd.template.clone()+ };++ write!(out, "{}", format_bash_with_gutter(&command_text, ""))?;+ }++ Ok(())+}++/// Expand a command template with context variables+fn expand_command_template(template: &str, ctx: &CommandContext, hook_type: HookType) -> String {+ use super::command_executor::build_hook_context;++ // Build extra vars based on hook type (same logic as run_hook approval)+ let default_branch = ctx.repo.default_branch().ok();+ let extra_vars: Vec<(&str, &str)> = match hook_type {+ HookType::PreCommit => {+ // Pre-commit uses default branch as target (for comparison context)+ default_branch+ .as_deref()+ .into_iter()+ .map(|t| ("target", t))+ .collect()+ }+ HookType::PreMerge | HookType::PostMerge => {+ // Pre-merge and post-merge use current branch as target+ vec![("target", ctx.branch)]+ }+ _ => Vec::new(),+ };+ let template_ctx = build_hook_context(ctx, &extra_vars);++ // Use the standard template expansion+ worktrunk::config::expand_template(+ template,+ ctx.repo_root+ .file_name()+ .and_then(|n| n.to_str())+ .unwrap_or("unknown"),+ ctx.branch,+ &template_ctx+ .iter()+ .map(|(k, v)| (k.as_str(), v.as_str()))+ .collect(),+ )+ .unwrap_or_else(|_| template.to_string())+}diff --git a/src/commands/worktree.rs b/src/commands/worktree.rsindex 8a99dbbf6..4f39e5aa5 100644--- a/src/commands/worktree.rs+++ b/src/commands/worktree.rs@@ -114,15 +114,15 @@ use color_print::cformat;use normalize_path::NormalizePath;use std::path::PathBuf;use worktrunk::HookType;-use worktrunk::config::{CommandPhase, WorktrunkConfig};-use worktrunk::git::{GitError, Repository, ResolvedWorktree, is_command_not_approved};+use worktrunk::config::WorktrunkConfig;+use worktrunk::git::{GitError, Repository, ResolvedWorktree};use worktrunk::styling::{format_with_gutter, hint_message, info_message, progress_message, success_message,warning_message,};use super::command_executor::CommandContext;-use super::hooks::{HookFailureStrategy, HookPipeline};+use super::hooks::{HookFailureStrategy, HookPipeline, HookSource};use super::repository_ext::RepositoryCliExt;/// Resolve a worktree argument using path-first lookup.@@ -206,7 +206,7 @@ pub fn resolve_worktree_path_first(}/// Compute the expected worktree path for a branch name.-fn compute_worktree_path(+pub fn compute_worktree_path(repo: &Repository,branch: &str,config: &WorktrunkConfig,@@ -493,17 +493,8 @@ pub fn handle_switch(&repo_root,force,);- if let Err(e) = ctx.execute_post_create_commands() {- // Only treat CommandNotApproved as non-fatal (user declined)- // Other errors should still fail- if is_command_not_approved(&e) {- crate::output::print(info_message(- "Commands declined, continuing worktree creation",- ))?;- } else {- return Err(e);- }- }+ // Approval was handled at the gate+ ctx.execute_post_create_commands(true)?;}// Note: post-start commands are spawned AFTER success message is shown@@ -600,7 +591,28 @@ pub fn handle_remove_by_path(impl<'a> CommandContext<'a> {/// Execute post-create commands sequentially (blocking)- pub fn execute_post_create_commands(&self) -> anyhow::Result<()> {+ ///+ /// Runs user hooks first, then project hooks. Skips all hooks if verify is false.+ pub fn execute_post_create_commands(&self, verify: bool) -> anyhow::Result<()> {+ if !verify {+ return Ok(());+ }++ let pipeline = HookPipeline::new(*self);++ // Run user hooks first (no approval required)+ if let Some(user_config) = &self.config.post_create {+ pipeline.run_sequential(+ user_config,+ HookType::PostCreate,+ HookSource::User,+ &[],+ HookFailureStrategy::Warn,+ None,+ )?;+ }++ // Then run project hooks (approval checked at gate, not here)let project_config = match self.repo.load_project_config()? {Some(cfg) => cfg,None => return Ok(()),@@ -610,21 +622,39 @@ impl<'a> CommandContext<'a> {return Ok(());};- let pipeline = HookPipeline::new(*self);pipeline.run_sequential(post_create_config,- CommandPhase::PostCreate,- false,- &[],- "post-create",HookType::PostCreate,+ HookSource::Project,+ &[],HookFailureStrategy::Warn,None,- )+ )?;+ Ok(())}/// Spawn post-start commands in parallel as background processes (non-blocking)- pub fn spawn_post_start_commands(&self) -> anyhow::Result<()> {+ ///+ /// Spawns user hooks first, then project hooks. Skips all hooks if verify is false.+ pub fn spawn_post_start_commands(&self, verify: bool) -> anyhow::Result<()> {+ if !verify {+ return Ok(());+ }++ let pipeline = HookPipeline::new(*self);++ // Spawn user hooks first (no approval required)+ if let Some(user_config) = &self.config.post_start {+ pipeline.spawn_background(+ user_config,+ HookType::PostStart,+ HookSource::User,+ &[],+ None,+ )?;+ }++ // Then spawn project hooks (approval checked at gate, not here)let project_config = match self.repo.load_project_config()? {Some(cfg) => cfg,None => return Ok(()),@@ -634,13 +664,11 @@ impl<'a> CommandContext<'a> {return Ok(());};- let pipeline = HookPipeline::new(*self);- pipeline.spawn_detached(+ pipeline.spawn_background(post_start_config,- CommandPhase::PostStart,- false,+ HookType::PostStart,+ HookSource::Project,&[],- "post-start",None,)}diff --git a/src/completion.rs b/src/completion.rsindex fb5b64f59..30da906de 100644--- a/src/completion.rs+++ b/src/completion.rs@@ -8,7 +8,7 @@ use clap_complete::env::CompleteEnv;use crate::cli;use crate::display::format_relative_time_short;-use worktrunk::config::ProjectConfig;+use worktrunk::config::{ProjectConfig, WorktrunkConfig};use worktrunk::git::{BranchCategory, Repository};/// Args that should never appear in completions, even when all options are shown.@@ -227,39 +227,58 @@ fn complete_hook_commands() -> Vec<CompletionCandidate> {return Vec::new();};- // Load project config- let repo = Repository::current();- let repo_root = match repo.worktree_root() {- Ok(root) => root,- Err(_) => return Vec::new(),- };+ let mut candidates = Vec::new();++ // Load user config and add user hook names+ if let Ok(user_config) = WorktrunkConfig::load() {+ let user_command_config = match hook_type {+ "post-create" => &user_config.post_create,+ "post-start" => &user_config.post_start,+ "pre-commit" => &user_config.pre_commit,+ "pre-merge" => &user_config.pre_merge,+ "post-merge" => &user_config.post_merge,+ "pre-remove" => &user_config.pre_remove,+ _ => &None,+ };- let project_config = match ProjectConfig::load(&repo_root) {- Ok(Some(config)) => config,- _ => return Vec::new(),- };+ if let Some(config) = user_command_config {+ candidates.extend(+ config+ .commands()+ .iter()+ .filter_map(|cmd| cmd.name.as_ref())+ .map(|name| CompletionCandidate::new(name.clone())),+ );+ }+ }- // Get command names for the hook type- let command_config = match hook_type {- "post-create" => &project_config.post_create,- "post-start" => &project_config.post_start,- "pre-commit" => &project_config.pre_commit,- "pre-merge" => &project_config.pre_merge,- "post-merge" => &project_config.post_merge,- "pre-remove" => &project_config.pre_remove,- _ => return Vec::new(),- };+ // Load project config and add project hook names+ let repo = Repository::current();+ if let Ok(repo_root) = repo.worktree_root()+ && let Ok(Some(project_config)) = ProjectConfig::load(&repo_root)+ {+ let project_command_config = match hook_type {+ "post-create" => &project_config.post_create,+ "post-start" => &project_config.post_start,+ "pre-commit" => &project_config.pre_commit,+ "pre-merge" => &project_config.pre_merge,+ "post-merge" => &project_config.post_merge,+ "pre-remove" => &project_config.pre_remove,+ _ => &None,+ };- let Some(config) = command_config else {- return Vec::new();- };+ if let Some(config) = project_command_config {+ candidates.extend(+ config+ .commands()+ .iter()+ .filter_map(|cmd| cmd.name.as_ref())+ .map(|name| CompletionCandidate::new(name.clone())),+ );+ }+ }- config- .commands()- .iter()- .filter_map(|cmd| cmd.name.as_ref())- .map(|name| CompletionCandidate::new(name.clone()))- .collect()+ candidates}#[derive(Clone, Copy)]diff --git a/src/config/mod.rs b/src/config/mod.rsindex e4a02d424..554a50c47 100644--- a/src/config/mod.rs+++ b/src/config/mod.rs@@ -723,4 +723,64 @@ squash-template-file = "~/file.txt"assert!(unknown_project.is_empty());assert!(unknown_user.is_empty());}++ #[test]+ fn test_user_hooks_config_parsing() {+ let toml_str = r#"+worktree-path = "../{{ main_worktree }}.{{ branch }}"++[post-create]+log = "echo '{{ repo }}' >> ~/.log"++[pre-merge]+test = "cargo test"+lint = "cargo clippy"+"#;+ let config: WorktrunkConfig = toml::from_str(toml_str).unwrap();++ // Check post-create+ let post_create = config.post_create.expect("post-create should be present");+ let commands = post_create.commands();+ assert_eq!(commands.len(), 1);+ assert_eq!(commands[0].name.as_deref(), Some("log"));++ // Check pre-merge (multiple commands preserve order)+ let pre_merge = config.pre_merge.expect("pre-merge should be present");+ let commands = pre_merge.commands();+ assert_eq!(commands.len(), 2);+ assert_eq!(commands[0].name.as_deref(), Some("test"));+ assert_eq!(commands[1].name.as_deref(), Some("lint"));+ }++ #[test]+ fn test_user_hooks_config_single_command() {+ let toml_str = r#"+worktree-path = "../{{ main_worktree }}.{{ branch }}"+post-create = "npm install"+"#;+ let config: WorktrunkConfig = toml::from_str(toml_str).unwrap();++ let post_create = config.post_create.expect("post-create should be present");+ let commands = post_create.commands();+ assert_eq!(commands.len(), 1);+ assert!(commands[0].name.is_none()); // single command has no name+ assert_eq!(commands[0].template, "npm install");+ }++ #[test]+ fn test_user_hooks_not_reported_as_unknown() {+ let toml_str = r#"+worktree-path = "../test"+post-create = "npm install"++[pre-merge]+test = "cargo test"+"#;+ let unknown = find_unknown_user_keys(toml_str);+ assert!(+ unknown.is_empty(),+ "hook fields should not be reported as unknown: {:?}",+ unknown+ );+ }}diff --git a/src/config/user.rs b/src/config/user.rsindex ba9f27fcf..cc2b628ea 100644--- a/src/config/user.rs+++ b/src/config/user.rs@@ -7,6 +7,8 @@ use serde::{Deserialize, Deserializer, Serialize};use std::path::PathBuf;use std::sync::OnceLock;+use super::commands::CommandConfig;+/// Deserialize a Vec<String> that can also accept a single String/// This enables setting array config fields via environment variablesfn deserialize_string_or_vec<'de, D>(deserializer: D) -> Result<Vec<String>, D::Error>@@ -146,6 +148,53 @@ pub struct WorktrunkConfig {#[serde(default, skip_serializing_if = "Option::is_none")]pub merge: Option<MergeConfig>,+ // =========================================================================+ // User-level hooks (same syntax as project hooks, run before project hooks)+ // =========================================================================+ /// Commands to execute after worktree creation (blocking)+ #[serde(+ default,+ rename = "post-create",+ skip_serializing_if = "Option::is_none"+ )]+ pub post_create: Option<CommandConfig>,++ /// Commands to execute after worktree creation (background)+ #[serde(+ default,+ rename = "post-start",+ skip_serializing_if = "Option::is_none"+ )]+ pub post_start: Option<CommandConfig>,++ /// Commands to execute before committing during merge (blocking, fail-fast)+ #[serde(+ default,+ rename = "pre-commit",+ skip_serializing_if = "Option::is_none"+ )]+ pub pre_commit: Option<CommandConfig>,++ /// Commands to execute before merging (blocking, fail-fast)+ #[serde(default, rename = "pre-merge", skip_serializing_if = "Option::is_none")]+ pub pre_merge: Option<CommandConfig>,++ /// Commands to execute after successful merge (blocking, best-effort)+ #[serde(+ default,+ rename = "post-merge",+ skip_serializing_if = "Option::is_none"+ )]+ pub post_merge: Option<CommandConfig>,++ /// Commands to execute before worktree removal (blocking, fail-fast)+ #[serde(+ default,+ rename = "pre-remove",+ skip_serializing_if = "Option::is_none"+ )]+ pub pre_remove: Option<CommandConfig>,+/// Captures unknown fields for validation warnings#[serde(flatten, default, skip_serializing)]pub(crate) unknown: std::collections::HashMap<String, toml::Value>,@@ -284,6 +333,12 @@ impl Default for WorktrunkConfig {list: None,commit: None,merge: None,+ post_create: None,+ post_start: None,+ pre_commit: None,+ pre_merge: None,+ post_merge: None,+ pre_remove: None,unknown: std::collections::HashMap::new(),}}diff --git a/src/main.rs b/src/main.rsindex 1bc293990..98ceb697c 100644--- a/src/main.rs+++ b/src/main.rs@@ -4,7 +4,7 @@ use color_print::cformat;use std::path::PathBuf;use std::process;use worktrunk::config::{WorktrunkConfig, set_config_path};-use worktrunk::git::{Repository, exit_code, is_command_not_approved, set_base_path};+use worktrunk::git::{Repository, exit_code, set_base_path};use worktrunk::path::format_path_for_display;use worktrunk::styling::{format_with_gutter, hint_message, info_message, println, success_message, warning_message,@@ -26,13 +26,13 @@ use commands::command_executor::CommandContext;use commands::handle_select;use commands::worktree::{SwitchResult, handle_push};use commands::{- ConfigAction, RebaseResult, SquashResult, handle_cache_clear, handle_cache_refresh,- handle_cache_show, handle_config_create, handle_config_show, handle_configure_shell,+ ConfigAction, RebaseResult, SquashResult, add_approvals, approve_hooks, clear_approvals,+ compute_worktree_path, handle_cache_clear, handle_cache_refresh, handle_cache_show,+ handle_config_create, handle_config_show, handle_configure_shell, handle_hook_show,handle_init, handle_list, handle_merge, handle_rebase, handle_remove, handle_remove_by_path,- handle_remove_current, handle_show_theme, handle_squash, handle_standalone_add_approvals,- handle_standalone_clear_approvals, handle_standalone_commit, handle_standalone_run_hook,- handle_switch, handle_unconfigure_shell, handle_var_clear, handle_var_get, handle_var_set,- resolve_worktree_path_first,+ handle_remove_current, handle_show_theme, handle_squash, handle_switch,+ handle_unconfigure_shell, handle_var_clear, handle_var_get, handle_var_set,+ resolve_worktree_path_first, run_hook, step_commit,};use output::{execute_user_command, handle_remove_output, handle_switch_output};@@ -892,8 +892,8 @@ fn main() {VarCommand::Clear { key, branch, all } => handle_var_clear(&key, branch, all),},ConfigCommand::Approvals { action } => match action {- ApprovalsCommand::Add { force, all } => handle_standalone_add_approvals(force, all),- ApprovalsCommand::Clear { global } => handle_standalone_clear_approvals(global),+ ApprovalsCommand::Add { force, all } => add_approvals(force, all),+ ApprovalsCommand::Clear { global } => clear_approvals(global),},},Commands::Step { action } => match action {@@ -907,7 +907,7 @@ fn main() {let stage_final = stage.or_else(|| config.commit.and_then(|c| c.stage)).unwrap_or_default();- handle_standalone_commit(force, !verify, stage_final)+ step_commit(force, !verify, stage_final)}),StepCommand::Squash {target,@@ -920,7 +920,32 @@ fn main() {let stage_final = stage.or_else(|| config.commit.and_then(|c| c.stage)).unwrap_or_default();- match handle_squash(target.as_deref(), force, !verify, false, stage_final)? {++ // "Approve at the Gate": approve pre-commit hooks upfront (unless --no-verify)+ // Shadow verify: if user declines approval, skip hooks but continue squash+ let verify = if verify {+ use commands::command_approval::approve_hooks;+ use commands::context::CommandEnv;+ let env = CommandEnv::for_action("squash")?;+ let ctx = env.context(force);+ let target_branch = env.repo.default_branch().ok();+ let extra_vars: Vec<(&str, &str)> = target_branch+ .as_deref()+ .into_iter()+ .map(|t| ("target", t))+ .collect();+ let approved = approve_hooks(&ctx, &[HookType::PreCommit], &extra_vars)?;+ if !approved {+ crate::output::print(info_message(+ "Commands declined, squashing without hooks",+ ))?;+ }+ approved+ } else {+ false+ };++ match handle_squash(target.as_deref(), force, !verify, stage_final)? {SquashResult::Squashed | SquashResult::NoNetChanges => {}SquashResult::NoCommitsAhead(branch) => {crate::output::print(info_message(format!(@@ -952,23 +977,27 @@ fn main() {}},Commands::Hook { action } => match action {+ HookCommand::Show {+ hook_type,+ expanded,+ } => handle_hook_show(hook_type.as_deref(), expanded),HookCommand::PostCreate { name, force } => {- handle_standalone_run_hook(HookType::PostCreate, force, name.as_deref())+ run_hook(HookType::PostCreate, force, name.as_deref())}HookCommand::PostStart { name, force } => {- handle_standalone_run_hook(HookType::PostStart, force, name.as_deref())+ run_hook(HookType::PostStart, force, name.as_deref())}HookCommand::PreCommit { name, force } => {- handle_standalone_run_hook(HookType::PreCommit, force, name.as_deref())+ run_hook(HookType::PreCommit, force, name.as_deref())}HookCommand::PreMerge { name, force } => {- handle_standalone_run_hook(HookType::PreMerge, force, name.as_deref())+ run_hook(HookType::PreMerge, force, name.as_deref())}HookCommand::PostMerge { name, force } => {- handle_standalone_run_hook(HookType::PostMerge, force, name.as_deref())+ run_hook(HookType::PostMerge, force, name.as_deref())}HookCommand::PreRemove { name, force } => {- handle_standalone_run_hook(HookType::PreRemove, force, name.as_deref())+ run_hook(HookType::PreRemove, force, name.as_deref())}},#[cfg(unix)]@@ -1038,9 +1067,40 @@ fn main() {} => WorktrunkConfig::load().context("Failed to load config").and_then(|config| {- // Execute switch operation (creates worktree, runs post-create hooks)+ // "Approve at the Gate": collect and approve hooks upfront when creating+ // This ensures approval happens once at the command entry point+ // If user declines, skip hooks but continue with worktree creation+ let approved = if create && verify {+ let repo = Repository::current();+ let repo_root = repo.worktree_base()?;+ // Compute worktree path for template expansion in approval prompt+ let worktree_path = compute_worktree_path(&repo, &branch, &config)?;+ let ctx = CommandContext::new(+ &repo,+ &config,+ &branch,+ &worktree_path,+ &repo_root,+ force,+ );+ approve_hooks(&ctx, &[HookType::PostCreate, HookType::PostStart], &[])?+ } else {+ true // No hooks to approve = considered approved+ };++ // Skip hooks if --no-hooks or user declined approval+ let skip_hooks = !verify || !approved;++ // Show message if user declined approval+ if !approved {+ crate::output::print(info_message(+ "Commands declined, continuing worktree creation",+ ))?;+ }++ // Execute switch operation (creates worktree, runs post-create hooks if approved)let (result, resolved_branch) =- handle_switch(&branch, create, base.as_deref(), force, !verify, &config)?;+ handle_switch(&branch, create, base.as_deref(), force, skip_hooks, &config)?;// Show success message (temporal locality: immediately after worktree creation)// Pass cli.internal to indicate whether shell integration is active@@ -1048,8 +1108,8 @@ fn main() {// Now spawn post-start hooks (background processes, after success message)// Only run post-start commands when creating a NEW worktree, not when switching to existing- // Note: If user declines post-start commands, continue anyway - they're optional- if verify && let SwitchResult::Created { path, .. } = &result {+ // Hooks only run if --no-hooks wasn't passed and approval was granted (or --force used)+ if !skip_hooks && let SwitchResult::Created { path, .. } = &result {let repo = Repository::current();let repo_root = repo.worktree_base()?;let ctx = CommandContext::new(@@ -1060,13 +1120,7 @@ fn main() {&repo_root,force,);- if let Err(e) = ctx.spawn_post_start_commands() {- // Only treat CommandNotApproved as non-fatal (user declined)- // Other errors should still fail- if !is_command_not_approved(&e) {- return Err(e);- }- }+ ctx.spawn_post_start_commands(true)?;}// Execute user command after post-start hooks have been spawned@@ -1082,6 +1136,7 @@ fn main() {force_delete,background,verify,+ force,} => WorktrunkConfig::load().context("Failed to load config").and_then(|config| {@@ -1093,15 +1148,47 @@ fn main() {.into());}+ // "Approve at the Gate": collect and approve pre-remove hooks upfront+ // This ensures approval happens once at the command entry point+ //+ // TODO(pre-remove-context): The approval context uses current worktree (cwd + current_branch),+ // but hooks execute in each target worktree. When removing another worktree, the approval+ // preview shows the wrong branch/path. Consider building approval context per target worktree.+ let repo = Repository::current();+ let verify = if verify {+ // Create context for template expansion in approval prompt+ let worktree_path =+ std::env::current_dir().context("Failed to get current directory")?;+ let repo_root = repo.worktree_base()?;+ let current_branch = repo.current_branch()?.unwrap_or_default();+ let ctx = CommandContext::new(+ &repo,+ &config,+ ¤t_branch,+ &worktree_path,+ &repo_root,+ force,+ );+ let approved = approve_hooks(&ctx, &[HookType::PreRemove], &[])?;+ // If declined, skip hooks but continue with removal+ if !approved {+ crate::output::print(info_message(+ "Commands declined, continuing removal",+ ))?;+ }+ approved+ } else {+ false+ };+if worktrees.is_empty() {// No worktrees specified, remove current worktree// Uses path-based removal to handle detached HEAD statelet result = handle_remove_current(!delete_branch, force_delete, background)?;+ // Approval was handled at the gatehandle_remove_output(&result, None, background, verify)} else {use worktrunk::git::ResolvedWorktree;-- let repo = Repository::current();// When removing multiple worktrees, we need to handle the current worktree last// to avoid deleting the directory we're currently inlet current_worktree = repo.worktree_root().ok();@@ -1127,7 +1214,7 @@ fn main() {}}- // Remove other worktrees first+ // Remove other worktrees first (approval was handled at the gate)for (path, branch) in &others {if let Some(branch_name) = branch {let result = handle_remove(diff --git a/src/output/handlers.rs b/src/output/handlers.rsindex 898a9c60a..ae34b43a8 100644--- a/src/output/handlers.rs+++ b/src/output/handlers.rs@@ -371,6 +371,8 @@ fn build_remove_command(worktree_path: &std::path::Path, branch_to_delete: Optio}/// Handle output for a remove operation+///+/// Approval is handled at the gate (command entry point), not here.pub fn handle_remove_output(result: &RemoveResult,branch: Option<&str>,@@ -484,9 +486,9 @@ fn handle_removed_worktree_output(hook_branch,worktree_path,main_path,- false, // force=false, prompt for approval+ false, // force=false for CommandContext (not approval-related));- execute_pre_remove_commands(&ctx, false, None)?;+ execute_pre_remove_commands(&ctx, None)?;}// Handle detached HEAD case (no branch known)diff --git a/tests/integration_tests/completion.rs b/tests/integration_tests/completion.rsindex 92ce8961c..a041a6db6 100644--- a/tests/integration_tests/completion.rs+++ b/tests/integration_tests/completion.rs@@ -719,7 +719,8 @@ fn test_complete_hook_subcommands() {assert!(output.status.success());let stdout = String::from_utf8_lossy(&output.stdout);let subcommands = value_suggestions(&stdout);- // Hook types+ // Hook types and commands+ assert!(subcommands.contains(&"show"), "Missing show");assert!(subcommands.contains(&"post-create"), "Missing post-create");assert!(subcommands.contains(&"post-start"), "Missing post-start");assert!(subcommands.contains(&"pre-commit"), "Missing pre-commit");@@ -728,8 +729,8 @@ fn test_complete_hook_subcommands() {assert!(subcommands.contains(&"pre-remove"), "Missing pre-remove");assert_eq!(subcommands.len(),- 6,- "Should have exactly 6 hook subcommands"+ 7,+ "Should have exactly 7 hook subcommands");// Test 2: Partial input "po" - filters to post-* subcommandsdiff --git a/tests/integration_tests/hook_show.rs b/tests/integration_tests/hook_show.rsnew file mode 100644index 000000000..81d8c8eab--- /dev/null+++ b/tests/integration_tests/hook_show.rs@@ -0,0 +1,197 @@+//! Integration tests for `wt hook show` command++use crate::common::{TestRepo, set_temp_home_env, setup_snapshot_settings_with_home, wt_command};+use insta_cmd::assert_cmd_snapshot;+use std::fs;+use tempfile::TempDir;++/// Test `wt hook show` with both user and project hooks+#[test]+fn test_hook_show_with_both_configs() {+ let repo = TestRepo::new();+ repo.commit("Initial commit");+ let temp_home = TempDir::new().unwrap();++ // Create user config with hooks+ let global_config_dir = temp_home.path().join(".config").join("worktrunk");+ fs::create_dir_all(&global_config_dir).unwrap();+ fs::write(+ global_config_dir.join("config.toml"),+ r#"worktree-path = "../{{ main_worktree }}.{{ branch }}"++[pre-commit]+user-lint = "pre-commit run --all-files"+"#,+ )+ .unwrap();++ // Create project config with hooks+ repo.write_project_config(+ r#"[post-start]+deps = "npm install"++[pre-merge]+build = "cargo build"+test = "cargo test"+"#,+ );+ repo.commit("Add project config");++ let settings = setup_snapshot_settings_with_home(&repo, &temp_home);+ settings.bind(|| {+ let mut cmd = wt_command();+ repo.clean_cli_env(&mut cmd);+ cmd.arg("hook").arg("show").current_dir(repo.root_path());+ set_temp_home_env(&mut cmd, temp_home.path());++ assert_cmd_snapshot!(cmd);+ });+}++/// Test `wt hook show` with no hooks configured+#[test]+fn test_hook_show_no_hooks() {+ let repo = TestRepo::new();+ repo.commit("Initial commit");+ let temp_home = TempDir::new().unwrap();++ // Create user config without hooks+ let global_config_dir = temp_home.path().join(".config").join("worktrunk");+ fs::create_dir_all(&global_config_dir).unwrap();+ fs::write(+ global_config_dir.join("config.toml"),+ r#"worktree-path = "../{{ main_worktree }}.{{ branch }}"+"#,+ )+ .unwrap();++ let settings = setup_snapshot_settings_with_home(&repo, &temp_home);+ settings.bind(|| {+ let mut cmd = wt_command();+ repo.clean_cli_env(&mut cmd);+ cmd.arg("hook").arg("show").current_dir(repo.root_path());+ set_temp_home_env(&mut cmd, temp_home.path());++ assert_cmd_snapshot!(cmd);+ });+}++/// Test `wt hook show` filtering by hook type+#[test]+fn test_hook_show_filter_by_type() {+ let repo = TestRepo::new();+ repo.commit("Initial commit");+ let temp_home = TempDir::new().unwrap();++ // Create user config without hooks+ let global_config_dir = temp_home.path().join(".config").join("worktrunk");+ fs::create_dir_all(&global_config_dir).unwrap();+ fs::write(+ global_config_dir.join("config.toml"),+ r#"worktree-path = "../{{ main_worktree }}.{{ branch }}"+"#,+ )+ .unwrap();++ // Create project config with multiple hook types+ repo.write_project_config(+ r#"[post-start]+deps = "npm install"++[pre-merge]+build = "cargo build"+test = "cargo test"++[post-merge]+deploy = "scripts/deploy.sh"+"#,+ );+ repo.commit("Add project config");++ let settings = setup_snapshot_settings_with_home(&repo, &temp_home);+ settings.bind(|| {+ let mut cmd = wt_command();+ repo.clean_cli_env(&mut cmd);+ cmd.arg("hook")+ .arg("show")+ .arg("pre-merge")+ .current_dir(repo.root_path());+ set_temp_home_env(&mut cmd, temp_home.path());++ assert_cmd_snapshot!(cmd);+ });+}++/// Test `wt hook show` shows approval status for project hooks+#[test]+fn test_hook_show_approval_status() {+ let repo = TestRepo::new();+ repo.commit("Initial commit");+ let temp_home = TempDir::new().unwrap();++ // Create user config at XDG path with one approved command+ let global_config_dir = temp_home.path().join(".config").join("worktrunk");+ fs::create_dir_all(&global_config_dir).unwrap();+ let config_path = global_config_dir.join("config.toml");+ fs::write(+ &config_path,+ r#"worktree-path = "../{{ main_worktree }}.{{ branch }}"++[projects."repo"]+approved-commands = ["cargo build"]+"#,+ )+ .unwrap();++ // Create project config with approved and unapproved hooks+ repo.write_project_config(+ r#"[pre-merge]+build = "cargo build"+test = "cargo test"+"#,+ );+ repo.commit("Add project config");++ let settings = setup_snapshot_settings_with_home(&repo, &temp_home);+ settings.bind(|| {+ let mut cmd = wt_command();+ repo.clean_cli_env(&mut cmd);+ // Override config path to point to our test config with approval+ cmd.env("WORKTRUNK_CONFIG_PATH", &config_path);+ cmd.arg("hook").arg("show").current_dir(repo.root_path());+ set_temp_home_env(&mut cmd, temp_home.path());++ assert_cmd_snapshot!(cmd);+ });+}++/// Test `wt hook show` outside git repo+#[test]+fn test_hook_show_outside_git_repo() {+ let temp_dir = tempfile::tempdir().unwrap();+ let temp_home = TempDir::new().unwrap();++ // Create user config+ let global_config_dir = temp_home.path().join(".config").join("worktrunk");+ fs::create_dir_all(&global_config_dir).unwrap();+ fs::write(+ global_config_dir.join("config.toml"),+ r#"worktree-path = "../{{ main_worktree }}.{{ branch }}"++[pre-commit]+lint = "pre-commit run"+"#,+ )+ .unwrap();++ let mut settings = insta::Settings::clone_current();+ // Replace temp home path with ~ for stable snapshots+ settings.add_filter(temp_home.path().to_string_lossy().as_ref(), "~");+ settings.bind(|| {+ let mut cmd = wt_command();+ cmd.arg("hook").arg("show").current_dir(temp_dir.path());+ set_temp_home_env(&mut cmd, temp_home.path());++ assert_cmd_snapshot!(cmd);+ });+}diff --git a/tests/integration_tests/merge.rs b/tests/integration_tests/merge.rsindex d56d3cc32..07cc0cca9 100644--- a/tests/integration_tests/merge.rs+++ b/tests/integration_tests/merge.rs@@ -1165,11 +1165,11 @@ fn test_merge_pre_merge_command_no_hooks() {.output().unwrap();- // Merge with --no-hooks - should skip pre-merge commands and succeed+ // Merge with --no-verify - should skip pre-merge commands and succeedsnapshot_merge("merge_pre_merge_command_no_hooks",&repo,- &["main", "--no-hooks"],+ &["main", "--no-verify"],Some(&feature_wt),);}diff --git a/tests/integration_tests/mod.rs b/tests/integration_tests/mod.rsindex 862724890..a8910aaf6 100644--- a/tests/integration_tests/mod.rs+++ b/tests/integration_tests/mod.rs@@ -22,6 +22,7 @@ pub mod directives;pub mod e2e_shell;pub mod e2e_shell_post_start;pub mod help;+pub mod hook_show;pub mod init;pub mod internal_flag;pub mod list;@@ -39,3 +40,4 @@ pub mod shell_wrapper;pub mod spacing_edge_cases;pub mod statusline;pub mod switch;+pub mod user_hooks;diff --git a/tests/integration_tests/shell_wrapper.rs b/tests/integration_tests/shell_wrapper.rsindex 2d5fb51ae..63ed53262 100644--- a/tests/integration_tests/shell_wrapper.rs+++ b/tests/integration_tests/shell_wrapper.rs@@ -1402,8 +1402,8 @@ approved-commands = ["echo 'background task'"]// Critical assertion: progress messages should appear to users// This is the test that catches the bug where progress() is suppressed in directive modeassert!(- output.combined.contains("Running post-start"),- "Progress message 'Running post-start' missing from output. \+ output.combined.contains("Running project post-start"),+ "Progress message 'Running project post-start' missing from output. \Output:\n{}",output.combined);@@ -1469,8 +1469,8 @@ approved-commands = ["echo 'fish background task'"]// Critical: progress messages should appear to users through Fish wrapperassert!(- output.combined.contains("Running post-start"),- "Progress message 'Running post-start' missing from Fish wrapper output. \+ output.combined.contains("Running project post-start"),+ "Progress message 'Running project post-start' missing from Fish wrapper output. \Output:\n{}",output.combined);diff --git a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_accept.snap b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_accept.snapindex 7cdfc107b..6405ec92b 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_accept.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_accept.snap@@ -10,7 +10,7 @@ y[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'test command'[0m[2m[0m❓ Allow and remember? [1m[y/N][22m-🔄 [36mRunning post-create:[39m+🔄 [36mRunning project post-create:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'test command'[0m[2m[0m[0mtest command✅ [32m[32mCreated new worktree for [1mtest-approve[22m from [1mmain[22m at [1m[REPO]/repo.test-approve[39m[22m[39mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_accept.snap b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_accept.snapindex 915e36e51..2ce98cd4d 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_accept.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_accept.snap@@ -13,13 +13,13 @@ y[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Third command'[0m[2m[0m❓ Allow and remember? [1m[y/N][22m-🔄 [36mRunning post-create [1mfirst[22m:[39m+🔄 [36mRunning project post-create [1mfirst[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'First command'[0m[2m[0m[0mFirst command-🔄 [36mRunning post-create [1msecond[22m:[39m+🔄 [36mRunning project post-create [1msecond[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Second command'[0m[2m[0m[0mSecond command-🔄 [36mRunning post-create [1mthird[22m:[39m+🔄 [36mRunning project post-create [1mthird[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Third command'[0m[2m[0m[0mThird command✅ [32m[32mCreated new worktree for [1mtest-mixed-accept[22m from [1mmain[22m at [1m[REPO]/repo.test-mixed-accept[39m[22m[39mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_multiple_commands.snap b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_multiple_commands.snapindex d148b0063..079c27971 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_multiple_commands.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_multiple_commands.snap@@ -16,13 +16,13 @@ y[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Third command'[0m[2m[0m❓ Allow and remember? [1m[y/N][22m-🔄 [36mRunning post-create [1mfirst[22m:[39m+🔄 [36mRunning project post-create [1mfirst[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'First command'[0m[2m[0m[0mFirst command-🔄 [36mRunning post-create [1msecond[22m:[39m+🔄 [36mRunning project post-create [1msecond[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Second command'[0m[2m[0m[0mSecond command-🔄 [36mRunning post-create [1mthird[22m:[39m+🔄 [36mRunning project post-create [1mthird[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Third command'[0m[2m[0m[0mThird command✅ [32m[32mCreated new worktree for [1mtest-multi[22m from [1mmain[22m at [1m[REPO]/repo.test-multi[39m[22m[39mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_named_commands.snap b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_named_commands.snapindex 2b58cb226..703aa1899 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_named_commands.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_named_commands.snap@@ -16,13 +16,13 @@ y[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Running tests...'[0m[2m[0m❓ Allow and remember? [1m[y/N][22m-🔄 [36mRunning post-create [1minstall[22m:[39m+🔄 [36mRunning project post-create [1minstall[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Installing dependencies...'[0m[2m[0m[0mInstalling dependencies...-🔄 [36mRunning post-create [1mbuild[22m:[39m+🔄 [36mRunning project post-create [1mbuild[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Building project...'[0m[2m[0m[0mBuilding project...-🔄 [36mRunning post-create [1mtest[22m:[39m+🔄 [36mRunning project post-create [1mtest[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Running tests...'[0m[2m[0m[0mRunning tests...✅ [32m[32mCreated new worktree for [1mtest-named[22m from [1mmain[22m at [1m[REPO]/repo.test-named[39m[22m[39mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_permission_error.snap b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_permission_error.snapindex 5939dfc2b..c1c28be53 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_permission_error.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_permission_error.snap@@ -12,7 +12,7 @@ y❓ Allow and remember? [1m[y/N][22m🟡 [33mFailed to save command approval: Failed to write config file: Permission denied (os error 13)[39m💡 [2mApproval will be requested again next time.[22m-🔄 [36mRunning post-create:[39m+🔄 [36mRunning project post-create:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'test command'[0m[2m[0m[0mtest command✅ [32m[32mCreated new worktree for [1mtest-permission[22m from [1mmain[22m at [1m[REPO]/repo.test-permission[39m[22m[39mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__hook_show__hook_show_outside_git_repo.snap b/tests/integration_tests/snapshots/integration__integration_tests__hook_show__hook_show_outside_git_repo.snapnew file mode 100644index 000000000..2c0934d21--- /dev/null+++ b/tests/integration_tests/snapshots/integration__integration_tests__hook_show__hook_show_outside_git_repo.snap@@ -0,0 +1,22 @@+---+source: tests/integration_tests/hook_show.rs+info:+ program: wt+ args:+ - hook+ - show+ env:+ CLICOLOR_FORCE: "1"+ COLUMNS: "150"+ GIT_EDITOR: ""+ HOME: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpwjXPMy+ SOURCE_DATE_EPOCH: "1735776000"+ WORKTRUNK_CONFIG_PATH: /nonexistent/test/config.toml+ XDG_CONFIG_HOME: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpwjXPMy/.config+---+success: false+exit_code: 1+----- stdout -----++----- stderr -----+❌ [31mfatal: not a git repository (or any of the parent directories): .git[39mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__fish_wrapper_preserves_progress_messages.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__fish_wrapper_preserves_progress_messages.snapindex cf52dbcc3..aaedd2370 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__fish_wrapper_preserves_progress_messages.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__fish_wrapper_preserves_progress_messages.snap@@ -3,5 +3,5 @@ source: tests/integration_tests/shell_wrapper.rsexpression: output.normalized()---✅ [32m[32mCreated new worktree for [1mfish-bg[22m from [1mmain[22m at [1m[TMPDIR]/repo.fish-bg[39m[22m[39m-🔄 [36mRunning post-start:[39m+🔄 [36mRunning project post-start:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'fish background task'[0m[2m[0mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_mixed_stdout_stderr_bash.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_mixed_stdout_stderr_bash.snapindex fb1e7b3f7..d21e56223 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_mixed_stdout_stderr_bash.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_mixed_stdout_stderr_bash.snap@@ -2,7 +2,7 @@source: tests/integration_tests/shell_wrapper.rsexpression: output.normalized()----🔄 [36mRunning pre-merge [1mcheck1[22m:[39m+🔄 [36mRunning project pre-merge [1mcheck1[22m:[39m[107m [0m [2m[0m[2m[34m[TMPDIR]/repo/mixed-output.sh[0m[2m check1 3[0m[check1] stdout line 1[check1] stderr line 1@@ -12,7 +12,7 @@ expression: output.normalized()[check1] stderr line 3[check1] stdout complete[check1] stderr complete-🔄 [36mRunning pre-merge [1mcheck2[22m:[39m+🔄 [36mRunning project pre-merge [1mcheck2[22m:[39m[107m [0m [2m[0m[2m[34m[TMPDIR]/repo/mixed-output.sh[0m[2m check2 3[0m[check2] stdout line 1[check2] stderr line 1diff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_mixed_stdout_stderr_zsh.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_mixed_stdout_stderr_zsh.snapindex fb1e7b3f7..d21e56223 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_mixed_stdout_stderr_zsh.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_mixed_stdout_stderr_zsh.snap@@ -2,7 +2,7 @@source: tests/integration_tests/shell_wrapper.rsexpression: output.normalized()----🔄 [36mRunning pre-merge [1mcheck1[22m:[39m+🔄 [36mRunning project pre-merge [1mcheck1[22m:[39m[107m [0m [2m[0m[2m[34m[TMPDIR]/repo/mixed-output.sh[0m[2m check1 3[0m[check1] stdout line 1[check1] stderr line 1@@ -12,7 +12,7 @@ expression: output.normalized()[check1] stderr line 3[check1] stdout complete[check1] stderr complete-🔄 [36mRunning pre-merge [1mcheck2[22m:[39m+🔄 [36mRunning project pre-merge [1mcheck2[22m:[39m[107m [0m [2m[0m[2m[34m[TMPDIR]/repo/mixed-output.sh[0m[2m check2 3[0m[check2] stdout line 1[check2] stderr line 1diff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_failure_bash.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_failure_bash.snapindex 9fdb6499f..9e6480cee 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_failure_bash.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_failure_bash.snap@@ -2,10 +2,10 @@source: tests/integration_tests/shell_wrapper.rsexpression: output.normalized()----🔄 [36mRunning pre-merge [1mformat[22m:[39m+🔄 [36mRunning project pre-merge [1mformat[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'✓ Code formatting check passed'[0m[2m[0m✓ Code formatting check passed-🔄 [36mRunning pre-merge [1mtest[22m:[39m+🔄 [36mRunning project pre-merge [1mtest[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'✗ Test suite failed: 3 tests failing'[0m[2m [0m[2m[36m&&[0m[2m [0m[2m[34mexit[0m[2m 1[0m✗ Test suite failed: 3 tests failing❌ [31mpre-merge command failed: [1mtest[22m: exit status: 1[39mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_failure_zsh.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_failure_zsh.snapindex 9fdb6499f..9e6480cee 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_failure_zsh.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_failure_zsh.snap@@ -2,10 +2,10 @@source: tests/integration_tests/shell_wrapper.rsexpression: output.normalized()----🔄 [36mRunning pre-merge [1mformat[22m:[39m+🔄 [36mRunning project pre-merge [1mformat[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'✓ Code formatting check passed'[0m[2m[0m✓ Code formatting check passed-🔄 [36mRunning pre-merge [1mtest[22m:[39m+🔄 [36mRunning project pre-merge [1mtest[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'✗ Test suite failed: 3 tests failing'[0m[2m [0m[2m[36m&&[0m[2m [0m[2m[34mexit[0m[2m 1[0m✗ Test suite failed: 3 tests failing❌ [31mpre-merge command failed: [1mtest[22m: exit status: 1[39mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_success_bash.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_success_bash.snapindex baf781fb8..c3aaf3781 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_success_bash.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_success_bash.snap@@ -2,13 +2,13 @@source: tests/integration_tests/shell_wrapper.rsexpression: output.normalized()----🔄 [36mRunning pre-merge [1mformat[22m:[39m+🔄 [36mRunning project pre-merge [1mformat[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'✓ Code formatting check passed'[0m[2m[0m✓ Code formatting check passed-🔄 [36mRunning pre-merge [1mlint[22m:[39m+🔄 [36mRunning project pre-merge [1mlint[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'✓ Linting passed - no warnings'[0m[2m[0m✓ Linting passed - no warnings-🔄 [36mRunning pre-merge [1mtest[22m:[39m+🔄 [36mRunning project pre-merge [1mtest[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'✓ All 47 tests passed in 2.3s'[0m[2m[0m✓ All 47 tests passed in 2.3s🔄 [36mMerging 1 commit to [1mmain[22m @ [2m[HASH][22m (no commit/squash/rebase needed)[39mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_success_zsh.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_success_zsh.snapindex baf781fb8..c3aaf3781 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_success_zsh.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_success_zsh.snap@@ -2,13 +2,13 @@source: tests/integration_tests/shell_wrapper.rsexpression: output.normalized()----🔄 [36mRunning pre-merge [1mformat[22m:[39m+🔄 [36mRunning project pre-merge [1mformat[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'✓ Code formatting check passed'[0m[2m[0m✓ Code formatting check passed-🔄 [36mRunning pre-merge [1mlint[22m:[39m+🔄 [36mRunning project pre-merge [1mlint[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'✓ Linting passed - no warnings'[0m[2m[0m✓ Linting passed - no warnings-🔄 [36mRunning pre-merge [1mtest[22m:[39m+🔄 [36mRunning project pre-merge [1mtest[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'✓ All 47 tests passed in 2.3s'[0m[2m[0m✓ All 47 tests passed in 2.3s🔄 [36mMerging 1 commit to [1mmain[22m @ [2m[HASH][22m (no commit/squash/rebase needed)[39mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__readme_example_hooks_post_create.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__readme_example_hooks_post_create.snapindex 783df959c..598c5cecf 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__readme_example_hooks_post_create.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__readme_example_hooks_post_create.snap@@ -2,11 +2,11 @@source: tests/integration_tests/shell_wrapper.rsexpression: output.normalized()----🔄 [36mRunning post-create [1minstall[22m:[39m+🔄 [36mRunning project post-create [1minstall[22m:[39m[107m [0m [2m[0m[2m[34muv[0m[2m sync[0mResolved 24 packages in 145msInstalled 24 packages in 1.2s✅ [32m[32mCreated new worktree for [1mfeature-x[22m from [1mmain[22m at [1m[TMPDIR]/repo.feature-x[39m[22m[39m-🔄 [36mRunning post-start [1mdev[22m:[39m+🔄 [36mRunning project post-start [1mdev[22m:[39m[107m [0m [2m[0m[2m[34muv[0m[2m run dev[0mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__readme_example_hooks_pre_merge.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__readme_example_hooks_pre_merge.snapindex 60067d250..f1de064e5 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__readme_example_hooks_pre_merge.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__readme_example_hooks_pre_merge.snap@@ -9,7 +9,7 @@ expression: output.normalized()[107m [0m Implement login and token refresh endpoints with JWT validation.[107m [0m Includes comprehensive test coverage and input validation.✅ [32mSquashed @ [2m[HASH][22m[39m-🔄 [36mRunning pre-merge [1mtest[22m:[39m+🔄 [36mRunning project pre-merge [1mtest[22m:[39m[107m [0m [2m[0m[2m[34muv[0m[2m run pytest[0m============================= test session starts ==============================@@ -21,7 +21,7 @@ tests/test_auth.py::test_token_validation PASSED [100%]============================== 3 passed in 0.8s ===============================-🔄 [36mRunning pre-merge [1mlint[22m:[39m+🔄 [36mRunning project pre-merge [1mlint[22m:[39m[107m [0m [2m[0m[2m[34muv[0m[2m run ruff check[0mAll checks passed!diff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_hooks_zsh.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_hooks_zsh.snapindex 875fd37c6..1ba35ba38 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_hooks_zsh.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_hooks_zsh.snap@@ -2,14 +2,14 @@source: tests/integration_tests/shell_wrapper.rsexpression: output.normalized()----🔄 [36mRunning post-create [1minstall[22m:[39m+🔄 [36mRunning project post-create [1minstall[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Installing dependencies...'[0m[2m[0mInstalling dependencies...-🔄 [36mRunning post-create [1mbuild[22m:[39m+🔄 [36mRunning project post-create [1mbuild[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Building project...'[0m[2m[0mBuilding project...✅ [32m[32mCreated new worktree for [1mfeature-hooks[22m from [1mmain[22m at [1m[TMPDIR]/repo.feature-hooks[39m[22m[39m-🔄 [36mRunning post-start [1mserver[22m:[39m+🔄 [36mRunning project post-start [1mserver[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Starting dev server on port 3000'[0m[2m[0m-🔄 [36mRunning post-start [1mwatch[22m:[39m+🔄 [36mRunning project post-start [1mwatch[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Watching for file changes'[0m[2m[0mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_post_start_command_no_directive_leak.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_post_start_command_no_directive_leak.snapindex 4ff0b1934..c259856b2 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_post_start_command_no_directive_leak.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_post_start_command_no_directive_leak.snap@@ -3,5 +3,5 @@ source: tests/integration_tests/shell_wrapper.rsexpression: output.normalized()---✅ [32m[32mCreated new worktree for [1mfeature-with-hooks[22m from [1mmain[22m at [1m[TMPDIR]/repo.feature-with-hooks[39m[22m[39m-🔄 [36mRunning post-start:[39m+🔄 [36mRunning project post-start:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'test command executed'[0m[2m[0mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__wrapper_preserves_progress_messages.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__wrapper_preserves_progress_messages.snapindex e7d498053..f11476a3a 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__wrapper_preserves_progress_messages.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__wrapper_preserves_progress_messages.snap@@ -3,5 +3,5 @@ source: tests/integration_tests/shell_wrapper.rsexpression: output.normalized()---✅ [32m[32mCreated new worktree for [1mfeature-bg[22m from [1mmain[22m at [1m[TMPDIR]/repo.feature-bg[39m[22m[39m-🔄 [36mRunning post-start:[39m+🔄 [36mRunning project post-start:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'background task'[0m[2m[0mdiff --git a/tests/integration_tests/switch.rs b/tests/integration_tests/switch.rsindex 21cdebc85..305c4538c 100644--- a/tests/integration_tests/switch.rs+++ b/tests/integration_tests/switch.rs@@ -310,7 +310,7 @@ fn test_switch_no_config_commands_execute_still_runs() {"no-hooks-test","--execute","echo 'execute command runs'",- "--no-hooks",+ "--no-verify",],);}@@ -353,11 +353,11 @@ approved-commands = ["{}"]).unwrap();- // With --no-hooks, the post-start command should be skipped+ // With --no-verify, the post-start command should be skippedsnapshot_switch_with_home("switch_no_hooks_skips_post_start",&repo,- &["--create", "no-post-start", "--no-hooks"],+ &["--create", "no-post-start", "--no-verify"],Some(temp_home.path()),&[],);@@ -370,7 +370,7 @@ fn test_switch_no_config_commands_with_existing_worktree() {// Create a worktree firstrepo.add_worktree("existing-no-hooks");- // With --no-hooks, the --execute command should still run+ // With --no-verify, the --execute command should still runsnapshot_switch("switch_no_hooks_existing",&repo,@@ -378,7 +378,7 @@ fn test_switch_no_config_commands_with_existing_worktree() {"existing-no-hooks","--execute","echo 'execute still runs'",- "--no-hooks",+ "--no-verify",],);}@@ -402,11 +402,11 @@ fn test_switch_no_config_commands_with_force() {repo.commit("Add config");- // With --no-hooks, even --force shouldn't execute config commands+ // With --no-verify, even --force shouldn't execute config commandssnapshot_switch_with_home("switch_no_hooks_with_force",&repo,- &["--create", "force-no-hooks", "--force", "--no-hooks"],+ &["--create", "force-no-hooks", "--force", "--no-verify"],Some(temp_home.path()),&[],);diff --git a/tests/integration_tests/user_hooks.rs b/tests/integration_tests/user_hooks.rsnew file mode 100644index 000000000..b4371260f--- /dev/null+++ b/tests/integration_tests/user_hooks.rs@@ -0,0 +1,727 @@+//! Integration tests for user-level hooks (~/.config/worktrunk/config.toml)+//!+//! User hooks differ from project hooks:+//! - Run for all repositories+//! - Execute before project hooks+//! - Don't require approval+//! - Skipped together with project hooks via --no-verify++use crate::common::{TestRepo, make_snapshot_cmd, setup_snapshot_settings, wait_for_file};+use insta_cmd::assert_cmd_snapshot;+use std::fs;+use std::process::Command;+use std::thread;+use std::time::Duration;++/// Wait duration when checking file absence (testing command did NOT run).+const SLEEP_FOR_ABSENCE_CHECK: Duration = Duration::from_millis(500);++// ============================================================================+// User Post-Create Hook Tests+// ============================================================================++/// Helper to create snapshot for switch commands+fn snapshot_switch(test_name: &str, repo: &TestRepo, args: &[&str]) {+ let settings = setup_snapshot_settings(repo);+ settings.bind(|| {+ let mut cmd = make_snapshot_cmd(repo, "switch", args, None);+ assert_cmd_snapshot!(test_name, cmd);+ });+}++#[test]+fn test_user_post_create_hook_executes() {+ let repo = TestRepo::new();+ repo.commit("Initial commit");++ // Write user config with post-create hook (no project config)+ repo.write_test_config(+ r#"worktree-path = "../{{ main_worktree }}.{{ branch }}"++[post-create]+log = "echo 'USER_POST_CREATE_RAN' > user_hook_marker.txt"+"#,+ );++ snapshot_switch("user_post_create_executes", &repo, &["--create", "feature"]);++ // Verify user hook actually ran+ let worktree_path = repo.root_path().parent().unwrap().join("repo.feature");+ let marker_file = worktree_path.join("user_hook_marker.txt");+ assert!(+ marker_file.exists(),+ "User post-create hook should have created marker file"+ );++ let contents = fs::read_to_string(&marker_file).unwrap();+ assert!(+ contents.contains("USER_POST_CREATE_RAN"),+ "Marker file should contain expected content"+ );+}++#[test]+fn test_user_hooks_run_before_project_hooks() {+ let repo = TestRepo::new();+ repo.commit("Initial commit");++ // Create project config with post-create hook+ repo.write_project_config(r#"post-create = "echo 'PROJECT_HOOK' >> hook_order.txt""#);+ repo.commit("Add project config");++ // Write user config with user hook AND pre-approve project command+ repo.write_test_config(+ r#"worktree-path = "../{{ main_worktree }}.{{ branch }}"++[post-create]+log = "echo 'USER_HOOK' >> hook_order.txt"++[projects."repo"]+approved-commands = ["echo 'PROJECT_HOOK' >> hook_order.txt"]+"#,+ );++ snapshot_switch("user_hooks_before_project", &repo, &["--create", "feature"]);++ // Verify execution order+ let worktree_path = repo.root_path().parent().unwrap().join("repo.feature");+ let order_file = worktree_path.join("hook_order.txt");+ assert!(order_file.exists(), "Hook order file should exist");++ let contents = fs::read_to_string(&order_file).unwrap();+ let lines: Vec<&str> = contents.lines().collect();++ assert_eq!(lines.len(), 2, "Should have two hooks executed");+ assert_eq!(lines[0], "USER_HOOK", "User hook should run first");+ assert_eq!(lines[1], "PROJECT_HOOK", "Project hook should run second");+}++#[test]+fn test_user_hooks_no_approval_required() {+ let repo = TestRepo::new();+ repo.commit("Initial commit");++ // Write user config with hook but NO pre-approved commands+ // (unlike project hooks, user hooks don't require approval)+ repo.write_test_config(+ r#"worktree-path = "../{{ main_worktree }}.{{ branch }}"++[post-create]+setup = "echo 'NO_APPROVAL_NEEDED' > no_approval.txt"+"#,+ );++ snapshot_switch("user_hooks_no_approval", &repo, &["--create", "feature"]);++ // Verify hook ran without approval+ let worktree_path = repo.root_path().parent().unwrap().join("repo.feature");+ let marker_file = worktree_path.join("no_approval.txt");+ assert!(+ marker_file.exists(),+ "User hook should run without pre-approval"+ );+}++#[test]+fn test_no_verify_flag_skips_all_hooks() {+ let repo = TestRepo::new();+ repo.commit("Initial commit");++ // Create project config with post-create hook+ repo.write_project_config(r#"post-create = "echo 'PROJECT_HOOK' > project_marker.txt""#);+ repo.commit("Add project config");++ // Write user config with both user hook and pre-approved project command+ repo.write_test_config(+ r#"worktree-path = "../{{ main_worktree }}.{{ branch }}"++[post-create]+log = "echo 'USER_HOOK' > user_marker.txt"++[projects."repo"]+approved-commands = ["echo 'PROJECT_HOOK' > project_marker.txt"]+"#,+ );++ // Create worktree with --no-verify (skips ALL hooks)+ snapshot_switch(+ "no_verify_skips_all_hooks",+ &repo,+ &["--create", "feature", "--no-verify"],+ );++ let worktree_path = repo.root_path().parent().unwrap().join("repo.feature");++ // User hook should NOT have run+ let user_marker = worktree_path.join("user_marker.txt");+ assert!(+ !user_marker.exists(),+ "User hook should be skipped with --no-verify"+ );++ // Project hook should also NOT have run (--no-verify skips ALL hooks)+ let project_marker = worktree_path.join("project_marker.txt");+ assert!(+ !project_marker.exists(),+ "Project hook should also be skipped with --no-verify"+ );+}++#[test]+fn test_user_post_create_hook_failure() {+ let repo = TestRepo::new();+ repo.commit("Initial commit");++ // Write user config with failing hook+ repo.write_test_config(+ r#"worktree-path = "../{{ main_worktree }}.{{ branch }}"++[post-create]+failing = "exit 1"+"#,+ );++ // Failing user hook should produce warning but not block creation+ snapshot_switch("user_post_create_failure", &repo, &["--create", "feature"]);++ // Worktree should still be created despite hook failure+ let worktree_path = repo.root_path().parent().unwrap().join("repo.feature");+ assert!(+ worktree_path.exists(),+ "Worktree should be created even if post-create hook fails"+ );+}++// ============================================================================+// User Post-Start Hook Tests (Background)+// ============================================================================++#[test]+fn test_user_post_start_hook_executes() {+ let repo = TestRepo::new();+ repo.commit("Initial commit");++ // Write user config with post-start hook (background)+ repo.write_test_config(+ r#"worktree-path = "../{{ main_worktree }}.{{ branch }}"++[post-start]+bg = "echo 'USER_POST_START_RAN' > user_bg_marker.txt"+"#,+ );++ snapshot_switch("user_post_start_executes", &repo, &["--create", "feature"]);++ // Wait for background hook to complete+ let worktree_path = repo.root_path().parent().unwrap().join("repo.feature");+ let marker_file = worktree_path.join("user_bg_marker.txt");+ wait_for_file(&marker_file, Duration::from_secs(5));++ let contents = fs::read_to_string(&marker_file).unwrap();+ assert!(+ contents.contains("USER_POST_START_RAN"),+ "User post-start hook should have run in background"+ );+}++#[test]+fn test_user_post_start_skipped_with_no_verify() {+ let repo = TestRepo::new();+ repo.commit("Initial commit");++ // Write user config with post-start hook+ repo.write_test_config(+ r#"worktree-path = "../{{ main_worktree }}.{{ branch }}"++[post-start]+bg = "echo 'USER_BG' > user_bg_marker.txt"+"#,+ );++ snapshot_switch(+ "user_post_start_skipped_no_verify",+ &repo,+ &["--create", "feature", "--no-verify"],+ );++ // Wait to ensure background hook would have had time to run+ thread::sleep(SLEEP_FOR_ABSENCE_CHECK);++ let worktree_path = repo.root_path().parent().unwrap().join("repo.feature");+ let marker_file = worktree_path.join("user_bg_marker.txt");+ assert!(+ !marker_file.exists(),+ "User post-start hook should be skipped with --no-verify"+ );+}++// ============================================================================+// User Pre-Merge Hook Tests+// ============================================================================++/// Helper for merge snapshots+fn snapshot_merge(test_name: &str, repo: &TestRepo, args: &[&str], cwd: Option<&std::path::Path>) {+ let settings = setup_snapshot_settings(repo);+ settings.bind(|| {+ let mut cmd = make_snapshot_cmd(repo, "merge", args, cwd);+ assert_cmd_snapshot!(test_name, cmd);+ });+}++#[test]+fn test_user_pre_merge_hook_executes() {+ let mut repo = TestRepo::new();+ repo.commit("Initial commit");+ repo.setup_remote("main");++ // Create feature worktree with a commit+ let feature_wt = repo.add_worktree("feature");+ fs::write(feature_wt.join("feature.txt"), "feature content").unwrap();++ let mut cmd = Command::new("git");+ repo.configure_git_cmd(&mut cmd);+ cmd.current_dir(&feature_wt)+ .args(["add", "."])+ .output()+ .unwrap();++ let mut cmd = Command::new("git");+ repo.configure_git_cmd(&mut cmd);+ cmd.current_dir(&feature_wt)+ .args(["commit", "-m", "Add feature"])+ .output()+ .unwrap();++ // Write user config with pre-merge hook+ repo.write_test_config(+ r#"worktree-path = "../{{ main_worktree }}.{{ branch }}"++[pre-merge]+check = "echo 'USER_PRE_MERGE_RAN' > user_premerge.txt"+"#,+ );++ snapshot_merge(+ "user_pre_merge_executes",+ &repo,+ &["main", "--force", "--no-remove"],+ Some(&feature_wt),+ );++ // Verify user hook ran+ let marker_file = feature_wt.join("user_premerge.txt");+ assert!(marker_file.exists(), "User pre-merge hook should have run");+}++#[test]+fn test_user_pre_merge_hook_failure_blocks_merge() {+ let mut repo = TestRepo::new();+ repo.commit("Initial commit");+ repo.setup_remote("main");++ // Create feature worktree with a commit+ let feature_wt = repo.add_worktree("feature");+ fs::write(feature_wt.join("feature.txt"), "feature content").unwrap();++ let mut cmd = Command::new("git");+ repo.configure_git_cmd(&mut cmd);+ cmd.current_dir(&feature_wt)+ .args(["add", "."])+ .output()+ .unwrap();++ let mut cmd = Command::new("git");+ repo.configure_git_cmd(&mut cmd);+ cmd.current_dir(&feature_wt)+ .args(["commit", "-m", "Add feature"])+ .output()+ .unwrap();++ // Write user config with failing pre-merge hook+ repo.write_test_config(+ r#"worktree-path = "../{{ main_worktree }}.{{ branch }}"++[pre-merge]+check = "exit 1"+"#,+ );++ // Failing pre-merge hook should block the merge+ snapshot_merge(+ "user_pre_merge_failure",+ &repo,+ &["main", "--force", "--no-remove"],+ Some(&feature_wt),+ );+}++#[test]+fn test_user_pre_merge_skipped_with_no_verify() {+ let mut repo = TestRepo::new();+ repo.commit("Initial commit");+ repo.setup_remote("main");++ // Create feature worktree with a commit+ let feature_wt = repo.add_worktree("feature");+ fs::write(feature_wt.join("feature.txt"), "feature content").unwrap();++ let mut cmd = Command::new("git");+ repo.configure_git_cmd(&mut cmd);+ cmd.current_dir(&feature_wt)+ .args(["add", "."])+ .output()+ .unwrap();++ let mut cmd = Command::new("git");+ repo.configure_git_cmd(&mut cmd);+ cmd.current_dir(&feature_wt)+ .args(["commit", "-m", "Add feature"])+ .output()+ .unwrap();++ // Write user config with pre-merge hook that creates a marker+ repo.write_test_config(+ r#"worktree-path = "../{{ main_worktree }}.{{ branch }}"++[pre-merge]+check = "echo 'USER_PRE_MERGE' > user_premerge_marker.txt"+"#,+ );++ snapshot_merge(+ "user_pre_merge_skipped_no_verify",+ &repo,+ &["main", "--force", "--no-remove", "--no-verify"],+ Some(&feature_wt),+ );++ // User hook should NOT have run (--no-verify skips all hooks)+ let marker_file = feature_wt.join("user_premerge_marker.txt");+ assert!(+ !marker_file.exists(),+ "User pre-merge hook should be skipped with --no-verify"+ );+}++// ============================================================================+// User Post-Merge Hook Tests+// ============================================================================++#[test]+fn test_user_post_merge_hook_executes() {+ let mut repo = TestRepo::new();+ repo.commit("Initial commit");+ repo.setup_remote("main");++ // Create feature worktree with a commit+ let feature_wt = repo.add_worktree("feature");+ fs::write(feature_wt.join("feature.txt"), "feature content").unwrap();++ let mut cmd = Command::new("git");+ repo.configure_git_cmd(&mut cmd);+ cmd.current_dir(&feature_wt)+ .args(["add", "."])+ .output()+ .unwrap();++ let mut cmd = Command::new("git");+ repo.configure_git_cmd(&mut cmd);+ cmd.current_dir(&feature_wt)+ .args(["commit", "-m", "Add feature"])+ .output()+ .unwrap();++ // Write user config with post-merge hook+ repo.write_test_config(+ r#"worktree-path = "../{{ main_worktree }}.{{ branch }}"++[post-merge]+notify = "echo 'USER_POST_MERGE_RAN' > user_postmerge.txt"+"#,+ );++ snapshot_merge(+ "user_post_merge_executes",+ &repo,+ &["main", "--force", "--no-remove"],+ Some(&feature_wt),+ );++ // Post-merge runs in the destination (main) worktree+ let main_worktree = repo.root_path();+ let marker_file = main_worktree.join("user_postmerge.txt");+ assert!(+ marker_file.exists(),+ "User post-merge hook should have run in main worktree"+ );+}++// ============================================================================+// User Pre-Remove Hook Tests+// ============================================================================++/// Helper for remove snapshots+fn snapshot_remove(test_name: &str, repo: &TestRepo, args: &[&str], cwd: Option<&std::path::Path>) {+ let settings = setup_snapshot_settings(repo);+ settings.bind(|| {+ let mut cmd = make_snapshot_cmd(repo, "remove", args, cwd);+ assert_cmd_snapshot!(test_name, cmd);+ });+}++#[test]+fn test_user_pre_remove_hook_executes() {+ let mut repo = TestRepo::new();+ repo.commit("Initial commit");++ // Create a worktree to remove+ let _feature_wt = repo.add_worktree("feature");++ // Write user config with pre-remove hook+ repo.write_test_config(+ r#"worktree-path = "../{{ main_worktree }}.{{ branch }}"++[pre-remove]+cleanup = "echo 'USER_PRE_REMOVE_RAN' > /tmp/user_preremove_marker.txt"+"#,+ );++ snapshot_remove(+ "user_pre_remove_executes",+ &repo,+ &["feature", "--force-delete"],+ Some(repo.root_path()),+ );++ // Verify user hook ran (writes to /tmp since worktree is being removed)+ let marker_file = std::path::Path::new("/tmp/user_preremove_marker.txt");+ assert!(marker_file.exists(), "User pre-remove hook should have run");+ // Clean up+ let _ = fs::remove_file(marker_file);+}++#[test]+fn test_user_pre_remove_failure_blocks_removal() {+ let mut repo = TestRepo::new();+ repo.commit("Initial commit");++ // Create a worktree to remove+ let feature_wt = repo.add_worktree("feature");++ // Write user config with failing pre-remove hook+ repo.write_test_config(+ r#"worktree-path = "../{{ main_worktree }}.{{ branch }}"++[pre-remove]+block = "exit 1"+"#,+ );++ snapshot_remove(+ "user_pre_remove_failure",+ &repo,+ &["feature", "--force-delete"],+ Some(repo.root_path()),+ );++ // Worktree should still exist (removal blocked by failing hook)+ assert!(+ feature_wt.exists(),+ "Worktree should not be removed when pre-remove hook fails"+ );+}++#[test]+fn test_user_pre_remove_skipped_with_no_verify() {+ let mut repo = TestRepo::new();+ repo.commit("Initial commit");++ // Create a worktree to remove+ let feature_wt = repo.add_worktree("feature");++ // Write user config with pre-remove hook that would block+ repo.write_test_config(+ r#"worktree-path = "../{{ main_worktree }}.{{ branch }}"++[pre-remove]+block = "exit 1"+"#,+ );++ // With --no-verify, all hooks (including the failing one) should be skipped+ snapshot_remove(+ "user_pre_remove_skipped_no_verify",+ &repo,+ &["feature", "--force-delete", "--no-verify"],+ Some(repo.root_path()),+ );++ // Worktree should be removed (hooks skipped)+ // Background removal needs time to complete+ let timeout = Duration::from_secs(5);+ let poll_interval = Duration::from_millis(50);+ let start = std::time::Instant::now();+ while feature_wt.exists() && start.elapsed() < timeout {+ thread::sleep(poll_interval);+ }+ assert!(+ !feature_wt.exists(),+ "Worktree should be removed when --no-verify skips failing hook"+ );+}++// ============================================================================+// User Pre-Commit Hook Tests+// ============================================================================++#[test]+fn test_user_pre_commit_hook_executes() {+ let mut repo = TestRepo::new();+ repo.commit("Initial commit");+ repo.setup_remote("main");++ // Create feature worktree+ let feature_wt = repo.add_worktree("feature");++ // Add uncommitted changes (triggers pre-commit during merge)+ fs::write(feature_wt.join("uncommitted.txt"), "uncommitted content").unwrap();++ // Write user config with pre-commit hook+ repo.write_test_config(+ r#"worktree-path = "../{{ main_worktree }}.{{ branch }}"++[pre-commit]+lint = "echo 'USER_PRE_COMMIT_RAN' > user_precommit.txt"+"#,+ );++ snapshot_merge(+ "user_pre_commit_executes",+ &repo,+ &["main", "--force", "--no-remove"],+ Some(&feature_wt),+ );++ // Verify user hook ran+ let marker_file = feature_wt.join("user_precommit.txt");+ assert!(marker_file.exists(), "User pre-commit hook should have run");+}++#[test]+fn test_user_pre_commit_failure_blocks_commit() {+ let mut repo = TestRepo::new();+ repo.commit("Initial commit");+ repo.setup_remote("main");++ // Create feature worktree+ let feature_wt = repo.add_worktree("feature");++ // Add uncommitted changes+ fs::write(feature_wt.join("uncommitted.txt"), "uncommitted content").unwrap();++ // Write user config with failing pre-commit hook+ repo.write_test_config(+ r#"worktree-path = "../{{ main_worktree }}.{{ branch }}"++[pre-commit]+lint = "exit 1"+"#,+ );++ // Failing pre-commit hook should block the merge+ snapshot_merge(+ "user_pre_commit_failure",+ &repo,+ &["main", "--force", "--no-remove"],+ Some(&feature_wt),+ );+}++// ============================================================================+// Template Variable Tests+// ============================================================================++#[test]+fn test_user_hook_template_variables() {+ let repo = TestRepo::new();+ repo.commit("Initial commit");++ // Write user config with hook using template variables+ repo.write_test_config(+ r#"worktree-path = "../{{ main_worktree }}.{{ branch }}"++[post-create]+vars = "echo 'repo={{ repo }} branch={{ branch }}' > template_vars.txt"+"#,+ );++ snapshot_switch("user_hook_template_vars", &repo, &["--create", "feature"]);++ // Verify template variables were expanded+ let worktree_path = repo.root_path().parent().unwrap().join("repo.feature");+ let vars_file = worktree_path.join("template_vars.txt");+ assert!(vars_file.exists(), "Template vars file should exist");++ let contents = fs::read_to_string(&vars_file).unwrap();+ assert!(+ contents.contains("repo=repo"),+ "Should have expanded repo variable: {}",+ contents+ );+ assert!(+ contents.contains("branch=feature"),+ "Should have expanded branch variable: {}",+ contents+ );+}++// ============================================================================+// Combined User and Project Hooks Tests+// ============================================================================++#[test]+fn test_user_and_project_post_start_both_run() {+ let repo = TestRepo::new();+ repo.commit("Initial commit");++ // Create project config with post-start hook+ repo.write_project_config(r#"post-start = "echo 'PROJECT_POST_START' > project_bg.txt""#);+ repo.commit("Add project config");++ // Write user config with user hook AND pre-approve project command+ repo.write_test_config(+ r#"worktree-path = "../{{ main_worktree }}.{{ branch }}"++[post-start]+bg = "echo 'USER_POST_START' > user_bg.txt"++[projects."repo"]+approved-commands = ["echo 'PROJECT_POST_START' > project_bg.txt"]+"#,+ );++ snapshot_switch(+ "user_and_project_post_start",+ &repo,+ &["--create", "feature"],+ );++ let worktree_path = repo.root_path().parent().unwrap().join("repo.feature");++ // Wait for both background commands+ wait_for_file(&worktree_path.join("user_bg.txt"), Duration::from_secs(5));+ wait_for_file(+ &worktree_path.join("project_bg.txt"),+ Duration::from_secs(5),+ );++ // Both should have run+ assert!(+ worktree_path.join("user_bg.txt").exists(),+ "User post-start should have run"+ );+ assert!(+ worktree_path.join("project_bg.txt").exists(),+ "Project post-start should have run"+ );+}diff --git a/tests/snapshots/integration__integration_tests__approval_ui__already_approved_skip_prompt.snap b/tests/snapshots/integration__integration_tests__approval_ui__already_approved_skip_prompt.snapindex 012bc53b8..22760621f 100644--- a/tests/snapshots/integration__integration_tests__approval_ui__already_approved_skip_prompt.snap+++ b/tests/snapshots/integration__integration_tests__approval_ui__already_approved_skip_prompt.snap@@ -24,7 +24,7 @@ exit_code: 0----- stdout ---------- stderr ------🔄 [36mRunning post-create:[39m+🔄 [36mRunning project post-create:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'approved'[0m[2m [0m[2m[36m>[0m[2m output.txt[0m[0m✅ [32m[32mCreated new worktree for [1mtest-approved[22m from [1mmain[22m at [1m[REPO].test-approved[39m[22m[39m💡 [2mRun [90mwt config shell install[39m to enable automatic cd[22mdiff --git a/tests/snapshots/integration__integration_tests__approval_ui__force_bypasses_tty_check.snap b/tests/snapshots/integration__integration_tests__approval_ui__force_bypasses_tty_check.snapindex 9549bcfec..73894efbe 100644--- a/tests/snapshots/integration__integration_tests__approval_ui__force_bypasses_tty_check.snap+++ b/tests/snapshots/integration__integration_tests__approval_ui__force_bypasses_tty_check.snap@@ -25,7 +25,7 @@ exit_code: 0----- stdout ---------- stderr ------🔄 [36mRunning post-create:[39m+🔄 [36mRunning project post-create:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'test command'[0m[2m[0m[0mtest command✅ [32m[32mCreated new worktree for [1mtest-force-tty[22m from [1mmain[22m at [1m[REPO].test-force-tty[39m[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__approval_ui__force_does_not_save_approvals_first_run.snap b/tests/snapshots/integration__integration_tests__approval_ui__force_does_not_save_approvals_first_run.snapindex fb75202da..b517ac0f9 100644--- a/tests/snapshots/integration__integration_tests__approval_ui__force_does_not_save_approvals_first_run.snap+++ b/tests/snapshots/integration__integration_tests__approval_ui__force_does_not_save_approvals_first_run.snap@@ -25,7 +25,7 @@ exit_code: 0----- stdout ---------- stderr ------🔄 [36mRunning post-create:[39m+🔄 [36mRunning project post-create:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'test command'[0m[2m [0m[2m[36m>[0m[2m output.txt[0m[0m✅ [32m[32mCreated new worktree for [1mtest-force[22m from [1mmain[22m at [1m[REPO].test-force[39m[22m[39m💡 [2mRun [90mwt config shell install[39m to enable automatic cd[22mdiff --git a/tests/snapshots/integration__integration_tests__approval_ui__step_hook_unknown_name_error.snap b/tests/snapshots/integration__integration_tests__approval_ui__step_hook_unknown_name_error.snapindex 87d89ee74..0a5d5a6b0 100644--- a/tests/snapshots/integration__integration_tests__approval_ui__step_hook_unknown_name_error.snap+++ b/tests/snapshots/integration__integration_tests__approval_ui__step_hook_unknown_name_error.snap@@ -3,7 +3,7 @@ source: tests/integration_tests/approval_ui.rsinfo:program: wtargs:- - step+ - hook- pre-merge- nonexistent- "--force"@@ -25,4 +25,4 @@ exit_code: 1----- stdout ---------- stderr ------❌ [31mNo command named [1mnonexistent[22m (available: [1mtest[22m, [1mlint[22m)[39m+❌ [31mNo command named [1mnonexistent[22m (available: [1mproject:test[22m, [1mproject:lint[22m)[39mdiff --git a/tests/snapshots/integration__integration_tests__help__help_config_create.snap b/tests/snapshots/integration__integration_tests__help__help_config_create.snapindex 80366e781..76c05d1d1 100644--- a/tests/snapshots/integration__integration_tests__help__help_config_create.snap+++ b/tests/snapshots/integration__integration_tests__help__help_config_create.snap@@ -273,7 +273,7 @@ With [2m--project[0m, creates [2m.config/wt.toml[0m in the current repositor[2m# Use for: uv sync, npm install, bundle install, build, dev servers, file watchers,[0m[2m# downloading assets too large for git (images, ML models, binaries), long-running tasks[0m[2m# The worktree switch completes immediately, these run in parallel[0m- [2m# Output is logged to .git/wt-logs/{branch}-post-start-{name}.log[0m+ [2m# Output is logged to .git/wt-logs/{branch}-{source}-post-start-{name}.log (source: user/project)[0m[2m#[0m[2m# Format options:[0m[2m# 1. Single string:[0mdiff --git a/tests/snapshots/integration__integration_tests__help__help_config_long.snap b/tests/snapshots/integration__integration_tests__help__help_config_long.snapindex 8f81545eb..c932ca09c 100644--- a/tests/snapshots/integration__integration_tests__help__help_config_long.snap+++ b/tests/snapshots/integration__integration_tests__help__help_config_long.snap@@ -120,7 +120,7 @@ Set persistent flag values for commands. These apply unless explicitly overridde[2msquash = false # Preserve individual commits (--no-squash)[0m[2mcommit = false # Skip committing uncommitted changes (--no-commit)[0m[2mremove = false # Keep worktree after merge (--no-remove)[0m- [2mverify = false # Skip project hooks (--no-verify)[0m+ [2mverify = false # Skip hooks (--no-verify)[0m[1mLLM commit messages[0m@@ -145,6 +145,20 @@ When project hooks run for the first time, Worktrunk prompts for approval. ApproManage approvals with [2mwt config approvals add[0m to review and pre-approve commands, and [2mwt config approvals clear[0m to reset (add [2m--global[0m to clearall projects).+[1mUser hooks[0m++Personal hooks that run for all repositories. Use the same syntax as project hooks:++ [2m[post-create][0m+ [2msetup = "echo 'Setting up worktree...'"[0m+ [2m[0m+ [2m[pre-merge][0m+ [2mnotify = "notify-send 'Merging {{ branch }}'"[0m++User hooks run before project hooks and don't require approval. Skip with [2m--no-verify[0m.++See wt hook for complete documentation.+[32mProject config[0mThe project config defines lifecycle hooks — commands that run at specific points during worktree operations. This file is checked into versiondiff --git a/tests/snapshots/integration__integration_tests__help__help_merge_long.snap b/tests/snapshots/integration__integration_tests__help__help_merge_long.snapindex 5eac2ce91..479c131e3 100644--- a/tests/snapshots/integration__integration_tests__help__help_merge_long.snap+++ b/tests/snapshots/integration__integration_tests__help__help_merge_long.snap@@ -38,7 +38,7 @@ Usage: [1m[36mwt merge[0m [36m[OPTIONS][0m [36m[TARGET][0mKeep worktree after merge[1m[36m--no-verify[0m- Skip all project hooks+ Skip hooks[1m[36m-f[0m, [1m[36m--force[0mSkip approval promptsdiff --git a/tests/snapshots/integration__integration_tests__help__help_merge_short.snap b/tests/snapshots/integration__integration_tests__help__help_merge_short.snapindex 8154afcd3..be42e29d7 100644--- a/tests/snapshots/integration__integration_tests__help__help_merge_short.snap+++ b/tests/snapshots/integration__integration_tests__help__help_merge_short.snap@@ -28,7 +28,7 @@ Usage: [1m[36mwt merge[0m [36m[OPTIONS][0m [36m[TARGET][0m[1m[36m--no-squash[0m Skip commit squashing[1m[36m--no-commit[0m Skip commit, squash, and rebase[1m[36m--no-remove[0m Keep worktree after merge- [1m[36m--no-verify[0m Skip all project hooks+ [1m[36m--no-verify[0m Skip hooks[1m[36m-f[0m, [1m[36m--force[0m Skip approval prompts[1m[36m--stage[0m[36m [0m[36m<STAGE>[0m What to stage before committing [default: all] [possible values: all, tracked, none][1m[36m-h[0m, [1m[36m--help[0m Print help (see more with '--help')diff --git a/tests/snapshots/integration__integration_tests__help__help_no_args.snap b/tests/snapshots/integration__integration_tests__help__help_no_args.snapindex 93c73819a..4cf8c3379 100644--- a/tests/snapshots/integration__integration_tests__help__help_no_args.snap+++ b/tests/snapshots/integration__integration_tests__help__help_no_args.snap@@ -22,7 +22,7 @@ Usage: [1m[36mwt[0m [36m[OPTIONS][0m [36m[COMMAND][0m[1m[32mCommands:[0m[1m[36mconfig[0m Manage configuration and shell integration[1m[36mstep[0m Run individual workflow operations- [1m[36mhook[0m Run project hooks+ [1m[36mhook[0m Run hooks independently[1m[36mselect[0m Interactive worktree selector[1m[36mlist[0m List worktrees and optionally branches[1m[36mswitch[0m Switch to a worktreediff --git a/tests/snapshots/integration__integration_tests__help__help_remove_long.snap b/tests/snapshots/integration__integration_tests__help__help_remove_long.snapindex 65e020305..aa5104f0c 100644--- a/tests/snapshots/integration__integration_tests__help__help_remove_long.snap+++ b/tests/snapshots/integration__integration_tests__help__help_remove_long.snap@@ -36,7 +36,10 @@ Usage: [1m[36mwt remove[0m [36m[OPTIONS][0m [36m[WORKTREES]...[0mRun removal in foreground[1m[36m--no-verify[0m- Skip pre-remove hooks+ Skip hooks++ [1m[36m--force[0m+ Skip approval prompts[1m[36m-h[0m, [1m[36m--help[0mPrint help (see a summary with '-h')diff --git a/tests/snapshots/integration__integration_tests__help__help_remove_short.snap b/tests/snapshots/integration__integration_tests__help__help_remove_short.snapindex c98b432d7..b4412dbe7 100644--- a/tests/snapshots/integration__integration_tests__help__help_remove_short.snap+++ b/tests/snapshots/integration__integration_tests__help__help_remove_short.snap@@ -28,7 +28,8 @@ Usage: [1m[36mwt remove[0m [36m[OPTIONS][0m [36m[WORKTREES]...[0m[1m[36m--no-delete-branch[0m Keep branch after removal[1m[36m-D[0m, [1m[36m--force-delete[0m Delete unmerged branches[1m[36m--no-background[0m Run removal in foreground- [1m[36m--no-verify[0m Skip pre-remove hooks+ [1m[36m--no-verify[0m Skip hooks+ [1m[36m--force[0m Skip approval prompts[1m[36m-h[0m, [1m[36m--help[0m Print help (see more with '--help')[1m[32mGlobal Options:[0mdiff --git a/tests/snapshots/integration__integration_tests__help__help_root_long.snap b/tests/snapshots/integration__integration_tests__help__help_root_long.snapindex f97fdaf31..35e1fe314 100644--- a/tests/snapshots/integration__integration_tests__help__help_root_long.snap+++ b/tests/snapshots/integration__integration_tests__help__help_root_long.snap@@ -23,7 +23,7 @@ Usage: [1m[36mwt[0m [36m[OPTIONS][0m [36m[COMMAND][0m[1m[32mCommands:[0m[1m[36mconfig[0m Manage configuration and shell integration[1m[36mstep[0m Run individual workflow operations- [1m[36mhook[0m Run project hooks+ [1m[36mhook[0m Run hooks independently[1m[36mselect[0m Interactive worktree selector[1m[36mlist[0m List worktrees and optionally branches[1m[36mswitch[0m Switch to a worktreediff --git a/tests/snapshots/integration__integration_tests__help__help_root_short.snap b/tests/snapshots/integration__integration_tests__help__help_root_short.snapindex e78df219d..889f4774b 100644--- a/tests/snapshots/integration__integration_tests__help__help_root_short.snap+++ b/tests/snapshots/integration__integration_tests__help__help_root_short.snap@@ -23,7 +23,7 @@ Usage: [1m[36mwt[0m [36m[OPTIONS][0m [36m[COMMAND][0m[1m[32mCommands:[0m[1m[36mconfig[0m Manage configuration and shell integration[1m[36mstep[0m Run individual workflow operations- [1m[36mhook[0m Run project hooks+ [1m[36mhook[0m Run hooks independently[1m[36mselect[0m Interactive worktree selector[1m[36mlist[0m List worktrees and optionally branches[1m[36mswitch[0m Switch to a worktreediff --git a/tests/snapshots/integration__integration_tests__help__help_step_long.snap b/tests/snapshots/integration__integration_tests__help__help_step_long.snapindex a281cb637..516a617b5 100644--- a/tests/snapshots/integration__integration_tests__help__help_step_long.snap+++ b/tests/snapshots/integration__integration_tests__help__help_step_long.snap@@ -67,4 +67,4 @@ Manual merge workflow with review between steps:[32mSee also[0m- wt merge — Runs commit → squash → rebase → hooks → push → cleanup automatically-- wt hook — Run project-defined lifecycle hooks+- wt hook — Run hooks independentlydiff --git a/tests/snapshots/integration__integration_tests__help__help_switch_long.snap b/tests/snapshots/integration__integration_tests__help__help_switch_long.snapindex d67336917..1136c6284 100644--- a/tests/snapshots/integration__integration_tests__help__help_switch_long.snap+++ b/tests/snapshots/integration__integration_tests__help__help_switch_long.snap@@ -52,7 +52,7 @@ Usage: [1m[36mwt switch[0m [36m[OPTIONS][0m [36m<BRANCH>[0mSkip approval prompts[1m[36m--no-verify[0m- Skip all project hooks+ Skip hooks[1m[36m-h[0m, [1m[36m--help[0mPrint help (see a summary with '-h')diff --git a/tests/snapshots/integration__integration_tests__help__help_switch_short.snap b/tests/snapshots/integration__integration_tests__help__help_switch_short.snapindex 139b065bf..429af0bc8 100644--- a/tests/snapshots/integration__integration_tests__help__help_switch_short.snap+++ b/tests/snapshots/integration__integration_tests__help__help_switch_short.snap@@ -29,7 +29,7 @@ Usage: [1m[36mwt switch[0m [36m[OPTIONS][0m [36m<BRANCH>[0m[1m[36m-b[0m, [1m[36m--base[0m[36m [0m[36m<BASE>[0m Base branch[1m[36m-x[0m, [1m[36m--execute[0m[36m [0m[36m<EXECUTE>[0m Command to run after switch[1m[36m-f[0m, [1m[36m--force[0m Skip approval prompts- [1m[36m--no-verify[0m Skip all project hooks+ [1m[36m--no-verify[0m Skip hooks[1m[36m-h[0m, [1m[36m--help[0m Print help (see more with '--help')[1m[32mGlobal Options:[0mdiff --git a/tests/snapshots/integration__integration_tests__hook_show__hook_show_approval_status.snap b/tests/snapshots/integration__integration_tests__hook_show__hook_show_approval_status.snapnew file mode 100644index 000000000..eb2119405--- /dev/null+++ b/tests/snapshots/integration__integration_tests__hook_show__hook_show_approval_status.snap@@ -0,0 +1,35 @@+---+source: tests/integration_tests/hook_show.rs+info:+ program: wt+ args:+ - hook+ - show+ env:+ CLICOLOR_FORCE: "1"+ COLUMNS: "150"+ 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: ""+ HOME: "[TEST_HOME]"+ LANG: C+ LC_ALL: C+ SOURCE_DATE_EPOCH: "1735776000"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"+---+success: true+exit_code: 0+----- stdout -----++----- stderr -----+⚪ User Hooks: [1m~/.config/worktrunk/config.toml[22m+💡 [2m(none configured)[22m++⚪ Project Hooks: [1m[REPO]/.config/wt.toml[22m+⚪ pre-merge [1mbuild[22m:+[107m [0m [2m[0m[2m[34mcargo[0m[2m build[0m+❓ pre-merge [1mtest[22m: [2m(requires approval)[22m+[107m [0m [2m[0m[2m[34mcargo[0m[2m test[0mdiff --git a/tests/snapshots/integration__integration_tests__hook_show__hook_show_filter_by_type.snap b/tests/snapshots/integration__integration_tests__hook_show__hook_show_filter_by_type.snapnew file mode 100644index 000000000..11a005692--- /dev/null+++ b/tests/snapshots/integration__integration_tests__hook_show__hook_show_filter_by_type.snap@@ -0,0 +1,36 @@+---+source: tests/integration_tests/hook_show.rs+info:+ program: wt+ args:+ - hook+ - show+ - pre-merge+ env:+ CLICOLOR_FORCE: "1"+ COLUMNS: "150"+ 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: ""+ HOME: "[TEST_HOME]"+ LANG: C+ LC_ALL: C+ SOURCE_DATE_EPOCH: "1735776000"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"+---+success: true+exit_code: 0+----- stdout -----++----- stderr -----+[TEST_CONFIG][22m+💡 [2m(none configured)[22m++⚪ Project Hooks: [1m[REPO]/.config/wt.toml[22m+❓ pre-merge [1mbuild[22m: [2m(requires approval)[22m+[107m [0m [2m[0m[2m[34mcargo[0m[2m build[0m+❓ pre-merge [1mtest[22m: [2m(requires approval)[22m+[107m [0m [2m[0m[2m[34mcargo[0m[2m test[0mdiff --git a/tests/snapshots/integration__integration_tests__hook_show__hook_show_no_hooks.snap b/tests/snapshots/integration__integration_tests__hook_show__hook_show_no_hooks.snapnew file mode 100644index 000000000..c2e8cb902--- /dev/null+++ b/tests/snapshots/integration__integration_tests__hook_show__hook_show_no_hooks.snap@@ -0,0 +1,32 @@+---+source: tests/integration_tests/hook_show.rs+info:+ program: wt+ args:+ - hook+ - show+ env:+ CLICOLOR_FORCE: "1"+ COLUMNS: "150"+ 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: ""+ HOME: "[TEST_HOME]"+ LANG: C+ LC_ALL: C+ SOURCE_DATE_EPOCH: "1735776000"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"+---+success: true+exit_code: 0+----- stdout -----++----- stderr -----+[TEST_CONFIG][22m+💡 [2m(none configured)[22m++⚪ Project Hooks: [1m[REPO]/.config/wt.toml[22m+💡 [2m(not found)[22mdiff --git a/tests/snapshots/integration__integration_tests__hook_show__hook_show_with_both_configs.snap b/tests/snapshots/integration__integration_tests__hook_show__hook_show_with_both_configs.snapnew file mode 100644index 000000000..0126e2122--- /dev/null+++ b/tests/snapshots/integration__integration_tests__hook_show__hook_show_with_both_configs.snap@@ -0,0 +1,37 @@+---+source: tests/integration_tests/hook_show.rs+info:+ program: wt+ args:+ - hook+ - show+ env:+ CLICOLOR_FORCE: "1"+ COLUMNS: "150"+ 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: ""+ HOME: "[TEST_HOME]"+ LANG: C+ LC_ALL: C+ SOURCE_DATE_EPOCH: "1735776000"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"+---+success: true+exit_code: 0+----- stdout -----++----- stderr -----+[TEST_CONFIG][22m+💡 [2m(none configured)[22m++⚪ Project Hooks: [1m[REPO]/.config/wt.toml[22m+❓ post-start [1mdeps[22m: [2m(requires approval)[22m+[107m [0m [2m[0m[2m[34mnpm[0m[2m install[0m+❓ pre-merge [1mbuild[22m: [2m(requires approval)[22m+[107m [0m [2m[0m[2m[34mcargo[0m[2m build[0m+❓ pre-merge [1mtest[22m: [2m(requires approval)[22m+[107m [0m [2m[0m[2m[34mcargo[0m[2m test[0mdiff --git a/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_failure.snap b/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_failure.snapindex e64a274b7..c6c999c09 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_failure.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_failure.snap@@ -30,7 +30,7 @@ exit_code: 1[107m [0m 1 file changed, 1 insertion(+)✅ [32mMerged to [1mmain[22m [90m(1 commit, 1 file, [32m+1[39m[39m[90m)[39m[39m🔄 [36m[36mRemoving [1mfeature[22m worktree & branch in background (already in main)[39m[39m-🔄 [36mRunning post-merge:[39m+🔄 [36mRunning project post-merge:[39m[107m [0m [2m[0m[2m[34mexit[0m[2m 1[0m[0m🟡 [33mCommand failed: exit status: 1[39m❌ [31mpost-merge command failed: exit status: 1[39mdiff --git a/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_named.snap b/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_named.snapindex 4a41235ba..2137ea73b 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_named.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_named.snap@@ -30,8 +30,8 @@ exit_code: 0[107m [0m 1 file changed, 1 insertion(+)✅ [32mMerged to [1mmain[22m [90m(1 commit, 1 file, [32m+1[39m[39m[90m)[39m[39m🔄 [36m[36mRemoving [1mfeature[22m worktree & branch in background (already in main)[39m[39m-🔄 [36mRunning post-merge [1mnotify[22m:[39m+🔄 [36mRunning project post-merge [1mnotify[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Merge to main complete'[0m[2m [0m[2m[36m>[0m[2m notify.txt[0m-[0m🔄 [36mRunning post-merge [1mdeploy[22m:[39m+[0m🔄 [36mRunning project post-merge [1mdeploy[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Deploying branch feature'[0m[2m [0m[2m[36m>[0m[2m deploy.txt[0m[0mdiff --git a/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_success.snap b/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_success.snapindex fa5d181f5..c6e558e00 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_success.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_success.snap@@ -30,6 +30,6 @@ exit_code: 0[107m [0m 1 file changed, 1 insertion(+)✅ [32mMerged to [1mmain[22m [90m(1 commit, 1 file, [32m+1[39m[39m[90m)[39m[39m🔄 [36m[36mRemoving [1mfeature[22m worktree & branch in background (already in main)[39m[39m-🔄 [36mRunning post-merge:[39m+🔄 [36mRunning project post-merge:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'merged feature to main'[0m[2m [0m[2m[36m>[0m[2m post-merge-ran.txt[0m[0mdiff --git a/tests/snapshots/integration__integration_tests__merge__merge_post_merge_runs_from_main_branch.snap b/tests/snapshots/integration__integration_tests__merge__merge_post_merge_runs_from_main_branch.snapindex 67b9a787e..23f61ae6b 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_post_merge_runs_from_main_branch.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_post_merge_runs_from_main_branch.snap@@ -25,6 +25,6 @@ exit_code: 0----- stderr -----⚪ Already up to date with [1mmain[22m (no new commits, no rebase needed)⚪ Worktree preserved (main worktree)-🔄 [36mRunning post-merge:[39m+🔄 [36mRunning project post-merge:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'post-merge ran from main'[0m[2m [0m[2m[36m>[0m[2m post-merge-ran.txt[0m[0mdiff --git a/tests/snapshots/integration__integration_tests__merge__merge_post_merge_runs_with_nothing_to_merge.snap b/tests/snapshots/integration__integration_tests__merge__merge_post_merge_runs_with_nothing_to_merge.snapindex 90312e838..76bec14fb 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_post_merge_runs_with_nothing_to_merge.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_post_merge_runs_with_nothing_to_merge.snap@@ -26,6 +26,6 @@ exit_code: 0----- stderr -----⚪ Already up to date with [1mmain[22m (no new commits, no rebase needed)🔄 [36m[36mRemoving [1mfeature[22m worktree & branch in background (already in main)[39m[39m-🔄 [36mRunning post-merge:[39m+🔄 [36mRunning project post-merge:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'post-merge ran'[0m[2m [0m[2m[36m>[0m[2m post-merge-ran.txt[0m[0mdiff --git a/tests/snapshots/integration__integration_tests__merge__merge_pre_commit_command_failure.snap b/tests/snapshots/integration__integration_tests__merge__merge_pre_commit_command_failure.snapindex 5dacb7013..1ee8acd64 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_pre_commit_command_failure.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_pre_commit_command_failure.snap@@ -26,7 +26,7 @@ exit_code: 1----- stderr -----🟡 [33mAuto-staging 1 untracked path:[39m[107m [0m feature.txt-🔄 [36mRunning pre-commit:[39m+🔄 [36mRunning project pre-commit:[39m[107m [0m [2m[0m[2m[34mexit[0m[2m 1[0m[0m❌ [31mpre-commit command failed: exit status: 1[39mdiff --git a/tests/snapshots/integration__integration_tests__merge__merge_pre_commit_command_success.snap b/tests/snapshots/integration__integration_tests__merge__merge_pre_commit_command_success.snapindex e8ef4c594..bef897325 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_pre_commit_command_success.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_pre_commit_command_success.snap@@ -26,7 +26,7 @@ exit_code: 0----- stderr -----🟡 [33mAuto-staging 1 untracked path:[39m[107m [0m feature.txt-🔄 [36mRunning pre-commit:[39m+🔄 [36mRunning project pre-commit:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Pre-commit check passed'[0m[2m[0m[0mPre-commit check passed🔄 [36mCommitting changes with default message... [90m(1 file, [32m+1[39m, no squashing needed[39m[90m)[39m[39mdiff --git a/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_failure.snap b/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_failure.snapindex 52b3648ee..65893bb63 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_failure.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_failure.snap@@ -24,7 +24,7 @@ exit_code: 1----- stdout ---------- stderr ------🔄 [36mRunning pre-merge:[39m+🔄 [36mRunning project pre-merge:[39m[107m [0m [2m[0m[2m[34mexit[0m[2m 1[0m[0m❌ [31mpre-merge command failed: exit status: 1[39mdiff --git a/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_named.snap b/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_named.snapindex 741576fb9..79bda620c 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_named.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_named.snap@@ -24,11 +24,11 @@ exit_code: 0----- stdout ---------- stderr ------🔄 [36mRunning pre-merge [1mformat[22m:[39m+🔄 [36mRunning project pre-merge [1mformat[22m:[39m[107m [0m [2m[0m[2m[34mexit[0m[2m 0[0m-[0m🔄 [36mRunning pre-merge [1mlint[22m:[39m+[0m🔄 [36mRunning project pre-merge [1mlint[22m:[39m[107m [0m [2m[0m[2m[34mexit[0m[2m 0[0m-[0m🔄 [36mRunning pre-merge [1mtest[22m:[39m+[0m🔄 [36mRunning project pre-merge [1mtest[22m:[39m[107m [0m [2m[0m[2m[34mexit[0m[2m 0[0m[0m🔄 [36mMerging 1 commit to [1mmain[22m @ [2m2cbe2a2[22m (no commit/squash/rebase needed)[39m[107m [0m * [33m2cbe2a2[m Add feature filediff --git a/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_no_hooks.snap b/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_no_hooks.snapindex 60ba734e2..1aec4c46c 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_no_hooks.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_no_hooks.snap@@ -5,7 +5,7 @@ info:args:- merge- main- - "--no-hooks"+ - "--no-verify"env:CLICOLOR_FORCE: "1"COLUMNS: "150"@@ -19,15 +19,14 @@ info:SOURCE_DATE_EPOCH: "1735776000"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"----success: false-exit_code: 2+success: true+exit_code: 0----- stdout ---------- stderr ------[1m[31merror:[0m unexpected argument '[1m[33m--no-hooks[0m' found-- [1m[32mtip:[0m to pass '[1m[33m--no-hooks[0m' as a value, use '[1m[32m-- --no-hooks[0m'--[1m[32mUsage:[0m [1m[36mwt merge[0m [36m<TARGET>[0m--For more information, try '[1m[36m--help[0m'.+🔄 [36mMerging 1 commit to [1mmain[22m @ [2mf2d96c5[22m (no commit/squash/rebase needed)[39m+[107m [0m * [33mf2d96c5[m Add feature file+[107m [0m feature.txt | 1 [32m+[m+[107m [0m 1 file changed, 1 insertion(+)+✅ [32mMerged to [1mmain[22m [90m(1 commit, 1 file, [32m+1[39m[39m[90m)[39m[39m+🔄 [36m[36mRemoving [1mfeature[22m worktree & branch in background (already in main)[39m[39mdiff --git a/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_success.snap b/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_success.snapindex 76e8c58e1..f89154d82 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_success.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_success.snap@@ -24,7 +24,7 @@ exit_code: 0----- stdout ---------- stderr ------🔄 [36mRunning pre-merge:[39m+🔄 [36mRunning project pre-merge:[39m[107m [0m [2m[0m[2m[34mexit[0m[2m 0[0m[0m🔄 [36mMerging 1 commit to [1mmain[22m @ [2m4b1199c[22m (no commit/squash/rebase needed)[39m[107m [0m * [33m4b1199c[m Add feature filediff --git a/tests/snapshots/integration__integration_tests__merge__merge_pre_squash_command_failure.snap b/tests/snapshots/integration__integration_tests__merge__merge_pre_squash_command_failure.snapindex d65718cdc..4d40320b4 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_pre_squash_command_failure.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_pre_squash_command_failure.snap@@ -24,7 +24,7 @@ exit_code: 1----- stdout ---------- stderr ------🔄 [36mRunning pre-commit:[39m+🔄 [36mRunning project pre-commit:[39m[107m [0m [2m[0m[2m[34mexit[0m[2m 1[0m[0m❌ [31mpre-commit command failed: exit status: 1[39mdiff --git a/tests/snapshots/integration__integration_tests__merge__merge_pre_squash_command_success.snap b/tests/snapshots/integration__integration_tests__merge__merge_pre_squash_command_success.snapindex da97cfce2..08ab7db8e 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_pre_squash_command_success.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_pre_squash_command_success.snap@@ -24,7 +24,7 @@ exit_code: 0----- stdout ---------- stderr ------🔄 [36mRunning pre-commit:[39m+🔄 [36mRunning project pre-commit:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Pre-commit check passed'[0m[2m[0m[0mPre-commit check passed🔄 [36mMerging 1 commit to [1mmain[22m @ [2m726717f[22m (no commit/squash/rebase needed)[39mdiff --git a/tests/snapshots/integration__integration_tests__merge__readme_example_complex.snap b/tests/snapshots/integration__integration_tests__merge__readme_example_complex.snapindex 3041bb5fe..41cb9db31 100644--- a/tests/snapshots/integration__integration_tests__merge__readme_example_complex.snap+++ b/tests/snapshots/integration__integration_tests__merge__readme_example_complex.snap@@ -37,7 +37,7 @@ exit_code: 0[107m [0m - Add JWT encoding/decoding with signature verification[107m [0m - Create test suite covering all authentication flows✅ [32mSquashed @ [2m95c3316[22m[39m-🔄 [36mRunning pre-merge [1mtest[22m:[39m+🔄 [36mRunning project pre-merge [1mtest[22m:[39m[107m [0m [2m[0m[2m[34mcargo[0m[2m test[0m[0m Finished test [unoptimized + debuginfo] target(s) in 0.12sRunning unittests src/lib.rs (target/debug/deps/worktrunk-abc123)@@ -49,7 +49,7 @@ test auth::tests::test_token_refresh ... oktest auth::tests::test_token_validation ... oktest result: ok. 18 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.08s-🔄 [36mRunning pre-merge [1mlint[22m:[39m+🔄 [36mRunning project pre-merge [1mlint[22m:[39m[107m [0m [2m[0m[2m[34mcargo[0m[2m clippy[0m[0m Checking worktrunk v0.1.0Finished dev [unoptimized + debuginfo] target(s) in 1.23s@@ -61,7 +61,7 @@ test result: ok. 18 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; fin[107m [0m 3 files changed, 33 insertions(+)✅ [32mMerged to [1mmain[22m [90m(1 commit, 3 files, [32m+33[39m[39m[90m)[39m[39m🔄 [36m[36mRemoving [1mfeature-auth[22m worktree & branch in background (already in main)[39m[39m-🔄 [36mRunning post-merge [1minstall[22m:[39m+🔄 [36mRunning project post-merge [1minstall[22m:[39m[107m [0m [2m[0m[2m[34mcargo[0m[2m install [0m[2m[36m--path[0m[2m .[0m[0m Installing worktrunk v0.1.0Compiling worktrunk v0.1.0diff --git a/tests/snapshots/integration__integration_tests__merge__readme_example_hooks_post_create.snap b/tests/snapshots/integration__integration_tests__merge__readme_example_hooks_post_create.snapindex 79f6db3c0..22a1ac25b 100644--- a/tests/snapshots/integration__integration_tests__merge__readme_example_hooks_post_create.snap+++ b/tests/snapshots/integration__integration_tests__merge__readme_example_hooks_post_create.snap@@ -26,12 +26,12 @@ exit_code: 0----- stdout ---------- stderr ------🔄 [36mRunning post-create [1minstall[22m:[39m+🔄 [36mRunning project post-create [1minstall[22m:[39m[107m [0m [2m[0m[2m[34muv[0m[2m sync[0m[0mResolved 24 packages in 145msInstalled 24 packages in 1.2s✅ [32m[32mCreated new worktree for [1mfeature-x[22m from [1mmain[22m at [1m[REPO].feature-x[39m[22m[39m💡 [2mRun [90mwt config shell install[39m to enable automatic cd[22m-🔄 [36mRunning post-start [1mdev[22m:[39m+🔄 [36mRunning project post-start [1mdev[22m:[39m[107m [0m [2m[0m[2m[34muv[0m[2m run dev[0mdiff --git a/tests/snapshots/integration__integration_tests__merge__readme_example_hooks_pre_merge.snap b/tests/snapshots/integration__integration_tests__merge__readme_example_hooks_pre_merge.snapindex aaafeb298..7014ec5d7 100644--- a/tests/snapshots/integration__integration_tests__merge__readme_example_hooks_pre_merge.snap+++ b/tests/snapshots/integration__integration_tests__merge__readme_example_hooks_pre_merge.snap@@ -32,7 +32,7 @@ exit_code: 0[107m [0m Implement login and token refresh endpoints with JWT validation.[107m [0m Includes comprehensive test coverage and input validation.✅ [32mSquashed @ [2m69200cc[22m[39m-🔄 [36mRunning pre-merge [1mtest[22m:[39m+🔄 [36mRunning project pre-merge [1mtest[22m:[39m[107m [0m [2m[0m[2m[34muv[0m[2m run pytest[0m[0m============================= test session starts ==============================@@ -44,7 +44,7 @@ tests/test_auth.py::test_token_validation PASSED [100%]============================== 3 passed in 0.8s ===============================-🔄 [36mRunning pre-merge [1mlint[22m:[39m+🔄 [36mRunning project pre-merge [1mlint[22m:[39m[107m [0m [2m[0m[2m[34muv[0m[2m run ruff check[0m[0mAll checks passed!diff --git a/tests/snapshots/integration__integration_tests__merge__step_commit_both_flags.snap b/tests/snapshots/integration__integration_tests__merge__step_commit_both_flags.snapindex 3a6973cae..98b3675d6 100644--- a/tests/snapshots/integration__integration_tests__merge__step_commit_both_flags.snap+++ b/tests/snapshots/integration__integration_tests__merge__step_commit_both_flags.snap@@ -27,7 +27,7 @@ exit_code: 0----- stdout ---------- stderr ------💡 [2mSkipping pre-commit hook ([90m--no-verify[39m)[22m+💡 [2mSkipping pre-commit hooks ([90m--no-verify[39m)[22m🔄 [36mGenerating commit message and committing tracked changes... [90m(1 file, [32m+1[39m, [31m-1[39m[39m[90m)[39m[39m[107m [0m [1mfix: update file[22m✅ [32mCommitted changes @ [2m0b66aac[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__merge__step_commit_no_verify.snap b/tests/snapshots/integration__integration_tests__merge__step_commit_no_verify.snapindex dcd77c242..abd2da770 100644--- a/tests/snapshots/integration__integration_tests__merge__step_commit_no_verify.snap+++ b/tests/snapshots/integration__integration_tests__merge__step_commit_no_verify.snap@@ -26,7 +26,7 @@ exit_code: 0----- stdout ---------- stderr ------💡 [2mSkipping pre-commit hook ([90m--no-verify[39m)[22m+💡 [2mSkipping pre-commit hooks ([90m--no-verify[39m)[22m🟡 [33mAuto-staging 2 untracked paths:[39m[107m [0m .config/[107m [0m file1.txtdiff --git a/tests/snapshots/integration__integration_tests__merge__step_squash_both_flags.snap b/tests/snapshots/integration__integration_tests__merge__step_squash_both_flags.snapindex dead9b8a1..57824ede6 100644--- a/tests/snapshots/integration__integration_tests__merge__step_squash_both_flags.snap+++ b/tests/snapshots/integration__integration_tests__merge__step_squash_both_flags.snap@@ -27,7 +27,7 @@ exit_code: 0----- stdout ---------- stderr ------💡 [2mSkipping pre-commit hook ([90m--no-verify[39m)[22m+💡 [2mSkipping pre-commit hooks ([90m--no-verify[39m)[22m🔄 [36mSquashing 2 commits & tracked changes into a single commit [90m(3 files, [32m+3[39m[39m[90m)[39m...[39m💡 [2mBackup created @ 31e06e8[22m🔄 [36mGenerating squash commit message...[39mdiff --git a/tests/snapshots/integration__integration_tests__merge__step_squash_no_verify.snap b/tests/snapshots/integration__integration_tests__merge__step_squash_no_verify.snapindex 9f5dc5a6f..df2d7d2d9 100644--- a/tests/snapshots/integration__integration_tests__merge__step_squash_no_verify.snap+++ b/tests/snapshots/integration__integration_tests__merge__step_squash_no_verify.snap@@ -26,7 +26,7 @@ exit_code: 0----- stdout ---------- stderr ------💡 [2mSkipping pre-commit hook ([90m--no-verify[39m)[22m+💡 [2mSkipping pre-commit hooks ([90m--no-verify[39m)[22m🔄 [36mSquashing 2 commits into a single commit [90m(3 files, [32m+3[39m[39m[90m)[39m...[39m🔄 [36mGenerating squash commit message...[39m[107m [0m [1msquash: combined commits[22mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__both_create_and_start.snap b/tests/snapshots/integration__integration_tests__post_start_commands__both_create_and_start.snapindex 0b93d0682..089a58b4a 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__both_create_and_start.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__both_create_and_start.snap@@ -25,9 +25,9 @@ exit_code: 0----- stdout ---------- stderr ------🔄 [36mRunning post-create:[39m+🔄 [36mRunning project post-create:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Setup done'[0m[2m [0m[2m[36m>[0m[2m setup.txt[0m[0m✅ [32m[32mCreated new worktree for [1mfeature[22m from [1mmain[22m at [1m[REPO].feature[39m[22m[39m💡 [2mRun [90mwt config shell install[39m to enable automatic cd[22m-🔄 [36mRunning post-start [1mserver[22m:[39m+🔄 [36mRunning project post-start [1mserver[22m:[39m[107m [0m [2m[0m[2m[34msleep[0m[2m 0.05 [0m[2m[36m&&[0m[2m [0m[2m[34mecho[0m[2m [0m[2m[32m'Server running'[0m[2m [0m[2m[36m>[0m[2m server.txt[0mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__execute_with_post_start.snap b/tests/snapshots/integration__integration_tests__post_start_commands__execute_with_post_start.snapindex 3e345601d..1d6881366 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__execute_with_post_start.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__execute_with_post_start.snap@@ -28,7 +28,7 @@ exit_code: 0----- stderr -----✅ [32m[32mCreated new worktree for [1mfeature[22m from [1mmain[22m at [1m[REPO].feature[39m[22m[39m-🔄 [36mRunning post-start:[39m+🔄 [36mRunning project post-start:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Background task'[0m[2m [0m[2m[36m>[0m[2m background.txt[0m🔄 [36mExecuting (--execute):[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Execute flag'[0m[2m [0m[2m[36m>[0m[2m execute.txt[0mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_default_branch_template.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_default_branch_template.snapindex f2bd79597..5d1e60415 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_default_branch_template.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_default_branch_template.snap@@ -26,7 +26,7 @@ exit_code: 0----- stdout ---------- stderr ------🔄 [36mRunning post-create:[39m+🔄 [36mRunning project post-create:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Default: main'[0m[2m [0m[2m[36m>[0m[2m default.txt[0m[0m✅ [32m[32mCreated new worktree for [1mfeature[22m from [1mmain[22m at [1m[REPO].feature[39m[22m[39m💡 [2mRun [90mwt config shell install[39m to enable automatic cd[22mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_failing_command.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_failing_command.snapindex 2a2ac6bd3..19314f969 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_failing_command.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_failing_command.snap@@ -25,7 +25,7 @@ exit_code: 0----- stdout ---------- stderr ------🔄 [36mRunning post-create:[39m+🔄 [36mRunning project post-create:[39m[107m [0m [2m[0m[2m[34mexit[0m[2m 1[0m[0m🟡 [33mCommand failed: exit status: 1[39m✅ [32m[32mCreated new worktree for [1mfeature[22m from [1mmain[22m at [1m[REPO].feature[39m[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_git_variables_template.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_git_variables_template.snapindex b5ed13760..70ab9cd99 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_git_variables_template.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_git_variables_template.snap@@ -26,13 +26,13 @@ exit_code: 0----- stdout ---------- stderr ------🔄 [36mRunning post-create [1mcommit[22m:[39m+🔄 [36mRunning project post-create [1mcommit[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Commit: d5f94f04f2d59bd7282f575b929b659aefa65f2e'[0m[2m [0m[2m[36m>[0m[2m git_vars.txt[0m-[0m🔄 [36mRunning post-create [1mshort[22m:[39m+[0m🔄 [36mRunning project post-create [1mshort[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Short: d5f94f0'[0m[2m [0m[2m[36m>>[0m[2m git_vars.txt[0m-[0m🔄 [36mRunning post-create [1mremote[22m:[39m+[0m🔄 [36mRunning project post-create [1mremote[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Remote: origin'[0m[2m [0m[2m[36m>>[0m[2m git_vars.txt[0m-[0m🔄 [36mRunning post-create [1mworktree_name[22m:[39m+[0m🔄 [36mRunning project post-create [1mworktree_name[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Worktree Name: repo.feature'[0m[2m [0m[2m[36m>>[0m[2m git_vars.txt[0m[0m✅ [32m[32mCreated new worktree for [1mfeature[22m from [1mmain[22m at [1m[REPO].feature[39m[22m[39m💡 [2mRun [90mwt config shell install[39m to enable automatic cd[22mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_multiline_control_structure.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_multiline_control_structure.snapindex 4f3876fc8..11ad93f86 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_multiline_control_structure.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_multiline_control_structure.snap@@ -25,7 +25,7 @@ exit_code: 0----- stdout ---------- stderr ------🔄 [36mRunning post-create:[39m+🔄 [36mRunning project post-create:[39m[107m [0m [2m[0m[2m[35mif[0m[2m [ ! -f test.txt ]; [0m[2m[35mthen[0m[2m[0m[2m[0m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'File does not exist'[0m[2m [0m[2m[36m>[0m[2m result.txt[0m[107m [0m [2m[0m[2m[34melse[0m[2m[0mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_named_commands.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_named_commands.snapindex a35f36531..e590dd388 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_named_commands.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_named_commands.snap@@ -25,10 +25,10 @@ exit_code: 0----- stdout ---------- stderr ------🔄 [36mRunning post-create [1minstall[22m:[39m+🔄 [36mRunning project post-create [1minstall[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Installing deps'[0m[2m[0m[0mInstalling deps-🔄 [36mRunning post-create [1msetup[22m:[39m+🔄 [36mRunning project post-create [1msetup[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Running setup'[0m[2m[0m[0mRunning setup✅ [32m[32mCreated new worktree for [1mfeature[22m from [1mmain[22m at [1m[REPO].feature[39m[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_single_command.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_single_command.snapindex d81d0b8d3..fe6715d21 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_single_command.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_single_command.snap@@ -25,7 +25,7 @@ exit_code: 0----- stdout ---------- stderr ------🔄 [36mRunning post-create:[39m+🔄 [36mRunning project post-create:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Setup complete'[0m[2m[0m[0mSetup complete✅ [32m[32mCreated new worktree for [1mfeature[22m from [1mmain[22m at [1m[REPO].feature[39m[22m[39mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_template_expansion.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_template_expansion.snapindex 0481e53dd..e12ba2585 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_template_expansion.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_template_expansion.snap@@ -25,13 +25,13 @@ exit_code: 0----- stdout ---------- stderr ------🔄 [36mRunning post-create [1mrepo[22m:[39m+🔄 [36mRunning project post-create [1mrepo[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Repo: repo'[0m[2m [0m[2m[36m>[0m[2m info.txt[0m-[0m🔄 [36mRunning post-create [1mbranch[22m:[39m+[0m🔄 [36mRunning project post-create [1mbranch[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Branch: feature-test'[0m[2m [0m[2m[36m>>[0m[2m info.txt[0m-[0m🔄 [36mRunning post-create [1mworktree[22m:[39m+[0m🔄 [36mRunning project post-create [1mworktree[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Worktree: [REPO].feature-test'[0m[2m [0m[2m[36m>>[0m[2m info.txt[0m-[0m🔄 [36mRunning post-create [1mroot[22m:[39m+[0m🔄 [36mRunning project post-create [1mroot[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Root: [REPO]'[0m[2m [0m[2m[36m>>[0m[2m info.txt[0m[0m✅ [32m[32mCreated new worktree for [1mfeature/test[22m from [1mmain[22m at [1m[REPO].feature-test[39m[22m[39m💡 [2mRun [90mwt config shell install[39m to enable automatic cd[22mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_upstream_template.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_upstream_template.snapindex 877508c7b..07c2e64c5 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_upstream_template.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_upstream_template.snap@@ -26,7 +26,7 @@ exit_code: 0----- stdout ---------- stderr ------🔄 [36mRunning post-create:[39m+🔄 [36mRunning project post-create:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Upstream: '[0m[2m [0m[2m[36m>[0m[2m upstream.txt[0m[0m✅ [32m[32mCreated new worktree for [1mfeature[22m from [1mmain[22m at [1m[REPO].feature[39m[22m[39m💡 [2mRun [90mwt config shell install[39m to enable automatic cd[22mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_complex_shell.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_complex_shell.snapindex 95c9ddd08..c227c8b39 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_complex_shell.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_complex_shell.snap@@ -27,7 +27,7 @@ exit_code: 0----- stderr -----✅ [32m[32mCreated new worktree for [1mfeature[22m from [1mmain[22m at [1m[REPO].feature[39m[22m[39m💡 [2mRun [90mwt config shell install[39m to enable automatic cd[22m-🔄 [36mRunning post-start:[39m+🔄 [36mRunning project post-start:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m 'line1[0m[107m [0m [2m[0m[2m[34mline2[0m[2m[0m[107m [0m [2m[0m[2m[34mline3[0m[2m' | grep line2 > filtered.txt[0mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_create_with_command.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_create_with_command.snapindex d7ef41efc..2605f479e 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_create_with_command.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_create_with_command.snap@@ -27,5 +27,5 @@ exit_code: 0----- stderr -----✅ [32m[32mCreated new worktree for [1mfeature[22m from [1mmain[22m at [1m[REPO].feature[39m[22m[39m💡 [2mRun [90mwt config shell install[39m to enable automatic cd[22m-🔄 [36mRunning post-start:[39m+🔄 [36mRunning project post-start:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'POST-START-RAN'[0m[2m [0m[2m[36m>[0m[2m post_start_marker.txt[0mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_invalid_command.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_invalid_command.snapindex 2a84c14d8..0f9c062da 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_invalid_command.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_invalid_command.snap@@ -27,5 +27,5 @@ exit_code: 0----- stderr -----✅ [32m[32mCreated new worktree for [1mfeature[22m from [1mmain[22m at [1m[REPO].feature[39m[22m[39m💡 [2mRun [90mwt config shell install[39m to enable automatic cd[22m-🔄 [36mRunning post-start:[39m+🔄 [36mRunning project post-start:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m 'unclosed quote[0mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_log_captures_output.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_log_captures_output.snapindex 276b3bbbc..c9179b09f 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_log_captures_output.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_log_captures_output.snap@@ -27,5 +27,5 @@ exit_code: 0----- stderr -----✅ [32m[32mCreated new worktree for [1mfeature[22m from [1mmain[22m at [1m[REPO].feature[39m[22m[39m💡 [2mRun [90mwt config shell install[39m to enable automatic cd[22m-🔄 [36mRunning post-start:[39m+🔄 [36mRunning project post-start:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'stdout output'[0m[2m [0m[2m[36m&&[0m[2m [0m[2m[34mecho[0m[2m [0m[2m[32m'stderr output'[0m[2m >&2[0mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_multiline_with_newlines.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_multiline_with_newlines.snapindex 7b79bba50..19f49b94c 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_multiline_with_newlines.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_multiline_with_newlines.snap@@ -27,7 +27,7 @@ exit_code: 0----- stderr -----✅ [32m[32mCreated new worktree for [1mfeature[22m from [1mmain[22m at [1m[REPO].feature[39m[22m[39m💡 [2mRun [90mwt config shell install[39m to enable automatic cd[22m-🔄 [36mRunning post-start:[39m+🔄 [36mRunning project post-start:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'first line'[0m[2m [0m[2m[36m>[0m[2m multiline.txt[0m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'second line'[0m[2m [0m[2m[36m>>[0m[2m multiline.txt[0m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'third line'[0m[2m [0m[2m[36m>>[0m[2m multiline.txt[0mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_multiple_background.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_multiple_background.snapindex 3f025f4ce..b4621efef 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_multiple_background.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_multiple_background.snap@@ -27,7 +27,7 @@ exit_code: 0----- stderr -----✅ [32m[32mCreated new worktree for [1mfeature[22m from [1mmain[22m at [1m[REPO].feature[39m[22m[39m💡 [2mRun [90mwt config shell install[39m to enable automatic cd[22m-🔄 [36mRunning post-start [1mtask1[22m:[39m+🔄 [36mRunning project post-start [1mtask1[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Task 1 running'[0m[2m [0m[2m[36m>[0m[2m task1.txt[0m-🔄 [36mRunning post-start [1mtask2[22m:[39m+🔄 [36mRunning project post-start [1mtask2[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Task 2 running'[0m[2m [0m[2m[36m>[0m[2m task2.txt[0mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_separate_logs.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_separate_logs.snapindex 509e81f6e..6dd76b88e 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_separate_logs.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_separate_logs.snap@@ -27,9 +27,9 @@ exit_code: 0----- stderr -----✅ [32m[32mCreated new worktree for [1mfeature[22m from [1mmain[22m at [1m[REPO].feature[39m[22m[39m💡 [2mRun [90mwt config shell install[39m to enable automatic cd[22m-🔄 [36mRunning post-start [1mtask1[22m:[39m+🔄 [36mRunning project post-start [1mtask1[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'TASK1_OUTPUT'[0m[2m[0m-🔄 [36mRunning post-start [1mtask2[22m:[39m+🔄 [36mRunning project post-start [1mtask2[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'TASK2_OUTPUT'[0m[2m[0m-🔄 [36mRunning post-start [1mtask3[22m:[39m+🔄 [36mRunning project post-start [1mtask3[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'TASK3_OUTPUT'[0m[2m[0mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_single_background.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_single_background.snapindex 4933fcebc..fccdcfbe6 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_single_background.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_single_background.snap@@ -27,5 +27,5 @@ exit_code: 0----- stderr -----✅ [32m[32mCreated new worktree for [1mfeature[22m from [1mmain[22m at [1m[REPO].feature[39m[22m[39m💡 [2mRun [90mwt config shell install[39m to enable automatic cd[22m-🔄 [36mRunning post-start:[39m+🔄 [36mRunning project post-start:[39m[107m [0m [2m[0m[2m[34msleep[0m[2m 0.1 [0m[2m[36m&&[0m[2m [0m[2m[34mecho[0m[2m [0m[2m[32m'Background task done'[0m[2m [0m[2m[36m>[0m[2m background.txt[0mdiff --git a/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_executes.snap b/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_executes.snapindex 1269aa611..c53f918db 100644--- a/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_executes.snap+++ b/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_executes.snap@@ -25,7 +25,7 @@ exit_code: 0----- stderr -----🔄 [36mRemoving worktree for [1mfeature-hook[22m...[39m-🔄 [36mRunning pre-remove:[39m+🔄 [36mRunning project pre-remove:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'About to remove worktree'[0m[2m[0m[0mAbout to remove worktree✅ [32mRemoved [1mfeature-hook[22m worktree & branch (already in main)[39mdiff --git a/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_failure_aborts.snap b/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_failure_aborts.snapindex fdebf022b..c7dd8d39d 100644--- a/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_failure_aborts.snap+++ b/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_failure_aborts.snap@@ -25,7 +25,7 @@ exit_code: 1----- stderr -----🔄 [36mRemoving worktree for [1mfeature-fail[22m...[39m-🔄 [36mRunning pre-remove:[39m+🔄 [36mRunning project pre-remove:[39m[107m [0m [2m[0m[2m[34mexit[0m[2m 1[0m[0m❌ [31mpre-remove command failed: exit status: 1[39mdiff --git a/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_runs_for_detached_head.snap b/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_runs_for_detached_head.snapindex 11eead0cb..23cb4aaf5 100644--- a/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_runs_for_detached_head.snap+++ b/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_runs_for_detached_head.snap@@ -24,6 +24,6 @@ exit_code: 0----- stderr -----🔄 [36mRemoving current worktree...[39m-🔄 [36mRunning pre-remove:[39m+🔄 [36mRunning project pre-remove:[39m[107m [0m [2m[0m[2m[34mtouch[0m[2m [REPO]/m.txt[0m[0m✅ [32mRemoved worktree (detached HEAD, no branch to delete)[39mdiff --git a/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_runs_for_detached_head_background.snap b/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_runs_for_detached_head_background.snapindex 516d387c0..a13365124 100644--- a/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_runs_for_detached_head_background.snap+++ b/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_runs_for_detached_head_background.snap@@ -22,6 +22,6 @@ exit_code: 0----- stdout ---------- stderr ------🔄 [36mRunning pre-remove:[39m+🔄 [36mRunning project pre-remove:[39m[107m [0m [2m[0m[2m[34mtouch[0m[2m [REPO]/detached-bg-hook-marker.txt[0m[0m🔄 [36mRemoving worktree in background (detached HEAD, no branch to delete)[39mdiff --git a/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_template_variables.snap b/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_template_variables.snapindex e6d78e2fd..aeff9472b 100644--- a/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_template_variables.snap+++ b/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_template_variables.snap@@ -25,13 +25,13 @@ exit_code: 0----- stderr -----🔄 [36mRemoving worktree for [1mfeature-templates[22m...[39m-🔄 [36mRunning pre-remove [1mbranch[22m:[39m+🔄 [36mRunning project pre-remove [1mbranch[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Branch: feature-templates'[0m[2m[0m[0mBranch: feature-templates-🔄 [36mRunning pre-remove [1mworktree[22m:[39m+🔄 [36mRunning project pre-remove [1mworktree[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Worktree: [REPO].feature-templates'[0m[2m[0m[0mWorktree: [REPO].feature-templates-🔄 [36mRunning pre-remove [1mworktree_name[22m:[39m+🔄 [36mRunning project pre-remove [1mworktree_name[22m:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Name: repo.feature-templates'[0m[2m[0m[0mName: repo.feature-templates✅ [32mRemoved [1mfeature-templates[22m worktree & branch (already in main)[39mdiff --git a/tests/snapshots/integration__integration_tests__switch__switch_no_hooks_execute_still_runs.snap b/tests/snapshots/integration__integration_tests__switch__switch_no_hooks_execute_still_runs.snapindex e352d82d9..44ce8ba36 100644--- a/tests/snapshots/integration__integration_tests__switch__switch_no_hooks_execute_still_runs.snap+++ b/tests/snapshots/integration__integration_tests__switch__switch_no_hooks_execute_still_runs.snap@@ -8,7 +8,7 @@ info:- no-hooks-test- "--execute"- "echo 'execute command runs'"- - "--no-hooks"+ - "--no-verify"env:CLICOLOR_FORCE: "1"COLUMNS: "150"@@ -23,15 +23,12 @@ info:SOURCE_DATE_EPOCH: "1735776000"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"----success: false-exit_code: 2+success: true+exit_code: 0----- stdout -----+execute command runs----- stderr ------[1m[31merror:[0m unexpected argument '[1m[33m--no-hooks[0m' found-- [1m[32mtip:[0m to pass '[1m[33m--no-hooks[0m' as a value, use '[1m[32m-- --no-hooks[0m'--[1m[32mUsage:[0m [1m[36mwt switch[0m [1m[36m--create[0m [1m[36m--execute[0m[36m [0m[36m<EXECUTE>[0m [36m<BRANCH>[0m--For more information, try '[1m[36m--help[0m'.+✅ [32m[32mCreated new worktree for [1mno-hooks-test[22m from [1mmain[22m at [1m[REPO].no-hooks-test[39m[22m[39m+🔄 [36mExecuting (--execute):[39m+[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'execute command runs'[0m[2m[0mdiff --git a/tests/snapshots/integration__integration_tests__switch__switch_no_hooks_existing.snap b/tests/snapshots/integration__integration_tests__switch__switch_no_hooks_existing.snapindex e60eabab6..aafa41bcf 100644--- a/tests/snapshots/integration__integration_tests__switch__switch_no_hooks_existing.snap+++ b/tests/snapshots/integration__integration_tests__switch__switch_no_hooks_existing.snap@@ -7,7 +7,7 @@ info:- existing-no-hooks- "--execute"- "echo 'execute still runs'"- - "--no-hooks"+ - "--no-verify"env:CLICOLOR_FORCE: "1"COLUMNS: "150"@@ -22,15 +22,12 @@ info:SOURCE_DATE_EPOCH: "1735776000"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"----success: false-exit_code: 2+success: true+exit_code: 0----- stdout -----+execute still runs----- stderr ------[1m[31merror:[0m unexpected argument '[1m[33m--no-hooks[0m' found-- [1m[32mtip:[0m to pass '[1m[33m--no-hooks[0m' as a value, use '[1m[32m-- --no-hooks[0m'--[1m[32mUsage:[0m [1m[36mwt switch[0m [1m[36m--execute[0m[36m [0m[36m<EXECUTE>[0m [36m<BRANCH>[0m--For more information, try '[1m[36m--help[0m'.+✅ [32m[32mSwitched to worktree for [1mexisting-no-hooks[22m at [1m[REPO].existing-no-hooks[39m[22m[39m+🔄 [36mExecuting (--execute):[39m+[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'execute still runs'[0m[2m[0mdiff --git a/tests/snapshots/integration__integration_tests__switch__switch_no_hooks_skips_post_start.snap b/tests/snapshots/integration__integration_tests__switch__switch_no_hooks_skips_post_start.snapindex b9068e95c..935fa1a11 100644--- a/tests/snapshots/integration__integration_tests__switch__switch_no_hooks_skips_post_start.snap+++ b/tests/snapshots/integration__integration_tests__switch__switch_no_hooks_skips_post_start.snap@@ -6,7 +6,7 @@ info:- switch- "--create"- no-post-start- - "--no-hooks"+ - "--no-verify"env:CLICOLOR_FORCE: "1"COLUMNS: "150"@@ -21,15 +21,10 @@ info:SOURCE_DATE_EPOCH: "1735776000"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"----success: false-exit_code: 2+success: true+exit_code: 0----- stdout ---------- stderr ------[1m[31merror:[0m unexpected argument '[1m[33m--no-hooks[0m' found-- [1m[32mtip:[0m to pass '[1m[33m--no-hooks[0m' as a value, use '[1m[32m-- --no-hooks[0m'--[1m[32mUsage:[0m [1m[36mwt switch[0m [1m[36m--create[0m [36m<BRANCH>[0m--For more information, try '[1m[36m--help[0m'.+✅ [32m[32mCreated new worktree for [1mno-post-start[22m from [1mmain[22m at [1m[REPO].no-post-start[39m[22m[39m+💡 [2mRun [90mwt config shell install[39m to enable automatic cd[22mdiff --git a/tests/snapshots/integration__integration_tests__switch__switch_no_hooks_with_force.snap b/tests/snapshots/integration__integration_tests__switch__switch_no_hooks_with_force.snapindex b04c592d2..9fbc9420c 100644--- a/tests/snapshots/integration__integration_tests__switch__switch_no_hooks_with_force.snap+++ b/tests/snapshots/integration__integration_tests__switch__switch_no_hooks_with_force.snap@@ -7,7 +7,7 @@ info:- "--create"- force-no-hooks- "--force"- - "--no-hooks"+ - "--no-verify"env:CLICOLOR_FORCE: "1"COLUMNS: "150"@@ -22,15 +22,10 @@ info:SOURCE_DATE_EPOCH: "1735776000"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"----success: false-exit_code: 2+success: true+exit_code: 0----- stdout ---------- stderr ------[1m[31merror:[0m unexpected argument '[1m[33m--no-hooks[0m' found-- [1m[32mtip:[0m to pass '[1m[33m--no-hooks[0m' as a value, use '[1m[32m-- --no-hooks[0m'--[1m[32mUsage:[0m [1m[36mwt switch[0m [1m[36m--create[0m [1m[36m--force[0m [36m<BRANCH>[0m--For more information, try '[1m[36m--help[0m'.+✅ [32m[32mCreated new worktree for [1mforce-no-hooks[22m from [1mmain[22m at [1m[REPO].force-no-hooks[39m[22m[39m+💡 [2mRun [90mwt config shell install[39m to enable automatic cd[22mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__no_user_hooks_flag.snap b/tests/snapshots/integration__integration_tests__user_hooks__no_user_hooks_flag.snapnew file mode 100644index 000000000..eded8f916--- /dev/null+++ b/tests/snapshots/integration__integration_tests__user_hooks__no_user_hooks_flag.snap@@ -0,0 +1,34 @@+---+source: tests/integration_tests/user_hooks.rs+info:+ program: wt+ args:+ - switch+ - "--create"+ - feature+ - "--no-user-hooks"+ env:+ CLICOLOR_FORCE: "1"+ COLUMNS: "150"+ 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: ""+ LANG: C+ LC_ALL: C+ SOURCE_DATE_EPOCH: "1735776000"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+---+success: false+exit_code: 2+----- stdout -----++----- stderr -----+[1m[31merror:[0m unexpected argument '[1m[33m--no-user-hooks[0m' found++ [1m[32mtip:[0m to pass '[1m[33m--no-user-hooks[0m' as a value, use '[1m[32m-- --no-user-hooks[0m'++[1m[32mUsage:[0m [1m[36mwt switch[0m [1m[36m--create[0m [36m<BRANCH>[0m++For more information, try '[1m[36m--help[0m'.diff --git a/tests/snapshots/integration__integration_tests__user_hooks__no_verify_skips_all_hooks.snap b/tests/snapshots/integration__integration_tests__user_hooks__no_verify_skips_all_hooks.snapnew file mode 100644index 000000000..7261d6686--- /dev/null+++ b/tests/snapshots/integration__integration_tests__user_hooks__no_verify_skips_all_hooks.snap@@ -0,0 +1,29 @@+---+source: tests/integration_tests/user_hooks.rs+info:+ program: wt+ args:+ - switch+ - "--create"+ - feature+ - "--no-verify"+ env:+ CLICOLOR_FORCE: "1"+ COLUMNS: "150"+ 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: ""+ LANG: C+ LC_ALL: C+ SOURCE_DATE_EPOCH: "1735776000"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+---+success: true+exit_code: 0+----- stdout -----++----- stderr -----+✅ [32m[32mCreated new worktree for [1mfeature[22m from [1mmain[22m at [1m[REPO].feature[39m[22m[39m+💡 [2mRun [90mwt config shell install[39m to enable automatic cd[22mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_and_project_post_start.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_and_project_post_start.snapnew file mode 100644index 000000000..c4e2e8445--- /dev/null+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_and_project_post_start.snap@@ -0,0 +1,32 @@+---+source: tests/integration_tests/user_hooks.rs+info:+ program: wt+ args:+ - switch+ - "--create"+ - feature+ env:+ CLICOLOR_FORCE: "1"+ COLUMNS: "150"+ 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: ""+ LANG: C+ LC_ALL: C+ SOURCE_DATE_EPOCH: "1735776000"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+---+success: true+exit_code: 0+----- stdout -----++----- stderr -----+✅ [32m[32mCreated new worktree for [1mfeature[22m from [1mmain[22m at [1m[REPO].feature[39m[22m[39m+💡 [2mRun [90mwt config shell install[39m to enable automatic cd[22m+🔄 [36mRunning user post-start [1mbg[22m:[39m+[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'USER_POST_START'[0m[2m [0m[2m[36m>[0m[2m user_bg.txt[0m+🔄 [36mRunning project post-start:[39m+[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'PROJECT_POST_START'[0m[2m [0m[2m[36m>[0m[2m project_bg.txt[0mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_hook_template_vars.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_hook_template_vars.snapnew file mode 100644index 000000000..e946d6e05--- /dev/null+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_hook_template_vars.snap@@ -0,0 +1,30 @@+---+source: tests/integration_tests/user_hooks.rs+info:+ program: wt+ args:+ - switch+ - "--create"+ - feature+ env:+ CLICOLOR_FORCE: "1"+ COLUMNS: "150"+ 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: ""+ LANG: C+ LC_ALL: C+ SOURCE_DATE_EPOCH: "1735776000"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+---+success: true+exit_code: 0+----- stdout -----++----- stderr -----+🔄 [36mRunning user post-create [1mvars[22m:[39m+[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'repo=repo branch=feature'[0m[2m [0m[2m[36m>[0m[2m template_vars.txt[0m+[0m✅ [32m[32mCreated new worktree for [1mfeature[22m from [1mmain[22m at [1m[REPO].feature[39m[22m[39m+💡 [2mRun [90mwt config shell install[39m to enable automatic cd[22mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_hooks_before_project.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_hooks_before_project.snapnew file mode 100644index 000000000..cc549c2dc--- /dev/null+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_hooks_before_project.snap@@ -0,0 +1,32 @@+---+source: tests/integration_tests/user_hooks.rs+info:+ program: wt+ args:+ - switch+ - "--create"+ - feature+ env:+ CLICOLOR_FORCE: "1"+ COLUMNS: "150"+ 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: ""+ LANG: C+ LC_ALL: C+ SOURCE_DATE_EPOCH: "1735776000"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+---+success: true+exit_code: 0+----- stdout -----++----- stderr -----+🔄 [36mRunning user post-create [1mlog[22m:[39m+[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'USER_HOOK'[0m[2m [0m[2m[36m>>[0m[2m hook_order.txt[0m+[0m🔄 [36mRunning project post-create:[39m+[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'PROJECT_HOOK'[0m[2m [0m[2m[36m>>[0m[2m hook_order.txt[0m+[0m✅ [32m[32mCreated new worktree for [1mfeature[22m from [1mmain[22m at [1m[REPO].feature[39m[22m[39m+💡 [2mRun [90mwt config shell install[39m to enable automatic cd[22mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_hooks_no_approval.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_hooks_no_approval.snapnew file mode 100644index 000000000..b89a93598--- /dev/null+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_hooks_no_approval.snap@@ -0,0 +1,30 @@+---+source: tests/integration_tests/user_hooks.rs+info:+ program: wt+ args:+ - switch+ - "--create"+ - feature+ env:+ CLICOLOR_FORCE: "1"+ COLUMNS: "150"+ 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: ""+ LANG: C+ LC_ALL: C+ SOURCE_DATE_EPOCH: "1735776000"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+---+success: true+exit_code: 0+----- stdout -----++----- stderr -----+🔄 [36mRunning user post-create [1msetup[22m:[39m+[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'NO_APPROVAL_NEEDED'[0m[2m [0m[2m[36m>[0m[2m no_approval.txt[0m+[0m✅ [32m[32mCreated new worktree for [1mfeature[22m from [1mmain[22m at [1m[REPO].feature[39m[22m[39m+💡 [2mRun [90mwt config shell install[39m to enable automatic cd[22mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_post_create_executes.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_post_create_executes.snapnew file mode 100644index 000000000..3051bd14d--- /dev/null+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_post_create_executes.snap@@ -0,0 +1,30 @@+---+source: tests/integration_tests/user_hooks.rs+info:+ program: wt+ args:+ - switch+ - "--create"+ - feature+ env:+ CLICOLOR_FORCE: "1"+ COLUMNS: "150"+ 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: ""+ LANG: C+ LC_ALL: C+ SOURCE_DATE_EPOCH: "1735776000"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+---+success: true+exit_code: 0+----- stdout -----++----- stderr -----+🔄 [36mRunning user post-create [1mlog[22m:[39m+[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'USER_POST_CREATE_RAN'[0m[2m [0m[2m[36m>[0m[2m user_hook_marker.txt[0m+[0m✅ [32m[32mCreated new worktree for [1mfeature[22m from [1mmain[22m at [1m[REPO].feature[39m[22m[39m+💡 [2mRun [90mwt config shell install[39m to enable automatic cd[22mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_post_create_failure.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_post_create_failure.snapnew file mode 100644index 000000000..f9f4bc3d3--- /dev/null+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_post_create_failure.snap@@ -0,0 +1,31 @@+---+source: tests/integration_tests/user_hooks.rs+info:+ program: wt+ args:+ - switch+ - "--create"+ - feature+ env:+ CLICOLOR_FORCE: "1"+ COLUMNS: "150"+ 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: ""+ LANG: C+ LC_ALL: C+ SOURCE_DATE_EPOCH: "1735776000"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+---+success: true+exit_code: 0+----- stdout -----++----- stderr -----+🔄 [36mRunning user post-create [1mfailing[22m:[39m+[107m [0m [2m[0m[2m[34mexit[0m[2m 1[0m+[0m🟡 [33mCommand [1mfailing[22m failed: exit status: 1[39m+✅ [32m[32mCreated new worktree for [1mfeature[22m from [1mmain[22m at [1m[REPO].feature[39m[22m[39m+💡 [2mRun [90mwt config shell install[39m to enable automatic cd[22mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_post_merge_executes.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_post_merge_executes.snapnew file mode 100644index 000000000..b4de68bd9--- /dev/null+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_post_merge_executes.snap@@ -0,0 +1,36 @@+---+source: tests/integration_tests/user_hooks.rs+info:+ program: wt+ args:+ - merge+ - main+ - "--force"+ - "--no-remove"+ env:+ CLICOLOR_FORCE: "1"+ COLUMNS: "150"+ 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: ""+ LANG: C+ LC_ALL: C+ SOURCE_DATE_EPOCH: "1735776000"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+---+success: true+exit_code: 0+----- stdout -----++----- stderr -----+🔄 [36mMerging 1 commit to [1mmain[22m @ [2m66266ec[22m (no commit/squash/rebase needed)[39m+[107m [0m * [33m66266ec[m Add feature+[107m [0m feature.txt | 1 [32m+[m+[107m [0m 1 file changed, 1 insertion(+)+✅ [32mMerged to [1mmain[22m [90m(1 commit, 1 file, [32m+1[39m[39m[90m)[39m[39m+⚪ Worktree preserved (--no-remove)+🔄 [36mRunning user post-merge [1mnotify[22m:[39m+[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'USER_POST_MERGE_RAN'[0m[2m [0m[2m[36m>[0m[2m user_postmerge.txt[0m+[0mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_executes.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_executes.snapnew file mode 100644index 000000000..3609b3de5--- /dev/null+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_executes.snap@@ -0,0 +1,30 @@+---+source: tests/integration_tests/user_hooks.rs+info:+ program: wt+ args:+ - switch+ - "--create"+ - feature+ env:+ CLICOLOR_FORCE: "1"+ COLUMNS: "150"+ 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: ""+ LANG: C+ LC_ALL: C+ SOURCE_DATE_EPOCH: "1735776000"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+---+success: true+exit_code: 0+----- stdout -----++----- stderr -----+✅ [32m[32mCreated new worktree for [1mfeature[22m from [1mmain[22m at [1m[REPO].feature[39m[22m[39m+💡 [2mRun [90mwt config shell install[39m to enable automatic cd[22m+🔄 [36mRunning user post-start [1mbg[22m:[39m+[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'USER_POST_START_RAN'[0m[2m [0m[2m[36m>[0m[2m user_bg_marker.txt[0mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_skipped.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_skipped.snapnew file mode 100644index 000000000..eded8f916--- /dev/null+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_skipped.snap@@ -0,0 +1,34 @@+---+source: tests/integration_tests/user_hooks.rs+info:+ program: wt+ args:+ - switch+ - "--create"+ - feature+ - "--no-user-hooks"+ env:+ CLICOLOR_FORCE: "1"+ COLUMNS: "150"+ 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: ""+ LANG: C+ LC_ALL: C+ SOURCE_DATE_EPOCH: "1735776000"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+---+success: false+exit_code: 2+----- stdout -----++----- stderr -----+[1m[31merror:[0m unexpected argument '[1m[33m--no-user-hooks[0m' found++ [1m[32mtip:[0m to pass '[1m[33m--no-user-hooks[0m' as a value, use '[1m[32m-- --no-user-hooks[0m'++[1m[32mUsage:[0m [1m[36mwt switch[0m [1m[36m--create[0m [36m<BRANCH>[0m++For more information, try '[1m[36m--help[0m'.diff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_skipped_no_verify.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_skipped_no_verify.snapnew file mode 100644index 000000000..7261d6686--- /dev/null+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_post_start_skipped_no_verify.snap@@ -0,0 +1,29 @@+---+source: tests/integration_tests/user_hooks.rs+info:+ program: wt+ args:+ - switch+ - "--create"+ - feature+ - "--no-verify"+ env:+ CLICOLOR_FORCE: "1"+ COLUMNS: "150"+ 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: ""+ LANG: C+ LC_ALL: C+ SOURCE_DATE_EPOCH: "1735776000"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+---+success: true+exit_code: 0+----- stdout -----++----- stderr -----+✅ [32m[32mCreated new worktree for [1mfeature[22m from [1mmain[22m at [1m[REPO].feature[39m[22m[39m+💡 [2mRun [90mwt config shell install[39m to enable automatic cd[22mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_pre_commit_executes.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_commit_executes.snapnew file mode 100644index 000000000..272ae1de2--- /dev/null+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_commit_executes.snap@@ -0,0 +1,41 @@+---+source: tests/integration_tests/user_hooks.rs+info:+ program: wt+ args:+ - merge+ - main+ - "--force"+ - "--no-remove"+ env:+ CLICOLOR_FORCE: "1"+ COLUMNS: "150"+ 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: ""+ LANG: C+ LC_ALL: C+ SOURCE_DATE_EPOCH: "1735776000"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+---+success: true+exit_code: 0+----- stdout -----++----- stderr -----+🟡 [33mAuto-staging 1 untracked path:[39m+[107m [0m uncommitted.txt+🔄 [36mRunning user pre-commit [1mlint[22m:[39m+[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'USER_PRE_COMMIT_RAN'[0m[2m [0m[2m[36m>[0m[2m user_precommit.txt[0m+[0m🔄 [36mCommitting changes with default message... [90m(1 file, [32m+1[39m, no squashing needed[39m[90m)[39m[39m+💡 [2mUsing fallback commit message. Run [90mwt config --help[39m for LLM setup guide[22m+[107m [0m [1mChanges to uncommitted.txt[22m+✅ [32mCommitted changes @ [2mdd71589[22m[39m+🔄 [36mMerging 1 commit to [1mmain[22m @ [2mdd71589[22m (no rebase needed)[39m+[107m [0m * [33mdd71589[m Changes to uncommitted.txt+[107m [0m uncommitted.txt | 1 [32m+[m+[107m [0m 1 file changed, 1 insertion(+)+✅ [32mMerged to [1mmain[22m [90m(1 commit, 1 file, [32m+1[39m[39m[90m)[39m[39m+⚪ Worktree preserved (--no-remove)diff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_pre_commit_failure.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_commit_failure.snapnew file mode 100644index 000000000..343c33b46--- /dev/null+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_commit_failure.snap@@ -0,0 +1,34 @@+---+source: tests/integration_tests/user_hooks.rs+info:+ program: wt+ args:+ - merge+ - main+ - "--force"+ - "--no-remove"+ env:+ CLICOLOR_FORCE: "1"+ COLUMNS: "150"+ 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: ""+ LANG: C+ LC_ALL: C+ SOURCE_DATE_EPOCH: "1735776000"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+---+success: false+exit_code: 1+----- stdout -----++----- stderr -----+🟡 [33mAuto-staging 1 untracked path:[39m+[107m [0m uncommitted.txt+🔄 [36mRunning user pre-commit [1mlint[22m:[39m+[107m [0m [2m[0m[2m[34mexit[0m[2m 1[0m+[0m❌ [31mpre-commit command failed: [1mlint[22m: exit status: 1[39m++💡 [2mUse [90m--no-verify[39m to skip pre-commit commands[22mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_pre_merge_executes.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_merge_executes.snapnew file mode 100644index 000000000..9f8519151--- /dev/null+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_merge_executes.snap@@ -0,0 +1,35 @@+---+source: tests/integration_tests/user_hooks.rs+info:+ program: wt+ args:+ - merge+ - main+ - "--force"+ - "--no-remove"+ env:+ CLICOLOR_FORCE: "1"+ COLUMNS: "150"+ 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: ""+ LANG: C+ LC_ALL: C+ SOURCE_DATE_EPOCH: "1735776000"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+---+success: true+exit_code: 0+----- stdout -----++----- stderr -----+🔄 [36mRunning user pre-merge [1mcheck[22m:[39m+[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'USER_PRE_MERGE_RAN'[0m[2m [0m[2m[36m>[0m[2m user_premerge.txt[0m+[0m🔄 [36mMerging 1 commit to [1mmain[22m @ [2m66266ec[22m (no commit/squash/rebase needed)[39m+[107m [0m * [33m66266ec[m Add feature+[107m [0m feature.txt | 1 [32m+[m+[107m [0m 1 file changed, 1 insertion(+)+✅ [32mMerged to [1mmain[22m [90m(1 commit, 1 file, [32m+1[39m[39m[90m)[39m[39m+⚪ Worktree preserved (--no-remove)diff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_pre_merge_failure.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_merge_failure.snapnew file mode 100644index 000000000..f353f0c44--- /dev/null+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_merge_failure.snap@@ -0,0 +1,32 @@+---+source: tests/integration_tests/user_hooks.rs+info:+ program: wt+ args:+ - merge+ - main+ - "--force"+ - "--no-remove"+ env:+ CLICOLOR_FORCE: "1"+ COLUMNS: "150"+ 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: ""+ LANG: C+ LC_ALL: C+ SOURCE_DATE_EPOCH: "1735776000"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+---+success: false+exit_code: 1+----- stdout -----++----- stderr -----+🔄 [36mRunning user pre-merge [1mcheck[22m:[39m+[107m [0m [2m[0m[2m[34mexit[0m[2m 1[0m+[0m❌ [31mpre-merge command failed: [1mcheck[22m: exit status: 1[39m++💡 [2mUse [90m--no-verify[39m to skip pre-merge commands[22mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_pre_merge_skipped.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_merge_skipped.snapnew file mode 100644index 000000000..f1b3acfe3--- /dev/null+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_merge_skipped.snap@@ -0,0 +1,35 @@+---+source: tests/integration_tests/user_hooks.rs+info:+ program: wt+ args:+ - merge+ - main+ - "--force"+ - "--no-remove"+ - "--no-user-hooks"+ env:+ CLICOLOR_FORCE: "1"+ COLUMNS: "150"+ 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: ""+ LANG: C+ LC_ALL: C+ SOURCE_DATE_EPOCH: "1735776000"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+---+success: false+exit_code: 2+----- stdout -----++----- stderr -----+[1m[31merror:[0m unexpected argument '[1m[33m--no-user-hooks[0m' found++ [1m[32mtip:[0m to pass '[1m[33m--no-user-hooks[0m' as a value, use '[1m[32m-- --no-user-hooks[0m'++[1m[32mUsage:[0m [1m[36mwt merge[0m [1m[36m--force[0m [1m[36m--no-remove[0m [36m<TARGET>[0m++For more information, try '[1m[36m--help[0m'.diff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_pre_merge_skipped_no_verify.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_merge_skipped_no_verify.snapnew file mode 100644index 000000000..5a56de979--- /dev/null+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_merge_skipped_no_verify.snap@@ -0,0 +1,34 @@+---+source: tests/integration_tests/user_hooks.rs+info:+ program: wt+ args:+ - merge+ - main+ - "--force"+ - "--no-remove"+ - "--no-verify"+ env:+ CLICOLOR_FORCE: "1"+ COLUMNS: "150"+ 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: ""+ LANG: C+ LC_ALL: C+ SOURCE_DATE_EPOCH: "1735776000"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+---+success: true+exit_code: 0+----- stdout -----++----- stderr -----+🔄 [36mMerging 1 commit to [1mmain[22m @ [2m66266ec[22m (no commit/squash/rebase needed)[39m+[107m [0m * [33m66266ec[m Add feature+[107m [0m feature.txt | 1 [32m+[m+[107m [0m 1 file changed, 1 insertion(+)+✅ [32mMerged to [1mmain[22m [90m(1 commit, 1 file, [32m+1[39m[39m[90m)[39m[39m+⚪ Worktree preserved (--no-remove)diff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_pre_remove_executes.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_remove_executes.snapnew file mode 100644index 000000000..8fa80d106--- /dev/null+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_remove_executes.snap@@ -0,0 +1,29 @@+---+source: tests/integration_tests/user_hooks.rs+info:+ program: wt+ args:+ - remove+ - feature+ - "--force-delete"+ env:+ CLICOLOR_FORCE: "1"+ COLUMNS: "150"+ 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: ""+ LANG: C+ LC_ALL: C+ SOURCE_DATE_EPOCH: "1735776000"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+---+success: true+exit_code: 0+----- stdout -----++----- stderr -----+🔄 [36mRunning user pre-remove [1mcleanup[22m:[39m+[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'USER_PRE_REMOVE_RAN'[0m[2m [0m[2m[36m>[0m[2m /tmp/user_preremove_marker.txt[0m+[0m🔄 [36m[36mRemoving [1mfeature[22m worktree & branch in background (--force-delete)[39m[39mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_pre_remove_failure.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_remove_failure.snapnew file mode 100644index 000000000..742156210--- /dev/null+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_remove_failure.snap@@ -0,0 +1,31 @@+---+source: tests/integration_tests/user_hooks.rs+info:+ program: wt+ args:+ - remove+ - feature+ - "--force-delete"+ env:+ CLICOLOR_FORCE: "1"+ COLUMNS: "150"+ 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: ""+ LANG: C+ LC_ALL: C+ SOURCE_DATE_EPOCH: "1735776000"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+---+success: false+exit_code: 1+----- stdout -----++----- stderr -----+🔄 [36mRunning user pre-remove [1mblock[22m:[39m+[107m [0m [2m[0m[2m[34mexit[0m[2m 1[0m+[0m❌ [31mpre-remove command failed: [1mblock[22m: exit status: 1[39m++💡 [2mUse [90m--no-verify[39m to skip pre-remove commands[22mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_pre_remove_skipped.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_remove_skipped.snapnew file mode 100644index 000000000..68e54b5c5--- /dev/null+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_remove_skipped.snap@@ -0,0 +1,34 @@+---+source: tests/integration_tests/user_hooks.rs+info:+ program: wt+ args:+ - remove+ - feature+ - "--force-delete"+ - "--no-user-hooks"+ env:+ CLICOLOR_FORCE: "1"+ COLUMNS: "150"+ 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: ""+ LANG: C+ LC_ALL: C+ SOURCE_DATE_EPOCH: "1735776000"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+---+success: false+exit_code: 2+----- stdout -----++----- stderr -----+[1m[31merror:[0m unexpected argument '[1m[33m--no-user-hooks[0m' found++ [1m[32mtip:[0m to pass '[1m[33m--no-user-hooks[0m' as a value, use '[1m[32m-- --no-user-hooks[0m'++[1m[32mUsage:[0m [1m[36mwt remove[0m [1m[36m--force-delete[0m [36m<WORKTREES>...[0m++For more information, try '[1m[36m--help[0m'.diff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_pre_remove_skipped_no_verify.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_remove_skipped_no_verify.snapnew file mode 100644index 000000000..1626940a9--- /dev/null+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_remove_skipped_no_verify.snap@@ -0,0 +1,28 @@+---+source: tests/integration_tests/user_hooks.rs+info:+ program: wt+ args:+ - remove+ - feature+ - "--force-delete"+ - "--no-verify"+ env:+ CLICOLOR_FORCE: "1"+ COLUMNS: "150"+ 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: ""+ LANG: C+ LC_ALL: C+ SOURCE_DATE_EPOCH: "1735776000"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+---+success: true+exit_code: 0+----- stdout -----++----- stderr -----+🔄 [36m[36mRemoving [1mfeature[22m worktree & branch in background (--force-delete)[39m[39m