feat: phases + tasks — per-task execution with phase directories
- A phase is now a directory: 00_phase.md (overview + task index) plus small, quick NN_task.md task files; complete/ mirrors todo/ - Task is the unit of execution: run-task.sh (one unit), run-phase.sh (phase to completion incl. 00_phase.md final pass), auto-phase.sh (all units in order); validate.sh gate runs after every task - PHASE_COMMIT commits at phase boundaries (00_phase.md / legacy file moves) - Legacy flat todo/NN_name.md files still execute as a single unit; new migrate-phases-to-tasks.sh converts them to the directory layout - phase-status.sh reports per-task state and the next unit - New task-template.md; phase templates now carry a Tasks index
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
# run-phase.sh — execute exactly one phase in a fresh pi context.
|
||||
# run-phase.sh — run every remaining task of one phase to completion.
|
||||
#
|
||||
# Each task runs in its own pi process (fresh context) with the
|
||||
# .agent/validate.sh gate after every task; the phase ends with its
|
||||
# 00_phase.md final pass.
|
||||
#
|
||||
# Usage:
|
||||
# run-phase.sh # first pending phase (alphanumerical order)
|
||||
# run-phase.sh 03_api.md # a specific pending phase (warns if out of order)
|
||||
# run-phase.sh # next phase with pending work, to completion
|
||||
# run-phase.sh 03_api # a specific phase (warns if out of order)
|
||||
# run-phase.sh 03_api.md # a legacy single-file phase
|
||||
#
|
||||
# Env: see SKILL.md (MAX_FIX_ATTEMPTS, PHASE_MODEL, PHASE_THINKING,
|
||||
# PHASE_COMMIT, PI_TRUST, FRESH_FIX).
|
||||
@@ -20,22 +25,29 @@ cd "$(find_root)" || die "no .agent/phases/todo found in this or parent director
|
||||
|
||||
phase="${1:-}"
|
||||
if [[ -n "$phase" ]]; then
|
||||
[[ "$phase" == *.md ]] || phase="$phase.md"
|
||||
[[ -f "$PHASE_TODO/$phase" ]] || die "$phase not found in $PHASE_TODO/"
|
||||
first="$(next_phase)"
|
||||
if [[ -n "$first" && "$first" != "$phase" ]]; then
|
||||
phase="${phase%/}"; phase="${phase%.md}"; phase="${phase%%/*}"
|
||||
[[ -d "$PHASE_TODO/$phase" || -f "$PHASE_TODO/$phase.md" ]] || die "$phase not found in $PHASE_TODO/"
|
||||
first="$(next_unit)"
|
||||
if [[ -n "$first" && "${first%%/*}" != "$phase" ]]; then
|
||||
warn "dependency order: $first is pending before $phase — running out of order"
|
||||
fi
|
||||
else
|
||||
phase="$(next_phase)"
|
||||
[[ -n "$phase" ]] || { echo "✓ no pending phases in $PHASE_TODO/ — project complete."; exit 0; }
|
||||
unit="$(next_unit)"
|
||||
[[ -n "$unit" ]] || { echo "✓ no pending tasks in $PHASE_TODO/ — project complete."; exit 0; }
|
||||
phase="$(unit_phase "$unit")"
|
||||
fi
|
||||
|
||||
build_pi_args
|
||||
if execute_phase "$phase"; then
|
||||
exit 0
|
||||
failed=0
|
||||
while unit="$(phase_next_unit "$phase")"; do
|
||||
[[ -n "$unit" ]] || break
|
||||
execute_unit "$unit" || { failed=1; break; }
|
||||
done
|
||||
if (( failed )); then
|
||||
echo "✗ ERROR: phase $phase FAILED — see error above" >&2
|
||||
echo " reports: $(unit_report_dir "$unit")/$(unit_base "$unit").a*.{md,err,validate}" >&2
|
||||
echo " resume: re-run this script — the failed executor session is resumed automatically" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "✗ ERROR: phase $phase FAILED after $MAX_FIX_ATTEMPTS attempts" >&2
|
||||
echo " reports: $PHASE_REPORTS/${phase%.md}.a*.{md,err,validate}" >&2
|
||||
echo " resume: re-run this script — the failed executor session is resumed automatically" >&2
|
||||
exit 1
|
||||
echo "✓ phase $phase complete"
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user