deploy-to-openclaw.ps1 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. # OpenClaw Skill Deploy Script v1.3.0
  2. # Flatten 41 skills into ~/.openclaw/skills/
  3. # 批量将voc技能部署在龙虾skills目录下脚本
  4. # 需要将.openclaw的路径更换后使用
  5. # Usage:
  6. # .\deploy-to-openclaw.ps1 -DryRun # Preview only
  7. # .\deploy-to-openclaw.ps1 # Actual deploy
  8. # .\deploy-to-openclaw.ps1 -SkillsRoot "D:\custom\skills"
  9. param(
  10. [string]$SkillsRoot = "$env:USERPROFILE\.openclaw\skills",
  11. [string]$SourceRoot = $PSScriptRoot,
  12. [switch]$DryRun
  13. )
  14. $ErrorActionPreference = "Stop"
  15. $categories = @(
  16. "voc",
  17. "social-media",
  18. "competitor-analysis",
  19. "review-analysis",
  20. "synthesis",
  21. "social-voc",
  22. "douyin"
  23. )
  24. Write-Host "========================================"
  25. Write-Host " OpenClaw Skill Deploy v1.3.0"
  26. Write-Host "========================================"
  27. Write-Host ""
  28. Write-Host "Source: $SourceRoot"
  29. Write-Host "Target: $SkillsRoot"
  30. if ($DryRun) { Write-Host "[DRY RUN] Preview only, no files copied" -ForegroundColor Yellow }
  31. Write-Host ""
  32. if (-not $DryRun) {
  33. if (-not (Test-Path $SkillsRoot)) {
  34. New-Item -ItemType Directory -Path $SkillsRoot -Force | Out-Null
  35. Write-Host "Created target dir: $SkillsRoot" -ForegroundColor Green
  36. }
  37. }
  38. $deployed = 0
  39. $skipped = 0
  40. $errors = 0
  41. foreach ($cat in $categories) {
  42. $catPath = Join-Path $SourceRoot $cat
  43. if (-not (Test-Path $catPath)) {
  44. Write-Host "SKIP category (not found): $cat" -ForegroundColor DarkGray
  45. continue
  46. }
  47. Write-Host "--- $cat ---" -ForegroundColor Cyan
  48. $skillDirs = Get-ChildItem -Directory -Path $catPath
  49. foreach ($skillDir in $skillDirs) {
  50. $skillName = $skillDir.Name
  51. $skillMd = Join-Path $skillDir.FullName "SKILL.md"
  52. $apiConfig = Join-Path $skillDir.FullName "api-config.json"
  53. if (-not (Test-Path $skillMd)) {
  54. Write-Host " [SKIP] $skillName - missing SKILL.md" -ForegroundColor DarkYellow
  55. $skipped++
  56. continue
  57. }
  58. if (-not (Test-Path $apiConfig)) {
  59. Write-Host " [SKIP] $skillName - missing api-config.json" -ForegroundColor DarkYellow
  60. $skipped++
  61. continue
  62. }
  63. $mdContent = Get-Content $skillMd -Raw -Encoding UTF8
  64. if ($mdContent -notmatch "^---\s*\r?\n") {
  65. Write-Host " [WARN] $skillName - SKILL.md missing YAML frontmatter" -ForegroundColor Yellow
  66. }
  67. try {
  68. $null = Get-Content $apiConfig -Raw -Encoding UTF8 | ConvertFrom-Json
  69. } catch {
  70. Write-Host " [ERROR] $skillName - invalid JSON in api-config.json" -ForegroundColor Red
  71. $errors++
  72. continue
  73. }
  74. $destDir = Join-Path $SkillsRoot $skillName
  75. if ($DryRun) {
  76. $tag = if (Test-Path $destDir) { "UPDATE" } else { "NEW" }
  77. Write-Host " [$tag] $skillName" -ForegroundColor White
  78. } else {
  79. if (Test-Path $destDir) {
  80. Remove-Item -Recurse -Force $destDir
  81. }
  82. New-Item -ItemType Directory -Path $destDir -Force | Out-Null
  83. Get-ChildItem -File -Path $skillDir.FullName | ForEach-Object {
  84. Copy-Item $_.FullName -Destination $destDir
  85. }
  86. Write-Host " [OK] $skillName" -ForegroundColor Green
  87. }
  88. $deployed++
  89. }
  90. }
  91. Write-Host ""
  92. Write-Host "========================================"
  93. Write-Host " Result: $deployed deployed, $skipped skipped, $errors errors"
  94. Write-Host "========================================"
  95. if ($DryRun) {
  96. Write-Host "Remove -DryRun to execute actual deployment." -ForegroundColor Yellow
  97. } else {
  98. Write-Host "Done! Refresh OpenClaw skill list to verify." -ForegroundColor Green
  99. Write-Host " openclaw skills list"
  100. }