@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,214 @@
|
|
|
1
|
+
<!-- Generated from content/docs/sdk/networked-state/page.mdx. Do not edit directly. -->
|
|
2
|
+
<!-- Canonical public doc: https://airjam.io/docs/sdk/networked-state -->
|
|
3
|
+
|
|
4
|
+
# Networked State
|
|
5
|
+
|
|
6
|
+
`createAirJamStore` is the canonical shared-state lane for Air Jam:
|
|
7
|
+
|
|
8
|
+
- Host is the only source of truth.
|
|
9
|
+
- Controllers dispatch actions through RPC.
|
|
10
|
+
- Host applies actions, then state sync is broadcast back.
|
|
11
|
+
|
|
12
|
+
Use this lane for replicated game state, not per-frame input.
|
|
13
|
+
|
|
14
|
+
## Canonical Action Model
|
|
15
|
+
|
|
16
|
+
Actions always use this shape on the host:
|
|
17
|
+
|
|
18
|
+
1. First argument: `ctx` (identity and role)
|
|
19
|
+
2. Second argument: `payload` (either `undefined` or one typed plain-object payload)
|
|
20
|
+
|
|
21
|
+
Controller-side dispatch always uses:
|
|
22
|
+
|
|
23
|
+
1. `const actions = useGameStore.useActions()`
|
|
24
|
+
2. `actions.someAction()` or `actions.someAction({ ...payload })`
|
|
25
|
+
|
|
26
|
+
No trailing `controllerId` arguments and no multi-argument action payloads.
|
|
27
|
+
No primitive, array, or event-like root payloads.
|
|
28
|
+
|
|
29
|
+
## Create a Store
|
|
30
|
+
|
|
31
|
+
This example uses a starter-friendly `stores/` folder shape.
|
|
32
|
+
The important contract is the action model and ownership boundary, not the exact filename.
|
|
33
|
+
|
|
34
|
+
```tsx filename="src/game/stores/game-store.ts"
|
|
35
|
+
import { createAirJamStore } from "@air-jam/sdk";
|
|
36
|
+
|
|
37
|
+
type Team = "team1" | "team2";
|
|
38
|
+
|
|
39
|
+
interface GameState {
|
|
40
|
+
phase: "lobby" | "playing";
|
|
41
|
+
teamAssignments: Record<string, Team>;
|
|
42
|
+
scores: { team1: number; team2: number };
|
|
43
|
+
actions: {
|
|
44
|
+
joinTeam: (
|
|
45
|
+
ctx: { actorId: string; role: "controller" | "host" },
|
|
46
|
+
payload: { team: Team },
|
|
47
|
+
) => void;
|
|
48
|
+
scorePoint: (
|
|
49
|
+
_ctx: { actorId: string; role: "controller" | "host" },
|
|
50
|
+
payload: { team: Team },
|
|
51
|
+
) => void;
|
|
52
|
+
setPhase: (
|
|
53
|
+
_ctx: { actorId: string; role: "controller" | "host" },
|
|
54
|
+
payload: { phase: "lobby" | "playing" },
|
|
55
|
+
) => void;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const useGameStore = createAirJamStore<GameState>((set) => ({
|
|
60
|
+
phase: "lobby",
|
|
61
|
+
teamAssignments: {},
|
|
62
|
+
scores: { team1: 0, team2: 0 },
|
|
63
|
+
actions: {
|
|
64
|
+
joinTeam: ({ actorId }, { team }) =>
|
|
65
|
+
set((state) => ({
|
|
66
|
+
teamAssignments: {
|
|
67
|
+
...state.teamAssignments,
|
|
68
|
+
[actorId]: team,
|
|
69
|
+
},
|
|
70
|
+
})),
|
|
71
|
+
scorePoint: (_ctx, { team }) =>
|
|
72
|
+
set((state) => ({
|
|
73
|
+
scores: {
|
|
74
|
+
...state.scores,
|
|
75
|
+
[team]: state.scores[team] + 1,
|
|
76
|
+
},
|
|
77
|
+
})),
|
|
78
|
+
setPhase: (_ctx, { phase }) => set({ phase }),
|
|
79
|
+
},
|
|
80
|
+
}));
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Use on Controller
|
|
84
|
+
|
|
85
|
+
This controller example matches the starter template surface layout.
|
|
86
|
+
It assumes your app has already mounted `airjam.Controller`.
|
|
87
|
+
|
|
88
|
+
```tsx filename="src/controller/index.tsx"
|
|
89
|
+
import { useAirJamController } from "@air-jam/sdk";
|
|
90
|
+
import { useGameStore } from "../game/stores/game-store";
|
|
91
|
+
|
|
92
|
+
export const ControllerView = () => {
|
|
93
|
+
const controller = useAirJamController();
|
|
94
|
+
const actions = useGameStore.useActions();
|
|
95
|
+
const teamAssignments = useGameStore((state) => state.teamAssignments);
|
|
96
|
+
|
|
97
|
+
const myTeam = controller.controllerId
|
|
98
|
+
? teamAssignments[controller.controllerId]
|
|
99
|
+
: null;
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<div>
|
|
103
|
+
<p>My team: {myTeam ?? "unassigned"}</p>
|
|
104
|
+
<button onClick={() => actions.joinTeam({ team: "team1" })}>
|
|
105
|
+
Join Team 1
|
|
106
|
+
</button>
|
|
107
|
+
</div>
|
|
108
|
+
);
|
|
109
|
+
};
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Use on Host
|
|
113
|
+
|
|
114
|
+
This host example also matches the starter template surface layout.
|
|
115
|
+
It assumes your app has already mounted `airjam.Host`.
|
|
116
|
+
|
|
117
|
+
```tsx filename="src/host/index.tsx"
|
|
118
|
+
import { useGameStore } from "../game/stores/game-store";
|
|
119
|
+
|
|
120
|
+
export const HostView = () => {
|
|
121
|
+
const phase = useGameStore((state) => state.phase);
|
|
122
|
+
const scores = useGameStore((state) => state.scores);
|
|
123
|
+
const actions = useGameStore.useActions();
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<div>
|
|
127
|
+
<p>Phase: {phase}</p>
|
|
128
|
+
<p>
|
|
129
|
+
{scores.team1} - {scores.team2}
|
|
130
|
+
</p>
|
|
131
|
+
<button onClick={() => actions.setPhase({ phase: "playing" })}>
|
|
132
|
+
Start
|
|
133
|
+
</button>
|
|
134
|
+
<button onClick={() => actions.scorePoint({ team: "team1" })}>
|
|
135
|
+
Team 1 +1
|
|
136
|
+
</button>
|
|
137
|
+
</div>
|
|
138
|
+
);
|
|
139
|
+
};
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Action Flow
|
|
143
|
+
|
|
144
|
+
1. Controller calls `actions.someAction()` or `actions.someAction({ ...payload })`.
|
|
145
|
+
2. SDK emits `controller:action_rpc`.
|
|
146
|
+
3. Server validates and injects actor identity from socket ownership.
|
|
147
|
+
4. Host receives `airjam:action_rpc` with `{ actor, payload }`.
|
|
148
|
+
5. Host executes action handler `(ctx, payload)` and updates state.
|
|
149
|
+
6. Host emits `host:state_sync`; controllers receive `airjam:state_sync`.
|
|
150
|
+
|
|
151
|
+
## Rules
|
|
152
|
+
|
|
153
|
+
1. Keep all networked mutations inside `actions`.
|
|
154
|
+
2. Always dispatch via `useActions()`; do not call `state.actions.*` directly.
|
|
155
|
+
3. Use one payload object per action for stable evolution.
|
|
156
|
+
4. Root payloads must be omitted or plain objects.
|
|
157
|
+
5. `T | undefined` payload unions are not valid roots. If an action has no payload, omit it entirely.
|
|
158
|
+
6. Nested values must stay RPC-serializable.
|
|
159
|
+
7. Use `ctx.actorId` for identity-aware actions (team join, ownership, etc.).
|
|
160
|
+
8. `ctx.actorId` is always the dispatcher identity. If host code dispatches through `useActions()`, then `ctx.actorId` is the host.
|
|
161
|
+
9. If the host intentionally needs to run the same semantic player action as controller `X`, use `useStore.asPlayer("X")` instead of inventing a target payload for an actor-owned action.
|
|
162
|
+
10. Keep per-frame gameplay input in `useInputWriter` / `host.getInput`, not in this store.
|
|
163
|
+
|
|
164
|
+
## Accept And Reject Examples
|
|
165
|
+
|
|
166
|
+
If a store action returns `void`, Air Jam treats it as accepted.
|
|
167
|
+
|
|
168
|
+
Return `rejectAirJamAction(...)` when the semantic action should fail with a clear machine-readable reason, and return `acceptAirJamAction(result)` when the semantic action should succeed with explicit result data:
|
|
169
|
+
|
|
170
|
+
```tsx
|
|
171
|
+
import {
|
|
172
|
+
acceptAirJamAction,
|
|
173
|
+
createAirJamStore,
|
|
174
|
+
rejectAirJamAction,
|
|
175
|
+
} from "@air-jam/sdk";
|
|
176
|
+
|
|
177
|
+
export const useGameStore = createAirJamStore((set) => ({
|
|
178
|
+
aliveByPlayerId: {} as Record<string, boolean>,
|
|
179
|
+
cooldownMsByPlayerId: {} as Record<string, number>,
|
|
180
|
+
actions: {
|
|
181
|
+
fire: ({ actorId }) =>
|
|
182
|
+
set((state) => {
|
|
183
|
+
if (!actorId || state.aliveByPlayerId[actorId] === false) {
|
|
184
|
+
return rejectAirJamAction("player_dead", "Dead players cannot fire.");
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const cooldownMs = 4500;
|
|
188
|
+
return acceptAirJamAction({ cooldownMs });
|
|
189
|
+
}),
|
|
190
|
+
},
|
|
191
|
+
}));
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Use this pattern when the caller needs a real semantic outcome.
|
|
195
|
+
|
|
196
|
+
## Embedded Arcade Runtimes
|
|
197
|
+
|
|
198
|
+
When a game runs inside Arcade, `createAirJamStore` still works the same way in game code.
|
|
199
|
+
|
|
200
|
+
The SDK/runtime automatically resolves the correct replicated store domain from the embedded runtime context, so you should:
|
|
201
|
+
|
|
202
|
+
1. keep normal `createAirJamStore(...)` usage in games
|
|
203
|
+
2. not parse Arcade URL params in app/game code
|
|
204
|
+
3. not pick custom store domains in game code just to work when embedded
|
|
205
|
+
|
|
206
|
+
## API Summary
|
|
207
|
+
|
|
208
|
+
`createAirJamStore<T>(initializer)` returns:
|
|
209
|
+
|
|
210
|
+
1. Zustand-compatible hook for selectors.
|
|
211
|
+
2. `useActions()` dispatch map with `() => void` or `(payloadObject) => void` signatures.
|
|
212
|
+
3. `asPlayer(controllerId)` host-only dispatch map for explicit player impersonation of semantic actions.
|
|
213
|
+
|
|
214
|
+
`T` must include an `actions` object with host handlers `(ctx, payload) => void`, where `payload` is `undefined` or a plain object.
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
<!-- Generated from content/docs/for-agents/project-structure/page.mdx. Do not edit directly. -->
|
|
2
|
+
<!-- Canonical public doc: https://airjam.io/docs/for-agents/project-structure -->
|
|
3
|
+
|
|
4
|
+
# Project Structure
|
|
5
|
+
|
|
6
|
+
Air Jam games should not grow as one large React surface.
|
|
7
|
+
|
|
8
|
+
The clean default is a boundary-first structure where host logic, controller logic, pure game rules, and framework integration do not collapse into the same modules.
|
|
9
|
+
|
|
10
|
+
## Framework Recommendation
|
|
11
|
+
|
|
12
|
+
Move toward a structure like this:
|
|
13
|
+
|
|
14
|
+
```text
|
|
15
|
+
src/
|
|
16
|
+
host/
|
|
17
|
+
controller/
|
|
18
|
+
game/
|
|
19
|
+
domain/
|
|
20
|
+
engine/
|
|
21
|
+
systems/
|
|
22
|
+
adapters/
|
|
23
|
+
ui/
|
|
24
|
+
debug/
|
|
25
|
+
shared/
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The exact folder names can vary slightly, but the boundaries should stay clear.
|
|
29
|
+
|
|
30
|
+
This is a framework-level recommendation about ownership boundaries, not a requirement that every Air Jam game use the exact same filenames.
|
|
31
|
+
|
|
32
|
+
### `src/host/`
|
|
33
|
+
|
|
34
|
+
Owns host-only composition and shell behavior.
|
|
35
|
+
|
|
36
|
+
Examples:
|
|
37
|
+
|
|
38
|
+
1. host screens
|
|
39
|
+
2. room and join presentation
|
|
40
|
+
3. host-facing overlays
|
|
41
|
+
4. host runtime composition
|
|
42
|
+
|
|
43
|
+
### `src/controller/`
|
|
44
|
+
|
|
45
|
+
Owns controller-only composition and touch interactions.
|
|
46
|
+
|
|
47
|
+
Examples:
|
|
48
|
+
|
|
49
|
+
1. lobby controls
|
|
50
|
+
2. gameplay controls
|
|
51
|
+
3. controller status surfaces
|
|
52
|
+
4. controller-specific UI hooks
|
|
53
|
+
|
|
54
|
+
### `src/game/domain/`
|
|
55
|
+
|
|
56
|
+
Owns pure gameplay rules, math, and types.
|
|
57
|
+
|
|
58
|
+
Examples:
|
|
59
|
+
|
|
60
|
+
1. score rules
|
|
61
|
+
2. win conditions
|
|
62
|
+
3. team assignment helpers
|
|
63
|
+
4. deterministic state transitions
|
|
64
|
+
|
|
65
|
+
This layer should stay testable without React or rendering.
|
|
66
|
+
|
|
67
|
+
### `src/game/engine/`
|
|
68
|
+
|
|
69
|
+
Owns runtime orchestration.
|
|
70
|
+
|
|
71
|
+
Examples:
|
|
72
|
+
|
|
73
|
+
1. ticking
|
|
74
|
+
2. lifecycle transitions
|
|
75
|
+
3. update ordering
|
|
76
|
+
4. system composition
|
|
77
|
+
|
|
78
|
+
### `src/game/systems/`
|
|
79
|
+
|
|
80
|
+
Owns focused gameplay systems when the game has enough scope to justify them.
|
|
81
|
+
|
|
82
|
+
Examples:
|
|
83
|
+
|
|
84
|
+
1. spawning
|
|
85
|
+
2. combat
|
|
86
|
+
3. pickups
|
|
87
|
+
4. abilities
|
|
88
|
+
5. scoring
|
|
89
|
+
|
|
90
|
+
### `src/game/adapters/`
|
|
91
|
+
|
|
92
|
+
Owns integration with frameworks and runtime services.
|
|
93
|
+
|
|
94
|
+
Examples:
|
|
95
|
+
|
|
96
|
+
1. Air Jam SDK integration
|
|
97
|
+
2. R3F integration
|
|
98
|
+
3. physics integration
|
|
99
|
+
4. audio integration
|
|
100
|
+
5. network and runtime bridges
|
|
101
|
+
|
|
102
|
+
Keep adapters thin. They should connect systems, not become the real game model.
|
|
103
|
+
|
|
104
|
+
### `src/game/ui/`
|
|
105
|
+
|
|
106
|
+
Owns reusable game-facing UI modules.
|
|
107
|
+
|
|
108
|
+
Examples:
|
|
109
|
+
|
|
110
|
+
1. score displays
|
|
111
|
+
2. status strips
|
|
112
|
+
3. overlays
|
|
113
|
+
4. icon wrappers
|
|
114
|
+
|
|
115
|
+
### `tests/`
|
|
116
|
+
|
|
117
|
+
Owns behavior-focused validation for the boundaries above.
|
|
118
|
+
|
|
119
|
+
Examples:
|
|
120
|
+
|
|
121
|
+
1. `tests/game/domain/` for pure rule tests
|
|
122
|
+
2. `tests/game/stores/` for pure state-transition tests
|
|
123
|
+
3. `tests/game/engine/` for focused runtime helper tests
|
|
124
|
+
4. `tests/game/adapters/` for transport-facing mapping and boundary tests
|
|
125
|
+
5. `tests/game/ui/` for shared game-facing UI primitives that can be validated without full app shells
|
|
126
|
+
|
|
127
|
+
## Starter Template Reference
|
|
128
|
+
|
|
129
|
+
The starter Pong template is the current best starter implementation of those boundaries.
|
|
130
|
+
|
|
131
|
+
It is a recommended reference, not a framework API.
|
|
132
|
+
|
|
133
|
+
Its useful starter modules look like:
|
|
134
|
+
|
|
135
|
+
1. `src/host/index.tsx` for host surface composition
|
|
136
|
+
2. `src/controller/index.tsx` for controller flow and input cadence
|
|
137
|
+
3. `src/game/stores/pong-store.ts` for networked store wiring
|
|
138
|
+
4. `src/game/stores/pong-store-state.ts` for pure state transitions
|
|
139
|
+
5. `src/game/engine/simulation.ts` for runtime orchestration
|
|
140
|
+
6. `src/game/engine/runtime-state.ts` for hot mutable runtime values
|
|
141
|
+
7. `src/game/adapters/controller-signals.ts` for host-to-controller transport-facing mapping
|
|
142
|
+
8. `src/game/ui/` for reusable game-facing presentation primitives shared by host and controller
|
|
143
|
+
9. `src/game/prefabs/arena/` for a folder-per-prefab contract with metadata, schema, preview, and runtime composition helper
|
|
144
|
+
10. `tests/game/` for the starter testing pattern that mirrors those same boundaries
|
|
145
|
+
|
|
146
|
+
If a starter module already demonstrates the boundary you need, extend it instead of introducing a second competing pattern.
|
|
147
|
+
If your game genuinely needs a different folder or module shape, preserve the boundary intent rather than copying Pong mechanically.
|
|
148
|
+
|
|
149
|
+
### `src/game/debug/`
|
|
150
|
+
|
|
151
|
+
Owns debug helpers and overlays.
|
|
152
|
+
|
|
153
|
+
Keep debug features removable and out of gameplay hot paths.
|
|
154
|
+
|
|
155
|
+
## Decision Rule
|
|
156
|
+
|
|
157
|
+
When adding code, ask:
|
|
158
|
+
|
|
159
|
+
1. is this pure game logic
|
|
160
|
+
2. is this runtime orchestration
|
|
161
|
+
3. is this framework integration
|
|
162
|
+
4. is this host-only or controller-only
|
|
163
|
+
|
|
164
|
+
Put the code where the answer is clearest.
|
|
165
|
+
|
|
166
|
+
## Refactor Rule
|
|
167
|
+
|
|
168
|
+
If a new feature would force host, controller, domain, and rendering concerns into one file, fix the boundary first or split the work into:
|
|
169
|
+
|
|
170
|
+
1. structural cleanup
|
|
171
|
+
2. feature implementation
|