| 4808 | } |
| 4809 | |
| 4810 | static int cbm_build_cline_context_script(const char *binary_path, const char *event, char *script, |
| 4811 | size_t script_size) { |
| 4812 | char quoted[CLI_BUF_8K]; |
| 4813 | #ifdef _WIN32 |
| 4814 | if (cbm_powershell_quote_word(binary_path, quoted, sizeof(quoted)) != CLI_OK) { |
| 4815 | return CLI_ERR; |
| 4816 | } |
| 4817 | int written = snprintf(script, script_size, |
| 4818 | "# Cline %s context adapter installed by codebase-memory-mcp.\n" |
| 4819 | "$bin = %s\n" |
| 4820 | "if (-not (Test-Path -LiteralPath $bin -PathType Leaf)) { exit 0 }\n" |
| 4821 | "& $bin hook-augment --dialect cline --event %s 2>$null\n" |
| 4822 | "exit 0\n", |
| 4823 | event, quoted, event); |
| 4824 | #else |
| 4825 | if (cbm_shell_quote_word(binary_path, quoted, sizeof(quoted)) != CLI_OK) { |
| 4826 | return CLI_ERR; |
| 4827 | } |
| 4828 | int written = snprintf(script, script_size, |
| 4829 | "#!/bin/sh\n" |
| 4830 | "# Cline %s context adapter installed by codebase-memory-mcp.\n" |
| 4831 | "BIN=%s\n" |
| 4832 | "[ -x \"$BIN\" ] || exit 0\n" |
| 4833 | "exec \"$BIN\" hook-augment --dialect cline --event %s 2>/dev/null\n", |
| 4834 | event, quoted, event); |
| 4835 | #endif |
| 4836 | return written > 0 && (size_t)written < script_size ? CLI_OK : CLI_ERR; |
| 4837 | } |
| 4838 | |
| 4839 | static const char cmm_gate_script_prefix[] = |
| 4840 | "#!/usr/bin/env bash\n" |
no test coverage detected