@air-jam/cli 0.0.0-stage → 0.9.3

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 (93) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +145 -2
  3. package/bin/airjam.mjs +66 -0
  4. package/dist/ai-pack.d.ts +44 -0
  5. package/dist/ai-pack.js +15 -0
  6. package/dist/ai-pack.js.map +1 -0
  7. package/dist/chunk-A4V2N4LX.js +938 -0
  8. package/dist/chunk-A4V2N4LX.js.map +1 -0
  9. package/dist/chunk-J5MAU4QZ.js +102 -0
  10. package/dist/chunk-J5MAU4QZ.js.map +1 -0
  11. package/dist/chunk-N7AI7HZK.js +529 -0
  12. package/dist/chunk-N7AI7HZK.js.map +1 -0
  13. package/dist/development.d.ts +98 -0
  14. package/dist/development.js +33 -0
  15. package/dist/development.js.map +1 -0
  16. package/dist/documentation.d.ts +27 -0
  17. package/dist/documentation.js +7 -0
  18. package/dist/documentation.js.map +1 -0
  19. package/dist/index.d.ts +1 -0
  20. package/dist/index.js +2184 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/scaffold.d.ts +6 -0
  23. package/dist/scaffold.js +20 -0
  24. package/dist/scaffold.js.map +1 -0
  25. package/package.json +78 -3
  26. package/runtime/local-network.d.mts +8 -0
  27. package/runtime/local-network.mjs +9 -0
  28. package/runtime/vite-config.d.mts +42 -0
  29. package/runtime/vite-config.mjs +130 -0
  30. package/runtime/vite-https.d.mts +11 -0
  31. package/runtime/vite-https.mjs +41 -0
  32. package/template-assets/bootstrap/.claude/launch.json +12 -0
  33. package/template-assets/bootstrap/AGENTS.md +248 -0
  34. package/template-assets/bootstrap/CLAUDE.md +63 -0
  35. package/template-assets/bootstrap/_gitignore +6 -0
  36. package/template-assets/bootstrap/skills/airjam-docs-workflow/SKILL.md +49 -0
  37. package/template-assets/bootstrap/skills/airjam-mcp/SKILL.md +56 -0
  38. package/template-assets/bootstrap/skills/canvas-2d-gameplay/SKILL.md +47 -0
  39. package/template-assets/bootstrap/skills/controller-ui/SKILL.md +69 -0
  40. package/template-assets/bootstrap/skills/debug-and-test/SKILL.md +72 -0
  41. package/template-assets/bootstrap/skills/game-architecture/SKILL.md +58 -0
  42. package/template-assets/bootstrap/skills/game-state-and-rendering/SKILL.md +44 -0
  43. package/template-assets/bootstrap/skills/host-surface/SKILL.md +52 -0
  44. package/template-assets/bootstrap/skills/index.md +36 -0
  45. package/template-assets/bootstrap/skills/prefab-authoring/SKILL.md +48 -0
  46. package/template-assets/bootstrap/skills/r3f-3d-scene/SKILL.md +51 -0
  47. package/template-assets/documentation/for-agents/controller-ui/page.mdx +60 -0
  48. package/template-assets/documentation/for-agents/page.mdx +98 -0
  49. package/template-assets/documentation/for-agents/project-structure/page.mdx +172 -0
  50. package/template-assets/documentation/for-agents/state-and-rendering/page.mdx +79 -0
  51. package/template-assets/documentation/getting-started/debugging/page.mdx +165 -0
  52. package/template-assets/documentation/getting-started/dev-logs/page.mdx +171 -0
  53. package/template-assets/documentation/getting-started/game-ideas/page.mdx +116 -0
  54. package/template-assets/documentation/getting-started/introduction/page.mdx +183 -0
  55. package/template-assets/documentation/getting-started/migrating-legacy-games/page.mdx +427 -0
  56. package/template-assets/documentation/getting-started/quick-start/page.mdx +333 -0
  57. package/template-assets/documentation/how-it-works/architecture/page.mdx +189 -0
  58. package/template-assets/documentation/how-it-works/host-system/page.mdx +267 -0
  59. package/template-assets/documentation/manifest.json +430 -0
  60. package/template-assets/documentation/sdk/hooks/page.mdx +500 -0
  61. package/template-assets/documentation/sdk/input-system/page.mdx +270 -0
  62. package/template-assets/documentation/sdk/networked-state/page.mdx +213 -0
  63. package/template-assets/documentation/sdk/ui-components/page.mdx +227 -0
  64. package/template-assets/managed/.airjam/ai-pack.json +191 -0
  65. package/template-assets/managed/docs/airjam/agent-gold-path.md +67 -0
  66. package/template-assets/managed/docs/airjam/agent-mcp.md +135 -0
  67. package/template-assets/managed/docs/airjam/canvas-2d-gameplay.md +82 -0
  68. package/template-assets/managed/docs/airjam/composition-shell-contract.md +87 -0
  69. package/template-assets/managed/docs/airjam/debug-and-testing.md +86 -0
  70. package/template-assets/managed/docs/airjam/development-loop.md +51 -0
  71. package/template-assets/managed/docs/airjam/docs-index.md +58 -0
  72. package/template-assets/managed/docs/airjam/generated/architecture.md +178 -0
  73. package/template-assets/managed/docs/airjam/generated/controller-ui.md +61 -0
  74. package/template-assets/managed/docs/airjam/generated/debugging-and-logs.md +164 -0
  75. package/template-assets/managed/docs/airjam/generated/for-agents.md +99 -0
  76. package/template-assets/managed/docs/airjam/generated/game-ideas.md +107 -0
  77. package/template-assets/managed/docs/airjam/generated/host-system.md +251 -0
  78. package/template-assets/managed/docs/airjam/generated/input-system.md +260 -0
  79. package/template-assets/managed/docs/airjam/generated/introduction.md +175 -0
  80. package/template-assets/managed/docs/airjam/generated/migrating-legacy-games.md +426 -0
  81. package/template-assets/managed/docs/airjam/generated/networked-state.md +214 -0
  82. package/template-assets/managed/docs/airjam/generated/project-structure.md +171 -0
  83. package/template-assets/managed/docs/airjam/generated/quick-start.md +334 -0
  84. package/template-assets/managed/docs/airjam/generated/sdk-hooks.md +490 -0
  85. package/template-assets/managed/docs/airjam/generated/state-and-rendering.md +80 -0
  86. package/template-assets/managed/docs/airjam/generated/ui-components.md +222 -0
  87. package/template-assets/managed/docs/airjam/generated/unified-dev-logs.md +170 -0
  88. package/template-assets/managed/docs/airjam/iconography.md +55 -0
  89. package/template-assets/managed/docs/airjam/prefab-authoring.md +112 -0
  90. package/template-assets/managed/docs/airjam/preview-controllers.md +126 -0
  91. package/template-assets/managed/docs/airjam/r3f-3d-scene.md +97 -0
  92. package/template-assets/managed/docs/airjam/state-lanes-cookbook.md +106 -0
  93. package/template-assets/managed/docs/airjam/visual-system.md +103 -0
