# Install the bino CLI on Windows. # # The Unix counterpart is scripts/bootstrap.sh; both rely on gh for the same reason, which # is that private release assets are served by the REST API and need a token. # # Exit codes: 0 installed, 1 failed, 3 not authorized. #Requires -Version 5.1 $ErrorActionPreference = 'Stop' $Repo = if ($env:BINO_REPO) { $env:BINO_REPO } else { 'Colombino-Universe/binoflow' } $Root = if ($env:BINO_ROOT) { $env:BINO_ROOT } else { Join-Path $env:LOCALAPPDATA 'Bino' } $BinDir = Join-Path $Root 'bin' function Fail($message) { Write-Error $message exit 1 } function Require-Gh { if (-not (Get-Command gh -ErrorAction SilentlyContinue)) { Write-Host 'The GitHub CLI (gh) was not found on PATH.' -ForegroundColor Red Write-Host 'bino downloads its releases from a private repository, which needs a token.' Write-Host "Install gh, run 'gh auth login', then run this script again." exit 3 } gh auth status *> $null if ($LASTEXITCODE -ne 0) { Write-Host 'gh is installed but not authenticated.' -ForegroundColor Red Write-Host "Run 'gh auth login' and try again." exit 3 } } function Get-AssetName { $arch = switch ($env:PROCESSOR_ARCHITECTURE) { 'AMD64' { 'amd64' } 'ARM64' { 'arm64' } default { Fail "Unsupported architecture: $env:PROCESSOR_ARCHITECTURE" } } return "bino_windows_$arch.exe" } function Get-LatestTag { # Filtered here rather than with gh --jq: Windows PowerShell 5.1 drops the double quotes # inside an argument it passes to a native program, so a jq string literal reaches gh # unquoted and fails to parse. The parentheses make 5.1 enumerate the parsed array. $json = gh release list --repo $Repo --limit 100 --json tagName,isDraft if ($LASTEXITCODE -ne 0) { Fail "Could not list the releases of $Repo." } $release = ($json | Out-String | ConvertFrom-Json) | Where-Object { -not $_.isDraft -and $_.tagName.StartsWith('cli-') } | Select-Object -First 1 if (-not $release) { Fail "No cli-* release found in $Repo." } return $release.tagName } function Assert-Checksum($dir, $asset) { $line = Select-String -Path (Join-Path $dir 'SHA256SUMS') -Pattern ([regex]::Escape($asset)) | Select-Object -First 1 if (-not $line) { Fail "SHA256SUMS does not list $asset" } $expected = ($line.Line -split '\s+')[0] $actual = (Get-FileHash -Path (Join-Path $dir $asset) -Algorithm SHA256).Hash if ($expected -ne $actual.ToLower() -and $expected.ToLower() -ne $actual.ToLower()) { Fail "Checksum mismatch for ${asset}: expected $expected, got $actual" } } Require-Gh $asset = Get-AssetName $tag = Get-LatestTag Write-Host "Installing $tag ($asset)" $staging = Join-Path ([System.IO.Path]::GetTempPath()) ([System.Guid]::NewGuid().ToString()) New-Item -ItemType Directory -Path $staging -Force | Out-Null try { gh release download $tag --repo $Repo --dir $staging --pattern $asset --pattern SHA256SUMS --clobber if ($LASTEXITCODE -ne 0) { Fail 'Download failed.' } Assert-Checksum $staging $asset New-Item -ItemType Directory -Path $BinDir -Force | Out-Null Copy-Item -Path (Join-Path $staging $asset) -Destination (Join-Path $BinDir 'bino.exe') -Force # Extend the user PATH, never the machine one: this is a per-user installation. $userPath = [Environment]::GetEnvironmentVariable('Path', 'User') if ($userPath -notlike "*$BinDir*") { [Environment]::SetEnvironmentVariable('Path', "$userPath;$BinDir", 'User') Write-Host "Added $BinDir to your PATH. Open a new terminal for it to take effect." } & (Join-Path $BinDir 'bino.exe') --version Write-Host "Run 'bino' to choose which AI agents receive the shared skills." } finally { Remove-Item -Path $staging -Recurse -Force -ErrorAction SilentlyContinue }