One explore call plus the CG-4 diagnostic for it.
(query: string)
| 174 | |
| 175 | /** One explore call plus the CG-4 diagnostic for it. */ |
| 176 | async 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 | |
| 193 | const fileRecord = (report: ExploreDiagnosticReport, file: string) => |
| 194 | report.files.find((f) => f.path === file); |
no test coverage detected