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:4939–4969  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4937#endif
4938
4939static int cbm_build_augment_session_script(const char *binary_path, char *script,
4940 size_t script_size) {
4941 if (!binary_path || !script || script_size == 0U) {
4942 return CLI_ERR;
4943 }
4944 char quoted[CLI_BUF_8K];
4945#ifdef _WIN32
4946 if (cbm_powershell_quote_word(binary_path, quoted, sizeof(quoted)) != CLI_OK) {
4947 return CLI_ERR;
4948 }
4949 int written = snprintf(script, script_size,
4950 "# SessionStart adapter installed by codebase-memory-mcp.\n"
4951 "$bin = %s\n"
4952 "if (-not (Test-Path -LiteralPath $bin -PathType Leaf)) { exit 0 }\n"
4953 "& $bin hook-augment --event SessionStart 2>$null\n"
4954 "exit 0\n",
4955 quoted);
4956#else
4957 if (cbm_shell_quote_word(binary_path, quoted, sizeof(quoted)) != CLI_OK) {
4958 return CLI_ERR;
4959 }
4960 int written = snprintf(script, script_size,
4961 "#!/bin/sh\n"
4962 "# SessionStart adapter installed by codebase-memory-mcp.\n"
4963 "BIN=%s\n"
4964 "[ -x \"$BIN\" ] || exit 0\n"
4965 "exec \"$BIN\" hook-augment --event SessionStart 2>/dev/null\n",
4966 quoted);
4967#endif
4968 return written > 0 && (size_t)written < script_size ? CLI_OK : CLI_ERR;
4969}
4970
4971static bool cbm_install_augment_session_script(const char *binary_path, const char *script_path) {
4972 char script[CLI_BUF_8K];

Callers 2

Calls 2

cbm_shell_quote_wordFunction · 0.85

Tested by

no test coverage detected