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

Function lang_open_indexed

tests/test_lang_contract.c:70–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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