Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions scripts/test-agents-md.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#!/usr/bin/env bash
# Tests for the top-level AGENTS.md.
#
# AGENTS.md is documentation, not executable code, so this suite verifies
# that the factual claims it makes (paths, npm scripts, ports, URLs) are
# actually true of the repository, catching doc/code drift. Mirrors the
# check style used by godmode/scripts/validate.sh.
#
# Run: bash scripts/test-agents-md.sh
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
AGENTS_MD="$ROOT/AGENTS.md"
pass=0
fail=0

ok() {
echo "OK: $1"
pass=$((pass + 1))
}

bad() {
echo "FAIL: $1"
fail=$((fail + 1))
}

check_exists() {
local path="$1" desc="$2"
if [[ -e "$ROOT/$path" ]]; then
ok "$desc ($path exists)"
else
bad "$desc ($path missing)"
fi
}

check_grep() {
local file="$1" pattern="$2" desc="$3"
if grep -qF -- "$pattern" "$ROOT/$file" 2>/dev/null; then
ok "$desc"
else
bad "$desc"
fi
}

check_not_grep() {
local file="$1" pattern="$2" desc="$3"
if grep -qF -- "$pattern" "$ROOT/$file" 2>/dev/null; then
bad "$desc"
else
ok "$desc"
fi
}

echo "== AGENTS.md itself =="
if [[ -f "$AGENTS_MD" ]]; then
ok "root AGENTS.md exists"
else
bad "root AGENTS.md exists"
fi
if [[ -s "$AGENTS_MD" ]]; then
ok "root AGENTS.md is non-empty"
else
bad "root AGENTS.md is non-empty"
fi
check_grep "AGENTS.md" "# AGENTS" "AGENTS.md has an # AGENTS heading"
check_grep "AGENTS.md" "**Bloom**" "AGENTS.md documents Bloom"
check_grep "AGENTS.md" "**GODMODE**" "AGENTS.md documents GODMODE"
check_grep "AGENTS.md" "## Cursor Cloud specific instructions" "AGENTS.md has Cursor Cloud section"

echo "== Paths referenced for Bloom exist =="
check_exists "src" "Bloom source directory"
check_exists "public/tulip" "prebuilt tulip frames directory"
check_exists "package-lock.json" "npm lockfile (documents npm as package manager)"
check_exists "vite.config.ts" "vite config (documents fixed dev port)"
check_exists "src/vision.ts" "vision module (documents MediaPipe fetch URLs)"

echo "== Paths referenced for GODMODE exist =="
check_exists "godmode" "godmode directory"
check_exists "godmode/README.md" "godmode README"
check_exists "godmode/AGENTS.md" "godmode AGENTS.md"
check_exists "godmode/scripts/validate.sh" "godmode validate script"

echo "== Documented npm scripts and quality gate match package.json =="
check_grep "package.json" '"dev": "vite"' "dev script matches documented \`npm run dev\`"
check_grep "package.json" '"build": "tsc && vite build"' "build script matches documented \`tsc && vite build\`"
check_not_grep "package.json" '"lint"' "no lint script, matching documented 'no lint script'"
check_not_grep "package.json" '"test"' "no test script, matching documented 'no test framework'"

echo "== Documented dev server port matches vite.config.ts =="
check_grep "vite.config.ts" "port: 5175" "vite.config.ts pins the documented port 5175"

echo "== Documented runtime network egress targets match src/vision.ts =="
check_grep "src/vision.ts" "cdn.jsdelivr.net" "WASM is fetched from documented cdn.jsdelivr.net"
check_grep "src/vision.ts" "storage.googleapis.com" "hand model is fetched from documented storage.googleapis.com"
check_grep "src/vision.ts" "hand_landmarker.task" "documented model filename hand_landmarker.task is referenced"

echo "== GODMODE has no build system, as documented =="
if [[ -e "$ROOT/godmode/package.json" ]]; then
bad "godmode has no package.json (matches 'no dependencies/build')"
else
ok "godmode has no package.json (matches 'no dependencies/build')"
fi

echo "== GODMODE self-check command matches documented invocation =="
check_grep "godmode/scripts/validate.sh" "python3" "validate.sh invokes python3, matching documented requirement"
if [[ -x "$ROOT/godmode/scripts/validate.sh" ]]; then
ok "validate.sh is executable (runnable as \`bash godmode/scripts/validate.sh\`)"
else
ok "validate.sh runnable via documented \`bash godmode/scripts/validate.sh\` even if not marked executable"
fi

echo
echo "Passed: $pass, Failed: $fail"
if [[ "$fail" -ne 0 ]]; then
echo "TEST FAILED"
exit 1
fi
echo "TEST PASSED"