@codyswann/lisa 2.178.5 → 2.179.0

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 (142) hide show
  1. package/dist/configs/eslint/phaser.d.ts +2 -8
  2. package/dist/configs/eslint/phaser.d.ts.map +1 -1
  3. package/dist/configs/eslint/phaser.js +143 -17
  4. package/dist/configs/eslint/phaser.js.map +1 -1
  5. package/eslint-plugin-phaser/README.md +19 -0
  6. package/eslint-plugin-phaser/index.js +35 -0
  7. package/eslint-plugin-phaser/package.json +10 -0
  8. package/eslint-plugin-phaser/rules/no-allocation-in-update.js +189 -0
  9. package/eslint-plugin-phaser/rules/no-create-in-update.js +200 -0
  10. package/eslint-plugin-phaser/rules/require-shutdown-cleanup.js +191 -0
  11. package/package.json +5 -3
  12. package/phaser/package-lisa/package.lisa.json +11 -3
  13. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  14. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  15. package/plugins/lisa/skills/analyze-claude-remote/SKILL.md +72 -2
  16. package/plugins/lisa/skills/generate-claude-remote-build-script/SKILL.md +30 -1
  17. package/plugins/lisa-agy/plugin.json +1 -1
  18. package/plugins/lisa-agy/skills/analyze-claude-remote/SKILL.md +72 -2
  19. package/plugins/lisa-agy/skills/generate-claude-remote-build-script/SKILL.md +30 -1
  20. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  21. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  22. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  23. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  24. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  25. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  26. package/plugins/lisa-copilot/skills/analyze-claude-remote/SKILL.md +72 -2
  27. package/plugins/lisa-copilot/skills/generate-claude-remote-build-script/SKILL.md +30 -1
  28. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  29. package/plugins/lisa-cursor/skills/analyze-claude-remote/SKILL.md +72 -2
  30. package/plugins/lisa-cursor/skills/generate-claude-remote-build-script/SKILL.md +30 -1
  31. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  32. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  33. package/plugins/lisa-expo/agents/ops-specialist.md +2 -2
  34. package/plugins/lisa-expo/skills/ops-check-logs/SKILL.md +8 -2
  35. package/plugins/lisa-expo/skills/ops-db-ops/SKILL.md +7 -3
  36. package/plugins/lisa-expo/skills/ops-deploy/SKILL.md +6 -2
  37. package/plugins/lisa-expo/skills/ops-run-local/SKILL.md +5 -2
  38. package/plugins/lisa-expo-agy/agents/ops-specialist.md +2 -2
  39. package/plugins/lisa-expo-agy/plugin.json +1 -1
  40. package/plugins/lisa-expo-agy/skills/ops-check-logs/SKILL.md +8 -2
  41. package/plugins/lisa-expo-agy/skills/ops-db-ops/SKILL.md +7 -3
  42. package/plugins/lisa-expo-agy/skills/ops-deploy/SKILL.md +6 -2
  43. package/plugins/lisa-expo-agy/skills/ops-run-local/SKILL.md +5 -2
  44. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  45. package/plugins/lisa-expo-copilot/agents/ops-specialist.agent.md +2 -2
  46. package/plugins/lisa-expo-copilot/skills/ops-check-logs/SKILL.md +8 -2
  47. package/plugins/lisa-expo-copilot/skills/ops-db-ops/SKILL.md +7 -3
  48. package/plugins/lisa-expo-copilot/skills/ops-deploy/SKILL.md +6 -2
  49. package/plugins/lisa-expo-copilot/skills/ops-run-local/SKILL.md +5 -2
  50. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  51. package/plugins/lisa-expo-cursor/agents/ops-specialist.md +2 -2
  52. package/plugins/lisa-expo-cursor/skills/ops-check-logs/SKILL.md +8 -2
  53. package/plugins/lisa-expo-cursor/skills/ops-db-ops/SKILL.md +7 -3
  54. package/plugins/lisa-expo-cursor/skills/ops-deploy/SKILL.md +6 -2
  55. package/plugins/lisa-expo-cursor/skills/ops-run-local/SKILL.md +5 -2
  56. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  57. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  58. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  59. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  60. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  61. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  62. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  63. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  64. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  65. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  66. package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
  67. package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
  68. package/plugins/lisa-openclaw-agy/plugin.json +1 -1
  69. package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
  70. package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
  71. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  72. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  73. package/plugins/lisa-phaser/rules/phaser.md +111 -44
  74. package/plugins/lisa-phaser/skills/phaser-accessibility/SKILL.md +135 -0
  75. package/plugins/lisa-phaser/skills/phaser-accessibility/agents/openai.yaml +4 -0
  76. package/plugins/lisa-phaser/skills/phaser-asset-pipeline/SKILL.md +148 -0
  77. package/plugins/lisa-phaser/skills/phaser-asset-pipeline/agents/openai.yaml +4 -0
  78. package/plugins/lisa-phaser/skills/phaser-build-deploy/SKILL.md +148 -0
  79. package/plugins/lisa-phaser/skills/phaser-build-deploy/agents/openai.yaml +4 -0
  80. package/plugins/lisa-phaser/skills/phaser-i18n/SKILL.md +122 -0
  81. package/plugins/lisa-phaser/skills/phaser-i18n/agents/openai.yaml +4 -0
  82. package/plugins/lisa-phaser/skills/phaser-services/SKILL.md +208 -0
  83. package/plugins/lisa-phaser/skills/phaser-services/agents/openai.yaml +4 -0
  84. package/plugins/lisa-phaser/skills/phaser-testing/SKILL.md +103 -10
  85. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  86. package/plugins/lisa-phaser-agy/skills/phaser-accessibility/SKILL.md +135 -0
  87. package/plugins/lisa-phaser-agy/skills/phaser-asset-pipeline/SKILL.md +148 -0
  88. package/plugins/lisa-phaser-agy/skills/phaser-build-deploy/SKILL.md +148 -0
  89. package/plugins/lisa-phaser-agy/skills/phaser-i18n/SKILL.md +122 -0
  90. package/plugins/lisa-phaser-agy/skills/phaser-services/SKILL.md +208 -0
  91. package/plugins/lisa-phaser-agy/skills/phaser-testing/SKILL.md +103 -10
  92. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  93. package/plugins/lisa-phaser-copilot/rules/phaser.md +111 -44
  94. package/plugins/lisa-phaser-copilot/skills/phaser-accessibility/SKILL.md +135 -0
  95. package/plugins/lisa-phaser-copilot/skills/phaser-asset-pipeline/SKILL.md +148 -0
  96. package/plugins/lisa-phaser-copilot/skills/phaser-build-deploy/SKILL.md +148 -0
  97. package/plugins/lisa-phaser-copilot/skills/phaser-i18n/SKILL.md +122 -0
  98. package/plugins/lisa-phaser-copilot/skills/phaser-services/SKILL.md +208 -0
  99. package/plugins/lisa-phaser-copilot/skills/phaser-testing/SKILL.md +103 -10
  100. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  101. package/plugins/lisa-phaser-cursor/rules/phaser.mdc +111 -44
  102. package/plugins/lisa-phaser-cursor/skills/phaser-accessibility/SKILL.md +135 -0
  103. package/plugins/lisa-phaser-cursor/skills/phaser-asset-pipeline/SKILL.md +148 -0
  104. package/plugins/lisa-phaser-cursor/skills/phaser-build-deploy/SKILL.md +148 -0
  105. package/plugins/lisa-phaser-cursor/skills/phaser-i18n/SKILL.md +122 -0
  106. package/plugins/lisa-phaser-cursor/skills/phaser-services/SKILL.md +208 -0
  107. package/plugins/lisa-phaser-cursor/skills/phaser-testing/SKILL.md +103 -10
  108. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  109. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  110. package/plugins/lisa-rails/agents/ops-specialist.md +1 -1
  111. package/plugins/lisa-rails-agy/agents/ops-specialist.md +1 -1
  112. package/plugins/lisa-rails-agy/plugin.json +1 -1
  113. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  114. package/plugins/lisa-rails-copilot/agents/ops-specialist.agent.md +1 -1
  115. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  116. package/plugins/lisa-rails-cursor/agents/ops-specialist.md +1 -1
  117. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  118. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  119. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  120. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  121. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  122. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  123. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  124. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  125. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  126. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  127. package/plugins/src/base/skills/analyze-claude-remote/SKILL.md +72 -2
  128. package/plugins/src/base/skills/generate-claude-remote-build-script/SKILL.md +30 -1
  129. package/plugins/src/expo/agents/ops-specialist.md +2 -2
  130. package/plugins/src/expo/skills/ops-check-logs/SKILL.md +8 -2
  131. package/plugins/src/expo/skills/ops-db-ops/SKILL.md +7 -3
  132. package/plugins/src/expo/skills/ops-deploy/SKILL.md +6 -2
  133. package/plugins/src/expo/skills/ops-run-local/SKILL.md +5 -2
  134. package/plugins/src/phaser/rules/phaser.md +111 -44
  135. package/plugins/src/phaser/skills/phaser-accessibility/SKILL.md +135 -0
  136. package/plugins/src/phaser/skills/phaser-asset-pipeline/SKILL.md +148 -0
  137. package/plugins/src/phaser/skills/phaser-build-deploy/SKILL.md +148 -0
  138. package/plugins/src/phaser/skills/phaser-i18n/SKILL.md +122 -0
  139. package/plugins/src/phaser/skills/phaser-services/SKILL.md +208 -0
  140. package/plugins/src/phaser/skills/phaser-testing/SKILL.md +103 -10
  141. package/plugins/src/rails/agents/ops-specialist.md +1 -1
  142. package/tsconfig/phaser.json +8 -1
