| 4232 | } |
| 4233 | |
| 4234 | static int cbm_upsert_qoder_context_hook(const char *settings_path, const char *binary_path) { |
| 4235 | char command[CLI_BUF_8K]; |
| 4236 | char shell[CLI_BUF_32]; |
| 4237 | if (cbm_build_qoder_hook_command(binary_path, cbm_current_platform_is_windows(), command, |
| 4238 | sizeof(command), shell, sizeof(shell)) != CLI_OK) { |
| 4239 | return CLI_ERR; |
| 4240 | } |
| 4241 | int legacy_result = remove_hooks_json((hooks_remove_args_t){ |
| 4242 | .settings_path = settings_path, |
| 4243 | .hook_event = "UserPromptSubmit", |
| 4244 | .match_command_exact = command, |
| 4245 | }); |
| 4246 | int session_result = upsert_hooks_json((hooks_upsert_args_t){ |
| 4247 | .settings_path = settings_path, |
| 4248 | .hook_event = "SessionStart", |
| 4249 | .matcher_str = "startup|resume|clear|compact|new", |
| 4250 | .command_str = command, |
| 4251 | .shell = shell[0] ? shell : NULL, |
| 4252 | .timeout_value = CMM_HOOK_TIMEOUT_SEC, |
| 4253 | .match_command_exact = command, |
| 4254 | }); |
| 4255 | int subagent_result = upsert_hooks_json((hooks_upsert_args_t){ |
| 4256 | .settings_path = settings_path, |
| 4257 | .hook_event = "SubagentStart", |
| 4258 | .matcher_str = "*", |
| 4259 | .command_str = command, |
| 4260 | .shell = shell[0] ? shell : NULL, |
| 4261 | .timeout_value = CMM_HOOK_TIMEOUT_SEC, |
| 4262 | .match_command_exact = command, |
| 4263 | }); |
| 4264 | int read_result = upsert_hooks_json((hooks_upsert_args_t){ |
| 4265 | .settings_path = settings_path, |
| 4266 | .hook_event = "PostToolUse", |
| 4267 | .matcher_str = "Read", |
| 4268 | .command_str = command, |
| 4269 | .shell = shell[0] ? shell : NULL, |
| 4270 | .timeout_value = CMM_HOOK_TIMEOUT_SEC, |
| 4271 | .match_command_exact = command, |
| 4272 | }); |
| 4273 | return legacy_result == CLI_OK && session_result == CLI_OK && subagent_result == CLI_OK && |
| 4274 | read_result == CLI_OK |
| 4275 | ? CLI_OK |
| 4276 | : CLI_ERR; |
| 4277 | } |
| 4278 | |
| 4279 | static int cbm_remove_qoder_context_hook(const char *settings_path, const char *binary_path) { |
| 4280 | char command[CLI_BUF_8K]; |
no test coverage detected