#!/bin/bash set -euo pipefail # Check if all phases in task_plan.md are complete. # Always exits 0 — uses stdout for status reporting. # Used by Stop hook to report task completion status. PLAN_FILE="${1:-task_plan.md}" if [ ! -f "$PLAN_FILE" ]; then echo "[planning-with-files] No task_plan.md found — no active planning session." exit 0 fi # Count total phases TOTAL=$(grep -c "### Phase" "$PLAN_FILE" || true) TOTAL="${TOTAL:-0}" # Check for **Status:** format first COMPLETE=$(grep -cF "**Status:** complete" "$PLAN_FILE" || true) IN_PROGRESS=$(grep -cF "**Status:** in_progress" "$PLAN_FILE" || true) PENDING=$(grep -cF "**Status:** pending" "$PLAN_FILE" || true) # Fallback: check for [complete] inline format if [ "${COMPLETE:-0}" -eq 0 ] && [ "${IN_PROGRESS:-0}" -eq 0 ] && [ "${PENDING:-0}" -eq 0 ]; then COMPLETE=$(grep -c "\[complete\]" "$PLAN_FILE" || true) IN_PROGRESS=$(grep -c "\[in_progress\]" "$PLAN_FILE" || true) PENDING=$(grep -c "\[pending\]" "$PLAN_FILE" || true) fi COMPLETE="${COMPLETE:-0}" IN_PROGRESS="${IN_PROGRESS:-0}" PENDING="${PENDING:-0}" if [ "$COMPLETE" -eq "$TOTAL" ] && [ "$TOTAL" -gt 0 ]; then echo "[planning-with-files] ALL PHASES COMPLETE ($COMPLETE/$TOTAL)" else echo "[planning-with-files] Task in progress ($COMPLETE/$TOTAL phases complete)" if [ "$IN_PROGRESS" -gt 0 ]; then echo "[planning-with-files] $IN_PROGRESS phase(s) still in progress." fi if [ "$PENDING" -gt 0 ]; then echo "[planning-with-files] $PENDING phase(s) pending." fi fi exit 0