| 3544 | enum { COPILOT_HOOK_TIMEOUT_SEC = 5 }; |
| 3545 | |
| 3546 | static int cbm_build_copilot_hook_command(const char *binary_path, const char *event, |
| 3547 | bool powershell, char *out, size_t out_size) { |
| 3548 | if (!binary_path || !event || !out || |
| 3549 | (strcmp(event, "SessionStart") != 0 && strcmp(event, "SubagentStart") != 0)) { |
| 3550 | return CLI_ERR; |
| 3551 | } |
| 3552 | char quoted[CLI_BUF_8K]; |
| 3553 | int quote_rc = powershell ? cbm_powershell_quote_word(binary_path, quoted, sizeof(quoted)) |
| 3554 | : cbm_shell_quote_word(binary_path, quoted, sizeof(quoted)); |
| 3555 | if (quote_rc != CLI_OK) { |
| 3556 | return CLI_ERR; |
| 3557 | } |
| 3558 | int written = snprintf(out, out_size, |
| 3559 | powershell ? "& %s hook-augment --event %s --dialect copilot" |
| 3560 | : "%s hook-augment --event %s --dialect copilot", |
| 3561 | quoted, event); |
| 3562 | return written > 0 && (size_t)written < out_size ? CLI_OK : CLI_ERR; |
| 3563 | } |
| 3564 | |
| 3565 | static bool cbm_copilot_add_hook_event(yyjson_mut_doc *doc, yyjson_mut_val *hooks, |
| 3566 | const char *event_key, const char *bash_command, |
no test coverage detected