create-threenative 0.2.2 → 0.2.4

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 (588) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +61 -2
  3. package/agent-docs/references/assertion-reference.md +819 -0
  4. package/agent-docs/references/capability-reference.md +4483 -0
  5. package/agent-docs/references/capture-the-frame.md +60 -0
  6. package/agent-docs/references/creating-creatures.md +215 -0
  7. package/agent-docs/references/ctx-cookbook.md +120 -0
  8. package/agent-docs/references/debug-surface.md +68 -0
  9. package/agent-docs/references/dream-loop.md +150 -0
  10. package/agent-docs/references/finding-assets.md +215 -0
  11. package/agent-docs/references/gameplay-recipes.md +54 -0
  12. package/agent-docs/references/menu-screens.md +69 -0
  13. package/agent-docs/references/mobile-memory-budget.md +87 -0
  14. package/agent-docs/references/sculpt-from-a-reference.md +40 -0
  15. package/agent-docs/references/trace-a-slow-frame.md +99 -0
  16. package/agent-docs/references/visual-baseline.md +174 -0
  17. package/agent-docs/references/webview-ui.md +113 -0
  18. package/agent-files/.agents/skills/file-engine-bug/SKILL.md +59 -0
  19. package/agent-files/.agents/skills/prd-creator/SKILL.md +40 -0
  20. package/agent-files/.agents/skills/threenative-assets/SKILL.md +45 -0
  21. package/agent-files/.agents/skills/threenative-builder/SKILL.md +7 -0
  22. package/agent-files/.agents/skills/threenative-capabilities/SKILL.md +27 -0
  23. package/agent-files/.agents/skills/threenative-context/SKILL.md +57 -0
  24. package/agent-files/.agents/skills/threenative-performance/SKILL.md +42 -0
  25. package/agent-files/.agents/skills/threenative-playtest/SKILL.md +44 -0
  26. package/agent-files/.agents/skills/threenative-ui/SKILL.md +20 -0
  27. package/agent-files/.agents/skills/threenative-verifier/SKILL.md +7 -0
  28. package/agent-files/.agents/skills/threenative-visuals/SKILL.md +41 -0
  29. package/agent-files/.claude/agents/threenative-builder.md +7 -0
  30. package/agent-files/.claude/agents/threenative-verifier.md +7 -0
  31. package/agent-files/.claude/skills/file-engine-bug/SKILL.md +59 -0
  32. package/agent-files/.claude/skills/prd-creator/SKILL.md +40 -0
  33. package/agent-files/.claude/skills/threenative-assets/SKILL.md +45 -0
  34. package/agent-files/.claude/skills/threenative-capabilities/SKILL.md +27 -0
  35. package/agent-files/.claude/skills/threenative-context/SKILL.md +57 -0
  36. package/agent-files/.claude/skills/threenative-performance/SKILL.md +42 -0
  37. package/agent-files/.claude/skills/threenative-playtest/SKILL.md +44 -0
  38. package/agent-files/.claude/skills/threenative-ui/SKILL.md +20 -0
  39. package/agent-files/.claude/skills/threenative-visuals/SKILL.md +41 -0
  40. package/agent-files/.threenative/agents/builder.md +32 -0
  41. package/agent-files/.threenative/agents/verifier.md +31 -0
  42. package/agent-files/AGENT-ROLES.md +26 -0
  43. package/agent-files/scripts/reference.mjs +705 -0
  44. package/agent-files/scripts/visual-loop.mjs +382 -0
  45. package/capabilities.json +5292 -0
  46. package/dist/index.d.ts +224 -3
  47. package/dist/index.js +1972 -73
  48. package/dist/threenative.d.ts +9 -2
  49. package/dist/threenative.js +2570 -176
  50. package/package.json +55 -6
  51. package/template-assets/icon.png +0 -0
  52. package/template-assets/loading.ts +325 -0
  53. package/template-assets/patches/three@0.185.1.patch +522 -0
  54. package/template-assets/worldEnvironment.ts +758 -0
  55. package/templates/action-rpg/.codex/config.toml +19 -0
  56. package/templates/action-rpg/.cursor/mcp.json +32 -0
  57. package/templates/action-rpg/.gemini/settings.json +32 -0
  58. package/templates/action-rpg/.mcp.json +18 -2
  59. package/templates/action-rpg/.vscode/mcp.json +36 -0
  60. package/templates/action-rpg/.zed/settings.json +36 -0
  61. package/templates/action-rpg/AGENTS.md +84 -29
  62. package/templates/action-rpg/CLAUDE.md +84 -29
  63. package/templates/action-rpg/index.html +0 -1
  64. package/templates/action-rpg/opencode.json +41 -0
  65. package/templates/action-rpg/package.json +15 -11
  66. package/templates/action-rpg/playtests/combat.playtest.json +32 -9
  67. package/templates/action-rpg/playtests/fail.playtest.json +3 -3
  68. package/templates/action-rpg/playtests/inventory.playtest.json +16 -10
  69. package/templates/action-rpg/playtests/performance.playtest.json +39 -0
  70. package/templates/action-rpg/playtests/progress.playtest.json +18 -13
  71. package/templates/action-rpg/playtests/survives.playtest.json +27 -0
  72. package/templates/action-rpg/playtests/touch-controls.playtest.json +42 -0
  73. package/templates/action-rpg/playtests/win.playtest.json +10 -4
  74. package/templates/action-rpg/src/conventions.ts +35 -0
  75. package/templates/action-rpg/src/entities/Enemy.ts +16 -7
  76. package/templates/action-rpg/src/entities/Player.ts +20 -3
  77. package/templates/action-rpg/src/game.ts +21 -0
  78. package/templates/action-rpg/src/render/camera.ts +7 -2
  79. package/templates/action-rpg/src/render/lighting.ts +11 -4
  80. package/templates/action-rpg/src/render/loading.ts +278 -43
  81. package/templates/action-rpg/src/render/materials.ts +11 -0
  82. package/templates/action-rpg/src/render/palette.ts +10 -3
  83. package/templates/action-rpg/src/render/postprocessing.ts +32 -16
  84. package/templates/action-rpg/src/render/quality.ts +170 -0
  85. package/templates/action-rpg/src/render/shapes.ts +185 -26
  86. package/templates/action-rpg/src/render/touch-controls.ts +185 -0
  87. package/templates/action-rpg/src/render/vfx.ts +257 -0
  88. package/templates/action-rpg/src/render/worldEnvironment.ts +758 -0
  89. package/templates/action-rpg/src/scenes/Play.ts +91 -24
  90. package/templates/action-rpg/src/state.ts +4 -0
  91. package/templates/action-rpg/src/style.css +65 -1
  92. package/templates/action-rpg/src/ui/AbilityBar.tsx +9 -7
  93. package/templates/action-rpg/src/ui/App.tsx +9 -8
  94. package/templates/action-rpg/src/ui/CharacterPanel.tsx +10 -8
  95. package/templates/action-rpg/src/ui/GameUi.tsx +24 -0
  96. package/templates/action-rpg/src/ui/Hud.tsx +10 -8
  97. package/templates/action-rpg/src/ui/InventoryPanel.tsx +9 -7
  98. package/templates/action-rpg/src/ui/main.tsx +14 -0
  99. package/templates/action-rpg/threenative.config.ts +28 -8
  100. package/templates/action-rpg/vite.config.ts +32 -2
  101. package/templates/defense/.codex/config.toml +19 -0
  102. package/templates/defense/.cursor/mcp.json +32 -0
  103. package/templates/defense/.gemini/settings.json +32 -0
  104. package/templates/defense/.mcp.json +18 -2
  105. package/templates/defense/.vscode/mcp.json +36 -0
  106. package/templates/defense/.zed/settings.json +36 -0
  107. package/templates/defense/AGENTS.md +81 -41
  108. package/templates/defense/CLAUDE.md +81 -41
  109. package/templates/defense/README.md +2 -1
  110. package/templates/defense/index.html +0 -1
  111. package/templates/defense/opencode.json +41 -0
  112. package/templates/defense/package.json +16 -12
  113. package/templates/defense/playtests/leak.playtest.json +9 -4
  114. package/templates/defense/playtests/performance.playtest.json +39 -0
  115. package/templates/defense/playtests/placement.playtest.json +5 -5
  116. package/templates/defense/playtests/pointer-placement.playtest.json +156 -0
  117. package/templates/defense/playtests/scan.playtest.json +4 -4
  118. package/templates/defense/playtests/survive.playtest.json +25 -6
  119. package/templates/defense/src/attackers/Attacker.ts +32 -16
  120. package/templates/defense/src/board/Route.ts +22 -8
  121. package/templates/defense/src/conventions.ts +18 -0
  122. package/templates/defense/src/entities/Player.ts +11 -3
  123. package/templates/defense/src/game.ts +25 -4
  124. package/templates/defense/src/physics.ts +9 -39
  125. package/templates/defense/src/placement/Buildable.ts +4 -4
  126. package/templates/defense/src/render/camera.ts +9 -3
  127. package/templates/defense/src/render/lighting.ts +6 -1
  128. package/templates/defense/src/render/loading.ts +274 -38
  129. package/templates/defense/src/render/materials.ts +9 -0
  130. package/templates/defense/src/render/palette.ts +12 -5
  131. package/templates/defense/src/render/postprocessing.ts +32 -12
  132. package/templates/defense/src/render/quality.ts +170 -0
  133. package/templates/defense/src/render/shapes.ts +180 -23
  134. package/templates/defense/src/render/sky.ts +2 -2
  135. package/templates/defense/src/render/worldEnvironment.ts +758 -0
  136. package/templates/defense/src/scenes/Boot.ts +2 -2
  137. package/templates/defense/src/scenes/Defense.ts +122 -56
  138. package/templates/defense/src/state.ts +6 -0
  139. package/templates/defense/src/style.css +65 -1
  140. package/templates/defense/src/towers/Tower.ts +11 -12
  141. package/templates/defense/src/towers/targeting.ts +1 -1
  142. package/templates/defense/src/ui/App.tsx +11 -6
  143. package/templates/defense/src/ui/GameUi.tsx +20 -0
  144. package/templates/defense/src/ui/Hud.tsx +6 -5
  145. package/templates/defense/src/ui/main.tsx +14 -0
  146. package/templates/defense/threenative.config.ts +28 -8
  147. package/templates/defense/vite.config.ts +34 -1
  148. package/templates/minimal/.codex/config.toml +19 -0
  149. package/templates/minimal/.cursor/mcp.json +32 -0
  150. package/templates/minimal/.gemini/settings.json +32 -0
  151. package/templates/minimal/.mcp.json +18 -2
  152. package/templates/minimal/.vscode/mcp.json +36 -0
  153. package/templates/minimal/.zed/settings.json +36 -0
  154. package/templates/minimal/AGENTS.md +78 -382
  155. package/templates/minimal/CLAUDE.md +78 -382
  156. package/templates/minimal/index.html +0 -1
  157. package/templates/minimal/opencode.json +41 -0
  158. package/templates/minimal/package.json +14 -11
  159. package/templates/minimal/playtests/atmosphere.playtest.json +32 -0
  160. package/templates/minimal/playtests/play.playtest.json +18 -5
  161. package/templates/minimal/playtests/survives.playtest.json +48 -4
  162. package/templates/minimal/playtests/touch-controls.playtest.json +42 -0
  163. package/templates/minimal/src/conventions.ts +18 -0
  164. package/templates/minimal/src/entities/Player.ts +39 -6
  165. package/templates/minimal/src/game.ts +1 -0
  166. package/templates/minimal/src/main.ts +14 -4
  167. package/templates/minimal/src/render/camera.ts +1 -1
  168. package/templates/minimal/src/render/hud.ts +24 -8
  169. package/templates/minimal/src/render/lighting.ts +23 -2
  170. package/templates/minimal/src/render/loading.ts +23 -103
  171. package/templates/minimal/src/render/materials.ts +7 -0
  172. package/templates/minimal/src/render/palette.ts +3 -3
  173. package/templates/minimal/src/render/postprocessing.ts +55 -16
  174. package/templates/minimal/src/render/quality.ts +162 -0
  175. package/templates/minimal/src/render/sky.ts +51 -32
  176. package/templates/minimal/src/render/touch-controls.ts +165 -0
  177. package/templates/minimal/src/render/worldEnvironment.ts +758 -0
  178. package/templates/minimal/src/scenes/Play.ts +128 -14
  179. package/templates/minimal/src/state.ts +8 -1
  180. package/templates/minimal/src/style.css +20 -0
  181. package/templates/minimal/threenative.config.ts +22 -10
  182. package/templates/minimal/vite.config.ts +28 -1
  183. package/templates/platformer/.codex/config.toml +19 -0
  184. package/templates/platformer/.cursor/mcp.json +32 -0
  185. package/templates/platformer/.gemini/settings.json +32 -0
  186. package/templates/platformer/.mcp.json +18 -2
  187. package/templates/platformer/.vscode/mcp.json +36 -0
  188. package/templates/platformer/.zed/settings.json +36 -0
  189. package/templates/platformer/AGENTS.md +81 -186
  190. package/templates/platformer/CLAUDE.md +81 -186
  191. package/templates/platformer/index.html +0 -1
  192. package/templates/platformer/opencode.json +41 -0
  193. package/templates/platformer/package.json +17 -14
  194. package/templates/platformer/playtests/avoidance.playtest.json +6 -1
  195. package/templates/platformer/playtests/branding.playtest.json +29 -0
  196. package/templates/platformer/playtests/buffer.playtest.json +1 -1
  197. package/templates/platformer/playtests/collect.playtest.json +1 -1
  198. package/templates/platformer/playtests/collision-layers.playtest.json +2 -2
  199. package/templates/platformer/playtests/coyote.playtest.json +42 -8
  200. package/templates/platformer/playtests/damage.playtest.json +4 -1
  201. package/templates/platformer/playtests/dash.playtest.json +2 -2
  202. package/templates/platformer/playtests/jump.playtest.json +2 -3
  203. package/templates/platformer/playtests/native/touch-controls.playtest.json +33 -0
  204. package/templates/platformer/playtests/oneway.playtest.json +30 -3
  205. package/templates/platformer/playtests/performance.playtest.json +7 -5
  206. package/templates/platformer/playtests/respawn.playtest.json +2 -2
  207. package/templates/platformer/playtests/stomp-rise.playtest.json +17 -3
  208. package/templates/platformer/playtests/stomp.playtest.json +11 -3
  209. package/templates/platformer/playtests/survives.playtest.json +31 -0
  210. package/templates/platformer/playtests/terminal-loop-fail.playtest.json +16 -4
  211. package/templates/platformer/playtests/terminal-loop-win.playtest.json +3 -3
  212. package/templates/platformer/playtests/touch-controls-web.playtest.json +57 -0
  213. package/templates/platformer/src/conventions.ts +18 -0
  214. package/templates/platformer/src/entities/Character.ts +79 -11
  215. package/templates/platformer/src/entities/Patrol.ts +5 -0
  216. package/templates/platformer/src/game.ts +27 -2
  217. package/templates/platformer/src/level/Platform.ts +13 -1
  218. package/templates/platformer/src/render/lighting.ts +13 -5
  219. package/templates/platformer/src/render/loading.ts +281 -62
  220. package/templates/platformer/src/render/palette.ts +4 -1
  221. package/templates/platformer/src/render/postprocessing.ts +42 -14
  222. package/templates/platformer/src/render/quality.ts +170 -0
  223. package/templates/platformer/src/render/touch-controls.ts +54 -36
  224. package/templates/platformer/src/render/worldEnvironment.ts +758 -0
  225. package/templates/platformer/src/scenes/Level.ts +97 -32
  226. package/templates/platformer/src/state.ts +4 -0
  227. package/templates/platformer/src/style.css +65 -1
  228. package/templates/platformer/src/ui/App.tsx +9 -4
  229. package/templates/platformer/src/ui/GameUi.tsx +20 -0
  230. package/templates/platformer/src/ui/Hud.tsx +6 -5
  231. package/templates/platformer/src/ui/main.tsx +14 -0
  232. package/templates/platformer/threenative.config.ts +27 -10
  233. package/templates/platformer/vite.config.ts +34 -1
  234. package/templates/puzzle/.codex/config.toml +19 -0
  235. package/templates/puzzle/.cursor/mcp.json +32 -0
  236. package/templates/puzzle/.gemini/settings.json +32 -0
  237. package/templates/puzzle/.mcp.json +32 -0
  238. package/templates/puzzle/.vscode/mcp.json +36 -0
  239. package/templates/puzzle/.zed/settings.json +36 -0
  240. package/templates/puzzle/AGENTS.md +96 -0
  241. package/templates/puzzle/CLAUDE.md +98 -0
  242. package/templates/puzzle/README.md +43 -0
  243. package/templates/puzzle/index.html +12 -0
  244. package/templates/puzzle/kit.json +7 -0
  245. package/templates/puzzle/opencode.json +41 -0
  246. package/templates/puzzle/package.json +50 -0
  247. package/templates/puzzle/playtests/carry.playtest.json +71 -0
  248. package/templates/puzzle/playtests/performance.playtest.json +23 -0
  249. package/templates/puzzle/playtests/survives.playtest.json +51 -0
  250. package/templates/puzzle/playtests/swing.playtest.json +38 -0
  251. package/templates/puzzle/public/favicon.svg +5 -0
  252. package/templates/puzzle/src/conventions.ts +25 -0
  253. package/templates/puzzle/src/entities/Ball.ts +70 -0
  254. package/templates/puzzle/src/entities/Crate.ts +76 -0
  255. package/templates/puzzle/src/entities/Gripper.ts +69 -0
  256. package/templates/puzzle/src/entities/Pendulum.ts +89 -0
  257. package/templates/puzzle/src/game.ts +48 -0
  258. package/templates/puzzle/src/main.ts +15 -0
  259. package/templates/puzzle/src/physics.ts +19 -0
  260. package/templates/puzzle/src/render/camera.ts +37 -0
  261. package/templates/puzzle/src/render/lighting.ts +55 -0
  262. package/templates/puzzle/src/render/loading.ts +325 -0
  263. package/templates/puzzle/src/render/materials.ts +28 -0
  264. package/templates/puzzle/src/render/palette.ts +31 -0
  265. package/templates/puzzle/src/render/postprocessing.ts +34 -0
  266. package/templates/puzzle/src/render/quality.ts +170 -0
  267. package/templates/puzzle/src/render/shapes.ts +134 -0
  268. package/templates/puzzle/src/render/sky.ts +16 -0
  269. package/templates/puzzle/src/render/touch-controls.ts +185 -0
  270. package/templates/puzzle/src/render/worldEnvironment.ts +758 -0
  271. package/templates/puzzle/src/room.ts +83 -0
  272. package/templates/puzzle/src/scenes/Boot.ts +12 -0
  273. package/templates/puzzle/src/scenes/Puzzle.ts +158 -0
  274. package/templates/puzzle/src/state.ts +30 -0
  275. package/templates/puzzle/src/style.css +96 -0
  276. package/templates/puzzle/src/ui/App.tsx +22 -0
  277. package/templates/puzzle/src/ui/GameUi.tsx +20 -0
  278. package/templates/puzzle/src/ui/Hud.tsx +57 -0
  279. package/templates/puzzle/src/ui/Menu.tsx +7 -0
  280. package/templates/puzzle/src/ui/main.tsx +14 -0
  281. package/templates/puzzle/tailwind.config.ts +1 -0
  282. package/templates/puzzle/threenative.config.ts +49 -0
  283. package/templates/puzzle/tsconfig.json +17 -0
  284. package/templates/puzzle/vite.config.ts +38 -0
  285. package/templates/racing/.codex/config.toml +19 -0
  286. package/templates/racing/.cursor/mcp.json +32 -0
  287. package/templates/racing/.gemini/settings.json +32 -0
  288. package/templates/racing/.mcp.json +18 -2
  289. package/templates/racing/.vscode/mcp.json +36 -0
  290. package/templates/racing/.zed/settings.json +36 -0
  291. package/templates/racing/AGENTS.md +84 -36
  292. package/templates/racing/CLAUDE.md +84 -36
  293. package/templates/racing/index.html +0 -1
  294. package/templates/racing/native-playtests/survives.playtest.json +43 -0
  295. package/templates/racing/opencode.json +41 -0
  296. package/templates/racing/package.json +17 -12
  297. package/templates/racing/playtests/boost.playtest.json +5 -5
  298. package/templates/racing/playtests/outcome.playtest.json +14 -4
  299. package/templates/racing/playtests/performance.playtest.json +39 -0
  300. package/templates/racing/playtests/ranking.playtest.json +2 -2
  301. package/templates/racing/playtests/rescue.playtest.json +12 -6
  302. package/templates/racing/playtests/reverse.playtest.json +3 -3
  303. package/templates/racing/playtests/shortcut.playtest.json +3 -3
  304. package/templates/racing/playtests/survives.playtest.json +36 -4
  305. package/templates/racing/playtests/touch-controls.playtest.json +41 -0
  306. package/templates/racing/src/conventions.ts +6 -0
  307. package/templates/racing/src/entities/RacingCar.ts +16 -4
  308. package/templates/racing/src/entities/Rival.ts +5 -2
  309. package/templates/racing/src/game.ts +24 -1
  310. package/templates/racing/src/render/camera.ts +15 -8
  311. package/templates/racing/src/render/lighting.ts +28 -14
  312. package/templates/racing/src/render/loading.ts +302 -35
  313. package/templates/racing/src/render/materials.ts +54 -4
  314. package/templates/racing/src/render/palette.ts +23 -6
  315. package/templates/racing/src/render/postprocessing.ts +32 -12
  316. package/templates/racing/src/render/quality.ts +170 -0
  317. package/templates/racing/src/render/shapes.ts +537 -26
  318. package/templates/racing/src/render/sky.ts +5 -2
  319. package/templates/racing/src/render/touch-controls.ts +185 -0
  320. package/templates/racing/src/render/worldEnvironment.ts +758 -0
  321. package/templates/racing/src/scenes/Race.ts +84 -37
  322. package/templates/racing/src/state.ts +4 -0
  323. package/templates/racing/src/style.css +65 -1
  324. package/templates/racing/src/track/Lap.ts +20 -9
  325. package/templates/racing/src/track/Ranking.ts +53 -14
  326. package/templates/racing/src/track/Track.ts +284 -32
  327. package/templates/racing/src/track/TrackSector.ts +14 -4
  328. package/templates/racing/src/ui/App.tsx +9 -4
  329. package/templates/racing/src/ui/GameUi.tsx +20 -0
  330. package/templates/racing/src/ui/Hud.tsx +6 -5
  331. package/templates/racing/src/ui/main.tsx +14 -0
  332. package/templates/racing/threenative.config.ts +28 -8
  333. package/templates/racing/vite.config.ts +34 -1
  334. package/templates/runner/.codex/config.toml +19 -0
  335. package/templates/runner/.cursor/mcp.json +32 -0
  336. package/templates/runner/.gemini/settings.json +32 -0
  337. package/templates/runner/.mcp.json +32 -0
  338. package/templates/runner/.vscode/mcp.json +36 -0
  339. package/templates/runner/.zed/settings.json +36 -0
  340. package/templates/runner/AGENTS.md +96 -0
  341. package/templates/runner/CLAUDE.md +98 -0
  342. package/templates/runner/README.md +43 -0
  343. package/templates/runner/index.html +12 -0
  344. package/templates/runner/kit.json +7 -0
  345. package/templates/runner/opencode.json +41 -0
  346. package/templates/runner/package.json +50 -0
  347. package/templates/runner/playtests/performance.playtest.json +23 -0
  348. package/templates/runner/playtests/streams.playtest.json +38 -0
  349. package/templates/runner/playtests/survives.playtest.json +51 -0
  350. package/templates/runner/public/favicon.svg +5 -0
  351. package/templates/runner/src/conventions.ts +24 -0
  352. package/templates/runner/src/entities/Runner.ts +135 -0
  353. package/templates/runner/src/game.ts +50 -0
  354. package/templates/runner/src/main.ts +15 -0
  355. package/templates/runner/src/physics.ts +13 -0
  356. package/templates/runner/src/render/camera.ts +39 -0
  357. package/templates/runner/src/render/dust.ts +131 -0
  358. package/templates/runner/src/render/lighting.ts +57 -0
  359. package/templates/runner/src/render/loading.ts +325 -0
  360. package/templates/runner/src/render/materials.ts +27 -0
  361. package/templates/runner/src/render/palette.ts +30 -0
  362. package/templates/runner/src/render/postprocessing.ts +34 -0
  363. package/templates/runner/src/render/quality.ts +170 -0
  364. package/templates/runner/src/render/shapes.ts +68 -0
  365. package/templates/runner/src/render/sky.ts +51 -0
  366. package/templates/runner/src/render/touch-controls.ts +185 -0
  367. package/templates/runner/src/render/worldEnvironment.ts +758 -0
  368. package/templates/runner/src/scenes/Boot.ts +12 -0
  369. package/templates/runner/src/scenes/Run.ts +142 -0
  370. package/templates/runner/src/state.ts +29 -0
  371. package/templates/runner/src/style.css +96 -0
  372. package/templates/runner/src/track.ts +176 -0
  373. package/templates/runner/src/ui/App.tsx +22 -0
  374. package/templates/runner/src/ui/GameUi.tsx +20 -0
  375. package/templates/runner/src/ui/Hud.tsx +55 -0
  376. package/templates/runner/src/ui/Menu.tsx +7 -0
  377. package/templates/runner/src/ui/main.tsx +14 -0
  378. package/templates/runner/tailwind.config.ts +1 -0
  379. package/templates/runner/threenative.config.ts +49 -0
  380. package/templates/runner/tsconfig.json +17 -0
  381. package/templates/runner/vite.config.ts +38 -0
  382. package/templates/sailing/.codex/config.toml +19 -0
  383. package/templates/sailing/.cursor/mcp.json +32 -0
  384. package/templates/sailing/.gemini/settings.json +32 -0
  385. package/templates/sailing/.mcp.json +32 -0
  386. package/templates/sailing/.vscode/mcp.json +36 -0
  387. package/templates/sailing/.zed/settings.json +36 -0
  388. package/templates/sailing/AGENTS.md +95 -0
  389. package/templates/sailing/CLAUDE.md +97 -0
  390. package/templates/sailing/README.md +28 -0
  391. package/templates/sailing/index.html +12 -0
  392. package/templates/sailing/kit.json +7 -0
  393. package/templates/sailing/native-playtests/float.playtest.json +55 -0
  394. package/templates/sailing/native-playtests/survives.playtest.json +38 -0
  395. package/templates/sailing/opencode.json +41 -0
  396. package/templates/sailing/package.json +52 -0
  397. package/templates/sailing/playtests/fail.playtest.json +24 -0
  398. package/templates/sailing/playtests/float-after-the-run-ends.playtest.json +75 -0
  399. package/templates/sailing/playtests/float.playtest.json +59 -0
  400. package/templates/sailing/playtests/performance.playtest.json +36 -0
  401. package/templates/sailing/playtests/survives.playtest.json +46 -0
  402. package/templates/sailing/playtests/touch-controls.playtest.json +48 -0
  403. package/templates/sailing/playtests/win.playtest.json +31 -0
  404. package/templates/sailing/public/favicon.svg +5 -0
  405. package/templates/sailing/src/conventions.ts +8 -0
  406. package/templates/sailing/src/entities/Ship.ts +233 -0
  407. package/templates/sailing/src/game.ts +40 -0
  408. package/templates/sailing/src/main.ts +15 -0
  409. package/templates/sailing/src/render/camera.ts +28 -0
  410. package/templates/sailing/src/render/lighting.ts +41 -0
  411. package/templates/sailing/src/render/loading.ts +325 -0
  412. package/templates/sailing/src/render/materials.ts +44 -0
  413. package/templates/sailing/src/render/ocean.ts +179 -0
  414. package/templates/sailing/src/render/palette.ts +17 -0
  415. package/templates/sailing/src/render/postprocessing.ts +34 -0
  416. package/templates/sailing/src/render/props.ts +602 -0
  417. package/templates/sailing/src/render/quality.ts +140 -0
  418. package/templates/sailing/src/render/sky.ts +37 -0
  419. package/templates/sailing/src/render/touch-controls.ts +142 -0
  420. package/templates/sailing/src/render/worldEnvironment.ts +758 -0
  421. package/templates/sailing/src/scenes/Boot.ts +12 -0
  422. package/templates/sailing/src/scenes/Sailing.ts +133 -0
  423. package/templates/sailing/src/state.ts +10 -0
  424. package/templates/sailing/src/style.css +81 -0
  425. package/templates/sailing/src/ui/App.tsx +15 -0
  426. package/templates/sailing/src/ui/GameUi.tsx +12 -0
  427. package/templates/sailing/src/ui/Hud.tsx +55 -0
  428. package/templates/sailing/src/ui/Menu.tsx +30 -0
  429. package/templates/sailing/src/ui/main.tsx +7 -0
  430. package/templates/sailing/tailwind.config.ts +2 -0
  431. package/templates/sailing/threenative.config.ts +40 -0
  432. package/templates/sailing/tsconfig.json +17 -0
  433. package/templates/sailing/vite.config.ts +34 -0
  434. package/templates/shooter/.codex/config.toml +19 -0
  435. package/templates/shooter/.cursor/mcp.json +32 -0
  436. package/templates/shooter/.gemini/settings.json +32 -0
  437. package/templates/shooter/.mcp.json +18 -2
  438. package/templates/shooter/.vscode/mcp.json +36 -0
  439. package/templates/shooter/.zed/settings.json +36 -0
  440. package/templates/shooter/AGENTS.md +81 -54
  441. package/templates/shooter/CLAUDE.md +81 -54
  442. package/templates/shooter/index.html +0 -1
  443. package/templates/shooter/kit.json +2 -2
  444. package/templates/shooter/opencode.json +41 -0
  445. package/templates/shooter/package.json +16 -11
  446. package/templates/shooter/playtests/combat.playtest.json +48 -0
  447. package/templates/shooter/playtests/fail.playtest.json +5 -4
  448. package/templates/shooter/playtests/input-control.playtest.json +261 -0
  449. package/templates/shooter/playtests/per-item.playtest.json +59 -0
  450. package/templates/shooter/playtests/performance.playtest.json +39 -0
  451. package/templates/shooter/playtests/shooter.playtest.json +31 -21
  452. package/templates/shooter/playtests/survives.playtest.json +28 -1
  453. package/templates/shooter/playtests/touch-controls.playtest.json +42 -0
  454. package/templates/shooter/playtests/weapon-cycle.playtest.json +164 -0
  455. package/templates/shooter/public/favicon.svg +1 -1
  456. package/templates/shooter/src/combat/damage.ts +1 -2
  457. package/templates/shooter/src/conventions.ts +51 -0
  458. package/templates/shooter/src/entities/Player.ts +235 -18
  459. package/templates/shooter/src/entities/Target.ts +2 -2
  460. package/templates/shooter/src/game.ts +35 -3
  461. package/templates/shooter/src/main.ts +3 -13
  462. package/templates/shooter/src/render/camera.ts +78 -18
  463. package/templates/shooter/src/render/decals.ts +211 -0
  464. package/templates/shooter/src/render/lighting.ts +13 -4
  465. package/templates/shooter/src/render/loading.ts +274 -35
  466. package/templates/shooter/src/render/materials.ts +56 -3
  467. package/templates/shooter/src/render/palette.ts +6 -3
  468. package/templates/shooter/src/render/postprocessing.ts +32 -17
  469. package/templates/shooter/src/render/quality.ts +170 -0
  470. package/templates/shooter/src/render/scale.ts +22 -0
  471. package/templates/shooter/src/render/shapes.ts +519 -60
  472. package/templates/shooter/src/render/sky.ts +5 -1
  473. package/templates/shooter/src/render/touch-controls.ts +305 -0
  474. package/templates/shooter/src/render/ui.css +119 -1
  475. package/templates/shooter/src/render/ui.ts +19 -3
  476. package/templates/shooter/src/render/vfx.ts +215 -0
  477. package/templates/shooter/src/render/worldEnvironment.ts +758 -0
  478. package/templates/shooter/src/scenes/Play.ts +385 -97
  479. package/templates/shooter/src/state.ts +18 -0
  480. package/templates/shooter/src/style.css +46 -0
  481. package/templates/shooter/src/ui/App.tsx +10 -12
  482. package/templates/shooter/src/ui/Crosshair.tsx +25 -0
  483. package/templates/shooter/src/ui/GameUi.tsx +22 -0
  484. package/templates/shooter/src/ui/Hud.tsx +14 -10
  485. package/templates/shooter/src/ui/Menu.tsx +24 -9
  486. package/templates/shooter/src/ui/main.tsx +15 -0
  487. package/templates/shooter/src/weapons/Hitscan.ts +3 -4
  488. package/templates/shooter/src/weapons/Projectile.ts +29 -13
  489. package/templates/shooter/src/weapons/Viewmodel.ts +275 -0
  490. package/templates/shooter/threenative.config.ts +28 -8
  491. package/templates/shooter/vite.config.ts +32 -2
  492. package/templates/starter/.codex/config.toml +19 -0
  493. package/templates/starter/.cursor/mcp.json +32 -0
  494. package/templates/starter/.gemini/settings.json +32 -0
  495. package/templates/starter/.mcp.json +18 -2
  496. package/templates/starter/.vscode/mcp.json +36 -0
  497. package/templates/starter/.zed/settings.json +36 -0
  498. package/templates/starter/AGENTS.md +72 -426
  499. package/templates/starter/CLAUDE.md +72 -426
  500. package/templates/starter/assets/pickup.wav +0 -0
  501. package/templates/starter/gitignore +4 -0
  502. package/templates/starter/index.html +0 -1
  503. package/templates/starter/native-playtests/react-hud.playtest.json +20 -0
  504. package/templates/starter/native-playtests/render-chain.playtest.json +81 -0
  505. package/templates/starter/opencode.json +41 -0
  506. package/templates/starter/package.json +16 -12
  507. package/templates/starter/playtests/assets.playtest.json +65 -0
  508. package/templates/starter/playtests/boot-failure.playtest.json +45 -0
  509. package/templates/starter/playtests/buffer.playtest.json +59 -9
  510. package/templates/starter/playtests/cloth.playtest.json +113 -0
  511. package/templates/starter/playtests/coyote.playtest.json +60 -8
  512. package/templates/starter/playtests/forward.playtest.json +29 -4
  513. package/templates/starter/playtests/gameover.playtest.json +66 -0
  514. package/templates/starter/playtests/goal.playtest.json +67 -0
  515. package/templates/starter/playtests/hot-reload.playtest.json +48 -8
  516. package/templates/starter/playtests/look.playtest.json +142 -10
  517. package/templates/starter/playtests/models-baseline.png +0 -0
  518. package/templates/starter/playtests/models.playtest.json +74 -0
  519. package/templates/starter/playtests/monitoring.playtest.json +38 -7
  520. package/templates/starter/playtests/odometer.playtest.json +54 -0
  521. package/templates/starter/playtests/pause.playtest.json +27 -4
  522. package/templates/starter/playtests/play.playtest.json +44 -7
  523. package/templates/starter/playtests/respawn.playtest.json +46 -6
  524. package/templates/starter/playtests/restart.playtest.json +65 -10
  525. package/templates/starter/playtests/seed.playtest.json +44 -8
  526. package/templates/starter/playtests/survives.playtest.json +48 -4
  527. package/templates/starter/playtests/textures-baseline.png +0 -0
  528. package/templates/starter/playtests/textures.playtest.json +74 -0
  529. package/templates/starter/playtests/touch-controls.playtest.json +42 -0
  530. package/templates/starter/playtests/zoom-pinch.playtest.json +86 -0
  531. package/templates/starter/playtests/zoom-wheel.playtest.json +59 -0
  532. package/templates/starter/src/conventions.ts +18 -0
  533. package/templates/starter/src/entities/Goal.ts +137 -0
  534. package/templates/starter/src/entities/Player.ts +111 -10
  535. package/templates/starter/src/game.ts +27 -0
  536. package/templates/starter/src/render/adaptiveQuality.ts +195 -0
  537. package/templates/starter/src/render/camera.ts +31 -5
  538. package/templates/starter/src/render/coast.ts +199 -0
  539. package/templates/starter/src/render/easing.ts +5 -0
  540. package/templates/starter/src/render/effects/gradualBackground.ts +48 -0
  541. package/templates/starter/src/render/effects/lensDistortion.ts +43 -0
  542. package/templates/starter/src/render/effects/sparkle.ts +49 -0
  543. package/templates/starter/src/render/hero.ts +88 -0
  544. package/templates/starter/src/render/implicitSurface.ts +199 -0
  545. package/templates/starter/src/render/kuwahara.ts +174 -0
  546. package/templates/starter/src/render/lighting.ts +10 -5
  547. package/templates/starter/src/render/loading.ts +325 -0
  548. package/templates/starter/src/render/materials.ts +39 -4
  549. package/templates/starter/src/render/outline.ts +141 -0
  550. package/templates/starter/src/render/painterly.ts +86 -0
  551. package/templates/starter/src/render/palette.ts +15 -6
  552. package/templates/starter/src/render/pennant.ts +54 -0
  553. package/templates/starter/src/render/postprocessing.ts +97 -15
  554. package/templates/starter/src/render/quality.ts +185 -0
  555. package/templates/starter/src/render/rockRidge.ts +198 -0
  556. package/templates/starter/src/render/rockRidge.worker.ts +77 -0
  557. package/templates/starter/src/render/scenery.ts +40 -0
  558. package/templates/starter/src/render/shapes.ts +9 -21
  559. package/templates/starter/src/render/textureLifetime.ts +53 -0
  560. package/templates/starter/src/render/touch-controls.ts +165 -0
  561. package/templates/starter/src/render/water.ts +38 -0
  562. package/templates/starter/src/render/watercolor.ts +85 -0
  563. package/templates/starter/src/render/worldEnvironment.ts +758 -0
  564. package/templates/starter/src/scenes/Play.ts +243 -46
  565. package/templates/starter/src/state.ts +12 -0
  566. package/templates/starter/src/style.css +72 -8
  567. package/templates/starter/src/ui/App.tsx +9 -6
  568. package/templates/starter/src/ui/GameUi.tsx +20 -0
  569. package/templates/starter/src/ui/Hud.tsx +52 -29
  570. package/templates/starter/src/ui/Menu.tsx +25 -23
  571. package/templates/starter/src/ui/main.tsx +14 -0
  572. package/templates/starter/threenative.config.ts +27 -9
  573. package/templates/starter/tools/look.mjs +109 -0
  574. package/templates/starter/vite.config.ts +32 -2
  575. package/templates/action-rpg/src/physics.ts +0 -40
  576. package/templates/minimal/assets/.gitkeep +0 -0
  577. package/templates/minimal/public/.gitkeep +0 -0
  578. package/templates/minimal/public/icon.png +0 -0
  579. package/templates/platformer/assets/.gitkeep +0 -0
  580. package/templates/platformer/public/.gitkeep +0 -0
  581. package/templates/platformer/public/icon.png +0 -0
  582. package/templates/shooter/src/physics.ts +0 -49
  583. package/templates/starter/assets/.gitkeep +0 -0
  584. package/templates/starter/public/.gitkeep +0 -0
  585. package/templates/starter/public/icon.png +0 -0
  586. package/templates/starter/public/pickup.ogg +0 -0
  587. /package/templates/starter/{public → assets}/native-proof.glb +0 -0
  588. /package/templates/starter/{public → assets}/native-proof.png +0 -0
