diff --git a/package.json b/package.json index 3c91e7f8b..ce16c9d57 100644 --- a/package.json +++ b/package.json @@ -39,9 +39,9 @@ "*.{js,ts,jsx,tsx,json,jsonc,css}": "biome check --write --no-errors-on-unmatched" }, "engines": { - "bun": ">=1.2.0" + "bun": ">=1.3.7" }, - "packageManager": "bun@1.3.6", + "packageManager": "bun@1.3.7", "version": "0.0.3", "dependencies": { "@sinclair/typebox": "^0.34.46" diff --git a/packages/coding-agent/package.json b/packages/coding-agent/package.json index 188ba809e..1373ef012 100644 --- a/packages/coding-agent/package.json +++ b/packages/coding-agent/package.json @@ -127,6 +127,6 @@ "directory": "packages/coding-agent" }, "engines": { - "bun": ">=1.0.0" + "bun": ">=1.3.7" } } diff --git a/scripts/install.ps1 b/scripts/install.ps1 index b6101772e..9f42f99d9 100644 --- a/scripts/install.ps1 +++ b/scripts/install.ps1 @@ -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" +$MinimumBunVersion = "1.3.7" function Test-BunInstalled { try { @@ -30,6 +31,41 @@ function Test-BunInstalled { } } +function Get-BunVersion { + try { + $versionText = (bun --version 2>$null) + if (-not $versionText) { + return $null + } + + $clean = $versionText.Trim().Split("-")[0] + return [version]$clean + } catch { + return $null + } +} + +function Test-BunVersion { + param([string]$MinimumVersion) + + $currentVersion = Get-BunVersion + if (-not $currentVersion) { + return $false + } + + return $currentVersion -ge [version]$MinimumVersion +} + +function Assert-BunVersion { + param([string]$MinimumVersion) + + if (-not (Test-BunVersion $MinimumVersion)) { + $current = Get-BunVersion + $currentText = if ($current) { $current.ToString() } else { "unknown" } + throw "Bun $MinimumVersion or newer is required. Current version: $currentText. Upgrade Bun at https://bun.sh/docs/installation" + } +} + function Test-GitInstalled { try { $null = Get-Command git -ErrorAction Stop @@ -129,6 +165,7 @@ function Install-Bun { irm bun.sh/install.ps1 | iex # Refresh PATH $env:Path = [System.Environment]::GetEnvironmentVariable("Path", "User") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "Machine") + Assert-BunVersion $MinimumBunVersion } function Install-ViaBun { @@ -254,12 +291,14 @@ if ($Source) { if (-not (Test-BunInstalled)) { Install-Bun } + Assert-BunVersion $MinimumBunVersion Install-ViaBun } elseif ($Binary) { Install-Binary } else { # Default: use bun if available, otherwise binary if (Test-BunInstalled) { + Assert-BunVersion $MinimumBunVersion Install-ViaBun } else { Install-Binary diff --git a/scripts/install.sh b/scripts/install.sh index 56f21538b..2581d6b09 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -13,6 +13,7 @@ set -e REPO="can1357/oh-my-pi" PACKAGE="@oh-my-pi/pi-coding-agent" INSTALL_DIR="${OMP_INSTALL_DIR:-$HOME/.local/bin}" +MIN_BUN_VERSION="1.3.7" # Parse arguments MODE="" @@ -70,6 +71,48 @@ has_bun() { command -v bun >/dev/null 2>&1 } +version_ge() { + current="$1" + minimum="$2" + + IFS=. set -- $current + current_major=${1:-0} + current_minor=${2:-0} + current_patch=${3:-0} + + IFS=. set -- $minimum + minimum_major=${1:-0} + minimum_minor=${2:-0} + minimum_patch=${3:-0} + + if [ "$current_major" -ne "$minimum_major" ]; then + [ "$current_major" -gt "$minimum_major" ] + return $? + fi + + if [ "$current_minor" -ne "$minimum_minor" ]; then + [ "$current_minor" -gt "$minimum_minor" ] + return $? + fi + + [ "$current_patch" -ge "$minimum_patch" ] +} + +require_bun_version() { + version_raw=$(bun --version 2>/dev/null || true) + if [ -z "$version_raw" ]; then + echo "Failed to read bun version" + exit 1 + fi + + version_clean=${version_raw%%-*} + if ! version_ge "$version_clean" "$MIN_BUN_VERSION"; then + echo "Bun ${MIN_BUN_VERSION} or newer is required. Current version: ${version_clean}" + echo "Upgrade Bun at https://bun.sh/docs/installation" + exit 1 + fi +} + # Check if git is available has_git() { command -v git >/dev/null 2>&1 @@ -86,6 +129,7 @@ install_bun() { fi export BUN_INSTALL="$HOME/.bun" export PATH="$BUN_INSTALL/bin:$PATH" + require_bun_version } # Check if git-lfs is available @@ -202,6 +246,7 @@ case "$MODE" in if ! has_bun; then install_bun fi + require_bun_version install_via_bun ;; binary) @@ -210,6 +255,7 @@ case "$MODE" in *) # Default: use bun if available, otherwise binary if has_bun; then + require_bun_version install_via_bun else install_binary