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:
@@ -1,22 +1,29 @@
|
||||
# Test binary build from local source
|
||||
FROM debian:bookworm-slim
|
||||
|
||||
RUN apt-get update && apt-get install -y curl ca-certificates unzip && rm -rf /var/lib/apt/lists/*
|
||||
RUN apt-get update && apt-get install -y curl ca-certificates unzip build-essential && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install bun
|
||||
RUN curl -fsSL https://bun.sh/install | bash
|
||||
ENV PATH="/root/.bun/bin:$PATH"
|
||||
|
||||
# Install Rust
|
||||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly
|
||||
ENV PATH="/root/.cargo/bin:$PATH"
|
||||
|
||||
# Copy local repo
|
||||
WORKDIR /repo
|
||||
COPY . .
|
||||
|
||||
# Build binary
|
||||
# Build native addon and binary
|
||||
RUN bun install --frozen-lockfile
|
||||
RUN bun --cwd=packages/natives run build:native
|
||||
RUN cd packages/coding-agent && bun run build:binary
|
||||
|
||||
# Install binary to PATH
|
||||
RUN mkdir -p /root/.local/bin && cp packages/coding-agent/dist/omp /root/.local/bin/
|
||||
# Install binary and native addon to PATH
|
||||
RUN mkdir -p /root/.local/bin && \
|
||||
cp packages/coding-agent/dist/omp /root/.local/bin/ && \
|
||||
cp packages/natives/native/pi_natives.linux-x64.node /root/.local/bin/
|
||||
ENV PATH="/root/.local/bin:$PATH"
|
||||
|
||||
# Verify
|
||||
|
||||
@@ -1,18 +1,23 @@
|
||||
# Test --source install from local repo
|
||||
FROM debian:bookworm-slim
|
||||
|
||||
RUN apt-get update && apt-get install -y curl ca-certificates unzip && rm -rf /var/lib/apt/lists/*
|
||||
RUN apt-get update && apt-get install -y curl ca-certificates unzip build-essential && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install bun
|
||||
RUN curl -fsSL https://bun.sh/install | bash
|
||||
ENV PATH="/root/.bun/bin:$PATH"
|
||||
|
||||
# Install Rust (needed to build native addon)
|
||||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly
|
||||
ENV PATH="/root/.cargo/bin:$PATH"
|
||||
|
||||
# Copy local repo
|
||||
WORKDIR /repo
|
||||
COPY . .
|
||||
|
||||
# Install dependencies and link globally
|
||||
# Install dependencies, build native addon, and link globally
|
||||
RUN bun install --frozen-lockfile
|
||||
RUN bun --cwd=packages/natives run build:native
|
||||
RUN cd packages/coding-agent && bun link
|
||||
|
||||
# Verify
|
||||
|
||||
@@ -2,12 +2,16 @@
|
||||
# Uses verdaccio as local registry to test full publish/install cycle
|
||||
FROM debian:bookworm-slim
|
||||
|
||||
RUN apt-get update && apt-get install -y curl ca-certificates unzip jq procps && rm -rf /var/lib/apt/lists/*
|
||||
RUN apt-get update && apt-get install -y curl ca-certificates unzip jq procps build-essential && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install bun
|
||||
RUN curl -fsSL https://bun.sh/install | bash
|
||||
ENV PATH="/root/.bun/bin:$PATH"
|
||||
|
||||
# Install Rust (needed to build native addon)
|
||||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly
|
||||
ENV PATH="/root/.cargo/bin:$PATH"
|
||||
|
||||
# Install Node.js (needed for verdaccio and npm)
|
||||
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
|
||||
&& apt-get install -y nodejs \
|
||||
@@ -22,6 +26,7 @@ COPY . .
|
||||
|
||||
# Build the project
|
||||
RUN bun install --frozen-lockfile
|
||||
RUN bun --cwd=packages/natives run build:native
|
||||
|
||||
# Create verdaccio config (allow anonymous publish)
|
||||
RUN mkdir -p /root/.config/verdaccio && cat > /root/.config/verdaccio/config.yaml <<'EOF'
|
||||
@@ -63,7 +68,7 @@ RUN cat > /repo/scripts/publish-local.sh <<'SCRIPT'
|
||||
set -e
|
||||
|
||||
REGISTRY="http://localhost:4873"
|
||||
PACKAGES=(utils ai agent tui stats coding-agent)
|
||||
PACKAGES=(utils natives ai agent tui stats coding-agent)
|
||||
|
||||
# Build version map from all package.json files
|
||||
declare -A VERSION_MAP
|
||||
|
||||
+13
-5
@@ -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")
|
||||
|
||||
+12
-5
@@ -200,6 +200,7 @@ install_binary() {
|
||||
esac
|
||||
|
||||
BINARY="omp-${PLATFORM}-${ARCH}"
|
||||
NATIVE_ADDON="pi_natives.${PLATFORM}-${ARCH}.node"
|
||||
|
||||
# Get release tag
|
||||
if [ -n "$REF" ]; then
|
||||
@@ -222,16 +223,22 @@ install_binary() {
|
||||
fi
|
||||
echo "Using version: $LATEST"
|
||||
|
||||
# Download binary
|
||||
URL="https://github.com/${REPO}/releases/download/${LATEST}/${BINARY}"
|
||||
echo "Downloading ${BINARY}..."
|
||||
|
||||
mkdir -p "$INSTALL_DIR"
|
||||
curl -fsSL "$URL" -o "${INSTALL_DIR}/omp"
|
||||
|
||||
# Download binary
|
||||
BINARY_URL="https://github.com/${REPO}/releases/download/${LATEST}/${BINARY}"
|
||||
echo "Downloading ${BINARY}..."
|
||||
curl -fsSL "$BINARY_URL" -o "${INSTALL_DIR}/omp"
|
||||
chmod +x "${INSTALL_DIR}/omp"
|
||||
|
||||
# Download native addon
|
||||
NATIVE_URL="https://github.com/${REPO}/releases/download/${LATEST}/${NATIVE_ADDON}"
|
||||
echo "Downloading ${NATIVE_ADDON}..."
|
||||
curl -fsSL "$NATIVE_URL" -o "${INSTALL_DIR}/${NATIVE_ADDON}"
|
||||
|
||||
echo ""
|
||||
echo "✓ Installed omp to ${INSTALL_DIR}/omp"
|
||||
echo "✓ Installed native addon to ${INSTALL_DIR}/${NATIVE_ADDON}"
|
||||
|
||||
# Check if in PATH
|
||||
case ":$PATH:" in
|
||||
|
||||
Reference in New Issue
Block a user