-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-validate.sh
More file actions
executable file
·80 lines (71 loc) · 2.92 KB
/
Copy pathtest-validate.sh
File metadata and controls
executable file
·80 lines (71 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env bash
#
# test-validate.sh
#
# Lightweight structural checks for the fusion-skills plugin:
# - Every SKILL.md has valid YAML frontmatter
# - Every Python script is syntactically valid
# - Reference docs named in each skill's Reading Guide exist
#
# Exits 1 if any check fails.
set -uo pipefail
ROOT="$(cd "$(dirname "$0")" && pwd)"
if [ -t 1 ]; then
GREEN=$'\033[0;32m'; RED=$'\033[0;31m'; NC=$'\033[0m'
else
GREEN=""; RED=""; NC=""
fi
PASS=0
FAIL=0
pass() { echo " ${GREEN}PASS${NC}: $1"; PASS=$((PASS + 1)); }
fail() { echo " ${RED}FAIL${NC}: $1"; FAIL=$((FAIL + 1)); }
echo ""
echo "1. SKILL.md frontmatter is valid YAML"
echo "─────────────────────────────────────"
while IFS= read -r skill; do
if python3 -c "
import sys, yaml
text = open('$skill', encoding='utf-8').read()
if not text.startswith('---'):
sys.exit('no frontmatter')
fm = text.split('---', 2)[1]
data = yaml.safe_load(fm)
assert isinstance(data, dict), 'frontmatter is not a mapping'
for key in ('name', 'description', 'version'):
assert key in data, f'missing key: {key}'
" 2>/dev/null; then
pass "$(echo "$skill" | sed "s#$ROOT/##")"
else
fail "$(echo "$skill" | sed "s#$ROOT/##") — invalid frontmatter"
fi
done < <(find "$ROOT" -name SKILL.md -not -path '*/node_modules/*' -not -path '*/.venv/*' -not -path '*/.git/*')
echo ""
echo "2. Python scripts are syntactically valid"
echo "─────────────────────────────────────────"
while IFS= read -r py; do
if python3 -c "import ast, sys; ast.parse(open('$py', encoding='utf-8').read())" 2>/dev/null; then
pass "$(echo "$py" | sed "s#$ROOT/##")"
else
fail "$(echo "$py" | sed "s#$ROOT/##") — syntax error"
fi
done < <(find "$ROOT" -name '*.py' -not -path '*/__pycache__/*' -not -path '*/.venv/*')
echo ""
echo "3. Reference docs referenced in Reading Guides exist"
echo "────────────────────────────────────────────────────"
# Check the known reference docs that skills point to.
check_ref() {
if [ -f "$ROOT/$1" ]; then pass "$1"; else fail "$1 — missing"; fi
}
check_ref "skills/lookup-files/references/cql-match-function.md"
check_ref "skills/lookup-files/references/lookup-file-formats.md"
check_ref "skills/workflows/references/yaml-schema.md"
check_ref "skills/workflows/references/json-structure.md"
check_ref "skills/workflows/references/cel-expressions.md"
check_ref "skills/workflows/references/trigger-types.md"
check_ref "skills/workflows/references/best-practices.md"
echo ""
echo "─────────────────────────────────────"
echo "Results: ${GREEN}${PASS} passed${NC}, ${RED}${FAIL} failed${NC}"
echo ""
if [ "$FAIL" -gt 0 ]; then exit 1; fi
exit 0