Skip to main content
The core never imports a module directly. Instead, 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 header line reads “generated by wa — do not edit. Run: npm run wa — generate”. Each feature file the generator recognizes ends up in a different array: 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.ts or 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.ts and auth-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 moduleMessages but not in clientModules. No core feature has env.ts, auth.ts, auth-client.ts or audit-sink.ts, so in a core-only project those arrays are empty.
A third generated file, 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.
Feature folders with translations must match ^[a-z][a-zA-Z0-9-]*$ (so my_feature is invalid) and must not be named common, errors, sidebar or serviceMode, which are core namespaces. Otherwise loading translations throws and the page does not render.

.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
What the generator uses from it: 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

It prints 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, including locales and projectModules;
  • add or remove module.ts, env.ts, auth.ts, auth-client.ts, audit-sink.ts or i18n/<locale>.json in a feature;
  • add, remove or rename a feature folder;
  • change a file referenced by a manifest’s compose or ciSteps.
Commit the output together with the change that caused it.

How features are discovered

  1. The generator walks the modules in registry order and their files patterns. A pattern that starts with src/features/<x>/, where <x> contains no / or *, makes <x> a candidate.
  2. For each candidate, it checks which of the recognized files exist in src/features/<x>/. Translation files count only for locales listed in locales.
  3. A candidate with at least one recognized file joins the registry. Otherwise it is skipped silently.
  4. 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 containing wa:<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
Region rules:
  • 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 User and Organization go to no region, and the generator does not report it. Put them in your module’s own schema file.
  • Core variables in .env.example are written directly in the file, outside the region.

Diagnosing registration problems

Generator errors

Errors go to stderr without a stack trace, exit with code 1, and leave every file unchanged. Messages are currently in Polish:
Writing your own feature? Build a feature walks through creating the folder, registering it in projectModules and generating the registry.