diff --git a/metagpt/roles/di/engineer2.py b/metagpt/roles/di/engineer2.py index 2fb9d05ee..beb240a66 100644 --- a/metagpt/roles/di/engineer2.py +++ b/metagpt/roles/di/engineer2.py @@ -34,7 +34,7 @@ class Engineer2(RoleZero): goal: str = "Take on game, app, and web development." instruction: str = ENGINEER2_INSTRUCTION terminal: Terminal = Field(default_factory=Terminal, exclude=True) - deployer: Deployer = Field(default_factory=Deployer) + deployer: Deployer = Field(default_factory=Deployer, exclude=True) tools: list[str] = [ "Plan", "Editor", @@ -88,7 +88,7 @@ class Engineer2(RoleZero): "Terminal.run_command": self._eval_terminal_run, "RoleZero.ask_human": self._end, "RoleZero.reply_to_human": self._end, - "Deployer.deploy_to_public": self.deployer.deploy_to_public, + "Deployer.deploy_to_public": self.deploy_to_public, } ) else: @@ -101,7 +101,7 @@ class Engineer2(RoleZero): "CodeReview.review": cr.review, "CodeReview.fix": cr.fix, "Terminal.run_command": self.terminal.run_command, - "Deployer.deploy_to_public": self.deployer.deploy_to_public, + "Deployer.deploy_to_public": self.deploy_to_public, } ) @@ -140,6 +140,11 @@ class Engineer2(RoleZero): # TODO: Consider adding line no to be ready for editing. return f"The file {path} has been successfully created, with content:\n{code}" + def deploy_to_public(self, dist_dir): + """fix the dist_dir path to absolute path before deploying""" + dist_dir = self.editor._try_fix_path(dist_dir) + return self.deployer.deploy_to_public(dist_dir) + async def _eval_terminal_run(self, cmd): """change command pull/push/commit to end.""" if any([cmd_key_word in cmd for cmd_key_word in ["pull", "push", "commit"]]): diff --git a/metagpt/tools/libs/deployer.py b/metagpt/tools/libs/deployer.py index 4f1ac0ecf..2b4d996d1 100644 --- a/metagpt/tools/libs/deployer.py +++ b/metagpt/tools/libs/deployer.py @@ -12,7 +12,7 @@ class Deployer: async def static_server(self, src_path: str) -> str: """This function will be implemented in the remote service.""" - return f"http://127.0.0.1:{8000}/index.html" + return "http://127.0.0.1:8000/index.html" async def deploy_to_public(self, dist_dir: str): """ diff --git a/metagpt/tools/libs/terminal.py b/metagpt/tools/libs/terminal.py index 0150e26e6..e8eeb363c 100644 --- a/metagpt/tools/libs/terminal.py +++ b/metagpt/tools/libs/terminal.py @@ -68,10 +68,10 @@ class Terminal: output = "" # Remove forbidden commands for cmd_name, reason in self.forbidden_commands.items(): - # 'true' is a pass command in linux terminal. + # "true" is a pass command in linux terminal. if cmd_name in cmd: cmd = cmd.replace(cmd_name, "true") - output += f"{cmd_name} is failed to executed. {reason}\n" + output += f"Failed to execut {cmd_name}. {reason}\n" # Send the command self.process.stdin.write((cmd + self.command_terminator).encode())