Class: AgentHarness::Providers::Aider
- Inherits:
-
Base
- Object
- Base
- AgentHarness::Providers::Aider
show all
- 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
#config, #executor, #logger
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#configure, #initialize, #sandboxed_environment?
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, #smoke_test, #smoke_test_contract, #supported_mcp_transports, #supports_dangerous_mode?, #supports_mcp?, #supports_tool_control?, #validate_config, #validate_mcp_servers!
Class Method Details
.binary_name ⇒ Object
29
30
31
|
# File 'lib/agent_harness/providers/aider.rb', line 29
def binary_name
"aider"
end
|
.discover_models ⇒ Object
58
59
60
61
62
63
64
65
66
|
# File 'lib/agent_harness/providers/aider.rb', line 58
def discover_models
return [] unless available?
[
{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
38
39
40
41
42
43
44
45
46
|
# File 'lib/agent_harness/providers/aider.rb', line 38
def firewall_requirements
{
domains: [
"api.openai.com",
"api.anthropic.com"
],
ip_ranges: []
}
end
|
.installation_contract(version: SUPPORTED_CLI_VERSION) ⇒ Object
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
123
124
125
126
|
# File 'lib/agent_harness/providers/aider.rb', line 68
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
48
49
50
51
52
53
54
55
56
|
# File 'lib/agent_harness/providers/aider.rb', line 48
def instruction_file_paths
[
{
path: ".aider.conf.yml",
description: "Aider configuration file",
symlink: false
}
]
end
|
.provider_name ⇒ Object
25
26
27
|
# File 'lib/agent_harness/providers/aider.rb', line 25
def provider_name
:aider
end
|
.smoke_test_contract ⇒ Object
Instance Method Details
#capabilities ⇒ Object
158
159
160
161
162
163
164
165
166
167
168
|
# File 'lib/agent_harness/providers/aider.rb', line 158
def capabilities
{
streaming: true,
file_upload: true,
vision: false,
tool_use: true,
json_mode: false,
mcp: false,
dangerous_mode: false
}
end
|
#configuration_schema ⇒ Object
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
# File 'lib/agent_harness/providers/aider.rb', line 141
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
137
138
139
|
# File 'lib/agent_harness/providers/aider.rb', line 137
def display_name
"Aider"
end
|
#execution_semantics ⇒ Object
177
178
179
180
181
182
183
184
185
186
187
188
|
# File 'lib/agent_harness/providers/aider.rb', line 177
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
133
134
135
|
# File 'lib/agent_harness/providers/aider.rb', line 133
def name
"aider"
end
|
#send_message(prompt:, **options) ⇒ Object
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
|
# File 'lib/agent_harness/providers/aider.rb', line 199
def send_message(prompt:, **options)
log_debug("send_message_start", prompt_length: prompt.length, options: options.keys)
options = normalize_provider_runtime(options)
runtime = options[:provider_runtime]
options = normalize_mcp_servers(options)
validate_mcp_servers!(options[:mcp_servers]) if options[:mcp_servers]&.any?
llm_history_path = generate_llm_history_path
command = build_command(prompt, options.merge(llm_history_path: llm_history_path))
preparation = build_execution_preparation(options)
timeout = options[:timeout] || @config.timeout || default_timeout
start_time = Time.now
result = execute_with_timeout(
command,
timeout: timeout,
env: build_env(options),
preparation: preparation,
**command_execution_options(options)
)
duration = Time.now - start_time
response = parse_response(result, duration: duration, llm_history_path: llm_history_path)
if runtime&.model
response = Response.new(
output: response.output,
exit_code: response.exit_code,
duration: response.duration,
provider: response.provider,
model: runtime.model,
tokens: response.tokens,
metadata: response.metadata,
error: response.error
)
end
track_tokens(response) if response.tokens
log_debug("send_message_complete", duration: duration, tokens: response.tokens)
response
rescue McpConfigurationError, McpUnsupportedError, McpTransportUnsupportedError
raise
rescue => e
handle_error(e, prompt: prompt, options: options)
ensure
cleanup_llm_history_file!(llm_history_path)
end
|
#session_flags(session_id) ⇒ Object
194
195
196
197
|
# File 'lib/agent_harness/providers/aider.rb', line 194
def session_flags(session_id)
return [] unless session_id && !session_id.empty?
["--restore-chat-history", session_id]
end
|
#supports_sessions? ⇒ Boolean
190
191
192
|
# File 'lib/agent_harness/providers/aider.rb', line 190
def supports_sessions?
true
end
|