From 89c3f510f35d2f263f3987bb76a3ec939ffbbe06 Mon Sep 17 00:00:00 2001 From: LeonOstrez Date: Tue, 19 Nov 2024 12:08:58 +0100 Subject: [PATCH] add --git-use flag --- core/agents/base.py | 2 ++ core/agents/orchestrator.py | 2 +- core/cli/helpers.py | 2 ++ core/cli/main.py | 7 ++++--- tests/cli/test_cli.py | 1 + 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/core/agents/base.py b/core/agents/base.py index 5be44511..c1e55a75 100644 --- a/core/agents/base.py +++ b/core/agents/base.py @@ -29,6 +29,7 @@ class BaseAgent: prev_response: Optional["AgentResponse"] = None, process_manager: Optional["ProcessManager"] = None, data: Optional[Any] = None, + args: Optional[Any] = None, ): """ Create a new agent. @@ -40,6 +41,7 @@ class BaseAgent: self.prev_response = prev_response self.step = step self.data = data + self.args = args @property def current_state(self) -> ProjectState: diff --git a/core/agents/orchestrator.py b/core/agents/orchestrator.py index 5557376e..9c34d870 100644 --- a/core/agents/orchestrator.py +++ b/core/agents/orchestrator.py @@ -57,7 +57,7 @@ class Orchestrator(BaseAgent, GitMixin): await self.init_ui() await self.offline_changes_check() - if await self.check_git_installed(): + if self.args.use_git and await self.check_git_installed(): await self.init_git_if_needed() # TODO: consider refactoring this into two loop; the outer with one iteration per comitted step, diff --git a/core/cli/helpers.py b/core/cli/helpers.py index 079fa7db..1eac6d3b 100644 --- a/core/cli/helpers.py +++ b/core/cli/helpers.py @@ -96,6 +96,7 @@ def parse_arguments() -> Namespace: --email: User's email address, if provided --extension-version: Version of the VSCode extension, if used --no-check: Disable initial LLM API check + --use-git: Use Git for version control :return: Parsed arguments object. """ version = get_version() @@ -136,6 +137,7 @@ def parse_arguments() -> Namespace: parser.add_argument("--email", help="User's email address", required=False) parser.add_argument("--extension-version", help="Version of the VSCode extension", required=False) parser.add_argument("--no-check", help="Disable initial LLM API check", action="store_true") + parser.add_argument("--use-git", help="Use Git for version control", action="store_true", required=False) return parser.parse_args() diff --git a/core/cli/main.py b/core/cli/main.py index 8a441d65..454d9a41 100644 --- a/core/cli/main.py +++ b/core/cli/main.py @@ -34,7 +34,7 @@ def sync_cleanup(ui: UIBase): asyncio.run(cleanup(ui)) -async def run_project(sm: StateManager, ui: UIBase) -> bool: +async def run_project(sm: StateManager, ui: UIBase, args) -> bool: """ Work on the project. @@ -43,13 +43,14 @@ async def run_project(sm: StateManager, ui: UIBase) -> bool: :param sm: State manager. :param ui: User interface. + :param args: Command-line arguments. :return: True if the orchestrator exited successfully, False otherwise. """ telemetry.set("app_id", str(sm.project.id)) telemetry.set("initial_prompt", sm.current_state.specification.description) - orca = Orchestrator(sm, ui) + orca = Orchestrator(sm, ui, args=args) success = False try: success = await orca.run() @@ -229,7 +230,7 @@ async def run_pythagora_session(sm: StateManager, ui: UIBase, args: Namespace): if not success: return False - return await run_project(sm, ui) + return await run_project(sm, ui, args) async def async_main( diff --git a/tests/cli/test_cli.py b/tests/cli/test_cli.py index 01bad3d7..42e6f6c5 100644 --- a/tests/cli/test_cli.py +++ b/tests/cli/test_cli.py @@ -57,6 +57,7 @@ def test_parse_arguments(mock_ArgumentParser): "--email", "--extension-version", "--no-check", + "--use-git", } parser.parse_args.assert_called_once_with()