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

Function cbm_tiered_profile_path

src/cli/cli.c:7470–7502  ·  view source on GitHub ↗

Derive tier siblings only from the exact shipped Verify basename. This keeps * vendor-specific suffixes such as .agent.md, .toml, and .json intact. */

Source from the content-addressed store, hash-verified

7468/* Derive tier siblings only from the exact shipped Verify basename. This keeps
7469 * vendor-specific suffixes such as .agent.md, .toml, and .json intact. */
7470static int cbm_tiered_profile_path(const char *verify_path, cbm_graph_tier_t tier, char *output,
7471 size_t output_size) {
7472 static const char verify_basename[] = "codebase-memory";
7473 if (!verify_path || !verify_path[0] || !output || output_size == 0U) {
7474 return CLI_ERR;
7475 }
7476 const char *basename = strrchr(verify_path, '/');
7477 const char *backslash = strrchr(verify_path, '\\');
7478 if (backslash && (!basename || backslash > basename)) {
7479 basename = backslash;
7480 }
7481 basename = basename ? basename + 1U : verify_path;
7482 size_t verify_len = strlen(verify_basename);
7483 if (strncmp(basename, verify_basename, verify_len) != 0 || basename[verify_len] != '.') {
7484 return CLI_ERR;
7485 }
7486 const char *slug = cbm_graph_tier_slug(tier);
7487 if (!slug) {
7488 return CLI_ERR;
7489 }
7490 const char *suffix = basename + verify_len;
7491 size_t directory_len = (size_t)(basename - verify_path);
7492 size_t slug_len = strlen(slug);
7493 size_t suffix_len = strlen(suffix);
7494 if (directory_len >= output_size || slug_len > output_size - directory_len - 1U ||
7495 suffix_len > output_size - directory_len - slug_len - 1U) {
7496 return CLI_ERR;
7497 }
7498 memcpy(output, verify_path, directory_len);
7499 memcpy(output + directory_len, slug, slug_len);
7500 memcpy(output + directory_len + slug_len, suffix, suffix_len + 1U);
7501 return CLI_OK;
7502}
7503
7504static cbm_graph_access_t cbm_tiered_profile_access(cbm_graph_profile_dialect_t dialect) {
7505 return cbm_graph_dialect_direct_capable(dialect) ? CBM_GRAPH_ACCESS_DIRECT

Calls 1

cbm_graph_tier_slugFunction · 0.85

Tested by

no test coverage detected