(
resultPaths: string[]
)
| 649 | } |
| 650 | |
| 651 | function summarizeResultHealth( |
| 652 | resultPaths: string[] |
| 653 | ): { level: 'low' | 'medium' | 'high'; reasons?: string[] } | undefined { |
| 654 | const matched = resultPaths |
| 655 | .map((filePath) => healthByFile.get(normalizeHealthLookupKey(filePath, ctx.rootPath))) |
| 656 | .filter((entry): entry is NonNullable<typeof entry> => Boolean(entry)); |
| 657 | if (matched.length === 0) { |
| 658 | return undefined; |
| 659 | } |
| 660 | |
| 661 | const priority = { high: 3, medium: 2, low: 1 }; |
| 662 | matched.sort((a, b) => { |
| 663 | if (priority[b.level] !== priority[a.level]) return priority[b.level] - priority[a.level]; |
| 664 | if (b.score !== a.score) return b.score - a.score; |
| 665 | return a.file.localeCompare(b.file); |
| 666 | }); |
| 667 | |
| 668 | const top = matched[0]; |
| 669 | const reasons = [...top.reasons]; |
| 670 | const sameLevelCount = matched.filter((entry) => entry.level === top.level).length; |
| 671 | if (sameLevelCount > 1) { |
| 672 | reasons.push(`${sameLevelCount} result files are marked ${top.level}-risk`); |
| 673 | } |
| 674 | |
| 675 | return { |
| 676 | level: top.level, |
| 677 | ...(reasons.length > 0 && { reasons: reasons.slice(0, 3) }) |
| 678 | }; |
| 679 | } |
| 680 | |
| 681 | // Build a 1-line pattern summary string from intelligence.json patterns (compact mode) |
| 682 | function buildPatternSummary(): string | undefined { |
no test coverage detected