Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions aider/coders/navigator_coder.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,16 @@
from aider.tools.delete_lines import _execute_delete_lines
from aider.tools.extract_lines import _execute_extract_lines
from aider.tools.git import (
_execute_git_branch,
_execute_git_diff,
_execute_git_log,
_execute_git_remote,
_execute_git_show,
_execute_git_status,
git_branch_schema,
git_diff_schema,
git_log_schema,
git_remote_schema,
git_show_schema,
git_status_schema,
)
Expand Down Expand Up @@ -217,6 +221,8 @@ def get_local_tool_schemas(self):
git_log_schema,
git_show_schema,
git_status_schema,
git_branch_schema,
git_remote_schema,
]

async def initialize_mcp_tools(self):
Expand Down Expand Up @@ -297,6 +303,8 @@ async def _execute_local_tool_calls(self, tool_calls_list):
"git_log": _execute_git_log,
"git_show": _execute_git_show,
"git_status": _execute_git_status,
"git_branch": _execute_git_branch,
"git_remote": _execute_git_remote,
}

func = tool_functions.get(norm_tool_name)
Expand Down
4 changes: 4 additions & 0 deletions aider/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@
from .delete_lines import _execute_delete_lines, delete_lines_schema
from .extract_lines import _execute_extract_lines, extract_lines_schema
from .git import (
_execute_git_branch,
_execute_git_diff,
_execute_git_log,
_execute_git_remote,
_execute_git_show,
_execute_git_status,
git_branch_schema,
git_diff_schema,
git_log_schema,
git_remote_schema,
git_show_schema,
git_status_schema,
)
Expand Down
69 changes: 69 additions & 0 deletions aider/tools/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,72 @@ def _execute_git_status(coder):
except ANY_GIT_ERROR as e:
coder.io.tool_error(f"Error running git status: {e}")
return f"Error running git status: {e}"


git_branch_schema = {
"type": "function",
"function": {
"name": "git_branch",
"description": "List branches in the repository.",
"parameters": {
"type": "object",
"properties": {},
"required": [],
},
},
}


def _execute_git_branch(coder):
"""
List branches in the repository.
"""
if not coder.repo:
return "Not in a git repository."

try:
# Get all branches and current branch
branches = []
current_branch = coder.repo.repo.active_branch.name
for branch in coder.repo.repo.heads:
prefix = "* " if branch.name == current_branch else " "
branches.append(f"{prefix}{branch.name}")
return "\n".join(branches)
except ANY_GIT_ERROR as e:
coder.io.tool_error(f"Error running git branch: {e}")
return f"Error running git branch: {e}"


git_remote_schema = {
"type": "function",
"function": {
"name": "git_remote",
"description": "List remote repositories.",
"parameters": {
"type": "object",
"properties": {},
"required": [],
},
},
}


def _execute_git_remote(coder):
"""
List remote repositories.
"""
if not coder.repo:
return "Not in a git repository."

try:
remotes = coder.repo.repo.remotes
if not remotes:
return "No remotes configured."

result = []
for remote in remotes:
result.append(f"{remote.name}\t{remote.url}")
return "\n".join(result)
except ANY_GIT_ERROR as e:
coder.io.tool_error(f"Error running git remote: {e}")
return f"Error running git remote: {e}"