@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,73 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ deleteFacilitatorGuideFiles,
4
+ findFacilitatorGuideReferences
5
+ } from "./cli-RA673NGF.js";
6
+ import {
7
+ loadPackageContext
8
+ } from "./cli-XSVGKI3R.js";
9
+ import "./cli-MBNMPVDC.js";
10
+ import "./cli-GFBGYFYD.js";
11
+ import {
12
+ operationError,
13
+ recordOperationResult
14
+ } from "./cli-UELGBQG7.js";
15
+ import {
16
+ confirmAction
17
+ } from "./cli-ZTWOE3ZT.js";
18
+ import "./cli-4BV45LBH.js";
19
+ import "./cli-4AKVLEC4.js";
20
+ import "./cli-VCKOC2EV.js";
21
+ import "./cli-E2NLWIFE.js";
22
+ import "./cli-25RWY5BQ.js";
23
+ import "./cli-QWQMPCL6.js";
24
+ import "./cli-SMFSZF2G.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/guide/delete.ts
32
+ async function deleteFacilitatorGuide(options) {
33
+ logger.info("\nDeleting facilitator guide...\n");
34
+ const identifier = "guide";
35
+ loadPackageContext(options.workingDir);
36
+ const references = findFacilitatorGuideReferences({
37
+ packagePath: options.workingDir,
38
+ identifier
39
+ });
40
+ logger.info(`Facilitator guide: ${identifier}`);
41
+ if (references.length > 0) {
42
+ logger.info("\nThis facilitator guide is referenced by:");
43
+ for (const ref of references) {
44
+ logger.info(` - ${ref}`);
45
+ }
46
+ logger.info("\nYou will need to remove these references manually.");
47
+ }
48
+ const confirmed = await confirmAction(
49
+ { message: "Are you sure you want to delete this facilitator guide?" },
50
+ options.yes
51
+ );
52
+ if (!confirmed) {
53
+ logger.info("\nDeletion cancelled.\n");
54
+ return;
55
+ }
56
+ logger.info("");
57
+ const result = deleteFacilitatorGuideFiles({
58
+ packagePath: options.workingDir,
59
+ identifier
60
+ });
61
+ if (!result.success) {
62
+ throw operationError(result, "Failed to delete facilitator guide files");
63
+ }
64
+ recordOperationResult(result);
65
+ for (const file of result.filesDeleted || []) {
66
+ logger.info(` \u2713 Deleted: ${file}`);
67
+ }
68
+ logger.info(" \u2713 Updated seriousgaming.sdk.json");
69
+ logger.success("Facilitator guide deleted successfully!");
70
+ }
71
+ export {
72
+ deleteFacilitatorGuide
73
+ };
@@ -0,0 +1,256 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ DEFAULT_LOGIC_EXECUTION_BOUND_MS,
4
+ LogicLoader,
5
+ resolveSettingsLayers
6
+ } from "./cli-E2NLWIFE.js";
7
+ import {
8
+ describeAssetByReference,
9
+ describeBlob,
10
+ readAssetByReference
11
+ } from "./cli-QWQMPCL6.js";
12
+ import {
13
+ SCENARIO_GATE_READ_LIMIT_BYTES,
14
+ ScenarioAssetTooLargeError,
15
+ Transpile,
16
+ errorMessage,
17
+ getPluralResourceMeta
18
+ } from "./cli-SMFSZF2G.js";
19
+
20
+ // cli/execution/scenario-gates.ts
21
+ import { existsSync } from "fs";
22
+ import { readFile } from "fs/promises";
23
+ var SCENARIO_VALIDATION = "scenario-validation";
24
+ var SCENARIO_FILES = "scenario-files";
25
+ function hasScenarioGate(config) {
26
+ return (config.validators ?? []).some((v) => v.definition.gates?.includes("scenario"));
27
+ }
28
+ async function runScenarioGates(options) {
29
+ const { config } = options;
30
+ if (!hasScenarioGate(config)) return [];
31
+ const loader = options.loader ?? new LogicLoader(options.packagePath, {
32
+ transpile: Transpile,
33
+ fs: { existsSync, readFile }
34
+ });
35
+ const resolved = resolveSettingsLayers(config, options.scenarioSettings, null);
36
+ const locale = options.locale ?? config.game?.definition.supportedLocales?.[0] ?? "en";
37
+ const readsFiles = (config.requires ?? []).includes(SCENARIO_FILES);
38
+ const problems = [];
39
+ for (const validator of config.validators ?? []) {
40
+ if (!validator.definition.gates?.includes("scenario")) continue;
41
+ const identifier = validator.definition.identifier;
42
+ const declared = validator.definition.settings ?? [];
43
+ const pick = (values) => Object.fromEntries(
44
+ declared.filter((id) => values[id] !== void 0).map((id) => [id, values[id]])
45
+ );
46
+ try {
47
+ const exports = await loader.load(
48
+ "validator",
49
+ identifier,
50
+ validator,
51
+ `Validator ${identifier} not found in configuration`
52
+ );
53
+ const gate = exports.Scenario;
54
+ if (!gate) {
55
+ problems.push({
56
+ validatorIdentifier: identifier,
57
+ message: `Validator ${identifier} does not export Scenario`
58
+ });
59
+ continue;
60
+ }
61
+ const found = await withBound(
62
+ gate({
63
+ settings: structuredClone(pick(resolved)),
64
+ locale,
65
+ callbacks: readsFiles ? scenarioCallbacks(
66
+ options.packagePath,
67
+ options.files ?? { scenarioRoot: null, blobs: "none" }
68
+ ) : withoutScenarioFiles(identifier)
69
+ }),
70
+ options.boundMs ?? DEFAULT_LOGIC_EXECUTION_BOUND_MS
71
+ );
72
+ if (!Array.isArray(found)) {
73
+ problems.push({
74
+ validatorIdentifier: identifier,
75
+ message: `Validator ${identifier}'s Scenario returned ${JSON.stringify(found)}, not an array of problems (an empty array passes)`
76
+ });
77
+ continue;
78
+ }
79
+ for (const problem of found) {
80
+ problems.push({ validatorIdentifier: identifier, ...problem });
81
+ }
82
+ } catch (error) {
83
+ problems.push({
84
+ validatorIdentifier: identifier,
85
+ message: `Validator ${identifier} threw: ${errorMessage(error, String(error))}`
86
+ });
87
+ }
88
+ }
89
+ return problems;
90
+ }
91
+ function scenarioCallbacks(packagePath, files) {
92
+ const unreadable = async (reference) => {
93
+ if (!reference.startsWith("blob:") || files.blobs === "all") return false;
94
+ if (files.blobs === "none") return true;
95
+ const blob = await describeBlob(packagePath, reference.slice("blob:".length));
96
+ return blob !== void 0 && blob.retention !== "scenario";
97
+ };
98
+ return {
99
+ readAsset: async (reference) => {
100
+ if (await unreadable(reference)) {
101
+ throw new Error(`Cannot read "${reference}": the scenario cannot name that file`);
102
+ }
103
+ const described = await describeAssetByReference(
104
+ packagePath,
105
+ files.scenarioRoot,
106
+ reference
107
+ );
108
+ if (described && described.size > SCENARIO_GATE_READ_LIMIT_BYTES) {
109
+ throw new ScenarioAssetTooLargeError(reference, described.size);
110
+ }
111
+ const asset = await readAssetByReference(packagePath, files.scenarioRoot, reference);
112
+ return { data: new Uint8Array(asset.data), mimeType: asset.mimeType, name: asset.name };
113
+ },
114
+ describeAsset: async (reference) => await unreadable(reference) ? void 0 : describeAssetByReference(packagePath, files.scenarioRoot, reference)
115
+ };
116
+ }
117
+ function withoutScenarioFiles(identifier) {
118
+ const refuse = (callback) => async () => {
119
+ throw new Error(
120
+ `Validator "${identifier}" called ${callback} in its Scenario gate, which needs the "${SCENARIO_FILES}" feature, but requires does not list it. Add "${SCENARIO_FILES}" to requires in seriousgaming.sdk.json.`
121
+ );
122
+ };
123
+ return { readAsset: refuse("readAsset"), describeAsset: refuse("describeAsset") };
124
+ }
125
+ async function withBound(run, boundMs) {
126
+ let timer;
127
+ try {
128
+ return await Promise.race([
129
+ run,
130
+ new Promise((_, reject) => {
131
+ timer = setTimeout(
132
+ () => reject(new Error(`did not finish within ${boundMs}ms`)),
133
+ boundMs
134
+ );
135
+ })
136
+ ]);
137
+ } finally {
138
+ if (timer) clearTimeout(timer);
139
+ }
140
+ }
141
+ function describeScenarioProblems(problems) {
142
+ return problems.map(
143
+ (p) => `${p.path ? `${p.path}: ` : ""}${p.message} (validator "${p.validatorIdentifier}")`
144
+ );
145
+ }
146
+
147
+ // cli/generation/ts-type.ts
148
+ import { existsSync as existsSync2, readFileSync, statSync } from "fs";
149
+ import { dirname, isAbsolute, join, relative, resolve, sep } from "path";
150
+ var RELATIVE_IMPORT = /import\((['"])(\.{1,2}\/[^'"]+)\1\)/g;
151
+ var ABSOLUTE_IMPORT = /import\((['"])(\/[^'"]+|[A-Za-z]:[\\/][^'"]+)\1\)/g;
152
+ var NAMED_IMPORT = /import\((['"])([^'"]+)\1\)\.([A-Za-z_$][\w$]*)/g;
153
+ var MODULE_EXTENSIONS = [".ts", ".tsx", ".d.ts", "/index.ts", "/index.tsx"];
154
+ function capabilityDirectory(workingDir, identifier) {
155
+ return join(workingDir, getPluralResourceMeta("capability").pluralDir, identifier);
156
+ }
157
+ function mapTsTypes(schema, rewrite) {
158
+ if (Array.isArray(schema)) return schema.map((item) => mapTsTypes(item, rewrite));
159
+ if (schema === null || typeof schema !== "object") return schema;
160
+ return Object.fromEntries(
161
+ Object.entries(schema).map(([key, value]) => [
162
+ key,
163
+ key === "tsType" && typeof value === "string" ? rewrite(value) : mapTsTypes(value, rewrite)
164
+ ])
165
+ );
166
+ }
167
+ function collectTsTypes(schema, into = []) {
168
+ if (Array.isArray(schema)) {
169
+ for (const item of schema) collectTsTypes(item, into);
170
+ } else if (schema !== null && typeof schema === "object") {
171
+ for (const [key, value] of Object.entries(schema)) {
172
+ if (key === "tsType" && typeof value === "string") into.push(value);
173
+ else collectTsTypes(value, into);
174
+ }
175
+ }
176
+ return into;
177
+ }
178
+ function absolutiseTsTypes(capabilities, workingDir) {
179
+ return capabilities.map((capability) => {
180
+ const schema = capability.definition.variablesSchema;
181
+ if (collectTsTypes(schema).length === 0) return capability;
182
+ const base = capabilityDirectory(workingDir, capability.definition.identifier);
183
+ return {
184
+ ...capability,
185
+ definition: {
186
+ ...capability.definition,
187
+ variablesSchema: mapTsTypes(
188
+ schema,
189
+ (tsType) => tsType.replace(
190
+ RELATIVE_IMPORT,
191
+ (_match, quote, path) => `import(${quote}${resolve(base, path)}${quote})`
192
+ )
193
+ )
194
+ }
195
+ };
196
+ });
197
+ }
198
+ function relativiseTsTypes(schema, outputPath) {
199
+ const from = dirname(outputPath);
200
+ return mapTsTypes(
201
+ schema,
202
+ (tsType) => tsType.replace(ABSOLUTE_IMPORT, (_match, quote, path) => {
203
+ let rel = relative(from, path).split(sep).join("/");
204
+ if (!rel.startsWith(".")) rel = `./${rel}`;
205
+ return `import(${quote}${rel}${quote})`;
206
+ })
207
+ );
208
+ }
209
+ function validateTsTypes(capabilities, workingDir) {
210
+ const errors = [];
211
+ for (const capability of capabilities) {
212
+ const { identifier } = capability.definition;
213
+ const base = capabilityDirectory(workingDir, identifier);
214
+ for (const tsType of collectTsTypes(capability.definition.variablesSchema)) {
215
+ for (const match of tsType.matchAll(NAMED_IMPORT)) {
216
+ const [, , specifier, name] = match;
217
+ if (!specifier.startsWith(".") && !isAbsolute(specifier)) continue;
218
+ const target = resolve(base, specifier);
219
+ const file = [target, ...MODULE_EXTENSIONS.map((ext) => `${target}${ext}`)].find(
220
+ (candidate) => existsSync2(candidate) && statSync(candidate).isFile()
221
+ );
222
+ if (!file) {
223
+ errors.push(
224
+ `Capability "${identifier}" has tsType "${tsType}", but "${specifier}" resolves to no module from ${relative(workingDir, base) || "."}. A tsType path is relative to the capability's own directory.`
225
+ );
226
+ continue;
227
+ }
228
+ if (!exportsName(readFileSync(file, "utf-8"), name)) {
229
+ errors.push(
230
+ `Capability "${identifier}" has tsType "${tsType}", but ${relative(workingDir, file)} does not export "${name}".`
231
+ );
232
+ }
233
+ }
234
+ }
235
+ }
236
+ return errors;
237
+ }
238
+ function exportsName(source, name) {
239
+ const escaped = name.replace(/[$]/g, "\\$");
240
+ const declared = new RegExp(
241
+ `export\\s+(?:declare\\s+)?(?:interface|type|class|enum|const|let|var|function|abstract\\s+class)\\s+${escaped}\\b`
242
+ );
243
+ const listed = new RegExp(`export\\s+(?:type\\s+)?\\{[^}]*\\b${escaped}\\b[^}]*\\}`);
244
+ return declared.test(source) || listed.test(source) || /export\s+\*\s+from/.test(source);
245
+ }
246
+
247
+ export {
248
+ SCENARIO_VALIDATION,
249
+ SCENARIO_FILES,
250
+ hasScenarioGate,
251
+ runScenarioGates,
252
+ describeScenarioProblems,
253
+ absolutiseTsTypes,
254
+ relativiseTsTypes,
255
+ validateTsTypes
256
+ };
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ getGlobalSetting,
4
+ loadGlobalSettings,
5
+ loadGlobalSettingsForWrite,
6
+ resolveGlobalSettingsPath,
7
+ saveGlobalSettings,
8
+ setGlobalSetting
9
+ } from "./cli-MMN4BPO4.js";
10
+ import {
11
+ logger
12
+ } from "./cli-4YB3ROVR.js";
13
+ import {
14
+ reportResult
15
+ } from "./cli-N6H6T2E2.js";
16
+
17
+ // cli/commands/config.ts
18
+ async function configPathCommand() {
19
+ const path = resolveGlobalSettingsPath();
20
+ reportResult({ path }, () => console.log(path));
21
+ }
22
+ async function configGetCommand(key) {
23
+ const settings = loadGlobalSettings();
24
+ const value = getGlobalSetting(settings, key);
25
+ reportResult({ key, value: value ?? null }, () => {
26
+ if (value !== void 0) console.log(value);
27
+ });
28
+ }
29
+ async function configSetCommand(key, value) {
30
+ const path = resolveGlobalSettingsPath();
31
+ const settings = loadGlobalSettingsForWrite(path);
32
+ const replaced = getGlobalSetting(settings, key) !== void 0;
33
+ const updated = setGlobalSetting(settings, key, value);
34
+ saveGlobalSettings(updated, path);
35
+ reportResult(
36
+ { key, path, replaced },
37
+ () => logger.success(
38
+ replaced ? `Set ${key} in ${path} (replaced the previous value)` : `Set ${key} in ${path}`
39
+ )
40
+ );
41
+ }
42
+ export {
43
+ configGetCommand,
44
+ configPathCommand,
45
+ configSetCommand
46
+ };
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ deleteScenarioFiles,
4
+ findScenarioReferences
5
+ } from "./cli-BYJWFFCF.js";
6
+ import {
7
+ loadPackageContext
8
+ } from "./cli-XSVGKI3R.js";
9
+ import "./cli-MBNMPVDC.js";
10
+ import "./cli-GFBGYFYD.js";
11
+ import {
12
+ operationError,
13
+ recordOperationResult
14
+ } from "./cli-UELGBQG7.js";
15
+ import {
16
+ confirmAction
17
+ } from "./cli-ZTWOE3ZT.js";
18
+ import "./cli-4BV45LBH.js";
19
+ import "./cli-4AKVLEC4.js";
20
+ import "./cli-VCKOC2EV.js";
21
+ import "./cli-E2NLWIFE.js";
22
+ import "./cli-25RWY5BQ.js";
23
+ import "./cli-QWQMPCL6.js";
24
+ import "./cli-SMFSZF2G.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,100 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ resolveSession
4
+ } from "./cli-GTSGLN3Z.js";
5
+ import "./cli-WU43JT4T.js";
6
+ import {
7
+ emit,
8
+ teamIndexFromArgument,
9
+ viewReport,
10
+ viewSummary,
11
+ warnIfStale
12
+ } from "./cli-PFFCNGHI.js";
13
+ import "./cli-LFM7GJHI.js";
14
+ import "./cli-C6TH5S7K.js";
15
+ import "./cli-TDSQSCX4.js";
16
+ import "./cli-SRHBXZCN.js";
17
+ import "./cli-GUXKQMJ7.js";
18
+ import "./cli-4LKXZQ2B.js";
19
+ import "./cli-MMN4BPO4.js";
20
+ import "./cli-QUNIRH7A.js";
21
+ import "./cli-E2NLWIFE.js";
22
+ import "./cli-25RWY5BQ.js";
23
+ import "./cli-QWQMPCL6.js";
24
+ import "./cli-SMFSZF2G.js";
25
+ import "./cli-F2D4GGUA.js";
26
+ import "./cli-4YB3ROVR.js";
27
+ import {
28
+ CliError
29
+ } from "./cli-N6H6T2E2.js";
30
+
31
+ // cli/commands/view.ts
32
+ async function viewCommand(options) {
33
+ const session = await resolveSession({
34
+ packagePath: options.workingDir,
35
+ ...options.walkthrough ? { runKind: "walkthrough" } : {},
36
+ ...options.server === false ? { noServer: true } : {}
37
+ });
38
+ try {
39
+ const state = await session.state();
40
+ warnIfStale(state);
41
+ const teamIndex = teamIndexFromArgument(state, options.team);
42
+ if (options.summary && (options.full || options.tick !== void 0)) {
43
+ throw new CliError(
44
+ "USAGE_BAD_FLAG",
45
+ `--summary reads the head in brief, so it cannot be combined with ${options.full ? "--full" : "--tick"}`
46
+ );
47
+ }
48
+ if (options.summary) {
49
+ emit(viewSummary(state, teamIndex));
50
+ return;
51
+ }
52
+ if (options.tick !== void 0) {
53
+ emit(await pastState(session, state, options, teamIndex));
54
+ return;
55
+ }
56
+ if (options.to !== void 0)
57
+ throw new CliError("USAGE_BAD_FLAG", "--to reads a range, so it needs --tick");
58
+ emit(options.full ? state : viewReport(state, teamIndex));
59
+ } finally {
60
+ await session.close();
61
+ }
62
+ }
63
+ async function pastState(session, state, options, teamIndex) {
64
+ if (options.full)
65
+ throw new CliError(
66
+ "USAGE_BAD_FLAG",
67
+ "--full reads the head, so it cannot be combined with --tick"
68
+ );
69
+ const fromTick = tickFromArgument(options.tick, "--tick");
70
+ const toTick = options.to === void 0 ? void 0 : tickFromArgument(options.to, "--to");
71
+ if (toTick !== void 0 && toTick < fromTick) {
72
+ throw new CliError("USAGE_BAD_FLAG", `--to ${toTick} is before --tick ${fromTick}`);
73
+ }
74
+ if (fromTick >= state.session.completedTicks) {
75
+ throw new CliError(
76
+ "USAGE_BAD_ARGUMENT",
77
+ `Tick ${fromTick} is not in the past: the session has completed ${state.session.completedTicks} ticks. Use sdk view for the head`
78
+ );
79
+ }
80
+ const result = await session.send({
81
+ type: "getPastState",
82
+ query: {
83
+ fromTick,
84
+ ...toTick === void 0 ? {} : { toTick },
85
+ teams: teamIndex === void 0 ? "all" : `team-${teamIndex + 1}`
86
+ }
87
+ });
88
+ if (!("type" in result) || result.type !== "pastState") {
89
+ throw new CliError("DEV_SERVER_OUTDATED", "The session did not answer with past state");
90
+ }
91
+ return { entries: result.entries };
92
+ }
93
+ function tickFromArgument(value, flag) {
94
+ if (!/^\d+$/.test(value))
95
+ throw new CliError("USAGE_BAD_ARGUMENT", `${flag} takes a tick number, and got "${value}"`);
96
+ return Number(value);
97
+ }
98
+ export {
99
+ viewCommand
100
+ };
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ isAlive,
4
+ lockOnDisk,
5
+ removeLockFile
6
+ } from "./cli-SRHBXZCN.js";
7
+ import {
8
+ CliError
9
+ } from "./cli-N6H6T2E2.js";
10
+
11
+ // cli/dev/stop-server.ts
12
+ var GRACE_MS = 5e3;
13
+ var KILL_TIMEOUT_MS = 5e3;
14
+ async function stopLockedServer(packagePath, lock, options = {}) {
15
+ signal(lock, "SIGTERM");
16
+ if (await released(packagePath, lock, options.graceMs ?? GRACE_MS)) return;
17
+ if (isAlive(lock.pid)) signal(lock, "SIGKILL");
18
+ if (!await released(packagePath, lock, KILL_TIMEOUT_MS)) {
19
+ throw new CliError(
20
+ "DEV_SERVER_STOP_FAILED",
21
+ `The dev server (pid ${lock.pid}) did not stop, even when killed.`
22
+ );
23
+ }
24
+ }
25
+ function signal(lock, name) {
26
+ try {
27
+ process.kill(lock.pid, name);
28
+ } catch (error) {
29
+ if (error.code === "ESRCH") return;
30
+ throw new CliError(
31
+ "DEV_SERVER_STOP_FAILED",
32
+ `Could not stop the dev server (pid ${lock.pid}): ${error.message}`
33
+ );
34
+ }
35
+ }
36
+ async function released(packagePath, lock, timeoutMs) {
37
+ const deadline = Date.now() + timeoutMs;
38
+ for (; ; ) {
39
+ const current = await lockOnDisk(packagePath);
40
+ if (!current || current.instanceId !== lock.instanceId) return true;
41
+ if (!isAlive(lock.pid)) {
42
+ await removeLockFile(packagePath, lock.instanceId);
43
+ return true;
44
+ }
45
+ if (Date.now() >= deadline) return false;
46
+ await new Promise((resolve) => setTimeout(resolve, 100));
47
+ }
48
+ }
49
+
50
+ export {
51
+ stopLockedServer
52
+ };