-
Notifications
You must be signed in to change notification settings - Fork 71
Description
Summary
After creating a worktree with gtr new we get output like this:
[OK] Worktree created: /Users/ed/dev/core-worktrees/<branch>
Next steps:
git gtr editor <branch> # Open in editor
git gtr ai <branch> # Start AI tool
cd "$(git gtr go <branch>)" # Navigate to worktreeBut when using the suggested command gtr ai <branch> to launch an AI coding agent in a worktree, the postCd hook defined in .gtrconfig is not executed. This means environment variables set by the hook are not available to the AI process.
Context
Our monorepo uses a postCd hook to source environment setup when navigating to a worktree:
[hooks]
postCd = source ./vars.shThis sets environment variables that tools and test frameworks depend on to locate resources relative to the worktree.
When using gtr cd <branch>, the hook runs and everything works. But gtr ai <branch> launches the AI process directly without running the hook, so it inherits the parent shell's environment which still points at the main checkout.
Suggestion
Have gtr ai execute the postCd hook before spawning the AI process, similar to how gtr cd does for interactive shells. This would ensure the AI agent has the same environment as a developer who gtr cd-ed into the worktree.