-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (123 loc) · 3.45 KB
/
Copy pathvalidate-skills.yml
File metadata and controls
140 lines (123 loc) · 3.45 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: Validate Skills
on:
push:
paths:
- 'project/.claude/skills/**'
- 'plugin/skills/**'
- 'scripts/validate_skills.sh'
pull_request:
paths:
- 'project/.claude/skills/**'
- 'plugin/skills/**'
- 'scripts/validate_skills.sh'
jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install PyYAML
run: pip install pyyaml
- name: Validate SKILL.md files
run: ./scripts/validate_skills.sh
- name: Check YAML syntax (additional verification)
run: |
for skill in $(find . -name "SKILL.md" -path "*/skills/*"); do
echo "Checking $skill..."
python3 << PYEOF
import yaml
import sys
with open('$skill', 'r') as f:
content = f.read()
lines = content.split('\n')
if lines[0] != '---':
print(f"Error: {sys.argv[0]} - No YAML frontmatter")
sys.exit(1)
end_idx = -1
for i, line in enumerate(lines[1:], 1):
if line == '---':
end_idx = i
break
if end_idx == -1:
print(f"Error: No closing frontmatter delimiter")
sys.exit(1)
frontmatter = '\n'.join(lines[1:end_idx])
try:
data = yaml.safe_load(frontmatter)
if not data.get('name'):
print(f"Error: Missing 'name' field")
sys.exit(1)
if not data.get('description'):
print(f"Error: Missing 'description' field")
sys.exit(1)
print(f"Valid: {data.get('name')}")
except yaml.YAMLError as e:
print(f"YAML Error: {e}")
sys.exit(1)
PYEOF
done
echo "All SKILL.md files are valid!"
- name: Check description length
run: |
failed=0
for skill in $(find . -name "SKILL.md" -path "*/skills/*"); do
python3 << PYEOF
import sys
with open('$skill', 'r') as f:
content = f.read()
lines = content.split('\n')
for line in lines[1:]:
if line == '---':
break
if line.startswith('description:'):
desc = line[12:].strip()
if len(desc) > 1024:
print(f"Error: $skill description exceeds 1024 characters ({len(desc)})")
sys.exit(1)
break
PYEOF
if [ $? -ne 0 ]; then
failed=1
fi
done
if [ $failed -eq 1 ]; then
echo "Some SKILL.md files have description length issues"
exit 1
fi
echo "All descriptions are within limits!"
- name: Check name format
run: |
failed=0
for skill in $(find . -name "SKILL.md" -path "*/skills/*"); do
python3 << PYEOF
import sys
import re
with open('$skill', 'r') as f:
content = f.read()
lines = content.split('\n')
for line in lines[1:]:
if line == '---':
break
if line.startswith('name:'):
name = line[5:].strip()
if not re.match(r'^[a-z0-9-]+$', name):
print(f"Error: $skill name '{name}' contains invalid characters")
sys.exit(1)
if len(name) > 64:
print(f"Error: $skill name exceeds 64 characters ({len(name)})")
sys.exit(1)
break
PYEOF
if [ $? -ne 0 ]; then
failed=1
fi
done
if [ $failed -eq 1 ]; then
echo "Some SKILL.md files have name format issues"
exit 1
fi
echo "All names are valid!"