diff --git a/ra_aid/__main__.py b/ra_aid/__main__.py index 72df89b..6c2489f 100644 --- a/ra_aid/__main__.py +++ b/ra_aid/__main__.py @@ -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, } diff --git a/ra_aid/tools/programmer.py b/ra_aid/tools/programmer.py index 62e8b1f..111e292 100644 --- a/ra_aid/tools/programmer.py +++ b/ra_aid/tools/programmer.py @@ -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 diff --git a/requirements-dev.txt b/requirements-dev.txt index 2103569..3095c4f 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,3 +1,4 @@ pytest-timeout>=2.2.0 pytest>=7.0.0 pytest-cov>=4.1.0 +pytest-mock>=4.0.0 diff --git a/tests/ra_aid/test_programmer.py b/tests/ra_aid/test_programmer.py index fc99963..3fdf0f3 100644 --- a/tests/ra_aid/test_programmer.py +++ b/tests/ra_aid/test_programmer.py @@ -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'