When you iterate on LLM prompts, RAG pipelines, or local model quantizations, your most important artifact is usually two boring .jsonl files: baseline.jsonl and candidate.jsonl.
Yet inspecting what actually regressed between those two files inside an editor is surprisingly painful:
- Webview OOM freezes: Naive extensions
fs.readFileSync()a 120MB JSONL file,JSON.parse()every row, and shove the entire array intowebview.postMessage(). The renderer stalls or crashes. - Dirty real-world logs: Long eval runs crash mid-write, leaving trailing truncated JSON lines or blank lines. Standard parsers throw on line 4,812 and refuse to render the other 4,811 valid cases.
- XSS inside eval datasets: Safety and red-team benchmarks routinely contain
<script>alert("xss")</script>payloads in prompts and completions. Dropping raw eval text into an HTML report or Webview is an instant security bug. - Cloud privacy blockers: Many teams working on healthcare, finance, or internal enterprise tools simply cannot upload customer prompts to hosted cloud eval dashboards.
To solve this for my own workflow, I built EvalDiff (v0.2.0)—a 100% local, strictly read-only extension for Cursor, Windsurf, VSCodium, Antigravity, and VS Code with zero third-party runtime npm dependencies.
- Live interactive preview: https://evaldiff.miaodui.workers.dev/
- MIT source code: https://github.com/miaoduitw-creator/evaldiff-workbench
- Open VSX install: https://open-vsx.org/extension/miaodui/evaldiff-workbench
Here are the four concrete engineering patterns that made it fast, safe, and crash-proof.
1. Streaming Line-by-Line With Three Circuit Breakers
Instead of buffering an entire file into memory, src/diffEngine.js uses only Node.js built-ins (fs.createReadStream and readline) with three explicit safety guards:
- Pre-read file size guard (
maxFileSizeMB, default 200MB) viafs.promises.stat. - Per-field character truncation (
maxFieldChars, default 8,000 chars) so a single 2MB retrieved document does not blow up the heap. - Buffered memory circuit breaker (
maxBufferedBytes, default 64MB) that cleanly closes the stream instead of triggering V8 OOM.
const stream = fs.createReadStream(filePath, { encoding: 'utf8', highWaterMark: 64 * 1024 }); const rl = readline.createInterface({ input: stream, crlfDelay: Infinity }); try { for await (const line of rl) { totalLines += 1; const trimmed = line.trim(); if (!trimmed) { blankLines += 1; continue; } let parsed; try { parsed = JSON.parse(trimmed); } catch (parseErr) { malformedCount += 1; malformedLines.push({ lineNumber: totalLines, rawPreview: trimmed.slice(0, 160), error: parseErr.message }); continue; } const normalized = normalizeRecord(parsed, totalLines, maxFieldChars); const recBytes = estimateRecordBytes(normalized); if (bufferedBytes + recBytes > maxBufferedBytes && records.length > 0) { truncated = true; truncationReason = 'MEMORY_LIMIT'; break; } bufferedBytes += recBytes; records.push(normalized); } } finally { rl.close(); stream.destroy(); } Notice two details:
- Corrupted lines never abort the diff—they are isolated with exact line numbers and a 160-char preview.
- The
finallyblock guarantees file descriptors are closed immediately if the memory circuit breaker trips.
2. Extension Host Owns the Dataset; Webview Gets 50 Rows at a Time
A common VS Code extension anti-pattern is sending the full parsed array to the Webview and filtering in browser JS. In EvalDiff, all filtering (status: regression | improvement | unchanged | added | removed), keyword search, sorting (regressionFirst), and human review state stay inside the Extension Host.
The Webview only sends tiny query messages ({ status: 'regression', search: 'SELECT', page: 1 }) and receives:
- One lightweight KPI
summaryobject (< 2KB) - Exactly one paginated slice (
50cases by default)
When the panel closes (panel.onDidDispose), the Extension Host drops its reference immediately so GC reclaims memory.
3. Strictly Read-Only Data Safety + Strict XSS Escaping
Unlike generic data tools that open local SQLite databases in read-write mode (risking WAL locks or file corruption), EvalDiff never opens source .jsonl files for writing. Our unit test suite verifies SHA-256 hashes of both input files before and after diffing to prove zero bytes changed.
Human Pass/Fail review annotations live separately in VS Code context.workspaceState, keyed by a SHA-1 hash of the file pair.
Meanwhile, both the Webview UI and exported standalone HTML audit reports lock down a strict nonce CSP (default-src 'none'; style-src 'unsafe-inline'; script-src 'nonce-...') and escape every dynamic field:
function escapeHtml(value) { if (value === null || value === undefined) return ''; return String(value) .replace(/&/g, '&') .replace(/</g, '<') .replace(/>/g, '>') .replace(/"/g, '"') .replace(/'/g, '''); } 4. Schema-Agnostic Auto-Detection Across Eval Frameworks
AI teams rarely agree on JSONL column names. OpenAI Evals writes sample_id + messages + completion, Promptfoo often exports case_id + response + duration_ms, and custom Python scripts use score or boolean passed.
Instead of forcing users to write a YAML mapping config, normalizeRecord resolves common aliases in priority order—even flattening OpenAI messages arrays and summing usage.prompt_tokens + usage.completion_tokens when total_tokens is absent.
If you want framework-specific setup notes:
- OpenAI Evals guide: https://evaldiff.miaodui.workers.dev/openai-evals-jsonl-viewer
- Promptfoo local diff guide: https://evaldiff.miaodui.workers.dev/promptfoo-regression-diff
- Offline alternative to cloud eval SaaS: https://evaldiff.miaodui.workers.dev/langsmith-offline-alternative
5. Zero-Telemetry Offline-First Licensing
For monetization, I wanted an honest split that never compromises offline privacy:
- Free (MIT Core): Unlimited single-file
.jsonlinspection, side-by-side diff up to 100 cases with KPI summary, malformed line diagnostics, local Pass/Fail review, and one-click Markdown PR summary copy. - Pro via Polar.sh (Solo $29/yr | Team 5-Seat $99/yr): Unlimited dataset diffing and one-click export of standalone offline HTML/CSV regression audit reports.
License activation uses Polar's public Customer Portal endpoint (POST /v1/customer-portal/license-keys/activate) with no private tokens in the extension—and it only fires when a user explicitly runs EvalDiff: Activate Pro License Key. After activation, the license state is cached in VS Code globalState, so everyday usage remains 100% offline.
Try It Locally in 10 Seconds
git clone https://github.com/miaoduitw-creator/evaldiff-workbench.git cd evaldiff-workbench npm test All 12 unit tests (streaming fault tolerance, read-only SHA-256 verification, regression math, OOM circuit breakers, XSS escaping, and mocked Polar license lifecycle) run on Node's built-in node:test runner with zero npm install step.
Or install directly from Open VSX for Cursor / Windsurf / VSCodium / Antigravity:
https://open-vsx.org/extension/miaodui/evaldiff-workbench

