mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-05-08 10:09:30 +00:00
Aider is the most popular open-source AI pair programming CLI. Natively supports OpenRouter via OPENROUTER_API_KEY env var and --model openrouter/... flag. - sprite/aider.sh, hetzner/aider.sh, digitalocean/aider.sh - Matrix now 4 agents x 3 clouds = 12/12 implemented Co-authored-by: Sprite <noreply@sprite.dev> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
68 lines
1.8 KiB
Bash
Executable file
68 lines
1.8 KiB
Bash
Executable file
#!/bin/bash
|
|
set -e
|
|
|
|
# Source common functions - try local file first, fall back to remote
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)"
|
|
if [[ -f "$SCRIPT_DIR/lib/common.sh" ]]; then
|
|
source "$SCRIPT_DIR/lib/common.sh"
|
|
else
|
|
source <(curl -fsSL https://raw.githubusercontent.com/OpenRouterTeam/spawn/main/sprite/lib/common.sh)
|
|
fi
|
|
|
|
log_info "Aider on Sprite"
|
|
echo ""
|
|
|
|
# Setup sprite environment
|
|
ensure_sprite_installed
|
|
ensure_sprite_authenticated
|
|
|
|
SPRITE_NAME=$(get_sprite_name)
|
|
ensure_sprite_exists "$SPRITE_NAME" 5
|
|
verify_sprite_connectivity "$SPRITE_NAME"
|
|
|
|
log_warn "Setting up sprite environment..."
|
|
|
|
# Configure shell environment
|
|
setup_shell_environment "$SPRITE_NAME"
|
|
|
|
# Install Aider
|
|
log_warn "Installing Aider..."
|
|
run_sprite "$SPRITE_NAME" "pip install aider-chat 2>/dev/null || pip3 install aider-chat"
|
|
|
|
# Get OpenRouter API key via OAuth
|
|
echo ""
|
|
if [[ -n "$OPENROUTER_API_KEY" ]]; then
|
|
log_info "Using OpenRouter API key from environment"
|
|
else
|
|
OPENROUTER_API_KEY=$(get_openrouter_api_key_oauth 5180)
|
|
fi
|
|
|
|
# Get model preference
|
|
echo ""
|
|
log_warn "Browse models at: https://openrouter.ai/models"
|
|
log_warn "Which model would you like to use with Aider?"
|
|
MODEL_ID=$(safe_read "Enter model ID [openrouter/auto]: ") || MODEL_ID=""
|
|
MODEL_ID="${MODEL_ID:-openrouter/auto}"
|
|
|
|
# Inject environment variables
|
|
log_warn "Setting up environment variables..."
|
|
|
|
ENV_TEMP=$(mktemp)
|
|
cat > "$ENV_TEMP" << EOF
|
|
|
|
# [spawn:env]
|
|
export OPENROUTER_API_KEY="${OPENROUTER_API_KEY}"
|
|
EOF
|
|
|
|
sprite exec -s "$SPRITE_NAME" -file "$ENV_TEMP:/tmp/env_config" -- bash -c "cat /tmp/env_config >> ~/.zshrc && rm /tmp/env_config"
|
|
rm "$ENV_TEMP"
|
|
|
|
echo ""
|
|
log_info "Sprite setup completed successfully!"
|
|
echo ""
|
|
|
|
# Start Aider interactively
|
|
log_warn "Starting Aider..."
|
|
sleep 1
|
|
clear
|
|
sprite exec -s "$SPRITE_NAME" -tty -- zsh -c "source ~/.zshrc && aider --model openrouter/${MODEL_ID}"
|