| 4717 | #endif |
| 4718 | |
| 4719 | static int cbm_build_augment_session_script(const char *binary_path, char *script, |
| 4720 | size_t script_size) { |
| 4721 | if (!binary_path || !script || script_size == 0U) { |
| 4722 | return CLI_ERR; |
| 4723 | } |
| 4724 | char quoted[CLI_BUF_8K]; |
| 4725 | #ifdef _WIN32 |
| 4726 | if (cbm_powershell_quote_word(binary_path, quoted, sizeof(quoted)) != CLI_OK) { |
| 4727 | return CLI_ERR; |
| 4728 | } |
| 4729 | int written = snprintf(script, script_size, |
| 4730 | "# SessionStart adapter installed by codebase-memory-mcp.\n" |
| 4731 | "$bin = %s\n" |
| 4732 | "if (-not (Test-Path -LiteralPath $bin -PathType Leaf)) { exit 0 }\n" |
| 4733 | "& $bin hook-augment --event SessionStart 2>$null\n" |
| 4734 | "exit 0\n", |
| 4735 | quoted); |
| 4736 | #else |
| 4737 | if (cbm_shell_quote_word(binary_path, quoted, sizeof(quoted)) != CLI_OK) { |
| 4738 | return CLI_ERR; |
| 4739 | } |
| 4740 | int written = snprintf(script, script_size, |
| 4741 | "#!/bin/sh\n" |
| 4742 | "# SessionStart adapter installed by codebase-memory-mcp.\n" |
| 4743 | "BIN=%s\n" |
| 4744 | "[ -x \"$BIN\" ] || exit 0\n" |
| 4745 | "exec \"$BIN\" hook-augment --event SessionStart 2>/dev/null\n", |
| 4746 | quoted); |
| 4747 | #endif |
| 4748 | return written > 0 && (size_t)written < script_size ? CLI_OK : CLI_ERR; |
| 4749 | } |
| 4750 | |
| 4751 | static bool cbm_install_augment_session_script(const char *binary_path, const char *script_path) { |
| 4752 | char script[CLI_BUF_8K]; |
no test coverage detected