diff --git a/metagpt/actions/di/detect_intent.py b/metagpt/actions/di/detect_intent.py index bfefcacff..d9b587e5c 100644 --- a/metagpt/actions/di/detect_intent.py +++ b/metagpt/actions/di/detect_intent.py @@ -35,7 +35,6 @@ class SOPItem(Enum): "Writes a design to the project repository, based on the PRD of the project.", "Writes a project plan to the project repository, based on the design of the project.", "Writes code to implement designed features according to the project plan and adds them to the project repository.", - # "Run QA test on the project repository.", "Stage and commit changes for the project repository using Git.", ], ) @@ -95,8 +94,7 @@ Intention index: REQ_WITH_SOP = """ {user_requirement} ## Knowledge -To meet user requirements, the following standard operating procedure(SOP) must be used. -SOP descriptions cannot be modified; user requirements can only be appended to the end of corresponding steps. +To meet user requirements, the following standard operating procedure(SOP) must be used: {sop} """ diff --git a/metagpt/actions/di/write_plan.py b/metagpt/actions/di/write_plan.py index 2dbe3f0e7..bc4fb4e71 100644 --- a/metagpt/actions/di/write_plan.py +++ b/metagpt/actions/di/write_plan.py @@ -19,26 +19,26 @@ from metagpt.utils.common import CodeParser class WritePlan(Action): PROMPT_TEMPLATE: str = """ - # Context: - {context} - # Available Task Types: - {task_type_desc} - # Task: - Based on the context, write a plan or modify an existing plan of what you should do to achieve the goal. A plan consists of one to {max_tasks} tasks. - If you are modifying an existing plan, carefully follow the instruction, don't make unnecessary changes. Give the whole plan unless instructed to modify only one task of the plan. - If you encounter errors on the current task, revise and output the current single task only. - Output a list of jsons following the format: - ```json - [ - {{ - "task_id": str = "unique identifier for a task in plan, can be an ordinal", - "dependent_task_ids": list[str] = "ids of tasks prerequisite to this task", - "instruction": "what you should do in this task, one short phrase or sentence", - "task_type": "type of this task, should be one of Available Task Types", - }}, - ... - ] - ``` +# Context: +{context} +# Available Task Types: +{task_type_desc} +# Task: +Based on the context, write a plan or modify an existing plan of what you should do to achieve the goal. A plan consists of one to {max_tasks} tasks. +If you are modifying an existing plan, carefully follow the instruction, don't make unnecessary changes. Give the whole plan unless instructed to modify only one task of the plan. +If you encounter errors on the current task, revise and output the current single task only. +Output a list of jsons following the format: +```json +[ + {{ + "task_id": str = "unique identifier for a task in plan, can be an ordinal", + "dependent_task_ids": list[str] = "ids of tasks prerequisite to this task", + "instruction": "what you should do in this task, one short phrase or sentence.", + "task_type": "type of this task, should be one of Available Task Types.", + }}, + ... +] +``` """ async def run(self, context: list[Message], max_tasks: int = 5) -> str: diff --git a/metagpt/configs/mermaid_config.py b/metagpt/configs/mermaid_config.py index 50c8a1847..47f14f4cd 100644 --- a/metagpt/configs/mermaid_config.py +++ b/metagpt/configs/mermaid_config.py @@ -13,7 +13,7 @@ from metagpt.utils.yaml_model import YamlModel class MermaidConfig(YamlModel): """Config for Mermaid""" - engine: Literal["nodejs", "ink", "playwright", "pyppeteer"] = "nodejs" + engine: Literal["nodejs", "ink", "playwright", "pyppeteer", "none"] = "nodejs" path: str = "mmdc" # mmdc puppeteer_config: str = "" pyppeteer_path: str = "/usr/bin/google-chrome-stable" diff --git a/metagpt/tools/libs/software_development.py b/metagpt/tools/libs/software_development.py index f8a409878..d06469b9a 100644 --- a/metagpt/tools/libs/software_development.py +++ b/metagpt/tools/libs/software_development.py @@ -10,6 +10,7 @@ from metagpt.logs import ToolLogItem, log_tool_output from metagpt.schema import BugFixContext, Message from metagpt.tools.tool_registry import register_tool from metagpt.utils.common import any_to_str +from metagpt.utils.project_repo import ProjectRepo @register_tool(tags=["software development", "ProductManager"]) @@ -365,7 +366,10 @@ async def git_archive(project_path: str | Path) -> str: ) ctx = Context() - ctx.set_repo_dir(project_path) + project_dir = ProjectRepo.search_project_path(project_path) + if not project_dir: + ValueError(f"{project_path} is not a valid git repository.") + ctx.set_repo_dir(project_dir) files = " ".join(ctx.git_repo.changed_files.keys()) outputs = [ToolLogItem(name="cmd", value=f"git add {files}")] log_tool_output(output=outputs, tool_name=git_archive.__name__) diff --git a/metagpt/utils/mermaid.py b/metagpt/utils/mermaid.py index e1d140e84..ba33b8d61 100644 --- a/metagpt/utils/mermaid.py +++ b/metagpt/utils/mermaid.py @@ -81,6 +81,8 @@ async def mermaid_to_file(engine, mermaid_code, output_file_without_suffix, widt from metagpt.utils.mmdc_ink import mermaid_to_file return await mermaid_to_file(mermaid_code, output_file_without_suffix) + elif engine == "none": + return 0 else: logger.warning(f"Unsupported mermaid engine: {engine}") return 0 diff --git a/metagpt/utils/project_repo.py b/metagpt/utils/project_repo.py index fce918570..64ed602a9 100644 --- a/metagpt/utils/project_repo.py +++ b/metagpt/utils/project_repo.py @@ -10,6 +10,7 @@ from __future__ import annotations from pathlib import Path +from typing import Optional from metagpt.const import ( CLASS_VIEW_FILE_REPO, @@ -148,3 +149,14 @@ class ProjectRepo(FileRepository): @property def src_relative_path(self) -> Path | None: return self._srcs_path + + @staticmethod + def search_project_path(filename: str | Path) -> Optional[Path]: + root = Path(filename).parent if Path(filename).is_file() else Path(filename) + root = root.resolve() + while str(root) != "/": + git_repo = root / ".git" + if git_repo.exists(): + return root + root = root.parent + return None