MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / parseExtractMetrics

Function parseExtractMetrics

src/tools/web/extract-metrics.ts:21–33  ·  view source on GitHub ↗
(jsonl: string)

Source from the content-addressed store, hash-verified

19
20/** Aggregate JSONL metric lines (`{"t":…,"mode":"semantic|head-tail"}`) into counts. PURE. */
21export 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
35async function metricsFile(): Promise<string> {
36 const { QODEX_HOME } = await import('../../config/defaults.js');

Callers 2

readExtractMetricsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected