feat: added CPU variant support for x64 native addons with AVX2/baseline fallback

- Added CPU variant support for x64 native addons with modern (AVX2/x86-64-v3) and baseline (x86-64-v2) variants, enabling automatic fallback when modern variants are unavailable.
- Added automatic AVX2 CPU detection on Linux, macOS, and Windows platforms to select appropriate native addon variant at runtime.
- Updated native addon filename scheme to include CPU variant suffix (e.g., pi_natives.linux-x64-modern.node) for x64 platforms.
- Updated CLI update mechanism to support downloading and installing multiple native addon variants per platform with fallback support.
- Removed fallback untagged pi_natives.node binary creation; platform and variant-tagged binaries are now required.
This commit is contained in:
can1357
2026-02-16 15:10:24 +00:00
parent 53ad78f7fb
commit a4f845a465
12 changed files with 439 additions and 161 deletions
+11 -8
View File
@@ -20,7 +20,7 @@ $Repo = "can1357/oh-my-pi"
$Package = "@oh-my-pi/pi-coding-agent"
$InstallDir = if ($env:PI_INSTALL_DIR) { $env:PI_INSTALL_DIR } else { "$env:LOCALAPPDATA\omp" }
$BinaryName = "omp-windows-x64.exe"
$NativeAddonName = "pi_natives.win32-x64.node"
$NativeAddonNames = @("pi_natives.win32-x64-modern.node", "pi_natives.win32-x64-baseline.node")
$MinimumBunVersion = "1.3.7"
function Test-BunInstalled {
@@ -263,15 +263,18 @@ function Install-Binary {
$OutPath = Join-Path $InstallDir "omp.exe"
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
# Download native addons
$downloadedNative = 0
foreach ($nativeAddonName in $NativeAddonNames) {
$nativeUrl = "https://github.com/$Repo/releases/download/$Latest/$nativeAddonName"
Write-Host "Downloading $nativeAddonName..."
$nativeOutPath = Join-Path $InstallDir $nativeAddonName
Invoke-WebRequest -Uri $nativeUrl -OutFile $nativeOutPath
$downloadedNative += 1
}
Write-Host ""
Write-Host "✓ Installed omp to $OutPath" -ForegroundColor Green
Write-Host "✓ Installed native addon to $NativeOutPath" -ForegroundColor Green
Write-Host "✓ Installed $downloadedNative native addon file(s) to $InstallDir" -ForegroundColor Green
# Add to PATH if not already there
$UserPath = [Environment]::GetEnvironmentVariable("Path", "User")