# ArcFlare CLI installer # irm https://arcflare.net/install.ps1 | iex # # Needs no admin. If Node.js 18+ is missing, a private copy of the current # Node LTS goes into %LOCALAPPDATA%\arcflare\node (checked against nodejs.org's # SHA256 list) and is added to your user PATH. Then llama.cpp, the engine that # runs models, is fetched for this PC with `arcflare engine install` (checked # against the SHA-256 GitHub publishes for the download), unless you have one. # # $env:ARCFLARE_DRY_RUN = "1" show what it would do # $env:ARCFLARE_NO_ENGINE = "1" skip llama.cpp # $env:ARCFLARE_MODEL = "1" also download a model that fits this PC $ErrorActionPreference = "Stop" $DryRun = $env:ARCFLARE_DRY_RUN -eq "1" $NoEngine = $env:ARCFLARE_NO_ENGINE -eq "1" $WithModel = $env:ARCFLARE_MODEL -eq "1" function Test-NodeOk { $node = Get-Command node -ErrorAction SilentlyContinue $npm = Get-Command npm -ErrorAction SilentlyContinue if (-not $node -or -not $npm) { return $false } try { $major = [int](& node -p "process.versions.node.split('.')[0]") } catch { return $false } return $major -ge 18 } function Add-UserPath($dir) { $current = [Environment]::GetEnvironmentVariable("Path", "User") if ($current -and ($current -split ";") -contains $dir) { return } if ($DryRun) { Write-Host " [dry-run] add $dir to your user PATH"; return } $new = if ($current) { "$dir;$current" } else { $dir } [Environment]::SetEnvironmentVariable("Path", $new, "User") Write-Host " added $dir to your user PATH" } if (-not (Test-NodeOk)) { $nodeDir = Join-Path $env:LOCALAPPDATA "arcflare\node" $arch = if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") { "arm64" } else { "x64" } $base = "https://nodejs.org/dist/latest-v22.x" Write-Host "Node.js 18+ not found: installing a private Node LTS into $nodeDir (no admin needed)..." if ($DryRun) { Write-Host " [dry-run] download $base/SHASUMS256.txt and node--win-$arch.zip, verify SHA256, unpack to $nodeDir" } else { $tmp = Join-Path ([IO.Path]::GetTempPath()) ("arcflare-node-" + [guid]::NewGuid()) New-Item -ItemType Directory -Force $tmp | Out-Null $sums = (Invoke-WebRequest "$base/SHASUMS256.txt" -UseBasicParsing).Content $line = ($sums -split "`n") | Where-Object { $_ -match " node-v[0-9.]+-win-$arch\.zip$" } | Select-Object -First 1 if (-not $line) { throw "couldn't find a Node.js build for win-$arch" } $want, $file = ($line.Trim() -split "\s+") $zip = Join-Path $tmp $file Invoke-WebRequest "$base/$file" -OutFile $zip -UseBasicParsing $got = (Get-FileHash $zip -Algorithm SHA256).Hash.ToLower() if ($got -ne $want.ToLower()) { Remove-Item -Recurse -Force $tmp; throw "checksum mismatch for $file" } Expand-Archive $zip -DestinationPath $tmp -Force if (Test-Path $nodeDir) { Remove-Item -Recurse -Force $nodeDir } Move-Item (Join-Path $tmp ($file -replace "\.zip$", "")) $nodeDir Remove-Item -Recurse -Force $tmp Write-Host " Node $(& (Join-Path $nodeDir 'node.exe') -v) installed" } $env:Path = "$nodeDir;$env:Path" Add-UserPath $nodeDir } else { Write-Host "Using Node $(node -v)." } Write-Host "Installing the ArcFlare CLI..." if ($DryRun) { Write-Host " [dry-run] npm install -g https://codeload.github.com/Hakeperty/ArcFlare-Code/tar.gz/refs/heads/main" } else { # npm.cmd, not npm: PowerShell would pick npm.ps1, which a Restricted execution policy refuses to run. & npm.cmd install -g https://codeload.github.com/Hakeperty/ArcFlare-Code/tar.gz/refs/heads/main if ($LASTEXITCODE -ne 0) { throw "npm couldn't install the ArcFlare CLI (exit code $LASTEXITCODE)" } } # llama.cpp: the engine. Without it the CLI installs fine but can't run a model. # A failure here (offline, GitHub rate limit) must not undo the install above. $engine = "ok" if ($NoEngine) { $engine = "skipped" } else { Write-Host "" Write-Host "Getting llama.cpp (the engine that runs models)..." if ($DryRun) { Write-Host " [dry-run] arcflare engine install --if-missing" } else { try { & arcflare.cmd engine install --if-missing if ($LASTEXITCODE -ne 0) { $engine = "failed" } } catch { $engine = "failed" } } } # Opt-in: one model chosen for this PC's free GPU memory. A large download, so # only on request; a failure here doesn't undo the install. $model = "skipped" if ($WithModel) { Write-Host "" Write-Host "Picking a model that fits this PC..." if ($DryRun) { Write-Host " [dry-run] arcflare shop best"; $model = "ok" } else { try { & arcflare.cmd shop best $model = if ($LASTEXITCODE -eq 0) { "ok" } else { "failed" } } catch { $model = "failed" } } } Write-Host "" Write-Host "ArcFlare installed." -ForegroundColor Green if ($engine -eq "skipped") { Write-Host "llama.cpp was skipped. Get it any time with: arcflare engine install" } if ($engine -eq "failed") { Write-Host "llama.cpp didn't download (the CLI itself is fine). Try again with: arcflare engine install" } if ($model -eq "failed") { Write-Host "The model didn't download (the CLI itself is fine). Try again with: arcflare shop best" } if ((Get-ExecutionPolicy) -in "Restricted", "AllSigned") { Write-Host "This PowerShell blocks scripts, so type arcflare.cmd instead of arcflare, or allow your own scripts once with:" Write-Host " Set-ExecutionPolicy -Scope CurrentUser RemoteSigned" } Write-Host "Next (open a new terminal first if Node was just installed):" if ($model -ne "ok") { Write-Host " arcflare shop best download a model that fits your GPU (or: arcflare shop, to choose)" } Write-Host " arcflare doctor check your GPU and engine"