gato generate reads .wa/kit.json, finds the features on disk and writes a registry: generated files that import each feature’s definition, env schema, auth plugins and translations. It also fills regions (wa:*) in a few core files. This is how a module can be added or removed without editing core code.
The registry files
There are two registry files: one safe for the browser and one for the server only. Here is the client file in a project with the core and three modules:src/modules.client.generated.ts
The server registry also exports
env = createEnv(moduleEnvSchemas), the validated environment object behind import { env } from "@/env".
Things worth knowing:
- The registry imports files; it does not copy them. Editing the contents of
module.ts,env.tsor a translation file needs no regeneration. Adding or removing such a file does. - There are two files because of the browser bundle. The client file imports only
module.tsandauth-client.ts. The server file also imports env schemas, server auth plugins, audit sinks and translation loaders, none of which belong in the browser. - Order: core features first, then other kit modules by module name, then your project modules alphabetically; within a module, by folder name. The menu ignores this order and sorts by
order. - A feature lands in each array independently. A feature with only translations shows up in
moduleMessagesbut not inclientModules. No core feature hasenv.ts,auth.ts,auth-client.tsoraudit-sink.ts, so in a core-only project those arrays are empty.
src/i18n/locales.generated.ts, holds the project’s locales from .wa/kit.json. It is not part of the module registry, but gato generate writes it too.
.wa/kit.json
This file says which kit modules the project is made of and which features it adds itself. gato create, gato add and gato remove write it; you edit locales and projectModules by hand. Abridged:
.wa/kit.json
kitVersion and kitRepo are read by add, list and update to fetch the matching kit. The full schema is in the kit.json reference.
The schema ignores unknown fields. A typo such as
schemaRelation instead of schemaRelations passes silently and the field gets its default value.Running the generator
Bez zmian (“no changes”) or one zmieniono <file> (“changed”) line per file written. create, add and remove run it automatically at the end.
Run it after you:
- change
.wa/kit.json, includinglocalesandprojectModules; - add or remove
module.ts,env.ts,auth.ts,auth-client.ts,audit-sink.tsori18n/<locale>.jsonin a feature; - add, remove or rename a feature folder;
- change a file referenced by a manifest’s
composeorciSteps.
How features are discovered
- The generator walks the modules in registry order and their
filespatterns. A pattern that starts withsrc/features/<x>/, where<x>contains no/or*, makes<x>a candidate. - For each candidate, it checks which of the recognized files exist in
src/features/<x>/. Translation files count only for locales listed inlocales. - A candidate with at least one recognized file joins the registry. Otherwise it is skipped silently.
- A name listed by several modules counts once.
The generator computes every file first and writes only at the end, so an error at any stage leaves all files untouched. It also writes only files whose content changed, so a second run reports no changes. CI relies on this:
.github/workflows/ci.yml
Generated regions
A region is the part of a file between a line containingwa:<marker>:start and a line containing wa:<marker>:end. The generator replaces everything in between and keeps the marker lines. The comment syntax (// or #) comes from the file.
For example, a project module with
schemaRelations: [{ "model": "Organization", "field": "invoices Invoice[]" }] produces this in organizations.prisma:
prisma/schema/organizations.prisma
- Each file needs exactly one start and one end marker, with the end below the start. The region content must not contain its own marker.
- A missing target file is skipped without error.
- A target file without markers is skipped while the region would be empty. As soon as a module has content for it, the generator fails with
brak regionu(“missing region”). - Relations on models other than
UserandOrganizationgo to no region, and the generator does not report it. Put them in your module’s own schema file. - Core variables in
.env.exampleare written directly in the file, outside the region.