MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / generateRuleSuggestions

Function generateRuleSuggestions

tools/bash/permissions.go:189–219  ·  view source on GitHub ↗
(subcommands []string)

Source from the content-addressed store, hash-verified

187}
188
189func generateRuleSuggestions(subcommands []string) []string {
190 var suggestions []string
191 seen := map[string]bool{}
192 for _, sub := range subcommands {
193 prefix := GetSimpleCommandPrefix(sub)
194 if prefix != "" && !seen[prefix] {
195 seen[prefix] = true
196 suggestions = append(suggestions, fmt.Sprintf("Bash(%s:*)", prefix))
197 if len(suggestions) >= MaxSuggestedRulesForCompound {
198 return suggestions
199 }
200 }
201 }
202 if len(suggestions) != 0 {
203 return suggestions
204 }
205 for _, sub := range subcommands {
206 if len(suggestions) >= MaxSuggestedRulesForCompound {
207 break
208 }
209 cleaned := strings.TrimSpace(sub)
210 if len([]rune(cleaned)) > 80 {
211 cleaned = firstCommandRunes(cleaned, 77) + "..."
212 }
213 if cleaned != "" && !seen[cleaned] {
214 seen[cleaned] = true
215 suggestions = append(suggestions, fmt.Sprintf("Bash(%s)", cleaned))
216 }
217 }
218 return suggestions
219}
220
221func firstCommandRunes(text string, limit int) string {
222 if limit <= 0 {

Callers 1

Calls 2

GetSimpleCommandPrefixFunction · 0.85
firstCommandRunesFunction · 0.85

Tested by

no test coverage detected