import git, add terminal state

This commit is contained in:
yzlin 2024-05-08 21:08:39 +08:00
parent 445db9074b
commit d8c2d1c707
3 changed files with 10 additions and 2 deletions

View file

@ -15,6 +15,7 @@ from metagpt.tools.libs import (
file_manager,
browser,
deployer,
git,
)
from metagpt.tools.libs.env import get_env, set_get_env_entry, default_get_env, get_env_description
@ -29,6 +30,7 @@ _ = (
file_manager,
browser,
deployer,
git,
get_env,
get_env_description,
set_get_env_entry,

View file

@ -12,7 +12,7 @@ from metagpt.tools.tool_registry import register_tool
from metagpt.utils.git_repository import GitRepository
@register_tool(tags=["git"])
# @register_tool(tags=["git"])
async def git_clone(url: str, output_dir: str | Path = None) -> Path:
"""
Clones a Git repository from the given URL.

View file

@ -28,10 +28,16 @@ class Terminal:
stderr=subprocess.STDOUT,
text=True,
bufsize=1, # Line buffered
executable="/bin/bash"
executable="/bin/bash",
)
self.stdout_queue = Queue()
self._check_state()
def _check_state(self):
"""Check the state of the terminal, e.g. the current directory of the terminal process. Useful for agent to understand."""
print("The terminal is at:", self.run_command("pwd"))
def run_command(self, cmd: str, daemon=False) -> str:
"""
Executes a specified command in the terminal and streams the output back in real time.