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

Function cbm_agent_cli_exists

src/cli/cli.c:1146–1169  ·  view source on GitHub ↗

Agent scans are also used for dry-run plans against an explicit/synthetic * home. In that mode, machine-global /usr/local and Homebrew fallbacks would * leak the host's agents into the result. Keep those fallbacks for a real-home * scan while still honoring the supplied PATH and home-local bin dirs. */

Source from the content-addressed store, hash-verified

1144 * leak the host's agents into the result. Keep those fallbacks for a real-home
1145 * scan while still honoring the supplied PATH and home-local bin dirs. */
1146static bool cbm_agent_cli_exists(const char *name, const char *home_dir) {
1147 const char *actual_home = cbm_get_home_dir();
1148 if (actual_home && home_dir && strcmp(actual_home, home_dir) == 0) {
1149 return cbm_find_cli(name, home_dir)[0] != '\0';
1150 }
1151
1152 char found[CLI_BUF_512];
1153 if (find_in_path(name, found, sizeof(found))) {
1154 return true;
1155 }
1156 if (!name || !name[0] || !home_dir || !home_dir[0]) {
1157 return false;
1158 }
1159 const char *const suffixes[] = {".npm/bin", ".local/bin", ".cargo/bin"};
1160 char candidate[CLI_BUF_512];
1161 for (size_t i = 0; i < sizeof(suffixes) / sizeof(suffixes[0]); i++) {
1162 int written =
1163 snprintf(candidate, sizeof(candidate), "%s/%s/%s", home_dir, suffixes[i], name);
1164 if (written > 0 && (size_t)written < sizeof(candidate) && is_executable(candidate)) {
1165 return true;
1166 }
1167 }
1168 return false;
1169}
1170
1171/* ── File utilities ───────────────────────────────────────────── */
1172

Callers 2

cbm_detect_agentsFunction · 0.85

Calls 4

cbm_get_home_dirFunction · 0.85
cbm_find_cliFunction · 0.85
find_in_pathFunction · 0.85
is_executableFunction · 0.85

Tested by

no test coverage detected