aider-ruby 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: df88e44078947c6ed81b117ed69f10fcff03a31984dc78b29e441f0825eb55c6
4
+ data.tar.gz: f2d7efbfe3672ec096c2daf2e9de40d2e52c0186431b9db42850b3565126482c
5
+ SHA512:
6
+ metadata.gz: 4a1ed7b2718a43da981d0a4d205237fdb4a02bccc3ee252630611547cc7ffa606f41d382f53b7503acf10a95f02c27e5cddd5cecc118228841a39e43850cab0b
7
+ data.tar.gz: b068e82c72ae514eed17a53ef8163e290d43f3c4b4dac3075391cdf9785f8c6610ede84415e7609df742e3fd040202e2e40e06acc8668cc4cb6826ca77d1e83e
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Renaud Gagnon
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,542 @@
1
+ # AiderRuby
2
+
3
+ A Ruby gem that serves as a wrapper for [aider](https://aider.chat), enabling LLM configuration and execution of AI-assisted programming tasks.
4
+
5
+ ## 🏗️ Architecture
6
+
7
+ AiderRuby uses a modular architecture to organize code in a clear and maintainable way:
8
+
9
+ - **Specialized configuration modules**: Each option category has its own module
10
+ - **Robust error handling**: Specialized error types with contextual handling
11
+ - **Integrated validation**: Automatic parameter validation
12
+ - **Fluid API**: Chainable methods for intuitive configuration
13
+ - **Compatibility**: Maintains existing API with aliases
14
+
15
+ See [ARCHITECTURE.md](ARCHITECTURE.md) for more details on the architecture.
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ gem install aider-ruby
21
+ ```
22
+
23
+ Or add it to your Gemfile:
24
+
25
+ ```ruby
26
+ gem 'aider-ruby'
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ ### Command Line Interface
32
+
33
+ ```bash
34
+ # Execute aider with a message
35
+ aider-ruby execute "Create a function to calculate factorial"
36
+
37
+ # Interactive mode
38
+ aider-ruby interactive
39
+
40
+ # Use a specific model
41
+ aider-ruby execute "Refactor this code" --model claude-3-5-sonnet-20241022
42
+
43
+ # Add files
44
+ aider-ruby execute "Improve this function" --files app/models/user.rb
45
+
46
+ # Verbose mode
47
+ aider-ruby execute "Debug this issue" --verbose
48
+
49
+ # List available models
50
+ aider-ruby models
51
+
52
+ # Model information
53
+ aider-ruby model_info gpt-4o
54
+
55
+ # Recommended models
56
+ aider-ruby recommended
57
+
58
+ # Load coding conventions
59
+ aider-ruby conventions CONVENTIONS.md
60
+
61
+ # Set edit format
62
+ aider-ruby edit_format diff
63
+
64
+ # Show reasoning settings
65
+ aider-ruby reasoning_settings
66
+
67
+ # Execute with advanced parameters
68
+ aider-ruby execute "Task" --reasoning-effort high --thinking-tokens 8k --edit-format diff-fenced
69
+ ```
70
+
71
+ ### Programmatic Usage
72
+
73
+ ```ruby
74
+ require 'aider_ruby'
75
+
76
+ # Create a client
77
+ client = AiderRuby.new_client(
78
+ model: 'claude-3-5-sonnet-20241022',
79
+ openai_api_key: 'your-key',
80
+ anthropic_api_key: 'your-key'
81
+ )
82
+
83
+ # Add files
84
+ client.add_files('app/models/user.rb')
85
+ client.add_files(['app/models/user.rb', 'app/models/post.rb']) # Multiple files
86
+ client.add_read_only_file('README.md')
87
+ client.add_read_only_file(['docs/api.md', 'docs/guide.md']) # Multiple read-only files
88
+
89
+ # Add entire folders
90
+ client.add_folder('app/models', extensions: ['.rb']) # Only Ruby files
91
+ client.add_read_only_folder('docs', exclude_patterns: ['temp/', /\.tmp$/]) # Exclude patterns
92
+
93
+ # Configure coding conventions
94
+ client.conventions_files(['CONVENTIONS.md', 'STYLE_GUIDE.md']) # Multiple files
95
+ client.add_read_files(['docs/guidelines.md', 'examples/patterns.rb']) # Basic usage
96
+ client.add_read_files(['docs/'], extensions: ['.md'], exclude_patterns: ['temp/']) # With filtering
97
+
98
+ # Configure edit formats
99
+ client.edit_format_diff(true)
100
+ client.editor_edit_format_diff_fenced(true)
101
+
102
+ # Advanced model configuration
103
+ client.use_temperature(true)
104
+ client.use_system_prompt(true)
105
+ client.use_repo_map(true)
106
+ client.reasoning_effort('high')
107
+ client.thinking_tokens('8k')
108
+
109
+ # Add model aliases
110
+ client.add_alias('sonnet', 'claude-3-5-sonnet-20241022')
111
+ client.add_alias('fast', 'claude-3-5-haiku-20241022')
112
+
113
+ # Execute a task
114
+ result = client.execute("Create tests for this class")
115
+ puts result
116
+
117
+ # Interactive mode
118
+ client.interactive
119
+
120
+ # Advanced configuration
121
+ client
122
+ .model('gpt-4o')
123
+ .add_files('app/models/user.rb')
124
+ .dark_mode(true)
125
+ .auto_commits(true)
126
+ .lint(true)
127
+ .execute("Refactor this code")
128
+ ```
129
+
130
+ ### Error Handling
131
+
132
+ AiderRuby provides robust error handling with specialized error types:
133
+
134
+ ```ruby
135
+ begin
136
+ client = AiderRuby.new_client(model: 'invalid-model')
137
+ rescue AiderRuby::ErrorHandling::ModelError => e
138
+ puts "Model error: #{e.message}"
139
+ rescue AiderRuby::ErrorHandling::ConfigurationError => e
140
+ puts "Configuration error: #{e.message}"
141
+ rescue AiderRuby::ErrorHandling::ExecutionError => e
142
+ puts "Execution error: #{e.message}"
143
+ rescue AiderRuby::ErrorHandling::FileError => e
144
+ puts "File error: #{e.message}"
145
+ rescue AiderRuby::ErrorHandling::ValidationError => e
146
+ puts "Validation error: #{e.message}"
147
+ end
148
+ ```
149
+
150
+ ### Parameter Validation
151
+
152
+ Validation is automatic during configuration:
153
+
154
+ ```ruby
155
+ # ✅ Valid formats
156
+ client.edit_format_diff(true)
157
+ client.reasoning_effort('high')
158
+ client.thinking_tokens('8k')
159
+
160
+ # ❌ Invalid formats (raise ValidationError)
161
+ client.edit_format('invalid')
162
+ client.reasoning_effort('invalid')
163
+ client.thinking_tokens('invalid')
164
+ ```
165
+
166
+ ### File Management
167
+
168
+ AiderRuby provides flexible file management options:
169
+
170
+ #### Adding Files for Editing
171
+ ```ruby
172
+ # Single file
173
+ client.add_files('app/models/user.rb')
174
+
175
+ # Multiple files
176
+ client.add_files(['app/models/user.rb', 'app/models/post.rb'])
177
+
178
+ # Entire folder (with filters)
179
+ client.add_folder('app/models',
180
+ extensions: ['.rb'], # Only Ruby files
181
+ exclude_patterns: ['spec/', /_test\.rb$/] # Exclude test files
182
+ )
183
+ ```
184
+
185
+ #### Adding Files for Context (Read-Only)
186
+ ```ruby
187
+ # Single read-only file
188
+ client.add_read_only_file('README.md')
189
+
190
+ # Multiple read-only files
191
+ client.add_read_only_file(['docs/api.md', 'docs/guide.md'])
192
+
193
+ # Entire folder as context
194
+ client.add_read_only_folder('docs',
195
+ extensions: ['.md', '.txt'],
196
+ exclude_patterns: ['temp/', /\.tmp$/]
197
+ )
198
+
199
+ # Using conventions (alternative method)
200
+ client.add_read_files(['docs/guidelines.md', 'examples/patterns.rb'])
201
+ ```
202
+
203
+ #### Key Differences
204
+ - **`add_files()`**: Files that aider can **modify/edit** (uses `--file` flag)
205
+ - **`add_read_only_file()`**: Files for **context only** (uses `--read` flag)
206
+ - **`add_read_files()`**: Alternative method for read-only files (stored in config)
207
+ - **`add_folder()`**: Recursively adds all files in a folder for editing
208
+ - **`add_read_only_folder()`**: Recursively adds all files in a folder as context
209
+
210
+ ### Enhanced Convention Management
211
+
212
+ AiderRuby provides advanced convention management with validation and filtering:
213
+
214
+ #### Single Convention File
215
+ ```ruby
216
+ # Basic usage with validation (default)
217
+ client.conventions_files(['CONVENTIONS.md'])
218
+
219
+ # Skip validation for non-existent files
220
+ client.conventions_files(['CONVENTIONS.md'], validate: false)
221
+ ```
222
+
223
+ #### Multiple Convention Files
224
+ ```ruby
225
+ # Add multiple convention files
226
+ client.conventions_files(['CONVENTIONS.md', 'STYLE_GUIDE.md', 'PATTERNS.md'])
227
+
228
+ # With validation disabled
229
+ client.conventions_files(['CONVENTIONS.md', 'STYLE_GUIDE.md'], validate: false)
230
+ ```
231
+
232
+ #### Enhanced Read Files Management
233
+ ```ruby
234
+ # Basic usage
235
+ client.add_read_files(['docs/guidelines.md', 'examples/patterns.rb'])
236
+
237
+ # With filtering by extensions
238
+ client.add_read_files(['docs/'], extensions: ['.md', '.txt'])
239
+
240
+ # With exclusion patterns
241
+ client.add_read_files(['docs/'],
242
+ extensions: ['.md'],
243
+ exclude_patterns: ['temp/', /\.tmp$/, 'draft/']
244
+ )
245
+
246
+ # Skip validation
247
+ client.add_read_files(['docs/'], validate: false)
248
+
249
+ # Add from entire folder with filtering
250
+ client.add_read_files_from_folder('docs',
251
+ extensions: ['.md', '.txt'],
252
+ exclude_patterns: ['temp/', /\.tmp$/]
253
+ )
254
+
255
+ # Clear all read files
256
+ client.clear_read_files
257
+
258
+ # Get list of read files
259
+ files = client.read_files_list
260
+ ```
261
+
262
+ #### Key Differences
263
+ - **`conventions_files()`**: Convention files with validation (single or multiple)
264
+ - **`add_read_files()`**: Enhanced method with filtering and validation
265
+ - **`add_read_files_from_folder()`**: Add files from folder with filtering
266
+ - **`clear_read_files()`**: Clear all read files
267
+ - **`read_files_list()`**: Get current list of read files
268
+
269
+ ### Complete In-Code Configuration
270
+
271
+ AiderRuby allows complete configuration without external files or environment variables:
272
+
273
+ ```ruby
274
+ # Complete configuration in code
275
+ client = AiderRuby.new_client(
276
+ # Model configuration
277
+ model: 'claude-3-5-sonnet-20241022',
278
+ anthropic_api_key: 'sk-ant-your-key',
279
+ reasoning_effort: 'high',
280
+ thinking_tokens: '8k',
281
+
282
+ # Output configuration
283
+ dark_mode: true,
284
+ pretty: true,
285
+ stream: true,
286
+ show_diffs: true,
287
+
288
+ # Git configuration
289
+ git: true,
290
+ auto_commits: true,
291
+ dirty_commits: false,
292
+
293
+ # Linting and testing
294
+ lint: true,
295
+ auto_lint: true,
296
+ test: true,
297
+ auto_test: true,
298
+
299
+ # General settings
300
+ verbose: true,
301
+ encoding: 'utf-8',
302
+ suggest_shell_commands: true,
303
+ fancy_input: true,
304
+ detect_urls: true,
305
+
306
+ # Conventions and files
307
+ conventions_files: ['CONVENTIONS.md'],
308
+ read_files: ['README.md'],
309
+
310
+ # Edit formats
311
+ edit_format_diff: true
312
+ )
313
+
314
+ # Add files and execute
315
+ client
316
+ .add_files(['app/models/user.rb', 'app/models/post.rb'])
317
+ .add_read_only_file('docs/api.md')
318
+ .execute("Refactor this code")
319
+ ```
320
+
321
+ ### Configuration with Files
322
+
323
+ ```ruby
324
+ # YAML Configuration
325
+ AiderRuby.configure do
326
+ model 'claude-3-5-sonnet-20241022'
327
+ openai_api_key ENV['OPENAI_API_KEY']
328
+ anthropic_api_key ENV['ANTHROPIC_API_KEY']
329
+ dark_mode true
330
+ auto_commits true
331
+ lint true
332
+ auto_lint true
333
+ end
334
+
335
+ # Load from file
336
+ AiderRuby::Config.load_from_file('config/aider.yml')
337
+ AiderRuby::Config.load_from_env_file('.env')
338
+ ```
339
+
340
+ ### Specialized Task Execution
341
+
342
+ ```ruby
343
+ client = AiderRuby.new_client
344
+ executor = AiderRuby::TaskExecutor.new(client)
345
+
346
+ # Coding task
347
+ executor.execute_coding_task(
348
+ "Implement a REST API",
349
+ ['app/controllers/api_controller.rb']
350
+ )
351
+
352
+ # Refactoring task
353
+ executor.execute_refactoring_task(
354
+ "Refactor this class to follow SOLID principles",
355
+ ['app/models/user.rb']
356
+ )
357
+
358
+ # Debugging task
359
+ executor.execute_debugging_task(
360
+ "Fix errors in this function",
361
+ ['app/services/payment_service.rb']
362
+ )
363
+
364
+ # Documentation task
365
+ executor.execute_documentation_task(
366
+ "Create API documentation",
367
+ ['app/controllers/api_controller.rb']
368
+ )
369
+
370
+ # Test generation
371
+ executor.execute_test_generation_task(
372
+ "Generate comprehensive unit tests",
373
+ ['app/models/user.rb']
374
+ )
375
+
376
+ # Multi-step task
377
+ steps = [
378
+ "Analyze existing code",
379
+ "Identify possible improvements",
380
+ "Implement changes",
381
+ "Create tests"
382
+ ]
383
+ executor.execute_multi_step_task(steps, ['app/models/user.rb'])
384
+ ```
385
+
386
+ ### Model Management
387
+
388
+ ```ruby
389
+ # List available models
390
+ AiderRuby::Models.list_models
391
+ AiderRuby::Models.list_models(:openai)
392
+
393
+ # Check if a model is supported
394
+ AiderRuby::Models.supported_model?('gpt-4o')
395
+
396
+ # Get model provider
397
+ AiderRuby::Models.provider_for_model('gpt-4o')
398
+
399
+ # Check capabilities
400
+ AiderRuby::Models.is_reasoning_model?('o1-preview')
401
+ AiderRuby::Models.has_vision?('gpt-4o')
402
+
403
+ # Detailed information
404
+ info = AiderRuby::Models.model_info('gpt-4o')
405
+ puts "Context: #{info[:context_window]} tokens"
406
+ puts "Cost: $#{info[:cost_per_token][:input]} per 1M tokens"
407
+
408
+ # Recommended models
409
+ AiderRuby::Models.recommended_models
410
+ ```
411
+
412
+ ## Configuration
413
+
414
+ ### Environment Variables
415
+
416
+ ```bash
417
+ export OPENAI_API_KEY="your-openai-key"
418
+ export ANTHROPIC_API_KEY="your-anthropic-key"
419
+ export AIDER_MODEL="claude-3-5-sonnet-20241022"
420
+ export AIDER_DARK_MODE="true"
421
+ export AIDER_AUTO_COMMITS="true"
422
+ ```
423
+
424
+ ### YAML Configuration File
425
+
426
+ ```yaml
427
+ # config/aider.yml
428
+ model: claude-3-5-sonnet-20241022
429
+ openai_api_key: ${OPENAI_API_KEY}
430
+ anthropic_api_key: ${ANTHROPIC_API_KEY}
431
+ dark_mode: true
432
+ light_mode: false
433
+ pretty: true
434
+ stream: true
435
+ git: true
436
+ auto_commits: true
437
+ dirty_commits: false
438
+ lint: true
439
+ auto_lint: true
440
+ test: true
441
+ auto_test: true
442
+ verbose: false
443
+ encoding: utf-8
444
+ line_endings: platform
445
+ suggest_shell_commands: true
446
+ fancy_input: true
447
+ multiline: false
448
+ notifications: false
449
+ detect_urls: true
450
+ voice_format: wav
451
+ voice_language: en
452
+ ```
453
+
454
+ ### .env File
455
+
456
+ ```bash
457
+ # .env
458
+ OPENAI_API_KEY=your-openai-key
459
+ ANTHROPIC_API_KEY=your-anthropic-key
460
+ AIDER_MODEL=claude-3-5-sonnet-20241022
461
+ AIDER_DARK_MODE=true
462
+ AIDER_AUTO_COMMITS=true
463
+ ```
464
+
465
+ ## Features
466
+
467
+ ### Supported Models
468
+
469
+ - **OpenAI**: gpt-4o, gpt-4o-mini, gpt-4-turbo, gpt-4, gpt-3.5-turbo, o1-preview, o1-mini
470
+ - **Anthropic**: claude-3-5-sonnet, claude-3-5-haiku, claude-3-opus, claude-3-sonnet, claude-3-haiku
471
+ - **Google**: gemini-1.5-pro, gemini-1.5-flash, gemini-pro
472
+ - **GROQ**: llama-3.1-70b-versatile, llama-3.1-8b-instant, mixtral-8x7b-32768, gemma-7b-it
473
+ - **DeepSeek**: deepseek-chat, deepseek-coder
474
+ - **xAI**: grok-beta
475
+ - **Cohere**: command-r-plus, command-r, command-light
476
+
477
+ ### Task Types
478
+
479
+ - **Coding**: Development of new features
480
+ - **Refactoring**: Improvement of existing code
481
+ - **Debugging**: Problem resolution
482
+ - **Documentation**: Documentation creation
483
+ - **Test Generation**: Test generation
484
+ - **Multi-step**: Complex multi-step tasks
485
+
486
+ ### Configuration Options
487
+
488
+ - Model and API key configuration
489
+ - Reasoning parameters (reasoning_effort, thinking_tokens)
490
+ - Output options (dark_mode, pretty, stream)
491
+ - Git integration (auto_commits, dirty_commits)
492
+ - Automatic linting and testing
493
+ - Voice parameters
494
+ - Advanced model configuration
495
+ - **Coding conventions**: Support for convention files
496
+ - **Edit formats**: whole, diff, diff-fenced
497
+ - **Advanced parameters**: temperature, system prompt, repo map
498
+ - **Model aliases**: Custom alias definitions
499
+ - **Model metadata**: Capability and cost configuration
500
+
501
+ ## Development
502
+
503
+ ### Install Dependencies
504
+
505
+ ```bash
506
+ bundle install
507
+ ```
508
+
509
+ ### Tests
510
+
511
+ ```bash
512
+ bundle exec rspec
513
+ ```
514
+
515
+ ### Linting
516
+
517
+ ```bash
518
+ bundle exec rubocop
519
+ ```
520
+
521
+ ### Build Gem
522
+
523
+ ```bash
524
+ gem build aider-ruby.gemspec
525
+ gem install ./aider-ruby-0.1.0.gem
526
+ ```
527
+
528
+ ## License
529
+
530
+ MIT License
531
+
532
+ ## Contributing
533
+
534
+ Contributions are welcome! Feel free to open an issue or pull request.
535
+
536
+ ## Useful Links
537
+
538
+ - [Aider Documentation](https://aider.chat/docs/)
539
+ - [Configuration Options](https://aider.chat/docs/config/options.html)
540
+ - [Reasoning Models](https://aider.chat/docs/config/reasoning.html)
541
+ - [Advanced Model Settings](https://aider.chat/docs/config/adv-model-settings.html)
542
+ - [Scripting with Aider](https://aider.chat/docs/scripting.html)