99 lines
3.6 KiB
PowerShell
99 lines
3.6 KiB
PowerShell
# sync-all.ps1 — 将 .ai/ 下的 skills、protocols、agents 同步到各平台目录
|
|
# 新增或更新后运行此脚本即可同步到全部平台
|
|
# 用法: cd ProjectNLD && 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 ─────────────────────────────────────────────
|
|
$AGENTS_SRC = ".ai/agents"
|
|
Write-Host ""
|
|
Write-Host "=== Syncing agents from $AGENTS_SRC ==="
|
|
$agentCount = 0
|
|
|
|
if (Test-Path $AGENTS_SRC) {
|
|
Get-ChildItem "$AGENTS_SRC" -Filter "*.md" | ForEach-Object {
|
|
$filename = $_.Name
|
|
|
|
foreach ($platform in $PLATFORMS) {
|
|
$targetDir = Join-Path $platform "agents"
|
|
New-Item -ItemType Directory -Force -Path $targetDir | Out-Null
|
|
Copy-Item $_.FullName (Join-Path $targetDir $filename) -Force
|
|
}
|
|
|
|
Write-Host " ✓ agent: $filename"
|
|
$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"
|