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

Function ri_index_capture

tests/test_index_resilience.c:95–122  ·  view source on GitHub ↗

Index the files already written under lp->tmpdir through the production MCP * flow, capturing the raw response. Returns the opened graph store (NULL on * failure). Mirrors repro_harness.h's rh_open_indexed but keeps the response so * we can assert on skipped_count / skipped[] / logfile. */

Source from the content-addressed store, hash-verified

93 * failure). Mirrors repro_harness.h's rh_open_indexed but keeps the response so
94 * we can assert on skipped_count / skipped[] / logfile. */
95static cbm_store_t *ri_index_capture(RProj *lp, char **out_resp) {
96 lp->project = cbm_project_name_from_path(lp->tmpdir);
97 if (!lp->project) {
98 return NULL;
99 }
100 const char *home = getenv("HOME");
101 if (!home) {
102 home = "/tmp";
103 }
104 char cache_dir[512];
105 snprintf(cache_dir, sizeof(cache_dir), "%s/.cache/codebase-memory-mcp", home);
106 cbm_mkdir(cache_dir);
107 snprintf(lp->dbpath, sizeof(lp->dbpath), "%s/%s.db", cache_dir, lp->project);
108 unlink(lp->dbpath);
109 lp->srv = cbm_mcp_server_new(NULL);
110 if (!lp->srv) {
111 return NULL;
112 }
113 char args[700];
114 snprintf(args, sizeof(args), "{\"repo_path\":\"%s\"}", lp->tmpdir);
115 char *resp = cbm_mcp_handle_tool(lp->srv, "index_repository", args);
116 if (out_resp) {
117 *out_resp = resp;
118 } else if (resp) {
119 free(resp);
120 }
121 return cbm_store_open_path(lp->dbpath);
122}
123
124/* ── Tests ──────────────────────────────────────────────────────── */
125

Callers 1

Calls 4

cbm_mcp_server_newFunction · 0.85
cbm_mcp_handle_toolFunction · 0.85
cbm_store_open_pathFunction · 0.85

Tested by

no test coverage detected