#!/usr/bin/env bash # Regression test for scripts/skill-size-check.sh: enforces agentskills.io's # 500-line/5,000-word(proxy-for-token) SKILL.md size ceiling. set -euo pipefail REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" SCRIPT="$REPO_ROOT/scripts/skill-size-check.sh" PASS=0 FAIL=0 pass() { echo " PASS: $1"; PASS=$((PASS + 1)); } fail() { echo " FAIL: $1"; FAIL=$((FAIL + 1)); } TMPDIR="$(mktemp -d)" trap 'rm -rf "$TMPDIR"' EXIT make_fixture() { local name="$1" lines="$2" words_per_line="$3" file file="$TMPDIR/$name.md" { echo "---" echo "name: $name" echo "description: Test fixture." echo "---" for ((i = 1; i <= lines; i++)); do w="" for ((j = 1; j <= words_per_line; j++)); do w="$w word" done echo "$w" done } > "$file" echo "$file" } echo "" echo "--- passes a file under both limits ---" SMALL="$(make_fixture small 10 5)" if "$SCRIPT" "$SMALL"; then pass "file under both limits exits 0" else fail "file under both limits should have exited 0" fi echo "" echo "--- fails a file over the line limit ---" MANY_LINES="$(make_fixture many-lines 600 1)" if "$SCRIPT" "$MANY_LINES" 2>/dev/null; then fail "file over the 500-line ceiling should have exited non-zero" else pass "file over the 500-line ceiling exits non-zero" fi echo "" echo "--- fails a file over the word-count limit ---" MANY_WORDS="$(make_fixture many-words 10 600)" if "$SCRIPT" "$MANY_WORDS" 2>/dev/null; then fail "file over the 5,000-word ceiling should have exited non-zero" else pass "file over the 5,000-word ceiling exits non-zero" fi echo "" echo "Results: $PASS passed, $FAIL failed" [[ $FAIL -eq 0 ]]