# Checks that the skill CLI is installed and refreshes upstream.json + LICENSES. # Does NOT copy or ship the EXE into the extension package. # Usage: scripts\fetch-cli.ps1 -Name [-CliPath ] param( [Parameter(Mandatory = $true)][string]$Name, [string]$CliPath ) . (Join-Path $PSScriptRoot 'lib.ps1') $dir = Join-Path $SkillsDir $Name $ext = Join-Path $dir 'extension' if (-not (Test-Path (Join-Path $ext 'manifest.json'))) { Write-Host "skills/$Name/extension/manifest.json fehlt." exit 1 } $defaults = @{ 'wordcraft-mcp' = @{ ExeName = 'wordcraft-cli.exe' Default = 'C:\Program Files\WordCraft\wordcraft-cli.exe' Repo = 'https://github.com/storytold/wordcraft' RepoSlug = 'storytold/wordcraft' } 'gridcraft-mcp' = @{ ExeName = 'gridcraft-cli.exe' Default = 'C:\Program Files\GridCraft\gridcraft-cli.exe' Repo = 'https://github.com/storytold/gridcraft' RepoSlug = 'storytold/gridcraft' } 'pdfcraft-mcp' = @{ ExeName = 'pdfcraft-cli.exe' Default = 'C:\Program Files\PdfCraft\pdfcraft-cli.exe' Repo = 'https://github.com/storytold/pdfcraft' RepoSlug = 'storytold/pdfcraft' } 'figcraft-mcp' = @{ ExeName = 'figcraft-cli.exe' Default = 'C:\Program Files\FigCraft\figcraft-cli.exe' Repo = 'https://github.com/storytold/figcraft' RepoSlug = 'storytold/figcraft' } 'vectorcraft-mcp' = @{ ExeName = 'vectorcraft-cli.exe' Default = 'C:\Program Files\VectorCraft\vectorcraft-cli.exe' Repo = 'https://github.com/storytold/vectorcraft' RepoSlug = 'storytold/vectorcraft' } 'solidcraft-mcp' = @{ ExeName = 'solidcraft-cli.exe' Default = 'C:\Program Files\SolidCraft\solidcraft-cli.exe' Repo = 'https://github.com/tangency-labs/solidcraft' RepoSlug = 'tangency-labs/solidcraft' Source = 'SolidCraft-Installer' } 'cadcraft-mcp' = @{ ExeName = 'cadcraft-cli.exe' Default = 'C:\Program Files\CADCraft\cadcraft-cli.exe' Repo = 'https://github.com/storytold/cadcraft' RepoSlug = 'storytold/cadcraft' } 'effectcraft-mcp' = @{ ExeName = 'effectcraft-cli.exe' Default = 'C:\Program Files\EffectCraft\effectcraft-cli.exe' Repo = 'https://github.com/storytold/effectcraft' RepoSlug = 'storytold/effectcraft' } 'filmcraft-mcp' = @{ ExeName = 'filmcraft-cli.exe' Default = 'C:\Program Files\FilmCraft\filmcraft-cli.exe' Repo = 'https://github.com/storytold/filmcraft' RepoSlug = 'storytold/filmcraft' } } if (-not $defaults.ContainsKey($Name)) { Write-Host "Kein CLI-Mapping fuer Skill '$Name'." exit 1 } $meta = $defaults[$Name] $sourceName = 'ArtCraft-Launcher' if ($meta.ContainsKey('Source') -and $meta.Source) { $sourceName = [string]$meta.Source } $src = if ($CliPath) { $CliPath } else { $meta.Default } if (-not (Test-Path -LiteralPath $src)) { Write-Host "CLI fehlt: $src" if ($sourceName -eq 'ArtCraft-Launcher') { Write-Host "Bitte die App ueber den ArtCraft-Launcher installieren, oder -CliPath angeben." } else { Write-Host "Bitte die App ueber den eigenen Installer installieren, oder -CliPath angeben." } exit 1 } # Ensure no EXE is left in the extension package from older builds. $serverDir = Join-Path $ext 'server' New-Item -ItemType Directory -Force -Path $serverDir | Out-Null Get-ChildItem -LiteralPath $serverDir -Filter '*.exe' -ErrorAction SilentlyContinue | Remove-Item -Force $readme = Join-Path $serverDir 'README.txt' if (-not (Test-Path $readme)) { if ($sourceName -eq 'ArtCraft-Launcher') { $installLine = 'Installiere die App ueber den ArtCraft-Launcher.' } else { $installLine = 'Installiere die App ueber den eigenen Installer.' } Write-Text $readme @" Diese Erweiterung enthaelt keine CLI. $installLine Erwarteter Pfad: $src "@ } $verResult = Get-ProcessOutputUtf8 $src '--version' $verOut = $verResult.Output if ($verResult.ExitCode -ne 0 -and $Name -eq 'gridcraft-mcp') { $verResult = Get-ProcessOutputUtf8 $src 'version' $verOut = $verResult.Output } $ver = '' if ($verOut -match '(\d+\.\d+\.\d+)') { $ver = $Matches[1] } if (-not $ver) { Write-Host "Version der CLI nicht lesbar: $verOut" exit 1 } $hash = (Get-FileHash -LiteralPath $src -Algorithm SHA256).Hash.ToLowerInvariant() $upstream = @{ source = $sourceName path = $src exe = $meta.ExeName version = $ver sha256 = $hash repository = $meta.Repo tag = "v$ver" bundled = $false } | ConvertTo-Json -Compress Write-Text (Join-Path $ext 'upstream.json') ($upstream + "`n") $licDir = Join-Path $ext 'LICENSES' New-Item -ItemType Directory -Force -Path $licDir | Out-Null $tag = "v$ver" foreach ($f in @('LICENSE-MIT', 'LICENSE-APACHE', 'NOTICE')) { $url = "https://raw.githubusercontent.com/$($meta.RepoSlug)/$tag/$f" $out = Join-Path $licDir $f try { Invoke-WebRequest -Uri $url -OutFile $out -UseBasicParsing } catch { Write-Host "Lizenzdatei fehlgeschlagen: $url" Write-Host $_ exit 1 } } Write-Host "OK $Name $ver (nicht gebundelt) $src" exit 0