(raw: &str, tracedecay_bin: &str)
| 277 | } |
| 278 | |
| 279 | fn cursor_plugin_hooks(raw: &str, tracedecay_bin: &str) -> Result<String> { |
| 280 | let mut hooks: serde_json::Value = serde_json::from_str(raw)?; |
| 281 | if let Some(events) = hooks |
| 282 | .get_mut("hooks") |
| 283 | .and_then(|value| value.as_object_mut()) |
| 284 | { |
| 285 | for entries in events.values_mut().filter_map(|value| value.as_array_mut()) { |
| 286 | for entry in entries { |
| 287 | if let Some(command_value) = entry.get_mut("command") { |
| 288 | let Some(command) = command_value.as_str() else { |
| 289 | continue; |
| 290 | }; |
| 291 | if let Some(suffix) = command.strip_prefix("tracedecay ") { |
| 292 | *command_value = json!(super::hook_command(tracedecay_bin, suffix)); |
| 293 | } |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | } |
| 298 | Ok(format!("{}\n", serde_json::to_string_pretty(&hooks)?)) |
| 299 | } |
| 300 | |
| 301 | fn remove_cursor_plugin_install(install_dir: &Path) -> Result<()> { |
| 302 | let Ok(metadata) = std::fs::symlink_metadata(install_dir) else { |
no test coverage detected