fix(cli): resolveCliPath off-by-one in src + dist fallback paths#1223
Merged
fix(cli): resolveCliPath off-by-one in src + dist fallback paths#1223
Conversation
Both fallback path resolutions in resolveCliPath were off: - src: '../../../cli.ts' from .../apps/cli/src/commands/results/ resolved to apps/cli/cli.ts (missing src/). Should be '../../cli.ts'. - dist: '../../cli.js' from .../apps/cli/dist/ resolved to apps/cli.js (one dir too high). tsup emits chunks alongside cli.js, so the entry is in the same dir — should be 'cli.js'. End users with `agentv` installed globally were unaffected because the third fallback (global PATH lookup) covered them. Affected: developers running Studio from a source checkout against any cwd that isn't the agentv repo itself. Strengthened the existing resume-API tests to assert exact 202 (was [202, 500]) so a regression of this off-by-one will fail CI. Closes #1221 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Deploying agentv with
|
| Latest commit: |
7bba0a1
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://00f2dc5a.agentv.pages.dev |
| Branch Preview URL: | https://fix-1221-resolve-cli-path.agentv.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1221
Summary
Two off-by-one errors in
resolveCliPath(added in the original eval-runner introduction, surfaced during PR #1220 e2e UAT) prevented Studio from spawning the CLI when run from a source checkout against any cwd that isn't the agentv repo itself.Bug
apps/cli/src/commands/results/eval-runner.ts:215-216resolved fallback paths fromcurrentDir(where the eval-runner module is loaded from) using:For a dev-from-source run,
currentDir = .../apps/cli/src/commands/results/and we wantapps/cli/src/cli.ts— so it's two..not three. For a tsup-bundled dist run,currentDir = .../apps/cli/dist/(chunks live alongsidecli.js) and we wantcli.jsin the same dir — no..at all.End users with
agentvinstalled globally hit the third fallback (global PATH lookup) and were unaffected. Developers running Studio from a worktree against a project outside the agentv repo got{"error":"Cannot locate agentv CLI entry point"}.Fix
Plus a comment block explaining the two layouts so the next person doesn't have to re-derive them.
Tests
The resume-API request-shaping tests in
apps/cli/test/commands/results/serve.test.tspreviously tolerated[202, 500]because of this exact bug ("either spawn succeeded or no CLI on disk in test env"). With the fix, the running-process fallback always succeeds in the test runner, so tightened those assertions to exactly 202. A regression of this off-by-one will now fail CI.Red / Green UAT
Foreign cwd:
/tmp/agentv-1221-aXeco4(random scratch dir, not the agentv repo).Red —
mainGreen — this branch
Test plan
bun test apps/cli/test/commands/results/serve.test.ts— 53 tests pass with strict 202 assertionsbun run lint— cleanbun run typecheck— clean🤖 Generated with Claude Code