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

Function lang_open_indexed

tests/test_lang_contract.c:69–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67}
68
69static cbm_store_t *lang_open_indexed(LangProj *lp) {
70 /* Freed before reassigning: a fixture that indexes more than once would
71 * otherwise drop the previous heap name on the floor. Teardown frees the
72 * last one. */
73 free(lp->project);
74 lp->project = cbm_project_name_from_path(lp->tmpdir);
75 if (!lp->project) {
76 return NULL;
77 }
78 char cache_dir[512];
79 const char *configured_cache = getenv("CBM_CACHE_DIR");
80 if (configured_cache && configured_cache[0]) {
81 snprintf(cache_dir, sizeof(cache_dir), "%s", configured_cache);
82 } else {
83 const char *home = getenv("HOME");
84 if (!home) {
85 home = "/tmp";
86 }
87 snprintf(cache_dir, sizeof(cache_dir), "%s/.cache/codebase-memory-mcp", home);
88 }
89 cbm_mkdir_p(cache_dir, 0755);
90 snprintf(lp->dbpath, sizeof(lp->dbpath), "%s/%s.db", cache_dir, lp->project);
91 unlink(lp->dbpath);
92 lp->srv = cbm_mcp_server_new(NULL);
93 if (!lp->srv) {
94 return NULL;
95 }
96 char args[700];
97 snprintf(args, sizeof(args), "{\"repo_path\":\"%s\"}", lp->tmpdir);
98 char *resp = cbm_mcp_handle_tool(lp->srv, "index_repository", args);
99 if (resp) {
100 free(resp);
101 }
102 return cbm_store_open_path(lp->dbpath);
103}
104
105/* Write each fixture file into a fresh temp project, index it via the MCP
106 * production flow (discover -> extract -> registry -> resolve -> dump), and open

Callers 2

lang_index_filesFunction · 0.85

Calls 5

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