# VibePod Installation Scripts

---

## Overview

VibePod provides multiple installation methods:

| Method | Command | Best For |
|--------|---------|----------|
| pipx | `pipx install vibepod` | Python developers |
| curl (binary) | `curl ... \| bash` | Quick install, no Python |
| pip | `pip install vibepod` | Virtual environments |
| Homebrew | `brew install vibepod/tap/vp` | macOS users |

---

## Unix Install Script

### `scripts/install.sh`

Served at: `https://vibepod.dev/install.sh`

```bash
#!/bin/bash
#
# VibePod Installation Script
# https://vibepod.dev
#
# Usage:
#   curl -fsSL https://vibepod.dev/install.sh | bash
#   curl -fsSL https://vibepod.dev/install.sh | bash -s -- --version v1.0.0
#   curl -fsSL https://vibepod.dev/install.sh | bash -s -- --binary
#
# Environment:
#   VIBEPOD_INSTALL_DIR   Installation directory (default: ~/.local/bin)
#   VIBEPOD_NO_MODIFY_PATH  Don't modify PATH in shell rc

set -e

# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

# Defaults
VERSION="${VIBEPOD_VERSION:-latest}"
INSTALL_DIR="${VIBEPOD_INSTALL_DIR:-$HOME/.local/bin}"
INSTALL_METHOD="auto"  # auto, pipx, binary
REPO="VibePod/vibepod"
GITHUB_URL="https://github.com/$REPO"

# Parse arguments
while [[ $# -gt 0 ]]; do
    case $1 in
        --version|-v)
            VERSION="$2"
            shift 2
            ;;
        --dir|-d)
            INSTALL_DIR="$2"
            shift 2
            ;;
        --binary|-b)
            INSTALL_METHOD="binary"
            shift
            ;;
        --pipx|-p)
            INSTALL_METHOD="pipx"
            shift
            ;;
        --help|-h)
            echo "VibePod Installation Script"
            echo ""
            echo "Usage: curl -fsSL https://vibepod.dev/install.sh | bash [options]"
            echo ""
            echo "Options:"
            echo "  --version, -v VERSION   Install specific version (default: latest)"
            echo "  --dir, -d DIR           Installation directory (default: ~/.local/bin)"
            echo "  --binary, -b            Install standalone binary"
            echo "  --pipx, -p              Install via pipx"
            echo "  --help, -h              Show this help"
            exit 0
            ;;
        *)
            echo "Unknown option: $1"
            exit 1
            ;;
    esac
done

info() {
    echo -e "${BLUE}==>${NC} $1"
}

success() {
    echo -e "${GREEN}==>${NC} $1"
}

warn() {
    echo -e "${YELLOW}Warning:${NC} $1"
}

error() {
    echo -e "${RED}Error:${NC} $1"
    exit 1
}

# Detect OS and architecture
detect_platform() {
    OS="$(uname -s)"
    ARCH="$(uname -m)"
    
    case "$OS" in
        Linux*)
            PLATFORM="linux"
            ;;
        Darwin*)
            PLATFORM="darwin"
            ;;
        CYGWIN*|MINGW*|MSYS*)
            PLATFORM="windows"
            ;;
        *)
            error "Unsupported operating system: $OS"
            ;;
    esac
    
    case "$ARCH" in
        x86_64|amd64)
            ARCH="amd64"
            ;;
        arm64|aarch64)
            ARCH="arm64"
            ;;
        *)
            error "Unsupported architecture: $ARCH"
            ;;
    esac
    
    BINARY_NAME="vp-${PLATFORM}-${ARCH}"
    if [ "$PLATFORM" = "windows" ]; then
        BINARY_NAME="${BINARY_NAME}.exe"
    fi
}

# Check if command exists
has() {
    command -v "$1" >/dev/null 2>&1
}

# Determine installation method
determine_method() {
    if [ "$INSTALL_METHOD" != "auto" ]; then
        return
    fi
    
    if has pipx; then
        INSTALL_METHOD="pipx"
        info "Found pipx, will use: pipx install vibepod"
    elif has pip3; then
        INSTALL_METHOD="pip"
        info "Found pip3, will use: pip3 install --user vibepod"
    elif has pip; then
        INSTALL_METHOD="pip"
        info "Found pip, will use: pip install --user vibepod"
    else
        INSTALL_METHOD="binary"
        info "Python not found, will install standalone binary"
    fi
}

# Install via pipx
install_pipx() {
    info "Installing via pipx..."
    
    if [ "$VERSION" = "latest" ]; then
        pipx install vibepod
    else
        pipx install "vibepod==${VERSION#v}"
    fi
    
    success "VibePod installed via pipx"
}

# Install via pip
install_pip() {
    info "Installing via pip..."
    
    PIP_CMD="pip3"
    if ! has pip3; then
        PIP_CMD="pip"
    fi
    
    if [ "$VERSION" = "latest" ]; then
        $PIP_CMD install --user vibepod
    else
        $PIP_CMD install --user "vibepod==${VERSION#v}"
    fi
    
    success "VibePod installed via pip"
    
    # Check if ~/.local/bin is in PATH
    if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then
        warn "~/.local/bin is not in your PATH"
        echo "Add this to your shell config:"
        echo "  export PATH=\"\$HOME/.local/bin:\$PATH\""
    fi
}

# Install standalone binary
install_binary() {
    info "Installing standalone binary..."
    
    detect_platform
    
    # Create install directory
    mkdir -p "$INSTALL_DIR"
    
    # Determine download URL
    if [ "$VERSION" = "latest" ]; then
        DOWNLOAD_URL="$GITHUB_URL/releases/latest/download/$BINARY_NAME"
    else
        DOWNLOAD_URL="$GITHUB_URL/releases/download/$VERSION/$BINARY_NAME"
    fi
    
    info "Downloading from $DOWNLOAD_URL"
    
    # Download
    TEMP_FILE=$(mktemp)
    if has curl; then
        curl -fsSL "$DOWNLOAD_URL" -o "$TEMP_FILE"
    elif has wget; then
        wget -q "$DOWNLOAD_URL" -O "$TEMP_FILE"
    else
        error "Neither curl nor wget found"
    fi
    
    # Install
    mv "$TEMP_FILE" "$INSTALL_DIR/vp"
    chmod +x "$INSTALL_DIR/vp"
    
    success "VibePod binary installed to $INSTALL_DIR/vp"
    
    # Check PATH
    if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
        warn "$INSTALL_DIR is not in your PATH"
        add_to_path
    fi
}

# Add to PATH
add_to_path() {
    if [ -n "$VIBEPOD_NO_MODIFY_PATH" ]; then
        echo "Add this to your shell config:"
        echo "  export PATH=\"$INSTALL_DIR:\$PATH\""
        return
    fi
    
    # Detect shell
    SHELL_NAME=$(basename "$SHELL")
    RC_FILE=""
    
    case "$SHELL_NAME" in
        bash)
            if [ -f "$HOME/.bashrc" ]; then
                RC_FILE="$HOME/.bashrc"
            elif [ -f "$HOME/.bash_profile" ]; then
                RC_FILE="$HOME/.bash_profile"
            fi
            ;;
        zsh)
            RC_FILE="$HOME/.zshrc"
            ;;
        fish)
            RC_FILE="$HOME/.config/fish/config.fish"
            ;;
    esac
    
    if [ -n "$RC_FILE" ]; then
        echo "" >> "$RC_FILE"
        echo "# VibePod" >> "$RC_FILE"
        if [ "$SHELL_NAME" = "fish" ]; then
            echo "set -gx PATH $INSTALL_DIR \$PATH" >> "$RC_FILE"
        else
            echo "export PATH=\"$INSTALL_DIR:\$PATH\"" >> "$RC_FILE"
        fi
        info "Added $INSTALL_DIR to PATH in $RC_FILE"
        echo "Run 'source $RC_FILE' or restart your shell"
    else
        echo "Add this to your shell config:"
        echo "  export PATH=\"$INSTALL_DIR:\$PATH\""
    fi
}

# Install shell completions
install_completions() {
    info "Installing shell completions..."
    
    # This will be done by the CLI itself
    if has vp; then
        vp --install-completion 2>/dev/null || true
    fi
}

# Verify installation
verify() {
    if has vp; then
        VERSION_OUTPUT=$(vp version 2>/dev/null || echo "unknown")
        success "VibePod installed successfully!"
        echo ""
        echo "  Version: $VERSION_OUTPUT"
        echo ""
        echo "Get started:"
        echo "  vp run claude        # Start Claude"
        echo "  vp --help            # Show help"
        echo ""
        echo "Documentation: https://vibepod.dev/docs"
    else
        warn "Installation completed but 'vp' not found in PATH"
        echo "You may need to restart your shell or add the install directory to PATH"
    fi
}

# Main
main() {
    echo ""
    echo -e "${GREEN}VibePod${NC} - One CLI for all AI coding agents"
    echo "https://vibepod.dev"
    echo ""
    
    # Check Docker
    if ! has docker; then
        warn "Docker not found. VibePod requires Docker to run agents."
        echo "Install Docker: https://docs.docker.com/get-docker/"
        echo ""
    fi
    
    determine_method
    
    case "$INSTALL_METHOD" in
        pipx)
            install_pipx
            ;;
        pip)
            install_pip
            ;;
        binary)
            install_binary
            ;;
        *)
            error "Unknown installation method: $INSTALL_METHOD"
            ;;
    esac
    
    install_completions
    verify
}

main
```

