Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions apps/cli/src/commands/results/eval-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,16 @@ function resolveCliPath(cwd: string): { binPath: string; args: string[] } | unde
}

// 2. Try from the current running process location (handles both CJS __dirname
// and ESM import.meta.url; fileURLToPath works correctly on Windows)
// and ESM import.meta.url; fileURLToPath works correctly on Windows).
// Layouts we can be loaded from:
// - dev/source: this module sits at apps/cli/src/commands/results/eval-runner.ts,
// so cli.ts is two dirs up at apps/cli/src/cli.ts.
// - bundled dist: tsup emits the chunk into apps/cli/dist/, alongside cli.js,
// so the entry is in the same directory as currentDir.
const currentDir =
typeof __dirname !== 'undefined' ? __dirname : path.dirname(fileURLToPath(import.meta.url));
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');

if (existsSync(fromSrc)) return { binPath: 'bun', args: [fromSrc] };
if (existsSync(fromDist)) return { binPath: 'bun', args: [fromDist] };
Expand Down
32 changes: 14 additions & 18 deletions apps/cli/test/commands/results/serve.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -900,13 +900,13 @@ describe('serve app', () => {
resume: true,
}),
});
// Either 202 (spawn succeeded) or 500 (no CLI on disk in test env).
expect([202, 500]).toContain(res.status);
const data = (await res.json()) as { command?: string; error?: string };
if (res.status === 202) {
expect(data.command).toContain('--resume');
expect(data.command).toContain('--output .agentv/results/runs/2026-05-06T00-00-00-000Z');
}
// resolveCliPath must resolve in the test env via the running-process
// fallback (apps/cli/src/cli.ts is two dirs up from this module). A
// 500 here would mean the off-by-one regression from #1221 came back.
expect(res.status).toBe(202);
const data = (await res.json()) as { command: string };
expect(data.command).toContain('--resume');
expect(data.command).toContain('--output .agentv/results/runs/2026-05-06T00-00-00-000Z');
});

it('builds --rerun-failed + --output flags from the request', async () => {
Expand All @@ -921,12 +921,10 @@ describe('serve app', () => {
rerun_failed: true,
}),
});
expect([202, 500]).toContain(res.status);
if (res.status === 202) {
const data = (await res.json()) as { command: string };
expect(data.command).toContain('--rerun-failed');
expect(data.command).toContain('--output runs/r1');
}
expect(res.status).toBe(202);
const data = (await res.json()) as { command: string };
expect(data.command).toContain('--rerun-failed');
expect(data.command).toContain('--output runs/r1');
});

it('builds --retry-errors <path> from the request', async () => {
Expand All @@ -939,11 +937,9 @@ describe('serve app', () => {
retry_errors: 'runs/r0/index.jsonl',
}),
});
expect([202, 500]).toContain(res.status);
if (res.status === 202) {
const data = (await res.json()) as { command: string };
expect(data.command).toContain('--retry-errors runs/r0/index.jsonl');
}
expect(res.status).toBe(202);
const data = (await res.json()) as { command: string };
expect(data.command).toContain('--retry-errors runs/r0/index.jsonl');
});

it('rejects resume + rerun_failed combo with 400', async () => {
Expand Down
Loading