# AGENTS.md

Guidance for coding agents (and humans) working in this repository. For setup,
PR workflow, and release process, see [CONTRIBUTING.md](./CONTRIBUTING.md).

## About eve

eve is a filesystem-first framework for durable backend AI agents. You author
an agent as a directory on disk — instructions, skills, tools, connections,
channels, subagents, and schedules are all files — and eve compiles and runs it.
See the [README](./README.md) for the full overview and
[`docs/`](./docs) for user-facing documentation.

Always style the framework name as `eve`, lowercase, in user-facing copy,
docs, prompts, comments, and headings.

## Repository layout

- `packages/eve` — the framework and `eve` CLI (the main package)
- `packages/eve-catalog` — internal, unpublished library
- `packages/eve-code` — `@eve/code`, internal source of the `eve/extensions/code` extension shipped in `eve`
- `apps/fixtures` — shared agent fixtures used by e2e, TUI smoke tests, and local dev
- `apps/frameworks`, `apps/templates`, `apps/docs` — framework integrations, templates, docs site
- `docs` — published documentation content
- `examples` — self-contained example agents built against the workspace `eve`
- `e2e/` — fixture-owned `eve eval` end-to-end tests
- `research` — issue-backed implementation plans for proposed changes

## Git workflow

Commits must be cryptographically signed with a GitHub-verified key and include
the DCO `Signed-off-by` trailer. Use `git commit -s` for every commit, and if a
commit is missing the trailer, amend it with `git commit --amend -s --no-edit`
before pushing.

PR descriptions are reviewer-oriented explanations of the problem or decision
behind the change, the solution, and meaningful behavior changes—not file lists
or commit logs. Keep the Summary short and lead with that justification. Follow
it with a Changes section: a flat list of the important changes, public API
first, each with a short reason only when it is not obvious. Link a prior issue
or discussion when one exists, and call out important scope boundaries or
preserved behavior. Never include a
Validation, Test plan, or Checklist section. Never create an issue solely to
accompany a PR.
Use the [`gh-pr-description`](./.agents/skills/gh-pr-description/SKILL.md)
skill when drafting or updating one.

When the user explicitly asks to shepherd, land, or merge a PR, or to get one
green, use the [`pr-shepherd`](./.agents/skills/pr-shepherd/SKILL.md) skill
to run a fresh-context review, address and resolve comments, get CI green,
and merge. Do not start it on your own after an implementation or when only
asked to open a PR.

## Commands

```sh
pnpm install            # install workspace dependencies
pnpm build              # build all packages
pnpm dev                # watch-mode build + weather fixture on an available local port

pnpm typecheck          # TypeScript across the workspace
pnpm lint               # oxlint (auto-fixes)
pnpm fmt                # oxfmt
pnpm guard:invariants   # mechanical code-invariant checks (runs in CI)
pnpm guard:docs-budget  # fixes and internal changes don't grow docs (pre-commit and CI)
pnpm docs:check         # docs frontmatter and nav validation

pnpm test               # unit + integration
pnpm test:unit          # unit tests (<3s)
pnpm test:integration   # integration tests (several minutes; leave the full run to CI)
pnpm test:scenario      # scenarios that run eve: eve dev, eve start, real files and shells (Turbo builds prerequisites)
pnpm test:build         # building and packaging apps with eve: framework, production, and packaging builds (Turbo builds prerequisites)
pnpm test:public-types  # type checks of the published declarations (Turbo builds prerequisites)
pnpm test:webchat       # web chat template in headless Chromium (needs playwright-core's chromium-headless-shell)
pnpm test:e2e           # fixture-owned eve eval suites (CI only)
pnpm test:tui           # TUI smoke scripts (not e2e)
```

We value fast local iteration whenever possible. Run `pnpm fmt`, `pnpm lint`,
and `pnpm typecheck` frequently to catch inexpensive failures early, and run
unit tests after material behavioral changes. Integration and scenario tests
are comparatively slow, so do not run them after every change; run the
narrowest relevant test when a change needs behavioral validation. Copy edits,
typo fixes, small code reorganizations, and similar non-behavioral changes can
proceed without local integration or scenario runs. CI is always the official
line of defense, and every required check must pass before merge.

Do not run a whole integration or scenario tier, or a whole multi-channel
suite such as the channel conformance suite, locally unless the task
expressly needs it (for example, the user asks, or you are chasing a failure
only the full run reproduces). Scope local runs to the files and test names
your change touches with a path and `-t` filter, and leave the full suites to
CI.

## Agent-ready product principles

1. **Docs is priority #1.** Agents read your docs before they ever touch your
   product. If the docs are incomplete or ambiguous, the agent is lost before it
   starts.

