@air-jam/cli 0.9.3 → 1.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/README.md +128 -0
  2. package/dist/auth-profile.d.ts +5 -0
  3. package/dist/auth-profile.js +7 -0
  4. package/dist/auth-profile.js.map +1 -0
  5. package/dist/auth-sessions.d.ts +5 -0
  6. package/dist/auth-sessions.js +7 -0
  7. package/dist/auth-sessions.js.map +1 -0
  8. package/dist/chunk-7D4AYBAV.js +64 -0
  9. package/dist/chunk-7D4AYBAV.js.map +1 -0
  10. package/dist/chunk-LH7UO57C.js +23 -0
  11. package/dist/chunk-LH7UO57C.js.map +1 -0
  12. package/dist/chunk-PKTLVQXZ.js +82 -0
  13. package/dist/chunk-PKTLVQXZ.js.map +1 -0
  14. package/dist/chunk-SQE4NPZP.js +31 -0
  15. package/dist/chunk-SQE4NPZP.js.map +1 -0
  16. package/dist/{chunk-A4V2N4LX.js → chunk-U6V3HEBB.js} +6 -5
  17. package/dist/chunk-U6V3HEBB.js.map +1 -0
  18. package/dist/chunk-VEHNFPEO.js +224 -0
  19. package/dist/chunk-VEHNFPEO.js.map +1 -0
  20. package/dist/development.d.ts +4 -0
  21. package/dist/development.js +1 -1
  22. package/dist/game-analytics.d.ts +5 -0
  23. package/dist/game-analytics.js +7 -0
  24. package/dist/game-analytics.js.map +1 -0
  25. package/dist/game-app-id.d.ts +5 -0
  26. package/dist/game-app-id.js +7 -0
  27. package/dist/game-app-id.js.map +1 -0
  28. package/dist/game-media.d.ts +5 -0
  29. package/dist/game-media.js +7 -0
  30. package/dist/game-media.js.map +1 -0
  31. package/dist/index.js +688 -404
  32. package/dist/index.js.map +1 -1
  33. package/dist/scaffold.d.ts +8 -1
  34. package/dist/scaffold.js +6 -1
  35. package/dist/scaffold.js.map +1 -1
  36. package/package.json +8 -4
  37. package/runtime/local-network.d.mts +4 -6
  38. package/runtime/public-assets.mjs +62 -0
  39. package/runtime/source-fence.mjs +182 -0
  40. package/runtime/vite-config.d.mts +2 -1
  41. package/runtime/vite-config.mjs +6 -2
  42. package/runtime/vite-dev.mjs +18 -0
  43. package/runtime/vite-https.mjs +2 -3
  44. package/template-assets/bootstrap/AGENTS.md +56 -14
  45. package/template-assets/bootstrap/CLAUDE.md +0 -8
  46. package/template-assets/bootstrap/skills/airjam-mcp/SKILL.md +44 -0
  47. package/template-assets/bootstrap/skills/controller-ui/SKILL.md +2 -0
  48. package/template-assets/bootstrap/skills/game-architecture/SKILL.md +47 -3
  49. package/template-assets/bootstrap/skills/index.md +1 -1
  50. package/template-assets/bootstrap/skills/prefab-authoring/SKILL.md +10 -0
  51. package/template-assets/bootstrap/skills/r3f-3d-scene/SKILL.md +10 -0
  52. package/template-assets/documentation/for-agents/controller-ui/page.mdx +41 -2
  53. package/template-assets/documentation/for-agents/page.mdx +24 -2
  54. package/template-assets/documentation/for-agents/project-structure/page.mdx +0 -2
  55. package/template-assets/documentation/for-agents/state-and-rendering/page.mdx +19 -2
  56. package/template-assets/documentation/for-agents/supported-agents/page.mdx +18 -0
  57. package/template-assets/documentation/getting-started/debugging/page.mdx +7 -8
  58. package/template-assets/documentation/getting-started/dev-logs/page.mdx +0 -2
  59. package/template-assets/documentation/getting-started/game-ideas/page.mdx +1 -3
  60. package/template-assets/documentation/getting-started/introduction/page.mdx +71 -54
  61. package/template-assets/documentation/getting-started/migrating-legacy-games/page.mdx +308 -62
  62. package/template-assets/documentation/getting-started/quick-start/page.mdx +56 -79
  63. package/template-assets/documentation/how-it-works/architecture/page.mdx +91 -50
  64. package/template-assets/documentation/how-it-works/host-system/page.mdx +112 -109
  65. package/template-assets/documentation/manifest.json +112 -42
  66. package/template-assets/documentation/sdk/assets-and-theme/page.mdx +185 -0
  67. package/template-assets/documentation/sdk/hooks/page.mdx +108 -172
  68. package/template-assets/documentation/sdk/input-system/page.mdx +201 -231
  69. package/template-assets/documentation/sdk/networked-state/page.mdx +134 -52
  70. package/template-assets/documentation/sdk/settings/page.mdx +166 -0
  71. package/template-assets/documentation/sdk/ui-components/page.mdx +38 -27
  72. package/template-assets/managed/.airjam/ai-pack.json +65 -47
  73. package/template-assets/managed/docs/airjam/agent-gold-path.md +55 -7
  74. package/template-assets/managed/docs/airjam/agent-mcp.md +44 -0
  75. package/template-assets/managed/docs/airjam/composition-shell-contract.md +4 -0
  76. package/template-assets/managed/docs/airjam/debug-and-testing.md +18 -0
  77. package/template-assets/managed/docs/airjam/docs-index.md +18 -12
  78. package/template-assets/managed/docs/airjam/generated/architecture.md +91 -46
  79. package/template-assets/managed/docs/airjam/generated/assets-and-theme.md +188 -0
  80. package/template-assets/managed/docs/airjam/generated/controller-ui.md +41 -0
  81. package/template-assets/managed/docs/airjam/generated/debugging-and-logs.md +7 -6
  82. package/template-assets/managed/docs/airjam/generated/for-agents.md +24 -0
  83. package/template-assets/managed/docs/airjam/generated/game-ideas.md +1 -1
  84. package/template-assets/managed/docs/airjam/generated/host-system.md +112 -102
  85. package/template-assets/managed/docs/airjam/generated/input-system.md +199 -218
  86. package/template-assets/managed/docs/airjam/generated/introduction.md +71 -51
  87. package/template-assets/managed/docs/airjam/generated/migrating-legacy-games.md +308 -60
  88. package/template-assets/managed/docs/airjam/generated/networked-state.md +134 -50
  89. package/template-assets/managed/docs/airjam/generated/quick-start.md +56 -79
  90. package/template-assets/managed/docs/airjam/generated/sdk-hooks.md +108 -167
  91. package/template-assets/managed/docs/airjam/generated/settings.md +169 -0
  92. package/template-assets/managed/docs/airjam/generated/state-and-rendering.md +19 -0
  93. package/template-assets/managed/docs/airjam/generated/supported-agents.md +21 -0
  94. package/template-assets/managed/docs/airjam/generated/ui-components.md +38 -25
  95. package/template-assets/managed/docs/airjam/prefab-authoring.md +100 -0
  96. package/template-assets/managed/docs/airjam/preview-controllers.md +5 -2
  97. package/template-assets/managed/docs/airjam/r3f-3d-scene.md +66 -0
  98. package/template-assets/managed/docs/airjam/state-lanes-cookbook.md +15 -20
  99. package/dist/chunk-A4V2N4LX.js.map +0 -1
