-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
135 lines (116 loc) · 3.92 KB
/
install.ps1
File metadata and controls
135 lines (116 loc) · 3.92 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
#Requires -Version 5.1
<#
.SYNOPSIS
Install clictl on Windows.
.DESCRIPTION
Downloads and installs the latest clictl binary for Windows.
Optionally specify an install directory as the first argument.
.EXAMPLE
irm https://download.clictl.dev/install.ps1 | iex
.EXAMPLE
.\install.ps1 C:\tools
#>
param(
[string]$InstallDir = "$env:LOCALAPPDATA\clictl\bin"
)
$ErrorActionPreference = "Stop"
$Repo = "clictl/cli"
$DownloadBase = "https://download.clictl.dev"
$BinaryName = "clictl.exe"
function Write-Status($msg) { Write-Host " $msg" -ForegroundColor Green }
function Write-Err($msg) { Write-Host " $msg" -ForegroundColor Red }
# Banner
Write-Host ""
Write-Host " clictl installer" -ForegroundColor Green
Write-Host ""
# Detect architecture
$arch = if ([Environment]::Is64BitOperatingSystem) {
if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") { "arm64" } else { "amd64" }
} else {
Write-Err "32-bit Windows is not supported."
exit 1
}
Write-Status "Detected: windows/$arch"
# Get latest release from version manifest (with GitHub API fallback)
Write-Status "Fetching latest release..."
$release = $null
try {
$versionJson = Invoke-RestMethod -Uri "$DownloadBase/version.json" -ErrorAction Stop
$release = $versionJson.version
} catch {}
if (-not $release) {
Write-Status "Falling back to GitHub API..."
try {
$latest = Invoke-RestMethod -Uri "https://api.github.com/repos/$Repo/releases/latest" -ErrorAction Stop
$release = $latest.tag_name
} catch {
Write-Err "Could not fetch latest release."
exit 1
}
}
Write-Status "Latest release: $release"
# Download
$filename = "clictl-windows-$arch.zip"
$downloadUrl = "$DownloadBase/releases/$release/$filename"
$tempZip = Join-Path $env:TEMP $filename
Write-Status "Downloading from $downloadUrl..."
try {
Invoke-WebRequest -Uri $downloadUrl -OutFile $tempZip -ErrorAction Stop
} catch {
Write-Status "Falling back to GitHub Releases..."
$downloadUrl = "https://github.com/$Repo/releases/download/$release/$filename"
try {
Invoke-WebRequest -Uri $downloadUrl -OutFile $tempZip -ErrorAction Stop
} catch {
Write-Err "Failed to download $filename"
exit 1
}
}
# Extract
Write-Status "Extracting..."
$tempExtract = Join-Path $env:TEMP "clictl-extract"
if (Test-Path $tempExtract) { Remove-Item -Recurse -Force $tempExtract }
Expand-Archive -Path $tempZip -DestinationPath $tempExtract -Force
$extractedBinary = Get-ChildItem -Path $tempExtract -Filter $BinaryName -Recurse | Select-Object -First 1
if (-not $extractedBinary) {
Write-Err "Binary not found after extraction."
Remove-Item -Force $tempZip
Remove-Item -Recurse -Force $tempExtract
exit 1
}
# Install
if (-not (Test-Path $InstallDir)) {
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
}
$installPath = Join-Path $InstallDir $BinaryName
Copy-Item -Path $extractedBinary.FullName -Destination $installPath -Force
# Cleanup
Remove-Item -Force $tempZip
Remove-Item -Recurse -Force $tempExtract
Write-Host ""
Write-Status "Installation successful!"
Write-Host ""
Write-Host " Binary: $installPath"
Write-Host " Version: $release"
Write-Host ""
# Check if install dir is in PATH
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($userPath -notlike "*$InstallDir*") {
Write-Host " Adding $InstallDir to your PATH..." -ForegroundColor Yellow
[Environment]::SetEnvironmentVariable(
"Path",
"$userPath;$InstallDir",
"User"
)
$env:Path = "$env:Path;$InstallDir"
Write-Host " Done. Restart your terminal for PATH changes to take effect." -ForegroundColor Yellow
Write-Host ""
}
Write-Host " Register as an agent:" -ForegroundColor Yellow
Write-Host ""
Write-Host " Option 1: Auto-detect and install skill file"
Write-Host " clictl install"
Write-Host ""
Write-Host " Option 2: Add as an MCP server"
Write-Host " clictl install --mcp"
Write-Host ""