| 4294 | } |
| 4295 | |
| 4296 | static int cbm_upsert_qoder_context_hook(const char *settings_path, const char *binary_path) { |
| 4297 | char command[CLI_BUF_8K]; |
| 4298 | char shell[CLI_BUF_32]; |
| 4299 | if (cbm_build_qoder_hook_command(binary_path, cbm_current_platform_is_windows(), command, |
| 4300 | sizeof(command), shell, sizeof(shell)) != CLI_OK) { |
| 4301 | return CLI_ERR; |
| 4302 | } |
| 4303 | int legacy_result = remove_hooks_json((hooks_remove_args_t){ |
| 4304 | .settings_path = settings_path, |
| 4305 | .hook_event = "UserPromptSubmit", |
| 4306 | .match_command_exact = command, |
| 4307 | }); |
| 4308 | int session_result = upsert_hooks_json((hooks_upsert_args_t){ |
| 4309 | .settings_path = settings_path, |
| 4310 | .hook_event = "SessionStart", |
| 4311 | .matcher_str = "startup|resume|clear|compact|new", |
| 4312 | .command_str = command, |
| 4313 | .shell = shell[0] ? shell : NULL, |
| 4314 | .timeout_value = CMM_HOOK_TIMEOUT_SEC, |
| 4315 | .match_command_exact = command, |
| 4316 | }); |
| 4317 | int subagent_result = upsert_hooks_json((hooks_upsert_args_t){ |
| 4318 | .settings_path = settings_path, |
| 4319 | .hook_event = "SubagentStart", |
| 4320 | .matcher_str = "*", |
| 4321 | .command_str = command, |
| 4322 | .shell = shell[0] ? shell : NULL, |
| 4323 | .timeout_value = CMM_HOOK_TIMEOUT_SEC, |
| 4324 | .match_command_exact = command, |
| 4325 | }); |
| 4326 | int read_result = upsert_hooks_json((hooks_upsert_args_t){ |
| 4327 | .settings_path = settings_path, |
| 4328 | .hook_event = "PostToolUse", |
| 4329 | .matcher_str = "Read", |
| 4330 | .command_str = command, |
| 4331 | .shell = shell[0] ? shell : NULL, |
| 4332 | .timeout_value = CMM_HOOK_TIMEOUT_SEC, |
| 4333 | .match_command_exact = command, |
| 4334 | }); |
| 4335 | return legacy_result == CLI_OK && session_result == CLI_OK && subagent_result == CLI_OK && |
| 4336 | read_result == CLI_OK |
| 4337 | ? CLI_OK |
| 4338 | : CLI_ERR; |
| 4339 | } |
| 4340 | |
| 4341 | static int cbm_remove_qoder_context_hook(const char *settings_path, const char *binary_path) { |
| 4342 | char command[CLI_BUF_8K]; |
no test coverage detected