Files
bible/tools/lint.sh
T

35 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
# Consistency checks for the rules library. Run from the repo root: sh tools/lint.sh
set -u
fail=0
# 1. Every pattern directory must be reachable from the bootstrap router.
for dir in rules/patterns/*/; do
name=$(basename "$dir")
if ! grep -q "$name" AGENT-BOOTSTRAP.md; then
echo "FAIL: rules/patterns/$name is not mentioned in AGENT-BOOTSTRAP.md"
fail=1
fi
done
# 2. Every bible/... path mentioned in the bootstrap must exist in the repo.
for ref in $(grep -o 'bible/rules/patterns/[a-z-]*/contract\.md' AGENT-BOOTSTRAP.md | sort -u); do
path=${ref#bible/}
if [ ! -f "$path" ]; then
echo "FAIL: AGENT-BOOTSTRAP.md references missing file $path"
fail=1
fi
done
# 3. No machine-local absolute paths or stale path prefixes in committed markdown.
if grep -rn '/Users/\|kit/patterns' --include='*.md' . --exclude-dir=.git; then
echo "FAIL: machine-local absolute paths or stale kit/patterns references found (see above)"
fail=1
fi
if [ "$fail" -eq 0 ]; then
echo "OK: all checks passed"
fi
exit "$fail"