2. **Authentication is the biggest friction point.** Auth is where agent runs
   stall most often: hidden prerequisites, unset keys, and OAuth flows that
   quietly assume a human is at the keyboard.

3. **Error messages make or break recovery.** A vague or misleading error sends
   an agent spiraling; a precise, actionable one lets it self-correct. Your errors
   are documentation.

4. **CLIs often assume a human is present.** Interactive prompts, TTY checks, and
   "press y to continue" break agents that have no way to answer back.

5. **Discoverability determines whether agents find you at all.** `llms.txt`,
   typed SDKs, MCP servers, machine-readable specs. If an agent can't discover
   your surface, it reaches for a competitor it already knows.

6. **Better for agents, better for humans.** Almost everything that makes a tool
   agent-ready, from clear docs to precise errors to sane defaults, makes it
   better for human developers too.

## Coding principles

1. **Public APIs are sensitive.** They usually require a research doc proposing the
   change, alongside proper e2e tests covering golden paths and known failure modes.
   They also require proper and legible documentation.

2. **The core is lean and powerful**. The framework core should be simple yet highly
   expressible i.e., `eve` can be built with `eve`. This means that changes in
   `execution/` and `harness/` should be only done when strictly necessary. The
   core should expose hooks and internal APIs so that broad functionality is built
   on top of it.

3. **KISS**. Keep things simple. If there are 5 ways to do something, the simplest
   and more obvious one should be the preferred option. Code should be legible and
   obvious.

4. **Code is liability**. Each net-new introduced snippet should earn its right
   to exist. Common abstractions should be reused. Accidental complexity needs
   to be derived to its essence. Entropy must be contained.

5. **Wrap third-party dependencies.** Do not expose third-party APIs as eve
   public APIs. Wrap them in eve-owned surfaces so internals can change freely.
   Add runtime `dependencies` only as a last resort: prefer vendoring code or
   generated artifacts into the repository and listing the source package under
   `devDependencies`. The `eve` package should aim to keep `nitro`, `rolldown`,
   and `undici` as its only runtime dependencies. This keeps eve installs as
   small as possible and avoids exposure to hijacked nested dependencies that
   are not pinned directly in the main lockfile. eve hands its own `rolldown`
   to Nitro through `deps.paths` and never lets Nitro resolve or install a
   package on demand.

