Extract the command string from tool input JSON. Tries several common field names: `command`, `cmd`, `script`, `input`.
(tool_input: Option<&serde_json::Value>)
| 222 | /// |
| 223 | /// Tries several common field names: `command`, `cmd`, `script`, `input`. |
| 224 | fn 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 |
no test coverage detected