@jalco/pi-herdr-worktree
v0.1.1
Published
Pi extension: git worktrees via Herdr's native worktree API, with project-level post-create/pre-remove hooks.
Maintainers
Readme
pi-herdr-worktree
Pi extension: Git worktrees via Herdr's native herdr worktree API, with optional project-level post-create/pre-remove hooks and file linking.
Unlike generic worktree extensions, this one does not reimplement git worktree logic. Herdr already manages worktree-backed panes/workspaces natively (herdr worktree list/create/open/remove); this extension just wraps that as pi tools and layers project hooks on top.
Install
pi install npm:@jalco/pi-herdr-worktreeRequires Herdr worktree support (check with herdr worktree --help) and pi running inside a Herdr pane.
Tools
| Tool | Wraps |
|---|---|
| herdr_worktree_list | herdr worktree list |
| herdr_worktree_create | herdr worktree create, then runs postCreate hooks and linkPaths symlinks |
| herdr_worktree_open | herdr worktree open |
| herdr_worktree_remove | herdr worktree remove, resolving path to a workspace ID via list if workspace isn't given; runs preRemove hooks first |
Also registers /worktree, which lists worktrees for the current repo.
Project hooks
Create .pi/worktree.json in your repo root:
{
"postCreate": ["npm install", "npx prisma db push"],
"preRemove": ["dropdb --if-exists myapp_$(basename $PWD) 2>/dev/null || true"],
"linkPaths": [".env.local"]
}postCreateruns (viash -c, cwd = new worktree) after Herdr creates the worktree.preRemoveruns (cwd = worktree path) before Herdr removes it. Failures do not block removal.linkPathsare relative paths symlinked from the source checkout into the new worktree beforepostCreateruns — useful for.env.localand similar files that shouldn't live in version control but are needed per-worktree.
Why not Herdr's CLI directly?
You still can (herdr worktree create --json). This extension exists so the model can call worktree operations as tools during a session, and so project-level hooks (dependency install, DB provisioning, env-file linking) run automatically without you scripting them by hand each time.
License
MIT
