@air-jam/cli 0.0.0-stage → 1.0.0-beta.1

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 (127) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +273 -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/auth-profile.d.ts +5 -0
  8. package/dist/auth-profile.js +7 -0
  9. package/dist/auth-profile.js.map +1 -0
  10. package/dist/auth-sessions.d.ts +5 -0
  11. package/dist/auth-sessions.js +7 -0
  12. package/dist/auth-sessions.js.map +1 -0
  13. package/dist/chunk-7D4AYBAV.js +64 -0
  14. package/dist/chunk-7D4AYBAV.js.map +1 -0
  15. package/dist/chunk-J5MAU4QZ.js +102 -0
  16. package/dist/chunk-J5MAU4QZ.js.map +1 -0
  17. package/dist/chunk-LH7UO57C.js +23 -0
  18. package/dist/chunk-LH7UO57C.js.map +1 -0
  19. package/dist/chunk-N7AI7HZK.js +529 -0
  20. package/dist/chunk-N7AI7HZK.js.map +1 -0
  21. package/dist/chunk-PKTLVQXZ.js +82 -0
  22. package/dist/chunk-PKTLVQXZ.js.map +1 -0
  23. package/dist/chunk-SQE4NPZP.js +31 -0
  24. package/dist/chunk-SQE4NPZP.js.map +1 -0
  25. package/dist/chunk-U6V3HEBB.js +939 -0
  26. package/dist/chunk-U6V3HEBB.js.map +1 -0
  27. package/dist/chunk-VEHNFPEO.js +224 -0
  28. package/dist/chunk-VEHNFPEO.js.map +1 -0
  29. package/dist/development.d.ts +102 -0
  30. package/dist/development.js +33 -0
  31. package/dist/development.js.map +1 -0
  32. package/dist/documentation.d.ts +27 -0
  33. package/dist/documentation.js +7 -0
  34. package/dist/documentation.js.map +1 -0
  35. package/dist/game-analytics.d.ts +5 -0
  36. package/dist/game-analytics.js +7 -0
  37. package/dist/game-analytics.js.map +1 -0
  38. package/dist/game-app-id.d.ts +5 -0
  39. package/dist/game-app-id.js +7 -0
  40. package/dist/game-app-id.js.map +1 -0
  41. package/dist/game-media.d.ts +5 -0
  42. package/dist/game-media.js +7 -0
  43. package/dist/game-media.js.map +1 -0
  44. package/dist/index.d.ts +1 -0
  45. package/dist/index.js +2468 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/scaffold.d.ts +6 -0
  48. package/dist/scaffold.js +20 -0
  49. package/dist/scaffold.js.map +1 -0
  50. package/package.json +82 -3
  51. package/runtime/local-network.d.mts +6 -0
  52. package/runtime/local-network.mjs +9 -0
  53. package/runtime/public-assets.mjs +62 -0
  54. package/runtime/source-fence.mjs +182 -0
  55. package/runtime/vite-config.d.mts +43 -0
  56. package/runtime/vite-config.mjs +134 -0
  57. package/runtime/vite-dev.mjs +18 -0
  58. package/runtime/vite-https.d.mts +11 -0
  59. package/runtime/vite-https.mjs +40 -0
  60. package/template-assets/bootstrap/.claude/launch.json +12 -0
  61. package/template-assets/bootstrap/AGENTS.md +290 -0
  62. package/template-assets/bootstrap/CLAUDE.md +55 -0
  63. package/template-assets/bootstrap/_gitignore +6 -0
  64. package/template-assets/bootstrap/skills/airjam-docs-workflow/SKILL.md +49 -0
  65. package/template-assets/bootstrap/skills/airjam-mcp/SKILL.md +100 -0
  66. package/template-assets/bootstrap/skills/canvas-2d-gameplay/SKILL.md +47 -0
  67. package/template-assets/bootstrap/skills/controller-ui/SKILL.md +71 -0
  68. package/template-assets/bootstrap/skills/debug-and-test/SKILL.md +72 -0
  69. package/template-assets/bootstrap/skills/game-architecture/SKILL.md +102 -0
  70. package/template-assets/bootstrap/skills/game-state-and-rendering/SKILL.md +44 -0
  71. package/template-assets/bootstrap/skills/host-surface/SKILL.md +52 -0
  72. package/template-assets/bootstrap/skills/index.md +36 -0
  73. package/template-assets/bootstrap/skills/prefab-authoring/SKILL.md +58 -0
  74. package/template-assets/bootstrap/skills/r3f-3d-scene/SKILL.md +61 -0
  75. package/template-assets/documentation/for-agents/controller-ui/page.mdx +99 -0
  76. package/template-assets/documentation/for-agents/page.mdx +120 -0
  77. package/template-assets/documentation/for-agents/project-structure/page.mdx +170 -0
  78. package/template-assets/documentation/for-agents/state-and-rendering/page.mdx +77 -0
  79. package/template-assets/documentation/for-agents/supported-agents/page.mdx +18 -0
  80. package/template-assets/documentation/getting-started/debugging/page.mdx +164 -0
  81. package/template-assets/documentation/getting-started/dev-logs/page.mdx +169 -0
  82. package/template-assets/documentation/getting-started/game-ideas/page.mdx +114 -0
  83. package/template-assets/documentation/getting-started/introduction/page.mdx +200 -0
  84. package/template-assets/documentation/getting-started/migrating-legacy-games/page.mdx +673 -0
  85. package/template-assets/documentation/getting-started/quick-start/page.mdx +310 -0
  86. package/template-assets/documentation/how-it-works/architecture/page.mdx +230 -0
  87. package/template-assets/documentation/how-it-works/host-system/page.mdx +270 -0
  88. package/template-assets/documentation/manifest.json +500 -0
  89. package/template-assets/documentation/sdk/assets-and-theme/page.mdx +185 -0
  90. package/template-assets/documentation/sdk/hooks/page.mdx +435 -0
  91. package/template-assets/documentation/sdk/input-system/page.mdx +240 -0
  92. package/template-assets/documentation/sdk/networked-state/page.mdx +295 -0
  93. package/template-assets/documentation/sdk/settings/page.mdx +155 -0
  94. package/template-assets/documentation/sdk/ui-components/page.mdx +268 -0
  95. package/template-assets/managed/.airjam/ai-pack.json +209 -0
  96. package/template-assets/managed/docs/airjam/agent-gold-path.md +115 -0
  97. package/template-assets/managed/docs/airjam/agent-mcp.md +179 -0
  98. package/template-assets/managed/docs/airjam/canvas-2d-gameplay.md +82 -0
  99. package/template-assets/managed/docs/airjam/composition-shell-contract.md +87 -0
  100. package/template-assets/managed/docs/airjam/debug-and-testing.md +104 -0
  101. package/template-assets/managed/docs/airjam/development-loop.md +51 -0
  102. package/template-assets/managed/docs/airjam/docs-index.md +64 -0
  103. package/template-assets/managed/docs/airjam/generated/architecture.md +223 -0
  104. package/template-assets/managed/docs/airjam/generated/assets-and-theme.md +188 -0
  105. package/template-assets/managed/docs/airjam/generated/controller-ui.md +102 -0
  106. package/template-assets/managed/docs/airjam/generated/debugging-and-logs.md +165 -0
  107. package/template-assets/managed/docs/airjam/generated/for-agents.md +123 -0
  108. package/template-assets/managed/docs/airjam/generated/game-ideas.md +107 -0
  109. package/template-assets/managed/docs/airjam/generated/host-system.md +261 -0
  110. package/template-assets/managed/docs/airjam/generated/input-system.md +241 -0
  111. package/template-assets/managed/docs/airjam/generated/introduction.md +195 -0
  112. package/template-assets/managed/docs/airjam/generated/migrating-legacy-games.md +674 -0
  113. package/template-assets/managed/docs/airjam/generated/networked-state.md +298 -0
  114. package/template-assets/managed/docs/airjam/generated/project-structure.md +171 -0
  115. package/template-assets/managed/docs/airjam/generated/quick-start.md +311 -0
  116. package/template-assets/managed/docs/airjam/generated/sdk-hooks.md +430 -0
  117. package/template-assets/managed/docs/airjam/generated/settings.md +158 -0
  118. package/template-assets/managed/docs/airjam/generated/state-and-rendering.md +80 -0
  119. package/template-assets/managed/docs/airjam/generated/supported-agents.md +21 -0
  120. package/template-assets/managed/docs/airjam/generated/ui-components.md +265 -0
  121. package/template-assets/managed/docs/airjam/generated/unified-dev-logs.md +170 -0
  122. package/template-assets/managed/docs/airjam/iconography.md +55 -0
  123. package/template-assets/managed/docs/airjam/prefab-authoring.md +212 -0
  124. package/template-assets/managed/docs/airjam/preview-controllers.md +129 -0
  125. package/template-assets/managed/docs/airjam/r3f-3d-scene.md +163 -0
  126. package/template-assets/managed/docs/airjam/state-lanes-cookbook.md +101 -0
  127. package/template-assets/managed/docs/airjam/visual-system.md +103 -0
