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

Function cv_index

tests/test_conditional_variants.c:70–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70static bool cv_index(cv_proj_t *p, const cv_file_t *files, int count) {
71 memset(p, 0, sizeof(*p));
72 snprintf(p->tmpdir, sizeof(p->tmpdir), "%s", th_mktempdir("cbm-cv"));
73 if (!p->tmpdir[0]) {
74 return false;
75 }
76 for (int i = 0; i < count; i++) {
77 if (!cv_write(p->tmpdir, &files[i])) {
78 return false;
79 }
80 }
81 p->project = cbm_project_name_from_path(p->tmpdir);
82 if (!p->project) {
83 return false;
84 }
85 /* Where the MCP server writes the project DB: CBM_CACHE_DIR, else the
86 * per-user cache (same resolution as test_lang_contract.c). */
87 char cache[700];
88 const char *configured = getenv("CBM_CACHE_DIR");
89 const char *home = getenv("HOME");
90 if (configured && configured[0]) {
91 snprintf(cache, sizeof(cache), "%s", configured);
92 } else {
93 snprintf(cache, sizeof(cache), "%s/.cache/codebase-memory-mcp", home ? home : "/tmp");
94 }
95 cbm_mkdir_p(cache, 0755);
96 snprintf(p->dbpath, sizeof(p->dbpath), "%s/%s.db", cache, p->project);
97 unlink(p->dbpath);
98 p->srv = cbm_mcp_server_new(NULL);
99 if (!p->srv) {
100 return false;
101 }
102 char args[800];
103 snprintf(args, sizeof(args), "{\"repo_path\":\"%s\"}", p->tmpdir);
104 free(cbm_mcp_handle_tool(p->srv, "index_repository", args));
105 p->store = cbm_store_open_path(p->dbpath);
106 return p->store != NULL;
107}
108
109static void cv_cleanup(cv_proj_t *p) {
110 if (p->store) {

Callers 3

cv_runFunction · 0.85
cv_platform_checkFunction · 0.85

Calls 7

th_mktempdirFunction · 0.85
cv_writeFunction · 0.85
cbm_mkdir_pFunction · 0.85
cbm_mcp_server_newFunction · 0.85
cbm_mcp_handle_toolFunction · 0.85
cbm_store_open_pathFunction · 0.85

Tested by

no test coverage detected