From 376ed5fdafa8a2f67edf94a76b275d01ebbbc239 Mon Sep 17 00:00:00 2001 From: matija-ilijas Date: Wed, 24 Jul 2024 11:52:06 +0200 Subject: [PATCH 01/14] Added initial add feature functionality --- core/agents/orchestrator.py | 3 +- core/agents/response.py | 7 ++++ core/agents/spec_writer.py | 41 ++++++++++++++++++- .../spec-writer/add_new_feature.prompt | 21 ++++++++++ 4 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 core/prompts/spec-writer/add_new_feature.prompt diff --git a/core/agents/orchestrator.py b/core/agents/orchestrator.py index 0c31132ff2..3966020adf 100644 --- a/core/agents/orchestrator.py +++ b/core/agents/orchestrator.py @@ -182,7 +182,8 @@ class Orchestrator(BaseAgent): return Importer(self.state_manager, self.ui, prev_response=prev_response) if prev_response.type == ResponseType.EXTERNAL_DOCS_REQUIRED: return ExternalDocumentation(self.state_manager, self.ui, prev_response=prev_response) - + if prev_response.type == ResponseType.NEW_FEATURE_REQUESTED: + return SpecWriter(self.state_manager, self.ui, prev_response=prev_response) if not state.specification.description: if state.files: # The project has been imported, but not analyzed yet diff --git a/core/agents/response.py b/core/agents/response.py index d41843367c..7b777eb6d3 100644 --- a/core/agents/response.py +++ b/core/agents/response.py @@ -45,6 +45,9 @@ class ResponseType(str, Enum): EXTERNAL_DOCS_REQUIRED = "external-docs-required" """We need to fetch external docs for a task.""" + NEW_FEATURE_REQUESTED = "new-feature-requested" + """User wants to add a new feature to project specification.""" + class AgentResponse: type: ResponseType = ResponseType.DONE @@ -144,3 +147,7 @@ class AgentResponse: @staticmethod def external_docs_required(agent: "BaseAgent") -> "AgentResponse": return AgentResponse(type=ResponseType.EXTERNAL_DOCS_REQUIRED, agent=agent) + + @staticmethod + def new_feature_requested(agent: "BaseAgent") -> "AgentResponse": + return AgentResponse(type=ResponseType.NEW_FEATURE_REQUESTED, agent=agent) diff --git a/core/agents/spec_writer.py b/core/agents/spec_writer.py index 5002f734c8..d586e28ff9 100644 --- a/core/agents/spec_writer.py +++ b/core/agents/spec_writer.py @@ -1,6 +1,6 @@ from core.agents.base import BaseAgent from core.agents.convo import AgentConvo -from core.agents.response import AgentResponse +from core.agents.response import AgentResponse, ResponseType from core.db.models import Complexity from core.llm.parser import StringParser from core.log import get_logger @@ -26,6 +26,12 @@ class SpecWriter(BaseAgent): display_name = "Spec Writer" async def run(self) -> AgentResponse: + if self.prev_response and self.prev_response.type == ResponseType.NEW_FEATURE_REQUESTED: + return await self.update_spec() + else: + return await self.initialize_spec() + + async def initialize_spec(self) -> AgentResponse: response = await self.ask_question( "Describe your app in as much detail as possible", allow_empty=False, @@ -72,6 +78,39 @@ class SpecWriter(BaseAgent): telemetry.set("initial_prompt", spec) telemetry.set("is_complex_app", complexity != Complexity.SIMPLE) + self.next_state.action = SPEC_STEP_NAME + return AgentResponse.new_feature_requested(self) + + async def update_spec(self) -> AgentResponse: + response = await self.ask_question( + "Describe the new feature you want to add", + allow_empty=False, + buttons={ + # FIXME: must be lowercase becase VSCode doesn't recognize it otherwise. Needs a fix in the extension + "cancel": "cancel", + }, + ) + if response.cancelled: + return AgentResponse.error(self, "No feature description") + + if response.button == "cancel": + return AgentResponse.error(self, "No feature description") + + feature_description = response.text.strip() + + await self.send_message("Adding new feature to project specification ...") + llm = self.get_llm() + convo = AgentConvo(self).template("add_new_feature", feature_description=feature_description) + llm_response: str = await llm(convo, temperature=0, parser=StringParser()) + updated_spec = llm_response.strip() + + self.next_state.specification = self.current_state.specification.clone() + self.next_state.specification.description = updated_spec + + telemetry.set( + "initial_prompt", updated_spec + ) # TODO Check if a separate telemetry variable needed for updated spec + self.next_state.action = SPEC_STEP_NAME return AgentResponse.done(self) diff --git a/core/prompts/spec-writer/add_new_feature.prompt b/core/prompts/spec-writer/add_new_feature.prompt new file mode 100644 index 0000000000..395efe3b9b --- /dev/null +++ b/core/prompts/spec-writer/add_new_feature.prompt @@ -0,0 +1,21 @@ +Your team has taken the client brief and turned it into a project specification. +Afterwards the client added a description for a new feature to be added to the project specification. +Your job is to update the project specification so that it contains the new feature information but does not lack any of the information from the original project specification. + +This might include: +* details on how the app should work +* information which 3rd party packages or APIs to use or avoid +* concrete examples of API requests/responses, library usage, or other external documentation + +Here is the client brief: +---PROJECT-SPECIFICATION-START--- +{{ state.specification.description }} +---PROJECT-SPECIFICATION-END--- + +Here is the specification your team came up with: +---FEATURE-DESCRIPTION-START--- +{{ feature_description }} +---FEATURE-DESCRIPTION-END--- + +In your response, output the new updated project specification. +If there is no feature description, just output the original project specification. From 17bdaf2fb33cdbbc6495dda3f8f258b9c4b7ac14 Mon Sep 17 00:00:00 2001 From: matija-ilijas Date: Thu, 25 Jul 2024 14:43:38 +0200 Subject: [PATCH 02/14] Added new feature request in deep focus pipeline --- core/agents/orchestrator.py | 5 +++-- core/agents/response.py | 3 --- core/agents/spec_writer.py | 28 ++++++++-------------------- core/agents/troubleshooter.py | 4 ++-- core/db/models/project_state.py | 1 + 5 files changed, 14 insertions(+), 27 deletions(-) diff --git a/core/agents/orchestrator.py b/core/agents/orchestrator.py index 3966020adf..475f37ac0a 100644 --- a/core/agents/orchestrator.py +++ b/core/agents/orchestrator.py @@ -182,8 +182,6 @@ class Orchestrator(BaseAgent): return Importer(self.state_manager, self.ui, prev_response=prev_response) if prev_response.type == ResponseType.EXTERNAL_DOCS_REQUIRED: return ExternalDocumentation(self.state_manager, self.ui, prev_response=prev_response) - if prev_response.type == ResponseType.NEW_FEATURE_REQUESTED: - return SpecWriter(self.state_manager, self.ui, prev_response=prev_response) if not state.specification.description: if state.files: # The project has been imported, but not analyzed yet @@ -253,6 +251,9 @@ class Orchestrator(BaseAgent): elif current_iteration_status == IterationStatus.PROBLEM_SOLVER: # Call Problem Solver if the user said "I'm stuck in a loop" return ProblemSolver(self.state_manager, self.ui) + elif current_iteration_status == IterationStatus.NEW_FEATURE_REQUESTED: + # Call Spec Writer to add the "change" requested by the user to project specification + return SpecWriter(self.state_manager, self.ui) # We have just finished the task, call Troubleshooter to ask the user to review return Troubleshooter(self.state_manager, self.ui) diff --git a/core/agents/response.py b/core/agents/response.py index 7b777eb6d3..4a4855f418 100644 --- a/core/agents/response.py +++ b/core/agents/response.py @@ -45,9 +45,6 @@ class ResponseType(str, Enum): EXTERNAL_DOCS_REQUIRED = "external-docs-required" """We need to fetch external docs for a task.""" - NEW_FEATURE_REQUESTED = "new-feature-requested" - """User wants to add a new feature to project specification.""" - class AgentResponse: type: ResponseType = ResponseType.DONE diff --git a/core/agents/spec_writer.py b/core/agents/spec_writer.py index d586e28ff9..3265ba046e 100644 --- a/core/agents/spec_writer.py +++ b/core/agents/spec_writer.py @@ -1,6 +1,7 @@ from core.agents.base import BaseAgent from core.agents.convo import AgentConvo -from core.agents.response import AgentResponse, ResponseType +from core.agents.response import AgentResponse +from core.db.models.project_state import IterationStatus from core.db.models import Complexity from core.llm.parser import StringParser from core.log import get_logger @@ -26,7 +27,8 @@ class SpecWriter(BaseAgent): display_name = "Spec Writer" async def run(self) -> AgentResponse: - if self.prev_response and self.prev_response.type == ResponseType.NEW_FEATURE_REQUESTED: + current_iteration = self.current_state.current_iteration + if current_iteration is not None and current_iteration["status"] == IterationStatus.NEW_FEATURE_REQUESTED: return await self.update_spec() else: return await self.initialize_spec() @@ -79,25 +81,10 @@ class SpecWriter(BaseAgent): telemetry.set("is_complex_app", complexity != Complexity.SIMPLE) self.next_state.action = SPEC_STEP_NAME - return AgentResponse.new_feature_requested(self) + return AgentResponse.done(self) async def update_spec(self) -> AgentResponse: - response = await self.ask_question( - "Describe the new feature you want to add", - allow_empty=False, - buttons={ - # FIXME: must be lowercase becase VSCode doesn't recognize it otherwise. Needs a fix in the extension - "cancel": "cancel", - }, - ) - if response.cancelled: - return AgentResponse.error(self, "No feature description") - - if response.button == "cancel": - return AgentResponse.error(self, "No feature description") - - feature_description = response.text.strip() - + feature_description = self.current_state.current_iteration["description"] await self.send_message("Adding new feature to project specification ...") llm = self.get_llm() convo = AgentConvo(self).template("add_new_feature", feature_description=feature_description) @@ -111,7 +98,8 @@ class SpecWriter(BaseAgent): "initial_prompt", updated_spec ) # TODO Check if a separate telemetry variable needed for updated spec - self.next_state.action = SPEC_STEP_NAME + self.next_state.current_iteration["status"] = IterationStatus.FIND_SOLUTION + self.next_state.flag_iterations_as_modified() return AgentResponse.done(self) async def check_prompt_complexity(self, prompt: str) -> str: diff --git a/core/agents/troubleshooter.py b/core/agents/troubleshooter.py index 6a3ebcccf9..d6b6159638 100644 --- a/core/agents/troubleshooter.py +++ b/core/agents/troubleshooter.py @@ -87,7 +87,7 @@ class Troubleshooter(IterationPromptMixin, BaseAgent): return await self.complete_task() user_feedback = bug_report or change_description - user_feedback_qa = await self.generate_bug_report(run_command, user_instructions, user_feedback) + user_feedback_qa = None # await self.generate_bug_report(run_command, user_instructions, user_feedback) if is_loop: if last_iteration["alternative_solutions"]: @@ -102,7 +102,7 @@ class Troubleshooter(IterationPromptMixin, BaseAgent): else: # should be - elif change_description is not None: - but to prevent bugs with the extension # this might be caused if we show the input field instead of buttons - iteration_status = IterationStatus.FIND_SOLUTION + iteration_status = IterationStatus.NEW_FEATURE_REQUESTED self.next_state.iterations = self.current_state.iterations + [ { diff --git a/core/db/models/project_state.py b/core/db/models/project_state.py index 5d4db95f60..67ad685ad0 100644 --- a/core/db/models/project_state.py +++ b/core/db/models/project_state.py @@ -41,6 +41,7 @@ class IterationStatus: IMPLEMENT_SOLUTION = "implement_solution" FIND_SOLUTION = "find_solution" PROBLEM_SOLVER = "problem_solver" + NEW_FEATURE_REQUESTED = "new_feature_requested" DONE = "done" From 3043b9301ce851bfea2b43561da705decea31aab Mon Sep 17 00:00:00 2001 From: matija-ilijas Date: Thu, 25 Jul 2024 16:20:11 +0200 Subject: [PATCH 03/14] Minor formatting --- core/agents/spec_writer.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/agents/spec_writer.py b/core/agents/spec_writer.py index 3265ba046e..f1222fc84a 100644 --- a/core/agents/spec_writer.py +++ b/core/agents/spec_writer.py @@ -1,8 +1,8 @@ from core.agents.base import BaseAgent from core.agents.convo import AgentConvo from core.agents.response import AgentResponse -from core.db.models.project_state import IterationStatus from core.db.models import Complexity +from core.db.models.project_state import IterationStatus from core.llm.parser import StringParser from core.log import get_logger from core.telemetry import telemetry @@ -85,7 +85,9 @@ class SpecWriter(BaseAgent): async def update_spec(self) -> AgentResponse: feature_description = self.current_state.current_iteration["description"] - await self.send_message("Adding new feature to project specification ...") + await self.send_message( + f"Adding feature with the following description to project specification:\n\n{feature_description}" + ) llm = self.get_llm() convo = AgentConvo(self).template("add_new_feature", feature_description=feature_description) llm_response: str = await llm(convo, temperature=0, parser=StringParser()) From 5e2cf85addaec5496de6bd94be29f8614d573d8a Mon Sep 17 00:00:00 2001 From: matija-ilijas Date: Thu, 25 Jul 2024 20:51:42 +0200 Subject: [PATCH 04/14] Minor fixes and database update --- .pre-commit-config.yaml | 4 +-- core/agents/response.py | 4 --- core/agents/spec_writer.py | 9 +++-- core/agents/tech_lead.py | 3 +- core/agents/troubleshooter.py | 2 +- ..._add_original_description_and_template_.py | 36 +++++++++++++++++++ core/db/models/specification.py | 4 +++ core/telemetry/__init__.py | 2 ++ 8 files changed, 51 insertions(+), 13 deletions(-) create mode 100644 core/db/migrations/versions/c8905d4ce784_add_original_description_and_template_.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 975ececd9f..5695bb827d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,7 @@ repos: name: alembic stages: [commit] types: [python] - entry: alembic -c core/db/alembic.ini check + entry: /Users/milijas/Code/PythagoraDev/gpt-pilot/venv/bin/alembic -c core/db/alembic.ini check language: system pass_filenames: false - repo: local @@ -26,6 +26,6 @@ repos: name: pytest stages: [commit] types: [python] - entry: pytest + entry: /Users/milijas/Code/PythagoraDev/gpt-pilot/venv/bin/pytest language: system pass_filenames: false diff --git a/core/agents/response.py b/core/agents/response.py index 4a4855f418..d41843367c 100644 --- a/core/agents/response.py +++ b/core/agents/response.py @@ -144,7 +144,3 @@ class AgentResponse: @staticmethod def external_docs_required(agent: "BaseAgent") -> "AgentResponse": return AgentResponse(type=ResponseType.EXTERNAL_DOCS_REQUIRED, agent=agent) - - @staticmethod - def new_feature_requested(agent: "BaseAgent") -> "AgentResponse": - return AgentResponse(type=ResponseType.NEW_FEATURE_REQUESTED, agent=agent) diff --git a/core/agents/spec_writer.py b/core/agents/spec_writer.py index f1222fc84a..a53529dcdd 100644 --- a/core/agents/spec_writer.py +++ b/core/agents/spec_writer.py @@ -28,7 +28,7 @@ class SpecWriter(BaseAgent): async def run(self) -> AgentResponse: current_iteration = self.current_state.current_iteration - if current_iteration is not None and current_iteration["status"] == IterationStatus.NEW_FEATURE_REQUESTED: + if current_iteration is not None and current_iteration.get("status") == IterationStatus.NEW_FEATURE_REQUESTED: return await self.update_spec() else: return await self.initialize_spec() @@ -75,6 +75,7 @@ class SpecWriter(BaseAgent): spec = await self.review_spec(spec) self.next_state.specification = self.current_state.specification.clone() + self.next_state.specification.original_description = spec self.next_state.specification.description = spec self.next_state.specification.complexity = complexity telemetry.set("initial_prompt", spec) @@ -84,7 +85,7 @@ class SpecWriter(BaseAgent): return AgentResponse.done(self) async def update_spec(self) -> AgentResponse: - feature_description = self.current_state.current_iteration["description"] + feature_description = self.current_state.current_iteration["user_feedback"] await self.send_message( f"Adding feature with the following description to project specification:\n\n{feature_description}" ) @@ -96,9 +97,7 @@ class SpecWriter(BaseAgent): self.next_state.specification = self.current_state.specification.clone() self.next_state.specification.description = updated_spec - telemetry.set( - "initial_prompt", updated_spec - ) # TODO Check if a separate telemetry variable needed for updated spec + telemetry.set("updated_prompt", updated_spec) self.next_state.current_iteration["status"] = IterationStatus.FIND_SOLUTION self.next_state.flag_iterations_as_modified() diff --git a/core/agents/tech_lead.py b/core/agents/tech_lead.py index 69464a52e8..5e572b17df 100644 --- a/core/agents/tech_lead.py +++ b/core/agents/tech_lead.py @@ -107,7 +107,8 @@ class TechLead(BaseAgent): if summaries: spec = self.current_state.specification.clone() - spec.description += "\n\n" + "\n\n".join(summaries) + spec.template_summary = "\n\n".join(summaries) + self.next_state.specification = spec async def ask_for_new_feature(self) -> AgentResponse: diff --git a/core/agents/troubleshooter.py b/core/agents/troubleshooter.py index d6b6159638..dc753b53c2 100644 --- a/core/agents/troubleshooter.py +++ b/core/agents/troubleshooter.py @@ -109,7 +109,7 @@ class Troubleshooter(IterationPromptMixin, BaseAgent): "id": uuid4().hex, "user_feedback": user_feedback, "user_feedback_qa": user_feedback_qa, - "description": change_description, + "description": None, "alternative_solutions": [], # FIXME - this is incorrect if this is a new problem; otherwise we could # just count the iterations diff --git a/core/db/migrations/versions/c8905d4ce784_add_original_description_and_template_.py b/core/db/migrations/versions/c8905d4ce784_add_original_description_and_template_.py new file mode 100644 index 0000000000..5d76dba8ce --- /dev/null +++ b/core/db/migrations/versions/c8905d4ce784_add_original_description_and_template_.py @@ -0,0 +1,36 @@ +"""Add original description and template summary fields to specifications + +Revision ID: c8905d4ce784 +Revises: 08d71952ec2f +Create Date: 2024-07-25 19:24:23.808237 + +""" + +from typing import Sequence, Union + +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision: str = "c8905d4ce784" +down_revision: Union[str, None] = "08d71952ec2f" +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table("specifications", schema=None) as batch_op: + batch_op.add_column(sa.Column("original_description", sa.String(), nullable=True)) + batch_op.add_column(sa.Column("template_summary", sa.String(), nullable=True)) + + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table("specifications", schema=None) as batch_op: + batch_op.drop_column("template_summary") + batch_op.drop_column("original_description") + + # ### end Alembic commands ### diff --git a/core/db/models/specification.py b/core/db/models/specification.py index 99eb54037e..7631fdeba1 100644 --- a/core/db/models/specification.py +++ b/core/db/models/specification.py @@ -26,7 +26,9 @@ class Specification(Base): id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True) # Attributes + original_description: Mapped[Optional[str]] = mapped_column() description: Mapped[str] = mapped_column(default="") + template_summary: Mapped[Optional[str]] = mapped_column() architecture: Mapped[str] = mapped_column(default="") system_dependencies: Mapped[list[dict]] = mapped_column(default=list) package_dependencies: Mapped[list[dict]] = mapped_column(default=list) @@ -43,7 +45,9 @@ class Specification(Base): Clone the specification. """ clone = Specification( + original_description=self.original_description, description=self.description, + template_summary=self.template_summary, architecture=self.architecture, system_dependencies=self.system_dependencies, package_dependencies=self.package_dependencies, diff --git a/core/telemetry/__init__.py b/core/telemetry/__init__.py index 89bd68a81a..16e62f6086 100644 --- a/core/telemetry/__init__.py +++ b/core/telemetry/__init__.py @@ -82,6 +82,8 @@ class Telemetry: "model": config.agent["default"].model, # Initial prompt "initial_prompt": None, + # Updated prompt + "updated_prompt": None, # App complexity "is_complex_app": None, # Optional template used for the project From c0e27081b1b4fbb03c079310cff1a92376c7ecbc Mon Sep 17 00:00:00 2001 From: matija-ilijas Date: Fri, 26 Jul 2024 11:52:46 +0200 Subject: [PATCH 05/14] Changed back pre-commit-config-yaml --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5695bb827d..975ececd9f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,7 @@ repos: name: alembic stages: [commit] types: [python] - entry: /Users/milijas/Code/PythagoraDev/gpt-pilot/venv/bin/alembic -c core/db/alembic.ini check + entry: alembic -c core/db/alembic.ini check language: system pass_filenames: false - repo: local @@ -26,6 +26,6 @@ repos: name: pytest stages: [commit] types: [python] - entry: /Users/milijas/Code/PythagoraDev/gpt-pilot/venv/bin/pytest + entry: pytest language: system pass_filenames: false From a7b0ad12cb4a67996f98e4b4e87d0b193eeb10f1 Mon Sep 17 00:00:00 2001 From: matija-ilijas Date: Fri, 26 Jul 2024 19:45:56 +0200 Subject: [PATCH 06/14] Added specification update to new feature add on app load and diff display on ui --- core/agents/orchestrator.py | 3 ++ core/agents/response.py | 13 ++++++ core/agents/spec_writer.py | 41 ++++++++++++++----- core/agents/tech_lead.py | 5 +-- core/agents/troubleshooter.py | 8 ++-- .../spec-writer/add_new_feature.prompt | 10 ++--- core/ui/ipc_client.py | 15 +++++++ tests/agents/test_tech_lead.py | 2 +- 8 files changed, 71 insertions(+), 26 deletions(-) diff --git a/core/agents/orchestrator.py b/core/agents/orchestrator.py index 475f37ac0a..2b6bdc439b 100644 --- a/core/agents/orchestrator.py +++ b/core/agents/orchestrator.py @@ -182,6 +182,9 @@ class Orchestrator(BaseAgent): return Importer(self.state_manager, self.ui, prev_response=prev_response) if prev_response.type == ResponseType.EXTERNAL_DOCS_REQUIRED: return ExternalDocumentation(self.state_manager, self.ui, prev_response=prev_response) + if prev_response.type == ResponseType.UPDATE_SPECIFICATION: + return SpecWriter(self.state_manager, self.ui, prev_response=prev_response) + if not state.specification.description: if state.files: # The project has been imported, but not analyzed yet diff --git a/core/agents/response.py b/core/agents/response.py index d41843367c..3fa0d61cd2 100644 --- a/core/agents/response.py +++ b/core/agents/response.py @@ -45,6 +45,9 @@ class ResponseType(str, Enum): EXTERNAL_DOCS_REQUIRED = "external-docs-required" """We need to fetch external docs for a task.""" + UPDATE_SPECIFICATION = "update-specification" + """We need to update the project specification.""" + class AgentResponse: type: ResponseType = ResponseType.DONE @@ -144,3 +147,13 @@ class AgentResponse: @staticmethod def external_docs_required(agent: "BaseAgent") -> "AgentResponse": return AgentResponse(type=ResponseType.EXTERNAL_DOCS_REQUIRED, agent=agent) + + @staticmethod + def update_specification(agent: "BaseAgent", description: str) -> "AgentResponse": + return AgentResponse( + type=ResponseType.UPDATE_SPECIFICATION, + agent=agent, + data={ + "description": description, + }, + ) diff --git a/core/agents/spec_writer.py b/core/agents/spec_writer.py index a53529dcdd..9e5494f576 100644 --- a/core/agents/spec_writer.py +++ b/core/agents/spec_writer.py @@ -1,6 +1,6 @@ from core.agents.base import BaseAgent from core.agents.convo import AgentConvo -from core.agents.response import AgentResponse +from core.agents.response import AgentResponse, ResponseType from core.db.models import Complexity from core.db.models.project_state import IterationStatus from core.llm.parser import StringParser @@ -29,7 +29,9 @@ class SpecWriter(BaseAgent): async def run(self) -> AgentResponse: current_iteration = self.current_state.current_iteration if current_iteration is not None and current_iteration.get("status") == IterationStatus.NEW_FEATURE_REQUESTED: - return await self.update_spec() + return await self.update_spec(iteration_mode=True) + elif self.prev_response and self.prev_response.type == ResponseType.UPDATE_SPECIFICATION: + return await self.update_spec(iteration_mode=False) else: return await self.initialize_spec() @@ -84,23 +86,40 @@ class SpecWriter(BaseAgent): self.next_state.action = SPEC_STEP_NAME return AgentResponse.done(self) - async def update_spec(self) -> AgentResponse: - feature_description = self.current_state.current_iteration["user_feedback"] + async def update_spec(self, iteration_mode) -> AgentResponse: + if iteration_mode: + feature_description = self.current_state.current_iteration["user_feedback"] + else: + feature_description = self.prev_response.data["description"] + await self.send_message( - f"Adding feature with the following description to project specification:\n\n{feature_description}" + f"Making the following changes to project specification:\n\n{feature_description}\n\nUpdated project specification:" ) llm = self.get_llm() convo = AgentConvo(self).template("add_new_feature", feature_description=feature_description) llm_response: str = await llm(convo, temperature=0, parser=StringParser()) updated_spec = llm_response.strip() + await self.ui.generate_diff(self.current_state.specification.description, updated_spec) + user_response = await self.ask_question( + "Do you accept these changes to the project specification?", + buttons={"yes": "Yes", "no": "No"}, + default="yes", + buttons_only=True, + ) + await self.ui.close_diff() - self.next_state.specification = self.current_state.specification.clone() - self.next_state.specification.description = updated_spec + if user_response.button == "yes": + self.next_state.specification = self.current_state.specification.clone() + self.next_state.specification.description = updated_spec + telemetry.set("updated_prompt", updated_spec) - telemetry.set("updated_prompt", updated_spec) + if iteration_mode: + self.next_state.current_iteration["status"] = IterationStatus.FIND_SOLUTION + self.next_state.flag_iterations_as_modified() + else: + complexity = await self.check_prompt_complexity(user_response.text) + self.next_state.current_epic["complexity"] = complexity - self.next_state.current_iteration["status"] = IterationStatus.FIND_SOLUTION - self.next_state.flag_iterations_as_modified() return AgentResponse.done(self) async def check_prompt_complexity(self, prompt: str) -> str: @@ -188,6 +207,6 @@ class SpecWriter(BaseAgent): llm = self.get_llm() llm_response: str = await llm(convo, temperature=0) additional_info = llm_response.strip() - if additional_info: + if additional_info and len(additional_info) > 6: spec += "\nAdditional info/examples:\n" + additional_info return spec diff --git a/core/agents/tech_lead.py b/core/agents/tech_lead.py index 5e572b17df..c217328418 100644 --- a/core/agents/tech_lead.py +++ b/core/agents/tech_lead.py @@ -5,7 +5,6 @@ from pydantic import BaseModel, Field from core.agents.base import BaseAgent from core.agents.convo import AgentConvo from core.agents.response import AgentResponse -from core.db.models import Complexity from core.db.models.project_state import TaskStatus from core.llm.parser import JSONParser from core.log import get_logger @@ -136,12 +135,12 @@ class TechLead(BaseAgent): "description": response.text, "summary": None, "completed": False, - "complexity": Complexity.HARD, + "complexity": None, # Determined and defined in SpecWriter } ] # Orchestrator will rerun us to break down the new feature epic self.next_state.action = f"Start of feature #{len(self.current_state.epics)}" - return AgentResponse.done(self) + return AgentResponse.update_specification(self, response.text) async def plan_epic(self, epic) -> AgentResponse: log.debug(f"Planning tasks for the epic: {epic['name']}") diff --git a/core/agents/troubleshooter.py b/core/agents/troubleshooter.py index dc753b53c2..081f7812bc 100644 --- a/core/agents/troubleshooter.py +++ b/core/agents/troubleshooter.py @@ -223,7 +223,7 @@ class Troubleshooter(IterationPromptMixin, BaseAgent): is_loop = False should_iterate = True - test_message = "Can you check if the app works please?" + test_message = "Please check if the app is working" if user_instructions: hint = " Here is a description of what should be working:\n\n" + user_instructions @@ -259,13 +259,11 @@ class Troubleshooter(IterationPromptMixin, BaseAgent): is_loop = True elif user_response.button == "change": - user_description = await self.ask_question( - "Please describe the change you want to make (one at the time please)" - ) + user_description = await self.ask_question("Please describe the change you want to make (one at a time)") change_description = user_description.text elif user_response.button == "bug": - user_description = await self.ask_question("Please describe the issue you found (one at the time please)") + user_description = await self.ask_question("Please describe the issue you found (one at a time)") bug_report = user_description.text return should_iterate, is_loop, bug_report, change_description diff --git a/core/prompts/spec-writer/add_new_feature.prompt b/core/prompts/spec-writer/add_new_feature.prompt index 395efe3b9b..b9ce2599bb 100644 --- a/core/prompts/spec-writer/add_new_feature.prompt +++ b/core/prompts/spec-writer/add_new_feature.prompt @@ -7,15 +7,13 @@ This might include: * information which 3rd party packages or APIs to use or avoid * concrete examples of API requests/responses, library usage, or other external documentation -Here is the client brief: ----PROJECT-SPECIFICATION-START--- +Here is the original project specification: {{ state.specification.description }} ----PROJECT-SPECIFICATION-END--- -Here is the specification your team came up with: +Here is the new feature description: ---FEATURE-DESCRIPTION-START--- {{ feature_description }} ---FEATURE-DESCRIPTION-END--- -In your response, output the new updated project specification. -If there is no feature description, just output the original project specification. +In your response, output only the new updated project specification, without any additional messages to the user. +If there is no feature description just output the original project specification. diff --git a/core/ui/ipc_client.py b/core/ui/ipc_client.py index 8915745470..a3d09b9aca 100644 --- a/core/ui/ipc_client.py +++ b/core/ui/ipc_client.py @@ -42,6 +42,8 @@ class MessageType(str, Enum): IMPORT_PROJECT = "importProject" APP_FINISHED = "appFinished" FEATURE_FINISHED = "featureFinished" + GENERATE_DIFF = "generateDiff" + CLOSE_DIFF = "closeDiff" class Message(BaseModel): @@ -356,6 +358,19 @@ class IPCClientUI(UIBase): content=stats, ) + async def generate_diff(self, file_old: str, file_new: str): + await self._send( + MessageType.GENERATE_DIFF, + content={ + "file_old": file_old, + "file_new": file_new, + }, + ) + + async def close_diff(self): + log.debug("Sending signal to close the generated diff file") + await self._send(MessageType.CLOSE_DIFF) + async def loading_finished(self): log.debug("Sending project loading finished signal to the extension") await self._send(MessageType.LOADING_FINISHED) diff --git a/tests/agents/test_tech_lead.py b/tests/agents/test_tech_lead.py index 892a9979ae..c6a4a546f0 100644 --- a/tests/agents/test_tech_lead.py +++ b/tests/agents/test_tech_lead.py @@ -56,7 +56,7 @@ async def test_ask_for_feature(agentcontext): tl = TechLead(sm, ui) response = await tl.run() - assert response.type == ResponseType.DONE + assert response.type == ResponseType.UPDATE_SPECIFICATION await sm.commit() From fe6b3d64a9474658f3f1680946f50ca97ba1bc96 Mon Sep 17 00:00:00 2001 From: Zvonimir Sabljic Date: Sun, 28 Jul 2024 18:47:55 -0700 Subject: [PATCH 07/14] Fix for when a command is being debugged - we want Developer to parse tasks and continue --- core/agents/error_handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/agents/error_handler.py b/core/agents/error_handler.py index 66dbe05ce3..0150bf3c19 100644 --- a/core/agents/error_handler.py +++ b/core/agents/error_handler.py @@ -111,7 +111,7 @@ class ErrorHandler(BaseAgent): "description": llm_response, "alternative_solutions": [], "attempts": 1, - "status": IterationStatus.HUNTING_FOR_BUG, + "status": IterationStatus.IMPLEMENT_SOLUTION, "bug_hunting_cycles": [], } ] From 52a21ee80223e955a9b700662276d8889368e2d3 Mon Sep 17 00:00:00 2001 From: Zvonimir Sabljic Date: Sun, 28 Jul 2024 18:49:18 -0700 Subject: [PATCH 08/14] Expand the output context size when we use Sonnet --- core/llm/anthropic_client.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/llm/anthropic_client.py b/core/llm/anthropic_client.py index f458a7b2b6..1fc7d1d01f 100644 --- a/core/llm/anthropic_client.py +++ b/core/llm/anthropic_client.py @@ -15,6 +15,7 @@ log = get_logger(__name__) # Maximum number of tokens supported by Anthropic Claude 3 MAX_TOKENS = 4096 +MAX_TOKENS_SONNET = 8192 class AnthropicClient(BaseLLMClient): @@ -72,6 +73,11 @@ class AnthropicClient(BaseLLMClient): "messages": messages, "temperature": self.config.temperature if temperature is None else temperature, } + + if "sonnet" in self.config.model: + completion_kwargs["extra_headers"] = {"anthropic-beta": "max-tokens-3-5-sonnet-2024-07-15"} + completion_kwargs["max_tokens"] = MAX_TOKENS_SONNET + if json_mode: completion_kwargs["response_format"] = {"type": "json_object"} From 694438d8eb3b67a89c7a23d196bd226697cc324a Mon Sep 17 00:00:00 2001 From: Zvonimir Sabljic Date: Sun, 28 Jul 2024 18:49:46 -0700 Subject: [PATCH 09/14] Small improvement for breakdown.prompt so that important info is at the end --- core/prompts/developer/breakdown.prompt | 31 +++++++++++++------------ 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/core/prompts/developer/breakdown.prompt b/core/prompts/developer/breakdown.prompt index f115119617..51715cbe70 100644 --- a/core/prompts/developer/breakdown.prompt +++ b/core/prompts/developer/breakdown.prompt @@ -4,21 +4,6 @@ You are working on an app called "{{ state.branch.project.name }}" and you need {% include "partials/features_list.prompt" %} {% include "partials/files_list.prompt" %} -We've broken the development of this {% if state.epics|length > 1 %}feature{% else %}app{% endif %} down to these tasks: -``` -{% for task in state.tasks %} -{{ loop.index }}. {{ task.description }}{% if task.get("status") == "done" %} (completed){% endif %} -{% endfor %} -``` - -You are currently working on task #{{ current_task_index + 1 }} with the following description: -``` -{{ task.description }} -``` -{% if current_task_index != 0 %}All previous tasks are finished and you don't have to work on them.{% endif %} - -Now, tell me all the code that needs to be written to implement ONLY this task and have it fully working and all commands that need to be run to implement this task. - {% include "partials/doc_snippets.prompt" %} {%- if state.epics|length == 1 %} @@ -35,3 +20,19 @@ DO NOT specify commands to create any folders or files, they will be created aut {% include "partials/file_size_limit.prompt" %} Never use the port 5000 to run the app, it's reserved. + +--IMPLEMENTATION INSTRUCTIONS-- +We've broken the development of this {% if state.epics|length > 1 %}feature{% else %}app{% endif %} down to these tasks: +``` +{% for task in state.tasks %} +{{ loop.index }}. {{ task.description }}{% if task.get("status") == "done" %} (completed){% endif %} +{% endfor %} +``` + +You are currently working on task #{{ current_task_index + 1 }} with the following description: +``` +{{ task.description }} +``` +{% if current_task_index != 0 %}All previous tasks are finished and you don't have to work on them.{% endif %} + +Now, tell me all the code that needs to be written to implement ONLY this task and have it fully working and all commands that need to be run to implement this task. From 3bbb0dd1b994dcc695ef5ecada1a1e47c1776af3 Mon Sep 17 00:00:00 2001 From: Zvonimir Sabljic Date: Sun, 28 Jul 2024 18:56:05 -0700 Subject: [PATCH 10/14] Added Sonnet support for the task breakdown --- core/agents/developer.py | 4 +++- core/config/__init__.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/agents/developer.py b/core/agents/developer.py index 5dff047c30..aaeed50f92 100644 --- a/core/agents/developer.py +++ b/core/agents/developer.py @@ -7,6 +7,7 @@ from core.agents.base import BaseAgent from core.agents.convo import AgentConvo from core.agents.mixins import TaskSteps from core.agents.response import AgentResponse, ResponseType +from core.config import TASK_BREAKDOWN_AGENT_NAME from core.db.models.project_state import IterationStatus, TaskStatus from core.db.models.specification import Complexity from core.llm.parser import JSONParser @@ -178,7 +179,7 @@ class Developer(BaseAgent): current_task_index = self.current_state.tasks.index(current_task) - llm = self.get_llm() + llm = self.get_llm(TASK_BREAKDOWN_AGENT_NAME) convo = AgentConvo(self).template( "breakdown", task=current_task, @@ -194,6 +195,7 @@ class Developer(BaseAgent): } self.next_state.flag_tasks_as_modified() + llm = self.get_llm() await self.send_message("Breaking down the task into steps ...") convo.assistant(response).template("parse_task").require_schema(TaskSteps) response: TaskSteps = await llm(convo, parser=JSONParser(TaskSteps), temperature=0) diff --git a/core/config/__init__.py b/core/config/__init__.py index 645670e30e..75055853e1 100644 --- a/core/config/__init__.py +++ b/core/config/__init__.py @@ -37,6 +37,7 @@ DEFAULT_AGENT_NAME = "default" CODE_MONKEY_AGENT_NAME = "CodeMonkey" DESCRIBE_FILES_AGENT_NAME = "CodeMonkey.describe_files" CHECK_LOGS_AGENT_NAME = "BugHunter.check_logs" +TASK_BREAKDOWN_AGENT_NAME = "Developer.breakdown_current_task" # Endpoint for the external documentation EXTERNAL_DOCUMENTATION_API = "http://docs-pythagora-io-439719575.us-east-1.elb.amazonaws.com" @@ -317,7 +318,8 @@ class Config(_StrictModel): DEFAULT_AGENT_NAME: AgentLLMConfig(), CODE_MONKEY_AGENT_NAME: AgentLLMConfig(model="gpt-4-0125-preview", temperature=0.0), DESCRIBE_FILES_AGENT_NAME: AgentLLMConfig(model="gpt-3.5-turbo", temperature=0.0), - CHECK_LOGS_AGENT_NAME: AgentLLMConfig(model="claude-3-5-sonnet-20240620", temperature=0.0), + CHECK_LOGS_AGENT_NAME: AgentLLMConfig(model="claude-3-5-sonnet-20240620", temperature=0.5), + TASK_BREAKDOWN_AGENT_NAME: AgentLLMConfig(model="claude-3-5-sonnet-20240620", temperature=0.5), } ) prompt: PromptConfig = PromptConfig() From 7970dc87727156d7a1c60f701b8f7a5ca1f7f051 Mon Sep 17 00:00:00 2001 From: Zvonimir Sabljic Date: Sun, 28 Jul 2024 19:16:40 -0700 Subject: [PATCH 11/14] look for DONE in the bigger chunk of the response --- core/agents/task_reviewer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/agents/task_reviewer.py b/core/agents/task_reviewer.py index 7c0aa9830e..f6b3999a4d 100644 --- a/core/agents/task_reviewer.py +++ b/core/agents/task_reviewer.py @@ -47,7 +47,7 @@ class TaskReviewer(BaseAgent): ) llm_response: str = await llm(convo, temperature=0.7) - if "done" in llm_response.strip().lower()[-7:]: + if "done" in llm_response.strip().lower()[-20:]: return AgentResponse.done(self) else: return AgentResponse.task_review_feedback(self, llm_response) From c4455a9c76ce5de2a871b939b09aff76d9df6260 Mon Sep 17 00:00:00 2001 From: Zvonimir Sabljic Date: Sun, 28 Jul 2024 19:17:21 -0700 Subject: [PATCH 12/14] Commented out Senko's last template until we get it fixed --- core/templates/registry.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/templates/registry.py b/core/templates/registry.py index f52f89b894..a951e92e42 100644 --- a/core/templates/registry.py +++ b/core/templates/registry.py @@ -3,7 +3,7 @@ from enum import Enum from core.log import get_logger from .node_express_mongoose import NodeExpressMongooseProjectTemplate -from .react_express import ReactExpressProjectTemplate +# from .react_express import ReactExpressProjectTemplate log = get_logger(__name__) @@ -13,11 +13,11 @@ class ProjectTemplateEnum(str, Enum): # JAVASCRIPT_REACT = JavascriptReactProjectTemplate.name NODE_EXPRESS_MONGOOSE = NodeExpressMongooseProjectTemplate.name - REACT_EXPRESS = ReactExpressProjectTemplate.name + # REACT_EXPRESS = ReactExpressProjectTemplate.name PROJECT_TEMPLATES = { # JavascriptReactProjectTemplate.name: JavascriptReactProjectTemplate, NodeExpressMongooseProjectTemplate.name: NodeExpressMongooseProjectTemplate, - ReactExpressProjectTemplate.name: ReactExpressProjectTemplate, + # ReactExpressProjectTemplate.name: ReactExpressProjectTemplate, } From ac7e3b6978b341f3b93762a8400b89d60ff18d17 Mon Sep 17 00:00:00 2001 From: Zvonimir Sabljic Date: Sun, 28 Jul 2024 19:23:08 -0700 Subject: [PATCH 13/14] Formatting fix --- core/templates/registry.py | 1 + tests/templates/test_templates.py | 95 +++++++++++++++---------------- 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/core/templates/registry.py b/core/templates/registry.py index a951e92e42..db4f84e224 100644 --- a/core/templates/registry.py +++ b/core/templates/registry.py @@ -3,6 +3,7 @@ from enum import Enum from core.log import get_logger from .node_express_mongoose import NodeExpressMongooseProjectTemplate + # from .react_express import ReactExpressProjectTemplate log = get_logger(__name__) diff --git a/tests/templates/test_templates.py b/tests/templates/test_templates.py index 25d61741ac..6d27e37b74 100644 --- a/tests/templates/test_templates.py +++ b/tests/templates/test_templates.py @@ -5,54 +5,53 @@ import pytest from core.state.state_manager import StateManager from core.templates.registry import PROJECT_TEMPLATES - -@pytest.mark.asyncio -@patch("core.state.state_manager.get_config") -async def test_render_react_express_sql(mock_get_config, testmanager): - mock_get_config.return_value.fs.type = "memory" - sm = StateManager(testmanager) - pm = MagicMock(run_command=AsyncMock()) - - await sm.create_project("TestProjectName") - await sm.commit() - - TemplateClass = PROJECT_TEMPLATES["react_express"] - options = TemplateClass.options_class(db_type="sql", auth=True) - template = TemplateClass(options, sm, pm) - - assert template.options_dict == {"db_type": "sql", "auth": True} - - await template.apply() - - files = sm.file_system.list() - for f in ["server.js", "index.html", "prisma/schema.prisma", "api/routes/authRoutes.js", "ui/pages/Register.jsx"]: - assert f in files - assert "api/models/user.js" not in files - - -@pytest.mark.asyncio -@patch("core.state.state_manager.get_config") -async def test_render_react_express_nosql(mock_get_config, testmanager): - mock_get_config.return_value.fs.type = "memory" - sm = StateManager(testmanager) - pm = MagicMock(run_command=AsyncMock()) - - await sm.create_project("TestProjectName") - await sm.commit() - - TemplateClass = PROJECT_TEMPLATES["react_express"] - options = TemplateClass.options_class(db_type="nosql", auth=True) - template = TemplateClass(options, sm, pm) - - assert template.options_dict == {"db_type": "nosql", "auth": True} - - await template.apply() - - files = sm.file_system.list() - print(files) - for f in ["server.js", "index.html", "api/models/user.js", "api/routes/authRoutes.js", "ui/pages/Register.jsx"]: - assert f in files - assert "prisma/schema.prisma" not in files +# @pytest.mark.asyncio +# @patch("core.state.state_manager.get_config") +# async def test_render_react_express_sql(mock_get_config, testmanager): +# mock_get_config.return_value.fs.type = "memory" +# sm = StateManager(testmanager) +# pm = MagicMock(run_command=AsyncMock()) +# +# await sm.create_project("TestProjectName") +# await sm.commit() +# +# TemplateClass = PROJECT_TEMPLATES["react_express"] +# options = TemplateClass.options_class(db_type="sql", auth=True) +# template = TemplateClass(options, sm, pm) +# +# assert template.options_dict == {"db_type": "sql", "auth": True} +# +# await template.apply() +# +# files = sm.file_system.list() +# for f in ["server.js", "index.html", "prisma/schema.prisma", "api/routes/authRoutes.js", "ui/pages/Register.jsx"]: +# assert f in files +# assert "api/models/user.js" not in files + + +# @pytest.mark.asyncio +# @patch("core.state.state_manager.get_config") +# async def test_render_react_express_nosql(mock_get_config, testmanager): +# mock_get_config.return_value.fs.type = "memory" +# sm = StateManager(testmanager) +# pm = MagicMock(run_command=AsyncMock()) +# +# await sm.create_project("TestProjectName") +# await sm.commit() +# +# TemplateClass = PROJECT_TEMPLATES["react_express"] +# options = TemplateClass.options_class(db_type="nosql", auth=True) +# template = TemplateClass(options, sm, pm) +# +# assert template.options_dict == {"db_type": "nosql", "auth": True} +# +# await template.apply() +# +# files = sm.file_system.list() +# print(files) +# for f in ["server.js", "index.html", "api/models/user.js", "api/routes/authRoutes.js", "ui/pages/Register.jsx"]: +# assert f in files +# assert "prisma/schema.prisma" not in files @pytest.mark.skip From b0e6ea72906e977522cae8b79625ae90dc1924fe Mon Sep 17 00:00:00 2001 From: LeonOstrez Date: Mon, 29 Jul 2024 10:40:50 +0200 Subject: [PATCH 14/14] skip tests instead of commenting them out --- core/templates/registry.py | 5 +- tests/templates/test_templates.py | 97 ++++++++++++++++--------------- 2 files changed, 53 insertions(+), 49 deletions(-) diff --git a/core/templates/registry.py b/core/templates/registry.py index db4f84e224..a07a25a39d 100644 --- a/core/templates/registry.py +++ b/core/templates/registry.py @@ -2,6 +2,7 @@ from enum import Enum from core.log import get_logger +from .javascript_react import JavascriptReactProjectTemplate from .node_express_mongoose import NodeExpressMongooseProjectTemplate # from .react_express import ReactExpressProjectTemplate @@ -12,13 +13,13 @@ log = get_logger(__name__) class ProjectTemplateEnum(str, Enum): """Choices of available project templates.""" - # JAVASCRIPT_REACT = JavascriptReactProjectTemplate.name + JAVASCRIPT_REACT = JavascriptReactProjectTemplate.name NODE_EXPRESS_MONGOOSE = NodeExpressMongooseProjectTemplate.name # REACT_EXPRESS = ReactExpressProjectTemplate.name PROJECT_TEMPLATES = { - # JavascriptReactProjectTemplate.name: JavascriptReactProjectTemplate, + JavascriptReactProjectTemplate.name: JavascriptReactProjectTemplate, NodeExpressMongooseProjectTemplate.name: NodeExpressMongooseProjectTemplate, # ReactExpressProjectTemplate.name: ReactExpressProjectTemplate, } diff --git a/tests/templates/test_templates.py b/tests/templates/test_templates.py index 6d27e37b74..dd21a78662 100644 --- a/tests/templates/test_templates.py +++ b/tests/templates/test_templates.py @@ -5,53 +5,56 @@ import pytest from core.state.state_manager import StateManager from core.templates.registry import PROJECT_TEMPLATES -# @pytest.mark.asyncio -# @patch("core.state.state_manager.get_config") -# async def test_render_react_express_sql(mock_get_config, testmanager): -# mock_get_config.return_value.fs.type = "memory" -# sm = StateManager(testmanager) -# pm = MagicMock(run_command=AsyncMock()) -# -# await sm.create_project("TestProjectName") -# await sm.commit() -# -# TemplateClass = PROJECT_TEMPLATES["react_express"] -# options = TemplateClass.options_class(db_type="sql", auth=True) -# template = TemplateClass(options, sm, pm) -# -# assert template.options_dict == {"db_type": "sql", "auth": True} -# -# await template.apply() -# -# files = sm.file_system.list() -# for f in ["server.js", "index.html", "prisma/schema.prisma", "api/routes/authRoutes.js", "ui/pages/Register.jsx"]: -# assert f in files -# assert "api/models/user.js" not in files - - -# @pytest.mark.asyncio -# @patch("core.state.state_manager.get_config") -# async def test_render_react_express_nosql(mock_get_config, testmanager): -# mock_get_config.return_value.fs.type = "memory" -# sm = StateManager(testmanager) -# pm = MagicMock(run_command=AsyncMock()) -# -# await sm.create_project("TestProjectName") -# await sm.commit() -# -# TemplateClass = PROJECT_TEMPLATES["react_express"] -# options = TemplateClass.options_class(db_type="nosql", auth=True) -# template = TemplateClass(options, sm, pm) -# -# assert template.options_dict == {"db_type": "nosql", "auth": True} -# -# await template.apply() -# -# files = sm.file_system.list() -# print(files) -# for f in ["server.js", "index.html", "api/models/user.js", "api/routes/authRoutes.js", "ui/pages/Register.jsx"]: -# assert f in files -# assert "prisma/schema.prisma" not in files + +@pytest.mark.skip +@pytest.mark.asyncio +@patch("core.state.state_manager.get_config") +async def test_render_react_express_sql(mock_get_config, testmanager): + mock_get_config.return_value.fs.type = "memory" + sm = StateManager(testmanager) + pm = MagicMock(run_command=AsyncMock()) + + await sm.create_project("TestProjectName") + await sm.commit() + + TemplateClass = PROJECT_TEMPLATES["react_express"] + options = TemplateClass.options_class(db_type="sql", auth=True) + template = TemplateClass(options, sm, pm) + + assert template.options_dict == {"db_type": "sql", "auth": True} + + await template.apply() + + files = sm.file_system.list() + for f in ["server.js", "index.html", "prisma/schema.prisma", "api/routes/authRoutes.js", "ui/pages/Register.jsx"]: + assert f in files + assert "api/models/user.js" not in files + + +@pytest.mark.skip +@pytest.mark.asyncio +@patch("core.state.state_manager.get_config") +async def test_render_react_express_nosql(mock_get_config, testmanager): + mock_get_config.return_value.fs.type = "memory" + sm = StateManager(testmanager) + pm = MagicMock(run_command=AsyncMock()) + + await sm.create_project("TestProjectName") + await sm.commit() + + TemplateClass = PROJECT_TEMPLATES["react_express"] + options = TemplateClass.options_class(db_type="nosql", auth=True) + template = TemplateClass(options, sm, pm) + + assert template.options_dict == {"db_type": "nosql", "auth": True} + + await template.apply() + + files = sm.file_system.list() + print(files) + for f in ["server.js", "index.html", "api/models/user.js", "api/routes/authRoutes.js", "ui/pages/Register.jsx"]: + assert f in files + assert "prisma/schema.prisma" not in files @pytest.mark.skip