* Run one explore call with the diagnostic pointed at a sidecar, and return the * report plus the response text.
({ CodeGraph, ToolHandler }, repoPath, query, sidecar)
| 95 | * report plus the response text. |
| 96 | */ |
| 97 | async function runExplore({ CodeGraph, ToolHandler }, repoPath, query, sidecar) { |
| 98 | const cg = CodeGraph.openSync(repoPath); |
| 99 | const prior = process.env.CODEGRAPH_EXPLORE_DEBUG; |
| 100 | process.env.CODEGRAPH_EXPLORE_DEBUG = sidecar; |
| 101 | try { |
| 102 | const res = await new ToolHandler(cg).execute('codegraph_explore', { query }); |
| 103 | const text = res.content?.[0]?.text ?? ''; |
| 104 | const lines = readFileSync(sidecar, 'utf-8').trim().split('\n').filter(Boolean); |
| 105 | if (lines.length === 0) throw new Error('diagnostic produced no report'); |
| 106 | return { report: JSON.parse(lines[lines.length - 1]), text }; |
| 107 | } finally { |
| 108 | if (prior === undefined) delete process.env.CODEGRAPH_EXPLORE_DEBUG; |
| 109 | else process.env.CODEGRAPH_EXPLORE_DEBUG = prior; |
| 110 | try { cg.close?.(); } catch {} |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | /** Copy a fixture tree to a fresh temp dir and index it — hermetic per run. */ |
| 115 | async function materializeFixture({ CodeGraph }, fixturePath) { |