@@ -24,6 +24,10 @@ class GitDiffUnstaged(BaseModel):
24
24
class GitDiffStaged (BaseModel ):
25
25
repo_path : str
26
26
27
+ class GitDiff (BaseModel ):
28
+ repo_path : str
29
+ target : str
30
+
27
31
class GitCommit (BaseModel ):
28
32
repo_path : str
29
33
message : str
@@ -48,6 +52,7 @@ class GitTools(str, Enum):
48
52
STATUS = "git_status"
49
53
DIFF_UNSTAGED = "git_diff_unstaged"
50
54
DIFF_STAGED = "git_diff_staged"
55
+ DIFF = "git_diff"
51
56
COMMIT = "git_commit"
52
57
ADD = "git_add"
53
58
RESET = "git_reset"
@@ -63,6 +68,9 @@ def git_diff_unstaged(repo: git.Repo) -> str:
63
68
def git_diff_staged (repo : git .Repo ) -> str :
64
69
return repo .git .diff ("--cached" )
65
70
71
+ def git_diff (repo : git .Repo , target : str ) -> str :
72
+ return repo .git .diff (target )
73
+
66
74
def git_commit (repo : git .Repo , message : str ) -> str :
67
75
commit = repo .index .commit (message )
68
76
return f"Changes committed successfully with hash { commit .hexsha } "
@@ -127,6 +135,11 @@ async def list_tools() -> list[Tool]:
127
135
description = "Shows changes that are staged for commit" ,
128
136
inputSchema = GitDiffStaged .schema (),
129
137
),
138
+ Tool (
139
+ name = GitTools .DIFF ,
140
+ description = "Shows differences between branches or commits" ,
141
+ inputSchema = GitDiff .schema (),
142
+ ),
130
143
Tool (
131
144
name = GitTools .COMMIT ,
132
145
description = "Records changes to the repository" ,
@@ -210,6 +223,13 @@ async def call_tool(name: str, arguments: dict) -> list[TextContent]:
210
223
text = f"Staged changes:\n { diff } "
211
224
)]
212
225
226
+ case GitTools .DIFF :
227
+ diff = git_diff (repo , arguments ["target" ])
228
+ return [TextContent (
229
+ type = "text" ,
230
+ text = f"Diff with { arguments ['target' ]} :\n { diff } "
231
+ )]
232
+
213
233
case GitTools .COMMIT :
214
234
result = git_commit (repo , arguments ["message" ])
215
235
return [TextContent (
0 commit comments