@seriousgaming/sdk-tools 1.5.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 (160) 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 +148 -43093
  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 +228 -48
  134. package/dist/core/session.d.ts +15 -1
  135. package/dist/dev/console/assets/{index-BVF8exas.js → index-CuMOOH9m.js} +1 -1
  136. package/dist/dev/console/index.html +1 -1
  137. package/dist/dev/shell.d.ts +19 -0
  138. package/dist/dev/surfaces.d.ts +7 -0
  139. package/dist/docs/api/index.md +14 -12
  140. package/dist/docs/api/sdk-tools-client.md +29 -0
  141. package/dist/docs/api/sdk-tools-playwright.md +104 -0
  142. package/dist/docs/changelog.md +19 -0
  143. package/dist/docs/cli-and-dev-server.md +21 -0
  144. package/dist/docs/cli-reference.md +45 -31
  145. package/dist/docs/environment-variables.md +6 -0
  146. package/dist/docs/guides/designing-a-game.md +29 -4
  147. package/dist/docs/guides/starter-game.md +2 -2
  148. package/dist/docs/guides/testing.md +33 -18
  149. package/dist/docs/page-index.md +8 -7
  150. package/dist/docs/recipes/e2e-testing.md +19 -20
  151. package/dist/playwright.js +32232 -0
  152. package/dist/templates/package/claude/rules/workflow-test-engine-or-ui.md +1 -1
  153. package/dist/templates/package/global-setup.ts.template +7 -18
  154. package/dist/templates/package/playwright.config.ts.liquid +8 -11
  155. package/dist/templates/starter-game/playwright.config.ts +8 -11
  156. package/dist/templates/starter-game/testing/e2e/game.spec.ts +1 -1
  157. package/dist/templates/starter-game/testing/e2e/global-setup.ts +7 -18
  158. package/dist/utils/prompt.d.ts +5 -5
  159. package/dist/utils/resource-scan.d.ts +39 -0
  160. package/package.json +7 -3
