@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,265 @@
1
+ <!-- Generated from content/docs/sdk/ui-components/page.mdx. Do not edit directly. -->
2
+ <!-- Canonical public doc: https://airjam.io/docs/sdk/ui-components -->
3
+
4
+ # SDK UI Components
5
+
6
+ `@air-jam/sdk` is headless by default. `@air-jam/sdk/ui` provides optional, composable UI primitives you can drop into your own game layout.
7
+
8
+ ```tsx
9
+ import {
10
+ SurfaceViewport,
11
+ PlayerAvatar,
12
+ RoomQrCode,
13
+ VolumeControls,
14
+ Button,
15
+ Slider,
16
+ } from "@air-jam/sdk/ui";
17
+ ```
18
+
19
+ ### `RoomQrCode`
20
+
21
+ Render a room join QR code from any URL string.
22
+
23
+ ```tsx
24
+ import { RoomQrCode } from "@air-jam/sdk/ui";
25
+ import { useAirJamHost } from "@air-jam/sdk";
26
+
27
+ const LobbyQr = () => {
28
+ const host = useAirJamHost();
29
+
30
+ if (host.joinUrlStatus !== "ready") {
31
+ return null;
32
+ }
33
+
34
+ return (
35
+ <RoomQrCode
36
+ value={host.joinUrl}
37
+ size={180}
38
+ padding={1}
39
+ className="rounded-xl border border-white/20 bg-black/50 p-2"
40
+ />
41
+ );
42
+ };
43
+ ```
44
+
45
+ If you are rendering before the join URL has been resolved, prefer gating with `host.joinUrlStatus === "ready"` and show your own loading state until then.
46
+
47
+ Props:
48
+
49
+ - `value: string` (required)
50
+ - `size?: number` default `180`
51
+ - `padding?: number` default `1`
52
+ - `foregroundColor?: string` default `#111111`
53
+ - `backgroundColor?: string` default `#ffffff`
54
+ - `errorCorrectionLevel?: "L" | "M" | "Q" | "H"` default `"M"`
55
+ - `className?: string`
56
+ - `style?: CSSProperties`
57
+ - `alt?: string` default `"Room join QR code"`
58
+
59
+ Use it for:
60
+
61
+ - lobby overlays
62
+ - pause overlays
63
+ - spectator join prompts
64
+
65
+ Avoid:
66
+
67
+ - generating URLs manually when `host.joinUrl` / `controller.joinUrl` already exists
68
+
69
+ ---
70
+
71
+ ### `PlayerAvatar`
72
+
73
+ Render a stable avatar ringed by player color from `PlayerProfile`. Set `isBot` when you want the same shell to represent an AI-controlled slot with a bot icon instead of player artwork.
74
+
75
+ ```tsx
76
+ import { PlayerAvatar } from "@air-jam/sdk/ui";
77
+
78
+ <PlayerAvatar player={player} size="md" />;
79
+ <PlayerAvatar player={player} isBot size="md" />;
80
+ ```
81
+
82
+ Props:
83
+
84
+ - `player: PlayerProfile` (required)
85
+ - `isBot?: boolean` render the shared bot icon instead of the player avatar image
86
+ - `size?: "sm" | "md" | "lg"` default `"md"`
87
+ - `className?: string`
88
+
89
+ Use it for:
90
+
91
+ - team strips
92
+ - connected player rows
93
+ - controller headers
94
+
95
+ ---
96
+
97
+ ### `SurfaceViewport`
98
+
99
+ 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.
100
+
101
+ Own safe-area, orientation, and page-level UI scaling for a game surface.
102
+ It should fill the available screen while scaling the UI system proportionally, rather than letterboxing a fixed contained stage.
103
+ Internally it publishes a local `--airjam-ui-scale` into Tailwind's own spacing, text, radius, and container variables so normal Tailwind utilities keep working.
104
+
105
+ ```tsx
106
+ import { SurfaceViewport } from "@air-jam/sdk/ui";
107
+
108
+ <SurfaceViewport className="bg-zinc-950">
109
+ <ControllerView />
110
+ </SurfaceViewport>;
111
+ ```
112
+
113
+ Props:
114
+
115
+ - `orientation?: "portrait" | "landscape"`
116
+ - `children: ReactNode` (required)
117
+ - `designWidth?: number`
118
+ - `designHeight?: number`
119
+ - `uiScaleMultiplier?: number`
120
+ - `minScale?: number`
121
+ - `maxScale?: number`
122
+ - `lockOnGesture?: boolean` default `true`
123
+ - `className?: string`
124
+ - `contentClassName?: string`
125
+ - `style?: CSSProperties`
126
+
127
+ Use it for:
128
+
129
+ - controller routes that should keep a stable phone-like UI feel while still filling the screen
130
+ - host routes that should scale proportionally without collapsing into ordinary website behavior
131
+
132
+ Avoid:
133
+
134
+ - nesting multiple surface viewports
135
+ - treating it like a centered black-bar stage wrapper
136
+ - depending on arbitrary raw `px` values for most of the UI chrome when a normal Tailwind scale utility would do
137
+ - assuming native OS/browser lock is guaranteed everywhere
138
+
139
+ ---
140
+
141
+ ### `VolumeControls`
142
+
143
+ Ready-made control block for master/music/sfx sliders bound to the shared platform settings runtime.
144
+
145
+ ```tsx
146
+ import { VolumeControls } from "@air-jam/sdk/ui";
147
+
148
+ <VolumeControls className="w-full max-w-xs" compact />;
149
+ ```
150
+
151
+ Mount it below `PlatformSettingsRuntime` when you want slider changes to persist in Arcade and inherit into embedded games.
152
+
153
+ Props:
154
+
155
+ - `className?: string`
156
+ - `compact?: boolean`
157
+
158
+ Use it for:
159
+
160
+ - in-game settings overlays
161
+ - pause/settings drawers
162
+ - Arcade- or platform-owned settings panels
163
+
164
+ ---
165
+
166
+ ## Phone Controls
167
+
168
+ `ControlButton`, `AxisButton` and `Stick` bind phone UI to the game's declared
169
+ controls and send them; see [Input System](./input-system.md).
170
+
171
+ ```tsx
172
+ import { AxisButton, ControlButton, Stick } from "@air-jam/sdk/ui";
173
+
174
+ <Stick control={shipInput.move} knobClassName="bg-white/30" />
175
+ <AxisButton control={pongInput.direction} value={-1}>Up</AxisButton>
176
+ <ControlButton control={shipInput.fire} className="data-[active=true]:ring-2">
177
+ Fire
178
+ </ControlButton>
179
+ ```
180
+
181
+ Each sets `data-active` while held. `Stick` takes `directions="4-way"`,
182
+ `deadzone`, `knob`, `knobClassName`, and a function child that draws the whole
183
+ stick from `{ value, active }`.
184
+
185
+ ### `GamepadLayout`
186
+
187
+ Lays out a sideways controller like a gamepad: `left` and `right` thumb
188
+ squares of the same size, sized from the phone's short side and mirrored about
189
+ the centre, with a compact `center` column between them. `right` holds one
190
+ action, or several as a cluster around the main one. It fills its parent, so
191
+ put a header above it. See [Controller UI](https://airjam.io/docs/for-agents/controller-ui#sideways-controllers).
192
+
193
+ ```tsx
194
+ import { ControlButton, GamepadLayout, Stick } from "@air-jam/sdk/ui";
195
+
196
+ <GamepadLayout
197
+ left={<Stick control={gameInput.move} className="rounded-full bg-white/10" />}
198
+ center={<span className="text-xs uppercase">Round 1</span>}
199
+ right={
200
+ <ControlButton control={gameInput.action} className="rounded-full">
201
+ Go
202
+ </ControlButton>
203
+ }
204
+ />;
205
+ ```
206
+
207
+ ### `Button`
208
+
209
+ Styling primitive for consistent buttons.
210
+
211
+ ```tsx
212
+ import { Button } from "@air-jam/sdk/ui";
213
+
214
+ <Button variant="secondary" size="lg">
215
+ Start Match
216
+ </Button>;
217
+ ```
218
+
219
+ Common props:
220
+
221
+ - `variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link"`
222
+ - `size?: "default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg"`
223
+ - `asChild?: boolean`
224
+
225
+ ### `Slider`
226
+
227
+ Styling primitive for ranges and tuning inputs.
228
+
229
+ ```tsx
230
+ import { Slider } from "@air-jam/sdk/ui";
231
+
232
+ <Slider
233
+ value={[pointsToWin]}
234
+ min={3}
235
+ max={15}
236
+ step={1}
237
+ onValueChange={([value]) => setPointsToWin(value)}
238
+ />;
239
+ ```
240
+
241
+ ---
242
+
243
+ ### Lobby Overlay
244
+
245
+ Combine:
246
+
247
+ - `RoomQrCode` for quick join
248
+ - `PlayerAvatar` for team roster
249
+ - `Button` for start/ready actions
250
+
251
+ ### Controller Route
252
+
253
+ Combine:
254
+
255
+ - `SurfaceViewport` for shared full-screen UI scaling
256
+ - `PlayerAvatar` in a compact header
257
+ - `Button` + `Slider` for controls/options
258
+
259
+ ---
260
+
261
+ ## Anti-Patterns
262
+
263
+ - Do not build gameplay input on `Button`; bind controls with `ControlButton`, `AxisButton` and `Stick`.
264
+ - Do not rely on UI primitives for room/session lifecycle; lifecycle stays in headless SDK hooks.
265
+ - Do not fork component behavior in each game if composition solves it; prefer small wrappers around canonical primitives.
@@ -0,0 +1,170 @@
1
+ <!-- Generated from content/docs/getting-started/dev-logs/page.mdx. Do not edit directly. -->
2
+ <!-- Canonical public doc: https://airjam.io/docs/getting-started/dev-logs -->
3
+
4
+ # Unified Dev Logs
5
+
6
+ Air Jam has one canonical local observability stream for development:
7
+
8
+ - server logs
9
+ - host runtime logs
10
+ - controller runtime logs
11
+ - embedded runtime diagnostics
12
+ - local dev-runner tool output such as Vite and other child-process failures
13
+
14
+ That stream exists so you do not have to debug each surface in isolation.
15
+
16
+ ## Canonical File
17
+
18
+ The canonical file is:
19
+
20
+ ```text
21
+ .airjam/logs/dev-latest.ndjson
22
+ ```
23
+
24
+ This file is:
25
+
26
+ 1. local-first
27
+ 2. append-only for the current server run
28
+ 3. reset when the Air Jam server process starts
29
+
30
+ That means it is the right place to inspect:
31
+
32
+ 1. room lifecycle
33
+ 2. host bootstrap and reconnect
34
+ 3. controller join and disconnect flow
35
+ 4. browser/runtime diagnostics that were mirrored back to the server
36
+
37
+ ## What Writes Into It
38
+
39
+ During normal Air Jam development:
40
+
41
+ 1. the Air Jam server writes structured server events into the file
42
+ 2. the SDK browser log sink mirrors host and controller browser/runtime logs into the same file
43
+ 3. the standard dev runners mirror local child-process output into the same file as `workspace` events
44
+
45
+ If you use the standard Air Jam server and standard SDK session providers in development, this happens automatically.
46
+
47
+ No extra logging setup should be required for the normal path.
48
+
49
+ ## When It Resets
50
+
51
+ The file resets when the Air Jam server process starts.
52
+
53
+ That gives you a clean current-session stream by default.
54
+
55
+ One nuance matters:
56
+
57
+ If your dev workflow reuses an already-running local server process, the file will not reset until that server actually restarts.
58
+
59
+ ### 1. Preferred: CLI Querying
60
+
61
+ Use the published server CLI first.
62
+
63
+ Examples:
64
+
65
+ ```bash
66
+ pnpm exec air-jam-server logs --view=signal
67
+ pnpm exec air-jam-server logs
68
+ pnpm exec air-jam-server logs --follow
69
+ pnpm exec air-jam-server logs --trace=host_abc123
70
+ pnpm exec air-jam-server logs --source=browser --level=warn
71
+ pnpm exec air-jam-server logs --view=signal --room=ROOM1
72
+ pnpm exec air-jam-server logs --source=workspace --process=platform --view=signal
73
+ ```
74
+
75
+ The intended Air Jam workflow is:
76
+
77
+ 1. start with `pnpm exec air-jam-server logs --view=signal`
78
+ 2. narrow to the failing trace, room, controller, runtime, or process
79
+ 3. only add custom logging if the stream still does not explain the issue
80
+
81
+ ### 2. Fallback: Read The File Directly
82
+
83
+ Direct file reads are also valid.
84
+
85
+ That is useful when:
86
+
87
+ 1. the repo does not yet expose the convenience CLI
88
+ 2. you are using your own tooling
89
+ 3. an LLM or script wants the raw NDJSON stream
90
+
91
+ ## Best Filters
92
+
93
+ The most useful filters are:
94
+
95
+ 1. `traceId` for one host session story
96
+ 2. `roomId` for one multiplayer room
97
+ 3. `controllerId` for one player/controller path
98
+ 4. `event` for one lifecycle edge
99
+ 5. `runtimeKind` and `runtimeEpoch` for embedded bridge/runtime issues
100
+ 6. `processName` via `--process` for one local dev process such as `platform`, `server`, or the active game
101
+
102
+ In practice, the fastest loop is usually:
103
+
104
+ 1. reproduce the issue
105
+ 2. find the relevant `traceId`, `roomId`, or `controllerId`
106
+ 3. inspect the rest of the stream through that lens
107
+
108
+ ## Which Identifier To Reach For First
109
+
110
+ Use the narrowest identifier that matches the failure:
111
+
112
+ 1. use `traceId` when the problem is mainly one host session story:
113
+ host bootstrap, reconnect, room ownership, launch flow
114
+ 2. use `roomId` when multiple surfaces are involved in one room and you want the whole multiplayer story
115
+ 3. use `controllerId` when one player path is failing:
116
+ join, disconnect, input, action RPC, targeted controller feedback
117
+ 4. use `runtimeKind` and `runtimeEpoch` when debugging embedded bridge/runtime activation problems
118
+ 5. use `event` when you already know the lifecycle edge you are hunting
119
+
120
+ If you are unsure, start with `roomId` or `traceId` and then narrow further.
121
+
122
+ ## Signal View Vs Raw NDJSON
123
+
124
+ Use `--view=signal` when:
125
+
126
+ 1. you want the fastest first read of the session
127
+ 2. you care about lifecycle edges, accepted/rejected outcomes, and high-signal runtime events
128
+ 3. you want to suppress low-value framework/browser console noise
129
+
130
+ Read raw NDJSON or use broader CLI filters when:
131
+
132
+ 1. you need exact append order
133
+ 2. you need the full event payloads and metadata
134
+ 3. you suspect the hidden plumbing events are part of the problem
135
+ 4. you are doing deeper agent/script analysis over the stream
136
+
137
+ The practical rule is:
138
+
139
+ 1. start with `pnpm exec air-jam-server logs --view=signal`
140
+ 2. narrow with `--trace`, `--room`, `--controller`, `--runtime`, `--process`, or `--source`
141
+ 3. fall back to raw NDJSON only when the signal view is still insufficient
142
+
143
+ ## Recommended Debug Order
144
+
145
+ When something breaks:
146
+
147
+ 1. inspect the canonical dev log stream first
148
+ 2. use SDK diagnostics second
149
+ 3. add temporary custom logs only if the canonical stream still leaves a gap
150
+
151
+ Do not default to scattered `console.log` calls across host, controller, and server code.
152
+
153
+ Air Jam is specifically designed to avoid that debugging style.
154
+
155
+ ## Important Exceptions
156
+
157
+ The automatic unified stream depends on the standard development path.
158
+
159
+ You should not assume full automatic coverage when:
160
+
161
+ 1. running `--web-only` without a local Air Jam server
162
+ 2. disabling the collector explicitly
163
+ 3. replacing the standard server/runtime path with custom infrastructure
164
+ 4. bypassing the standard dev runner and launching tools outside the Air Jam scripts
165
+
166
+ ## Related Docs
167
+
168
+ 1. [Debugging and Logs](./debugging-and-logs.md)
169
+ 2. [For Agents](./for-agents.md)
170
+ 3. [Host System](./host-system.md)
@@ -0,0 +1,55 @@
1
+ # Iconography
2
+
3
+ Use icons intentionally.
4
+
5
+ Do not use emojis as UI icons.
6
+
7
+ ## Default Pack Split
8
+
9
+ Prefer:
10
+
11
+ 1. `@tabler/icons-react` for general UI and system icons
12
+ 2. `react-icons` `Gi*` exports for game-specific icons
13
+
14
+ ## When To Use `Tabler`
15
+
16
+ Use `@tabler/icons-react` for:
17
+
18
+ 1. navigation
19
+ 2. menu items
20
+ 3. settings
21
+ 4. device and network status
22
+ 5. close, back, play, pause, stop, confirm, and other general actions
23
+ 6. shell and dashboard-like non-gameplay UI
24
+
25
+ ## When To Use `Game Icons`
26
+
27
+ Use `react-icons` `Gi*` exports for:
28
+
29
+ 1. abilities
30
+ 2. status effects
31
+ 3. pickups
32
+ 4. damage or energy types
33
+ 5. equipment-like gameplay concepts
34
+ 6. game-specific verbs and entities that general UI packs do not express well
35
+
36
+ ## Architecture Rule
37
+
38
+ Do not import icon packs randomly throughout the app.
39
+
40
+ Prefer local wrappers such as:
41
+
42
+ 1. `src/ui/icons/` for general UI icons
43
+ 2. `src/game/ui/icons/` for gameplay icons
44
+
45
+ That keeps:
46
+
47
+ 1. icon usage consistent
48
+ 2. future swaps possible
49
+ 3. game icon curation easier
50
+
51
+ ## Attribution Note
52
+
53
+ The `Gi*` icon set in `react-icons` comes from Game Icons and carries its own attribution expectations.
54
+
55
+ The project should note that when using those assets, but the template should not hard-enforce attribution behavior for every downstream team.
@@ -0,0 +1,212 @@
1
+ # Prefab Authoring
2
+
3
+ Prefabs should be first-class reusable content units.
4
+
5
+ The goal is not just code reuse.
6
+
7
+ The goal is to make content predictable enough for future tooling to scan, preview, configure, and compose.
8
+
9
+ ## What A Prefab Is
10
+
11
+ A prefab is a reusable gameplay or scene object with a stable contract.
12
+
13
+ Examples:
14
+
15
+ 1. a tree, rock, wall, or prop
16
+ 2. a pickup or spawn point
17
+ 3. a vehicle or obstacle
18
+ 4. a reusable gameplay actor shell
19
+
20
+ ## Goals
21
+
22
+ Good prefabs should make it possible to:
23
+
24
+ 1. reuse the same content definition in multiple scenes
25
+ 2. expose safe configuration without rewriting component internals
26
+ 3. generate previews later
27
+ 4. scan the prefab directory and build a lightweight catalog
28
+
29
+ Each game should also expose one game-owned prefab catalog export so future
30
+ Studio or agent tooling has a single honest scan surface instead of searching
31
+ the whole codebase heuristically.
32
+
33
+ ## Prefabs vs Scene Population
34
+
35
+ Do not mix these two concepts.
36
+
37
+ 1. a prefab is a reusable authored content unit with a stable contract
38
+ 2. scene population is the runtime or authored layer that places many prefab instances into a scene
39
+
40
+ Examples of scene population:
41
+
42
+ 1. spawn one ship per connected player
43
+ 2. render all collectibles from replicated store state
44
+ 3. fill an arena with obstacle instances from a level layout
45
+
46
+ Those population or pooling layers should live outside `src/game/prefabs/`.
47
+
48
+ ## Recommended Shape
49
+
50
+ Move toward a folder per prefab under `src/game/prefabs/`.
51
+
52
+ Example:
53
+
54
+ ```text
55
+ src/game/prefabs/
56
+ tree/
57
+ prefab.ts
58
+ tree.prefab.tsx
59
+ tree.schema.ts
60
+ tree.preview.ts
61
+ ```
62
+
63
+ The exact filenames can vary, but the boundary should stay clear:
64
+
65
+ 1. metadata and registry-facing contract
66
+ 2. config schema and defaults
67
+ 3. runtime render entry
68
+ 4. optional preview descriptor
69
+
70
+ ## Recommended Metadata
71
+
72
+ Each prefab should converge on stable fields like:
73
+
74
+ 1. `id`
75
+ 2. `label`
76
+ 3. `category`
77
+ 4. `description`
78
+ 5. `tags`
79
+ 6. `defaultProps`
80
+ 7. `configSchema`
81
+ 8. `render`
82
+ 9. `preview`
83
+ 10. `placement`
84
+
85
+ ## Placement Rule
86
+
87
+ Prefab placement should be deterministic.
88
+
89
+ Do not rely on manual trial-and-error offsets that leave models floating, clipping, or inconsistently grounded.
90
+
91
+ If a prefab needs grounding logic:
92
+
93
+ 1. define its origin clearly
94
+ 2. define its footprint or bounds clearly
95
+ 3. keep placement helpers reusable instead of baking ad hoc offsets into every scene
96
+
97
+ ## Behavior Rule
98
+
99
+ Do not let prefabs become a dumping ground for full gameplay systems.
100
+
101
+ Use:
102
+
103
+ 1. prefab files for reusable content assembly
104
+ 2. domain or system modules for larger rules and behavior
105
+ 3. adapters for engine or renderer integration
106
+ 4. scene-population or pooling modules for multi-instance runtime ownership
107
+
108
+ ## Decision Rule
109
+
110
+ If something is meant to be reused, previewed, or configured later, give it a prefab contract early.
111
+
112
+ If it is truly one-off scene glue, keep it out of the prefab layer.
113
+
114
+ ## Isolated assets and states
115
+
116
+ Prefabs are the catalog identity. Declare `space` and, for animated assets, named
117
+ `states`. `space` is optional: it defaults to `"3d"` when `preview.camera` is set,
118
+ otherwise `"2d"`. A rendered `PrefabDefinition` requires `render`; a renderer-free
119
+ `PrefabDeclaration` omits it. Omitting states creates one static state (`static`). State time is in
120
+ seconds; the SDK owns playback and seeking, while the game draws that exact time.
121
+ A state without `seconds` is a static pose. `loop: true` wraps a timed state;
122
+ otherwise it pauses at the end.
123
+
124
+ ```ts filename="src/airjam.config.ts"
125
+ import { defineAirJamGame } from "@air-jam/sdk/core";
126
+ import { createPrefabCatalog, definePrefab } from "@air-jam/sdk/prefabs";
127
+ import { z } from "zod";
128
+
129
+ export const dotProps = z.object({ radius: z.number().positive() });
130
+ export const dot = definePrefab({
131
+ id: "dot",
132
+ label: "Dot",
133
+ category: "effect",
134
+ description: "Pulsing circle",
135
+ tags: ["effect"],
136
+ space: "2d",
137
+ configSchema: dotProps,
138
+ defaultProps: { radius: 40 },
139
+ states: [{ id: "pulse", label: "Pulse", seconds: 1, loop: true }],
140
+ });
141
+ // Add to your existing definition, retaining its metadata and other declarations:
142
+ export const game = defineAirJamGame({
143
+ metadata,
144
+ prefabs: createPrefabCatalog([dot]),
145
+ });
146
+ ```
147
+
148
+ Keep this declaration module free of React and renderer imports. In the host
149
+ application, the stage selects the renderer for the declared prefab:
150
+
151
+ ```tsx filename="src/prefab-stage.tsx"
152
+ import {
153
+ createAirJamApp,
154
+ drawAgentCanvas,
155
+ useHostAgentCapture,
156
+ usePrefabInspection,
157
+ } from "@air-jam/sdk";
158
+ import { resolvePrefab2DTransform } from "@air-jam/sdk/prefabs";
159
+ import { useLayoutEffect, useRef } from "react";
160
+ import { dot, dotProps, game } from "./airjam.config";
161
+
162
+ function Stage() {
163
+ const canvas = useRef<HTMLCanvasElement>(null);
164
+ const { prefab, props, time, view } = usePrefabInspection();
165
+ if (prefab.id !== dot.id) throw new Error(`Unknown prefab: ${prefab.id}`);
166
+ const { radius } = dotProps.parse(props);
167
+ useHostAgentCapture((image, options) =>
168
+ drawAgentCanvas(canvas.current, image, options),
169
+ );
170
+ useLayoutEffect(() => {
171
+ const context = canvas.current?.getContext("2d");
172
+ if (!context) return;
173
+ const { scale, translate } = resolvePrefab2DTransform(view, 512);
174
+ context.resetTransform();
175
+ context.clearRect(0, 0, 512, 512);
176
+ context.translate(256 + translate[0], 256 + translate[1]);
177
+ context.scale(scale, scale);
178
+ context.beginPath();
179
+ context.arc(
180
+ 0,
181
+ 0,
182
+ radius * (1 + 0.2 * Math.sin(time * Math.PI * 2)),
183
+ 0,
184
+ Math.PI * 2,
185
+ );
186
+ context.fillStyle = "#ff6a35";
187
+ context.fill();
188
+ }, [radius, time, view]);
189
+ return <canvas ref={canvas} width={512} height={512} />;
190
+ }
191
+ const app = createAirJamApp(game);
192
+ // In the existing host route (LiveGame is your game's live component):
193
+ <app.Host prefabStage={Stage}>
194
+ <LiveGame />
195
+ </app.Host>;
196
+ ```
197
+
198
+ For R3F, use `resolvePrefabOrbitCamera(prefab.preview?.camera, view)` and apply its
199
+ `position`, `target` and `fov` to the game's camera. Capture through
200
+ `useHostAgentCapture`: render the R3F scene immediately before copying `gl.domElement`
201
+ with `drawAgentCanvas`, because WebGL drawing buffers need not survive a frame.
202
+ The helper has no Three dependency. Zoom 1 keeps default framing; yaw/pitch use
203
+ degrees relative to the preview camera. Pan uses fractions of view height, right/up
204
+ positive. The 2D helper returns pixel translation and scale around default framing;
205
+ yaw and pitch have no effect in 2D.
206
+
207
+ Open `?airjamInspect=1&prefab=dot&state=pulse&time=0.3` for a paused isolated frame.
208
+ Stages read parsed default props, state, time, playing and view from
209
+ `usePrefabInspection()`. They must draw only that prefab, without reading live room
210
+ stores, starting physics or advancing their own animation clock. The SDK reports
211
+ missing catalogs, missing stages and rendering errors. `@air-jam/sdk/prefab-inspection`
212
+ exports the validated parent client for lists, selection and batch canvas captures.