| 6454 | const char *canonical_command); |
| 6455 | |
| 6456 | static int cbm_upsert_qwen_lifecycle_hooks(const char *settings_path, const char *binary_path, |
| 6457 | bool windows) { |
| 6458 | char command[CLI_BUF_8K]; |
| 6459 | char released_command[CLI_BUF_8K]; |
| 6460 | char shell[CLI_BUF_32]; |
| 6461 | if (cbm_build_qwen_hook_command(binary_path, windows, command, sizeof(command), shell, |
| 6462 | sizeof(shell)) != CLI_OK || |
| 6463 | (windows ? cbm_build_augment_command_windows(binary_path, released_command, |
| 6464 | sizeof(released_command)) |
| 6465 | : cbm_build_augment_command(binary_path, released_command, |
| 6466 | sizeof(released_command))) != CLI_OK) { |
| 6467 | return CLI_ERR; |
| 6468 | } |
| 6469 | int legacy_result = cbm_remove_paired_lifecycle_hooks_json(settings_path, released_command); |
| 6470 | int lifecycle_result = cbm_upsert_paired_lifecycle_hooks_json(settings_path, command, NULL, |
| 6471 | shell, GEMINI_HOOK_TIMEOUT_MS); |
| 6472 | int read_result = upsert_hooks_json((hooks_upsert_args_t){ |
| 6473 | .settings_path = settings_path, |
| 6474 | .hook_event = "PostToolUse", |
| 6475 | .matcher_str = "ReadFile", |
| 6476 | .command_str = command, |
| 6477 | .shell = shell[0] ? shell : NULL, |
| 6478 | .timeout_value = GEMINI_HOOK_TIMEOUT_MS, |
| 6479 | .match_command_exact = command, |
| 6480 | }); |
| 6481 | return legacy_result == CLI_OK && lifecycle_result == CLI_OK && read_result == CLI_OK ? CLI_OK |
| 6482 | : CLI_ERR; |
| 6483 | } |
| 6484 | |
| 6485 | #ifdef CBM_CLI_ENABLE_TEST_API |
| 6486 | int cbm_upsert_qwen_lifecycle_hooks_for_testing(const char *settings_path, const char *binary_path, |
no test coverage detected