feat: support parallel loops with per-project tmux session names
The tmux session name is now derived from the project directory name (e.g., agent-loop-server, agent-loop-webapp). This allows running multiple loops in parallel on different projects without collisions. Previously hardcoded to "agent-loop", which meant launching a second loop would kill the first project's tmux session.
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
"name": "agent-loop",
|
||||
"source": "./",
|
||||
"description": "Autonomous generator-evaluator agent loop for long-running coding tasks. Plan interactively, then execute with full visibility.",
|
||||
"version": "0.10.2",
|
||||
"version": "0.11.0",
|
||||
"author": {
|
||||
"name": "Sheldon"
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "agent-loop",
|
||||
"version": "0.10.2",
|
||||
"version": "0.11.0",
|
||||
"description": "Autonomous generator-evaluator agent loop for long-running coding tasks. Run /agent-loop:run to start.",
|
||||
"author": {
|
||||
"name": "Sheldon"
|
||||
|
||||
@@ -161,33 +161,37 @@ Agent(
|
||||
|
||||
4. Parse arguments for any flags to pass through (e.g., `--skip-eval`).
|
||||
|
||||
5. Build the loop.sh command with any flags:
|
||||
5. Build the loop.sh command and derive a unique tmux session name:
|
||||
|
||||
```bash
|
||||
LOOP_CMD=".loop/loop.sh"
|
||||
# Add --skip-eval if requested
|
||||
# Add --max N if specified
|
||||
|
||||
# Derive tmux session name from project directory name.
|
||||
# This allows multiple loops to run in parallel on different projects.
|
||||
SESSION_NAME="agent-loop-$(basename "$(pwd)")"
|
||||
```
|
||||
|
||||
6. Kill any existing agent-loop tmux session, then launch detached:
|
||||
6. Kill any existing tmux session for THIS project, then launch detached:
|
||||
|
||||
```bash
|
||||
tmux kill-session -t agent-loop 2>/dev/null; tmux new-session -d -s agent-loop -c <project_root> "$LOOP_CMD"
|
||||
tmux kill-session -t "$SESSION_NAME" 2>/dev/null; tmux new-session -d -s "$SESSION_NAME" -c <project_root> "$LOOP_CMD"
|
||||
```
|
||||
|
||||
7. Start a **background watcher** that waits for the loop to finish. Use the Bash tool with `run_in_background: true`:
|
||||
|
||||
```bash
|
||||
while tmux has-session -t agent-loop 2>/dev/null; do sleep 10; done; echo "LOOP_COMPLETE"
|
||||
while tmux has-session -t "$SESSION_NAME" 2>/dev/null; do sleep 10; done; echo "LOOP_COMPLETE"
|
||||
```
|
||||
|
||||
This runs silently. When the tmux session exits, Claude Code gets notified automatically.
|
||||
|
||||
8. Tell the user:
|
||||
|
||||
> **Loop launched.** Watch it live:
|
||||
> **Loop launched** as tmux session `{SESSION_NAME}`. Watch it live:
|
||||
> ```
|
||||
> ! tmux attach -t agent-loop
|
||||
> ! tmux attach -t {SESSION_NAME}
|
||||
> ```
|
||||
> (Type the above — it opens the session right here in your terminal.)
|
||||
>
|
||||
@@ -223,10 +227,11 @@ When you receive the background task notification (the watcher prints "LOOP_COMP
|
||||
If the user asks about progress (e.g., "status", "how's it going"):
|
||||
|
||||
1. Read `.loop/prd.json` — count passed/failed/blocked
|
||||
2. Capture recent tmux output:
|
||||
2. Derive the session name and capture recent tmux output:
|
||||
|
||||
```bash
|
||||
tmux capture-pane -t agent-loop -p | tail -20
|
||||
SESSION_NAME="agent-loop-$(basename "$(pwd)")"
|
||||
tmux capture-pane -t "$SESSION_NAME" -p | tail -20
|
||||
```
|
||||
|
||||
3. Report current status.
|
||||
|
||||
Reference in New Issue
Block a user