|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +This file is the operating manual for AI coding agents (Cursor, Claude Code, Codex, Aider, Devin, and others) working in this repository. Read this file before making changes. |
| 4 | + |
| 5 | +Human contributors may also find it useful. It is written in direct, imperative style on purpose. |
| 6 | + |
| 7 | +## What this repo is |
| 8 | + |
| 9 | +`react-virtualized-diff` is a React component for rendering large code/text diffs without freezing the browser. The published library lives in `packages/react/`. The repo is a **pnpm workspace monorepo** — use `pnpm`, not `npm` or `yarn`. |
| 10 | + |
| 11 | +Public documentation lives in `README.md` and `llms.txt`. User-facing API changes must update both. |
| 12 | + |
| 13 | +## Project structure |
| 14 | + |
| 15 | +``` |
| 16 | +packages/react/ # published npm package source — this is where most work happens |
| 17 | +apps/demo/ # Vite demo app, used for manual testing and the hosted live demo |
| 18 | +apps/benchmark/ # benchmark harness that produces benchmark-results/results.md |
| 19 | +benchmark-results/ # committed benchmark output, reviewed in PRs when perf changes |
| 20 | +.github/workflows/ # CI: runs lint + build |
| 21 | +scripts/ # repo-level tooling |
| 22 | +``` |
| 23 | + |
| 24 | +The published surface area is exactly what `packages/react/` exports. Nothing under `apps/` ships to npm. |
| 25 | + |
| 26 | +## Setup |
| 27 | + |
| 28 | +``` |
| 29 | +pnpm install |
| 30 | +``` |
| 31 | + |
| 32 | +Node and pnpm are required. Do not run `npm install` or `yarn` — it will corrupt the workspace lockfile. |
| 33 | + |
| 34 | +## Commands |
| 35 | + |
| 36 | +All commands run from the repo root unless noted. |
| 37 | + |
| 38 | +- `pnpm dev` — start the Vite demo app against the local package source (watches and reloads) |
| 39 | +- `pnpm build` — build `packages/react/` |
| 40 | +- `pnpm test` — run the test suite |
| 41 | +- `pnpm lint` — run lint checks |
| 42 | +- `pnpm benchmark` — run the benchmark harness; updates `benchmark-results/results.md` |
| 43 | + |
| 44 | +## Before opening a PR |
| 45 | + |
| 46 | +All of these must pass locally: |
| 47 | + |
| 48 | +1. `pnpm lint` is clean |
| 49 | +2. `pnpm build` succeeds |
| 50 | +3. `pnpm test` passes |
| 51 | +4. `CHANGELOG.md` has an entry for the change |
| 52 | + |
| 53 | +CI also runs `pnpm lint` and `pnpm build`. Tests and CHANGELOG are checked by reviewers. |
| 54 | + |
| 55 | +## Code-change priorities |
| 56 | + |
| 57 | +These are in priority order. If they conflict, earlier rules win. |
| 58 | + |
| 59 | +1. **Default scope is `packages/react/`.** Make changes here unless there is a direct reason not to. If a change requires touching `apps/demo/`, `apps/benchmark/`, or repo-level config, call that out explicitly in the PR description and explain why. |
| 60 | + |
| 61 | +2. **Public API changes must update `README.md` and `llms.txt`.** The list of props in both files is part of the public contract. Renaming a prop, changing a default, adding a prop, or removing a prop requires updating both docs in the same PR. `llms.txt` is how AI coding agents in downstream projects learn this library — keeping it accurate is load-bearing. |
| 62 | + |
| 63 | +3. **Performance-sensitive changes require a benchmark comparison.** "Performance-sensitive" includes anything in the render path, diff computation, virtual list integration, or memoization boundaries. Run `pnpm benchmark` on `main` first, then on your branch, and paste both relevant rows into the PR description. Do not rely on the committed `results.md` alone — it is a snapshot and may be stale. |
| 64 | + |
| 65 | +4. **Every change gets a `CHANGELOG.md` entry.** Even small fixes. Use the existing format in that file. Entries do not need to be long — one sentence is fine — but they must exist. |
| 66 | + |
| 67 | +## Code style |
| 68 | + |
| 69 | +- TypeScript throughout. Strict mode is on — do not introduce `any` to silence type errors. If a type is genuinely unknowable, use `unknown` and narrow. |
| 70 | +- Formatting is controlled by `.prettierrc` and `.editorconfig`. Do not hand-adjust whitespace; run the formatter. |
| 71 | +- Prefer named exports from `packages/react/` entry points. |
| 72 | +- React hooks follow standard rules (exhaustive deps unless justified with a comment). |
| 73 | + |
| 74 | +## Things not to do without explicit instruction |
| 75 | + |
| 76 | +- Do not commit `dist/` or other build output. `.gitignore` covers this; double-check before pushing. |
| 77 | +- Do not hand-edit `pnpm-lock.yaml`. If a dependency needs to change, use `pnpm add` / `pnpm remove` and commit the lockfile update. |
| 78 | +- Do not add new runtime dependencies without flagging the addition in the PR description. Bundle size is part of the library's value. |
| 79 | +- Do not bump the version in any `package.json`. Releases are managed separately. |
| 80 | +- Do not modify `benchmark-results/results.md` by hand — it is generated by `pnpm benchmark`. |
| 81 | +- Do not rewrite the "Why react-virtualized-diff" section of `README.md` or the framing of the benchmark without reviewer discussion. Those sections reflect the project's positioning. |
| 82 | + |
| 83 | +## When in doubt |
| 84 | + |
| 85 | +Open a draft PR with a clear description of what you tried and why. The maintainer (@Zhang-JiahangH) would rather see an honest draft than a polished PR that made the wrong call. |
0 commit comments