Skip to content

Commit 6f7c60d

Browse files
committed
docs/test(evals): welcome onboarding — README section, framework unit tests
Tests cover env-variant resolution, plan derivation (real vs scripted, recommended command), and leaderboard rendering (all public rows, uniform panel width, independent count-up of the user's row).
1 parent 954e502 commit 6f7c60d

2 files changed

Lines changed: 98 additions & 0 deletions

File tree

packages/evals/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,18 @@ Inside the REPL (or as `evals <command>` from your shell):
4545

4646
Use `Esc` to abort an in-flight run without exiting the REPL.
4747

48+
### Onboarding
49+
50+
`evals welcome` runs a guided first-run flow built on the agent benchmarks. Three designs are available while we decide which one ships. Each opens with the same short intro (logo → what we measure → top of the board):
51+
52+
| Command | Design |
53+
| ----------------- | ------------------------------------------------------------------------- |
54+
| `evals welcome a` | **Arena** — three models race the same real WebVoyager task in lanes |
55+
| `evals welcome b` | **Trace** — scrub through a recorded agent trajectory (← → space) |
56+
| `evals welcome c` | **Dialogue** — the agent narrates a real task in first person, chat-style |
57+
58+
`welcome` alone shows a picker; `welcome-a`, `welcome-b`, `welcome-c` are one-token spellings. With a provider key and a browser each design hands off to a real `run b:webvoyager -l 3`; without them it replays scripted trajectories of real benchmark tasks and says what unlocks the real thing. Set `EVALS_WELCOME_WIZARD=<variant>` (or `1`) to auto-run one on the first REPL launch; `EVALS_NO_WELCOME=1` suppresses the first-run welcome. Esc skips ahead, Ctrl+C cancels.
59+
4860
## Run targets
4961

5062
`evals run` accepts any of these shapes:
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import { describe, expect, it } from "vitest";
2+
import { stripAnsi } from "../../tui/format.js";
3+
import { derivePlan } from "../../tui/welcome/detect.js";
4+
import { LEADERBOARD, renderLeaderboard } from "../../tui/welcome/leaderboard.js";
5+
import { DEFAULT_VARIANT, isWelcomeVariant, variantFromEnv } from "../../tui/welcome/index.js";
6+
7+
describe("variantFromEnv", () => {
8+
it("maps truthy opt-in values to the default variant", () => {
9+
expect(variantFromEnv("1")).toBe(DEFAULT_VARIANT);
10+
expect(variantFromEnv("true")).toBe(DEFAULT_VARIANT);
11+
});
12+
it("selects an explicit variant letter, case-insensitively", () => {
13+
expect(variantFromEnv("a")).toBe("a");
14+
expect(variantFromEnv("C")).toBe("c");
15+
});
16+
it("returns null for unset or unknown values", () => {
17+
expect(variantFromEnv(undefined)).toBeNull();
18+
expect(variantFromEnv("")).toBeNull();
19+
expect(variantFromEnv("zzz")).toBeNull();
20+
});
21+
it("isWelcomeVariant guards the five letters", () => {
22+
expect(isWelcomeVariant("c")).toBe(true);
23+
expect(isWelcomeVariant("d")).toBe(false);
24+
expect(isWelcomeVariant("e")).toBe(false);
25+
expect(isWelcomeVariant(1)).toBe(false);
26+
});
27+
});
28+
29+
describe("derivePlan", () => {
30+
it("is real when a provider key and a browser both exist", () => {
31+
const { plan, recommend } = derivePlan({
32+
chrome: true,
33+
browserbase: false,
34+
providers: ["anthropic"],
35+
});
36+
expect(plan.kind).toBe("real");
37+
if (plan.kind === "real") expect(plan.browser).toBe("local");
38+
expect(recommend.command).toBe("run b:webvoyager -l 3");
39+
});
40+
it("prefers local Chrome, but uses Browserbase when Chrome is absent", () => {
41+
const { plan, recommend } = derivePlan({
42+
chrome: false,
43+
browserbase: true,
44+
providers: ["openai"],
45+
});
46+
expect(plan.kind).toBe("real");
47+
if (plan.kind === "real") expect(plan.browser).toBe("browserbase");
48+
expect(recommend.command).toBe("run b:webvoyager -l 3 -e browserbase");
49+
});
50+
it("is scripted without a key, and says what is missing", () => {
51+
const noKey = derivePlan({ chrome: true, browserbase: true, providers: [] });
52+
expect(noKey.plan.kind).toBe("scripted");
53+
expect(noKey.recommend.command).toBe("list bench");
54+
expect(noKey.recommend.line).toMatch(/OPENAI_API_KEY/);
55+
const noBrowser = derivePlan({ chrome: false, browserbase: false, providers: ["google"] });
56+
expect(noBrowser.plan.kind).toBe("scripted");
57+
expect(noBrowser.recommend.line).toMatch(/browser/i);
58+
});
59+
});
60+
61+
describe("renderLeaderboard", () => {
62+
it("renders every public row inside a panel with the benchmark title", () => {
63+
const lines = renderLeaderboard({}).map(stripAnsi);
64+
expect(lines[0]).toContain("Browserbase Benchmark v1");
65+
for (const row of LEADERBOARD) {
66+
expect(lines.some((l) => l.includes(row.model))).toBe(true);
67+
}
68+
});
69+
it("keeps every row the same visible width (no jagged borders)", () => {
70+
const widths = new Set(
71+
renderLeaderboard({
72+
yourRow: { label: "you · navigation/open", accuracy: 100, speedS: 2.1, costUsd: 0 },
73+
}).map((l) => stripAnsi(l).length),
74+
);
75+
expect(widths.size).toBe(1);
76+
});
77+
it("scales the user's row independently of the public rows", () => {
78+
const half = renderLeaderboard({
79+
progress: 1,
80+
yourProgress: 0.5,
81+
yourRow: { label: "you", accuracy: 100, speedS: 2, costUsd: 0 },
82+
}).map(stripAnsi);
83+
expect(half.some((l) => l.includes("92.1%"))).toBe(true); // public rows fully counted
84+
expect(half.some((l) => l.includes("you") && l.includes("50.0%"))).toBe(true);
85+
});
86+
});

0 commit comments

Comments
 (0)