| 4503 | } |
| 4504 | |
| 4505 | static int cbm_remove_qoder_context_hook(const char *settings_path, const char *binary_path) { |
| 4506 | char command[CLI_BUF_8K]; |
| 4507 | char shell[CLI_BUF_32]; |
| 4508 | if (cbm_build_qoder_hook_command(binary_path, cbm_current_platform_is_windows(), command, |
| 4509 | sizeof(command), shell, sizeof(shell)) != CLI_OK) { |
| 4510 | return CLI_ERR; |
| 4511 | } |
| 4512 | int legacy_result = remove_hooks_json((hooks_remove_args_t){ |
| 4513 | .settings_path = settings_path, |
| 4514 | .hook_event = "UserPromptSubmit", |
| 4515 | .match_command_exact = command, |
| 4516 | }); |
| 4517 | int session_result = remove_hooks_json((hooks_remove_args_t){ |
| 4518 | .settings_path = settings_path, |
| 4519 | .hook_event = "SessionStart", |
| 4520 | .matcher_str = "startup|resume|clear|compact|new", |
| 4521 | .match_command_exact = command, |
| 4522 | }); |
| 4523 | int subagent_result = remove_hooks_json((hooks_remove_args_t){ |
| 4524 | .settings_path = settings_path, |
| 4525 | .hook_event = "SubagentStart", |
| 4526 | .matcher_str = "*", |
| 4527 | .match_command_exact = command, |
| 4528 | }); |
| 4529 | int read_result = remove_hooks_json((hooks_remove_args_t){ |
| 4530 | .settings_path = settings_path, |
| 4531 | .hook_event = "PostToolUse", |
| 4532 | .matcher_str = "Read", |
| 4533 | .match_command_exact = command, |
| 4534 | }); |
| 4535 | return legacy_result == CLI_OK && session_result == CLI_OK && subagent_result == CLI_OK && |
| 4536 | read_result == CLI_OK |
| 4537 | ? CLI_OK |
| 4538 | : CLI_ERR; |
| 4539 | } |
| 4540 | |
| 4541 | #ifdef CBM_CLI_ENABLE_TEST_API |
| 4542 | int cbm_upsert_qoder_context_hooks_for_testing(const char *settings_path, const char *binary_path) { |
no test coverage detected