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>
3.2 KiB
AGENTS.md — {{project_name}}
A green-tea 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, nonext(), and nothing mutatesreqorres. - A
@Providerbuilds a value once at boot. A@Stepcomputes a value per request. Each declaresprovidesandneeds, 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,undefinedbecomes 204. ThrowUnauthorized,NotFoundor anotherHttpErrorto fail the request. createAppvalidates 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 providesx.
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:
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.tsbuilds and exportsapp(createApp({ modules: [...] })). Introspection and tests import it.src/main.tsservesapp. It is the only file that differs per runtime.src/app.module.tslists 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 pluginscaffolds a plugin, in-app or (--package) as its own package.matcha add sse|stream|buffer|ws|upload|cookieadds 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 aResponse. matcha doctorfinds 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