kumiko codegen
kumiko codegen [<path>]Reads r.defineEvent / r.entity calls in the app and emits:
.kumiko/define.ts, the runtime registry the app’s bootstrap importstypes.generated.d.ts, the type maps your IDE picks up, plus (when the app registers write handlers) aWriteHandlerQnunion andcreateTypedDispatcher()
Idempotent, re-running with no changes leaves files untouched. CI-safe for a “is the checkout in sync?” gate.
Typed write handlers (Custom Screens)
Section titled “Typed write handlers (Custom Screens)”When the dev-server runs codegen it also collects every registered write-handler
QN and appends a union type to types.generated.d.ts. Import the typed
wrapper from @app/define:
import { createTypedDispatcher } from "@app/define";import { createLiveDispatcher } from "@cosmicdrift/kumiko-dispatcher-live";
const dispatcher = createTypedDispatcher(createLiveDispatcher());
// Typo → TypeScript error before deploy (not a silent POST /api/write 404):await dispatcher.write("tenant:write:create", payload);Prefer handler constant objects (as const) over raw strings in Custom
Screens, the CI guard resolves those too. String literals in src/** are
also checked at boot (validateAppCustomScreenWriteQns).
When to run
Section titled “When to run”- After adding/renaming an event or entity
- After pulling changes from another dev that touched events/entities
- As a
postinstallhook (already wired, seepackage.json)
Output
Section titled “Output”✓ codegen done, 41 events, 87ms output: .kumiko/ types: rewritten define: unchangedunchanged means the file already matched what would be written :
this is the “no work to do” exit, not an error.
See also
Section titled “See also”kumiko create, usually followed by codegenkumiko build, run codegen first if events changed