@@ -0,0 +1,673 @@
1
+ # Migrating Legacy Games
2
+
3
+ This guide is for older Air Jam games that still use the pre-v1 app shape.
4
+
5
+ If you are starting fresh, use [Quick Start](/docs/getting-started/quick-start) instead.
6
+
7
+ <Callout variant="info" title="Tip">
8
+ If you are using an LLM to help with the migration, copy this guide into the
9
+ conversation first. Codex or Claude are the best fit for this kind of
10
+ repo-wide migration work.
11
+ </Callout>
12
+
13
+ ## Node.js Minimum
14
+
15
+ Air Jam 1.0 authoring requires Node.js 22.15 or newer for devtools, the CLI and MCP,
16
+ create-airjam and generated projects. The declaration loader uses synchronous
17
+ module hooks to enforce its framework-free boundary through imports, `require`
18
+ and `createRequire`. The SDK and server retain their Node.js 22.0 minimum.
19
+
20
+ ## When You Need This Guide
21
+
22
+ You are likely on the old shape if your game still has some of these patterns:
23
+
24
+ - `AirJamProvider` in `App.tsx`
25
+ - flat files like `src/host-view.tsx`, `src/controller-view.tsx`, and `src/store.ts`
26
+ - `HostShell` / `ControllerShell`
27
+ - old store actions like `joinTeam(team, playerId?)`
28
+ - controller code that calls `controller.sendInput(...)` directly in a loop
29
+
30
+ The v1 goal is not “make old code barely compile”.
31
+
32
+ The goal is:
33
+
34
+ 1. move to the canonical v1 runtime shape
35
+ 2. keep boundaries clean between runtime, replicated state, and game logic
36
+ 3. remove old shell/provider assumptions instead of carrying them forward
37
+
38
+ ## Prerelease Local Migration Note
39
+
40
+ If you are migrating an old game against a local unreleased Air Jam workspace before packages are published, keep the setup split clean:
41
+
42
+ 1. install `@air-jam/sdk` from the local package or a local tarball
43
+ 2. do not depend on `@air-jam/server` through a direct `file:` package reference if it still carries monorepo-only `workspace:*` internals
44
+ 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
45
+
46
+ This is only a prerelease migration concern. The release goal is published packages or tarball validation, not permanent cross-repo path coupling.
47
+
48
+ ## The Target Shape
49
+
50
+ The current canonical app shape looks like this:
51
+
52
+ ```text
53
+ src/
54
+ airjam.config.ts
55
+ app.tsx
56
+ routes/
57
+ host-view.tsx
58
+ controller-view.tsx
59
+ game/
60
+ input.ts
61
+ store.ts
62
+ ...
63
+ ```
64
+
65
+ Not every migrated game must match that exact folder tree.
66
+
67
+ What matters is the boundary model:
68
+
69
+ 1. `defineAirJamGame(...)` declares the game in core; `createAirJamApp(game, options)` binds its browser runtime
70
+ 2. `app.tsx` owns route-level `<airjam.Host>` and `<airjam.Controller>` wrappers
71
+ 3. host/controller runtime owner hooks mount only in those route entry files
72
+ 4. replicated state uses the current `createAirJamStore` action contract
73
+ 5. host-local simulation stays separate from replicated store state
74
+
75
+ ## Migration Checklist
76
+
77
+ Use this order. Do not jump around randomly.
78
+
79
+ 1. Replace `AirJamProvider` bootstrap with `createAirJamApp`
80
+ 2. Move host/controller ownership into route wrappers
81
+ 3. Migrate replicated store actions to `(ctx, payload)`
82
+ 4. Remove `HostShell` / `ControllerShell`
83
+ 5. Decide what belongs in replicated store state versus host-local simulation
84
+ 6. Modernize controller input only if the game actually has continuous input
85
+ 7. Clean up old shell/theme workarounds and dead legacy branches
86
+ 8. Re-run local validation before changing game behavior
87
+
88
+ ## Step 1: Move Runtime Setup Into `airjam.config.ts`
89
+
90
+ Old shape:
91
+
92
+ ```tsx filename="src/App.tsx"
93
+ import { AirJamProvider } from "@air-jam/sdk";
94
+ import { gameInputSchema } from "./types";
95
+
96
+ export function App() {
97
+ return (
98
+ <AirJamProvider
99
+ serverUrl={import.meta.env.VITE_AIR_JAM_SERVER_URL}
100
+ publicHost={import.meta.env.VITE_AIR_JAM_PUBLIC_HOST}
101
+ input={{
102
+ schema: gameInputSchema,
103
+ latch: {
104
+ booleanFields: ["action"],
105
+ },
106
+ }}
107
+ >
108
+ ...
109
+ </AirJamProvider>
110
+ );
111
+ }
112
+ ```
113
+
114
+ Target shape:
115
+
116
+ ```ts filename="src/airjam.config.ts"
117
+ import { defineAirJamGame } from "@air-jam/sdk/core";
118
+ import { gameInput } from "./game/input";
119
+ import { simulation } from "./game/simulation";
120
+
121
+ export const airjam = defineAirJamGame({
122
+ metadata: {
123
+ slug: "space-game",
124
+ name: "Space Game",
125
+ tagline: "Fly together and defend the fleet.",
126
+ category: "arcade",
127
+ minPlayers: 1,
128
+ maxPlayers: 4,
129
+ inputModalities: ["buttons", "touch"],
130
+ supportedSdkRange: "^1.0.0",
131
+ maintainer: { name: "Air Jam" },
132
+ version: 1,
133
+ },
134
+ controllerPath: "/controller",
135
+ simulation,
136
+ input: gameInput,
137
+ });
138
+ ```
139
+
140
+ This removes runtime wiring noise from your app tree and gives you one canonical config surface.
141
+
142
+ ## Step 2: Move Host And Controller Ownership Into `app.tsx`
143
+
144
+ Old shape:
145
+
146
+ ```tsx filename="src/App.tsx"
147
+ <Routes>
148
+ <Route path="/" element={<HostView />} />
149
+ <Route path="/controller" element={<ControllerView />} />
150
+ </Routes>
151
+ ```
152
+
153
+ Target shape:
154
+
155
+ ```tsx filename="src/app.tsx"
156
+ import { Route, Routes } from "react-router-dom";
157
+ import { createAirJamApp, env } from "@air-jam/sdk";
158
+ import { airjam as game } from "./airjam.config";
159
+
160
+ const airjam = createAirJamApp(game, { runtime: env.vite(import.meta.env) });
161
+
162
+ export function App() {
163
+ return (
164
+ <Routes>
165
+ <Route
166
+ path="/"
167
+ element={
168
+ <airjam.Host>
169
+ <HostView />
170
+ </airjam.Host>
171
+ }
172
+ />
173
+ <Route
174
+ path={airjam.paths.controller}
175
+ element={
176
+ <airjam.Controller>
177
+ <ControllerView />
178
+ </airjam.Controller>
179
+ }
180
+ />
181
+ </Routes>
182
+ );
183
+ }
184
+ ```
185
+
186
+ This is the runtime boundary. Keep it explicit.
187
+
188
+ ## Step 3: Fix Store Actions First
189
+
190
+ This is the most important migration after bootstrap.
191
+
192
+ Old actions often looked like this:
193
+
194
+ ```tsx filename="src/store.ts"
195
+ actions: {
196
+ joinTeam: (team, playerId) => {
197
+ if (!playerId) return;
198
+ ...
199
+ },
200
+ setReady: (ready, playerId) => {
201
+ if (!playerId) return;
202
+ ...
203
+ },
204
+ }
205
+ ```
206
+
207
+ The current action model is:
208
+
209
+ The `src/game/stores/game-store.ts` path below is a starter-friendly example.
210
+ If your project already uses a different store module layout, keep the same action contract and ownership rules while migrating.
211
+
212
+ ```tsx filename="src/game/stores/game-store.ts"
213
+ actions: {
214
+ joinTeam: ({ actorId, connectedPlayerIds }, { team }) =>
215
+ set((state) => {
216
+ if (!actorId) return state;
217
+ ...
218
+ }),
219
+
220
+ setReady: ({ actorId }, { ready }) =>
221
+ set((state) => {
222
+ if (!actorId) return state;
223
+ ...
224
+ }),
225
+ }
226
+ ```
227
+
228
+ Controller-side dispatch should always look like:
229
+
230
+ ```tsx filename="src/routes/controller-view.tsx"
231
+ gameStore.actions.joinTeam({ team: "team1" });
232
+ gameStore.actions.setReady({ ready: true });
233
+ ```
234
+
235
+ Do not keep trailing `playerId` arguments around.
236
+
237
+ For the full store model, see [Networked State](/docs/sdk/networked-state).
238
+
239
+ ## Step 4: Remove `HostShell` And `ControllerShell`
240
+
241
+ Treat the old shell components as migration targets, not as permanent app structure.
242
+
243
+ Why:
244
+
245
+ 1. they hide app-owned layout inside generic wrappers
246
+ 2. they can leak presentational concerns into the app
247
+ 3. they make theme and layout cleanup harder than it should be
248
+
249
+ Use app-owned layout instead.
250
+
251
+ If you still need a narrow layout helper, use one intentionally, for example `SurfaceViewport` for shared full-screen controller or host UI scaling.
252
+
253
+ Do not rebuild your app around a generic shell.
254
+
255
+ ## Step 5: Choose The Right Migration Branch
256
+
257
+ Not every legacy game should be migrated the same way.
258
+
259
+ ### Branch A: Flat Legacy App
260
+
261
+ If your app still looks like:
262
+
263
+ ```text
264
+ src/
265
+ App.tsx
266
+ host-view.tsx
267
+ controller-view.tsx
268
+ store.ts
269
+ types.ts
270
+ ```
271
+
272
+ then do the full cleanup:
273
+
274
+ 1. add `src/airjam.config.ts`
275
+ 2. rename to `src/app.tsx`
276
+ 3. move runtime entry files to `src/routes/`
277
+ 4. move input/store/domain files into `src/game/`
278
+
279
+ This is the cleanest migration for older minimal apps.
280
+
281
+ ### Branch B: Already Modular Legacy App
282
+
283
+ If your app already has good structure like:
284
+
285
+ ```text
286
+ src/
287
+ features/
288
+ store/
289
+ hooks/
290
+ components/
291
+ ```
292
+
293
+ then do not force a cosmetic rewrite just to match a template.
294
+
295
+ Instead:
296
+
297
+ 1. modernize bootstrap and route ownership
298
+ 2. modernize the store action contract
299
+ 3. keep healthy feature/domain modules mostly where they are
300
+
301
+ The migration guide is about boundaries, not folder cosplay.
302
+
303
+ ### Branch C: Host-Simulation-Heavy App
304
+
305
+ If most of the game logic lives in a host-side hook or `useHostTick` loop, move it into a declared simulation (`defineAirJamSimulation`, declared with `defineAirJamGame({ simulation })`). `useHostTick` is removed.
306
+
307
+ 1. replicated store state owns shared, synchronized state
308
+ 2. the simulation owns timers, positions, physics and outcomes; it reads input from its step context, uses the step's `random` and game time instead of `Math.random()` and `Date.now()`, and dispatches store actions for outcomes such as scores
309
+ 3. the host view draws with `useSimulationFrame`, plays sounds and toasts from `useSimulationEvents`, and keeps media loading and draw caches
310
+ 4. what agents see moves from `useHostAgentObservation` into the simulation's `observe`
311
+
312
+ This is usually cleaner than trying to stuff the whole game loop into the replicated store, and it lets the game's tests run headless.
313
+
314
+ ## Step 6: Migrate Input Based On Input Type
315
+
316
+ Do not overgeneralize input migration.
317
+
318
+ ### Continuous Input Games
319
+
320
+ If your controller sends directional or analog-style input, declare those
321
+ controls and let the SDK's phone controls send them:
322
+
323
+ ```tsx filename="src/game/input.ts"
324
+ import { button, defineAirJamInput, stick } from "@air-jam/sdk/core";
325
+
326
+ export const gameInput = defineAirJamInput({
327
+ move: stick(),
328
+ action: button("held"),
329
+ });
330
+ ```
331
+
332
+ ```tsx filename="src/controller/index.tsx"
333
+ import { ControlButton, Stick } from "@air-jam/sdk/ui";
334
+ import { gameInput } from "../game/input";
335
+
336
+ export function ControllerView() {
337
+ return (
338
+ <div className="grid h-full grid-cols-2 gap-3 p-3">
339
+ <Stick control={gameInput.move} />
340
+ <ControlButton control={gameInput.action}>Action</ControlButton>
341
+ </div>
342
+ );
343
+ }
344
+ ```
345
+
346
+ The simulation reads them each step with `input(playerId)`. Remove the old
347
+ send loop, input writer and any timestamp field.
348
+
349
+ ### Action-Only Or Choice-Driven Games
350
+
351
+ If the controller mainly sends taps, choices, or store actions, do not add per-frame input machinery just because another game needed it.
352
+
353
+ Use the simpler model that matches your game.
354
+
355
+ For more input details, see [Input System](/docs/sdk/input-system).
356
+
357
+ ## Step 7: Replace `latch` And Input Behavior Lists
358
+
359
+ Older games configure input through `latch` or `input.behavior` lists of
360
+ `pulse`, `hold` and `latest` fields. Both are gone: each control's kind carries
361
+ its meaning. A tap-safe boolean becomes `button("pressed")`, a held boolean
362
+ `button("held")`, a sticky vector `stick({ keepDirection: true })`, and any
363
+ other number an `axis()`.
364
+
365
+ ## Step 8: Remove Legacy Workarounds
366
+
367
+ After bootstrap, shell, and action migration, remove old hacks that only existed because of the old shape.
368
+
369
+ Common examples:
370
+
371
+ 1. theme fixes that fight shell-injected classes
372
+ 2. old child-mode or shell-mode presentation branches
373
+ 3. duplicated route aliases like `/host` unless you truly still need them
374
+ 4. stale README instructions that still describe the old app shape
375
+
376
+ This step matters. A migration is not complete if the old assumptions are still quietly shaping the code.
377
+
378
+ ## Identity Rules To Recheck
379
+
380
+ During migration, be explicit about identity.
381
+
382
+ You should know:
383
+
384
+ 1. what is the Air Jam controller/session identity
385
+ 2. what is the in-game avatar or character identity
386
+ 3. which store keys use which identity
387
+
388
+ Do not leave this implicit.
389
+
390
+ This becomes especially important when:
391
+
392
+ 1. controllers are assigned to in-game characters
393
+ 2. bots exist
394
+ 3. host simulation uses different IDs than controller presence
395
+
396
+ ## Validation Checklist
397
+
398
+ Before calling a migration done, verify:
399
+
400
+ 1. host route boots cleanly with `<airjam.Host>`
401
+ 2. controller route joins cleanly with `<airjam.Controller>`
402
+ 3. store actions no longer rely on trailing `playerId` arguments
403
+ 4. no child component mounts a second runtime owner hook
404
+ 5. shell-removal cleanup is complete
405
+ 6. README and local dev commands match the migrated app shape
406
+ 7. `pnpm run typecheck`
407
+ 8. `pnpm run build`
408
+ 9. the game still behaves correctly in local host/controller play
409
+
410
+ ## Recommended Order For Real Migrations
411
+
412
+ When migrating multiple games, do them in this order:
413
+
414
+ 1. smallest flat app first
415
+ 2. host-simulation-heavy app second
416
+ 3. already-modular app third
417
+
418
+ That order usually sharpens the guide fastest:
419
+
420
+ 1. first app proves the basic recipe
421
+ 2. second app forces the harder boundary decisions
422
+ 3. third app benefits from the refined guide and should migrate more cleanly
423
+
424
+ ## From 0.9 To 1.0
425
+
426
+ Games written against the 0.9 SDK, including agent-made Studio games, move
427
+ mechanically with the mappings below. Each removal fails typecheck, so work
428
+ through the compiler errors with this section open.
429
+
430
+ ### The game is declared in core
431
+
432
+ `src/airjam.config.ts` exports only the named `airjam = defineAirJamGame(...)`
433
+ declaration from `@air-jam/sdk/core`. Move metadata into its `metadata` field;
434
+ remove the separate metadata export. Its entire import graph must stay free of
435
+ React, the SDK root, TSX and CSS. The loader names the importing file with
436
+ `AJ_DECLARATION_NOT_FRAMEWORK_FREE` when that boundary is crossed.
437
+
438
+ Move `createAirJamApp` to `app.tsx` and call
439
+ `createAirJamApp(airjam, { runtime: env.vite(import.meta.env) })`. The binding
440
+ returns `Host`, `Controller`, `paths` and `session`; game data stays on the
441
+ declaration. Passing the former options object as the first argument fails
442
+ with an error naming `defineAirJamGame` as its replacement.
443
+
444
+ Import agent helpers and their types from `@air-jam/sdk/core`. A declared
445
+ `testing` path, relative to the config, names the development module:
446
+
447
+ ```ts
448
+ import { defineAirJamTesting } from "@air-jam/devtools/testing";
449
+ import { gamePlayer } from "./player";
450
+
451
+ export const testing = defineAirJamTesting({
452
+ player: gamePlayer,
453
+ profiles: { scoring, diagnostics },
454
+ // Optional: visual: { scenarios: [...] }, using the game's declared agent.
455
+ });
456
+ ```
457
+
458
+ The declared player is offered as `model` in every profile. Remove each
459
+ profile's manually created model policy; the name is reserved and fails with
460
+ `AJ_TEST_POLICY_RESERVED` when authored. Visual packs no longer declare their
461
+ own agent. Tools read the game through `airjam.inspect_game` and its
462
+ `declaration.agent` field.
463
+
464
+ Remove capacity from runtime options. `metadata.maxPlayers` is the capacity
465
+ for both browser and headless rooms: a four-player game refuses a fifth phone.
466
+ Remove identity fields from `airjam-template.json`; it now holds only scaffold
467
+ and export flags. Regenerate template catalogs after changing declarations.
468
+
469
+ ### Stores Are Plain Objects
470
+
471
+ `createAirJamStore` moved to `@air-jam/sdk/core` and returns a store object,
472
+ not a hook. Declare every store in the app; reading an undeclared store throws
473
+ `AJ_STORE_NOT_DECLARED`.
474
+
475
+ ```ts
476
+ // 0.9
477
+ import { createAirJamStore } from "@air-jam/sdk";
478
+ export const useGameStore = createAirJamStore<GameState>((set) => ({ ... }));
479
+
480
+ // 1.0
481
+ import { createAirJamStore } from "@air-jam/sdk/core";
482
+ export const gameStore = createAirJamStore<GameState>((set) => ({ ... }));
483
+ // airjam.config.ts
484
+ defineAirJamGame({ stores: [gameStore], ... });
485
+ ```
486
+
487
+ | 0.9 | 1.0 |
488
+ | --------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
489
+ | `useGameStore((s) => s.score)` | `useAirJamStore(gameStore, (s) => s.score)` from `@air-jam/sdk` |
490
+ | `useGameStore.useActions().joinTeam(...)` | `gameStore.actions.joinTeam(...)` |
491
+ | `useGameStore.asPlayer(id)` | `gameStore.asPlayer(id)` |
492
+ | `useGameStore.getState()`, `.subscribe` | `gameStore.getState()`, `gameStore.subscribe` |
493
+ | `useGameStore.useHostActionListener(listener)` | `useHostActionListener(gameStore, listener)` from `@air-jam/sdk` |
494
+ | `useGameStore.useLiveStateRef().current` | `gameStore.getState()`, always current |
495
+ | `acceptAirJamAction`, `rejectAirJamAction`, `AirJamActionContext` and the other store types from `@air-jam/sdk` | the same names from `@air-jam/sdk/core` |
496
+ | `createAirJamStore(init, { storeDomain })` | unchanged, from `@air-jam/sdk/core` |
497
+ | `Date.now()` inside an action | `ctx.now`, the game time the action runs at |
498
+
499
+ Shells that compose runtimes themselves, such as the Arcade, pass their
500
+ stores to `AirJamHostRuntime` and `AirJamControllerRuntime` from
501
+ `@air-jam/sdk/arcade/runtime` with the `stores` prop.
502
+
503
+ ### Settings are declared
504
+
505
+ Move tunable speed, force, damage, health, duration and count constants into
506
+ `defineAirJamSettings` from `@air-jam/sdk/core`, and pass the result as the
507
+ `settings` field of `defineAirJamGame`. Keep a leaf settings module and infer
508
+ its values with `AirJamSettingsValues<typeof gameSettings>`. Delete the old
509
+ constants. Lobby choices remain store state.
510
+
511
+ Read `settings` in simulation create, step and observe contexts, and in
512
+ `AirJamActionContext<GameSettings>`. Supply the fourth simulation type parameter
513
+ for typed values. Host drawing uses `useAirJamSettings(gameSettings)`; copy any
514
+ phone display values into the store rather than reading settings on controllers.
515
+
516
+ Only settings declared `live: true` can change during a host's lifetime.
517
+ `airjam.read_game_settings` returns the current values and revision;
518
+ `airjam.update_game_settings` takes an atomic patch and `expectedRevision`.
519
+ Unknown, invalid, stale and non-live updates fail with `AJ_SETTING_UNKNOWN`,
520
+ `AJ_SETTING_INVALID`, `AJ_SETTING_STALE` and `AJ_SETTING_NOT_LIVE` respectively.
521
+ Start a new room through `airjam.start_game_run({ settings: { ... }, ... })`
522
+ for a non-live value. Input logs now require version 2, resolved initial
523
+ settings and the ordered settings events; version 1 logs must be recorded again.
524
+
525
+ See [Game Settings](/docs/sdk/settings) for declarations, host hooks and CLI
526
+ commands.
527
+
528
+ ### Assets and theme are declared
529
+
530
+ Move sound manifests into `defineAirJamAssets` from `@air-jam/sdk/core` and
531
+ pass the result as `assets` in `defineAirJamGame`. Import `SoundConfig` from
532
+ `@air-jam/sdk/core`. Declare images and other loaded files there too, using
533
+ served paths under `public/`. Read their paths
534
+ from the object and remove old manifests and path imports. Use sound `surface`
535
+ marks for host-only or controller-only audio. Remove game-owned `<AudioRuntime>`
536
+ mounts; the binding supplies it on each surface. Keep playlist and playback
537
+ logic inside that binding.
538
+
539
+ Move colours and font families into `defineAirJamTheme` and pass it as `theme`.
540
+ Map existing Tailwind names to `--airjam-color-*` and `--airjam-font-*` with
541
+ `@theme inline`. Canvas and 3D drawing read the same theme object. Remove
542
+ repeated colour and font literals; shadows and gradients remain CSS.
543
+ Inspection now fails `AJ_ASSET_MISSING` for a declared file that is absent.
544
+
545
+ See [Game Assets and Theme](/docs/sdk/assets-and-theme) for the complete shapes.
546
+
547
+ ### The SDK Owns The Loop
548
+
549
+ `useHostTick` is removed. Per-step game logic moves into a declared
550
+ simulation; components only draw it.
551
+
552
+ ```tsx
553
+ // 0.9
554
+ useHostTick({
555
+ mode: "fixed",
556
+ intervalMs: 16,
557
+ onTick: ({ deltaSeconds }) => stepGame(world, deltaSeconds),
558
+ });
559
+
560
+ // 1.0: src/game/simulation.ts
561
+ export const simulation = defineAirJamSimulation<World, GameInput, GameEvent>({
562
+ stepMs: 16,
563
+ create: ({ random }) => createWorld(random),
564
+ step: (world, { dtSeconds, input, players, random, emit }) =>
565
+ stepGame(world, dtSeconds),
566
+ observe: (world) => ({ score: world.score }),
567
+ });
568
+ // airjam.config.ts
569
+ defineAirJamGame({ simulation, ... });
570
+ ```
571
+
572
+ | 0.9 | 1.0 |
573
+ | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
574
+ | `useHostTick({ onTick })` | the simulation's `step` |
575
+ | `useHostTick({ onFrame })`, `fixedStepAlpha` | `useSimulationFrame(({ sim, alpha }) => draw(sim, alpha))` |
576
+ | `HostTickInfo.deltaSeconds`, `.tick` | the step context's `dtSeconds`, `tick` |
577
+ | `Math.random()` in game logic | the step context's `random` |
578
+ | `useHostAgentObservation({ read, capture })` | `read` becomes the simulation's `observe`; `useHostAgentCapture(draw)` draws into the supplied canvas, and its returned function runs after the game renders |
579
+ | UI state derived from the world | `useSimulationSelector((sim) => value)` |
580
+ | one-off feedback such as sounds | `emit` in `step`, `useSimulationEvents` in a component |
581
+
582
+ ### Input Is Declared
583
+
584
+ The `input: { schema, behavior }` config, controller send loops and the host's
585
+ `getInput` are removed. A game declares its controls, the SDK's phone controls
586
+ send them, and the simulation reads them each step.
587
+
588
+ ```tsx
589
+ // 0.9: src/game/contracts/input.ts
590
+ export const gameInputSchema = z.object({ direction: z.number(), fire: z.boolean() });
591
+ // airjam.config.ts
592
+ createAirJamApp({ input: { schema: gameInputSchema, behavior: { pulse: ["fire"] } }, ... });
593
+ // controller
594
+ const writeInput = useInputWriter();
595
+ useControllerTick(() => writeInput({ direction: directionRef.current, fire: fireRef.current }), {
596
+ intervalMs: 16,
597
+ });
598
+ <button onPointerDown={() => (directionRef.current = -1)} onPointerUp={() => (directionRef.current = 0)}>Up</button>
599
+ // host
600
+ const { direction, fire } = host.getInput(playerId) ?? { direction: 0, fire: false };
601
+
602
+ // 1.0: src/game/contracts/input.ts
603
+ import { axis, button, defineAirJamInput } from "@air-jam/sdk/core";
604
+ export const gameInput = defineAirJamInput({ direction: axis(), fire: button("pressed") });
605
+ // airjam.config.ts
606
+ defineAirJamGame({ input: gameInput, simulation, ... });
607
+ // controller
608
+ import { AxisButton, ControlButton } from "@air-jam/sdk/ui";
609
+ <AxisButton control={gameInput.direction} value={-1}>Up</AxisButton>
610
+ <ControlButton control={gameInput.fire}>Fire</ControlButton>
611
+ // simulation step
612
+ step: (sim, { input, players }) => {
613
+ for (const player of players) {
614
+ const { direction, fire } = input(player.id);
615
+ }
616
+ },
617
+ ```
618
+
619
+ | 0.9 | 1.0 |
620
+ | --------------------------------------------------------- | ------------------------------------------------------------------------------ |
621
+ | a boolean in `behavior.pulse` or `latch` | `button("pressed")`: true for exactly one step per press |
622
+ | any other boolean | `button("held")` |
623
+ | a number from -1 to 1 | `axis()`, sent by `AxisButton` with a `value` |
624
+ | a `{ x, y }` vector | `stick()`, or `stick({ keepDirection: true })` for a vector in `behavior.hold` |
625
+ | a timestamp or sequence field | nothing: the SDK orders input by step |
626
+ | buttons with pointer handlers writing refs | `ControlButton`, `AxisButton` and `Stick`, styled through `data-active` |
627
+ | `useInputWriter` and `useControllerTick` send loops | nothing: the controller runtime sends on change, once per frame |
628
+ | `host.getInput(playerId)` or `useGetInput` in a host tick | `input(playerId)` in the simulation's `step`; it always returns every control |
629
+ | `z.infer<typeof gameInputSchema>` | `AirJamInputValues<typeof gameInput>` from `@air-jam/sdk/core` |
630
+
631
+ Choices, menus and other taps that are not per-step play stay store actions.
632
+
633
+ ### Removed Exports
634
+
635
+ These exports are gone; use the replacement.
636
+
637
+ | Removed | Use instead |
638
+ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
639
+ | `@air-jam/sdk/arcade`, `@air-jam/sdk/arcade/bridge` | the leaf that owns the concept, such as `@air-jam/sdk/arcade/bridge/host` |
640
+ | `useHostTick`, `HostTickInfo`, `HostTickOptions`, `HostFrameInfo` | a declared simulation, above |
641
+ | `useHostAgentObservation` | the simulation's `observe` and `useHostAgentCapture` |
642
+ | `AirJamSyncedStoreHook` | `AirJamStore` from `@air-jam/sdk/core` |
643
+ | `useConnectionStatus()` | `useAirJamHost((s) => s.connectionStatus)` or `useAirJamController((s) => s.connectionStatus)` |
644
+ | `usePlayers()` | `useAirJamHost((s) => s.players)` |
645
+ | `isActiveMatchPhase`, `isEndedMatchPhase`, `isStandardMatchPhase`, `standardMatchPhases` | compare the phase directly; `toShellMatchPhase` stays |
646
+ | `AirJamErrorBoundary`, `PlatformSettingsBoundary` | nothing: `createAirJamApp` and the session runtimes mount both |
647
+ | `getEffectiveAudioVolume`, `useAudioCategoryVolume`, `mergeRoomPlatformSettingsSnapshot` | `useMusicVolume`, `usePlatformAudioSettings` |
648
+ | `parseAirJamGameMetadata` | `airJamGameMetadataSchema.safeParse` |
649
+ | `RoomCode`, `RunMode`, `SignalPayload`, `SignalType`, `ControllerStatePayload`, `ControllerUpdatePlayerProfileAck`, `AirJamActionAccepted`, `AirJamActionRejected` from `@air-jam/sdk` | the same types from `@air-jam/sdk/protocol` |
650
+ | `isInternalActionName`, `resolveControllerJoinSource`, `JoinUrlStatus` from `@air-jam/sdk/core` | internal; `JoinUrlStatus` comes from `@air-jam/sdk` |
651
+ | `buttonVariants`, `getPlayerAvatarImageUrl`, `resolvePlayerAvatarSeed` from `@air-jam/sdk/ui` | `Button`, `PlayerAvatar` |
652
+ | `useInputWriter`, `useControllerTick`, `ControllerTickInfo`, `ControllerTickOptions` | declared controls and the SDK's phone controls, above |
653
+ | `useGetInput`, the host's `getInput` | `input(playerId)` in a simulation step |
654
+
655
+ Tool and platform paths also dropped helpers only the SDK itself used:
656
+ `arcade/bridge/controller` (`AIRJAM_CONTROLLER_BRIDGE_RESPONSE`,
657
+ `AIRJAM_CONTROLLER_PRESENTATION_SYNC`, `createControllerPresentationSyncMessage`,
658
+ `parseControllerBridgeResponseMessage`), `arcade/bridge/host`
659
+ (`AIRJAM_HOST_BRIDGE_RESPONSE`), `arcade/bridge/iframe` (the bridge init and
660
+ settings sync messages), `arcade/surface` (implicit store domain resolution),
661
+ `arcade/url` (`urlBuilder`, `arcadeSurfaceRuntimeUrlParams`, which stays in
662
+ `arcade/surface`), `controller-bridge`, `preview`, `runtime-control`,
663
+ `runtime-inspection`, `agent-tooling` and `metadata`. The
664
+ [architecture guide](/docs/how-it-works/architecture) lists what each path
665
+ keeps.
666
+
667
+ ## Related Docs
668
+
669
+ 1. [Quick Start](/docs/getting-started/quick-start)
670
+ 2. [Debugging and Logs](/docs/getting-started/debugging)
671
+ 3. [Input System](/docs/sdk/input-system)
672
+ 4. [Networked State](/docs/sdk/networked-state)
673
+ 5. [Hooks](/docs/sdk/hooks)