| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- param(
- [string]$SkillsRoot = "$env:USERPROFILE\.openclaw\skills",
- [string]$SourceRoot = $PSScriptRoot,
- [switch]$DryRun
- )
- $ErrorActionPreference = "Stop"
- $categories = @("wechat")
- Write-Host "=== OpenClaw WeChat Skill Deploy v1.0.0 ==="
- Write-Host "Source: $SourceRoot"
- Write-Host "Target: $SkillsRoot"
- if ($DryRun) { Write-Host "[DRY RUN]" -ForegroundColor Yellow }
- if (-not $DryRun -and -not (Test-Path $SkillsRoot)) {
- New-Item -ItemType Directory -Path $SkillsRoot -Force | Out-Null
- }
- $deployed = 0; $skipped = 0; $errors = 0
- foreach ($cat in $categories) {
- $catPath = Join-Path $SourceRoot $cat
- if (-not (Test-Path $catPath)) { continue }
- Write-Host "--- $cat ---" -ForegroundColor Cyan
- foreach ($skillDir in (Get-ChildItem -Directory -Path $catPath)) {
- $n = $skillDir.Name
- $sm = Join-Path $skillDir.FullName "SKILL.md"
- $ac = Join-Path $skillDir.FullName "api-config.json"
- if (-not (Test-Path $sm) -or -not (Test-Path $ac)) { $skipped++; continue }
- try { $null = Get-Content $ac -Raw -Encoding UTF8 | ConvertFrom-Json } catch { $errors++; continue }
- $dest = Join-Path $SkillsRoot $n
- if ($DryRun) {
- Write-Host " [$( if (Test-Path $dest){'UPDATE'}else{'NEW'} )] $n"
- } else {
- if (Test-Path $dest) { Remove-Item -Recurse -Force $dest }
- New-Item -ItemType Directory -Path $dest -Force | Out-Null
- Get-ChildItem -File -Path $skillDir.FullName | ForEach-Object { Copy-Item $_.FullName -Destination $dest }
- Write-Host " [OK] $n" -ForegroundColor Green
- }
- $deployed++
- }
- }
- Write-Host "Result: $deployed deployed, $skipped skipped, $errors errors"
- # Deploy workflows
- $wfSource = Join-Path $SourceRoot "workflows"
- $wfTarget = Join-Path (Split-Path $SkillsRoot -Parent) "workflows"
- if (Test-Path $wfSource) {
- Write-Host "--- workflows ---" -ForegroundColor Cyan
- if (-not $DryRun) {
- if (-not (Test-Path $wfTarget)) { New-Item -ItemType Directory -Path $wfTarget -Force | Out-Null }
- Get-ChildItem -File -Path $wfSource | ForEach-Object {
- Copy-Item $_.FullName -Destination $wfTarget -Force
- Write-Host " [OK] $($_.Name)" -ForegroundColor Green
- }
- } else {
- Get-ChildItem -File -Path $wfSource | ForEach-Object { Write-Host " [WORKFLOW] $($_.Name)" }
- }
- }
- if (-not $DryRun) {
- # Copy credentials template
- $tpl = Join-Path $SourceRoot "__config\wechat-credentials.template.json"
- $dst = Join-Path (Split-Path $SkillsRoot -Parent) "wechat-credentials.template.json"
- if (Test-Path $tpl) { Copy-Item $tpl -Destination $dst -Force; Write-Host "Template: $dst" }
- # Create default credentials if not exists
- $credFile = Join-Path (Split-Path $SkillsRoot -Parent) "wechat-credentials.json"
- if (-not (Test-Path $credFile)) {
- Copy-Item $tpl -Destination $credFile -Force
- Write-Host "[!] Created $credFile - please edit wechatApiBase to your server address" -ForegroundColor Yellow
- }
- Write-Host "Done!" -ForegroundColor Green
- }
|