@@ -31,7 +31,7 @@ tracker/source, plus the host project's own package manager and tooling — not
31
31
 
32
32
  1. **Inventory.** Invoke `/lisa:analyze-claude-remote --json` and parse its machine-readable
33
33
  inventory block (`packageManager`, `tools`, `env`, `mcp`, `gaps`, `platform`,
34
- `networkAccess`, `allowlistDomains`). If the analysis cannot run, stop and report why — never
34
+ `networkAccess`, `allowlistDomains`, `awsProfiles`). If the analysis cannot run, stop and report why — never
35
35
  emit a script from guesses.
36
36
 
37
37
  2. **Compose the setup script** from the inventory. The script must be:
@@ -71,6 +71,9 @@ tracker/source, plus the host project's own package manager and tooling — not
71
71
  include `JAM_PAT`, `SONAR_TOKEN`, or similar documented substrate env vars
72
72
  only as optional secrets, with their acquire/scope comments when the analysis
73
73
  supplied them. Never invent values or promote dormant substrates to required.
74
+ When AWS entries are present, list `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, optional
75
+ `AWS_SESSION_TOKEN`, and `AWS_DEFAULT_REGION` exactly as the analysis reported. State that these
76
+ bootstrap credentials are for STS assume-role only; do not emit or recommend `aws sso login`.
74
77
 
75
78
  3a. **Emit substrate setup snippets.** When the inventory marks an MCP
76
79
  `headlessUsable: true` through a documented substrate, render the matching
@@ -88,6 +91,19 @@ tracker/source, plus the host project's own package manager and tooling — not
88
91
  transport supports static-token auth. Do not print a Jam `.mcp.json` header snippet because
89
92
  Jam's preferred headless substrate is its PAT-authenticated CLI.
90
93
 
94
+ 3b. **Emit AWS assume-role profile setup.** When the inventory includes `awsProfiles`, write an
95
+ idempotent `~/.aws/config` block gated on `[ -n "${AWS_ACCESS_KEY_ID:-}" ]`. The generated block
96
+ must:
97
+ - `mkdir -p "$HOME/.aws"` and create or append profile stanzas without writing secrets.
98
+ - Emit one `[profile <name>]` stanza per inventory profile with `role_arn`,
99
+ `credential_source = Environment`, `region` when present, and `external_id` when present.
100
+ - Keep regions and ExternalIds as non-secret project metadata from the inventory; never invent
101
+ account IDs, role names, profile names, regions, or ExternalIds.
102
+ - Warn and skip profile writing when AWS profile metadata is absent, while still listing the
103
+ required `AWS_*` env var names in the secret template.
104
+ - Include a comment that agents should use `aws --profile <name> ...` and must not run
105
+ `aws sso login` in headless routines.
106
+
91
107
  4. **Emit the allowlist + gaps notice.** List any custom domains the setup or runtime reaches
92
108
  (from `networkAccess.allowlistDomains`, falling back to legacy `allowlistDomains`) that the user
93
109
  must add when the environment needs Custom network access. Do not include default Trusted domains
@@ -123,6 +139,9 @@ shape, not a fixed payload):
123
139
  # # Note: GH_TOKEN is for gh CLI only. Raw git uses Claude's connected-GitHub proxy/identity;
124
140
  # # sibling repos reached only by raw git do not need to be in this token scope.
125
141
  # - GH_TOKEN=<token> # REQUIRED, github is the active tracker+source
142
+ # - AWS_ACCESS_KEY_ID=<access-key-id> # REQUIRED when AWS inventory is active
143
+ # - AWS_SECRET_ACCESS_KEY=<secret-access-key> # REQUIRED when AWS inventory is active
144
+ # - AWS_SESSION_TOKEN=<session-token> # OPTIONAL for temporary bootstrap creds
126
145
  # NETWORK: set the environment to Custom and allowlist these non-default domains if not on Full:
127
146
  # - <networkAccess.allowlistDomains, if any>
128
147
  set -uo pipefail
@@ -165,6 +184,14 @@ need gh || (sudo apt-get update -y && sudo apt-get install -y gh)
165
184
  need jq || sudo apt-get install -y jq
166
185
  require gh; require jq
167
186
 
187
+ # --- AWS assume-role profiles, when inventory includes awsProfiles ---
188
+ if [ -n "${AWS_ACCESS_KEY_ID:-}" ]; then
189
+ mkdir -p "$HOME/.aws"
190
+ # Generated stanzas use credential_source=Environment and contain no secrets.
191
+ # Agents should run: aws --profile <profile> ...
192
+ # Do not run aws sso login in headless routines; SSO requires an interactive browser/device flow.
193
+ fi
194
+
168
195
  # --- optional, only with --include-optional ---
169
196
  # (docker / ruby / chromium / etc., guarded)
170
197
  ```
