| 4339 | } |
| 4340 | |
| 4341 | static int cbm_remove_qoder_context_hook(const char *settings_path, const char *binary_path) { |
| 4342 | char command[CLI_BUF_8K]; |
| 4343 | char shell[CLI_BUF_32]; |
| 4344 | if (cbm_build_qoder_hook_command(binary_path, cbm_current_platform_is_windows(), command, |
| 4345 | sizeof(command), shell, sizeof(shell)) != CLI_OK) { |
| 4346 | return CLI_ERR; |
| 4347 | } |
| 4348 | int legacy_result = remove_hooks_json((hooks_remove_args_t){ |
| 4349 | .settings_path = settings_path, |
| 4350 | .hook_event = "UserPromptSubmit", |
| 4351 | .match_command_exact = command, |
| 4352 | }); |
| 4353 | int session_result = remove_hooks_json((hooks_remove_args_t){ |
| 4354 | .settings_path = settings_path, |
| 4355 | .hook_event = "SessionStart", |
| 4356 | .matcher_str = "startup|resume|clear|compact|new", |
| 4357 | .match_command_exact = command, |
| 4358 | }); |
| 4359 | int subagent_result = remove_hooks_json((hooks_remove_args_t){ |
| 4360 | .settings_path = settings_path, |
| 4361 | .hook_event = "SubagentStart", |
| 4362 | .matcher_str = "*", |
| 4363 | .match_command_exact = command, |
| 4364 | }); |
| 4365 | int read_result = remove_hooks_json((hooks_remove_args_t){ |
| 4366 | .settings_path = settings_path, |
| 4367 | .hook_event = "PostToolUse", |
| 4368 | .matcher_str = "Read", |
| 4369 | .match_command_exact = command, |
| 4370 | }); |
| 4371 | return legacy_result == CLI_OK && session_result == CLI_OK && subagent_result == CLI_OK && |
| 4372 | read_result == CLI_OK |
| 4373 | ? CLI_OK |
| 4374 | : CLI_ERR; |
| 4375 | } |
| 4376 | |
| 4377 | #ifdef CBM_CLI_ENABLE_TEST_API |
| 4378 | int cbm_upsert_qoder_context_hooks_for_testing(const char *settings_path, const char *binary_path) { |
no test coverage detected