Coding agents
Coding agents
Coding agents
Read this before writing or changing chttp code. The core is authored in the scriptc compilable subset, so some normal TypeScript is banned.
Give an agent the docs
These docs are published for agents too: llms.txt is the page index, llms-full.txt is every page in one file. Point your agent at either.
Subset rules for packages/router/src
| nullunions only. Neverundefined.- No
Object.create(null),Object.freeze. Plain({})records only. - Classes only for the router’s entity types (
CtxCore/Ctx,ReqViewCore/ReqView, the response sinks,HttpError). - Indexed
forloops orfor...ofover arrays. Neverfor...in. - No
new Function,eval, non-programinstanceof, object or method shorthand. - Concrete types on route and middleware tables. No
any[]orunknown[]. - Never detect promises with
typeof r.thenorinstanceof Promise. Dispatch settles non-settled results byawaitinsidesettleChain.
// ok
for (let i = 0; i < routes.length; i++) {}
const rec: { [k: string]: string } = {};
// banned
for (const k in rec) {}
const fns = { run: function (): void {} };
Shape of the code
- One core file,
packages/router/src/index.ts: router, context, dispatch, the Node-shapedapp.handler()adapter, and the Web Standards-shapedapp.fetch(). - A second core file,
packages/router/src/sink.ts: theResponseSinkabstraction plusNodeResponseSink(writes toServerResponse) andFetchResponseSink(captures into a WebResponse).Ctxholds aResponseSink; both surfaces route through the same chain. - Route data is plain records. Handlers live in
App._fns, nodes carry indices. - Matching uses an explicit frame stack, no recursion.
- Response helpers call the sink at statement level.
app.fetch()finalizes the sink to aResponsein the chained promise;app.handler()finalizes by writing tores.end().
Where to read more
- ARCHITECTURE.md: request flow, compose model, error path, scriptc compilation.
- AGENTS.md: commands, release flow, full ban list.
- Repo skills:
chttp-app-devfor writing subset-compatible apps,chttp-integrationfor wiring chttp and the plugin into an existing project. - Build-time lowering: Route lowering plugin.