suggestPermissionRule function
Suggest a permission rule for a command.
Implementation
String suggestPermissionRule(String command) {
final lines = command.split('\n');
// Multiline → use first line prefix
if (lines.length > 1) {
final firstLine = lines.first.trim();
final words = firstLine.split(RegExp(r'\s+'));
if (words.length >= 2) return '${words[0]} ${words[1]}*';
return '${words[0]}*';
}
// Single line → 2-word prefix
final words = command.trim().split(RegExp(r'\s+'));
if (words.length >= 2) return '${words[0]} ${words[1]}';
return words[0];
}