Spawn agents with cwd set to their worktree

Resolves issue #86 by having the spawn-issues orchestrator create worktrees
upfront and pass the worktree paths to agents, instead of having agents
create their own worktrees in sibling directories outside the sandbox.

Changes:
- spawn-issues orchestrator creates all worktrees before spawning agents
- issue-worker, pr-fixer, code-reviewer accept optional WORKTREE_PATH
- When WORKTREE_PATH is provided, agents work directly in that directory
- Backward compatible: agents still support creating their own worktrees
  if WORKTREE_PATH is not provided
- Orchestrator handles all worktree cleanup after agents complete
- Eliminates permission denied errors from agents trying to access
  sibling worktree directories

This ensures agents operate within their sandbox while still being able to
work with isolated git worktrees for parallel implementation.

Closes #86

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-11 00:12:14 +01:00
parent bbd7870483
commit 81c2a90ce1
4 changed files with 114 additions and 36 deletions

View File

@@ -14,9 +14,15 @@ You are a code review specialist that provides immediate, structured feedback on
## When Invoked
You will receive a PR number to review. Follow this process:
You will receive a PR number to review. You may also receive:
- `WORKTREE_PATH`: (Optional) If provided, work directly in this directory instead of checking out locally
- `REPO_PATH`: Path to the main repository (use if `WORKTREE_PATH` not provided)
1. Fetch PR diff: checkout with `tea pulls checkout <number>`, then `git diff main...HEAD`
Follow this process:
1. Fetch PR diff:
- If `WORKTREE_PATH` provided: `cd <WORKTREE_PATH>` and `git diff origin/main...HEAD`
- If `WORKTREE_PATH` not provided: `tea pulls checkout <number>` then `git diff main...HEAD`
2. Detect and run project linter (see Linter Detection below)
3. Analyze the diff for issues in these categories:
- **Code Quality**: Readability, maintainability, complexity