MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cbm_build_augment_session_script

Function cbm_build_augment_session_script

src/cli/cli.c:4713–4743  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4711#endif
4712
4713static int cbm_build_augment_session_script(const char *binary_path, char *script,
4714 size_t script_size) {
4715 if (!binary_path || !script || script_size == 0U) {
4716 return CLI_ERR;
4717 }
4718 char quoted[CLI_BUF_8K];
4719#ifdef _WIN32
4720 if (cbm_powershell_quote_word(binary_path, quoted, sizeof(quoted)) != CLI_OK) {
4721 return CLI_ERR;
4722 }
4723 int written = snprintf(script, script_size,
4724 "# SessionStart adapter installed by codebase-memory-mcp.\n"
4725 "$bin = %s\n"
4726 "if (-not (Test-Path -LiteralPath $bin -PathType Leaf)) { exit 0 }\n"
4727 "& $bin hook-augment --event SessionStart 2>$null\n"
4728 "exit 0\n",
4729 quoted);
4730#else
4731 if (cbm_shell_quote_word(binary_path, quoted, sizeof(quoted)) != CLI_OK) {
4732 return CLI_ERR;
4733 }
4734 int written = snprintf(script, script_size,
4735 "#!/bin/sh\n"
4736 "# SessionStart adapter installed by codebase-memory-mcp.\n"
4737 "BIN=%s\n"
4738 "[ -x \"$BIN\" ] || exit 0\n"
4739 "exec \"$BIN\" hook-augment --event SessionStart 2>/dev/null\n",
4740 quoted);
4741#endif
4742 return written > 0 && (size_t)written < script_size ? CLI_OK : CLI_ERR;
4743}
4744
4745static bool cbm_install_augment_session_script(const char *binary_path, const char *script_path) {
4746 char script[CLI_BUF_8K];

Callers 2

Calls 2

cbm_shell_quote_wordFunction · 0.85

Tested by

no test coverage detected