@@ -0,0 +1,616 @@
1
+ #!/usr/bin/env node
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ try {
10
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
11
+ } catch (e) {
12
+ throw mod = 0, e;
13
+ }
14
+ };
15
+ var __export = (target, all) => {
16
+ for (var name in all)
17
+ __defProp(target, name, { get: all[name], enumerable: true });
18
+ };
19
+ var __copyProps = (to, from, except, desc) => {
20
+ if (from && typeof from === "object" || typeof from === "function") {
21
+ for (let key of __getOwnPropNames(from))
22
+ if (!__hasOwnProp.call(to, key) && key !== except)
23
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
24
+ }
25
+ return to;
26
+ };
27
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
28
+ // If the importer is in node compatibility mode or this is not an ESM
29
+ // file that has been converted to a CommonJS file using a Babel-
30
+ // compatible transform (i.e. "__esModule" has not been set), then set
31
+ // "default" to the CommonJS "module.exports" for node compatibility.
32
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
33
+ mod
34
+ ));
35
+
36
+ // cli/utils/error-codes.ts
37
+ var EXIT_CODES = {
38
+ internal: 1,
39
+ usage: 2,
40
+ package: 3,
41
+ refused: 4,
42
+ environment: 5
43
+ };
44
+ var ERROR_CODES = {
45
+ // 1: internal
46
+ INTERNAL: {
47
+ category: "internal",
48
+ description: "An unexpected failure inside the CLI. Please report it."
49
+ },
50
+ // 2: usage
51
+ USAGE_UNKNOWN_COMMAND: {
52
+ category: "usage",
53
+ description: "The command or subcommand does not exist."
54
+ },
55
+ USAGE_REMOVED_COMMAND: {
56
+ category: "usage",
57
+ description: "The command was removed in an earlier release; the hint names what replaces it."
58
+ },
59
+ USAGE_BAD_FLAG: {
60
+ category: "usage",
61
+ description: "A flag is unknown, has a value the command cannot use, or is combined with one it cannot be."
62
+ },
63
+ USAGE_BAD_ARGUMENT: {
64
+ category: "usage",
65
+ description: "A positional argument has a value the command cannot use."
66
+ },
67
+ USAGE_MISSING_ARGUMENT: {
68
+ category: "usage",
69
+ description: "A required argument or flag was not given."
70
+ },
71
+ USAGE_MISSING_INPUT: {
72
+ category: "usage",
73
+ description: "The command needs input (a JSON definition, settings or a patch) and none was given as an argument, with --file or on stdin."
74
+ },
75
+ USAGE_NOT_APPLICABLE: {
76
+ category: "usage",
77
+ description: "The command or flag does not apply to this package or session, such as --team on a single-team game."
78
+ },
79
+ PROMPT_REQUIRED: {
80
+ category: "usage",
81
+ description: "The command would have to ask a question, and prompts are off: there is no terminal, --json or SERIOUSGAMING_JSON is set, or CI is set."
82
+ },
83
+ INPUT_INVALID: {
84
+ category: "usage",
85
+ description: "Input given to the command is not valid JSON, or does not match the shape it must have."
86
+ },
87
+ FILE_NOT_FOUND: {
88
+ category: "usage",
89
+ description: "A file named on the command line does not exist or cannot be read."
90
+ },
91
+ DOCS_SECTION_NOT_FOUND: {
92
+ category: "usage",
93
+ description: "The page `docs view --section` reads has no heading by that name; the details list the ones it has."
94
+ },
95
+ RESOURCE_TYPE_UNKNOWN: {
96
+ category: "usage",
97
+ description: "The resource type does not exist, or does not support this operation."
98
+ },
99
+ RESOURCE_NOT_FOUND: {
100
+ category: "usage",
101
+ description: "The package has no resource of that type with that identifier."
102
+ },
103
+ RESOURCE_EXISTS: {
104
+ category: "usage",
105
+ description: "A resource with that identifier, or in that slot, already exists."
106
+ },
107
+ BUILD_NOT_FOUND: {
108
+ category: "usage",
109
+ description: "The build output or bundle the command reads is missing. Run `build` (or `package bundle`) first."
110
+ },
111
+ PUBLISHER_MISSING: {
112
+ category: "usage",
113
+ description: "No publisher was given with --publisher, SERIOUSGAMING_PUBLISHER or platform.defaultPublisher."
114
+ },
115
+ // 3: package
116
+ PACKAGE_INVALID: {
117
+ category: "package",
118
+ description: "The package fails validation. The diagnostics say where. As a diagnostic code, a finding no finer code describes yet."
119
+ },
120
+ MANIFEST_NOT_FOUND: {
121
+ category: "package",
122
+ description: "There is no seriousgaming.sdk.json (or package.json) where the command looked."
123
+ },
124
+ MANIFEST_INVALID: {
125
+ category: "package",
126
+ description: "seriousgaming.sdk.json or package.json cannot be read, or is not valid."
127
+ },
128
+ BUNDLE_INVALID: {
129
+ category: "package",
130
+ description: "A resource's bundle file (such as engine.sdk.json) cannot be read, or is not valid."
131
+ },
132
+ LOGIC_NODE_BUILTIN: {
133
+ category: "package",
134
+ description: "Game logic imports a Node built-in, which is absent in production: logic runs on the JavaScript language alone."
135
+ },
136
+ LOGIC_BUNDLE_FAILED: {
137
+ category: "package",
138
+ description: "A logic file does not bundle: a syntax error, or an import that does not resolve."
139
+ },
140
+ SCHEMA_INVALID: {
141
+ category: "package",
142
+ description: "A bundle or the manifest does not match the SDK's schema. The diagnostic's pointer names the value."
143
+ },
144
+ JSON_INVALID: {
145
+ category: "package",
146
+ description: "A bundle file is not valid JSON."
147
+ },
148
+ BUNDLE_MISSING: {
149
+ category: "package",
150
+ description: "A resource directory holds no bundle file."
151
+ },
152
+ REMOVED_FIELD: {
153
+ category: "package",
154
+ description: "A bundle or the manifest carries a field the SDK no longer reads. The hint says what replaced it."
155
+ },
156
+ LAYOUT_OUTDATED: {
157
+ category: "package",
158
+ description: "A directory or bundle file sits where an earlier version of the SDK kept it. The hint says where it goes now."
159
+ },
160
+ FEATURE_UNSUPPORTED: {
161
+ category: "package",
162
+ description: "The manifest's `requires` names an optional feature this version of the SDK does not support."
163
+ },
164
+ FEATURE_UNDECLARED: {
165
+ category: "package",
166
+ description: "The package uses an optional feature its manifest's `requires` does not list, so a runtime without the feature would run it with part of it missing."
167
+ },
168
+ REFERENCE_UNKNOWN: {
169
+ category: "package",
170
+ description: "A `reads`, `writes`, `settings`, `configures` or `endpoints` entry names something the package does not declare."
171
+ },
172
+ SETTINGS_UNKNOWN: {
173
+ category: "package",
174
+ description: "A scenario overrides a settings resource the package does not declare."
175
+ },
176
+ SETTINGS_UNKNOWN_KEY: {
177
+ category: "package",
178
+ description: "A scenario overrides a key that its settings resource does not declare."
179
+ },
180
+ SETTINGS_INVALID: {
181
+ category: "package",
182
+ description: "A scenario's override does not match its settings resource's schema."
183
+ },
184
+ SETTINGS_RESERVED: {
185
+ category: "package",
186
+ description: "A settings resource is named `game`, which is reserved for the built-in game settings."
187
+ },
188
+ SETTINGS_LOCKED: {
189
+ category: "package",
190
+ description: "A scenario overrides a setting the game locks with `readOnly`, in its settings schema or its `gameSettingsConstraints`."
191
+ },
192
+ GAME_CONSTRAINT_INVALID: {
193
+ category: "package",
194
+ description: "A `gameSettingsConstraints` entry widens the SDK schema for the `game` settings rather than narrowing it."
195
+ },
196
+ GAME_CONSTRAINT_VIOLATED: {
197
+ category: "package",
198
+ description: "The game's own value for a `game` setting breaks its `gameSettingsConstraints`."
199
+ },
200
+ LOGIC_EXPORT_MISSING: {
201
+ category: "package",
202
+ description: "A logic file is missing, or does not export the functions its resource needs."
203
+ },
204
+ READ_NEVER_WRITTEN: {
205
+ category: "package",
206
+ description: "A warning: a resource reads a capability nothing in the package writes, so it only ever holds its defaults."
207
+ },
208
+ NO_TERMINATION: {
209
+ category: "package",
210
+ description: "A warning: the game declares neither `maxTicks` nor a tick controller, so only its engine can end it."
211
+ },
212
+ SCENARIO_EDITOR_UNREACHABLE: {
213
+ category: "package",
214
+ description: "A warning: the game ships a scenario editor but does not set `customScenarios.supported`, so no host ever opens it."
215
+ },
216
+ SCENARIO_REFUSED: {
217
+ category: "package",
218
+ description: "A validator's `Scenario` gate found a problem with a package scenario, or with the defaults when no scenario is the default. The diagnostic points at the setting it names."
219
+ },
220
+ EDITOR_ENDPOINT_NOT_SCENARIO: {
221
+ category: "package",
222
+ description: 'The scenario editor lists an endpoint that is not scenario-scoped. It works on a scenario draft with no session, so it calls `"scope": "scenario"` endpoints alone.'
223
+ },
224
+ SCENARIO_ENDPOINT_STATEFUL: {
225
+ category: "package",
226
+ description: "A scenario-scoped endpoint declares `reads`, `writes`, `actions` or `roster`, which need a session a scenario draft does not have."
227
+ },
228
+ EXTERNAL_REQUEST_NOT_OBJECT: {
229
+ category: "package",
230
+ description: 'An external endpoint\'s `requestSchema` does not declare `"type": "object"` at the top, which a caller outside the game needs to pass named arguments.'
231
+ },
232
+ ENDPOINT_UNREQUESTED: {
233
+ category: "package",
234
+ description: "A warning: an internal endpoint no user interface lists in its `endpoints`."
235
+ },
236
+ PLATFORM_REJECTED: {
237
+ category: "package",
238
+ description: "The platform refused the uploaded package as invalid."
239
+ },
240
+ VERSION_EXISTS: {
241
+ category: "package",
242
+ description: "The platform already has this version of the package. Bump it and publish again."
243
+ },
244
+ // 4: refused
245
+ REFUSED_DENIED: {
246
+ category: "refused",
247
+ description: "The session refused the command (the 'denied' outcome)."
248
+ },
249
+ REFUSED_VALIDATION: {
250
+ category: "refused",
251
+ description: "A validator rejected the write (the 'validation-rejected' outcome). error.details.rejections lists why."
252
+ },
253
+ REFUSED_CONFLICT: {
254
+ category: "refused",
255
+ description: "The write conflicted with a concurrent tick (the 'conflict' outcome)."
256
+ },
257
+ REFUSED_SUPERSEDED: {
258
+ category: "refused",
259
+ description: "The write arrived after the tick it was for (the 'superseded' outcome)."
260
+ },
261
+ TICK_FAILED: {
262
+ category: "refused",
263
+ description: "The tick failed, usually because game logic threw (the 'tick-failed' outcome)."
264
+ },
265
+ SESSION_ERROR: {
266
+ category: "refused",
267
+ description: "The session failed the command unexpectedly (the 'error' outcome)."
268
+ },
269
+ INVALID_REQUEST: {
270
+ category: "refused",
271
+ description: "The endpoint request failed its requestSchema, so the handler did not run."
272
+ },
273
+ HANDLER_ERROR: {
274
+ category: "refused",
275
+ description: "The endpoint's handler threw, or ran past its execution bound."
276
+ },
277
+ INVALID_RESPONSE: {
278
+ category: "refused",
279
+ description: "What the endpoint's handler returned broke its declaration."
280
+ },
281
+ LOGIC_ERROR: {
282
+ category: "refused",
283
+ description: "Game logic (an engine, hook, endpoint, validator or tick controller) threw. A diagnostic, not an error code: it sits in `diagnostics` under the command's TICK_FAILED, SESSION_ERROR or HANDLER_ERROR, with the file, line and column it threw at."
284
+ },
285
+ SURFACE_NOT_RENDERED: {
286
+ category: "refused",
287
+ description: "`sdk screenshot` gave up on the page: its surface did not connect, or did not report its first paint before the timeout. error.details carries the page's console errors, failed requests and uncaught exceptions."
288
+ },
289
+ SETTINGS_STALE: {
290
+ category: "refused",
291
+ description: "The package changed on disk since the session started in a way that applies only at initialisation (a setting, a manifest field such as `teams`, or a capability removed or moved to another scope), so a command that advances or changes play was refused. Run `sdk init`."
292
+ },
293
+ // 5: environment
294
+ NO_SESSION: {
295
+ category: "environment",
296
+ description: "No dev server is running for this package, and the command will not start one."
297
+ },
298
+ SESSION_STALE: {
299
+ category: "environment",
300
+ description: "The running session was started from an out-of-date package and must restart."
301
+ },
302
+ LOCK_HELD: {
303
+ category: "environment",
304
+ description: "A dev server is already running for this package."
305
+ },
306
+ PORT_IN_USE: {
307
+ category: "environment",
308
+ description: "No free port was found to listen on."
309
+ },
310
+ DEV_SERVER_OUTDATED: {
311
+ category: "environment",
312
+ description: "The running dev server does not understand the command: it is older than this CLI. Restart it."
313
+ },
314
+ DEV_SERVER_UNREACHABLE: {
315
+ category: "environment",
316
+ description: "The dev server the lock file names does not answer."
317
+ },
318
+ DEV_SERVER_UNRESPONSIVE: {
319
+ category: "environment",
320
+ description: "A dev server holds the lock and accepts connections but does not answer, most often because logic is stuck in a synchronous loop. Run `sdk dev stop`."
321
+ },
322
+ DEV_SERVER_START_FAILED: {
323
+ category: "environment",
324
+ description: "A dev server could not be started."
325
+ },
326
+ DEV_SERVER_STOP_FAILED: {
327
+ category: "environment",
328
+ description: "The dev server could not be stopped."
329
+ },
330
+ BROWSER_MISSING: {
331
+ category: "environment",
332
+ description: "`sdk screenshot` found no Playwright in the package's dependencies, or no Chromium installed for it. Add `@playwright/test` and run `pnpm exec playwright install chromium`."
333
+ },
334
+ LLM_NOT_CONFIGURED: {
335
+ category: "environment",
336
+ description: "Logic called generateText, and the dev server or in-process session running it has no platform API key configured."
337
+ },
338
+ PLATFORM_UNREACHABLE: {
339
+ category: "environment",
340
+ description: "The Serious Gaming platform could not be reached."
341
+ },
342
+ PLATFORM_UNAUTHORISED: {
343
+ category: "environment",
344
+ description: "The platform refused the API key, or its holder lacks the role the call needs."
345
+ },
346
+ PLATFORM_ERROR: {
347
+ category: "environment",
348
+ description: "The platform failed the request."
349
+ },
350
+ API_KEY_MISSING: {
351
+ category: "environment",
352
+ description: "No API key is configured: set SERIOUSGAMING_API_KEY, add it to .env, or pass --api-key."
353
+ },
354
+ INSTALL_FAILED: {
355
+ category: "environment",
356
+ description: "Installing a new package's dependencies failed."
357
+ },
358
+ SDK_INCOMPLETE: {
359
+ category: "environment",
360
+ description: "This install of the SDK tools is missing files it ships with, such as its docs."
361
+ },
362
+ SETTINGS_FILE_INVALID: {
363
+ category: "environment",
364
+ description: "The global settings file (~/.seriousgaming-sdk/config.json) cannot be parsed."
365
+ },
366
+ WRITE_FAILED: {
367
+ category: "environment",
368
+ description: "A file or directory could not be written, moved or removed."
369
+ }
370
+ };
371
+ function categoryOf(code) {
372
+ return ERROR_CODES[code].category;
373
+ }
374
+ function exitCodeOf(code) {
375
+ return EXIT_CODES[categoryOf(code)];
376
+ }
377
+ function isErrorCode(value) {
378
+ return typeof value === "string" && Object.hasOwn(ERROR_CODES, value);
379
+ }
380
+
381
+ // cli/utils/cli-error.ts
382
+ function diagnosticLocation(diagnostic) {
383
+ if (diagnostic.file === void 0) return void 0;
384
+ if (diagnostic.line !== void 0) {
385
+ return `${diagnostic.file}:${diagnostic.line}${diagnostic.column === void 0 ? "" : `:${diagnostic.column}`}`;
386
+ }
387
+ if (diagnostic.pointer !== void 0 && diagnostic.pointer !== "") {
388
+ return `${diagnostic.file}#${diagnostic.pointer}`;
389
+ }
390
+ return diagnostic.file;
391
+ }
392
+ var CliError = class extends Error {
393
+ code;
394
+ hint;
395
+ diagnostics;
396
+ details;
397
+ constructor(code, message, options = {}) {
398
+ super(message, options.cause === void 0 ? void 0 : { cause: options.cause });
399
+ this.name = "CliError";
400
+ this.code = code;
401
+ this.hint = options.hint;
402
+ this.diagnostics = options.diagnostics ?? [];
403
+ this.details = options.details;
404
+ }
405
+ get category() {
406
+ return categoryOf(this.code);
407
+ }
408
+ get exitCode() {
409
+ return exitCodeOf(this.code);
410
+ }
411
+ };
412
+
413
+ // cli/utils/output.ts
414
+ var JSON_ENV_VAR = "SERIOUSGAMING_JSON";
415
+ var exitRequested = false;
416
+ function requestProcessExit() {
417
+ exitRequested = true;
418
+ }
419
+ function processExitRequested() {
420
+ return exitRequested;
421
+ }
422
+ var directWrite = (text) => {
423
+ process.stdout.write(text);
424
+ };
425
+ var state = {
426
+ command: "",
427
+ json: false,
428
+ data: null,
429
+ diagnostics: [],
430
+ warnings: [],
431
+ restoreStdout: null,
432
+ writeStdout: directWrite
433
+ };
434
+ function jsonRequestedByEnvironment(env = process.env) {
435
+ const value = env[JSON_ENV_VAR]?.trim().toLowerCase();
436
+ return value === "1" || value === "true";
437
+ }
438
+ function beginCommand(command, json) {
439
+ endCommand();
440
+ state = {
441
+ command,
442
+ json,
443
+ data: null,
444
+ diagnostics: [],
445
+ warnings: [],
446
+ restoreStdout: null,
447
+ writeStdout: directWrite
448
+ };
449
+ if (json) holdStdout();
450
+ }
451
+ function setCommandPath(command) {
452
+ state.command = command;
453
+ }
454
+ function enableJsonOutput() {
455
+ if (state.json) return;
456
+ state.json = true;
457
+ holdStdout();
458
+ }
459
+ function isJsonOutput() {
460
+ return state.json;
461
+ }
462
+ function reportResult(data, human) {
463
+ if (state.json) {
464
+ state.data = data;
465
+ return;
466
+ }
467
+ human?.();
468
+ }
469
+ function printJson(value) {
470
+ console.log(JSON.stringify(value, null, 2));
471
+ }
472
+ function recordWarning(message, code) {
473
+ state.warnings.push(code === void 0 ? { message } : { message, code });
474
+ }
475
+ function hasWarning(code) {
476
+ return state.warnings.some((warning) => warning.code === code);
477
+ }
478
+ function recordDiagnostic(diagnostic) {
479
+ state.diagnostics.push(diagnostic);
480
+ }
481
+ function finishSuccess() {
482
+ if (state.json) {
483
+ const envelope = {
484
+ ok: true,
485
+ command: state.command,
486
+ data: state.data ?? null,
487
+ diagnostics: state.diagnostics,
488
+ warnings: state.warnings
489
+ };
490
+ state.writeStdout(`${JSON.stringify(envelope, null, 2)}
491
+ `);
492
+ }
493
+ endCommand();
494
+ }
495
+ function finishFailure(error) {
496
+ const failure = toCliError(error);
497
+ if (state.json) {
498
+ const envelope = {
499
+ ok: false,
500
+ command: state.command,
501
+ error: {
502
+ code: failure.code,
503
+ message: failure.message,
504
+ ...failure.hint === void 0 ? {} : { hint: failure.hint },
505
+ ...failure.details === void 0 ? {} : { details: failure.details }
506
+ },
507
+ diagnostics: [...state.diagnostics, ...failure.diagnostics],
508
+ warnings: state.warnings
509
+ };
510
+ state.writeStdout(`${JSON.stringify(envelope, null, 2)}
511
+ `);
512
+ } else {
513
+ process.stderr.write(`Error: ${failure.message}
514
+ `);
515
+ for (const line of locatedDiagnostics(failure.diagnostics)) {
516
+ process.stderr.write(`${line}
517
+ `);
518
+ }
519
+ if (failure.hint !== void 0) process.stderr.write(`Hint: ${failure.hint}
520
+ `);
521
+ if (failure.code === "INTERNAL" && error instanceof Error && error.stack) {
522
+ process.stderr.write(`${error.stack}
523
+ `);
524
+ }
525
+ }
526
+ endCommand();
527
+ return exitCodeOf(failure.code);
528
+ }
529
+ function locatedDiagnostics(diagnostics) {
530
+ const lines = [];
531
+ for (const diagnostic of diagnostics) {
532
+ const location = diagnosticLocation(diagnostic);
533
+ if (location === void 0) continue;
534
+ const where = [
535
+ diagnostic.tick === void 0 ? void 0 : `tick ${diagnostic.tick}`,
536
+ diagnostic.team === void 0 ? void 0 : `team ${diagnostic.team.index + 1}`
537
+ ].filter((part) => part !== void 0);
538
+ lines.push(
539
+ ` ${diagnostic.code} at ${location}` + (where.length > 0 ? ` (${where.join(", ")})` : "")
540
+ );
541
+ }
542
+ return lines;
543
+ }
544
+ var COMMANDER_CODES = {
545
+ "commander.unknownCommand": "USAGE_UNKNOWN_COMMAND",
546
+ "commander.unknownOption": "USAGE_BAD_FLAG",
547
+ "commander.optionMissingArgument": "USAGE_BAD_FLAG",
548
+ "commander.conflictingOption": "USAGE_BAD_FLAG",
549
+ "commander.missingArgument": "USAGE_MISSING_ARGUMENT",
550
+ "commander.missingMandatoryOptionValue": "USAGE_MISSING_ARGUMENT",
551
+ "commander.excessArguments": "USAGE_BAD_ARGUMENT",
552
+ "commander.invalidArgument": "USAGE_BAD_ARGUMENT",
553
+ "commander.help": "USAGE_MISSING_ARGUMENT",
554
+ "commander.error": "USAGE_BAD_ARGUMENT"
555
+ };
556
+ function toCliError(error) {
557
+ if (error instanceof CliError) return error;
558
+ const commander = commanderError(error);
559
+ if (commander) {
560
+ const code = COMMANDER_CODES[commander.code] ?? "USAGE_BAD_ARGUMENT";
561
+ const message2 = commander.code === "commander.help" ? "A subcommand is required. Run with --help to list them." : commander.message.replace(/^error:\s*/i, "");
562
+ return new CliError(code, message2, { cause: error });
563
+ }
564
+ const message = typeof error === "object" && error !== null && "message" in error ? String(error.message) : String(error);
565
+ return new CliError("INTERNAL", message, { cause: error });
566
+ }
567
+ function commanderError(error) {
568
+ if (typeof error === "object" && error !== null && "code" in error && "exitCode" in error && typeof error.code === "string" && error.code.startsWith("commander.")) {
569
+ const { code, exitCode, message } = error;
570
+ return { code, exitCode, message: String(message) };
571
+ }
572
+ return null;
573
+ }
574
+ function holdStdout() {
575
+ if (state.restoreStdout) return;
576
+ const stdout = process.stdout;
577
+ const original = stdout.write;
578
+ const toStderr = ((...args) => process.stderr.write(...args));
579
+ stdout.write = toStderr;
580
+ state.writeStdout = (text) => {
581
+ original.call(stdout, text);
582
+ };
583
+ state.restoreStdout = () => {
584
+ if (stdout.write === toStderr) stdout.write = original;
585
+ };
586
+ }
587
+ function endCommand() {
588
+ state.restoreStdout?.();
589
+ state.restoreStdout = null;
590
+ state.writeStdout = directWrite;
591
+ }
592
+
593
+ export {
594
+ __commonJS,
595
+ __export,
596
+ __toESM,
597
+ isErrorCode,
598
+ diagnosticLocation,
599
+ CliError,
600
+ JSON_ENV_VAR,
601
+ requestProcessExit,
602
+ processExitRequested,
603
+ jsonRequestedByEnvironment,
604
+ beginCommand,
605
+ setCommandPath,
606
+ enableJsonOutput,
607
+ isJsonOutput,
608
+ reportResult,
609
+ printJson,
610
+ recordWarning,
611
+ hasWarning,
612
+ recordDiagnostic,
613
+ finishSuccess,
614
+ finishFailure,
615
+ commanderError
616
+ };
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ validateEngine
4
+ } from "./cli-JMZLT65J.js";
5
+ import "./cli-4LKXZQ2B.js";
6
+ import {
7
+ LOGIC_NODE_BUILTIN,
8
+ Transpile,
9
+ loadConfig
10
+ } from "./cli-SMFSZF2G.js";
11
+ import "./cli-F2D4GGUA.js";
12
+ import "./cli-4YB3ROVR.js";
13
+ import {
14
+ CliError,
15
+ reportResult
16
+ } from "./cli-N6H6T2E2.js";
17
+
18
+ // cli/commands/build-engine.ts
19
+ import { resolve, join } from "path";
20
+ async function buildEngineCommand(options) {
21
+ const configPath = resolve(options.workingDir, options.config);
22
+ const config = await loadConfig(configPath);
23
+ const engine = config.engine;
24
+ if (!engine) {
25
+ throw new CliError(
26
+ "RESOURCE_NOT_FOUND",
27
+ "This package has no engine: the `engine` slot is empty"
28
+ );
29
+ }
30
+ const validationResult = validateEngine(engine, config);
31
+ if (!validationResult.success) {
32
+ throw new CliError(
33
+ validationResult.errors.every((error) => error.includes(LOGIC_NODE_BUILTIN)) ? LOGIC_NODE_BUILTIN : "PACKAGE_INVALID",
34
+ `Engine validation failed:
35
+ ${validationResult.errors.map((error) => ` - ${error}`).join("\n")}`,
36
+ {
37
+ diagnostics: validationResult.errors.map((message) => ({
38
+ severity: "error",
39
+ ...validationResult.findings?.find(
40
+ (finding) => finding.message === message
41
+ ) ?? {
42
+ code: message.includes(LOGIC_NODE_BUILTIN) ? LOGIC_NODE_BUILTIN : "PACKAGE_INVALID",
43
+ message
44
+ },
45
+ resource: { type: "engine", identifier: "engine" }
46
+ }))
47
+ }
48
+ );
49
+ }
50
+ const engineSourceDir = join(options.workingDir, engine.rootDirectory);
51
+ const logicDirectory = resolve(engineSourceDir, engine.logic.directory);
52
+ const logicEntrypoint = resolve(logicDirectory, engine.logic.entrypoint);
53
+ const bundledCode = await Transpile({
54
+ entrypoint: logicEntrypoint,
55
+ packageRoot: options.workingDir
56
+ });
57
+ reportResult({ code: bundledCode }, () => process.stdout.write(bundledCode));
58
+ }
59
+ export {
60
+ buildEngineCommand
61
+ };
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ normalizeSettingsSchema
4
+ } from "./cli-FYINNRML.js";
5
+ import {
6
+ CliError
7
+ } from "./cli-N6H6T2E2.js";
8
+
9
+ // cli/commands/resources/settings/defaults.ts
10
+ function assertEveryPropertyHasDefault(schema) {
11
+ const properties = normalizeSettingsSchema(schema).properties;
12
+ if (!properties || typeof properties !== "object") return;
13
+ const missing = Object.entries(properties).filter(
14
+ ([, property]) => property === null || typeof property !== "object" || !("default" in property)
15
+ ).map(([name]) => name);
16
+ if (missing.length === 0) return;
17
+ throw new CliError(
18
+ "INPUT_INVALID",
19
+ `Every settings property declares a default, and ${missing.map((name) => `"${name}"`).join(", ")} ${missing.length === 1 ? "does" : "do"} not. The default is the value a game plays with unless a scenario or the session overrides it, so add one.`
20
+ );
21
+ }
22
+
23
+ export {
24
+ assertEveryPropertyHasDefault
25
+ };