| 198 | } |
| 199 | |
| 200 | static cbm_store_t *cp_open_indexed(CP_Proj *lp) { |
| 201 | lp->project = cbm_project_name_from_path(lp->tmpdir); |
| 202 | if (!lp->project) return NULL; |
| 203 | const char *home = getenv("HOME"); |
| 204 | if (!home) home = "/tmp"; |
| 205 | char cache_dir[512]; |
| 206 | snprintf(cache_dir, sizeof(cache_dir), "%s/.cache/codebase-memory-mcp", home); |
| 207 | cbm_mkdir(cache_dir); |
| 208 | snprintf(lp->dbpath, sizeof(lp->dbpath), "%s/%s.db", cache_dir, lp->project); |
| 209 | unlink(lp->dbpath); |
| 210 | lp->srv = cbm_mcp_server_new(NULL); |
| 211 | if (!lp->srv) return NULL; |
| 212 | char args[700]; |
| 213 | snprintf(args, sizeof(args), "{\"repo_path\":\"%s\"}", lp->tmpdir); |
| 214 | char *resp = cbm_mcp_handle_tool(lp->srv, "index_repository", args); |
| 215 | if (resp) free(resp); |
| 216 | return cbm_store_open_path(lp->dbpath); |
| 217 | } |
| 218 | |
| 219 | static cbm_store_t *cp_index_files(CP_Proj *lp, const CP_File *files, int nfiles) { |
| 220 | memset(lp, 0, sizeof(*lp)); |
no test coverage detected