Skip to content

kumiko codegen

Terminal window
kumiko codegen [<path>]

Reads r.defineEvent / r.entity calls in the app and emits:

  • .kumiko/define.ts — the runtime registry the app’s bootstrap imports
  • types.generated.d.ts — the type maps your IDE picks up, plus (when the app registers write handlers) a WriteHandlerQn union and createTypedDispatcher()

Idempotent — re-running with no changes leaves files untouched. CI-safe for a “is the checkout in sync?” gate.

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).

  • After adding/renaming an event or entity
  • After pulling changes from another dev that touched events/entities
  • As a postinstall hook (already wired — see package.json)
✓ codegen done — 41 events, 87ms
output: .kumiko/
types: rewritten
define: unchanged

unchanged means the file already matched what would be written — this is the “no work to do” exit, not an error.