---

## Windows Install Script

### `scripts/install.ps1`

Served at: `https://vibepod.dev/install.ps1`

```powershell
#Requires -Version 5.1
<#
.SYNOPSIS
    VibePod Installation Script for Windows
.DESCRIPTION
    Installs VibePod CLI tool
.PARAMETER Version
    Version to install (default: latest)
.PARAMETER InstallDir
    Installation directory (default: $env:LOCALAPPDATA\Programs\vibepod)
.PARAMETER Method
    Installation method: auto, pipx, binary (default: auto)
.EXAMPLE
    irm https://vibepod.dev/install.ps1 | iex
.EXAMPLE
    & { irm https://vibepod.dev/install.ps1 } -Version v1.0.0
#>

param(
    [string]$Version = "latest",
    [string]$InstallDir = "$env:LOCALAPPDATA\Programs\vibepod",
    [ValidateSet("auto", "pipx", "binary")]
    [string]$Method = "auto"
)

$ErrorActionPreference = "Stop"

$Repo = "VibePod/vibepod"
$GithubUrl = "https://github.com/$Repo"

function Write-Info {
    param([string]$Message)
    Write-Host "==> " -ForegroundColor Blue -NoNewline
    Write-Host $Message
}

function Write-Success {
    param([string]$Message)
    Write-Host "==> " -ForegroundColor Green -NoNewline
    Write-Host $Message
}

function Write-Warn {
    param([string]$Message)
    Write-Host "Warning: " -ForegroundColor Yellow -NoNewline
    Write-Host $Message
}

function Test-Command {
    param([string]$Command)
    $null -ne (Get-Command $Command -ErrorAction SilentlyContinue)
}

function Get-InstallMethod {
    if ($Method -ne "auto") {
        return $Method
    }
    
    if (Test-Command "pipx") {
        Write-Info "Found pipx, will use: pipx install vibepod"
        return "pipx"
    }
    elseif (Test-Command "pip") {
        Write-Info "Found pip, will use: pip install vibepod"
        return "pip"
    }
    else {
        Write-Info "Python not found, will install standalone binary"
        return "binary"
    }
}

function Install-WithPipx {
    Write-Info "Installing via pipx..."
    
    if ($Version -eq "latest") {
        pipx install vibepod
    }
    else {
        $ver = $Version -replace '^v', ''
        pipx install "vibepod==$ver"
    }
    
    Write-Success "VibePod installed via pipx"
}

function Install-WithPip {
    Write-Info "Installing via pip..."
    
    if ($Version -eq "latest") {
        pip install vibepod
    }
    else {
        $ver = $Version -replace '^v', ''
        pip install "vibepod==$ver"
    }
    
    Write-Success "VibePod installed via pip"
}

function Install-Binary {
    Write-Info "Installing standalone binary..."
    
    # Create install directory
    if (-not (Test-Path $InstallDir)) {
        New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
    }
    
    # Determine architecture
    $arch = if ([Environment]::Is64BitOperatingSystem) { "amd64" } else { "386" }
    $binaryName = "vp-windows-$arch.exe"
    
    # Determine download URL
    if ($Version -eq "latest") {
        $downloadUrl = "$GithubUrl/releases/latest/download/$binaryName"
    }
    else {
        $downloadUrl = "$GithubUrl/releases/download/$Version/$binaryName"
    }
    
    Write-Info "Downloading from $downloadUrl"
    
    # Download
    $outFile = Join-Path $InstallDir "vp.exe"
    Invoke-WebRequest -Uri $downloadUrl -OutFile $outFile -UseBasicParsing
    
    Write-Success "VibePod binary installed to $outFile"
    
    # Add to PATH
    Add-ToPath
}

function Add-ToPath {
    $currentPath = [Environment]::GetEnvironmentVariable("Path", "User")
    
    if ($currentPath -notlike "*$InstallDir*") {
        Write-Info "Adding $InstallDir to PATH..."
        
        $newPath = "$InstallDir;$currentPath"
        [Environment]::SetEnvironmentVariable("Path", $newPath, "User")
        
        # Update current session
        $env:Path = "$InstallDir;$env:Path"
        
        Write-Info "Added to PATH. You may need to restart your terminal."
    }
}

function Test-Installation {
    if (Test-Command "vp") {
        $version = & vp version 2>$null
        Write-Success "VibePod installed successfully!"
        Write-Host ""
        Write-Host "Get started:"
        Write-Host "  vp run claude        # Start Claude"
        Write-Host "  vp --help            # Show help"
        Write-Host ""
        Write-Host "Documentation: https://vibepod.dev/docs"
    }
    else {
        Write-Warn "Installation completed but 'vp' not found in PATH"
        Write-Host "You may need to restart your terminal"
    }
}

# Main
Write-Host ""
Write-Host "VibePod" -ForegroundColor Green -NoNewline
Write-Host " - One CLI for all AI coding agents"
Write-Host "https://vibepod.dev"
Write-Host ""

# Check Docker
if (-not (Test-Command "docker")) {
    Write-Warn "Docker not found. VibePod requires Docker Desktop to run agents."
    Write-Host "Install Docker Desktop: https://docs.docker.com/desktop/windows/"
    Write-Host ""
}

$installMethod = Get-InstallMethod

switch ($installMethod) {
    "pipx" { Install-WithPipx }
    "pip" { Install-WithPip }
    "binary" { Install-Binary }
}

Test-Installation
```

