-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
78 lines (65 loc) · 2.69 KB
/
install.ps1
File metadata and controls
78 lines (65 loc) · 2.69 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
# agenttrace Windows installer (PowerShell)
# Usage: powershell -ExecutionPolicy Bypass -File install.ps1
# Or: iwr -useb https://raw.githubusercontent.com/luoyuctl/agenttrace/master/install.ps1 | iex
param(
[string]$Version = "latest",
[string]$InstallDir = "$env:LOCALAPPDATA\agenttrace"
)
$REPO = "luoyuctl/agenttrace"
$BIN = "agenttrace.exe"
# Detect architecture
$ARCH = switch ([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture) {
"X64" { "amd64" }
"Arm64" { "arm64" }
default { throw "Unsupported architecture: $_" }
}
Write-Host "🔍 Fetching latest release..." -ForegroundColor Cyan
if ($Version -eq "latest") {
$release = Invoke-RestMethod -Uri "https://api.github.com/repos/$REPO/releases/latest"
$Version = $release.tag_name
$assets = $release.assets | Where-Object { $_.name -eq "agenttrace-windows-${ARCH}.exe" }
} else {
$assets = Invoke-RestMethod -Uri "https://api.github.com/repos/$REPO/releases/tags/$Version" |
Select-Object -ExpandProperty assets |
Where-Object { $_.name -eq "agenttrace-windows-${ARCH}.exe" }
}
if (-not $assets) {
Write-Host "❌ No binary found for windows/${ARCH}" -ForegroundColor Red
Write-Host " Build from source: git clone https://github.com/$REPO.git && cd agenttrace && go build -ldflags='-s -w' -o agenttrace.exe ./cmd/agenttrace/"
exit 1
}
$asset = $assets | Select-Object -First 1
$url = $asset.browser_download_url
Write-Host "⬇️ Downloading agenttrace (windows/${ARCH})..." -ForegroundColor Cyan
Write-Host " $url"
# Create install directory
New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
$DEST = Join-Path $InstallDir $BIN
# Download
$tmp = [System.IO.Path]::GetTempFileName()
try {
Invoke-WebRequest -Uri $url -OutFile $tmp
$size = (Get-Item $tmp).Length
Write-Host " Binary size: $size bytes"
Move-Item -Force $tmp $DEST
Write-Host "✅ Installed to $DEST" -ForegroundColor Green
} catch {
Write-Host "❌ Download failed: $_" -ForegroundColor Red
exit 1
} finally {
if (Test-Path $tmp) { Remove-Item $tmp -Force }
}
# PATH check
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($userPath -notlike "*$InstallDir*") {
Write-Host ""
Write-Host "⚠️ $InstallDir is not in your PATH." -ForegroundColor Yellow
Write-Host " Run this to add it:"
Write-Host ' [Environment]::SetEnvironmentVariable("Path", "$env:LOCALAPPDATA\agenttrace;$env:PATH", "User")'
Write-Host " Then restart your terminal."
Write-Host ""
}
Write-Host ""
Write-Host "🎉 agenttrace installed! Try:" -ForegroundColor Cyan
Write-Host " agenttrace --latest"
Write-Host " agenttrace # launch TUI"