@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,72 @@
1
+ ---
2
+ name: debug-and-test
3
+ description: Use when debugging or validating an Air Jam project so diagnostics, logging, and tests stay intentional, structured, and aligned with the project architecture.
4
+ ---
5
+
6
+ # Debug And Test
7
+
8
+ Use this skill when adding debug helpers, using logs, or deciding what to test.
9
+
10
+ ## Read First
11
+
12
+ 1. `docs/airjam/debug-and-testing.md`
13
+ 2. `docs/airjam/development-loop.md`
14
+ 3. `docs/airjam/generated/unified-dev-logs.md`
15
+
16
+ ## Debug Order
17
+
18
+ 1. inspect the canonical Air Jam dev log stream first
19
+ 2. use framework diagnostics second
20
+ 3. use domain-level debug helpers third
21
+ 4. add custom logs only when they add clear value
22
+
23
+ ## Canonical Log Workflow
24
+
25
+ Use the unified Air Jam log stream early when debugging host/controller/server issues.
26
+
27
+ Key facts:
28
+
29
+ 1. the canonical file is `.airjam/logs/dev-latest.ndjson`
30
+ 2. it resets when the Air Jam server process restarts
31
+ 3. `pnpm exec air-jam-server logs` is the preferred path
32
+ 4. direct file reads are valid when you need the raw stream
33
+ 5. standard dev-runner failures from Vite and similar tools should also appear there as `workspace` events
34
+ 6. this should usually come before adding new temporary logs
35
+
36
+ Query order:
37
+
38
+ 1. start with `pnpm exec air-jam-server logs --view=signal`
39
+ 2. use `--trace` for host-session stories
40
+ 3. use `--room` for one multiplayer room story
41
+ 4. use `--controller` for one player/controller path
42
+ 5. use `--runtime` and `--epoch` for embedded runtime problems
43
+ 6. use `--process` when the likely failure is in one local dev process such as `platform`, `server`, or the active game
44
+ 7. use `--source` when you already know which producer layer you need
45
+ 8. fall back to raw NDJSON when signal view is still not enough
46
+
47
+ ## Test Order
48
+
49
+ 1. pure domain logic with unit tests
50
+ 2. focused gameplay systems with behavior tests
51
+ 3. targeted integration coverage only where the boundary really matters
52
+
53
+ If the starter testing layout exists, prefer:
54
+
55
+ 1. `tests/game/domain/`
56
+ 2. `tests/game/stores/`
57
+ 3. `tests/game/engine/`
58
+ 4. `tests/game/adapters/`
59
+ 5. `tests/game/ui/`
60
+
61
+ ## Structure Rules
62
+
63
+ 1. keep debug helpers under `src/game/debug/`
64
+ 2. keep debug-only code out of hot gameplay paths
65
+ 3. prefer structured logs over ad hoc console noise
66
+ 4. keep core logic testable without rendering where practical
67
+
68
+ ## Anti-Patterns
69
+
70
+ 1. bolting debug code directly into render hot paths
71
+ 2. waiting until the project is tangled before writing tests
72
+ 3. testing implementation details instead of behavior
@@ -0,0 +1,102 @@
1
+ ---
2
+ name: game-architecture
3
+ description: Use when creating or refactoring gameplay code in an Air Jam project and you need guidance on host vs controller vs domain boundaries, modular structure, and when to refactor before implementing.
4
+ ---
5
+
6
+ # Game Architecture
7
+
8
+ Use this skill when adding new systems or moving code between boundaries.
9
+
10
+ ## Read First
11
+
12
+ 1. `docs/airjam/generated/project-structure.md`
13
+ 2. `docs/airjam/generated/architecture.md`
14
+
15
+ ## Boundary Model
16
+
17
+ Prefer this split:
18
+
19
+ 1. `src/airjam.config.ts` for the framework-free `defineAirJamGame` declaration from `@air-jam/sdk/core`: metadata, stores, simulation, input, bindings, agent and testing path
20
+ 2. `src/app.tsx` for `createAirJamApp(airjam, { runtime })` and mounting its host/controller runtime boundaries
21
+ 3. `src/host/` for host-only composition
22
+ 4. `src/controller/` for controller-only composition
23
+ 5. `src/game/domain/` for pure rules
24
+ 6. `src/game/engine/` for orchestration
25
+ 7. `src/game/systems/` for focused gameplay systems
26
+ 8. `src/game/adapters/` for framework integration
27
+ 9. `src/game/ui/` for reusable game-facing UI
28
+ 10. `src/game/debug/` for debug helpers
29
+
30
+ Keep runtime ownership explicit:
31
+
32
+ 1. mount `app.Host` / `app.Controller` from the React binding once at the boundary
33
+ 2. use consumer hooks like `useAirJamHost()` and `useAirJamController()` only below that boundary
34
+ 3. keep gameplay code out of runtime setup and transport bootstrap
35
+
36
+ ## Decision Rule
37
+
38
+ Ask:
39
+
40
+ 1. is this pure gameplay logic
41
+ 2. is this runtime orchestration
42
+ 3. is this rendering integration
43
+ 4. is this host-only or controller-only
44
+
45
+ Put the code where the answer is clearest.
46
+
47
+ ## Refactor-First Rule
48
+
49
+ If new work would harden a mixed boundary, split the structure first or split the task into:
50
+
51
+ 1. boundary cleanup
52
+ 2. feature implementation
53
+
54
+ ## Anti-Patterns
55
+
56
+ 1. one large file that mixes host, controller, domain, and rendering concerns
57
+ 2. React components as the only home for gameplay logic
58
+ 3. adapter code becoming the real game model
59
+
60
+ ## One game declaration
61
+
62
+ Read `airjam.inspect_game` for the versioned `declaration`, including
63
+ `declaration.agent`, controls, controller path and metadata. The game's
64
+ `src/airjam.config.ts` exports `airjam = defineAirJamGame(...)` from
65
+ `@air-jam/sdk/core`; agent helpers also come from core. Keep React, the SDK
66
+ root, TSX and CSS out of its graph. `app.tsx` alone binds it with
67
+ `createAirJamApp(airjam, { runtime })`.
68
+
69
+ Capacity comes from `metadata.maxPlayers`. The `testing` path names a module
70
+ exporting `testing = defineAirJamTesting({ player, profiles, visual })` from
71
+ `@air-jam/devtools/testing`. Profiles author scripted policies only; a declared
72
+ player is offered as the reserved `model` policy in every profile. Optional
73
+ `visual.scenarios` uses the game's declared agent. A profile's `setup` brings
74
+ the room to where its test starts; its `handBack` returns the creator's room,
75
+ usually with `return_to_lobby`, once the test ends and before its players
76
+ leave, so the game never plays on without them. Profiles that join play already
77
+ under way hand it back too. Declare `handBack: []` only when the game has no
78
+ phase to leave, such as a shared counter; a missing one is reported as
79
+ `undeclared` in the run record. Do not duplicate identity in template flags or read config source with
80
+ regular expressions.
81
+
82
+ ## Declared settings
83
+
84
+ Declare creator tuning values with `defineAirJamSettings` and `setting` from
85
+ `@air-jam/sdk/core`, in the game declaration's `settings` field. Remove the
86
+ constants they replace. Read values in simulation create/step/observe contexts
87
+ and typed action contexts; host rendering uses `useAirJamSettings`. Controllers
88
+ show copies in replicated state. Lobby player choices stay store state.
89
+
90
+ Inspect descriptors in `airjam.inspect_game` → `declaration.settings`.
91
+ Use `airjam.read_game_settings({ gameSessionId })` for live values and revision,
92
+ then `airjam.update_game_settings({ gameSessionId, patch, expectedRevision })`
93
+ under host authority. Only `live: true` values can change; non-live values go
94
+ in `airjam.start_game_run({ settings, ... })` for a fresh room. Stale revisions
95
+ require a fresh read. Input log version 2 records initial values and ordered
96
+ settings updates for replay. See `docs/airjam/generated/settings.md`.
97
+
98
+ Declared assets and theme are read through `airjam.inspect_game` in
99
+ `declaration.assets` and `declaration.theme`. Keep sounds, images and loaded
100
+ files in `defineAirJamAssets`, colours and font families in `defineAirJamTheme`,
101
+ and pass both to `defineAirJamGame`. The React binding owns audio mounts and
102
+ theme CSS variables; games consume the declared objects and never duplicate them.
@@ -0,0 +1,44 @@
1
+ ---
2
+ name: game-state-and-rendering
3
+ description: Use when changing stores, per-frame gameplay logic, React state, refs, or rendering integration in an Air Jam project so state ownership stays clear and rerenders stay controlled.
4
+ ---
5
+
6
+ # Game State And Rendering
7
+
8
+ Use this skill when a task touches state ownership, per-frame updates, or rendering hot paths.
9
+
10
+ ## Read First
11
+
12
+ 1. `docs/airjam/generated/state-and-rendering.md`
13
+ 2. `docs/airjam/generated/input-system.md`
14
+ 3. `docs/airjam/generated/networked-state.md`
15
+
16
+ ## Core Rules
17
+
18
+ 1. keep input in the input lane
19
+ 2. keep authoritative shared truth in replicated state
20
+ 3. keep coarse UX/system events in signals
21
+ 4. keep per-frame mutable values out of React state when React rendering is not needed
22
+ 5. use narrow Zustand selectors
23
+
24
+ ## Decision Guide
25
+
26
+ Use:
27
+
28
+ 1. replicated state for replayable shared truth
29
+ 2. local UI state for local view concerns
30
+ 3. refs for hot mutable runtime values
31
+ 4. pure domain modules for rules and calculations
32
+
33
+ ## R3F / Three Guidance
34
+
35
+ 1. avoid per-frame React rerenders
36
+ 2. mutate refs in frame handlers when appropriate
37
+ 3. keep scene integration separate from domain decisions
38
+
39
+ ## Anti-Patterns
40
+
41
+ 1. using store actions for high-frequency input
42
+ 2. using React state as the simulation engine
43
+ 3. selecting whole stores throughout the tree
44
+ 4. mixing debug state into hot loops
@@ -0,0 +1,52 @@
1
+ ---
2
+ name: host-surface
3
+ description: Use when building or reviewing the Air Jam host shell so the active game surface stays full-frame, overlays stay modular, and host UI does not interfere with gameplay layout.
4
+ ---
5
+
6
+ # Host Surface
7
+
8
+ Use this skill for host presentation, overlays, room chrome, and game viewport composition.
9
+
10
+ ## Read First
11
+
12
+ 1. `docs/airjam/generated/host-system.md`
13
+ 2. `docs/airjam/generated/project-structure.md`
14
+ 3. `docs/airjam/visual-system.md` if the template already ships a shared visual language
15
+ 4. `docs/airjam/generated/controller-ui.md` only if the host and controller should mirror a shared visual language
16
+ 5. `docs/airjam/composition-shell-contract.md` when the host lobby/join shell is part of the work
17
+
18
+ ## Surface Rules
19
+
20
+ 1. the active game surface should fill an absolute `inset-0` root
21
+ 2. avoid wrappers that constrain, crop, or offset the play surface accidentally
22
+ 3. keep host chrome outside the gameplay coordinate space where possible
23
+ 4. keep overlays layered above the game surface, not embedded into gameplay components
24
+
25
+ ## Composition Rules
26
+
27
+ 1. separate room bootstrap, shell, gameplay viewport, and overlays into distinct modules
28
+ 2. keep host-only orchestration in `src/host/`
29
+ 3. keep gameplay state and rendering concerns in `src/game/`
30
+ 4. prefer reusable overlay modules over inline one-off markup
31
+
32
+ ## Layout Rules
33
+
34
+ 1. avoid overflow bugs on the main host surface
35
+ 2. prefer fluid sizing over fixed panel widths and heights
36
+ 3. keep QR, room, pause, and status UI visually secondary to the active game
37
+ 4. keep readable safe margins for overlays without shrinking the gameplay surface unnecessarily
38
+
39
+ ## Lobby Contract Rule
40
+
41
+ For host lobby work:
42
+
43
+ 1. the host lobby should expose room context, QR access, join URL field, copy/open actions, and a primary start action
44
+ 2. prefer `useHostJoinControls` plus `JoinQrOverlay`, `JoinUrlField`, `JoinUrlActionButtons`, `JoinUrlControls`, and `LifecycleActionGroup` unless the game needs a fully custom shell
45
+ 3. if the shell is fully custom, preserve the same join and lifecycle behavior contract
46
+
47
+ ## Anti-Patterns
48
+
49
+ 1. gameplay rendered inside a card, panel, or centered content column
50
+ 2. host shell state mixed directly into gameplay components
51
+ 3. overlay UI positioned by guesswork inside the game scene
52
+ 4. host layout choices that make the game viewport smaller than necessary
@@ -0,0 +1,36 @@
1
+ # Skills Index
2
+
3
+ These local skills teach how to work in this repo.
4
+
5
+ Do not read every skill for every task.
6
+
7
+ Pick the one that matches the current problem.
8
+
9
+ ## Core Skills
10
+
11
+ 1. `airjam-mcp`
12
+ Use when the project includes the Air Jam MCP and the task fits Air Jam-native devtools flows such as project inspection, log reading, and quality gates.
13
+ 2. `airjam-docs-workflow`
14
+ Use when you need canonical guidance and need to know whether local docs or hosted docs should be consulted.
15
+ 3. `game-architecture`
16
+ Use when creating systems, moving code, or deciding where logic should live.
17
+ 4. `game-state-and-rendering`
18
+ Use when changing stores, frame logic, refs, React state, or rendering integration.
19
+ 5. `controller-ui`
20
+ Use when building or reviewing controller surfaces, including the shared controller shell contract, lifecycle actions, and icon choices for controller and gameplay UI.
21
+ 6. `debug-and-test`
22
+ Use when debugging with the unified dev log stream, adding diagnostics, or writing tests.
23
+ 7. `host-surface`
24
+ Use when building or reviewing the host shell, host-lobby join contract, active game viewport, overlays, and room-facing presentation.
25
+ 8. `prefab-authoring`
26
+ Use when creating reusable gameplay objects or scene presets that should stay declarative, configurable, and tool-friendly.
27
+ 9. `r3f-3d-scene`
28
+ For R3F or Three.js work, read `skills/r3f-3d-scene/SKILL.md` before creating scene objects.
29
+ 10. `canvas-2d-gameplay`
30
+ Use when building or reviewing 2D canvas gameplay, render/simulation separation, scaling, SVG assets, and lightweight collision patterns.
31
+
32
+ ## Rule
33
+
34
+ If the task does not match a skill boundary, do not force it.
35
+
36
+ Use the smallest relevant guidance.
@@ -0,0 +1,58 @@
1
+ ---
2
+ name: prefab-authoring
3
+ description: Use when creating reusable gameplay objects or scene presets so prefabs stay declarative, configurable, and ready for future tooling such as previews and scanned catalogs.
4
+ ---
5
+
6
+ # Prefab Authoring
7
+
8
+ Use this skill when adding reusable scene objects, pickups, obstacles, props, spawnable entities, or authored content presets.
9
+
10
+ ## Read First
11
+
12
+ 1. `docs/airjam/prefab-authoring.md`
13
+ 2. `docs/airjam/generated/project-structure.md`
14
+ 3. `docs/airjam/generated/state-and-rendering.md` if the prefab introduces hot runtime behavior
15
+
16
+ ## Contract Rule
17
+
18
+ A prefab should be a reusable content unit, not a hidden pile of gameplay logic.
19
+
20
+ Keep the prefab definition declarative and stable enough that future tooling can:
21
+
22
+ 1. scan it
23
+ 2. render a preview
24
+ 3. expose safe config
25
+ 4. instantiate it consistently
26
+
27
+ ## Structure Rules
28
+
29
+ 1. place prefab code under `src/game/prefabs/`
30
+ 2. keep metadata, schema, and runtime component clearly separated
31
+ 3. put pure behavior in domain/system modules when it outgrows the prefab itself
32
+ 4. avoid coupling prefab definitions directly to scene-global mutable state
33
+ 5. keep scene-population, spawn, and pooling layers outside `src/game/prefabs/`
34
+
35
+ ## Config Rules
36
+
37
+ 1. expose explicit defaults
38
+ 2. keep config serializable where practical
39
+ 3. use stable ids, labels, categories, and tags
40
+ 4. avoid hidden magic props or implicit scene dependencies
41
+
42
+ ## Anti-Patterns
43
+
44
+ 1. one-off scene objects masquerading as reusable prefabs
45
+ 2. prefab files that bury behavior, metadata, and config in one component
46
+ 3. prefab placement rules that depend on trial-and-error offsets
47
+ 4. prefab contracts that are too ad hoc for future scanning or preview generation
48
+ 5. plural runtime mappers like `Ships` or `Collectibles` living in `src/game/prefabs/` when they are actually population layers over state
49
+
50
+ Declare every asset once as a prefab with optional `space` and real `states`.
51
+ Without `space`, `preview.camera` implies `"3d"`; otherwise it is `"2d"`.
52
+ Use a renderer-free declaration in config; rendered definitions still require `render`.
53
+ Attach `createPrefabCatalog([...])` as `defineAirJamGame({ prefabs })`, and supply
54
+ `<app.Host prefabStage={Stage}>`. Read the managed prefab-authoring guide for the
55
+ complete stage example. The stage uses `usePrefabInspection()` and
56
+ `useHostAgentCapture`, draws from the SDK clock and applies the canonical view.
57
+ Inspect at least three angles or states through the inspector before presenting
58
+ an asset; then verify it in the live game. Do not create a second capture catalog.
@@ -0,0 +1,61 @@
1
+ ---
2
+ name: r3f-3d-scene
3
+ description: Use when building or reviewing a 3D Air Jam game with React Three Fiber so scene structure, lighting, shadows, grounding, particles, and physics stay deliberate instead of becoming ad hoc Three.js chaos.
4
+ ---
5
+
6
+ # R3F 3D Scene
7
+
8
+ Use this skill for 3D host gameplay surfaces built with React Three Fiber and Three.js.
9
+
10
+ ## Read First
11
+
12
+ 1. `docs/airjam/r3f-3d-scene.md`
13
+ 2. `docs/airjam/generated/state-and-rendering.md`
14
+ 3. `docs/airjam/generated/project-structure.md`
15
+
16
+ ## Core Rule
17
+
18
+ Before importing 3D libraries, follow the dependency setup in
19
+ `docs/airjam/r3f-3d-scene.md`. Starters do not include Three.js or React Three
20
+ Fiber. In Studio, use `studio_change_dependency`; elsewhere use the project's
21
+ package manager. Add only the libraries this game uses.
22
+
23
+ In React, create three.js objects inside an effect, keep them in state and free
24
+ them in its cleanup, never during render into a useRef, useMemo or module
25
+ variable: live edits and StrictMode rerun effects, so an object kept from render
26
+ is freed while still shown and the scene goes empty.
27
+
28
+ Treat R3F as a rendering layer.
29
+
30
+ Keep:
31
+
32
+ 1. gameplay rules in domain/system modules
33
+ 2. runtime orchestration in engine/adapters
34
+ 3. scene composition and visual presentation in the 3D layer
35
+
36
+ ## Scene Quality Rules
37
+
38
+ 1. establish a deliberate lighting recipe early
39
+ 2. define world origin, ground level, and object placement conventions clearly
40
+ 3. keep shadows intentionally tuned to the actual play area
41
+ 4. use particles and post effects as accents, not camouflage for weak art direction
42
+
43
+ ## Physics Rule
44
+
45
+ Use Rapier when the game really benefits from rigid-body style simulation, collision response, or stacked interactions.
46
+
47
+ If gameplay only needs simple movement, overlap checks, or authored responses, prefer a lighter custom movement/collision model.
48
+
49
+ ## Asset Rule
50
+
51
+ 1. keep model scale and grounding consistent
52
+ 2. prefer curated materials and textures over random defaults
53
+ 3. use custom shaders only when they materially improve the look or mechanic
54
+
55
+ ## Anti-Patterns
56
+
57
+ 1. React state driving per-frame scene simulation
58
+ 2. giant untuned shadow maps with clipped or blurry shadows
59
+ 3. floating models fixed by random per-scene offsets
60
+ 4. adding a full physics engine where simple authored logic would be clearer
61
+ 5. piling on particles, bloom, or shaders before the base scene reads well
@@ -0,0 +1,99 @@
1
+ # Controller UI
2
+
3
+ Controller UI should feel like a game controller first and a webpage second.
4
+
5
+ The main failure mode is borrowing desktop web-app patterns for active gameplay surfaces.
6
+
7
+ ## Gameplay Controller Rules
8
+
9
+ 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.
10
+
11
+ For active gameplay:
12
+
13
+ 1. use an absolute `inset-0` root
14
+ 2. avoid scroll
15
+ 3. disable accidental text selection
16
+ 4. use large touch targets
17
+ 5. keep controls visually obvious and single-purpose
18
+ 6. minimize text and dense hierarchy
19
+
20
+ ## Sideways Controllers
21
+
22
+ A sideways phone is held like a gamepad, so its controls use the screen like one. Compose them in `GamepadLayout`:
23
+
24
+ 1. the stick goes in `left` and the actions in `right`; both get the same square, so they carry the same weight and mirror each other about the centre, each centred in its thumb zone on one line
25
+ 2. a single action fills its square; several actions share it as one cluster, as phone action games do, rather than starting a third column: the main action sits at the square's centre under the resting thumb at about half the square's width, each other action is about two thirds of the main one's size on a tight arc around its inner side (below, toward the centre, above) with the most used nearest, a rarely used utility goes smaller on the outer side, and every button stays inside the thumb zone
26
+ 3. a button with a cooldown shows it on itself: a dark sweep over the icon that shrinks as it recovers, the seconds left when the wait is over a second, and full colour once it is ready again
27
+ 4. buttons show icons, not words, drawn as one family: the same grid, the same stroke width with round caps and joins (or all filled), the same optical size of about half the button, one simple silhouette each and no detail finer than the stroke; judge them at real size on a phone
28
+ 5. `center` holds only what a player reads at a glance: a round, a number, a word, a few icons; it never wraps into squeezed lines
29
+ 6. a longer message goes in the header bar above the layout, or stays on the TV
30
+
31
+ ```tsx
32
+ import { ControlButton, GamepadLayout, Stick } from "@air-jam/sdk/ui";
33
+
34
+ // Before: a big stick, a small button pushed to the edge, a sentence wrapping between them.
35
+ <div className="flex h-full items-center justify-between px-6">
36
+ <Stick control={gameInput.move} className="size-56" />
37
+ <p className="max-w-48 text-2xl">Splash! Back next round</p>
38
+ <ControlButton control={gameInput.dash} className="size-28">Dash</ControlButton>
39
+ </div>
40
+
41
+ // After: equal mirrored thumbs, a glanceable centre, the sentence in the header.
42
+ <GamepadLayout
43
+ left={<Stick control={gameInput.move} className="rounded-full bg-white/10" />}
44
+ center={<span className="text-xs uppercase">Round 1</span>}
45
+ right={<ControlButton control={gameInput.dash} className="rounded-full bg-sky-400">Dash</ControlButton>}
46
+ />
47
+ ```
48
+
49
+ ## Lobby Rules
50
+
51
+ Lobby screens can be slightly more flexible, but should still prefer:
52
+
53
+ 1. simple layout
54
+ 2. large controls
55
+ 3. minimal friction
56
+ 4. scroll only when it actually helps the flow
57
+
58
+ ## Interaction Rules
59
+
60
+ Avoid:
61
+
62
+ 1. tiny toggles
63
+ 2. multi-purpose buttons with unclear affordance
64
+ 3. deeply nested control groups
65
+ 4. layouts that assume precise pointer interaction
66
+
67
+ ## Visual Rules
68
+
69
+ Prefer:
70
+
71
+ 1. sparse game-like hierarchy
72
+ 2. fluid layout over hard-coded widths and heights
73
+ 3. obvious action grouping
74
+ 4. strong contrast and immediate readability
75
+
76
+ Avoid:
77
+
78
+ 1. card-heavy dashboard styling for active gameplay
79
+ 2. emoji-as-icon UI
80
+ 3. cluttered web-app chrome
81
+
82
+ ## Icon Rule
83
+
84
+ For template and starter work, a practical split is:
85
+
86
+ 1. a general UI and system icon pack for shell actions
87
+ 2. a gameplay-oriented icon set for abilities, pickups, and status effects
88
+
89
+ Keep icon usage behind local wrappers where practical so the project can curate or replace icons later.
90
+
91
+ ## Private player screens and word games
92
+
93
+ Keep secret words or cards in a per-controller map declared with
94
+ `createAirJamStore`'s `privateField`; read that phone's entry with
95
+ `useAirJamPrivateState`. The public store excludes this field and each phone
96
+ receives only its own entry. Test a reveal with `studio_press_phone`'s hold action.
97
+
98
+ A decision-model seat (Jev) answers choice questions only. Give model seats authored
99
+ candidate clues or answers as options; people can type freely into phone fields.
@@ -0,0 +1,120 @@
1
+ # For Agents
2
+
3
+ This page is the fastest entrypoint for LLM agents and automation tools.
4
+
5
+ ## What Air Jam Is
6
+
7
+ Air Jam is an open AI-native framework for multiplayer games controlled by
8
+ phones.
9
+ Hosts run in your game, inputs are routed through the Air Jam server, and both
10
+ humans and agents work against typed controller, runtime, state, and release
11
+ surfaces instead of guessing through UI only.
12
+
13
+ Air Jam is the harness around your existing coding agent, not a separate hosted
14
+ editor. Local project instructions, CLI commands, MCP tools, runtime observations,
15
+ and hosted release services form one development path.
16
+
17
+ ## Connect to a Project
18
+
19
+ Run these commands from a generated game project with dependencies installed:
20
+
21
+ ```bash
22
+ pnpm exec airjam --help
23
+ pnpm exec airjam mcp doctor --dir . --json
24
+ pnpm exec airjam mcp config --profile portable --dir .
25
+ ```
26
+
27
+ New projects include `.mcp.json`. If a project has no declaration, use
28
+ `pnpm exec airjam mcp init --dir .`; it does not overwrite an existing declaration
29
+ unless you explicitly pass `--force`.
30
+
31
+ Some clients use their own registration formats instead of reading `.mcp.json`:
32
+
33
+ ```bash
34
+ pnpm exec airjam mcp config --profile codex --dir .
35
+ pnpm exec airjam mcp config --profile claude-desktop --dir .
36
+ ```
37
+
38
+ These commands render configuration; they do not install it into the client.
39
+ Use the rendered command, arguments, and absolute project directory when adding
40
+ the server. `mcp doctor` distinguishes project declarations from detected client
41
+ registrations. Confirm that the connected client discovers Air Jam's tools before
42
+ treating the connection as working.
43
+
44
+ [Supported Agents](/docs/for-agents/supported-agents) lists the clients tested end to end.
45
+
46
+ ## Operate and Evaluate
47
+
48
+ For gameplay assertions, use `airjam.open_game_session`,
49
+ `airjam.read_game_session`, `airjam.invoke_game_session_action`, and
50
+ `airjam.close_game_session`. Read each session's published actions and state;
51
+ do not guess game-specific action IDs. `airjam.capture_game_session_visuals`
52
+ adds host and phone-controller screenshots to the same session.
53
+
54
+ In Studio, `studio_press_phone` taps, holds or types on one named mounted Studio phone
55
+ and returns its private screen in the same call. Coordinates are fractions 0..1 of
56
+ `studio_observe_current_game`'s `surface=phone` image. Tap a field before typing;
57
+ a hold captures while pressed, then releases. Reuse the requestId UUID for retries.
58
+ Guest/real phones and older runtimes return an explicit unavailable reason.
59
+
60
+ MCP is optional. A terminal agent can use the same services:
61
+
62
+ ```bash
63
+ pnpm exec airjam session open --dir .
64
+ pnpm exec airjam session read <session-id> --dir .
65
+ pnpm exec airjam session invoke <session-id> <action-id> --payload '{}'
66
+ pnpm exec airjam session capture <session-id> --dir .
67
+ pnpm exec airjam session close <session-id> --dir .
68
+ ```
69
+
70
+ A session starts or reuses the canonical development process. If you start it
71
+ yourself, use `pnpm run dev`, not raw Vite. Use semantic state for repeatable
72
+ gameplay checks and rendered screenshots or browser interaction for visual polish.
73
+ During editing, run the relevant focused checks. Before sharing a completed game,
74
+ run `pnpm exec airjam evaluate --dir .` or the `airjam.evaluate` tool for the complete
75
+ typecheck, lint, test, and build result.
76
+
77
+ The [Quick Start publishing guide](/docs/getting-started/quick-start#terminal-or-agent-publishing)
78
+ covers CLI authentication, hosted release submission, inspection, and explicit
79
+ publication. Local development and evaluation do not require hosted publishing.
80
+
81
+ ## Decision-model Players
82
+
83
+ An `AirJamPlayerContract` from `@air-jam/devtools/testing` describes play with
84
+ `brief` and `turn`. A turn returns `{ state, question, options }` or `null` when
85
+ the seat has nothing to do. Offer 1 to 16 named options, each with a plain-language
86
+ `when` and its `control`. Zero options is invalid; use `null` to wait.
87
+
88
+ A single sensible move is allowed: for example, a lobby turn can offer only
89
+ `join` with `control: { kind: "action", actionId: "join_match" }`. The run owner
90
+ takes that control directly without calling a decision model or incurring model
91
+ cost. Do not invent a second option to satisfy validation. Multiple options ask
92
+ the run's model to choose. Automatic answers retain the choice and control in the
93
+ trace, marked `Only option; no model asked.`, and count toward the seat's optional
94
+ `answers.automatic` summary. The policy receives the choice just like a model
95
+ answer on its next step.
96
+
97
+ ## Read These First
98
+
99
+ 1. [Introduction](/docs/getting-started/introduction)
100
+ 2. [Quick Start](/docs/getting-started/quick-start)
101
+ 3. [Architecture](/docs/how-it-works/architecture)
102
+ 4. [Host System](/docs/how-it-works/host-system)
103
+ 5. [Project Structure](/docs/for-agents/project-structure)
104
+ 6. [Controller UI](/docs/for-agents/controller-ui)
105
+ 7. [State and Rendering](/docs/for-agents/state-and-rendering)
106
+ 8. [SDK Hooks](/docs/sdk/hooks)
107
+ 9. [Debugging and Logs](/docs/getting-started/debugging)
108
+ 10. [Unified Dev Logs](/docs/getting-started/dev-logs)
109
+
110
+ ## SDK Focus Areas
111
+
112
+ - [Input System](/docs/sdk/input-system)
113
+ - [Networked State](/docs/sdk/networked-state)
114
+
115
+ ## Machine Discovery
116
+
117
+ - [AI Pack Manifest](/ai-pack/manifest.json)
118
+ - [LLMs Index](/llms.txt)
119
+ - [Sitemap](/sitemap.xml)
120
+ - [Robots](/robots.txt)