Class: Aidp::Providers::Aider
- Includes:
- DebugMixin
- Defined in:
- lib/aidp/providers/aider.rb
Constant Summary collapse
- MODEL_PATTERN =
Model name pattern for Aider (supports various models via OpenRouter) Aider can use any model, but we’ll match common patterns
/^(gpt-|claude-|gemini-|deepseek-|qwen-|o1-)/i- LONG_PROMPT_THRESHOLD =
8000- LONG_PROMPT_TIMEOUT =
15 minutes for large prompts
900
Constants included from DebugMixin
DebugMixin::DEBUG_BASIC, DebugMixin::DEBUG_OFF, DebugMixin::DEBUG_VERBOSE
Constants inherited from Base
Base::ACTIVITY_STATES, Base::DEFAULT_STUCK_TIMEOUT, Base::TIER_TIMEOUT_MULTIPLIERS, Base::TIMEOUT_ARCHITECTURE_ANALYSIS, Base::TIMEOUT_DEFAULT, Base::TIMEOUT_DOCUMENTATION_ANALYSIS, Base::TIMEOUT_FUNCTIONALITY_ANALYSIS, Base::TIMEOUT_IMPLEMENTATION, Base::TIMEOUT_QUICK_MODE, Base::TIMEOUT_REFACTORING_RECOMMENDATIONS, Base::TIMEOUT_REPOSITORY_ANALYSIS, Base::TIMEOUT_STATIC_ANALYSIS, Base::TIMEOUT_TEST_ANALYSIS
Constants included from MessageDisplay
Instance Attribute Summary
Attributes inherited from Base
#activity_state, #last_activity_time, #model, #start_time, #step_name, #stuck_timeout
Class Method Summary collapse
- .available? ⇒ Boolean
-
.discover_models ⇒ Array<Hash>
Discover available models from registry.
-
.firewall_requirements ⇒ Object
Get firewall requirements for Aider provider Aider uses aider.chat for updates, openrouter.ai for API access, and pypi.org for version checking.
-
.supports_model_family?(family_name) ⇒ Boolean
Check if this provider supports a given model family.
Instance Method Summary collapse
- #available? ⇒ Boolean
- #display_name ⇒ Object
-
#harness_healthy? ⇒ Boolean
Override health check for Aider specific considerations.
- #name ⇒ Object
- #send_message(prompt:, session: nil, options: {}) ⇒ Object
-
#send_with_options(prompt:, session: nil, model: nil, auto_commits: false) ⇒ Object
Enhanced send method with additional options.
Methods included from DebugMixin
#debug_basic?, #debug_command, #debug_enabled?, #debug_error, #debug_execute_command, #debug_level, #debug_log, #debug_logger, #debug_provider, #debug_step, #debug_timing, #debug_verbose?, included, shared_logger
Methods inherited from Base
#activity_summary, #configure, discover_models_from_registry, #execution_time, #fetch_mcp_servers, #harness_config, #harness_health_status, #harness_metrics, #harness_mode?, #initialize, #mark_completed, #mark_failed, #record_activity, #record_harness_request, #send_with_harness, #set_harness_context, #set_job_context, #setup_activity_monitoring, #stuck?, #supports_activity_monitoring?, #supports_mcp?, #time_since_last_activity, #update_activity_state
Methods included from Adapter
#capabilities, #classify_error, #dangerous_mode=, #dangerous_mode_enabled?, #dangerous_mode_flags, #error_metadata, #error_patterns, #fetch_mcp_servers, #health_status, #logging_metadata, #redact_secrets, #retryable_error?, #supports_dangerous_mode?, #supports_mcp?, #validate_config
Methods included from MessageDisplay
#display_message, included, #message_display_prompt
Constructor Details
This class inherits a constructor from Aidp::Providers::Base
Class Method Details
.available? ⇒ Boolean
19 20 21 |
# File 'lib/aidp/providers/aider.rb', line 19 def self.available? !!Aidp::Util.which("aider") end |
.discover_models ⇒ Array<Hash>
Discover available models from registry
Note: Aider uses its own configuration for models Returns registry-based models that match common patterns
37 38 39 40 41 |
# File 'lib/aidp/providers/aider.rb', line 37 def self.discover_models return [] unless available? discover_models_from_registry(MODEL_PATTERN, "aider") end |
.firewall_requirements ⇒ Object
Get firewall requirements for Aider provider Aider uses aider.chat for updates, openrouter.ai for API access, and pypi.org for version checking
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/aidp/providers/aider.rb', line 46 def self.firewall_requirements { domains: [ "aider.chat", "openrouter.ai", "api.openrouter.ai", "pypi.org" ], ip_ranges: [] } end |
.supports_model_family?(family_name) ⇒ Boolean
Check if this provider supports a given model family
27 28 29 |
# File 'lib/aidp/providers/aider.rb', line 27 def self.supports_model_family?(family_name) MODEL_PATTERN.match?(family_name) end |
Instance Method Details
#available? ⇒ Boolean
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/aidp/providers/aider.rb', line 66 def available? return false unless self.class.available? # Additional check to ensure the CLI is properly configured begin result = Aidp::Util.execute_command("aider", ["--version"], timeout: 10) result.exit_status == 0 rescue false end end |
#display_name ⇒ Object
62 63 64 |
# File 'lib/aidp/providers/aider.rb', line 62 def display_name "Aider" end |
#harness_healthy? ⇒ Boolean
Override health check for Aider specific considerations
188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/aidp/providers/aider.rb', line 188 def harness_healthy? return false unless super # Additional health checks specific to Aider # Check if we can access the CLI (basic connectivity test) begin result = Aidp::Util.execute_command("aider", ["--help"], timeout: 5) result.exit_status == 0 rescue false end end |
#name ⇒ Object
58 59 60 |
# File 'lib/aidp/providers/aider.rb', line 58 def name "aider" end |
#send_message(prompt:, session: nil, options: {}) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/aidp/providers/aider.rb', line 78 def (prompt:, session: nil, options: {}) raise "aider CLI not available" unless self.class.available? # Smart timeout calculation (store prompt length for adaptive logic) @current_aider_prompt_length = prompt.length timeout_seconds = calculate_timeout debug_provider("aider", "Starting execution", {timeout: timeout_seconds}) debug_log("📝 Sending prompt to aider (length: #{prompt.length})", level: :info) # Set up activity monitoring setup_activity_monitoring("aider", method(:activity_callback)) record_activity("Starting aider execution") # Create a spinner for activity display spinner = TTY::Spinner.new("[:spinner] :title", format: :dots, hide_cursor: true) spinner.auto_spin activity_display_thread = Thread.new do start_time = Time.now loop do sleep 0.5 # Update every 500ms to reduce spam elapsed = Time.now - start_time # Break if we've been running too long or state changed break if elapsed > timeout_seconds || @activity_state == :completed || @activity_state == :failed update_spinner_status(spinner, elapsed, "🤖 Aider") end end begin # Use non-interactive mode with --yes-always flag and --message # --yes-always is equivalent to Claude's --dangerously-skip-permissions args = ["--yes-always", "--message", prompt] # Disable aider's auto-commits by default - let AIDP handle commits # based on work_loop.version_control.behavior configuration args += ["--no-auto-commits"] # Add model if configured if @model && !@model.empty? args += ["--model", @model] end # Add session support if provided (aider supports chat history) if session && !session.empty? args += ["--restore-chat-history"] end # In devcontainer, aider should run in non-interactive mode if in_devcontainer_or_codespace? debug_log("🔓 Running aider in non-interactive mode with --yes-always (devcontainer)", level: :info) end # Use debug_execute_command for better debugging result = debug_execute_command("aider", args: args, timeout: timeout_seconds) # Log the results debug_command("aider", args: args, input: prompt, output: result.out, error: result.err, exit_code: result.exit_status) if result.exit_status == 0 spinner.success("✓") mark_completed result.out else spinner.error("✗") mark_failed("aider failed with exit code #{result.exit_status}") debug_error(StandardError.new("aider failed"), {exit_code: result.exit_status, stderr: result.err}) raise "aider failed with exit code #{result.exit_status}: #{result.err}" end rescue => e spinner&.error("✗") mark_failed("aider execution failed: #{e.message}") debug_error(e, {provider: "aider", prompt_length: prompt.length}) raise ensure cleanup_activity_display(activity_display_thread, spinner) @current_aider_prompt_length = nil end end |
#send_with_options(prompt:, session: nil, model: nil, auto_commits: false) ⇒ Object
Enhanced send method with additional options
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/aidp/providers/aider.rb', line 161 def (prompt:, session: nil, model: nil, auto_commits: false) args = ["--yes-always", "--message", prompt] # Disable auto-commits by default (let AIDP handle commits) # unless explicitly enabled via auto_commits parameter args += if auto_commits ["--auto-commits"] else ["--no-auto-commits"] end # Add session support if session && !session.empty? args += ["--restore-chat-history"] end # Add model selection (from parameter or configured model) model_to_use = model || @model if model_to_use args += ["--model", model_to_use] end # Use the enhanced version of send send_with_custom_args(prompt: prompt, args: args) end |