#!/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 set -euo pipefail WORKPLAN_FILE="${1:?workplan_file required}" 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