Validate scenes & regenerate schema
vgai’s scene formats (.vscn.json, .prefab.json) are defined by Zod schemas in the
engine — the single source of truth. Two commands keep everything in sync: generate-schema
regenerates the JSON Schema (which powers VS Code autocomplete) from those Zod definitions, and
validate-scenes checks that scene files only use components/fields the registry defines. This is
a terminal tutorial — the transcript below is real captured output (including a real,
honestly-reported gotcha).
# transcript pending capture — run: node site/media/capture-cli.mjs site/media/capture-cli.mjs -
Regenerate the JSON Schema from the Zod source.
Terminal window npm run generate-schemaThis writes
vscn.schema.json,prefab.schema.json,scn2d.schema.json,vgai-game.schema.json(T3.1), andinputmap.schema.json(intopackages/engine/schemas/) from the Zod schemas — the transcript shows it completing cleanly. Run it after any schema change so editor autocomplete and the on-disk JSON Schema match the code; a pre-commit hook verifies it’s up to date. (animgraph.schema.jsonwas removed by E5 along with theAnimGraphformat it described — there is no schema to regenerate for it any more.) -
Validate scenes against the component registry.
Terminal window npm run validate-scenesThis is the scene guardrail: it walks the
.vscn.json/.prefab.jsonfiles and checks each entity’s components and fields against the engine’s component registry + Zod schemas, exiting non-zero on a violation (so bad scenes can’t land in CI). It also content-parses every.mat.json/.inputmap.json/.instances.jsonunderpublic/through the same Zod schemas the runtime rejects them with at fetch time — previously these formats were only existence-checked when a scene referenced them, so a present-but-malformed asset passed the command and failed at load. (.animgraph.jsonno longer exists as a format — animation is authored asmeta.animationinside an ordinary XState machine, not a separate fetched JSON asset — so there is nothing left for this step to content-parse for animation.)
Recap
New functionality
- Regenerated the JSON Schema from the Zod source (clean)
- Ran validate-scenes and learned to read its output critically
New concepts & skills
- Zod schemas are the single source of truth for .vscn/.prefab
- generate-schema keeps the on-disk JSON Schema (and autocomplete) in sync
- validate-scenes is the scene guardrail — but from the monorepo source layout it currently over-reports due to a cross-package GameComponent identity mismatch (false positives, not drift)
Next lesson → Scene schemas (manual)