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

<p align="center">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="docs/assets/everdoc-mark-dark.svg">
    <img src="docs/assets/everdoc-mark-light.svg" width="72" height="72" alt="Everdoc">
  </picture>
</p>

<h1 align="center">Everdoc</h1>

<p align="center"><strong>Architecture docs that cannot lie, because they are compiled from the code.</strong></p>

<p align="center">
  <a href="https://github.com/OmarAlex24/everdoc/actions/workflows/ci.yml"><img src="https://github.com/OmarAlex24/everdoc/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
  <a href="https://github.com/OmarAlex24/everdoc/actions/workflows/docs.yml"><img src="https://github.com/OmarAlex24/everdoc/actions/workflows/docs.yml/badge.svg" alt="Live atlas"></a>
  <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License: MIT"></a>
</p>

Everdoc statically analyzes a repository and regenerates its architecture atlas on every commit, tag, or nightly: system maps, step-through flows, a full API reference, suggested engineering rules, and structural diffs between channels. No LLM sits in the loop. Every box, arrow, flag, and type is traced back to a line of source with a permalink, and every page has a Markdown twin for agents.

**See it live.** Each atlas is rebuilt by CI whenever its repository changes:

| Atlas | Repository | Stack | Channels | Config |
| --- | --- | --- | --- | --- |
| [**Everdoc Atlas**](https://everdoc.dev/) | [OmarAlex24/everdoc](https://github.com/OmarAlex24/everdoc) (this repo, documenting itself) | TypeScript pnpm monorepo | `nightly` | [21 lines](everdoc.config.ts) |
| [**T3 Code Atlas**](https://t3code.everdoc.dev/) | [pingdotgg/t3code](https://github.com/pingdotgg/t3code) | TypeScript/Effect monorepo | `stable` vs `nightly` | [34 lines](https://github.com/OmarAlex24/t3code-atlas/blob/main/everdoc.config.ts) |
| [**Klav Atlas**](https://klav.everdoc.dev/) | [OmarAlex24/klav](https://github.com/OmarAlex24/klav) | Rust + TypeScript + Swift polyglot monorepo | `stable` vs `main` | [38 lines](https://github.com/OmarAlex24/klav-atlas/blob/main/everdoc.config.ts) |

All three run on Cloudflare Pages, so each one is also a live MCP server over Streamable HTTP (`/mcp`, or `/<channel>/mcp` to pin a channel) and answers `Accept: text/markdown` with the page's Markdown:

```sh
claude mcp add --transport http t3code https://t3code.everdoc.dev/mcp      # T3 Code's architecture as MCP tools
curl -H "Accept: text/markdown" https://t3code.everdoc.dev/stable/reference/rpc   # the RPC reference as Markdown
```

```
source code ──► extractors ──► facts ──► canonical IR snapshot ──► renderers
 (any commit)   (zero-LLM,      (atomic,    (versioned, hashed,      ├─ architecture maps
                 plugin API)     dedup'd)    validated JSON)          ├─ step-through flows
                                                                       ├─ reference (CLI, env, RPC, IPC, MCP, routes…)
                                                                       ├─ stable ⇄ nightly structural diffs
                                                                       ├─ llms.txt + Markdown mirror
                                                                       └─ MCP server
```

## Why

Hand-written architecture docs rot the week they are written. LLM-written docs are plausible, expensive, and occasionally invented. Everdoc takes a third path:

- **Zero-LLM by default.** Static analysis only. Same commit in, byte-identical snapshot out.
- **One canonical IR.** Workspaces, graph, flows, reference entities, docs, and history live in a single, schema-versioned, content-hashed JSON snapshot. Every output is a pure function of it.
- **Diffs are structural, not textual.** Compare `stable` against `nightly` and get "the `t3 update` command gained a required `--github-token` flag", grouped by subsystem and linked to the PR, instead of a wall of changed lines.
- **Docs drift detection.** Hand-written Markdown is indexed and checked against the code: broken links, removed entities, stale signatures.
- **Generic.** Nothing is hard-coded for a framework or a repository. Extractors are small plugins; most are declarative call-site `sinks` with no AST code at all.
- **Polyglot.** TypeScript/JavaScript, Rust/Cargo, and Swift workspaces in one repository, wired across languages (HTTP, WASM, FFI).
- **Built for agents.** `llms.txt`, a Markdown twin of every page, HTTP content negotiation, and an MCP server, so agents get the same ground truth humans do ([below](#markdown-for-agents)).
- **Surgical LLM, optional.** `llm: { mode: "surgical" }` adds a few content-hash-cached prose summaries on top ([below](#ai-summaries-optional)). Structure is never model-derived, and unchanged code costs zero tokens.

## 60-second quickstart

Requires Node.js 22+ and git. In the repository you want to document:

```sh
npx everdoc init      # inspects the repo, writes everdoc.config.ts + .github/workflows/everdoc.yml
npx everdoc build     # extracts every channel, diffs them, renders the site into dist/
npx everdoc serve     # http://127.0.0.1:4321 (MCP at /mcp)
```

`everdoc init` reads the `origin` remote, JS/TS workspaces (pnpm, npm, yarn, bun), Cargo workspaces, Swift apps, `README.md` and `docs/`, and your release tags, then writes a commented ~20-line config: a `stable` channel on the newest semver tag (when there is one), `nightly` on the default branch, a `stable...nightly` compare, and your GitHub Pages URL. It never overwrites an existing file unless you pass `--force`.

```sh
everdoc init [--repo <owner/repo|.>] [--dir .] [--yes] [--site-title "Acme Atlas"] [--site-url https://acme.dev/atlas]
             [--with-ci | --no-ci] [--with-pr-check] [--force]
```

Commit, push, and set **Settings → Pages → Source: GitHub Actions**; the generated workflow rebuilds and redeploys the atlas on every push and release tag.

<details>
<summary>From source (before the first npm release, or to hack on Everdoc)</summary>

```sh
git clone https://github.com/OmarAlex24/everdoc && cd everdoc
pnpm install && pnpm build
alias everdoc="node $PWD/packages/cli/bin/everdoc.js"
cd ../your-repo && everdoc init && everdoc build && everdoc serve
```

</details>

`everdoc build` reads the repository named in the config through a blobless mirror in `.everdoc/` (every branch and tag, commits and trees only; the analyzed files' blobs arrive in one batched fetch). With `repo: "."` (what `init` writes) it reads the local clone instead, which is never modified.

## GitHub Action

The repository root is a composite action. It builds Everdoc from the ref you pin, restores the per-file fact cache, runs `everdoc build`, and outputs the site directory:

```yaml
jobs:
  atlas:
    runs-on: ubuntu-latest
    permissions: { contents: read, pages: write, id-token: write }
    environment: { name: github-pages, url: "${{ steps.deploy.outputs.page_url }}" }
    steps:
      - uses: actions/checkout@v4
        with: { fetch-depth: 0 }          # tags and history: channels, releases, diff evidence
      - uses: OmarAlex24/everdoc@main
        id: everdoc
      - uses: actions/upload-pages-artifact@v3
        with: { path: "${{ steps.everdoc.outputs.out-dir }}" }
      - uses: actions/deploy-pages@v4
        id: deploy
```

| Input | Default | |
| --- | --- | --- |
| `command` | `build` | `build` (static atlas) or `pr-check` (structural PR report, see [`everdoc init --with-pr-check`](packages/cli/templates/everdoc-pr-check.yml)) |
| `config` | `everdoc.config.ts` | config file |
| `out` | `site.outDir` (`dist`) | `build`: output directory; `pr-check`: report file |
| `base` | path of `site.baseUrl` | `build`: base path; `pr-check`: base ref (`origin/<PR base>`) |
| `site-url`, `args` | | public URL; extra CLI arguments (`--fail-on-breaking`) |
| `cache`, `node-version` | `true`, `24` | fact cache (`.everdoc/cache`) and Node.js version |

Outputs: `out-dir` (built site or report path) and `exit-code` (`pr-check`: `2` when a `--fail-on-*` gate tripped). This repository's own [docs workflow](.github/workflows/docs.yml) uses it (`uses: ./`) to publish the [Everdoc Atlas](https://everdoc.dev/).

## Configure

```ts
// everdoc.config.ts
import { defineConfig } from "@everdoc/sdk";

export default defineConfig({
  repo: { url: "https://github.com/acme/app" },   // or "." for the repository holding this file
  site: {
    title: "Acme Atlas",
    baseUrl: "https://acme.github.io/atlas",      // canonical links, llms.txt, social cards; its path is the base path
    logo: "./docs/logo.svg",                      // optional: header logo and favicon (default: the Everdoc mark)
    ogImage: "./docs/social.png",                 // optional: replaces the generated 1200×630 social card
    analytics: { plausible: { domain: "atlas.acme.dev" } }, // optional: cloudflare, plausible, umami, posthog
    poweredBy: true,                              // optional: "Built with Everdoc" links in the sidebar and footer (default true)
  },
  channels: {
    stable: { tag: /^v\d+\.\d+\.\d+$/ },
    nightly: { branch: "main" },
  },
  compare: [{ base: "stable", head: "nightly" }],
  groups: {
    clients: ["apps/web", "apps/desktop"],
    backend: ["apps/server", "packages/*"],
  },
  subsystems: { from: "commit-scope" },
  flows: { maxKeyFlows: 10 },
  llm: { mode: "off" },
});
```

**Page analytics (optional).** `site.analytics` adds one deferred, non-blocking script tag per configured
provider to every page's `<head>`, and nothing when it is unset:

```ts
analytics: {
  cloudflare: { token: "…" },                                        // Cloudflare Web Analytics beacon
  plausible: { domain: "atlas.acme.dev", src: "https://plausible.io/js/script.js" }, // src optional
  umami: { websiteId: "…", src: "https://cloud.umami.is/script.js" },
  posthog: { key: "phc_…", host: "https://eu.i.posthog.com" },       // host optional (default US cloud)
}
```

Agent and MCP traffic is measured at the edge instead (see [Deploy](#deploy)).

**Attribution.** The sidebar foot and the page footer link to [everdoc.dev](https://everdoc.dev) and this repository ("Built with Everdoc ↗"). Set `site.poweredBy: false` to keep only the provenance line and the commit metadata.

**Brand and social cards.** Every page carries full Open Graph and Twitter Card tags, plus a schema.org `WebSite` JSON-LD block. Unless `site.ogImage` is set, `everdoc build` renders a 1200×630 card into `dist/og.png` from the data: site title, repository, channel versions, workspace, entity, and flow counts, and your `site.logo`. It uses `sharp` (an optional dependency) and falls back to `dist/og.svg` where `sharp` cannot load.

## Markdown for agents

Every HTML page has a Markdown twin, and agents can ask for it by URL or by HTTP header:

- **`<head>` links on every page:** `<link rel="alternate" type="text/markdown" href="…/stable/architecture.md">` for the exact page (the site root points at the default channel's home), `<link rel="alternate" type="text/plain" href="…/llms.txt">`, and a clean `<link rel="canonical">` (`https://acme.dev/atlas/`, never `index.html`).
- **YAML frontmatter** on every generated `.md` page (`title`, `description`, `canonical` (the HTML page, when `site.baseUrl` is set), `channel`), so agents and indexers get the page's metadata without parsing it.
- **On every page:** "Copy page" puts the page's Markdown on the clipboard in one click (its menu views the `.md`, or opens `llms.txt` and `skill.md`), and "Connect agent" opens the MCP client configs.
- **Content negotiation** in both `everdoc serve` and the Cloudflare `_worker.js`: a page requested with `Accept: text/markdown` (preferred over `text/html`, or `text/plain` without `text/html`) is answered with its `.md` sibling as `text/markdown; charset=utf-8`, with `Vary: Accept`. The root answers with `<default channel>/index.md`. Browsers keep getting HTML.
- **`Link` header** on pages: `Link: </atlas/llms.txt>; rel="alternate"; type="text/markdown"` (also written to `_headers` for static hosts that support it).

```sh
curl -H "Accept: text/markdown" https://klav.everdoc.dev/stable/architecture   # the architecture page as Markdown
curl -I -H "Accept: text/markdown" https://everdoc.dev/              # content-type: text/markdown, vary: Accept, link: </llms.txt>
```

`llms.txt` indexes every Markdown page, `<channel>/llms-full.txt` holds a whole channel in one file, and `/{channel}/skill.md` exports the suggested rules as an Agent Skill. The [MCP server](#mcp) answers the same questions as tools.

## Benchmark: T3 Code

`everdoc build` on [pingdotgg/t3code](https://github.com/pingdotgg/t3code), with the [t3code-atlas config](https://github.com/OmarAlex24/t3code-atlas/blob/main/everdoc.config.ts): `stable` = `v0.1.13`, `nightly` = `v0.1.14-nightly.20261204.5734`. Measured on an 8-vCPU AMD EPYC VM (16 GB RAM, Node 24, git 2.43), 2026-12-04.

| | Cold (empty `.everdoc/`) | Warm (same commits) |
| --- | --- | --- |
| Clone + extract both channels + diff | 62.1 s | 22.5 s |
| Modules parsed | 7,484 (stable reuses 3,018 of nightly's) | 0 (every module from the fact cache) |
| Render the site (Astro) | 12.5 s | 11.7 s |
| **Total wall clock** | **76 s** | **36 s** |
| Peak memory | 1.5 GB | 1.4 GB |

| What it found | stable | nightly |
| --- | --- | --- |
| Tracked files / analyzed modules | 33,623 / 5,206 | 34,186 / 5,303 |
| Workspaces | 42 | 43 |
| Reference entities (RPC, HTTP, IPC, MCP, CLI, env, routes, schemas…) | 5,369 | 5,457 |
| Flows | 745 | 760 |

- **Diff** `stable...nightly`: 2,472 commits in range, 598 field-level entity changes (26 breaking, 403 notable, 169 patch), 131 commits cited as evidence.
- **Output:** 1,825 files (89 MB): 897 HTML pages, 886 `.md` siblings, `llms.txt` (18 KB), `llms-full.txt` (150 KB / 166 KB), two 6.4 MB snapshots.
- **Deterministic:** snapshots from the cached run and a `--no-cache` run are byte-identical.

Per-file analysis is cached by git blob SHA (`.everdoc/cache/facts/<packHash>/<blobSha>.json`), so a new nightly only re-parses the files that changed, and channels share their cache.

## CLI

```sh
everdoc init --yes --with-pr-check                                    # config + GitHub Pages and PR check workflows
everdoc resolve --config everdoc.config.ts --print-key          # channels → commits → cache key (refs.lock.json)
everdoc extract --config everdoc.config.ts --out .everdoc/out         # one snapshot.json per channel (+ compare diffs)
everdoc extract --local-repo ../app --channel stable                 # read a local clone (never modified)
everdoc doctor .everdoc/out/stable/snapshot.json                          # validation + coverage report
everdoc diff .everdoc/out/stable/snapshot.json .everdoc/out/nightly/snapshot.json --repo ../app --markdown diff.md
everdoc llms --dir .everdoc/out --site-url https://example.com/atlas       # llms.txt, <channel>/llms-full.txt, <channel>/**/*.md
everdoc mcp --dir .everdoc/out                                            # MCP over stdio (or --remote https://example.com/atlas)
everdoc build --config everdoc.config.ts --out dist              # extract + diff + llms + (optional) summaries + static site
everdoc summarize --dry-run                                          # summary slots, cache hits, estimated tokens (no calls)
everdoc build --config everdoc.config.ts --base /atlas/ --out dist   # site served from a sub-path (GitHub Pages)
everdoc build --skip-extract --data-dir .everdoc/out --out dist           # render existing snapshots only
everdoc serve --dir dist --base /atlas/ --port 4321                  # site + MCP at http://127.0.0.1:4321/atlas/mcp
everdoc serve --dir dist --require-auth                              # token in $EVERDOC_TOKEN: Bearer or browser sign-in
everdoc mcp --remote https://atlas.acme.dev --token-env EVERDOC_TOKEN   # MCP over stdio from a protected site
everdoc pr-check --base origin/main --head HEAD --fail-on-breaking   # structural PR report (sticky comment), exit 2 on policy
everdoc capture --config everdoc.config.ts                       # screenshot visual flows (scripted, or discovered from routes) with Playwright
```

For every `compare` pair whose channels were extracted, `everdoc extract` writes `compare/<base>...<head>/diff.json`
(`--skip-diff` to opt out). Diffs cite commits from the full `base..head` git range: a commit is linked to an
entity change when its patch mentions the entity (or a changed field) in the entity's file.

Severity rules: inputs (RPC/HTTP/IPC/MCP inputs, CLI flags, env vars) are contravariant, so a new required field,
a narrowed type, or a removed flag is **breaking** and a new optional field is **notable**; outputs are covariant,
so a lost field or widened type is **breaking** and a new union member is **notable**. Removing a public entity is
breaking, adding one is notable, and changes in tests, tooling, or schemas alone are capped.

## Static site

`everdoc build` renders every channel and compare pair into a static site (Astro + React islands). Everything on it
comes from `everdoc.json`, `<channel>/snapshot.json`, and `compare/<a>...<b>/diff.json`.

| Route | What it shows |
| --- | --- |
| `/{channel}` | Counts with deltas, a framed screenshot from the first walkthrough, a "Start here" reading order and (when the repository declares a CLI binary) a CLI quickstart as numbered steppers, the system diagram, top changes since the base channel, key flows |
| `/{channel}/architecture`, `/architecture/<workspace>` | System, workspace, and package diagrams; edge inspector; workspace roles, dependencies, owned entities, blast radius, README |
| `/{channel}/insights` | Bug hotspots (files, workspaces, entities; fixes, reverts, fix-of-fix follow-ups, PRs), hidden co-change coupling, orphan contracts, layer violations |
| `/{channel}/rules` | Suggested engineering rules by category with evidence, and one-click `AGENTS.md`, `SKILL.md`, and `.cursor/rules` exports |
| `/{channel}/walkthroughs/<flow>` | Screenshot storyboards: each screen framed on a muted backdrop with a Zoom pill and a caption (light/dark, `←`/`→`, filmstrip, steps in the right rail, stable vs nightly side by side) |
| `/{channel}/flows`, `/flows/<flow>` | Ranked, filterable flows with a complete/partial legend; step-through sequence diagrams (`←`/`→`) with source permalinks |
| `/{channel}/reference/...` | CLI; env grouped by name prefix or owner (runtime vs build-time, required); RPC and HTTP by namespace (with blast radius); IPC; MCP; UI routes; processes by workspace; schemas by workspace |
| `/{channel}/guides/<doc>` | Repository Markdown rendered with Shiki (code blocks with a language header and a copy button), with a fresh/stale/broken drift banner |
| `/{channel}/changes`, `/{channel}/about/coverage` | Releases and commits by subsystem; extractor coverage, pairing, and diagnostics |
| `/compare/<base>...<head>` | Structural diff explorer (severity, kind, subsystem, text), graph and doc drift, release notes |

**Page weight.** Pages ship a server-rendered outline and the interactive islands fetch their datasets on demand
from `/{channel}/data/*.json`: the architecture maps load `graph-system.json`, `graph-workspaces.json`, or
`graph-packages.json` when they hydrate (the home map when it scrolls into view) and `edge-entities.json` only when
an edge is opened; the env explorer renders every variable as an anchored outline and loads `env.json` at idle; the
flows page renders the 40 top-ranked flows and loads `flows.json` on the first search, filter, or "Show all"; the
<kbd>⌘K</kbd> palette fetches its packed `search-index.json` on first open. On T3 Code (55 workspaces, 5,500
entities, 767 flows) that took the env reference from 2.9 MB of HTML to about 72 KB, the architecture page from
863 KB to about 96 KB, flows from 754 KB to about 79 KB, the home page from 518 KB to about 80 KB, and the search
index from 919 KB to 319 KB. Long reference lists use `content-visibility: auto`, and walkthrough images other
than the active step load lazily.

<kbd>⌘K</kbd> searches the channel; <kbd>c</kbd> switches channel and keeps the page. Every page has a sibling
`.md` (`/stable/architecture.md`), and the build copies `llms.txt`, `llms-full.txt`, snapshots, diffs, the
favicon, your logo, and the social card next to the pages.

**Insights and rules** are computed at extraction, with no model: hotspots and co-change pairs from the last
2,000 non-merge commits (fix and revert subjects, fixes within 48 hours of an earlier fix, pairs changed together in
at least 3 commits with ≥ 50% confidence, flagged hidden when no import connects them), orphan contracts and layer
violations from the IR, and a 3–5 step reading order from the dependency layers. Rules turn those facts into
durable constraints ("98.2% of RPCs (270/275) are paired with handlers — do not leave new RPCs unhandled"), each
with its confidence and citations; `/{channel}/rules.md`, `/{channel}/skill.md`, and `/{channel}/insights.md` are
the Markdown versions. `computeBlastRadius(snapshot, id)` (from `@everdoc/ir`) answers what a change to a
workspace or entity reaches.

**Visual walkthroughs** come from `visualFlows` in the config: either `capture` blocks that `everdoc capture` replays
in a browser (it starts `startCommand`, waits for `readyUrl`, runs click/fill/press/wait actions, and saves 2x PNGs
per theme), or `steps` pointing at screenshots already in the repository. Captures go to `.everdoc/captures` unless a
flow sets `capture.dir` (relative to the config): then `everdoc capture` writes `<dir>/<step>.<theme>.png` there, so
you can commit them (recompressed as `.webp` or `.jpg` if you like) and CI builds publish them without a browser.
A `route` pattern such as `/users/:id` labels a step without opening it; reach that screen with actions.

**Route discovery** needs no step list at all: a flow with `discover: { from: "routes" }` takes the UI routes
Everdoc extracted from the code (TanStack Router, Remix, Next.js, Expo Router), so screens a release adds are
captured on the next run:

```ts
visualFlows: [{
  id: "screens",
  title: "App screens",                          // the walkthrough of routes that share no prefix
  discover: {
    from: "routes",
    workspaces: ["apps/web"],                     // optional: only this app's routes
    exclude: ["/pair", "/guest"],                 // exact paths, path prefixes, or globs (`/admin/**`)
    routeParams: { projectKey: "demo" },          // fills `/projects/$projectKey`; other parameterized routes are skipped
    skipIfUrlMatches: ["^/login"],                // landing here means "not available": skip
    setup: { url: "http://127.0.0.1:3000/dev-login" }, // optional, once per theme (sign in)
    startCommand: "pnpm dev", readyUrl: "http://127.0.0.1:3000/",
    themes: ["dark", "light"], dir: "visuals/routes",
  },
}],
```

`everdoc capture` extracts the channel (incrementally), normalizes every route (`stripPrefixes`, one screen per
URL, the page over its layout), groups them by first segment (`groupBy: "prefix"`: `/settings/*` becomes a
"Settings" walkthrough with every settings screen; `"single"` keeps one walkthrough), visits each in every theme,
and skips, with the reason in the log and the manifest, HTTP errors, redirects, 404 and error screens, and blank
screens (`minTextLength`, default 40 characters). It writes `<dir>/<walkthrough>/<step>.<theme>.png` and a
deterministic `<dir>/discovered.json` (walkthroughs, steps, captions, the linked `route` entity of every step, and
the skipped routes), which `everdoc extract` and `everdoc build` read like any other walkthrough.
[T3 Code Atlas](https://t3code.everdoc.dev/stable/walkthroughs) uses it for every T3 Code screen besides its two scripted stories.
`everdoc extract` copies the images, content-hashed, into `.everdoc/visuals/<channel>/` and `everdoc build` publishes them under
`assets/visuals/`. Playwright is an optional peer dependency (`npm i -D playwright`); without a downloaded
browser, `everdoc capture` uses the system Chrome.

**Architecture diagrams** are drawn by a deterministic, dependency-free layout engine
(`packages/site/src/lib/diagram.ts`), not from raw coordinates:

- *Protocol views* become left-to-right swimlanes: entrypoints (external callers), clients and apps, core
  runtimes (servers and nodes most of the system calls into), and shared code and external services. Bands come
  from each node's kind, role, and distinct callers, never from names.
- *Dependency views* use longest-path layers. Columns are ordered by barycenter sweeps (fewest crossings wins),
  centered, spread to the canvas aspect, and long edges pass through gaps reserved in the columns they cross.
- Edges are bundled per node pair and protocol (both directions merge into one `⇄` edge); ports are spread along
  each card side, and protocol pills (`RPC · 278`) sit on their own curve, clear of cards and of each other.
- Hovering a node or edge spotlights its neighborhood and dims the rest; clicking an edge opens what it carries.

`--base /repo-name/` builds for a GitHub Pages project site: every link, asset, data fetch, and `llms.txt` URL
stays under the base (the e2e suite link-checks a `--base` build). Without `--base`, the path of `site.baseUrl`
is the base. `--site-url` (default `site.baseUrl`) sets canonical links, `og:image`, and the absolute links in
`llms.txt`.

## AI summaries (optional)

`@everdoc/summarize` writes four kinds of plain-English summaries, never raw code dumps:

| Slot | What | Shown on |
| --- | --- | --- |
| `overview` | 2–3 sentences: what the repository is and how its pieces fit together | Home |
| `workspaces` | 1–2 sentences per workspace and collapsed package family | Workspace pages, architecture tables and family cards |
| `flows` | 1–2 sentences per key flow (top 12) | Above each key flow's sequence diagram |
| `compare` | TL;DR of each channel diff | Top of `/compare/<base>...<head>` |

Each summary is keyed by `hash(normalized IR slice + prompt version + provider:model)` in
`.everdoc/cache/summaries.json`, so a slice that did not change costs zero tokens, and the result is written to
`<data-dir>/summaries.json`: an overlay next to the snapshots, which are never modified. The site drops any entry
whose snapshot or diff hash no longer matches, and labels the rest `AI summary · cached`.

```ts
llm: {
  mode: "surgical",            // "off" (default): no model calls at all
  provider: "anthropic",       // optional: else the first of ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY that is set
  model: "claude-haiku-5-5",   // optional: defaults to a small model per provider
  baseUrl: "http://localhost:11434/v1", // optional: OpenAI-compatible endpoint (provider "openai")
  apiKeyEnv: "MY_KEY",         // optional: read the key from another variable
  budget: { maxTokensPerRun: 150_000 }, // hard cap per run (default 150 000)
},
```

`everdoc build` summarizes only with `mode: "surgical"` and a key; otherwise it prints why it skipped and the build
stays fully deterministic. `everdoc summarize` runs the step on its own (`--dry-run` estimates tokens without calls).
Providers are called with native `fetch` (no SDKs). On T3 Code, a cold run is 84 unique summaries (estimated at
about 30k tokens with `--dry-run`), and a nightly that touched a few workspaces re-summarizes only those.

## Deploy

**GitHub Pages, no secrets.** In the repository itself, `everdoc init` writes a workflow that runs the
[GitHub Action](#github-action) and deploys with `actions/deploy-pages` (static files only: no live MCP endpoint and
no content negotiation; agents use the `.md` twins and `everdoc mcp --remote`).

**Cloudflare Pages, with live MCP and content negotiation.** The build also writes a self-contained `_worker.js`
(no Node built-ins, no compatibility flags) and a `_routes.json` that sends pages, `.md` files, `llms.txt`, and
`/mcp` through it while scripts, styles, images, and data files are served straight from the static asset server.
`npx wrangler pages deploy dist` and the site answers MCP over Streamable HTTP and `Accept: text/markdown` with
Markdown. Set the `EVERDOC_TOKEN` secret to require a Bearer token on `/mcp` ([private deployments](docs/private-repos.md#cloudflare-pages-with-access-sso)).

**Agent and MCP telemetry (optional).** The worker can record how agents use the site, after each response is
ready (`ctx.waitUntil`, so it never delays or fails a request), with no IP address, user agent, query string,
token, or tool argument. Each page, Markdown, `llms.txt`, and MCP request becomes one event: `surface` (`html`,
`markdown-negotiated`, `md-file`, `llms-txt`, `mcp`), `channel` (or `root`), `mcpMethod` and `mcpTool` (for
example `tools/call:search` and `search`), `clientFamily` (`claude`, `cursor`, `openai`, `curl`, `browser`, `bot`,
`other`, classified from the User-Agent, which is not kept), `status`, and `durationMs`. Configure any of:

| Pages setting | Sink |
| --- | --- |
| Analytics Engine binding `EVERDOC_ANALYTICS` | `writeDataPoint`: blobs `[surface, channel, clientFamily, mcpMethod, mcpTool]`, doubles `[status, durationMs]`, index `surface` |
| `EVERDOC_TELEMETRY_URL` | JSON `POST` of the event to any collector |
| `POSTHOG_KEY` (and `POSTHOG_HOST`) | PostHog `everdoc_request` events, without person profiles |

With none set the worker does no extra work.
This repository's [docs workflow](.github/workflows/docs.yml) deploys with `cloudflare/wrangler-action@v3`
(`pages deploy <out-dir> --project-name=everdoc --branch=main`, using the `CLOUDFLARE_API_TOKEN` and
`CLOUDFLARE_ACCOUNT_ID` secrets). For a separate atlas repository that tracks someone else's code,
[`t3code-atlas/.github/workflows/docs.yml`](https://github.com/OmarAlex24/t3code-atlas/blob/main/.github/workflows/docs.yml)
is a complete template: a seconds-long `check` job resolves the newest tags with `git ls-remote`, hashes them with
Everdoc's `HEAD` and the config, and stops if that key was already deployed; otherwise `build` runs `everdoc build`,
validates with `everdoc doctor`, and deploys to Cloudflare Pages. It passes `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, and
`GEMINI_API_KEY` from repository secrets when they exist, so adding one secret and `llm: { mode: "surgical" }` turns
on cached summaries.

## Private repositories

Private code gets the same atlas without publishing anything you do not choose to. The full guide is
[`docs/private-repos.md`](docs/private-repos.md):

- **Git auth:** `repo: { url, tokenEnv: "ACME_GIT_TOKEN" }` sends the token as an `Authorization` header for that
  host only (never in URLs, `.git/config`, snapshots, or logs); SSH remotes use your agent; `repo: "."` documents
  the repository the config lives in, read-only.
- **Privacy:** `privacy: { stripSourceLinks, redactEnvDefaults: "secrets", noindex }` removes links to the git host,
  redacts secret env defaults before anything is written, and keeps search engines out.
- **Access:** `everdoc serve --require-auth` (Bearer token or browser sign-in, open `/healthz`), a
  [Docker image](docker/Dockerfile), and a Cloudflare `_worker.js` that enforces `EVERDOC_TOKEN` on `/mcp`
  (or everywhere), alongside Cloudflare Access SSO ([workflow template](templates/private-docs-cloudflare.yml)).
- **PR diff gate:** `everdoc pr-check` posts one sticky comment per PR with breaking changes (field-level), notable API
  changes, new layer violations, and docs drift, and exits `2` when a `--fail-on-*` policy trips
  (`everdoc init --with-pr-check` writes the [workflow](packages/cli/templates/everdoc-pr-check.yml)).

## MCP

Tools: `search`, `get_entity`, `list_entities`, `find_usages`, `get_flow`, `diff_channels`, `get_architecture`,
`get_doc`, `get_hotspots` (hotspots, co-change pairs, orphans), `get_rules` (JSON, `agents-md`, `skill-md`, or
`cursor-mdc`), and `get_impact` (blast radius); resources: `docs://{channel}/{path}` for every Markdown page.

Every site deployed to Cloudflare Pages is itself a remote MCP server (Streamable HTTP, stateless, no install):
`https://t3code.everdoc.dev/mcp` for the default channel, `https://t3code.everdoc.dev/nightly/mcp` to pin one.

```jsonc
// Claude Code / any MCP client with Streamable HTTP
{ "mcpServers": { "t3code": { "type": "http", "url": "https://t3code.everdoc.dev/mcp" } } }
```

```sh
claude mcp add --transport http t3code https://t3code.everdoc.dev/mcp   # the same, from the CLI
everdoc mcp --remote https://t3code.everdoc.dev                         # stdio, backed by any deployed Everdoc site (static hosts too)
everdoc mcp --dir .everdoc/out                                           # stdio, backed by local snapshots
```

`everdoc serve` mounts the Streamable HTTP endpoint locally. To serve MCP from your own Worker or Pages Function:

```ts
// Cloudflare Pages Function at functions/[[path]].ts: serves /mcp and /{channel}/mcp
import { createMcpFetchHandler, createRemoteDataSource } from "@everdoc/mcp";

const handler = createMcpFetchHandler(createRemoteDataSource("https://example.com/atlas"));
export const onRequest = ({ request }: { request: Request }) => handler(request);
```

## Polyglot repositories (Rust, TypeScript, Swift)

A repository with a Cargo workspace, JS/TS packages, and a Swift app needs no extra config: every
discoverer contributes workspaces, and `.rs`/`.swift` files are analyzed and cached by blob SHA like
JS/TS modules (Cargo's `target/` and Rust/Swift tests are skipped).

- **Workspaces:** Cargo `[workspace].members` globs (and standalone crates such as `src-tauri/`), with
  `path`/`workspace = true` internal dependencies, `[lib]`/`[[bin]]` entrypoints, and a role and runtime
  from the manifest (`cdylib` + `wasm-bindgen` → `wasm`, `cdylib`/`staticlib` → `native`); XcodeGen
  `project.yml`, `Package.swift`, and `*.xcodeproj` apps (`ios`/`native`) unless they are a JS/TS package's
  native module. Rust `use` paths become import edges between crates and modules.
- **Reference:** clap derives (nested subcommands, flattened args, `env`/`default_value` flags, the `match`
  arm that dispatches each command), axum/actix-web/rocket routes (`nest`/`merge`/`scope`/`mount` prefixes,
  paths from constants and `format!`), public serde types as schemas (renames, `tag`/`content`, `flatten`),
  tagged `Request`/`Command` enums as RPC methods (handler arms and constructions across crates),
  `std::env::var`/`env!`/`option_env!` env vars, MCP tools (`json!` tool lists, `#[tool]`, `Tool::new`),
  and `std`/`tokio` `Command::new` spawns.
- **Bridges:** `#[wasm_bindgen]`, `#[uniffi::export]`, and `extern "C"` exports are RPCs (transport =
  the bridge); JS/TS packages importing the wasm module and Swift apps embedding the FFI library are
  their callers, and TS `fetch`/axios calls are paired with Rust routes, so the system map draws
  TypeScript → WASM, Swift → Rust, and web → server edges.

The Rust packs (`@everdoc/extractors-rust`) read code with a small built-in parser: no native or
WebAssembly dependencies.

## Writing an extractor

```ts
import { defineExtractor } from "@everdoc/sdk";

export default defineExtractor({
  name: "electron-ipc",
  sinks: [
    {
      id: "handle",
      module: "electron",
      callee: "ipcMain.handle",
      fact: "ipc.handle",
      entity: "ipc-channel",
      args: [
        { index: 0, role: "name" },
        { index: 1, role: "handler" },
      ],
    },
  ],
});
```

Extractors emit **facts**; a `link` phase turns facts into IR entities, nodes, edges, and flows. Fixture tests assert determinism:

```ts
import { assertSnapshotDeterministic } from "@everdoc/sdk";

await assertSnapshotDeterministic(() => analyze("fixtures/electron-app"));
```

## Packages

| Package | Purpose |
| --- | --- |
| [`@everdoc/ir`](packages/ir) | Canonical IR types (`schemaVersion: 1`), `canonicalStringify`, SHA-256 content/shape hashing, `normalizeTypeShape`, stable ID builders, permalinks, and a strict runtime `validateSnapshot`. |
| [`@everdoc/sdk`](packages/sdk) | `defineConfig` + `resolveConfig`, the extractor plugin API (`defineExtractor`, `Sink`, phase contexts), an in-memory `FactStore`, and fixture-test helpers (`assertSnapshotDeterministic`). |
| [`@everdoc/engine`](packages/engine) | Deterministic pipeline: channel resolution (`refs.lock.json`), read-only materialization (blobless mirror, one batched blob fetch), git-blob-keyed fact cache, oxc parsing, cross-module constant evaluation, sink matching with wrapper following, contract ↔ handler ↔ caller pairing, workspace roles/runtimes, package families, curated graph views, flows, docs drift, and history. |
| [`@everdoc/extractors-js`](packages/extractors-js) | Generic JS/TS packs: workspaces, CLI (`@effect/cli`, commander, yargs, citty), env, RPC (`@effect/rpc`, method registries, tRPC), HTTP (Effect platform, express, hono, fastify, elysia), Electron IPC, MCP (Effect AI, MCP SDK), schemas (Effect Schema, zod, TS unions), file-based routes, events, and spawned processes. |
| [`@everdoc/extractors-rust`](packages/extractors-rust) | Generic Rust/Cargo packs and polyglot glue: Cargo and Swift/Xcode workspace discovery, crate import edges, clap CLIs, axum/actix-web/rocket routes, serde schemas and tagged wire protocols, env vars, MCP tools, process spawns, and wasm-bindgen/uniffi/C ABI bridges with TS and Swift callers. |
| [`@everdoc/diff`](packages/diff) | `diffSnapshots(base, head)` → `SnapshotDiff`: ID/rename/move matching, ref-resolving field-level shape diffs, contravariant-input / covariant-output breaking rules, graph + layer-violation and docs-drift diffs, commit/PR evidence, subsystem release notes. |
| [`@everdoc/llms`](packages/llms) | Deterministic `llms.txt`, `llms-full.txt`, the Markdown mirror of the site, and the `everdoc.json` manifest. Depends only on the IR and owns the page plan the site follows. |
| [`@everdoc/mcp`](packages/mcp) | MCP server (official SDK) over stdio or stateless Streamable HTTP (`Request → Response`), backed by a directory or a deployed site. |
| [`@everdoc/site`](packages/site) | Static Astro site with React islands: semantic architecture diagrams (swimlanes or layers, bundled edges, protocol pills, hover spotlight, edge inspector, delta overlay on `@xyflow/react`), SVG sequence diagrams, grouped reference pages with type-shape trees, guides with drift banners, the diff explorer, `⌘K`, `.md` siblings and content negotiation, social cards, optional AI summary callouts, and the Cloudflare `_worker.js`. |
| [`@everdoc/summarize`](packages/summarize) | Optional summaries overlay: overview, workspace/family, key-flow, and compare TL;DR prose from normalized IR slices; content-hash cache; Anthropic, OpenAI (or compatible), and Gemini over `fetch`; per-run token budget. |
| [`everdoc`](packages/cli) (bin `everdoc`) | `everdoc init`, `resolve`, `extract`, `diff`, `llms`, `mcp`, `build`, `summarize`, `serve`, `capture`, `pr-check`, `doctor`. |

## Development

```sh
pnpm install
pnpm build       # tsc per package → dist/
pnpm typecheck   # strict TypeScript, sources and tests
pnpm test        # Vitest (resolves workspace packages to src/, no build needed)
pnpm clean
```

CI runs `pnpm install --frozen-lockfile`, `pnpm build`, `pnpm typecheck`, `pnpm test`, and an `npm pack --dry-run` of every package on every push to `main` and every pull request, and Everdoc's own [PR check](.github/workflows/pr-check.yml) comments the structural diff on every pull request. Every push to `main` also rebuilds and redeploys the [Everdoc Atlas](https://everdoc.dev/).

Read [CONTRIBUTING.md](CONTRIBUTING.md) before opening a pull request (coding agents: [AGENTS.md](AGENTS.md)). Report security problems privately as described in [SECURITY.md](SECURITY.md).

## License

[MIT](LICENSE)
