Run tasks directly with language-independent project tools

This commit is contained in:
2026-10-09 01:48:46 +01:00
parent 998b0941d3
commit ed93d055bf
23 changed files with 170 additions and 156 deletions
+20 -9
View File
@@ -2,6 +2,7 @@ package stage
import (
"fmt"
"path/filepath"
"strings"
)
@@ -33,13 +34,11 @@ func ToolNames(def Definition) ([]string, bool, error) {
return tools, true, nil
}
var verificationCommands = []string{"go test ./...", "go test -count=1 ./...", "go test -race ./...", "go test -race -count=1 ./...", "go vet ./...", "go build ./cmd/..."}
func (c *AgentClient) permissionRules() []map[string]string {
rules := []map[string]string{{"action": "*", "resource": "*", "effect": "deny"}}
tools := c.Tools
// Preserve historical explicitly approved manual agents when no tools block
// exists. A present tools block always replaces this legacy bundle.
// A missing block gets normal local agent tools. Explicit stage blocks still
// select which tools are available, including an empty block for text-only work.
if tools == nil {
tools = []string{"read", "glob", "grep", "edit", "shell"}
}
@@ -51,13 +50,25 @@ func (c *AgentClient) permissionRules() []map[string]string {
case "websearch", "webfetch", "read", "glob", "grep":
allow(tool, "*")
case "edit":
for _, path := range c.WritePaths {
allow("edit", path)
if len(c.WritePaths) == 0 {
allow("edit", "*")
rules = append(rules, map[string]string{"action": "edit", "resource": "/*", "effect": "deny"})
if c.Directory != "" {
allow("edit", filepath.ToSlash(filepath.Join(c.Directory, "*")))
}
} else {
for _, path := range c.WritePaths {
allow("edit", filepath.ToSlash(path))
if c.Directory != "" {
allow("edit", filepath.ToSlash(filepath.Join(c.Directory, path)))
}
}
}
for _, pattern := range []string{"../*", "*/../*"} {
rules = append(rules, map[string]string{"action": "edit", "resource": pattern, "effect": "deny"})
}
case "shell":
for _, command := range verificationCommands {
allow("shell", command)
}
allow("shell", "*")
}
}
for _, pattern := range []string{"*.env", "*.env.*", "pipelines.db*"} {