Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/benchmark-hub/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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): `<repo>/experiments/benchmark-hub-demo` (seeded demo data, writable
Expand Down
4 changes: 2 additions & 2 deletions src/benchmark-hub-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions src/benchmarks-mcp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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 ---------------- */
Expand Down Expand Up @@ -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");
}
Expand Down
2 changes: 1 addition & 1 deletion tests/benchmarks-mcp.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down