(jsonl: string)
| 19 | |
| 20 | /** Aggregate JSONL metric lines (`{"t":…,"mode":"semantic|head-tail"}`) into counts. PURE. */ |
| 21 | export function parseExtractMetrics(jsonl: string): ExtractCounts { |
| 22 | let semantic = 0, headTail = 0; |
| 23 | for (const line of jsonl.split('\n')) { |
| 24 | if (!line.trim()) continue; |
| 25 | try { |
| 26 | const mode = JSON.parse(line)?.mode; |
| 27 | if (mode === 'semantic') semantic++; |
| 28 | else if (mode === 'head-tail') headTail++; |
| 29 | } catch { /* skip malformed line */ } |
| 30 | } |
| 31 | const truncated = semantic + headTail; |
| 32 | return { semantic, headTail, truncated, semanticRate: truncated ? semantic / truncated : 0 }; |
| 33 | } |
| 34 | |
| 35 | async function metricsFile(): Promise<string> { |
| 36 | const { QODEX_HOME } = await import('../../config/defaults.js'); |
no outgoing calls
no test coverage detected