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

Function explore

__tests__/explore-declaration-only.test.ts:60–73  ·  view source on GitHub ↗
(query: string)

Source from the content-addressed store, hash-verified

58
59 /** One explore call; returns its diagnostic report plus the response text. */
60 const explore = async (query: string): Promise<{ report: ExploreDiagnosticReport; text: string }> => {
61 fs.rmSync(sidecar, { force: true });
62 const previous = process.env.CODEGRAPH_EXPLORE_DEBUG;
63 process.env.CODEGRAPH_EXPLORE_DEBUG = sidecar;
64 let text: string;
65 try {
66 text = (await new ToolHandler(cg).execute('codegraph_explore', { query })).content?.[0]?.text ?? '';
67 } finally {
68 if (previous === undefined) delete process.env.CODEGRAPH_EXPLORE_DEBUG;
69 else process.env.CODEGRAPH_EXPLORE_DEBUG = previous;
70 }
71 const written = fs.readFileSync(sidecar, 'utf-8').trim().split('\n').filter(Boolean);
72 return { report: JSON.parse(written[written.length - 1]!) as ExploreDiagnosticReport, text };
73 };
74
75 const fileOf = (report: ExploreDiagnosticReport, p: string): ExploreDiagnosticFile | undefined =>
76 report.files.find((f) => f.path === p);

Calls 1

executeMethod · 0.80

Tested by

no test coverage detected