@playcraft/cli 0.0.53 → 0.0.56

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 (242) hide show
  1. package/README.md +21 -0
  2. package/REMIX.md +103 -19
  3. package/dist/atom-tree/fusion-hints.js +8 -3
  4. package/dist/atom-tree/fusion-intent.js +62 -0
  5. package/dist/atom-tree/selection.js +3 -1
  6. package/dist/commands/create.js +439 -159
  7. package/dist/commands/image.js +79 -69
  8. package/dist/commands/levels.js +29 -0
  9. package/dist/commands/patterns.js +75 -0
  10. package/dist/commands/remix.js +47 -0
  11. package/dist/commands/skills.js +48 -17
  12. package/dist/index.js +13 -6
  13. package/dist/remix/clone-source.js +208 -0
  14. package/dist/remix/clone.js +255 -0
  15. package/dist/scaffold/templates.js +35 -0
  16. package/dist/utils/agent-api-client.js +10 -3
  17. package/dist/utils/remix-image-attachments.js +4 -32
  18. package/dist/utils/sandbox-path.js +20 -0
  19. package/package.json +3 -3
  20. package/project-template/.claude/agents/creative-director.md +114 -0
  21. package/project-template/.claude/agents/developer.md +5 -2
  22. package/project-template/.claude/agents/game-designer.md +41 -20
  23. package/project-template/.claude/agents/refs/README.md +8 -0
  24. package/project-template/.claude/agents/refs/creative-director-guide.md +35 -0
  25. package/project-template/.claude/agents/refs/creative-director-kickoff-guide.md +52 -0
  26. package/project-template/.claude/agents/refs/creative-discovery-guide.md +76 -0
  27. package/project-template/.claude/agents/refs/creative-north-star-examples.md +82 -0
  28. package/project-template/.claude/agents/refs/developer-dev-handoff.md +1 -1
  29. package/project-template/.claude/agents/refs/game-designer-fusion-depth-playbook.md +28 -0
  30. package/project-template/.claude/agents/refs/game-designer-gameplay-sufficiency.md +4 -4
  31. package/project-template/.claude/agents/reviewer.md +11 -0
  32. package/project-template/.claude/hooks/README.md +12 -12
  33. package/project-template/.claude/hooks/block-developer-preflight.mjs +49 -13
  34. package/project-template/.claude/hooks/block-ring1-tasklist.mjs +1 -1
  35. package/project-template/.claude/hooks/user-prompt.mjs +3 -13
  36. package/project-template/.claude/hooks/validate-workflow-stop.mjs +209 -12
  37. package/project-template/.claude/settings.json +2 -2
  38. package/project-template/.claude/skills/playcraft-playable-optimization/SKILL.md +20 -20
  39. package/project-template/.claude/skills/session-analyzer/scripts/resolve-session.mjs +0 -1
  40. package/project-template/.claude/snapshot.mjs +0 -1
  41. package/project-template/.codebuddy/settings.json +1 -1
  42. package/project-template/.cursor/rules/playcraft-orchestrator.mdc +1 -1
  43. package/project-template/CLAUDE.md +9 -9
  44. package/project-template/docs/project-state.md +1 -1
  45. package/project-template/docs/team/agent-conduct.md +18 -18
  46. package/project-template/docs/team/collaboration.md +19 -7
  47. package/project-template/docs/team/workflow-changelog.md +15 -0
  48. package/project-template/fusion-patterns/catalog.json +77 -0
  49. package/project-template/package.json +2 -0
  50. package/project-template/skills/_shared/scripts/create-playable.mjs +31 -11
  51. package/project-template/skills/_shared/scripts/dev-start.mjs +3 -3
  52. package/project-template/skills/_shared/scripts/disclosure-config.mjs +65 -39
  53. package/project-template/skills/_shared/scripts/harness-smoke.mjs +3 -1
  54. package/project-template/skills/_shared/scripts/lib/fusion-intent.mjs +88 -0
  55. package/project-template/skills/_shared/scripts/lib/skill-fidelity.mjs +185 -0
  56. package/project-template/skills/_shared/scripts/slice-set.mjs +29 -2
  57. package/project-template/skills/_shared/scripts/state-get.mjs +124 -7
  58. package/project-template/skills/_shared/scripts/state-store.mjs +25 -2
  59. package/project-template/skills/_shared/scripts/validate-level-sketch.mjs +444 -0
  60. package/project-template/skills/_shared/scripts/verify-design-consistency.mjs +728 -0
  61. package/project-template/skills/playable-record/scripts/lib/dev-server.mjs +46 -11
  62. package/project-template/skills/playable-record/scripts/record-playable.mjs +2 -1
  63. package/project-template/skills/playable-record/scripts/verify-contract.mjs +4 -4
  64. package/project-template/skills/playable-record/scripts/verify-firstwin.mjs +3 -3
  65. package/project-template/skills/playable-record/scripts/verify-fusion.mjs +37 -2
  66. package/project-template/skills/playable-record/scripts/verify-slice.mjs +2 -2
  67. package/project-template/templates/design-brief.template.md +34 -0
  68. package/project-template/templates/design-methodology.md +1 -2
  69. package/project-template/templates/design.template.md +65 -0
  70. package/project-template/templates/developer-log.template.md +12 -1
  71. package/project-template/templates/five-axis-framework.md +12 -0
  72. package/project-template/templates/game-designer-creative-process.template.md +99 -0
  73. package/project-template/templates/level-sketch.template.json +56 -0
  74. package/project-template/templates/north-star.template.md +43 -0
  75. package/project-template/templates/project-state.template.md +1 -1
  76. package/project-template/vite.config.ts +4 -5
  77. package/project-templates/phaser/.claude/agents/creative-director.md +114 -0
  78. package/project-templates/phaser/.claude/agents/game-designer.md +41 -20
  79. package/project-templates/phaser/.claude/agents/refs/creative-director-guide.md +35 -0
  80. package/project-templates/phaser/.claude/agents/refs/creative-director-kickoff-guide.md +52 -0
  81. package/project-templates/phaser/.claude/agents/refs/creative-discovery-guide.md +76 -0
  82. package/project-templates/phaser/.claude/agents/refs/creative-north-star-examples.md +82 -0
  83. package/project-templates/phaser/.claude/agents/refs/developer-dev-handoff.md +1 -1
  84. package/project-templates/phaser/.claude/agents/refs/game-designer-fusion-depth-playbook.md +28 -0
  85. package/project-templates/phaser/.claude/agents/reviewer.md +11 -0
  86. package/project-templates/phaser/.claude/hooks/block-ring1-tasklist.mjs +2 -2
  87. package/project-templates/phaser/.claude/hooks/user-prompt.mjs +17 -18
  88. package/project-templates/phaser/.claude/hooks/validate-workflow-stop.mjs +209 -12
  89. package/project-templates/phaser/.claude/skills/playcraft-playable-optimization/SKILL.md +20 -20
  90. package/project-templates/phaser/.cursor/rules/playcraft-orchestrator.mdc +1 -1
  91. package/project-templates/phaser/CLAUDE.md +88 -54
  92. package/project-templates/phaser/docs/DESIGN.md +25 -0
  93. package/project-templates/phaser/docs/project-state.md +1 -1
  94. package/project-templates/phaser/docs/team/collaboration.md +19 -7
  95. package/project-templates/phaser/docs/team/workflow-changelog.md +14 -0
  96. package/project-templates/phaser/fusion-patterns/catalog.json +77 -0
  97. package/project-templates/phaser/package.json +3 -1
  98. package/project-templates/phaser/skills/_shared/scripts/dev-start.mjs +3 -3
  99. package/project-templates/phaser/skills/_shared/scripts/disclosure-config.mjs +65 -39
  100. package/project-templates/phaser/skills/_shared/scripts/harness-smoke.mjs +3 -1
  101. package/project-templates/phaser/skills/_shared/scripts/lib/fusion-intent.mjs +88 -0
  102. package/project-templates/phaser/skills/_shared/scripts/lib/skill-fidelity.mjs +185 -0
  103. package/project-templates/phaser/skills/_shared/scripts/state-get.mjs +124 -7
  104. package/project-templates/phaser/skills/_shared/scripts/state-store.mjs +25 -2
  105. package/project-templates/phaser/skills/_shared/scripts/validate-level-sketch.mjs +444 -0
  106. package/project-templates/phaser/skills/_shared/scripts/verify-design-consistency.mjs +728 -0
  107. package/project-templates/phaser/skills/playable-record/scripts/lib/dev-server.mjs +46 -11
  108. package/project-templates/phaser/skills/playable-record/scripts/record-playable.mjs +2 -1
  109. package/project-templates/phaser/skills/playable-record/scripts/verify-contract.mjs +4 -4
  110. package/project-templates/phaser/skills/playable-record/scripts/verify-firstwin.mjs +3 -3
  111. package/project-templates/phaser/skills/playable-record/scripts/verify-fusion.mjs +37 -2
  112. package/project-templates/phaser/skills/playable-record/scripts/verify-slice.mjs +2 -2
  113. package/project-templates/phaser/templates/design-brief.template.md +42 -11
  114. package/project-templates/phaser/templates/design-methodology.md +1 -2
  115. package/project-templates/phaser/templates/design.template.md +77 -0
  116. package/project-templates/phaser/templates/five-axis-framework.md +50 -1
  117. package/project-templates/phaser/templates/game-designer-creative-process.template.md +99 -0
  118. package/project-templates/phaser/templates/level-sketch.template.json +56 -0
  119. package/project-templates/phaser/templates/north-star.template.md +43 -0
  120. package/project-templates/phaser/templates/project-state.template.md +1 -1
  121. package/project-templates/phaser/vite.config.ts +4 -5
  122. package/project-templates/playable-template-phaser/.playcraftignore +10 -0
  123. package/project-templates/playable-template-phaser/CLAUDE.md +178 -0
  124. package/project-templates/playable-template-phaser/PLAYCRAFT-MIGRATION.md +328 -0
  125. package/project-templates/playable-template-phaser/README.md +381 -0
  126. package/project-templates/playable-template-phaser/assets/brain.png +0 -0
  127. package/project-templates/playable-template-phaser/assets/button.png +0 -0
  128. package/project-templates/playable-template-phaser/assets/interact.png +0 -0
  129. package/project-templates/playable-template-phaser/assets/logo.webp +0 -0
  130. package/project-templates/playable-template-phaser/assets/warn_brain.png +0 -0
  131. package/project-templates/playable-template-phaser/builds.config.js +12 -0
  132. package/project-templates/playable-template-phaser/globals.d.ts +2 -0
  133. package/project-templates/playable-template-phaser/index.html +12 -0
  134. package/project-templates/playable-template-phaser/package.json +45 -0
  135. package/project-templates/playable-template-phaser/scripts/base64-to-mp3.js +340 -0
  136. package/project-templates/playable-template-phaser/scripts/convert-to-webp.js +370 -0
  137. package/project-templates/playable-template-phaser/src/Game.ts +154 -0
  138. package/project-templates/playable-template-phaser/src/config/LoadingConfig.ts +40 -0
  139. package/project-templates/playable-template-phaser/src/config/ThemeConfig.ts +81 -0
  140. package/project-templates/playable-template-phaser/src/index.css +18 -0
  141. package/project-templates/playable-template-phaser/src/index.html +9 -0
  142. package/project-templates/playable-template-phaser/src/index.ts +30 -0
  143. package/project-templates/playable-template-phaser/src/json5.d.ts +4 -0
  144. package/project-templates/playable-template-phaser/src/managers/AudioManager.ts +559 -0
  145. package/project-templates/playable-template-phaser/src/scenes/MainScene.ts +301 -0
  146. package/project-templates/playable-template-phaser/src/scenes/PreloadScene.ts +256 -0
  147. package/project-templates/playable-template-phaser/src/theme/README.md +194 -0
  148. package/project-templates/playable-template-phaser/src/theme/blue-theme/assets/.gitkeep +24 -0
  149. package/project-templates/playable-template-phaser/src/theme/blue-theme/index.ts +27 -0
  150. package/project-templates/playable-template-phaser/src/theme/blue-theme/theme.data.json5 +19 -0
  151. package/project-templates/playable-template-phaser/src/theme/green-theme/assets/.gitkeep +3 -0
  152. package/project-templates/playable-template-phaser/src/theme/green-theme/index.ts +20 -0
  153. package/project-templates/playable-template-phaser/src/theme/green-theme/theme.data.json5 +19 -0
  154. package/project-templates/playable-template-phaser/src/theme/index.ts +1 -0
  155. package/project-templates/playable-template-phaser/src/theme/red-theme/assets/.gitkeep +3 -0
  156. package/project-templates/playable-template-phaser/src/theme/red-theme/index.ts +20 -0
  157. package/project-templates/playable-template-phaser/src/theme/red-theme/theme.data.json5 +19 -0
  158. package/project-templates/playable-template-phaser/src/theme/theme.metadata.md +60 -0
  159. package/project-templates/playable-template-phaser/src/theme/theme.schema.json5 +149 -0
  160. package/project-templates/playable-template-phaser/src/ui/BrainAgeUI.ts +681 -0
  161. package/project-templates/playable-template-phaser/src/ui/CountdownUI.ts +565 -0
  162. package/project-templates/playable-template-phaser/src/ui/PlayButton.ts +51 -0
  163. package/project-templates/playable-template-phaser/src/ui/ScoreUI.ts +207 -0
  164. package/project-templates/playable-template-phaser/src/ui/SuccessUI.ts +43 -0
  165. package/project-templates/playable-template-phaser/src/ui/index.ts +15 -0
  166. package/project-templates/playable-template-phaser/tsconfig.json +26 -0
  167. package/project-templates/playable-template-phaser/vite.config.ts +64 -0
  168. package/project-templates/playable-template-phaser//346/226/260/346/211/213/345/274/200/345/217/221/346/214/207/345/215/227.md +209 -0
  169. package/project-templates/playable-template-three/README.md +795 -0
  170. package/project-templates/playable-template-three/assets/Stork.glb +0 -0
  171. package/project-templates/playable-template-three/assets/button.png +0 -0
  172. package/project-templates/playable-template-three/assets/logo.webp +0 -0
  173. package/project-templates/playable-template-three/build.json +7 -0
  174. package/project-templates/playable-template-three/builds.config.example.js +151 -0
  175. package/project-templates/playable-template-three/builds.config.js +158 -0
  176. package/project-templates/playable-template-three/package.json +36 -0
  177. package/project-templates/playable-template-three/scripts/convert-to-webp.js +370 -0
  178. package/project-templates/playable-template-three/scripts/theme-builds.js +514 -0
  179. package/project-templates/playable-template-three/src/Game.ts +215 -0
  180. package/project-templates/playable-template-three/src/config/LoadingConfig.ts +27 -0
  181. package/project-templates/playable-template-three/src/config/ThemeConfig.ts +36 -0
  182. package/project-templates/playable-template-three/src/global.d.ts +108 -0
  183. package/project-templates/playable-template-three/src/index.css +18 -0
  184. package/project-templates/playable-template-three/src/index.html +9 -0
  185. package/project-templates/playable-template-three/src/index.ts +20 -0
  186. package/project-templates/playable-template-three/src/managers/AudioManager.ts +538 -0
  187. package/project-templates/playable-template-three/src/scenes/PreloadScene.ts +305 -0
  188. package/project-templates/playable-template-three/src/theme/README.md +225 -0
  189. package/project-templates/playable-template-three/src/theme/blue-theme/assets/.gitkeep +28 -0
  190. package/project-templates/playable-template-three/src/theme/blue-theme/index.ts +45 -0
  191. package/project-templates/playable-template-three/src/theme/current.ts +12 -0
  192. package/project-templates/playable-template-three/src/theme/green-theme/assets/.gitkeep +3 -0
  193. package/project-templates/playable-template-three/src/theme/green-theme/index.ts +34 -0
  194. package/project-templates/playable-template-three/src/theme/red-theme/assets/.gitkeep +3 -0
  195. package/project-templates/playable-template-three/src/theme/red-theme/index.ts +34 -0
  196. package/project-templates/playable-template-three/tsconfig.json +24 -0
  197. package/project-templates/threejs/.claude/agents/creative-director.md +114 -0
  198. package/project-templates/threejs/.claude/agents/game-designer.md +41 -20
  199. package/project-templates/threejs/.claude/agents/refs/creative-director-guide.md +35 -0
  200. package/project-templates/threejs/.claude/agents/refs/creative-director-kickoff-guide.md +52 -0
  201. package/project-templates/threejs/.claude/agents/refs/creative-discovery-guide.md +76 -0
  202. package/project-templates/threejs/.claude/agents/refs/creative-north-star-examples.md +82 -0
  203. package/project-templates/threejs/.claude/agents/refs/developer-dev-handoff.md +1 -1
  204. package/project-templates/threejs/.claude/agents/refs/game-designer-fusion-depth-playbook.md +28 -0
  205. package/project-templates/threejs/.claude/agents/reviewer.md +11 -0
  206. package/project-templates/threejs/.claude/hooks/block-ring1-tasklist.mjs +2 -2
  207. package/project-templates/threejs/.claude/hooks/user-prompt.mjs +17 -18
  208. package/project-templates/threejs/.claude/hooks/validate-workflow-stop.mjs +209 -12
  209. package/project-templates/threejs/.claude/skills/playcraft-playable-optimization/SKILL.md +20 -20
  210. package/project-templates/threejs/.cursor/rules/playcraft-orchestrator.mdc +1 -1
  211. package/project-templates/threejs/CLAUDE.md +88 -54
  212. package/project-templates/threejs/docs/DESIGN.md +25 -0
  213. package/project-templates/threejs/docs/project-state.md +1 -1
  214. package/project-templates/threejs/docs/team/collaboration.md +19 -7
  215. package/project-templates/threejs/docs/team/workflow-changelog.md +14 -0
  216. package/project-templates/threejs/fusion-patterns/catalog.json +77 -0
  217. package/project-templates/threejs/package.json +3 -1
  218. package/project-templates/threejs/skills/_shared/scripts/dev-start.mjs +3 -3
  219. package/project-templates/threejs/skills/_shared/scripts/disclosure-config.mjs +65 -39
  220. package/project-templates/threejs/skills/_shared/scripts/harness-smoke.mjs +3 -1
  221. package/project-templates/threejs/skills/_shared/scripts/lib/fusion-intent.mjs +88 -0
  222. package/project-templates/threejs/skills/_shared/scripts/lib/skill-fidelity.mjs +185 -0
  223. package/project-templates/threejs/skills/_shared/scripts/state-get.mjs +124 -7
  224. package/project-templates/threejs/skills/_shared/scripts/state-store.mjs +25 -2
  225. package/project-templates/threejs/skills/_shared/scripts/validate-level-sketch.mjs +444 -0
  226. package/project-templates/threejs/skills/_shared/scripts/verify-design-consistency.mjs +728 -0
  227. package/project-templates/threejs/skills/playable-record/scripts/lib/dev-server.mjs +46 -11
  228. package/project-templates/threejs/skills/playable-record/scripts/record-playable.mjs +2 -1
  229. package/project-templates/threejs/skills/playable-record/scripts/verify-contract.mjs +4 -4
  230. package/project-templates/threejs/skills/playable-record/scripts/verify-firstwin.mjs +3 -3
  231. package/project-templates/threejs/skills/playable-record/scripts/verify-fusion.mjs +37 -2
  232. package/project-templates/threejs/skills/playable-record/scripts/verify-slice.mjs +2 -2
  233. package/project-templates/threejs/templates/design-brief.template.md +42 -11
  234. package/project-templates/threejs/templates/design-methodology.md +1 -2
  235. package/project-templates/threejs/templates/design.template.md +77 -0
  236. package/project-templates/threejs/templates/five-axis-framework.md +50 -1
  237. package/project-templates/threejs/templates/game-designer-creative-process.template.md +99 -0
  238. package/project-templates/threejs/templates/level-sketch.template.json +56 -0
  239. package/project-templates/threejs/templates/north-star.template.md +43 -0
  240. package/project-templates/threejs/templates/project-state.template.md +1 -1
  241. package/project-templates/threejs/vite.config.ts +4 -5
  242. package/project-template/docs/DESIGN.md +0 -65
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": 1,
3
+ "row": 8,
4
+ "col": 8,
5
+ "levelTime": 0,
6
+ "trayCapacity": 7,
7
+ "matchCount": 3,
8
+ "colors": ["red", "red", "red", "blue", "blue", "blue"],
9
+ "arrows": [
10
+ [
11
+ [0, 0],
12
+ [1, 0],
13
+ [2, 0],
14
+ [3, 0],
15
+ [4, 0],
16
+ [5, 0]
17
+ ],
18
+ [
19
+ [7, 1],
20
+ [6, 1],
21
+ [5, 1],
22
+ [4, 1],
23
+ [3, 1],
24
+ [2, 1]
25
+ ],
26
+ [
27
+ [2, 2],
28
+ [2, 3],
29
+ [2, 4],
30
+ [2, 5],
31
+ [2, 6]
32
+ ],
33
+ [
34
+ [0, 7],
35
+ [1, 7],
36
+ [2, 7],
37
+ [3, 7],
38
+ [4, 7]
39
+ ],
40
+ [
41
+ [7, 6],
42
+ [6, 6],
43
+ [5, 6],
44
+ [4, 6],
45
+ [3, 6]
46
+ ],
47
+ [
48
+ [6, 3],
49
+ [6, 4],
50
+ [6, 5],
51
+ [5, 5],
52
+ [4, 5],
53
+ [3, 5]
54
+ ]
55
+ ]
56
+ }
@@ -0,0 +1,43 @@
1
+ # Creative North Star — {Game Name}
2
+
3
+ <!--
4
+ Ring 1 creative discovery output (written by @creative-director).
5
+ @game-designer-spec copies §0 fields from this file into docs/DESIGN.md §0.
6
+ One-liner: verbatim. Micro-Story Spine: field-value match (trimmed per field).
7
+ Source: templates/north-star.template.md
8
+ -->
9
+
10
+ **Date**: {YYYY-MM-DD}
11
+
12
+ ---
13
+
14
+ ## Micro-Story Spine
15
+
16
+ **Narrative level**: L1 | L2 <!-- default L1; L0 only when user explicitly opts out of story; L3 forbidden -->
17
+ **Who**: {player identity; L0 may use n/a — pure mechanic showcase}
18
+ **Situation**: {opening Hook frame — one glance readable scene/situation}
19
+ **Stakes**: {what core pressure means in the player's world — not abstract game over}
20
+ **Payoff image**: {first core payoff moment — must film a PGS beat: path slide out, fly to tray, or tray match burst}
21
+ **Emotional arc**: {Urgency | Challenge | Competence | Curiosity | Relaxation}
22
+
23
+ ## One-liner
24
+
25
+ {L1/L2: one vivid pitch — must name Who or Situation; no pure debt/bet abstract stacking.}
26
+ {L0: Hook spectacle + mechanic payoff; Who optional.}
27
+
28
+ ## System Dynamic
29
+
30
+ {One sentence — what system tension keeps the player acting.}
31
+
32
+ ## Why this fusion
33
+
34
+ {2–3 sentences — how parent mechanics **serve** the idea above. Start with intent, not grid sizes.}
35
+
36
+ ## Rejected vibe
37
+
38
+ - {Not this — e.g. not a casual match-3 binge}
39
+ - {Not this — e.g. not a pure arrow logic puzzle with no payoff}
40
+
41
+ ## Design Intent
42
+
43
+ {Phase 4 single line — must match One-liner verbatim when copied to DESIGN §0.}
@@ -55,7 +55,7 @@
55
55
 
56
56
  Each iteration runs inner loops: `clarify` → `build` → `verify` → **Ring Gate** (user acceptance) → next iteration.
57
57
 
58
- <!-- Iteration definitions: see CLAUDE.md § Growth-Ring Model -->
58
+ <!-- Iteration definitions: see docs/team/collaboration.md (growth-rings-v1) -->
59
59
 
60
60
  ## Ring DoD (current iteration)
61
61
 
@@ -12,11 +12,10 @@ export default defineConfig(({ command }) => ({
12
12
  },
13
13
  server: {
14
14
  host: "0.0.0.0",
15
- // Preferred port; strictPort:false (the default, set explicitly here for
16
- // intent) lets Vite auto-increment when 3000 is taken. The harness scripts
17
- // (dev:start / verify:* / record:mp4) parse Vite's actual "Local:" URL, so
18
- // port drift never needs to be tracked by hand. See dev-start.mjs.
19
- port: 3000,
15
+ // Preferred port; avoid 6000 (Chromium ERR_UNSAFE_PORT). strictPort:false
16
+ // lets Vite auto-increment when 5173 is taken. Harness scripts parse the
17
+ // actual "Local:" URL. See dev-start.mjs.
18
+ port: 5173,
20
19
  strictPort: false,
21
20
  open: true,
22
21
  },
@@ -0,0 +1,10 @@
1
+ # 构建时排除的文件/目录
2
+ .git/
3
+ scripts/
4
+ node_modules/
5
+ *.md
6
+ *.backup
7
+ .DS_Store
8
+ vite.config.ts
9
+ index.html
10
+ tsconfig.json
@@ -0,0 +1,178 @@
1
+ # Phaser Playable Template - 项目说明
2
+
3
+ 本项目是基于 Phaser 的可玩广告模板,使用 PlayCraft 平台架构(`@playcraft/adsdk` + `@playcraft/devkit`)。
4
+
5
+ ## 架构特点
6
+
7
+ - **SDK**:`@playcraft/adsdk` - 可玩广告运行时 SDK
8
+ - **构建工具**:`@playcraft/devkit` - 可玩广告构建工具链
9
+ - **本地开发**:Vite 开发服务器,支持 HMR 热更新
10
+ - **主题系统**:配置化架构,支持 JSON5 Schema + 覆盖配置
11
+
12
+ ## 开发命令
13
+
14
+ ### 本地开发
15
+
16
+ ```bash
17
+ # 使用 Vite 开发服务器(推荐,速度快,支持 HMR)
18
+ npm run dev
19
+
20
+ # 使用 playable-scripts 开发服务器(与构建环境一致)
21
+ npm run dev:wp
22
+ ```
23
+
24
+ ### 构建
25
+
26
+ ```bash
27
+ # 构建单个渠道(preview)
28
+ npm run build
29
+
30
+ # 批量构建所有渠道
31
+ npm run builds
32
+
33
+ # 打包为 PlayCraft 模板 ZIP
34
+ npm run pack-to-playcraft-template-zip
35
+ ```
36
+
37
+ ### 资源处理
38
+
39
+ ```bash
40
+ # 将图片转为 WebP 格式(质量 90)
41
+ npm run webp
42
+
43
+ # 将图片转为 WebP 格式(质量 80)
44
+ npm run webp:80
45
+ ```
46
+
47
+ ## 目录结构
48
+
49
+ ```
50
+ playable-template-phaser/
51
+ ├── src/
52
+ │ ├── theme/ # 主题系统
53
+ │ │ ├── theme.schema.json5 # 配置协议(默认值)
54
+ │ │ ├── theme.metadata.md # 主题元数据
55
+ │ │ ├── blue-theme/ # 蓝色主题
56
+ │ │ │ ├── index.ts # 主题入口
57
+ │ │ │ ├── theme.data.json5 # 配置覆盖
58
+ │ │ │ └── assets/ # 主题资源
59
+ │ │ ├── green-theme/ # 绿色主题
60
+ │ │ ├── red-theme/ # 红色主题
61
+ │ │ └── index.ts # 主题统一出口
62
+ │ ├── config/ # 配置管理
63
+ │ │ ├── ThemeConfig.ts # 主题配置获取器
64
+ │ │ └── LoadingConfig.ts # Loading 配置
65
+ │ ├── scenes/ # Phaser 场景
66
+ │ ├── managers/ # 管理器
67
+ │ ├── ui/ # UI 组件
68
+ │ ├── Game.ts # 游戏主类
69
+ │ └── index.ts # 入口文件
70
+ ├── assets/ # 公共资源
71
+ ├── vite.config.ts # Vite 配置
72
+ ├── index.html # Vite 入口 HTML
73
+ ├── builds.config.js # 构建配置
74
+ ├── package.json # 项目配置
75
+ └── tsconfig.json # TypeScript 配置
76
+ ```
77
+
78
+ ## 主题系统
79
+
80
+ ### 配置优先级
81
+
82
+ ```
83
+ theme.data.json5(主题覆盖)> theme.schema.json5(默认值)
84
+ ```
85
+
86
+ ### 切换主题
87
+
88
+ 修改 `src/theme/index.ts`:
89
+
90
+ ```typescript
91
+ export { default } from './blue-theme'; // 蓝色主题
92
+ // export { default } from './green-theme'; // 绿色主题
93
+ // export { default } from './red-theme'; // 红色主题
94
+ ```
95
+
96
+ ### 添加新主题
97
+
98
+ 1. 复制现有主题目录(如 `blue-theme`)
99
+ 2. 修改 `theme.data.json5` 配置
100
+ 3. 添加主题特定资源到 `assets/` 目录
101
+ 4. 更新 `index.ts` 的资源映射
102
+ 5. 在 `theme/index.ts` 切换主题
103
+
104
+ ## 配置系统
105
+
106
+ ### 读取配置
107
+
108
+ 使用 `sdk.getConfig()` 或封装的配置获取器:
109
+
110
+ ```typescript
111
+ import { GameThemeConfig } from './config/ThemeConfig';
112
+
113
+ // 获取配置值
114
+ const backgroundColor = GameThemeConfig.BACKGROUND_COLOR;
115
+ const difficulty = GameThemeConfig.DIFFICULTY;
116
+ ```
117
+
118
+ ### 资源路径解析
119
+
120
+ 资源路径通过 `assetRecordByPath` 自动解析为真实 URL:
121
+
122
+ ```typescript
123
+ // theme.schema.json5 中定义路径
124
+ assets: {
125
+ logo: {
126
+ default: "./assets/logo.webp"
127
+ }
128
+ }
129
+
130
+ // theme/index.ts 中映射路径
131
+ import logoWebp from 'assets/logo.webp';
132
+ const assetRecordByPath = {
133
+ './assets/logo.webp': logoWebp,
134
+ };
135
+
136
+ // 代码中获取 URL
137
+ const logoUrl = GameThemeConfig.ASSET_LOGO; // 解析后的真实 URL
138
+ ```
139
+
140
+ ## 相关技能
141
+
142
+ 如需进行以下操作,请加载对应技能:
143
+
144
+ - **SDK 埋点检查**:`playable-sdk-tracking`
145
+ - **构建产物检查**:`playable-output-checker`
146
+ - **项目初始化**:`playable-project-scaffold`
147
+ - **资源提取/重打包**:`game-asset-extractor`
148
+
149
+ ## 常见问题
150
+
151
+ ### Q1: 资源 URL 为空
152
+
153
+ **原因**:`assetRecordByPath` 缺少路径映射
154
+
155
+ **解决**:在主题 `index.ts` 中添加资源映射
156
+
157
+ ### Q2: 配置值为 undefined
158
+
159
+ **原因**:`theme.schema.json5` 缺少该字段的 `default` 值
160
+
161
+ **解决**:在 schema 中添加字段定义及默认值
162
+
163
+ ### Q3: 模块顶层缓存导致配置为空
164
+
165
+ **原因**:在模块加载时立即读取配置,此时 `sdk.setConfig()` 还没执行
166
+
167
+ **解决**:使用 getter 延迟获取,或在运行时获取配置
168
+
169
+ ## 技术栈
170
+
171
+ - **游戏引擎**:Phaser 3.88.2
172
+ - **语言**:TypeScript 5.7.2
173
+ - **构建工具**:Vite 5.4.0 (本地) / @playcraft/devkit (生产)
174
+ - **配置格式**:JSON5 (支持注释)
175
+
176
+ ## 更多信息
177
+
178
+ 详细的平台改造指南请参考:`playable-template/skills/playable-platform-refactor/SKILL.md`
@@ -0,0 +1,328 @@
1
+ # PlayCraft 平台改造总结
2
+
3
+ 本文档记录了 `playable-template-phaser` 从原有架构改造为 PlayCraft 平台架构的完整过程。
4
+
5
+ ## 改造概述
6
+
7
+ **改造前**:使用 `@tencent/playable-sdk` + 硬编码配置
8
+
9
+ **改造后**:使用 `@playcraft/adsdk` + JSON5 Schema 配置化架构
10
+
11
+ ## 改造内容
12
+
13
+ ### 1. SDK 依赖替换
14
+
15
+ #### ✅ globals.d.ts
16
+
17
+ ```diff
18
+ - /// <reference types="@tencent/playable-sdk/defines" />
19
+ - /// <reference types="@tencent/playable-scripts/defines" />
20
+ + /// <reference types="@playcraft/adsdk/defines" />
21
+ + /// <reference types="@playcraft/devkit/defines" />
22
+ ```
23
+
24
+ #### ✅ package.json
25
+
26
+ - 添加 `vite`、`json5`、`typescript`、`@types/node`
27
+ - 添加 `json5-loader` 等构建工具
28
+ - 新增 `dev` 脚本(Vite)和 `dev:wp` 脚本
29
+
30
+ ### 2. 本地开发支持
31
+
32
+ #### ✅ 新增文件
33
+
34
+ - `vite.config.ts` - Vite 配置,支持 JSON5 插件和路径别名
35
+ - `index.html` - Vite 入口 HTML
36
+ - `src/json5.d.ts` - JSON5 模块类型声明
37
+
38
+ ### 3. 主题系统配置化
39
+
40
+ #### ✅ 新增配置协议
41
+
42
+ - `src/theme/theme.schema.json5` - 定义所有可配置项及默认值
43
+ - `src/theme/theme.metadata.md` - 主题元数据文档
44
+
45
+ #### ✅ 改造主题目录
46
+
47
+ 每个主题目录(blue-theme、green-theme、red-theme):
48
+
49
+ - 新增 `theme.data.json5` - 配置覆盖文件
50
+ - 改造 `index.ts` - 导出 `themeData` 和 `assetRecordByPath`
51
+
52
+ **改造前**:
53
+
54
+ ```typescript
55
+ const config: ThemeConfig = {
56
+ name: '蓝色主题',
57
+ backgroundColor: 0x4a90e2,
58
+ // ... 大量硬编码配置
59
+ };
60
+ export default config;
61
+ ```
62
+
63
+ **改造后**:
64
+
65
+ ```typescript
66
+ import themeData from './theme.data.json5';
67
+ const assetRecordByPath = {
68
+ /* 资源映射 */
69
+ };
70
+ export default { themeData, assetRecordByPath };
71
+ ```
72
+
73
+ ### 4. 配置获取方式改造
74
+
75
+ #### ✅ ThemeConfig.ts
76
+
77
+ - 从硬编码接口改为通过 `sdk.getConfig()` 获取
78
+ - 使用 getter 延迟获取,避免模块顶层缓存问题
79
+
80
+ **改造前**:
81
+
82
+ ```typescript
83
+ export interface ThemeConfig {
84
+ backgroundColor: number;
85
+ // ...
86
+ }
87
+ ```
88
+
89
+ **改造后**:
90
+
91
+ ```typescript
92
+ export const GameThemeConfig = {
93
+ get BACKGROUND_COLOR(): number {
94
+ return get('visual.backgroundColor', 0xf7d37f);
95
+ },
96
+ // ...
97
+ };
98
+ ```
99
+
100
+ #### ✅ LoadingConfig.ts
101
+
102
+ - 同样改为通过 `sdk.getConfig()` 获取
103
+ - 移除硬编码的资源 import
104
+
105
+ ### 5. 入口文件改造
106
+
107
+ #### ✅ src/index.ts
108
+
109
+ 添加主题系统初始化:
110
+
111
+ ```typescript
112
+ import ThemeConfig from './theme/theme.schema.json5';
113
+ import Theme from './theme';
114
+
115
+ sdk.setConfig([ThemeConfig, Theme.themeData], {
116
+ assetRecordByPath: Theme.assetRecordByPath,
117
+ });
118
+
119
+ sdk.playcraftInit((width, height) => {
120
+ // ...
121
+ });
122
+ ```
123
+
124
+ ### 6. 场景文件改造
125
+
126
+ #### ✅ src/scenes/MainScene.ts
127
+
128
+ ```diff
129
+ - import themeConfig from '../theme/index';
130
+ + import { GameThemeConfig } from '../config/ThemeConfig';
131
+
132
+ - this.cameras.main.setBackgroundColor(themeConfig.backgroundColor);
133
+ + this.cameras.main.setBackgroundColor(GameThemeConfig.BACKGROUND_COLOR);
134
+ ```
135
+
136
+ ### 7. 项目配置文件
137
+
138
+ #### ✅ 新增/更新
139
+
140
+ - `.playcraftignore` - 构建排除配置
141
+ - `CLAUDE.md` - 详细项目说明
142
+ - `PLAYCRAFT-MIGRATION.md` - 改造总结(本文档)
143
+ - `新手开发指南.md` - 更新后的开发指南
144
+
145
+ #### ✅ tsconfig.json
146
+
147
+ 添加路径别名:
148
+
149
+ ```json
150
+ "paths": {
151
+ "assets/*": ["./assets/*"],
152
+ "@/*": ["./src/*"],
153
+ "src/*": ["./src/*"]
154
+ }
155
+ ```
156
+
157
+ #### ✅ README.md
158
+
159
+ 更新为 PlayCraft 平台说明
160
+
161
+ ## 改造后的优势
162
+
163
+ ### 1. 配置化
164
+
165
+ - ✅ 主题配置集中管理
166
+ - ✅ 配置与代码分离
167
+ - ✅ 支持 PlayCraft 平台在线编辑
168
+
169
+ ### 2. 开发体验
170
+
171
+ - ✅ Vite 极速 HMR 热更新
172
+ - ✅ 更好的类型提示
173
+ - ✅ 配置使用 JSON5(支持注释)
174
+
175
+ ### 3. 维护性
176
+
177
+ - ✅ 配置优先级清晰(schema → data)
178
+ - ✅ 资源路径自动解析
179
+ - ✅ 避免模块顶层缓存问题
180
+
181
+ ### 4. 扩展性
182
+
183
+ - ✅ 易于添加新主题(只需写差异配置)
184
+ - ✅ 易于添加新配置项
185
+ - ✅ 支持批量构建
186
+
187
+ ## 配置系统工作流程
188
+
189
+ ```
190
+ 1. sdk.setConfig([ThemeConfig, themeData], { assetRecordByPath })
191
+ ↓
192
+ 2. SDK 提取 schema 的 default 值作为基底配置
193
+ ↓
194
+ 3. 深度合并 基底配置 + themeData 覆盖值
195
+ ↓
196
+ 4. 递归解析资源路径(通过 assetRecordByPath 映射)
197
+ ↓
198
+ 5. sdk.getConfig() 返回最终配置
199
+ ```
200
+
201
+ ## 使用示例
202
+
203
+ ### 添加新配置项
204
+
205
+ 1. 在 `theme.schema.json5` 中定义:
206
+
207
+ ```json5
208
+ gameplay: {
209
+ maxScore: {
210
+ type: "integer",
211
+ default: 1000,
212
+ description: "最高分数",
213
+ },
214
+ }
215
+ ```
216
+
217
+ 2. 在 `ThemeConfig.ts` 中添加 getter:
218
+
219
+ ```typescript
220
+ get MAX_SCORE(): number { return get('gameplay.maxScore', 1000); }
221
+ ```
222
+
223
+ 3. 在代码中使用:
224
+
225
+ ```typescript
226
+ const maxScore = GameThemeConfig.MAX_SCORE;
227
+ ```
228
+
229
+ ### 添加新资源
230
+
231
+ 1. 在 `theme.schema.json5` 中定义路径:
232
+
233
+ ```json5
234
+ assets: {
235
+ logo: {
236
+ type: "string",
237
+ default: "./assets/logo.webp",
238
+ xplatform: { value_type: "path", mime_type: "image/webp" },
239
+ },
240
+ }
241
+ ```
242
+
243
+ 2. 在主题 `index.ts` 中映射:
244
+
245
+ ```typescript
246
+ import logoWebp from 'assets/logo.webp';
247
+ const assetRecordByPath = {
248
+ './assets/logo.webp': logoWebp,
249
+ };
250
+ ```
251
+
252
+ 3. 在配置中获取:
253
+
254
+ ```typescript
255
+ get ASSET_LOGO(): string { return get('assets.logo', ''); }
256
+ ```
257
+
258
+ ## 注意事项
259
+
260
+ ### ⚠️ 必须使用 getter
261
+
262
+ 配置获取器必须使用 getter 而非顶层常量:
263
+
264
+ ```typescript
265
+ // ❌ 错误:模块加载时立即执行,此时 setConfig 还没调用
266
+ const CONFIG = sdk.getConfig();
267
+
268
+ // ✅ 正确:运行时获取
269
+ get CONFIG() { return sdk.getConfig(); }
270
+ ```
271
+
272
+ ### ⚠️ schema 必须有 $schema 字段
273
+
274
+ ```json5
275
+ {
276
+ $schema: 'http://json-schema.org/draft-07/schema#', // 必须!
277
+ // ...
278
+ }
279
+ ```
280
+
281
+ ### ⚠️ 资源路径必须一致
282
+
283
+ ```json5
284
+ // schema 中的路径
285
+ default: "./assets/logo.webp"
286
+
287
+ // assetRecordByPath 中的 key 必须完全一致
288
+ './assets/logo.webp': logoWebp
289
+ ```
290
+
291
+ ## 检查清单
292
+
293
+ - [x] globals.d.ts 类型引用已更新
294
+ - [x] package.json 依赖已更新
295
+ - [x] vite.config.ts 已创建
296
+ - [x] index.html 已创建
297
+ - [x] src/json5.d.ts 已创建
298
+ - [x] theme.schema.json5 已创建
299
+ - [x] theme.metadata.md 已创建
300
+ - [x] 所有主题已改造(theme.data.json5 + index.ts)
301
+ - [x] src/index.ts 已添加 setConfig
302
+ - [x] ThemeConfig.ts 已改为 sdk.getConfig()
303
+ - [x] LoadingConfig.ts 已改为 sdk.getConfig()
304
+ - [x] MainScene.ts 已更新配置引用
305
+ - [x] tsconfig.json 已更新路径别名
306
+ - [x] .playcraftignore 已创建
307
+ - [x] CLAUDE.md 已创建
308
+ - [x] README.md 已更新
309
+ - [x] 所有 lint 错误已修复
310
+ - [x] 新手开发指南已更新
311
+
312
+ ## 下一步
313
+
314
+ 1. 运行 `npm install` 安装新依赖
315
+ 2. 运行 `npm run dev` 测试 Vite 开发服务器
316
+ 3. 运行 `npm run dev:wp` 测试 playable-scripts 开发服务器
317
+ 4. 运行 `npm run builds` 测试批量构建
318
+
319
+ ## 参考文档
320
+
321
+ - [PlayCraft 平台改造 Skill](../skills/playable-platform-refactor/SKILL.md)
322
+ - [项目详细说明](./CLAUDE.md)
323
+ - [开发指南](./新手开发指南.md)
324
+
325
+ ---
326
+
327
+ 改造完成时间:2026-04-24
328
+ 改造完成者:AI Assistant