@@ -16,8 +16,8 @@ Use this skill when adding new systems or moving code between boundaries.
16
16
 
17
17
  Prefer this split:
18
18
 
19
- 1. `src/airjam.config.ts` for catalog metadata plus runtime config such as `controllerPath` and input schema
20
- 2. `src/app.tsx` for mounting explicit host/controller runtime boundaries
19
+ 1. `src/airjam.config.ts` for the framework-free `defineAirJamGame` declaration from `@air-jam/sdk/core`: metadata, stores, simulation, input, bindings, agent and testing path
20
+ 2. `src/app.tsx` for `createAirJamApp(airjam, { runtime })` and mounting its host/controller runtime boundaries
21
21
  3. `src/host/` for host-only composition
22
22
  4. `src/controller/` for controller-only composition
23
23
  5. `src/game/domain/` for pure rules
@@ -29,7 +29,7 @@ Prefer this split:
29
29
 
30
30
  Keep runtime ownership explicit:
31
31
 
32
- 1. mount `airjam.Host` / `airjam.Controller` once at the boundary
32
+ 1. mount `app.Host` / `app.Controller` from the React binding once at the boundary
33
33
  2. use consumer hooks like `useAirJamHost()` and `useAirJamController()` only below that boundary
34
34
  3. keep gameplay code out of runtime setup and transport bootstrap
