Skip to content

🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming

rm git-push tool

shenchuchengda551f052696
diff --git a/metagpt/prompts/di/swe_agent.py b/metagpt/prompts/di/swe_agent.py
index fd95dc997..7f4fb956d 100644
--- a/metagpt/prompts/di/swe_agent.py
+++ b/metagpt/prompts/di/swe_agent.py
@@ -124,12 +124,9 @@ Thought: The bug has been fixed. Let's submit the changes.
##### Push the changes from the local repository to the remote repository.
Thought: All changes have been saved, let's push the code to the remote repository.
{{
- "command_name": "git_push",
+ "command_name": "Bash.run",
"args": {{
- "local_path": "/workspace/MetaGPT",
- "app_name": "github",
- "comments": "Fix Issue #1275: produced TypeError: openai.types.completion_usage.CompletionUsage() argument after ** must be a mapping, not NoneType"",
- "new_branch": "test-fix"
+ "cmd": "git push orign test-fix"
}}
}}
->
@@ -220,7 +217,7 @@ IMPORTANT_TIPS = """
- Based on feedback of observation or bash command in trajectory to guide adjustments in your search strategy.
13. Save the code change:
- - If you need to submit changes to the remote repository, first use the regular git commit command to save the changes locally, then select a command from the `Available Commands: [git_push, git_create_pull]` to submit the changes to the remote repository.
+ - If you need to submit changes to the remote repository, first use the regular git commit command to save the changes locally, then select a command from the `Available Commands: [git_create_pull]` to submit the changes to the remote repository.
- If you don't need to submit code changes to the remote repository. use the command Bash.run('submit') to commit the changes locally.
diff --git a/metagpt/roles/di/swe_agent.py b/metagpt/roles/di/swe_agent.py
index e3cca3330..7be794265 100644
--- a/metagpt/roles/di/swe_agent.py
+++ b/metagpt/roles/di/swe_agent.py
@@ -9,7 +9,7 @@ from metagpt.prompts.di.swe_agent import (
SWE_AGENT_SYSTEM_TEMPLATE,
)
from metagpt.roles.di.role_zero import RoleZero
-from metagpt.tools.libs.git import git_create_pull, git_push
+from metagpt.tools.libs.git import git_create_pull
from metagpt.tools.libs.terminal import Bash
@@ -23,7 +23,6 @@ class SWEAgent(RoleZero):
"Bash",
"Browser:goto,scroll",
"RoleZero",
- "git_push",
"git_create_pull",
]
terminal: Bash = Field(default_factory=Bash, exclude=True)
@@ -42,7 +41,6 @@ class SWEAgent(RoleZero):
self.tool_execution_map.update(
{
"Bash.run": self.terminal.run,
- "git_push": git_push,
"git_create_pull": git_create_pull,
}
)
diff --git a/metagpt/tools/libs/git.py b/metagpt/tools/libs/git.py
index a2fd87a92..9a33ee4c1 100644
--- a/metagpt/tools/libs/git.py
+++ b/metagpt/tools/libs/git.py
@@ -2,8 +2,7 @@
# -*- coding: utf-8 -*-
from __future__ import annotations
-from pathlib import Path
-from typing import Optional, Union
+from typing import Optional
from github.Issue import Issue
from github.PullRequest import PullRequest
@@ -11,56 +10,6 @@ from github.PullRequest import PullRequest
from metagpt.tools.tool_registry import register_tool
-@register_tool(tags=["software development", "git", "Push to remote git repository."])
-async def git_push(
- local_path: Union[str, Path],
- app_name: str,
- comments: str = "Commit",
- new_branch: str = "",
-) -> "GitBranch":
- """
- Pushes changes from a local Git repository to its remote counterpart.
-
- Args:
- local_path (Union[str, Path]): The absolute path to the local Git repository.
- app_name (str): The name of the platform hosting the repository (e.g., "github", "gitlab", "bitbucket").
- comments (str, optional): Comments to be associated with the push. Defaults to "Commit".
- new_branch (str, optional): The name of the new branch to create and push changes to.
- If not provided, changes will be pushed to the current branch. Defaults to "".
-
- Returns:
- GitBranch: The branch to which the changes were pushed.
-
- Raises:
- ValueError: If the provided local_path does not point to a valid Git repository.
-
- Example:
- >>> url = "https://github.com/iorisa/snake-game.git"
- >>> local_path = await git_clone(url=url)
- >>> app_name = "github"
- >>> comments = "Commit"
- >>> new_branch = "feature/new"
- >>> branch = await git_push(local_path=local_path, app_name=app_name, comments=comments, new_branch=new_branch)
- >>> base = branch.base
- >>> head = branch.head
- >>> repo_name = branch.repo_name
- >>> print(f"base branch:'{base}', head branch:'{head}', repo_name:'{repo_name}'")
- base branch:'master', head branch:'feature/new', repo_name:'iorisa/snake-game'
- """
-
- from metagpt.tools.libs import get_env
- from metagpt.utils.git_repository import GitRepository
-
- if not GitRepository.is_git_dir(local_path):
- raise ValueError("Invalid local git repository")
-
- repo = GitRepository(local_path=local_path, auto_init=False)
- # Read access token from environment variables.
- access_token = await get_env(key="access_token", app_name=app_name)
- branch = await repo.push(new_branch=new_branch, comments=comments, access_token=access_token)
- return branch
-
-
@register_tool(tags=["software development", "git", "create a git pull request or merge request"])
async def git_create_pull(
base: str,