# AGENTS.md

Guidance for AI agents (and humans in a hurry) working on `@adaptivestone/framework`.

## Check the plans first

All non-trivial work is tracked in `.plans/refactor/`. Status = directory:
`done/` shipped · `active/` in flight · `queued/` designed, not started · `later/` v6+ horizon.
`.plans/refactor/README.md` is the index and dependency map — it can lag the code, so verify its claims against the source before relying on them.

Before starting any task:

1. Read `.plans/refactor/README.md`.
2. Open every plan whose area overlaps the task (search the folder for the files/terms you are about to touch).
3. If a plan covers the task, follow its settled decisions — do not silently re-design them.
4. If your change conflicts with a queued/active plan, stop and flag the conflict instead of shipping a competing design.

Keep the plans in sync with the work:

- Finishing planned work = update the plan file, move it to the right status directory, and fix the README index in the same change.
- New non-trivial work gets a plan doc in `queued/` before implementation starts.

## Verification

Run before claiming anything is done:

- `npm test` — full suite (node:test)
- `npm run check` — biome lint + format
- `npm run check:types` — codegen + `tsc --noEmit`
- `npm run check:types:tests` — same, but with the test suite included (`tsconfig.tests.json`)
- `npm run smoke` — packaging smoke test (pack → install into a scratch consumer)

### TypeScript resource usage

Prefer one checker for local TypeScript 7 checks, especially when memory is limited.
The compiler investigation found substantially lower memory use and fewer generic
instantiations with `--checkers 1`. This selects one checker, not one Go thread;
do not set `GOMAXPROCS=1` on that basis. Benchmark CI separately before changing
its concurrency defaults.

Keep code generation in the check and use separate incremental caches for the
main and test configurations:

```sh
npm run check:types -- --checkers 1 --incremental --tsBuildInfoFile node_modules/.cache/tsc/framework.tsbuildinfo
npm run check:types:tests -- --checkers 1 --incremental --tsBuildInfoFile node_modules/.cache/tsc/tests.tsbuildinfo
```

Run these commands sequentially and retain the caches between local checks.
For cold measurements, omit `--incremental` and `--tsBuildInfoFile`; add
`--extendedDiagnostics` to record compiler cost. Keep all verification gates above.
See [the measurements](.plans/refactor/done/model-type-cost-experiments.md).

## Conventions

- Do not commit or push. Leave changes in the working tree — a human reviews every diff and does their own git.
- Changelog entries go under `Unreleased` in `CHANGELOG.md`.
- Match the surrounding code style; `biome` is the arbiter. Compact JSDoc, no framework-internals talk in public-facing docs.