35
35
 
@@ -56,3 +56,47 @@ If new work would harden a mixed boundary, split the structure first or split th
56
56
  1. one large file that mixes host, controller, domain, and rendering concerns
57
57
  2. React components as the only home for gameplay logic
58
58
  3. adapter code becoming the real game model
59
+
60
+ ## One game declaration
61
+
62
+ Read `airjam.inspect_game` for the versioned `declaration`, including
63
+ `declaration.agent`, controls, controller path and metadata. The game's
64
+ `src/airjam.config.ts` exports `airjam = defineAirJamGame(...)` from
65
+ `@air-jam/sdk/core`; agent helpers also come from core. Keep React, the SDK
66
+ root, TSX and CSS out of its graph. `app.tsx` alone binds it with
67
+ `createAirJamApp(airjam, { runtime })`.
68
+
69
+ Capacity comes from `metadata.maxPlayers`. The `testing` path names a module
70
+ exporting `testing = defineAirJamTesting({ player, profiles, visual })` from
71
+ `@air-jam/devtools/testing`. Profiles author scripted policies only; a declared
72
+ player is offered as the reserved `model` policy in every profile. Optional
73
+ `visual.scenarios` uses the game's declared agent. A profile's `setup` brings
74
+ the room to where its test starts; its `handBack` returns the creator's room,
75
+ usually with `return_to_lobby`, once the test ends and before its players
76
+ leave, so the game never plays on without them. Profiles that join play already
77
+ under way hand it back too. Declare `handBack: []` only when the game has no
78
+ phase to leave, such as a shared counter; a missing one is reported as
79
+ `undeclared` in the run record. Do not duplicate identity in template flags or read config source with
80
+ regular expressions.
81
+
82
+ ## Declared settings
83
+
84
+ Declare creator tuning values with `defineAirJamSettings` and `setting` from
85
+ `@air-jam/sdk/core`, in the game declaration's `settings` field. Remove the
86
+ constants they replace. Read values in simulation create/step/observe contexts
87
+ and typed action contexts; host rendering uses `useAirJamSettings`. Controllers
88
+ show copies in replicated state. Lobby player choices stay store state.
89
+
90
+ Inspect descriptors in `airjam.inspect_game` → `declaration.settings`.
91
+ Use `airjam.read_game_settings({ gameSessionId })` for live values and revision,
92
+ then `airjam.update_game_settings({ gameSessionId, patch, expectedRevision })`
93
+ under host authority. Only `live: true` values can change; non-live values go
94
+ in `airjam.start_game_run({ settings, ... })` for a fresh room. Stale revisions
95
+ require a fresh read. Input log version 2 records initial values and ordered
96
+ settings updates for replay. See `docs/airjam/generated/settings.md`.
97
+
98
+ Declared assets and theme are read through `airjam.inspect_game` in
99
+ `declaration.assets` and `declaration.theme`. Keep sounds, images and loaded
100
+ files in `defineAirJamAssets`, colours and font families in `defineAirJamTheme`,
101
+ and pass both to `defineAirJamGame`. The React binding owns audio mounts and
102
+ theme CSS variables; games consume the declared objects and never duplicate them.
@@ -25,7 +25,7 @@ Pick the one that matches the current problem.
25
25
  8. `prefab-authoring`
26
26
  Use when creating reusable gameplay objects or scene presets that should stay declarative, configurable, and tool-friendly.
27
27
  9. `r3f-3d-scene`
28
- Use when building or reviewing 3D Air Jam gameplay with React Three Fiber, lighting, shadows, grounding, particles, and physics.
28
+ For R3F or Three.js work, read `skills/r3f-3d-scene/SKILL.md` before creating scene objects.
29
29
  10. `canvas-2d-gameplay`
30
30
  Use when building or reviewing 2D canvas gameplay, render/simulation separation, scaling, SVG assets, and lightweight collision patterns.
31
31
 
@@ -46,3 +46,13 @@ Keep the prefab definition declarative and stable enough that future tooling can
46
46
  3. prefab placement rules that depend on trial-and-error offsets
47
47
  4. prefab contracts that are too ad hoc for future scanning or preview generation
