| 5533 | #endif |
| 5534 | |
| 5535 | static int cbm_build_augment_session_script(const char *binary_path, char *script, |
| 5536 | size_t script_size) { |
| 5537 | if (!binary_path || !script || script_size == 0U) { |
| 5538 | return CLI_ERR; |
| 5539 | } |
| 5540 | char quoted[CLI_BUF_8K]; |
| 5541 | #ifdef _WIN32 |
| 5542 | if (cbm_powershell_quote_word(binary_path, quoted, sizeof(quoted)) != CLI_OK) { |
| 5543 | return CLI_ERR; |
| 5544 | } |
| 5545 | int written = snprintf(script, script_size, |
| 5546 | "# SessionStart adapter installed by codebase-memory-mcp.\n" |
| 5547 | "$bin = %s\n" |
| 5548 | "if (-not (Test-Path -LiteralPath $bin -PathType Leaf)) { exit 0 }\n" |
| 5549 | "& $bin hook-augment --event SessionStart 2>$null\n" |
| 5550 | "exit 0\n", |
| 5551 | quoted); |
| 5552 | #else |
| 5553 | if (cbm_shell_quote_word(binary_path, quoted, sizeof(quoted)) != CLI_OK) { |
| 5554 | return CLI_ERR; |
| 5555 | } |
| 5556 | int written = snprintf(script, script_size, |
| 5557 | "#!/bin/sh\n" |
| 5558 | "# SessionStart adapter installed by codebase-memory-mcp.\n" |
| 5559 | "BIN=%s\n" |
| 5560 | "[ -x \"$BIN\" ] || exit 0\n" |
| 5561 | "exec \"$BIN\" hook-augment --event SessionStart 2>/dev/null\n", |
| 5562 | quoted); |
| 5563 | #endif |
| 5564 | return written > 0 && (size_t)written < script_size ? CLI_OK : CLI_ERR; |
| 5565 | } |
| 5566 | |
| 5567 | static bool cbm_install_augment_session_script(const char *binary_path, const char *script_path) { |
| 5568 | char script[CLI_BUF_8K]; |
no test coverage detected