<!-- CONTRIBUTING.md at a961efe7d646cb70cbfae04e1cfde3a31fbe086c · https://github.com/OmarAlex24/everdoc/blob/a961efe7d646cb70cbfae04e1cfde3a31fbe086c/CONTRIBUTING.md · status: fresh -->

# Contributing to Everdoc

Thanks for helping. Everdoc compiles a codebase into an architecture atlas with static analysis, so the
bar for a change is simple to state: the output stays **deterministic**, **generic**, and **true to the
code**. This guide covers how to work in the repository and what a pull request needs to be merged.

Coding agents: read [AGENTS.md](AGENTS.md) as well. It holds the same rules in checklist form.

## Local setup

Requirements: Node.js 22 or newer (CI uses 24), pnpm (the version pinned in `package.json#packageManager`;
`corepack enable` picks it up), and git.

```sh
pnpm install
pnpm build        # tsc per package → dist/, plus the site's Cloudflare worker bundle
pnpm typecheck    # strict TypeScript over sources and tests
pnpm test         # Vitest; workspace packages resolve to src/, so no build is needed for unit tests
pnpm pack:check   # npm pack --dry-run of every publishable package (run after pnpm build)
```

CI runs exactly these five commands on every push to `main` and every pull request
([ci.yml](.github/workflows/ci.yml)). Run all of them before you open a pull request.

To see your change on a real site, build an atlas of any repository you have locally:

```sh
node packages/cli/bin/everdoc.js init --yes            # in the repository to document
node packages/cli/bin/everdoc.js build                 # extract, then render dist/
node packages/cli/bin/everdoc.js serve --dir dist      # http://localhost:4321
```

`everdoc build --skip-extract` re-renders the site from the last extraction, which is the fast loop for
site and Markdown changes.

## How the workspace is layered

Dependencies point one way. A package may depend only on the packages to its left:

```
ir  →  sdk, diff, llms  →  engine, extractors-*, mcp, summarize  →  site  →  cli
```

- **`@everdoc/ir`** is the leaf: the snapshot types, canonical JSON, hashing, stable IDs, and
  `validateSnapshot`. It has no runtime dependencies. Keep it that way; a type or helper that needs a
  dependency belongs in a higher package.
- **`@everdoc/sdk`** holds the config schema and the extractor plugin API. **`@everdoc/llms`** renders
  Markdown and `llms.txt` and depends only on the IR, so the CLI, the site, and the MCP server all share
  one rendering.
- **`@everdoc/extractors-*`** are packs of generic recognizers for frameworks and languages (commander,
  Effect, express, zod, clap, axum, serde, and so on). They never know which repository they are reading.
- **`@everdoc/site`** renders the static atlas; **`everdoc`** (the CLI) wires everything together.

### Zero repository-specific code

Nothing in `packages/*/src` may name, special-case, or tune for a specific repository, including the
public showcases (T3 Code, Klav) and Everdoc itself. If a repository needs different behavior, that is
a config option or a generic heuristic that holds for any repository with the same shape. A test walks
every `packages/*/src` tree and fails on the showcase names
([genericity test](packages/extractors-rust/test/rust.test.ts)); the e2e test also checks that the
fixture site carries none of them.

## Adding a language or an extractor pack

1. **Write the recognizer generically.** Match the framework's API (imports, call shapes, macros,
   manifests), not file paths or names from a particular project. Read the
   [extractor guide](README.md#writing-an-extractor) for the fact → link model.
2. **Add a generic fixture.** A small, invented project under `packages/*/test/fixtures/` (or inline in
   the test) that uses the framework the way real projects do. No code copied from a real repository,
   no real product names: use `acme`-style names.
3. **Prove determinism.** Two extractions of the fixture must produce byte-identical snapshots
   (`assertSnapshotDeterministic` from `@everdoc/sdk`, or compare canonical JSON yourself).
4. **Validate the output.** `validateSnapshot` must report zero errors on the fixture snapshot.
5. **Test the edges.** Unresolvable references, empty inputs, and partial code must produce fewer
   facts, never a crash or an invented entity. Prefer `undefined` and a diagnostic over a guess.
6. **Document it.** Add the framework to the package's README and to the packages table in the root
   README.

## Commits

Conventional commits, imperative mood, one logical change each:

```
feat(site): frame walkthrough screenshots on a backdrop
fix(engine): resolve re-exported RPC contracts through barrel files
docs: explain channel compare pairs
chore: bump Astro to 7.4
```

Common types: `feat`, `fix`, `perf`, `refactor`, `test`, `docs`, `ci`, `chore`. The scope is the
package name without `@everdoc/` when the change lives in one package.

## Pull requests

- **Keep the diff focused.** One concern per pull request. Refactors that a feature needs go in their
  own commit; unrelated cleanups go in their own pull request.
- **Replace, don't duplicate.** When you supersede a component, helper, or code path, move its callers
  and delete the old one in the same change.
- **Test what you changed.** New behavior comes with unit tests; bug fixes come with a test that fails
  without the fix.
- **Screenshots for UI changes.** Any change to `packages/site` includes before and after screenshots
  of the rendered page, in light and dark themes, plus a narrow (mobile) width when layout changed.
- **Mind the page weight.** The atlas of a large monorepo must stay fast. On the T3 Code benchmark,
  `/` and `/<channel>/architecture` stay under 100 KB of HTML and `/<channel>/flows` and
  `/<channel>/reference/env` under 80 KB. Datasets belong in `/<channel>/data/*.json`, loaded by the
  islands on demand; repeated styling belongs in the shared stylesheet (`packages/site/src/styles`), not
  in long utility strings on every row.
- **Fill in the template.** Say what changed, why, and how you verified it. Tick only the checks you
  actually ran.

## AI-assisted contributions

AI-assisted contributions are welcome. The standard is the same as for any other contribution, and the
person opening the pull request owns all of it:

- You have read every line of the diff and can explain why each change is there.
- You ran the verification yourself: the five commands above, plus a look at the rendered site in a
  real browser for UI changes. Passing type checks or a mocked test is not verification.
- The description is yours and accurate. Do not paste a generated summary of work that was not done.

Pull requests that show signs of unreviewed generation (code that does not run, invented APIs, tests
that assert nothing, descriptions that do not match the diff) are closed without a detailed review.

## Reporting bugs and requesting extractors

Use the [issue forms](https://github.com/OmarAlex24/everdoc/issues/new/choose): a bug report, a request
for a framework or language, or a public repository to showcase. Report security problems privately as
described in [SECURITY.md](SECURITY.md), never in a public issue.

## Code of conduct

Everyone taking part follows the [Code of Conduct](CODE_OF_CONDUCT.md).

## License

By contributing, you agree that your contributions are licensed under the [MIT License](LICENSE).
