-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
72 lines (69 loc) · 3.79 KB
/
install.ps1
File metadata and controls
72 lines (69 loc) · 3.79 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
#!/usr/bin/env pwsh
# eximagent installer for Windows (PowerShell).
# Usage:
# irm https://install.eximagent.ai/install.ps1 | iex
# $env:EXIMAGENT_VERSION='v0.0.37'; irm https://install.eximagent.ai/install.ps1 | iex
$ErrorActionPreference = 'Stop'
$repo = 'EximAgent/cli'
$installDir = if ($env:EXIMAGENT_INSTALL_DIR) { $env:EXIMAGENT_INSTALL_DIR } else { Join-Path $env:USERPROFILE '.eximagent\bin' }
$arch = if ([System.Environment]::Is64BitOperatingSystem) { 'amd64' } else { throw '[eximagent] only 64-bit Windows is supported' }
$target = "windows-${arch}.exe"
if ($env:EXIMAGENT_VERSION) {
$tag = $env:EXIMAGENT_VERSION
} else {
$latest = Invoke-RestMethod -Uri "https://api.github.com/repos/${repo}/releases/latest" -Headers @{ 'User-Agent' = 'eximagent-installer' }
$tag = $latest.tag_name
if (-not $tag) { throw '[eximagent] could not resolve latest release tag' }
}
$url = "https://github.com/${repo}/releases/download/${tag}/eximagent-${target}"
New-Item -ItemType Directory -Force -Path $installDir | Out-Null
$dest = Join-Path $installDir 'eximagent.exe'
Write-Host "[eximagent] fetching ${target} from ${tag}..."
Invoke-WebRequest -Uri $url -OutFile $dest -UseBasicParsing
$userPath = [Environment]::GetEnvironmentVariable('Path', 'User')
if (-not ($userPath -split ';' | Where-Object { $_ -ieq $installDir })) {
[Environment]::SetEnvironmentVariable('Path', "${userPath};${installDir}", 'User')
Write-Host "[eximagent] added ${installDir} to user PATH"
}
# Expose to the current process so chained `; eximagent login` works without restarting the shell.
if (-not ($env:Path -split ';' | Where-Object { $_ -ieq $installDir })) {
$env:Path = "${env:Path};${installDir}"
}
Write-Host "[eximagent] installed -> ${dest}"
# Self-check: binary version must match the tag we just resolved.
# Catches "release mirrored to wrong repo" / "stale CDN" / "PAT lost write" silent-stale failures.
$installedVersion = (& $dest --version 2>&1 | Select-Object -First 1).Trim()
if ($installedVersion -like "*${tag}*" -or $installedVersion -like "*$($tag.TrimStart('v'))*") {
Write-Host "[eximagent] version OK ($installedVersion matches ${tag})"
} else {
Write-Host "[eximagent] !! VERSION MISMATCH: binary reports '$installedVersion', expected '${tag}'."
Write-Host "[eximagent] !! The release on github.com/${repo} is out of sync with the source repo."
Write-Host "[eximagent] !! Report this to the EximAgent team with the line above."
}
if ($env:EXIMAGENT_NO_LOGIN -ne '1') {
Write-Host '[eximagent] starting login (opt out with $env:EXIMAGENT_NO_LOGIN=1)...'
& $dest login
}
# Drop SKILL.md to host-agent directories (parity with the prior npm postinstall behaviour).
# Skip with $env:EXIMAGENT_NO_SKILL='1'; override source with $env:EXIMAGENT_SKILL_URL.
if ($env:EXIMAGENT_NO_SKILL -ne '1') {
$skillUrl = if ($env:EXIMAGENT_SKILL_URL) { $env:EXIMAGENT_SKILL_URL } else { 'https://go-api.eximagent.ai/api/cli/skill' }
try {
$skill = (Invoke-WebRequest -Uri $skillUrl -UseBasicParsing -Headers @{ 'User-Agent' = 'eximagent-installer' }).Content
$home_ = $env:USERPROFILE
$targets = @(
@{ Path = (Join-Path $home_ '.claude\skills\eximagent\SKILL.md'); Label = 'Claude Code' },
@{ Path = (Join-Path $home_ '.codex\skills\eximagent\SKILL.md'); Label = 'Codex' },
@{ Path = (Join-Path $home_ '.cursor\rules\eximagent.mdc'); Label = 'Cursor' },
@{ Path = (Join-Path $home_ '.agents\skills\eximagent\SKILL.md'); Label = 'Universal' }
)
foreach ($t in $targets) {
$dir = Split-Path $t.Path
New-Item -ItemType Directory -Force -Path $dir | Out-Null
Set-Content -Path $t.Path -Value $skill -NoNewline
Write-Host "[eximagent] skill -> $($t.Label): $($t.Path)"
}
} catch {
Write-Host "[eximagent] could not fetch skill from ${skillUrl} (skip with EXIMAGENT_NO_SKILL=1)"
}
}