@joiner-platform/cli 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (303) hide show
  1. package/README.md +30 -2
  2. package/bundled-resources/poe-tile-templates/base/CLAUDE.md +72 -0
  3. package/bundled-resources/poe-tile-templates/base/README.md +7 -0
  4. package/bundled-resources/poe-tile-templates/base/_bunfig.toml +8 -0
  5. package/bundled-resources/poe-tile-templates/base/_gitignore +18 -0
  6. package/bundled-resources/poe-tile-templates/base/client.ts +12 -0
  7. package/bundled-resources/poe-tile-templates/base/package.json +36 -0
  8. package/bundled-resources/poe-tile-templates/base/playwright.config.ts +38 -0
  9. package/bundled-resources/poe-tile-templates/base/scripts/check-source.ts +148 -0
  10. package/bundled-resources/poe-tile-templates/base/scripts/dev.ts +19 -0
  11. package/bundled-resources/poe-tile-templates/base/scripts/doctor.sh +29 -0
  12. package/bundled-resources/poe-tile-templates/base/scripts/visual-check.ts +64 -0
  13. package/bundled-resources/poe-tile-templates/base/synced-store/backend-config.ts +9 -0
  14. package/bundled-resources/poe-tile-templates/base/synced-store/client-config.ts +8 -0
  15. package/bundled-resources/poe-tile-templates/base/synced-store/data/items.ts +16 -0
  16. package/bundled-resources/poe-tile-templates/base/synced-store/mutators/index.ts +10 -0
  17. package/bundled-resources/poe-tile-templates/base/synced-store/mutators/remove-todo.ts +5 -0
  18. package/bundled-resources/poe-tile-templates/base/synced-store/mutators/set-todo.ts +20 -0
  19. package/bundled-resources/poe-tile-templates/base/synced-store/mutators/types.ts +5 -0
  20. package/bundled-resources/poe-tile-templates/base/synced-store/mutators.test.ts +138 -0
  21. package/bundled-resources/poe-tile-templates/base/synced-store/schema.ts +40 -0
  22. package/bundled-resources/poe-tile-templates/base/tests/e2e.test.playwright.ts +92 -0
  23. package/bundled-resources/poe-tile-templates/base/tests/mobile-viewport.test.playwright.ts +111 -0
  24. package/bundled-resources/poe-tile-templates/base/tests/render-check.test.playwright.ts +128 -0
  25. package/bundled-resources/poe-tile-templates/base/tests/screenshot.test.playwright.ts +86 -0
  26. package/bundled-resources/poe-tile-templates/base/tests/setup-dom.ts +70 -0
  27. package/bundled-resources/poe-tile-templates/base/tile/src/backend.ts +3 -0
  28. package/bundled-resources/poe-tile-templates/base/tile/styles.css +47 -0
  29. package/bundled-resources/poe-tile-templates/base/tsconfig.json +13 -0
  30. package/bundled-resources/poe-tile-templates/coverage.config.json +6 -0
  31. package/bundled-resources/poe-tile-templates/index.ts +27 -0
  32. package/bundled-resources/poe-tile-templates/package.json +31 -0
  33. package/bundled-resources/poe-tile-templates/phaserjs/package.partial.json +6 -0
  34. package/bundled-resources/poe-tile-templates/phaserjs/tile/index.html +14 -0
  35. package/bundled-resources/poe-tile-templates/phaserjs/tile/src/entry.ts +35 -0
  36. package/bundled-resources/poe-tile-templates/phaserjs/ui/App.test.happydom.tsx +98 -0
  37. package/bundled-resources/poe-tile-templates/phaserjs/ui/App.ts +180 -0
  38. package/bundled-resources/poe-tile-templates/phaserjs/ui/phaser-scene.ts +174 -0
  39. package/bundled-resources/poe-tile-templates/phaserjs/vite.config.ts +28 -0
  40. package/bundled-resources/poe-tile-templates/preact/package.partial.json +9 -0
  41. package/bundled-resources/poe-tile-templates/preact/postcss.config.js +5 -0
  42. package/bundled-resources/poe-tile-templates/preact/tile/index.html +14 -0
  43. package/bundled-resources/poe-tile-templates/preact/tile/src/entry.tsx +36 -0
  44. package/bundled-resources/poe-tile-templates/preact/tile/styles.css +51 -0
  45. package/bundled-resources/poe-tile-templates/preact/tsconfig.json +15 -0
  46. package/bundled-resources/poe-tile-templates/preact/ui/App.test.happydom.tsx +69 -0
  47. package/bundled-resources/poe-tile-templates/preact/ui/App.tsx +116 -0
  48. package/bundled-resources/poe-tile-templates/preact/vite.config.ts +18 -0
  49. package/bundled-resources/poe-tile-templates/react/package.partial.json +12 -0
  50. package/bundled-resources/poe-tile-templates/react/postcss.config.js +5 -0
  51. package/bundled-resources/poe-tile-templates/react/tile/index.html +14 -0
  52. package/bundled-resources/poe-tile-templates/react/tile/src/entry.tsx +38 -0
  53. package/bundled-resources/poe-tile-templates/react/tile/styles.css +51 -0
  54. package/bundled-resources/poe-tile-templates/react/tsconfig.json +14 -0
  55. package/bundled-resources/poe-tile-templates/react/ui/App.test.happydom.tsx +71 -0
  56. package/bundled-resources/poe-tile-templates/react/ui/App.tsx +110 -0
  57. package/bundled-resources/poe-tile-templates/react/vite.config.ts +21 -0
  58. package/bundled-resources/poe-tile-templates/scripts/cleanup.ts +10 -0
  59. package/bundled-resources/poe-tile-templates/scripts/generate.ts +57 -0
  60. package/bundled-resources/poe-tile-templates/scripts/install-diagnostics.ts +52 -0
  61. package/bundled-resources/poe-tile-templates/scripts/paths.ts +7 -0
  62. package/bundled-resources/poe-tile-templates/scripts/sdk-dependency-key.ts +288 -0
  63. package/bundled-resources/poe-tile-templates/scripts/verify-all-sdks.ts +132 -0
  64. package/bundled-resources/poe-tile-templates/scripts/verify-local-sdk-command.ts +30 -0
  65. package/bundled-resources/poe-tile-templates/scripts/verify-local-sdk-tarball.ts +397 -0
  66. package/bundled-resources/poe-tile-templates/solidjs/_bunfig.toml +14 -0
  67. package/bundled-resources/poe-tile-templates/solidjs/package.partial.json +13 -0
  68. package/bundled-resources/poe-tile-templates/solidjs/postcss.config.js +5 -0
  69. package/bundled-resources/poe-tile-templates/solidjs/tests/solid-plugin.ts +49 -0
  70. package/bundled-resources/poe-tile-templates/solidjs/tile/index.html +14 -0
  71. package/bundled-resources/poe-tile-templates/solidjs/tile/src/entry.tsx +36 -0
  72. package/bundled-resources/poe-tile-templates/solidjs/tile/styles.css +51 -0
  73. package/bundled-resources/poe-tile-templates/solidjs/tsconfig.json +15 -0
  74. package/bundled-resources/poe-tile-templates/solidjs/ui/App.test.happydom.tsx +70 -0
  75. package/bundled-resources/poe-tile-templates/solidjs/ui/App.tsx +129 -0
  76. package/bundled-resources/poe-tile-templates/solidjs/vite.config.ts +18 -0
  77. package/bundled-resources/poe-tile-templates/tests/check-source.test.ts +131 -0
  78. package/bundled-resources/poe-tile-templates/tests/dev-script.test.slow.ts +166 -0
  79. package/bundled-resources/poe-tile-templates/tests/fixtures/customized-manager.ts +67 -0
  80. package/bundled-resources/poe-tile-templates/tests/fixtures/extended-mutators.ts.txt +106 -0
  81. package/bundled-resources/poe-tile-templates/tests/fixtures/multiplayer-verification.test.playwright.ts.txt +103 -0
  82. package/bundled-resources/poe-tile-templates/tests/fixtures/replace-starter-schema.ts +67 -0
  83. package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/phaserjs.tsx.txt +85 -0
  84. package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/preact.tsx.txt +69 -0
  85. package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/react.tsx.txt +73 -0
  86. package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/seating.ts.txt +54 -0
  87. package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/solidjs.tsx.txt +70 -0
  88. package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/vanilla-js.tsx.txt +85 -0
  89. package/bundled-resources/poe-tile-templates/tests/generated-templates.test.ts +278 -0
  90. package/bundled-resources/poe-tile-templates/tests/happy-dom-version.test.ts +27 -0
  91. package/bundled-resources/poe-tile-templates/tests/install-diagnostics.test.ts +99 -0
  92. package/bundled-resources/poe-tile-templates/tests/native-gesture-defaults.test.ts +23 -0
  93. package/bundled-resources/poe-tile-templates/tests/playwright-version.test.ts +84 -0
  94. package/bundled-resources/poe-tile-templates/tests/render-check-scaffold.test.ts +56 -0
  95. package/bundled-resources/poe-tile-templates/tests/sdk-dependency-key.test.ts +129 -0
  96. package/bundled-resources/poe-tile-templates/tests/visual-check.test.ts +90 -0
  97. package/bundled-resources/poe-tile-templates/vanilla-js/package.partial.json +3 -0
  98. package/bundled-resources/poe-tile-templates/vanilla-js/tile/index.html +14 -0
  99. package/bundled-resources/poe-tile-templates/vanilla-js/tile/src/entry.ts +35 -0
  100. package/bundled-resources/poe-tile-templates/vanilla-js/ui/App.test.happydom.tsx +96 -0
  101. package/bundled-resources/poe-tile-templates/vanilla-js/ui/App.ts +113 -0
  102. package/bundled-resources/poe-tile-templates/vanilla-js/vite.config.ts +17 -0
  103. package/cli.ts +134 -0
  104. package/index.ts +96 -0
  105. package/package.json +48 -5
  106. package/skills/audio-generation/.generated-by-poe-templated-docs +0 -0
  107. package/skills/audio-generation/SKILL.md +125 -0
  108. package/skills/finish-prototype/.generated-by-poe-templated-docs +0 -0
  109. package/skills/finish-prototype/SKILL.md +22 -0
  110. package/skills/help-me-build/.generated-by-poe-templated-docs +0 -0
  111. package/skills/help-me-build/SKILL.md +56 -0
  112. package/skills/image-generation/.generated-by-poe-templated-docs +0 -0
  113. package/skills/image-generation/SKILL.md +128 -0
  114. package/skills/one-shot/.generated-by-poe-templated-docs +0 -0
  115. package/skills/one-shot/SKILL.md +22 -0
  116. package/skills/platform-prototype/.generated-by-poe-templated-docs +0 -0
  117. package/skills/platform-prototype/SKILL.md +60 -0
  118. package/skills/platform-subagent/.generated-by-poe-templated-docs +0 -0
  119. package/skills/platform-subagent/SKILL.md +16 -0
  120. package/skills/poe-tiles-cli/.generated-by-poe-templated-docs +0 -0
  121. package/skills/poe-tiles-cli/SKILL.md +609 -0
  122. package/skills/poe-tiles-cli/references/device-motion.md +40 -0
  123. package/skills/poe-tiles-cli/references/player-updates.md +41 -0
  124. package/skills/prototype/.generated-by-poe-templated-docs +0 -0
  125. package/skills/prototype/SKILL.md +148 -0
  126. package/skills/publish/.generated-by-poe-templated-docs +0 -0
  127. package/skills/publish/SKILL.md +73 -0
  128. package/skills/synced-store/.generated-by-poe-templated-docs +0 -0
  129. package/skills/synced-store/SKILL.md +583 -0
  130. package/skills/synced-store/references/actions.md +85 -0
  131. package/skills/synced-store/references/api-patterns.md +245 -0
  132. package/skills/synced-store/references/architecture-scaling-and-performance.md +280 -0
  133. package/skills/synced-store/references/client-api-reference.md +263 -0
  134. package/skills/synced-store/references/data-visibility.md +95 -0
  135. package/skills/synced-store/references/external-stores.md +162 -0
  136. package/skills/synced-store/references/file-uploads.md +216 -0
  137. package/skills/synced-store/references/getting-user-info-of-members.md +228 -0
  138. package/skills/synced-store/references/limitations.md +72 -0
  139. package/skills/synced-store/references/live-data-limit-hook.md +131 -0
  140. package/skills/synced-store/references/mutator-rules.md +169 -0
  141. package/skills/synced-store/references/platform.md +49 -0
  142. package/skills/synced-store/references/schema-and-bindings.md +85 -0
  143. package/skills/synced-store/references/schema-libraries.md +57 -0
  144. package/skills/synced-store/references/schema-migrations.md +119 -0
  145. package/skills/synced-store/references/searchable-tables.md +27 -0
  146. package/skills/synced-store/references/server-forking.md +115 -0
  147. package/skills/synced-store/references/singleton-tables.md +61 -0
  148. package/skills/synced-store/references/sort-keys.md +253 -0
  149. package/skills/synced-store/references/ui-patterns.md +95 -0
  150. package/skills/tile-creator/.generated-by-poe-templated-docs +0 -0
  151. package/skills/tile-creator/SKILL.md +196 -0
  152. package/skills/tile-creator/references/assets.md +124 -0
  153. package/skills/tile-creator/references/backend-api.md +308 -0
  154. package/skills/tile-creator/references/cli-limitations.md +64 -0
  155. package/skills/tile-creator/references/cli.md +604 -0
  156. package/skills/tile-creator/references/client-api.md +2407 -0
  157. package/skills/tile-creator/references/composing-apps.md +166 -0
  158. package/skills/tile-creator/references/e2e-tests.md +55 -0
  159. package/skills/tile-creator/references/game-ux-best-practices.md +57 -0
  160. package/skills/tile-creator/references/migrating-pre-rename-tiles.md +79 -0
  161. package/skills/tile-creator/references/multiplayer-api-recipe.md +205 -0
  162. package/skills/tile-creator/references/native-results.md +100 -0
  163. package/skills/tile-creator/references/platform-integration.md +201 -0
  164. package/skills/tile-creator/references/power-report.md +199 -0
  165. package/skills/tile-creator/references/publish-rollout.md +166 -0
  166. package/skills/tile-creator/references/publishing.md +33 -0
  167. package/skills/tile-creator/references/push-notification-guidelines.md +58 -0
  168. package/skills/tile-creator/references/render-check.md +266 -0
  169. package/skills/tile-creator/references/running-the-client-api-on-a-server-owned-by-the-user.md +95 -0
  170. package/skills/tile-creator/references/safe-area-insets.md +79 -0
  171. package/skills/tile-creator/references/sandbox-limitations.md +32 -0
  172. package/skills/tile-creator/references/scaffolded-tile-folder-structure.md +48 -0
  173. package/skills/tile-creator/references/scaffolding-a-new-app.md +202 -0
  174. package/skills/tile-creator/references/simulations.md +125 -0
  175. package/skills/tile-creator/references/synced-store-client-reference.md +92 -0
  176. package/skills/tile-creator/references/troubleshooting.md +22 -0
  177. package/skills/tile-creator/references/turn-based-mutator.md +43 -0
  178. package/skills/tile-creator/references/user-erasure.md +14 -0
  179. package/skills/tile-creator/references/vite-plugin.md +166 -0
  180. package/skills/tile-creator/references/workspace-retention.md +72 -0
  181. package/src/admin-conversions-client.ts +28 -0
  182. package/src/admin-reviews-client.ts +36 -0
  183. package/src/api.generated.ts +1527 -0
  184. package/src/auth-token.ts +198 -0
  185. package/src/bounded-read.ts +35 -0
  186. package/src/bun-version.ts +33 -0
  187. package/src/checkout-base.ts +207 -0
  188. package/src/cli-bun-version.ts +16 -0
  189. package/src/cli-env.ts +28 -0
  190. package/src/cli-name.ts +23 -0
  191. package/src/client.ts +2474 -0
  192. package/src/collect-files.ts +226 -0
  193. package/src/commands/accounts.ts +55 -0
  194. package/src/commands/admin-abandon-conversion.ts +60 -0
  195. package/src/commands/admin-reviews.ts +66 -0
  196. package/src/commands/admin.ts +219 -0
  197. package/src/commands/auth.ts +89 -0
  198. package/src/commands/checkout-prototype.ts +67 -0
  199. package/src/commands/creator-source-capability.ts +11 -0
  200. package/src/commands/doctor-bun.ts +145 -0
  201. package/src/commands/doctor-command.ts +64 -0
  202. package/src/commands/doctor-package-json.ts +47 -0
  203. package/src/commands/doctor-sdk-pin.ts +156 -0
  204. package/src/commands/doctor-store-keys-lexer.ts +213 -0
  205. package/src/commands/doctor-store-keys-scan.ts +262 -0
  206. package/src/commands/doctor-store-keys.ts +196 -0
  207. package/src/commands/doctor.ts +371 -0
  208. package/src/commands/init/blank-scaffold-templates.ts +397 -0
  209. package/src/commands/init/index.ts +170 -0
  210. package/src/commands/init/internal-toolchain.ts +49 -0
  211. package/src/commands/init/manager-test-template.ts +107 -0
  212. package/src/commands/init/multiplayer-test-template.ts +217 -0
  213. package/src/commands/init/name-input.tsx +167 -0
  214. package/src/commands/init/no-store-scaffold-templates.ts +281 -0
  215. package/src/commands/init/no-store-scaffold.ts +134 -0
  216. package/src/commands/init/package-json-scripts.ts +72 -0
  217. package/src/commands/init/scaffold.ts +960 -0
  218. package/src/commands/init/sdk-tarball-url.generated.ts +4 -0
  219. package/src/commands/init/sdk-tarball-url.ts +31 -0
  220. package/src/commands/init/template-picker.tsx +147 -0
  221. package/src/commands/inspect-child-entry.ts +107 -0
  222. package/src/commands/inspect-contract.ts +87 -0
  223. package/src/commands/inspect-freshness.ts +217 -0
  224. package/src/commands/inspect-lock.ts +201 -0
  225. package/src/commands/inspect-options.ts +360 -0
  226. package/src/commands/inspect-orchestrate.ts +375 -0
  227. package/src/commands/inspect-process.ts +172 -0
  228. package/src/commands/inspect-ready.ts +65 -0
  229. package/src/commands/inspect-report.ts +235 -0
  230. package/src/commands/inspect-run-state.ts +296 -0
  231. package/src/commands/inspect-run.ts +157 -0
  232. package/src/commands/inspect-watchdog.ts +74 -0
  233. package/src/commands/install-joiner.ts +208 -0
  234. package/src/commands/login.ts +308 -0
  235. package/src/commands/models.ts +40 -0
  236. package/src/commands/parse-options.ts +36 -0
  237. package/src/commands/remix-package-json.ts +64 -0
  238. package/src/commands/remix.ts +379 -0
  239. package/src/commands/sdk-url.ts +141 -0
  240. package/src/commands/simulations.ts +133 -0
  241. package/src/commands/skills.ts +108 -0
  242. package/src/commands/store-files.ts +92 -0
  243. package/src/commands/stores.ts +703 -0
  244. package/src/commands/tiles-channel-commands.ts +115 -0
  245. package/src/commands/tiles-checkout.ts +351 -0
  246. package/src/commands/tiles-gallery-command.ts +95 -0
  247. package/src/commands/tiles-get-helpers.ts +27 -0
  248. package/src/commands/tiles-inspect.ts +276 -0
  249. package/src/commands/tiles-power-command.ts +308 -0
  250. package/src/commands/tiles-power-format.ts +396 -0
  251. package/src/commands/tiles-power-versions.ts +299 -0
  252. package/src/commands/tiles-publish-helpers.ts +145 -0
  253. package/src/commands/tiles-upload-command.ts +277 -0
  254. package/src/commands/tiles-version-commands.ts +201 -0
  255. package/src/commands/tiles-visibility-command.ts +103 -0
  256. package/src/commands/tiles.ts +257 -0
  257. package/src/commands/upgrade.ts +307 -0
  258. package/src/commit-in-progress.ts +42 -0
  259. package/src/creator-source-context.ts +97 -0
  260. package/src/creator-source-publish.ts +52 -0
  261. package/src/deferred-assets.ts +125 -0
  262. package/src/distribution.ts +28 -0
  263. package/src/errors.ts +61 -0
  264. package/src/install-command.ts +43 -0
  265. package/src/output.ts +62 -0
  266. package/src/poe-tile-config-files.ts +100 -0
  267. package/src/poe-tile-config-players.ts +168 -0
  268. package/src/poe-tile-config-remix.ts +166 -0
  269. package/src/poe-tile-config.ts +831 -0
  270. package/src/power-report-client.ts +55 -0
  271. package/src/prototype-startup.ts +21 -0
  272. package/src/publish-change-summary.ts +55 -0
  273. package/src/publish-overrides-validation.ts +49 -0
  274. package/src/publish-pack.ts +167 -0
  275. package/src/publish-phases.ts +57 -0
  276. package/src/publish-retry.ts +51 -0
  277. package/src/publish-tile-from-config.ts +434 -0
  278. package/src/recorder-stream.ts +169 -0
  279. package/src/remix-provenance.ts +156 -0
  280. package/src/resolve-client-credential.ts +71 -0
  281. package/src/resolve-media-uploads.ts +147 -0
  282. package/src/sdk-dependency.ts +54 -0
  283. package/src/sdk-skills.ts +85 -0
  284. package/src/should-skip-client-setup.ts +20 -0
  285. package/src/simulation-snapshot.ts +123 -0
  286. package/src/simulation-types.ts +74 -0
  287. package/src/simulations-client.ts +112 -0
  288. package/src/source-bundle.ts +466 -0
  289. package/src/staged-publish-cleanup.ts +44 -0
  290. package/src/staged-publish-deferred.ts +160 -0
  291. package/src/staged-publish.ts +401 -0
  292. package/src/store-file-upload.ts +268 -0
  293. package/src/store-request.ts +168 -0
  294. package/src/tar-canonical.ts +41 -0
  295. package/src/tar-extensions.ts +159 -0
  296. package/src/tar-extract.ts +193 -0
  297. package/src/tar-parse.ts +224 -0
  298. package/src/tar.ts +231 -0
  299. package/src/template-check-scripts.ts +18 -0
  300. package/src/tile-gallery-client.ts +82 -0
  301. package/src/types.ts +258 -0
  302. package/src/upload-concurrency.ts +54 -0
  303. package/src/whole-tile.ts +52 -0
