Skip to content
Open
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
41 changes: 41 additions & 0 deletions .changeset/eve-testing-kit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
'@github-tools/eve-extension': minor
---

Test an eve agent without GitHub.

`@github-tools/eve-extension/testing` runs an agent's evals against a local GitHub emulator, [`vercel-labs/emulate`](https://github.com/vercel-labs/emulate), and a Vercel Connect emulator. An eval creates an issue as one person, asks the agent as another, and reads the result back. No request reaches `api.github.com` or `api.vercel.com`, so an eval needs no GitHub token and makes no real write.

```ts
// evals/evals.config.ts
import { defineEvalConfig } from 'eve/evals'
import { emulateGithub } from '@github-tools/eve-extension/testing'

export default defineEvalConfig({
setup: () => emulateGithub({
repositories: { 'acme/web': { labels: ['bug'] } },
people: { alice: { role: 'write' }, bob: { role: 'read' } },
}),
teardown: context => context?.close(),
})
```

```ts
// evals/triage.eval.ts
const web = t.context.github.repo('acme/web')
const issue = await web.as('bob').createIssue({ title: 'Crash on save' })

const turn = await t.send(`Triage acme/web#${issue.number}`, as('alice'))

turn.calledTool('github__addLabels')
t.check((await web.issue(issue.number)).labels, includes('bug'))
```

What it adds:

- **All 97 tools run against the emulator.** The package adds what emulate 0.13.1 lacks: the REST routes and GraphQL queries the tools call, and the role checks GitHub makes for a personal token. A reader's label or merge is refused with `403`, and the labels a reader sends with a new issue are dropped, as on GitHub.
- **Named people.** Each person is a GitHub user with a role and the eve principal of the same name. `as('alice')` sends a message or answers an approval as her, and `evalIdentity()` from `@github-tools/eve-extension/testing/agent` names the caller in the eve channel's auth. It accepts nothing outside a local eve server.
- **Vercel Connect.** App tokens are narrowed to the scopes the mounted tools ask for, a person with `authorized: false` signs in first, and `t.context.connect.revoke(person)` invalidates their token.
- **The GitHub channel.** After `t.context.github.deliverWebhooksTo(t)`, a comment an eval creates reaches the agent as a signed webhook, and `waitForComment` reads the reply. `underEmulation()` adapts `connectGitHubCredentials` for the run.

Install `@emulators/core@0.13.1` and `@emulators/github@0.13.1` as development dependencies to use it. Nothing changes for an agent that doesn't. See [Test an agent](https://github-tools.com/guides/test-an-agent).
5 changes: 3 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ Every tool splits into a **core** function (pure logic) and a **tool factory** (
- `apps/docs/content/docs/3.core/3.approval.md` if the write tool joins `AUTO_APPROVAL_TOOLS`
- `apps/docs/content/docs/3.core/5.context.md` if the tool is a context tool or changes default payload behavior (`detail`, `includePatch`, ranges)
- `packages/github-tools/README.md` (tool tables, preset tables, write tools list, token permissions) — the root `README.md` is a symlink to this file, no separate edit needed
6. **Changeset** — `pnpm changeset` (`minor`)
7. Run checks:
6. **Emulator** — add a sample input for the tool to `SAMPLES` in `packages/github-tools-eve-extension/testing/coverage.test.ts`, which runs every tool against the GitHub emulator in that folder (the file doesn't type-check without it, once the SDK is built). When the tool calls a route or sends a GraphQL document emulate doesn't answer, add it to `testing/github/supplement/`. For a write tool, either the test's reader case gets `403`, which may need a rule in `testing/github/role-guard.ts`, or the tool joins `READER_MAY` with the reason GitHub allows it, and a `holds` check of the result when GitHub accepts the call and ignores part of it
7. **Changeset** — `pnpm changeset` (`minor`)
8. Run checks:

```sh
pnpm build && pnpm lint && pnpm typecheck && pnpm test
Expand Down
17 changes: 14 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
pnpm build # Build all packages (turbo)
pnpm lint # Lint all packages
pnpm typecheck # Type-check all packages
pnpm test # SDK vitest + eve extension evals (examples/eve-smoke, tests/eve-act-as, tests/eve-auto) + the eve-bench gh classifier test
pnpm test # SDK and eve extension vitest + eve extension evals (examples/eve-smoke, tests/eve-act-as, tests/eve-auto, tests/eve-emulate) + the eve-bench gh classifier test
pnpm dev # Run the chat app in dev mode
pnpm docs:dev # Run the docs site in dev mode

Expand All @@ -24,7 +24,7 @@ pnpm version-packages # Apply changesets
pnpm release # Build SDK + publish
```

Verify changes with `pnpm build && pnpm lint && pnpm typecheck && pnpm test`. The SDK has vitest (`packages/github-tools/**/*.test.ts`). The eve extension is covered by `examples/eve-smoke`: `eve eval` mounts the built extension with a `mockModel`, a fixed routing model, and an in-process `api.github.com` stub, and checks routing, registration, execution, and approval gating.
Verify changes with `pnpm build && pnpm lint && pnpm typecheck && pnpm test`. The SDK has vitest (`packages/github-tools/**/*.test.ts`), and so does the extension's testing entry (`packages/github-tools-eve-extension/testing/**/*.test.ts`). The eve extension is covered by `examples/eve-smoke`: `eve eval` mounts the built extension with a `mockModel`, a fixed routing model, and an in-process `api.github.com` stub, and checks routing, registration, execution, and approval gating.

## Monorepo Structure

Expand All @@ -34,7 +34,7 @@ pnpm workspaces + Turborepo, with published packages, apps, and examples:
- **`packages/github-tools-eve-extension`** — the published eve extension (`@github-tools/eve-extension`).
- **`examples/*`** — consumer integrations used for development, smoke tests (`examples/eve-smoke`), and canary checks.
- **`examples/eve`** — the Slack and GitHub agent people clone or deploy on its own (Deploy button, `giget`), so it must work outside the monorepo: no `workspace:*`, no root config. It depends on `@github-tools/eve-extension` from npm as `latest`, because Changesets rewrites a semver range to the unreleased version in the Version PR, which breaks `pnpm install --frozen-lockfile`. Only use released options in it; to try unreleased extension code, use `examples/eve-smoke` or `tests/*`. After a release, move its lockfile entry to the new version so CI builds against it: set the dependency to that version, run `pnpm install`, set it back to `latest` and run `pnpm install` again. `pnpm update --filter` also refreshes unrelated transitive dependencies.
- **`tests/*`** — eval-only agents that are not usable examples: `tests/eve-act-as` covers the eve extension's `actAs`, `approvers` and `githubChannel`'s `respondTo`, and `tests/eve-auto` covers `preset: 'auto'` and `requireApproval: 'auto'`, both with stubbed Vercel Connect and GitHub.
- **`tests/*`** — eval-only agents that are not usable examples: `tests/eve-act-as` covers the eve extension's `actAs`, `approvers` and `githubChannel`'s `respondTo`, and `tests/eve-auto` covers `preset: 'auto'` and `requireApproval: 'auto'`, both with stubbed Vercel Connect and GitHub. `tests/eve-emulate` runs the extension's testing entry end to end, against the GitHub and Vercel Connect emulators.
- **`apps/chat`** — Nuxt 4 demo app with NuxtHub (SQLite + blob), GitHub OAuth, dual-mode agent (standard `ToolLoopAgent` vs durable `WorkflowAgent`).
- **`apps/docs`** — Nuxt 4 docs site built on Docus. Also publishes a consumer-facing Agent Skill at `apps/docs/skills/github-tools-agents/` (served via `/.well-known/skills/`, see `apps/docs/content/docs/1.start/4.agent-skills.md`).

Expand Down Expand Up @@ -112,6 +112,17 @@ Ten presets (`code-review`, `issue-triage`, `repo-explorer`, `ci-ops`, `security

`channels/index.ts` (`@github-tools/eve-extension/channels`, the `githubChannel` wrapper with `respondTo`) is not part of the mounted extension: `tsc -p tsconfig.channels.json` compiles it to `channels/dist`. Keep it out of `extension/` and `dist/`. eve binds every module under `dist/extension` to a mount, so an agent with two mounts of the package can't import one from a channel file, and building an agent that uses the workspace extension rebuilds `dist/` and deletes anything else in it. A scheduled canary (`.github/workflows/eve-canary.yml`) builds `examples/eve` and runs that smoke eval against a coherent `eve@latest` / `ai@latest` pair.

`testing/` (`@github-tools/eve-extension/testing` for eval files, `/testing/agent` for agent files) is compiled the same way, by `tsc -p tsconfig.testing.json` to `testing/dist`. It runs evals against [`vercel-labs/emulate`](https://github.com/vercel-labs/emulate), pinned exactly, plus what emulate lacks:

- `testing/github/role-guard.ts`: the role a personal token needs on each write route, and the body fields GitHub ignores from a person below Triage instead of refusing the request. emulate checks a role for contents, refs and admin routes only.
- `testing/github/supplement/`: the REST routes and the GraphQL documents the SDK sends that emulate doesn't answer. They register before emulate's routes, because its router takes the first match.
- `testing/github/fixes.ts`: requests emulate has a route for and answers differently from GitHub.
- `testing/connect/`: the Vercel Connect routes `@vercel/connect` calls.

`testing/coverage.test.ts` is the contract: it runs every tool against the emulator, fails on a GraphQL document the emulator doesn't know, checks that a reader is refused every write GitHub refuses and that the fields GitHub ignores from a reader stay unset, and fails with "delete this route" when emulate answers a supplement route itself. It reaches the tools through `@github-tools/sdk/eve-runtime` (`listEveToolDescriptors`, `executeGithubEveTool`), so it runs against the SDK's build, and the SDK has no dependency on the extension. A bump of the emulate pin is its own pull request.

`testing/emulators.ts` imports `@emulators/*` through a specifier a bundler can't follow, and `emulateGithub` finds the redirect with `import.meta.resolve`. Keep both: eve bundles what an eval imports from a workspace-linked package, and a bundled `@emulators/core` can't find the files it reads at load.

## Chat App Architecture (`apps/chat`)

- **Frontend**: Vue 3 + `@nuxt/ui`. Chat pages at `app/pages/chat/[id].vue` with tool invocation rendering and approval UI.
Expand Down
3 changes: 2 additions & 1 deletion apps/docs/app/utils/docs-sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export const docsSidebar: DocsSidebarGroup[] = [
{ path: '/guides/release-notes' },
{ path: '/guides/chat-bot' },
{ path: '/guides/multi-agent' },
{ path: '/guides/self-improving-agent' }
{ path: '/guides/self-improving-agent' },
{ path: '/guides/test-an-agent' }
]
},
{
Expand Down
70 changes: 70 additions & 0 deletions apps/docs/content/docs/4.integrations/2.eve.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,76 @@ export default githubExtension({

Pair it with `guardrails`, and try the schedule with `dryRun: true` first.

## Test your agent

`@github-tools/eve-extension/testing` runs your evals against a local GitHub emulator, [`vercel-labs/emulate`](https://github.com/vercel-labs/emulate), with the routes, GraphQL queries and role checks the tools need added to it, and a Vercel Connect emulator beside it. An eval creates an issue as one person, asks the agent as another, and reads the result back, with no GitHub token and no real write.

Install the emulator as a development dependency:

:::code-group
```bash [pnpm]
pnpm add -D @emulators/core@0.13.1 @emulators/github@0.13.1
```
```bash [npm]
npm install -D @emulators/core@0.13.1 @emulators/github@0.13.1
```
```bash [yarn]
yarn add -D @emulators/core@0.13.1 @emulators/github@0.13.1
```
```bash [bun]
bun add -d @emulators/core@0.13.1 @emulators/github@0.13.1
```
:::

Start the emulators from the eval run's `setup`, with the repositories and the people your evals use:

```ts [evals/evals.config.ts]
import { defineEvalConfig } from 'eve/evals'
import { emulateGithub } from '@github-tools/eve-extension/testing'

export default defineEvalConfig({
setup: () => emulateGithub({
repositories: { 'acme/web': { labels: ['bug', 'docs'] } },
people: { alice: { role: 'write' }, bob: { role: 'read' } },
}),
teardown: context => context?.close(),
})
```

Name the caller of an eval in the eve channel's auth. `evalIdentity()` accepts a request on a local development server only, as eve's `localDev()` does, so it accepts nothing in production:

```ts [agent/channels/eve.ts]
import { eveChannel } from 'eve/channels/eve'
import { evalIdentity } from '@github-tools/eve-extension/testing/agent'

export default eveChannel({ auth: [evalIdentity(), /* your production auth */] })
```

An eval then arranges, sends and asserts:

```ts [evals/triage.eval.ts]
import { defineEval } from 'eve/evals'
import { includes } from 'eve/evals/expect'
import { as } from '@github-tools/eve-extension/testing'
import type config from './evals.config'