---

## Homebrew Formula

### `homebrew-tap/Formula/vp.rb`

Repository: `VibePod/homebrew-tap`

```ruby
class Vp < Formula
  desc "One CLI for all AI coding agents"
  homepage "https://vibepod.dev"
  version "1.0.0"
  license "MIT"

  on_macos do
    on_arm do
      url "https://github.com/VibePod/vibepod/releases/download/v#{version}/vp-darwin-arm64"
      sha256 "REPLACE_WITH_SHA256"
    end
    on_intel do
      url "https://github.com/VibePod/vibepod/releases/download/v#{version}/vp-darwin-amd64"
      sha256 "REPLACE_WITH_SHA256"
    end
  end

  on_linux do
    on_arm do
      url "https://github.com/VibePod/vibepod/releases/download/v#{version}/vp-linux-arm64"
      sha256 "REPLACE_WITH_SHA256"
    end
    on_intel do
      url "https://github.com/VibePod/vibepod/releases/download/v#{version}/vp-linux-amd64"
      sha256 "REPLACE_WITH_SHA256"
    end
  end

  depends_on "docker" => :recommended

  def install
    binary_name = "vp-#{OS.kernel_name.downcase}-#{Hardware::CPU.arch}"
    bin.install binary_name => "vp"
  end

  test do
    assert_match "VibePod", shell_output("#{bin}/vp version")
  end
end
```

