| 3488 | enum { COPILOT_HOOK_TIMEOUT_SEC = 5 }; |
| 3489 | |
| 3490 | static int cbm_build_copilot_hook_command(const char *binary_path, const char *event, |
| 3491 | bool powershell, char *out, size_t out_size) { |
| 3492 | if (!binary_path || !event || !out || |
| 3493 | (strcmp(event, "SessionStart") != 0 && strcmp(event, "SubagentStart") != 0)) { |
| 3494 | return CLI_ERR; |
| 3495 | } |
| 3496 | char quoted[CLI_BUF_8K]; |
| 3497 | int quote_rc = powershell ? cbm_powershell_quote_word(binary_path, quoted, sizeof(quoted)) |
| 3498 | : cbm_shell_quote_word(binary_path, quoted, sizeof(quoted)); |
| 3499 | if (quote_rc != CLI_OK) { |
| 3500 | return CLI_ERR; |
| 3501 | } |
| 3502 | int written = snprintf(out, out_size, |
| 3503 | powershell ? "& %s hook-augment --event %s --dialect copilot" |
| 3504 | : "%s hook-augment --event %s --dialect copilot", |
| 3505 | quoted, event); |
| 3506 | return written > 0 && (size_t)written < out_size ? CLI_OK : CLI_ERR; |
| 3507 | } |
| 3508 | |
| 3509 | static bool cbm_copilot_add_hook_event(yyjson_mut_doc *doc, yyjson_mut_val *hooks, |
| 3510 | const char *event_key, const char *bash_command, |
no test coverage detected