feat(skill-sync): 扩展技能同步功能以支持多平台

更新技能同步功能,支持将项目中的技能同步到多个全局目录(Claude、Trae 和 Trae-CN)
修改同步脚本以处理多个目标目录,并添加相应的文档说明
This commit is contained in:
2026-02-02 15:38:16 +08:00
parent 4491793742
commit 3ea09a1cdd
3 changed files with 45 additions and 20 deletions
+27 -14
View File
@@ -2,27 +2,40 @@
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$SkillDir = Split-Path -Parent $ScriptDir
$ProjectSkillsDir = Split-Path -Parent $SkillDir
$GlobalSkillsDir = Join-Path $HOME ".claude\skills"
Write-Host "Syncing skills from $ProjectSkillsDir to $GlobalSkillsDir..." -ForegroundColor Cyan
# Define global skills directories for different platforms
$GlobalSkillsDirs = @(
@{ Name = "Claude"; Path = Join-Path $HOME ".claude\skills" }
@{ Name = "Trae"; Path = Join-Path $HOME ".trae\skills" }
@{ Name = "Trae-CN"; Path = Join-Path $HOME ".trae-cn\skills" }
)
if (-not (Test-Path $GlobalSkillsDir)) {
Write-Host "Global skills directory does not exist. Creating it..." -ForegroundColor Yellow
New-Item -ItemType Directory -Path $GlobalSkillsDir -Force
}
Write-Host "Syncing skills from $ProjectSkillsDir..." -ForegroundColor Cyan
# Get all skill directories in the project
$Skills = Get-ChildItem -Path $ProjectSkillsDir -Directory
foreach ($Skill in $Skills) {
$SkillName = $Skill.Name
$TargetDir = Join-Path $GlobalSkillsDir $SkillName
foreach ($DirConfig in $GlobalSkillsDirs) {
$PlatformName = $DirConfig.Name
$TargetBaseDir = $DirConfig.Path
Write-Host "Syncing skill: $SkillName..." -ForegroundColor Green
Write-Host "`nSyncing to $PlatformName skills directory: $TargetBaseDir..." -ForegroundColor Magenta
# Sync the skill directory
# Note: Copy-Item -Recurse -Force will overwrite existing files
Copy-Item -Path $Skill.FullName -Destination $GlobalSkillsDir -Recurse -Force
if (-not (Test-Path $TargetBaseDir)) {
Write-Host "$PlatformName skills directory does not exist. Creating it..." -ForegroundColor Yellow
New-Item -ItemType Directory -Path $TargetBaseDir -Force
}
foreach ($Skill in $Skills) {
$SkillName = $Skill.Name
$TargetDir = Join-Path $TargetBaseDir $SkillName
Write-Host "Syncing skill: $SkillName..." -ForegroundColor Green
# Sync the skill directory
# Note: Copy-Item -Recurse -Force will overwrite existing files
Copy-Item -Path $Skill.FullName -Destination $TargetBaseDir -Recurse -Force
}
}
Write-Host "Sync completed successfully." -ForegroundColor Green
Write-Host "`nSync completed successfully to all platforms!" -ForegroundColor Green