48
48
  5. plural runtime mappers like `Ships` or `Collectibles` living in `src/game/prefabs/` when they are actually population layers over state
49
+
50
+ Declare every asset once as a prefab with optional `space` and real `states`.
51
+ Without `space`, `preview.camera` implies `"3d"`; otherwise it is `"2d"`.
52
+ Use a renderer-free declaration in config; rendered definitions still require `render`.
53
+ Attach `createPrefabCatalog([...])` as `defineAirJamGame({ prefabs })`, and supply
54
+ `<app.Host prefabStage={Stage}>`. Read the managed prefab-authoring guide for the
55
+ complete stage example. The stage uses `usePrefabInspection()` and
56
+ `useHostAgentCapture`, draws from the SDK clock and applies the canonical view.
57
+ Inspect at least three angles or states through the inspector before presenting
58
+ an asset; then verify it in the live game. Do not create a second capture catalog.
@@ -15,6 +15,16 @@ Use this skill for 3D host gameplay surfaces built with React Three Fiber and Th
15
15
 
16
16
  ## Core Rule
17
17
 
18
+ Before importing 3D libraries, follow the dependency setup in
19
+ `docs/airjam/r3f-3d-scene.md`. Starters do not include Three.js or React Three
20
+ Fiber. In Studio, use `studio_change_dependency`; elsewhere use the project's
21
+ package manager. Add only the libraries this game uses.
22
+
23
+ In React, create three.js objects inside an effect, keep them in state and free
24
+ them in its cleanup, never during render into a useRef, useMemo or module
25
+ variable: live edits and StrictMode rerun effects, so an object kept from render
26
+ is freed while still shown and the scene goes empty.
27
+
18
28
  Treat R3F as a rendering layer.
19
29
 
20
30
  Keep:
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  # Controller UI
4
2
 
5
3
  Controller UI should feel like a game controller first and a webpage second.
@@ -8,6 +6,8 @@ The main failure mode is borrowing desktop web-app patterns for active gameplay
8
6
 
9
7
  ## Gameplay Controller Rules
10
8
 
9
+ A game whose `inputModalities` include `'joystick'` always gets a landscape controller; the SDK applies it, so do not set orientation; lay it out with `GamepadLayout` from `@air-jam/sdk/ui`: the stick under the left thumb, the actions under the right in a square the same size, and only short status between them.
10
+
11
11
  For active gameplay:
12
12
 
13
13
  1. use an absolute `inset-0` root
@@ -17,6 +17,35 @@ For active gameplay:
17
17
  5. keep controls visually obvious and single-purpose
18
18
  6. minimize text and dense hierarchy
19
19
 
20
+ ## Sideways Controllers
21
+
22
+ A sideways phone is held like a gamepad, so its controls use the screen like one. Compose them in `GamepadLayout`:
23
+
24
+ 1. the stick goes in `left` and the actions in `right`; both get the same square, so they carry the same weight and mirror each other about the centre, each centred in its thumb zone on one line
25
+ 2. a single action fills its square; several actions share it as one cluster, as phone action games do, rather than starting a third column: the main action sits at the square's centre under the resting thumb at about half the square's width, each other action is about two thirds of the main one's size on a tight arc around its inner side (below, toward the centre, above) with the most used nearest, a rarely used utility goes smaller on the outer side, and every button stays inside the thumb zone
26
+ 3. a button with a cooldown shows it on itself: a dark sweep over the icon that shrinks as it recovers, the seconds left when the wait is over a second, and full colour once it is ready again
27
+ 4. buttons show icons, not words, drawn as one family: the same grid, the same stroke width with round caps and joins (or all filled), the same optical size of about half the button, one simple silhouette each and no detail finer than the stroke; judge them at real size on a phone
28
+ 5. `center` holds only what a player reads at a glance: a round, a number, a word, a few icons; it never wraps into squeezed lines
29
+ 6. a longer message goes in the header bar above the layout, or stays on the TV
30
+
31
+ ```tsx
32
+ import { ControlButton, GamepadLayout, Stick } from "@air-jam/sdk/ui";
33
+
34
+ // Before: a big stick, a small button pushed to the edge, a sentence wrapping between them.
35
+ <div className="flex h-full items-center justify-between px-6">
36
+ <Stick control={gameInput.move} className="size-56" />
37
+ <p className="max-w-48 text-2xl">Splash! Back next round</p>
38
+ <ControlButton control={gameInput.dash} className="size-28">Dash</ControlButton>
39
+ </div>
40
+
41
+ // After: equal mirrored thumbs, a glanceable centre, the sentence in the header.
42
+ <GamepadLayout
43
+ left={<Stick control={gameInput.move} className="rounded-full bg-white/10" />}
44
+ center={<span className="text-xs uppercase">Round 1</span>}
45
+ right={<ControlButton control={gameInput.dash} className="rounded-full bg-sky-400">Dash</ControlButton>}
46
+ />
47
+ ```
48
+
20
49
  ## Lobby Rules
