NLDClient-yudde/.ai/sync-all.ps1

103 lines
3.8 KiB
PowerShell
Raw Permalink Normal View History

2026-05-08 13:25:20 +08:00
# sync-all.ps1 — 将 .ai/ 下的 skills、protocols、agents 同步到各平台目录
# 新增或更新后运行此脚本即可同步到全部平台
2026-05-14 19:37:04 +08:00
# 用法: powershell -ExecutionPolicy Bypass -File .ai/sync-all.ps1
2026-05-08 13:25:20 +08:00
$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/ 目录(跳过 .githubCopilot 兼容 Claude agents
2026-05-08 13:25:20 +08:00
$AGENTS_SRC = ".ai/agents"
Write-Host ""
Write-Host "=== Syncing agents from $AGENTS_SRC ==="
$agentCount = 0
# 排除 .githubCopilot 直接使用 .claude/agents/
$AGENT_PLATFORMS = @(".cursor", ".claude", ".kiro")
2026-05-08 13:25:20 +08:00
if (Test-Path $AGENTS_SRC) {
Get-ChildItem "$AGENTS_SRC" -Filter "*.md" | ForEach-Object {
2026-05-14 19:37:04 +08:00
$baseName = [System.IO.Path]::GetFileNameWithoutExtension($_.Name)
2026-05-08 13:25:20 +08:00
foreach ($platform in $AGENT_PLATFORMS) {
2026-05-08 13:25:20 +08:00
$targetDir = Join-Path $platform "agents"
New-Item -ItemType Directory -Force -Path $targetDir | Out-Null
Copy-Item $_.FullName (Join-Path $targetDir "$baseName.md") -Force
2026-05-08 13:25:20 +08:00
}
2026-05-14 19:37:04 +08:00
Write-Host " ✓ agent: $baseName"
2026-05-08 13:25:20 +08:00
$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++
}
}
2026-05-08 13:25:20 +08:00
# ── 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"