The harness now pushes the phase commit right after committing it (PHASE_PUSH=1 default, new push_phase in lib.sh): upstream when set, else 'git push -u <first remote> <branch>'; no remote = skip with a notice. A push failure keeps the commit local, prints the same loud ERROR contract as a commit failure, and stops the run — the next phase's push sweeps the unpushed commit in. PHASE_PUSH=0 opts out with a loud notice. SKILL.md (Commits + config table + exit codes) and the executor prompts document the new behavior.
47 lines
1.9 KiB
Bash
47 lines
1.9 KiB
Bash
#!/usr/bin/env bash
|
|
# run-task.sh — execute exactly one task in a fresh pi context.
|
|
#
|
|
# A task is the smallest execution unit: a task file inside a phase
|
|
# directory (03_api/02_routes.md), a phase's 00_phase.md final pass, or a
|
|
# legacy single-file phase.
|
|
#
|
|
# Usage:
|
|
# run-task.sh # next pending task (pipeline order)
|
|
# run-task.sh 03_api/02_routes.md # a specific task (warns if out of order)
|
|
# run-task.sh 03_api/02_routes # ".md" is added when missing
|
|
#
|
|
# Env: see SKILL.md (MAX_FIX_ATTEMPTS, PHASE_MODEL, PHASE_THINKING,
|
|
# PHASE_COMMIT, PHASE_PUSH, PI_TRUST, FRESH_FIX).
|
|
set -uo pipefail
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
source "$SCRIPT_DIR/lib.sh"
|
|
|
|
# Make interruptions visible: state stays in .agents/phases/todo, and the
|
|
# failed executor's session is still resumable on the next run.
|
|
trap 'echo; echo "✗ ERROR: interrupted (SIGINT) — ${unit:-this task} is left in $PHASE_TODO/; re-run to continue" >&2; exit 130' INT
|
|
trap 'echo; echo "✗ ERROR: interrupted (SIGTERM) — ${unit:-this task} is left in $PHASE_TODO/; re-run to continue" >&2; exit 143' TERM
|
|
|
|
cd "$(find_root)" || die "no .agents/phases/todo found in this or parent directories (run /to-phase or /audit-create first)"
|
|
|
|
unit="${1:-}"
|
|
if [[ -n "$unit" ]]; then
|
|
[[ "$unit" == *.md ]] || unit="$unit.md"
|
|
[[ -f "$PHASE_TODO/$unit" ]] || die "$unit not found in $PHASE_TODO/"
|
|
first="$(next_unit)"
|
|
if [[ -n "$first" && "$first" != "$unit" ]]; then
|
|
warn "execution order: $first is pending before $unit — running out of order"
|
|
fi
|
|
else
|
|
unit="$(next_unit)"
|
|
[[ -n "$unit" ]] || { echo "✓ no pending tasks in $PHASE_TODO/ — project complete."; exit 0; }
|
|
fi
|
|
|
|
build_pi_args
|
|
if execute_unit "$unit"; then
|
|
exit 0
|
|
fi
|
|
# execute_unit printed the failure detail (task failure: errors, logs,
|
|
# resume command — or phase commit/push failure: the hand-fix command).
|
|
echo "✗ ERROR: $unit did not complete — see the error output above" >&2
|
|
exit 1
|