-
Notifications
You must be signed in to change notification settings - Fork 0
164 lines (148 loc) · 5.92 KB
/
validate.yml
File metadata and controls
164 lines (148 loc) · 5.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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: Validate Plugin Structure
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Validate plugin.json
run: |
echo "Checking plugin.json is valid JSON..."
python3 -c "import json; json.load(open('.cursor-plugin/plugin.json'))"
echo "plugin.json is valid."
- name: Check referenced paths exist
run: |
echo "Checking referenced paths..."
test -d skills || { echo "ERROR: skills/ directory missing"; exit 1; }
test -d rules || { echo "ERROR: rules/ directory missing"; exit 1; }
test -f assets/logo.png || { echo "ERROR: assets/logo.png missing"; exit 1; }
echo "All referenced paths exist."
- name: Validate skill frontmatter
run: |
echo "Checking skill YAML frontmatter..."
errors=0
for skill in skills/*/SKILL.md; do
name=$(echo "$skill" | sed 's|skills/\(.*\)/SKILL.md|\1|')
if ! head -1 "$skill" | grep -q "^---$"; then
echo "ERROR: $skill missing YAML frontmatter opening ---"
errors=$((errors + 1))
continue
fi
frontmatter=$(sed -n '/^---$/,/^---$/p' "$skill" | sed '1d;$d')
if ! echo "$frontmatter" | grep -q "^name:"; then
echo "ERROR: $skill missing 'name' in frontmatter"
errors=$((errors + 1))
fi
if ! echo "$frontmatter" | grep -q "^description:"; then
echo "ERROR: $skill missing 'description' in frontmatter"
errors=$((errors + 1))
fi
done
if [ $errors -gt 0 ]; then
echo "$errors frontmatter error(s) found."
exit 1
fi
echo "All skill frontmatter valid."
- name: Check skill name matches directory
run: |
echo "Checking skill names match directory names..."
errors=0
for skill in skills/*/SKILL.md; do
dir_name=$(echo "$skill" | sed 's|skills/\(.*\)/SKILL.md|\1|')
fm_name=$(sed -n '/^---$/,/^---$/p' "$skill" | sed '1d;$d' | grep "^name:" | sed 's/^name: *//')
if [ "$dir_name" != "$fm_name" ]; then
echo "ERROR: $skill has name '$fm_name' but directory is '$dir_name'"
errors=$((errors + 1))
fi
done
if [ $errors -gt 0 ]; then
echo "$errors name mismatch(es) found."
exit 1
fi
echo "All skill names match their directories."
- name: Validate rule frontmatter
run: |
echo "Checking rule YAML frontmatter..."
errors=0
for rule in rules/*.mdc; do
if ! head -1 "$rule" | grep -q "^---$"; then
echo "ERROR: $rule missing YAML frontmatter opening ---"
errors=$((errors + 1))
continue
fi
frontmatter=$(sed -n '/^---$/,/^---$/p' "$rule" | sed '1d;$d')
if ! echo "$frontmatter" | grep -q "^description:"; then
echo "ERROR: $rule missing 'description' in frontmatter"
errors=$((errors + 1))
fi
if ! echo "$frontmatter" | grep -q "^alwaysApply:"; then
echo "ERROR: $rule missing 'alwaysApply' in frontmatter"
errors=$((errors + 1))
fi
done
if [ $errors -gt 0 ]; then
echo "$errors frontmatter error(s) found."
exit 1
fi
echo "All rule frontmatter valid."
- name: Check version consistency
run: |
plugin_ver=$(python3 -c "import json; print(json.load(open('.cursor-plugin/plugin.json'))['version'])")
pkg_ver=$(python3 -c "import json; print(json.load(open('mcp-server/package.json'))['version'])")
index_ver=$(grep -oP 'version:\s*"\K[^"]+' mcp-server/src/index.ts)
echo "plugin.json: $plugin_ver"
echo "package.json: $pkg_ver"
echo "index.ts: $index_ver"
errors=0
if [ "$plugin_ver" != "$pkg_ver" ]; then
echo "ERROR: plugin.json ($plugin_ver) != package.json ($pkg_ver)"
errors=$((errors + 1))
fi
if [ "$plugin_ver" != "$index_ver" ]; then
echo "ERROR: plugin.json ($plugin_ver) != index.ts ($index_ver)"
errors=$((errors + 1))
fi
if [ $errors -gt 0 ]; then
exit 1
fi
echo "All versions match: $plugin_ver"
- name: Count components
run: |
skill_count=$(ls -d skills/*/SKILL.md 2>/dev/null | wc -l)
rule_count=$(ls rules/*.mdc 2>/dev/null | wc -l)
echo "Skills: $skill_count"
echo "Rules: $rule_count"
validate-counts:
name: Validate content counts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Check content counts match README
run: |
python3 << 'PYEOF'
import os, sys
errors = []
skill_count = len([
d for d in os.listdir('skills')
if os.path.isdir(os.path.join('skills', d))
and os.path.exists(os.path.join('skills', d, 'SKILL.md'))
])
rule_count = len([
f for f in os.listdir('rules')
if f.endswith('.mdc')
])
readme = open('README.md').read()
if f'{skill_count} skills' not in readme:
errors.append(f'README skill count mismatch (expected "{skill_count} skills")')
if f'{rule_count} rules' not in readme:
errors.append(f'README rule count mismatch (expected "{rule_count} rules")')
if errors:
for e in errors:
print(f'::error::{e}', file=sys.stderr)
sys.exit(1)
print(f'Counts verified: {skill_count} skills, {rule_count} rules')
PYEOF