MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / extract_command

Function extract_command

atomic-agent/src/provenance/classify.rs:224–243  ·  view source on GitHub ↗

Extract the command string from tool input JSON. Tries several common field names: `command`, `cmd`, `script`, `input`.

(tool_input: Option<&serde_json::Value>)

Source from the content-addressed store, hash-verified

222///
223/// Tries several common field names: `command`, `cmd`, `script`, `input`.
224fn extract_command(tool_input: Option<&serde_json::Value>) -> &str {
225 let input = match tool_input {
226 Some(v) => v,
227 None => return "",
228 };
229
230 // Try known field names in order of likelihood
231 for field in &["command", "cmd", "script", "input"] {
232 if let Some(s) = input.get(field).and_then(|v| v.as_str()) {
233 return s;
234 }
235 }
236
237 // If the input is a bare string, use it directly
238 if let Some(s) = input.as_str() {
239 return s;
240 }
241
242 ""
243}
244
245// =============================================================================
246// Command Pattern Matchers

Callers 3

classify_shell_commandFunction · 0.70
summarize_verificationFunction · 0.70
summarize_executionFunction · 0.70

Calls 2

getMethod · 0.65
as_strMethod · 0.45

Tested by

no test coverage detected