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