21
50
 
22
51
  Lobby screens can be slightly more flexible, but should still prefer:
@@ -58,3 +87,13 @@ For template and starter work, a practical split is:
58
87
  2. a gameplay-oriented icon set for abilities, pickups, and status effects
59
88
 
60
89
  Keep icon usage behind local wrappers where practical so the project can curate or replace icons later.
90
+
91
+ ## Private player screens and word games
92
+
93
+ Keep secret words or cards in a per-controller map declared with
94
+ `createAirJamStore`'s `privateField`; read that phone's entry with
95
+ `useAirJamPrivateState`. The public store excludes this field and each phone
96
+ receives only its own entry. Test a reveal with `studio_press_phone`'s hold action.
97
+
98
+ A decision-model seat (Jev) answers choice questions only. Give model seats authored
99
+ candidate clues or answers as options; people can type freely into phone fields.
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  # For Agents
4
2
 
5
3
  This page is the fastest entrypoint for LLM agents and automation tools.
@@ -43,6 +41,8 @@ the server. `mcp doctor` distinguishes project declarations from detected client
43
41
  registrations. Confirm that the connected client discovers Air Jam's tools before
44
42
  treating the connection as working.
45
43
 
44
+ [Supported Agents](/docs/for-agents/supported-agents) lists the clients tested end to end.
45
+
46
46
  ## Operate and Evaluate
47
47
 
48
48
  For gameplay assertions, use `airjam.open_game_session`,
@@ -51,6 +51,12 @@ For gameplay assertions, use `airjam.open_game_session`,
51
51
  do not guess game-specific action IDs. `airjam.capture_game_session_visuals`
52
52
  adds host and phone-controller screenshots to the same session.
53
53
 
54
+ In Studio, `studio_press_phone` taps, holds or types on one named mounted Studio phone
55
+ and returns its private screen in the same call. Coordinates are fractions 0..1 of
56
+ `studio_observe_current_game`'s `surface=phone` image. Tap a field before typing;
57
+ a hold captures while pressed, then releases. Reuse the requestId UUID for retries.
58
+ Guest/real phones and older runtimes return an explicit unavailable reason.
59
+
54
60
  MCP is optional. A terminal agent can use the same services:
55
61
 
