File tree Expand file tree Collapse file tree 3 files changed +50
-2
lines changed Expand file tree Collapse file tree 3 files changed +50
-2
lines changed Original file line number Diff line number Diff line change
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ import subprocess
5
+
6
+ from patchwork .common .tools .tool import Tool
7
+
8
+
9
+ class GitTool (Tool , tool_name = "git_tool" , abc_register = False ):
10
+ def __init__ (self , path : str ):
11
+ super ().__init__ ()
12
+ self .path = path
13
+
14
+ @property
15
+ def json_schema (self ) -> dict :
16
+ return {
17
+ "name" : "git_tool" ,
18
+ "description" : """\
19
+ Access to the Git CLI, the command is also `git` all args provided are used as is
20
+ """ ,
21
+ "input_schema" : {
22
+ "type" : "object" ,
23
+ "properties" : {
24
+ "args" : {
25
+ "type" : "array" ,
26
+ "items" : {"type" : "string" },
27
+ "description" : "The args to run `git` command with." ,
28
+ }
29
+ },
30
+ "required" : ["args" ],
31
+ },
32
+ }
33
+
34
+ def execute (self , args : list [str ]) -> str :
35
+ env = os .environ .copy ()
36
+ p = subprocess .run (
37
+ ["gh" , * args ],
38
+ env = env ,
39
+ cwd = self .path ,
40
+ text = True ,
41
+ stdout = subprocess .PIPE ,
42
+ stderr = subprocess .STDOUT ,
43
+ )
44
+ return p .stdout
Original file line number Diff line number Diff line change 6
6
from patchwork .common .tools .tool import Tool
7
7
8
8
9
- class GitHubTool (Tool , tool_name = "github_tool" ):
9
+ class GitHubTool (Tool , tool_name = "github_tool" , abc_register = False ):
10
10
def __init__ (self , path : str , gh_token : str ):
11
11
super ().__init__ ()
12
12
self .path = path
Original file line number Diff line number Diff line change 5
5
AgentConfig ,
6
6
AgenticStrategyV2 ,
7
7
)
8
+ from patchwork .common .tools .git_tool import GitTool
8
9
from patchwork .common .tools .github_tool import GitHubTool
9
10
from patchwork .common .utils .utils import mustache_render
10
11
from patchwork .step import Step
@@ -34,7 +35,10 @@ def __init__(self, inputs):
34
35
AgentConfig (
35
36
name = "Assistant" ,
36
37
model = "gemini-2.0-flash" ,
37
- tool_set = dict (github_tool = GitHubTool (base_path , inputs ["github_api_key" ])),
38
+ tool_set = dict (
39
+ github_tool = GitHubTool (base_path , inputs ["github_api_key" ]),
40
+ git_tool = GitTool (base_path ),
41
+ ),
38
42
system_prompt = """\
39
43
You are a senior software developer helping the program manager to obtain some data from GitHub.
40
44
You can access github through the `gh` CLI app.
You can’t perform that action at this time.
0 commit comments