fix: use cross-platform wrapper for wt CLI in Claude Code integration#1754
fix: use cross-platform wrapper for wt CLI in Claude Code integration#1754lucaspimentel wants to merge 13 commits intomax-sixty:mainfrom
wt CLI in Claude Code integration#1754Conversation
On Windows the binary is git-wt.exe, not wt. Add a wt.sh wrapper
script that detects the platform and calls the correct binary, then
update hooks.json to use it via ${CLAUDE_PLUGIN_ROOT}.
🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
wt CLI in plugin hookswt CLI in Claude Code integration
|
thanks! can we have it fall back to (unless there's some non-convoluted way to detect that |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9be3764104
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
A few options for detecting Windows Terminal's
case "$(uname -o 2>/dev/null)" in
Msys|Cygwin)
if command -v git-wt.exe >/dev/null 2>&1; then
WT=git-wt.exe
else
WT=wt
fi
;;
*) WT=wt ;;
esac
case "$(uname -o 2>/dev/null)" in
Msys|Cygwin)
if command -v git-wt.exe >/dev/null 2>&1; then
WT=git-wt.exe
elif command -v wt >/dev/null 2>&1 && ! command -v wt 2>/dev/null | grep -qi WindowsApps; then
WT=wt
else
echo "worktrunk not found — install with: cargo install worktrunk --features git-wt" >&2
exit 1
fi
;;
*) WT=wt ;;
esacOption 2 seems like the right balance — simple, handles the "deactivated @lucaspimentel what do you think — want to go with option 2 (fallback) or 3 (with WindowsApps detection)? |
|
@worktrunk-bot can we combine both checks? "if (is windows) AND ( |
On Windows, try git-wt.exe first and fall back to wt if it doesn't exist. This handles users who have deactivated the wt alias. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Done — pushed a commit that does exactly that: on Windows, tries |
🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
Check that `wt` doesn't resolve to the WindowsApps directory before using it as a fallback, since that path is the Windows Terminal alias. 🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
worktrunk-bot
left a comment
There was a problem hiding this comment.
The WindowsApps detection on line 11 works, but the ${WT:=wt} default on line 16 undoes it: when git-wt.exe is absent and wt is Windows Terminal, neither branch sets WT, so the default still invokes Windows Terminal — the exact bug this PR fixes.
Co-authored-by: worktrunk-bot <w@worktrunk.dev>
worktrunk-bot
left a comment
There was a problem hiding this comment.
The Windows Terminal detection logic looks good now. One bug: the final invocation line is duplicated, so every hook command will execute twice.
🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
|
@lucaspimentel would you mind running this for a day or so to confirm it behaves well? It's difficult to test this stuff... |
|
@max-sixty definitely. I opened the PR too quickly (edit: the fix wasn't as simple as I originally thought) 😅 I'll convert it to a draft while I keep testing. |
Remove OS-specific branching — git-wt.exe check is harmless on non-Windows. Add missing PATH validation and distinct error for Windows Terminal alias vs not-found cases. 🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
|
thank you v much @lucaspimentel ! |
🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
The UserPromptSubmit hook runs on every prompt, including outside git repos. Guard against missing git and non-repo directories to prevent "fatal: not a git repository" stderr noise in Claude Code. 🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
| if ! command -v git >/dev/null 2>&1 || ! git rev-parse --git-dir >/dev/null 2>&1; then | ||
| exit 0 | ||
| fi |
There was a problem hiding this comment.
fwiw if wt can handle it, then I think it's better that we put the logic in the binary than a bash file...
When set, use WORKTRUNK_BIN exclusively to find the worktrunk binary instead of searching PATH. Fail with a clear error if not found. 🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
Summary
Currently, Worktrunk's Claude Code hook keeps opening Windows Terminal windows because it calls
wt, which is an alias~/AppData/Local/Microsoft/WindowsApps/wt.exeby default.Windows users have three workarounds:
git-wt.exewt.exeand disable the Windows Terminal alias to avoid conflictswt.exeand re-order the paths inPATHso Worktrunk is found firstChanges
wt.shwrapper script that tries to find the correct Worktrunk binary.hooks.jsonto usewt.sh.Manual tests
Windows
git-wt.exe, Windows Terminal alias enabledgit-wt.exe, Windows Terminal alias disabledwt.exe, Windows Terminal alias enabledwt.exe, Windows Terminal alias disabledWSL (Windows Subsystem for Linux)
In WSL, users can install the Linux version of Worktree as
wt, butwtcan still map to Windows Terminal if Worktree is not installed.wtin WSL, Windows Terminal alias enabledwtin WSL, Windows Terminal alias disabled