56
62
  ```bash
@@ -72,6 +78,22 @@ The [Quick Start publishing guide](/docs/getting-started/quick-start#terminal-or
72
78
  covers CLI authentication, hosted release submission, inspection, and explicit
73
79
  publication. Local development and evaluation do not require hosted publishing.
74
80
 
81
+ ## Decision-model Players
82
+
83
+ An `AirJamPlayerContract` from `@air-jam/devtools/testing` describes play with
84
+ `brief` and `turn`. A turn returns `{ state, question, options }` or `null` when
85
+ the seat has nothing to do. Offer 1 to 16 named options, each with a plain-language
86
+ `when` and its `control`. Zero options is invalid; use `null` to wait.
87
+
88
+ A single sensible move is allowed: for example, a lobby turn can offer only
89
+ `join` with `control: { kind: "action", actionId: "join_match" }`. The run owner
90
+ takes that control directly without calling a decision model or incurring model
91
+ cost. Do not invent a second option to satisfy validation. Multiple options ask
92
+ the run's model to choose. Automatic answers retain the choice and control in the
93
+ trace, marked `Only option; no model asked.`, and count toward the seat's optional
94
+ `answers.automatic` summary. The policy receives the choice just like a model
95
+ answer on its next step.
96
+
75
97
  ## Read These First
76
98
 
77
99
  1. [Introduction](/docs/getting-started/introduction)
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  # Project Structure
4
2
 
5
3
  Air Jam games should not grow as one large React surface.
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  # State and Rendering
4
2
 
5
3
  Air Jam projects often combine React, Zustand, per-frame gameplay logic, and sometimes R3F or Three.
@@ -60,6 +58,25 @@ The default order is:
60
58
  3. keep rendering integration separate from pure game rules
61
59
  4. use instancing when repeated objects justify it
62
60
 
61
+ ## Loading and the Reveal
62
+
63
+ In the Arcade and the Studio, the page around a game keeps its own cover up
64
+ until the game's host says it is ready, so players never watch a game assemble
65
+ itself. The host is ready once it has mounted, its fonts have loaded and its
66
+ room is connected. Anything still loading after that holds the reveal with
67
+ `<HoldReveal />` from `@air-jam/sdk`:
68
+
69
+ 1. render it in every Suspense fallback on the host, including the route-level
70
+ fallback around a lazy host view: `<Suspense fallback={<HoldReveal />}>`
71
+ 2. put a Suspense boundary with that fallback around R3F content that loads
72
+ models or textures (`useGLTF`, `useTexture`), so the scene appears whole
73
+ 3. render it conditionally for any other loading the host waits on:
74
+ `{!ready && <HoldReveal />}`
75
+
76
+ A fallback can draw its own placeholder and include `<HoldReveal />` inside it.
77
+ The reveal happens once; holding again later changes nothing, and outside a
78
+ host it does nothing.
79
+
63
80
  ## Air Jam Lane Rules
64
81
 
65
82
  Keep the framework lanes separate:
@@ -0,0 +1,18 @@
1
+ # Supported Agents
2
+
3
+ Any coding agent that can run terminal commands or start a local stdio MCP
4
+ server can build with Air Jam. Tested means the agent made a game through Air
5
+ Jam's CLI and MCP, played it with two phones and released it.
6
+
7
+ | Agent | Status | Notes |
8
+ | ---------------------------------- | ---------------------- | --------------------------------------- |
9
+ | Codex CLI | Tested | |
10
+ | Claude Code | Tested | |
11
+ | T3 Code | Tested | |
12
+ | Codex app, over SSH | Covered by Codex CLI | Runs the same `codex` program |
13
+ | Claude Desktop Code tab, over SSH | Covered by Claude Code | Runs the same `claude` program |
14
+ | Claude Desktop chat | Not for building | Cannot edit project files |
15
+ | Other terminal or stdio MCP agents | Not tested | Expected to work through the CLI or MCP |
16
+
17
+ Air Jam supports its own CLI and MCP, not the agent's interface. To connect an
18
+ agent, see [For Agents](/docs/for-agents).
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  # Debugging and Logs
4
2
 
5
3
  When local Air Jam development breaks, the fastest fix is usually knowing which surface is failing:
@@ -62,7 +60,7 @@ Use the right browser console for the right problem:
62
60
 
63
61
  1. **Host tab** for room creation, host bootstrap, input consumption, and gameplay errors
64
62
  2. **Controller tab/phone remote inspector** for join failures, input publishing, haptics, and controller UI state
65
- 3. **Server terminal** for room lifecycle, socket disconnects, auth/bootstrap problems, and routing issues
63
+ 3. **Server terminal** for room lifecycle, dropped connections, refused hosts and phones
66
64
 
67
65
  Do not debug everything from only one surface.
68
66
 
@@ -96,16 +94,17 @@ pnpm run dev -- --secure
96
94
 
97
95
  Check:
98
96
 
99
- 1. controller is publishing input via `useControllerTick` + `useInputWriter`
100
- 2. host is reading input via `getInput` or `useGetInput`
101
- 3. you are not trying to send per-frame input through store actions
102
- 4. the input schema still matches the payload shape
97
+ 1. the game declares its controls with `defineAirJamGame({ input })`
98
+ 2. the controller renders the SDK's phone controls bound to those controls
99
+ 3. the simulation reads them in its step with `input(playerId)`
100
+ 4. you are not trying to send per-frame input through store actions
101
+ 5. the dev log shows no `AJ_INPUT_INVALID` diagnostic
103
102
 
104
103
  ### Store actions do nothing
105
104
 
106
105
  Check:
107
106
 
108
- 1. actions are dispatched via `useActions()`
107
+ 1. actions are dispatched via `gameStore.actions` and the store is declared in `defineAirJamGame({ stores })`
109
108
  2. payloads are plain serializable objects
110
109
  3. your controller is connected before dispatching
111
110
  4. identity-dependent actions use `ctx.actorId` on the host side
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  # Unified Dev Logs
4
2
 
5
3
  Air Jam has one canonical local observability stream for development:
@@ -1,8 +1,6 @@
1
-
2
-
3
1
  # Game Ideas for Air Jam
4
2
 
5
- A collection of game concepts that leverage Air Jam's unique architecture: **High-Frequency Input Streams** (Socket.IO) + **Reliable Shared State** (AirJam Store).
3
+ A collection of game concepts that leverage Air Jam's unique architecture: **High-Frequency Input Streams** (declared controls) + **Reliable Shared State** (AirJam Store).
6
4
 
7
5
  ---
8
6
 
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  # Introduction
4
2
 
5
3
  Air Jam is an open **AI-native framework for multiplayer games controlled by
@@ -10,7 +8,7 @@ input, state, and release model.
10
8
  ## Key Features
11
9
 
12
10
  - **Zero App Download**: Players join by scanning a QR code—no app store required
13
- - **Instant Multiplayer**: Seamlessly connect up to 8 smartphones as controllers
11
+ - **Instant Multiplayer**: Connect smartphones up to the game’s declared player capacity
14
12
  - **Developer Friendly**: Built with modern web technologies (React, TypeScript)
15
13
  - **AI-Native By Design**: Humans and agents share explicit contracts for runtime, input, logs, and release workflows
16
14
  - **Type Safe**: End-to-end type safety with Zod schema validation
@@ -19,7 +17,6 @@ input, state, and release model.
19
17
 
20
18
  ## How It Works
21
19
 
22
-
23
20
  <HowItWorksDiagram />
24
21
 
25
22
  ## Quick Start
@@ -33,7 +30,10 @@ pnpm add @air-jam/sdk
33
30
  ### 2. Wrap Your App
34
31
 
35
32
  ```tsx filename="src/app.tsx"
