# Palette Code installer for Windows (x64). # # From PowerShell: irm https://llm.pltt.dev/install.ps1 | iex # From cmd.exe: powershell -ExecutionPolicy Bypass -Command "irm https://llm.pltt.dev/install.ps1 | iex" # $env:PALETTE_CODE_VERSION="0.1.2"; irm https://llm.pltt.dev/install.ps1 | iex # # Installs palette-code.exe to %LOCALAPPDATA%\palette-code\bin and adds it to the user PATH. $ErrorActionPreference = "Stop" try { [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 } catch { } $Base = if ($env:PALETTE_CODE_BASE) { $env:PALETTE_CODE_BASE } else { "https://llm.pltt.dev" } $Version = $env:PALETTE_CODE_VERSION $InstallDir = if ($env:PALETTE_CODE_INSTALL_DIR) { $env:PALETTE_CODE_INSTALL_DIR } else { Join-Path $env:LOCALAPPDATA "palette-code\bin" } $arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLower() if ($arch -ne "x64") { Write-Host "palette-code: only windows-x64 is built today (this machine: $arch). Use: npm i -g palette-code" -ForegroundColor Yellow exit 1 } $target = "palette-code-windows-x64" $url = if ($Version) { "$Base/download/$target-$Version.tgz" } else { "$Base/download/$target.tgz" } $tmp = Join-Path ([System.IO.Path]::GetTempPath()) ("palette-code-" + [System.Guid]::NewGuid().ToString("N")) New-Item -ItemType Directory -Force -Path $tmp | Out-Null try { Write-Host "palette-code: downloading $url" Invoke-WebRequest -Uri $url -OutFile (Join-Path $tmp "pc.tgz") -UseBasicParsing & tar -xzf (Join-Path $tmp "pc.tgz") -C $tmp if ($LASTEXITCODE -ne 0) { throw "tar failed (Windows 10 1803+ ships tar.exe)" } $exe = Join-Path $tmp "package\bin\palette-code.exe" if (-not (Test-Path $exe)) { throw "tarball did not contain package\bin\palette-code.exe" } New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null Copy-Item $exe (Join-Path $InstallDir "palette-code.exe") -Force } finally { Remove-Item -Recurse -Force $tmp -ErrorAction SilentlyContinue } $userPath = [Environment]::GetEnvironmentVariable("Path", "User") if (-not (($userPath -split ";") -contains $InstallDir)) { [Environment]::SetEnvironmentVariable("Path", "$userPath;$InstallDir", "User") $env:Path = "$env:Path;$InstallDir" Write-Host "palette-code: added $InstallDir to the user PATH" } $v = & (Join-Path $InstallDir "palette-code.exe") --version 2>$null | Select-Object -First 1 Write-Host "palette-code: installed $v -> $InstallDir\palette-code.exe" -ForegroundColor Magenta # The key, without an environment-variable lesson: ask here and store it as a user variable, which every # later window gets; also set it in this window. Skipped when already set or no console (CI). $saved = [Environment]::GetEnvironmentVariable("PALETTE_API_KEY", "User") if (-not $env:PALETTE_API_KEY -and -not $saved -and $env:PALETTE_CODE_NO_PROMPT -ne "1" -and [Environment]::UserInteractive) { try { $key = Read-Host "Paste your Palette API key and press Enter (or press Enter to add it later)" if ($key -like "pk_*") { [Environment]::SetEnvironmentVariable("PALETTE_API_KEY", $key, "User") $env:PALETTE_API_KEY = $key Write-Host "palette-code: key saved" } elseif ($key) { Write-Host "palette-code: that does not look like a Palette key (they start with pk_). Add it later: setx PALETTE_API_KEY " } } catch { } } Write-Host "" Write-Host "DONE. Type: palette-code" -ForegroundColor Green if (-not $env:PALETTE_API_KEY) { Write-Host "(the first run will ask for your Palette API key)" } Write-Host "help: $Base/docs"