66 lines
2.1 KiB
PowerShell
66 lines
2.1 KiB
PowerShell
|
|
<#
|
||
|
|
Esporta ogni skill (plugins/*/skills/<nome>/) in uno zip separato in dist/,
|
||
|
|
pronto per essere caricato come skill singola su Claude (Settings -> Capabilities -> Skills)
|
||
|
|
per test rapidi senza passare dall'installazione dell'intero plugin/marketplace.
|
||
|
|
|
||
|
|
Uso:
|
||
|
|
powershell -File scripts/export-skills.ps1
|
||
|
|
powershell -File scripts/export-skills.ps1 -Skill o-ring # esporta solo una skill
|
||
|
|
|
||
|
|
Ogni zip contiene i file della skill alla radice dell'archivio (SKILL.md in cima),
|
||
|
|
non dentro una sottocartella, come richiesto dal caricamento manuale su Claude.
|
||
|
|
#>
|
||
|
|
param(
|
||
|
|
[string]$Skill
|
||
|
|
)
|
||
|
|
|
||
|
|
$ErrorActionPreference = "Stop"
|
||
|
|
$root = Split-Path -Parent $PSScriptRoot
|
||
|
|
$distDir = Join-Path $root "dist"
|
||
|
|
|
||
|
|
if (-not (Test-Path $distDir)) {
|
||
|
|
New-Item -ItemType Directory -Path $distDir | Out-Null
|
||
|
|
}
|
||
|
|
|
||
|
|
$skillDirs = Get-ChildItem -Path (Join-Path $root "plugins") -Directory |
|
||
|
|
ForEach-Object { Join-Path $_.FullName "skills" } |
|
||
|
|
Where-Object { Test-Path $_ } |
|
||
|
|
ForEach-Object { Get-ChildItem -Path $_ -Directory }
|
||
|
|
|
||
|
|
if ($Skill) {
|
||
|
|
$skillDirs = $skillDirs | Where-Object { $_.Name -eq $Skill }
|
||
|
|
if (-not $skillDirs) {
|
||
|
|
throw "Skill '$Skill' non trovata sotto plugins/*/skills/"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
foreach ($dir in $skillDirs) {
|
||
|
|
$skillMd = Join-Path $dir.FullName "SKILL.md"
|
||
|
|
if (-not (Test-Path $skillMd)) {
|
||
|
|
Write-Warning "Salto $($dir.Name): manca SKILL.md"
|
||
|
|
continue
|
||
|
|
}
|
||
|
|
|
||
|
|
$zipPath = Join-Path $distDir "$($dir.Name).zip"
|
||
|
|
if (Test-Path $zipPath) {
|
||
|
|
Remove-Item $zipPath -Force
|
||
|
|
}
|
||
|
|
|
||
|
|
Add-Type -AssemblyName System.IO.Compression
|
||
|
|
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||
|
|
|
||
|
|
$zip = [System.IO.Compression.ZipFile]::Open($zipPath, [System.IO.Compression.ZipArchiveMode]::Create)
|
||
|
|
try {
|
||
|
|
$files = Get-ChildItem -Path $dir.FullName -Recurse -File
|
||
|
|
foreach ($file in $files) {
|
||
|
|
$relativePath = $file.FullName.Substring($dir.FullName.Length + 1) -replace '\\', '/'
|
||
|
|
[System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zip, $file.FullName, $relativePath) | Out-Null
|
||
|
|
}
|
||
|
|
}
|
||
|
|
finally {
|
||
|
|
$zip.Dispose()
|
||
|
|
}
|
||
|
|
|
||
|
|
Write-Host "Creato $zipPath"
|
||
|
|
}
|