feat: auto-archive completed runs before starting new features

When /agent-loop:run detects a previous run with all stories passed (or the
feature branch deleted after merge), it archives the old artifacts and resets
.loop/ automatically — no more manual rm -rf .loop.

- Add archive_and_reset() for on-demand archiving from skills
- Add runs.log index tracking all archived runs
- Update /run and /stories skills to detect completed runs
- setup.sh archives instead of hard-failing when prd.json exists
- Bump version to 0.9.0
This commit is contained in:
2026-04-02 07:40:07 -04:00
parent ce111b4cbe
commit ad58a49182
6 changed files with 157 additions and 12 deletions

View File

@@ -44,7 +44,38 @@ Show the output. If setup fails, stop.
Check if `.loop/prd.json` exists.
**If it does NOT exist**, generate it:
**If it exists**, check whether the previous run is complete. Run:
```bash
source .loop/lib/state.sh 2>/dev/null; LOOP_DIR=.loop all_stories_pass 2>/dev/null && echo "ALL_PASSED" || echo "IN_PROGRESS"
```
Also check if the feature branch from prd.json still exists:
```bash
jq -r '.branchName // empty' .loop/prd.json
```
If the result is `ALL_PASSED` **or** the branch no longer exists (deleted after merge), the previous run is done. Archive it and reset:
```bash
LOOP_DIR=.loop source .loop/lib/state.sh && source .loop/lib/archive.sh && archive_and_reset .loop
```
Tell the user: *"Archived previous run ({branch}). Starting fresh."*
Then proceed to generate new stories below.
If the result is `IN_PROGRESS` and the branch still exists, the previous run is still active. Tell the user:
> **Existing run found** — {passed}/{total} stories complete on `{branch}`.
>
> - Say **go** to resume the existing run
> - Say **archive** to archive this run and start fresh
Wait for the user to decide before proceeding.
**If `prd.json` does NOT exist**, generate it:
1. Search for existing specs or plans:
- `docs/superpowers/specs/*.md`