Objective
resolveCliPath in apps/cli/src/commands/results/eval-runner.ts:215 returns "Cannot locate agentv CLI entry point" when Studio is run from source against a project directory that is not the agentv monorepo itself, and agentv is not installed globally.
Repro
# Pretend we're a user with a project that isn't the agentv repo
TMPDIR=$(mktemp -d)
cd "$TMPDIR"
# Boot Studio from a source checkout of the agentv worktree, pointed at $TMPDIR cwd
bun /path/to/agentv/apps/cli/src/cli.ts studio --port 4182 &
sleep 4
# Hit the launch endpoint
curl -s -X POST http://localhost:4182/api/eval/run -H "Content-Type: application/json" \
-d '{"suite_filter":"any.eval.yaml","output":"runs/r1","resume":true}'
# → {"error":"Cannot locate agentv CLI entry point"}
Root cause
The path math in fallback path 2 is off by one. With currentDir = .../apps/cli/src/commands/results:
path.resolve(currentDir, '../../../cli.ts') → .../apps/cli/cli.ts (missing src/) ❌
- Should be
path.resolve(currentDir, '../../cli.ts') → .../apps/cli/src/cli.ts ✓
The first candidate (path.join(cwd, 'apps/cli/src/cli.ts')) only succeeds when cwd is the agentv repo. The third fallback (global agentv binary) only works when the user has a published version installed. So a developer running Studio from a worktree against any other project hits all three failure modes.
// apps/cli/src/commands/results/eval-runner.ts:215-216
const fromSrc = path.resolve(currentDir, '../../../cli.ts'); // ❌ off-by-one
const fromDist = path.resolve(currentDir, '../../cli.js'); // also suspect — see below
Discovered by
PR #1220 e2e UAT — exercising the new "Resume run" / "Rerun failed cases" buttons against a synthetic project (not the agentv repo) hit this error. Worked around by installing a wrapper agentv shim on PATH.
Acceptance signals
Non-goals
- The existing global-agentv fallback works fine for end users who installed via npm; this only blocks dev-from-source workflows.
Suggested fix
- const fromSrc = path.resolve(currentDir, '../../../cli.ts');
- const fromDist = path.resolve(currentDir, '../../cli.js');
+ const fromSrc = path.resolve(currentDir, '../../cli.ts');
+ const fromDist = path.resolve(currentDir, 'cli.js'); // dist is bundled flat
Verify both branches with: bun apps/cli/src/cli.ts studio --port X (src) and bun apps/cli/dist/cli.js studio --port X (dist) from a foreign cwd, then POST to /api/eval/preview to confirm the spawn args resolve.
Objective
resolveCliPathinapps/cli/src/commands/results/eval-runner.ts:215returns "Cannot locate agentv CLI entry point" when Studio is run from source against a project directory that is not the agentv monorepo itself, andagentvis not installed globally.Repro
Root cause
The path math in fallback path 2 is off by one. With
currentDir = .../apps/cli/src/commands/results:path.resolve(currentDir, '../../../cli.ts')→.../apps/cli/cli.ts(missingsrc/) ❌path.resolve(currentDir, '../../cli.ts')→.../apps/cli/src/cli.ts✓The first candidate (
path.join(cwd, 'apps/cli/src/cli.ts')) only succeeds when cwd is the agentv repo. The third fallback (globalagentvbinary) only works when the user has a published version installed. So a developer running Studio from a worktree against any other project hits all three failure modes.Discovered by
PR #1220 e2e UAT — exercising the new "Resume run" / "Rerun failed cases" buttons against a synthetic project (not the agentv repo) hit this error. Worked around by installing a wrapper
agentvshim on PATH.Acceptance signals
fromDistpath against tsup output layout — bundled cli.js sits atapps/cli/dist/cli.js, so resolving from a chunk's location may also need adjustment)apps/cli/test/commands/results/serve.test.tscover the launch-from-foreign-cwd case (currently the resume API tests tolerate[202, 500]because they hit this bug)Non-goals
Suggested fix
Verify both branches with:
bun apps/cli/src/cli.ts studio --port X(src) andbun apps/cli/dist/cli.js studio --port X(dist) from a foreign cwd, then POST to/api/eval/previewto confirm the spawn args resolve.