Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 0 additions & 78 deletions pkg/workflow/claude_engine_tools_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,84 +547,6 @@ func TestClaudeEngineAddsTmpByDefault(t *testing.T) {
}
}

func TestHasBashWildcardInTools(t *testing.T) {
tests := []struct {
name string
tools map[string]any
expected bool
}{
{
name: "nil tools",
tools: nil,
expected: false,
},
{
name: "empty tools (no bash key)",
tools: map[string]any{},
expected: false,
},
{
name: "bash with specific commands only",
tools: map[string]any{
"bash": []any{"git", "echo"},
},
expected: false,
},
{
name: "bash with wildcard *",
tools: map[string]any{
"bash": []any{"*"},
},
expected: true,
},
{
name: "bash with colon-wildcard :*",
tools: map[string]any{
"bash": []any{":*"},
},
expected: true,
},
{
name: "bash with wildcard mixed with other commands",
tools: map[string]any{
"bash": []any{"git", "*", "echo"},
},
expected: true,
},
{
name: "bash with nil value (non-list — unrestricted)",
tools: map[string]any{
"bash": nil,
},
expected: true,
},
{
name: "bash with true value (non-list — unrestricted)",
tools: map[string]any{
"bash": true,
},
expected: true,
},
{
name: "no bash key at all",
tools: map[string]any{
"edit": nil,
"github": map[string]any{},
},
expected: false,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := hasBashWildcardInTools(tt.tools)
if result != tt.expected {
t.Errorf("hasBashWildcardInTools(%v): expected %v, got %v", tt.tools, tt.expected, result)
}
})
}
}

func TestGenerateAllowedToolsComment(t *testing.T) {
engine := NewClaudeEngine()

Expand Down
29 changes: 0 additions & 29 deletions pkg/workflow/claude_tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,6 @@ var claudeToolsLog = logger.New("workflow:claude_tools")

const defaultClaudeTmpWritePath = "/tmp"

// hasBashWildcardInTools returns true when the neutral tools map grants unrestricted
// bash access — either because bash is not a list (e.g. bash: true) or because the
// list contains a "*" or ":*" wildcard entry.
//
// When bash is unrestricted the agent can already reach any tool via the shell, so
// --permission-mode bypassPermissions is safe and produces a smoother headless
// experience than acceptEdits (which can stall on some non-file-edit permission
// requests that do not match the acceptEdits auto-approval pattern).
func hasBashWildcardInTools(tools map[string]any) bool {
if tools == nil {
return false
}
bashVal, hasBash := tools["bash"]
if !hasBash {
return false
}
// bash: true (non-list value) means unrestricted bash
bashCommands, ok := bashVal.([]any)
if !ok {
return true
}
for _, cmd := range bashCommands {
if cmdStr, ok := cmd.(string); ok && (cmdStr == "*" || cmdStr == ":*") {
return true
}
}
return false
}

// expandNeutralToolsToClaudeTools converts neutral tool names to Claude-specific tool configurations
func (e *ClaudeEngine) expandNeutralToolsToClaudeTools(tools map[string]any) map[string]any {
claudeToolsLog.Printf("Starting neutral tools expansion: input_tools=%d", len(tools))
Expand Down
Loading