@seriousgaming/sdk-tools 1.5.0 → 1.6.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 (169) hide show
  1. package/dist/agent/guidance.md +350 -0
  2. package/dist/bundling/ui-bundler.d.ts +12 -0
  3. package/dist/cli-25RWY5BQ.js +41 -0
  4. package/dist/cli-2BH7FX27.js +52 -0
  5. package/dist/cli-2GZYGRVL.js +36 -0
  6. package/dist/cli-2NU2LPEE.js +97 -0
  7. package/dist/cli-3BRC32CP.js +132 -0
  8. package/dist/cli-3D3ZXWOV.js +111 -0
  9. package/dist/cli-3ZKWV3PN.js +96 -0
  10. package/dist/cli-45OCBG53.js +60 -0
  11. package/dist/cli-4LKXZQ2B.js +48 -0
  12. package/dist/cli-4PXNOJQX.js +81 -0
  13. package/dist/cli-4SIWLHQO.js +717 -0
  14. package/dist/cli-4UWFQNGF.js +54 -0
  15. package/dist/cli-4VFZHLDG.js +202 -0
  16. package/dist/cli-4YB3ROVR.js +78 -0
  17. package/dist/cli-5ACDPCXI.js +21 -0
  18. package/dist/cli-5IAW3LIF.js +38 -0
  19. package/dist/cli-5SM367K7.js +30 -0
  20. package/dist/cli-64AB62PM.js +25 -0
  21. package/dist/cli-6K3VQQUS.js +307 -0
  22. package/dist/cli-6QB2VFPY.js +80 -0
  23. package/dist/cli-6SGCYEEC.js +649 -0
  24. package/dist/cli-6UTPHWRQ.js +207 -0
  25. package/dist/cli-6VNKQ3OX.js +391 -0
  26. package/dist/cli-72XDEFU3.js +61 -0
  27. package/dist/cli-7A6MKCUJ.js +463 -0
  28. package/dist/cli-7XLHO2FE.js +226 -0
  29. package/dist/cli-AV2FYC5G.js +225 -0
  30. package/dist/cli-B6YHEKIJ.js +248 -0
  31. package/dist/cli-BJMS3VX3.js +1837 -0
  32. package/dist/cli-BUQI5UU4.js +43 -0
  33. package/dist/cli-BWX5E7TQ.js +23 -0
  34. package/dist/cli-BYCHKSSH.js +1331 -0
  35. package/dist/cli-C3CMJSNL.js +89 -0
  36. package/dist/cli-C47GJATR.js +42 -0
  37. package/dist/cli-C5QOJJWX.js +46 -0
  38. package/dist/cli-C6ZLPK2U.js +124 -0
  39. package/dist/cli-CD5CIJZI.js +72 -0
  40. package/dist/cli-DDJYUKQG.js +36 -0
  41. package/dist/cli-DFBTZEBX.js +167 -0
  42. package/dist/cli-DOXRQ3S5.js +60 -0
  43. package/dist/cli-EVI36HEM.js +79 -0
  44. package/dist/cli-F2D4GGUA.js +549 -0
  45. package/dist/cli-FQRVFGN6.js +0 -0
  46. package/dist/cli-FWFRKQNE.js +11 -0
  47. package/dist/cli-G6CANSPL.js +88 -0
  48. package/dist/cli-GFNDW2DL.js +124 -0
  49. package/dist/cli-HCRTYQQS.js +16 -0
  50. package/dist/cli-HFX3YPUL.js +76 -0
  51. package/dist/cli-HKORECAG.js +53 -0
  52. package/dist/cli-HOE3WLFH.js +73 -0
  53. package/dist/cli-HSIHDN6K.js +187 -0
  54. package/dist/cli-HW53ICZC.js +89 -0
  55. package/dist/cli-IDVUHGKG.js +218 -0
  56. package/dist/cli-IEMKI7J7.js +1387 -0
  57. package/dist/cli-ILFDANBR.js +101 -0
  58. package/dist/cli-ILKCQNM6.js +8 -0
  59. package/dist/cli-IP4RXGHM.js +2847 -0
  60. package/dist/cli-IUS2YCD3.js +31 -0
  61. package/dist/cli-J4DKUUTK.js +138 -0
  62. package/dist/cli-J4UBELKF.js +37 -0
  63. package/dist/cli-JJSWBW4H.js +89 -0
  64. package/dist/cli-JVI24FI6.js +68 -0
  65. package/dist/cli-JZCLIT3O.js +135 -0
  66. package/dist/cli-JZOZOEZM.js +131 -0
  67. package/dist/cli-KGM6RRQW.js +185 -0
  68. package/dist/cli-KGT5L7VZ.js +13641 -0
  69. package/dist/cli-KOGRWFN7.js +89 -0
  70. package/dist/cli-KSGB2ZLK.js +101 -0
  71. package/dist/cli-L7VYSXQK.js +243 -0
  72. package/dist/cli-LK3V4RI5.js +36 -0
  73. package/dist/cli-LQOHATY2.js +126 -0
  74. package/dist/cli-MJUYJIEP.js +13 -0
  75. package/dist/cli-MJV47HKI.js +143 -0
  76. package/dist/cli-MMN4BPO4.js +145 -0
  77. package/dist/cli-MOPSZ3CS.js +88 -0
  78. package/dist/cli-MU5LB43S.js +136 -0
  79. package/dist/cli-MYJGMA6U.js +40 -0
  80. package/dist/cli-N24OHSAN.js +36 -0
  81. package/dist/cli-N45DREM4.js +99 -0
  82. package/dist/cli-N6H6T2E2.js +616 -0
  83. package/dist/cli-NROTDF5Y.js +182 -0
  84. package/dist/cli-O5ABH2WK.js +226 -0
  85. package/dist/cli-OMWC75CC.js +256 -0
  86. package/dist/cli-OXAUOWCN.js +50 -0
  87. package/dist/cli-PGCIHPU7.js +143 -0
  88. package/dist/cli-Q6ZBZYK2.js +35 -0
  89. package/dist/cli-QUNIRH7A.js +57 -0
  90. package/dist/cli-QUSCIUOM.js +142 -0
  91. package/dist/cli-QVASWX2A.js +187 -0
  92. package/dist/cli-QWQMPCL6.js +253 -0
  93. package/dist/cli-QY5NZAR7.js +97 -0
  94. package/dist/cli-R2MUZQE2.js +62 -0
  95. package/dist/cli-RCIWBCXD.js +36 -0
  96. package/dist/cli-RLEGRWFM.js +81 -0
  97. package/dist/cli-RSW6EBBD.js +89 -0
  98. package/dist/cli-RZITKPJX.js +367 -0
  99. package/dist/cli-S5IVGDDD.js +32 -0
  100. package/dist/cli-SRHBXZCN.js +159 -0
  101. package/dist/cli-TDSQSCX4.js +131 -0
  102. package/dist/cli-TIDQ4WUE.js +257 -0
  103. package/dist/cli-TT36JCU5.js +370 -0
  104. package/dist/cli-TTKICM5P.js +100 -0
  105. package/dist/cli-TTMBBEJC.js +131 -0
  106. package/dist/cli-UMEBPAZQ.js +16 -0
  107. package/dist/cli-UNAJ2OTE.js +15 -0
  108. package/dist/cli-UZZFNXRX.js +226 -0
  109. package/dist/cli-VDBW23SS.js +81 -0
  110. package/dist/cli-VL2P354N.js +46 -0
  111. package/dist/cli-VPRRICZA.js +304 -0
  112. package/dist/cli-VQ6HVQW4.js +4010 -0
  113. package/dist/cli-WR3NOY74.js +36 -0
  114. package/dist/cli-WU43JT4T.js +52 -0
  115. package/dist/cli-XAT25PRU.js +117 -0
  116. package/dist/cli-XOTNXEJA.js +124 -0
  117. package/dist/cli-XSLNH5PR.js +6417 -0
  118. package/dist/cli-XSVGKI3R.js +39 -0
  119. package/dist/cli-XZCJIKIV.js +124 -0
  120. package/dist/cli-Y3DDNMPX.js +97 -0
  121. package/dist/cli-Y3O5F4JN.js +90 -0
  122. package/dist/cli-YOTGR3NB.js +82 -0
  123. package/dist/cli-Z56ZIVA6.js +97 -0
  124. package/dist/cli-ZBN5KAIB.js +59 -0
  125. package/dist/cli-ZDOTXEKL.js +31 -0
  126. package/dist/cli-ZDUADFBY.js +88 -0
  127. package/dist/cli-ZJFQ7EEA.js +131 -0
  128. package/dist/cli-ZTWOE3ZT.js +65 -0
  129. package/dist/cli.js +148 -43093
  130. package/dist/client/build-surfaces.d.ts +33 -0
  131. package/dist/client/dev-server.d.ts +6 -0
  132. package/dist/client/index.d.ts +1 -0
  133. package/dist/client/playwright.d.ts +62 -0
  134. package/dist/client.js +228 -48
  135. package/dist/core/session.d.ts +15 -1
  136. package/dist/dev/console/assets/{index-BVF8exas.js → index-CuMOOH9m.js} +1 -1
  137. package/dist/dev/console/index.html +1 -1
  138. package/dist/dev/shell.d.ts +19 -0
  139. package/dist/dev/surfaces.d.ts +7 -0
  140. package/dist/docs/ai-agents.md +1 -1
  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.md +34 -0
  145. package/dist/docs/cli-and-dev-server.md +21 -0
  146. package/dist/docs/cli-reference.md +45 -31
  147. package/dist/docs/environment-variables.md +6 -0
  148. package/dist/docs/getting-started.md +1 -1
  149. package/dist/docs/guides/designing-a-game.md +29 -4
  150. package/dist/docs/guides/starter-game.md +3 -3
  151. package/dist/docs/guides/testing.md +33 -18
  152. package/dist/docs/guides/upgrading.md +19 -2
  153. package/dist/docs/page-index.md +10 -9
  154. package/dist/docs/recipes/e2e-testing.md +19 -20
  155. package/dist/playwright.js +32232 -0
  156. package/dist/templates/package/CLAUDE.md.template +7 -346
  157. package/dist/templates/package/claude/rules/workflow-create-engine.md +2 -2
  158. package/dist/templates/package/claude/rules/workflow-create-guide.md +2 -2
  159. package/dist/templates/package/claude/rules/workflow-create-user-interface.md +1 -1
  160. package/dist/templates/package/claude/rules/workflow-test-engine-or-ui.md +1 -1
  161. package/dist/templates/package/claude/rules/workflow-update-sdk-version.md +3 -3
  162. package/dist/templates/package/global-setup.ts.template +7 -18
  163. package/dist/templates/package/playwright.config.ts.liquid +8 -11
  164. package/dist/templates/starter-game/playwright.config.ts +8 -11
  165. package/dist/templates/starter-game/testing/e2e/game.spec.ts +1 -1
  166. package/dist/templates/starter-game/testing/e2e/global-setup.ts +7 -18
  167. package/dist/utils/prompt.d.ts +5 -5
  168. package/dist/utils/resource-scan.d.ts +39 -0
  169. package/package.json +7 -3
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ deleteSessionUserInterfaceFiles,
4
+ findSessionUserInterfaceReferences
5
+ } from "./cli-4SIWLHQO.js";
6
+ import "./cli-IUS2YCD3.js";
7
+ import "./cli-QUNIRH7A.js";
8
+ import "./cli-J4UBELKF.js";
9
+ import {
10
+ loadPackageContext
11
+ } from "./cli-XSVGKI3R.js";
12
+ import "./cli-TT36JCU5.js";
13
+ import "./cli-OXAUOWCN.js";
14
+ import {
15
+ operationError,
16
+ recordOperationResult
17
+ } from "./cli-KSGB2ZLK.js";
18
+ import {
19
+ confirmAction
20
+ } from "./cli-ZTWOE3ZT.js";
21
+ import {
22
+ generateCommand
23
+ } from "./cli-LQOHATY2.js";
24
+ import "./cli-IEMKI7J7.js";
25
+ import "./cli-OMWC75CC.js";
26
+ import "./cli-BYCHKSSH.js";
27
+ import "./cli-25RWY5BQ.js";
28
+ import "./cli-QWQMPCL6.js";
29
+ import "./cli-VQ6HVQW4.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
+ };
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ stopLockedServer
4
+ } from "./cli-WU43JT4T.js";
5
+ import {
6
+ inspectLockFile,
7
+ readLockFile,
8
+ removeLockFile
9
+ } from "./cli-SRHBXZCN.js";
10
+ import {
11
+ reportResult
12
+ } from "./cli-N6H6T2E2.js";
13
+
14
+ // cli/commands/dev-control.ts
15
+ async function devStatusCommand(options) {
16
+ const inspection = await inspectLockFile(options.workingDir);
17
+ if (inspection.status === "stale") await removeLockFile(options.workingDir);
18
+ const lock = "lock" in inspection ? inspection.lock : null;
19
+ const responding = inspection.status === "live";
20
+ reportResult(
21
+ lock ? { running: true, responding, url: `http://localhost:${lock.port}`, ...lock } : { running: false },
22
+ () => console.log(
23
+ !lock ? "No dev server is running for this package." : responding ? `Running at http://localhost:${lock.port} (pid ${lock.pid}, since ${lock.startedAt})` : `Running at http://localhost:${lock.port} (pid ${lock.pid}, since ${lock.startedAt}), but not answering. Stop it with \`sdk dev stop\`.`
24
+ )
25
+ );
26
+ }
27
+ async function devStopCommand(options) {
28
+ const lock = await readLockFile(options.workingDir, { unresponsive: "accept" });
29
+ if (!lock) {
30
+ reportResult(
31
+ { stopped: false },
32
+ () => console.log("No dev server is running for this package.")
33
+ );
34
+ return;
35
+ }
36
+ await stopLockedServer(options.workingDir, lock);
37
+ reportResult({ stopped: true, pid: lock.pid }, () => console.log("Dev server stopped."));
38
+ }
39
+ export {
40
+ devStatusCommand,
41
+ devStopCommand
42
+ };
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ CliError
4
+ } from "./cli-N6H6T2E2.js";
5
+
6
+ // cli/dev/default-port.ts
7
+ var DEV_PORT_ENV_VAR = "SERIOUSGAMING_DEV_PORT";
8
+ function defaultDevPort() {
9
+ return process.env[DEV_PORT_ENV_VAR] || "3000";
10
+ }
11
+ function parseDevPortOrAuto(value) {
12
+ return value.trim().toLowerCase() === "auto" ? 0 : parseDevPort(value);
13
+ }
14
+ function parseDevPort(value) {
15
+ const port = Number(value);
16
+ if (!Number.isInteger(port) || port < 1 || port > 65535) {
17
+ throw new CliError(
18
+ "USAGE_BAD_FLAG",
19
+ `"${value}" is not a port. Pass a whole number between 1 and 65535 (or \`auto\`) to --port, or in ${DEV_PORT_ENV_VAR}.`
20
+ );
21
+ }
22
+ return port;
23
+ }
24
+
25
+ // cli/dev/error-overlay.ts
26
+ var ERROR_OVERLAY_ENV_VAR = "SERIOUSGAMING_DEV_ERROR_OVERLAY";
27
+ function resolveErrorOverlay(flag, env = process.env) {
28
+ if (flag === false) return false;
29
+ const value = env[ERROR_OVERLAY_ENV_VAR]?.trim().toLowerCase();
30
+ if (!value) return true;
31
+ if (value === "false" || value === "0") return false;
32
+ if (value === "true" || value === "1") return true;
33
+ throw new CliError(
34
+ "USAGE_BAD_FLAG",
35
+ `${ERROR_OVERLAY_ENV_VAR}="${env[ERROR_OVERLAY_ENV_VAR]}" is neither true nor false.`
36
+ );
37
+ }
38
+
39
+ export {
40
+ DEV_PORT_ENV_VAR,
41
+ defaultDevPort,
42
+ parseDevPortOrAuto,
43
+ parseDevPort,
44
+ ERROR_OVERLAY_ENV_VAR,
45
+ resolveErrorOverlay
46
+ };
@@ -0,0 +1,124 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ resolveSession
4
+ } from "./cli-6K3VQQUS.js";
5
+ import {
6
+ emit,
7
+ participantsFromArgument,
8
+ raiseIfRefused,
9
+ requireScenario,
10
+ sessionSummary,
11
+ teamCountFromFlag,
12
+ teamIndexFromArgument,
13
+ tickReport
14
+ } from "./cli-L7VYSXQK.js";
15
+ import {
16
+ applyJsonPatch
17
+ } from "./cli-S5IVGDDD.js";
18
+ import {
19
+ CliError
20
+ } from "./cli-N6H6T2E2.js";
21
+
22
+ // cli/commands/tick.ts
23
+ import dotenv from "dotenv";
24
+ dotenv.config({ path: ".env", debug: false, quiet: true });
25
+ async function tickCommand(options) {
26
+ const session = await resolveSession({
27
+ packagePath: options.workingDir,
28
+ ...options.walkthrough ? { runKind: "walkthrough" } : {},
29
+ ...options.server === false ? { noServer: true } : {},
30
+ ...options.teams === void 0 ? {} : { teams: teamCountFromFlag(options.teams) },
31
+ ...options.participants === void 0 ? {} : { participants: participantsFromArgument(options.participants) },
32
+ ...options.scenario === void 0 ? {} : { scenarioId: requireScenario(options.workingDir, options.scenario) },
33
+ ...options.locale === void 0 ? {} : { locale: options.locale }
34
+ });
35
+ try {
36
+ let state = await session.state();
37
+ const teamIndex = teamIndexFromArgument(state, options.team);
38
+ if (options.team !== void 0 && state.teams.length <= 1) {
39
+ throw new CliError(
40
+ "USAGE_NOT_APPLICABLE",
41
+ "--team can only be used with multi-team games (started with --teams N)"
42
+ );
43
+ }
44
+ if (options.patch && state.teams.length > 1 && teamIndex === void 0) {
45
+ throw new CliError(
46
+ "USAGE_MISSING_ARGUMENT",
47
+ "--team is required when using --patch with a multi-team game"
48
+ );
49
+ }
50
+ if (options.patch) {
51
+ await submitPatch(session, state, options.patch, teamIndex);
52
+ }
53
+ const result = await session.send({
54
+ type: "tick",
55
+ ...teamIndex === void 0 ? {} : { teamIndex }
56
+ });
57
+ raiseIfRefused(result);
58
+ state = await session.state();
59
+ if (state.session.complete) {
60
+ console.error("Game complete after this tick \u2014 no further ticks will be allowed");
61
+ }
62
+ emit(options.summary ? sessionSummary(state) : tickReport(state));
63
+ } finally {
64
+ await session.close();
65
+ }
66
+ }
67
+ async function submitSharedPatch(session, state, patch) {
68
+ let operations;
69
+ try {
70
+ operations = JSON.parse(patch);
71
+ } catch (error) {
72
+ throw new CliError("INPUT_INVALID", `Failed to apply patch: ${error.message}`);
73
+ }
74
+ if (operations.some((operation) => operation.op === "remove")) {
75
+ throw new CliError(
76
+ "INPUT_INVALID",
77
+ "A shared write merges into the store, so it cannot remove a value. Replace it instead"
78
+ );
79
+ }
80
+ let patched;
81
+ try {
82
+ patched = applyJsonPatch(state.shared, operations);
83
+ } catch (error) {
84
+ throw new CliError("INPUT_INVALID", `Failed to apply patch: ${error.message}`);
85
+ }
86
+ const touched = new Set(
87
+ operations.map(
88
+ (operation) => (operation.path.split("/")[1] ?? "").replace(/~1/g, "/").replace(/~0/g, "~")
89
+ )
90
+ );
91
+ const payload = Object.fromEntries(
92
+ [...touched].filter((id) => id in patched).map((id) => [id, patched[id]])
93
+ );
94
+ raiseIfRefused(await session.send({ type: "updateSharedContext", payload }));
95
+ }
96
+ async function submitPatch(session, state, patch, teamIndex) {
97
+ let operations;
98
+ try {
99
+ operations = JSON.parse(patch);
100
+ } catch (error) {
101
+ throw new CliError("INPUT_INVALID", `Failed to apply patch: ${error.message}`);
102
+ }
103
+ const team = teamIndex === void 0 ? [...state.teams].sort((a, b) => a.index - b.index)[0] : state.teams.find((candidate) => candidate.index === teamIndex);
104
+ let payload;
105
+ try {
106
+ payload = applyJsonPatch(team?.context ?? {}, operations);
107
+ } catch (error) {
108
+ throw new CliError("INPUT_INVALID", `Failed to apply patch: ${error.message}`);
109
+ }
110
+ const deletes = operations.filter((operation) => operation.op === "remove").map((operation) => operation.path.split("/").filter((segment) => segment.length > 0));
111
+ const result = await session.send({
112
+ type: "updateContext",
113
+ payload,
114
+ ...deletes.length === 0 ? {} : { deletes },
115
+ ...teamIndex === void 0 ? {} : { teamIndex }
116
+ });
117
+ raiseIfRefused(result);
118
+ }
119
+
120
+ export {
121
+ tickCommand,
122
+ submitSharedPatch,
123
+ submitPatch
124
+ };
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ deleteScenarioFiles,
4
+ findScenarioReferences
5
+ } from "./cli-J4UBELKF.js";
6
+ import {
7
+ loadPackageContext
8
+ } from "./cli-XSVGKI3R.js";
9
+ import "./cli-TT36JCU5.js";
10
+ import "./cli-OXAUOWCN.js";
11
+ import {
12
+ operationError,
13
+ recordOperationResult
14
+ } from "./cli-KSGB2ZLK.js";
15
+ import {
16
+ confirmAction
17
+ } from "./cli-ZTWOE3ZT.js";
18
+ import "./cli-LQOHATY2.js";
19
+ import "./cli-IEMKI7J7.js";
20
+ import "./cli-OMWC75CC.js";
21
+ import "./cli-BYCHKSSH.js";
22
+ import "./cli-25RWY5BQ.js";
23
+ import "./cli-QWQMPCL6.js";
24
+ import "./cli-VQ6HVQW4.js";
25
+ import "./cli-F2D4GGUA.js";
26
+ import {
27
+ logger
28
+ } from "./cli-4YB3ROVR.js";
29
+ import "./cli-N6H6T2E2.js";
30
+
31
+ // cli/commands/resources/scenario/delete.ts
32
+ async function deleteScenario(identifier, options) {
33
+ logger.info("\nDeleting scenario...\n");
34
+ loadPackageContext(options.workingDir);
35
+ const references = findScenarioReferences({
36
+ packagePath: options.workingDir,
37
+ identifier
38
+ });
39
+ logger.info(`Scenario: ${identifier}`);
40
+ if (references.length > 0) {
41
+ logger.info("\nThis scenario is referenced by:");
42
+ for (const ref of references) {
43
+ logger.info(` - ${ref}`);
44
+ }
45
+ logger.info("\nYou will need to remove these references manually.");
46
+ }
47
+ const confirmed = await confirmAction(
48
+ { message: "Are you sure you want to delete this scenario?" },
49
+ options.yes
50
+ );
51
+ if (!confirmed) {
52
+ logger.info("\nDeletion cancelled.\n");
53
+ return;
54
+ }
55
+ logger.info("");
56
+ const result = deleteScenarioFiles({
57
+ packagePath: options.workingDir,
58
+ identifier
59
+ });
60
+ if (!result.success) {
61
+ throw operationError(result, "Failed to delete scenario files");
62
+ }
63
+ recordOperationResult(result);
64
+ for (const file of result.filesDeleted || []) {
65
+ logger.info(` \u2713 Deleted: ${file}`);
66
+ }
67
+ logger.info(" \u2713 Updated seriousgaming.sdk.json");
68
+ logger.success("Scenario deleted successfully!");
69
+ }
70
+ export {
71
+ deleteScenario
72
+ };
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ deleteSettingsEditor
4
+ } from "./cli-AV2FYC5G.js";
5
+ import "./cli-Q6ZBZYK2.js";
6
+ import "./cli-5IAW3LIF.js";
7
+ import "./cli-S5IVGDDD.js";
8
+ import "./cli-4VFZHLDG.js";
9
+ import "./cli-4UWFQNGF.js";
10
+ import "./cli-4SIWLHQO.js";
11
+ import "./cli-IUS2YCD3.js";
12
+ import "./cli-QUNIRH7A.js";
13
+ import "./cli-J4UBELKF.js";
14
+ import "./cli-XSVGKI3R.js";
15
+ import "./cli-TT36JCU5.js";
16
+ import "./cli-OXAUOWCN.js";
17
+ import "./cli-KSGB2ZLK.js";
18
+ import "./cli-ZTWOE3ZT.js";
19
+ import "./cli-LQOHATY2.js";
20
+ import "./cli-IEMKI7J7.js";
21
+ import "./cli-OMWC75CC.js";
22
+ import "./cli-BYCHKSSH.js";
23
+ import "./cli-25RWY5BQ.js";
24
+ import "./cli-QWQMPCL6.js";
25
+ import "./cli-VQ6HVQW4.js";
26
+ import "./cli-F2D4GGUA.js";
27
+ import "./cli-4YB3ROVR.js";
28
+ import "./cli-N6H6T2E2.js";
29
+
30
+ // cli/commands/resources/scenario-editor/delete.ts
31
+ function deleteScenarioEditor(options) {
32
+ return deleteSettingsEditor("scenario_editor", options);
33
+ }
34
+ export {
35
+ deleteScenarioEditor
36
+ };
@@ -0,0 +1,167 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ getPackageIdentifierError,
4
+ getVersionError,
5
+ parseAuthoredInput
6
+ } from "./cli-4VFZHLDG.js";
7
+ import {
8
+ resolveInputSource
9
+ } from "./cli-4UWFQNGF.js";
10
+ import {
11
+ createPackageFiles
12
+ } from "./cli-4SIWLHQO.js";
13
+ import "./cli-IUS2YCD3.js";
14
+ import "./cli-QUNIRH7A.js";
15
+ import "./cli-J4UBELKF.js";
16
+ import "./cli-TT36JCU5.js";
17
+ import "./cli-OXAUOWCN.js";
18
+ import {
19
+ generateTypes,
20
+ operationError,
21
+ recordOperationResult
22
+ } from "./cli-KSGB2ZLK.js";
23
+ import {
24
+ input
25
+ } from "./cli-ZTWOE3ZT.js";
26
+ import "./cli-LQOHATY2.js";
27
+ import "./cli-IEMKI7J7.js";
28
+ import "./cli-OMWC75CC.js";
29
+ import "./cli-BYCHKSSH.js";
30
+ import "./cli-25RWY5BQ.js";
31
+ import "./cli-QWQMPCL6.js";
32
+ import "./cli-VQ6HVQW4.js";
33
+ import {
34
+ resourceExample
35
+ } from "./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/new.ts
44
+ function requiredString(input2, field) {
45
+ const value = input2[field];
46
+ if (typeof value !== "string" || !value) {
47
+ throw new CliError(
48
+ "INPUT_INVALID",
49
+ `Validation error: \`${field}\` is required and must be a string.
50
+
51
+ Expected format:
52
+ ${resourceExample("package", "new")}`
53
+ );
54
+ }
55
+ return value;
56
+ }
57
+ async function createPackage(definitionInput, options) {
58
+ const inputSource = await resolveInputSource(definitionInput, options.file);
59
+ const jsonDefinition = inputSource.kind === "json" ? inputSource.json : null;
60
+ if (jsonDefinition) {
61
+ const packageInput = parseAuthoredInput(jsonDefinition, "package", "new");
62
+ const identifier2 = requiredString(packageInput, "identifier");
63
+ const name2 = requiredString(packageInput, "name");
64
+ const version2 = requiredString(packageInput, "version");
65
+ for (const [field, error] of [
66
+ ["identifier", getPackageIdentifierError(identifier2)],
67
+ ["version", getVersionError(version2)]
68
+ ]) {
69
+ if (error)
70
+ throw new CliError("INPUT_INVALID", `Validation error: \`${field}\` ${error}`);
71
+ }
72
+ logger.info("\nCreating package files...\n");
73
+ const result2 = await createPackageFiles({
74
+ packagePath: options.workingDir,
75
+ identifier: identifier2,
76
+ name: name2,
77
+ version: version2,
78
+ empty: options.empty,
79
+ skipInstall: options.skipInstall
80
+ });
81
+ if (!result2.success) {
82
+ throw operationError(result2, "Failed to create package files");
83
+ }
84
+ logger.success("Package created successfully!");
85
+ logger.info("Files created:");
86
+ recordOperationResult(result2);
87
+ for (const file of result2.filesCreated || []) {
88
+ logger.info(` \u2713 ${file}`);
89
+ }
90
+ if (!options.empty) {
91
+ await generateTypes(options.workingDir);
92
+ }
93
+ raiseIfInstallFailed(result2);
94
+ logger.info("\nNext steps:");
95
+ logger.info(' 1. Run "pnpm run sdk init" to initialise your game');
96
+ logger.info(' 2. Run "pnpm run sdk tick" to run a tick');
97
+ logger.info(' 3. Run "pnpm run sdk dev" to open the dev server');
98
+ return;
99
+ }
100
+ logger.info("\nCreating new Serious Gaming package...\n");
101
+ const identifier = await input({
102
+ message: "Package identifier (namespace-style):",
103
+ default: "com.example.mypackage",
104
+ validate: (value) => {
105
+ const error = getPackageIdentifierError(value);
106
+ return error || true;
107
+ }
108
+ });
109
+ const name = await input({
110
+ message: "Package name (friendly display name):",
111
+ default: "My Package",
112
+ validate: (value) => {
113
+ if (!value.trim()) {
114
+ return "Package name is required";
115
+ }
116
+ return true;
117
+ }
118
+ });
119
+ const version = await input({
120
+ message: "Package version:",
121
+ default: "1.0.0",
122
+ validate: (value) => {
123
+ const error = getVersionError(value);
124
+ return error || true;
125
+ }
126
+ });
127
+ logger.info("\nCreating package files...\n");
128
+ const result = await createPackageFiles({
129
+ packagePath: options.workingDir,
130
+ identifier,
131
+ name,
132
+ version,
133
+ empty: options.empty,
134
+ skipInstall: options.skipInstall
135
+ });
136
+ if (!result.success) {
137
+ throw operationError(result, "Failed to create package files");
138
+ }
139
+ logger.success("Package created successfully!");
140
+ logger.info("Files created:");
141
+ recordOperationResult(result);
142
+ for (const file of result.filesCreated || []) {
143
+ logger.info(` \u2713 ${file}`);
144
+ }
145
+ if (!options.empty) {
146
+ await generateTypes(options.workingDir);
147
+ }
148
+ raiseIfInstallFailed(result);
149
+ logger.info("\nNext steps:");
150
+ logger.info(' 1. Run "pnpm run sdk init" to initialise your game');
151
+ logger.info(' 2. Run "pnpm run sdk tick" to run a tick');
152
+ logger.info(' 3. Run "pnpm run sdk dev" to open the dev server');
153
+ }
154
+ function raiseIfInstallFailed(result) {
155
+ if (!result.installFailed) return;
156
+ throw new CliError(
157
+ "INSTALL_FAILED",
158
+ "The package was created, but `pnpm install` failed in it.",
159
+ {
160
+ hint: 'Run "pnpm install" in the package directory, then carry on.',
161
+ details: { filesCreated: result.filesCreated ?? [] }
162
+ }
163
+ );
164
+ }
165
+ export {
166
+ createPackage
167
+ };
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ runResourceCommand
4
+ } from "./cli-HFX3YPUL.js";
5
+ import {
6
+ RESOURCE_DESCRIPTORS_BY_TYPE,
7
+ supportedTypes
8
+ } from "./cli-VPRRICZA.js";
9
+ import "./cli-KSGB2ZLK.js";
10
+ import "./cli-ZTWOE3ZT.js";
11
+ import "./cli-LQOHATY2.js";
12
+ import "./cli-IEMKI7J7.js";
13
+ import "./cli-OMWC75CC.js";
14
+ import "./cli-BYCHKSSH.js";
15
+ import "./cli-25RWY5BQ.js";
16
+ import "./cli-QWQMPCL6.js";
17
+ import "./cli-VQ6HVQW4.js";
18
+ import "./cli-F2D4GGUA.js";
19
+ import "./cli-4YB3ROVR.js";
20
+ import {
21
+ CliError
22
+ } from "./cli-N6H6T2E2.js";
23
+
24
+ // cli/commands/update.ts
25
+ async function updateCommand(resourceType, identifierOrDefinition, definition, options) {
26
+ const descriptor = RESOURCE_DESCRIPTORS_BY_TYPE.get(resourceType);
27
+ const isUnidentified = descriptor?.update.kind === "unidentified";
28
+ await runResourceCommand(
29
+ {
30
+ command: "update",
31
+ resourceType,
32
+ packagePath: options.workingDir,
33
+ identifier: isUnidentified ? void 0 : identifierOrDefinition
34
+ },
35
+ async () => {
36
+ if (!descriptor) {
37
+ throw new CliError(
38
+ "RESOURCE_TYPE_UNKNOWN",
39
+ `Resource type "${resourceType}" is not supported for updates
40
+ Supported types: ${supportedTypes("update")}`
41
+ );
42
+ }
43
+ if (descriptor.update.kind === "unidentified") {
44
+ await descriptor.update.run(identifierOrDefinition, options);
45
+ return;
46
+ }
47
+ if (!identifierOrDefinition) {
48
+ throw new CliError(
49
+ "USAGE_MISSING_ARGUMENT",
50
+ `Resource identifier is required.
51
+ Usage: seriousgaming-sdk update ${resourceType} <identifier> [definition]`
52
+ );
53
+ }
54
+ await descriptor.update.run(identifierOrDefinition, definition, options);
55
+ }
56
+ );
57
+ }
58
+ export {
59
+ updateCommand
60
+ };