diff --git a/metagpt/prompts/di/engineer2.py b/metagpt/prompts/di/engineer2.py index fcf3b4242..1c39444de 100644 --- a/metagpt/prompts/di/engineer2.py +++ b/metagpt/prompts/di/engineer2.py @@ -44,10 +44,11 @@ Note: 21. When planning, consider whether images are needed. If you are developing a showcase website, start by using ImageGetter.get_image to obtain the necessary images. 22. When planning, merge multiple tasks that operate on the same file into a single task. For example, create one task for writing unit tests for all functions in a class. Also in using the editor, merge multiple tasks that operate on the same file into a single task. 23. When create unit tests for a code file, use Editor.read() to read the code file before planing. And create one plan to writing the unit test for the whole file. -24. Follow the Sytem Design and Project Schedule if exists. Otherwise, use default template folder of Vite, React, MUI and Tailwind CSS. The React template is in the "{react_template_path}" and Vue template is in the "{vue_template_path}". If the template does not exist, use native HTML. -25. When writing Vue/React project: +24. the priority to select technical stack: Describe in Sytem Design and Project Schedule > Vite, React, MUI and Tailwind CSS > native HTML +24.1. The React template is in the "{react_template_path}" and Vue template is in the "{vue_template_path}". +25. If no programmming language is specified, use Vue/React project. Do the following steps: 25.1. Create the project folder first. Use cmd " mkdir -p {{project_name}} " -25.2. Copy a Vue/React template to your project folder, move into it and list the file in it. This must be a single respond. Use cmd "cp -r {{template_folder}}/* {{workspace}}/{{project_name}}/ && cd {{workspace}}/{{project_name}} && pwd && tree -f". +25.2. Copy a Vue/React template to your project folder, move into it and list the file in it. Use cmd "cp -r {{template_folder}}/* {{workspace}}/{{project_name}}/ && cd {{workspace}}/{{project_name}} && pwd && tree -f". This must be a single response without other commands. 25.3. User Editor.read to read the content of files in the src and read the index.html in the project root before making a plan. 25.4. List the files that you need to rewrite and create when making a plan. Indicate clearly what file to rewrite or create in each task. "index.html" and all files in the src folder always must be rewritten. Use Tailwind CSS for styling. Notice that you are in {{project_name}}. 25.5. After finish the project. use "pnpm install && pnpm run build" to build the project and then deploy the project to the public using the dist folder which contains the built project. diff --git a/metagpt/roles/di/engineer2.py b/metagpt/roles/di/engineer2.py index 95f18a1b0..22b3554bc 100644 --- a/metagpt/roles/di/engineer2.py +++ b/metagpt/roles/di/engineer2.py @@ -150,8 +150,7 @@ class Engineer2(RoleZero): default_dir = self.editor._try_fix_path(dist_dir) if not default_dir.exists(): raise ValueError("dist_dir must be an absolute path.") - else: - dist_dir = default_dir + dist_dir = default_dir return await self.deployer.deploy_to_public(dist_dir) async def _eval_terminal_run(self, cmd): diff --git a/metagpt/roles/di/role_zero.py b/metagpt/roles/di/role_zero.py index c284db702..b66d8bf8c 100644 --- a/metagpt/roles/di/role_zero.py +++ b/metagpt/roles/di/role_zero.py @@ -535,7 +535,7 @@ class RoleZero(Role): command_output = await self._end() elif cmd["command_name"] == "RoleZero.ask_human": human_response = await self.ask_human(**cmd["args"]) - if "" in human_response: + if "stop" in human_response.lower(): human_response += "The user has asked me to stop because I have encountered a problem." self.rc.memory.add(UserMessage(content=human_response, cause_by=RunCommand)) end_output = "\nCommand end executed:" diff --git a/metagpt/strategy/experience_retriever.py b/metagpt/strategy/experience_retriever.py index 7c7957782..003bcd90c 100644 --- a/metagpt/strategy/experience_retriever.py +++ b/metagpt/strategy/experience_retriever.py @@ -927,7 +927,7 @@ Explanation: Take on one task, such as writing or rewriting a file. Upon complet { "command_name": "Engineer2.write_new_code", "args": { - "path": "src/index.html" + "path": "/absolute/path/to/src/index.html" } }, { diff --git a/metagpt/tools/libs/editor.py b/metagpt/tools/libs/editor.py index 523465a7e..223216d4f 100644 --- a/metagpt/tools/libs/editor.py +++ b/metagpt/tools/libs/editor.py @@ -97,7 +97,7 @@ class LineNumberError(Exception): "search_dir", "search_file", "find_file", - "search_index_repo", + "similarity_search", ] ) class Editor(BaseModel): @@ -811,7 +811,7 @@ class Editor(BaseModel): context=context.strip(), ) if mismatch_error: - return mismatch_error + raise ValueError(mismatch_error) ret_str = self._edit_file_impl( file_name, start=first_replaced_line_number,