diff --git a/metagpt/actions/design_api_an.py b/metagpt/actions/design_api_an.py index 740348481..5f17d4656 100644 --- a/metagpt/actions/design_api_an.py +++ b/metagpt/actions/design_api_an.py @@ -9,7 +9,7 @@ from typing import List from metagpt.actions.action_node import ActionNode from metagpt.logs import logger -from metagpt.utils.mermaid import MMC1, MMC1_INC_AND_REFINE, MMC2 +from metagpt.utils.mermaid import MMC1, MMC1_INC_AND_REFINE, MMC2, MMC2_INC IMPLEMENTATION_APPROACH = ActionNode( key="Implementation approach", @@ -35,7 +35,6 @@ REFINE_IMPLEMENTATION_APPROACH = ActionNode( example="We will refine ...", ) - PROJECT_NAME = ActionNode( key="Project name", expected_type=str, instruction="The project name with underline", example="game_2048" ) @@ -51,7 +50,8 @@ REFINE_FILE_LIST = ActionNode( key="File List", expected_type=List[str], instruction="Update and expand the original file list, including only relative paths. " - "Ensure that the refined file list reflects the evolving structure of the project due to incremental development.", + "Ensure that the refined file list reflects the evolving structure of the project due to incremental development." + "Only output filename!Do not include comments in the list.", example=["main.py", "game.py", "utils.py", "new_feature.py"], ) @@ -93,6 +93,15 @@ PROGRAM_CALL_FLOW = ActionNode( example=MMC2, ) +REFINE_PROGRAM_CALL_FLOW = ActionNode( + key="Program call flow", + expected_type=str, + instruction="Extend the existing sequenceDiagram code syntax with detailed information, accurately covering the" + "CRUD and initialization of each object. Ensure correct syntax usage and reflect the incremental changes introduced" + "in the classes and API defined above.Retain content unrelated to incremental development for coherence and clarity", + example=MMC2_INC, +) + ANYTHING_UNCLEAR = ActionNode( key="Anything UNCLEAR", expected_type=str, @@ -134,14 +143,14 @@ NODES = [ ANYTHING_UNCLEAR, ] -INC_NODES = [INC_IMPLEMENTATION_APPROACH, INC_DATA_STRUCTURES_AND_INTERFACES] +INC_NODES = [INC_IMPLEMENTATION_APPROACH, INC_DATA_STRUCTURES_AND_INTERFACES, REFINE_PROGRAM_CALL_FLOW] REFINE_NODES = [ REFINE_IMPLEMENTATION_APPROACH, # PROJECT_NAME, REFINE_FILE_LIST, REFINE_DATA_STRUCTURES_AND_INTERFACES, - PROGRAM_CALL_FLOW, + REFINE_PROGRAM_CALL_FLOW, ANYTHING_UNCLEAR, ] diff --git a/metagpt/actions/project_management_an.py b/metagpt/actions/project_management_an.py index a13ce2dcd..27d238e9f 100644 --- a/metagpt/actions/project_management_an.py +++ b/metagpt/actions/project_management_an.py @@ -70,8 +70,9 @@ TASK_LIST = ActionNode( INC_TASK_LIST = ActionNode( key="Incremental Task list", expected_type=List[str], - instruction="Break down the incremental development tasks into a prioritized list of filenames. " - "Organize the tasks based on dependency order, ensuring a systematic and efficient implementation.", + instruction="Break down the incremental development tasks into a prioritized list of filenames." + "Organize the tasks based on dependency order, ensuring a systematic and efficient implementation." + "Only output filename! Do not include comments in the list ", example=["new_feature.py", "utils.py", "main.py"], ) @@ -80,7 +81,7 @@ REFINE_TASK_LIST = ActionNode( expected_type=List[str], instruction="Review and refine the combined task list after the merger of Legacy Content and Incremental Content. " "Ensure that tasks are organized in a logical and prioritized order, considering dependencies for a streamlined and" - " efficient development process.", + " efficient development process. Only output filename! Do not include comments in the list", example=["game.py", "utils.py", "new_feature.py", "main.py"], ) diff --git a/metagpt/actions/write_code_guide_an.py b/metagpt/actions/write_code_guide_an.py index 5b0a438c3..b21e66098 100644 --- a/metagpt/actions/write_code_guide_an.py +++ b/metagpt/actions/write_code_guide_an.py @@ -149,7 +149,6 @@ Role: You are a professional engineer; The main goal is to complete incremental # Instruction: Based on the context, follow "Format example", write or rewrite code. ## Write/Rewrite Code: Only write one file {filename}, write or rewrite complete code using triple quotes based on the following attentions and context. -### Important Attention: If Legacy Code files contain "{filename} to be rewritten", you are required to merge the Incremental Change into the {filename} file and retain any content unrelated to incremental development to maintain clarity and coherence, when rewriting "{filename} to be rewritten". 1. Only One file: do your best to implement THIS ONLY ONE FILE. 2. COMPLETE CODE: Your code will be part of the entire project, so please implement complete, reliable, reusable code snippets. 3. Set default value: If there is any setting, ALWAYS SET A DEFAULT VALUE, ALWAYS USE STRONG TYPE AND EXPLICIT VARIABLE. AVOID circular import. @@ -158,6 +157,7 @@ Role: You are a professional engineer; The main goal is to complete incremental 6. CAREFULLY CHECK THAT YOU DONT MISS ANY NECESSARY CLASS/FUNCTION IN THIS FILE. 7. Before using a external variable/module, make sure you import it first. 8. Write out EVERY CODE DETAIL, DON'T LEAVE TODO. +9. Attention: If Legacy Code files contain "{filename} to be rewritten", you are required to merge the Incremental Change into the {filename} file when rewriting "{filename} to be rewritten". """ CODE_GUIDE_CONTEXT_EXAMPLE = """ diff --git a/metagpt/actions/write_prd_an.py b/metagpt/actions/write_prd_an.py index 5ba694b0f..79046bb7d 100644 --- a/metagpt/actions/write_prd_an.py +++ b/metagpt/actions/write_prd_an.py @@ -172,10 +172,8 @@ ANYTHING_UNCLEAR = ActionNode( ISSUE_TYPE = ActionNode( key="issue_type", expected_type=str, - instruction="Answer BUG/REFINE/OVERHAUL. If it is a bugfix, answer BUG;" - "if it is a minor improvement, answer REFINE;" - "if it is a major overhaul, answer OVERHAUL that most likely not answer in most cases.", - example="REFINE", + instruction="Answer BUG/REQUIREMENT. If it is a bugfix, answer BUG, otherwise answer Requirement", + example="BUG", ) IS_RELATIVE = ActionNode( diff --git a/metagpt/utils/mermaid.py b/metagpt/utils/mermaid.py index 636ec4598..d1cd1b328 100644 --- a/metagpt/utils/mermaid.py +++ b/metagpt/utils/mermaid.py @@ -176,6 +176,32 @@ MMC2 = """sequenceDiagram S-->>SE: return summary SE-->>M: return summary""" +MMC2_INC = """sequenceDiagram + participant M as Main + participant SE as SearchEngine + participant I as Index + participant R as Ranking + participant S as Summary + participant KB as KnowledgeBase + M->>SE: search(query) + SE->>I: query_index(query) + I->>KB: fetch_data(query) + KB-->>I: return data + I-->>SE: return results + SE->>R: rank_results(results) + R-->>SE: return ranked_results + SE->>S: summarize_results(ranked_results) + S-->>SE: return summary + SE-->>M: return summary + M->>SE: newMethod() # Incremental change + SE->>I: newMethod() # Incremental change + I->>KB: newMethod() # Incremental change + KB-->>I: newMethod() # Incremental change + SE->>R: newMethod() # Incremental change + R-->>SE: newMethod() # Incremental change + SE->>S: newMethod() # Incremental change + S-->>SE: newMethod() # Incremental change + SE-->>M: newMethod() # Incremental change""" if __name__ == "__main__": loop = asyncio.new_event_loop()