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

Function cbm_find_cli

src/cli/cli.c:913–942  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

911}
912
913const char *cbm_find_cli(const char *name, const char *home_dir) {
914 static char buf[CLI_BUF_512];
915 if (!name || !name[0]) {
916 return "";
917 }
918 if (find_in_path(name, buf, sizeof(buf))) {
919 return buf;
920 }
921 if (!home_dir || !home_dir[0]) {
922 return "";
923 }
924 enum { NUM_PATHS = 5 };
925 char paths[NUM_PATHS][CLI_BUF_512];
926 snprintf(paths[0], sizeof(paths[0]), "/usr/local/bin/%s", name);
927 snprintf(paths[1], sizeof(paths[1]), "%s/.npm/bin/%s", home_dir, name);
928 snprintf(paths[2], sizeof(paths[2]), "%s/.local/bin/%s", home_dir, name);
929 snprintf(paths[3], sizeof(paths[3]), "%s/.cargo/bin/%s", home_dir, name);
930#ifdef __APPLE__
931 snprintf(paths[4], sizeof(paths[4]), "/opt/homebrew/bin/%s", name);
932#else
933 paths[4][0] = '\0';
934#endif
935 for (int i = 0; i < NUM_RETRIES; i++) {
936 if (paths[i][0] && is_executable(paths[i])) {
937 snprintf(buf, sizeof(buf), "%s", paths[i]);
938 return buf;
939 }
940 }
941 return "";
942}
943
944/* Agent scans are also used for dry-run plans against an explicit/synthetic
945 * home. In that mode, machine-global /usr/local and Homebrew fallbacks would

Callers 5

cbm_agent_cli_existsFunction · 0.85
test_cli.cFile · 0.85
mcp_test_gitFunction · 0.85
app_test_gitFunction · 0.85
repro_issue221.cFile · 0.85

Calls 2

find_in_pathFunction · 0.85
is_executableFunction · 0.85

Tested by 2

mcp_test_gitFunction · 0.68
app_test_gitFunction · 0.68