ralph-workplan/plugin/scripts/check-done.sh
tegwick d379ff9dbc
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 2s
Complete RALPH-WP-0002 plugin hardening and adoption docs
2026-07-08 15:21:13 +02:00

26 lines
No EOL
935 B
Bash
Executable file

#!/bin/bash
# check-done.sh — exit 0 when workplan is complete, 1 when work remains, 2 if missing.
set -euo pipefail
WORKPLAN_FILE="${1:?workplan_file required}"
[[ -f "$WORKPLAN_FILE" ]] || { echo "❌ Workplan file not found: $WORKPLAN_FILE" >&2; exit 2; }
python3 - "$WORKPLAN_FILE" <<'PY'
import re, sys
from pathlib import Path
path = Path(sys.argv[1])
text = path.read_text(encoding="utf-8")
fm = re.search(r"^---\n(.*?)\n---", text, re.S)
if not fm:
print(f"⚠️ No frontmatter in {path}", file=sys.stderr)
raise SystemExit(1)
status_match = re.search(r"^status:\s*(\S+)", fm.group(1), re.M)
status = (status_match.group(1) if status_match else "").strip('"')
tasks = re.findall(r"```task\n(.*?)```", text, re.S)
open_tasks = [
t for t in tasks
if not re.search(r"^status:\s*(done|cancel)\s*$", t, re.M)
]
if status in {"done", "finished"} and not open_tasks:
raise SystemExit(0)
raise SystemExit(1)
PY