feat(coding-agent): added self-update command with bundled templates
- Added `pi update` command for checking and installing CLI updates from GitHub releases or bun. - Added cross-platform installer scripts (shell and PowerShell) with automatic PATH configuration. - Changed HTML export to use compile-time bundled templates via Bun macros. - Changed `exportToHtml` and `exportFromFile` functions to async operations.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
# Pi Coding Agent Installer for Windows
|
||||
# Usage: irm https://raw.githubusercontent.com/can1357/oh-my-pi/main/scripts/install.ps1 | iex
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$Repo = "can1357/oh-my-pi"
|
||||
$InstallDir = if ($env:PI_INSTALL_DIR) { $env:PI_INSTALL_DIR } else { "$env:LOCALAPPDATA\pi" }
|
||||
$Binary = "pi-windows-x64.exe"
|
||||
|
||||
# Get latest release
|
||||
Write-Host "Fetching latest release..."
|
||||
$Release = Invoke-RestMethod -Uri "https://api.github.com/repos/$Repo/releases/latest"
|
||||
$Latest = $Release.tag_name
|
||||
Write-Host "Latest version: $Latest"
|
||||
|
||||
# Download binary
|
||||
$Url = "https://github.com/$Repo/releases/download/$Latest/$Binary"
|
||||
Write-Host "Downloading $Binary..."
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
|
||||
$OutPath = Join-Path $InstallDir "pi.exe"
|
||||
Invoke-WebRequest -Uri $Url -OutFile $OutPath
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Installed pi to $OutPath"
|
||||
|
||||
# Add to PATH if not already there
|
||||
$UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
|
||||
if ($UserPath -notlike "*$InstallDir*") {
|
||||
Write-Host "Adding $InstallDir to PATH..."
|
||||
[Environment]::SetEnvironmentVariable("Path", "$UserPath;$InstallDir", "User")
|
||||
Write-Host "Restart your terminal, then run 'pi' to get started!"
|
||||
} else {
|
||||
Write-Host "Run 'pi' to get started!"
|
||||
}
|
||||
Executable
+52
@@ -0,0 +1,52 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# Pi Coding Agent Installer
|
||||
# Usage: curl -fsSL https://raw.githubusercontent.com/can1357/oh-my-pi/main/scripts/install.sh | sh
|
||||
|
||||
REPO="can1357/oh-my-pi"
|
||||
INSTALL_DIR="${PI_INSTALL_DIR:-$HOME/.local/bin}"
|
||||
|
||||
# Detect platform
|
||||
OS="$(uname -s)"
|
||||
ARCH="$(uname -m)"
|
||||
|
||||
case "$OS" in
|
||||
Linux) PLATFORM="linux" ;;
|
||||
Darwin) PLATFORM="darwin" ;;
|
||||
*) echo "Unsupported OS: $OS"; exit 1 ;;
|
||||
esac
|
||||
|
||||
case "$ARCH" in
|
||||
x86_64|amd64) ARCH="x64" ;;
|
||||
arm64|aarch64) ARCH="arm64" ;;
|
||||
*) echo "Unsupported architecture: $ARCH"; exit 1 ;;
|
||||
esac
|
||||
|
||||
BINARY="pi-${PLATFORM}-${ARCH}"
|
||||
|
||||
# Get latest release tag
|
||||
echo "Fetching latest release..."
|
||||
LATEST=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')
|
||||
if [ -z "$LATEST" ]; then
|
||||
echo "Failed to fetch latest release"
|
||||
exit 1
|
||||
fi
|
||||
echo "Latest 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}/pi"
|
||||
chmod +x "${INSTALL_DIR}/pi"
|
||||
|
||||
echo ""
|
||||
echo "Installed pi to ${INSTALL_DIR}/pi"
|
||||
|
||||
# Check if in PATH
|
||||
case ":$PATH:" in
|
||||
*":$INSTALL_DIR:"*) echo "Run 'pi' to get started!" ;;
|
||||
*) echo "Add ${INSTALL_DIR} to your PATH, then run 'pi'" ;;
|
||||
esac
|
||||
Reference in New Issue
Block a user