mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-05-08 10:09:30 +00:00
feat: implement local/cline.sh (#853)
Add Cline agent support on local machine. Combines local provider primitives with Cline installation and OpenRouter credential injection. Features: - npm-based installation of Cline globally - OpenRouter API key injection via OAuth or env var - Persistent env vars in shell config (.zshrc or .bashrc) - Sets OPENAI_BASE_URL to route through OpenRouter Agent: gap-filler-2 Co-authored-by: B (Discovery Team) <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
2e32f2c9fe
commit
de265c543b
2 changed files with 69 additions and 1 deletions
68
local/cline.sh
Executable file
68
local/cline.sh
Executable file
|
|
@ -0,0 +1,68 @@
|
|||
#!/bin/bash
|
||||
set -eo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)"
|
||||
if [[ -n "${SCRIPT_DIR}" && -f "${SCRIPT_DIR}/lib/common.sh" ]]; then
|
||||
source "${SCRIPT_DIR}/lib/common.sh"
|
||||
else
|
||||
eval "$(curl -fsSL https://raw.githubusercontent.com/OpenRouterTeam/spawn/main/local/lib/common.sh)"
|
||||
fi
|
||||
|
||||
log_info "Cline on Local Machine"
|
||||
echo ""
|
||||
|
||||
ensure_local_ready
|
||||
|
||||
SERVER_NAME=$(get_server_name)
|
||||
create_server "${SERVER_NAME}"
|
||||
|
||||
log_step "Installing Cline..."
|
||||
if ! command -v npm &>/dev/null; then
|
||||
log_error "npm is required but not installed. Please install Node.js and npm first."
|
||||
exit 1
|
||||
fi
|
||||
npm install -g cline
|
||||
|
||||
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
|
||||
|
||||
log_step "Setting up environment variables..."
|
||||
# Export env vars for current session
|
||||
export OPENROUTER_API_KEY="${OPENROUTER_API_KEY}"
|
||||
export OPENAI_API_KEY="${OPENROUTER_API_KEY}"
|
||||
export OPENAI_BASE_URL="https://openrouter.ai/api/v1"
|
||||
|
||||
# Persist to shell config
|
||||
SHELL_CONFIG=""
|
||||
if [[ -f "${HOME}/.zshrc" ]]; then
|
||||
SHELL_CONFIG="${HOME}/.zshrc"
|
||||
elif [[ -f "${HOME}/.bashrc" ]]; then
|
||||
SHELL_CONFIG="${HOME}/.bashrc"
|
||||
fi
|
||||
|
||||
if [[ -n "${SHELL_CONFIG}" ]]; then
|
||||
# Remove old entries if they exist
|
||||
sed -i.bak '/^export OPENROUTER_API_KEY=/d' "${SHELL_CONFIG}" 2>/dev/null || true
|
||||
sed -i.bak '/^export OPENAI_API_KEY=/d' "${SHELL_CONFIG}" 2>/dev/null || true
|
||||
sed -i.bak '/^export OPENAI_BASE_URL=/d' "${SHELL_CONFIG}" 2>/dev/null || true
|
||||
|
||||
# Add new entries
|
||||
printf '\nexport OPENROUTER_API_KEY="%s"\n' "${OPENROUTER_API_KEY}" >> "${SHELL_CONFIG}"
|
||||
printf 'export OPENAI_API_KEY="%s"\n' "${OPENROUTER_API_KEY}" >> "${SHELL_CONFIG}"
|
||||
printf 'export OPENAI_BASE_URL="https://openrouter.ai/api/v1"\n' >> "${SHELL_CONFIG}"
|
||||
|
||||
log_info "Environment variables persisted to ${SHELL_CONFIG}"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
log_info "Local machine setup completed successfully!"
|
||||
echo ""
|
||||
|
||||
log_step "Starting Cline..."
|
||||
sleep 1
|
||||
clear
|
||||
cline
|
||||
|
|
@ -1195,7 +1195,7 @@
|
|||
"local/interpreter": "implemented",
|
||||
"local/gemini": "implemented",
|
||||
"local/amazonq": "missing",
|
||||
"local/cline": "missing",
|
||||
"local/cline": "implemented",
|
||||
"local/gptme": "implemented",
|
||||
"local/opencode": "implemented",
|
||||
"local/plandex": "missing",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue