feat: Prepare agent-eval for npm CLI usage#42
Conversation
|
@copilot resolve the merge conflicts in this pull request |
| Run local experiments with the `agent-eval` CLI: | ||
|
|
||
| ```sh | ||
| COPILOT_GITHUB_TOKEN=... agent-eval --experiments ./experiments --experiment example |
There was a problem hiding this comment.
@copilot I think --experiment should support a name or path for the experiment (in cases where they don't want to specify a directory)
There was a problem hiding this comment.
Implemented in b528b96. --experiment now accepts an existing local experiment file path when --experiments is not provided, while preserving the existing name lookup behavior. Validation passed: pnpm test --run packages/agent-eval/src/experiments.test.ts, pnpm run format:diff, pnpm run lint, pnpm run build, pnpm run type-check, pnpm test --run, secret scanning, and CodeQL.
|
@copilot resolve the merge conflicts in this pull request |
…-eval-for-publishing # Conflicts: # packages/agent-eval/package.json
|
@copilot resolve the merge conflicts in this pull request |
…-eval-for-publishing # Conflicts: # packages/agent-eval/src/cli.ts # packages/agent-eval/src/config.ts
Resolved the merge conflicts in cd9a758 and pushed the merge commit. Validation passed: targeted agent-eval tests/type-check, |
There was a problem hiding this comment.
Pull request overview
Prepares @primer/agent-eval to be publishable as an npm-installed CLI while adding support for loading experiments from a caller-provided local directory and exporting typed config helpers for external experiment authoring.
Changes:
- Adds a runnable
agent-evalCLI entrypoint and updates build/bundling (Rolldown + DTS generation) to emit publishable artifacts. - Introduces local experiment discovery/loading (
--experiments) with support for named (experiment) and default exports. - Exposes typed config helpers/types via
@primer/agent-evaland@primer/agent-eval/config, and updates docs/CI workflow usage.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents authoring typed experiments outside the repo and running them via the CLI. |
| pnpm-lock.yaml | Locks new/updated dependencies needed for CLI packaging and type output generation. |
| packages/sandbox/src/index.ts | Re-exports McpServerConfig type for downstream typing. |
| packages/agent-eval/tsconfig.build.json | Adds a build tsconfig for emitting declarations into dist. |
| packages/agent-eval/src/index.ts | Adds package entrypoint exports for runner + experiment loading + config helpers. |
| packages/agent-eval/src/experiments.ts | Implements local experiment directory scanning and dynamic module loading. |
| packages/agent-eval/src/experiments.test.ts | Adds tests covering local experiment listing and loading behaviors. |
| packages/agent-eval/src/config.ts | Re-exports/aliases core types and adds a typed experiment helper. |
| packages/agent-eval/src/cli.ts | Adds --experiments flag and wires CLI to local experiment loading. |
| packages/agent-eval/rolldown.config.ts | Switches to multi-entry output and adds rolldown-plugin-dts for .d.ts emission. |
| packages/agent-eval/README.md | Adds package-specific usage docs (CLI + typed authoring + programmatic API). |
| packages/agent-eval/package.json | Adds bin, exports, engine/files metadata, and runtime deps for npm publishing. |
| .github/workflows/experiment.yml | Updates CI workflow to run experiments via the built CLI and pass --experiments. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
- Files reviewed: 12/13 changed files
- Comments generated: 4
- Review effort level: Low
| async function findExperiment( | ||
| id: string, | ||
| options: ExperimentSourceOptions = {}, | ||
| ): Promise<ExperimentConfig | undefined> { | ||
| if (options.experimentsDirectory) { | ||
| const experiments = await getLocalExperimentEntries(options.experimentsDirectory) | ||
| return experiments.find(([name]) => name === id)?.[1] | ||
| } | ||
|
|
||
| if (existsSync(id)) { | ||
| return loadExperimentFile(id) | ||
| } | ||
|
|
||
| return findPackagedExperiment(id) | ||
| } |
| test('finds an experiment from a local file path', async () => { | ||
| const directory = await createExperimentsDirectory() | ||
|
|
||
| await expect(findExperiment(path.join(directory, 'example.mjs'))).resolves.toEqual( | ||
| expect.objectContaining({name: 'Example'}), | ||
| ) | ||
| }) |
| When authoring experiments outside of this repository, import the helper from | ||
| `@primer/agent-eval/config` to keep the experiment config typed: | ||
|
|
||
| ```ts | ||
| import {createExperiment} from '@primer/agent-eval/config' | ||
|
|
||
| export const experiment = createExperiment({ |
| "./config": { | ||
| "types": "./dist/config.d.ts", | ||
| "default": "./src/config.ts" | ||
| } |
Prepares
@primer/agent-evalfor npm publishing as a runnable CLI, with support for running experiments from a caller-provided local folder while retaining typed experiment authoring.CLI package metadata
agent-evalas the package binary.Local experiment loading
--experimentsto load experiment files from a local directory.experimentnamed exports and default exports.Typed config authoring
defineExperimentConfigfrom@primer/agent-eval/config.