6. **Stable APIs follow semantic versioning.** Break a stable public API only
   in a major release. Prefer additive changes; when a stable API needs an
   incompatible replacement, ship the replacement beside it, mark the old API
   `@deprecated`, and remove it in the next major release. The
   [stability policy](./docs/reference/typescript-api.md#stability-policy)
   defines which surfaces carry this promise; experimental and internal APIs
   do not.

7. **Derive names from file paths.** Connection names, tool names, and similar
   identifiers come from the filesystem path (e.g.
   `agent/connections/linear.ts` → `"linear"`). Do not add redundant `name`
   fields to definitions.

8. **Name definitions for the protocol they target.** Use
   `defineMcpClientConnection`, not `defineConnection`.

9. **All runtime functionality lives in the `eve` package.** Never rely on
   emitted or generated code for runtime behavior.

10. **Comments document the public API, nothing else.** In `packages/`, the
    only comments are JSDoc on declarations users can see (what a published
    entry exports and the types it refers to), tool directives such as
    `@ts-expect-error`, and license notices (`/*! ... */`, `@license`,
    `SPDX-License-Identifier`) that credit adapted third-party code. Every
    published export has JSDoc. Do not add comments
    while fixing a bug or refactoring; well-named code is the documentation.
    Express an invariant as code that fails when it breaks: a named assert that
    throws with the reason in its message, a type, or a `pnpm guard:invariants`
    rule. Rules 67 and 68 enforce this with no baseline.

11. **Configure Nitro from data.** eve's Nitro host is built from one typed host
    spec, one ordered plugin list, and one route table. Follow the foundation
    invariants in
    [`packages/eve/src/internal/nitro/AGENTS.md`](./packages/eve/src/internal/nitro/AGENTS.md)
    when touching `internal/nitro/`.

Machine-checkable invariants are enforced by `pnpm guard:invariants`, which
runs in Vercel CI. If the guard fails, fix the violation rather than
editing the baseline — baselines may only shrink.

## Research plans

Research documents live in the top-level `research/` directory and require
`issue`, `status`, and `last_updated` frontmatter. Keep plans concise and focus
primarily on the proposed authoring API and externally observable semantics.
Include only the architecture needed to explain boundaries, data flow, and
invariants; avoid speculative implementation detail, repeated rationale, and
exhaustive task inventories. Use a compact diagram when it makes a lifecycle
or ownership relationship materially clearer.

## Testing

Use the [`test-audit`](./.agents/skills/test-audit/SKILL.md) skill when
writing, reviewing, or pruning tests.

Tests belong in one of four tiers. Pick the tightest tier that can express the
assertion:

- **Unit** (`src/**/*.test.ts`): pure logic, colocated. No filesystem writes,
  subprocesses, or real network calls.
- **Integration** (`src/**/*.integration.test.ts`): multiple modules in memory.
- **Scenario** (`src/**/*.scenario.test.ts`, `test/scenarios/`): real
  subprocess, HTTP port, or bundler. Scenario files run in one of three areas:
  - running eve (`vitest.scenario.config.ts`): `eve dev` and `eve start`
    behavior, and small files that need a real filesystem or shell;
  - building and packaging apps with eve (`vitest.build.config.ts`): the
    `apps/frameworks` smoke builds (`framework-fixtures`), framework host
    builds (`framework-builds`), `eve build` and its Nitro and Vercel output
    (`production-build`), and consumers of the packed tarball and its CLI
    (`packaging`);
  - type checks of the published declarations
    (`vitest.public-types.config.ts`).

  A new scenario file runs eve unless it is listed in
  `packages/eve/vitest.scenario-shared.ts`; add build and packaging files
  there.

- **E2E** (`e2e/fixtures/*/evals/`): fixture-owned `eve eval` suites that run
  only in CI. The model suite (`e2e-local`) runs real matrix models against
  the local world; the world suites (`e2e-vercel`, …) run deterministic mock
  models (`EVE_E2E_MODEL=mock`) and exclude `real-model`-tagged evals. See
  [`e2e/README.md`](./e2e/README.md).

Windows CI runs every integration file except those whose first line is
`// @linux-only: <reason>`. Mark a file only when none of its tests touches
anything Windows can change: filesystem paths and links, file watching,
processes and signals, module loading, bundling, the CLI, the dev host, or
Workflow's local World on disk. Agent and session behavior compiled from
memory, on either host, is the same on every OS. Unmarked files run on Windows.

**Running a single file or filtered test: always pass the tier config.** Only
the `vitest.<tier>.config.ts` files alias `#*` imports to `./src`; a bare
`vitest run <path>` resolves them to compiled `./dist` output, so you end up
testing stale builds. Use:

```sh
pnpm --filter eve exec vitest run --config vitest.unit.config.ts <path-or-pattern>
# or vitest.integration.config.ts / vitest.scenario.config.ts for those tiers,
# and vitest.build.config.ts (add --project <name>) / vitest.public-types.config.ts
# for the scenario files they run
```

Add `-t "<name>"` to filter by test name. If you touched anything under
`#compiled/*`, run `pnpm build:compiled` first — the tier configs
do not rebuild it.

Do not commit fixture trees under `packages/eve/test/fixtures/` — scenario app
content is defined inline as `ScenarioAppDescriptor` objects (CI enforces this).

## End-to-end tests

Automated tests cover module-level behavior, but they don't prove a fixture
agent boots, accepts a request, and streams a response over HTTP. E2E suites
cannot run locally and must run in CI. When a change needs e2e coverage, add or
update the relevant fixture eval, then proceed to commit and push. Optionally
watch CI for the results and iterate on any failures.

Pick the fixture that exercises the surface you changed; if none does, add a
new eval under the matching fixture's `evals/` directory. E2E evals must be
deterministic and self-contained. Keep e2e free of external service startup
and injected env requirements (beyond model-provider credentials).

Write model-facing eval prompts as benign, process-oriented narratives. Use
neutral named actors such as Alice and Bob, and describe the ordinary workflow
that produces the state under test. Avoid terse, adversarial, or probe-like
wording when a natural scenario can test the same behavior. Such wording can
trigger provider refusals and cause live-model flake. Do not weaken the
behavior or security boundary under test.

Do not set `VERCEL_TEAM_ID` at build: sandbox template keys must derive
identically at build and runtime, and Vercel has no team variable at runtime.

The shared Vercel project's Preview env must provide the model-provider
credentials the fixtures need. TUI smoke tests
live under `packages/eve/test/tui-client` and run with `pnpm test:tui`. See
[`e2e/README.md`](./e2e/README.md).

## Templates

Keep every template in `apps/templates` on the same versions:

- `packageManager` matches the root `package.json`.
- The `eve` dependency is the same published version everywhere, including
  nested packages such as `eve-discord-agent-template/daemon`.

When you add, import, or update a template, match these versions. When you bump
either one, bump it in every template in the same PR and regenerate each
template's `pnpm-lock.yaml`. See
[`apps/templates/README.md`](./apps/templates/README.md).

## Documentation

- `docs/**` is the published documentation. If your change alters
  public behavior, update the relevant doc in the same PR and run
  `pnpm docs:check`.
- A bug fix or internal change may rewrite docs but not grow them. When a
  branch changes code in `packages/` without a `minor` or `major` changeset,
  the lines it adds to `docs/` Markdown and to JSDoc may not exceed the lines
  it deletes. Do not document a fix; its changeset records it. A feature takes
  a `minor` changeset, and a docs correction that needs more words goes in its
  own docs-only PR. `pnpm guard:docs-budget` checks this, as do the pre-commit
  hook and CI.
- When moving a published route, update authored links to the new URL and add a
  permanent redirect from every old HTML and supported Markdown URL.
- Sidebar order lives in `docs/meta.json`.
- Use Title Case for page `title` frontmatter and `meta.json` section titles
  (Fumadocs renders `title` as both the sidebar entry and the `<h1>`), and
  sentence case for in-page headings — capitalize only the first word plus
  proper nouns and acronyms, e.g. `Next.js`, `CLI`, `agent.ts`.
- Keep markdown framework-agnostic — no MDX-only constructs unless the page is
  `.mdx`.

## Changesets

Every PR that touches the published `eve` package must include a
changeset (`pnpm changeset`). Choose the bump by semantic versioning: `patch`
for bug fixes and changes that add no public API, `minor` for new features and
other backward-compatible public API additions, and `major` only when the
change breaks a stable public API. Changes to experimental APIs never need
`major`. Start the changeset body with one sentence for someone
reading release notes; put migration details and contributor thanks in later
paragraphs. For PRs with changesets, use `feat:`, `perf:`, `fix:`,
`docs(feature):`, `docs(bugfix):`, or an internal type (`chore:`, `refactor:`,
`test:`, `ci:`, `build:`, or `internal:`) in the PR title. An optional scope is
allowed for all types except `docs`, where the scope selects the feature or bug
fix section. CI checks the PR title because GitHub uses it as the squash-merge
subject. Keep the prefix in the squash commit; its subject determines the
release section. A `major` changeset always appears under Breaking Changes,
and other internal changes are omitted from the release notes. Run `pnpm guard:invariants` to validate changeset summaries. See
[Changeset summaries](./CONTRIBUTING.md#changeset-summaries).

Docs-only, internal-tooling, and fixture changes do not need a changeset. When
in doubt, add one.

## Crediting contributors

External contributors propose changes through issues, prompts, and plans, and
maintainers implement them (see [CONTRIBUTING.md](./CONTRIBUTING.md)). When a
change builds on someone else's work, such as an issue, reproduction, prompt,
implementation plan, or a closed outside pull request, credit them by GitHub
handle:

- Thank them in the changeset body, for example: "Thanks @octocat for the
  original implementation in #1234." or "Thanks @octocat for reporting this in
  #1234." If the change needs no changeset, put the thanks in the PR
  description.
- When they wrote code or an implementation plan that the change follows, add
  a `Co-authored-by: Name <email>` trailer to the commit and keep it in the
  squash-merge message. Use their GitHub noreply address
  (`<id>+<login>@users.noreply.github.com`) when they have no public email.
- Link their issue or pull request from the PR description.

## Security

Baseline invariants for authorization, injection, disclosure, and untrusted
input. Use established patterns in the codebase when existing (libraries, etc.)
instead of reinventing the wheel.

- **Authorize every access on the server, keyed to the resource.** Check the
  caller's session against the specific resource id from the request — never
  trust a client-supplied id, role, or `isAdmin` flag (IDOR / privilege
  escalation).
- **Never render untrusted input as HTML.** Use framework escaping (JSX text) or
  an explicit sanitizer — no `dangerouslySetInnerHTML`, `innerHTML`, or HTML
  built from template literals on user or third-party data (XSS).
- **Errors and logs must not leak internals.** Client-facing errors stay
  generic; stack traces, SQL, internal hostnames, tokens, and other users' data
  go to server logs only — and logs never persist secrets, credentials, or PII
  in cleartext.
- **Bound work derived from untrusted input.** Request-driven loops, pagination,
  recursion, and body/file reads need explicit caps (page size, timeout, max
  depth, max bytes) so one caller can't force unbounded work.
- **Validate outbound destinations before fetching.** Server-side fetches,
  webhooks, and imports whose URL or host comes from user input must block
  access to internal resources (SSRF). Use established patterns / libraries from
  the project already.