package/dist/index.js CHANGED
@@ -1,25 +1,1695 @@
1
1
  #!/usr/bin/env node
2
+ import { createRequire } from 'node:module';
2
3
  import { spawn } from 'child_process';
3
- import { existsSync, realpathSync, readdirSync, readFileSync } from 'fs';
4
- import { mkdir, cp, readdir, readFile, writeFile } from 'fs/promises';
5
- import path from 'path';
6
- import { fileURLToPath } from 'url';
4
+ import { existsSync, realpathSync, readdirSync, readFileSync, rmSync, mkdirSync, writeFileSync } from 'fs';
5
+ import { mkdir, cp, rename, readFile, readdir, writeFile, access, unlink, stat } from 'fs/promises';
6
+ import path5 from 'path';
7
+ import { fileURLToPath, pathToFileURL } from 'url';
8
+ import { LoadingManager, Box3, Vector3 } from 'three';
9
+ import { createHash } from 'crypto';
10
+ import { createRequire as createRequire$1 } from 'module';
11
+ import { parsePng, parseAudioConfig } from '@threenative/assets';
7
12
 
13
+ createRequire(import.meta.url);
14
+ var SUPPORTED_EXTENSIONS = /* @__PURE__ */ new Set([".glb", ".gltf"]);
15
+ var METRE_UPPER_BOUND = 10;
16
+ var CENTIMETRE_LOWER_BOUND = 100;
17
+ var RESOURCE_MIME_TYPES = {
18
+ ".avif": "image/avif",
19
+ ".gif": "image/gif",
20
+ ".jpeg": "image/jpeg",
21
+ ".jpg": "image/jpeg",
22
+ ".png": "image/png",
23
+ ".webp": "image/webp"
24
+ };
25
+ function vector(value) {
26
+ return { x: value.x, y: value.y, z: value.z };
27
+ }
28
+ function emptyBounds() {
29
+ return {
30
+ center: { x: 0, y: 0, z: 0 },
31
+ size: { x: 0, y: 0, z: 0 }
32
+ };
33
+ }
34
+ function longestAxis(size) {
35
+ const axes = [
36
+ { axis: "X", value: size.x },
37
+ { axis: "Y", value: size.y },
38
+ { axis: "Z", value: size.z }
39
+ ];
40
+ const result = axes.reduce(
41
+ (largest, current) => current.value > largest.value ? current : largest
42
+ );
43
+ return result.value > 0 ? result : void 0;
44
+ }
45
+ function installNodeGltfGlobals() {
46
+ const globals = globalThis;
47
+ const nodeGlobals = globals;
48
+ const previousSelf = globals.self;
49
+ const previousCreateImageBitmap = globals.createImageBitmap;
50
+ const previousProgressEvent = nodeGlobals.ProgressEvent;
51
+ const nodeUrl = URL;
52
+ const previousCreateObjectUrl = nodeUrl.createObjectURL;
53
+ if (globals.self === void 0) globals.self = globalThis;
54
+ if (globals.createImageBitmap === void 0) {
55
+ globals.createImageBitmap = async () => ({ close() {
56
+ }, height: 1, width: 1 });
57
+ }
58
+ if (previousProgressEvent === void 0) {
59
+ nodeGlobals.ProgressEvent = class {
60
+ constructor(type, init) {
61
+ this.type = type;
62
+ this.init = init;
63
+ }
64
+ type;
65
+ init;
66
+ };
67
+ }
68
+ if (nodeUrl.createObjectURL === void 0) {
69
+ nodeUrl.createObjectURL = () => "blob:threenative-inspect";
70
+ }
71
+ return () => {
72
+ if (previousSelf === void 0) globals.self = void 0;
73
+ else globals.self = previousSelf;
74
+ if (previousCreateImageBitmap === void 0) globals.createImageBitmap = void 0;
75
+ else globals.createImageBitmap = previousCreateImageBitmap;
76
+ nodeGlobals.ProgressEvent = previousProgressEvent;
77
+ if (previousCreateObjectUrl === void 0) nodeUrl.createObjectURL = void 0;
78
+ else nodeUrl.createObjectURL = previousCreateObjectUrl;
79
+ };
80
+ }
81
+ function localResourcePath(baseDirectory, uri) {
82
+ if (/^(?:blob|data):/i.test(uri) || /^(?:https?:)?\/\//i.test(uri)) return void 0;
83
+ let decoded;
84
+ try {
85
+ decoded = decodeURIComponent(uri);
86
+ } catch (error) {
87
+ throw new Error(`Invalid glTF resource URI "${uri}": ${String(error)}`);
88
+ }
89
+ return path5.resolve(baseDirectory, decoded);
90
+ }
91
+ function resourceMimeType(resourcePath, declared) {
92
+ return declared ?? RESOURCE_MIME_TYPES[path5.extname(resourcePath).toLowerCase()] ?? "application/octet-stream";
93
+ }
94
+ function gltfResourceReferences(document) {
95
+ const references = [];
96
+ for (const section of ["buffers", "images"]) {
97
+ const entries = document[section];
98
+ if (!Array.isArray(entries)) continue;
99
+ for (const entry of entries) {
100
+ if (!isObject(entry) || typeof entry.uri !== "string") continue;
101
+ references.push({
102
+ ...typeof entry.mimeType === "string" ? { declared: entry.mimeType } : {},
103
+ uri: entry.uri
104
+ });
105
+ }
106
+ }
107
+ return references;
108
+ }
109
+ async function readLocalResources(baseDirectory, references) {
110
+ const resources = /* @__PURE__ */ new Map();
111
+ for (const reference of references) {
112
+ const resourcePath = localResourcePath(baseDirectory, reference.uri);
113
+ if (resourcePath === void 0 || resources.has(resourcePath)) continue;
114
+ const resource = await readFile(resourcePath);
115
+ const mimeType = resourceMimeType(resourcePath, reference.declared);
116
+ resources.set(resourcePath, `data:${mimeType};base64,${resource.toString("base64")}`);
117
+ }
118
+ return resources;
119
+ }
120
+ async function localResourceResolver(file, data) {
121
+ if (path5.extname(file).toLowerCase() !== ".gltf") return (url) => url;
122
+ const document = JSON.parse(data.toString("utf8"));
123
+ const references = gltfResourceReferences(document);
124
+ const baseDirectory = path5.dirname(path5.resolve(file));
125
+ const resources = await readLocalResources(baseDirectory, references);
126
+ return (url) => {
127
+ const resourcePath = localResourcePath(baseDirectory, url);
128
+ return resourcePath === void 0 ? url : resources.get(resourcePath) ?? url;
129
+ };
130
+ }
131
+ async function parseGltf(file, data) {
132
+ const restoreGlobals = installNodeGltfGlobals();
133
+ try {
134
+ const { GLTFLoader } = await import('three/addons/loaders/GLTFLoader.js');
135
+ const manager = new LoadingManager();
136
+ manager.setURLModifier(await localResourceResolver(file, data));
137
+ const loader = new GLTFLoader(manager);
138
+ const extension = path5.extname(file).toLowerCase();
139
+ const payload = extension === ".gltf" ? data.toString("utf8") : data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
140
+ const parsed = await loader.parseAsync(
141
+ payload,
142
+ `${path5.dirname(path5.resolve(file))}${path5.sep}`
143
+ );
144
+ const json = parsed.parser.json;
145
+ return {
146
+ animations: parsed.animations,
147
+ resourceCounts: {
148
+ ...Array.isArray(json.meshes) ? { meshes: json.meshes.length } : {},
149
+ ...Array.isArray(json.materials) ? { materials: json.materials.length } : {},
150
+ ...Array.isArray(json.textures) ? { textures: json.textures.length } : {}
151
+ },
152
+ scene: parsed.scene
153
+ };
154
+ } finally {
155
+ restoreGlobals();
156
+ }
157
+ }
158
+ function isObject(value) {
159
+ return typeof value === "object" && value !== null;
160
+ }
161
+ function countSceneResources(scene) {
162
+ const materials = /* @__PURE__ */ new Set();
163
+ const textures = /* @__PURE__ */ new Set();
164
+ const visited = /* @__PURE__ */ new WeakSet();
165
+ const collectTextures = (value) => {
166
+ if (!isObject(value)) return;
167
+ if (value.isTexture === true) {
168
+ textures.add(value);
169
+ return;
170
+ }
171
+ if (visited.has(value)) return;
172
+ visited.add(value);
173
+ for (const child of Object.values(value)) collectTextures(child);
174
+ };
175
+ const bones = [];
176
+ let meshes = 0;
177
+ scene.traverse((object) => {
178
+ const candidate = object;
179
+ if (candidate.isBone === true) bones.push(candidate.name || "(unnamed)");
180
+ if (candidate.isMesh !== true) return;
181
+ meshes += 1;
182
+ const material = candidate.material;
183
+ for (const surface of Array.isArray(material) ? material : [material]) {
184
+ if (isObject(surface)) {
185
+ materials.add(surface);
186
+ collectTextures(surface);
187
+ }
188
+ }
189
+ });
190
+ return { bones, materials: materials.size, meshes, textures: textures.size };
191
+ }
192
+ function inspectScene(file, scene, animations, resourceCounts) {
193
+ scene.updateWorldMatrix(true, true);
194
+ const box = new Box3().setFromObject(scene);
195
+ const bounds = box.isEmpty() ? emptyBounds() : { center: vector(box.getCenter(new Vector3())), size: vector(box.getSize(new Vector3())) };
196
+ const largest = longestAxis(bounds.size);
197
+ const resources = countSceneResources(scene);
198
+ return {
199
+ bounds,
200
+ bones: resources.bones,
201
+ clips: animations.map((clip) => clip.name || "(unnamed)"),
202
+ file: path5.basename(file),
203
+ forwardAxis: largest === void 0 ? { axis: "unknown", basis: "none", direction: "unknown" } : { axis: largest.axis, basis: "longest geometry axis", direction: "unknown" },
204
+ materials: resourceCounts.materials ?? resources.materials,
205
+ meshes: resourceCounts.meshes ?? resources.meshes,
206
+ path: path5.resolve(file),
207
+ textures: resourceCounts.textures ?? resources.textures,
208
+ units: {
209
+ label: unitsLabel(largest?.value ?? 0),
210
+ longestAxis: largest?.value ?? 0
211
+ }
212
+ };
213
+ }
214
+ function unitsLabel(longestAxis2) {
215
+ if (longestAxis2 <= METRE_UPPER_BOUND) return "likely metres";
216
+ if (longestAxis2 >= CENTIMETRE_LOWER_BOUND) return "likely centimetres";
217
+ return "ambiguous";
218
+ }
219
+ function inspectionFailure(file, error) {
220
+ const detail = error instanceof Error ? error.message : String(error);
221
+ return new Error(`TN_ASSET_INSPECT_FAILED: ${file}: ${detail}`);
222
+ }
223
+ function parseInspectArgs(argv) {
224
+ const positional = argv.filter((argument) => !argument.startsWith("-"));
225
+ const unknown = argv.filter((argument) => argument.startsWith("-") && argument !== "--json");
226
+ if (unknown.length > 0 || positional.length !== 1) {
227
+ throw new Error("Usage: npx create-threenative inspect <file.glb> [--json]");
228
+ }
229
+ const file = positional[0];
230
+ if (file === void 0)
231
+ throw new Error("Usage: npx create-threenative inspect <file.glb> [--json]");
232
+ return { file, json: argv.includes("--json") };
233
+ }
234
+ async function inspectAsset(file) {
235
+ const extension = path5.extname(file).toLowerCase();
236
+ if (!SUPPORTED_EXTENSIONS.has(extension)) {
237
+ throw new Error(`TN_ASSET_INSPECT_UNSUPPORTED: ${file}: expected a .glb or .gltf file.`);
238
+ }
239
+ let data;
240
+ try {
241
+ data = await readFile(file);
242
+ } catch (error) {
243
+ throw inspectionFailure(file, error);
244
+ }
245
+ try {
246
+ const parsed = await parseGltf(file, data);
247
+ return inspectScene(file, parsed.scene, parsed.animations, parsed.resourceCounts);
248
+ } catch (error) {
249
+ throw inspectionFailure(file, error);
250
+ }
251
+ }
252
+ function formatVector(value, separator) {
253
+ return [value.x, value.y, value.z].map((component) => component.toFixed(3)).join(separator);
254
+ }
255
+ function listOrNone(values) {
256
+ return values.length === 0 ? "(none)" : values.join(", ");
257
+ }
258
+ function formatAssetInspection(result) {
259
+ const forward = result.forwardAxis.axis === "unknown" ? "unknown (glTF has no forward-axis metadata)" : `${result.forwardAxis.axis} (inferred from geometry; sign unknown)`;
260
+ const bones = result.bones.length === 0 ? "(none)" : `${result.bones.join(", ")} (${result.bones.length})`;
261
+ return `${[
262
+ result.file,
263
+ ` bounds ${formatVector(result.bounds.size, " x ")} (centre ${formatVector(result.bounds.center, ", ")})`,
264
+ ` units ${result.units.label} \u2014 longest axis ${result.units.longestAxis.toFixed(1)}`,
265
+ ` forward ${forward}`,
266
+ ` clips ${listOrNone(result.clips)}`,
267
+ ` bones ${bones}`,
268
+ ` meshes ${result.meshes} materials ${result.materials} textures ${result.textures}`
269
+ ].join("\n")}
270
+ `;
271
+ }
272
+ function inspectHelp() {
273
+ return `${[
274
+ "Usage: npx create-threenative inspect <file.glb> [--json]",
275
+ "",
276
+ "Read a glTF asset and report its bounds, units heuristic, axis observation, clips, bones,",
277
+ "meshes, materials and textures. The command never modifies the asset.",
278
+ "",
279
+ "Options:",
280
+ " --json Print the same inspection as machine-readable JSON."
281
+ ].join("\n")}
282
+ `;
283
+ }
284
+ async function inspectCommand(argv, write = (text) => process.stdout.write(text)) {
285
+ const options = parseInspectArgs(argv);
286
+ const result = await inspectAsset(options.file);
287
+ write(options.json ? `${JSON.stringify(result, null, 2)}
288
+ ` : formatAssetInspection(result));
289
+ return result;
290
+ }
291
+
292
+ // ../core/mcp/servers.mjs
293
+ var MCP_SERVERS = Object.freeze({
294
+ "threenative-assets": Object.freeze({
295
+ command: "node",
296
+ args: Object.freeze(["./node_modules/@threenative/core/mcp/assets.mjs"]),
297
+ // Entries rather than an object literal: these are environment variable names, not identifiers,
298
+ // and written as property names they read as names the naming rule must judge.
299
+ env: Object.freeze(
300
+ Object.fromEntries([
301
+ ["ASSET_DOWNLOAD_DIR", "./public/assets"],
302
+ ["AUDIO_DOWNLOAD_DIR", "./public/audio"]
303
+ ])
304
+ )
305
+ }),
306
+ "threenative-sculpt": Object.freeze({
307
+ command: "node",
308
+ args: Object.freeze(["./node_modules/@threenative/core/mcp/sculpt.mjs"])
309
+ }),
310
+ "threenative-engine": Object.freeze({
311
+ command: "node",
312
+ args: Object.freeze(["./node_modules/@threenative/core/mcp/engine.mjs"])
313
+ }),
314
+ // Drives an installed Blender headlessly so a downloaded .fbx becomes a GLB. It ships no
315
+ // Blender and probes for one only when a tool is called, so a project that never converts a
316
+ // model pays nothing for having this server wired.
317
+ "threenative-blender": Object.freeze({
318
+ command: "node",
319
+ args: Object.freeze(["./node_modules/@threenative/core/mcp/blender.mjs"])
320
+ })
321
+ });
322
+ var SERVER_FORMATS = Object.freeze({
323
+ // Claude Code (`.mcp.json`), Cursor and the Gemini CLI all read this one.
324
+ mcpServers: Object.freeze({
325
+ key: "mcpServers",
326
+ entry: (server) => ({
327
+ command: server.command,
328
+ args: [...server.args],
329
+ ...server.env === void 0 ? {} : { env: { ...server.env } }
330
+ })
331
+ }),
332
+ // VS Code names the table `servers` and requires an explicit transport per server.
333
+ vscode: Object.freeze({
334
+ key: "servers",
335
+ entry: (server) => ({
336
+ type: "stdio",
337
+ command: server.command,
338
+ args: [...server.args],
339
+ ...server.env === void 0 ? {} : { env: { ...server.env } }
340
+ })
341
+ }),
342
+ // opencode folds the command and its arguments into one array and spells the environment
343
+ // `environment`. A server it does not mark enabled is written down and never started.
344
+ opencode: Object.freeze({
345
+ key: "mcp",
346
+ entry: (server) => ({
347
+ type: "local",
348
+ command: [server.command, ...server.args],
349
+ enabled: true,
350
+ ...server.env === void 0 ? {} : { environment: { ...server.env } }
351
+ })
352
+ }),
353
+ // Zed calls them context servers and needs `source: "custom"` to accept a command of our own.
354
+ zed: Object.freeze({
355
+ key: "context_servers",
356
+ entry: (server) => ({
357
+ source: "custom",
358
+ command: server.command,
359
+ args: [...server.args],
360
+ ...server.env === void 0 ? {} : { env: { ...server.env } }
361
+ })
362
+ })
363
+ });
364
+ Object.freeze(Object.keys(SERVER_FORMATS));
365
+ function codexServerBlock(name, server) {
366
+ const args = server.args.map((argument) => JSON.stringify(argument)).join(", ");
367
+ const lines = [
368
+ `[mcp_servers.${name}]`,
369
+ `command = ${JSON.stringify(server.command)}`,
370
+ `args = [${args}]`
371
+ ];
372
+ if (server.env !== void 0) {
373
+ lines.push("", `[mcp_servers.${name}.env]`);
374
+ for (const [key, value] of Object.entries(server.env)) {
375
+ lines.push(`${key} = ${JSON.stringify(value)}`);
376
+ }
377
+ }
378
+ return lines.join("\n");
379
+ }
380
+ Object.freeze(
381
+ Object.entries(MCP_SERVERS).map(
382
+ ([name, server]) => Object.freeze({ body: codexServerBlock(name, server), name })
383
+ )
384
+ );
385
+
386
+ // src/mcp-servers.ts
387
+ function serverEntryPath(server) {
388
+ const entry = server.args[0];
389
+ if (entry === void 0) {
390
+ throw new Error("TN_MCP_TABLE: an MCP server entry declares no shim to launch.");
391
+ }
392
+ return entry;
393
+ }
394
+ var MARKER_RELATIVE = path5.join("node_modules", ".vite", "threenative-engine-build.json");
395
+ function hashTree(hash, directory) {
396
+ const entries = readdirSync(directory, { withFileTypes: true }).sort(
397
+ (left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0
398
+ );
399
+ for (const entry of entries) {
400
+ const full = path5.join(directory, entry.name);
401
+ if (entry.isDirectory()) {
402
+ hashTree(hash, full);
403
+ } else if (entry.isFile()) {
404
+ hash.update(path5.relative(directory, full));
405
+ hash.update(readFileSync(full));
406
+ }
407
+ }
408
+ }
409
+ function hashEngineDist(projectRoot) {
410
+ const scopeDir = path5.join(projectRoot, "node_modules", "@threenative");
411
+ let packages;
412
+ try {
413
+ packages = readdirSync(scopeDir, { withFileTypes: true }).filter((entry) => entry.isDirectory() || entry.isSymbolicLink()).map((entry) => entry.name).sort((left, right) => left < right ? -1 : left > right ? 1 : 0);
414
+ } catch {
415
+ return void 0;
416
+ }
417
+ const dists = [];
418
+ for (const name of packages) {
419
+ let packageDir = path5.join(scopeDir, name);
420
+ try {
421
+ packageDir = realpathSync(packageDir);
422
+ } catch {
423
+ continue;
424
+ }
425
+ const dist = path5.join(packageDir, "dist");
426
+ if (existsSync(dist)) dists.push([name, dist]);
427
+ }
428
+ if (dists.length === 0) return void 0;
429
+ const hash = createHash("sha256");
430
+ for (const [name, dist] of dists) {
431
+ hash.update(name);
432
+ hashTree(hash, dist);
433
+ }
434
+ return hash.digest("hex");
435
+ }
436
+ function markerPath(projectRoot) {
437
+ return path5.join(projectRoot, MARKER_RELATIVE);
438
+ }
439
+ function readMarker(file) {
440
+ try {
441
+ return JSON.parse(readFileSync(file, "utf8"));
442
+ } catch {
443
+ return void 0;
444
+ }
445
+ }
446
+ function processIsAlive(pid) {
447
+ if (pid === process.pid) return true;
448
+ try {
449
+ process.kill(pid, 0);
450
+ return true;
451
+ } catch (error) {
452
+ return error.code === "EPERM";
453
+ }
454
+ }
455
+ function createEngineFreshnessPlugin() {
456
+ let recordedHash;
457
+ const rootOf = (config) => path5.resolve(config.root ?? process.cwd());
458
+ return {
459
+ name: "threenative-engine-freshness",
460
+ config(config, env) {
461
+ const resolve = { dedupe: ["three", "react", "react-dom"] };
462
+ if (env.command !== "serve") return { resolve };
463
+ const root = rootOf(config);
464
+ recordedHash = hashEngineDist(root);
465
+ const marker = recordedHash === void 0 ? void 0 : readMarker(markerPath(root));
466
+ if (recordedHash === void 0 || marker === void 0 || marker.hash === recordedHash) {
467
+ return { resolve };
468
+ }
469
+ if (processIsAlive(marker.pid)) {
470
+ const where = marker.port === void 0 ? `pid ${marker.pid}` : `pid ${marker.pid} on port ${marker.port}`;
471
+ const how = marker.port === void 0 ? "" : ` (lsof -ti tcp:${marker.port} | xargs -r kill)`;
472
+ console.warn(
473
+ `threenative: a dev server is still running at ${where}, serving engine build ${marker.hash.slice(0, 8)}; the installed build is ${recordedHash.slice(0, 8)}. Kill it before playing${how} \u2014 its tab renders yesterday's engine.`
474
+ );
475
+ }
476
+ return { resolve, optimizeDeps: { force: true } };
477
+ },
478
+ configureServer(server) {
479
+ const root = rootOf(server.config);
480
+ const file = markerPath(root);
481
+ const writeBootMarker = (port) => {
482
+ const hash = recordedHash ?? hashEngineDist(root);
483
+ if (hash === void 0) return;
484
+ mkdirSync(path5.dirname(file), { recursive: true });
485
+ writeFileSync(
486
+ file,
487
+ JSON.stringify(
488
+ port === void 0 ? { hash, pid: process.pid } : { hash, pid: process.pid, port }
489
+ )
490
+ );
491
+ };
492
+ const httpServer = server.httpServer;
493
+ if (httpServer === void 0 || httpServer === null) {
494
+ writeBootMarker(void 0);
495
+ return;
496
+ }
497
+ httpServer.once("listening", () => {
498
+ const address = httpServer.address();
499
+ writeBootMarker(
500
+ typeof address === "object" && address !== null && address.port !== void 0 ? address.port : void 0
501
+ );
502
+ });
503
+ httpServer.once("close", () => {
504
+ const marker = readMarker(file);
505
+ if (marker?.pid === process.pid) rmSync(file, { force: true });
506
+ });
507
+ }
508
+ };
509
+ }
510
+ var ORIENTATIONS = ["landscape", "portrait", "sensor"];
511
+ var CONFIG_FILE = "threenative.config.ts";
512
+ var ConfigFailure = class extends Error {
513
+ code;
514
+ context;
515
+ detail;
516
+ constructor(code, detail, context) {
517
+ super(`${code}: ${context === void 0 ? detail : formatContext(context, detail)}`);
518
+ this.name = "ConfigFailure";
519
+ this.code = code;
520
+ this.context = context;
521
+ this.detail = detail;
522
+ }
523
+ };
524
+ function formatContext(context, detail) {
525
+ return `${context.layer} layer failed for ${context.sources.map((source) => `'${source}'`).join(", ")} from '${context.cwd}'. Searched: ${context.searched.join(", ")}. ${detail} Fix: ${context.fix}`;
526
+ }
527
+ function fail(code, message) {
528
+ throw new ConfigFailure(code, message);
529
+ }
530
+ function isRecord(value) {
531
+ return typeof value === "object" && value !== null && !Array.isArray(value);
532
+ }
533
+ function assertRecord(value, group) {
534
+ if (value === void 0) return {};
535
+ if (!isRecord(value)) fail("TN_CONFIG_GROUP_INVALID", `${group} must be an object.`);
536
+ return value;
537
+ }
538
+ function assertKeys(value, group, allowed) {
539
+ for (const key of Object.keys(value)) {
540
+ if (!allowed.includes(key)) fail("TN_CONFIG_UNKNOWN_KEY", `${group}.${key} is not recognised.`);
541
+ }
542
+ }
543
+ function nonEmptyString(value, code, label) {
544
+ if (typeof value !== "string" || value.trim().length === 0)
545
+ fail(code, `${label} must be non-empty.`);
546
+ return value;
547
+ }
548
+ function booleanValue(value, fallback, code, label) {
549
+ if (value === void 0) return fallback;
550
+ if (typeof value !== "boolean") fail(code, `${label} must be true or false.`);
551
+ return value;
552
+ }
553
+ function positiveInteger(value, fallback, code, label) {
554
+ if (value === void 0) return fallback;
555
+ if (!Number.isSafeInteger(value) || value <= 0) {
556
+ fail(code, `${label} must be a positive integer.`);
557
+ }
558
+ return value;
559
+ }
560
+ function maxFpsValue(value) {
561
+ if (value === void 0) return 60;
562
+ if (!Number.isSafeInteger(value) || value < 0 || value > 1e3) {
563
+ fail(
564
+ "TN_CONFIG_MAX_FPS_INVALID",
565
+ "display.maxFps must be a whole number between 0 (uncapped) and 1000."
566
+ );
567
+ }
568
+ return value;
569
+ }
570
+ function packageDisplayName(manifest) {
571
+ if (typeof manifest.name !== "string" || manifest.name.trim().length === 0) {
572
+ fail("TN_CONFIG_PACKAGE_NAME_MISSING", "package.json must declare a non-empty name.");
573
+ }
574
+ const name = manifest.name.replace(/^@[^/]+\//u, "");
575
+ if (name.length === 0) fail("TN_CONFIG_PACKAGE_NAME_MISSING", "package.json name is incomplete.");
576
+ return name;
577
+ }
578
+ function defaultAppId(name) {
579
+ let segment = name.toLowerCase().replace(/[^a-z0-9]/gu, "") || "game";
580
+ if (!/^[a-z]/u.test(segment)) segment = `game${segment}`;
581
+ return `com.threenative.${segment}`;
582
+ }
583
+ function projectRequire(cwd) {
584
+ return createRequire$1(path5.join(cwd, "package.json"));
585
+ }
586
+ function configLoaderSearch(cwd) {
587
+ return [
588
+ path5.join(cwd, "node_modules", "vite"),
589
+ path5.join(cwd, "node_modules", "esbuild"),
590
+ path5.resolve(path5.dirname(fileURLToPath(import.meta.url)), "..", "node_modules", "esbuild")
591
+ ];
592
+ }
593
+ var CONFIG_BUILD_COMMAND = "pnpm exec threenative build --target web";
594
+ function configContext(cwd, layer, sources, searched, fix) {
595
+ return { cwd, fix, layer, searched, sources };
596
+ }
597
+ function packageContext(cwd) {
598
+ const packagePath = path5.join(cwd, "package.json");
599
+ return configContext(
600
+ cwd,
601
+ "package manifest",
602
+ [packagePath],
603
+ [packagePath],
604
+ `repair '${packagePath}' and rerun ${CONFIG_BUILD_COMMAND}`
605
+ );
606
+ }
607
+ function loadingContext(cwd, sourcePath, fix) {
608
+ return configContext(
609
+ cwd,
610
+ "config loading",
611
+ [sourcePath],
612
+ configLoaderSearch(cwd),
613
+ fix ?? `fix '${sourcePath}' and rerun ${CONFIG_BUILD_COMMAND}`
614
+ );
615
+ }
616
+ function validationContext(cwd, sources) {
617
+ return configContext(
618
+ cwd,
619
+ "config validation",
620
+ sources,
621
+ [path5.join(cwd, "package.json"), path5.join(cwd, CONFIG_FILE)],
622
+ `fix '${path5.join(cwd, CONFIG_FILE)}' and rerun ${CONFIG_BUILD_COMMAND}`
623
+ );
624
+ }
625
+ function configFailure(code, context, detail) {
626
+ throw new ConfigFailure(code, detail, context);
627
+ }
628
+ function contextualize(error, context, fallbackCode) {
629
+ if (error instanceof ConfigFailure && error.context !== void 0) return error;
630
+ if (error instanceof ConfigFailure) return new ConfigFailure(error.code, error.detail, context);
631
+ return new ConfigFailure(
632
+ fallbackCode,
633
+ error instanceof Error ? error.message : String(error),
634
+ context
635
+ );
636
+ }
637
+ async function withConfigContext(context, fallbackCode, action) {
638
+ try {
639
+ return await action();
640
+ } catch (error) {
641
+ throw contextualize(error, context, fallbackCode);
642
+ }
643
+ }
644
+ function resolveEsbuild(cwd) {
645
+ const require2 = projectRequire(cwd);
646
+ try {
647
+ return require2.resolve("esbuild");
648
+ } catch {
649
+ try {
650
+ const vite = require2.resolve("vite");
651
+ return createRequire$1(vite).resolve("esbuild");
652
+ } catch {
653
+ try {
654
+ return createRequire$1(import.meta.url).resolve("esbuild");
655
+ } catch {
656
+ return void 0;
657
+ }
658
+ }
659
+ }
660
+ }
661
+ async function importConfig(cwd) {
662
+ const sourcePath = path5.join(cwd, CONFIG_FILE);
663
+ try {
664
+ await access(sourcePath);
665
+ } catch {
666
+ return void 0;
667
+ }
668
+ const esbuildPath = resolveEsbuild(cwd);
669
+ if (esbuildPath === void 0) {
670
+ configFailure(
671
+ "TN_CONFIG_TRANSPILER_MISSING",
672
+ loadingContext(
673
+ cwd,
674
+ sourcePath,
675
+ `run pnpm add -D esbuild in '${cwd}' and rerun ${CONFIG_BUILD_COMMAND}`
676
+ ),
677
+ // Not "install Vite": Vite 8 dropped esbuild for rolldown, so a project on it satisfies the
678
+ // old advice and still lands here. The templates ship esbuild explicitly for this reason;
679
+ // projects scaffolded before that do not.
680
+ "threenative.config.ts needs project-resolved esbuild; install esbuild."
681
+ );
682
+ }
683
+ let esbuild;
684
+ try {
685
+ esbuild = projectRequire(cwd)(esbuildPath);
686
+ } catch (error) {
687
+ configFailure(
688
+ "TN_CONFIG_TRANSPILER_MISSING",
689
+ loadingContext(
690
+ cwd,
691
+ sourcePath,
692
+ `run pnpm install in '${cwd}' and rerun ${CONFIG_BUILD_COMMAND}`
693
+ ),
694
+ error instanceof Error ? error.message : String(error)
695
+ );
696
+ }
697
+ const context = loadingContext(cwd, sourcePath);
698
+ let source;
699
+ try {
700
+ source = await readFile(sourcePath, "utf8");
701
+ } catch (error) {
702
+ configFailure(
703
+ "TN_CONFIG_LOAD_FAILED",
704
+ context,
705
+ error instanceof Error ? error.message : String(error)
706
+ );
707
+ }
708
+ let code;
709
+ try {
710
+ code = esbuild.transformSync(source, {
711
+ format: "esm",
712
+ loader: "ts",
713
+ platform: "node",
714
+ target: "node20"
715
+ }).code;
716
+ } catch (error) {
717
+ configFailure(
718
+ "TN_CONFIG_TRANSPILE_FAILED",
719
+ context,
720
+ error instanceof Error ? error.message : String(error)
721
+ );
722
+ }
723
+ const compiledPath = path5.join(cwd, `.threenative.config.${process.pid}.${Date.now()}.mjs`);
724
+ try {
725
+ await writeFile(compiledPath, code, "utf8");
726
+ } catch (error) {
727
+ configFailure(
728
+ "TN_CONFIG_LOAD_FAILED",
729
+ context,
730
+ error instanceof Error ? error.message : String(error)
731
+ );
732
+ }
733
+ try {
734
+ let module;
735
+ try {
736
+ module = await import(`${pathToFileURL(compiledPath).href}?cache=${Date.now()}`);
737
+ } catch (error) {
738
+ configFailure(
739
+ "TN_CONFIG_LOAD_FAILED",
740
+ context,
741
+ error instanceof Error ? error.message : String(error)
742
+ );
743
+ }
744
+ if (!isRecord(module.default)) {
745
+ configFailure(
746
+ "TN_CONFIG_DEFAULT_MISSING",
747
+ context,
748
+ "the config did not default-export an object."
749
+ );
750
+ }
751
+ return module.default;
752
+ } finally {
753
+ await unlink(compiledPath).catch(() => void 0);
754
+ }
755
+ }
756
+ async function readManifest(cwd) {
757
+ let parsed;
758
+ try {
759
+ parsed = JSON.parse(await readFile(path5.join(cwd, "package.json"), "utf8"));
760
+ } catch (error) {
761
+ fail("TN_CONFIG_PACKAGE_INVALID", error instanceof Error ? error.message : String(error));
762
+ }
763
+ if (!isRecord(parsed)) fail("TN_CONFIG_PACKAGE_INVALID", "package.json must contain an object.");
764
+ return parsed;
765
+ }
766
+ function packageNativeEntry(manifest) {
767
+ if (manifest.threenative === void 0) return void 0;
768
+ if (!isRecord(manifest.threenative)) {
769
+ fail("TN_CONFIG_PACKAGE_INVALID", "package.json.threenative must be an object.");
770
+ }
771
+ assertKeys(manifest.threenative, "package.json.threenative", ["nativeEntry"]);
772
+ const value = manifest.threenative.nativeEntry;
773
+ if (value === void 0) return void 0;
774
+ return nonEmptyString(value, "TN_NATIVE_ENTRY_MISSING", "package.json.threenative.nativeEntry");
775
+ }
776
+ function validateNativeEntry(value, cwd) {
777
+ const entry = nonEmptyString(value, "TN_NATIVE_ENTRY_MISSING", "nativeEntry");
778
+ if (path5.isAbsolute(entry)) {
779
+ fail("TN_CONFIG_NATIVE_ENTRY_INVALID", "nativeEntry must be project-relative.");
780
+ }
781
+ const resolved = path5.resolve(cwd, entry);
782
+ const relative = path5.relative(cwd, resolved);
783
+ if (relative === ".." || relative.startsWith(`..${path5.sep}`) || path5.isAbsolute(relative)) {
784
+ fail("TN_CONFIG_NATIVE_ENTRY_INVALID", "nativeEntry must stay inside the project.");
785
+ }
786
+ return entry;
787
+ }
788
+ async function validateApp(raw, name, cwd) {
789
+ const app = assertRecord(raw, "app");
790
+ assertKeys(app, "app", ["id", "name", "version", "build", "icon", "icons"]);
791
+ const id = app.id === void 0 ? defaultAppId(name) : nonEmptyString(app.id, "TN_CONFIG_APP_ID_INVALID", "app.id");
792
+ if (!/^[a-z][a-z0-9]*(?:\.[a-z][a-z0-9]*)+$/u.test(id)) {
793
+ fail("TN_CONFIG_APP_ID_INVALID", "app.id must be a lower-case reverse-DNS identifier.");
794
+ }
795
+ const appName = app.name === void 0 ? name : nonEmptyString(app.name, "TN_CONFIG_APP_NAME_INVALID", "app.name");
796
+ const version = app.version === void 0 ? "0.1.13" : nonEmptyString(app.version, "TN_CONFIG_APP_VERSION_INVALID", "app.version");
797
+ if (!/^\d+\.\d+\.\d+$/u.test(version)) {
798
+ fail(
799
+ "TN_CONFIG_APP_VERSION_INVALID",
800
+ "app.version must contain three period-separated integer components."
801
+ );
802
+ }
803
+ const build = positiveInteger(app.build, 1, "TN_CONFIG_APP_BUILD_INVALID", "app.build");
804
+ const icon = app.icon === void 0 ? void 0 : await validateProjectAsset(app.icon, cwd, "app.icon", {
805
+ codePrefix: "TN_CONFIG_ICON",
806
+ formats: ["png"],
807
+ square: true
808
+ });
809
+ const icons = await validateIconVariants(app.icons, cwd);
810
+ if (icons?.android !== void 0 && icon === void 0 && icons.android.foreground === void 0) {
811
+ fail(
812
+ "TN_CONFIG_BRAND_ANDROID_FOREGROUND_MISSING",
813
+ "app.icons.android.foreground is required when app.icon is not declared."
814
+ );
815
+ }
816
+ return {
817
+ id,
818
+ name: appName,
819
+ version,
820
+ build,
821
+ ...icon === void 0 ? {} : { icon },
822
+ ...icons === void 0 ? {} : { icons }
823
+ };
824
+ }
825
+ async function validateProjectAsset(raw, cwd, label, options) {
826
+ const relative = nonEmptyString(raw, `${options.codePrefix}_INVALID`, label);
827
+ if (path5.isAbsolute(relative)) {
828
+ fail(`${options.codePrefix}_PATH_INVALID`, `${label} must be project-relative: ${relative}`);
829
+ }
830
+ const resolved = path5.resolve(cwd, relative);
831
+ const withinProject = path5.relative(cwd, resolved);
832
+ if (withinProject === ".." || withinProject.startsWith(`..${path5.sep}`) || path5.isAbsolute(withinProject)) {
833
+ fail(
834
+ `${options.codePrefix}_PATH_INVALID`,
835
+ `${label} must stay inside the project: ${relative}`
836
+ );
837
+ }
838
+ const extension = path5.extname(relative).slice(1).toLowerCase();
839
+ if (!options.formats.includes(extension)) {
840
+ fail(
841
+ options.codePrefix === "TN_CONFIG_ICON" ? `${options.codePrefix}_INVALID` : `${options.codePrefix}_FORMAT_INVALID`,
842
+ `${label} must use ${options.formats.map((format) => `.${format}`).join(" or ")}: ${relative}`
843
+ );
844
+ }
845
+ let info;
846
+ try {
847
+ info = await stat(resolved);
848
+ } catch {
849
+ fail(`${options.codePrefix}_MISSING`, `${label} does not exist: ${relative}`);
850
+ }
851
+ if (!info.isFile()) fail(`${options.codePrefix}_MISSING`, `${label} is not a file: ${relative}`);
852
+ let contents;
853
+ try {
854
+ contents = await readFile(resolved);
855
+ } catch (error) {
856
+ fail(
857
+ `${options.codePrefix}_INVALID`,
858
+ `${label} could not be read at ${relative}: ${error instanceof Error ? error.message : String(error)}`
859
+ );
860
+ }
861
+ if (extension === "svg") {
862
+ if (!/<svg(?:\s|>)/iu.test(contents.toString("utf8"))) {
863
+ fail(`${options.codePrefix}_INVALID`, `${label} is not a valid SVG file: ${relative}`);
864
+ }
865
+ return relative;
866
+ }
867
+ const png = parsePng(contents);
868
+ if (png === void 0) {
869
+ fail(`${options.codePrefix}_INVALID`, `${label} is not a valid PNG file: ${relative}`);
870
+ }
871
+ if (options.square === true && png.width !== png.height) {
872
+ fail(
873
+ `${options.codePrefix}_DIMENSIONS_INVALID`,
874
+ `${label} must be square (${png.width}x${png.height}): ${relative}`
875
+ );
876
+ }
877
+ if (options.requiresAlpha === true && !png.hasAlpha) {
878
+ fail(
879
+ `${options.codePrefix}_ALPHA_INVALID`,
880
+ `${label} must include an alpha channel: ${relative}`
881
+ );
882
+ }
883
+ return relative;
884
+ }
885
+ function validateBrandColor(raw, label) {
886
+ if (typeof raw !== "string" || !/^#[0-9a-f]{6}$/iu.test(raw)) {
887
+ fail("TN_CONFIG_BRAND_COLOR_INVALID", `${label} must be a #rrggbb colour.`);
888
+ }
889
+ return raw;
890
+ }
891
+ async function validateIconVariants(raw, cwd) {
892
+ if (raw === void 0) return void 0;
893
+ const icons = assertRecord(raw, "app.icons");
894
+ assertKeys(icons, "app.icons", ["android", "ios", "web"]);
895
+ const android = icons.android === void 0 ? void 0 : assertRecord(icons.android, "app.icons.android");
896
+ const ios = icons.ios === void 0 ? void 0 : assertRecord(icons.ios, "app.icons.ios");
897
+ const web = icons.web === void 0 ? void 0 : assertRecord(icons.web, "app.icons.web");
898
+ if (android !== void 0)
899
+ assertKeys(android, "app.icons.android", ["foreground", "background", "monochrome"]);
900
+ if (ios !== void 0) assertKeys(ios, "app.icons.ios", ["dark", "tinted"]);
901
+ if (web !== void 0)
902
+ assertKeys(web, "app.icons.web", ["favicon", "maskable", "monochrome", "appleTouch"]);
903
+ const androidResult = android === void 0 ? void 0 : {
904
+ ...android.foreground === void 0 ? {} : {
905
+ foreground: await validateProjectAsset(
906
+ android.foreground,
907
+ cwd,
908
+ "app.icons.android.foreground",
909
+ {
910
+ codePrefix: "TN_CONFIG_BRAND_ANDROID_FOREGROUND",
911
+ formats: ["png"],
912
+ requiresAlpha: true,
913
+ square: true
914
+ }
915
+ )
916
+ },
917
+ ...android.background === void 0 ? {} : {
918
+ background: validateBrandColor(android.background, "app.icons.android.background")
919
+ },
920
+ ...android.monochrome === void 0 ? {} : {
921
+ monochrome: await validateProjectAsset(
922
+ android.monochrome,
923
+ cwd,
924
+ "app.icons.android.monochrome",
925
+ {
926
+ codePrefix: "TN_CONFIG_BRAND_ANDROID_MONOCHROME",
927
+ formats: ["png"],
928
+ requiresAlpha: true,
929
+ square: true
930
+ }
931
+ )
932
+ }
933
+ };
934
+ const iosResult = ios === void 0 ? void 0 : {
935
+ ...ios.dark === void 0 ? {} : {
936
+ dark: await validateProjectAsset(ios.dark, cwd, "app.icons.ios.dark", {
937
+ codePrefix: "TN_CONFIG_BRAND_IOS_DARK",
938
+ formats: ["png"],
939
+ square: true
940
+ })
941
+ },
942
+ ...ios.tinted === void 0 ? {} : {
943
+ tinted: await validateProjectAsset(ios.tinted, cwd, "app.icons.ios.tinted", {
944
+ codePrefix: "TN_CONFIG_BRAND_IOS_TINTED",
945
+ formats: ["png"],
946
+ square: true
947
+ })
948
+ }
949
+ };
950
+ const webResult = web === void 0 ? void 0 : {
951
+ ...web.favicon === void 0 ? {} : {
952
+ favicon: await validateProjectAsset(web.favicon, cwd, "app.icons.web.favicon", {
953
+ codePrefix: "TN_CONFIG_BRAND_WEB_FAVICON",
954
+ formats: ["png", "svg"],
955
+ square: true
956
+ })
957
+ },
958
+ ...web.maskable === void 0 ? {} : {
959
+ maskable: await validateProjectAsset(web.maskable, cwd, "app.icons.web.maskable", {
960
+ codePrefix: "TN_CONFIG_BRAND_WEB_MASKABLE",
961
+ formats: ["png"],
962
+ square: true
963
+ })
964
+ },
965
+ ...web.monochrome === void 0 ? {} : {
966
+ monochrome: await validateProjectAsset(
967
+ web.monochrome,
968
+ cwd,
969
+ "app.icons.web.monochrome",
970
+ {
971
+ codePrefix: "TN_CONFIG_BRAND_WEB_MONOCHROME",
972
+ formats: ["png"],
973
+ square: true
974
+ }
975
+ )
976
+ },
977
+ ...web.appleTouch === void 0 ? {} : {
978
+ appleTouch: await validateProjectAsset(
979
+ web.appleTouch,
980
+ cwd,
981
+ "app.icons.web.appleTouch",
982
+ {
983
+ codePrefix: "TN_CONFIG_BRAND_WEB_APPLE_TOUCH",
984
+ formats: ["png"],
985
+ square: true
986
+ }
987
+ )
988
+ }
989
+ };
990
+ return {
991
+ ...androidResult === void 0 ? {} : { android: androidResult },
992
+ ...iosResult === void 0 ? {} : { ios: iosResult },
993
+ ...webResult === void 0 ? {} : { web: webResult }
994
+ };
995
+ }
996
+ function validateDisplay(raw) {
997
+ const display = assertRecord(raw, "display");
998
+ assertKeys(display, "display", ["orientation", "fullscreen", "keepScreenOn", "maxFps"]);
999
+ const orientation = display.orientation === void 0 ? "landscape" : display.orientation;
1000
+ if (typeof orientation !== "string" || !ORIENTATIONS.includes(orientation)) {
1001
+ fail(
1002
+ "TN_NATIVE_ORIENTATION_INVALID",
1003
+ "display.orientation must be landscape, portrait, or sensor."
1004
+ );
1005
+ }
1006
+ return {
1007
+ orientation,
1008
+ fullscreen: booleanValue(
1009
+ display.fullscreen,
1010
+ true,
1011
+ "TN_CONFIG_FULLSCREEN_INVALID",
1012
+ "display.fullscreen"
1013
+ ),
1014
+ keepScreenOn: booleanValue(
1015
+ display.keepScreenOn,
1016
+ false,
1017
+ "TN_CONFIG_KEEP_SCREEN_ON_INVALID",
1018
+ "display.keepScreenOn"
1019
+ ),
1020
+ maxFps: maxFpsValue(display.maxFps)
1021
+ };
1022
+ }
1023
+ function validateWindow(raw, appName) {
1024
+ const window = assertRecord(raw, "window");
1025
+ assertKeys(window, "window", ["title", "width", "height", "maximized", "resizable"]);
1026
+ return {
1027
+ title: window.title === void 0 ? appName : nonEmptyString(window.title, "TN_CONFIG_WINDOW_TITLE_INVALID", "window.title"),
1028
+ width: positiveInteger(window.width, 1280, "TN_CONFIG_WINDOW_WIDTH_INVALID", "window.width"),
1029
+ height: positiveInteger(window.height, 720, "TN_CONFIG_WINDOW_HEIGHT_INVALID", "window.height"),
1030
+ maximized: booleanValue(
1031
+ window.maximized,
1032
+ false,
1033
+ "TN_CONFIG_WINDOW_MAXIMIZED_INVALID",
1034
+ "window.maximized"
1035
+ ),
1036
+ resizable: booleanValue(
1037
+ window.resizable,
1038
+ true,
1039
+ "TN_CONFIG_WINDOW_RESIZABLE_INVALID",
1040
+ "window.resizable"
1041
+ )
1042
+ };
1043
+ }
1044
+ async function validateBootSplash(raw, cwd) {
1045
+ if (raw === void 0) return void 0;
1046
+ const bootSplash = assertRecord(raw, "bootSplash");
1047
+ assertKeys(bootSplash, "bootSplash", ["backgroundColor", "image"]);
1048
+ const backgroundColor = bootSplash.backgroundColor === void 0 ? void 0 : validateBrandColor(bootSplash.backgroundColor, "bootSplash.backgroundColor");
1049
+ const image = bootSplash.image === void 0 ? void 0 : await validateProjectAsset(bootSplash.image, cwd, "bootSplash.image", {
1050
+ codePrefix: "TN_CONFIG_BRAND_SPLASH",
1051
+ formats: ["png"]
1052
+ });
1053
+ return {
1054
+ ...backgroundColor === void 0 ? {} : { backgroundColor },
1055
+ ...image === void 0 ? {} : { image }
1056
+ };
1057
+ }
1058
+ var UI_RENDERERS = ["native", "web"];
1059
+ function validateUi(raw) {
1060
+ const ui = assertRecord(raw, "ui");
1061
+ assertKeys(ui, "ui", ["renderer"]);
1062
+ const renderer = ui.renderer === void 0 ? "native" : ui.renderer;
1063
+ if (typeof renderer !== "string" || !UI_RENDERERS.includes(renderer)) {
1064
+ fail("TN_CONFIG_UI_RENDERER_INVALID", "ui.renderer must be web or native.");
1065
+ }
1066
+ return { renderer };
1067
+ }
1068
+ function validateRenderer(raw) {
1069
+ const renderer = assertRecord(raw, "renderer");
1070
+ assertKeys(renderer, "renderer", [
1071
+ "preferWebGPU",
1072
+ "resolutionScale",
1073
+ "antialias",
1074
+ "alphaAntialiasing",
1075
+ "android"
1076
+ ]);
1077
+ const android = assertRecord(renderer.android, "renderer.android");
1078
+ assertKeys(android, "renderer.android", ["resolutionScale", "antialias", "alphaAntialiasing"]);
1079
+ const resolutionScale = renderer.resolutionScale;
1080
+ const androidResolutionScale = android.resolutionScale;
1081
+ for (const [name, value] of [
1082
+ ["renderer.resolutionScale", resolutionScale],
1083
+ ["renderer.android.resolutionScale", androidResolutionScale]
1084
+ ]) {
1085
+ if (value === void 0 || value === "auto") continue;
1086
+ if (typeof value !== "number" || !Number.isFinite(value) || value <= 0 || value > 1) {
1087
+ fail(
1088
+ "TN_CONFIG_RENDERER_RESOLUTION_SCALE_INVALID",
1089
+ `${name} must be "auto" or a number within (0, 1].`
1090
+ );
1091
+ }
1092
+ }
1093
+ const antialias = booleanOrUndefined(renderer.antialias, "renderer.antialias");
1094
+ const androidAntialias = booleanOrUndefined(android.antialias, "renderer.android.antialias");
1095
+ const alphaAntialiasing = booleanOrUndefined(
1096
+ renderer.alphaAntialiasing,
1097
+ "renderer.alphaAntialiasing"
1098
+ );
1099
+ const androidAlphaAntialiasing = booleanOrUndefined(
1100
+ android.alphaAntialiasing,
1101
+ "renderer.android.alphaAntialiasing"
1102
+ );
1103
+ const androidOverrides = {
1104
+ ...androidResolutionScale === void 0 ? {} : { resolutionScale: androidResolutionScale },
1105
+ ...androidAntialias === void 0 ? {} : { antialias: androidAntialias },
1106
+ ...androidAlphaAntialiasing === void 0 ? {} : { alphaAntialiasing: androidAlphaAntialiasing }
1107
+ };
1108
+ return {
1109
+ preferWebGPU: booleanValue(
1110
+ renderer.preferWebGPU,
1111
+ true,
1112
+ "TN_CONFIG_RENDERER_INVALID",
1113
+ "renderer.preferWebGPU"
1114
+ ),
1115
+ ...antialias === void 0 ? {} : { antialias },
1116
+ ...alphaAntialiasing === void 0 ? {} : { alphaAntialiasing },
1117
+ ...resolutionScale === void 0 ? {} : { resolutionScale },
1118
+ ...Object.keys(androidOverrides).length === 0 ? {} : { android: androidOverrides }
1119
+ };
1120
+ }
1121
+ function booleanOrUndefined(value, name) {
1122
+ if (value === void 0) return void 0;
1123
+ if (typeof value !== "boolean") fail("TN_CONFIG_RENDERER_INVALID", `${name} must be a boolean.`);
1124
+ return value;
1125
+ }
1126
+ var ASSET_TARGET_KEYS = [
1127
+ "maxMaterials",
1128
+ "maxTriangles",
1129
+ "maxTextureDimension"
1130
+ ];
1131
+ function validateAssetTargets(raw) {
1132
+ const targets = assertRecord(raw, "assets.targets");
1133
+ assertKeys(targets, "assets.targets", ASSET_TARGET_KEYS);
1134
+ return {
1135
+ ...targets.maxMaterials === void 0 ? {} : {
1136
+ maxMaterials: positiveInteger(
1137
+ targets.maxMaterials,
1138
+ 1,
1139
+ "TN_CONFIG_ASSETS_INVALID",
1140
+ "assets.targets.maxMaterials"
1141
+ )
1142
+ },
1143
+ ...targets.maxTriangles === void 0 ? {} : {
1144
+ maxTriangles: positiveInteger(
1145
+ targets.maxTriangles,
1146
+ 1,
1147
+ "TN_CONFIG_ASSETS_INVALID",
1148
+ "assets.targets.maxTriangles"
1149
+ )
1150
+ },
1151
+ ...targets.maxTextureDimension === void 0 ? {} : {
1152
+ maxTextureDimension: positiveInteger(
1153
+ targets.maxTextureDimension,
1154
+ 1,
1155
+ "TN_CONFIG_ASSETS_INVALID",
1156
+ "assets.targets.maxTextureDimension"
1157
+ )
1158
+ }
1159
+ };
1160
+ }
1161
+ var ASSET_TEXTURE_KEYS = ["maxSize", "overrides", "quality"];
1162
+ var TEXTURE_OVERRIDE_KEYS = ["codec", "glob", "quality"];
1163
+ var TEXTURE_CODECS = ["etc1s", "none", "uastc"];
1164
+ function textureQuality(value, label) {
1165
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 1 || value > 255) {
1166
+ fail("TN_CONFIG_ASSETS_INVALID", `${label} must be an integer between 1 and 255.`);
1167
+ }
1168
+ return value;
1169
+ }
1170
+ function textureMaxSize(value) {
1171
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 4) {
1172
+ fail(
1173
+ "TN_CONFIG_ASSETS_INVALID",
1174
+ "assets.textures.maxSize must be a positive integer of at least 4."
1175
+ );
1176
+ }
1177
+ return value;
1178
+ }
1179
+ function validateTextureOverrides(raw) {
1180
+ if (!Array.isArray(raw)) {
1181
+ fail("TN_CONFIG_ASSETS_INVALID", "assets.textures.overrides must be an array.");
1182
+ }
1183
+ return raw.map((item, index) => {
1184
+ if (!isRecord(item)) {
1185
+ fail(
1186
+ "TN_CONFIG_ASSETS_INVALID",
1187
+ `assets.textures.overrides[${String(index)}] must be an object.`
1188
+ );
1189
+ }
1190
+ assertKeys(item, `assets.textures.overrides[${String(index)}]`, TEXTURE_OVERRIDE_KEYS);
1191
+ const glob = nonEmptyString(
1192
+ item.glob,
1193
+ "TN_CONFIG_ASSETS_INVALID",
1194
+ `assets.textures.overrides[${String(index)}].glob`
1195
+ );
1196
+ if (typeof item.codec !== "string" || !TEXTURE_CODECS.includes(item.codec)) {
1197
+ fail(
1198
+ "TN_CONFIG_ASSETS_INVALID",
1199
+ `assets.textures.overrides[${String(index)}].codec must be one of ${TEXTURE_CODECS.join(", ")}; received '${String(item.codec)}'.`
1200
+ );
1201
+ }
1202
+ return {
1203
+ codec: item.codec,
1204
+ glob,
1205
+ ...item.quality === void 0 ? {} : {
1206
+ quality: textureQuality(
1207
+ item.quality,
1208
+ `assets.textures.overrides[${String(index)}].quality`
1209
+ )
1210
+ }
1211
+ };
1212
+ });
1213
+ }
1214
+ function validateTextures(raw) {
1215
+ if (raw === "none") return "none";
1216
+ const textures = assertRecord(raw, "assets.textures");
1217
+ assertKeys(textures, "assets.textures", ASSET_TEXTURE_KEYS);
1218
+ return {
1219
+ ...textures.maxSize === void 0 ? {} : { maxSize: textureMaxSize(textures.maxSize) },
1220
+ ...textures.quality === void 0 ? {} : { quality: textureQuality(textures.quality, "assets.textures.quality") },
1221
+ ...textures.overrides === void 0 ? {} : { overrides: validateTextureOverrides(textures.overrides) }
1222
+ };
1223
+ }
1224
+ var MODEL_PASS_KEYS = ["dedup", "meshopt", "prune", "quantize", "reorder"];
1225
+ var MODEL_QUANTIZE_KEYS = ["normalBits", "positionBits", "uvBits"];
1226
+ var MODEL_VIRTUAL_KEYS = [
1227
+ "groupSize",
1228
+ "maxTriangles",
1229
+ "minSourceTriangles",
1230
+ "minTriangles",
1231
+ "simplifyRatio"
1232
+ ];
1233
+ function bitDepth(value, label) {
1234
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 1 || value > 16) {
1235
+ fail("TN_CONFIG_ASSETS_INVALID", `${label} must be an integer between 1 and 16 bits.`);
1236
+ }
1237
+ return value;
1238
+ }
1239
+ function validateModels(raw) {
1240
+ if (raw === "none") return "none";
1241
+ const models = assertRecord(raw, "assets.models");
1242
+ assertKeys(models, "assets.models", [
1243
+ "lightmap",
1244
+ "passes",
1245
+ "quantize",
1246
+ "sharedImages",
1247
+ "simplify",
1248
+ "textures",
1249
+ "virtual"
1250
+ ]);
1251
+ if (models.sharedImages !== void 0 && typeof models.sharedImages !== "boolean") {
1252
+ fail("TN_CONFIG_ASSETS_INVALID", "assets.models.sharedImages must be true or false.");
1253
+ }
1254
+ const sharedImages = models.sharedImages;
1255
+ let lightmap;
1256
+ if (models.lightmap !== void 0) {
1257
+ const rawLightmap = assertRecord(models.lightmap, "assets.models.lightmap");
1258
+ assertKeys(rawLightmap, "assets.models.lightmap", ["atlasSize", "padding"]);
1259
+ if (rawLightmap.atlasSize === void 0 || rawLightmap.padding === void 0) {
1260
+ fail("TN_CONFIG_ASSETS_INVALID", "assets.models.lightmap requires atlasSize and padding.");
1261
+ }
1262
+ lightmap = {
1263
+ atlasSize: positiveInteger(
1264
+ rawLightmap.atlasSize,
1265
+ 1,
1266
+ "TN_CONFIG_ASSETS_INVALID",
1267
+ "assets.models.lightmap.atlasSize"
1268
+ ),
1269
+ padding: positiveInteger(
1270
+ rawLightmap.padding,
1271
+ 1,
1272
+ "TN_CONFIG_ASSETS_INVALID",
1273
+ "assets.models.lightmap.padding"
1274
+ )
1275
+ };
1276
+ }
1277
+ let passes;
1278
+ if (models.passes !== void 0) {
1279
+ const rawPasses = assertRecord(models.passes, "assets.models.passes");
1280
+ assertKeys(rawPasses, "assets.models.passes", MODEL_PASS_KEYS);
1281
+ passes = {};
1282
+ for (const key of MODEL_PASS_KEYS) {
1283
+ const value = rawPasses[key];
1284
+ if (value === void 0) continue;
1285
+ if (typeof value !== "boolean")
1286
+ fail("TN_CONFIG_ASSETS_INVALID", `assets.models.passes.${key} must be true or false.`);
1287
+ passes = { ...passes, [key]: value };
1288
+ }
1289
+ }
1290
+ let quantize;
1291
+ if (models.quantize !== void 0) {
1292
+ const rawQuantize = assertRecord(models.quantize, "assets.models.quantize");
1293
+ assertKeys(rawQuantize, "assets.models.quantize", MODEL_QUANTIZE_KEYS);
1294
+ quantize = {};
1295
+ for (const key of MODEL_QUANTIZE_KEYS) {
1296
+ const value = rawQuantize[key];
1297
+ if (value === void 0) continue;
1298
+ quantize = {
1299
+ ...quantize,
1300
+ [key]: bitDepth(value, `assets.models.quantize.${key}`)
1301
+ };
1302
+ }
1303
+ }
1304
+ const simplify = models.simplify;
1305
+ const textures = models.textures;
1306
+ let virtual;
1307
+ if (models.virtual === "none") {
1308
+ virtual = "none";
1309
+ } else if (models.virtual !== void 0) {
1310
+ const rawVirtual = assertRecord(models.virtual, "assets.models.virtual");
1311
+ assertKeys(rawVirtual, "assets.models.virtual", MODEL_VIRTUAL_KEYS);
1312
+ const bake = {};
1313
+ for (const key of MODEL_VIRTUAL_KEYS) {
1314
+ const value = rawVirtual[key];
1315
+ if (value === void 0) continue;
1316
+ if (key === "simplifyRatio") {
1317
+ if (typeof value !== "number" || !(value > 0) || !(value < 1))
1318
+ fail(
1319
+ "TN_CONFIG_ASSETS_INVALID",
1320
+ "assets.models.virtual.simplifyRatio must be a number between 0 and 1, exclusive."
1321
+ );
1322
+ bake.simplifyRatio = value;
1323
+ continue;
1324
+ }
1325
+ bake[key] = positiveInteger(
1326
+ value,
1327
+ 1,
1328
+ "TN_CONFIG_ASSETS_INVALID",
1329
+ `assets.models.virtual.${key}`
1330
+ );
1331
+ }
1332
+ virtual = bake;
1333
+ }
1334
+ return {
1335
+ ...lightmap === void 0 ? {} : { lightmap },
1336
+ ...passes === void 0 || Object.keys(passes).length === 0 ? {} : { passes },
1337
+ ...quantize === void 0 || Object.keys(quantize).length === 0 ? {} : { quantize },
1338
+ ...sharedImages === void 0 ? {} : { sharedImages },
1339
+ ...simplify === void 0 ? {} : { simplify },
1340
+ ...textures === void 0 ? {} : { textures },
1341
+ ...virtual === void 0 ? {} : { virtual }
1342
+ };
1343
+ }
1344
+ function validateBudget(raw) {
1345
+ const limit = (value) => value === "none" || typeof value === "number" && Number.isSafeInteger(value) && value > 0;
1346
+ if (limit(raw)) return raw;
1347
+ if (typeof raw !== "object" || raw === null || Array.isArray(raw) || Object.entries(raw).some(
1348
+ ([key, value]) => !["uncooked", "total"].includes(key) || !limit(value)
1349
+ )) {
1350
+ fail(
1351
+ "TN_CONFIG_ASSETS_INVALID",
1352
+ 'assets.budget must contain positive integer byte limits or "none" for uncooked and total.'
1353
+ );
1354
+ }
1355
+ return raw;
1356
+ }
1357
+ function validateAudio(raw) {
1358
+ try {
1359
+ parseAudioConfig(raw);
1360
+ } catch (error) {
1361
+ fail("TN_CONFIG_ASSETS_INVALID", error instanceof Error ? error.message : String(error));
1362
+ }
1363
+ return raw;
1364
+ }
1365
+ function validateAssets(raw) {
1366
+ const assets = assertRecord(raw, "assets");
1367
+ assertKeys(assets, "assets", [
1368
+ "audio",
1369
+ "budget",
1370
+ "exclude",
1371
+ "concurrency",
1372
+ "models",
1373
+ "source",
1374
+ "output",
1375
+ "targets",
1376
+ "textures"
1377
+ ]);
1378
+ const targets = assets.targets === void 0 ? void 0 : validateAssetTargets(assets.targets);
1379
+ const models = assets.models === void 0 ? void 0 : validateModels(assets.models);
1380
+ const textures = assets.textures === void 0 ? void 0 : validateTextures(assets.textures);
1381
+ if (assets.exclude !== void 0 && (!Array.isArray(assets.exclude) || assets.exclude.some((glob) => typeof glob !== "string" || glob.trim() === ""))) {
1382
+ fail("TN_CONFIG_ASSETS_INVALID", "assets.exclude must be an array of non-empty glob strings.");
1383
+ }
1384
+ return {
1385
+ ...assets.audio === void 0 ? {} : { audio: validateAudio(assets.audio) },
1386
+ ...assets.exclude === void 0 ? {} : { exclude: assets.exclude },
1387
+ ...assets.budget === void 0 ? {} : { budget: validateBudget(assets.budget) },
1388
+ // The worker bound a bake may use. Validated here so a malformed value fails at config
1389
+ // load with the named code, and handed to the driver unchanged, which re-checks it —
1390
+ // the producer→consumer seam the config spec proves by running the pipeline.
1391
+ ...assets.concurrency === void 0 ? {} : {
1392
+ concurrency: positiveInteger(
1393
+ assets.concurrency,
1394
+ 1,
1395
+ "TN_CONFIG_ASSETS_INVALID",
1396
+ "assets.concurrency"
1397
+ )
1398
+ },
1399
+ ...assets.source === void 0 ? {} : { source: nonEmptyString(assets.source, "TN_CONFIG_ASSETS_INVALID", "assets.source") },
1400
+ ...assets.output === void 0 ? {} : { output: nonEmptyString(assets.output, "TN_CONFIG_ASSETS_INVALID", "assets.output") },
1401
+ ...targets === void 0 ? {} : { targets },
1402
+ ...models === void 0 ? {} : { models },
1403
+ ...textures === void 0 ? {} : { textures }
1404
+ };
1405
+ }
1406
+ async function loadConfigInternal(root) {
1407
+ const packagePath = path5.join(root, "package.json");
1408
+ const sourcePath = path5.join(root, CONFIG_FILE);
1409
+ const manifest = await withConfigContext(
1410
+ packageContext(root),
1411
+ "TN_CONFIG_PACKAGE_INVALID",
1412
+ () => readManifest(root)
1413
+ );
1414
+ const name = await withConfigContext(
1415
+ packageContext(root),
1416
+ "TN_CONFIG_PACKAGE_INVALID",
1417
+ () => packageDisplayName(manifest)
1418
+ );
1419
+ const packageEntry = await withConfigContext(
1420
+ packageContext(root),
1421
+ "TN_CONFIG_PACKAGE_INVALID",
1422
+ () => packageNativeEntry(manifest)
1423
+ );
1424
+ const raw = await importConfig(root);
1425
+ const sources = packageEntry === void 0 ? [sourcePath] : [sourcePath, packagePath];
1426
+ return withConfigContext(
1427
+ validationContext(root, sources),
1428
+ "TN_CONFIG_VALIDATION_FAILED",
1429
+ async () => {
1430
+ if (raw !== void 0) {
1431
+ assertKeys(raw, "config", [
1432
+ "app",
1433
+ "display",
1434
+ "bootSplash",
1435
+ "window",
1436
+ "nativeEntry",
1437
+ "renderer",
1438
+ "ui",
1439
+ "assets"
1440
+ ]);
1441
+ }
1442
+ const configuredEntry = raw?.nativeEntry;
1443
+ if (configuredEntry !== void 0 && packageEntry !== void 0) {
1444
+ fail(
1445
+ "TN_CONFIG_CONFLICT",
1446
+ "nativeEntry is declared in both threenative.config.ts and package.json."
1447
+ );
1448
+ }
1449
+ const app = await validateApp(raw?.app, name, root);
1450
+ const bootSplash = await validateBootSplash(raw?.bootSplash, root);
1451
+ const assets = raw?.assets === void 0 ? void 0 : validateAssets(raw.assets);
1452
+ return {
1453
+ app,
1454
+ display: validateDisplay(raw?.display),
1455
+ window: validateWindow(raw?.window, app.name),
1456
+ nativeEntry: validateNativeEntry(configuredEntry ?? packageEntry ?? "src/game.ts", root),
1457
+ renderer: validateRenderer(raw?.renderer),
1458
+ ui: validateUi(raw?.ui),
1459
+ ...bootSplash === void 0 ? {} : { bootSplash },
1460
+ ...assets === void 0 ? {} : { assets }
1461
+ };
1462
+ }
1463
+ );
1464
+ }
1465
+ async function loadConfig(cwd) {
1466
+ const root = path5.resolve(cwd);
1467
+ return withConfigContext(
1468
+ validationContext(root, [path5.join(root, CONFIG_FILE), path5.join(root, "package.json")]),
1469
+ "TN_CONFIG_VALIDATION_FAILED",
1470
+ () => loadConfigInternal(root)
1471
+ );
1472
+ }
1473
+
1474
+ // src/web-brand.ts
1475
+ function htmlAttribute(value) {
1476
+ return value.replaceAll("&", "&amp;").replaceAll('"', "&quot;").replaceAll("<", "&lt;");
1477
+ }
1478
+ function publicUrl(root, value) {
1479
+ if (value === void 0) return void 0;
1480
+ const relative = path5.isAbsolute(value) ? path5.relative(root, value) : value;
1481
+ const normalized = relative.replaceAll(path5.sep, "/").replace(/^public\//u, "");
1482
+ return `/${normalized.replace(/^\//u, "")}`;
1483
+ }
1484
+ function manifestIcon(root, source, purpose) {
1485
+ const url = publicUrl(root, source);
1486
+ if (url === void 0) return void 0;
1487
+ const type = url.endsWith(".svg") ? "image/svg+xml" : "image/png";
1488
+ return { purpose, src: url, type };
1489
+ }
1490
+ function renderWebManifest(root, config) {
1491
+ const web = config.app.icons?.web;
1492
+ const fallback = web?.favicon ?? config.app.icon;
1493
+ const icons = [
1494
+ manifestIcon(root, fallback, "any"),
1495
+ manifestIcon(root, web?.maskable ?? config.app.icon, "maskable"),
1496
+ manifestIcon(root, web?.monochrome, "monochrome")
1497
+ ].filter((icon) => icon !== void 0);
1498
+ const background = config.bootSplash?.backgroundColor ?? "#000000";
1499
+ const manifest = Object.fromEntries([
1500
+ ["background_color", background],
1501
+ ["display", "fullscreen"],
1502
+ ["icons", icons],
1503
+ ["name", config.app.name],
1504
+ ["orientation", config.display.orientation],
1505
+ ["short_name", config.app.name],
1506
+ ["start_url", "."],
1507
+ ["theme_color", background]
1508
+ ]);
1509
+ return `${JSON.stringify(manifest, null, 2)}
1510
+ `;
1511
+ }
1512
+ function metadataLinks(root, config) {
1513
+ const web = config.app.icons?.web;
1514
+ const favicon = publicUrl(root, web?.favicon ?? config.app.icon);
1515
+ const appleTouch = publicUrl(root, web?.appleTouch ?? config.app.icon);
1516
+ const links = [
1517
+ favicon === void 0 ? void 0 : `<link rel="icon" href="${htmlAttribute(favicon)}" />`,
1518
+ appleTouch === void 0 ? void 0 : `<link rel="apple-touch-icon" href="${htmlAttribute(appleTouch)}" />`,
1519
+ '<link rel="manifest" href="/manifest.webmanifest" />'
1520
+ ].filter((link) => link !== void 0);
1521
+ const background = config.bootSplash?.backgroundColor ?? "#000000";
1522
+ links.push(`<meta name="theme-color" content="${htmlAttribute(background)}" />`);
1523
+ return links.join("\n ");
1524
+ }
1525
+ function updateLaunchMarkup(root, config, html) {
1526
+ let output = html.replace(
1527
+ /(<title[^>]*>)[\s\S]*?(<\/title>)/iu,
1528
+ `$1${htmlAttribute(config.app.name)}$2`
1529
+ );
1530
+ output = output.replace(
1531
+ /(<[^>]*data-threenative-launch-name[^>]*>)[\s\S]*?(<\/[^>]+>)/iu,
1532
+ `$1${htmlAttribute(config.app.name)}$2`
1533
+ );
1534
+ const launchImage = publicUrl(root, config.bootSplash?.image);
1535
+ if (launchImage !== void 0) {
1536
+ output = output.replace(
1537
+ /<img([^>]*data-threenative-launch-image[^>]*)>/iu,
1538
+ (_match, attributes) => `<img${attributes.replace(/\s+hidden(?:="[^"]*")?/iu, "")} src="${htmlAttribute(launchImage)}">`
1539
+ );
1540
+ }
1541
+ const links = metadataLinks(root, config);
1542
+ output = output.replace(/\s*<link\s+rel="icon"[^>]*>/giu, "");
1543
+ output = output.replace(/\s*<link\s+rel="apple-touch-icon"[^>]*>/giu, "");
1544
+ output = output.replace(/\s*<link\s+rel="manifest"[^>]*>/giu, "");
1545
+ output = output.replace(/(<\/head>)/iu, ` ${links}
1546
+ $1`);
1547
+ return output;
1548
+ }
1549
+ function createWebBrandPlugin() {
1550
+ let root = process.cwd();
1551
+ let config;
1552
+ return {
1553
+ name: "threenative-web-brand",
1554
+ async configResolved(resolved) {
1555
+ root = resolved.root;
1556
+ config = await loadConfig(root);
1557
+ },
1558
+ transformIndexHtml(html) {
1559
+ if (config === void 0) throw new Error("TN_WEB_BRAND_CONFIG_MISSING");
1560
+ return updateLaunchMarkup(root, config, html);
1561
+ },
1562
+ generateBundle() {
1563
+ if (config === void 0) throw new Error("TN_WEB_BRAND_CONFIG_MISSING");
1564
+ this.emitFile({
1565
+ fileName: "manifest.webmanifest",
1566
+ source: renderWebManifest(root, config),
1567
+ type: "asset"
1568
+ });
1569
+ }
1570
+ };
1571
+ }
1572
+
1573
+ // src/index.ts
1574
+ var PACKAGE_SOURCE_FLAGS = {
1575
+ "@threenative/core": "--core-package",
1576
+ "@threenative/assets": "--assets-package",
1577
+ "@threenative/physics": "--physics-package",
1578
+ "@threenative/playtest": "--playtest-package",
1579
+ "@threenative/runtime-native": "--runtime-native-package",
1580
+ "@threenative/ui": "--ui-package",
1581
+ "threenative-blender-mcp": "--blender-mcp-package",
1582
+ "threenative-engine-mcp": "--engine-mcp-package",
1583
+ "create-threenative": "--cli-package"
1584
+ };
1585
+ var UNSCOPED_PACKAGE_FLAG_ALIASES = {
1586
+ "blender-mcp": "threenative-blender-mcp",
1587
+ cli: "create-threenative",
1588
+ "engine-mcp": "threenative-engine-mcp"
1589
+ };
8
1590
  var TEXT_FILE_EXTENSIONS = /* @__PURE__ */ new Set([".css", ".html", ".json", ".md", ".svg", ".ts", ".tsx"]);
9
1591
  var TEMPLATE_NAME = /^[a-z][a-z0-9-]*$/u;
1592
+ var SHARED_AGENT_MARKER_LINE = /^<!--\s*(?:shared:\s*[^>]+|\/shared)\s*-->\r?\n?/gmu;
1593
+ var DEFAULT_TEMPLATE = "starter";
10
1594
  function templateRoot() {
11
- return path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../templates");
1595
+ return path5.resolve(path5.dirname(fileURLToPath(import.meta.url)), "../templates");
1596
+ }
1597
+ var LOADING_SOURCE_RELATIVE_PATH = path5.join("src", "render", "loading.ts");
1598
+ var LOADING_APPEARANCE_MARKER = "BEGIN THREENATIVE LOADING APPEARANCE";
1599
+ var TEMPLATE_ICON_NAME = "icon.png";
1600
+ var LOADING_APPEARANCE_BLOCK_PATTERN = /\/\* BEGIN THREENATIVE LOADING APPEARANCE \*\/[\s\S]*?\/\* END THREENATIVE LOADING APPEARANCE \*\//gu;
1601
+ function discoverStampedTemplates(root = templateRoot()) {
1602
+ return readdirSync(root, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => entry.name).sort((left, right) => left.localeCompare(right)).filter((template) => {
1603
+ const file = path5.join(root, template, LOADING_SOURCE_RELATIVE_PATH);
1604
+ return existsSync(file) && readFileSync(file, "utf8").includes(LOADING_APPEARANCE_MARKER);
1605
+ });
1606
+ }
1607
+ function canonicalLoadingPath(root = templateRoot()) {
1608
+ const local = path5.resolve(root, "..", "template-assets", "loading.ts");
1609
+ if (existsSync(local)) return local;
1610
+ return path5.resolve(templateRoot(), "..", "template-assets", "loading.ts");
1611
+ }
1612
+ function loadingAppearanceBlock(source, file) {
1613
+ const matches = source.match(LOADING_APPEARANCE_BLOCK_PATTERN) ?? [];
1614
+ if (matches.length !== 1) {
1615
+ throw new Error(
1616
+ `TN_LOADING_TEMPLATE_INVALID: ${file}: expected exactly one loading appearance block, found ${matches.length}.`
1617
+ );
1618
+ }
1619
+ return matches[0];
1620
+ }
1621
+ function stampLoadingSource(canonical, template) {
1622
+ const canonicalBlock = loadingAppearanceBlock(canonical, "canonical loading source");
1623
+ const templateBlock = loadingAppearanceBlock(template, "template loading source");
1624
+ return canonical.replace(canonicalBlock, templateBlock);
1625
+ }
1626
+ var SHARED_RENDER_SOURCES = [path5.join("src", "render", "worldEnvironment.ts")];
1627
+ function canonicalRenderSourcePath(relativePath, root = templateRoot()) {
1628
+ const name = path5.basename(relativePath);
1629
+ const local = path5.resolve(root, "..", "template-assets", name);
1630
+ if (existsSync(local)) return local;
1631
+ return path5.resolve(templateRoot(), "..", "template-assets", name);
1632
+ }
1633
+ async function restampSharedRenderCopies(root = templateRoot()) {
1634
+ const stamped = [];
1635
+ for (const relativePath of SHARED_RENDER_SOURCES) {
1636
+ const canonical = await readFile(canonicalRenderSourcePath(relativePath, root), "utf8");
1637
+ for (const template of readdirSync(root, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => entry.name).sort((left, right) => left.localeCompare(right))) {
1638
+ const file = path5.join(root, template, relativePath);
1639
+ if (!existsSync(file)) continue;
1640
+ await writeFile(file, canonical);
1641
+ stamped.push(file);
1642
+ }
1643
+ }
1644
+ return stamped;
1645
+ }
1646
+ async function restampTemplateLoadingCopies(root = templateRoot()) {
1647
+ const canonical = await readFile(canonicalLoadingPath(root), "utf8");
1648
+ const stamped = [];
1649
+ for (const template of discoverStampedTemplates(root)) {
1650
+ const file = path5.join(root, template, LOADING_SOURCE_RELATIVE_PATH);
1651
+ const source = await readFile(file, "utf8");
1652
+ await writeFile(file, stampLoadingSource(canonical, source));
1653
+ stamped.push(file);
1654
+ }
1655
+ return stamped;
1656
+ }
1657
+ async function stampTemplateLoading(target, template, root) {
1658
+ const sourcePath = path5.join(template, LOADING_SOURCE_RELATIVE_PATH);
1659
+ if (!existsSync(sourcePath)) return;
1660
+ const source = await readFile(sourcePath, "utf8");
1661
+ if (!source.includes("BEGIN THREENATIVE LOADING APPEARANCE")) return;
1662
+ const canonical = await readFile(canonicalLoadingPath(root), "utf8");
1663
+ await writeFile(
1664
+ path5.join(target, LOADING_SOURCE_RELATIVE_PATH),
1665
+ stampLoadingSource(canonical, source)
1666
+ );
1667
+ }
1668
+ async function copyTemplateIcon(target, templateRootDirectory) {
1669
+ const source = path5.join(
1670
+ path5.dirname(templateRootDirectory),
1671
+ "template-assets",
1672
+ TEMPLATE_ICON_NAME
1673
+ );
1674
+ if (!existsSync(source)) {
1675
+ throw new Error(
1676
+ `TN_TEMPLATE_ICON_MISSING: '${source}' is not in the package; every generated project needs the native icon asset.`
1677
+ );
1678
+ }
1679
+ const destination = path5.join(target, "public", TEMPLATE_ICON_NAME);
1680
+ await mkdir(path5.dirname(destination), { recursive: true });
1681
+ await cp(source, destination, { errorOnExist: true, force: false });
12
1682
  }
13
1683
  function invalidManifest(file, reason) {
14
1684
  throw new Error(`TN_KIT_MANIFEST_INVALID: ${file}: ${reason}`);
15
1685
  }
16
- function nonEmptyString(value, field, file) {
1686
+ function nonEmptyString2(value, field, file) {
17
1687
  if (typeof value !== "string" || value.trim().length === 0)
18
1688
  return invalidManifest(file, `${field} must be a non-empty string`);
19
1689
  return value;
20
1690
  }
21
1691
  function loadManifest(directory) {
22
- const file = path.join(directory, "kit.json");
1692
+ const file = path5.join(directory, "kit.json");
23
1693
  let raw;
24
1694
  try {
25
1695
  raw = readFileSync(file, "utf8");
@@ -37,8 +1707,8 @@ function loadManifest(directory) {
37
1707
  if (typeof value !== "object" || value === null || Array.isArray(value))
38
1708
  return invalidManifest(file, "the root must be an object");
39
1709
  const record = value;
40
- const directoryName = path.basename(directory);
41
- const name = nonEmptyString(record.name, "name", file);
1710
+ const directoryName = path5.basename(directory);
1711
+ const name = nonEmptyString2(record.name, "name", file);
42
1712
  if (!TEMPLATE_NAME.test(name))
43
1713
  return invalidManifest(file, "name must match /^[a-z][a-z0-9-]*$/");
44
1714
  if (name !== directoryName)
@@ -46,15 +1716,15 @@ function loadManifest(directory) {
46
1716
  const kit = record.kit;
47
1717
  if (typeof kit !== "boolean") return invalidManifest(file, "kit must be a boolean");
48
1718
  return {
49
- blurb: nonEmptyString(record.blurb, "blurb", file),
50
- genre: nonEmptyString(record.genre, "genre", file),
1719
+ blurb: nonEmptyString2(record.blurb, "blurb", file),
1720
+ genre: nonEmptyString2(record.genre, "genre", file),
51
1721
  kit,
52
1722
  name,
53
- title: nonEmptyString(record.title, "title", file)
1723
+ title: nonEmptyString2(record.title, "title", file)
54
1724
  };
55
1725
  }
56
1726
  function discoverKitManifests(root = templateRoot()) {
57
- return readdirSync(root, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => loadManifest(path.join(root, entry.name))).sort((left, right) => left.name.localeCompare(right.name));
1727
+ return readdirSync(root, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => loadManifest(path5.join(root, entry.name))).sort((left, right) => left.name.localeCompare(right.name));
58
1728
  }
59
1729
  function discoverTemplateNames(root = templateRoot()) {
60
1730
  return discoverKitManifests(root).map(({ name }) => name);
@@ -67,17 +1737,32 @@ function kitManifest(template, root = templateRoot()) {
67
1737
  );
68
1738
  return manifest;
69
1739
  }
1740
+ function templateForGenre(genre, root = templateRoot()) {
1741
+ const normalized = genre.trim().toLowerCase();
1742
+ if (normalized.length === 0) throw new Error("Genre must not be empty.");
1743
+ return discoverKitManifests(root).find((manifest) => manifest.genre.toLowerCase() === normalized)?.name ?? "minimal";
1744
+ }
70
1745
  function templateHelp(manifests) {
71
1746
  const width = Math.max(...manifests.map(({ name }) => name.length), 0);
72
1747
  return manifests.map(({ blurb, name, title }) => ` ${name.padEnd(width)} ${title}: ${blurb}`).join("\n");
73
1748
  }
1749
+ function scaffoldCompletionMessage(manifests, defaultTemplate = DEFAULT_TEMPLATE) {
1750
+ const names = manifests.map(({ name }) => name === defaultTemplate ? `${name} (default)` : name).join(", ");
1751
+ return `Templates: ${names}. Choose with --template <name>.
1752
+ `;
1753
+ }
74
1754
  function cliHelp() {
75
1755
  const manifests = discoverKitManifests();
76
1756
  return `${[
77
1757
  "Usage: npx create-threenative <directory> [options]",
1758
+ " npx create-threenative inspect <file.glb> [--json]",
1759
+ "",
1760
+ "Commands:",
1761
+ " inspect <file> Report the facts in a glTF asset.",
78
1762
  "",
79
1763
  "Options:",
80
1764
  " --template <name> Choose a template.",
1765
+ " --genre <name> Choose an exact genre kit; unknown genres use minimal.",
81
1766
  " --no-install Copy the project without running pnpm install.",
82
1767
  " --help Show this help.",
83
1768
  "",
@@ -87,65 +1772,196 @@ function cliHelp() {
87
1772
  `;
88
1773
  }
89
1774
  function packageName(target) {
90
- const name = path.basename(target).toLowerCase().replace(/[^a-z0-9-_]+/g, "-");
1775
+ const name = path5.basename(target).toLowerCase().replace(/[^a-z0-9-_]+/g, "-");
91
1776
  if (name.length === 0 || name === "-" || name === "_") {
92
1777
  throw new Error(`Cannot derive a package name from '${target}'.`);
93
1778
  }
94
1779
  return name;
95
1780
  }
96
1781
  async function isEmpty(directory) {
97
- const entries = await readdir(directory).catch(() => []);
1782
+ const entries = await readdir(directory).catch(
1783
+ (error) => error?.code === "ENOENT" ? [] : void 0
1784
+ );
1785
+ if (entries === void 0) return false;
98
1786
  return entries.length === 0;
99
1787
  }
1788
+ function substituteTemplateVariables(content, replacements) {
1789
+ let rendered = content;
1790
+ for (const [placeholder, value] of Object.entries(replacements)) {
1791
+ rendered = rendered.replaceAll(placeholder, value);
1792
+ }
1793
+ return rendered;
1794
+ }
100
1795
  async function renderTemplate(directory, replacements) {
101
1796
  const files = await readdir(directory, { withFileTypes: true });
102
1797
  for (const entry of files) {
103
- const source = path.join(directory, entry.name);
1798
+ const source = path5.join(directory, entry.name);
104
1799
  if (entry.isDirectory()) {
105
1800
  await renderTemplate(source, replacements);
106
1801
  continue;
107
1802
  }
108
- if (!TEXT_FILE_EXTENSIONS.has(path.extname(entry.name))) continue;
1803
+ if (!TEXT_FILE_EXTENSIONS.has(path5.extname(entry.name))) continue;
109
1804
  const content = await readFile(source, "utf8");
110
- let rendered = content;
111
- for (const [placeholder, value] of Object.entries(replacements)) {
112
- rendered = rendered.replaceAll(placeholder, value);
1805
+ let rendered = substituteTemplateVariables(content, replacements);
1806
+ if (entry.name === "AGENTS.md" || entry.name === "CLAUDE.md") {
1807
+ rendered = rendered.replace(SHARED_AGENT_MARKER_LINE, "");
113
1808
  }
114
1809
  await writeFile(source, rendered);
115
1810
  }
116
1811
  }
1812
+ var REFERENCE_BUNDLE_DIRECTORY = "agent-docs";
1813
+ var REFERENCE_FILE_NAME = /^[a-z0-9][a-z0-9-]*\.md$/u;
1814
+ var AGENT_FILES_DIRECTORY = "agent-files";
1815
+ var AUTHORING_GITIGNORE_RULES = [
1816
+ "# ThreeNative local authoring state and dependency secrets",
1817
+ ".dream-loop/",
1818
+ "node_modules/",
1819
+ ".env",
1820
+ ".env.*",
1821
+ "!.env.example"
1822
+ ];
1823
+ var REFERENCE_TOKEN_PATTERN = /`agent-docs\/([a-z0-9][a-z0-9./-]*\.md)`|\[[^\]]*\]\(agent-docs\/([^)#]+\.md)\)/gu;
1824
+ async function copyReferenceBundle(target, templateRootDirectory, replacements) {
1825
+ const bundle = path5.join(
1826
+ path5.dirname(templateRootDirectory),
1827
+ REFERENCE_BUNDLE_DIRECTORY,
1828
+ "references"
1829
+ );
1830
+ if (!existsSync(bundle)) return;
1831
+ const destination = path5.join(target, REFERENCE_BUNDLE_DIRECTORY);
1832
+ await mkdir(destination, { recursive: true });
1833
+ for (const entry of await readdir(bundle, { withFileTypes: true })) {
1834
+ if (!entry.isFile() || !REFERENCE_FILE_NAME.test(entry.name)) continue;
1835
+ const content = substituteTemplateVariables(
1836
+ await readFile(path5.join(bundle, entry.name), "utf8"),
1837
+ replacements
1838
+ );
1839
+ const destinationPath = path5.join(destination, entry.name);
1840
+ if (path5.relative(target, destinationPath).startsWith("..")) {
1841
+ throw new Error(`Reference page '${entry.name}' resolves outside '${target}'.`);
1842
+ }
1843
+ await writeFile(destinationPath, content);
1844
+ }
1845
+ }
1846
+ async function copyAgentFiles(target, templateRootDirectory) {
1847
+ const source = path5.join(path5.dirname(templateRootDirectory), AGENT_FILES_DIRECTORY);
1848
+ if (!existsSync(source)) {
1849
+ throw new Error(
1850
+ `TN_AGENT_FILES_MISSING: '${source}' is not in the package; every generated project needs the canonical agent roles.`
1851
+ );
1852
+ }
1853
+ await cp(source, target, { recursive: true });
1854
+ }
1855
+ async function installAuthoringGitignore(target) {
1856
+ const file = path5.join(target, ".gitignore");
1857
+ const existing = existsSync(file) ? await readFile(file, "utf8") : "";
1858
+ const present = new Set(existing.split(/\r?\n/u));
1859
+ const missing = AUTHORING_GITIGNORE_RULES.filter((entry) => !present.has(entry));
1860
+ if (missing.length === 0) return;
1861
+ const prefix = existing.length === 0 || existing.endsWith("\n") ? existing : `${existing}
1862
+ `;
1863
+ await writeFile(
1864
+ file,
1865
+ `${prefix}${prefix.length > 0 && !prefix.endsWith("\n\n") ? "\n" : ""}${missing.join("\n")}
1866
+ `
1867
+ );
1868
+ }
1869
+ async function assertReferenceBundle(target) {
1870
+ for (const file of [
1871
+ "AGENTS.md",
1872
+ "CLAUDE.md",
1873
+ ".agents/skills/threenative-visuals/SKILL.md",
1874
+ ".claude/skills/threenative-visuals/SKILL.md",
1875
+ ".agents/skills/threenative-assets/SKILL.md",
1876
+ ".claude/skills/threenative-assets/SKILL.md"
1877
+ ]) {
1878
+ const filePath = path5.join(target, file);
1879
+ if (existsSync(filePath)) await assertReferenceTargets(target, file, filePath);
1880
+ }
1881
+ }
1882
+ async function assertReferenceTargets(target, from, filePath) {
1883
+ const content = await readFile(filePath, "utf8");
1884
+ for (const match of content.matchAll(REFERENCE_TOKEN_PATTERN)) {
1885
+ const referenced = match[1] ?? match[2];
1886
+ if (referenced === void 0) continue;
1887
+ if (!REFERENCE_FILE_NAME.test(referenced) || referenced.includes("/")) {
1888
+ throw new Error(
1889
+ `RED observed: referenced recipe missing: '${from}' names '${referenced}', which is not a shipped reference page.`
1890
+ );
1891
+ }
1892
+ const resolved = path5.join(target, REFERENCE_BUNDLE_DIRECTORY, referenced);
1893
+ if (!existsSync(resolved)) {
1894
+ throw new Error(
1895
+ `RED observed: referenced recipe missing: '${from}' links 'agent-docs/${referenced}', which the scaffold did not copy.`
1896
+ );
1897
+ }
1898
+ }
1899
+ }
117
1900
  async function applyPackageSources(target, packageSources) {
118
1901
  if (packageSources === void 0) return;
119
- const packagePath = path.join(target, "package.json");
1902
+ const packagePath = path5.join(target, "package.json");
120
1903
  const packageJson = JSON.parse(await readFile(packagePath, "utf8"));
1904
+ const localSource = (source) => {
1905
+ const filePath = source.startsWith("file:") ? source.slice("file:".length) : source;
1906
+ return `file:${path5.resolve(filePath)}`;
1907
+ };
121
1908
  for (const [name, source] of Object.entries(packageSources)) {
122
1909
  if (source === void 0) continue;
1910
+ const resolvedSource = localSource(source);
1911
+ const isExistingDevDependency = packageJson.devDependencies?.[name] !== void 0;
123
1912
  if (packageJson.optionalDependencies?.[name] !== void 0) {
124
- packageJson.optionalDependencies[name] = source.startsWith("file:") ? source : `file:${source}`;
125
- } else if (name === "@threenative/playtest" || name === "@threenative/studio" || name === "create-threenative") {
1913
+ packageJson.optionalDependencies[name] = resolvedSource;
1914
+ } else if (isExistingDevDependency || name === "@threenative/playtest" || name === "create-threenative" || name === "threenative-engine-mcp") {
126
1915
  packageJson.devDependencies ??= {};
127
- packageJson.devDependencies[name] = source.startsWith("file:") ? source : `file:${source}`;
1916
+ packageJson.devDependencies[name] = resolvedSource;
128
1917
  } else {
129
1918
  packageJson.dependencies ??= {};
130
- packageJson.dependencies[name] = source.startsWith("file:") ? source : `file:${source}`;
131
- }
132
- if (name === "create-threenative") {
133
- packageJson.pnpm ??= {};
134
- packageJson.pnpm.overrides ??= {};
135
- packageJson.pnpm.overrides[name] = source.startsWith("file:") ? source : `file:${source}`;
1919
+ packageJson.dependencies[name] = resolvedSource;
136
1920
  }
1921
+ packageJson.pnpm ??= {};
1922
+ packageJson.pnpm.overrides ??= {};
1923
+ packageJson.pnpm.overrides[name] = resolvedSource;
137
1924
  }
138
1925
  await writeFile(packagePath, `${JSON.stringify(packageJson, null, 2)}
139
1926
  `);
140
1927
  }
1928
+ async function copyCapabilityManifest(target, templateRootDirectory) {
1929
+ const source = path5.join(path5.dirname(templateRootDirectory), "capabilities.json");
1930
+ if (!existsSync(source)) {
1931
+ throw new Error(
1932
+ `TN_KIT_CAPABILITIES_MISSING: '${source}' is not in the package; the generated project needs the capability manifest for its agent tooling.`
1933
+ );
1934
+ }
1935
+ await cp(source, path5.join(target, "capabilities.json"));
1936
+ }
1937
+ var FRAMEWORK_PATCH_DIRECTORY = "patches";
1938
+ var THREE_PATCH_NAME = "three@0.185.1.patch";
1939
+ async function copyFrameworkPatches(target, templateRootDirectory) {
1940
+ const source = path5.join(
1941
+ path5.dirname(templateRootDirectory),
1942
+ "template-assets",
1943
+ FRAMEWORK_PATCH_DIRECTORY,
1944
+ THREE_PATCH_NAME
1945
+ );
1946
+ if (!existsSync(source)) {
1947
+ throw new Error(
1948
+ `TN_FRAMEWORK_PATCH_MISSING: '${source}' is not in the package; the generated project needs the Three.js velocity patch for batched temporal history.`
1949
+ );
1950
+ }
1951
+ const destination = path5.join(target, FRAMEWORK_PATCH_DIRECTORY, THREE_PATCH_NAME);
1952
+ await mkdir(path5.dirname(destination), { recursive: true });
1953
+ await cp(source, destination);
1954
+ }
141
1955
  var NODE_MODULES_PREFIX = "./node_modules/";
142
- var REQUIRED_MCP_SERVERS = ["threenative-assets", "threenative-sculpt"];
1956
+ var REQUIRED_MCP_SERVERS = Object.fromEntries(
1957
+ Object.entries(MCP_SERVERS).map(([name, server]) => [name, serverEntryPath(server)])
1958
+ );
143
1959
  function mcpPackageName(entry) {
144
1960
  const segments = entry.slice(NODE_MODULES_PREFIX.length).split("/");
145
1961
  return entry.startsWith(`${NODE_MODULES_PREFIX}@`) ? segments.slice(0, 2).join("/") : segments[0] ?? "";
146
1962
  }
147
1963
  async function assertMcpConfig(target) {
148
- const configPath = path.join(target, ".mcp.json");
1964
+ const configPath = path5.join(target, ".mcp.json");
149
1965
  const raw = await readFile(configPath, "utf8").catch(() => {
150
1966
  throw new Error(`Scaffold produced no .mcp.json at '${configPath}'.`);
151
1967
  });
@@ -153,12 +1969,12 @@ async function assertMcpConfig(target) {
153
1969
  if (mcpServers === void 0 || Object.keys(mcpServers).length === 0) {
154
1970
  throw new Error(`'${configPath}' declares no mcpServers.`);
155
1971
  }
156
- for (const name of REQUIRED_MCP_SERVERS) {
1972
+ for (const name of Object.keys(REQUIRED_MCP_SERVERS)) {
157
1973
  if (mcpServers[name] === void 0) {
158
1974
  throw new Error(`'${configPath}' is missing required MCP server '${name}'.`);
159
1975
  }
160
1976
  }
161
- const manifest = JSON.parse(await readFile(path.join(target, "package.json"), "utf8"));
1977
+ const manifest = JSON.parse(await readFile(path5.join(target, "package.json"), "utf8"));
162
1978
  const declared = /* @__PURE__ */ new Set([
163
1979
  ...Object.keys(manifest.dependencies ?? {}),
164
1980
  ...Object.keys(manifest.devDependencies ?? {})
@@ -185,6 +2001,22 @@ async function assertMcpConfig(target) {
185
2001
  }
186
2002
  }
187
2003
  }
2004
+ for (const [name, entry] of Object.entries(REQUIRED_MCP_SERVERS)) {
2005
+ if (mcpServers[name]?.args?.[0] !== entry) {
2006
+ throw new Error(
2007
+ `MCP server '${name}' must launch '${entry}', not '${mcpServers[name]?.args?.[0] ?? "nothing"}'.`
2008
+ );
2009
+ }
2010
+ }
2011
+ const codexPath = path5.join(target, ".codex", "config.toml");
2012
+ const codex = await readFile(codexPath, "utf8").catch(() => {
2013
+ throw new Error(`Scaffold produced no Codex MCP config at '${codexPath}'.`);
2014
+ });
2015
+ for (const [name, entry] of Object.entries(REQUIRED_MCP_SERVERS)) {
2016
+ if (!codex.includes(`[mcp_servers.${name}]`) || !codex.includes(`args = ["${entry}"]`)) {
2017
+ throw new Error(`'${codexPath}' does not wire required MCP server '${name}' to '${entry}'.`);
2018
+ }
2019
+ }
188
2020
  }
189
2021
  async function runInstall(target) {
190
2022
  await new Promise((resolve, reject) => {
@@ -196,68 +2028,137 @@ async function runInstall(target) {
196
2028
  });
197
2029
  });
198
2030
  }
199
- async function createProject(options, cwd = process.cwd()) {
200
- const manifests = discoverKitManifests();
201
- const template = options.template ?? "starter";
202
- if (!manifests.some(({ name }) => name === template)) kitManifest(template);
203
- const target = path.resolve(cwd, options.target);
2031
+ async function createProject(options, cwd = process.cwd(), root = templateRoot()) {
2032
+ const manifests = discoverKitManifests(root);
2033
+ const template = options.template ?? DEFAULT_TEMPLATE;
2034
+ if (!manifests.some(({ name }) => name === template)) kitManifest(template, root);
2035
+ const target = path5.resolve(cwd, options.target);
204
2036
  const targetExists = await isEmpty(target).catch(() => false);
205
2037
  if (!targetExists) {
206
2038
  throw new Error(`Target '${target}' already exists and is not empty.`);
207
2039
  }
208
2040
  await mkdir(target, { recursive: true });
209
- const source = path.join(templateRoot(), template);
2041
+ const source = path5.join(root, template);
210
2042
  await cp(source, target, { recursive: true, errorOnExist: true });
2043
+ await copyTemplateIcon(target, root);
2044
+ if (existsSync(path5.join(target, "gitignore"))) {
2045
+ await rename(path5.join(target, "gitignore"), path5.join(target, ".gitignore"));
2046
+ }
2047
+ await installAuthoringGitignore(target);
211
2048
  const projectName = packageName(target);
212
2049
  const compactProjectId = projectName.toLowerCase().replace(/[^a-z0-9]+/gu, "") || "game";
213
2050
  const projectId = /^[a-z]/u.test(compactProjectId) ? compactProjectId : `game${compactProjectId}`;
214
- await renderTemplate(
215
- target,
216
- Object.fromEntries([
217
- ["__PROJECT_NAME__", projectName],
218
- ["__PROJECT_ID__", projectId]
219
- ])
220
- );
2051
+ const replacements = Object.fromEntries([
2052
+ ["__PROJECT_NAME__", projectName],
2053
+ ["__PROJECT_ID__", projectId]
2054
+ ]);
2055
+ await stampTemplateLoading(target, source, root);
2056
+ await copyAgentFiles(target, root);
2057
+ await renderTemplate(target, replacements);
2058
+ await copyReferenceBundle(target, root, replacements);
2059
+ await copyCapabilityManifest(target, root);
2060
+ await copyFrameworkPatches(target, root);
221
2061
  await applyPackageSources(target, options.packageSources);
222
2062
  await assertMcpConfig(target);
2063
+ await assertReferenceBundle(target);
223
2064
  const installed = options.install ?? true;
224
2065
  if (installed) await runInstall(target);
225
2066
  return { installed, target, template };
226
2067
  }
227
- function readFlag(argv, name) {
228
- const index = argv.indexOf(name);
229
- return index === -1 ? void 0 : argv[index + 1];
2068
+ var PACKAGE_SOURCE_FLAG = /^--([a-z0-9-]+)-package$/u;
2069
+ var SCOPED_PACKAGE_FLAG_PREFIX = "threenative-";
2070
+ function packageNameFromFlag(flag) {
2071
+ const match = flag.match(PACKAGE_SOURCE_FLAG);
2072
+ if (match === null) return void 0;
2073
+ const suffix = match[1];
2074
+ if (suffix === void 0) return void 0;
2075
+ if (suffix.startsWith(SCOPED_PACKAGE_FLAG_PREFIX)) {
2076
+ const scopedSuffix = suffix.slice(SCOPED_PACKAGE_FLAG_PREFIX.length);
2077
+ return scopedSuffix.length === 0 ? void 0 : `@threenative/${scopedSuffix}`;
2078
+ }
2079
+ if (suffix === "runtime") return void 0;
2080
+ const unscoped = UNSCOPED_PACKAGE_FLAG_ALIASES[suffix];
2081
+ if (unscoped !== void 0) return unscoped;
2082
+ return `@threenative/${suffix}`;
230
2083
  }
2084
+ var BOOLEAN_FLAGS = /* @__PURE__ */ new Set(["--no-install", "--help", "-h"]);
2085
+ var VALUE_FLAGS = /* @__PURE__ */ new Set([
2086
+ "--template",
2087
+ "--genre",
2088
+ "--runtime-package",
2089
+ ...Object.values(PACKAGE_SOURCE_FLAGS)
2090
+ ]);
2091
+ var SCAFFOLD_USAGE = "Usage: pnpm create threenative my-game";
231
2092
  function parseArgs(argv) {
232
- const target = argv.find(
233
- (value, index) => !value.startsWith("-") && (index === 0 || !argv[index - 1]?.startsWith("--"))
234
- );
235
- if (target === void 0)
236
- throw new Error("Missing target directory. Usage: pnpm create threenative my-game");
237
- const template = readFlag(argv, "--template");
2093
+ const values = /* @__PURE__ */ new Map();
2094
+ const booleans = /* @__PURE__ */ new Set();
2095
+ const targets = [];
2096
+ for (let index = 0; index < argv.length; index += 1) {
2097
+ const token = argv[index] ?? "";
2098
+ if (!token.startsWith("-")) {
2099
+ targets.push(token);
2100
+ continue;
2101
+ }
2102
+ const equals = token.indexOf("=");
2103
+ const name = equals === -1 ? token : token.slice(0, equals);
2104
+ const inlineValue = equals === -1 ? void 0 : token.slice(equals + 1);
2105
+ if (BOOLEAN_FLAGS.has(name)) {
2106
+ if (inlineValue !== void 0)
2107
+ throw new Error(`Option '${name}' takes no value. ${SCAFFOLD_USAGE}`);
2108
+ booleans.add(name);
2109
+ continue;
2110
+ }
2111
+ if (!VALUE_FLAGS.has(name) && !PACKAGE_SOURCE_FLAG.test(name))
2112
+ throw new Error(`Unknown option '${name}'. ${SCAFFOLD_USAGE}`);
2113
+ const next = argv[index + 1];
2114
+ const value = inlineValue ?? next;
2115
+ if (value === void 0 || value.length === 0 || value.startsWith("-"))
2116
+ throw new Error(`Option '${name}' requires a value. ${SCAFFOLD_USAGE}`);
2117
+ values.set(name, value);
2118
+ if (inlineValue === void 0) index += 1;
2119
+ }
2120
+ const target = targets[0];
2121
+ if (target === void 0) throw new Error(`Missing target directory. ${SCAFFOLD_USAGE}`);
2122
+ if (targets.length > 1)
2123
+ throw new Error(`Unexpected extra argument '${targets.at(1)}'. ${SCAFFOLD_USAGE}`);
2124
+ const template = values.get("--template");
238
2125
  if (template !== void 0) kitManifest(template);
2126
+ const genre = values.get("--genre");
2127
+ if (template !== void 0 && genre !== void 0)
2128
+ throw new Error(`Options '--template' and '--genre' cannot be combined. ${SCAFFOLD_USAGE}`);
2129
+ const resolvedTemplate = genre === void 0 ? template : templateForGenre(genre);
239
2130
  const packageSources = {};
240
- for (const [name, flag] of [
241
- ["@threenative/core", "--core-package"],
242
- ["@threenative/physics", "--physics-package"],
243
- ["@threenative/playtest", "--playtest-package"],
244
- ["@threenative/runtime-native", "--runtime-native-package"],
245
- ["@threenative/studio", "--studio-package"],
246
- ["@threenative/ui", "--ui-package"],
247
- ["create-threenative", "--cli-package"]
248
- ]) {
249
- const source = readFlag(argv, flag);
2131
+ const knownPackageFlags = new Set(Object.values(PACKAGE_SOURCE_FLAGS));
2132
+ for (const [name, flag] of Object.entries(PACKAGE_SOURCE_FLAGS)) {
2133
+ const source = values.get(flag);
250
2134
  if (source !== void 0) packageSources[name] = source;
251
2135
  }
2136
+ for (const [flag, source] of values) {
2137
+ if (knownPackageFlags.has(flag)) continue;
2138
+ const name = packageNameFromFlag(flag);
2139
+ if (name !== void 0) packageSources[name] = source;
2140
+ }
2141
+ const shortRuntimeSource = values.get("--runtime-package");
2142
+ if (shortRuntimeSource !== void 0) {
2143
+ packageSources["@threenative/runtime-native"] = shortRuntimeSource;
2144
+ }
252
2145
  return {
253
- install: !argv.includes("--no-install"),
2146
+ install: !booleans.has("--no-install"),
254
2147
  target,
255
2148
  ...Object.keys(packageSources).length === 0 ? {} : { packageSources },
256
- ...template === void 0 ? {} : { template }
2149
+ ...resolvedTemplate === void 0 ? {} : { template: resolvedTemplate }
257
2150
  };
258
2151
  }
259
2152
  async function main() {
260
2153
  const argv = process.argv.slice(2);
2154
+ if (argv[0] === "inspect") {
2155
+ if (argv.includes("--help") || argv.includes("-h")) {
2156
+ process.stdout.write(inspectHelp());
2157
+ return;
2158
+ }
2159
+ await inspectCommand(argv.slice(1));
2160
+ return;
2161
+ }
261
2162
  if (argv.includes("--help") || argv.includes("-h")) {
262
2163
  process.stdout.write(cliHelp());
263
2164
  return;
@@ -265,15 +2166,13 @@ async function main() {
265
2166
  const result = await createProject(parseArgs(argv));
266
2167
  process.stdout.write(`Created ${result.template} project at ${result.target}
267
2168
  `);
268
- process.stdout.write(
269
- "Templates: minimal (smallest), starter (default), platformer. Choose with --template <name>.\n"
270
- );
2169
+ process.stdout.write(scaffoldCompletionMessage(discoverKitManifests()));
271
2170
  if (!result.installed)
272
2171
  process.stdout.write("Skipped install (--no-install). Run pnpm install, then pnpm dev.\n");
273
2172
  else process.stdout.write("Next: cd into the project and run pnpm dev.\n");
274
2173
  }
275
2174
  var entryPath = process.argv[1];
276
- if (entryPath !== void 0 && existsSync(entryPath) && realpathSync(path.resolve(entryPath)) === realpathSync(fileURLToPath(import.meta.url))) {
2175
+ if (entryPath !== void 0 && existsSync(entryPath) && realpathSync(path5.resolve(entryPath)) === realpathSync(fileURLToPath(import.meta.url))) {
277
2176
  main().catch((error) => {
278
2177
  process.stderr.write(`${error instanceof Error ? error.message : String(error)}
279
2178
  `);
@@ -281,4 +2180,4 @@ if (entryPath !== void 0 && existsSync(entryPath) && realpathSync(path.resolve(e
281
2180
  });
282
2181
  }
283
2182
 
284
- export { cliHelp, createProject, discoverKitManifests, discoverTemplateNames, kitManifest, parseArgs, templateRoot };
2183
+ export { SHARED_RENDER_SOURCES, canonicalLoadingPath, canonicalRenderSourcePath, cliHelp, createEngineFreshnessPlugin, createProject, createWebBrandPlugin, discoverKitManifests, discoverStampedTemplates, discoverTemplateNames, hashEngineDist, kitManifest, packageNameFromFlag, parseArgs, renderWebManifest, restampSharedRenderCopies, restampTemplateLoadingCopies, scaffoldCompletionMessage, stampLoadingSource, templateForGenre, templateRoot };