From 39ed52328807a140dda8195ffd6701d523e91f75 Mon Sep 17 00:00:00 2001 From: Will Date: Fri, 14 Mar 2025 15:29:11 -0400 Subject: [PATCH 1/2] Removing get_aidr_executable as no longer a depedency --- ra_aid/tools/programmer.py | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/ra_aid/tools/programmer.py b/ra_aid/tools/programmer.py index 1a5d99c..c3962b8 100644 --- a/ra_aid/tools/programmer.py +++ b/ra_aid/tools/programmer.py @@ -20,31 +20,6 @@ from ra_aid.database.repositories.related_files_repository import get_related_fi console = Console() logger = get_logger(__name__) - -def get_aider_executable() -> str: - """Get the path to the aider executable in the same bin/Scripts directory as Python. - - Returns: - str: Full path to aider executable - """ - # Get directory containing Python executable - bin_dir = Path(sys.executable).parent - - # Check for platform-specific executable name - if sys.platform == "win32": - aider_exe = bin_dir / "aider.exe" - else: - aider_exe = bin_dir / "aider" - - if not aider_exe.exists(): - raise RuntimeError(f"Could not find aider executable at {aider_exe}") - - if not os.access(aider_exe, os.X_OK): - raise RuntimeError(f"Aider executable at {aider_exe} is not executable") - - return str(aider_exe) - - def _truncate_for_log(text: str, max_length: int = 300) -> str: """Truncate text for logging, adding [truncated] if necessary.""" if len(text) <= max_length: @@ -79,9 +54,8 @@ def run_programming_task( files: Optional; if not provided, uses related_files """ # Build command - aider_exe = get_aider_executable() command = [ - aider_exe, + "aider", "--yes-always", "--no-git", "--no-auto-commits", @@ -234,4 +208,4 @@ def parse_aider_flags(aider_flags: str) -> List[str]: # Export the functions -__all__ = ["run_programming_task", "get_aider_executable"] \ No newline at end of file +__all__ = ["run_programming_task"] \ No newline at end of file From 5445a5c4a98a9741a67bb66f7aa8e20c637c35b8 Mon Sep 17 00:00:00 2001 From: Will Date: Fri, 14 Mar 2025 15:35:34 -0400 Subject: [PATCH 2/2] Removing get_aider_executable test as no longer relevant --- tests/ra_aid/test_programmer.py | 55 --------------------------------- 1 file changed, 55 deletions(-) diff --git a/tests/ra_aid/test_programmer.py b/tests/ra_aid/test_programmer.py index 5e6380d..1e9e94e 100644 --- a/tests/ra_aid/test_programmer.py +++ b/tests/ra_aid/test_programmer.py @@ -3,7 +3,6 @@ import pytest from unittest.mock import patch, MagicMock from ra_aid.tools.programmer import ( - get_aider_executable, parse_aider_flags, run_programming_task, ) @@ -179,12 +178,6 @@ def test_path_normalization_and_deduplication(monkeypatch, tmp_path, mock_config test_file.write_text("") new_file = tmp_path / "new.py" - # Config is mocked by mock_config_repository fixture - monkeypatch.setattr( - "ra_aid.tools.programmer.get_aider_executable", - lambda: "/path/to/aider" - ) - mock_run = MagicMock(return_value=(b"", 0)) monkeypatch.setattr("ra_aid.tools.programmer.run_interactive_command", mock_run) @@ -219,51 +212,3 @@ def test_path_normalization_and_deduplication(monkeypatch, tmp_path, mock_config assert ( sum(1 for arg in cmd_args if arg == str(new_file)) == 1 ), "Expected one instance of new_file" - - -def test_get_aider_executable(monkeypatch): - """Test the get_aider_executable function.""" - # Create mock objects using standard unittest.mock.MagicMock - mock_path_instance = MagicMock() - mock_parent = MagicMock() - mock_aider = MagicMock() - - # Setup sys mock - mock_sys_attrs = { - "executable": "/path/to/venv/bin/python", - "platform": "linux" - } - monkeypatch.setattr("ra_aid.tools.programmer.sys", MagicMock(**mock_sys_attrs)) - - # Setup Path mock - monkeypatch.setattr("ra_aid.tools.programmer.Path", lambda x: mock_path_instance) - mock_path_instance.parent = mock_parent - mock_parent.__truediv__.return_value = mock_aider - mock_aider.exists.return_value = True - - # Setup os mock - mock_os = MagicMock() - mock_os.access.return_value = True - mock_os.X_OK = 1 - monkeypatch.setattr("ra_aid.tools.programmer.os", mock_os) - - # Test happy path on Linux - aider_path = get_aider_executable() - assert aider_path == str(mock_aider) - mock_parent.__truediv__.assert_called_with("aider") - - # Test Windows path - monkeypatch.setattr("ra_aid.tools.programmer.sys.platform", "win32") - aider_path = get_aider_executable() - mock_parent.__truediv__.assert_called_with("aider.exe") - - # Test executable not found - mock_aider.exists.return_value = False - with pytest.raises(RuntimeError, match="Could not find aider executable"): - get_aider_executable() - - # Test not executable - mock_aider.exists.return_value = True - mock_os.access.return_value = False - with pytest.raises(RuntimeError, match="is not executable"): - get_aider_executable() \ No newline at end of file