From 48812a7aa773e40cb44d9e7d037325e97ed75bcc Mon Sep 17 00:00:00 2001 From: Tyagiquamar Date: Tue, 25 Aug 2026 16:55:05 +0530 Subject: [PATCH] fix(benchmarks): split BENCHMARK_HUB_DATA_DIR on the platform path delimiter --- apps/benchmark-hub/README.md | 3 ++- src/benchmark-hub-core.ts | 4 ++-- src/benchmarks-mcp.ts | 10 +++++----- tests/benchmarks-mcp.test.mjs | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/apps/benchmark-hub/README.md b/apps/benchmark-hub/README.md index 9bc654f4..25156a46 100644 --- a/apps/benchmark-hub/README.md +++ b/apps/benchmark-hub/README.md @@ -166,7 +166,8 @@ bun run start:demo # production server incl. repo demo data The server-side loader (`lib/data-core.ts`) scans: -1. `BENCHMARK_HUB_DATA_DIR` — a colon-separated list of directories whose +1. `BENCHMARK_HUB_DATA_DIR` — a list of directories (separated by the + platform path delimiter, `:` on POSIX / `;` on Windows) whose subdirectories are benchmarks; when unset, `~/.understudy/benchmarks` 2. Only when `BENCHMARK_HUB_DEMO=1` (the `dev` and `start:demo` scripts set it): `/experiments/benchmark-hub-demo` (seeded demo data, writable diff --git a/src/benchmark-hub-core.ts b/src/benchmark-hub-core.ts index 032c2577..0aa0d8d5 100644 --- a/src/benchmark-hub-core.ts +++ b/src/benchmark-hub-core.ts @@ -78,7 +78,7 @@ export type { CalibrationSummary } from "./benchmark-hub-types.js"; /** * Data-dir contract: - * - BENCHMARK_HUB_DATA_DIR: colon-separated list of directories whose + * - BENCHMARK_HUB_DATA_DIR: list of directories (path.delimiter-separated) whose * subdirectories are benchmarks. Each benchmark dir holds benchmark.json * (understudy.benchmark.v1), optional rows-*.jsonl and/or rows/*.jsonl * (understudy.eval_result.v1 lines), optional traces*.jsonl (message DAG @@ -104,7 +104,7 @@ function demoEnabled(): boolean { function slugRoots(): { prefix: string; root: string; source: HubEntry["source"]; readOnly: boolean }[] { const roots: { prefix: string; root: string; source: HubEntry["source"]; readOnly: boolean }[] = []; const envDirs = (process.env.BENCHMARK_HUB_DATA_DIR ?? "") - .split(":") + .split(path.delimiter) .map((d) => d.trim()) .filter(Boolean); if (envDirs.length > 0) { diff --git a/src/benchmarks-mcp.ts b/src/benchmarks-mcp.ts index 19706043..87e1d159 100644 --- a/src/benchmarks-mcp.ts +++ b/src/benchmarks-mcp.ts @@ -15,7 +15,7 @@ import { existsSync, readFileSync, readdirSync, statSync } from "node:fs"; import { homedir } from "node:os"; -import { basename, extname, join, resolve } from "node:path"; +import { basename, delimiter, extname, join, resolve } from "node:path"; import { Server } from "@modelcontextprotocol/sdk/server/index.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js"; @@ -57,15 +57,15 @@ class ToolError extends Error {} /** * Point the loaders at the requested roots. Default (no extra roots, env * unset) is ~/.understudy/benchmarks — data-core's own default. Extra roots - * are ADDED after the default, via the same colon-separated + * are ADDED after the default, via the same path.delimiter-separated * BENCHMARK_HUB_DATA_DIR contract the hub honors. */ export function configureBenchmarksMcpRoots(extraRoots: string[]): void { if (extraRoots.length === 0) return; const defaults = process.env.BENCHMARK_HUB_DATA_DIR - ? process.env.BENCHMARK_HUB_DATA_DIR.split(":").filter(Boolean) + ? process.env.BENCHMARK_HUB_DATA_DIR.split(delimiter).filter(Boolean) : [join(homedir(), ".understudy", "benchmarks")]; - process.env.BENCHMARK_HUB_DATA_DIR = [...defaults, ...extraRoots.map((r) => resolve(r))].join(":"); + process.env.BENCHMARK_HUB_DATA_DIR = [...defaults, ...extraRoots.map((r) => resolve(r))].join(delimiter); } /* ---------------- shared summaries ---------------- */ @@ -699,7 +699,7 @@ const SLUG_RE = /^[a-z0-9][a-z0-9._-]{0,63}$/; function hubPrimaryRoot(): string { const roots = (process.env.BENCHMARK_HUB_DATA_DIR ?? join(homedir(), ".understudy", "benchmarks")) - .split(":") + .split(delimiter) .filter(Boolean); return roots[0] ?? join(homedir(), ".understudy", "benchmarks"); } diff --git a/tests/benchmarks-mcp.test.mjs b/tests/benchmarks-mcp.test.mjs index fc74e0a0..66972241 100644 --- a/tests/benchmarks-mcp.test.mjs +++ b/tests/benchmarks-mcp.test.mjs @@ -586,7 +586,7 @@ describe("server wiring", () => { configureBenchmarksMcpRoots([]); assert.equal(process.env.BENCHMARK_HUB_DATA_DIR, saved); // no-op without roots configureBenchmarksMcpRoots(["/tmp/extra-bench"]); - assert.equal(process.env.BENCHMARK_HUB_DATA_DIR, `${saved}:${path.resolve("/tmp/extra-bench")}`); + assert.equal(process.env.BENCHMARK_HUB_DATA_DIR, `${saved}${path.delimiter}${path.resolve("/tmp/extra-bench")}`); } finally { process.env.BENCHMARK_HUB_DATA_DIR = saved; }