@@ -186,6 +213,8 @@ to stop are: the analysis could not run, or the `--out` path is not writable.
186
213
  raw git/cross-repo clone guidance must not expand the token scope to sibling repositories.
187
214
  - Never emit an install for a tool the analysis did not surface, and never install `OPTIONAL` tools
188
215
  unless `--include-optional` is set.
216
+ - When AWS is in the inventory, generate environment-backed assume-role profile stanzas from
217
+ `awsProfiles`; never emit `aws sso login` as a remote setup step.
189
218
  - Prefer `networkAccess.allowlistDomains` over legacy top-level `allowlistDomains`; never emit
190
219
  domains already covered by the routine environment's default Trusted list.
191
220
  - Keep the script idempotent and detect-before-install so it is safe to re-run and cache.
@@ -100,10 +100,10 @@ Read `app/` directory structure to discover all available routes.
100
100
  |---------|-------------|-----|
101
101
  | `port 8081 already in use` | Previous Metro bundler running | `lsof -ti :8081 \| xargs kill -9` |
102
102
  | `port 3000 already in use` | Previous backend running | `lsof -ti :3000 \| xargs kill -9` |
103
- | `ExpiredTokenException` | AWS SSO session expired | Run `aws:signin:{env}` script from backend dir |
103
+ | `ExpiredTokenException` | AWS credentials expired | Interactive local: refresh the backend AWS signin flow. Headless: use the environment-backed AWS profile; do not start an SSO browser/device flow |
104
104
  | Metro bundler crash | Cache corruption | `bun start:local --clear` |
105
105
  | `ECONNREFUSED localhost:3000` | Backend not running | Start backend first, then frontend |
106
- | Migration fails | Missing AWS credentials | Run `aws:signin:{env}` script before migration |
106
+ | Migration fails | Missing AWS credentials | Verify `aws sts get-caller-identity --profile {profile}`; use interactive signin only locally, environment-backed profile headless |
107
107
  | EAS CLI not found | Not installed globally | `npm install -g eas-cli` |
108
108
  | `sls` not found | Serverless not installed | `cd $BACKEND_DIR && bun install` |
109
109
  | GraphQL schema mismatch | Stale generated types | Run `generate:types:{env}` script |
