# SummonAI Kit CLI Installer for Windows # Usage: iwr -useb https://cli.summonaikit.com/install.ps1 | iex $ErrorActionPreference = "Stop" $ReleasesUrl = if ($env:SUMMONAIKIT_RELEASES_URL) { $env:SUMMONAIKIT_RELEASES_URL } else { "https://cli.summonaikit.com" } $InstallDir = if ($env:SUMMONAIKIT_INSTALL_DIR) { $env:SUMMONAIKIT_INSTALL_DIR } else { "$env:LOCALAPPDATA\SummonAIKit\bin" } function Write-Banner { Write-Host "" Write-Host "=================================" -ForegroundColor Green Write-Host " SummonAI Kit CLI Installer" -ForegroundColor Cyan Write-Host "=================================" -ForegroundColor Green Write-Host "" } function Write-Info { param([string]$Message) Write-Host "-> " -ForegroundColor Blue -NoNewline Write-Host $Message } function Write-Success { param([string]$Message) Write-Host "[OK] " -ForegroundColor Green -NoNewline Write-Host $Message } function Write-Warn { param([string]$Message) Write-Host "[!] " -ForegroundColor Yellow -NoNewline Write-Host $Message } function Write-Err { param([string]$Message) Write-Host "[X] " -ForegroundColor Red -NoNewline Write-Host $Message exit 1 } function Get-BinaryName { $arch = $env:PROCESSOR_ARCHITECTURE switch ($arch) { "ARM64" { return "summonaikit-windows-arm64.exe" } "AMD64" { return "summonaikit-windows-x64.exe" } "x86" { return "summonaikit-windows-x64.exe" } # Use x64 binary for x86 too default { Write-Err "Unsupported architecture: $arch" } } } function Add-ToPath { param([string]$Directory) $currentPath = [Environment]::GetEnvironmentVariable("Path", "User") if ($currentPath -split ";" | Where-Object { $_ -eq $Directory }) { Write-Success "PATH already configured" return $false } $newPath = "$currentPath;$Directory" [Environment]::SetEnvironmentVariable("Path", $newPath, "User") # Also update current session $env:Path = "$env:Path;$Directory" Write-Success "Added to PATH: $Directory" return $true } function Main { Write-Banner # Detect platform Write-Info "Detecting platform..." $binary = Get-BinaryName Write-Success "Binary: $binary" # Create install directory Write-Info "Creating install directory: $InstallDir" if (-not (Test-Path $InstallDir)) { New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null } Write-Success "Directory ready" # Download binary $dest = Join-Path $InstallDir "summonaikit.exe" $url = "$ReleasesUrl/cli/latest/$binary" Write-Info "Downloading from $url..." try { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 Invoke-WebRequest -Uri $url -OutFile $dest -UseBasicParsing Write-Success "Downloaded successfully" } catch { if ($binary -eq "summonaikit-windows-arm64.exe") { Write-Warn "ARM64 binary unavailable, falling back to x64 binary" $binary = "summonaikit-windows-x64.exe" $url = "$ReleasesUrl/cli/latest/$binary" Write-Info "Downloading fallback from $url..." try { Invoke-WebRequest -Uri $url -OutFile $dest -UseBasicParsing Write-Success "Downloaded fallback successfully" } catch { Write-Err "Failed to download fallback binary: $_" } } else { Write-Err "Failed to download: $_" } } # Add to PATH Write-Info "Setting up PATH..." $pathChanged = Add-ToPath -Directory $InstallDir if ($pathChanged) { Write-Warn "Please restart your terminal for PATH changes to take effect" } Write-Host "" Write-Host "=================================" -ForegroundColor Green Write-Host " Installation complete!" -ForegroundColor Cyan Write-Host "=================================" -ForegroundColor Green Write-Host "" Write-Host " Binary installed to: $dest" Write-Host "" Write-Host " Get started:" Write-Host " summonaikit # Start the CLI" Write-Host " summonaikit help # Show help" Write-Host " summonaikit update # Update to latest" Write-Host "" # Verify installation try { $version = & $dest --version 2>&1 Write-Success "Installed: $version" } catch { Write-Warn "Could not verify installation" } } Main