|
| 1 | +#!/usr/bin/env pwsh |
| 2 | +<# |
| 3 | +.SYNOPSIS |
| 4 | + Validates the repository structure for Claude Plugin and Agent Skills. |
| 5 | +
|
| 6 | +.DESCRIPTION |
| 7 | + This script validates that all required files and folders exist for: |
| 8 | + |
| 9 | + 1. Claude Plugin (.claude-plugin/) |
| 10 | + - marketplace.json : Plugin metadata for Claude marketplace |
| 11 | + - plugin.json : Plugin configuration and capabilities |
| 12 | + |
| 13 | + 2. Agent Skills (skills/) |
| 14 | + - Each subfolder must contain a SKILL.md file describing the skill |
| 15 | + - Skills help AI agents use MCP tools more effectively |
| 16 | + |
| 17 | + 3. MCP Configuration (.mcp.json) |
| 18 | + - Root-level MCP server configuration |
| 19 | +
|
| 20 | + Run this script to verify your changes before submitting a PR. |
| 21 | +
|
| 22 | +.EXAMPLE |
| 23 | + ./scripts/validate-repo.ps1 |
| 24 | +#> |
| 25 | + |
| 26 | +$ErrorActionPreference = "Stop" |
| 27 | +$script:hasErrors = $false |
| 28 | +$repoRoot = Split-Path -Parent $PSScriptRoot |
| 29 | + |
| 30 | +function Write-ValidationError($message) { |
| 31 | + Write-Host "❌ ERROR: $message" -ForegroundColor Red |
| 32 | + $script:hasErrors = $true |
| 33 | +} |
| 34 | + |
| 35 | +function Write-ValidationSuccess($message) { |
| 36 | + Write-Host "✅ $message" -ForegroundColor Green |
| 37 | +} |
| 38 | + |
| 39 | +function Write-ValidationHeader($message) { |
| 40 | + Write-Host "`n📋 $message" -ForegroundColor Cyan |
| 41 | + Write-Host ("-" * 50) -ForegroundColor Gray |
| 42 | +} |
| 43 | + |
| 44 | +function Test-ValidJson($path) { |
| 45 | + try { |
| 46 | + $null = Get-Content $path -Raw | ConvertFrom-Json |
| 47 | + return $true |
| 48 | + } catch { |
| 49 | + return $false |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | +# ============================================================================ |
| 54 | +# Validation 1: Claude Plugin Files |
| 55 | +# The .claude-plugin folder contains configuration for Claude marketplace |
| 56 | +# ============================================================================ |
| 57 | +Write-ValidationHeader "Validating Claude Plugin (.claude-plugin/)" |
| 58 | + |
| 59 | +$claudePluginFiles = @( |
| 60 | + "marketplace.json", # Plugin metadata (name, description, author, etc.) |
| 61 | + "plugin.json" # Plugin capabilities and MCP server reference |
| 62 | +) |
| 63 | + |
| 64 | +foreach ($file in $claudePluginFiles) { |
| 65 | + $path = Join-Path $repoRoot ".claude-plugin" $file |
| 66 | + if (Test-Path $path) { |
| 67 | + Write-ValidationSuccess "Found: .claude-plugin/$file" |
| 68 | + if (Test-ValidJson $path) { |
| 69 | + Write-ValidationSuccess "Valid JSON: .claude-plugin/$file" |
| 70 | + } else { |
| 71 | + Write-ValidationError "Invalid JSON: .claude-plugin/$file" |
| 72 | + } |
| 73 | + } else { |
| 74 | + Write-ValidationError "Missing: .claude-plugin/$file" |
| 75 | + } |
| 76 | +} |
| 77 | + |
| 78 | +# ============================================================================ |
| 79 | +# Validation 2: Agent Skills Structure |
| 80 | +# Each skill folder under /skills must have a SKILL.md describing the skill |
| 81 | +# ============================================================================ |
| 82 | +Write-ValidationHeader "Validating Agent Skills (skills/)" |
| 83 | + |
| 84 | +$skillsDir = Join-Path $repoRoot "skills" |
| 85 | + |
| 86 | +if (-not (Test-Path $skillsDir)) { |
| 87 | + Write-ValidationError "Missing: skills/ directory" |
| 88 | +} else { |
| 89 | + $skillFolders = Get-ChildItem -Path $skillsDir -Directory |
| 90 | + |
| 91 | + if ($skillFolders.Count -eq 0) { |
| 92 | + Write-ValidationError "No skill folders found in skills/" |
| 93 | + } else { |
| 94 | + foreach ($folder in $skillFolders) { |
| 95 | + $skillMd = Join-Path $folder.FullName "SKILL.md" |
| 96 | + if (Test-Path $skillMd) { |
| 97 | + Write-ValidationSuccess "Found: skills/$($folder.Name)/SKILL.md" |
| 98 | + } else { |
| 99 | + Write-ValidationError "Missing: skills/$($folder.Name)/SKILL.md - Each skill folder must have a SKILL.md file" |
| 100 | + } |
| 101 | + } |
| 102 | + } |
| 103 | +} |
| 104 | + |
| 105 | +# ============================================================================ |
| 106 | +# Validation 3: MCP Configuration |
| 107 | +# The .mcp.json file at repo root defines MCP server settings |
| 108 | +# ============================================================================ |
| 109 | +Write-ValidationHeader "Validating MCP Configuration (.mcp.json)" |
| 110 | + |
| 111 | +$mcpJsonPath = Join-Path $repoRoot ".mcp.json" |
| 112 | +if (Test-Path $mcpJsonPath) { |
| 113 | + Write-ValidationSuccess "Found: .mcp.json" |
| 114 | + if (Test-ValidJson $mcpJsonPath) { |
| 115 | + Write-ValidationSuccess "Valid JSON: .mcp.json" |
| 116 | + } else { |
| 117 | + Write-ValidationError "Invalid JSON: .mcp.json" |
| 118 | + } |
| 119 | +} else { |
| 120 | + Write-ValidationError "Missing: .mcp.json at repository root" |
| 121 | +} |
| 122 | + |
| 123 | +# ============================================================================ |
| 124 | +# Summary |
| 125 | +# ============================================================================ |
| 126 | +Write-Host "`n" ("-" * 50) -ForegroundColor Gray |
| 127 | +if ($script:hasErrors) { |
| 128 | + Write-Host "❌ Validation FAILED - Please fix the errors above" -ForegroundColor Red |
| 129 | + exit 1 |
| 130 | +} else { |
| 131 | + Write-Host "✅ All validations PASSED" -ForegroundColor Green |
| 132 | + exit 0 |
| 133 | +} |
0 commit comments