@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.
- package/LICENSE +21 -0
- package/README.md +273 -2
- package/bin/airjam.mjs +66 -0
- package/dist/ai-pack.d.ts +44 -0
- package/dist/ai-pack.js +15 -0
- package/dist/ai-pack.js.map +1 -0
- package/dist/auth-profile.d.ts +5 -0
- package/dist/auth-profile.js +7 -0
- package/dist/auth-profile.js.map +1 -0
- package/dist/auth-sessions.d.ts +5 -0
- package/dist/auth-sessions.js +7 -0
- package/dist/auth-sessions.js.map +1 -0
- package/dist/chunk-7D4AYBAV.js +64 -0
- package/dist/chunk-7D4AYBAV.js.map +1 -0
- package/dist/chunk-J5MAU4QZ.js +102 -0
- package/dist/chunk-J5MAU4QZ.js.map +1 -0
- package/dist/chunk-LH7UO57C.js +23 -0
- package/dist/chunk-LH7UO57C.js.map +1 -0
- package/dist/chunk-N7AI7HZK.js +529 -0
- package/dist/chunk-N7AI7HZK.js.map +1 -0
- package/dist/chunk-PKTLVQXZ.js +82 -0
- package/dist/chunk-PKTLVQXZ.js.map +1 -0
- package/dist/chunk-SQE4NPZP.js +31 -0
- package/dist/chunk-SQE4NPZP.js.map +1 -0
- package/dist/chunk-U6V3HEBB.js +939 -0
- package/dist/chunk-U6V3HEBB.js.map +1 -0
- package/dist/chunk-VEHNFPEO.js +224 -0
- package/dist/chunk-VEHNFPEO.js.map +1 -0
- package/dist/development.d.ts +102 -0
- package/dist/development.js +33 -0
- package/dist/development.js.map +1 -0
- package/dist/documentation.d.ts +27 -0
- package/dist/documentation.js +7 -0
- package/dist/documentation.js.map +1 -0
- package/dist/game-analytics.d.ts +5 -0
- package/dist/game-analytics.js +7 -0
- package/dist/game-analytics.js.map +1 -0
- package/dist/game-app-id.d.ts +5 -0
- package/dist/game-app-id.js +7 -0
- package/dist/game-app-id.js.map +1 -0
- package/dist/game-media.d.ts +5 -0
- package/dist/game-media.js +7 -0
- package/dist/game-media.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2468 -0
- package/dist/index.js.map +1 -0
- package/dist/scaffold.d.ts +6 -0
- package/dist/scaffold.js +20 -0
- package/dist/scaffold.js.map +1 -0
- package/package.json +82 -3
- package/runtime/local-network.d.mts +6 -0
- package/runtime/local-network.mjs +9 -0
- package/runtime/public-assets.mjs +62 -0
- package/runtime/source-fence.mjs +182 -0
- package/runtime/vite-config.d.mts +43 -0
- package/runtime/vite-config.mjs +134 -0
- package/runtime/vite-dev.mjs +18 -0
- package/runtime/vite-https.d.mts +11 -0
- package/runtime/vite-https.mjs +40 -0
- package/template-assets/bootstrap/.claude/launch.json +12 -0
- package/template-assets/bootstrap/AGENTS.md +290 -0
- package/template-assets/bootstrap/CLAUDE.md +55 -0
- package/template-assets/bootstrap/_gitignore +6 -0
- package/template-assets/bootstrap/skills/airjam-docs-workflow/SKILL.md +49 -0
- package/template-assets/bootstrap/skills/airjam-mcp/SKILL.md +100 -0
- package/template-assets/bootstrap/skills/canvas-2d-gameplay/SKILL.md +47 -0
- package/template-assets/bootstrap/skills/controller-ui/SKILL.md +71 -0
- package/template-assets/bootstrap/skills/debug-and-test/SKILL.md +72 -0
- package/template-assets/bootstrap/skills/game-architecture/SKILL.md +102 -0
- package/template-assets/bootstrap/skills/game-state-and-rendering/SKILL.md +44 -0
- package/template-assets/bootstrap/skills/host-surface/SKILL.md +52 -0
- package/template-assets/bootstrap/skills/index.md +36 -0
- package/template-assets/bootstrap/skills/prefab-authoring/SKILL.md +58 -0
- package/template-assets/bootstrap/skills/r3f-3d-scene/SKILL.md +61 -0
- package/template-assets/documentation/for-agents/controller-ui/page.mdx +99 -0
- package/template-assets/documentation/for-agents/page.mdx +120 -0
- package/template-assets/documentation/for-agents/project-structure/page.mdx +170 -0
- package/template-assets/documentation/for-agents/state-and-rendering/page.mdx +77 -0
- package/template-assets/documentation/for-agents/supported-agents/page.mdx +18 -0
- package/template-assets/documentation/getting-started/debugging/page.mdx +164 -0
- package/template-assets/documentation/getting-started/dev-logs/page.mdx +169 -0
- package/template-assets/documentation/getting-started/game-ideas/page.mdx +114 -0
- package/template-assets/documentation/getting-started/introduction/page.mdx +200 -0
- package/template-assets/documentation/getting-started/migrating-legacy-games/page.mdx +673 -0
- package/template-assets/documentation/getting-started/quick-start/page.mdx +310 -0
- package/template-assets/documentation/how-it-works/architecture/page.mdx +230 -0
- package/template-assets/documentation/how-it-works/host-system/page.mdx +270 -0
- package/template-assets/documentation/manifest.json +500 -0
- package/template-assets/documentation/sdk/assets-and-theme/page.mdx +185 -0
- package/template-assets/documentation/sdk/hooks/page.mdx +435 -0
- package/template-assets/documentation/sdk/input-system/page.mdx +240 -0
- package/template-assets/documentation/sdk/networked-state/page.mdx +295 -0
- package/template-assets/documentation/sdk/settings/page.mdx +155 -0
- package/template-assets/documentation/sdk/ui-components/page.mdx +268 -0
- package/template-assets/managed/.airjam/ai-pack.json +209 -0
- package/template-assets/managed/docs/airjam/agent-gold-path.md +115 -0
- package/template-assets/managed/docs/airjam/agent-mcp.md +179 -0
- package/template-assets/managed/docs/airjam/canvas-2d-gameplay.md +82 -0
- package/template-assets/managed/docs/airjam/composition-shell-contract.md +87 -0
- package/template-assets/managed/docs/airjam/debug-and-testing.md +104 -0
- package/template-assets/managed/docs/airjam/development-loop.md +51 -0
- package/template-assets/managed/docs/airjam/docs-index.md +64 -0
- package/template-assets/managed/docs/airjam/generated/architecture.md +223 -0
- package/template-assets/managed/docs/airjam/generated/assets-and-theme.md +188 -0
- package/template-assets/managed/docs/airjam/generated/controller-ui.md +102 -0
- package/template-assets/managed/docs/airjam/generated/debugging-and-logs.md +165 -0
- package/template-assets/managed/docs/airjam/generated/for-agents.md +123 -0
- package/template-assets/managed/docs/airjam/generated/game-ideas.md +107 -0
- package/template-assets/managed/docs/airjam/generated/host-system.md +261 -0
- package/template-assets/managed/docs/airjam/generated/input-system.md +241 -0
- package/template-assets/managed/docs/airjam/generated/introduction.md +195 -0
- package/template-assets/managed/docs/airjam/generated/migrating-legacy-games.md +674 -0
- package/template-assets/managed/docs/airjam/generated/networked-state.md +298 -0
- package/template-assets/managed/docs/airjam/generated/project-structure.md +171 -0
- package/template-assets/managed/docs/airjam/generated/quick-start.md +311 -0
- package/template-assets/managed/docs/airjam/generated/sdk-hooks.md +430 -0
- package/template-assets/managed/docs/airjam/generated/settings.md +158 -0
- package/template-assets/managed/docs/airjam/generated/state-and-rendering.md +80 -0
- package/template-assets/managed/docs/airjam/generated/supported-agents.md +21 -0
- package/template-assets/managed/docs/airjam/generated/ui-components.md +265 -0
- package/template-assets/managed/docs/airjam/generated/unified-dev-logs.md +170 -0
- package/template-assets/managed/docs/airjam/iconography.md +55 -0
- package/template-assets/managed/docs/airjam/prefab-authoring.md +212 -0
- package/template-assets/managed/docs/airjam/preview-controllers.md +129 -0
- package/template-assets/managed/docs/airjam/r3f-3d-scene.md +163 -0
- package/template-assets/managed/docs/airjam/state-lanes-cookbook.md +101 -0
- package/template-assets/managed/docs/airjam/visual-system.md +103 -0
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
# Quick Start
|
|
2
|
+
|
|
3
|
+
Get your first Air Jam game up and running in minutes using our project generator.
|
|
4
|
+
|
|
5
|
+
You need Node.js 22.15 or newer and pnpm installed. The generator runs `pnpm install`
|
|
6
|
+
for you unless you explicitly choose `--skip-install`.
|
|
7
|
+
|
|
8
|
+
## 1. Create a New Project
|
|
9
|
+
|
|
10
|
+
The fastest way to start is using our CLI tool. This creates a ready-to-use workspace with a working Pong game, local development server, and SDK configuration.
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npx create-airjam my-game
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
After the project is created, navigate into the directory and open it in your editor:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
cd my-game
|
|
20
|
+
code . # or your preferred editor
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 2. Start Local Development
|
|
24
|
+
|
|
25
|
+
The scaffold uses one command for the normal local loop. It starts the local Air Jam server and the game together.
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pnpm run dev
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
That command starts:
|
|
32
|
+
|
|
33
|
+
1. the local Air Jam server on `http://localhost:4000`
|
|
34
|
+
2. the game on `http://localhost:5173`
|
|
35
|
+
|
|
36
|
+
If Claude Code Desktop preview launches the app, use the committed `.claude/launch.json`. It still goes through the normal Air Jam dev runner, but adds the preview-managed adapter Claude Preview needs.
|
|
37
|
+
|
|
38
|
+
For other browser or agent preview tools that ask for a launch command, use `pnpm run dev`. Do not fall back to raw `vite` or a separate preview-only script.
|
|
39
|
+
|
|
40
|
+
## 3. Play the Game
|
|
41
|
+
|
|
42
|
+
Open your browser and visit:
|
|
43
|
+
|
|
44
|
+
[http://localhost:5173](http://localhost:5173)
|
|
45
|
+
|
|
46
|
+
You should see the Pong template game. You can now:
|
|
47
|
+
|
|
48
|
+
1. Open the game in your browser (Host view)
|
|
49
|
+
2. Scan the QR code with your phone (Controller view)
|
|
50
|
+
3. Play the game!
|
|
51
|
+
|
|
52
|
+
## Optional: HTTPS for Motion Sensors
|
|
53
|
+
|
|
54
|
+
Most local Air Jam development works on HTTP. Enable HTTPS only when you need secure browser APIs such as gyroscope or motion sensors.
|
|
55
|
+
|
|
56
|
+
1. Install `mkcert` once on your machine.
|
|
57
|
+
2. Initialize secure mode:
|
|
58
|
+
```bash
|
|
59
|
+
pnpm run secure:init
|
|
60
|
+
```
|
|
61
|
+
3. Run secure dev:
|
|
62
|
+
```bash
|
|
63
|
+
pnpm run dev -- --secure
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
This keeps the local Air Jam server on `http://localhost:4000` and serves the game over trusted local HTTPS.
|
|
67
|
+
|
|
68
|
+
Optional tunnel fallback:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pnpm exec airjam secure:init --mode=tunnel --hostname my-game-dev.example.com --tunnel my-game-dev
|
|
72
|
+
pnpm run dev -- --secure --secure-mode=tunnel
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## 4. Customize & Build
|
|
76
|
+
|
|
77
|
+
This project is "vibecode friendly"—it includes documentation and AI instructions to help you build faster.
|
|
78
|
+
|
|
79
|
+
- **Check `AGENTS.md`**: Project-wide coding contract and workflow for AI coding assistants.
|
|
80
|
+
- **Check `docs/airjam/docs-index.md`**: Canonical local framework references bundled with the template.
|
|
81
|
+
- **Modify `src/airjam.config.ts`**: The game declaration: metadata, controls, stores, settings and simulation.
|
|
82
|
+
- **Modify `src/game/contracts/input.ts`**: Declare the controls each player has.
|
|
83
|
+
- **Use the starter module map in the template `README.md`**: Follow the current starter structure before creating new homes for code.
|
|
84
|
+
- **Modify `src/game/stores/`**: Starter location for shared networked state and pure transitions.
|
|
85
|
+
- **Modify `src/game/engine/`**: Starter simulation the host advances in fixed steps.
|
|
86
|
+
- **Modify `src/host/index.tsx`**: Starter host screen.
|
|
87
|
+
- **Modify `src/controller/index.tsx`**: Starter mobile controller surface.
|
|
88
|
+
- **Use `tests/game/`**: Starter testing pattern for domain, stores, engine, adapters, and shared game UI.
|
|
89
|
+
|
|
90
|
+
These paths are the current starter template shape.
|
|
91
|
+
They are recommended defaults for new projects, not framework-mandated filenames.
|
|
92
|
+
|
|
93
|
+
### Connect Your Coding Agent
|
|
94
|
+
|
|
95
|
+
Use your existing editor, terminal agent, or MCP client; Air Jam does not require
|
|
96
|
+
a separate hosted game editor. The generated project includes local instructions
|
|
97
|
+
and a portable `.mcp.json` declaration. A declaration is not the same as a client
|
|
98
|
+
being connected. Inspect the setup and render the configuration your client uses:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
pnpm exec airjam mcp doctor --dir . --json
|
|
102
|
+
pnpm exec airjam mcp config --profile portable --dir .
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
The `codex` and `claude-desktop` profiles render their respective registration
|
|
106
|
+
formats. Configuration rendering is read-only: install the rendered entry in
|
|
107
|
+
your client, then check its tool discovery. See [For Agents](/docs/for-agents)
|
|
108
|
+
for semantic game control and a CLI-only path, and
|
|
109
|
+
[Supported Agents](/docs/for-agents/supported-agents) for the clients tested end to end.
|
|
110
|
+
|
|
111
|
+
### Run the Complete Evaluation
|
|
112
|
+
|
|
113
|
+
Before sharing a game—and again after any repair—run the canonical complete evaluation:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
pnpm exec airjam evaluate --dir .
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
It returns one machine-readable `air-jam-complete-evaluation/v1` document containing the results of typecheck, lint, tests, and the production build. Agents can call the same service through the `airjam.evaluate` MCP action. Individual gates remain available when narrowing a failure.
|
|
120
|
+
|
|
121
|
+
### Refresh Managed Framework Guidance
|
|
122
|
+
|
|
123
|
+
Scaffolded projects include an AI pack that owns canonical framework references under `docs/airjam/`. Top-level agent instructions and project-local skills are bootstrap files: after creation, they belong to the project and Air Jam never overwrites them.
|
|
124
|
+
|
|
125
|
+
Use these commands from your project root:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
pnpm exec airjam ai-pack status --dir .
|
|
129
|
+
pnpm exec airjam ai-pack diff --dir .
|
|
130
|
+
pnpm exec airjam ai-pack update --dir .
|
|
131
|
+
pnpm exec airjam ai-pack repair --dir .
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
`ai-pack update` consumes only the snapshot inside the installed, provenance-backed CLI package. `ai-pack repair` explicitly restores same-version managed drift. Both replace only AI-pack-managed framework references; neither is a merge tool or owns `AGENTS.md`, `CLAUDE.md`, project-local skills, application code, or user-created notes.
|
|
135
|
+
|
|
136
|
+
## Troubleshooting
|
|
137
|
+
|
|
138
|
+
### Server not connecting locally
|
|
139
|
+
|
|
140
|
+
1. Verify `pnpm run dev` is running.
|
|
141
|
+
2. Confirm server health: [http://localhost:4000/health](http://localhost:4000/health).
|
|
142
|
+
3. Confirm your game is using `http://localhost:4000` for `VITE_AIR_JAM_SERVER_URL` (or no override at all for local defaults).
|
|
143
|
+
|
|
144
|
+
### Local port already in use
|
|
145
|
+
|
|
146
|
+
Each parallel agent or project can run an isolated stack without stopping another one:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
AIR_JAM_SERVER_PORT=4400 \
|
|
150
|
+
VITE_PORT=5573 \
|
|
151
|
+
VITE_AIR_JAM_PUBLIC_HOST=http://127.0.0.1:5573 \
|
|
152
|
+
pnpm run dev
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
`pnpm exec airjam topology --mode=standalone-dev` honors the same environment, so the CLI, semantic sessions, QR URL, Vite proxy, and local server stay on one coherent topology.
|
|
156
|
+
|
|
157
|
+
### App ID errors in deployed environments
|
|
158
|
+
|
|
159
|
+
1. Ensure `VITE_AIR_JAM_APP_ID` is set in your host platform.
|
|
160
|
+
2. Ensure the server URL points at your real Air Jam backend.
|
|
161
|
+
3. Ensure your site's exact origin is in the game's allowed origins in Create.
|
|
162
|
+
4. Re-copy the App ID from your game's page in Create if the room is refused.
|
|
163
|
+
|
|
164
|
+
### QR / controller join URL issues
|
|
165
|
+
|
|
166
|
+
1. Confirm host and controller are on the same room code.
|
|
167
|
+
2. If testing on phone outside localhost, set `VITE_AIR_JAM_PUBLIC_HOST` (or use `pnpm run dev -- --secure`).
|
|
168
|
+
3. For SPA hosting, ensure rewrites route `/controller?room=XXXX` to your app entry.
|
|
169
|
+
|
|
170
|
+
## 5. Connect Your Game To Air Jam Services
|
|
171
|
+
|
|
172
|
+
When you're ready to share your game outside local development, first register
|
|
173
|
+
it with Air Jam so the runtime has a stable hosted identity.
|
|
174
|
+
|
|
175
|
+
1. **Create a game record**:
|
|
176
|
+
Register your game from the terminal after a one-time browser-assisted login:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
pnpm exec airjam auth login
|
|
180
|
+
pnpm exec airjam game create --dir . --name "My Game" --slug my-game
|
|
181
|
+
pnpm exec airjam game inspect --game my-game
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Copy the **App ID** from the response. Your game also appears in [Create](/studio)
|
|
185
|
+
at `/studio/games/<id>`, with **Releases**, **Media**, **Analytics** and **Security**.
|
|
186
|
+
Studio projects create their game record on the first release.
|
|
187
|
+
|
|
188
|
+
2. **Choose your distribution lane**:
|
|
189
|
+
- Deploy your game to a static hosting provider like Vercel, Netlify, or GitHub Pages.
|
|
190
|
+
- Use that self-hosted URL for normal private review and iteration.
|
|
191
|
+
- If you want public Air Jam Arcade distribution, publish a hosted release artifact in step 6 below.
|
|
192
|
+
- For self-hosted deployments, set the following environment variables:
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
VITE_AIR_JAM_APP_ID=your_app_id_here
|
|
196
|
+
VITE_AIR_JAM_SERVER_URL=https://rooms.airjam.io
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Add your site's origin (for example `https://my-game.example`) to the
|
|
200
|
+
allowed origins in your game's **Security** section in Create. When your page
|
|
201
|
+
opens a room, the SDK asks Air Jam for a short-lived host grant for your App
|
|
202
|
+
ID. Air Jam signs one only for an active App ID, asked from one of its allowed
|
|
203
|
+
origins exactly, and the grant names that one origin. You do not mint tokens or
|
|
204
|
+
add auth code to your game.
|
|
205
|
+
|
|
206
|
+
The origin check keeps other websites from opening rooms under your App ID in
|
|
207
|
+
players' browsers. It is not a secret: a script outside a browser can claim any
|
|
208
|
+
origin, just as it can claim any App ID. What bounds misuse is admission: each
|
|
209
|
+
game and each account may run 20 hosted rooms at once, inside Air Jam's overall
|
|
210
|
+
limit, so rooms someone else opens under your App ID can crowd yours but never
|
|
211
|
+
grow past those caps.
|
|
212
|
+
|
|
213
|
+
On hosted rooms, a crash your game's error boundary catches is also reported to
|
|
214
|
+
Air Jam, as its error name and a short digest (never its message, stack or any
|
|
215
|
+
player input), so it shows up with your game's other room records. Pass your own
|
|
216
|
+
`reportError` to send reports elsewhere.
|
|
217
|
+
|
|
218
|
+
Before publishing your scaffolded game, run the local checks:
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
pnpm test
|
|
222
|
+
pnpm run typecheck
|
|
223
|
+
pnpm run build
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
If you are self-hosting the client, keep SPA rewrites enabled so `/controller?room=XXXX` resolves to your app entry.
|
|
227
|
+
|
|
228
|
+
### Self-hosted rooms
|
|
229
|
+
|
|
230
|
+
Run the open `air-jam-server` yourself and point `VITE_AIR_JAM_SERVER_URL` at
|
|
231
|
+
it. In production it needs a gate of your own: compose it with
|
|
232
|
+
`createRoomServer({ gate })` from `@air-jam/server/room-server`, or set
|
|
233
|
+
`AIR_JAM_AUTH_MODE=disabled` to run it open to any host. Its master key is for
|
|
234
|
+
local development and tests only. The SDK sends whatever
|
|
235
|
+
`VITE_AIR_JAM_HOST_GRANT_ENDPOINT` returns (`{ "hostGrant": "..." }`) as the
|
|
236
|
+
credential when it opens a room, so your gate can verify a token your own
|
|
237
|
+
backend signs. Game code stays unchanged.
|
|
238
|
+
|
|
239
|
+
## 6. Publish A Hosted Arcade Release
|
|
240
|
+
|
|
241
|
+
The official Arcade hosting lane is now artifact-based. Self-hosted URLs are still useful for private preview, but public Arcade hosting should use a hosted release artifact.
|
|
242
|
+
|
|
243
|
+
1. Run the local hosted-release preflight from your project root:
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
pnpm exec airjam release doctor --dir .
|
|
247
|
+
pnpm exec airjam release validate --dir .
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
2. Build a hosted bundle from your project root:
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
pnpm exec airjam release bundle --dir .
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
That command:
|
|
257
|
+
|
|
258
|
+
- runs your build script
|
|
259
|
+
- bundles the static output from `dist/`
|
|
260
|
+
- writes `.airjam/release-manifest.json`
|
|
261
|
+
- creates a hosted release zip under `.airjam/releases/<version>/`
|
|
262
|
+
|
|
263
|
+
The hosted artifact contract is fixed:
|
|
264
|
+
|
|
265
|
+
- host entry at `/`
|
|
266
|
+
- controller entry at `/controller`
|
|
267
|
+
|
|
268
|
+
### Terminal or Agent Publishing
|
|
269
|
+
|
|
270
|
+
The CLI can bundle, upload, and wait for validation. Use the game slug or ID
|
|
271
|
+
created in step 5:
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
pnpm exec airjam release submit --game my-game --dir . --wait
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
This leaves the processed release unpublished. Inspect the returned release ID,
|
|
278
|
+
then explicitly make it live when you are ready:
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
pnpm exec airjam release inspect --release <release-id>
|
|
282
|
+
pnpm exec airjam release publish --release <release-id>
|
|
283
|
+
pnpm exec airjam game media list --game my-game --json
|
|
284
|
+
pnpm exec airjam game media assign --game my-game --asset-id <asset-id> --json
|
|
285
|
+
pnpm exec airjam game media archive --game my-game --asset-id <asset-id> --json
|
|
286
|
+
pnpm exec airjam game update --game my-game --arcade-visibility listed
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Publishing a release and listing its game are separate decisions. A processing
|
|
290
|
+
timeout does not cancel the background job: inspect the same release rather
|
|
291
|
+
than submitting another copy. CLI responses retain the release and generation
|
|
292
|
+
identities needed to resume work.
|
|
293
|
+
|
|
294
|
+
`game media list` (also `inspect`) returns existing assets with IDs, kinds,
|
|
295
|
+
status and active selections. `assign` reuses an earlier asset for its kind;
|
|
296
|
+
`archive` retires one by ID and clears its slot if active. These commands use
|
|
297
|
+
the saved machine login and accept `--platform-url` and `--help`. Without
|
|
298
|
+
`--json` they print readable output. Use `game media upload` for new files.
|
|
299
|
+
|
|
300
|
+
### Publish From Create
|
|
301
|
+
|
|
302
|
+
Alternatively, upload the zip produced by `airjam release bundle` above:
|
|
303
|
+
|
|
304
|
+
1. Open your game in [Create](/studio) and choose **Releases**.
|
|
305
|
+
2. Upload the generated zip artifact.
|
|
306
|
+
3. Make the validated release live.
|
|
307
|
+
4. Upload thumbnail, cover, and preview media in **Media**.
|
|
308
|
+
5. Set the game's Arcade visibility to listed.
|
|
309
|
+
|
|
310
|
+
Your game is now live in the public Arcade on Air Jam-hosted infrastructure.
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
Air Jam's open framework has three core components: the room server, game SDK,
|
|
4
|
+
and creator harness. Reference games show how they work together for multiplayer
|
|
5
|
+
gaming with smartphone controllers.
|
|
6
|
+
|
|
7
|
+
The important current rule is that Air Jam has one framework model, not one model for standalone games and a different model for Arcade.
|
|
8
|
+
|
|
9
|
+
Arcade is an Air Jam app around another Air Jam app.
|
|
10
|
+
|
|
11
|
+
## System Overview
|
|
12
|
+
|
|
13
|
+
<SystemOverviewDiagram />
|
|
14
|
+
|
|
15
|
+
## Components
|
|
16
|
+
|
|
17
|
+
The Arcade and Studio at [airjam.io](https://airjam.io) are a separately operated
|
|
18
|
+
product, not an application in this public repository. Their hosted services
|
|
19
|
+
compose the same open runtime; standalone games need neither that product nor
|
|
20
|
+
its database. The diagrams include hosted surfaces to show how embedding works.
|
|
21
|
+
|
|
22
|
+
### 1. Room server (`packages/server`)
|
|
23
|
+
|
|
24
|
+
**Role:** Keeps rooms: it seats phones, carries their controls to the game's
|
|
25
|
+
host and the host's state to the phones
|
|
26
|
+
|
|
27
|
+
**Technology:** Node.js and `ws`; the room itself is plain synchronous code
|
|
28
|
+
(`@air-jam/server/room`), so the hosted Arcade runs the same rooms elsewhere
|
|
29
|
+
|
|
30
|
+
Every device holds one WebSocket to its room. A game's host connects to
|
|
31
|
+
`/v1/host` and gets a room code; a phone connects to `/v1/play/CODE` and gets
|
|
32
|
+
a seat (`p1`, `p2`, …). The room speaks the room protocol
|
|
33
|
+
(`@air-jam/sdk/room-protocol`):
|
|
34
|
+
|
|
35
|
+
- **Hello and welcome.** Each device sends a key that only it knows; the same
|
|
36
|
+
key gets the same place back after a reload or a dropped network.
|
|
37
|
+
- **Channels.** The host publishes named state documents (the room's
|
|
38
|
+
presentation, each networked store); the room keeps the latest copy and
|
|
39
|
+
sends phones what changed.
|
|
40
|
+
- **Requests and signals.** A phone asks the host to run an action and gets
|
|
41
|
+
one answer; the host sends haptics, toasts and sounds to one seat or all.
|
|
42
|
+
- **Input.** Controls travel in small binary frames; the room delivers the
|
|
43
|
+
latest of each seat's to the host.
|
|
44
|
+
|
|
45
|
+
### 2. SDK (`packages/sdk`)
|
|
46
|
+
|
|
47
|
+
**Role:** Developer toolkit for building Air Jam games
|
|
48
|
+
|
|
49
|
+
**Technology:** TypeScript, Zustand, Zod; React for the binding
|
|
50
|
+
|
|
51
|
+
**Architecture:**
|
|
52
|
+
|
|
53
|
+
<SdkArchitectureDiagram />
|
|
54
|
+
|
|
55
|
+
The SDK is one runtime in two layers:
|
|
56
|
+
|
|
57
|
+
1. **The core** (`@air-jam/sdk/core`) owns a room: the connection, players,
|
|
58
|
+
input, networked stores and their sync, the game's simulation on the SDK
|
|
59
|
+
clock, signals and the agent contract. It imports no React and no DOM, so
|
|
60
|
+
the same game runs in a browser, in Node without drawing, or faster than
|
|
61
|
+
real time in headless tests.
|
|
62
|
+
2. **The React binding** (`@air-jam/sdk`) starts the core for a host or a
|
|
63
|
+
controller page and lets components read it: `useAirJamHost`,
|
|
64
|
+
`useAirJamController`, `useAirJamStore`, `useSimulationFrame`. Hooks
|
|
65
|
+
subscribe to the core; they never keep a second copy of the runtime.
|
|
66
|
+
|
|
67
|
+
A game declares metadata, stores, simulation, controls and its agent contract
|
|
68
|
+
once in `src/airjam.config.ts` with `defineAirJamGame` from core.
|
|
69
|
+
`app.tsx` binds it with `createAirJamApp(airjam, { runtime })`. Store
|
|
70
|
+
definitions and simulations import from `@air-jam/sdk/core`; components import
|
|
71
|
+
from `@air-jam/sdk`.
|
|
72
|
+
|
|
73
|
+
**Entry points.** Each import path has one purpose:
|
|
74
|
+
|
|
75
|
+
| Import path | Purpose |
|
|
76
|
+
| ------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
|
|
77
|
+
| `@air-jam/sdk` | React binding: host and controller surfaces and hooks, audio and platform settings |
|
|
78
|
+
| `@air-jam/sdk/core` | Framework-free game declaration, agent helpers, networked stores, simulations and runtimes |
|
|
79
|
+
| `@air-jam/sdk/ui` | Ready-made React components for host and controller shells |
|
|
80
|
+
| `@air-jam/sdk/styles.css` | Styles for those components |
|
|
81
|
+
| `@air-jam/sdk/metadata` | The game's catalog metadata declaration |
|
|
82
|
+
| `@air-jam/sdk/prefabs` | Placeable scene pieces with previews |
|
|
83
|
+
| `@air-jam/sdk/preview` | Preview controllers shown beside a host during development |
|
|
84
|
+
| `@air-jam/sdk/protocol` | Shared schemas: players, actions, leased control, runtime reports |
|
|
85
|
+
| `@air-jam/sdk/room-protocol` | The room protocol: frames, close codes, channels and the input codec |
|
|
86
|
+
| `@air-jam/sdk/room-session` | A host's or phone's session in a room, and connectors for WebSockets and embedded frames |
|
|
87
|
+
| `@air-jam/sdk/runtime-topology` | Where a runtime connects in each run mode |
|
|
88
|
+
| `@air-jam/sdk/runtime-control` | Calling a running host: agent requests, actions and observations |
|
|
89
|
+
| `@air-jam/sdk/runtime-inspection` | Reading what a running host or controller publishes for tools |
|
|
90
|
+
| `@air-jam/sdk/agent-tooling` | Checking and evaluating a game's agent contract |
|
|
91
|
+
| `@air-jam/sdk/controller-bridge` | Serving an embedded controller page its seat from the page around it |
|
|
92
|
+
| `@air-jam/sdk/arcade/*` | Embedding games in the Arcade: `bridge/host`, `bridge/controller`, `bridge/iframe`, `host`, `runtime`, `surface`, `url` |
|
|
93
|
+
| `@air-jam/sdk/release`, `@air-jam/sdk/platform-machine` | Contracts with the hosted platform for releases and the CLI |
|
|
94
|
+
|
|
95
|
+
Games use the first five or six; the rest serve the CLI, MCP server, devtools,
|
|
96
|
+
the server and the hosted platform.
|
|
97
|
+
|
|
98
|
+
### 3. Creator Harness
|
|
99
|
+
|
|
100
|
+
The public CLI, MCP server and harness packages support project creation,
|
|
101
|
+
development, semantic game sessions, visual inspection and release preparation.
|
|
102
|
+
The same contracts work with external agents and the managed Studio; creator
|
|
103
|
+
tools do not depend on private application source.
|
|
104
|
+
|
|
105
|
+
### Reference Game: Air Capture (`games/air-capture`)
|
|
106
|
+
|
|
107
|
+
**Role:** Reference implementation showcasing SDK capabilities
|
|
108
|
+
|
|
109
|
+
**Technology:** React, Vite, React Three Fiber, Rapier Physics
|
|
110
|
+
|
|
111
|
+
**Demonstrates:**
|
|
112
|
+
|
|
113
|
+
- Host-side game logic with physics
|
|
114
|
+
- Controller UI with joystick and buttons
|
|
115
|
+
- Player spawning/despawning on join/leave
|
|
116
|
+
- Haptic feedback on collisions
|
|
117
|
+
- Multiple game modes (CTF, survival)
|
|
118
|
+
|
|
119
|
+
## Core Lane Model
|
|
120
|
+
|
|
121
|
+
Air Jam uses three lanes and they should stay separate:
|
|
122
|
+
|
|
123
|
+
1. **Input lane** for players' controls: declared with `defineAirJamInput`, filled by phone controls, agents or replays, and read once per simulation step
|
|
124
|
+
2. **Replicated state lane** for replayable shared state via `createAirJamStore`
|
|
125
|
+
3. **Signal / command lane** for coarse UX/runtime messages such as haptics, toasts, pause, and exit
|
|
126
|
+
|
|
127
|
+
This is the same model in standalone games and in Arcade-embedded games.
|
|
128
|
+
|
|
129
|
+
## Run Modes
|
|
130
|
+
|
|
131
|
+
The SDK automatically detects and adapts to different deployment scenarios:
|
|
132
|
+
|
|
133
|
+
### Standalone Mode
|
|
134
|
+
|
|
135
|
+
Your game connects straight to a room server over a WebSocket.
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
|
|
139
|
+
│ Your Game │◀───▶│ AirJam │◀───▶│ Controller │
|
|
140
|
+
│ (Host) │ │ Server │ │ (Phone) │
|
|
141
|
+
└──────────────┘ └──────────────┘ └──────────────┘
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**Use case:** Self-hosted games, development, custom deployments
|
|
145
|
+
|
|
146
|
+
### Arcade Mode
|
|
147
|
+
|
|
148
|
+
Game runs inside an iframe on the Air Jam Platform.
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
┌─────────────────────────────────────────┐
|
|
152
|
+
│ Air Jam Platform (Parent) │
|
|
153
|
+
│ ┌───────────────────────────────────┐ │
|
|
154
|
+
│ │ Your Game (iframe) │ │
|
|
155
|
+
│ │ • Room served by the Arcade │ │
|
|
156
|
+
│ │ • Same room, its own channels │ │
|
|
157
|
+
│ └───────────────────────────────────┘ │
|
|
158
|
+
└─────────────────────────────────────────┘
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
**Use case:** Featured on Air Jam arcade, game discovery
|
|
162
|
+
|
|
163
|
+
### Bridge Mode
|
|
164
|
+
|
|
165
|
+
Controller runs inside platform's runtime wrapper (iframe communication).
|
|
166
|
+
|
|
167
|
+
```
|
|
168
|
+
┌─────────────────────────────────────────┐
|
|
169
|
+
│ Platform Controller Runtime (Parent) │
|
|
170
|
+
│ ┌───────────────────────────────────┐ │
|
|
171
|
+
│ │ Your Controller UI (iframe) │ │
|
|
172
|
+
│ │ • Seat served via MessagePort │ │
|
|
173
|
+
│ │ • Seamless game switching │ │
|
|
174
|
+
│ └───────────────────────────────────┘ │
|
|
175
|
+
└─────────────────────────────────────────┘
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
**Use case:** Arcade mode controllers, persistent session
|
|
179
|
+
|
|
180
|
+
## Data Flow
|
|
181
|
+
|
|
182
|
+
### Input Path (Controller → Game)
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
1. Player holds a stick or button rendered by the SDK's phone controls
|
|
186
|
+
2. The controller's input lane updates the declared control's state
|
|
187
|
+
3. Once per display frame, if anything changed, the SDK sends one binary
|
|
188
|
+
input frame
|
|
189
|
+
4. The room passes each seat's latest frame to the host
|
|
190
|
+
5. The host's input lane decodes it against the declared controls
|
|
191
|
+
6. Before each simulation step, the host samples every player's controls and
|
|
192
|
+
applies each kind's meaning (a pressed button reads true for one step)
|
|
193
|
+
7. The step reads input(playerId)
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Signal Path (Game → Controller)
|
|
197
|
+
|
|
198
|
+
```
|
|
199
|
+
1. Game detects collision
|
|
200
|
+
2. Host calls sendSignal("HAPTIC", { pattern: "heavy" }, playerId)
|
|
201
|
+
3. The host's session sends a signal to that seat
|
|
202
|
+
4. The room delivers it to the seat's phone
|
|
203
|
+
5. Controller SDK receives signal
|
|
204
|
+
6. SDK triggers navigator.vibrate() with pattern
|
|
205
|
+
7. Player feels haptic feedback
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Security
|
|
209
|
+
|
|
210
|
+
### Opening a room
|
|
211
|
+
|
|
212
|
+
- A host's hello may carry a credential for the server's gate; a local server
|
|
213
|
+
needs none, and a self-hosted production server composes its own gate
|
|
214
|
+
(`createRoomServer({ gate })`) or runs open to any host
|
|
215
|
+
- A host returning to its room proves itself with its key alone, so a reload
|
|
216
|
+
keeps the room and its players
|
|
217
|
+
- An embedded game never opens a room of its own: the Arcade serves it the
|
|
218
|
+
Arcade's room over a MessagePort, scoped to that game's channels
|
|
219
|
+
|
|
220
|
+
### Room Isolation
|
|
221
|
+
|
|
222
|
+
- Each room has a unique code
|
|
223
|
+
- Phones can only join with the code, and hold their seat by their key
|
|
224
|
+
- Input reaches only the room's host
|
|
225
|
+
|
|
226
|
+
### Input Validation
|
|
227
|
+
|
|
228
|
+
- Every incoming input is checked against the game's declared controls
|
|
229
|
+
- Invalid input is dropped with an `AJ_INPUT_INVALID` diagnostic
|
|
230
|
+
- Agents' input passes the same check before they take a seat
|