{"slug": "how-i-built-a-200mb-streaming-jsonl-eval-diff-viewer-for-vs-code-and-cursor-with", "title": "How I Built a 200MB Streaming JSONL Eval Diff Viewer for VS Code and Cursor With Zero Runtime Dependencies", "summary": "A developer built EvalDiff v0.2.0, a read-only VS Code and Cursor extension that diffs large JSONL eval files (baseline vs. candidate) with zero third-party runtime dependencies. The extension streams files with Node's fs.createReadStream and readline under a 200MB file-size cap, an 8,000-character field cap and a 64MB memory circuit breaker, keeps filtering, search and sorting in the Extension Host, and renders results in a Webview with a nonce CSP and HTML escaping. It never opens source files for writing, with unit tests hashing inputs before and after to prove zero bytes changed.", "body_md": "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`.\n\nYet inspecting what actually regressed between those two files inside an editor is surprisingly painful:\n\n`fs.readFileSync()` a 120MB JSONL file, `JSON.parse()` every row, and shove the entire array into `webview.postMessage()`. The renderer stalls or crashes.`<script>alert(\"xss\")</script>` payloads in prompts and completions. Dropping raw eval text into an HTML report or Webview is an instant security bug.\nTo 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**.\n\nHere are the four concrete engineering patterns that made it fast, safe, and crash-proof.\n\nInstead 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:\n\n`maxFileSizeMB`, default 200MB)` fs.promises.stat`.` maxFieldChars`, default 8,000 chars)` maxBufferedBytes`, default 64MB)\n\n``` js\nconst stream = fs.createReadStream(filePath, {\n  encoding: 'utf8',\n  highWaterMark: 64 * 1024\n});\nconst rl = readline.createInterface({ input: stream, crlfDelay: Infinity });\n\ntry {\n  for await (const line of rl) {\n    totalLines += 1;\n    const trimmed = line.trim();\n    if (!trimmed) {\n      blankLines += 1;\n      continue;\n    }\n\n    let parsed;\n    try {\n      parsed = JSON.parse(trimmed);\n    } catch (parseErr) {\n      malformedCount += 1;\n      malformedLines.push({\n        lineNumber: totalLines,\n        rawPreview: trimmed.slice(0, 160),\n        error: parseErr.message\n      });\n      continue;\n    }\n\n    const normalized = normalizeRecord(parsed, totalLines, maxFieldChars);\n    const recBytes = estimateRecordBytes(normalized);\n\n    if (bufferedBytes + recBytes > maxBufferedBytes && records.length > 0) {\n      truncated = true;\n      truncationReason = 'MEMORY_LIMIT';\n      break;\n    }\n\n    bufferedBytes += recBytes;\n    records.push(normalized);\n  }\n} finally {\n  rl.close();\n  stream.destroy();\n}\n```\n\nNotice two details:\n\n`finally` block guarantees file descriptors are closed immediately if the memory circuit breaker trips.\nA 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.\n\nThe Webview only sends tiny query messages (`{ status: 'regression', search: 'SELECT', page: 1 }`) and receives:\n\n`summary` object (< 2KB)`50` cases by default)\nWhen the panel closes (`panel.onDidDispose`), the Extension Host drops its reference immediately so GC reclaims memory.\n\nUnlike 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.\n\nHuman Pass/Fail review annotations live separately in VS Code `context.workspaceState`, keyed by a SHA-1 hash of the file pair.\n\nMeanwhile, 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:\n\n```\nfunction escapeHtml(value) {\n  if (value === null || value === undefined) return '';\n  return String(value)\n    .replace(/&/g, '&amp;')\n    .replace(/</g, '&lt;')\n    .replace(/>/g, '&gt;')\n    .replace(/\"/g, '&quot;')\n    .replace(/'/g, '&#39;');\n}\n```\n\nAI 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`.\n\nInstead 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.\n\nIf you want framework-specific setup notes:\n\nFor monetization, I wanted an honest split that never compromises offline privacy:\n\n`.jsonl` inspection, 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.\nLicense 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.\n\n```\ngit clone https://github.com/miaoduitw-creator/evaldiff-workbench.git\ncd evaldiff-workbench\nnpm test\n```\n\nAll 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.\n\nOr install directly from Open VSX for Cursor / Windsurf / VSCodium / Antigravity:\n\n[https://open-vsx.org/extension/miaodui/evaldiff-workbench](https://open-vsx.org/extension/miaodui/evaldiff-workbench)", "url": "https://wpnews.pro/news/how-i-built-a-200mb-streaming-jsonl-eval-diff-viewer-for-vs-code-and-cursor-with", "canonical_source": "https://dev.to/miaoduitwcreator/how-i-built-a-200mb-streaming-jsonl-eval-diff-viewer-for-vs-code-and-cursor-with-zero-runtime-3926", "published_at": "2026-11-30 03:39:31+00:00", "updated_at": "2026-11-30 03:45:35.911129+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "large-language-models", "mlops"], "entities": ["EvalDiff", "VS Code", "Cursor", "Windsurf", "VSCodium", "Antigravity", "OpenAI Evals", "Promptfoo"], "also_reported_by": [], "takeaway": "Stream JSONL line-by-line with readline and a byte-budget circuit breaker instead of JSON.parse-ing whole files, and keep filtering and paging in the Extension Host so the Webview only receives summaries and 50-case pages.", "recommendation": {"advice": "For large JSONL eval diffs, stream with readline under explicit file-size and buffered-byte caps, and escape every dynamic field behind a nonce CSP before rendering in a Webview.", "playbook": "evals-testing", "playbook_url": "https://wpnews.pro/playbooks/evals-testing"}, "alternates": {"html": "https://wpnews.pro/news/how-i-built-a-200mb-streaming-jsonl-eval-diff-viewer-for-vs-code-and-cursor-with", "markdown": "https://wpnews.pro/news/how-i-built-a-200mb-streaming-jsonl-eval-diff-viewer-for-vs-code-and-cursor-with.md", "text": "https://wpnews.pro/news/how-i-built-a-200mb-streaming-jsonl-eval-diff-viewer-for-vs-code-and-cursor-with.txt", "jsonld": "https://wpnews.pro/news/how-i-built-a-200mb-streaming-jsonl-eval-diff-viewer-for-vs-code-and-cursor-with.jsonld"}}