feat: background watcher notifies CC session when loop completes
This commit is contained in:
@@ -128,7 +128,15 @@ LOOP_CMD=".loop/loop.sh"
|
|||||||
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 agent-loop 2>/dev/null; tmux new-session -d -s agent-loop -c <project_root> "$LOOP_CMD"
|
||||||
```
|
```
|
||||||
|
|
||||||
7. Tell the user:
|
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"
|
||||||
|
```
|
||||||
|
|
||||||
|
This runs silently. When the tmux session exits, Claude Code gets notified automatically.
|
||||||
|
|
||||||
|
8. Tell the user:
|
||||||
|
|
||||||
> **Loop launched.** Watch it live:
|
> **Loop launched.** Watch it live:
|
||||||
> ```
|
> ```
|
||||||
@@ -139,36 +147,39 @@ tmux kill-session -t agent-loop 2>/dev/null; tmux new-session -d -s agent-loop -
|
|||||||
> - **Detach** (return to Claude Code): `Ctrl+B` then `D`
|
> - **Detach** (return to Claude Code): `Ctrl+B` then `D`
|
||||||
> - **Stop the loop**: `Ctrl+C`
|
> - **Stop the loop**: `Ctrl+C`
|
||||||
> - Ask me "status" anytime and I'll check progress.
|
> - Ask me "status" anytime and I'll check progress.
|
||||||
|
>
|
||||||
|
> I'll notify you when the loop finishes.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Monitoring
|
## When Background Watcher Completes
|
||||||
|
|
||||||
If the user asks about progress (e.g., "status", "how's it going", "check progress"):
|
When you receive the background task notification (the watcher prints "LOOP_COMPLETE"), the loop has finished. Automatically:
|
||||||
|
|
||||||
1. Read `.loop/prd.json` — count passed/failed/blocked stories
|
1. Read `.loop/prd.json` — count passed/failed/blocked stories
|
||||||
2. Read `.loop/progress.md` — show the latest session log entries
|
2. Read `.loop/progress.md` — show the latest session log entries
|
||||||
3. Capture recent tmux output:
|
3. Check `git log --oneline` for commits made during the run
|
||||||
|
4. Present a summary:
|
||||||
|
|
||||||
```bash
|
> **Loop Complete**
|
||||||
tmux capture-pane -t agent-loop -p | tail -30
|
|
||||||
```
|
|
||||||
|
|
||||||
4. Report:
|
|
||||||
|
|
||||||
> **Loop Status**
|
|
||||||
> - Stories: {passed}/{total} complete, {blocked} blocked
|
> - Stories: {passed}/{total} complete, {blocked} blocked
|
||||||
> - Current: {last story from progress.md}
|
> - Iterations: {from progress.md}
|
||||||
> - tmux session: {running/stopped}
|
> - Commits: {list from git log}
|
||||||
|
>
|
||||||
|
> {If any stories blocked: "Some stories need human review. Run /agent-loop:triage for details."}
|
||||||
|
> {If all passed: "All stories complete. Review the code and test it."}
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## When Loop Completes
|
## Monitoring (if user asks mid-run)
|
||||||
|
|
||||||
The tmux session exits when `loop.sh` finishes. If the user asks for a summary:
|
If the user asks about progress (e.g., "status", "how's it going"):
|
||||||
|
|
||||||
1. Read `.loop/prd.json` for final story statuses
|
1. Read `.loop/prd.json` — count passed/failed/blocked
|
||||||
2. Read `.loop/progress.md` for the full session log
|
2. Capture recent tmux output:
|
||||||
3. Check git log for commits made during the run
|
|
||||||
|
|
||||||
Report the final status and suggest `/agent-loop:triage` if any stories are blocked.
|
```bash
|
||||||
|
tmux capture-pane -t agent-loop -p | tail -20
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Report current status.
|
||||||
|
|||||||
Reference in New Issue
Block a user