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

Function recordExtract

src/tools/web/extract-metrics.ts:42–51  ·  view source on GitHub ↗
(mode: ExtractMode)

Source from the content-addressed store, hash-verified

40
41/** Append one extract event. Only the truncation modes are recorded (whole pages aren't interesting). Best-effort. */
42export async function recordExtract(mode: ExtractMode): Promise<void> {
43 if (mode !== 'semantic' && mode !== 'head-tail') return;
44 try {
45 const { promises: fs } = await import('fs');
46 const path = await import('path');
47 const file = await metricsFile();
48 await fs.mkdir(path.dirname(file), { recursive: true });
49 await fs.appendFile(file, JSON.stringify({ t: Date.now(), mode }) + '\n');
50 } catch { /* metrics must never break a fetch */ }
51}
52
53/** Read + aggregate the metrics file (last 5000 events). Best-effort → zeros if absent. */
54export async function readExtractMetrics(): Promise<ExtractCounts> {

Callers 1

searchMethod · 0.85

Calls 1

metricsFileFunction · 0.85

Tested by

no test coverage detected