diff --git a/internal/agents/amazonq_cli.go b/internal/agents/amazonq_cli.go index 617ce9e4..6d830526 100644 --- a/internal/agents/amazonq_cli.go +++ b/internal/agents/amazonq_cli.go @@ -252,6 +252,24 @@ Note: Amazon Q CLI has separate usage quota from Kiro IDE. ` } +// GetShellConfig returns shell profile configuration for Amazon Q CLI +func (h *AmazonQCLIHandler) GetShellConfig(proxyURL string) string { + return fmt.Sprintf(`# ProxyPilot - Amazon Q CLI Configuration +# Amazon Q CLI uses its own authentication via 'q login'. +# ProxyPilot automatically imports the tokens after you authenticate. + +# To authenticate: +# q login + +# ProxyPilot will detect and use the tokens automatically. +# No additional environment variables needed. + +# Optional: For other OpenAI-compatible tools +export OPENAI_BASE_URL="%s/v1" +export OPENAI_API_KEY="proxypilot-local" +`, proxyURL) +} + // GetWSLInfo returns WSL distro and user information (for external use) func (h *AmazonQCLIHandler) GetWSLInfo() (distro, user string) { return h.wslDistro, h.wslUser diff --git a/internal/agents/claude_code.go b/internal/agents/claude_code.go index 5d1e53c2..1d5a7c5d 100644 --- a/internal/agents/claude_code.go +++ b/internal/agents/claude_code.go @@ -204,6 +204,25 @@ func (h *ClaudeCodeHandler) GetInstructions(proxyURL string) string { `, h.configPath, proxyURL) } +// GetShellConfig returns shell profile configuration for Claude Code +func (h *ClaudeCodeHandler) GetShellConfig(proxyURL string) string { + return fmt.Sprintf(`# ProxyPilot - Claude Code Configuration +# Add these lines to your shell profile (~/.bashrc, ~/.zshrc, or ~/.profile) + +export ANTHROPIC_BASE_URL="%s" +export ANTHROPIC_AUTH_TOKEN="proxypilot-local" + +# For Claude Code 2.x, you can also set default models: +# export ANTHROPIC_DEFAULT_OPUS_MODEL="claude-opus-4-1-20250805" +# export ANTHROPIC_DEFAULT_SONNET_MODEL="claude-sonnet-4-5-20250929" +# export ANTHROPIC_DEFAULT_HAIKU_MODEL="claude-3-5-haiku-20241022" + +# For Claude Code 1.x: +# export ANTHROPIC_MODEL="claude-sonnet-4-5-20250929" +# export ANTHROPIC_SMALL_FAST_MODEL="claude-3-5-haiku-20241022" +`, proxyURL) +} + // readConfig reads the Claude Code settings file func (h *ClaudeCodeHandler) readConfig() (map[string]any, error) { data, err := os.ReadFile(h.configPath) diff --git a/internal/agents/codex.go b/internal/agents/codex.go index 9abae73c..c732a344 100644 --- a/internal/agents/codex.go +++ b/internal/agents/codex.go @@ -203,3 +203,17 @@ wire_api = "openai" 4. Restart Codex CLI for changes to take effect. `, h.configPath, proxyURL) } + +// GetShellConfig returns shell profile configuration for Codex CLI +func (h *CodexHandler) GetShellConfig(proxyURL string) string { + return fmt.Sprintf(`# ProxyPilot - Codex CLI Configuration +# Add these lines to your shell profile (~/.bashrc, ~/.zshrc, or ~/.profile) + +export PROXYPILOT_API_KEY="proxypilot-local" +export OPENAI_BASE_URL="%s/v1" +export OPENAI_API_KEY="proxypilot-local" + +# Note: Codex CLI also requires config.toml configuration. +# See the setup instructions for full details. +`, proxyURL) +} diff --git a/internal/agents/cursor.go b/internal/agents/cursor.go index a5b560c7..c464c130 100644 --- a/internal/agents/cursor.go +++ b/internal/agents/cursor.go @@ -193,6 +193,18 @@ Or edit %s directly and add: `, proxyURL, h.configPath, proxyURL) } +// GetShellConfig returns shell profile configuration for Cursor +func (h *CursorHandler) GetShellConfig(proxyURL string) string { + return fmt.Sprintf(`# ProxyPilot - Cursor IDE Configuration +# Note: Cursor primarily uses settings.json, not environment variables. +# Use the UI or edit settings.json directly. + +# Optional: Set OPENAI-compatible environment variables as fallback +export OPENAI_BASE_URL="%s/v1" +export OPENAI_API_KEY="proxypilot-local" +`, proxyURL) +} + // readConfig reads the Cursor settings file func (h *CursorHandler) readConfig() (map[string]any, error) { data, err := os.ReadFile(h.configPath) diff --git a/internal/agents/factory_droid.go b/internal/agents/factory_droid.go index 216be925..038dfd61 100644 --- a/internal/agents/factory_droid.go +++ b/internal/agents/factory_droid.go @@ -196,6 +196,18 @@ func (h *FactoryDroidHandler) GetInstructions(proxyURL string) string { `, h.settingsPath, proxyURL) } +// GetShellConfig returns shell profile configuration for Factory Droid +func (h *FactoryDroidHandler) GetShellConfig(proxyURL string) string { + return fmt.Sprintf(`# ProxyPilot - Factory Droid Configuration +# Factory Droid uses settings.json for configuration, not environment variables. +# Use the auto-configure feature or edit %s directly. + +# Optional: For other OpenAI-compatible tools +export OPENAI_BASE_URL="%s/v1" +export OPENAI_API_KEY="proxypilot-local" +`, h.settingsPath, proxyURL) +} + func (h *FactoryDroidHandler) readSettings() (map[string]any, error) { data, err := os.ReadFile(h.settingsPath) if err != nil { @@ -277,7 +289,7 @@ func buildDroidModels(proxyURL string) []map[string]any { displayName := "proxypilot-" + m.displayName // Create ID in Droid's format: custom:- id := fmt.Sprintf("custom:%s-%d", strings.ReplaceAll(displayName, " ", "-"), i) - + models = append(models, map[string]any{ "model": m.modelID, "id": id, diff --git a/internal/agents/gemini_cli.go b/internal/agents/gemini_cli.go index 6ad7ee0f..dc7bf37f 100644 --- a/internal/agents/gemini_cli.go +++ b/internal/agents/gemini_cli.go @@ -198,3 +198,17 @@ func (h *GeminiCLIHandler) writeConfig(config map[string]any) error { return os.WriteFile(h.configPath, data, 0644) } + +// GetShellConfig returns shell profile configuration for Gemini CLI +func (h *GeminiCLIHandler) GetShellConfig(proxyURL string) string { + return fmt.Sprintf(`# ProxyPilot - Gemini CLI Configuration +# Add these lines to your shell profile (~/.bashrc, ~/.zshrc, or ~/.profile) + +# Option 1: OAuth mode (local only) +export CODE_ASSIST_ENDPOINT="%s" + +# Option 2: API Key mode (works with any IP/domain) +# export GOOGLE_GEMINI_BASE_URL="%s" +# export GEMINI_API_KEY="proxypilot-local" +`, proxyURL, proxyURL) +} diff --git a/internal/agents/manager.go b/internal/agents/manager.go index cded67b1..0be3f672 100644 --- a/internal/agents/manager.go +++ b/internal/agents/manager.go @@ -15,6 +15,7 @@ type AgentInfo struct { CanAutoConfigure bool `json:"can_auto_configure"` ConfigPath string `json:"config_path,omitempty"` Instructions string `json:"instructions,omitempty"` + ShellConfig string `json:"shell_config,omitempty"` EnvVars map[string]string `json:"env_vars,omitempty"` } @@ -56,6 +57,10 @@ type AgentHandler interface { // GetInstructions returns manual configuration instructions GetInstructions(proxyURL string) string + + // GetShellConfig returns shell script configuration for this agent. + // This is used for agents that need environment variables in shell profiles. + GetShellConfig(proxyURL string) string } // Manager manages all CLI agent configurations @@ -133,6 +138,7 @@ func (m *Manager) DetectAll() ([]AgentInfo, error) { CanAutoConfigure: handler.CanAutoConfigure(), ConfigPath: handler.GetConfigPath(), Instructions: handler.GetInstructions(m.proxyURL), + ShellConfig: handler.GetShellConfig(m.proxyURL), } detected, err := handler.Detect() @@ -174,6 +180,7 @@ func (m *Manager) GetAgentInfo(agentID string) (AgentInfo, error) { CanAutoConfigure: handler.CanAutoConfigure(), ConfigPath: handler.GetConfigPath(), Instructions: handler.GetInstructions(m.proxyURL), + ShellConfig: handler.GetShellConfig(m.proxyURL), } detected, _ := handler.Detect() diff --git a/internal/agents/opencode.go b/internal/agents/opencode.go index 04ce5e26..8d2ffb34 100644 --- a/internal/agents/opencode.go +++ b/internal/agents/opencode.go @@ -197,6 +197,20 @@ func (h *OpenCodeHandler) GetInstructions(proxyURL string) string { `, h.configPath, proxyURL) } +// GetShellConfig returns shell profile configuration for OpenCode +func (h *OpenCodeHandler) GetShellConfig(proxyURL string) string { + return fmt.Sprintf(`# ProxyPilot - OpenCode Configuration +# Add these lines to your shell profile (~/.bashrc, ~/.zshrc, or ~/.profile) + +export OPENAI_BASE_URL="%s/v1" +export OPENAI_API_KEY="proxypilot-local" + +# Or use Anthropic-compatible settings: +# export ANTHROPIC_BASE_URL="%s" +# export ANTHROPIC_AUTH_TOKEN="proxypilot-local" +`, proxyURL, proxyURL) +} + // readConfig reads the OpenCode settings file func (h *OpenCodeHandler) readConfig() (map[string]any, error) { data, err := os.ReadFile(h.configPath)