@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,298 @@
1
+ <!-- Generated from content/docs/sdk/networked-state/page.mdx. Do not edit directly. -->
2
+ <!-- Canonical public doc: https://airjam.io/docs/sdk/networked-state -->
3
+
4
+ # Networked State
5
+
6
+ `createAirJamStore` is the canonical shared-state lane for Air Jam:
7
+
8
+ - Host is the only source of truth.
9
+ - Controllers dispatch actions through RPC.
10
+ - Host applies actions, then state sync is broadcast back.
11
+
12
+ Use this lane for replicated game state, not per-frame input.
13
+
14
+ A store is a plain object from `@air-jam/sdk/core`, so game logic can use it
15
+ without React. Components read it with `useAirJamStore`.
16
+
17
+ ## Private per-player state
18
+
19
+ A store can declare one `privateField`: a map keyed by `controllerId`. Use it for
20
+ hidden hands, roles or shopping lists. The host keeps every entry. The room's
21
+ public state broadcast never contains this field; each phone receives only its
22
+ own entry through targeted delivery, including after a reconnect.
23
+
24
+ ```tsx
25
+ import { createAirJamStore } from "@air-jam/sdk/core";
26
+ import { useAirJamPrivateState } from "@air-jam/sdk";
27
+
28
+ type MarketState = {
29
+ round: number;
30
+ secrets: Record<string, { shoppingList: string[] }>;
31
+ actions: {};
32
+ };
33
+
34
+ const marketStore = createAirJamStore<MarketState, "secrets">(
35
+ () => ({ round: 1, secrets: {}, actions: {} }),
36
+ { privateField: "secrets" },
37
+ );
38
+
39
+ function ShoppingList() {
40
+ const ownEntry = useAirJamPrivateState(marketStore);
41
+ return <p>{ownEntry?.shoppingList.join(", ") ?? "Waiting for your list"}</p>;
42
+ }
43
+ ```
44
+
45
+ When supplying an explicit state type, name the private field as the second type
46
+ argument so the hook infers that entry even when the store has other maps.
47
+ Declare this store in the game just like a public store. The hook returns
48
+ `undefined` until this controller's entry arrives, and when the host removes it.
49
+ Host actions update the map normally. Only changed entries are sent; public-only
50
+ changes do not resend private data. Embedded controllers use the same private
51
+ lane through their MessagePort bridge.
52
+
53
+ Agent `projectSnapshot` receives the public fields and a private map containing
54
+ only the requested controller's entry (an empty map without a controller).
55
+ Host-authority `rawStores` and host restore retain the whole map. Keep private
56
+ values out of other public fields and explicitly author any end-of-round reveal.
57
+ Private state derives from the replicated store, so headless runs and replays use
58
+ the same authoritative state; it is not a separate RPC or an encrypted channel.
59
+
60
+ ## Canonical Action Model
61
+
62
+ Actions always use this shape on the host:
63
+
64
+ 1. First argument: `ctx` (identity, role, connected players and game time `now`)
65
+ 2. Second argument: `payload` (either `undefined` or one typed plain-object payload)
66
+
67
+ Dispatch always goes through the store's `actions`:
68
+
69
+ 1. `gameStore.actions.someAction()`
70
+ 2. `gameStore.actions.someAction({ ...payload })`
71
+
72
+ No trailing `controllerId` arguments and no multi-argument action payloads.
73
+ No primitive, array, or event-like root payloads.
74
+
75
+ ## Create a Store
76
+
77
+ This example uses a starter-friendly `stores/` folder shape.
78
+ The important contract is the action model and ownership boundary, not the exact filename.
79
+
80
+ ```tsx filename="src/game/stores/game-store.ts"
81
+ import { createAirJamStore, type AirJamActionContext } from "@air-jam/sdk/core";
82
+
83
+ type Team = "team1" | "team2";
84
+
85
+ interface GameState {
86
+ phase: "lobby" | "playing";
87
+ teamAssignments: Record<string, Team>;
88
+ scores: { team1: number; team2: number };
89
+ actions: {
90
+ joinTeam: (ctx: AirJamActionContext, payload: { team: Team }) => void;
91
+ scorePoint: (ctx: AirJamActionContext, payload: { team: Team }) => void;
92
+ setPhase: (
93
+ ctx: AirJamActionContext,
94
+ payload: { phase: "lobby" | "playing" },
95
+ ) => void;
96
+ };
97
+ }
98
+
99
+ export const gameStore = createAirJamStore<GameState>((set) => ({
100
+ phase: "lobby",
101
+ teamAssignments: {},
102
+ scores: { team1: 0, team2: 0 },
103
+ actions: {
104
+ joinTeam: ({ actorId }, { team }) =>
105
+ set((state) => ({
106
+ teamAssignments: {
107
+ ...state.teamAssignments,
108
+ [actorId]: team,
109
+ },
110
+ })),
111
+ scorePoint: (_ctx, { team }) =>
112
+ set((state) => ({
113
+ scores: {
114
+ ...state.scores,
115
+ [team]: state.scores[team] + 1,
116
+ },
117
+ })),
118
+ setPhase: (_ctx, { phase }) => set({ phase }),
119
+ },
120
+ }));
121
+ ```
122
+
123
+ ## Declare the Store
124
+
125
+ The host and controllers sync a store only when the app declares it:
126
+
127
+ ```ts filename="src/airjam.config.ts"
128
+ import { defineAirJamGame } from "@air-jam/sdk/core";
129
+ import { gameStore } from "./game/stores/game-store";
130
+
131
+ export const airjam = defineAirJamGame({
132
+ metadata: {
133
+ slug: "space-game",
134
+ name: "Space Game",
135
+ tagline: "Fly together and defend the fleet.",
136
+ category: "arcade",
137
+ minPlayers: 1,
138
+ maxPlayers: 4,
139
+ inputModalities: ["buttons", "touch"],
140
+ supportedSdkRange: "^1.0.0",
141
+ maintainer: { name: "Air Jam" },
142
+ version: 1,
143
+ },
144
+ controllerPath: "/controller",
145
+ stores: [gameStore],
146
+ });
147
+ ```
148
+
149
+ A declared store syncs for as long as the host or controller runs, whether or
150
+ not any component is reading it. Reading a store the app does not declare
151
+ throws `AJ_STORE_NOT_DECLARED`.
152
+
153
+ ## Use on Controller
154
+
155
+ This controller example matches the starter template surface layout.
156
+ It assumes your app has already mounted `airjam.Controller`.
157
+
158
+ ```tsx filename="src/controller/index.tsx"
159
+ import { useAirJamController, useAirJamStore } from "@air-jam/sdk";
160
+ import { gameStore } from "../game/stores/game-store";
161
+
162
+ export const ControllerView = () => {
163
+ const controller = useAirJamController();
164
+ const teamAssignments = useAirJamStore(
165
+ gameStore,
166
+ (state) => state.teamAssignments,
167
+ );
168
+
169
+ const myTeam = controller.controllerId
170
+ ? teamAssignments[controller.controllerId]
171
+ : null;
172
+
173
+ return (
174
+ <div>
175
+ <p>My team: {myTeam ?? "unassigned"}</p>
176
+ <button onClick={() => gameStore.actions.joinTeam({ team: "team1" })}>
177
+ Join Team 1
178
+ </button>
179
+ </div>
180
+ );
181
+ };
182
+ ```
183
+
184
+ ## Use on Host
185
+
186
+ This host example also matches the starter template surface layout.
187
+ It assumes your app has already mounted `airjam.Host`.
188
+
189
+ ```tsx filename="src/host/index.tsx"
190
+ import { useAirJamStore } from "@air-jam/sdk";
191
+ import { gameStore } from "../game/stores/game-store";
192
+
193
+ export const HostView = () => {
194
+ const phase = useAirJamStore(gameStore, (state) => state.phase);
195
+ const scores = useAirJamStore(gameStore, (state) => state.scores);
196
+
197
+ return (
198
+ <div>
199
+ <p>Phase: {phase}</p>
200
+ <p>
201
+ {scores.team1} - {scores.team2}
202
+ </p>
203
+ <button onClick={() => gameStore.actions.setPhase({ phase: "playing" })}>
204
+ Start
205
+ </button>
206
+ <button onClick={() => gameStore.actions.scorePoint({ team: "team1" })}>
207
+ Team 1 +1
208
+ </button>
209
+ </div>
210
+ );
211
+ };
212
+ ```
213
+
214
+ ## Action Flow
215
+
216
+ 1. Controller calls `actions.someAction()` or `actions.someAction({ ...payload })`.
217
+ 2. The phone's session sends a request on the store's channel.
218
+ 3. The room stamps it with the phone's seat, which becomes `ctx.actorId`.
219
+ 4. Host executes action handler `(ctx, payload)`, updates state and answers.
220
+ 5. Host publishes what changed; the room keeps the latest copy and sends each
221
+ phone the change, with only its own private entry.
222
+ 6. If the phone's connection drops before the answer arrives, the action
223
+ resolves `unconfirmed`: it may or may not have run, and the state the phone
224
+ mirrors shows which.
225
+
226
+ ## Rules
227
+
228
+ 1. Keep all networked mutations inside `actions`.
229
+ 2. Always dispatch via `store.actions`; do not call `store.getState().actions.*` directly.
230
+ 3. Use one payload object per action for stable evolution.
231
+ 4. Root payloads must be omitted or plain objects.
232
+ 5. `T | undefined` payload unions are not valid roots. If an action has no payload, omit it entirely.
233
+ 6. Nested values must stay RPC-serializable.
234
+ 7. Use `ctx.actorId` for identity-aware actions (team join, ownership, etc.).
235
+ 8. `ctx.actorId` is always the dispatcher identity. If host code dispatches through `store.actions`, then `ctx.actorId` is the host.
236
+ 9. Read time as `ctx.now`, never `Date.now()`: it is game time, the simulation's when the game declares one, so headless runs and replays see the same time. Store deadlines in it and let the simulation act on them; phones show what the host writes to the store, such as whole seconds left, because they cannot read the host's clock.
237
+ 10. If the host intentionally needs to run the same semantic player action as controller `X`, use `store.asPlayer("X")` instead of inventing a target payload for an actor-owned action.
238
+ 11. Keep per-frame gameplay input in declared controls, read in simulation steps, not in this store.
239
+ 12. For a host-only side effect of an action, such as a sound, use `useHostActionListener(store, listener)`.
240
+
241
+ ## Accept And Reject Examples
242
+
243
+ If a store action returns `void`, Air Jam treats it as accepted.
244
+
245
+ Return `rejectAirJamAction(...)` when the semantic action should fail with a clear machine-readable reason, and return `acceptAirJamAction(result)` when the semantic action should succeed with explicit result data:
246
+
247
+ ```tsx
248
+ import {
249
+ acceptAirJamAction,
250
+ createAirJamStore,
251
+ rejectAirJamAction,
252
+ } from "@air-jam/sdk/core";
253
+
254
+ export const gameStore = createAirJamStore((set, get) => ({
255
+ aliveByPlayerId: {} as Record<string, boolean>,
256
+ cooldownMsByPlayerId: {} as Record<string, number>,
257
+ actions: {
258
+ fire: ({ actorId }) => {
259
+ if (!actorId || get().aliveByPlayerId[actorId] === false)
260
+ return rejectAirJamAction("player_dead", "Dead players cannot fire.");
261
+ const cooldownMs = 4500;
262
+ set((state) => ({
263
+ cooldownMsByPlayerId: {
264
+ ...state.cooldownMsByPlayerId,
265
+ [actorId]: cooldownMs,
266
+ },
267
+ }));
268
+ return acceptAirJamAction({ cooldownMs });
269
+ },
270
+ },
271
+ }));
272
+ ```
273
+
274
+ Use this pattern when the caller needs a real semantic outcome.
275
+
276
+ ## Embedded Arcade Runtimes
277
+
278
+ When a game runs inside Arcade, `createAirJamStore` still works the same way in game code.
279
+
280
+ The SDK/runtime automatically resolves the correct replicated store domain from the embedded runtime context, so you should:
281
+
282
+ 1. keep normal `createAirJamStore(...)` usage in games
283
+ 2. not parse Arcade URL params in app/game code
284
+ 3. not pick custom store domains in game code just to work when embedded
285
+
286
+ ## API Summary
287
+
288
+ `createAirJamStore<T>(initializer)` from `@air-jam/sdk/core` returns a store to
289
+ declare in `defineAirJamGame({ stores })`. It provides:
290
+
291
+ 1. `actions`, dispatching with `() => Promise` or `(payloadObject) => Promise` signatures.
292
+ 2. `getState()` and `subscribe()` for logic outside React.
293
+ 3. `asPlayer(controllerId)`, a host-only dispatch map for explicit player impersonation of semantic actions.
294
+
295
+ React reads it with `useAirJamStore(store, selector)` and listens to host-applied
296
+ actions with `useHostActionListener(store, listener)`.
297
+
298
+ `T` must include an `actions` object with host handlers `(ctx, payload) => void`, where `payload` is `undefined` or a plain object.
@@ -0,0 +1,171 @@
1
+ <!-- Generated from content/docs/for-agents/project-structure/page.mdx. Do not edit directly. -->
2
+ <!-- Canonical public doc: https://airjam.io/docs/for-agents/project-structure -->
3
+
4
+ # Project Structure
5
+
6
+ Air Jam games should not grow as one large React surface.
7
+
8
+ The clean default is a boundary-first structure where host logic, controller logic, pure game rules, and framework integration do not collapse into the same modules.
9
+
10
+ ## Framework Recommendation
11
+
12
+ Move toward a structure like this:
13
+
14
+ ```text
15
+ src/
16
+ host/
17
+ controller/
18
+ game/
19
+ domain/
20
+ engine/
21
+ systems/
22
+ adapters/
23
+ ui/
24
+ debug/
25
+ shared/
26
+ ```
27
+
28
+ The exact folder names can vary slightly, but the boundaries should stay clear.
29
+
30
+ This is a framework-level recommendation about ownership boundaries, not a requirement that every Air Jam game use the exact same filenames.
31
+
32
+ ### `src/host/`
33
+
34
+ Owns host-only composition and shell behavior.
35
+
36
+ Examples:
37
+
38
+ 1. host screens
39
+ 2. room and join presentation
40
+ 3. host-facing overlays
41
+ 4. host runtime composition
42
+
43
+ ### `src/controller/`
44
+
45
+ Owns controller-only composition and touch interactions.
46
+
47
+ Examples:
48
+
49
+ 1. lobby controls
50
+ 2. gameplay controls
51
+ 3. controller status surfaces
52
+ 4. controller-specific UI hooks
53
+
54
+ ### `src/game/domain/`
55
+
56
+ Owns pure gameplay rules, math, and types.
57
+
58
+ Examples:
59
+
60
+ 1. score rules
61
+ 2. win conditions
62
+ 3. team assignment helpers
63
+ 4. deterministic state transitions
64
+
65
+ This layer should stay testable without React or rendering.
66
+
67
+ ### `src/game/engine/`
68
+
69
+ Owns runtime orchestration.
70
+
71
+ Examples:
72
+
73
+ 1. ticking
74
+ 2. lifecycle transitions
75
+ 3. update ordering
76
+ 4. system composition
77
+
78
+ ### `src/game/systems/`
79
+
80
+ Owns focused gameplay systems when the game has enough scope to justify them.
81
+
82
+ Examples:
83
+
84
+ 1. spawning
85
+ 2. combat
86
+ 3. pickups
87
+ 4. abilities
88
+ 5. scoring
89
+
90
+ ### `src/game/adapters/`
91
+
92
+ Owns integration with frameworks and runtime services.
93
+
94
+ Examples:
95
+
96
+ 1. Air Jam SDK integration
97
+ 2. R3F integration
98
+ 3. physics integration
99
+ 4. audio integration
100
+ 5. network and runtime bridges
101
+
102
+ Keep adapters thin. They should connect systems, not become the real game model.
103
+
104
+ ### `src/game/ui/`
105
+
106
+ Owns reusable game-facing UI modules.
107
+
108
+ Examples:
109
+
110
+ 1. score displays
111
+ 2. status strips
112
+ 3. overlays
113
+ 4. icon wrappers
114
+
115
+ ### `tests/`
116
+
117
+ Owns behavior-focused validation for the boundaries above.
118
+
119
+ Examples:
120
+
121
+ 1. `tests/game/domain/` for pure rule tests
122
+ 2. `tests/game/stores/` for pure state-transition tests
123
+ 3. `tests/game/engine/` for focused runtime helper tests
124
+ 4. `tests/game/adapters/` for transport-facing mapping and boundary tests
125
+ 5. `tests/game/ui/` for shared game-facing UI primitives that can be validated without full app shells
126
+
127
+ ## Starter Template Reference
128
+
129
+ The starter Pong template is the current best starter implementation of those boundaries.
130
+
131
+ It is a recommended reference, not a framework API.
132
+
133
+ Its useful starter modules look like:
134
+
135
+ 1. `src/host/index.tsx` for host surface composition
136
+ 2. `src/controller/index.tsx` for controller flow and input cadence
137
+ 3. `src/game/stores/pong-store.ts` for networked store wiring
138
+ 4. `src/game/stores/pong-store-state.ts` for pure state transitions
139
+ 5. `src/game/engine/simulation.ts` for runtime orchestration
140
+ 6. `src/game/engine/runtime-state.ts` for hot mutable runtime values
141
+ 7. `src/game/adapters/controller-signals.ts` for host-to-controller transport-facing mapping
142
+ 8. `src/game/ui/` for reusable game-facing presentation primitives shared by host and controller
143
+ 9. `src/game/prefabs/arena/` for a folder-per-prefab contract with metadata, schema, preview, and runtime composition helper
144
+ 10. `tests/game/` for the starter testing pattern that mirrors those same boundaries
145
+
146
+ If a starter module already demonstrates the boundary you need, extend it instead of introducing a second competing pattern.
147
+ If your game genuinely needs a different folder or module shape, preserve the boundary intent rather than copying Pong mechanically.
148
+
149
+ ### `src/game/debug/`
150
+
151
+ Owns debug helpers and overlays.
152
+
153
+ Keep debug features removable and out of gameplay hot paths.
154
+
155
+ ## Decision Rule
156
+
157
+ When adding code, ask:
158
+
159
+ 1. is this pure game logic
160
+ 2. is this runtime orchestration
161
+ 3. is this framework integration
162
+ 4. is this host-only or controller-only
163
+
164
+ Put the code where the answer is clearest.
165
+
166
+ ## Refactor Rule
167
+
168
+ If a new feature would force host, controller, domain, and rendering concerns into one file, fix the boundary first or split the work into:
169
+
170
+ 1. structural cleanup
171
+ 2. feature implementation