Add herdr plugin integration and WT_* hook environment - #53
Open
bkildow wants to merge 1 commit into
Open
Conversation
wt herdr init installs a global herdr plugin whose worktree.created and worktree.removed event hooks call back into wt, so worktrees created from herdr's sidebar get shared files applied and setup hooks run, and removals get cleaned up. Because herdr emits worktree.removed after the checkout is deleted, ordinary teardown hooks are skipped there (they would run against the wrong directory) and a new post_remove hook list runs from the project root instead. The created hook records its PID in herdr's plugin state dir so the removed hook can stop a setup that is still running. All hooks (setup, parallel_setup, teardown, parallel_teardown, post_remove) now receive WT_PROJECT_ROOT, WT_WORKTREE_ID, WT_WORKTREE_PATH and WT_BRANCH_NAME, mirroring the template variables, across wt add, wt setup, wt remove, wt prune, and the Claude Code and herdr hooks. Verified end to end against herdr 0.9.0, including removal while setup is still running. Claude-Session: https://claude.ai/code/session_01DYtq4h1YVJrotQVtc4bpDR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
wt herdr initinstalls a global herdr plugin. Itsworktree.createdhook applies shared files and runs setup hooks in herdr-created worktrees; itsworktree.removedhook handles cleanup. Project root is resolved from the event'srepo_key, so it works for both.bareand.gitlayouts and for checkouts outside the project tree.post_removehooks (new.worktree.ymlkey). herdr deletes the checkout before emittingworktree.removed, so ordinaryteardownhooks are skipped there with a warning rather than run against the wrong directory.post_removeruns from the project root withWT_*exported, e.g.ddev delete -Oy "$(basename "$WT_WORKTREE_PATH")".WT_*environment for all hooks:WT_PROJECT_ROOT,WT_WORKTREE_ID,WT_WORKTREE_PATH,WT_BRANCH_NAMEare now exported to every hook acrosswt add,wt setup,wt remove,wt prune, the Claude Code hooks, and the herdr hooks. Hook runners takeTemplateVarsinstead of a bare path.wt herdr init, hook environment variables, and post-remove hooks;integrations/herdr/README.mdrecords what herdr 0.9.0 actually does, with captured payloads.Test plan
make dev(fmt, lint, tests, build) cleanWT_*env visible to setup/teardown/post_removewt add(foreground and background) andwt removeshow correct per-worktreeWT_*valuesddev delete <name>confirmed to work after the project directory is deleted (basis for the post_remove example)https://claude.ai/code/session_01DYtq4h1YVJrotQVtc4bpDR