@air-jam/cli 0.0.0-stage → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +145 -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/chunk-A4V2N4LX.js +938 -0
- package/dist/chunk-A4V2N4LX.js.map +1 -0
- package/dist/chunk-J5MAU4QZ.js +102 -0
- package/dist/chunk-J5MAU4QZ.js.map +1 -0
- package/dist/chunk-N7AI7HZK.js +529 -0
- package/dist/chunk-N7AI7HZK.js.map +1 -0
- package/dist/development.d.ts +98 -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/index.d.ts +1 -0
- package/dist/index.js +2184 -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 +78 -3
- package/runtime/local-network.d.mts +8 -0
- package/runtime/local-network.mjs +9 -0
- package/runtime/vite-config.d.mts +42 -0
- package/runtime/vite-config.mjs +130 -0
- package/runtime/vite-https.d.mts +11 -0
- package/runtime/vite-https.mjs +41 -0
- package/template-assets/bootstrap/.claude/launch.json +12 -0
- package/template-assets/bootstrap/AGENTS.md +248 -0
- package/template-assets/bootstrap/CLAUDE.md +63 -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 +56 -0
- package/template-assets/bootstrap/skills/canvas-2d-gameplay/SKILL.md +47 -0
- package/template-assets/bootstrap/skills/controller-ui/SKILL.md +69 -0
- package/template-assets/bootstrap/skills/debug-and-test/SKILL.md +72 -0
- package/template-assets/bootstrap/skills/game-architecture/SKILL.md +58 -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 +48 -0
- package/template-assets/bootstrap/skills/r3f-3d-scene/SKILL.md +51 -0
- package/template-assets/documentation/for-agents/controller-ui/page.mdx +60 -0
- package/template-assets/documentation/for-agents/page.mdx +98 -0
- package/template-assets/documentation/for-agents/project-structure/page.mdx +172 -0
- package/template-assets/documentation/for-agents/state-and-rendering/page.mdx +79 -0
- package/template-assets/documentation/getting-started/debugging/page.mdx +165 -0
- package/template-assets/documentation/getting-started/dev-logs/page.mdx +171 -0
- package/template-assets/documentation/getting-started/game-ideas/page.mdx +116 -0
- package/template-assets/documentation/getting-started/introduction/page.mdx +183 -0
- package/template-assets/documentation/getting-started/migrating-legacy-games/page.mdx +427 -0
- package/template-assets/documentation/getting-started/quick-start/page.mdx +333 -0
- package/template-assets/documentation/how-it-works/architecture/page.mdx +189 -0
- package/template-assets/documentation/how-it-works/host-system/page.mdx +267 -0
- package/template-assets/documentation/manifest.json +430 -0
- package/template-assets/documentation/sdk/hooks/page.mdx +500 -0
- package/template-assets/documentation/sdk/input-system/page.mdx +270 -0
- package/template-assets/documentation/sdk/networked-state/page.mdx +213 -0
- package/template-assets/documentation/sdk/ui-components/page.mdx +227 -0
- package/template-assets/managed/.airjam/ai-pack.json +191 -0
- package/template-assets/managed/docs/airjam/agent-gold-path.md +67 -0
- package/template-assets/managed/docs/airjam/agent-mcp.md +135 -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 +86 -0
- package/template-assets/managed/docs/airjam/development-loop.md +51 -0
- package/template-assets/managed/docs/airjam/docs-index.md +58 -0
- package/template-assets/managed/docs/airjam/generated/architecture.md +178 -0
- package/template-assets/managed/docs/airjam/generated/controller-ui.md +61 -0
- package/template-assets/managed/docs/airjam/generated/debugging-and-logs.md +164 -0
- package/template-assets/managed/docs/airjam/generated/for-agents.md +99 -0
- package/template-assets/managed/docs/airjam/generated/game-ideas.md +107 -0
- package/template-assets/managed/docs/airjam/generated/host-system.md +251 -0
- package/template-assets/managed/docs/airjam/generated/input-system.md +260 -0
- package/template-assets/managed/docs/airjam/generated/introduction.md +175 -0
- package/template-assets/managed/docs/airjam/generated/migrating-legacy-games.md +426 -0
- package/template-assets/managed/docs/airjam/generated/networked-state.md +214 -0
- package/template-assets/managed/docs/airjam/generated/project-structure.md +171 -0
- package/template-assets/managed/docs/airjam/generated/quick-start.md +334 -0
- package/template-assets/managed/docs/airjam/generated/sdk-hooks.md +490 -0
- package/template-assets/managed/docs/airjam/generated/state-and-rendering.md +80 -0
- package/template-assets/managed/docs/airjam/generated/ui-components.md +222 -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 +112 -0
- package/template-assets/managed/docs/airjam/preview-controllers.md +126 -0
- package/template-assets/managed/docs/airjam/r3f-3d-scene.md +97 -0
- package/template-assets/managed/docs/airjam/state-lanes-cookbook.md +106 -0
- package/template-assets/managed/docs/airjam/visual-system.md +103 -0
|
@@ -0,0 +1,333 @@
|
|
|
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 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`**: Canonical runtime setup and input wiring.
|
|
82
|
+
- **Modify `src/game/input.ts`**: Define your input schema.
|
|
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/host/index.tsx`**: Starter host/gameplay surface.
|
|
86
|
+
- **Modify `src/controller/index.tsx`**: Starter mobile controller surface.
|
|
87
|
+
- **Use `tests/game/`**: Starter testing pattern for domain, stores, engine, adapters, and shared game UI.
|
|
88
|
+
|
|
89
|
+
These paths are the current starter template shape.
|
|
90
|
+
They are recommended defaults for new projects, not framework-mandated filenames.
|
|
91
|
+
|
|
92
|
+
### Connect Your Coding Agent
|
|
93
|
+
|
|
94
|
+
Use your existing editor, terminal agent, or MCP client; Air Jam does not require
|
|
95
|
+
a separate hosted game editor. The generated project includes local instructions
|
|
96
|
+
and a portable `.mcp.json` declaration. A declaration is not the same as a client
|
|
97
|
+
being connected. Inspect the setup and render the configuration your client uses:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
pnpm exec airjam mcp doctor --dir . --json
|
|
101
|
+
pnpm exec airjam mcp config --profile portable --dir .
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The `codex` and `claude-desktop` profiles render their respective registration
|
|
105
|
+
formats. Configuration rendering is read-only: install the rendered entry in
|
|
106
|
+
your client, then check its tool discovery. See [For Agents](/docs/for-agents)
|
|
107
|
+
for semantic game control and a CLI-only path.
|
|
108
|
+
|
|
109
|
+
### Run the Complete Evaluation
|
|
110
|
+
|
|
111
|
+
Before sharing a game—and again after any repair—run the canonical complete evaluation:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
pnpm exec airjam evaluate --dir .
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
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.
|
|
118
|
+
|
|
119
|
+
### Refresh Managed Framework Guidance
|
|
120
|
+
|
|
121
|
+
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.
|
|
122
|
+
|
|
123
|
+
Use these commands from your project root:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
pnpm exec airjam ai-pack status --dir .
|
|
127
|
+
pnpm exec airjam ai-pack diff --dir .
|
|
128
|
+
pnpm exec airjam ai-pack update --dir .
|
|
129
|
+
pnpm exec airjam ai-pack repair --dir .
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
`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.
|
|
133
|
+
|
|
134
|
+
## Troubleshooting
|
|
135
|
+
|
|
136
|
+
### Server not connecting locally
|
|
137
|
+
|
|
138
|
+
1. Verify `pnpm run dev` is running.
|
|
139
|
+
2. Confirm server health: [http://localhost:4000/health](http://localhost:4000/health).
|
|
140
|
+
3. Confirm your game is using `http://localhost:4000` for `VITE_AIR_JAM_SERVER_URL` (or no override at all for local defaults).
|
|
141
|
+
|
|
142
|
+
### Local port already in use
|
|
143
|
+
|
|
144
|
+
Each parallel agent or project can run an isolated stack without stopping another one:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
AIR_JAM_SERVER_PORT=4400 \
|
|
148
|
+
VITE_PORT=5573 \
|
|
149
|
+
VITE_AIR_JAM_PUBLIC_HOST=http://127.0.0.1:5573 \
|
|
150
|
+
pnpm run dev
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
`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.
|
|
154
|
+
|
|
155
|
+
### App ID errors in deployed environments
|
|
156
|
+
|
|
157
|
+
1. Ensure `VITE_AIR_JAM_APP_ID` is set in your host platform.
|
|
158
|
+
2. Ensure the server URL points at your real Air Jam backend.
|
|
159
|
+
3. Re-copy the App ID from your game's dashboard settings if bootstrap fails.
|
|
160
|
+
|
|
161
|
+
### QR / controller join URL issues
|
|
162
|
+
|
|
163
|
+
1. Confirm host and controller are on the same room code.
|
|
164
|
+
2. If testing on phone outside localhost, set `VITE_AIR_JAM_PUBLIC_HOST` (or use `pnpm run dev -- --secure`).
|
|
165
|
+
3. For SPA hosting, ensure rewrites route `/controller?room=XXXX` to your app entry.
|
|
166
|
+
|
|
167
|
+
## 5. Connect Your Game To Air Jam Services
|
|
168
|
+
|
|
169
|
+
When you're ready to share your game outside local development, first register
|
|
170
|
+
it with Air Jam so the runtime has a stable hosted identity.
|
|
171
|
+
|
|
172
|
+
1. **Create a game record**:
|
|
173
|
+
- Go to the [Platform Dashboard](/dashboard)
|
|
174
|
+
- Create a game if you do not already have one
|
|
175
|
+
- Copy its **App ID**
|
|
176
|
+
|
|
177
|
+
An agent or terminal user can create the same hosted identity without
|
|
178
|
+
navigating the dashboard after the one-time browser-assisted login:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
pnpm exec airjam auth login
|
|
182
|
+
pnpm exec airjam game create --dir . --name "My Game" --slug my-game
|
|
183
|
+
pnpm exec airjam game inspect --game my-game
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
2. **Choose your distribution lane**:
|
|
187
|
+
- Deploy your game to a static hosting provider like Vercel, Netlify, or GitHub Pages.
|
|
188
|
+
- Use that self-hosted URL for normal private review and iteration.
|
|
189
|
+
- If you want public Air Jam Arcade distribution, publish a hosted release artifact in step 6 below.
|
|
190
|
+
- For self-hosted deployments, set the following environment variables:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
VITE_AIR_JAM_APP_ID=your_app_id_here
|
|
194
|
+
VITE_AIR_JAM_SERVER_URL=https://api.airjam.io # or your own Air Jam backend
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
The SDK handles production bootstrap automatically from that `appId`. You do not need to mint tokens or add auth code in your game.
|
|
198
|
+
If you want to lock production bootstrap to your deployed site only, set the
|
|
199
|
+
optional allowed-origin list for the App ID in the dashboard settings.
|
|
200
|
+
|
|
201
|
+
Before publishing your scaffolded game, run the local checks:
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
pnpm test
|
|
205
|
+
pnpm run typecheck
|
|
206
|
+
pnpm run build
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
If you are self-hosting the client, keep SPA rewrites enabled so `/controller?room=XXXX` resolves to your app entry.
|
|
210
|
+
|
|
211
|
+
### Optional: Stronger Signed Host Bootstrap
|
|
212
|
+
|
|
213
|
+
If you want stricter production ownership guarantees, you can keep the game static and add one small backend or edge endpoint that returns a signed host grant.
|
|
214
|
+
|
|
215
|
+
This requires a realtime backend that verifies those grants: the hosted Air Jam
|
|
216
|
+
backend or your own server composed with an `authService` adapter. The standalone
|
|
217
|
+
`air-jam-server` command does not read `AIR_JAM_HOST_GRANT_SECRET` and rejects host
|
|
218
|
+
grants by default. Setting the secret alone does not enable grant verification.
|
|
219
|
+
|
|
220
|
+
Frontend env:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
VITE_AIR_JAM_HOST_GRANT_ENDPOINT=/api/airjam/host-grant
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Grant issuer and verifying backend env (not the standalone server command):
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
AIR_JAM_HOST_GRANT_SECRET=your_signing_secret
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
The SDK will fetch the host grant automatically before `host:bootstrap`. Your game code stays unchanged.
|
|
233
|
+
|
|
234
|
+
Example endpoint shape:
|
|
235
|
+
|
|
236
|
+
```ts
|
|
237
|
+
import { createHostGrant } from "@air-jam/sdk/protocol";
|
|
238
|
+
|
|
239
|
+
export async function POST(request: Request) {
|
|
240
|
+
const { appId } = await request.json();
|
|
241
|
+
const { gameId, creatorId } = await loadTrustedAppIdentity(appId);
|
|
242
|
+
const now = Math.floor(Date.now() / 1000);
|
|
243
|
+
|
|
244
|
+
const hostGrant = await createHostGrant({
|
|
245
|
+
secret: process.env.AIR_JAM_HOST_GRANT_SECRET!,
|
|
246
|
+
claims: {
|
|
247
|
+
jti: crypto.randomUUID(),
|
|
248
|
+
aud: "airjam:realtime",
|
|
249
|
+
appId,
|
|
250
|
+
gameId,
|
|
251
|
+
creatorId,
|
|
252
|
+
iat: now,
|
|
253
|
+
exp: now + 60,
|
|
254
|
+
origins: ["https://your-game.example"],
|
|
255
|
+
sessionKind: "game",
|
|
256
|
+
},
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
return Response.json({ hostGrant });
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
`loadTrustedAppIdentity` represents your server-side lookup; never copy game or
|
|
264
|
+
creator identity from the browser request. That endpoint is also where you can
|
|
265
|
+
add your own rules, for example checking the signed-in user or limiting which
|
|
266
|
+
app IDs they are allowed to bootstrap.
|
|
267
|
+
|
|
268
|
+
## 6. Publish A Hosted Arcade Release
|
|
269
|
+
|
|
270
|
+
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.
|
|
271
|
+
|
|
272
|
+
1. Run the local hosted-release preflight from your project root:
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
pnpm exec airjam release doctor --dir .
|
|
276
|
+
pnpm exec airjam release validate --dir .
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
2. Build a hosted bundle from your project root:
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
pnpm exec airjam release bundle --dir .
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
That command:
|
|
286
|
+
|
|
287
|
+
- runs your build script
|
|
288
|
+
- bundles the static output from `dist/`
|
|
289
|
+
- writes `.airjam/release-manifest.json`
|
|
290
|
+
- creates a hosted release zip under `.airjam/releases/<version>/`
|
|
291
|
+
|
|
292
|
+
The scaffolded `release:bundle` script wraps `airjam release bundle --dir .` for you.
|
|
293
|
+
|
|
294
|
+
The hosted artifact contract is fixed:
|
|
295
|
+
|
|
296
|
+
- host entry at `/`
|
|
297
|
+
- controller entry at `/controller`
|
|
298
|
+
|
|
299
|
+
### Terminal or Agent Publishing
|
|
300
|
+
|
|
301
|
+
The CLI can bundle, upload, and wait for validation using the same release
|
|
302
|
+
services as the dashboard. Use the game slug or ID created in step 5:
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
pnpm exec airjam release submit --game my-game --dir . --wait
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
This leaves the processed release unpublished. Inspect the returned release ID,
|
|
309
|
+
then explicitly make it live when you are ready:
|
|
310
|
+
|
|
311
|
+
```bash
|
|
312
|
+
pnpm exec airjam release inspect --release <release-id>
|
|
313
|
+
pnpm exec airjam release publish --release <release-id>
|
|
314
|
+
pnpm exec airjam game media --help
|
|
315
|
+
pnpm exec airjam game update --game my-game --arcade-visibility listed
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
Publishing a release and listing its game are separate decisions. A processing
|
|
319
|
+
timeout does not cancel the background job: inspect the same release rather
|
|
320
|
+
than submitting another copy. CLI responses retain the release and generation
|
|
321
|
+
identities needed to resume work.
|
|
322
|
+
|
|
323
|
+
### Dashboard Publishing
|
|
324
|
+
|
|
325
|
+
Alternatively, upload the zip produced by `airjam release bundle` above:
|
|
326
|
+
|
|
327
|
+
1. Go to your game's **Releases** page in the [Dashboard](/dashboard).
|
|
328
|
+
2. Upload the generated zip artifact.
|
|
329
|
+
3. Make the validated release live.
|
|
330
|
+
4. Upload managed thumbnail, cover, and preview media in the Dashboard.
|
|
331
|
+
5. Set the game's Arcade visibility to listed.
|
|
332
|
+
|
|
333
|
+
Your game is now live in the public Arcade on Air Jam-hosted infrastructure.
|
|
@@ -0,0 +1,189 @@
|
|
|
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. Server (`packages/server`)
|
|
23
|
+
|
|
24
|
+
**Role:** Real-time communication backbone
|
|
25
|
+
|
|
26
|
+
**Technology:** Node.js, Express, Socket.IO
|
|
27
|
+
|
|
28
|
+
**Core Services:**
|
|
29
|
+
|
|
30
|
+
<CoreServicesDiagram />
|
|
31
|
+
|
|
32
|
+
**Socket Events:**
|
|
33
|
+
|
|
34
|
+
<SocketEventsDiagram />
|
|
35
|
+
|
|
36
|
+
### 2. SDK (`packages/sdk`)
|
|
37
|
+
|
|
38
|
+
**Role:** Developer toolkit for building Air Jam games
|
|
39
|
+
|
|
40
|
+
**Technology:** React, TypeScript, Socket.IO Client, Zustand, Zod
|
|
41
|
+
|
|
42
|
+
**Architecture:**
|
|
43
|
+
|
|
44
|
+
<SdkArchitectureDiagram />
|
|
45
|
+
|
|
46
|
+
**Key Design Decisions:**
|
|
47
|
+
|
|
48
|
+
1. **Provider Pattern** - Single provider for configuration, multiple hooks for access
|
|
49
|
+
2. **Lightweight Hooks** - `useGetInput`, `useSendSignal` don't trigger re-renders
|
|
50
|
+
3. **Input Latching** - Ensures rapid button taps are never missed
|
|
51
|
+
4. **Schema Validation** - Type-safe input with runtime validation
|
|
52
|
+
|
|
53
|
+
### 3. Creator Harness
|
|
54
|
+
|
|
55
|
+
The public CLI, MCP server and harness packages support project creation,
|
|
56
|
+
development, semantic game sessions, visual inspection and release preparation.
|
|
57
|
+
The same contracts work with external agents and the managed Studio; creator
|
|
58
|
+
tools do not depend on private application source.
|
|
59
|
+
|
|
60
|
+
### Reference Game: Air Capture (`games/air-capture`)
|
|
61
|
+
|
|
62
|
+
**Role:** Reference implementation showcasing SDK capabilities
|
|
63
|
+
|
|
64
|
+
**Technology:** React, Vite, React Three Fiber, Rapier Physics
|
|
65
|
+
|
|
66
|
+
**Demonstrates:**
|
|
67
|
+
|
|
68
|
+
- Host-side game logic with physics
|
|
69
|
+
- Controller UI with joystick and buttons
|
|
70
|
+
- Player spawning/despawning on join/leave
|
|
71
|
+
- Haptic feedback on collisions
|
|
72
|
+
- Multiple game modes (CTF, survival)
|
|
73
|
+
|
|
74
|
+
## Core Lane Model
|
|
75
|
+
|
|
76
|
+
Air Jam uses three lanes and they should stay separate:
|
|
77
|
+
|
|
78
|
+
1. **Input lane** for high-frequency transient control data via `useInputWriter` and `getInput` / `useGetInput`
|
|
79
|
+
2. **Replicated state lane** for replayable shared state via `createAirJamStore`
|
|
80
|
+
3. **Signal / command lane** for coarse UX/runtime messages such as haptics, toasts, pause, and exit
|
|
81
|
+
|
|
82
|
+
This is the same model in standalone games and in Arcade-embedded games.
|
|
83
|
+
|
|
84
|
+
## Run Modes
|
|
85
|
+
|
|
86
|
+
The SDK automatically detects and adapts to different deployment scenarios:
|
|
87
|
+
|
|
88
|
+
### Standalone Mode
|
|
89
|
+
|
|
90
|
+
Your game runs independently with direct WebSocket connection.
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
|
|
94
|
+
│ Your Game │◀───▶│ AirJam │◀───▶│ Controller │
|
|
95
|
+
│ (Host) │ │ Server │ │ (Phone) │
|
|
96
|
+
└──────────────┘ └──────────────┘ └──────────────┘
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**Use case:** Self-hosted games, development, custom deployments
|
|
100
|
+
|
|
101
|
+
### Arcade Mode
|
|
102
|
+
|
|
103
|
+
Game runs inside an iframe on the Air Jam Platform.
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
┌─────────────────────────────────────────┐
|
|
107
|
+
│ Air Jam Platform (Parent) │
|
|
108
|
+
│ ┌───────────────────────────────────┐ │
|
|
109
|
+
│ │ Your Game (iframe) │ │
|
|
110
|
+
│ │ • Receives launch capability │ │
|
|
111
|
+
│ │ • Controlled player routing │ │
|
|
112
|
+
│ └───────────────────────────────────┘ │
|
|
113
|
+
└─────────────────────────────────────────┘
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**Use case:** Featured on Air Jam arcade, game discovery
|
|
117
|
+
|
|
118
|
+
### Bridge Mode
|
|
119
|
+
|
|
120
|
+
Controller runs inside platform's runtime wrapper (iframe communication).
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
┌─────────────────────────────────────────┐
|
|
124
|
+
│ Platform Controller Runtime (Parent) │
|
|
125
|
+
│ ┌───────────────────────────────────┐ │
|
|
126
|
+
│ │ Your Controller UI (iframe) │ │
|
|
127
|
+
│ │ • Input via postMessage │ │
|
|
128
|
+
│ │ • Seamless game switching │ │
|
|
129
|
+
│ └───────────────────────────────────┘ │
|
|
130
|
+
└─────────────────────────────────────────┘
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Use case:** Arcade mode controllers, persistent session
|
|
134
|
+
|
|
135
|
+
## Data Flow
|
|
136
|
+
|
|
137
|
+
### Input Path (Controller → Game)
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
1. Player moves joystick on phone
|
|
141
|
+
2. Controller publishes input via useInputWriter({ vector: {x, y}, action: false })
|
|
142
|
+
3. SDK sends controller:input event to server
|
|
143
|
+
4. Server routes to host socket
|
|
144
|
+
5. Host SDK's InputManager receives input
|
|
145
|
+
6. InputManager validates with Zod schema
|
|
146
|
+
7. InputManager applies configured input behavior (`pulse`, `hold`, `latest`)
|
|
147
|
+
8. Game calls getInput(playerId) in game loop
|
|
148
|
+
9. Returns typed, validated input with behavior semantics applied
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Signal Path (Game → Controller)
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
1. Game detects collision
|
|
155
|
+
2. Host calls sendSignal("HAPTIC", { pattern: "heavy" }, playerId)
|
|
156
|
+
3. SDK sends host:signal event to server
|
|
157
|
+
4. Server routes to target controller(s)
|
|
158
|
+
5. Controller SDK receives signal
|
|
159
|
+
6. SDK triggers navigator.vibrate() with pattern
|
|
160
|
+
7. Player feels haptic feedback
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Security
|
|
164
|
+
|
|
165
|
+
### Host Bootstrap
|
|
166
|
+
|
|
167
|
+
- Hosts perform one `host:bootstrap` verification step in production/static mode
|
|
168
|
+
- In normal static mode, the server validates the browser-facing `appId` once, then binds host authority to the socket
|
|
169
|
+
- Static apps can optionally restrict bootstrap by allowed origin per app identity
|
|
170
|
+
- In optional signed mode, the SDK first fetches a short-lived host grant from `hostGrantEndpoint`, then bootstraps with that grant instead of raw `appId`
|
|
171
|
+
- Later host lifecycle events rely on socket authority instead of repeated raw auth payloads
|
|
172
|
+
|
|
173
|
+
### Child Launch Capability
|
|
174
|
+
|
|
175
|
+
- Arcade game launch issues a room/game-scoped `launchCapability`
|
|
176
|
+
- Embedded host iframes receive `aj_cap` / `aj_cap_exp` automatically
|
|
177
|
+
- Game code does not parse or manage this capability directly
|
|
178
|
+
|
|
179
|
+
### Room Isolation
|
|
180
|
+
|
|
181
|
+
- Each room has unique 4-character code
|
|
182
|
+
- Controllers can only join with correct code
|
|
183
|
+
- Input is only routed to the designated host
|
|
184
|
+
|
|
185
|
+
### Input Validation
|
|
186
|
+
|
|
187
|
+
- Zod schemas validate all incoming input
|
|
188
|
+
- Invalid input is rejected with console warning
|
|
189
|
+
- Protects game logic from malformed data
|