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

@@ -57,9 +57,17 @@ PROJECT_ROOT="$(pwd)"
LOOP_DIR="$PROJECT_ROOT/.loop"
if [ -d "$LOOP_DIR" ] && [ -f "$LOOP_DIR/prd.json" ]; then
echo "[setup] .loop/ already exists with prd.json."
echo "[setup] To re-initialize, delete .loop/ first: rm -rf .loop"
exit 1
echo "[setup] .loop/ already exists with prd.json — archiving previous run..."
# Source state.sh (needed by archive.sh for story queries) and archive.sh
LOOP_DIR="$LOOP_DIR" source "$LOOP_DIR/lib/state.sh" 2>/dev/null || true
LOOP_DIR="$LOOP_DIR" source "$LOOP_DIR/lib/archive.sh" 2>/dev/null || true
if type archive_and_reset &>/dev/null; then
archive_and_reset "$LOOP_DIR"
else
# Fallback for old harness versions without archive_and_reset
echo "[setup] WARNING: Could not archive (old harness version). To re-initialize, delete .loop/ first: rm -rf .loop"
exit 1
fi
fi
mkdir -p "$LOOP_DIR"