From 2b7d018cd0fdf38b5dfc236935adf413a2e42887 Mon Sep 17 00:00:00 2001 From: Senko Rasic Date: Fri, 24 May 2024 12:51:29 +0200 Subject: [PATCH] use "continue" label for continue buttons; fix project template message --- core/agents/developer.py | 29 ++++++++++++++--------------- core/agents/spec_writer.py | 10 +++++++++- core/agents/tech_lead.py | 11 ++++++----- core/agents/troubleshooter.py | 4 ++-- core/cli/main.py | 2 +- core/templates/registry.py | 14 ++++++++++++++ 6 files changed, 46 insertions(+), 24 deletions(-) diff --git a/core/agents/developer.py b/core/agents/developer.py index ade58bccd8..909d8b3f12 100644 --- a/core/agents/developer.py +++ b/core/agents/developer.py @@ -55,9 +55,7 @@ class TaskSteps(BaseModel): class RelevantFiles(BaseModel): - relevant_files: list[str] = Field( - description="List of relevant files for the current task." - ) + relevant_files: list[str] = Field(description="List of relevant files for the current task.") class Developer(BaseAgent): @@ -206,20 +204,22 @@ class Developer(BaseAgent): return AgentResponse.done(self) async def get_relevant_files( - self, - user_feedback: Optional[str] = None, - solution_description: Optional[str] = None + self, user_feedback: Optional[str] = None, solution_description: Optional[str] = None ) -> AgentResponse: log.debug("Getting relevant files for the current task") await self.send_message("Figuring out which project files are relevant for the next task ...") llm = self.get_llm() - convo = AgentConvo(self).template( - "filter_files", - current_task=self.current_state.current_task, - user_feedback=user_feedback, - solution_description=solution_description, - ).require_schema(RelevantFiles) + convo = ( + AgentConvo(self) + .template( + "filter_files", + current_task=self.current_state.current_task, + user_feedback=user_feedback, + solution_description=solution_description, + ) + .require_schema(RelevantFiles) + ) llm_response: list[str] = await llm(convo, parser=JSONParser(RelevantFiles), temperature=0) @@ -290,9 +290,8 @@ class Developer(BaseAgent): user_response = await self.ask_question( "Edit the task description:", buttons={ - # FIXME: Continue doesn't actually work, VSCode doesn't send the user - # message if it's clicked. Long term we need to fix the extension. - # "continue": "Continue", + # FIXME: must be lowercase becase VSCode doesn't recognize it otherwise. Needs a fix in the extension + "continue": "continue", "cancel": "Cancel", }, default="continue", diff --git a/core/agents/spec_writer.py b/core/agents/spec_writer.py index 23047409b4..09a4468b73 100644 --- a/core/agents/spec_writer.py +++ b/core/agents/spec_writer.py @@ -26,7 +26,11 @@ class SpecWriter(BaseAgent): response = await self.ask_question( "Describe your app in as much detail as possible", allow_empty=False, - buttons={"example": "Start an example project"}, + buttons={ + # FIXME: must be lowercase becase VSCode doesn't recognize it otherwise. Needs a fix in the extension + "continue": "continue", + "example": "Start an example project", + }, ) if response.cancelled: return AgentResponse.error(self, "No project description") @@ -34,6 +38,10 @@ class SpecWriter(BaseAgent): if response.button == "example": self.prepare_example_project() return AgentResponse.done(self) + elif response.button == "continue": + # FIXME: Workaround for the fact that VSCode "continue" button does + # nothing but repeat the question. We reproduce this bug for bug here. + return AgentResponse.done(self) spec = response.text diff --git a/core/agents/tech_lead.py b/core/agents/tech_lead.py index 67ad656c40..fa8a9456c3 100644 --- a/core/agents/tech_lead.py +++ b/core/agents/tech_lead.py @@ -9,7 +9,7 @@ from core.agents.response import AgentResponse, ResponseType from core.db.models import Complexity from core.llm.parser import JSONParser from core.log import get_logger -from core.templates.registry import apply_project_template, get_template_summary +from core.templates.registry import apply_project_template, get_template_description, get_template_summary from core.ui.base import ProjectStage log = get_logger(__name__) @@ -76,8 +76,9 @@ class TechLead(BaseAgent): if len(state.epics) != 1 or not state.specification.template: return None - log.info(f"Applying project template: {self.current_state.specification.template}") - await self.send_message(f"Applying project template {self.current_state.specification.template} ...") + description = get_template_description(state.specification.template) + log.info(f"Applying project template: {state.specification.template}") + await self.send_message(f"Applying project template {description} ...") summary = await apply_project_template( self.current_state.specification.template, self.state_manager, @@ -92,11 +93,11 @@ class TechLead(BaseAgent): log.debug("Asking for new feature") response = await self.ask_question( "Do you have a new feature to add to the project? Just write it here", - buttons={"end": "No, I'm done"}, + buttons={"continue": "continue", "end": "No, I'm done"}, allow_empty=True, ) - if response.cancelled or response.button == "end" or not response.text: + if response.cancelled or not response.text: return AgentResponse.exit(self) self.next_state.epics = self.current_state.epics + [ diff --git a/core/agents/troubleshooter.py b/core/agents/troubleshooter.py index 9da6dbb23c..72bd3a52b4 100644 --- a/core/agents/troubleshooter.py +++ b/core/agents/troubleshooter.py @@ -175,9 +175,9 @@ class Troubleshooter(IterationPromptMixin, BaseAgent): if run_command: await self.ui.send_run_command(run_command) - buttons = {"continue": "Everything works, continue"} + buttons = {"continue": "continue"} if last_iteration: - buttons["loop"] = "I still have the same issue" + buttons["loop"] = "I'm stuck in a loop" user_response = await self.ask_question( test_message, diff --git a/core/cli/main.py b/core/cli/main.py index 2c55ae5ab9..af8ddc2adc 100644 --- a/core/cli/main.py +++ b/core/cli/main.py @@ -66,7 +66,7 @@ async def start_new_project(sm: StateManager, ui: UIBase) -> bool: :param ui: User interface. :return: True if the project was created successfully, False otherwise. """ - user_input = await ui.ask_question("What is the name of the project", allow_empty=False, source=pythagora_source) + user_input = await ui.ask_question("What is the project name?", allow_empty=False, source=pythagora_source) if user_input.cancelled: return False diff --git a/core/templates/registry.py b/core/templates/registry.py index e67d6dad87..3fdbd26da4 100644 --- a/core/templates/registry.py +++ b/core/templates/registry.py @@ -92,3 +92,17 @@ def get_template_summary(template_name: str) -> Optional[str]: return None template = PROJECT_TEMPLATES[template_name] return template["summary"] + + +def get_template_description(template_name: str) -> Optional[str]: + """ + Get the description of a project template. + + :param template_name: The name of the project template. + :return: A summary of the template, or None if no template was found. + """ + if not template_name or template_name not in PROJECT_TEMPLATES: + log.warning(f"Project template '{template_name}' not found, ignoring") + return None + template = PROJECT_TEMPLATES[template_name] + return template["description"]