Files
matcha/template/shared/AGENTS.md
T
chrnx 56b5d7581f
CI / starter (bun) (pull_request) Successful in 44s
CI / starter (deno) (pull_request) Successful in 32s
CI / starter (node) (pull_request) Successful in 35s
CI / installer (macos-14) (pull_request) Successful in 3s
CI / core-freshness (pull_request) Has been skipped
CI / starter (edge) (pull_request) Failing after 57s
CI / check (pull_request) Successful in 36s
CI / installer (ubuntu-latest) (pull_request) Successful in 11s
docs(template): current generators and plugin docs in AGENTS.md
The scaffolded AGENTS.md listed matcha add sse|ws|upload|stream|buffer and
create controller|step|provider|module. Add cookie, transformer and create
plugin, and point agents at the official plugins' READMEs, which are their
only agent-readable docs.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-11-19 13:15:32 -06:00

63 lines
3.2 KiB
Markdown

# AGENTS.md — {{project_name}}
A [green-tea](https://green-tea.expressive-tea.io/docs/) app (`@green-tea/core` {{core_version}}), scaffolded by
matcha. Read this before editing.
## green-tea is not Express
green-tea is new, so code that looks right from Express, Fastify or NestJS habits is usually wrong here.
- The request pipeline is a **dependency graph**, not a middleware chain. There is no `app.use`, no
`next()`, and nothing mutates `req` or `res`.
- A `@Provider` builds a value once at boot. A `@Step` computes a value per request. Each declares
`provides` and `needs`, and green-tea derives the order from those declarations.
- A handler declares what it needs **in its signature**: `@needs('user')`, `@param('id')`, `@body()`,
`@query()`, `@cookie('name')`. Return a value to answer: an object becomes JSON 200, `undefined` becomes 204.
Throw `Unauthorized`, `NotFound` or another `HttpError` to fail the request.
- `createApp` validates the graph at boot. A token nothing provides, a token with two producers, or a node
that needs what it provides all fail before the app serves anything.
- **Reuse what the graph already has.** Before writing a new step, check whether a token you need, such as
`user`, already exists. Before writing `@needs('x')`, check that something provides `x`.
## Look before you edit
Ask the app what it contains instead of guessing. These commands read `src/app.ts` without starting a
server or opening connections:
```bash
matcha routes --json # every route, its transport, and the chain it runs
matcha tokens --json # every token: who provides it, who needs it
matcha explain /some/:pattern --json # one route's chain, in execution order
matcha graph --format json # the whole graph
```
`explain` takes the route **pattern** as declared (`/users/:id`), not a URL.
## Where things are
- `src/app.ts` builds and exports `app` (`createApp({ modules: [...] })`). Introspection and tests import it.
- `src/main.ts` serves `app`. It is the only file that differs per runtime.
- `src/app.module.ts` lists the providers, steps and controllers with `@Module`.
- `matcha create controller|step|provider|module|transformer <Name>` generates a piece and wires it into the module.
- `matcha create plugin` scaffolds a plugin, in-app or (`--package`) as its own package.
- `matcha add sse|stream|buffer|ws|upload|cookie` adds a capability to a controller.
## Check your work
- Type-check: `npx tsc --noEmit` (Node, edge), `deno check src/main.ts` (Deno), `bunx tsc --noEmit` (Bun).
- Test without a port: `await app.fetch(new Request('http://x/api/thing'))` returns a `Response`.
- `matcha doctor` finds the misconfigurations that fail confusingly.
## The full guide
The rules, decorators, built-in tokens and common mistakes for the installed version are in the package
itself:
- npm / Bun: `node_modules/@green-tea/core/llms.txt`
- Deno (JSR): `https://jsr.io/@green-tea/core/{{core_version}}/llms.txt`
Official plugins (`@green-tea/jwt`, `@green-tea/metrics`, `@green-tea/rate-limit`, ...) ship no llms.txt;
read the installed one's `node_modules/@green-tea/<name>/README.md`.
The complete docs as one file: https://green-tea.expressive-tea.io/docs/llms-full.txt