summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2026-02-28 16:16:32 +0300
committerGrail Finder <wohilas@gmail.com>2026-02-28 16:16:32 +0300
commita505ffaaa9f7bc94903554b577a2a23d4cd4fe09 (patch)
treefbea5a1d42b9d04bb80653cefb28d2abfe3da0b7
parent32be271aa3c14c73d5a1d9d8d03432f836594401 (diff)
Fix (tool): handle subcommands
-rw-r--r--tools.go18
1 files changed, 16 insertions, 2 deletions
diff --git a/tools.go b/tools.go
index eeb60e8..e6cabe5 100644
--- a/tools.go
+++ b/tools.go
@@ -789,6 +789,16 @@ func executeCommand(args map[string]string) []byte {
argNum++
}
}
+ // Handle commands passed as single string with spaces (e.g., "go run main.go")
+ // Split into base command and arguments
+ if strings.Contains(command, " ") {
+ parts := strings.Fields(command)
+ baseCmd := parts[0]
+ extraArgs := parts[1:]
+ // Prepend extra args to cmdArgs
+ cmdArgs = append(extraArgs, cmdArgs...)
+ command = baseCmd
+ }
if !isCommandAllowed(command, cmdArgs...) {
msg := fmt.Sprintf("command '%s' is not allowed", command)
logger.Error(msg)
@@ -1049,12 +1059,16 @@ func isCommandAllowed(command string, args ...string) bool {
"git": true,
"go": true,
}
- if !allowedCommands[command] {
- return false
+ // Allow all go subcommands (go run, go mod tidy, go test, etc.)
+ if strings.HasPrefix(command, "go ") && allowedCommands["go"] {
+ return true
}
if command == "git" && len(args) > 0 {
return gitReadSubcommands[args[0]]
}
+ if !allowedCommands[command] {
+ return false
+ }
return true
}