|
| 1 | +name: Validate Plugin Structure |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +jobs: |
| 10 | + validate: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v4 |
| 14 | + |
| 15 | + - name: Validate plugin.json |
| 16 | + run: | |
| 17 | + echo "Checking plugin.json is valid JSON..." |
| 18 | + python3 -c "import json; json.load(open('.cursor-plugin/plugin.json'))" |
| 19 | + echo "plugin.json is valid." |
| 20 | +
|
| 21 | + - name: Check referenced paths exist |
| 22 | + run: | |
| 23 | + echo "Checking referenced paths..." |
| 24 | + test -d skills || { echo "ERROR: skills/ directory missing"; exit 1; } |
| 25 | + test -d rules || { echo "ERROR: rules/ directory missing"; exit 1; } |
| 26 | + test -f assets/logo.png || { echo "ERROR: assets/logo.png missing"; exit 1; } |
| 27 | + echo "All referenced paths exist." |
| 28 | +
|
| 29 | + - name: Validate skill frontmatter |
| 30 | + run: | |
| 31 | + echo "Checking skill YAML frontmatter..." |
| 32 | + errors=0 |
| 33 | + for skill in skills/*/SKILL.md; do |
| 34 | + name=$(echo "$skill" | sed 's|skills/\(.*\)/SKILL.md|\1|') |
| 35 | + if ! head -1 "$skill" | grep -q "^---$"; then |
| 36 | + echo "ERROR: $skill missing YAML frontmatter opening ---" |
| 37 | + errors=$((errors + 1)) |
| 38 | + continue |
| 39 | + fi |
| 40 | + frontmatter=$(sed -n '/^---$/,/^---$/p' "$skill" | sed '1d;$d') |
| 41 | + if ! echo "$frontmatter" | grep -q "^name:"; then |
| 42 | + echo "ERROR: $skill missing 'name' in frontmatter" |
| 43 | + errors=$((errors + 1)) |
| 44 | + fi |
| 45 | + if ! echo "$frontmatter" | grep -q "^description:"; then |
| 46 | + echo "ERROR: $skill missing 'description' in frontmatter" |
| 47 | + errors=$((errors + 1)) |
| 48 | + fi |
| 49 | + done |
| 50 | + if [ $errors -gt 0 ]; then |
| 51 | + echo "$errors frontmatter error(s) found." |
| 52 | + exit 1 |
| 53 | + fi |
| 54 | + echo "All skill frontmatter valid." |
| 55 | +
|
| 56 | + - name: Check skill name matches directory |
| 57 | + run: | |
| 58 | + echo "Checking skill names match directory names..." |
| 59 | + errors=0 |
| 60 | + for skill in skills/*/SKILL.md; do |
| 61 | + dir_name=$(echo "$skill" | sed 's|skills/\(.*\)/SKILL.md|\1|') |
| 62 | + fm_name=$(sed -n '/^---$/,/^---$/p' "$skill" | sed '1d;$d' | grep "^name:" | sed 's/^name: *//') |
| 63 | + if [ "$dir_name" != "$fm_name" ]; then |
| 64 | + echo "ERROR: $skill has name '$fm_name' but directory is '$dir_name'" |
| 65 | + errors=$((errors + 1)) |
| 66 | + fi |
| 67 | + done |
| 68 | + if [ $errors -gt 0 ]; then |
| 69 | + echo "$errors name mismatch(es) found." |
| 70 | + exit 1 |
| 71 | + fi |
| 72 | + echo "All skill names match their directories." |
| 73 | +
|
| 74 | + - name: Validate rule frontmatter |
| 75 | + run: | |
| 76 | + echo "Checking rule YAML frontmatter..." |
| 77 | + errors=0 |
| 78 | + for rule in rules/*.mdc; do |
| 79 | + if ! head -1 "$rule" | grep -q "^---$"; then |
| 80 | + echo "ERROR: $rule missing YAML frontmatter opening ---" |
| 81 | + errors=$((errors + 1)) |
| 82 | + continue |
| 83 | + fi |
| 84 | + frontmatter=$(sed -n '/^---$/,/^---$/p' "$rule" | sed '1d;$d') |
| 85 | + if ! echo "$frontmatter" | grep -q "^description:"; then |
| 86 | + echo "ERROR: $rule missing 'description' in frontmatter" |
| 87 | + errors=$((errors + 1)) |
| 88 | + fi |
| 89 | + if ! echo "$frontmatter" | grep -q "^alwaysApply:"; then |
| 90 | + echo "ERROR: $rule missing 'alwaysApply' in frontmatter" |
| 91 | + errors=$((errors + 1)) |
| 92 | + fi |
| 93 | + done |
| 94 | + if [ $errors -gt 0 ]; then |
| 95 | + echo "$errors frontmatter error(s) found." |
| 96 | + exit 1 |
| 97 | + fi |
| 98 | + echo "All rule frontmatter valid." |
| 99 | +
|
| 100 | + - name: Count components |
| 101 | + run: | |
| 102 | + skill_count=$(ls -d skills/*/SKILL.md 2>/dev/null | wc -l) |
| 103 | + rule_count=$(ls rules/*.mdc 2>/dev/null | wc -l) |
| 104 | + echo "Skills: $skill_count" |
| 105 | + echo "Rules: $rule_count" |
0 commit comments