Usage:
```bash
brew tap vibepod/tap
brew install vp
```

---

## Uninstall Script

### `scripts/uninstall.sh`

```bash
#!/bin/bash
# VibePod Uninstall Script

set -e

echo "Uninstalling VibePod..."

# Remove via pipx
if command -v pipx &>/dev/null; then
    pipx uninstall vibepod 2>/dev/null || true
fi

# Remove via pip
if command -v pip &>/dev/null; then
    pip uninstall -y vibepod 2>/dev/null || true
fi
if command -v pip3 &>/dev/null; then
    pip3 uninstall -y vibepod 2>/dev/null || true
fi

# Remove binary
for dir in "$HOME/.local/bin" "/usr/local/bin"; do
    if [ -f "$dir/vp" ]; then
        rm -f "$dir/vp"
        echo "Removed $dir/vp"
    fi
done

# Remove config (optional)
read -p "Remove configuration (~/.config/vibepod)? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
    rm -rf "$HOME/.config/vibepod"
    echo "Removed ~/.config/vibepod"
fi

# Remove Docker images (optional)
read -p "Remove Docker images (vibepod/*)? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
    docker images --format '{{.Repository}}:{{.Tag}}' | grep '^vibepod/' | xargs -r docker rmi
    echo "Removed VibePod Docker images"
fi

echo "VibePod uninstalled."
```
