Skip to content

Commit 9c739a9

Browse files
committed
introduce roo-code as supported --tool
Incl. adding tests for the `setup` command Tool: gitpod/catfood.gitpod.cloud
1 parent 9d3143e commit 9c739a9

File tree

5 files changed

+1050
-33
lines changed

5 files changed

+1050
-33
lines changed

cmd/setup.go

Lines changed: 84 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func init() {
2626
setupCmd.Flags().StringVarP(&repoPath, "repository", "r", "", "Git repository path")
2727
setupCmd.Flags().StringVar(&mode, "mode", "shell", "Git operation mode: 'shell' or 'go-git'")
2828
setupCmd.Flags().BoolVar(&writeAccess, "write-access", false, "Enable write access for remote operations (push)")
29-
setupCmd.Flags().StringVar(&tool, "tool", "cline", "The AI assistant tool to set up for")
29+
setupCmd.Flags().StringVar(&tool, "tool", "cline", "The AI assistant tool(s) to set up for (comma-separated, e.g., cline,roo-code)")
3030
setupCmd.Flags().StringVar(&autoApprove, "auto-approve", "", "Comma-separated list of tools to auto-approve, or 'allow-read-only' to auto-approve all read-only tools, or 'allow-local-only' to auto-approve all local-only tools")
3131
}
3232

@@ -62,20 +62,43 @@ This command sets up the Git MCP server for use with an AI assistant by installi
6262
}
6363
}
6464

65-
// Set up the tool-specific configuration
66-
switch strings.ToLower(tool) {
67-
case "cline":
68-
if err := setupCline(binaryPath, repoPath, writeAccess, autoApprove); err != nil {
69-
fmt.Printf("Error setting up Cline: %v\n", err)
70-
os.Exit(1)
65+
// Process each tool
66+
tools := strings.Split(tool, ",")
67+
hasErrors := false
68+
69+
for _, t := range tools {
70+
t = strings.TrimSpace(t)
71+
if t == "" {
72+
continue
73+
}
74+
75+
fmt.Printf("Setting up tool: %s\n", t)
76+
77+
// Set up the tool-specific configuration
78+
var err error
79+
switch strings.ToLower(t) {
80+
case "cline":
81+
err = setupCline(binaryPath, repoPath, writeAccess, autoApprove)
82+
case "roo-code":
83+
err = setupRooCode(binaryPath, repoPath, writeAccess, autoApprove)
84+
default:
85+
fmt.Printf("Unsupported tool: %s\n", t)
86+
fmt.Println("Currently supported tools: cline, roo-code")
87+
hasErrors = true
88+
continue
89+
}
90+
91+
if err != nil {
92+
fmt.Printf("Error setting up %s: %v\n", t, err)
93+
hasErrors = true
94+
} else {
95+
fmt.Printf("git-mcp-go binary successfully set up for %s\n", t)
7196
}
72-
default:
73-
fmt.Printf("Unsupported tool: %s\n", tool)
74-
fmt.Println("Currently supported tools: cline")
75-
os.Exit(1)
7697
}
7798

78-
fmt.Printf("git-mcp-go binary successfully set up for %s\n", tool)
99+
if hasErrors {
100+
os.Exit(1)
101+
}
79102
},
80103
}
81104

@@ -149,26 +172,8 @@ func copySelfToBinaryPath(binaryPath string) error {
149172
return nil
150173
}
151174

152-
// setupCline sets up the git-mcp-go server for Cline
153-
func setupCline(binaryPath string, repoPath string, writeAccess bool, autoApprove string) error {
154-
// Determine the Cline config directory
155-
homeDir, err := os.UserHomeDir()
156-
if err != nil {
157-
return fmt.Errorf("failed to get user home directory: %w", err)
158-
}
159-
160-
var configDir string
161-
switch runtime.GOOS {
162-
case "darwin":
163-
configDir = filepath.Join(homeDir, "Library", "Application Support", "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings")
164-
case "linux":
165-
configDir = filepath.Join(homeDir, ".vscode-server", "data", "User", "globalStorage", "saoudrizwan.claude-dev", "settings")
166-
case "windows":
167-
configDir = filepath.Join(homeDir, "AppData", "Roaming", "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings")
168-
default:
169-
return fmt.Errorf("unsupported OS: %s", runtime.GOOS)
170-
}
171-
175+
// setupTool sets up the git-mcp-go server for a specific tool
176+
func setupTool(toolName string, binaryPath string, repoPath string, writeAccess bool, autoApprove string, configDir string) error {
172177
// Create the config directory if it doesn't exist
173178
if err := os.MkdirAll(configDir, 0755); err != nil {
174179
return fmt.Errorf("failed to create config directory: %w", err)
@@ -254,6 +259,52 @@ func setupCline(binaryPath string, repoPath string, writeAccess bool, autoApprov
254259
return fmt.Errorf("failed to write settings: %w", err)
255260
}
256261

257-
fmt.Printf("Cline MCP settings updated at %s\n", settingsPath)
262+
fmt.Printf("%s MCP settings updated at %s\n", toolName, settingsPath)
258263
return nil
259264
}
265+
266+
// setupCline sets up the git-mcp-go server for Cline
267+
func setupCline(binaryPath string, repoPath string, writeAccess bool, autoApprove string) error {
268+
// Determine the Cline config directory
269+
homeDir, err := os.UserHomeDir()
270+
if err != nil {
271+
return fmt.Errorf("failed to get user home directory: %w", err)
272+
}
273+
274+
var configDir string
275+
switch runtime.GOOS {
276+
case "darwin":
277+
configDir = filepath.Join(homeDir, "Library", "Application Support", "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings")
278+
case "linux":
279+
configDir = filepath.Join(homeDir, ".vscode-server", "data", "User", "globalStorage", "saoudrizwan.claude-dev", "settings")
280+
case "windows":
281+
configDir = filepath.Join(homeDir, "AppData", "Roaming", "Code", "User", "globalStorage", "saoudrizwan.claude-dev", "settings")
282+
default:
283+
return fmt.Errorf("unsupported OS: %s", runtime.GOOS)
284+
}
285+
286+
return setupTool("Cline", binaryPath, repoPath, writeAccess, autoApprove, configDir)
287+
}
288+
289+
// setupRooCode sets up the git-mcp-go server for Roo Code
290+
func setupRooCode(binaryPath string, repoPath string, writeAccess bool, autoApprove string) error {
291+
// Determine the Roo Code config directory
292+
homeDir, err := os.UserHomeDir()
293+
if err != nil {
294+
return fmt.Errorf("failed to get user home directory: %w", err)
295+
}
296+
297+
var configDir string
298+
switch runtime.GOOS {
299+
case "darwin":
300+
configDir = filepath.Join(homeDir, "Library", "Application Support", "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings")
301+
case "linux":
302+
configDir = filepath.Join(homeDir, ".vscode-server", "data", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings")
303+
case "windows":
304+
configDir = filepath.Join(homeDir, "AppData", "Roaming", "Code", "User", "globalStorage", "rooveterinaryinc.roo-cline", "settings")
305+
default:
306+
return fmt.Errorf("unsupported OS: %s", runtime.GOOS)
307+
}
308+
309+
return setupTool("Roo Code", binaryPath, repoPath, writeAccess, autoApprove, configDir)
310+
}

0 commit comments

Comments
 (0)