# Installs (or updates) Nibi for the current Windows user. No admin needed. # # irm https://niranjand.in/nibi/install.ps1 | iex # # What it does: reads latest.json from the public releases repo # (github.com/Niranjan266/nibi-releases), downloads that version's installer to # %TEMP%, checks it, runs it silently for you only, and starts Nibi. # Nothing else is downloaded and nothing is sent anywhere. & { $ErrorActionPreference = 'Stop' $repo = 'https://github.com/Niranjan266/nibi-releases' $latestUrl = "$repo/releases/latest/download/latest.json" function Say([string]$text, [string]$color = 'Gray') { Write-Host " $text" -ForegroundColor $color } function Fail([string]$text) { Write-Host '' Write-Host " Nibi was not installed: $text" -ForegroundColor Red Write-Host " You can always download the installer from $repo/releases/latest" -ForegroundColor Gray Write-Host '' } Write-Host '' Write-Host ' Nibi installer' -ForegroundColor Magenta Write-Host ' A small friend on your desktop that watches your AI agents.' -ForegroundColor Gray Write-Host '' if ($env:OS -ne 'Windows_NT' -or -not [Environment]::Is64BitOperatingSystem) { Fail 'Nibi needs 64-bit Windows 10 or 11.' return } # Windows PowerShell 5.1 may default to old TLS versions; GitHub needs TLS 1.2. try { [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 } catch { } $oldProgress = $ProgressPreference $ProgressPreference = 'SilentlyContinue' # the progress bar makes downloads much slower in 5.1 try { Say 'Looking for the latest version...' try { $latest = Invoke-RestMethod -Uri $latestUrl -UseBasicParsing -TimeoutSec 30 } catch { Fail "could not read $latestUrl ($($_.Exception.Message))." return } $version = [string]$latest.version $url = [string]$latest.platforms.'windows-x86_64'.url if ($version -notmatch '^\d+\.\d+\.\d+$' -or -not $url) { Fail 'latest.json did not look right.' return } $expected = "Nibi_${version}_x64-setup.exe" $prefix = "$repo/releases/download/" if (-not $url.StartsWith($prefix, [StringComparison]::OrdinalIgnoreCase) -or [IO.Path]::GetFileName(([Uri]$url).AbsolutePath) -ne $expected) { Fail "the download link was not the expected $expected from $repo." return } Say "Latest version: $version" 'Green' $installed = Get-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\Nibi' -ErrorAction SilentlyContinue if ($installed -and $installed.DisplayVersion) { if ($installed.DisplayVersion -eq $version) { Say "Nibi $version is already installed; installing it again." } else { Say "Updating Nibi $($installed.DisplayVersion) to $version. Your rules, history and hooks are kept." } } $file = Join-Path ([IO.Path]::GetTempPath()) $expected Say "Downloading $expected..." try { Invoke-WebRequest -Uri $url -OutFile $file -UseBasicParsing -TimeoutSec 600 } catch { Fail "the download failed ($($_.Exception.Message))." return } $info = Get-Item -LiteralPath $file -ErrorAction SilentlyContinue if (-not $info -or $info.Name -ne $expected -or $info.Length -lt 1MB) { Fail 'the downloaded file was missing or too small.' Remove-Item -LiteralPath $file -ErrorAction SilentlyContinue return } Say ('Downloaded {0:N1} MB.' -f ($info.Length / 1MB)) 'Green' Say 'Installing for you only (no admin prompt)...' $p = Start-Process -FilePath $file -ArgumentList '/S' -Wait -PassThru Remove-Item -LiteralPath $file -ErrorAction SilentlyContinue if ($p.ExitCode -ne 0) { Fail "the installer stopped with code $($p.ExitCode)." return } $exe = Join-Path $env:LOCALAPPDATA 'Nibi\nibi.exe' if (Test-Path -LiteralPath $exe) { Say "Nibi $version is installed." 'Green' Say 'Starting Nibi. Look for it on your taskbar.' Start-Process -FilePath $exe } else { Say "Nibi $version is installed. Start it from the Start menu." 'Green' } Write-Host '' Say 'To remove it later: Settings > Apps > Nibi, or' Say 'irm https://niranjand.in/nibi/uninstall.ps1 | iex' Write-Host '' } finally { $ProgressPreference = $oldProgress } }