# Autoclank CLI Installer for Windows # Usage: iwr -useb http://your-server/tools/install.ps1 | iex $ErrorActionPreference = "Stop" # Server URL - will be replaced by the server when served, or use env var $ServerUrl = if ($env:AUTOCLANK_SERVER_URL) { $env:AUTOCLANK_SERVER_URL } else { "{{SERVER_URL}}" } $BinaryName = "autoclank.exe" $InstallDir = "$env:LOCALAPPDATA\Programs\autoclank" function Write-Info { param($msg) Write-Host "[INFO] $msg" -ForegroundColor Green } function Write-Warn { param($msg) Write-Host "[WARN] $msg" -ForegroundColor Yellow } function Write-Err { param($msg) Write-Host "[ERROR] $msg" -ForegroundColor Red; exit 1 } function Get-Platform { $arch = [System.Environment]::GetEnvironmentVariable("PROCESSOR_ARCHITECTURE") switch ($arch) { "AMD64" { return "windows_amd64" } "ARM64" { return "windows_arm64" } default { Write-Err "Unsupported architecture: $arch" } } } function Install-Binary { param($Platform) $downloadUrl = "$ServerUrl/tools/binaries/autoclank_$Platform.exe" $tmpDir = Join-Path $env:TEMP "autoclank-install" # Create temp directory New-Item -ItemType Directory -Force -Path $tmpDir | Out-Null Write-Info "Downloading from $downloadUrl..." try { Invoke-WebRequest -Uri $downloadUrl -OutFile (Join-Path $tmpDir $BinaryName) } catch { Write-Err "Download failed. Make sure the server has binaries available at $downloadUrl" } # Create install directory New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null Write-Info "Installing to $InstallDir..." Move-Item -Path (Join-Path $tmpDir $BinaryName) -Destination $InstallDir -Force # Cleanup Remove-Item -Recurse -Force $tmpDir Write-Info "Installed $BinaryName to $InstallDir" } function Add-ToPath { $currentPath = [Environment]::GetEnvironmentVariable("Path", "User") if ($currentPath -notlike "*$InstallDir*") { Write-Info "Adding $InstallDir to PATH..." [Environment]::SetEnvironmentVariable("Path", "$currentPath;$InstallDir", "User") $env:Path = "$env:Path;$InstallDir" Write-Info "Added to PATH. Restart your terminal for changes to take effect." } else { Write-Info "$InstallDir already in PATH" } } function Test-ClaudeCLI { Write-Info "Checking for Claude Code CLI..." try { $version = npx @anthropic-ai/claude-code --version 2>$null if ($version) { Write-Info "Claude Code CLI found: $version" } else { Write-Warn "Claude Code CLI not found. Install with: npm install -g @anthropic-ai/claude-code" } } catch { Write-Warn "npx not found. Install Node.js to use Claude Code CLI" } } function Test-Installation { $binaryPath = Join-Path $InstallDir $BinaryName if (Test-Path $binaryPath) { Write-Info "Installation verified!" & $binaryPath version } else { Write-Warn "Binary not found at $binaryPath" } } function Main { Write-Host "================================" -ForegroundColor Cyan Write-Host " Autoclank CLI Installer" -ForegroundColor Cyan Write-Host "================================" -ForegroundColor Cyan Write-Host "" $platform = Get-Platform Write-Info "Detected platform: $platform" Install-Binary -Platform $platform Add-ToPath Test-ClaudeCLI Test-Installation Write-Host "" Write-Info "Installation complete!" Write-Host "" Write-Host "Get started:" Write-Host " autoclank init # Initialize in a project" Write-Host " autoclank agent test # Test Claude Code connection" Write-Host " autoclank help # Show all commands" } Main