Skip to content

Commit c4c8eae

Browse files
author
Test User
committed
feat(agents): suggest permissionMode for agents with editing tools
Add info-level suggestion when agent has Edit, Write, MultiEdit, or "*" tools but no permissionMode set. Recommends acceptEdits for seamless file editing workflows.
1 parent 1e943bf commit c4c8eae

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

internal/cli/agents.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,35 @@ func validateAgentSpecific(data map[string]interface{}, filePath string, content
183183
return errors
184184
}
185185

186+
// hasEditingTools checks if the tools field includes editing capabilities
187+
func hasEditingTools(tools interface{}) bool {
188+
editingTools := []string{"Edit", "Write", "MultiEdit"}
189+
190+
switch v := tools.(type) {
191+
case string:
192+
if v == "*" {
193+
return true
194+
}
195+
// Check comma-separated string
196+
for _, tool := range editingTools {
197+
if strings.Contains(v, tool) {
198+
return true
199+
}
200+
}
201+
case []interface{}:
202+
for _, item := range v {
203+
if s, ok := item.(string); ok {
204+
for _, tool := range editingTools {
205+
if s == tool {
206+
return true
207+
}
208+
}
209+
}
210+
}
211+
}
212+
return false
213+
}
214+
186215
// validateAgentBestPractices checks opinionated best practices for agents
187216
func validateAgentBestPractices(filePath string, contents string, data map[string]interface{}) []cue.ValidationError {
188217
var suggestions []cue.ValidationError
@@ -282,5 +311,18 @@ func validateAgentBestPractices(filePath string, contents string, data map[strin
282311
}
283312
}
284313

314+
// Check for permissionMode when agent has editing tools - OUR OBSERVATION
315+
if _, hasPermMode := data["permissionMode"]; !hasPermMode {
316+
if hasEditingTools(data["tools"]) {
317+
suggestions = append(suggestions, cue.ValidationError{
318+
File: filePath,
319+
Message: "Agent has editing tools but no permissionMode. Consider 'permissionMode: acceptEdits' for seamless file edits.",
320+
Severity: "suggestion",
321+
Source: cue.SourceCClintObserve,
322+
Line: FindFrontmatterFieldLine(contents, "tools"),
323+
})
324+
}
325+
}
326+
285327
return suggestions
286328
}

0 commit comments

Comments
 (0)