#!/usr/bin/env bash set -euo pipefail # ─── autoresearch.checks.sh ───────────────────────────────────────────────── # Backpressure checks for the sequence diagram skill. # ───────────────────────────────────────────────────────────────────────────── SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SKILL_FILE="${SCRIPT_DIR}/skill/SKILL.md" ERRORS=0 # 1. Skill exists and is non-empty if [[ ! -s "$SKILL_FILE" ]]; then echo "FAIL: skill/SKILL.md is missing or empty" ERRORS=$((ERRORS + 1)) fi # 2. Skill is not trivially short CHAR_COUNT=$(wc -c < "$SKILL_FILE" 2>/dev/null || echo "0") if (( CHAR_COUNT < 200 )); then echo "FAIL: skill/SKILL.md is only ${CHAR_COUNT} chars (min: 200)" ERRORS=$((ERRORS + 1)) fi # 3. Skill is not too long (rough token proxy: 1500 tokens ≈ 6000 chars) if (( CHAR_COUNT > 6000 )); then echo "FAIL: skill/SKILL.md is ${CHAR_COUNT} chars (max: ~6000)" ERRORS=$((ERRORS + 1)) fi # 4. Skill must contain "sequenceDiagram" or "sequence diagram" (it's a diagram skill) if ! grep -qi 'sequence.diagram' "$SKILL_FILE" 2>/dev/null; then echo "FAIL: skill/SKILL.md doesn't mention sequence diagrams" ERRORS=$((ERRORS + 1)) fi # 5. Skill must NOT contain Firehose-specific code (no overfitting) for term in "BlogController" "EngineeringBlog" "Firehose" "blogex" "priv/blog"; do if grep -q "$term" "$SKILL_FILE" 2>/dev/null; then echo "FAIL: skill/SKILL.md contains codebase-specific term '${term}'" ERRORS=$((ERRORS + 1)) fi done # 6. Valid UTF-8 if ! iconv -f utf-8 -t utf-8 "$SKILL_FILE" > /dev/null 2>&1; then echo "FAIL: skill/SKILL.md contains invalid UTF-8" ERRORS=$((ERRORS + 1)) fi if (( ERRORS > 0 )); then echo "Checks FAILED with ${ERRORS} error(s)" exit 1 else echo "All checks passed. Skill: ${CHAR_COUNT} chars." exit 0 fi