MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / is_shell_search_command

Function is_shell_search_command

src/hooks/tool_hints/classifiers.rs:67–86  ·  view source on GitHub ↗
(command: &str)

Source from the content-addressed store, hash-verified

65}
66
67pub(super) fn is_shell_search_command(command: &str) -> bool {
68 // The quote/escape-aware parser shared with hooks.rs: quoted arguments
69 // stay single tokens, so a pattern like `grep "needle -r" file` can no
70 // longer leak a fake `-r` flag (the old split_whitespace misparse).
71 let tokens = shell_words(command);
72 let Some(first) = tokens.first() else {
73 return false;
74 };
75 // Tolerate a leading subshell paren (`(grep -r foo)`), which the shell
76 // parser keeps attached to the first word.
77 let program = first.trim_start_matches('(').to_ascii_lowercase();
78 match program.as_str() {
79 "rg" | "ripgrep" => true,
80 "grep" => tokens
81 .iter()
82 .skip(1)
83 .any(|token| is_recursive_grep_flag(token)),
84 _ => false,
85 }
86}
87
88/// Classifies a shell command as a build/type-check invocation whose output the
89/// model is about to parse by hand: `cargo check|build|clippy|test`, a bare

Callers

nothing calls this directly

Calls 3

shell_wordsFunction · 0.85
is_recursive_grep_flagFunction · 0.85
as_strMethod · 0.45

Tested by

no test coverage detected