-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathinstall.ps1
More file actions
175 lines (150 loc) · 6.86 KB
/
Copy pathinstall.ps1
File metadata and controls
175 lines (150 loc) · 6.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#Requires -Version 5.1
[CmdletBinding()]
param(
[string]$InstallDir = ""
)
$ErrorActionPreference = 'Stop'
$GithubOwner = 'edgee-ai'
$GithubRepo = 'edgee'
$Target = 'x86_64-pc-windows-msvc'
$BinaryName = 'edgee.exe'
# ── Formatting helpers ──────────────────────────────────────────────────────
function Write-Header {
Write-Host ""
Write-Host " " -NoNewline; Write-Host "◢████◤" -ForegroundColor White
Write-Host " " -NoNewline; Write-Host "" -ForegroundColor White
Write-Host " " -NoNewline; Write-Host "◢██████◤" -ForegroundColor White
Write-Host " " -NoNewline; Write-Host "" -ForegroundColor White
Write-Host " " -NoNewline; Write-Host "◢████████◤" -ForegroundColor White
Write-Host ""
Write-Host " Token compression gateway for Claude Code, Codex & Opencode" -ForegroundColor DarkGray
Write-Host " https://www.edgee.ai" -ForegroundColor DarkGray
Write-Host ""
}
function Write-Step([string]$msg) {
Write-Host " " -NoNewline
Write-Host "→" -ForegroundColor Cyan -NoNewline
Write-Host " $msg"
}
function Write-Ok([string]$msg) {
Write-Host " " -NoNewline
Write-Host "✓" -ForegroundColor Green -NoNewline
Write-Host " $msg"
}
function Write-Err([string]$msg) {
Write-Host ""
Write-Host " " -NoNewline
Write-Host "✗ Error:" -ForegroundColor Red -NoNewline
Write-Host " $msg"
Write-Host ""
exit 1
}
# ── Installation logic ──────────────────────────────────────────────────────
function Get-InstallDir {
if ($InstallDir -ne "") { return $InstallDir }
if ($env:INSTALL_DIR -ne $null -and $env:INSTALL_DIR -ne "") { return $env:INSTALL_DIR }
return Join-Path $env:LOCALAPPDATA "Programs\edgee"
}
function Get-LatestVersion {
$apiUrl = "https://api.github.com/repos/$GithubOwner/$GithubRepo/releases/latest"
try {
$response = Invoke-RestMethod -Uri $apiUrl -Headers @{ 'User-Agent' = 'edgee-installer' }
return $response.tag_name
} catch {
Write-Err "Failed to fetch latest release info: $_"
}
}
function Get-Sha256([string]$FilePath) {
$hash = Get-FileHash -Path $FilePath -Algorithm SHA256
return $hash.Hash.ToLower()
}
function Install-Edgee {
Write-Header
$targetInstallDir = Get-InstallDir
$version = Get-LatestVersion
$baseUrl = "https://github.com/$GithubOwner/$GithubRepo/releases/download/$version"
$remoteFile = "edgee.$Target.exe"
$checksumFile = "edgee.$Target.exe.sha256"
Write-Host (" {0,-9} Windows (x86_64)" -f "Platform") -ForegroundColor White
Write-Host (" {0,-9} $targetInstallDir" -f "Directory") -ForegroundColor White
Write-Host ""
$tmpDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName())
New-Item -ItemType Directory -Path $tmpDir | Out-Null
try {
# Download binary
Write-Step "Downloading binary..."
$binaryTmp = Join-Path $tmpDir $BinaryName
try {
Invoke-WebRequest -Uri "$baseUrl/$remoteFile" -OutFile $binaryTmp -UseBasicParsing
} catch {
Write-Err "Failed to download binary: $_"
}
Write-Ok "Binary downloaded"
# Download checksum
Write-Step "Downloading checksum..."
$checksumTmp = Join-Path $tmpDir "edgee.sha256"
try {
Invoke-WebRequest -Uri "$baseUrl/$checksumFile" -OutFile $checksumTmp -UseBasicParsing
} catch {
Write-Err "Failed to download checksum: $_"
}
Write-Ok "Checksum downloaded"
# Verify checksum
Write-Step "Verifying integrity..."
$expected = (Get-Content $checksumTmp).Trim().ToLower()
$actual = Get-Sha256 $binaryTmp
if ($expected -ne $actual) {
Write-Err "Checksum mismatch!`n Expected: $expected`n Got: $actual"
}
Write-Ok "Checksum verified"
# Install binary
Write-Step "Installing to $targetInstallDir..."
if (-not (Test-Path $targetInstallDir)) {
New-Item -ItemType Directory -Path $targetInstallDir -Force | Out-Null
}
$dest = Join-Path $targetInstallDir $BinaryName
Copy-Item -Path $binaryTmp -Destination $dest -Force
$installedVersion = & $dest --version 2>&1
$versionNum = ($installedVersion -split ' ')[1]
Write-Ok "Installed edgee v$versionNum"
} finally {
Remove-Item -Recurse -Force $tmpDir -ErrorAction SilentlyContinue
}
Write-Host ""
Write-Host " ╔═══════════════════════════════════════════════╗"
Write-Host " ║ " -NoNewline
Write-Host ("Edgee v$versionNum installed successfully!") -ForegroundColor Green -NoNewline
Write-Host "$((' ' * [Math]::Max(0, 43 - "Edgee v$versionNum installed successfully!".Length)))║"
Write-Host " ╚═══════════════════════════════════════════════╝"
Write-Host ""
Write-Host " Get started:" -ForegroundColor White
Write-Host ""
Write-Host " " -NoNewline; Write-Host "edgee auth login" -ForegroundColor Cyan -NoNewline
Write-Host " # authenticate with your Edgee account" -ForegroundColor DarkGray
Write-Host " " -NoNewline; Write-Host "edgee launch claude" -ForegroundColor Cyan -NoNewline
Write-Host " # launch Claude Code with token compression" -ForegroundColor DarkGray
Write-Host " " -NoNewline; Write-Host "edgee --help" -ForegroundColor Cyan -NoNewline
Write-Host " # show all available commands" -ForegroundColor DarkGray
Write-Host ""
# Add install dir to PATH permanently (User scope, no admin required)
$registryPath = [System.Environment]::GetEnvironmentVariable('PATH', 'User')
$registryDirs = if ($registryPath) { $registryPath -split ';' } else { @() }
if ($registryDirs -notcontains $targetInstallDir) {
$newPath = ($registryDirs + $targetInstallDir | Where-Object { $_ -ne '' }) -join ';'
[System.Environment]::SetEnvironmentVariable('PATH', $newPath, 'User')
# Also update current session so edgee is usable immediately
$env:PATH = "$env:PATH;$targetInstallDir"
Write-Ok "Added to PATH"
Write-Host ""
Write-Host " " -NoNewline
Write-Host "Open a new terminal" -ForegroundColor Yellow -NoNewline
Write-Host " to use " -NoNewline
Write-Host "edgee" -ForegroundColor Cyan -NoNewline
Write-Host " globally."
Write-Host ""
} else {
Write-Ok "Already in PATH"
Write-Host ""
}
}
Install-Edgee