Class: AgentHarness::Providers::Aider
- Defined in:
- lib/agent_harness/providers/aider.rb
Overview
Aider AI coding assistant provider
Provides integration with the Aider CLI tool.
Constant Summary collapse
- UV_VERSION =
"0.8.17"- SUPPORTED_CLI_VERSION =
"0.86.2"- SUPPORTED_CLI_REQUIREMENT =
Gem::Requirement.new(">= #{SUPPORTED_CLI_VERSION}", "< 0.87.0").freeze
- PYTHON_VERSION =
"python3.12"- BINARY_PATH =
"/usr/local/bin/aider"- UV_TOOL_ENV =
{ "UV_TOOL_BIN_DIR" => "/usr/local/bin", "UV_TOOL_DIR" => "/opt/uv/tools", "UV_PYTHON_INSTALL_DIR" => "/opt/uv/python" }.freeze
Constants inherited from Base
Base::COMMON_ERROR_PATTERNS, Base::DEFAULT_SMOKE_TEST_CONTRACT
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
- .available? ⇒ Boolean
- .binary_name ⇒ Object
- .discover_models ⇒ Object
- .firewall_requirements ⇒ Object
- .installation_contract(version: SUPPORTED_CLI_VERSION) ⇒ Object
- .instruction_file_paths ⇒ Object
- .provider_name ⇒ Object
- .smoke_test_contract ⇒ Object
Instance Method Summary collapse
- #capabilities ⇒ Object
- #configuration_schema ⇒ Object
- #display_name ⇒ Object
- #error_patterns ⇒ Object
- #execution_semantics ⇒ Object
- #name ⇒ Object
- #session_flags(session_id) ⇒ Object
- #supports_sessions? ⇒ Boolean
Methods inherited from Base
#configure, #initialize, #sandboxed_environment?, #send_message
Methods included from Adapter
#auth_type, #build_mcp_flags, #dangerous_mode_flags, #fetch_mcp_servers, #health_status, included, metadata_package_name, normalize_metadata_installation, normalize_metadata_source_type, normalize_metadata_version_requirement, #parse_rate_limit_reset, #send_message, #smoke_test, #smoke_test_contract, #supported_mcp_transports, #supports_dangerous_mode?, #supports_mcp?, #validate_config, #validate_mcp_servers!
Constructor Details
This class inherits a constructor from AgentHarness::Providers::Base
Class Method Details
.available? ⇒ Boolean
29 30 31 32 |
# File 'lib/agent_harness/providers/aider.rb', line 29 def available? executor = AgentHarness.configuration.command_executor !!executor.which(binary_name) end |
.binary_name ⇒ Object
25 26 27 |
# File 'lib/agent_harness/providers/aider.rb', line 25 def binary_name "aider" end |
.discover_models ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/agent_harness/providers/aider.rb', line 54 def discover_models return [] unless available? # Aider supports multiple model providers [ {name: "gpt-4o", family: "gpt-4o", tier: "standard", provider: "aider"}, {name: "claude-3-5-sonnet", family: "claude-3-5-sonnet", tier: "standard", provider: "aider"} ] end |
.firewall_requirements ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/agent_harness/providers/aider.rb', line 34 def firewall_requirements { domains: [ "api.openai.com", "api.anthropic.com" ], ip_ranges: [] } end |
.installation_contract(version: SUPPORTED_CLI_VERSION) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 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 |
# File 'lib/agent_harness/providers/aider.rb', line 64 def installation_contract(version: SUPPORTED_CLI_VERSION) version = version.strip if version.respond_to?(:strip) unless version.is_a?(String) && !version.empty? raise ArgumentError, "Unsupported Aider CLI version #{version.inspect}; " \ "supported versions must satisfy #{SUPPORTED_CLI_REQUIREMENT}" end parsed_version = begin Gem::Version.new(version) rescue ArgumentError raise ArgumentError, "Unsupported Aider CLI version #{version.inspect}; " \ "supported versions must satisfy #{SUPPORTED_CLI_REQUIREMENT}" end unless SUPPORTED_CLI_REQUIREMENT.satisfied_by?(parsed_version) raise ArgumentError, "Unsupported Aider CLI version #{version.inspect}; " \ "supported versions must satisfy #{SUPPORTED_CLI_REQUIREMENT}" end default_package = "aider-chat==#{version}".freeze bootstrap_command = [ "python3", "-m", "pip", "install", "--no-cache-dir", "--break-system-packages", "uv==#{UV_VERSION}" ].freeze install_command_prefix = [ "uv", "tool", "install", "--force", "--python", PYTHON_VERSION, "--with", "pip" ].freeze install_command = (install_command_prefix + [default_package]).freeze supported_versions = [version].freeze version_requirement = SUPPORTED_CLI_REQUIREMENT.requirements .map { |op, ver| "#{op} #{ver}".freeze } .freeze contract = { source: :uv_tool, bootstrap_source: :pip, bootstrap_package: "uv==#{UV_VERSION}", bootstrap_commands: [bootstrap_command].freeze, install_environment: UV_TOOL_ENV, package: default_package, package_name: "aider-chat", version: version, version_format: "%{package_name}==%{version}", version_requirement: version_requirement, binary_name: binary_name, binary_path: BINARY_PATH, install_command_prefix: install_command_prefix, install_command: install_command, supported_versions: supported_versions } contract.each_value do |value| value.freeze if value.is_a?(String) end contract.freeze end |
.instruction_file_paths ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/agent_harness/providers/aider.rb', line 44 def instruction_file_paths [ { path: ".aider.conf.yml", description: "Aider configuration file", symlink: false } ] end |
.provider_name ⇒ Object
21 22 23 |
# File 'lib/agent_harness/providers/aider.rb', line 21 def provider_name :aider end |
.smoke_test_contract ⇒ Object
124 125 126 |
# File 'lib/agent_harness/providers/aider.rb', line 124 def smoke_test_contract Base::DEFAULT_SMOKE_TEST_CONTRACT end |
Instance Method Details
#capabilities ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/agent_harness/providers/aider.rb', line 154 def capabilities { streaming: true, file_upload: true, vision: false, tool_use: true, json_mode: false, mcp: false, dangerous_mode: false } end |
#configuration_schema ⇒ Object
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/agent_harness/providers/aider.rb', line 137 def configuration_schema { fields: [ { name: :model, type: :string, label: "Model", required: false, hint: "Model identifier (supports OpenAI, Anthropic, and other model names)", accepts_arbitrary: true } ], auth_modes: [:api_key], openai_compatible: false } end |
#display_name ⇒ Object
133 134 135 |
# File 'lib/agent_harness/providers/aider.rb', line 133 def display_name "Aider" end |
#error_patterns ⇒ Object
166 167 168 169 170 171 |
# File 'lib/agent_harness/providers/aider.rb', line 166 def error_patterns COMMON_ERROR_PATTERNS.merge( auth_expired: COMMON_ERROR_PATTERNS[:auth_expired] + [/incorrect.*api.*key/i], transient: COMMON_ERROR_PATTERNS[:transient] + [/connection.*reset/i] ) end |
#execution_semantics ⇒ Object
173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/agent_harness/providers/aider.rb', line 173 def execution_semantics { prompt_delivery: :flag, output_format: :text, sandbox_aware: false, uses_subcommand: false, non_interactive_flag: "--yes", legitimate_exit_codes: [0], stderr_is_diagnostic: true, parses_rate_limit_reset: false } end |
#name ⇒ Object
129 130 131 |
# File 'lib/agent_harness/providers/aider.rb', line 129 def name "aider" end |
#session_flags(session_id) ⇒ Object
190 191 192 193 |
# File 'lib/agent_harness/providers/aider.rb', line 190 def session_flags(session_id) return [] unless session_id && !session_id.empty? ["--restore-chat-history", session_id] end |
#supports_sessions? ⇒ Boolean
186 187 188 |
# File 'lib/agent_harness/providers/aider.rb', line 186 def supports_sessions? true end |