-
Notifications
You must be signed in to change notification settings - Fork 0
Make worktree isolation opt-in — default to simple branch strategy #173
Copy link
Copy link
Closed
Description
Problem
Worktree isolation adds 289 lines of complexity (worktree.ts) and causes real problems:
- Agent gets confused about which directory it's in (worktree vs main workspace)
- lota-1 Task Phase 1: Vue 3 + Vite project scaffold with Tailwind CSS 4, Pinia, Vue Router #148 spent ~30 bash commands navigating between
~/kid-club-vueand~/kid-club-vue/.worktrees/lota-1 - Merge conflicts leave conflict markers in files (Task Phase 5: Period detail view with KPI cards, monthly tabs, and transitions #152:
TS1185: Merge conflict marker encountered) - When agent times out, all worktree work is lost (cleanup deletes everything)
- For single-agent-per-repo (the common case), worktrees are pure overhead
Worktrees only help when multiple agents work on the same repo simultaneously. But logs show agents typically work on different repos (lota-1 on kid-club-vue, lota-3 on bosphorusIre).
What to do
In src/daemon.ts, runClaude() function:
- Make worktree creation conditional — only use worktrees when
--worktreeflag is passed - Default behavior (no flag): agent works directly in the workspace on a branch
task-{id}-{agent} - The agent creates the branch, does work, commits, pushes the branch
- Daemon merges the branch to main after completion (simple
git merge+git push) - No worktree creation, no worktree cleanup, no path confusion
New default flow (no worktree):
1. cd <workspace>
2. git checkout -b task-{id}-{agent}
3. [agent does work]
4. git commit + git push origin task-{id}-{agent}
5. [daemon merges branch to main]
Opt-in worktree flow (with --worktree flag):
1. createWorktree() in <workspace>/.worktrees/<agent>
2. [agent works in worktree]
3. [daemon merges + cleans up worktree]
Files
src/daemon.ts— make worktree conditional inrunClaude()src/worktree.ts— keep the code but only call it when opt-in- Add
--worktreeflag toparseArgs()
Acceptance
- Default: no worktrees, agent works on branch in workspace directly
--worktreeflag enables worktree isolation- Agent no longer confused about directory paths
- Timeout doesn't lose work (branch still exists on remote)
- Build passes:
npm run build
Reactions are currently unavailable