#!/usr/bin/env bash
# Task 698 — the prompt-optimiser restatement mode must end with the three-tier
# routing ladder, not the lone "Delegate this task to the appropriate specialist."
# line it carried before.
set -u

SK="$(cd "$(dirname "$0")/.." && pwd)/SKILL.md"
[ -f "$SK" ] || { echo "FAIL: $SK not found" >&2; exit 1; }

PASS=0; FAIL=0
chk() { if eval "$2"; then echo "PASS: $1"; PASS=$((PASS+1)); else echo "FAIL: $1" >&2; FAIL=$((FAIL+1)); fi; }

chk "lone delegate line removed"   '! grep -q "Delegate this task to the appropriate specialist." "$SK"'
chk "tier 1 delegate to specialist" 'grep -qiE "delegate to (a |the )?specialist" "$SK"'
chk "tier 2 admin-usable skill"    'grep -qi "admin-usable" "$SK"'
chk "tier 3 freestyle last resort" 'grep -qiE "freestyle|last resort" "$SK"'
chk "restatement section present"  'grep -qi "In-session restatement mode" "$SK"'

echo "----"
echo "PASS=$PASS FAIL=$FAIL"
[ "$FAIL" -eq 0 ]
