Add Aider config File Argument Support (#43)

* feat(main.py): add --aider-config argument to specify aider config file path for better configuration management
feat(programmer.py): include aider config in command if specified to enhance functionality
test: add unit test for aider config flag inclusion in command to ensure correct behavior
chore: update requirements-dev.txt to include pytest-mock for testing enhancements

* test(tests/ra_aid/test_programmer.py): remove unnecessary comments to improve code readability and maintainability
This commit is contained in:
Ariel Frischer 2025-01-21 10:17:59 -08:00 committed by GitHub
parent 46e7340ddb
commit 7a68de2d06
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 30 additions and 1 deletions

View File

@ -128,6 +128,11 @@ Examples:
default=DEFAULT_RECURSION_LIMIT,
help="Maximum recursion depth for agent operations (default: 100)",
)
parser.add_argument(
'--aider-config',
type=str,
help='Specify the aider config file path'
)
if args is None:
args = sys.argv[1:]
@ -321,6 +326,7 @@ def main():
"research_only": args.research_only,
"cowboy_mode": args.cowboy_mode,
"web_research_enabled": web_research_enabled,
"aider_config": args.aider_config,
"limit_tokens": args.disable_limit_tokens,
}

View File

@ -45,6 +45,10 @@ Returns: { "output": stdout+stderr, "return_code": 0 if success, "success": True
"--no-suggest-shell-commands",
]
# Add config file if specified
if 'config' in _global_memory and _global_memory['config'].get('aider_config'):
command.extend(['--config', _global_memory['config']['aider_config']])
# if environment variable AIDER_FLAGS exists then parse
if 'AIDER_FLAGS' in os.environ:
# wrap in try catch in case of any error and log the error

View File

@ -1,3 +1,4 @@
pytest-timeout>=2.2.0
pytest>=7.0.0
pytest-cov>=4.1.0
pytest-mock>=4.0.0

View File

@ -1,5 +1,5 @@
import pytest
from ra_aid.tools.programmer import parse_aider_flags
from ra_aid.tools.programmer import parse_aider_flags, run_programming_task
# Test cases for parse_aider_flags function
test_cases = [
@ -51,3 +51,21 @@ def test_parse_aider_flags(input_flags, expected, description):
"""Table-driven test for parse_aider_flags function."""
result = parse_aider_flags(input_flags)
assert result == expected, f"Failed test case: {description}"
def test_aider_config_flag(mocker):
"""Test that aider config flag is properly included in the command when specified."""
mock_memory = {
'config': {'aider_config': '/path/to/config.yml'},
'related_files': {}
}
mocker.patch('ra_aid.tools.programmer._global_memory', mock_memory)
# Mock the run_interactive_command to capture the command that would be run
mock_run = mocker.patch('ra_aid.tools.programmer.run_interactive_command', return_value=(b'', 0))
run_programming_task("test instruction")
args = mock_run.call_args[0][0] # Get the first positional arg (command list)
assert '--config' in args
config_index = args.index('--config')
assert args[config_index + 1] == '/path/to/config.yml'