mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-27 14:25:20 +02:00
Merge branch 'fixbug/plan' into 'mgx_ops'
fixbug: plan See merge request pub/MetaGPT!32
This commit is contained in:
commit
6e05eb87ad
6 changed files with 41 additions and 25 deletions
|
|
@ -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}
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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__)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue