feat(natives): added native addon distribution and platform validation to CLI update mechanism

- Added native addon distribution and installation support to the CLI update mechanism, enabling platform-specific native modules to be downloaded and installed alongside the main binary.
- Added platform validation in native addon loader to verify supported platforms (linux-x64, linux-arm64, darwin-x64, darwin-arm64, win32-x64) with helpful error messages for unsupported configurations.
- Enhanced native addon loading error messages to provide platform-specific troubleshooting guidance for both npm/bun installations and local development environments.
- Updated installation scripts (install.sh, install.ps1) to download and install native addon files alongside the main binary during CLI installation.
This commit is contained in:
can1357
2026-02-01 05:17:06 +01:00
parent 67fcf85518
commit 1e52c837c8
10 changed files with 130 additions and 24 deletions
+13 -5
View File
@@ -20,6 +20,7 @@ $Repo = "can1357/oh-my-pi"
$Package = "@oh-my-pi/pi-coding-agent"
$InstallDir = if ($env:OMP_INSTALL_DIR) { $env:OMP_INSTALL_DIR } else { "$env:LOCALAPPDATA\omp" }
$BinaryName = "omp-windows-x64.exe"
$NativeAddonName = "pi_natives.win32-x64.node"
$MinimumBunVersion = "1.3.7"
function Test-BunInstalled {
@@ -254,16 +255,23 @@ function Install-Binary {
}
Write-Host "Using version: $Latest"
# Download binary
$Url = "https://github.com/$Repo/releases/download/$Latest/$BinaryName"
Write-Host "Downloading $BinaryName..."
New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
# Download binary
$BinaryUrl = "https://github.com/$Repo/releases/download/$Latest/$BinaryName"
Write-Host "Downloading $BinaryName..."
$OutPath = Join-Path $InstallDir "omp.exe"
Invoke-WebRequest -Uri $Url -OutFile $OutPath
Invoke-WebRequest -Uri $BinaryUrl -OutFile $OutPath
# Download native addon
$NativeUrl = "https://github.com/$Repo/releases/download/$Latest/$NativeAddonName"
Write-Host "Downloading $NativeAddonName..."
$NativeOutPath = Join-Path $InstallDir $NativeAddonName
Invoke-WebRequest -Uri $NativeUrl -OutFile $NativeOutPath
Write-Host ""
Write-Host "✓ Installed omp to $OutPath" -ForegroundColor Green
Write-Host "✓ Installed native addon to $NativeOutPath" -ForegroundColor Green
# Add to PATH if not already there
$UserPath = [Environment]::GetEnvironmentVariable("Path", "User")