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

Function indexRepository

graph-ui/tools/lib/cbm-server.mjs:72–105  ·  view source on GitHub ↗
(binary, { home, repoPath, project, mode = 'full' })

Source from the content-addressed store, hash-verified

70 * und genau das haelt der Beweislauf hier fest.
71 */
72export async function indexRepository(binary, { home, repoPath, project, mode = 'full' }) {
73 const started = Date.now();
74 const payload = JSON.stringify({ repo_path: repoPath, name: project, mode });
75 const result = await new Promise((resolve, reject) => {
76 const child = spawn(binary, ['cli', 'index_repository'], {
77 env: { ...process.env, HOME: home },
78 stdio: ['pipe', 'pipe', 'pipe'],
79 });
80 let out = '';
81 let err = '';
82 child.stdout.on('data', (d) => { out += d.toString(); });
83 child.stderr.on('data', (d) => { err += d.toString(); });
84 child.on('error', reject);
85 child.on('close', (code) => resolve({ code, out, err }));
86 child.stdin.end(payload + '\n');
87 });
88
89 const line = result.out.split('\n').map((l) => l.trim()).filter(Boolean).pop();
90 if (!line) {
91 throw new Error(
92 `index_repository lieferte keine Ausgabe (exit ${result.code}): ${result.err.trim()}`,
93 );
94 }
95 let parsed;
96 try {
97 parsed = JSON.parse(line);
98 } catch {
99 throw new Error(`index_repository lieferte kein JSON: ${line.slice(0, 400)}`);
100 }
101 if (parsed.status !== 'indexed' && parsed.nodes === undefined) {
102 throw new Error(`index_repository status=${parsed.status}: ${line.slice(0, 400)}`);
103 }
104 return { ...parsed, durationMs: Date.now() - started, stderr: result.err.trim() };
105}
106
107const INITIALIZE = JSON.stringify({
108 jsonrpc: '2.0',

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected