Skip to content

Getting started

Requirements: Node.js 24+ (26 used in development) and pnpm 12 (npm i -g pnpm).

Terminal window
pnpm install
pnpm dev # Sprout, the sample game, with hot reload → http://localhost:5173
pnpm dev:demo # the Phase 1a test scene (also on :5173; run one at a time)

Open http://localhost:5173/?debug to start with the debug overlay open (toggle it with the backquote key). In the 1a demo, the sprite stress test is at /?bench=sprites&n=2000.

Sprout’s controls, file layout and tools are described in games/sprout/README.md (games/sprout/README.md).

Command What it does
pnpm dev Sprout dev server with hot reload (code: page reload; JSON data: swapped in place)
pnpm dev:demo The 1a demo instead
pnpm test Unit and headless game tests (Vitest), including a bot that plays all of Sprout
pnpm test:e2e Builds both games for production and plays them in headless Chromium (Playwright): keyboard, gamepad, level 1 completed. First time: pnpm exec playwright install chromium
pnpm lint / pnpm format Biome check / fix
pnpm typecheck TypeScript strict across all packages
pnpm bench ECS benchmark (fails if 5k entities exceed the 4 ms simulation budget)
pnpm size Builds both games, checks bundle-size budgets and that no Zod reached a production bundle
pnpm docs:api Generates the API reference into docs/api/ (Markdown)
pnpm schemas Regenerates JSON Schemas from the Zod definitions
pnpm docs:llms Regenerates the AI docs and references (--check fails if they are stale)
pnpm create-game <name> Creates games/<name> from a template
pnpm mcp Starts the MCP server on stdio (clients usually start it themselves)
pnpm evals AI success tests (see below; the default runner is free)
pnpm platform:dev The platform locally without Docker (http://localhost:3000)
pnpm platform:up The platform in Docker (docker compose up --build)
pnpm platform publish <dir> Publish a game folder to a running platform (needs PLATFORM_TOKEN)
pnpm verify Everything above in sequence (except evals with a model)

A game is a folder of JSON documents plus optional TypeScript (see games/sprout/game):

game.json manifest: display, input actions, UI theme, asset bundles, scenes, permissions
scenes/*.json scene: level, camera, background, music, systems, HUD, menu, rules
levels/*.json tilemap: tilesets with per-tile collision, tile layers, object layers
prefabs/*.json entity templates: component values by component name
assets/* images (PNG/SVG), bitmap fonts
audio/*.json synthesized sounds and songs (or recorded files with the `audio` asset type)

Built-in components cover a typical platformer: PlatformerController, Health, ContactDamage (set stompable), Patrol (walkers), Hover (flyers), Pickup, Checkpoint, Lifetime and PlatformerAnimator. Scenes connect events to actions with rules:

"rules": [
{ "on": "pickup:coin", "do": [{ "action": "addToCounter", "counter": "coins", "amount": 1 },
{ "action": "playSound", "sound": "sfx.coin" }] },
{ "on": "player:died", "do": [{ "action": "respawn", "entity": "player", "delayMs": 1300 }] },
{ "on": "input:pause", "do": [{ "action": "pushScene", "scene": "pause" }] }
]

Events include scene:start, controller:jump, pickup:<kind>, enemy:stomped, <name>:hurt, <name>:died, checkpoint:reached, trigger:<event>, input:<action> and app:hidden. Actions: goToScene (fades), pushScene, popScene, restartScene, addToCounter, setCounter, playSound, playMusic, stopMusic, cameraShake, emit, respawn, setComponent, banner, toggleSetting, saveGame; any action takes delayMs.

HUD entries (text, counter, icon, hearts, bar, timer) and menu labels read values with bindings: {game.coins} (scene state), {session.coins} (across scenes), {settings.sound}, {player.Health.hp}.

vite build with the platformData plugin validates every document (a mistake fails the build with its JSON pointer) and bundles normalized documents, so games load them without the validator and without Zod (ADR 0016).

Every document has a JSON Schema (packages/schema/json), so editors autocomplete and the framework reports mistakes with exact paths, e.g. levels/test-level.json#/layers/0/data — Expected 1200 cells, got 1199.

Code is the escape hatch: a game registers behaviors by name and scenes list them in systems:

import { defineSystem, ParticleEmitter, startGame, type BehaviorFactory } from '@ludrel/framework';
const jumpDust: BehaviorFactory = () =>
defineSystem({
name: 'jumpDust',
phase: 'fixed',
setup(world) {
world.events.on('controller:jump', (payload) => {
const { entity } = payload as { entity: number };
const emitter = world.tryGet(entity, ParticleEmitter);
if (emitter) emitter.burst += 8;
});
},
run() {},
});
await startGame({ files, parent, behaviors: { jumpDust } });

pnpm platform:dev runs the whole platform locally without Docker (catalog, accounts, publishing, sandboxed player, moderation) at http://localhost:3000; pnpm platform:up runs it in Docker. See platform.md.

The MCP server (apps/mcp) gives any MCP client the same tools the built-in assistant will use: create a game from a template, read and edit its files with validation, build levels from text, validate, run headless with assertions, capture screenshots and search the docs. Start with the AI guide; the generated AI docs are docs/llms.txt and docs/llms-full.txt (pnpm docs:llms regenerates them).

  • Claude Code: the repository’s .mcp.json registers the server as platform; approve it when Claude Code asks.
  • Other clients (e.g. Claude Desktop): add a stdio server with the command <repo>/node_modules/.bin/tsx and the arguments <repo>/apps/mcp/src/main.ts --root <repo>.

New games without AI:

Terminal window
pnpm create-game my-game --title "My Game"
pnpm --filter @ludrel/my-game dev

pnpm evals runs scripted tasks (add a double-jump power-up, add a second level, replace bees with a bat) on a fresh game and grades the result automatically. Runners:

Runner Cost What runs the task
--runner reference (default) free each task’s reference solution, through the same tools; proves the graders
--runner api API tokens a fresh Claude session through @ludrel/ai (needs ANTHROPIC_API_KEY in your environment or an ant auth login profile)
--runner claude-code your Claude plan claude -p restricted to this repository’s MCP tools (needs the Claude Code CLI)

Add --task <id> for one task and --keep to inspect the game afterwards. Reports go to .cache/evals/.

With pnpm dev running, edit a prefab in games/sprout/game/prefabs/ (e.g. the player’s PlatformerController.jumpSpeed or a mushroom’s Patrol.speed) or a scene’s rules. The scene rebuilds in place and the player keeps its position. Save an invalid change (e.g. delete a number from data) and the overlay shows why it was rejected while the game keeps running.

import { runHeadless } from '@ludrel/testing';
const r = await runHeadless({
gameDir: 'games/sprout/game',
ticks: 300,
inputs: [{ tick: 0, action: 'moveX', value: 1 }],
watchEvents: ['player:died'],
});
expect(r.errors).toEqual([]);

Same seed + same inputs = same result, so these tests are reliable — and the Phase 2 MCP run_headless tool will use this runner.