diff --git a/apps/cli/src/commands/results/serve.ts b/apps/cli/src/commands/results/serve.ts index 4851f11b..eeb3a4d6 100644 --- a/apps/cli/src/commands/results/serve.ts +++ b/apps/cli/src/commands/results/serve.ts @@ -19,6 +19,10 @@ * variants. They share handler functions via DataContext, differing only in * how searchDir is resolved. * + * Before starting the server, the command enforces `required_version` from + * the cwd's `.agentv/config.yaml` (single-project scope) via + * `enforceRequiredVersion()`, matching the behavior of `agentv eval`. + * * Exported functions (for testing): * - resolveSourceFile(source, cwd) — resolves a run manifest path * - loadResults(content) — parses JSONL into EvaluationResult[] @@ -37,14 +41,17 @@ import { discoverBenchmarks, getBenchmark, loadBenchmarkRegistry, + loadConfig, removeBenchmark, } from '@agentv/core'; import type { Context } from 'hono'; import { Hono } from 'hono'; +import { enforceRequiredVersion } from '../../version-check.js'; import { parseJsonlResults } from '../eval/artifact-writer.js'; import { resolveRunManifestPath } from '../eval/result-layout.js'; import { loadRunCache, resolveRunCacheFile } from '../eval/run-cache.js'; +import { findRepoRoot } from '../eval/shared.js'; import { listResultFiles } from '../inspect/utils.js'; import { registerEvalRoutes } from './eval-runner.js'; import { @@ -1449,6 +1456,18 @@ export const resultsServeCommand = command({ return; } + // ── Version check ──────────────────────────────────────────────── + // Enforce `required_version` from .agentv/config.yaml so Studio/serve + // match `agentv eval` behavior. Same prompt in TTY, warn+continue + // otherwise. Single-project scope only — when one agentv instance + // serves multiple repos with differing version requirements, a + // per-project local install is required instead. + const repoRoot = await findRepoRoot(cwd); + const yamlConfig = await loadConfig(path.join(cwd, '_'), repoRoot); + if (yamlConfig?.required_version) { + await enforceRequiredVersion(yamlConfig.required_version); + } + // ── Determine multi-project mode ──────────────────────────────── const registry = loadBenchmarkRegistry(); const { isMultiProject, showMultiWarning } = resolveDashboardMode(registry.benchmarks.length, {