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:
@@ -20,11 +20,22 @@ You will receive:
|
||||
- `PR_NUMBER`: The PR number to fix
|
||||
- `REPO_PATH`: Absolute path to the main repository
|
||||
- `REPO_NAME`: Name of the repository (for worktree naming)
|
||||
- `WORKTREE_PATH`: (Optional) Absolute path to pre-created worktree. If provided, agent works directly in this directory. If not provided, agent creates its own worktree as a sibling directory.
|
||||
|
||||
## Process
|
||||
|
||||
### 1. Get PR Details
|
||||
### 1. Get PR Details and Setup Worktree
|
||||
|
||||
If `WORKTREE_PATH` was provided:
|
||||
```bash
|
||||
# Use the pre-created worktree
|
||||
cd <WORKTREE_PATH>
|
||||
|
||||
# Get PR info and review comments
|
||||
tea pulls <PR_NUMBER> --comments
|
||||
```
|
||||
|
||||
If `WORKTREE_PATH` was NOT provided (backward compatibility):
|
||||
```bash
|
||||
cd <REPO_PATH>
|
||||
git fetch origin
|
||||
@@ -34,15 +45,7 @@ tea pulls <PR_NUMBER>
|
||||
|
||||
# Get review comments
|
||||
tea pulls <PR_NUMBER> --comments
|
||||
```
|
||||
|
||||
Extract:
|
||||
- The PR branch name (e.g., `issue-42-add-feature`)
|
||||
- All review comments and requested changes
|
||||
|
||||
### 2. Setup Worktree
|
||||
|
||||
```bash
|
||||
# Create worktree from the PR branch
|
||||
git worktree add ../<REPO_NAME>-pr-<PR_NUMBER> origin/<branch-name>
|
||||
|
||||
@@ -53,6 +56,10 @@ cd ../<REPO_NAME>-pr-<PR_NUMBER>
|
||||
git checkout <branch-name>
|
||||
```
|
||||
|
||||
Extract:
|
||||
- The PR branch name (e.g., `issue-42-add-feature`)
|
||||
- All review comments and requested changes
|
||||
|
||||
### 3. Analyze Review Feedback
|
||||
|
||||
Read all review comments and identify:
|
||||
@@ -105,8 +112,15 @@ Based on review feedback:
|
||||
|
||||
### 7. Cleanup Worktree
|
||||
|
||||
Always clean up, even if earlier steps failed:
|
||||
If `WORKTREE_PATH` was provided:
|
||||
```bash
|
||||
# Orchestrator will handle cleanup - no action needed
|
||||
# Just ensure git is clean
|
||||
cd <WORKTREE_PATH>
|
||||
git status
|
||||
```
|
||||
|
||||
If `WORKTREE_PATH` was NOT provided (backward compatibility):
|
||||
```bash
|
||||
cd <REPO_PATH>
|
||||
git worktree remove ../<REPO_NAME>-pr-<PR_NUMBER> --force
|
||||
|
||||
Reference in New Issue
Block a user