| 5028 | } |
| 5029 | |
| 5030 | static int cbm_build_cline_context_script(const char *binary_path, const char *event, char *script, |
| 5031 | size_t script_size) { |
| 5032 | char quoted[CLI_BUF_8K]; |
| 5033 | #ifdef _WIN32 |
| 5034 | if (cbm_powershell_quote_word(binary_path, quoted, sizeof(quoted)) != CLI_OK) { |
| 5035 | return CLI_ERR; |
| 5036 | } |
| 5037 | int written = snprintf(script, script_size, |
| 5038 | "# Cline %s context adapter installed by codebase-memory-mcp.\n" |
| 5039 | "$bin = %s\n" |
| 5040 | "if (-not (Test-Path -LiteralPath $bin -PathType Leaf)) { exit 0 }\n" |
| 5041 | "& $bin hook-augment --dialect cline --event %s 2>$null\n" |
| 5042 | "exit 0\n", |
| 5043 | event, quoted, event); |
| 5044 | #else |
| 5045 | if (cbm_shell_quote_word(binary_path, quoted, sizeof(quoted)) != CLI_OK) { |
| 5046 | return CLI_ERR; |
| 5047 | } |
| 5048 | int written = snprintf(script, script_size, |
| 5049 | "#!/bin/sh\n" |
| 5050 | "# Cline %s context adapter installed by codebase-memory-mcp.\n" |
| 5051 | "BIN=%s\n" |
| 5052 | "[ -x \"$BIN\" ] || exit 0\n" |
| 5053 | "exec \"$BIN\" hook-augment --dialect cline --event %s 2>/dev/null\n", |
| 5054 | event, quoted, event); |
| 5055 | #endif |
| 5056 | return written > 0 && (size_t)written < script_size ? CLI_OK : CLI_ERR; |
| 5057 | } |
| 5058 | |
| 5059 | static const char cmm_gate_script_prefix[] = |
| 5060 | "#!/usr/bin/env bash\n" |
no test coverage detected