From 47c92ffc61daa8ba13adce1750fafd40e4a12eae Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Thu, 16 Jul 2026 20:16:07 -0700 Subject: [PATCH] feat: name the template owner in the -v variables block MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `-v` variables table printed a bare `template variables:` header, so nothing in it said which template the variables were for. The adjacent blocks in the same lane already label themselves (`○ eval source`, `○ user:noop result`), and the table only carried its owner incidentally — in the `hook_type` row at the bottom of a ~20-row listing, or in the `Running ...` line below it. Background hooks made that ambiguous rather than just inconvenient: `wt -v remove` prints one table per hook type back to back, then a single combined `Running post-remove: cleanup; post-switch: notify` line, leaving two identical headers above two tables that differ only in their rows. Prefix each header with the hook type, alias name, or `eval`, matching the sibling `source` / `result` headers. `wt step eval -v` now reads: ○ eval template variables: ○ eval source ○ eval result Co-Authored-By: Claude Opus 4.8 (1M context) --- docs/content/step.md | 2 +- plugins/worktrunk/skills/worktrunk/reference/step.md | 2 +- skills/worktrunk/reference/step.md | 2 +- src/cli/step.rs | 2 +- src/commands/alias.rs | 5 ++++- src/commands/command_executor.rs | 5 ++++- src/commands/eval.rs | 5 ++++- src/commands/hooks.rs | 5 ++++- ...n__integration_tests__eval__eval_format_json_verbose.snap | 4 +++- .../integration__integration_tests__eval__eval_verbose.snap | 4 +++- ...ests__post_start_commands__post_start_verbose_output.snap | 4 +++- ...tart_commands__post_start_verbose_template_expansion.snap | 4 +++- ..._tests__step_alias__alias_verbose_args_shell_escaped.snap | 4 +++- ...tion_tests__step_alias__alias_verbose_variable_table.snap | 4 +++- ..._hooks__combined_post_remove_and_post_switch_verbose.snap | 5 +++-- ...ion_tests__user_hooks__hook_verbose_background_dedup.snap | 4 +++- ...ation_tests__user_hooks__hook_verbose_variable_table.snap | 3 ++- 17 files changed, 46 insertions(+), 18 deletions(-) diff --git a/docs/content/step.md b/docs/content/step.md index 8f05a60786..e7629361d5 100644 --- a/docs/content/step.md +++ b/docs/content/step.md @@ -551,7 +551,7 @@ feature_auth_oauth2_a1b List the available template variables with `-v` (alongside the expansion, on stderr): {% terminal(cmd="wt step eval -v '__WT_OPEN__ branch __WT_CLOSE__'") %} -○ Available template variables +○ eval template variables: branch = feature/auth-oauth2 worktree_path = /home/user/projects/myapp-feature-auth-oauth2 ○ eval source diff --git a/plugins/worktrunk/skills/worktrunk/reference/step.md b/plugins/worktrunk/skills/worktrunk/reference/step.md index 85d72b08ed..82fa91d435 100644 --- a/plugins/worktrunk/skills/worktrunk/reference/step.md +++ b/plugins/worktrunk/skills/worktrunk/reference/step.md @@ -568,7 +568,7 @@ List the available template variables with `-v` (alongside the expansion, on std ```bash $ wt step eval -v '{{ branch }}' -○ Available template variables +○ eval template variables: branch = feature/auth-oauth2 worktree_path = /home/user/projects/myapp-feature-auth-oauth2 ○ eval source diff --git a/skills/worktrunk/reference/step.md b/skills/worktrunk/reference/step.md index 85d72b08ed..82fa91d435 100644 --- a/skills/worktrunk/reference/step.md +++ b/skills/worktrunk/reference/step.md @@ -568,7 +568,7 @@ List the available template variables with `-v` (alongside the expansion, on std ```bash $ wt step eval -v '{{ branch }}' -○ Available template variables +○ eval template variables: branch = feature/auth-oauth2 worktree_path = /home/user/projects/myapp-feature-auth-oauth2 ○ eval source diff --git a/src/cli/step.rs b/src/cli/step.rs index 084cb8db23..a4d9d67e5a 100644 --- a/src/cli/step.rs +++ b/src/cli/step.rs @@ -439,7 +439,7 @@ List the available template variables with `-v` (alongside the expansion, on std ```console $ wt step eval -v '{{ branch }}' -○ Available template variables +○ eval template variables: branch = feature/auth-oauth2 worktree_path = /home/user/projects/myapp-feature-auth-oauth2 ○ eval source diff --git a/src/commands/alias.rs b/src/commands/alias.rs index cc2dcd3500..a321ff8c05 100644 --- a/src/commands/alias.rs +++ b/src/commands/alias.rs @@ -618,7 +618,10 @@ fn run_alias( if verbosity() >= 1 { let vars = format_alias_variables(&context_map, Some(&referenced)); - eprintln!("{}", info_message("template variables:")); + eprintln!( + "{}", + info_message(cformat!("{} template variables:", opts.name)) + ); eprintln!("{}", format_with_gutter(&vars, None)); } diff --git a/src/commands/command_executor.rs b/src/commands/command_executor.rs index 7bf2b21a29..885fc97f18 100644 --- a/src/commands/command_executor.rs +++ b/src/commands/command_executor.rs @@ -628,7 +628,10 @@ fn announce_command(cmd: &PreparedCommand, kind: &PipelineKind, command_str: &st }; if verbosity() >= 1 { let vars = format_hook_variables(*hook_type, &cmd.context); - eprintln!("{}", info_message("template variables:")); + eprintln!( + "{}", + info_message(cformat!("{hook_type} template variables:")) + ); eprintln!("{}", format_with_gutter(&vars, None)); } eprintln!("{}", progress_message(message)); diff --git a/src/commands/eval.rs b/src/commands/eval.rs index 277ec7f881..1fe01fb828 100644 --- a/src/commands/eval.rs +++ b/src/commands/eval.rs @@ -51,7 +51,10 @@ pub fn step_eval(template: &str, format: SwitchFormat) -> anyhow::Result<()> { }) .collect::>() .join("\n"); - eprintln!("{}", info_message("Available template variables")); + eprintln!( + "{}", + info_message(cformat!("{EVAL_NAME} template variables:")) + ); eprintln!("{}", format_with_gutter(&listing, None)); } diff --git a/src/commands/hooks.rs b/src/commands/hooks.rs index 9b9d9078c0..39da3cfbdf 100644 --- a/src/commands/hooks.rs +++ b/src/commands/hooks.rs @@ -465,7 +465,10 @@ fn print_background_variable_table(pipelines: &[PendingPipeline], hook_type: Hoo PreparedStep::Single(cmd) => cmd, PreparedStep::Concurrent(cmds) => &cmds[0], }; - eprintln!("{}", info_message("template variables:")); + eprintln!( + "{}", + info_message(cformat!("{hook_type} template variables:")) + ); eprintln!( "{}", format_with_gutter(&format_hook_variables(hook_type, &cmd.context), None) diff --git a/tests/snapshots/integration__integration_tests__eval__eval_format_json_verbose.snap b/tests/snapshots/integration__integration_tests__eval__eval_format_json_verbose.snap index e58a3161f9..18a1cf9bfe 100644 --- a/tests/snapshots/integration__integration_tests__eval__eval_format_json_verbose.snap +++ b/tests/snapshots/integration__integration_tests__eval__eval_format_json_verbose.snap @@ -10,6 +10,7 @@ info: - "{{ branch | hash_port }}" env: APPDATA: "[TEST_CONFIG_HOME]" + CLAUDE_CONFIG_DIR: "[TEST_CLAUDE_CONFIG]" CLICOLOR_FORCE: "1" COLUMNS: "500" GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z" @@ -38,6 +39,7 @@ info: WORKTRUNK_TEST_GEMINI_INSTALLED: "0" WORKTRUNK_TEST_NUSHELL_ENV: "0" WORKTRUNK_TEST_OPENCODE_INSTALLED: "0" + WORKTRUNK_TEST_PARENT_SHELL: "" WORKTRUNK_TEST_POWERSHELL_ENV: "0" WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0" WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1" @@ -54,7 +56,7 @@ exit_code: 0 } ----- stderr ----- -○ Available template variables +○ eval template variables:   branch = main   commit = 05a4a45d0b981dad5c27db59dca482836d59f89e   cwd = _REPO_ diff --git a/tests/snapshots/integration__integration_tests__eval__eval_verbose.snap b/tests/snapshots/integration__integration_tests__eval__eval_verbose.snap index 6331f4e6ec..031080134b 100644 --- a/tests/snapshots/integration__integration_tests__eval__eval_verbose.snap +++ b/tests/snapshots/integration__integration_tests__eval__eval_verbose.snap @@ -9,6 +9,7 @@ info: - "{{ branch | hash_port }}" env: APPDATA: "[TEST_CONFIG_HOME]" + CLAUDE_CONFIG_DIR: "[TEST_CLAUDE_CONFIG]" CLICOLOR_FORCE: "1" COLUMNS: "500" GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z" @@ -37,6 +38,7 @@ info: WORKTRUNK_TEST_GEMINI_INSTALLED: "0" WORKTRUNK_TEST_NUSHELL_ENV: "0" WORKTRUNK_TEST_OPENCODE_INSTALLED: "0" + WORKTRUNK_TEST_PARENT_SHELL: "" WORKTRUNK_TEST_POWERSHELL_ENV: "0" WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0" WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1" @@ -49,7 +51,7 @@ exit_code: 0 12107 ----- stderr ----- -○ Available template variables +○ eval template variables:   branch = main   commit = 05a4a45d0b981dad5c27db59dca482836d59f89e   cwd = _REPO_ diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_verbose_output.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_verbose_output.snap index 43d4a6fccc..ed0d680512 100644 --- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_verbose_output.snap +++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_verbose_output.snap @@ -9,6 +9,7 @@ info: - feature env: APPDATA: "[TEST_CONFIG_HOME]" + CLAUDE_CONFIG_DIR: "[TEST_CLAUDE_CONFIG]" CLICOLOR_FORCE: "1" COLUMNS: "500" GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z" @@ -37,6 +38,7 @@ info: WORKTRUNK_TEST_GEMINI_INSTALLED: "0" WORKTRUNK_TEST_NUSHELL_ENV: "0" WORKTRUNK_TEST_OPENCODE_INSTALLED: "0" + WORKTRUNK_TEST_PARENT_SHELL: "" WORKTRUNK_TEST_POWERSHELL_ENV: "0" WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0" WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1" @@ -56,7 +58,7 @@ exit_code: 0 ↳ To customize worktree locations, run wt config create ▲ Cannot change directory — shell integration not installed ↳ To enable automatic cd, run wt config shell install -○ template variables: +○ post-start template variables:   branch = feature   worktree_path = _REPO_.feature   worktree_name = repo.feature diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_verbose_template_expansion.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_verbose_template_expansion.snap index 801da48b39..f4626fe732 100644 --- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_verbose_template_expansion.snap +++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_verbose_template_expansion.snap @@ -9,6 +9,7 @@ info: - verbose-hooks env: APPDATA: "[TEST_CONFIG_HOME]" + CLAUDE_CONFIG_DIR: "[TEST_CLAUDE_CONFIG]" CLICOLOR_FORCE: "1" COLUMNS: "500" GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z" @@ -37,6 +38,7 @@ info: WORKTRUNK_TEST_GEMINI_INSTALLED: "0" WORKTRUNK_TEST_NUSHELL_ENV: "0" WORKTRUNK_TEST_OPENCODE_INSTALLED: "0" + WORKTRUNK_TEST_PARENT_SHELL: "" WORKTRUNK_TEST_POWERSHELL_ENV: "0" WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0" WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1" @@ -56,7 +58,7 @@ exit_code: 0   echo 'Setting up {{ branch | sanitize }} in {{ worktree_path }}' ○ project:setup result   echo 'Setting up verbose-hooks in _REPO_.verbose-hooks' -○ template variables: +○ pre-start template variables:   branch = verbose-hooks   worktree_path = _REPO_.verbose-hooks   worktree_name = repo.verbose-hooks diff --git a/tests/snapshots/integration__integration_tests__step_alias__alias_verbose_args_shell_escaped.snap b/tests/snapshots/integration__integration_tests__step_alias__alias_verbose_args_shell_escaped.snap index 4bd1f29c2f..3c2c866735 100644 --- a/tests/snapshots/integration__integration_tests__step_alias__alias_verbose_args_shell_escaped.snap +++ b/tests/snapshots/integration__integration_tests__step_alias__alias_verbose_args_shell_escaped.snap @@ -9,6 +9,7 @@ info: - bar baz env: APPDATA: "[TEST_CONFIG_HOME]" + CLAUDE_CONFIG_DIR: "[TEST_CLAUDE_CONFIG]" CLICOLOR_FORCE: "1" COLUMNS: "500" GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z" @@ -37,6 +38,7 @@ info: WORKTRUNK_TEST_GEMINI_INSTALLED: "0" WORKTRUNK_TEST_NUSHELL_ENV: "0" WORKTRUNK_TEST_OPENCODE_INSTALLED: "0" + WORKTRUNK_TEST_PARENT_SHELL: "" WORKTRUNK_TEST_POWERSHELL_ENV: "0" WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0" WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1" @@ -49,7 +51,7 @@ exit_code: 0 hello foo bar baz ----- stderr ----- -○ template variables: +○ greet template variables:   branch = feature   worktree_path = _REPO_.feature   worktree_name = repo.feature diff --git a/tests/snapshots/integration__integration_tests__step_alias__alias_verbose_variable_table.snap b/tests/snapshots/integration__integration_tests__step_alias__alias_verbose_variable_table.snap index 133928cef1..8f1787f5d3 100644 --- a/tests/snapshots/integration__integration_tests__step_alias__alias_verbose_variable_table.snap +++ b/tests/snapshots/integration__integration_tests__step_alias__alias_verbose_variable_table.snap @@ -8,6 +8,7 @@ info: - world env: APPDATA: "[TEST_CONFIG_HOME]" + CLAUDE_CONFIG_DIR: "[TEST_CLAUDE_CONFIG]" CLICOLOR_FORCE: "1" COLUMNS: "500" GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z" @@ -36,6 +37,7 @@ info: WORKTRUNK_TEST_GEMINI_INSTALLED: "0" WORKTRUNK_TEST_NUSHELL_ENV: "0" WORKTRUNK_TEST_OPENCODE_INSTALLED: "0" + WORKTRUNK_TEST_PARENT_SHELL: "" WORKTRUNK_TEST_POWERSHELL_ENV: "0" WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0" WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1" @@ -48,7 +50,7 @@ exit_code: 0 hello world ----- stderr ----- -○ template variables: +○ greet template variables:   branch = feature   worktree_path = _REPO_.feature   worktree_name = repo.feature diff --git a/tests/snapshots/integration__integration_tests__user_hooks__combined_post_remove_and_post_switch_verbose.snap b/tests/snapshots/integration__integration_tests__user_hooks__combined_post_remove_and_post_switch_verbose.snap index cb272a0f55..36e8cc153e 100644 --- a/tests/snapshots/integration__integration_tests__user_hooks__combined_post_remove_and_post_switch_verbose.snap +++ b/tests/snapshots/integration__integration_tests__user_hooks__combined_post_remove_and_post_switch_verbose.snap @@ -38,6 +38,7 @@ info: WORKTRUNK_TEST_GEMINI_INSTALLED: "0" WORKTRUNK_TEST_NUSHELL_ENV: "0" WORKTRUNK_TEST_OPENCODE_INSTALLED: "0" + WORKTRUNK_TEST_PARENT_SHELL: "" WORKTRUNK_TEST_POWERSHELL_ENV: "0" WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0" WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1" @@ -52,7 +53,7 @@ exit_code: 0 ◎ Removing feature worktree & branch in background (--force-delete) ▲ Cannot change directory — shell integration not installed ↳ To enable automatic cd, run wt config shell install -○ template variables: +○ post-remove template variables:   branch = feature   worktree_path = _REPO_.feature   worktree_name = repo.feature @@ -71,7 +72,7 @@ exit_code: 0   cwd = _REPO_   hook_type = post-remove   hook_name = cleanup -○ template variables: +○ post-switch template variables:   branch = main   worktree_path = _REPO_   worktree_name = repo diff --git a/tests/snapshots/integration__integration_tests__user_hooks__hook_verbose_background_dedup.snap b/tests/snapshots/integration__integration_tests__user_hooks__hook_verbose_background_dedup.snap index 848d57dfd9..e55a5cc951 100644 --- a/tests/snapshots/integration__integration_tests__user_hooks__hook_verbose_background_dedup.snap +++ b/tests/snapshots/integration__integration_tests__user_hooks__hook_verbose_background_dedup.snap @@ -9,6 +9,7 @@ info: - feature env: APPDATA: "[TEST_CONFIG_HOME]" + CLAUDE_CONFIG_DIR: "[TEST_CLAUDE_CONFIG]" CLICOLOR_FORCE: "1" COLUMNS: "500" GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z" @@ -37,6 +38,7 @@ info: WORKTRUNK_TEST_GEMINI_INSTALLED: "0" WORKTRUNK_TEST_NUSHELL_ENV: "0" WORKTRUNK_TEST_OPENCODE_INSTALLED: "0" + WORKTRUNK_TEST_PARENT_SHELL: "" WORKTRUNK_TEST_POWERSHELL_ENV: "0" WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0" WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1" @@ -56,7 +58,7 @@ exit_code: 0 ↳ To customize worktree locations, run wt config create ▲ Cannot change directory — shell integration not installed ↳ To enable automatic cd, run wt config shell install -○ template variables: +○ post-start template variables:   branch = feature   worktree_path = _REPO_.feature   worktree_name = repo.feature diff --git a/tests/snapshots/integration__integration_tests__user_hooks__hook_verbose_variable_table.snap b/tests/snapshots/integration__integration_tests__user_hooks__hook_verbose_variable_table.snap index a92b955133..398447a0bc 100644 --- a/tests/snapshots/integration__integration_tests__user_hooks__hook_verbose_variable_table.snap +++ b/tests/snapshots/integration__integration_tests__user_hooks__hook_verbose_variable_table.snap @@ -37,6 +37,7 @@ info: WORKTRUNK_TEST_GEMINI_INSTALLED: "0" WORKTRUNK_TEST_NUSHELL_ENV: "0" WORKTRUNK_TEST_OPENCODE_INSTALLED: "0" + WORKTRUNK_TEST_PARENT_SHELL: "" WORKTRUNK_TEST_POWERSHELL_ENV: "0" WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0" WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1" @@ -52,7 +53,7 @@ exit_code: 0   true ○ user:noop result   true -○ template variables: +○ pre-switch template variables:   branch = feature   worktree_path = _REPO_.feature   worktree_name = repo.feature