|
| 1 | +<# |
| 2 | +.SYNOPSIS |
| 3 | +OMNI - Universal Windows Install Script |
| 4 | +
|
| 5 | +.DESCRIPTION |
| 6 | +Installs the latest OMNI binary to $HOME\.local\bin\omni.exe. |
| 7 | +Supports: Windows (x86_64) |
| 8 | +
|
| 9 | +.EXAMPLE |
| 10 | +irm https://raw.githubusercontent.com/fajarhide/omni/main/scripts/install.ps1 | iex |
| 11 | +#> |
| 12 | + |
| 13 | +$ErrorActionPreference = "Stop" |
| 14 | + |
| 15 | +$Repo = "fajarhide/omni" |
| 16 | +$InstallDir = if ($env:OMNI_INSTALL_DIR) { $env:OMNI_INSTALL_DIR } else { "$env:USERPROFILE\.local\bin" } |
| 17 | +$Version = if ($env:OMNI_VERSION) { $env:OMNI_VERSION } else { "latest" } |
| 18 | + |
| 19 | +Write-Host "" |
| 20 | +Write-Host " ┌─────────────────────────────────────┐" -ForegroundColor Cyan |
| 21 | +Write-Host " │ OMNI Installer │" -ForegroundColor Cyan |
| 22 | +Write-Host " │ Less noise. More signal. │" -ForegroundColor Cyan |
| 23 | +Write-Host " └─────────────────────────────────────┘" -ForegroundColor Cyan |
| 24 | +Write-Host "" |
| 25 | + |
| 26 | +# --- Version Resolution --- |
| 27 | +if ($Version -eq "latest") { |
| 28 | + Write-Host "[omni] Fetching latest version from GitHub..." -ForegroundColor Cyan |
| 29 | + try { |
| 30 | + $ReleaseInfo = Invoke-RestMethod -Uri "https://api.github.com/repos/$Repo/releases/latest" |
| 31 | + $Version = $ReleaseInfo.tag_name |
| 32 | + } catch { |
| 33 | + Write-Error "[omni] Failed to fetch latest version from GitHub." |
| 34 | + exit 1 |
| 35 | + } |
| 36 | +} |
| 37 | + |
| 38 | +$Platform = "x86_64-pc-windows-msvc" |
| 39 | +$TargetUrl = "https://github.com/$Repo/releases/download/$Version/omni-$Version-$Platform.zip" |
| 40 | +$TmpDir = Join-Path $env:TEMP "omni_install_$([guid]::NewGuid().ToString().Substring(0,8))" |
| 41 | +$ZipFile = Join-Path $TmpDir "omni.zip" |
| 42 | + |
| 43 | +Write-Host "[omni] Platform: $Platform" -ForegroundColor Cyan |
| 44 | +Write-Host "[omni] Version: $Version" -ForegroundColor Cyan |
| 45 | +Write-Host "[omni] Target: $InstallDir\omni.exe" -ForegroundColor Cyan |
| 46 | +Write-Host "" |
| 47 | + |
| 48 | +# --- Download & Install --- |
| 49 | +if (-not (Test-Path $TmpDir)) { |
| 50 | + New-Item -ItemType Directory -Force -Path $TmpDir | Out-Null |
| 51 | +} |
| 52 | + |
| 53 | +Write-Host "[omni] Downloading omni $Version for $Platform..." -ForegroundColor Cyan |
| 54 | +try { |
| 55 | + Invoke-WebRequest -Uri $TargetUrl -OutFile $ZipFile |
| 56 | +} catch { |
| 57 | + Write-Error "[omni] Download failed. Check if version $Version exists at: $TargetUrl" |
| 58 | + exit 1 |
| 59 | +} |
| 60 | + |
| 61 | +Write-Host "[omni] Extracting archive..." -ForegroundColor Cyan |
| 62 | +Expand-Archive -Path $ZipFile -DestinationPath $TmpDir -Force |
| 63 | + |
| 64 | +if (-not (Test-Path $InstallDir)) { |
| 65 | + New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null |
| 66 | +} |
| 67 | + |
| 68 | +$ExtractedExe = Join-Path $TmpDir "omni.exe" |
| 69 | +if (-not (Test-Path $ExtractedExe)) { |
| 70 | + Write-Error "[omni] Extract failed: omni.exe not found in downloaded archive." |
| 71 | + exit 1 |
| 72 | +} |
| 73 | + |
| 74 | +Copy-Item -Path $ExtractedExe -Destination "$InstallDir\omni.exe" -Force |
| 75 | + |
| 76 | +# --- Cleanup --- |
| 77 | +Remove-Item -Path $TmpDir -Recurse -Force | Out-Null |
| 78 | + |
| 79 | +Write-Host "" |
| 80 | +Write-Host "[omni] ✓ OMNI installed to $InstallDir\omni.exe" -ForegroundColor Green |
| 81 | + |
| 82 | +# --- Verify --- |
| 83 | +try { |
| 84 | + $ExeVersion = & "$InstallDir\omni.exe" version |
| 85 | + Write-Host "[omni] Verified: $ExeVersion" -ForegroundColor Green |
| 86 | +} catch { |
| 87 | + Write-Host "[omni] Unable to verify executable easily." -ForegroundColor Yellow |
| 88 | +} |
| 89 | + |
| 90 | +# --- PATH Check --- |
| 91 | +$UserPath = [Environment]::GetEnvironmentVariable("Path", "User") |
| 92 | +if ($UserPath -notmatch [regex]::Escape($InstallDir)) { |
| 93 | + Write-Host "" |
| 94 | + Write-Host "[omni] $InstallDir is not in your PATH." -ForegroundColor Yellow |
| 95 | + Write-Host "[omni] Adding $InstallDir to your User PATH..." -ForegroundColor Cyan |
| 96 | + |
| 97 | + $NewPath = "$UserPath;$InstallDir" |
| 98 | + [Environment]::SetEnvironmentVariable("Path", $NewPath, "User") |
| 99 | + |
| 100 | + Write-Host "[omni] ✓ PATH updated successfully." -ForegroundColor Green |
| 101 | + Write-Host "[omni] IMPORTANT: You must restart your terminal or open a new PowerShell window to use the 'omni' command." -ForegroundColor Yellow |
| 102 | +} |
| 103 | + |
| 104 | +Write-Host "" |
| 105 | +Write-Host " Next steps:" |
| 106 | +Write-Host " omni init --hook # Activate Claude Code hooks" |
| 107 | +Write-Host " omni doctor # Verify installation" |
| 108 | +Write-Host " omni stats # View savings after first session" |
| 109 | +Write-Host "" |
0 commit comments