MCP eval harness
pnpm eval benchmarks whether GhostVue's AI-native layer (@ghostvue/mcp manifests, examples, docs search, and tokens) improves real UI code generation compared to documentation alone.
Benchmark design
Every run compares two conditions using the same pinned model and generation settings:
| Condition | Tools provided to the agent | Purpose |
|---|---|---|
docs-only | docs_search, docs_read over GhostVue's Markdown/llms-full.txt corpus | Baseline with published docs and no MCP manifest/example server |
docs+mcp | Live @ghostvue/mcp stdio tools (list_components, get_component, get_examples, search_docs, get_tokens) | Measures the incremental value of structured MCP component contracts |
Fixed five-task suite
The task set (EVAL_TASK_SET_VERSION 1.0.0 in scripts/lib/eval/tasks.js) uses only shipped GhostVue primitives:
| Task ID | Primitives exercised | Key grading checks |
|---|---|---|
login-form | GhostCard, GhostField, GhostInput, GhostCheckbox, GhostButton | Empty submit validation (aria-invalid="true", role="alert"), valid submit status, Tab / Space / Enter keyboard flow |
settings-dialog | GhostDialog*, GhostSwitch, GhostField, GhostInput, GhostButton | role="dialog" + aria-modal="true", Tab focus trap, Space switch toggle, Escape draft discard + focus restoration, save summary update |
async-combobox-search | GhostCombobox*, GhostSpinner, useGhostComboboxAsyncSearch | Out-of-order async search race safety (begin / isLatest), empty state, ArrowDown (aria-activedescendant), Enter, Escape focus retention |
paginated-table | GhostTable*, GhostPagination (explicitly forbids GhostDataTable / useGhostDataTable) | Semantic <table> + <caption> + scope="col", 5 rows/page slicing, keyboard Enter pagination + aria-current="page" + boundary disable state |
validation-error-form | GhostField*, GhostInput, GhostInlineAlert, GhostButton | GhostInlineAlert error summary + field errors, focus moved to first [aria-invalid="true"] control on invalid submit, error clearing + status on valid resubmit |
Separate scoring and visual evidence
pnpm eval never collapses results into a single misleading accessibility or quality score. Each (task, condition) trial reports every grading dimension separately, with explicit passed, failed, skipped, and missing counts:
- Constraints (
constraints): SFC structure (<script>+<template>), expected primitives, and forbidden-API checks (such as rejectingGhostDataTableonpaginated-table). - ESLint (
eslint):@ghostvue/eslint-pluginconfigs.recommended(no-unknown-props,no-unknown-slots,no-undeclared-v-model). - Typecheck (
typecheck): Isolatedvue-tsc --noEmitagainst workspace@ghostvue/themesand@ghostvue/vuetypes. - Build (
build): Vite +@vitejs/plugin-vuebundle inside a.ghost-theme(default.css) host page. - Behavior (
behavior) & Keyboard (keyboard): Real Chromium Playwright assertions for functional DOM state, focus movement (document.activeElement), andaria-*updates. When--skip-browseris passed or Vite build fails, browser checks are markedskippedrather than omitted or passed. - Axe (
axe): Per-state@axe-core/playwrightscans (initial,open,validation-error,page-2, etc.), reporting exact violations per state. - Visual evidence (
visual): Full-page Playwright PNG screenshots saved underreports/eval/<run-id>/artifacts/<condition>/<taskId>/<state>.pngwithstatus: "captured-pending-human-review",reviewed: false, andhumanAssessment: "unreviewed". Unreviewed images never count as having passed human visual assessment.
Safety and budget enforcement
Live paid runs are manual only and fail closed:
- Default $5 total cap:
--budgetdefaults to5USD, covering bothdocs-onlyanddocs+mcpacross all selected tasks (not $5 per task or condition). - Explicit authorization: Paid providers (
anthropic,openai,gemini) require--allow-paid, an explicit--model, and the provider API key (ANTHROPIC_API_KEY,OPENAI_API_KEY, orGEMINI_API_KEY). - CI / PR guard: Paid providers are blocked whenever
CI,GITHUB_ACTIONS, orCONTINUOUS_INTEGRATIONis set. Automated tests and CI only run offline--provider mockor stubbed HTTP transports. - Fail-closed preflight: Before issuing any API request,
evaluateBudgetPreflightverifies pinned pricing for(provider, model)and finitemaxTurnsPerTrial,maxInputTokensPerTurn,maxOutputTokensPerTurn, andmaxRetries = 0. Unknown model pricing or worst-case total cost above--budgetaborts before spending $0.00 (EvalBudgetError). - Per-call ledger & zero retries:
BudgetLedger.assertCanExecuteCallchecks worst-case remaining headroom before every single turn, andmaxRetriesis locked to0on paid runs.
Running pnpm eval
Offline deterministic run (uses the real @ghostvue/mcp stdio server for docs+mcp and $0.00 mock agent output):
pnpm build
pnpm evalRun a fast static/typecheck smoke without launching Chromium:
pnpm eval --skip-browser --tasks login-form,paginated-tableRun a manual bounded comparison against a live model (local terminal only):
ANTHROPIC_API_KEY=... pnpm eval \
--provider anthropic \
--model claude-sonnet-4-20250514 \
--budget 5 \
--allow-paidCLI flags
| Flag | Default | Description |
|---|---|---|
--provider | mock | mock, anthropic, openai, or gemini |
--model | mock-deterministic-v1 | Pinned model identifier (required for paid providers) |
--budget | 5 | Total USD cap across all selected tasks and conditions |
--allow-paid | false | Required explicit opt-in for non-mock providers |
--tasks | all 5 tasks | Comma-separated task IDs |
--conditions | docs-only,docs+mcp | Comma-separated conditions |
--mock-profile | comparison | comparison (shows representative docs-only gaps vs docs+mcp) or reference (all reference SFCs) |
--max-turns | 6 | Maximum tool/completion turns per trial |
--max-input-tokens | 24000 | Upper bound on input tokens per turn for budget preflight |
--max-output-tokens | 4096 | Output token cap per turn |
--out-dir | reports/eval | Directory where per-run folders are written (gitignored) |
--skip-browser | false | Skip Playwright behavior, keyboard, axe, and visual checks |
--skip-typecheck | false | Skip vue-tsc typecheck |
Stored per-run artifacts
Each run writes a self-contained folder under reports/eval/<run-id>/ (ignored by Git and Prettier):
results.json— Pinned task versions and prompt hashes, model/provider/settings, budget preflight & actual token/USD usage, Git SHA + dirty flag, workspace package versions, live MCPassetBundleId, tool traces, and per-dimension grading results.summary.md— Side-by-side comparison table acrossdocs-onlyanddocs+mcpwith separate dimension counts and visual review notices.generated/<condition>/<taskId>/TaskOutput.vue— Generated SFC source for inspection.artifacts/<condition>/<taskId>/<state>.png— Unreviewed visual evidence screenshots.