export default defineEval<typeof config>({
async test(t) {
const web = t.context.github.repo('acme/web')
const issue = await web.as('bob').createIssue({ title: 'Crash on save' })

const turn = await t.send(`Triage acme/web#${issue.number}`, as('alice'))

turn.calledTool('github__addLabels')
t.check((await web.issue(issue.number)).labels, includes('bug'))
},
})
```

Each person is a GitHub user with the role you gave them, and the emulator answers a call the way GitHub does: a label that bob adds with his own token fails with `github_tools.FORBIDDEN`, and the labels he sends with a new issue are dropped. With `actAs: 'user'` or `'caller'`, the Connect emulator issues each person's token, and a person with `authorized: false` is asked to sign in first.

On the GitHub channel, wrap Connect's credentials in `underEmulation` from the same entry, and call `t.context.github.deliverWebhooksTo(t)`: a comment an eval creates then reaches the agent as a signed webhook. [Test an agent](/guides/test-an-agent) walks through the channel, sign-ins, what the emulators don't cover, and which checks belong in an eval and which in a [shadow run](/approval#shadow-mode).

## Config

| Field | Type | What it does |
Expand Down
1 change: 1 addition & 0 deletions apps/docs/content/docs/5.guides/1.index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Each guide builds one working GitHub agent for one job, from install to the comm
| [Chat bot](/guides/chat-bot) | [Chat SDK](/integrations/chat-sdk), [Vercel Workflow](/integrations/workflow) | `issue-triage` | Beginner |
| [Multi-agent](/guides/multi-agent) | [eve](/integrations/eve), [AI SDK](/integrations/ai-sdk) | `code-review`, `issue-triage`, `release-manager` | Advanced |
| [Self-improving agent](/guides/self-improving-agent) | [eve](/integrations/eve) | `auto` | Advanced |
| [Test an agent](/guides/test-an-agent) | [eve](/integrations/eve) | Any | Intermediate |

New to agents? Start with [Your first agent](/learn/first-agent), which builds an issue-triage agent in a terminal and explains each part.

Expand Down
Loading
Loading