@@ -132,9 +132,14 @@ Discover available log scripts from the backend `package.json` (matching `logs:*
132
132
 
133
133
  ```bash
134
134
  cd "${BACKEND_DIR:-../backend-v2}"
135
- bun run aws:signin:{env}
135
+ aws sts get-caller-identity --profile {aws-profile} 2>/dev/null
136
136
  ```
137
137
 
138
+ If this is an interactive local session and credentials are expired, refresh the backend's local
139
+ AWS signin flow. In a headless or remote-routine session, do not start an SSO browser/device flow;
140
+ use the preconfigured `~/.aws/config` profile backed by `AWS_ACCESS_KEY_ID` /
141
+ `AWS_SECRET_ACCESS_KEY` environment credentials.
142
+
138
143
  ### View Recent Logs
139
144
 
140
145
  ```bash
@@ -151,7 +156,8 @@ FUNCTION_NAME={fn} bun run logs:watch:{env}
151
156
 
152
157
  ## Remote Logs (AWS CLI — Advanced Filtering)
153
158
 
154
- For more advanced filtering, use the AWS CLI directly. Discover the AWS profile from backend `package.json` `aws:signin:*` scripts.
159
+ For more advanced filtering, use the AWS CLI directly. Discover the AWS profile from backend
160
+ `package.json` scripts or the remote-routine `~/.aws/config` profile.
155
161
 
156
162
  ### Discover Log Groups
157
163
 
@@ -29,7 +29,7 @@ Read the backend `package.json` to discover available migration and schema scrip
29
29
  - `migration:generate:*` — generate new migration from entity changes
30
30
  - `migration:create` — create empty migration
31
31
  - `generate:sql-schema*` — regenerate SQL schema for MCP
32
- - `aws:signin:*` AWS credential scripts
32
+ - AWS credential/profile scripts such as `aws:signin:*` and any environment-backed remote profile
33
33
 
34
34
  Read the frontend `package.json` to discover codegen scripts:
35
35
  - `fetch:graphql:schema:*` — fetch GraphQL schema
@@ -37,13 +37,17 @@ Read the frontend `package.json` to discover codegen scripts:
37
37
 
38
38
  ## AWS Prerequisite
39
39
 
40
- All database operations (except `codegen`) require AWS credentials. Run the backend's AWS signin script first:
40
+ All database operations (except `codegen`) require AWS credentials. Verify the target profile first:
41
41
 
42
42
  ```bash
43
43
  cd "${BACKEND_DIR:-../backend-v2}"
44
- bun run aws:signin:{env}
44
+ aws sts get-caller-identity --profile {aws-profile}
45
45
  ```
46
46
 
47
+ If this is an interactive local session and credentials are expired, refresh the backend's local AWS
48
+ signin flow. In a headless or remote-routine session, use the preconfigured environment-backed
49
+ assume-role profile and do not start an SSO browser/device flow.
50
+
47
51
  ## Operations
48
52
 
49
53
  ### migrate (run pending migrations)
@@ -73,11 +73,15 @@ Use for JS-only changes (no native module changes).
73
73
 
74
74
  ### Full Deploy (Serverless Framework)
75
75
 
76
- 1. AWS signin (discover script name from backend `package.json`):
76
+ 1. Verify AWS credentials (discover the profile from backend `package.json` or remote-routine
77
+ `~/.aws/config`):
77
78
  ```bash
78
79
  cd "${BACKEND_DIR:-../backend-v2}"
79
- bun run aws:signin:{env}
80
+ aws sts get-caller-identity --profile {aws-profile}
80
81
  ```
82
+ If this is an interactive local session and credentials are expired, refresh the backend's local
83
+ AWS signin flow. In a headless or remote-routine session, use the environment-backed assume-role
84
+ profile and do not start an SSO browser/device flow.
81
85
 
82
86
  2. Deploy all functions:
83
87
  ```bash
@@ -95,11 +95,14 @@ Use when the backend is already deployed and you only need the frontend.
95
95
 
96
96
  ### start-backend (backend only)
97
97
 
98
- 1. Check AWS credentials (discover profile from backend `package.json` `aws:signin:*` scripts):
98
+ 1. Check AWS credentials (discover profile from backend `package.json` scripts or remote-routine
99
+ `~/.aws/config`):
99
100
  ```bash
100
101
  aws sts get-caller-identity --profile {aws-profile} 2>/dev/null
101
102
  ```
102
- If expired, run the backend's `aws:signin:{env}` script.
103
+ If this is an interactive local session and credentials are expired, refresh the backend's local
104
+ AWS signin flow. In headless sessions, rely on the configured environment-backed AWS profile and
105
+ do not start an SSO browser/device flow.
103
106
 
104
107
  2. Start:
105
108
  ```bash
@@ -1,59 +1,126 @@
1
1
  # Phaser 4 Project Rules
2
2
 
3
- This is a **Phaser 4** (v4.1+ "Salusa") TypeScript game project. Phaser 4 is the
4
- only supported target never introduce Phaser 3 idioms. The lint config enforces
5
- the bans below; do not disable those rules, fix the code.
6
-
7
- ## Phaser 4 Only — Banned v3 Idioms
8
-
9
- - **No pipelines.** `setPipeline` / `setPostPipeline` / `resetPipeline` are gone.
10
- Custom rendering is a **RenderNode** (registered via `render.renderNodes` in the
11
- game config); post-processing is a **Filter** (`gameObject.filters` /
12
- `camera.filters`). See the `phaser-rendering` skill.
13
- - **No preFX/postFX.** The v3 FX controllers were replaced by the unified Filter
14
- system. `BitmapMask` `Mask` filter.
15
- - **No `setTintFill`/`tintFill`.** Use `setTint()` + `setTintMode(Phaser.TintModes.FILL)`.
16
- - **No `Phaser.Geom.Point`** (removed use `Phaser.Math.Vector2`) and **no
17
- `Phaser.Struct.Set/Map`** (removed use native `Set`/`Map`).
18
- - **No raw WebGL calls.** External GL work goes through the `Extern` game object.
19
- - **No `setPipeline('Light2D')`.** Lighting is `gameObject.setLighting(true)`.
3
+ This is a **Phaser 4** (v4.2+, npm `phaser@^4.2.0`) TypeScript game project built
4
+ on the official `template-vite-ts` layout (Vite + TypeScript 6). Phaser 4 is the
5
+ only supported target never introduce Phaser 3 idioms. These decisions are
6
+ **locked** and most are **lint-enforced**; do not disable a rule, fix the code.
7
+
8
+ ## Locked architecture decisions
9
+
10
+ 1. **Thin scenes over a pure-logic core.** Scenes and GameObjects are thin
11
+ adapters that wire pure logic to the engine. All game rules live in
12
+ `src/logic/**` as plain TypeScript with **zero `phaser` imports** (data in,
13
+ data out). This is what makes the game unit-testable. ECS (bitECS / Miniplex)
14
+ is an opt-in option, not the default — reach for it only at high entity
15
+ counts. See `phaser-project-structure` and `phaser-testing`.
16
+ 2. **Canvas-only, framework-agnostic UI.** UI is plain TS + DOM/canvas (the
17
+ `template-vite-ts` baseline). A React/Vue EventBus bridge is documented only
18
+ as an upgrade path it is not the default and is not added unless required.
19
+ 3. **Arcade physics by default; Matter is opt-in.** Matter is heavier and does
20
+ not interop with Arcade. Switching is a one-line config swap. See
21
+ `phaser-physics`.
22
+ 4. **Determinism.** No `Math.random()`, `Date.now()`, or `performance.now()` in
23
+ game code. Use the seeded `Phaser.Math.RandomDataGenerator` (`Phaser.Math.RND`
24
+ or a local instance seeded from one place) so replays and tests reproduce.
25
+ 5. **State and events.** Global state goes through a **typed wrapper over the
26
+ registry**; cross-cutting events go through a **single dedicated
27
+ EventsCenter** (`new Phaser.Events.EventEmitter()`) — **never reuse
28
+ `game.events`**. Every external `.on()` (`this.input` / `scale` / `time` /
29
+ `window` / the custom bus) must have a matching `.off()` in the scene's
30
+ `shutdown`. See `phaser-services`.
31
+ 6. **Performance.** Pool transient objects via `Group`s; make **no allocations
32
+ and create no objects/tweens/timers inside `update()`**; atlas everything; use
33
+ `BitmapText` for high-churn text; use `SpriteGPULayer` / `TilemapGPULayer` for
34
+ mass rendering. See `phaser-gameobjects`.
35
+ 7. **Baked-in asset pipeline.** Raw art in `assets/src` is packed at build time
36
+ (free-tex-packer-core atlases, audiosprite, BMFont) into `public/assets`, and
37
+ a codegen step emits typed keys to `src/assets.ts` so a missing or renamed key
38
+ is a **compile error**. No raw string asset / scene / event keys anywhere.
39
+ See `phaser-asset-pipeline`.
40
+ 8. **PWA on by default** via `vite-plugin-pwa` (`registerType: "autoUpdate"`,
41
+ `globPatterns` extended to cover game assets). See `phaser-build-deploy`.
42
+ 9. **Cross-cutting services are scaffolded** in `src/services/**`: SoundService
43
+ (mobile audio unlock on first gesture), InputService (semantic actions, not
44
+ raw keys), SaveService (typed `localStorage` with a schema `VERSION` +
45
+ migration chain — never raw `localStorage`), a typed i18n string catalog (no
46
+ hardcoded user-facing strings), accessibility (prefers-reduced-motion,
47
+ pause-on-blur, keyboard-navigable menus, screen-reader live region), and a
48
+ vendor-neutral telemetry/analytics abstraction. In-game errors are wired to
49
+ the observability sink. See `phaser-services`, `phaser-i18n`,
50
+ `phaser-accessibility`.
51
+ 10. **Testing is a pyramid.** Pure logic is unit-tested with Vitest;
52
+ scenes/entities are excluded from unit coverage and verified by **runtime
53
+ gates** in CI (boot smoke, allocation/perf budget, leak gate, determinism
54
+ gate, deterministic visual regression, bundle-size budget). See
55
+ `phaser-testing`. Build pins: `phaser ^4.2.0`, Vite, TypeScript 6.
56
+
57
+ ## Enforced lint rules (prose must match machine enforcement)
58
+
59
+ The lint config enforces the rules below. Each exists because the prose above
60
+ relies on it — keep them in sync.
61
+
62
+ **`no-restricted-imports`**
63
+
64
+ - Importing `phaser` anywhere under `src/logic/**` is banned. The logic core
65
+ stays engine-free so Vitest runs it without a browser.
66
+
67
+ **`no-restricted-syntax`** bans:
68
+
69
+ - Removed v3 idioms: `setPipeline` / `setPostPipeline` / `resetPipeline`,
70
+ `setTintFill`, `preFX` / `postFX`, `Phaser.Geom.Point`, `Phaser.Struct`,
71
+ `BitmapMask`, `Mesh`, `Plane`, `Camera3D`. Use the v4 replacements
72
+ (RenderNodes, Filters, `Phaser.Math.Vector2`, native `Set`/`Map`, GPU layers).
73
+ - `Math.random()` / `Date.now()` / `performance.now()` in `src` game code — use
74
+ the seeded RND and the scene clock (`this.time.now`).
75
+ - Reusing `game.events` for app messaging — use the dedicated EventsCenter.
76
+ - `debug: true` inside a physics/game config object literal — debug stays off in
77
+ committed code (toggle locally, never commit it on).
78
+
79
+ **Direct-`localStorage` ban**
80
+
81
+ - Direct `localStorage` access outside `src/services/**` is banned. Persist
82
+ through SaveService (versioned + migrated).
83
+
84
+ **Custom `eslint-plugin-phaser` rules**
85
+
86
+ - `no-create-in-update` — no `this.add.*`, `tweens.add`, `time.addEvent`,
87
+ `physics.add.*`, or `new Phaser.*` inside an `update()` method. Create in
88
+ `create()`; in the loop, reuse and pool.
89
+ - `no-allocation-in-update` — no object/array literals, closures, or
90
+ `.map`/`.filter`/`.reduce` chains inside `update()`. Hoist scratch objects.
91
+ - `require-shutdown-cleanup` — a `Scene` that registers persistent external
92
+ listeners must define a `shutdown` handler that removes them.
20
93
 
21
94
  ## Architecture
22
95
 
23
96
  - **One scene class per file** under `src/scenes/`, named after the scene key.
24
97
  The scene flow is `Boot → Preloader → MainMenu → Game` (plus overlays). Boot
25
98
  loads only what the Preloader needs; the Preloader loads everything else.
26
- - **Pure game logic lives outside scenes** in `src/logic/` (or `src/core/`) with
27
- **no `phaser` imports** plain TypeScript functions and classes that take and
28
- return data. Scenes are thin orchestrators that wire logic to GameObjects.
29
- This is what makes the game unit-testable; see the `phaser-testing` skill.
30
- - **Asset keys are typed constants** in `src/assets.ts` never inline magic
31
- strings for texture/audio/animation keys. Load via asset-pack manifests
32
- (`this.load.pack`), not ad-hoc `load.image` lists scattered across scenes.
33
-
34
- ## Determinism
35
-
36
- - **No `Math.random()` in game code.** Use the scene-seeded
37
- `Phaser.Math.RandomDataGenerator` (`Phaser.Math.RND` or a local instance with
38
- an explicit seed) so replays and tests are reproducible.
39
- - Arcade physics keeps its v4 default `fixedStep: true`. Do not switch physics to
40
- variable step to "fix" a tunneling bug — fix the body/velocity configuration.
99
+ - **Pure game logic lives in `src/logic/**`** with no `phaser` imports — plain
100
+ TypeScript that takes and returns data. Scenes/entities are thin orchestrators
101
+ that wire that logic to GameObjects. See `phaser-testing`.
102
+ - **Keys are typed constants** generated into `src/assets.ts` — never inline
103
+ magic strings for texture/audio/animation/scene/event keys. Load via asset-pack
104
+ manifests (`this.load.pack`), not ad-hoc `load.image` lists.
41
105
 
42
106
  ## Performance
43
107
 
44
- - **No allocations in `update()`.** No `new`, array literals, closures, or
45
- `.filter/.map` chains in per-frame paths — hoist scratch objects, reuse vectors.
108
+ - **No allocations in `update()`** and **no object/tween/timer creation in
109
+ `update()`** (both lint-enforced) — hoist scratch objects, reuse vectors.
46
110
  - **Pool, don't churn.** Bullets, enemies, particles, and pickups come from
47
- `Group` pools (`get`/`killAndHide`), never `new`/`destroy` per spawn.
48
- - **Mass rendering uses the GPU layers.** Large static/animated sprite fields →
49
- `SpriteGPULayer`; large tile maps → `TilemapGPULayer`. Texture atlases (PCT
50
- where possible) over loose images — see the `phaser-assets` skill.
51
- - Target WebGL; the Canvas renderer is deprecated in v4 and only acceptable as an
52
- explicit, documented fallback decision.
111
+ `Group` pools (`get` / `killAndHide`), never `new` / `destroy` per spawn.
112
+ - **Mass rendering uses the GPU layers.** Large sprite fields → `SpriteGPULayer`;
113
+ large tile maps → `TilemapGPULayer`. Atlas everything (see
114
+ `phaser-asset-pipeline`); `BitmapText` for high-churn text.
115
+ - Target WebGL; the Canvas renderer is deprecated in v4 and acceptable only as an
116
+ explicit, documented fallback.
53
117
 
54
118
  ## Verification
55
119
 
56
- Before reporting any change complete: run `bun run typecheck`, `bun run test`,
57
- and `bun run build`. For changes that affect rendering or input, verify in the
58
- real browser — `bun run dev` plus a Playwright check (the game boots, the canvas
59
- renders, no console errors). A green typecheck alone is not proof a game works.
120
+ Before reporting any change complete: run `bun run typecheck`, `bun run lint`,
121
+ `bun run test`, and `bun run build`. For changes that affect rendering or input,
122
+ verify in the real browser — `bun run dev` plus a Playwright check (the game
123
+ boots, the canvas renders, no console errors). CI additionally runs the runtime
124
+ gates (`phaser-testing`). A green typecheck alone is not proof a game works.
125
+ </content>
126
+ </invoke>
@@ -0,0 +1,135 @@
1
+ ---
2
+ name: phaser-accessibility
3
+ description: This skill should be used when making a Phaser 4 game accessible — honoring prefers-reduced-motion, pausing on window/tab blur, keyboard navigation and visible focus for menus, colorblind-safe palettes, and a screen-reader live region that announces game state through the DOM. Use it when building menus, settings, HUD, or any player-facing UI, or when an accessibility requirement comes up. Pairs with phaser-services, phaser-i18n, and phaser-scenes.
4
+ ---
5
+
6
+ # Phaser 4 Accessibility
7
+
8
+ ## Overview
9
+
10
+ The canvas is opaque to assistive tech, so accessibility is something you build
11
+ in, not get for free. Five pillars carry most of the value: respect
12
+ `prefers-reduced-motion`, pause when the window loses focus, make menus fully
13
+ keyboard-navigable with visible focus, use colorblind-safe palettes, and mirror
14
+ game state into a DOM **live region** for screen readers. These wire through the
15
+ shared services ([[phaser-services]]) and use translated strings ([[phaser-i18n]]).
16
+
17
+ ## prefers-reduced-motion
18
+
19
+ Read the media query once and gate non-essential motion (screen shake, parallax,
20
+ big tweens, particle bursts) behind it. Reduced motion means "convey the same
21
+ information with less movement", not "remove feedback".
22
+
23
+ ```ts
24
+ // src/services/a11y.ts
25
+ export const reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
26
+
27
+ // in a scene
28
+ if (!reduceMotion) this.cameras.main.shake(120, 0.004);
29
+ this.tweens.add({ targets: panel, alpha: 1, duration: reduceMotion ? 0 : 250 });
30
+ ```
31
+
32
+ Expose it as a togglable setting too (some players want it on regardless of OS),
33
+ stored via SaveService ([[phaser-services]]).
34
+
35
+ ## Pause on blur
36
+
37
+ A game that keeps running while the tab is hidden drains battery, desyncs audio,
38
+ and is hostile to players who switch away. Phaser already exposes blur/focus
39
+ events — pause the loop and audio, resume on focus.
40
+
41
+ ```ts
42
+ this.game.events.on(Phaser.Core.Events.BLUR, () => { this.scene.pause(); this.sound.pauseAll(); });
43
+ this.game.events.on(Phaser.Core.Events.FOCUS, () => { this.scene.resume(); this.sound.resumeAll(); });
44
+ ```
45
+
46
+ Set `Phaser.Types.Core.GameConfig.autoFocus` and `disableContextMenu` as needed.
47
+ (These are listeners — remove them in `shutdown` per the on/off discipline in
48
+ [[phaser-services]].) For competitive/timed play, pausing on blur is also the
49
+ fair behavior.
50
+
51
+ ## Keyboard navigation and visible focus
52
+
53
+ Every menu must be operable without a pointer: arrow keys / Tab move focus, Enter
54
+ or Space activates, Escape backs out. Keep a focus index over a typed list of
55
+ items and render an unmistakable focus indicator (outline/scale, not color alone).
56
+
57
+ ```ts
58
+ private items: MenuItem[] = [];
59
+ private focus = 0;
60
+
61
+ private move(delta: number) {
62
+ this.items[this.focus].setFocused(false);
63
+ this.focus = Phaser.Math.Wrap(this.focus + delta, 0, this.items.length);
64
+ this.items[this.focus].setFocused(true); // visible outline + announce
65
+ this.announce(this.items[this.focus].label);
66
+ }
67
+ create() {
68
+ this.input.keyboard!.on("keydown-DOWN", () => this.move(1));
69
+ this.input.keyboard!.on("keydown-UP", () => this.move(-1));
70
+ this.input.keyboard!.on("keydown-ENTER",() => this.items[this.focus].activate());
71
+ }
72
+ ```
73
+
74
+ Use the semantic InputService actions ([[phaser-services]]) so the same bindings
75
+ serve gamepad and touch. Never rely on hover-only affordances.
76
+
77
+ ## Colorblind-safe palettes
78
+
79
+ Never encode meaning in hue alone — pair every color cue with a shape, icon,
80
+ label, or pattern (red enemy *and* a spike icon; green/red status *and* a check/x).
81
+ Choose palettes that stay distinguishable across deuteranopia/protanopia
82
+ /tritanopia, and offer a colorblind palette option in settings.
83
+
84
+ ```ts
85
+ // src/logic/palette.ts — pure, testable, no phaser import
86
+ export const palettes = {
87
+ default: { ally: 0x2e7d32, enemy: 0xc62828, neutral: 0xf9a825 },
88
+ deuter: { ally: 0x0072b2, enemy: 0xd55e00, neutral: 0xf0e442 }, // Okabe–Ito, CB-safe
89
+ } as const;
90
+ ```
91
+
92
+ Keep palette selection in `src/logic/**` so contrast/choice logic is unit-tested,
93
+ and store the player's choice via SaveService.
94
+
95
+ ## Screen-reader live region
96
+
97
+ Mirror important state changes into an ARIA live region in the DOM (outside the
98
+ canvas) so screen readers announce them. One polite region for status, one
99
+ assertive for urgent events.
100
+
101
+ ```html
102
+ <!-- index.html, alongside the game container -->
103
+ <div id="sr-status" aria-live="polite" class="sr-only"></div>
104
+ <div id="sr-alert" aria-live="assertive" class="sr-only"></div>
105
+ ```
106
+
107
+ ```ts
108
+ // src/services/a11y.ts
109
+ const status = document.getElementById("sr-status")!;
110
+ export function announce(msg: string, urgent = false) {
111
+ const el = urgent ? document.getElementById("sr-alert")! : status;
112
+ el.textContent = ""; el.textContent = msg; // clear+set so identical repeats re-announce
113
+ }
114
+ ```
115
+
116
+ Announce menu focus, score milestones, level changes, and game-over. Messages
117
+ come from the i18n catalog ([[phaser-i18n]]) — never hardcoded — and `.sr-only`
118
+ keeps the region visually hidden but readable by AT.
119
+
120
+ ## Project conventions
121
+
122
+ - A11y plumbing lives in `src/services/a11y.ts`; palette/choice logic lives in
123
+ `src/logic/**` (unit-tested).
124
+ - Accessibility settings (reduced motion, colorblind palette) persist via
125
+ SaveService and apply on boot ([[phaser-services]]).
126
+ - All announced/visible text comes from the i18n catalog ([[phaser-i18n]]).
127
+
128
+ ## Verification
129
+
130
+ Verified by manual passes that double as runtime checks: tab through every menu
131
+ with the pointer unplugged and confirm visible focus + activation; set the OS to
132
+ reduce-motion and confirm shake/parallax stop while feedback remains; blur the
133
+ tab and confirm the game pauses and audio stops; and run a screen reader (VoiceOver
134
+ /NVDA) to confirm the live region announces menu focus and game state.
135
+ </content>
@@ -0,0 +1,148 @@
1
+ ---
2
+ name: phaser-asset-pipeline
3
+ description: This skill should be used when setting up or changing the build-time asset pipeline of a Phaser 4 game — packing raw art in assets/src into public/assets (free-tex-packer-core texture atlases, audiosprite audio sprites, BMFont bitmap fonts) and the codegen step that emits typed keys to src/assets.ts so a missing or renamed key is a compile error. Use it when adding source art, wiring packing into the build, regenerating typed keys, or eliminating raw string asset keys. Pairs with phaser-assets, phaser-build-deploy, and phaser-services.
4
+ ---
5
+
6
+ # Phaser 4 Asset Pipeline
7
+
8
+ ## Overview
9
+
10
+ Runtime assets are **generated, not hand-placed**. Raw source art lives in
11
+ `assets/src/**` (PNGs, audio, font sources); a build step packs it into
12
+ `public/assets/**` (atlases, audio sprites, bitmap fonts) and **codegens typed
13
+ key constants into `src/assets.ts`**. The payoff: a missing or renamed asset is a
14
+ **compile error**, not a green square or silent-missing audio at runtime. No raw
15
+ string asset / scene / event keys anywhere — they all come from the generated
16
+ module ([[phaser-assets]] covers loading those keys at runtime).
17
+
18
+ ## Layout
19
+
20
+ | Path | Role |
21
+ | --- | --- |
22
+ | `assets/src/sprites/**` | Raw individual PNGs — the art source of truth |
23
+ | `assets/src/audio/**` | Raw audio clips (wav/ogg sources) |
24
+ | `assets/src/fonts/**` | Font sources for BMFont generation |
25
+ | `public/assets/**` | **Generated** packed output (atlases, audiosprites, fonts, `pack.json`) — git-ignored or committed as a build artifact |
26
+ | `src/assets.ts` | **Generated** typed key constants — never edited by hand |
27
+ | `scripts/pack-assets.mjs` | The pipeline driver (runs the three packers + codegen) |
28
+
29
+ ## Step 1: texture atlases with free-tex-packer-core
30
+
31
+ `free-tex-packer-core` packs many PNGs into atlas pages plus a JSON manifest, in
32
+ a Node script (no GUI, runs in CI):
33
+
34
+ ```js
35
+ // scripts/pack-assets.mjs (excerpt)
36
+ import { packAsync } from "free-tex-packer-core";
37
+ import { glob } from "glob";
38
+ import { readFile, writeFile } from "node:fs/promises";
39
+
40
+ const images = await Promise.all(
41
+ (await glob("assets/src/sprites/**/*.png")).map(async p => ({
42
+ path: p.replace("assets/src/sprites/", ""), contents: await readFile(p),
43
+ })));
44
+
45
+ const files = await packAsync(images, {
46
+ textureName: "game", width: 2048, height: 2048,
47
+ padding: 2, allowRotation: false, allowTrim: true,
48
+ exporter: "JsonHash", removeFileExtension: true,
49
+ });
50
+ for (const f of files) await writeFile(`public/assets/atlases/${f.name}`, f.buffer ?? f.content);
51
+ ```
52
+
53
+ The frame names in the manifest become the atlas frame keys you reference as
54
+ generated constants. Atlas everything that renders together — loose images break
55
+ sprite batching ([[phaser-assets]]).
56
+
57
+ ## Step 2: audio sprites with audiosprite
58
+
59
+ `audiosprite` concatenates short SFX into one file (in multiple codecs) plus a
60
+ JSON map of `{ start, end }` per clip — one request, one decode, instead of dozens:
61
+
62
+ ```jsonc
63
+ // package.json script
64
+ "pack:audio": "audiosprite --output public/assets/audio/sfx --export ogg,m4a --format howler2 assets/src/audio/*.wav"
65
+ ```
66
+
67
+ Provide at least two codecs (`ogg` + `m4a`) so every browser can play one. Load
68
+ with `this.load.audioSprite(Audio.Sfx, "audio/sfx.json")` and play by sprite key.
69
+
70
+ ## Step 3: bitmap fonts with BMFont
71
+
72
+ `BitmapText` is the performant choice for high-churn text (scores, timers) —
73
+ [[phaser-assets]] / [[phaser-i18n]]. Generate the `.fnt` (XML/JSON) + PNG page
74
+ from a font source with a BMFont tool (`msdf-bmfont-xml` or the `bmfont` CLI) in
75
+ the same script:
76
+
77
+ ```jsonc
78
+ "pack:font": "msdf-bmfont -o public/assets/fonts/ui --font-size 42 --texture-size 1024 1024 assets/src/fonts/ui.ttf"
79
+ ```
80
+
81
+ Load with `this.load.bitmapFont(Font.UI, "fonts/ui.png", "fonts/ui.fnt")`.
82
+
83
+ ## Step 4: codegen typed keys into `src/assets.ts`
84
+
85
+ After packing, walk the generated manifests and emit `as const` key maps. This is
86
+ the step that turns runtime failures into compile failures:
87
+
88
+ ```js
89
+ // scripts/pack-assets.mjs (codegen excerpt)
90
+ const atlas = JSON.parse(await readFile("public/assets/atlases/game.json", "utf8"));
91
+ const frames = Object.keys(atlas.frames); // raw keys, e.g. "player/idle"
92
+ const sfx = Object.keys(JSON.parse(await readFile("public/assets/audio/sfx.json","utf8")).spritemap);
93
+
94
+ const out = `// AUTO-GENERATED by scripts/pack-assets.mjs — do not edit.
95
+ export const Tex = { GameAtlas: "game" } as const;
96
+ export const Frame = { ${frames.map(k => `${toIdent(k)}: "${k}"`).join(", ")} } as const;
97
+ export const Audio = { Sfx: "sfx" } as const;
98
+ export const Sfx = { ${sfx.map(s => `${toIdent(s)}: "${s}"`).join(", ")} } as const;
99
+ export const Font = { UI: "ui" } as const;
100
+ export const SceneKeys = { Boot:"Boot", Preloader:"Preloader", MainMenu:"MainMenu", Game:"Game" } as const;
101
+ export const GameEvent = { ScoreChanged:"score-changed", EnemyDied:"enemy-died" } as const;
102
+ `;
103
+ await writeFile("src/assets.ts", out);
104
+ ```
105
+
106
+ Scenes import `Tex`, `Frame`, `Sfx`, `Font`, `SceneKeys`, `GameEvent` — never an
107
+ inline string. Rename art, re-run the pipeline, and every now-stale reference
108
+ fails `bun run typecheck` immediately. (Scene/event keys are kept in the same
109
+ generated module so they share the no-raw-string discipline; edit them via the
110
+ codegen template, not by hand.)
111
+
112
+ ## Step 5: wire into the build
113
+
114
+ The pipeline runs before dev and before build so generated output is never stale:
115
+
116
+ ```jsonc
117
+ // package.json
118
+ "scripts": {
119
+ "assets": "node scripts/pack-assets.mjs",
120
+ "predev": "bun run assets",
121
+ "prebuild": "bun run assets",
122
+ "dev": "vite",
123
+ "build": "vite build"
124
+ }
125
+ ```
126
+
127
+ For fast iteration, a `--watch` mode on the pack script re-packs changed source
128
+ art. In CI the pack step runs once before `vite build`; the build then hashes the
129
+ generated files for immutable caching ([[phaser-build-deploy]]).
130
+
131
+ ## Project conventions
132
+
133
+ - `assets/src/**` is the source of truth; `public/assets/**` and `src/assets.ts`
134
+ are generated — treat them as build output (re-runnable, not hand-edited).
135
+ - One atlas per render group, one audiosprite per SFX set, BMFont for hot text.
136
+ - A contract test asserts every constant in `src/assets.ts` resolves to an entry
137
+ in the generated `pack.json`/manifests ([[phaser-testing]]).
138
+ - The generated `src/assets.ts` is the single source of asset/scene/event keys —
139
+ the no-raw-string-keys rule depends on it existing.
140
+
141
+ ## Verification
142
+
143
+ The pipeline is verified by deleting a source PNG and re-running `bun run assets`:
144
+ the corresponding generated constant disappears and `bun run typecheck` fails at
145
+ every use site (proving keys are compile-checked). Then boot the game and confirm
146
+ the atlas/audiosprite/font load with no `FILE_LOAD_ERROR` and render/play
147
+ correctly.
148
+ </content>