@@ -0,0 +1,397 @@
1
+ // owner: jyoung-q
2
+
3
+ import type { TemplateName } from "./scaffold.js";
4
+
5
+ /**
6
+ * Per-framework entry pieces. `frameworkImport` is the bare renderer package
7
+ * (empty when the template mounts by hand) and `appImport` is the `../../ui/App`
8
+ * line. They are kept apart because biome's `organizeImports` sorts the bare
9
+ * package above `../../client`, and the app import below it — emitting them as
10
+ * one block would fail the scaffold's own lint on its first run.
11
+ */
12
+ const BLANK_ENTRY_RENDERERS: Record<
13
+ TemplateName,
14
+ { frameworkImport: string; appImport: string; renderCall: string }
15
+ > = {
16
+ preact: {
17
+ frameworkImport: `import { render } from "preact";`,
18
+ appImport: `import { App } from "../../ui/App";`,
19
+ renderCall: "render(<App {...appProps} />, appRoot);",
20
+ },
21
+ react: {
22
+ frameworkImport: `import { createRoot } from "react-dom/client";`,
23
+ appImport: `import { App } from "../../ui/App";`,
24
+ renderCall: "createRoot(appRoot).render(<App {...appProps} />);",
25
+ },
26
+ solidjs: {
27
+ frameworkImport: `import { render } from "solid-js/web";`,
28
+ appImport: `import { App } from "../../ui/App";`,
29
+ renderCall: "render(() => <App {...appProps} />, appRoot);",
30
+ },
31
+ "vanilla-js": {
32
+ frameworkImport: "",
33
+ appImport: `import { mountApp } from "../../ui/App";`,
34
+ renderCall: "mountApp(appRoot, appProps);",
35
+ },
36
+ phaserjs: {
37
+ frameworkImport: "",
38
+ appImport: `import { mountApp } from "../../ui/App";`,
39
+ renderCall: "mountApp(appRoot, appProps);",
40
+ },
41
+ };
42
+
43
+ export function blankEntryFor(template: TemplateName): string {
44
+ const renderer = BLANK_ENTRY_RENDERERS[template];
45
+ return `/**
46
+ * Entry point — the only file that imports joiner-sdk.
47
+ */
48
+ import {
49
+ applyNativeAppGestureOverrides,
50
+ createPoe,
51
+ createVerticalScrollBounceMount,
52
+ PostMessageEnvironment,
53
+ resumeAudioContext,
54
+ suppressLongPressMagnifier,
55
+ } from "joiner-sdk/v1/client.js";
56
+ ${renderer.frameworkImport === "" ? "" : `${renderer.frameworkImport}\n`}import { tileClientConfig } from "../../client";
57
+ ${renderer.appImport}
58
+ import type { AppProps } from "../../ui/app-contract";
59
+
60
+ // Suppress native WebView text selection, callouts, and link dragging so
61
+ // touch interactions behave like an app, not a web page.
62
+ applyNativeAppGestureOverrides();
63
+
64
+ const environment = new PostMessageEnvironment();
65
+ const Poe = createPoe({ environment });
66
+ const store = Poe.setupStore(tileClientConfig);
67
+ const appProps = {
68
+ store,
69
+ poe: Poe,
70
+ resumeAudioContext,
71
+ suppressLongPressMagnifier,
72
+ } satisfies AppProps;
73
+
74
+ const root = document.getElementById("root");
75
+ if (root) {
76
+ const appRoot = createVerticalScrollBounceMount(root);
77
+ ${renderer.renderCall}
78
+ }
79
+ `;
80
+ }
81
+
82
+ export const BLANK_APP_CONTRACT_TS = `import type {
83
+ PoeAPI,
84
+ resumeAudioContext,
85
+ suppressLongPressMagnifier,
86
+ } from "joiner-sdk/v1/client.js";
87
+ import type { AppStoreClient } from "../client";
88
+
89
+ /**
90
+ * Runtime dependencies supplied by the entry point. Keep this shared with the
91
+ * test-props helper when the app needs another platform capability.
92
+ */
93
+ export interface AppProps {
94
+ store: AppStoreClient;
95
+ poe: PoeAPI;
96
+ resumeAudioContext: typeof resumeAudioContext;
97
+ suppressLongPressMagnifier: typeof suppressLongPressMagnifier;
98
+ }
99
+ `;
100
+
101
+ export const BLANK_TEST_APP_PROPS_TS = `import type { PoeTileTestClient } from "joiner-sdk/v1/test-utils.js";
102
+ import type { AppSchema } from "../synced-store/schema";
103
+ import type { AppProps } from "../ui/app-contract";
104
+
105
+ /** Build the same typed App props as the production entry, with safe DOM-test stubs. */
106
+ export function createTestAppProps(
107
+ client: PoeTileTestClient<AppSchema>,
108
+ ): AppProps {
109
+ return {
110
+ store: client.store,
111
+ poe: client.Poe,
112
+ resumeAudioContext: () => undefined,
113
+ suppressLongPressMagnifier: () => () => undefined,
114
+ };
115
+ }
116
+ `;
117
+
118
+ export function blankAppFor({
119
+ template,
120
+ appName,
121
+ }: {
122
+ template: TemplateName;
123
+ appName: string;
124
+ }): string {
125
+ const heading = `Hello, ${appName}`;
126
+ const noteLine1 = "Edit ui/App and synced-store/schema.ts to build your app.";
127
+ const noteLine2 = "For multi-player game patterns, see poe-tiles/spy-words.";
128
+ if (template === "react") {
129
+ return `import { useLiveQuery } from "joiner-sdk/v1/react";
130
+ import type { AppReadContext } from "../client";
131
+ import type { AppProps } from "./app-contract";
132
+
133
+ // Keep reusable readers at module scope so useLiveQuery retains one stable
134
+ // subscription. AppReadContext includes app tables and Poe system tables.
135
+ async function readRoster(ctx: AppReadContext) {
136
+ return {
137
+ players: await ctx.table("players").scan().values().toArray(),
138
+ members: (await ctx.table("$users").scan().values().toArray()).filter(
139
+ (member) => member.removedAt === undefined,
140
+ ),
141
+ profiles: await ctx.table("$userInfo").scan().values().toArray(),
142
+ currentUserId: ctx.userId,
143
+ };
144
+ }
145
+
146
+ export function App({ store }: AppProps) {
147
+ const { data } = useLiveQuery(store, readRoster);
148
+ return (
149
+ <div>
150
+ <h1 id="app-heading">${heading}</h1>
151
+ <p data-testid="connected-player-count">
152
+ {data?.members.length ?? 0} connected players
153
+ </p>
154
+ <p>
155
+ ${noteLine1}
156
+ <br />
157
+ ${noteLine2}
158
+ </p>
159
+ </div>
160
+ );
161
+ }
162
+ `;
163
+ }
164
+ if (template === "preact") {
165
+ return `import { useEffect, useState } from "preact/hooks";
166
+ import type { AppReadContext } from "../client";
167
+ import type { AppProps } from "./app-contract";
168
+
169
+ async function readRoster(ctx: AppReadContext) {
170
+ return {
171
+ players: await ctx.table("players").scan().values().toArray(),
172
+ members: (await ctx.table("$users").scan().values().toArray()).filter(
173
+ (member) => member.removedAt === undefined,
174
+ ),
175
+ profiles: await ctx.table("$userInfo").scan().values().toArray(),
176
+ currentUserId: ctx.userId,
177
+ };
178
+ }
179
+
180
+ export function App({ store }: AppProps) {
181
+ const [roster, setRoster] = useState<
182
+ Awaited<ReturnType<typeof readRoster>> | undefined
183
+ >();
184
+ useEffect(() => store.subscribe(readRoster, setRoster), [store]);
185
+ return (
186
+ <div>
187
+ <h1 id="app-heading">${heading}</h1>
188
+ <p data-testid="connected-player-count">
189
+ {roster?.members.length ?? 0} connected players
190
+ </p>
191
+ <p>
192
+ ${noteLine1}
193
+ <br />
194
+ ${noteLine2}
195
+ </p>
196
+ </div>
197
+ );
198
+ }
199
+ `;
200
+ }
201
+ if (template === "solidjs") {
202
+ return `import { createLiveQueryResource } from "joiner-sdk/v1/solid";
203
+ import { Suspense } from "solid-js";
204
+ import type { AppReadContext } from "../client";
205
+ import type { AppProps } from "./app-contract";
206
+
207
+ async function readRoster(ctx: AppReadContext) {
208
+ return {
209
+ players: await ctx.table("players").scan().values().toArray(),
210
+ members: (await ctx.table("$users").scan().values().toArray()).filter(
211
+ (member) => member.removedAt === undefined,
212
+ ),
213
+ profiles: await ctx.table("$userInfo").scan().values().toArray(),
214
+ currentUserId: ctx.userId,
215
+ };
216
+ }
217
+
218
+ export function App(props: AppProps) {
219
+ const roster = createLiveQueryResource(
220
+ () => props.store,
221
+ () => readRoster,
222
+ );
223
+ return (
224
+ <div>
225
+ <h1 id="app-heading">${heading}</h1>
226
+ <Suspense fallback={<p>Loading players…</p>}>
227
+ <p data-testid="connected-player-count">
228
+ {roster.data()?.members.length ?? 0} connected players
229
+ </p>
230
+ </Suspense>
231
+ <p>
232
+ ${noteLine1}
233
+ <br />
234
+ ${noteLine2}
235
+ </p>
236
+ </div>
237
+ );
238
+ }
239
+ `;
240
+ }
241
+ return `import type { AppReadContext } from "../client";
242
+ import type { AppProps } from "./app-contract";
243
+
244
+ async function readRoster(ctx: AppReadContext) {
245
+ return {
246
+ players: await ctx.table("players").scan().values().toArray(),
247
+ members: (await ctx.table("$users").scan().values().toArray()).filter(
248
+ (member) => member.removedAt === undefined,
249
+ ),
250
+ profiles: await ctx.table("$userInfo").scan().values().toArray(),
251
+ currentUserId: ctx.userId,
252
+ };
253
+ }
254
+
255
+ export function mountApp(root: HTMLElement, props: AppProps): void {
256
+ root.innerHTML = \`
257
+ <div>
258
+ <h1 id="app-heading">${heading}</h1>
259
+ <p data-testid="connected-player-count">0 connected players</p>
260
+ <p>${noteLine1}<br>${noteLine2}</p>
261
+ </div>
262
+ \`;
263
+ const count = root.querySelector<HTMLElement>(
264
+ '[data-testid="connected-player-count"]',
265
+ );
266
+ props.store.subscribe(readRoster, (roster) => {
267
+ if (count) count.textContent = \`\${roster.members.length} connected players\`;
268
+ });
269
+ }
270
+ `;
271
+ }
272
+
273
+ const COMPONENT_FRAMEWORKS = new Set<TemplateName>([
274
+ "react",
275
+ "preact",
276
+ "solidjs",
277
+ ]);
278
+
279
+ export function blankHappyDomTestFor(template: TemplateName): string {
280
+ const isComponentFramework = COMPONENT_FRAMEWORKS.has(template);
281
+ const jsxDirective =
282
+ template === "solidjs" ? "/** @jsxImportSource solid-js */\n" : "";
283
+ // Import lines are emitted in biome's `organizeImports` order: `bun:test`,
284
+ // the bare testing-library package, the SDK, the `../` app modules, then the
285
+ // `./App` sibling last. A scaffold committed with `--internal-mono-repo` is
286
+ // linted by this repo, so the emitted order has to be the sorted one.
287
+ let testingLibraryImport: string;
288
+ let appImport: string;
289
+ let renderApp: string;
290
+ let cleanupApp: string;
291
+ if (template === "react") {
292
+ testingLibraryImport =
293
+ 'import { cleanup, render, waitFor } from "@testing-library/react";';
294
+ appImport = 'import { App } from "./App";';
295
+ renderApp =
296
+ "({ container } = render(<App {...createTestAppProps(aliceClient)} />));";
297
+ cleanupApp = "cleanup();\n\t\tcontainer.remove();";
298
+ } else if (template === "preact") {
299
+ testingLibraryImport =
300
+ 'import { cleanup, render, waitFor } from "@testing-library/preact";';
301
+ appImport = 'import { App } from "./App";';
302
+ renderApp =
303
+ "({ container } = render(<App {...createTestAppProps(aliceClient)} />));";
304
+ cleanupApp = "cleanup();\n\t\tcontainer.remove();";
305
+ } else if (template === "solidjs") {
306
+ testingLibraryImport =
307
+ 'import { cleanup, render, waitFor } from "@solidjs/testing-library";';
308
+ appImport = 'import { App } from "./App";';
309
+ // The formatter breaks this arrow body onto its own line; emitting the
310
+ // single-line form would fail the scaffold's own `format:check`.
311
+ renderApp = `({ container } = render(() => (
312
+ <App {...createTestAppProps(aliceClient)} />
313
+ )));`;
314
+ cleanupApp = "cleanup();\n\t\tcontainer.remove();";
315
+ } else {
316
+ testingLibraryImport = "";
317
+ appImport = 'import { mountApp } from "./App";';
318
+ renderApp = `document.body.appendChild(container);
319
+ mountApp(container, createTestAppProps(aliceClient));`;
320
+ cleanupApp = "container.remove();";
321
+ }
322
+ // Non-component templates have no testing-library `waitFor`, so the
323
+ // generated test ships its own. It yields with the SDK's `tick()` rather
324
+ // than a raw `setTimeout(..., 0)`: `tick()` awaits a microtask AND a
325
+ // macrotask (so store I/O callbacks actually run), and it is the only
326
+ // sanctioned form — the repo's `.grit/no-settimeout-in-tests` Biome plugin
327
+ // errors on `setTimeout` in any file, including scaffolds committed here
328
+ // with `--internal-mono-repo`. It retries by recursion rather than a loop
329
+ // because the repo's `noAwaitInLoops` rule bans `await` inside a loop body.
330
+ const waitForHelper = isComponentFramework
331
+ ? ""
332
+ : `
333
+ async function waitFor(
334
+ assertion: () => void,
335
+ timeoutMs = 2_000,
336
+ ): Promise<void> {
337
+ const deadline = Date.now() + timeoutMs;
338
+ const attempt = async (): Promise<void> => {
339
+ try {
340
+ assertion();
341
+ } catch (error) {
342
+ if (Date.now() >= deadline) throw error;
343
+ await tick();
344
+ return attempt();
345
+ }
346
+ };
347
+ return attempt();
348
+ }
349
+ `;
350
+ const containerType = template === "preact" ? "Element" : "HTMLElement";
351
+
352
+ const harnessImports = isComponentFramework
353
+ ? "createPoeTileTestHarness"
354
+ : "createPoeTileTestHarness, tick";
355
+
356
+ // Component frameworks rebind `container` from the render result; the
357
+ // vanilla/Phaser mount path never reassigns it, and `useConst` rejects a
358
+ // `let` that is only ever read.
359
+ const containerBinding = isComponentFramework ? "let" : "const";
360
+
361
+ return `${jsxDirective}import { expect, test } from "bun:test";
362
+ ${testingLibraryImport === "" ? "" : `${testingLibraryImport}\n`}import { ${harnessImports} } from "joiner-sdk/v1/test-utils.js";
363
+ import { tileBackendConfig } from "../synced-store/backend-config";
364
+ import type { AppSchema } from "../synced-store/schema";
365
+ import { createTestAppProps } from "../tests/app-test-props";
366
+ ${appImport}
367
+ ${waitForHelper}
368
+ test("renders with a real two-client store and configured DOM matchers", async () => {
369
+ const harness = createPoeTileTestHarness<AppSchema>({
370
+ store: { backendConfig: tileBackendConfig },
371
+ });
372
+ ${containerBinding} container: ${containerType} = document.createElement("div");
373
+ try {
374
+ const aliceClient = await harness.createClient({ userId: "alice" });
375
+ await harness.createClient({ userId: "bob" });
376
+ ${renderApp}
377
+
378
+ // Add assertions for your app's behavior as you implement it.
379
+ await waitFor(() => {
380
+ expect(container).not.toBeEmptyDOMElement();
381
+ });
382
+
383
+ const control = document.createElement("button");
384
+ control.disabled = true;
385
+ control.setAttribute("data-state", "ready");
386
+ container.appendChild(control);
387
+ expect(control).toBeInTheDocument();
388
+ expect(control).toBeDisabled();
389
+ expect(control).toHaveAttribute("data-state", "ready");
390
+ expect(control).not.toHaveAttribute("aria-hidden");
391
+ } finally {
392
+ ${cleanupApp}
393
+ harness.dispose();
394
+ }
395
+ });
396
+ `;
397
+ }
@@ -0,0 +1,170 @@
1
+ // owner: jyoung-q
2
+ /**
3
+ * `poe-tiles tiles init` command.
4
+ *
5
+ * Scaffolds a new Poe app from a template. Both prompts (name + template)
6
+ * mount through Ink when the user is running interactively; passing
7
+ * `<app-name>` and/or `--template` skips the corresponding prompt and
8
+ * keeps the CLI fully scriptable. The Ink modules are dynamically
9
+ * imported so non-interactive runs don't pay the load cost.
10
+ */
11
+
12
+ import { resolve } from "node:path";
13
+ import { Command } from "commander";
14
+ import { assertSupportedCliBun } from "../../cli-bun-version.js";
15
+ import { CliError } from "../../errors.js";
16
+ import {
17
+ defaultPoeTileConfig,
18
+ writePoeTileConfig,
19
+ } from "../../poe-tile-config.js";
20
+ import {
21
+ INVALID_NAME_HINT,
22
+ scaffoldApp,
23
+ TEMPLATES,
24
+ type TemplateName,
25
+ VALID_NAME_MAX_LENGTH,
26
+ VALID_NAME_RE,
27
+ } from "./scaffold.js";
28
+
29
+ /**
30
+ * Optional injection seam for tests so the dynamic-import branches that
31
+ * mount the Ink prompts can be exercised without a real TTY. Production
32
+ * callers pass nothing.
33
+ */
34
+ export interface InitPrompters {
35
+ pickName?: (parentDir: string) => Promise<string>;
36
+ pickTemplate?: () => Promise<TemplateName>;
37
+ }
38
+
39
+ export function createInitCommand(prompters: InitPrompters = {}): Command {
40
+ return (
41
+ new Command("init")
42
+ .description("Initialize a new Joiner tile from a template")
43
+ .argument("[app-name]", "App name (lowercase alphanumeric + hyphens)")
44
+ .option(
45
+ "-t, --template <template>",
46
+ `Template to use (${TEMPLATES.join(", ")})`,
47
+ )
48
+ .option(
49
+ "--workspace-sdk",
50
+ 'Resolve joiner-sdk via workspace dependency ("workspace:*") instead of the published tarball. Useful when scaffolding into the monorepo.',
51
+ )
52
+ .option(
53
+ "--internal-mono-repo",
54
+ "Tune the scaffold for an app in the internal ai-app monorepo: forces joiner-sdk=workspace:*, adds lint/format:check scripts, pins zod to the syncpack-enforced version, and generates a tsconfig that extends the monorepo root. Implies --workspace-sdk.",
55
+ )
56
+ .option(
57
+ "--output-dir <path>",
58
+ "Parent directory for the new app (defaults to current directory)",
59
+ )
60
+ .option(
61
+ "--no-skills",
62
+ "Skip copying SDK skills into `.claude/skills/` and `.agents/skills/`. Default: skills are copied. Pass `--no-skills` for in-monorepo apps (the monorepo already ships these skills at the repo root, so a per-app copy is noise).",
63
+ )
64
+ .option(
65
+ "--no-blank",
66
+ "Keep the todo-list example code instead of the minimal multiplayer starter. By default, the scaffold includes typed system-table reads, deterministic seating hooks, and executable Happy DOM behavior tests. Pass `--no-blank` only when you specifically want the todo example as a starting point.",
67
+ )
68
+ .option(
69
+ "--no-store",
70
+ "Experimental. Scaffold without synced-store: no synced-store/, client.ts, backend entry, mutator test, or e2e tests. The app keeps state in memory only, and the generated .poe-tile.json has no sourceBundle block. Use for throwaway prototypes; scaffold without this flag for a shared or durable tile.",
71
+ )
72
+ // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: Existing function exceeds the cognitive-complexity limit; keep the rule enabled for new code.
73
+ .action(async function (
74
+ this: Command,
75
+ appNameArg?: string,
76
+ opts?: {
77
+ template?: string;
78
+ workspaceSdk?: boolean;
79
+ internalMonoRepo?: boolean;
80
+ outputDir?: string;
81
+ skills?: boolean;
82
+ blank?: boolean;
83
+ store?: boolean;
84
+ },
85
+ ) {
86
+ assertSupportedCliBun(Bun.version, {
87
+ internalMonoRepo: opts?.internalMonoRepo,
88
+ });
89
+ const parentDir = opts?.outputDir ?? process.cwd();
90
+ const noStore = opts?.store === false;
91
+
92
+ let appName: string;
93
+ if (appNameArg) {
94
+ appName = appNameArg.trim();
95
+ if (
96
+ !VALID_NAME_RE.test(appName) ||
97
+ appName.length > VALID_NAME_MAX_LENGTH
98
+ ) {
99
+ throw new CliError(
100
+ `Invalid app name "${appName}". ${INVALID_NAME_HINT}`,
101
+ );
102
+ }
103
+ } else {
104
+ // Dynamic import so non-interactive runs (which pass an
105
+ // app-name argument) don't pay the Ink + React load cost.
106
+ const pickName =
107
+ prompters.pickName ?? (await import("./name-input.js")).pickName;
108
+ appName = await pickName(parentDir);
109
+ }
110
+
111
+ let template: TemplateName;
112
+ if (opts?.template) {
113
+ if (!TEMPLATES.includes(opts.template as TemplateName)) {
114
+ throw new CliError(
115
+ `Unknown template "${opts.template}". Available: ${TEMPLATES.join(", ")}`,
116
+ );
117
+ }
118
+ template = opts.template as TemplateName;
119
+ } else {
120
+ const pickTemplate =
121
+ prompters.pickTemplate ??
122
+ (await import("./template-picker.js")).pickTemplate;
123
+ template = await pickTemplate();
124
+ }
125
+
126
+ const outputDir = resolve(parentDir, appName);
127
+
128
+ scaffoldApp({
129
+ appName,
130
+ template,
131
+ outputDir,
132
+ ...(opts?.workspaceSdk ? { sdkVersion: "workspace:*" } : {}),
133
+ ...(opts?.internalMonoRepo ? { internalMonoRepo: true } : {}),
134
+ includeSkill: opts?.skills !== false,
135
+ blank: opts?.blank !== false,
136
+ ...(noStore ? { noStore: true } : {}),
137
+ });
138
+
139
+ // Drop a `.poe-tile.json` at the new app's root so subsequent
140
+ // `tiles upload` calls in this directory pick up the right handle
141
+ // without flags. The default includes a public `sourceBundle`
142
+ // block — scaffolded apps upload source by default so the
143
+ // platform's edit/remix flows can reach them. Creators flip
144
+ // `sourceBundle.visibility` to `"owner_only"` or delete the
145
+ // block entirely to opt out. A store-less scaffold (`--no-store`) is a
146
+ // prototype shape and ships no source bundle.
147
+ writePoeTileConfig(
148
+ outputDir,
149
+ defaultPoeTileConfig({ handle: appName, sourceBundle: !noStore }),
150
+ );
151
+
152
+ process.stdout.write(
153
+ `\nCreated ${appName} with template "${template}".\n\n`,
154
+ );
155
+ process.stdout.write("Next steps:\n");
156
+ process.stdout.write(` cd ${appName}\n`);
157
+ process.stdout.write(" bun install\n");
158
+ process.stdout.write(" bun run doctor\n");
159
+ process.stdout.write(" bun run dev\n\n");
160
+ process.stdout.write("Before uploading, customize:\n");
161
+ process.stdout.write(" README.md — long description\n");
162
+ process.stdout.write(
163
+ " .poe-tile.json — shortDescription (≤140 chars)\n",
164
+ );
165
+ process.stdout.write(
166
+ " assets/icon.png — optional starter profile picture\n",
167
+ );
168
+ })
169
+ );
170
+ }
@@ -0,0 +1,49 @@
1
+ // owner: jyoung-q
2
+ /** Internal apps share the repository toolchain; external apps pin releases. */
3
+ const WORKSPACE_RANGES: Record<string, string> = {
4
+ "@playwright/test": "^1.59.0",
5
+ "@testing-library/jest-dom": "^6",
6
+ "@types/bun": "^1",
7
+ "fake-indexeddb": "^6",
8
+ "happy-dom": "^20.11.2",
9
+ typescript: "npm:@typescript/typescript6@6.0.2",
10
+ vite: "^6",
11
+ zod: "^4.5.4",
12
+ "@vitejs/plugin-react": "^4",
13
+ "@tailwindcss/postcss": "^4.0.0",
14
+ "@testing-library/react": "^16",
15
+ "@types/react": "^19",
16
+ "@types/react-dom": "^19",
17
+ react: "^19",
18
+ "react-dom": "^19",
19
+ tailwindcss: "^4.0.0",
20
+ "@babel/core": "^7",
21
+ "@babel/preset-typescript": "^7",
22
+ "@solidjs/testing-library": "^0.8.10",
23
+ "@types/babel__core": "^7.20.5",
24
+ "babel-preset-solid": "^1",
25
+ "solid-js": "^1",
26
+ "vite-plugin-solid": "^2",
27
+ "@preact/preset-vite": "^2",
28
+ "@testing-library/preact": "^3",
29
+ preact: "^10",
30
+ phaser: "^3.88.0",
31
+ };
32
+
33
+ export function applyInternalToolchain(pkg: Record<string, unknown>): void {
34
+ for (const key of ["dependencies", "devDependencies"] as const) {
35
+ const dependencies = pkg[key] as Record<string, string> | undefined;
36
+ if (!dependencies) continue;
37
+ for (const name of Object.keys(dependencies)) {
38
+ const range = WORKSPACE_RANGES[name];
39
+ if (range) dependencies[name] = range;
40
+ }
41
+ }
42
+ const devDependencies = pkg["devDependencies"] as Record<string, string>;
43
+ devDependencies["typescript7"] = "npm:typescript@^7.0.2";
44
+ const scripts = pkg["scripts"] as Record<string, string>;
45
+ delete scripts["preinstall"];
46
+ scripts["dev"] = "bun scripts/dev.ts";
47
+ scripts["build"] = "vite build";
48
+ delete pkg["engines"];
49
+ }