| 4773 | #endif |
| 4774 | |
| 4775 | static int cbm_build_augment_session_script(const char *binary_path, char *script, |
| 4776 | size_t script_size) { |
| 4777 | if (!binary_path || !script || script_size == 0U) { |
| 4778 | return CLI_ERR; |
| 4779 | } |
| 4780 | char quoted[CLI_BUF_8K]; |
| 4781 | #ifdef _WIN32 |
| 4782 | if (cbm_powershell_quote_word(binary_path, quoted, sizeof(quoted)) != CLI_OK) { |
| 4783 | return CLI_ERR; |
| 4784 | } |
| 4785 | int written = snprintf(script, script_size, |
| 4786 | "# SessionStart adapter installed by codebase-memory-mcp.\n" |
| 4787 | "$bin = %s\n" |
| 4788 | "if (-not (Test-Path -LiteralPath $bin -PathType Leaf)) { exit 0 }\n" |
| 4789 | "& $bin hook-augment --event SessionStart 2>$null\n" |
| 4790 | "exit 0\n", |
| 4791 | quoted); |
| 4792 | #else |
| 4793 | if (cbm_shell_quote_word(binary_path, quoted, sizeof(quoted)) != CLI_OK) { |
| 4794 | return CLI_ERR; |
| 4795 | } |
| 4796 | int written = snprintf(script, script_size, |
| 4797 | "#!/bin/sh\n" |
| 4798 | "# SessionStart adapter installed by codebase-memory-mcp.\n" |
| 4799 | "BIN=%s\n" |
| 4800 | "[ -x \"$BIN\" ] || exit 0\n" |
| 4801 | "exec \"$BIN\" hook-augment --event SessionStart 2>/dev/null\n", |
| 4802 | quoted); |
| 4803 | #endif |
| 4804 | return written > 0 && (size_t)written < script_size ? CLI_OK : CLI_ERR; |
| 4805 | } |
| 4806 | |
| 4807 | static bool cbm_install_augment_session_script(const char *binary_path, const char *script_path) { |
| 4808 | char script[CLI_BUF_8K]; |
no test coverage detected