-
Notifications
You must be signed in to change notification settings - Fork 192
Expand file tree
/
Copy pathinstall.ps1
More file actions
131 lines (120 loc) · 4.81 KB
/
install.ps1
File metadata and controls
131 lines (120 loc) · 4.81 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
$repo = "iOfficeAI/OfficeCli"
$asset = "officecli-win-x64.exe"
$binary = "officecli.exe"
$source = $null
# Step 1: Try downloading from GitHub
$url = "https://github.com/$repo/releases/latest/download/$asset"
$checksumUrl = "https://github.com/$repo/releases/latest/download/SHA256SUMS"
$tempFile = "$env:TEMP\$binary"
Write-Host "Downloading OfficeCli..."
try {
Invoke-WebRequest -Uri $url -OutFile $tempFile
# Verify checksum if available
$checksumOk = $false
try {
$checksumFile = "$env:TEMP\officecli-SHA256SUMS"
Invoke-WebRequest -Uri $checksumUrl -OutFile $checksumFile
$checksumContent = Get-Content $checksumFile
$expectedLine = $checksumContent | Where-Object { $_ -match $asset }
if ($expectedLine) {
$expected = ($expectedLine -split '\s+')[0]
$actual = (Get-FileHash -Path $tempFile -Algorithm SHA256).Hash.ToLower()
if ($expected -eq $actual) {
$checksumOk = $true
Write-Host "Checksum verified."
} else {
Write-Host "Checksum mismatch! Expected: $expected, Got: $actual"
Remove-Item -Force $tempFile, $checksumFile -ErrorAction SilentlyContinue
exit 1
}
}
Remove-Item -Force $checksumFile -ErrorAction SilentlyContinue
} catch {
Write-Host "Checksum file not available, skipping verification."
}
$output = & $tempFile --version 2>&1
if ($LASTEXITCODE -eq 0) {
$source = $tempFile
Write-Host "Download verified."
} else {
Write-Host "Downloaded file is not a valid OfficeCli binary."
Remove-Item -Force $tempFile -ErrorAction SilentlyContinue
}
} catch {
Write-Host "Download failed."
}
# Step 2: Fallback to local files
if (-not $source) {
Write-Host "Looking for local binary..."
$candidates = @(".\$asset", ".\$binary", ".\bin\$asset", ".\bin\$binary", ".\bin\release\$asset", ".\bin\release\$binary")
foreach ($candidate in $candidates) {
if (Test-Path $candidate) {
$output = & $candidate --version 2>&1
if ($LASTEXITCODE -eq 0) {
$source = $candidate
Write-Host "Found valid binary at $candidate"
break
}
}
}
}
if (-not $source) {
Write-Host "Error: Could not find a valid OfficeCli binary."
Write-Host "Download manually from: https://github.com/$repo/releases"
exit 1
}
# Step 3: Install
$existing = Get-Command $binary -ErrorAction SilentlyContinue
if ($existing) {
$installDir = Split-Path $existing.Source
Write-Host "Found existing installation at $($existing.Source), upgrading..."
} else {
$installDir = "$env:LOCALAPPDATA\OfficeCli"
}
New-Item -ItemType Directory -Force -Path $installDir | Out-Null
Copy-Item -Force $source "$installDir\$binary"
Remove-Item -Force $tempFile -ErrorAction SilentlyContinue
# Add to PATH if not already there
$currentPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($currentPath -notlike "*$installDir*") {
[Environment]::SetEnvironmentVariable("Path", "$currentPath;$installDir", "User")
Write-Host "Added $installDir to PATH (restart your terminal to take effect)."
}
# Step 4: Install AI agent skills (first install only)
$skillMarker = "$installDir\.officecli-skills-installed"
if (-not (Test-Path $skillMarker)) {
$skillTargets = @()
$tools = @{
"$env:USERPROFILE\.claude" = "Claude Code"
"$env:USERPROFILE\.copilot" = "GitHub Copilot"
"$env:USERPROFILE\.agents" = "Codex CLI"
"$env:USERPROFILE\.cursor" = "Cursor"
"$env:USERPROFILE\.windsurf" = "Windsurf"
"$env:USERPROFILE\.minimax" = "MiniMax CLI"
"$env:USERPROFILE\.openclaw" = "OpenClaw"
"$env:USERPROFILE\.nanobot\workspace" = "NanoBot"
"$env:USERPROFILE\.zeroclaw\workspace" = "ZeroClaw"
}
foreach ($dir in $tools.Keys) {
if (Test-Path $dir) {
$skillTargets += "$dir\skills\officecli"
Write-Host "$($tools[$dir]) detected."
}
}
if ($skillTargets.Count -gt 0) {
Write-Host "Downloading officecli skill..."
$tempSkill = "$env:TEMP\officecli-skill.md"
try {
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/$repo/main/SKILL.md" -OutFile $tempSkill
foreach ($target in $skillTargets) {
New-Item -ItemType Directory -Force -Path $target | Out-Null
Copy-Item -Force $tempSkill "$target\SKILL.md"
Write-Host " Installed: $target\SKILL.md"
}
Remove-Item -Force $tempSkill -ErrorAction SilentlyContinue
} catch {}
}
New-Item -ItemType File -Force -Path $skillMarker | Out-Null
}
Write-Host "OfficeCli installed successfully!"
Write-Host "Run 'officecli --help' to get started."