@@ -0,0 +1,183 @@
1
+
2
+
3
+ # Introduction
4
+
5
+ Air Jam is an open **AI-native framework for multiplayer games controlled by
6
+ phones**. A computer or TV acts as the host display, smartphones become the
7
+ controllers, and both humans and coding agents build against the same runtime,
8
+ input, state, and release model.
9
+
10
+ ## Key Features
11
+
12
+ - **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
14
+ - **Developer Friendly**: Built with modern web technologies (React, TypeScript)
15
+ - **AI-Native By Design**: Humans and agents share explicit contracts for runtime, input, logs, and release workflows
16
+ - **Type Safe**: End-to-end type safety with Zod schema validation
17
+ - **Performance Optimized**: Tap-safe button input with fixed tick cadence
18
+ - **Haptic Feedback**: Send vibration patterns to controllers for game events
19
+
20
+ ## How It Works
21
+
22
+
23
+ <HowItWorksDiagram />
24
+
25
+ ## Quick Start
26
+
27
+ ### 1. Install the SDK
28
+
29
+ ```bash
30
+ pnpm add @air-jam/sdk
31
+ ```
32
+
33
+ ### 2. Wrap Your App
34
+
35
+ ```tsx filename="src/app.tsx"
36
+ import { airjam } from "./airjam.config";
37
+
38
+ export const App = () => (
39
+ <Routes>
40
+ <Route
41
+ path="/"
42
+ element={
43
+ <airjam.Host
44
+ onPlayerJoin={(player) => {
45
+ console.log(`${player.label} joined!`);
46
+ }}
47
+ onPlayerLeave={(id) => {
48
+ console.log(`Player ${id} left`);
49
+ }}
50
+ >
51
+ <HostView />
52
+ </airjam.Host>
53
+ }
54
+ />
55
+ <Route
56
+ path={airjam.paths.controller}
57
+ element={
58
+ <airjam.Controller>
59
+ <ControllerView />
60
+ </airjam.Controller>
61
+ }
62
+ />
63
+ </Routes>
64
+ );
65
+ ```
66
+
67
+ ```tsx filename="src/airjam.config.ts"
68
+ import { createAirJamApp, env } from "@air-jam/sdk";
69
+ import { z } from "zod";
70
+
71
+ const gameInputSchema = z.object({
72
+ direction: z.number().min(-1).max(1),
73
+ action: z.boolean(),
74
+ });
75
+
76
+ export const airjam = createAirJamApp({
77
+ runtime: env.vite(import.meta.env),
78
+ controllerPath: "/controller",
79
+ input: { schema: gameInputSchema },
80
+ });
81
+ ```
82
+
83
+ ### 3. Create Your Host View
84
+
85
+ The path below matches the current starter template layout.
86
+ It is a good default, not a required framework filename.
87
+
88
+ ```tsx filename="src/host/index.tsx"
89
+ import { useAirJamHost } from "@air-jam/sdk";
90
+
91
+ const HostView = () => {
92
+ 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
+ // });
102
+
103
+ return (
104
+ <div className="relative min-h-screen bg-black text-white">
105
+ <header className="absolute top-0 right-0 left-0 z-10 flex items-center justify-between border-b border-white/10 bg-black/70 px-4 py-2 backdrop-blur">
106
+ <span>Room {host.roomId}</span>
107
+ <button
108
+ onClick={
109
+ host.runtimeState === "playing"
110
+ ? host.pauseRuntime
111
+ : host.resumeRuntime
112
+ }
113
+ >
114
+ {host.runtimeState === "playing" ? "Pause" : "Resume"}
115
+ </button>
116
+ </header>
117
+ <GameCanvas />
118
+ </div>
119
+ );
120
+ };
121
+ ```
122
+
123
+ Mount host ownership once at `<airjam.Host ...>`, then use `useAirJamHost()` only as a consumer hook inside that boundary.
124
+
125
+ ### 4. Create Your Controller View
126
+
127
+ The path below also matches the current starter template layout.
128
+ If your project uses a different file shape, keep the same ownership boundary even if the filename changes.
129
+
130
+ ```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
+ };
158
+ ```
159
+
160
+ ## Canonical Architecture: Three Lanes
161
+
162
+ Use one lane per concern:
163
+
164
+ 1. **Input lane**: `useControllerTick` + `useInputWriter` (controller), `getInput` / `useGetInput` (host).
165
+ 2. **State lane**: `createAirJamStore` with host-owned actions and `useActions()` dispatch.
166
+ 3. **Signal lane**: `sendSignal` / system commands for out-of-band UX and runtime commands.
167
+
168
+ <Callout variant="info" title="Tip">
169
+ Arcade does not replace this model. Arcade is an Air Jam app around another
170
+ Air Jam app, so the same lane rules still apply in embedded runtime mode.
171
+ </Callout>
172
+
173
+ Avoid cross-lane misuse:
174
+
175
+ 1. Don’t stream per-frame movement through store actions.
176
+ 2. Don’t encode authoritative gameplay state in signals.
177
+ 3. Don’t call `state.actions.*`; use `useActions()` only.
178
+
179
+ ## Next Steps
180
+
181
+ - [Architecture](/docs/how-it-works/architecture) - Understand the system design
182
+ - [Hooks Reference](/docs/sdk/hooks) - Complete API documentation
183
+ - [Input System](/docs/sdk/input-system) - Learn about input behavior and validation
@@ -0,0 +1,427 @@
1
+
2
+
3
+ # Migrating Legacy Games
4
+
5
+ This guide is for older Air Jam games that still use the pre-v1 app shape.
6
+
7
+ If you are starting fresh, use [Quick Start](/docs/getting-started/quick-start) instead.
8
+
9
+ <Callout variant="info" title="Tip">
10
+ If you are using an LLM to help with the migration, copy this guide into the
11
+ conversation first. Codex or Claude are the best fit for this kind of
12
+ repo-wide migration work.
13
+ </Callout>
14
+
15
+ ## When You Need This Guide
16
+
17
+ You are likely on the old shape if your game still has some of these patterns:
18
+
19
+ - `AirJamProvider` in `App.tsx`
20
+ - flat files like `src/host-view.tsx`, `src/controller-view.tsx`, and `src/store.ts`
21
+ - `HostShell` / `ControllerShell`
22
+ - old store actions like `joinTeam(team, playerId?)`
23
+ - controller code that calls `controller.sendInput(...)` directly in a loop
24
+
25
+ The v1 goal is not “make old code barely compile”.
26
+
27
+ The goal is:
28
+
29
+ 1. move to the canonical v1 runtime shape
30
+ 2. keep boundaries clean between runtime, replicated state, and game logic
31
+ 3. remove old shell/provider assumptions instead of carrying them forward
32
+
33
+ ## Prerelease Local Migration Note
34
+
35
+ If you are migrating an old game against a local unreleased Air Jam workspace before packages are published, keep the setup split clean:
36
+
37
+ 1. install `@air-jam/sdk` from the local package or a local tarball
38
+ 2. do not depend on `@air-jam/server` through a direct `file:` package reference if it still carries monorepo-only `workspace:*` internals
39
+ 3. for prerelease local dev, resolve `air-jam-server` from your nearby Air Jam workspace checkout or use tarballs once you are doing package validation
40
+
41
+ This is only a prerelease migration concern. The release goal is published packages or tarball validation, not permanent cross-repo path coupling.
42
+
43
+ ## The Target Shape
44
+
45
+ The current canonical app shape looks like this:
46
+
47
+ ```text
48
+ src/
49
+ airjam.config.ts
50
+ app.tsx
51
+ routes/
52
+ host-view.tsx
53
+ controller-view.tsx
54
+ game/
55
+ input.ts
56
+ store.ts
57
+ ...
58
+ ```
59
+
60
+ Not every migrated game must match that exact folder tree.
61
+
62
+ What matters is the boundary model:
63
+
64
+ 1. `createAirJamApp(...)` defines runtime and input config
65
+ 2. `app.tsx` owns route-level `<airjam.Host>` and `<airjam.Controller>` wrappers
66
+ 3. host/controller runtime owner hooks mount only in those route entry files
67
+ 4. replicated state uses the current `createAirJamStore` action contract
68
+ 5. host-local simulation stays separate from replicated store state
69
+
70
+ ## Migration Checklist
71
+
72
+ Use this order. Do not jump around randomly.
73
+
74
+ 1. Replace `AirJamProvider` bootstrap with `createAirJamApp`
75
+ 2. Move host/controller ownership into route wrappers
76
+ 3. Migrate replicated store actions to `(ctx, payload)`
77
+ 4. Remove `HostShell` / `ControllerShell`
78
+ 5. Decide what belongs in replicated store state versus host-local simulation
79
+ 6. Modernize controller input only if the game actually has continuous input
80
+ 7. Clean up old shell/theme workarounds and dead legacy branches
81
+ 8. Re-run local validation before changing game behavior
82
+
83
+ ## Step 1: Move Runtime Setup Into `airjam.config.ts`
84
+
85
+ Old shape:
86
+
87
+ ```tsx filename="src/App.tsx"
88
+ import { AirJamProvider } from "@air-jam/sdk";
89
+ import { gameInputSchema } from "./types";
90
+
91
+ export function App() {
92
+ return (
93
+ <AirJamProvider
94
+ serverUrl={import.meta.env.VITE_AIR_JAM_SERVER_URL}
95
+ publicHost={import.meta.env.VITE_AIR_JAM_PUBLIC_HOST}
96
+ input={{
97
+ schema: gameInputSchema,
98
+ latch: {
99
+ booleanFields: ["action"],
100
+ },
101
+ }}
102
+ >
103
+ ...
104
+ </AirJamProvider>
105
+ );
106
+ }
107
+ ```
108
+
109
+ Target shape:
110
+
111
+ ```tsx filename="src/airjam.config.ts"
112
+ import { createAirJamApp, env } from "@air-jam/sdk";
113
+ import { gameInputSchema } from "./game/input";
114
+
115
+ export const airjam = createAirJamApp({
116
+ runtime: env.vite(import.meta.env),
117
+ controllerPath: "/controller",
118
+ input: {
119
+ schema: gameInputSchema,
120
+ },
121
+ });
122
+ ```
123
+
124
+ This removes runtime wiring noise from your app tree and gives you one canonical config surface.
125
+
126
+ ## Step 2: Move Host And Controller Ownership Into `app.tsx`
127
+
128
+ Old shape:
129
+
130
+ ```tsx filename="src/App.tsx"
131
+ <Routes>
132
+ <Route path="/" element={<HostView />} />
133
+ <Route path="/controller" element={<ControllerView />} />
134
+ </Routes>
135
+ ```
136
+
137
+ Target shape:
138
+
139
+ ```tsx filename="src/app.tsx"
140
+ import { Route, Routes } from "react-router-dom";
141
+ import { airjam } from "./airjam.config";
142
+
143
+ export function App() {
144
+ return (
145
+ <Routes>
146
+ <Route
147
+ path="/"
148
+ element={
149
+ <airjam.Host>
150
+ <HostView />
151
+ </airjam.Host>
152
+ }
153
+ />
154
+ <Route
155
+ path={airjam.paths.controller}
156
+ element={
157
+ <airjam.Controller>
158
+ <ControllerView />
159
+ </airjam.Controller>
160
+ }
161
+ />
162
+ </Routes>
163
+ );
164
+ }
165
+ ```
166
+
167
+ This is the runtime boundary. Keep it explicit.
168
+
169
+ ## Step 3: Fix Store Actions First
170
+
171
+ This is the most important migration after bootstrap.
172
+
173
+ Old actions often looked like this:
174
+
175
+ ```tsx filename="src/store.ts"
176
+ actions: {
177
+ joinTeam: (team, playerId) => {
178
+ if (!playerId) return;
179
+ ...
180
+ },
181
+ setReady: (ready, playerId) => {
182
+ if (!playerId) return;
183
+ ...
184
+ },
185
+ }
186
+ ```
187
+
188
+ The current action model is:
189
+
190
+ The `src/game/stores/game-store.ts` path below is a starter-friendly example.
191
+ If your project already uses a different store module layout, keep the same action contract and ownership rules while migrating.
192
+
193
+ ```tsx filename="src/game/stores/game-store.ts"
194
+ actions: {
195
+ joinTeam: ({ actorId, connectedPlayerIds }, { team }) =>
196
+ set((state) => {
197
+ if (!actorId) return state;
198
+ ...
199
+ }),
200
+
201
+ setReady: ({ actorId }, { ready }) =>
202
+ set((state) => {
203
+ if (!actorId) return state;
204
+ ...
205
+ }),
206
+ }
207
+ ```
208
+
209
+ Controller-side dispatch should always look like:
210
+
211
+ ```tsx filename="src/routes/controller-view.tsx"
212
+ const actions = useGameStore.useActions();
213
+
214
+ actions.joinTeam({ team: "team1" });
215
+ actions.setReady({ ready: true });
216
+ ```
217
+
218
+ Do not keep trailing `playerId` arguments around.
219
+
220
+ For the full store model, see [Networked State](/docs/sdk/networked-state).
221
+
222
+ ## Step 4: Remove `HostShell` And `ControllerShell`
223
+
224
+ Treat the old shell components as migration targets, not as permanent app structure.
225
+
226
+ Why:
227
+
228
+ 1. they hide app-owned layout inside generic wrappers
229
+ 2. they can leak presentational concerns into the app
230
+ 3. they make theme and layout cleanup harder than it should be
231
+
232
+ Use app-owned layout instead.
233
+
234
+ If you still need a narrow layout helper, use one intentionally, for example `SurfaceViewport` for shared full-screen controller or host UI scaling.
235
+
236
+ Do not rebuild your app around a generic shell.
237
+
238
+ ## Step 5: Choose The Right Migration Branch
239
+
240
+ Not every legacy game should be migrated the same way.
241
+
242
+ ### Branch A: Flat Legacy App
243
+
244
+ If your app still looks like:
245
+
246
+ ```text
247
+ src/
248
+ App.tsx
249
+ host-view.tsx
250
+ controller-view.tsx
251
+ store.ts
252
+ types.ts
253
+ ```
254
+
255
+ then do the full cleanup:
256
+
257
+ 1. add `src/airjam.config.ts`
258
+ 2. rename to `src/app.tsx`
259
+ 3. move runtime entry files to `src/routes/`
260
+ 4. move input/store/domain files into `src/game/`
261
+
262
+ This is the cleanest migration for older minimal apps.
263
+
264
+ ### Branch B: Already Modular Legacy App
265
+
266
+ If your app already has good structure like:
267
+
268
+ ```text
269
+ src/
270
+ features/
271
+ store/
272
+ hooks/
273
+ components/
274
+ ```
275
+
276
+ then do not force a cosmetic rewrite just to match a template.
277
+
278
+ Instead:
279
+
280
+ 1. modernize bootstrap and route ownership
281
+ 2. modernize the store action contract
282
+ 3. keep healthy feature/domain modules mostly where they are
283
+
284
+ The migration guide is about boundaries, not folder cosplay.
285
+
286
+ ### Branch C: Host-Simulation-Heavy App
287
+
288
+ If most of the game logic lives in a host-side hook or engine module, keep that boundary explicit:
289
+
290
+ 1. replicated store state owns shared, synchronized state
291
+ 2. host-local hook/engine owns timers, refs, physics, media loading, and simulation details
292
+ 3. only the minimum necessary state should cross between them
293
+
294
+ This is usually cleaner than trying to stuff the whole game loop into the replicated store.
295
+
296
+ ## Step 6: Migrate Input Based On Input Type
297
+
298
+ Do not overgeneralize input migration.
299
+
300
+ ### Continuous Input Games
301
+
302
+ If your controller sends directional or analog-style input every frame, prefer:
303
+
304
+ 1. local refs/state
305
+ 2. `useInputWriter()`
306
+ 3. `useControllerTick(...)`
307
+
308
+ Example:
309
+
310
+ ```tsx filename="src/routes/controller-view.tsx"
311
+ import {
312
+ useAirJamController,
313
+ useControllerTick,
314
+ useInputWriter,
315
+ } from "@air-jam/sdk";
316
+ import { useRef } from "react";
317
+
318
+ export function ControllerView() {
319
+ const controller = useAirJamController();
320
+ const writeInput = useInputWriter();
321
+ const movementRef = useRef({ x: 0, y: 0 });
322
+ const actionRef = useRef(false);
323
+
324
+ useControllerTick(
325
+ () => {
326
+ writeInput({
327
+ movementX: movementRef.current.x,
328
+ movementY: movementRef.current.y,
329
+ action: actionRef.current,
330
+ });
331
+ },
332
+ {
333
+ enabled:
334
+ controller.connectionStatus === "connected" &&
335
+ controller.runtimeState === "playing",
336
+ intervalMs: 16,
337
+ },
338
+ );
339
+ }
340
+ ```
341
+
342
+ ### Action-Only Or Choice-Driven Games
343
+
344
+ If the controller mainly sends taps, choices, or store actions, do not add per-frame input machinery just because another game needed it.
345
+
346
+ Use the simpler model that matches your game.
347
+
348
+ For more input details, see [Input System](/docs/sdk/input-system).
349
+
350
+ ## Step 7: Clean Up Old `latch` Usage Carefully
351
+
352
+ Older games may still configure input through `latch`.
353
+
354
+ For most games, the right migration is smaller than you think:
355
+
356
+ - move the schema into `airjam.config.ts`
357
+ - remove `latch` entirely
358
+ - keep the default input behavior unless you have a real non-default need
359
+
360
+ Only add `input.behavior` overrides when the defaults are not enough.
361
+
362
+ ## Step 8: Remove Legacy Workarounds
363
+
364
+ After bootstrap, shell, and action migration, remove old hacks that only existed because of the old shape.
365
+
366
+ Common examples:
367
+
368
+ 1. theme fixes that fight shell-injected classes
369
+ 2. old child-mode or shell-mode presentation branches
370
+ 3. duplicated route aliases like `/host` unless you truly still need them
371
+ 4. stale README instructions that still describe the old app shape
372
+
373
+ This step matters. A migration is not complete if the old assumptions are still quietly shaping the code.
374
+
375
+ ## Identity Rules To Recheck
376
+
377
+ During migration, be explicit about identity.
378
+
379
+ You should know:
380
+
381
+ 1. what is the Air Jam controller/session identity
382
+ 2. what is the in-game avatar or character identity
383
+ 3. which store keys use which identity
384
+
385
+ Do not leave this implicit.
386
+
387
+ This becomes especially important when:
388
+
389
+ 1. controllers are assigned to in-game characters
390
+ 2. bots exist
391
+ 3. host simulation uses different IDs than controller presence
392
+
393
+ ## Validation Checklist
394
+
395
+ Before calling a migration done, verify:
396
+
397
+ 1. host route boots cleanly with `<airjam.Host>`
398
+ 2. controller route joins cleanly with `<airjam.Controller>`
399
+ 3. store actions no longer rely on trailing `playerId` arguments
400
+ 4. no child component mounts a second runtime owner hook
401
+ 5. shell-removal cleanup is complete
402
+ 6. README and local dev commands match the migrated app shape
403
+ 7. `pnpm run typecheck`
404
+ 8. `pnpm run build`
405
+ 9. the game still behaves correctly in local host/controller play
406
+
407
+ ## Recommended Order For Real Migrations
408
+
409
+ When migrating multiple games, do them in this order:
410
+
411
+ 1. smallest flat app first
412
+ 2. host-simulation-heavy app second
413
+ 3. already-modular app third
414
+
415
+ That order usually sharpens the guide fastest:
416
+
417
+ 1. first app proves the basic recipe
418
+ 2. second app forces the harder boundary decisions
419
+ 3. third app benefits from the refined guide and should migrate more cleanly
420
+
421
+ ## Related Docs
422
+
423
+ 1. [Quick Start](/docs/getting-started/quick-start)
424
+ 2. [Debugging and Logs](/docs/getting-started/debugging)
425
+ 3. [Input System](/docs/sdk/input-system)
426
+ 4. [Networked State](/docs/sdk/networked-state)
427
+ 5. [Hooks](/docs/sdk/hooks)