#!/usr/bin/env bash # Regression test for the ADR-0020 body-shape checks and, just as importantly, # for the false-positive fixes each of them needed. Every check here was # completely untested. # # * Gotchas section over 5 entries — SUGGESTION # * Gotchas section over 25% of the body — SUGGESTION # * a references/.md named but absent — ERROR (a broken pointer is not a # style opinion) # * description with no boundary clause — SUGGESTION # # The false-positive half is not optional extra coverage. Each of these checks # scans prose, and the first naive version of each one fired on ordinary writing: # a ```-fenced EXAMPLE of a Gotchas section became the section itself, indented # child bullets were counted as top-level entries, `## Gotcha handling` was read # as the Gotchas section, and a documented-then-removed references/ file became a # hard ERROR. The skills most likely to carry such an example are skill-author and # factory-audit — the two that DOCUMENT these conventions — so a gate that fires on # them is a gate nobody can turn on. # # Every case is a matched pair: the check fires just over its boundary, and stays # silent just under it (or on the shape it must not match). A test asserting only # that a bad file fails proves nothing about a check that fires on everything. set -euo pipefail REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" HOOK="$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_T="$(mktemp -d)" trap 'rm -rf "$TMPDIR_T"' EXIT # A description with a boundary clause and no routing target — the neutral # default, so a fixture about Gotchas or references does not also trip the # missing-boundary-clause SUGGESTION and stop isolating what it names. CLEAN_DESC="Use when doing the thing. Do not use for anything else." # make_skill — SKILL.md with the body read from stdin. Echoes the # path. Each skill gets its own directory so references/ fixtures are isolated. make_skill() { local name="$1" desc="$2" dir dir="$TMPDIR_T/$name" mkdir -p "$dir" { echo "---" echo "name: $name" echo "description: $desc" echo "metadata:" echo " version: \"1.0.0\"" echo "---" cat } > "$dir/SKILL.md" echo "$dir/SKILL.md" } # expect