Language: English · 简体中文
AI-native TypeScript game engine — turn ideas into playable games.
AI agents are its primary users. Data, lifecycles, APIs, and tools serve one goal:
help AI understand the system, act precisely, inspect results, and repair failures.
Showcase · Features · Get started · AI efficiency · Architecture · Explore
Important
Efficiency is the goal; design is the method. Complete more verified game-development work with less context, fewer failed attempts, and shorter feedback cycles.
Games built on the engine, authored through the forgeax CLI and an AI-first workflow.
|
Tiangong Warframe · Mecha action / 3D |
My AI Companion Can't Be an Ancient Weapon Spirit! · ARPG / 3D |
|
Pet Go-Karts · Racing / 3D |
Rotten Farm |
- Rendering — Materials, lights, shadows, post-processing, GPU particles, trails, and beams on WebGPU
- Gameplay — ECS world, 2D/3D physics (Rapier), animation, input, audio, and network sync
- Asset pipeline — Import glTF / FBX / images, or generate assets in TypeScript with parameterized variants
- AI-first debugging — Query live entities, record / replay render frames, and inspect draws down to pixels
- CLI workflow — Create, run, inspect, and package games with
forgeaxcommands - Multi-platform — Web, WeChat Mini Game, Steam, Steam Deck, Switch, and Kubee
With Node.js and pnpm available, install Engine from the development channel to create a project and open View.
npm install -g @forgeax/engine@next
forgeax project new my-game --template game-3d
cd my-game
forgeax dev startTo reproduce a specific setup, install the exact version from its release notes. See the Engine package guide for local package testing.
game-3d is a third-person reference; empty is a minimal start. Read the generated README and skills, then see Engine and the CLI guide.
Run and verify
pnpm exec forgeax help --tree --json
pnpm exec forgeax project check
pnpm exec forgeax dev status --json
pnpm exec forgeax dev capture --json
pnpm exec forgeax dev stop --json
pnpm exec forgeax project test
pnpm exec forgeax project package --format web-zipObservations carry a revision; captures return PNG and report references. For entity lookup, camera control, and runtime identity constraints, see persistent live control.
Build from Engine source
Toolchain versions are defined in .nvmrc, .pnpm-version, and .bun-version.
pnpm install
pnpm build:engine
pnpm test| Scenario | Entry |
|---|---|
| Public source checkout | Independent public source with .forgeax-public-distribution and prebuilt WASM; run the install / build commands above without private submodules |
| Full contributor checkout | Clone with --recurse-submodules for authorized private asset access; run pnpm build for the complete application fleet |
| Single demo iteration | pnpm build:app hello/triangle; broader acceptance follows the Smoke gate |
pnpm engine:pack --output <directory> builds the Engine npm archive under
the 64 MB compressed size limit (64,000,000 bytes). The
authoring guide covers game work.
Both local and GitHub development releases publish this package under next.
See the release procedure.
- Node.js ≥ 22.13.0 —
.nvmrcpins22.22.3 - pnpm
12.10.1via Corepack (corepack enable) - Bun ≥ 1.2.0
- A WebGPU-capable browser (latest Chrome / Edge)
Efficiency means verified useful work, accounting for diagnosis and rework, context, and tool round trips.
| Capability | How it improves AI efficiency |
|---|---|
| Transparent rendering | RHI-debug records and replays self-contained frames, exposing draw/dispatch work, bindings, resources, and pixels to locate incorrect inputs |
| Transparent runtime logic and data | ECS makes components, queries, and schedules explicit; Remote queries live instances to locate failures from actual state |
| Authorable, traceable assets | ScriptablePack / Pack generate content in TypeScript or declare it in JSON; stable GUIDs connect sources and artifacts, with repair routed through the producer |
| Reversible plugin changes | Native Cordis unifies dependencies, activation, and cleanup; failed configuration updates can restore the last working Fiber |
| Measurable performance and results | Profiler provides bounded CPU captures and offline comparison; Preview, browser captures, and project tests supply runtime evidence |
| CLI-first operation | DevKit unifies forgeax discovery, JSON input/output, and persistent instances for repeatable, composable operations |
| Context on demand | Skills, package contracts, and tool descriptions reveal only the knowledge needed for the task |
| Structured failure and recovery | Result and closed error unions provide codes, expectations, hints, and details; capabilities, execution tiers, and recovery state are explicit |
Note
Screenshots, structural checks, and real GPU execution answer different questions. CPU captures cannot substitute for GPU performance measurements.
Design principles
Compression is intelligence: reduce the concepts needed to understand local behavior. Avoid duplicate state, extra lifecycles, and implicit branches.
| Design principle | How ForgeAX applies it |
|---|---|
| AI is the primary user | Prioritize discoverable, callable, verifiable machine contracts; AI usability takes precedence over human convention |
| One source of truth | World owns game state, Renderer owns render projections, and source assets plus Meta own author facts; other layers consume or derive |
| Derive from declarations | Material paramSchema derives layouts; RenderGraph derives dependencies and lifetimes from accesses; project declarations generate the Catalog |
| Compose within domain boundaries | Physics, rendering, assets, and audio own their execution data; plugins assemble capabilities and ECS schedules frame work |
| Native lifecycle and unified cleanup | Cordis Context / Entry / Fiber manage capability existence; inject / provide / effect express dependencies, services, and cleanup |
| Explicit states and failures | Closed unions, structured errors, and reported capability absence and fallback reduce hidden branches |
| Prepare at build time, consume at runtime | Import, WGSL composition and reflection, and VFX compilation produce published content for runtime loading |
See the AI-first design axiom and module ownership map for the full constraints.
One authoritative World. Runtime assembles services, Render maintains render projections, and build tools produce resources.
flowchart TB
PROJECT["Game project<br/>forge.json · code · asset sources"]
DEVKIT["DevKit / CLI<br/>project operations · build · inspect"]
COOK["Build-time production<br/>import · cook · shader / VFX compilation"]
ASSETS["AssetRegistry<br/>GUID → published content"]
APP["App + native Cordis<br/>realm assembly · input · frame pacing · lifecycle"]
WORLD["ECS World<br/>state · time · Update / FixedUpdate"]
DOMAINS["Domain systems<br/>scene · animation · physics · audio intents · net"]
RUNTIME["Runtime<br/>select backends and services · assemble Renderer"]
RENDER["Render<br/>persistent projection · extract / prepare / record"]
GRAPH["RenderGraph<br/>resource accesses · pass dependencies · lifetimes"]
RHI["RHI<br/>opaque handles · capabilities"]
GPU["rhi-webgpu / rhi-wgpu<br/>browser WebGPU / wgpu WASM"]
NULL["rhi-null<br/>structural validation"]
DEBUG["RHI-debug<br/>capture · replay · inspect"]
PROJECT --> DEVKIT
DEVKIT --> COOK
COOK --> ASSETS
DEVKIT --> APP
APP --> WORLD
APP --> RUNTIME
WORLD <--> DOMAINS
RUNTIME --> RENDER
WORLD -->|"Change evidence and scene data"| RENDER
ASSETS --> RENDER
RENDER --> GRAPH
GRAPH --> RHI
RHI --> GPU
RHI --> NULL
RHI -.->|"Optional recording"| DEBUG
Rendering and GPU
| Subsystem | Key design and responsibility | Read more |
|---|---|---|
| Render / RenderGraph | Persistent CPU projection and capability-gated GPU Scene; programmable pipelines and RenderFeatures; derived dependencies, usages, and lifetimes with raster / compute / copy passes executed in declaration order | Render · RenderGraph |
| Shader / Material | Schema-derived parameter and binding layouts; WGSL composition, Naga validation and reflection; runtime lookup of content-addressed compiled artifacts | Shader · Compiler |
| GPU VFX | GPU simulation and indirect rendering; code authoring and build-time compilation; particles, ribbons, trails, beams, billboards, and meshes | VFX · VFX render |
| RHI / Backends | Capability-gated operations across browser WebGPU, wgpu WASM, and null backends; a spec-aligned, math-free interface with opaque handles | RHI · wgpu |
ECS and multiple Workers
ECS World owns entities, components, relationships, resources, and time. Systems declare access and scheduling in Update / FixedUpdate. Scene owns hierarchy and transforms; State owns state-scoped entity lifetimes. Renderer consumes World changes into a persistent projection.
flowchart LR
HOST["Host<br/>DOM / UI · input · Web Audio · frame credit"]
ENGINE["Engine Worker<br/>World + Renderer + Assets + game plugins"]
KERNEL["Kernel Worker pool<br/>QuerySpan shards over shared numeric columns"]
HOST -->|"Input and one frame credit"| ENGINE
ENGINE -->|"Results and audio intents"| HOST
ENGINE -->|"Eligible numeric work"| KERNEL
KERNEL -->|"Completion barrier"| ENGINE
| Execution tier | Placement | Constraints and scope |
|---|---|---|
shared |
Engine Worker plus persistent Kernel Worker pool | Requires cross-origin isolation, SharedArrayBuffer, and related capabilities; only eligible numeric work runs in parallel |
engine-worker |
World, Renderer, assets, and game plugins in one Worker | Host retains DOM, input, and audio; requires Worker rendering capabilities |
main-serial |
World and Renderer on the main thread | The direct serial execution path |
auto |
Selects an available tier from capabilities | Reports the actual selection and reason; explicitly requesting an unavailable tier returns an error |
[!NOTE] Multiple Workers preserve one logical World with serial structural changes, no live-object transfer, and no split RenderGraph. Partial shared writes require World rebuild. See App execution and the multithreaded example.
Text and scripted assets
Procedural generation and parameter reuse bring content into the code workflow. AI can generate assets in batches, edit text directly, review diffs, and validate automatically.
| Authoring form | Purpose |
|---|---|
ScriptablePack · .pack.ts |
Generate asset collections with functions, loops, and composition; reuse scene and geometry logic |
| Parameterized instances | Independent package identity, parent source, and sparse overrides for reusable variants |
Pack · .pack.json |
Declare assets, references, and instance parameters for direct field editing and diff review |
| Imported assets and sidecars | External glTF / FBX / image sources and metadata share the identity and cooking path |
[!IMPORTANT] Sources and artifacts are separate.
.pack.tsexecutes at build time; runtime loads cooked content by stable GUID. Textures, models, and audio can still use binary sources. Repair source inputs, then cook again. See the Pack authoring contract.
Game and engine plugins
Game and engine plugins share native Cordis dependencies, activation, updates, and disposal.
| Plugin layer | Typical responsibility | Composition |
|---|---|---|
| Project assembly | Installed plugins, configuration, and realm placement | forge.json#roots references one plugin asset GUID per engine / frontend / build / host root; DevKit compiles the plugin programs for native Loader activation |
| Engine plugins | Scene, input, physics, audio, and ECS capabilities | Native inject / provide declare dependencies and services; effect registers contributions and their inverses |
| Game plugins | Player movement, camera, game UI, and gameplay systems | The reference template composes child plugin assets with mountPluginAsset in assets/game.pack.ts (the engine root); the frontend root mounts game UI |
Effects unwind when their Fiber exits. ECS schedules frame work; plugin assembly stays outside hot paths. See the plugin contract and game-3d root plugin.
Simulation and interaction
| Subsystem | Key design and responsibility | Read more |
|---|---|---|
| Networking | Sessions own replication, ACKs, retries, baselines/deltas, and connection recovery; WebSocket supplies transport | Net · WebSocket |
| Physics | ECS physics contracts separated from Rapier 2D / 3D backends; input synchronization, simulation stepping, and state writeback | Physics |
| Animation / Skinning | Renderer-independent animation graphs, clips, and playback; Skin binding and joint-path resolution | Animation · Skinning |
| Input / UI / Audio | Frozen frame-start input snapshots; Shadow DOM UI; realm-neutral audio intents played by Host Web Audio | Input · UI · Audio |
| Entry | Purpose |
|---|---|
| AGENTS.md | Design axioms, module ownership, errors, source-work rules, and verification constraints |
| Packages | Package READMEs defining APIs, lifecycles, and capability contracts |
| Schemas / CI guide | Machine-readable contracts and verification workflows |
| Engine skills | Task-oriented capability discovery and operating paths |
| Apps / Templates | Examples, regression scenarios, and game starting points |
| Forbidden City showcase | pack.ts architecture, lighting, and continuous CLI inspection; visual quality remains a work in progress |
- 🌐 Website — forgeax.github.io
- 📧 Email — forgeax@outlook.com
- 🐧 QQ group — join here
Note
The default README is English; README.zh-CN.md is the Simplified Chinese translation. Keep both versions in sync. Linked package contracts define precise capabilities and limitations.