@seriousgaming/sdk-tools 1.4.0 → 1.6.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 (302) hide show
  1. package/dist/bundling/ui-bundler.d.ts +12 -0
  2. package/dist/cli-25RWY5BQ.js +41 -0
  3. package/dist/cli-272KBNJH.js +97 -0
  4. package/dist/cli-2BH7FX27.js +52 -0
  5. package/dist/cli-2GOFEW26.js +81 -0
  6. package/dist/cli-3E3MD5U4.js +21 -0
  7. package/dist/cli-3HE4AVZG.js +115 -0
  8. package/dist/cli-4AKVLEC4.js +1387 -0
  9. package/dist/cli-4BV45LBH.js +126 -0
  10. package/dist/cli-4LKXZQ2B.js +48 -0
  11. package/dist/cli-4UWFQNGF.js +54 -0
  12. package/dist/cli-4YB3ROVR.js +78 -0
  13. package/dist/cli-57RXC3HQ.js +36 -0
  14. package/dist/cli-5JEGTVTG.js +96 -0
  15. package/dist/cli-6AMT3BUO.js +97 -0
  16. package/dist/cli-6RRVEGFB.js +80 -0
  17. package/dist/cli-6WXLXJVX.js +36 -0
  18. package/dist/cli-7OGYADZ3.js +97 -0
  19. package/dist/cli-AK7OIPWY.js +229 -0
  20. package/dist/cli-B4TN6PJP.js +124 -0
  21. package/dist/cli-B6YHEKIJ.js +248 -0
  22. package/dist/cli-BPYMTOUL.js +89 -0
  23. package/dist/cli-BWX5E7TQ.js +23 -0
  24. package/dist/cli-BYJWFFCF.js +37 -0
  25. package/dist/cli-C3NVCKO6.js +43 -0
  26. package/dist/cli-C47GJATR.js +42 -0
  27. package/dist/cli-C5QOJJWX.js +46 -0
  28. package/dist/cli-C6TH5S7K.js +6417 -0
  29. package/dist/cli-DL2CVMRF.js +89 -0
  30. package/dist/cli-DMW2OQIJ.js +76 -0
  31. package/dist/cli-DZW3XD5F.js +143 -0
  32. package/dist/cli-E2NLWIFE.js +1331 -0
  33. package/dist/cli-E33CJRRQ.js +36 -0
  34. package/dist/cli-E6DJIMYD.js +142 -0
  35. package/dist/cli-EEFJKIGL.js +151 -0
  36. package/dist/cli-EVFS55WN.js +185 -0
  37. package/dist/cli-F2D4GGUA.js +549 -0
  38. package/dist/cli-FBTRTIZJ.js +226 -0
  39. package/dist/cli-FWFRKQNE.js +11 -0
  40. package/dist/cli-FYINNRML.js +760 -0
  41. package/dist/cli-G522CPRL.js +88 -0
  42. package/dist/cli-G6KELFSX.js +2847 -0
  43. package/dist/cli-G6UE5NL4.js +90 -0
  44. package/dist/cli-GBFM76BF.js +16 -0
  45. package/dist/cli-GDQ6ILJY.js +101 -0
  46. package/dist/cli-GFBGYFYD.js +50 -0
  47. package/dist/cli-GGPDQNM3.js +35 -0
  48. package/dist/cli-GTSGLN3Z.js +307 -0
  49. package/dist/cli-GUXKQMJ7.js +13641 -0
  50. package/dist/cli-GXD36NF2.js +60 -0
  51. package/dist/cli-HCRTYQQS.js +16 -0
  52. package/dist/cli-HYY64SUD.js +185 -0
  53. package/dist/cli-I355WTAF.js +463 -0
  54. package/dist/cli-IDKYF5XB.js +59 -0
  55. package/dist/cli-ILKCQNM6.js +8 -0
  56. package/dist/cli-IRZ5KB7D.js +36 -0
  57. package/dist/cli-IUS2YCD3.js +31 -0
  58. package/dist/cli-J4DKUUTK.js +138 -0
  59. package/dist/cli-JFU22EJ2.js +187 -0
  60. package/dist/cli-JMZLT65J.js +226 -0
  61. package/dist/cli-JZM7XTNV.js +89 -0
  62. package/dist/cli-K2B6WHKA.js +81 -0
  63. package/dist/cli-KL3756X6.js +126 -0
  64. package/dist/cli-KNOOKGYW.js +88 -0
  65. package/dist/cli-LFGRFIEO.js +226 -0
  66. package/dist/cli-LFM7GJHI.js +0 -0
  67. package/dist/cli-LMDJCHHD.js +304 -0
  68. package/dist/cli-LXYPE3L5.js +99 -0
  69. package/dist/cli-M6BCQRID.js +153 -0
  70. package/dist/cli-MBNMPVDC.js +367 -0
  71. package/dist/cli-MJUYJIEP.js +13 -0
  72. package/dist/cli-MMN4BPO4.js +145 -0
  73. package/dist/cli-MYJGMA6U.js +40 -0
  74. package/dist/cli-N6H6T2E2.js +616 -0
  75. package/dist/cli-O5KP4OVN.js +61 -0
  76. package/dist/cli-O6PWMJTZ.js +25 -0
  77. package/dist/cli-ORIG557O.js +141 -0
  78. package/dist/cli-PFFCNGHI.js +243 -0
  79. package/dist/cli-PNLYX6R6.js +131 -0
  80. package/dist/cli-PQBXVLEU.js +649 -0
  81. package/dist/cli-PTT5RGKO.js +62 -0
  82. package/dist/cli-Q2XJF5AS.js +127 -0
  83. package/dist/cli-QEVDDBNO.js +60 -0
  84. package/dist/cli-QEVE5HUM.js +167 -0
  85. package/dist/cli-QUIJCBYB.js +391 -0
  86. package/dist/cli-QUNIRH7A.js +57 -0
  87. package/dist/cli-QVASWX2A.js +187 -0
  88. package/dist/cli-QWQMPCL6.js +253 -0
  89. package/dist/cli-R4PCG5YX.js +131 -0
  90. package/dist/cli-RA673NGF.js +53 -0
  91. package/dist/cli-RN6IWTL2.js +36 -0
  92. package/dist/cli-ROT3DRKU.js +145 -0
  93. package/dist/cli-RZITKPJX.js +367 -0
  94. package/dist/cli-S5IVGDDD.js +32 -0
  95. package/dist/cli-S5QDONIQ.js +218 -0
  96. package/dist/cli-SIPDUBFL.js +36 -0
  97. package/dist/cli-SMFSZF2G.js +4009 -0
  98. package/dist/cli-SRHBXZCN.js +159 -0
  99. package/dist/cli-TCY5LJ7E.js +88 -0
  100. package/dist/cli-TDSQSCX4.js +131 -0
  101. package/dist/cli-TIDQ4WUE.js +257 -0
  102. package/dist/cli-TLLA6KAP.js +79 -0
  103. package/dist/cli-TPU4TUR6.js +132 -0
  104. package/dist/cli-U2UE7I7J.js +30 -0
  105. package/dist/cli-UELGBQG7.js +101 -0
  106. package/dist/cli-UHSZBKYO.js +97 -0
  107. package/dist/cli-UJ4UCL2Z.js +38 -0
  108. package/dist/cli-UKQYZYFK.js +31 -0
  109. package/dist/cli-UMFFURZ7.js +81 -0
  110. package/dist/cli-UNAJ2OTE.js +15 -0
  111. package/dist/cli-UNJ5X6BU.js +89 -0
  112. package/dist/cli-UTJU4IYG.js +117 -0
  113. package/dist/cli-V4GHRWOV.js +1837 -0
  114. package/dist/cli-VCI3CG36.js +73 -0
  115. package/dist/cli-VCKOC2EV.js +256 -0
  116. package/dist/cli-VL2P354N.js +46 -0
  117. package/dist/cli-WAE26SVW.js +72 -0
  118. package/dist/cli-WOGIAU2E.js +100 -0
  119. package/dist/cli-WU43JT4T.js +52 -0
  120. package/dist/cli-XCO2VQOH.js +122 -0
  121. package/dist/cli-XSVGKI3R.js +39 -0
  122. package/dist/cli-YOTGR3NB.js +82 -0
  123. package/dist/cli-YVVXUD2G.js +197 -0
  124. package/dist/cli-ZISJ36MM.js +89 -0
  125. package/dist/cli-ZTWOE3ZT.js +65 -0
  126. package/dist/cli-ZVSFYDPQ.js +205 -0
  127. package/dist/cli-ZWPYIXNI.js +68 -0
  128. package/dist/cli.js +171 -42385
  129. package/dist/client/build-surfaces.d.ts +33 -0
  130. package/dist/client/dev-server.d.ts +6 -0
  131. package/dist/client/index.d.ts +1 -0
  132. package/dist/client/playwright.d.ts +62 -0
  133. package/dist/client.js +339 -56
  134. package/dist/core/session.d.ts +15 -1
  135. package/dist/dev/console/assets/{index-BvB-LFQZ.js → index-CuMOOH9m.js} +21 -21
  136. package/dist/dev/console/index.html +1 -1
  137. package/dist/dev/public-origins.d.ts +61 -0
  138. package/dist/dev/shell.d.ts +51 -4
  139. package/dist/dev/surfaces.d.ts +7 -0
  140. package/dist/docs/ai-agents.md +5 -0
  141. package/dist/docs/api/index.md +14 -12
  142. package/dist/docs/api/sdk-tools-client.md +29 -0
  143. package/dist/docs/api/sdk-tools-playwright.md +104 -0
  144. package/dist/docs/changelog-0.x.md +2 -2
  145. package/dist/docs/changelog.md +56 -4
  146. package/dist/docs/cli-and-dev-server.md +79 -0
  147. package/dist/docs/cli-error-codes.md +39 -36
  148. package/dist/docs/cli-reference.md +93 -32
  149. package/dist/docs/environment-variables.md +16 -5
  150. package/dist/docs/guides/ai-facilitation.md +2 -0
  151. package/dist/docs/guides/capabilities.md +2 -0
  152. package/dist/docs/guides/designing-a-game.md +31 -4
  153. package/dist/docs/guides/designing-screens.md +133 -0
  154. package/dist/docs/guides/endpoints.md +2 -0
  155. package/dist/docs/guides/engine-testing.md +5 -1
  156. package/dist/docs/guides/engine.md +2 -0
  157. package/dist/docs/guides/file-handling.md +3 -1
  158. package/dist/docs/guides/games.md +3 -1
  159. package/dist/docs/guides/global-settings.md +2 -0
  160. package/dist/docs/guides/guide.md +2 -0
  161. package/dist/docs/guides/hooks.md +2 -0
  162. package/dist/docs/guides/index.md +9 -0
  163. package/dist/docs/guides/internationalization.md +2 -0
  164. package/dist/docs/guides/llm-integration.md +4 -2
  165. package/dist/docs/guides/multi-team-games.md +3 -1
  166. package/dist/docs/guides/patterns.md +2 -0
  167. package/dist/docs/guides/presentation.md +1 -1
  168. package/dist/docs/guides/production-constraints.md +2 -0
  169. package/dist/docs/guides/scenario-editor.md +2 -0
  170. package/dist/docs/guides/scenarios.md +6 -2
  171. package/dist/docs/guides/session-game-flow.md +365 -0
  172. package/dist/docs/guides/session-hooks.md +205 -0
  173. package/dist/docs/guides/session.md +27 -565
  174. package/dist/docs/guides/settings.md +2 -0
  175. package/dist/docs/guides/setup.md +3 -1
  176. package/dist/docs/guides/speech-generation.md +2 -0
  177. package/dist/docs/guides/starter-game.md +63 -23
  178. package/dist/docs/guides/testing.md +35 -18
  179. package/dist/docs/guides/tick-controller.md +3 -1
  180. package/dist/docs/guides/type-safety.md +2 -0
  181. package/dist/docs/guides/ui-files-and-llms.md +328 -0
  182. package/dist/docs/guides/ui-participants.md +281 -0
  183. package/dist/docs/guides/ui-styling.md +263 -0
  184. package/dist/docs/guides/ui-ticks.md +247 -0
  185. package/dist/docs/guides/ui.md +11 -1092
  186. package/dist/docs/guides/upgrading.md +2 -0
  187. package/dist/docs/guides/validators.md +2 -0
  188. package/dist/docs/guides/waiting-room.md +1 -1
  189. package/dist/docs/index.md +2 -1
  190. package/dist/docs/page-index.md +146 -0
  191. package/dist/docs/recipes/adapt-a-game-for-walkthroughs.md +1 -1
  192. package/dist/docs/recipes/adapt-ui-for-observers.md +1 -1
  193. package/dist/docs/recipes/create-presentation.md +11 -0
  194. package/dist/docs/recipes/create-scenario-editor.md +1 -0
  195. package/dist/docs/recipes/create-session-ui.md +2 -1
  196. package/dist/docs/recipes/create-setup.md +1 -0
  197. package/dist/docs/recipes/create-user-interface.md +1 -0
  198. package/dist/docs/recipes/create-waiting-room-ui.md +1 -0
  199. package/dist/docs/recipes/design-state-for-concurrent-writes.md +1 -1
  200. package/dist/docs/recipes/e2e-testing.md +19 -20
  201. package/dist/docs/recipes/fix-duplicate-packages.md +2 -2
  202. package/dist/docs/recipes/index.md +3 -0
  203. package/dist/docs/recipes/screenshot-a-surface.md +80 -0
  204. package/dist/docs/recipes/test-a-multi-role-game.md +1 -1
  205. package/dist/docs/recipes/use-request-tick.md +2 -2
  206. package/dist/execution/config-resolver.d.ts +4 -1
  207. package/dist/playwright.js +32232 -0
  208. package/dist/runtime/manifest-version.d.ts +1 -1
  209. package/dist/runtime.js +1 -1
  210. package/dist/templates/package/CLAUDE.md.template +14 -5
  211. package/dist/templates/package/DESIGN.md.liquid +39 -7
  212. package/dist/templates/package/README.md.liquid +1 -1
  213. package/dist/templates/package/claude/rules/workflow-create-user-interface.md +1 -1
  214. package/dist/templates/package/claude/rules/workflow-test-engine-or-ui.md +1 -1
  215. package/dist/templates/package/global-setup.ts.template +7 -18
  216. package/dist/templates/package/playwright.config.ts.liquid +8 -11
  217. package/dist/templates/package/pnpm-workspace.yaml.template +13 -0
  218. package/dist/templates/starter-game/capabilities/pacing/capability.sdk.json +18 -0
  219. package/dist/templates/starter-game/package.json +2 -0
  220. package/dist/templates/starter-game/playwright.config.ts +8 -11
  221. package/dist/templates/starter-game/presentation/defaults.ts +52 -0
  222. package/dist/templates/starter-game/presentation/index.html +20 -0
  223. package/dist/templates/starter-game/presentation/presentation.sdk.json +10 -0
  224. package/dist/templates/starter-game/presentation/src/App.tsx +55 -0
  225. package/dist/templates/starter-game/presentation/src/Band.tsx +40 -0
  226. package/dist/templates/starter-game/presentation/src/Slides.tsx +415 -0
  227. package/dist/templates/starter-game/presentation/src/WeatherIcon.tsx +21 -0
  228. package/dist/templates/starter-game/presentation/src/i18n.ts +88 -0
  229. package/dist/templates/starter-game/presentation/src/main.tsx +15 -0
  230. package/dist/templates/starter-game/presentation/src/stalls.test.ts +196 -0
  231. package/dist/templates/starter-game/presentation/src/stalls.ts +199 -0
  232. package/dist/templates/starter-game/presentation/types.ts +94 -0
  233. package/dist/templates/starter-game/seriousgaming.sdk.json +2 -1
  234. package/dist/templates/starter-game/session/defaults.ts +6 -0
  235. package/dist/templates/starter-game/session/index.html +1 -1
  236. package/dist/templates/starter-game/session/session.sdk.json +2 -2
  237. package/dist/templates/starter-game/session/src/App.test.tsx +436 -115
  238. package/dist/templates/starter-game/session/src/App.tsx +372 -222
  239. package/dist/templates/starter-game/session/src/JoinCodes.tsx +184 -0
  240. package/dist/templates/starter-game/session/src/ManagePanel.tsx +188 -0
  241. package/dist/templates/starter-game/session/src/Results.tsx +340 -0
  242. package/dist/templates/starter-game/session/src/SessionBar.tsx +179 -0
  243. package/dist/templates/starter-game/session/src/SessionPanels.tsx +105 -0
  244. package/dist/templates/starter-game/session/src/SidePanel.tsx +89 -0
  245. package/dist/templates/starter-game/session/src/StallCard.tsx +253 -0
  246. package/dist/templates/starter-game/session/src/TopBar.tsx +36 -0
  247. package/dist/templates/starter-game/session/src/i18n.ts +91 -24
  248. package/dist/templates/starter-game/session/src/status.ts +28 -0
  249. package/dist/templates/starter-game/session/types.ts +8 -2
  250. package/dist/templates/starter-game/shared/Awning.tsx +31 -0
  251. package/dist/templates/starter-game/shared/HostLogo.test.tsx +38 -0
  252. package/dist/templates/starter-game/shared/HostLogo.tsx +48 -0
  253. package/dist/templates/starter-game/shared/StallIcons.tsx +83 -0
  254. package/dist/templates/starter-game/shared/days.ts +11 -0
  255. package/dist/templates/starter-game/shared/format.test.ts +13 -0
  256. package/dist/templates/starter-game/{ui/src → shared}/format.ts +1 -1
  257. package/dist/templates/starter-game/testing/e2e/game.spec.ts +43 -9
  258. package/dist/templates/starter-game/testing/e2e/global-setup.ts +7 -18
  259. package/dist/templates/starter-game/ui/defaults.ts +3 -0
  260. package/dist/templates/starter-game/ui/src/App.test.tsx +197 -29
  261. package/dist/templates/starter-game/ui/src/App.tsx +176 -99
  262. package/dist/templates/starter-game/ui/src/DayBar.test.tsx +50 -7
  263. package/dist/templates/starter-game/ui/src/DayBar.tsx +96 -38
  264. package/dist/templates/starter-game/ui/src/DaysTable.tsx +69 -0
  265. package/dist/templates/starter-game/ui/src/FirstDay.tsx +37 -0
  266. package/dist/templates/starter-game/ui/src/Header.tsx +257 -0
  267. package/dist/templates/starter-game/ui/src/Lesson.tsx +63 -0
  268. package/dist/templates/starter-game/ui/src/MakeRow.tsx +98 -71
  269. package/dist/templates/starter-game/ui/src/Notices.tsx +59 -0
  270. package/dist/templates/starter-game/ui/src/PastDay.tsx +88 -0
  271. package/dist/templates/starter-game/ui/src/Section.tsx +26 -26
  272. package/dist/templates/starter-game/ui/src/ThemeToggle.tsx +25 -11
  273. package/dist/templates/starter-game/ui/src/TodayPanel.test.tsx +37 -33
  274. package/dist/templates/starter-game/ui/src/TodayPanel.tsx +66 -52
  275. package/dist/templates/starter-game/ui/src/WeatherCard.tsx +47 -0
  276. package/dist/templates/starter-game/ui/src/WeekOver.tsx +145 -0
  277. package/dist/templates/starter-game/ui/src/YesterdayPanel.tsx +65 -114
  278. package/dist/templates/starter-game/ui/src/days.ts +58 -0
  279. package/dist/templates/starter-game/ui/src/i18n.ts +86 -32
  280. package/dist/templates/starter-game/ui/src/test-helpers.ts +1 -0
  281. package/dist/templates/starter-game/ui/src/theme.ts +8 -8
  282. package/dist/templates/starter-game/ui/types.ts +6 -0
  283. package/dist/templates/starter-game/ui/ui.sdk.json +1 -1
  284. package/dist/templates/starter-game/validators/daylimit/defaults.ts +13 -0
  285. package/dist/templates/starter-game/validators/daylimit/logic/logic.test.ts +20 -0
  286. package/dist/templates/starter-game/validators/daylimit/logic/logic.ts +23 -0
  287. package/dist/templates/starter-game/validators/daylimit/types.ts +23 -0
  288. package/dist/templates/starter-game/validators/daylimit/validator.sdk.json +10 -0
  289. package/dist/templates/starter-game/waiting_room/src/App.test.tsx +83 -5
  290. package/dist/templates/starter-game/waiting_room/src/App.tsx +262 -119
  291. package/dist/templates/starter-game/waiting_room/src/i18n.ts +8 -4
  292. package/dist/utils/error-codes.d.ts +12 -0
  293. package/dist/utils/prompt.d.ts +5 -5
  294. package/dist/utils/resource-scan.d.ts +39 -0
  295. package/package.json +15 -4
  296. package/dist/templates/starter-game/session/src/Section.tsx +0 -37
  297. package/dist/templates/starter-game/session/src/TeamDoor.tsx +0 -96
  298. package/dist/templates/starter-game/session/src/format.ts +0 -8
  299. package/dist/templates/starter-game/ui/src/HistoryPanel.test.tsx +0 -74
  300. package/dist/templates/starter-game/ui/src/HistoryPanel.tsx +0 -120
  301. package/dist/templates/starter-game/ui/src/HostLogo.test.tsx +0 -25
  302. package/dist/templates/starter-game/ui/src/HostLogo.tsx +0 -38