36
- import { airjam } from "./airjam.config";
33
+ import { createAirJamApp, env } from "@air-jam/sdk";
34
+ import { airjam as game } from "./airjam.config";
35
+
36
+ const airjam = createAirJamApp(game, { runtime: env.vite(import.meta.env) });
37
37
 
38
38
  export const App = () => (
39
39
  <Routes>
@@ -64,19 +64,52 @@ export const App = () => (
64
64
  );
65
65
  ```
66
66
 
67
- ```tsx filename="src/airjam.config.ts"
68
- import { createAirJamApp, env } from "@air-jam/sdk";
69
- import { z } from "zod";
67
+ ```ts filename="src/airjam.config.ts"
68
+ import { defineAirJamGame } from "@air-jam/sdk/core";
69
+ import {
70
+ axis,
71
+ button,
72
+ defineAirJamInput,
73
+ defineAirJamSimulation,
74
+ type AirJamInputValues,
75
+ } from "@air-jam/sdk/core";
76
+
77
+ export const gameInput = defineAirJamInput({
78
+ direction: axis(),
79
+ fire: button("pressed"),
80
+ });
70
81
 
71
- const gameInputSchema = z.object({
72
- direction: z.number().min(-1).max(1),
73
- action: z.boolean(),
82
+ const simulation = defineAirJamSimulation<
83
+ World,
84
+ AirJamInputValues<typeof gameInput>
85
+ >({
86
+ stepMs: 1000 / 60,
87
+ create: () => createWorld(),
88
+ step: (world, { input, players, dtSeconds }) => {
89
+ for (const player of players) {
90
+ const { direction, fire } = input(player.id);
91
+ movePaddle(world, player.id, direction * SPEED * dtSeconds);
92
+ if (fire) fireLaser(world, player.id);
93
+ }
94
+ },
74
95
  });
75
96
 
76
- export const airjam = createAirJamApp({
77
- runtime: env.vite(import.meta.env),
97
+ export const airjam = defineAirJamGame({
98
+ metadata: {
99
+ slug: "space-game",
100
+ name: "Space Game",
101
+ tagline: "Fly together and defend the fleet.",
102
+ category: "arcade",
103
+ minPlayers: 1,
104
+ maxPlayers: 4,
105
+ inputModalities: ["buttons", "touch"],
106
+ supportedSdkRange: "^1.0.0",
107
+ maintainer: { name: "Air Jam" },
108
+ version: 1,
109
+ },
78
110
  controllerPath: "/controller",
79
- input: { schema: gameInputSchema },
111
+ simulation,
112
+ input: gameInput,
80
113
  });
81
114
  ```
82
115
 
@@ -90,15 +123,7 @@ import { useAirJamHost } from "@air-jam/sdk";
90
123
 
91
124
  const HostView = () => {
92
125
  const host = useAirJamHost();
93
-
94
- // In your game loop (e.g., useFrame or requestAnimationFrame):
95
- // host.players.forEach(p => {
96
- // const input = host.getInput(p.id);
97
- // if (input) {
98
- // player.y += input.direction * SPEED;
99
- // if (input.action) fireLaser(p.id);
100
- // }
101
- // });
126
+ // The simulation moves the game; this view draws it with useSimulationFrame.
102
127
 
103
128
  return (
104
129
  <div className="relative min-h-screen bg-black text-white">
@@ -128,41 +153,33 @@ The path below also matches the current starter template layout.
128
153
  If your project uses a different file shape, keep the same ownership boundary even if the filename changes.
129
154
 
130
155
  ```tsx filename="src/controller/index.tsx"
131
- import {
132
- useAirJamController,
133
- useControllerTick,
134
- useInputWriter,
135
- } from "@air-jam/sdk";
136
- import { useRef } from "react";
137
-
138
- const ControllerView = () => {
139
- const controller = useAirJamController();
140
- const writeInput = useInputWriter();
141
- const directionRef = useRef(0);
142
-
143
- useControllerTick(
144
- () => {
145
- writeInput({
146
- direction: directionRef.current,
147
- action: false,
148
- });
149
- },
150
- {
151
- enabled:
152
- controller.connectionStatus === "connected" &&
153
- controller.runtimeState === "playing",
154
- intervalMs: 16,
155
- },
156
- );
157
- };
156
+ import { AxisButton, ControlButton } from "@air-jam/sdk/ui";
157
+ import { gameInput } from "../airjam.config";
158
+
159
+ const ControllerView = () => (
160
+ <div className="grid h-full grid-cols-2 gap-3 p-3">
161
+ <AxisButton control={gameInput.direction} value={-1}>
162
+ Up
163
+ </AxisButton>
164
+ <AxisButton control={gameInput.direction} value={1}>
165
+ Down
166
+ </AxisButton>
167
+ <ControlButton control={gameInput.fire} className="col-span-2">
168
+ Fire
169
+ </ControlButton>
170
+ </div>
171
+ );
158
172
  ```
159
173
 
174
+ The SDK's phone controls fill the declared controls and send them; the
175
+ controller runs no send loop.
176
+
160
177
  ## Canonical Architecture: Three Lanes
161
178
 
162
179
  Use one lane per concern:
163
180
 
164
- 1. **Input lane**: `useControllerTick` + `useInputWriter` (controller), `getInput` / `useGetInput` (host).
165
- 2. **State lane**: `createAirJamStore` with host-owned actions and `useActions()` dispatch.
181
+ 1. **Input lane**: controls declared with `defineAirJamInput`, filled by the SDK's phone controls, read in simulation steps with `input(playerId)`.
182
+ 2. **State lane**: `createAirJamStore` with host-owned actions, dispatched through `store.actions`.
166
183
  3. **Signal lane**: `sendSignal` / system commands for out-of-band UX and runtime commands.
167
184
 
168
185
  <Callout variant="info" title="Tip">
@@ -174,10 +191,10 @@ Avoid cross-lane misuse:
174
191
 
175
192
  1. Don’t stream per-frame movement through store actions.
176
193
  2. Don’t encode authoritative gameplay state in signals.
177
- 3. Don’t call `state.actions.*`; use `useActions()` only.
194
+ 3. Don’t call `state.actions.*`; dispatch through `gameStore.actions`.
178
195
 
179
196
  ## Next Steps
180
197
 
181
198
  - [Architecture](/docs/how-it-works/architecture) - Understand the system design
182
199
  - [Hooks Reference](/docs/sdk/hooks) - Complete API documentation
183
- - [Input System](/docs/sdk/input-system) - Learn about input behavior and validation
200
+ - [Input System](/docs/sdk/input-system) - Declare controls and read them each step