# sync-all.ps1 — 将 .ai/ 下的 skills、protocols、agents 同步到各平台目录 # 新增或更新后运行此脚本即可同步到全部平台 # 用法: powershell -ExecutionPolicy Bypass -File .ai/sync-all.ps1 $ErrorActionPreference = "Stop" $PLATFORMS = @(".cursor", ".claude", ".github", ".kiro") # ── 1. Sync skills ────────────────────────────────────────────── $SKILLS_SRC = ".ai/skills" Write-Host "=== Syncing skills from $SKILLS_SRC ===" $skillCount = 0 Get-ChildItem "$SKILLS_SRC" -Directory | ForEach-Object { $skill = $_.Name $skillMd = Join-Path $_.FullName "SKILL.md" if (-not (Test-Path $skillMd)) { return } foreach ($platform in $PLATFORMS) { $targetDir = Join-Path $platform "skills/$skill" New-Item -ItemType Directory -Force -Path $targetDir | Out-Null Copy-Item $skillMd (Join-Path $targetDir "SKILL.md") -Force } Write-Host " ✓ skill: $skill" $skillCount++ } # ── 2. Sync protocols ────────────────────────────────────────── $PROTOCOLS_SRC = ".ai/protocols" Write-Host "" Write-Host "=== Syncing protocols from $PROTOCOLS_SRC ===" $protoCount = 0 if (Test-Path $PROTOCOLS_SRC) { Get-ChildItem "$PROTOCOLS_SRC" -Filter "*.md" | ForEach-Object { $filename = $_.Name foreach ($platform in $PLATFORMS) { $targetDir = Join-Path $platform "protocols" New-Item -ItemType Directory -Force -Path $targetDir | Out-Null Copy-Item $_.FullName (Join-Path $targetDir $filename) -Force } Write-Host " ✓ protocol: $filename" $protoCount++ } } # ── 3. Sync agents ───────────────────────────────────────────── # .ai/agents/*.md → 各平台 agents/ 目录(跳过 .github,Copilot 兼容 Claude agents) $AGENTS_SRC = ".ai/agents" Write-Host "" Write-Host "=== Syncing agents from $AGENTS_SRC ===" $agentCount = 0 # 排除 .github(Copilot 直接使用 .claude/agents/) $AGENT_PLATFORMS = @(".cursor", ".claude", ".kiro") if (Test-Path $AGENTS_SRC) { Get-ChildItem "$AGENTS_SRC" -Filter "*.md" | ForEach-Object { $baseName = [System.IO.Path]::GetFileNameWithoutExtension($_.Name) foreach ($platform in $AGENT_PLATFORMS) { $targetDir = Join-Path $platform "agents" New-Item -ItemType Directory -Force -Path $targetDir | Out-Null Copy-Item $_.FullName (Join-Path $targetDir "$baseName.md") -Force } Write-Host " ✓ agent: $baseName" $agentCount++ } } # ── 4. Sync hooks ────────────────────────────────────────────── $HOOKS_SRC = ".ai/hooks" Write-Host "" Write-Host "=== Syncing hooks from $HOOKS_SRC ===" $hookCount = 0 if (Test-Path $HOOKS_SRC) { Get-ChildItem "$HOOKS_SRC" -Filter "*.md" | ForEach-Object { $filename = $_.Name foreach ($platform in $PLATFORMS) { $targetDir = Join-Path $platform "hooks" New-Item -ItemType Directory -Force -Path $targetDir | Out-Null Copy-Item $_.FullName (Join-Path $targetDir $filename) -Force } Write-Host " ✓ hook: $filename" $hookCount++ } } # ── Summary ───────────────────────────────────────────────────── Write-Host "" Write-Host "Done. Synced to $($PLATFORMS.Count) platforms:" Write-Host " Skills: $skillCount" Write-Host " Protocols: $protoCount" Write-Host " Agents: $agentCount" Write-Host " Hooks: $hookCount"