MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / explore

Function explore

__tests__/explore-same-basename-pin.test.ts:176–191  ·  view source on GitHub ↗

One explore call plus the CG-4 diagnostic for it.

(query: string)

Source from the content-addressed store, hash-verified

174
175/** One explore call plus the CG-4 diagnostic for it. */
176async function explore(query: string): Promise<{ text: string; report: ExploreDiagnosticReport }> {
177 const sidecar = path.join(fs.mkdtempSync(path.join(os.tmpdir(), 'codegraph-same-basename-diag-')), 'r.jsonl');
178 const previous = process.env.CODEGRAPH_EXPLORE_DEBUG;
179 process.env.CODEGRAPH_EXPLORE_DEBUG = sidecar;
180 let text = '';
181 try {
182 const res = await new ToolHandler(cg).execute('codegraph_explore', { query });
183 text = res.content?.[0]?.text ?? '';
184 } finally {
185 if (previous === undefined) delete process.env.CODEGRAPH_EXPLORE_DEBUG;
186 else process.env.CODEGRAPH_EXPLORE_DEBUG = previous;
187 }
188 const lines = fs.readFileSync(sidecar, 'utf-8').trim().split('\n').filter(Boolean);
189 fs.rmSync(path.dirname(sidecar), { recursive: true, force: true });
190 return { text, report: JSON.parse(lines[lines.length - 1]!) as ExploreDiagnosticReport };
191}
192
193const fileRecord = (report: ExploreDiagnosticReport, file: string) =>
194 report.files.find((f) => f.path === file);

Calls 3

parseMethod · 0.80
joinMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected