mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-05-06 08:10:48 +00:00
feat: implement local/plandex.sh (#854)
Add Plandex agent support for local machine execution: - Install Plandex via official installer - Inject OPENROUTER_API_KEY into shell config - Support both interactive and prompt modes - Follow local cloud provider pattern Agent: gap-filler 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
bfb125c028
commit
0f69e2abe9
2 changed files with 84 additions and 1 deletions
83
local/plandex.sh
Normal file
83
local/plandex.sh
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
#!/bin/bash
|
||||
set -eo pipefail
|
||||
|
||||
# Source common functions - try local file first, fall back to remote
|
||||
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 "Plandex on Local Machine"
|
||||
echo ""
|
||||
|
||||
# Ensure local machine is ready
|
||||
ensure_local_ready
|
||||
|
||||
SERVER_NAME=$(get_server_name)
|
||||
log_info "Running on: ${SERVER_NAME}"
|
||||
|
||||
# Install Plandex
|
||||
log_step "Installing Plandex..."
|
||||
run_server "curl -sL https://plandex.ai/install.sh | bash"
|
||||
|
||||
# Verify installation succeeded
|
||||
if ! run_server "command -v plandex &> /dev/null && plandex version &> /dev/null"; then
|
||||
log_error "Plandex installation verification failed"
|
||||
log_error "The 'plandex' command is not available or not working properly"
|
||||
exit 1
|
||||
fi
|
||||
log_info "Plandex installation verified successfully"
|
||||
|
||||
# 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
|
||||
|
||||
# Inject environment variables
|
||||
log_step "Setting up environment variables..."
|
||||
|
||||
# Add to shell config
|
||||
SHELL_CONFIG=""
|
||||
if [[ -f "${HOME}/.zshrc" ]]; then
|
||||
SHELL_CONFIG="${HOME}/.zshrc"
|
||||
elif [[ -f "${HOME}/.bashrc" ]]; then
|
||||
SHELL_CONFIG="${HOME}/.bashrc"
|
||||
else
|
||||
SHELL_CONFIG="${HOME}/.bashrc"
|
||||
touch "${SHELL_CONFIG}"
|
||||
fi
|
||||
|
||||
# Check if already configured
|
||||
if ! grep -q "export OPENROUTER_API_KEY=" "${SHELL_CONFIG}" 2>/dev/null; then
|
||||
printf '\n# OpenRouter API Key for Plandex\nexport OPENROUTER_API_KEY="%s"\n' "${OPENROUTER_API_KEY}" >> "${SHELL_CONFIG}"
|
||||
fi
|
||||
|
||||
# Export for current session
|
||||
export OPENROUTER_API_KEY="${OPENROUTER_API_KEY}"
|
||||
|
||||
echo ""
|
||||
log_info "Local setup completed successfully!"
|
||||
echo ""
|
||||
|
||||
# Check if running in non-interactive mode
|
||||
if [[ -n "${SPAWN_PROMPT:-}" ]]; then
|
||||
# Non-interactive mode: execute prompt and exit
|
||||
log_step "Executing Plandex with prompt..."
|
||||
|
||||
# Escape prompt for safe shell execution
|
||||
escaped_prompt=$(printf '%q' "${SPAWN_PROMPT}")
|
||||
|
||||
# Execute without TTY
|
||||
bash -c "source ${SHELL_CONFIG} && plandex new && plandex tell ${escaped_prompt}"
|
||||
else
|
||||
# Interactive mode: start Plandex normally
|
||||
log_step "Starting Plandex..."
|
||||
sleep 1
|
||||
clear
|
||||
interactive_session "source ${SHELL_CONFIG} && plandex"
|
||||
fi
|
||||
|
|
@ -1227,7 +1227,7 @@
|
|||
"local/cline": "implemented",
|
||||
"local/gptme": "implemented",
|
||||
"local/opencode": "implemented",
|
||||
"local/plandex": "missing",
|
||||
"local/plandex": "implemented",
|
||||
"local/kilocode": "missing",
|
||||
"local/continue": "implemented",
|
||||
"ramnode/claude": "implemented",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue