(value: unknown)
| 579 | } |
| 580 | |
| 581 | function readCoverageRows(value: unknown): CoverageRow[] { |
| 582 | const rows: CoverageRow[] = []; |
| 583 | for (const entry of coverageArray(value)) { |
| 584 | if (!isRecord(entry)) { |
| 585 | continue; |
| 586 | } |
| 587 | const path = normalizeCoveragePath(coverageString(entry['path'])); |
| 588 | if (path.length === 0) { |
| 589 | continue; |
| 590 | } |
| 591 | const row: CoverageRow = { |
| 592 | path, |
| 593 | kind: coverageString(entry['kind']), |
| 594 | detail: coverageString(entry['detail']), |
| 595 | }; |
| 596 | // The current MCP encoder replaces parse_partial's stored detail with |
| 597 | // structured ranges. Preserve that source evidence in the shared join. |
| 598 | if (row.kind === 'parse_partial' && !row.detail) { |
| 599 | const ranges = coverageArray(entry['ranges']).flatMap((range) => { |
| 600 | if (!isRecord(range)) return []; |
| 601 | const start = range['start']; |
| 602 | const end = range['end']; |
| 603 | return typeof start === 'number' && typeof end === 'number' |
| 604 | && Number.isSafeInteger(start) && Number.isSafeInteger(end) |
| 605 | && start > 0 && end >= start ? [`${start}-${end}`] : []; |
| 606 | }); |
| 607 | if (ranges.length > 0) row.detail = `Source lines: ${ranges.join(', ')}`; |
| 608 | } |
| 609 | const match = coverageString(entry['match']); |
| 610 | if (match.length > 0) { |
| 611 | row.match = match; |
| 612 | } |
| 613 | rows.push(row); |
| 614 | } |
| 615 | return rows; |
| 616 | } |
| 617 | |
| 618 | /** Eine rohe `check_index_coverage`-Antwort lesen. */ |
| 619 | export function readCoverageAnswer(payload: unknown): CoverageAnswer { |
no test coverage detected