(answer: string)
| 63 | |
| 64 | /** Classify the vision model's free-text answer into a verdict using its leading token. */ |
| 65 | export function classifyVisionAnswer(answer: string): ReviewVerdict { |
| 66 | const head = (answer || '').trim().toUpperCase(); |
| 67 | if (/^BROKEN\b/.test(head)) return 'broken'; |
| 68 | if (/^NEEDS_WORK\b/.test(head)) return 'needs_work'; |
| 69 | if (/^LOOKS_GOOD\b/.test(head)) return 'looks_good'; |
| 70 | // No explicit token — infer conservatively from wording. |
| 71 | if (/\b(blank|empty|error|nothing renders|failed to render|white screen)\b/i.test(answer)) return 'broken'; |
| 72 | if (/\b(overlap|cut off|cut-off|unreadable|misalign|too small|off-screen|broken layout)\b/i.test(answer)) return 'needs_work'; |
| 73 | if (/\b(looks good|renders correctly|no issues|correct)\b/i.test(answer)) return 'looks_good'; |
| 74 | return 'unverified'; |
| 75 | } |
| 76 | |
| 77 | /** Pull bulleted/■ issue lines out of the vision answer (everything after the verdict token). */ |
| 78 | export function extractIssues(answer: string): string[] { |
no outgoing calls
no test coverage detected