@joiner-platform/cli 0.0.0-stage → 0.1.1

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 +149 -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 +197 -0
  152. package/skills/tile-creator/references/assets.md +124 -0
  153. package/skills/tile-creator/references/backend-api.md +354 -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,115 @@
1
+ // owner: klu
2
+ /**
3
+ * The write half of the `tiles` channel commands — `set-channel` and
4
+ * `delete-channel`. Split from `tiles.ts` (which keeps the read-only `channels`
5
+ * list command) so that file stays within the per-file line budget, and so the
6
+ * per-command action helpers keep each action under the complexity cap.
7
+ */
8
+
9
+ import type { Command } from "commander";
10
+ import type { SlopPoeClient } from "../client.js";
11
+ import { assertSuccess, CliError } from "../errors.js";
12
+ import { isJsonMode, printJson, printKeyValue } from "../output.js";
13
+ import type { CliTileChannel } from "../types.js";
14
+
15
+ /** Parse a positive-integer CLI argument or throw a `CliError`. */
16
+ function parsePositiveInt(arg: string, label: string): number {
17
+ const value = Number.parseInt(arg, 10);
18
+ if (!Number.isInteger(value) || value < 1) {
19
+ throw new CliError(`${label} must be a positive integer`);
20
+ }
21
+ return value;
22
+ }
23
+
24
+ /** One-line human summary of a channel's target version + auto-advance flag. */
25
+ function channelSummary(channel: CliTileChannel): string {
26
+ return `v${channel.versionNumber}${channel.autoAdvance ? " [auto-advance]" : ""}`;
27
+ }
28
+
29
+ /** Register `tiles set-channel` and `tiles delete-channel` on `tiles`. */
30
+ export function addTileChannelWriteCommands(
31
+ tiles: Command,
32
+ client: SlopPoeClient,
33
+ ): void {
34
+ tiles
35
+ .command("set-channel")
36
+ .description(
37
+ "Point a custom channel at a published version — e.g. to " +
38
+ "test an old build. Owner only. The 'live' channel moves via " +
39
+ "`tiles deploy` / `tiles promote` or the creator page, not here.",
40
+ )
41
+ .argument("<tileHandleOrId>", "Tile ID or userHandle/tileHandle")
42
+ .argument(
43
+ "<channel>",
44
+ "Channel name (lowercase letters, digits, hyphens; not 'live')",
45
+ )
46
+ .argument("<versionNumber>", "Published version number to point it at")
47
+ // Paired boolean: `--auto-advance` sets it true, `--no-auto-advance` false,
48
+ // neither leaves it undefined. `--no-auto-advance` is required to hold a
49
+ // follow-latest channel on an old build — an omitted flag preserves the
50
+ // stored preference and the next publish would move it back.
51
+ .option(
52
+ "--auto-advance",
53
+ "Make the channel jump to the newest version on every publish",
54
+ )
55
+ .option(
56
+ "--no-auto-advance",
57
+ "Pin the channel manually so it stops advancing to the newest publish",
58
+ )
59
+ .action(async function (
60
+ this: Command,
61
+ tileHandleOrId: string,
62
+ channel: string,
63
+ versionNumberArg: string,
64
+ opts: { autoAdvance?: boolean },
65
+ ) {
66
+ const versionNumber = parsePositiveInt(versionNumberArg, "versionNumber");
67
+ const lookup = await client.getTile(tileHandleOrId);
68
+ assertSuccess(lookup);
69
+ // Pass the flag through UNCHANGED: undefined = preserve the channel's
70
+ // existing auto-advance, true/false = set it explicitly. Collapsing
71
+ // false→undefined would make `--no-auto-advance` a silent no-op.
72
+ const result = await client.setTileChannel(
73
+ lookup.tile.id,
74
+ channel,
75
+ versionNumber,
76
+ opts.autoAdvance,
77
+ );
78
+ assertSuccess(result);
79
+ if (isJsonMode(this)) {
80
+ // Carry `url` through: the whole point of the server returning it
81
+ // is that a scripted caller can act on the link without
82
+ // reassembling `/tile/<creator>/<handle>?channel=…` itself.
83
+ printJson({ ...result.channel, url: result.url });
84
+ } else {
85
+ printKeyValue([
86
+ [result.channel.name, channelSummary(result.channel)],
87
+ ["url", result.url],
88
+ ]);
89
+ }
90
+ });
91
+
92
+ tiles
93
+ .command("delete-channel")
94
+ .description(
95
+ "Delete a custom channel. Owner only. The reserved 'live' channel " +
96
+ "cannot be deleted.",
97
+ )
98
+ .argument("<tileHandleOrId>", "Tile ID or userHandle/tileHandle")
99
+ .argument("<channel>", "Channel name to delete")
100
+ .action(async function (
101
+ this: Command,
102
+ tileHandleOrId: string,
103
+ channel: string,
104
+ ) {
105
+ const lookup = await client.getTile(tileHandleOrId);
106
+ assertSuccess(lookup);
107
+ const result = await client.deleteTileChannel(lookup.tile.id, channel);
108
+ assertSuccess(result);
109
+ if (isJsonMode(this)) {
110
+ printJson({ success: true });
111
+ } else {
112
+ printKeyValue([[channel, "deleted"]]);
113
+ }
114
+ });
115
+ }
@@ -0,0 +1,351 @@
1
+ // owner: aaronroe
2
+ /**
3
+ * `poe-tiles tiles checkout` — import one of YOUR OWN tiles into a local
4
+ * folder, ready for an external coding agent (Claude Code, Codex).
5
+ *
6
+ * It reuses the `remix` preparation (extract, SDK dependency rewrite, skills),
7
+ * with three differences:
8
+ * - it refuses a tile the caller does not own, and points to `remix`;
9
+ * - it records no `remixOf`: a later publish from the folder updates the same
10
+ * tile, it is not a copy;
11
+ * - it rebuilds the SDK skills from this CLI release (the bundled copies are
12
+ * frozen at scaffold time) and runs `bun install`.
13
+ *
14
+ * A Creator prototype checks out too: its source is the runtime bundle it
15
+ * published. It has nothing to install and gets its own agent instructions
16
+ * (`checkout-prototype.ts`).
17
+ *
18
+ * Publishing from the folder later marks the Creator workspace outdated, and
19
+ * Creator shows its merge notice. The other direction is the folder's to
20
+ * guard: it records the version it was taken from, and a deploy asks before
21
+ * replacing newer versions (`checkout-base.ts`).
22
+ */
23
+
24
+ import { spawnSync } from "node:child_process";
25
+ import { existsSync, lstatSync, readFileSync, writeFileSync } from "node:fs";
26
+ import { isAbsolute, join, relative, resolve } from "node:path";
27
+ import { Command, Option } from "commander";
28
+ import { writeCheckoutBase } from "../checkout-base.js";
29
+ import { cliName } from "../cli-name.js";
30
+ import type { SlopPoeClient, SourceBundleDownload } from "../client.js";
31
+ import { assertSuccess, CliError } from "../errors.js";
32
+ import { isJsonMode, printJson, printKeyValue } from "../output.js";
33
+ import { POE_TILE_CONFIG_FILENAME } from "../poe-tile-config.js";
34
+ import { LEGACY_PUBLISH_CONFIG_FILENAME } from "../poe-tile-config-files.js";
35
+ import { prepareCopiedTileConfig } from "../remix-provenance.js";
36
+ import { installWorkspaceSkills } from "../sdk-skills.js";
37
+ import {
38
+ isPrototypeFolder,
39
+ preparePrototypeCheckout,
40
+ } from "./checkout-prototype.js";
41
+ import {
42
+ extractBundle,
43
+ rewriteRemixDependencies,
44
+ type SdkDependencyRewrite,
45
+ warnStrandedWorkspaceDeps,
46
+ } from "./remix.js";
47
+
48
+ export const CHECKOUT_AGENTS = ["claude", "codex"] as const;
49
+ export type CheckoutAgent = (typeof CHECKOUT_AGENTS)[number];
50
+
51
+ type CheckoutClient = Pick<
52
+ SlopPoeClient,
53
+ "getTile" | "getCurrentUserId" | "downloadSourceBundle"
54
+ >;
55
+
56
+ /** A child process run with the terminal attached; returns its exit status. */
57
+ export type CheckoutSpawn = (
58
+ command: string,
59
+ args: readonly string[],
60
+ options: { cwd: string; stdoutToStderr: boolean },
61
+ ) => { status: number | null; error?: Error };
62
+
63
+ export interface CheckoutDeps {
64
+ spawn?: CheckoutSpawn;
65
+ }
66
+
67
+ interface CheckoutOptions {
68
+ dir?: string;
69
+ install: boolean;
70
+ agent?: CheckoutAgent;
71
+ }
72
+
73
+ const defaultSpawn: CheckoutSpawn = (command, args, options) =>
74
+ spawnSync(command, [...args], {
75
+ cwd: options.cwd,
76
+ // In --json mode stdout carries only the JSON result, so child output
77
+ // goes to stderr.
78
+ stdio: ["inherit", options.stdoutToStderr ? 2 : "inherit", "inherit"],
79
+ });
80
+
81
+ export function createTilesCheckoutCommand(
82
+ client: CheckoutClient,
83
+ deps: CheckoutDeps = {},
84
+ ): Command {
85
+ const spawn = deps.spawn ?? defaultSpawn;
86
+ return new Command("checkout")
87
+ .description(
88
+ "Import one of your own tiles into a local folder for an external coding agent: " +
89
+ "downloads its source, installs fresh SDK skills, and runs `bun install`. " +
90
+ `To copy someone else's tile, use \`${cliName()} remix\`.`,
91
+ )
92
+ .argument("<tileHandleOrId>", "Tile ID or userHandle/tileHandle")
93
+ .option(
94
+ "--dir <path>",
95
+ "Output directory. Defaults to the tile handle. Must not exist.",
96
+ )
97
+ .option("--no-install", "Skip `bun install` in the new folder.")
98
+ .addOption(
99
+ new Option(
100
+ "--agent <agent>",
101
+ "Start this coding agent in the folder when the checkout is ready.",
102
+ ).choices(CHECKOUT_AGENTS),
103
+ )
104
+ .action(async function (
105
+ this: Command,
106
+ tileHandleOrId: string,
107
+ opts: CheckoutOptions,
108
+ ) {
109
+ await runCheckout({ client, spawn }, tileHandleOrId, {
110
+ ...opts,
111
+ jsonMode: isJsonMode(this),
112
+ });
113
+ });
114
+ }
115
+
116
+ async function runCheckout(
117
+ deps: { client: CheckoutClient; spawn: CheckoutSpawn },
118
+ tileHandleOrId: string,
119
+ opts: CheckoutOptions & { jsonMode: boolean },
120
+ ): Promise<void> {
121
+ if (opts.jsonMode && opts.agent !== undefined) {
122
+ throw new CliError(
123
+ "--agent starts an interactive program and cannot be combined with --json.",
124
+ );
125
+ }
126
+ const tile = await resolveOwnTile(deps.client, tileHandleOrId);
127
+ const prepared = await prepareCheckout(
128
+ deps.client,
129
+ tile,
130
+ resolve(opts.dir ?? tile.handle),
131
+ );
132
+ const installOptions = { install: opts.install, jsonMode: opts.jsonMode };
133
+ if (opts.jsonMode) {
134
+ const installed = installDependencies(deps.spawn, prepared, installOptions);
135
+ printJson(checkoutJson(prepared, installed));
136
+ return;
137
+ }
138
+ reportPrepared(prepared);
139
+ installDependencies(deps.spawn, prepared, installOptions);
140
+ if (opts.agent === undefined) printNextSteps(prepared.targetDir);
141
+ else startAgent(deps.spawn, prepared.targetDir, opts.agent);
142
+ }
143
+
144
+ interface PreparedCheckout {
145
+ tile: CheckoutTile;
146
+ targetDir: string;
147
+ extracted: { fileCount: number; totalBytes: number };
148
+ depRewrite: SdkDependencyRewrite;
149
+ skills: string[];
150
+ prototype: boolean;
151
+ }
152
+
153
+ type CheckoutTile = { id: string; handle: string; creator_id: string };
154
+
155
+ async function resolveOwnTile(
156
+ client: CheckoutClient,
157
+ tileHandleOrId: string,
158
+ ): Promise<CheckoutTile> {
159
+ const lookup = await client.getTile(tileHandleOrId);
160
+ assertSuccess(lookup);
161
+ if (lookup.tile.creator_id !== (await client.getCurrentUserId())) {
162
+ throw new CliError(
163
+ `You can check out only your own tiles; ${tileHandleOrId} belongs to someone else. ` +
164
+ `To make your own copy, run \`${cliName()} remix ${tileHandleOrId}\`.`,
165
+ );
166
+ }
167
+ return lookup.tile;
168
+ }
169
+
170
+ async function prepareCheckout(
171
+ client: CheckoutClient,
172
+ tile: CheckoutTile,
173
+ targetDir: string,
174
+ ): Promise<PreparedCheckout> {
175
+ if (existsSync(targetDir)) {
176
+ throw new CliError(`Output directory already exists: ${targetDir}`);
177
+ }
178
+ const download = await downloadOwnSource(client, tile);
179
+ const extracted = extractBundle(download.bytes, targetDir);
180
+ const depRewrite = rewriteRemixDependencies(targetDir);
181
+ // `null` provenance: drop obsolete config fields without recording a
182
+ // remix, the same preparation a Creator Edit session gets.
183
+ prepareCopiedTileConfig(targetDir, null);
184
+ pinCurrentHandle(targetDir, tile.handle);
185
+ const prototype = isPrototypeFolder(targetDir);
186
+ // Before the skills, whose generic AGENTS.md text yields to an existing file.
187
+ if (prototype) preparePrototypeCheckout(targetDir);
188
+ const skills = installWorkspaceSkills(targetDir, { replace: true });
189
+ // What a later deploy from this folder compares against, so it can ask
190
+ // before replacing versions published since (`checkout-base.ts`).
191
+ if (download.versionNumber !== null)
192
+ writeCheckoutBase(targetDir, {
193
+ tileId: tile.id,
194
+ baseVersion: download.versionNumber,
195
+ });
196
+ return { tile, targetDir, extracted, depRewrite, skills, prototype };
197
+ }
198
+
199
+ /**
200
+ * A deploy publishes to the handle in the folder's config. `tiles rename` does
201
+ * not rewrite the stored source, so after a rename that handle is the old one:
202
+ * a deploy would create a new tile, or replace another tile that took the old
203
+ * handle. Point the config at the tile's current handle. A malformed config is
204
+ * left as it is; a deploy reports it.
205
+ */
206
+ function pinCurrentHandle(targetDir: string, handle: string): void {
207
+ for (const filename of [
208
+ POE_TILE_CONFIG_FILENAME,
209
+ LEGACY_PUBLISH_CONFIG_FILENAME,
210
+ ]) {
211
+ const path = join(targetDir, filename);
212
+ if (!lstatSync(path, { throwIfNoEntry: false })?.isFile()) continue;
213
+ let config: unknown;
214
+ try {
215
+ config = JSON.parse(readFileSync(path, "utf8"));
216
+ } catch {
217
+ continue;
218
+ }
219
+ if (typeof config !== "object" || config === null || Array.isArray(config))
220
+ continue;
221
+ if ((config as { handle?: unknown }).handle === handle) continue;
222
+ writeFileSync(
223
+ path,
224
+ `${JSON.stringify({ ...config, handle }, null, "\t")}\n`,
225
+ );
226
+ }
227
+ }
228
+
229
+ function reportPrepared(p: PreparedCheckout): void {
230
+ console.log(
231
+ `Checked out ${p.tile.handle}${p.prototype ? ", a Creator prototype" : ""}.`,
232
+ );
233
+ printKeyValue([
234
+ ["Tile ID", p.tile.id],
235
+ ["Directory", p.targetDir],
236
+ ["Files", p.extracted.fileCount],
237
+ ["SDK", p.depRewrite.sdkVersion ?? "unchanged"],
238
+ ["Skills", p.skills.join(", ")],
239
+ ]);
240
+ warnStrandedWorkspaceDeps(p.depRewrite.strandedWorkspaceDeps);
241
+ }
242
+
243
+ /** Runs `bun install` unless skipped or a prototype; returns whether it ran. */
244
+ function installDependencies(
245
+ spawn: CheckoutSpawn,
246
+ p: PreparedCheckout,
247
+ options: { install: boolean; jsonMode: boolean },
248
+ ): boolean {
249
+ if (!options.install) return false;
250
+ if (p.prototype) {
251
+ if (!options.jsonMode)
252
+ console.log(
253
+ "\nThis tile is a prototype. It has no package.json, so `bun install` did not run.",
254
+ );
255
+ return false;
256
+ }
257
+ runBunInstall(spawn, p.targetDir, options.jsonMode);
258
+ return true;
259
+ }
260
+
261
+ function runBunInstall(
262
+ spawn: CheckoutSpawn,
263
+ targetDir: string,
264
+ jsonMode: boolean,
265
+ ): void {
266
+ if (!jsonMode) console.log("\nRunning bun install...");
267
+ const result = spawn(process.execPath, ["install"], {
268
+ cwd: targetDir,
269
+ stdoutToStderr: jsonMode,
270
+ });
271
+ if (result.error === undefined && result.status === 0) return;
272
+ const reason =
273
+ result.error?.message ?? `exit code ${result.status ?? "unknown"}`;
274
+ throw new CliError(
275
+ `The source is in ${targetDir}, but \`bun install\` failed (${reason}). ` +
276
+ "Fix the error above, then run `bun install` in that folder.",
277
+ );
278
+ }
279
+
280
+ function checkoutJson(p: PreparedCheckout, installed: boolean) {
281
+ const cdTarget = displayPath(p.targetDir);
282
+ return {
283
+ id: p.tile.id,
284
+ handle: p.tile.handle,
285
+ dir: p.targetDir,
286
+ files: p.extracted.fileCount,
287
+ bytes: p.extracted.totalBytes,
288
+ sdkVersion: p.depRewrite.sdkVersion,
289
+ skills: p.skills,
290
+ prototype: p.prototype,
291
+ installed,
292
+ strandedWorkspaceDeps: p.depRewrite.strandedWorkspaceDeps,
293
+ nextSteps: CHECKOUT_AGENTS.map((agent) => `cd ${cdTarget} && ${agent}`),
294
+ };
295
+ }
296
+
297
+ function startAgent(
298
+ spawn: CheckoutSpawn,
299
+ targetDir: string,
300
+ agent: CheckoutAgent,
301
+ ): void {
302
+ console.log(`\nStarting ${agent} in ${targetDir}...`);
303
+ const result = spawn(agent, [], { cwd: targetDir, stdoutToStderr: false });
304
+ if (result.error === undefined) {
305
+ // The agent ran and printed its own errors; pass on its exit status
306
+ // (`null` when a signal ended it) so a shell caller sees the failure.
307
+ if (result.status !== 0) process.exitCode = result.status ?? 1;
308
+ return;
309
+ }
310
+ throw new CliError(
311
+ `Could not start ${agent} (${result.error.message}). ` +
312
+ `Install it, then run: cd ${displayPath(targetDir)} && ${agent}`,
313
+ );
314
+ }
315
+
316
+ function printNextSteps(targetDir: string): void {
317
+ const cdTarget = displayPath(targetDir);
318
+ console.log("\nNext, start a coding agent in the folder:");
319
+ for (const agent of CHECKOUT_AGENTS) {
320
+ console.log(` cd ${cdTarget} && ${agent}`);
321
+ }
322
+ console.log(
323
+ `\nWhen you are done, publish from the folder with \`${cliName()} tiles deploy\`.`,
324
+ );
325
+ }
326
+
327
+ async function downloadOwnSource(
328
+ client: CheckoutClient,
329
+ tile: CheckoutTile,
330
+ ): Promise<SourceBundleDownload> {
331
+ try {
332
+ return await client.downloadSourceBundle(tile.id);
333
+ } catch (error) {
334
+ // The owner gets 404 only when no source bundle was uploaded.
335
+ if (error instanceof CliError && error.status === 404) {
336
+ throw new CliError(
337
+ `${tile.handle} has no uploaded source code, so it cannot be checked out. ` +
338
+ "A tile published without the `sourceBundle` block in .poe-tile.json has no source.",
339
+ );
340
+ }
341
+ throw error;
342
+ }
343
+ }
344
+
345
+ /** A short, shell-safe path for the printed `cd` line. */
346
+ function displayPath(targetDir: string): string {
347
+ const rel = relative(process.cwd(), targetDir);
348
+ const path =
349
+ rel === "" || rel.startsWith("..") || isAbsolute(rel) ? targetDir : rel;
350
+ return /^[\w./-]+$/.test(path) ? path : `'${path.replaceAll("'", "'\\''")}'`;
351
+ }
@@ -0,0 +1,95 @@
1
+ // owner: aaronroe
2
+ /**
3
+ * `tiles set-gallery` — replace the gallery players see on a tile's detail
4
+ * card, from `.poe-tile.json → screenshots`, without uploading a build.
5
+ *
6
+ * An upload records its gallery on its own version, and the listing changes
7
+ * only when a version goes live. So after `tiles promote`, new screenshots in
8
+ * the manifest would wait for the next promotion. This command writes them to
9
+ * the live listing now (and to the live version, so promoting it again keeps
10
+ * them). The preview video stays.
11
+ */
12
+
13
+ import { dirname } from "node:path";
14
+ import type { Command } from "commander";
15
+ import type { SlopPoeClient } from "../client.js";
16
+ import { assertSuccess, CliError } from "../errors.js";
17
+ import { isJsonMode, printJson, printKeyValue } from "../output.js";
18
+ import {
19
+ POE_TILE_CONFIG_FILENAME,
20
+ readPoeTileConfig,
21
+ } from "../poe-tile-config.js";
22
+ import { resolveScreenshots } from "../resolve-media-uploads.js";
23
+
24
+ /** Register `tiles set-gallery <tileHandleOrId>` on `tiles`. */
25
+ export function addTileGalleryCommand(
26
+ tiles: Command,
27
+ client: SlopPoeClient,
28
+ ): void {
29
+ tiles
30
+ .command("set-gallery")
31
+ .description(
32
+ `Replace a tile's gallery with the \`screenshots\` in ${POE_TILE_CONFIG_FILENAME}, ` +
33
+ "without uploading a build. Players see it now, on the live version. " +
34
+ "An empty list clears the gallery; the preview video is kept.",
35
+ )
36
+ .argument(
37
+ "<tileHandleOrId>",
38
+ "Tile ID or userHandle/tileHandle of the tile to change",
39
+ )
40
+ .option(
41
+ "--dir <dir>",
42
+ `Directory that holds ${POE_TILE_CONFIG_FILENAME}`,
43
+ ".",
44
+ )
45
+ .action(async function (
46
+ this: Command,
47
+ tileHandleOrId: string,
48
+ opts: { dir: string },
49
+ ) {
50
+ const screenshots = readGallery(opts.dir);
51
+ const lookup = await client.getTile(tileHandleOrId);
52
+ assertSuccess(lookup);
53
+ const tileId = lookup.tile.id;
54
+ const result = await client.tileGallery.set(tileId, screenshots);
55
+ const urls = result.tile.media
56
+ .filter((item) => item.type === "screenshot")
57
+ .map((item) => item.url);
58
+ reportGallery(this, tileId, urls);
59
+ });
60
+ }
61
+
62
+ /** The manifest's `screenshots`, read and typed like an upload reads them. */
63
+ function readGallery(dir: string) {
64
+ const read = readPoeTileConfig(dir);
65
+ if (!read.found) {
66
+ throw new CliError(`No ${POE_TILE_CONFIG_FILENAME} in ${dir}.`);
67
+ }
68
+ const entries = read.config.screenshots;
69
+ if (entries === undefined) {
70
+ throw new CliError(
71
+ `${POE_TILE_CONFIG_FILENAME} has no \`screenshots\` list. Add one (an empty list clears the gallery).`,
72
+ );
73
+ }
74
+ return resolveScreenshots(entries, dirname(read.path));
75
+ }
76
+
77
+ /** Print the new gallery as JSON or as a confirmation. */
78
+ function reportGallery(command: Command, tileId: string, urls: string[]): void {
79
+ if (isJsonMode(command)) {
80
+ printJson({ id: tileId, screenshots: urls });
81
+ return;
82
+ }
83
+ console.log(
84
+ urls.length === 0
85
+ ? "Gallery cleared."
86
+ : `Gallery set: ${urls.length} screenshot${urls.length === 1 ? "" : "s"}.`,
87
+ );
88
+ printKeyValue([
89
+ ["Tile ID", tileId],
90
+ ...urls.map((url, index): [string, string] => [
91
+ `Screenshot ${index + 1}`,
92
+ url,
93
+ ]),
94
+ ]);
95
+ }
@@ -0,0 +1,27 @@
1
+ // owner: aaronroe
2
+ import type { SlopPoeClient } from "../client.js";
3
+ import { CliError } from "../errors.js";
4
+
5
+ /** Optional metadata must not prevent reading an otherwise public tile. */
6
+ export async function getTileWithOwnerMetadata(
7
+ client: SlopPoeClient,
8
+ id: string,
9
+ ) {
10
+ try {
11
+ return await client.getTile(id, { includeOwnerMetadata: true });
12
+ } catch (error) {
13
+ // The transport exposes HTTP failures as CliError messages. Match this
14
+ // one denial exactly: unrelated 403s (including identity-link failures),
15
+ // invalid credentials, and upstream failures must remain visible errors.
16
+ // Production-route tests pin this boundary if the server wording changes.
17
+ if (
18
+ !(error instanceof CliError) ||
19
+ error.message !==
20
+ "Request failed (403): This credential cannot read that activity's owner metadata."
21
+ )
22
+ throw error;
23
+ }
24
+ // No metadata opt-in means cookie-only access, not a broader credential.
25
+ // Retry only once; an error from the public read propagates to the caller.
26
+ return client.getTile(id);
27
+ }