Build a string representation of arguments for matching
(&self, tool_name: &str, args: &serde_json::Value)
| 133 | |
| 134 | /// Build a string representation of arguments for matching |
| 135 | fn build_arg_string(&self, tool_name: &str, args: &serde_json::Value) -> String { |
| 136 | match tool_name.to_lowercase().as_str() { |
| 137 | "bash" => { |
| 138 | // For Bash, use the command field |
| 139 | args.get("command") |
| 140 | .and_then(|v| v.as_str()) |
| 141 | .unwrap_or("") |
| 142 | .to_string() |
| 143 | } |
| 144 | "read" | "write" | "edit" => { |
| 145 | // For file operations, use the file_path field |
| 146 | args.get("file_path") |
| 147 | .and_then(|v| v.as_str()) |
| 148 | .unwrap_or("") |
| 149 | .to_string() |
| 150 | } |
| 151 | "glob" => { |
| 152 | // For glob, use the pattern field |
| 153 | args.get("pattern") |
| 154 | .and_then(|v| v.as_str()) |
| 155 | .unwrap_or("") |
| 156 | .to_string() |
| 157 | } |
| 158 | "grep" => { |
| 159 | // For grep, combine pattern and path |
| 160 | let pattern = args.get("pattern").and_then(|v| v.as_str()).unwrap_or(""); |
| 161 | let path = args.get("path").and_then(|v| v.as_str()).unwrap_or(""); |
| 162 | format!("{} {}", pattern, path) |
| 163 | } |
| 164 | "ls" => { |
| 165 | // For ls, use the path field |
| 166 | args.get("path") |
| 167 | .and_then(|v| v.as_str()) |
| 168 | .unwrap_or("") |
| 169 | .to_string() |
| 170 | } |
| 171 | _ => { |
| 172 | // For other tools, serialize the entire args |
| 173 | serde_json::to_string(args).unwrap_or_default() |
| 174 | } |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | /// Perform glob-style pattern matching |
| 179 | /// |
no test coverage detected