Hey @webdevcody ,
Next on my list for worktrees is setup hooks, branch cleanup and a local merge. Before I build any of it, I think we should use worktrunk instead. It's a Rust worktree manager built for parallel agents, and it already has all of it.
My own pain, day to day: every new worktree means copying .env over by hand before the agent can run anything, and after deleting worktrees I end up cleaning out the branches they left behind myself. worktrunk handles both: wt step copy-ignored in a post-start hook copies .env (and other gitignored files) in, and removal takes the branch with it.
What we're missing today
- hooks live in git config, cover only create/delete, and time out after 30s
- new worktrees start cold: nothing copies
.env, target/ or node_modules
- deleting a worktree always leaves the branch behind
- the path is fixed to
<repo>-worktrees/<branch>
- no local merge
What worktrunk gives us
- hooks in the repo's
.config/wt.toml for create, switch, commit, merge and remove, with approval for project hooks
wt step copy-ignored copies build caches copy-on-write (their repo: 68s down to 3s for a new worktree)
- remove deletes the branch, but refuses unmerged work
wt merge: squash, rebase, fast-forward, pre-merge gate
- a configurable worktree path
It isn't nebula-specific, so repos already set up for worktrunk work in nebula as is, and wt and nebula see the same worktrees. It's actively maintained (~8.8k stars, 18 releases since July), so we don't have to maintain a hook format, runner and merge flow ourselves.
Importing it
I checked it with a scratch crate: worktrunk = { version = "0.80", default-features = false } builds on our edition and toolchain, and adds 75 crates we don't have. The repo model, config, removal with branch cleanup and the copy-on-write code are public. The hook runner and merge are private to the wt binary. Max made the removal API public on request before (#2227), so I'd ask him to do the same for hooks. Until then we can call wt when it's installed.
Plan, in small PRs
- Use worktrunk's removal so branches get cleaned up.
- Read
worktree-path from worktrunk's config, with our current layout as the default.
- Run worktrunk hooks on create.
- Maybe a merge key that runs
wt merge in a pane.
Sync, adoption, relocation and PR status stay as they are.
Questions
- OK with the dependency, or should we only shell out to
wt?
- Should project hooks show worktrunk's approval prompt, or should nebula pass
--yes?
- Do you want local merge in nebula, or PR-only?
Hey @webdevcody ,
Next on my list for worktrees is setup hooks, branch cleanup and a local merge. Before I build any of it, I think we should use worktrunk instead. It's a Rust worktree manager built for parallel agents, and it already has all of it.
My own pain, day to day: every new worktree means copying
.envover by hand before the agent can run anything, and after deleting worktrees I end up cleaning out the branches they left behind myself. worktrunk handles both:wt step copy-ignoredin apost-starthook copies.env(and other gitignored files) in, and removal takes the branch with it.What we're missing today
.env,target/ornode_modules<repo>-worktrees/<branch>What worktrunk gives us
.config/wt.tomlfor create, switch, commit, merge and remove, with approval for project hookswt step copy-ignoredcopies build caches copy-on-write (their repo: 68s down to 3s for a new worktree)wt merge: squash, rebase, fast-forward, pre-merge gateIt isn't nebula-specific, so repos already set up for worktrunk work in nebula as is, and
wtand nebula see the same worktrees. It's actively maintained (~8.8k stars, 18 releases since July), so we don't have to maintain a hook format, runner and merge flow ourselves.Importing it
I checked it with a scratch crate:
worktrunk = { version = "0.80", default-features = false }builds on our edition and toolchain, and adds 75 crates we don't have. The repo model, config, removal with branch cleanup and the copy-on-write code are public. The hook runner and merge are private to thewtbinary. Max made the removal API public on request before (#2227), so I'd ask him to do the same for hooks. Until then we can callwtwhen it's installed.Plan, in small PRs
worktree-pathfrom worktrunk's config, with our current layout as the default.wt mergein a pane.Sync, adoption, relocation and PR status stay as they are.
Questions
wt?--yes?