Complete RALPH-WP-0002 plugin hardening and adoption docs
This commit is contained in:
parent
af3fba2d70
commit
d379ff9dbc
3 changed files with 61 additions and 31 deletions
|
|
@ -1,33 +1,26 @@
|
|||
#!/bin/bash
|
||||
# check-done.sh
|
||||
# Exit 0 if the workplan is done, 1 if not.
|
||||
# Used as the pre-start guard in the ralph-workplan skill.
|
||||
#
|
||||
# Usage: check-done.sh <workplan_file>
|
||||
|
||||
# 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
|
||||
|
||||
if [[ ! -f "$WORKPLAN_FILE" ]]; then
|
||||
echo "❌ Workplan file not found: $WORKPLAN_FILE" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Extract status from YAML frontmatter (first occurrence between --- markers)
|
||||
STATUS=$(sed -n '/^---$/,/^---$/{ /^---$/d; p; }' "$WORKPLAN_FILE" \
|
||||
| grep '^status:' \
|
||||
| head -1 \
|
||||
| sed 's/status:[[:space:]]*//' \
|
||||
| tr -d '"'"'" )
|
||||
|
||||
if [[ -z "$STATUS" ]]; then
|
||||
echo "⚠️ No status field found in frontmatter of: $WORKPLAN_FILE" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$STATUS" == "done" ]]; then
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue