@@ -136,12 +136,25 @@ func (c *Checker) evaluateRules(command string) (Action, string) {
136136 return action , pattern
137137}
138138
139- // denyError creates an appropriate error message for denied commands.
139+ // denyError creates an error message that lists denied patterns so callers
140+ // (especially LLM agents) know which commands are blocked and stop retrying.
140141func (c * Checker ) denyError (matchedPattern , command string ) error {
141- if matchedPattern == "" {
142- return fmt .Errorf ("command denied (no matching allow rule): %s" , command )
142+ denied := c .deniedPatterns ()
143+ if len (denied ) == 0 {
144+ return fmt .Errorf ("command denied: %s" , command )
143145 }
144- return fmt .Errorf ("command denied by rule '%s': %s" , matchedPattern , command )
146+ return fmt .Errorf ("command denied: %s. Blocked command patterns: [%s]" ,
147+ command , strings .Join (denied , ", " ))
148+ }
149+
150+ func (c * Checker ) deniedPatterns () []string {
151+ var patterns []string
152+ for _ , r := range c .rules {
153+ if r .Action == ActionDeny {
154+ patterns = append (patterns , r .Pattern )
155+ }
156+ }
157+ return patterns
145158}
146159
147160// matchPattern checks if a command matches a glob pattern.
@@ -163,10 +176,10 @@ func (c *Checker) IsAllowed(command string) bool {
163176 return c .Check (command ) == nil
164177}
165178
166- // DefaultRules returns a set of safe default rules.
179+ // DefaultRules returns a set of default rules that trust model capabilities .
167180func DefaultRules () map [string ]string {
168181 return map [string ]string {
169- "*" : "deny" , // Deny all by default
182+ "*" : "allow" ,
170183 }
171184}
172185
0 commit comments