@@ -0,0 +1,138 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ logger
4
+ } from "./cli-4YB3ROVR.js";
5
+ import {
6
+ CliError,
7
+ reportResult
8
+ } from "./cli-N6H6T2E2.js";
9
+
10
+ // cli/commands/package-bundle.ts
11
+ import { existsSync, readdirSync, readFileSync, statSync } from "fs";
12
+ import { mkdir, rm } from "fs/promises";
13
+ import { dirname, join, relative, resolve, sep } from "path";
14
+ import AdmZip from "adm-zip";
15
+ function emptyDirectoryEntries(root, excluded) {
16
+ const empty = /* @__PURE__ */ new Set();
17
+ const walk = (absolute, prefix) => {
18
+ let holdsFile = false;
19
+ for (const child of readdirSync(absolute, { withFileTypes: true })) {
20
+ const childPath = join(absolute, child.name);
21
+ if (child.isDirectory()) {
22
+ if (walk(childPath, `${prefix}${child.name}/`)) holdsFile = true;
23
+ } else if (childPath !== excluded) {
24
+ holdsFile = true;
25
+ }
26
+ }
27
+ if (!holdsFile && prefix !== "") empty.add(prefix);
28
+ return holdsFile;
29
+ };
30
+ walk(root, "");
31
+ return empty;
32
+ }
33
+ function includeBundleEntry(entryPath, emptyDirectories, outputRelToBuildDir, separator = sep) {
34
+ const entryName = separator === "/" ? entryPath : entryPath.split(separator).join("/");
35
+ if (emptyDirectories.has(entryName)) return false;
36
+ if (outputRelToBuildDir === null) return true;
37
+ return entryPath !== outputRelToBuildDir;
38
+ }
39
+ function readManifest(buildDirAbs) {
40
+ const manifestPath = join(buildDirAbs, "seriousgaming.json");
41
+ if (!existsSync(manifestPath)) {
42
+ throw new CliError(
43
+ "BUILD_NOT_FOUND",
44
+ `Manifest not found at ${manifestPath}. Run "seriousgaming-sdk build" before "package bundle".`
45
+ );
46
+ }
47
+ let raw;
48
+ try {
49
+ raw = readFileSync(manifestPath, "utf-8");
50
+ } catch (error) {
51
+ const message = error instanceof Error ? error.message : String(error);
52
+ throw new CliError("BUILD_NOT_FOUND", `Failed to read ${manifestPath}: ${message}`);
53
+ }
54
+ let manifest;
55
+ try {
56
+ manifest = JSON.parse(raw);
57
+ } catch (error) {
58
+ const message = error instanceof Error ? error.message : String(error);
59
+ throw new CliError("BUILD_NOT_FOUND", `Failed to parse ${manifestPath}: ${message}`, {
60
+ hint: 'Run "seriousgaming-sdk build" again.'
61
+ });
62
+ }
63
+ const identifier = manifest.package?.definition?.identifier;
64
+ const version = manifest.package?.definition?.version;
65
+ if (!identifier || !version) {
66
+ throw new CliError(
67
+ "BUILD_NOT_FOUND",
68
+ `Manifest at ${manifestPath} is missing package.definition.identifier or package.definition.version.`
69
+ );
70
+ }
71
+ return { identifier, version };
72
+ }
73
+ async function bundlePackage(options) {
74
+ const buildDirAbs = resolve(options.workingDir, options.buildDir);
75
+ if (!existsSync(buildDirAbs)) {
76
+ throw new CliError(
77
+ "BUILD_NOT_FOUND",
78
+ `Build directory not found at ${buildDirAbs}. Run "seriousgaming-sdk build" first.`
79
+ );
80
+ }
81
+ const manifest = readManifest(buildDirAbs);
82
+ const defaultOutputFile = join(
83
+ options.buildDir,
84
+ `${manifest.identifier}-${manifest.version}.zip`
85
+ );
86
+ const outputFileAbs = resolve(options.workingDir, options.outputFile ?? defaultOutputFile);
87
+ await mkdir(dirname(outputFileAbs), { recursive: true });
88
+ await rm(outputFileAbs, { force: true });
89
+ const outputRelToBuildDir = relative(buildDirAbs, outputFileAbs);
90
+ const outputIsInsideBuildDir = !outputRelToBuildDir.startsWith("..") && !outputRelToBuildDir.startsWith(sep);
91
+ const emptyDirectories = emptyDirectoryEntries(
92
+ buildDirAbs,
93
+ outputIsInsideBuildDir ? outputFileAbs : ""
94
+ );
95
+ const zip = new AdmZip();
96
+ zip.addLocalFolder(
97
+ buildDirAbs,
98
+ void 0,
99
+ (entryPath) => includeBundleEntry(
100
+ entryPath,
101
+ emptyDirectories,
102
+ outputIsInsideBuildDir ? outputRelToBuildDir : null
103
+ )
104
+ );
105
+ const fileCount = zip.getEntries().filter((entry) => !entry.isDirectory).length;
106
+ if (fileCount === 0) {
107
+ throw new CliError(
108
+ "BUILD_NOT_FOUND",
109
+ `Build directory ${buildDirAbs} contains no files to bundle.`
110
+ );
111
+ }
112
+ zip.writeZip(outputFileAbs);
113
+ const size = statSync(outputFileAbs).size;
114
+ const result = {
115
+ outputFile: outputFileAbs,
116
+ size,
117
+ fileCount,
118
+ identifier: manifest.identifier,
119
+ version: manifest.version
120
+ };
121
+ return result;
122
+ }
123
+ async function packageBundleCommand(options) {
124
+ const result = await bundlePackage(options);
125
+ reportResult(result, () => {
126
+ logger.success(`Bundle created at ${result.outputFile}`);
127
+ console.log(` identifier: ${result.identifier}`);
128
+ console.log(` version: ${result.version}`);
129
+ console.log(` files: ${result.fileCount}`);
130
+ console.log(` size: ${result.size} bytes`);
131
+ });
132
+ }
133
+
134
+ export {
135
+ includeBundleEntry,
136
+ bundlePackage,
137
+ packageBundleCommand
138
+ };
@@ -0,0 +1,187 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ applyJsonPatch
4
+ } from "./cli-S5IVGDDD.js";
5
+ import {
6
+ assertNoRemovedManifestFields,
7
+ getPackageIdentifierError
8
+ } from "./cli-YVVXUD2G.js";
9
+ import {
10
+ resolveInputSource
11
+ } from "./cli-4UWFQNGF.js";
12
+ import {
13
+ updatePackageFiles
14
+ } from "./cli-FYINNRML.js";
15
+ import "./cli-IUS2YCD3.js";
16
+ import "./cli-QUNIRH7A.js";
17
+ import "./cli-BYJWFFCF.js";
18
+ import "./cli-MBNMPVDC.js";
19
+ import "./cli-GFBGYFYD.js";
20
+ import {
21
+ operationError,
22
+ recordOperationResult
23
+ } from "./cli-UELGBQG7.js";
24
+ import {
25
+ confirmAction,
26
+ input
27
+ } from "./cli-ZTWOE3ZT.js";
28
+ import "./cli-4BV45LBH.js";
29
+ import "./cli-4AKVLEC4.js";
30
+ import "./cli-VCKOC2EV.js";
31
+ import "./cli-E2NLWIFE.js";
32
+ import "./cli-25RWY5BQ.js";
33
+ import "./cli-QWQMPCL6.js";
34
+ import "./cli-SMFSZF2G.js";
35
+ import "./cli-F2D4GGUA.js";
36
+ import {
37
+ logger
38
+ } from "./cli-4YB3ROVR.js";
39
+ import {
40
+ CliError
41
+ } from "./cli-N6H6T2E2.js";
42
+
43
+ // cli/commands/resources/package/update.ts
44
+ import { existsSync, readFileSync } from "fs";
45
+ import { join } from "path";
46
+ var IDENTIFIER_CHANGE_WARNING = "\n\u26A0\uFE0F WARNING: The package identifier names the game everywhere it is published.\nA new identifier is a new game to a runtime, not a new version of this one.\n";
47
+ async function updatePackage(definitionInput, options) {
48
+ logger.info("\nUpdating package...\n");
49
+ const configPath = join(options.workingDir, "seriousgaming.sdk.json");
50
+ if (!existsSync(configPath)) {
51
+ throw new CliError(
52
+ "MANIFEST_NOT_FOUND",
53
+ "seriousgaming.sdk.json not found.\nThis command must be run in a Serious Gaming package directory."
54
+ );
55
+ }
56
+ let manifest;
57
+ try {
58
+ manifest = JSON.parse(readFileSync(configPath, "utf-8"));
59
+ } catch (error) {
60
+ throw new CliError(
61
+ "MANIFEST_INVALID",
62
+ "Could not read seriousgaming.sdk.json\n" + (error instanceof Error ? error.message : "Unknown error")
63
+ );
64
+ }
65
+ const existing = manifest;
66
+ const currentIdentifier = existing.identifier;
67
+ const locale = existing.supportedLocales?.[0] ?? "en";
68
+ const currentName = existing.locales?.[locale]?.name ?? currentIdentifier;
69
+ let settings = null;
70
+ if (options.patch) {
71
+ let operations;
72
+ try {
73
+ operations = JSON.parse(options.patch);
74
+ } catch {
75
+ throw new CliError("INPUT_INVALID", "--patch must be a valid JSON Patch array");
76
+ }
77
+ try {
78
+ settings = applyJsonPatch(manifest, operations);
79
+ } catch (error) {
80
+ throw new CliError(
81
+ "INPUT_INVALID",
82
+ `Failed to apply patch: ${error.message}`
83
+ );
84
+ }
85
+ } else {
86
+ const inputSource = await resolveInputSource(definitionInput, options.file);
87
+ if (inputSource.kind === "json") {
88
+ try {
89
+ settings = JSON.parse(inputSource.json);
90
+ } catch (error) {
91
+ throw new CliError(
92
+ "INPUT_INVALID",
93
+ "Failed to parse JSON definition\n" + (error instanceof Error ? error.message : "Unknown error")
94
+ );
95
+ }
96
+ }
97
+ }
98
+ if (settings) {
99
+ assertNoRemovedManifestFields(settings);
100
+ if (settings.identifier !== currentIdentifier) {
101
+ logger.info(IDENTIFIER_CHANGE_WARNING);
102
+ }
103
+ applyUpdate(options.workingDir, settings, currentIdentifier);
104
+ return;
105
+ }
106
+ logger.info("No JSON definition provided. Starting interactive mode...\n");
107
+ logger.info("Current package values:");
108
+ logger.info(` Identifier: ${currentIdentifier}`);
109
+ logger.info(` Name (${locale}): ${currentName}`);
110
+ logger.info(` Max ticks: ${existing.maxTicks ?? "(unset)"}`);
111
+ logger.info("");
112
+ const newIdentifier = await input({
113
+ message: "Package identifier (namespace-style):",
114
+ default: currentIdentifier,
115
+ validate: (value) => getPackageIdentifierError(value) || true
116
+ });
117
+ const newName = await input({
118
+ message: `Game name (${locale}):`,
119
+ default: currentName,
120
+ validate: (value) => value.trim() ? true : "A name is required"
121
+ });
122
+ const newTicks = await input({
123
+ message: "Number of ticks (maxTicks):",
124
+ default: existing.maxTicks === void 0 ? void 0 : String(existing.maxTicks),
125
+ validate: (value) => {
126
+ const num = Number(value);
127
+ if (isNaN(num)) return "Ticks must be a number";
128
+ if (num < 1) return "Ticks must be at least 1";
129
+ if (!Number.isInteger(num)) return "Ticks must be a whole number";
130
+ return true;
131
+ }
132
+ });
133
+ if (newIdentifier !== currentIdentifier) {
134
+ logger.info("");
135
+ logger.info(IDENTIFIER_CHANGE_WARNING);
136
+ const confirmChange = await confirmAction({
137
+ message: "Do you want to continue with this identifier change?",
138
+ default: false
139
+ });
140
+ if (!confirmChange) {
141
+ logger.info("\nPackage update cancelled.\n");
142
+ return;
143
+ }
144
+ }
145
+ applyUpdate(
146
+ options.workingDir,
147
+ {
148
+ ...existing,
149
+ identifier: newIdentifier,
150
+ locales: {
151
+ ...existing.locales,
152
+ [locale]: { name: newName }
153
+ },
154
+ maxTicks: Number(newTicks)
155
+ },
156
+ currentIdentifier
157
+ );
158
+ }
159
+ function applyUpdate(workingDir, settings, currentIdentifier) {
160
+ logger.info("Updating package files...\n");
161
+ const result = updatePackageFiles({ packagePath: workingDir, newSettings: settings });
162
+ if (!result.success) {
163
+ throw operationError(result, "Failed to update package files");
164
+ }
165
+ logger.success("Package updated successfully!");
166
+ recordOperationResult(result);
167
+ if (result.filesUpdated && result.filesUpdated.length > 0) {
168
+ logger.info("Files updated:");
169
+ for (const file of result.filesUpdated) {
170
+ logger.info(` \u2713 ${file}`);
171
+ }
172
+ }
173
+ if (result.directoriesRenamed && result.directoriesRenamed.length > 0) {
174
+ logger.info("\nDirectories renamed:");
175
+ for (const rename of result.directoriesRenamed) {
176
+ logger.info(` \u2713 ${rename.from} \u2192 ${rename.to}`);
177
+ }
178
+ }
179
+ if (settings.identifier !== currentIdentifier) {
180
+ logger.info("\nChanges:");
181
+ logger.info(` Identifier: ${currentIdentifier} \u2192 ${settings.identifier}`);
182
+ }
183
+ logger.info("");
184
+ }
185
+ export {
186
+ updatePackage
187
+ };
@@ -0,0 +1,226 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ validateTickControllerResult
4
+ } from "./cli-4LKXZQ2B.js";
5
+ import {
6
+ LOGIC_NODE_BUILTIN,
7
+ bundleFileOf,
8
+ didYouMean,
9
+ pointerOf,
10
+ readLogicExports
11
+ } from "./cli-SMFSZF2G.js";
12
+
13
+ // cli/validation/resource-validator.ts
14
+ import { existsSync } from "fs";
15
+ import { relative, resolve, sep } from "path";
16
+ function checkCapabilityReferences(label, resource, definition, keys, config) {
17
+ const known = (config.capabilities ?? []).map((capability) => capability.definition.identifier);
18
+ const declared = new Set(known);
19
+ const errors = [];
20
+ const findings = [];
21
+ const file = bundleFileOf(resource.type, resource.identifier);
22
+ for (const key of keys) {
23
+ (definition[key] ?? []).forEach((capability, index) => {
24
+ if (declared.has(capability)) return;
25
+ const message = `${label} "${resource.identifier}" ${key} capability "${capability}" which is not found in configuration`;
26
+ const hint = didYouMean(capability, known) ?? "Create it with `pnpm run sdk new capability`, or remove the entry.";
27
+ errors.push(message);
28
+ findings.push({
29
+ code: "REFERENCE_UNKNOWN",
30
+ message,
31
+ ...file === void 0 ? {} : { file },
32
+ pointer: pointerOf("definition", key, index),
33
+ resource,
34
+ hint
35
+ });
36
+ });
37
+ }
38
+ return { success: errors.length === 0, errors, findings };
39
+ }
40
+ function validateEngine(engine, config) {
41
+ return checkCapabilityReferences(
42
+ "Engine",
43
+ { type: "engine", identifier: engine.definition.identifier },
44
+ engine.definition,
45
+ ["reads", "writes"],
46
+ config
47
+ );
48
+ }
49
+ function validateUserInterface(userInterface, config) {
50
+ const identifier = userInterface.definition.identifier;
51
+ return checkCapabilityReferences(
52
+ "User Interface",
53
+ { type: identifier, identifier },
54
+ userInterface.definition,
55
+ ["reads", "writes"],
56
+ config
57
+ );
58
+ }
59
+ function validateEndpoint(endpoint, config) {
60
+ return checkCapabilityReferences(
61
+ "Endpoint",
62
+ { type: "endpoint", identifier: endpoint.definition.identifier },
63
+ endpoint.definition,
64
+ ["reads"],
65
+ config
66
+ );
67
+ }
68
+ function validateHook(hook, config) {
69
+ return checkCapabilityReferences(
70
+ "Hook",
71
+ { type: "hook", identifier: hook.definition.identifier },
72
+ hook.definition,
73
+ ["reads", "writes"],
74
+ config
75
+ );
76
+ }
77
+ function validateValidator(validator, config) {
78
+ return checkCapabilityReferences(
79
+ "Validator",
80
+ { type: "validator", identifier: validator.definition.identifier },
81
+ validator.definition,
82
+ ["reads"],
83
+ config
84
+ );
85
+ }
86
+ function validateTickController(tc, config) {
87
+ const tcId = tc.definition.identifier;
88
+ const references = checkCapabilityReferences(
89
+ "Tick Controller",
90
+ { type: "tick_controller", identifier: tcId },
91
+ tc.definition,
92
+ ["reads"],
93
+ config
94
+ );
95
+ const errors = [...references.errors];
96
+ const declaredInterval = staticIntervalCandidate(tc, config);
97
+ if (declaredInterval !== void 0) {
98
+ const intervalError = validateTickControllerResult({ intervalMs: declaredInterval });
99
+ if (intervalError) {
100
+ errors.push(`Tick Controller "${tcId}" has an out-of-range interval: ${intervalError}`);
101
+ }
102
+ }
103
+ return { success: errors.length === 0, errors, findings: references.findings };
104
+ }
105
+ function staticIntervalCandidate(tc, config) {
106
+ for (const identifier of tc.definition.settings ?? []) {
107
+ const settings = config.settings?.find((s) => s.definition.identifier === identifier);
108
+ const schema = settings?.definition.settingsSchema;
109
+ const intervalProp = schema?.properties?.intervalMs;
110
+ const candidate = intervalProp?.const ?? intervalProp?.default;
111
+ if (typeof candidate === "number") return candidate;
112
+ }
113
+ return void 0;
114
+ }
115
+ function builtinRefusal(check) {
116
+ return check.failure?.includes(LOGIC_NODE_BUILTIN) ? check.failure : void 0;
117
+ }
118
+ function refusedResult(message, check, resource) {
119
+ const located = (check.failureDiagnostics ?? []).map(
120
+ ({ severity: _severity, ...diagnostic }) => ({ ...diagnostic, resource })
121
+ );
122
+ return {
123
+ success: false,
124
+ errors: [message],
125
+ findings: located.length > 0 ? located.map((finding, i) => i === 0 ? { ...finding, message } : finding) : [{ code: "LOGIC_NODE_BUILTIN", message, resource }]
126
+ };
127
+ }
128
+ function logicFileOf(workingDir, logicFile) {
129
+ return relative(workingDir, logicFile).split(sep).join("/");
130
+ }
131
+ async function validateEngineFiles(engine, workingDir) {
132
+ const errors = [];
133
+ const engineDir = resolve(workingDir, engine.rootDirectory);
134
+ const logicDir = resolve(engineDir, engine.logic.directory);
135
+ const logicFile = resolve(logicDir, engine.logic.entrypoint);
136
+ const isAggregate = engine.definition.aggregate === true;
137
+ const requiredExports = isAggregate ? ["InitAggregate", "RunAggregate"] : ["Run"];
138
+ const expectedExports = isAggregate ? "InitAggregate and RunAggregate" : "Run";
139
+ const check = await readLogicExports(logicFile, requiredExports, workingDir);
140
+ const resource = { type: "engine", identifier: engine.definition.identifier };
141
+ const file = logicFileOf(workingDir, logicFile);
142
+ const findings = [];
143
+ if (!check.exists) {
144
+ const message = `Engine "${engine.definition.identifier}": Logic file not found: ${logicFile}. Create it with exports for ${expectedExports} functions.`;
145
+ errors.push(message);
146
+ findings.push({ code: "LOGIC_EXPORT_MISSING", message, file, resource });
147
+ return { success: errors.length === 0, errors, findings };
148
+ }
149
+ const refused = builtinRefusal(check);
150
+ if (refused) {
151
+ return refusedResult(
152
+ `Engine "${engine.definition.identifier}": ${refused}`,
153
+ check,
154
+ resource
155
+ );
156
+ }
157
+ const missingExports = requiredExports.filter((name) => !check.present.has(name));
158
+ for (const name of missingExports) {
159
+ const why = isAggregate ? `This engine is aggregate because its logic exports the other of "InitAggregate" / "RunAggregate". An aggregate engine runs across every team at both initialisation and tick time, so it needs both.` : "A per-team engine must export `Run`; `Init` is optional.";
160
+ const message = `Engine "${engine.definition.identifier}": Logic file "${logicFile}" does not export "${name}". ` + why;
161
+ errors.push(message);
162
+ findings.push({ code: "LOGIC_EXPORT_MISSING", message, file, resource });
163
+ }
164
+ return errors.length === 0 ? { success: true, errors } : { success: false, errors, findings };
165
+ }
166
+ async function validateEndpointFiles(endpoint, workingDir) {
167
+ const logicFile = resolve(
168
+ workingDir,
169
+ endpoint.rootDirectory,
170
+ endpoint.logic.directory,
171
+ endpoint.logic.entrypoint
172
+ );
173
+ const identifier = endpoint.definition.identifier;
174
+ const check = await readLogicExports(logicFile, ["Handle", "Plan"], workingDir);
175
+ const resource = { type: "endpoint", identifier };
176
+ const missing = (message) => ({
177
+ success: false,
178
+ errors: [message],
179
+ findings: [
180
+ {
181
+ code: "LOGIC_EXPORT_MISSING",
182
+ message,
183
+ file: logicFileOf(workingDir, logicFile),
184
+ resource
185
+ }
186
+ ]
187
+ });
188
+ if (!check.exists) {
189
+ return missing(
190
+ `Endpoint "${identifier}": Logic file not found: ${logicFile}. Create it exporting \`Handle\`, or \`Plan\` and \`Respond\`.`
191
+ );
192
+ }
193
+ const refused = builtinRefusal(check);
194
+ if (refused) {
195
+ return refusedResult(`Endpoint "${identifier}": ${refused}`, check, resource);
196
+ }
197
+ if (!check.present.has("Handle") && !check.present.has("Plan")) {
198
+ return missing(
199
+ `Endpoint "${identifier}": Logic file "${logicFile}" exports neither \`Handle\` nor \`Plan\`, so there is nothing to call. Export \`Handle\` to answer with the effects, or \`Plan\` and \`Respond\` to answer after they land.`
200
+ );
201
+ }
202
+ return { success: true, errors: [] };
203
+ }
204
+ function validateUIFiles(ui, workingDir) {
205
+ const errors = [];
206
+ const uiSourceDir = resolve(workingDir, ui.rootDirectory);
207
+ const entrypoint = resolve(uiSourceDir, ui.ui.entrypoint);
208
+ if (!existsSync(entrypoint)) {
209
+ errors.push(
210
+ `"${ui.definition.identifier}": UI entrypoint not found: ${entrypoint}. The UI directory "${uiSourceDir}" must contain "${ui.ui.entrypoint}".`
211
+ );
212
+ }
213
+ return { success: errors.length === 0, errors };
214
+ }
215
+
216
+ export {
217
+ validateEngine,
218
+ validateUserInterface,
219
+ validateEndpoint,
220
+ validateHook,
221
+ validateValidator,
222
+ validateTickController,
223
+ validateEngineFiles,
224
+ validateEndpointFiles,
225
+ validateUIFiles
226
+ };
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ deleteSessionUserInterfaceFiles,
4
+ findSessionUserInterfaceReferences
5
+ } from "./cli-FYINNRML.js";
6
+ import "./cli-IUS2YCD3.js";
7
+ import "./cli-QUNIRH7A.js";
8
+ import "./cli-BYJWFFCF.js";
9
+ import {
10
+ loadPackageContext
11
+ } from "./cli-XSVGKI3R.js";
12
+ import "./cli-MBNMPVDC.js";
13
+ import "./cli-GFBGYFYD.js";
14
+ import {
15
+ operationError,
16
+ recordOperationResult
17
+ } from "./cli-UELGBQG7.js";
18
+ import {
19
+ confirmAction
20
+ } from "./cli-ZTWOE3ZT.js";
21
+ import {
22
+ generateCommand
23
+ } from "./cli-4BV45LBH.js";
24
+ import "./cli-4AKVLEC4.js";
25
+ import "./cli-VCKOC2EV.js";
26
+ import "./cli-E2NLWIFE.js";
27
+ import "./cli-25RWY5BQ.js";
28
+ import "./cli-QWQMPCL6.js";
29
+ import "./cli-SMFSZF2G.js";
30
+ import "./cli-F2D4GGUA.js";
31
+ import {
32
+ logger
33
+ } from "./cli-4YB3ROVR.js";
34
+ import "./cli-N6H6T2E2.js";
35
+
36
+ // cli/commands/resources/session/delete.ts
37
+ async function deleteSessionUserInterface(options) {
38
+ logger.info("\nDeleting session user interface...\n");
39
+ const identifier = "session";
40
+ loadPackageContext(options.workingDir);
41
+ const references = findSessionUserInterfaceReferences({
42
+ packagePath: options.workingDir,
43
+ identifier
44
+ });
45
+ logger.info(`Session User Interface: ${identifier}`);
46
+ if (references.length > 0) {
47
+ logger.info("\nThis session user interface is used in games:");
48
+ for (const ref of references) {
49
+ logger.info(` - ${ref}`);
50
+ }
51
+ logger.info("\nThese references will be removed.");
52
+ }
53
+ const confirmed = await confirmAction(
54
+ { message: "Are you sure you want to delete this session user interface?" },
55
+ options.yes
56
+ );
57
+ if (!confirmed) {
58
+ logger.info("\nDeletion cancelled.\n");
59
+ return;
60
+ }
61
+ logger.info("");
62
+ const result = deleteSessionUserInterfaceFiles({
63
+ packagePath: options.workingDir,
64
+ identifier
65
+ });
66
+ if (!result.success) {
67
+ throw operationError(result, "Failed to delete session user interface files");
68
+ }
69
+ recordOperationResult(result);
70
+ for (const file of result.filesDeleted || []) {
71
+ logger.info(` \u2713 Deleted: ${file}`);
72
+ }
73
+ for (const ref of result.referencesRemoved || []) {
74
+ logger.info(` \u2713 Removed reference from: ${ref}`);
75
+ }
76
+ logger.info(" \u2713 Updated seriousgaming.sdk.json");
77
+ logger.info("\nRegenerating TypeScript types...\n");
78
+ try {
79
+ await generateCommand({ workingDir: options.workingDir });
80
+ logger.success("TypeScript types regenerated successfully!");
81
+ } catch (error) {
82
+ logger.warn("\nWarning: Failed to regenerate TypeScript types:");
83
+ logger.warn(error instanceof Error ? error.message : "Unknown error");
84
+ }
85
+ logger.success("Session user interface deleted successfully!");
86
+ }
87
+ export {
88
+ deleteSessionUserInterface
89
+ };