Update github_tool.py
This commit is contained in:
+254
-2
@@ -59,7 +59,259 @@ class GitHubTool(BaseTool):
|
|||||||
"required": ["path"]
|
"required": ["path"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
# ... (rest of the functions remain unchanged)
|
{
|
||||||
|
"name": "create_branch",
|
||||||
|
"description": "Create a new branch in the repository",
|
||||||
|
"parameters": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"branch_name": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Name of the new branch"
|
||||||
|
},
|
||||||
|
"base_branch": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Name of the base branch",
|
||||||
|
"default": "main"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["branch_name"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "commit_file",
|
||||||
|
"description": "Commit a file to a branch (not main)",
|
||||||
|
"parameters": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"file_path": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Path to the file in the repository"
|
||||||
|
},
|
||||||
|
"commit_message": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Commit message"
|
||||||
|
},
|
||||||
|
"content": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Content of the file"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["file_path", "commit_message", "content"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "create_pull_request",
|
||||||
|
"description": "Create a pull request",
|
||||||
|
"parameters": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"title": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Title of the pull request"
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Body of the pull request"
|
||||||
|
},
|
||||||
|
"base": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "The name of the branch you want the changes pulled into",
|
||||||
|
"default": "main"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["title", "body"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "list_files",
|
||||||
|
"description": "List files in a directory of the repository",
|
||||||
|
"parameters": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"path": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Path to the directory in the repository"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["path"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "search_code",
|
||||||
|
"description": "Search for code in the repository",
|
||||||
|
"parameters": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"query": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Search query"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["query"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "get_commit_history",
|
||||||
|
"description": "Get commit history for a file",
|
||||||
|
"parameters": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"file_path": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Path to the file in the repository"
|
||||||
|
},
|
||||||
|
"num_commits": {
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Number of commits to retrieve",
|
||||||
|
"default": 10
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["file_path"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "get_branch_sha",
|
||||||
|
"description": "Get the SHA of the latest commit on a branch",
|
||||||
|
"parameters": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"branch": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Name of the branch"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["branch"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "get_current_branch",
|
||||||
|
"description": "Get the name of the current branch",
|
||||||
|
"parameters": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "set_current_branch",
|
||||||
|
"description": "Set the current branch",
|
||||||
|
"parameters": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"branch_name": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Name of the branch to set as current"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["branch_name"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "get_file_at_commit",
|
||||||
|
"description": "Get the contents of a file at a specific commit",
|
||||||
|
"parameters": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"file_path": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Path to the file in the repository"
|
||||||
|
},
|
||||||
|
"commit_sha": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "SHA of the commit to retrieve the file from"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["file_path", "commit_sha"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "list_branches",
|
||||||
|
"description": "List all branches in the repository",
|
||||||
|
"parameters": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"per_page": {
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Number of branches to return per page (max 100)",
|
||||||
|
"default": 100
|
||||||
|
},
|
||||||
|
"all_pages": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Whether to fetch all pages of results",
|
||||||
|
"default": True
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "approve_pull_request",
|
||||||
|
"description": "Approve a pull request",
|
||||||
|
"parameters": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"pull_number": {
|
||||||
|
"type": "integer",
|
||||||
|
"description": "The number of the pull request"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["pull_number"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "close_pull_request",
|
||||||
|
"description": "Close a pull request",
|
||||||
|
"parameters": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"pull_number": {
|
||||||
|
"type": "integer",
|
||||||
|
"description": "The number of the pull request"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["pull_number"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "merge_pull_request",
|
||||||
|
"description": "Merge a pull request",
|
||||||
|
"parameters": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"pull_number": {
|
||||||
|
"type": "integer",
|
||||||
|
"description": "The number of the pull request"
|
||||||
|
},
|
||||||
|
"commit_title": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Title for the automatic commit message",
|
||||||
|
"default": "Merge pull request"
|
||||||
|
},
|
||||||
|
"commit_message": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Extra detail to append to automatic commit message",
|
||||||
|
"default": ""
|
||||||
|
},
|
||||||
|
"merge_method": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Merge method to use",
|
||||||
|
"enum": ["merge", "squash", "rebase"],
|
||||||
|
"default": "merge"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["pull_number"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "delete_branch",
|
||||||
|
"description": "Delete a branch",
|
||||||
|
"parameters": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"branch_name": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Name of the branch to delete"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["branch_name"]
|
||||||
|
}
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@metrics.measure
|
@metrics.measure
|
||||||
@@ -166,4 +418,4 @@ class GitHubTool(BaseTool):
|
|||||||
|
|
||||||
@metrics.measure
|
@metrics.measure
|
||||||
def _delete_branch(self, branch_name):
|
def _delete_branch(self, branch_name):
|
||||||
# ... (rest of the method remains unchanged)
|
# ... (rest of the method remains unchanged)
|
||||||
|
|||||||
Reference in New Issue
Block a user