Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
fix: Rename _wt_exec to wt_exec for Claude Code compatibility
Maximilian Roosaa754a987f3b
diff --git a/templates/bash.sh b/templates/bash.shindex 15c14ed7d..90ebae1e7 100644--- a/templates/bash.sh+++ b/templates/bash.sh@@ -38,7 +38,7 @@ if command -v {{ cmd_prefix }} >/dev/null 2>&1 || [[ -n "${WORKTRUNK_BIN:-}" ]];fi# Always use --internal mode for directive support- _wt_exec --internal "${args[@]}"+ wt_exec --internal "${args[@]}"# Restore original commandlocal result=$?diff --git a/templates/elvish.elv b/templates/elvish.elvindex 526592ab8..a1dd7dca8 100644--- a/templates/elvish.elv+++ b/templates/elvish.elv@@ -14,7 +14,7 @@ if (or (has-external {{ cmd_prefix }}) (has-env WORKTRUNK_BIN)) {# NOTE: Uses 'slurp' which buffers output. Elvish's I/O model doesn't provide# good primitives for byte-level streaming of process output while also capturing# it for directive processing. Exit codes are now captured correctly.- fn _wt_exec {|@args|+ fn wt_exec {|@args|var exit-code = 0var output = ""var exec-cmd = ""@@ -112,7 +112,7 @@ if (or (has-external {{ cmd_prefix }}) (has-env WORKTRUNK_BIN)) {}# Always use --internal mode for directive support- _wt_exec --internal $@filtered-args+ wt_exec --internal $@filtered-args# Restore original commandset _WORKTRUNK_CMD = $saved-cmddiff --git a/templates/fish.fish b/templates/fish.fishindex 7e3d8c35d..5f5369ce1 100644--- a/templates/fish.fish+++ b/templates/fish.fish@@ -18,14 +18,14 @@ if type -q {{ cmd_prefix }}; or set -q WORKTRUNK_BIN# would serialize the pipeline (RHS wouldn't run until LHS finishes).# By keeping the LHS as a plain external command, the RHS can consume# the stream concurrently, preserving temporal ordering.- function _wt_exec+ function wt_execset -l exec_cmd ""# Debug mode: set WORKTRUNK_DEBUG=1 to see what's happeningset -l debug_mode 0if set -q WORKTRUNK_DEBUGset debug_mode 1- echo "[DEBUG] Starting _wt_exec with args: $argv" >&2+ echo "[DEBUG] Starting wt_exec with args: $argv" >&2end# CRITICAL: Do NOT add "2>&1" here!@@ -118,7 +118,7 @@ if type -q {{ cmd_prefix }}; or set -q WORKTRUNK_BINend# Always use --internal mode for directive support- _wt_exec --internal $args+ wt_exec --internal $args# Restore original commandset -l result $statusdiff --git a/templates/nushell.nu b/templates/nushell.nuindex 9f9605d61..b3bf531a8 100644--- a/templates/nushell.nu+++ b/templates/nushell.nu@@ -11,7 +11,7 @@ if (which {{ cmd_prefix }} | is-not-empty) or ($env.WORKTRUNK_BIN? | is-not-empt# NOTE: Uses 'complete' which buffers output. Nushell's streaming model doesn't# provide primitives for byte-level reading of process output, so real-time# streaming is not currently possible. Exit codes are captured correctly.- export def --env _wt_exec [cmd?: string, ...args] {+ export def --env wt_exec [cmd?: string, ...args] {let command = (if ($cmd | is-empty) { $_WORKTRUNK_CMD } else { $cmd })# Run command and capture result@@ -87,7 +87,7 @@ if (which {{ cmd_prefix }} | is-not-empty) or ($env.WORKTRUNK_BIN? | is-not-empt# Always use --internal mode for directive supportlet internal_args = (["--internal"] | append $filtered_args)- let exit_code = (_wt_exec $cmd ...$internal_args)+ let exit_code = (wt_exec $cmd ...$internal_args)return $exit_code}}diff --git a/templates/posix_directives.sh b/templates/posix_directives.shindex e400bfc36..eee87f0cc 100644--- a/templates/posix_directives.sh+++ b/templates/posix_directives.sh@@ -1,7 +1,9 @@# Shared directive parser for POSIX shells (bash, zsh, oil).# Reads worktrunk's NUL-delimited output in real-time via a FIFO so progress# and hint messages stream immediately while keeping stderr attached to the TTY.-_wt_exec() {+# Note: Named without leading underscore to avoid being filtered by shell+# snapshot systems (e.g., Claude Code) that exclude private functions.+wt_exec() {local exec_cmd="" chunk="" exit_code=0 tmp_dir="" exit_file="" fifo_path="" runner_pid=""tmp_dir=$(mktemp -d "${TMPDIR:-/tmp}/wt.XXXXXX") || {diff --git a/templates/powershell.ps1 b/templates/powershell.ps1index d4630605f..58e77bc19 100644--- a/templates/powershell.ps1+++ b/templates/powershell.ps1@@ -8,7 +8,7 @@ if ((Get-Command {{ cmd_prefix }} -ErrorAction SilentlyContinue) -or $env:WORKTR# Helper function to parse wt output and handle directives# Directives are NUL-terminated to support multi-line commands- function _wt_exec {+ function wt_exec {param([string]$Command,[Parameter(ValueFromRemainingArguments=$true)]@@ -135,7 +135,7 @@ if ((Get-Command {{ cmd_prefix }} -ErrorAction SilentlyContinue) -or $env:WORKTR}# Always use --internal mode for directive support- $exitCode = _wt_exec -Command $cmd --internal @filteredArgs+ $exitCode = wt_exec -Command $cmd --internal @filteredArgsreturn $exitCode}}diff --git a/templates/xonsh.xsh b/templates/xonsh.xshindex 8074509b3..f8f61d3c3 100644--- a/templates/xonsh.xsh+++ b/templates/xonsh.xsh@@ -9,7 +9,7 @@ if shutil.which("{{ cmd_prefix }}") is not None or os.environ.get('WORKTRUNK_BIN# This allows testing development builds: $WORKTRUNK_BIN = ./target/debug/{{ cmd_prefix }}_WORKTRUNK_CMD = os.environ.get('WORKTRUNK_BIN', '{{ cmd_prefix }}')- def _wt_exec(args, cmd=None):+ def wt_exec(args, cmd=None):"""Helper function to parse wt output and handle directivesDirectives are NUL-terminated to support multi-line commands"""import subprocess@@ -108,7 +108,7 @@ if shutil.which("{{ cmd_prefix }}") is not None or os.environ.get('WORKTRUNK_BINos.environ['CLICOLOR_FORCE'] = '1'# Always use --internal mode for directive support- return _wt_exec(["--internal"] + filtered_args, cmd=cmd)+ return wt_exec(["--internal"] + filtered_args, cmd=cmd)# Register the aliasaliases['{{ cmd_prefix }}'] = _{{ cmd_prefix }}_wrapperdiff --git a/templates/zsh.zsh b/templates/zsh.zshindex 921b6ba6f..0902d2540 100644--- a/templates/zsh.zsh+++ b/templates/zsh.zsh@@ -38,7 +38,7 @@ if command -v {{ cmd_prefix }} >/dev/null 2>&1 || [[ -n "${WORKTRUNK_BIN:-}" ]];fi# Always use --internal mode for directive support- _wt_exec --internal "${args[@]}"+ wt_exec --internal "${args[@]}"# Restore original commandlocal result=$?diff --git a/tests/integration_tests/shell_wrapper.rs b/tests/integration_tests/shell_wrapper.rsindex 9f1d490a0..e64e6bf56 100644--- a/tests/integration_tests/shell_wrapper.rs+++ b/tests/integration_tests/shell_wrapper.rs@@ -1,7 +1,7 @@//! Shell wrapper integration tests//!//! Tests that verify the complete shell integration path - commands executed through-//! the actual shell wrapper (_wt_exec in bash/zsh/fish).+//! the actual shell wrapper (wt_exec in bash/zsh/fish).//!//! These tests ensure that://! - Directives are never leaked to users@@ -331,7 +331,7 @@ fn normalize_newlines(s: &str) -> String {////// This simulates what actually happens when users run `wt switch`, etc. in their shell:/// 1. The `wt` function is defined (from shell integration)-/// 2. It calls `_wt_exec --internal switch ...`+/// 2. It calls `wt_exec --internal switch ...`/// 3. The wrapper parses NUL-delimited output and handles directives/// 4. Users see only the final human-friendly output///diff --git a/tests/snapshots/integration__integration_tests__init__init_bash.snap b/tests/snapshots/integration__integration_tests__init__init_bash.snapindex e3353e395..899db461f 100644--- a/tests/snapshots/integration__integration_tests__init__init_bash.snap+++ b/tests/snapshots/integration__integration_tests__init__init_bash.snap@@ -16,7 +16,7 @@ info:LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpGSj2lQ/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpuSx06y/test-config.toml---success: trueexit_code: 0@@ -32,7 +32,9 @@ if command -v wt >/dev/null 2>&1 || [[ -n "${WORKTRUNK_BIN:-}" ]]; then# Shared directive parser for POSIX shells (bash, zsh, oil).# Reads worktrunk's NUL-delimited output in real-time via a FIFO so progress# and hint messages stream immediately while keeping stderr attached to the TTY.-_wt_exec() {+# Note: Named without leading underscore to avoid being filtered by shell+# snapshot systems (e.g., Claude Code) that exclude private functions.+wt_exec() {local exec_cmd="" chunk="" exit_code=0 tmp_dir="" exit_file="" fifo_path="" runner_pid=""tmp_dir=$(mktemp -d "${TMPDIR:-/tmp}/wt.XXXXXX") || {@@ -119,7 +121,7 @@ _wt_exec() {fi# Always use --internal mode for directive support- _wt_exec --internal "${args[@]}"+ wt_exec --internal "${args[@]}"# Restore original commandlocal result=$?diff --git a/tests/snapshots/integration__integration_tests__init__init_fish.snap b/tests/snapshots/integration__integration_tests__init__init_fish.snapindex eca021b87..c5b56ffbb 100644--- a/tests/snapshots/integration__integration_tests__init__init_fish.snap+++ b/tests/snapshots/integration__integration_tests__init__init_fish.snap@@ -16,7 +16,7 @@ info:LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmprUHMIQ/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpfehyR7/test-config.toml---success: trueexit_code: 0@@ -41,14 +41,14 @@ if type -q wt; or set -q WORKTRUNK_BIN# would serialize the pipeline (RHS wouldn't run until LHS finishes).# By keeping the LHS as a plain external command, the RHS can consume# the stream concurrently, preserving temporal ordering.- function _wt_exec+ function wt_execset -l exec_cmd ""# Debug mode: set WORKTRUNK_DEBUG=1 to see what's happeningset -l debug_mode 0if set -q WORKTRUNK_DEBUGset debug_mode 1- echo "[DEBUG] Starting _wt_exec with args: $argv" >&2+ echo "[DEBUG] Starting wt_exec with args: $argv" >&2end# CRITICAL: Do NOT add "2>&1" here!@@ -141,7 +141,7 @@ if type -q wt; or set -q WORKTRUNK_BINend# Always use --internal mode for directive support- _wt_exec --internal $args+ wt_exec --internal $args# Restore original commandset -l result $statusdiff --git a/tests/snapshots/integration__integration_tests__init__init_zsh.snap b/tests/snapshots/integration__integration_tests__init__init_zsh.snapindex f2e1e04ec..34e91f798 100644--- a/tests/snapshots/integration__integration_tests__init__init_zsh.snap+++ b/tests/snapshots/integration__integration_tests__init__init_zsh.snap@@ -16,7 +16,7 @@ info:LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpdnJurE/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpUvdB1W/test-config.toml---success: trueexit_code: 0@@ -32,7 +32,9 @@ if command -v wt >/dev/null 2>&1 || [[ -n "${WORKTRUNK_BIN:-}" ]]; then# Shared directive parser for POSIX shells (bash, zsh, oil).# Reads worktrunk's NUL-delimited output in real-time via a FIFO so progress# and hint messages stream immediately while keeping stderr attached to the TTY.-_wt_exec() {+# Note: Named without leading underscore to avoid being filtered by shell+# snapshot systems (e.g., Claude Code) that exclude private functions.+wt_exec() {local exec_cmd="" chunk="" exit_code=0 tmp_dir="" exit_file="" fifo_path="" runner_pid=""tmp_dir=$(mktemp -d "${TMPDIR:-/tmp}/wt.XXXXXX") || {@@ -119,7 +121,7 @@ _wt_exec() {fi# Always use --internal mode for directive support- _wt_exec --internal "${args[@]}"+ wt_exec --internal "${args[@]}"# Restore original commandlocal result=$?