@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,31 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ CliError
4
+ } from "./cli-N6H6T2E2.js";
5
+
6
+ // cli/utils/sdk-tools-version.ts
7
+ import { existsSync, readFileSync } from "fs";
8
+ import { dirname, join } from "path";
9
+ import { fileURLToPath } from "url";
10
+ var PACKAGE_NAME = "@seriousgaming/sdk-tools";
11
+ function readSdkToolsVersion() {
12
+ const here = dirname(fileURLToPath(import.meta.url));
13
+ try {
14
+ for (const candidate of [join(here, "../../package.json"), join(here, "../package.json")]) {
15
+ if (!existsSync(candidate)) continue;
16
+ const packageJson = JSON.parse(readFileSync(candidate, "utf-8"));
17
+ if (packageJson.name === PACKAGE_NAME) return packageJson.version || "0.0.0";
18
+ }
19
+ } catch (error) {
20
+ throw new CliError(
21
+ "SDK_INCOMPLETE",
22
+ `Error reading version: ${error instanceof Error ? error.message : "Unknown error"}`,
23
+ { cause: error }
24
+ );
25
+ }
26
+ throw new CliError("SDK_INCOMPLETE", `Error reading version: no ${PACKAGE_NAME} package.json`);
27
+ }
28
+
29
+ export {
30
+ readSdkToolsVersion
31
+ };
@@ -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,37 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ createResourceFiles,
4
+ deleteResourceFiles,
5
+ findResourceReferences,
6
+ updateResourceFiles
7
+ } from "./cli-TT36JCU5.js";
8
+ import {
9
+ getResourceMeta
10
+ } from "./cli-VQ6HVQW4.js";
11
+
12
+ // cli/templating/scenario.ts
13
+ var scenarioMeta = getResourceMeta("scenario");
14
+ function createScenarioFiles(options) {
15
+ const { identifier: _named, ...authored } = options.definition;
16
+ return createResourceFiles(scenarioMeta, options, {
17
+ definition: authored,
18
+ rootDirectory: options.rootDirectory,
19
+ directories: ["assets/shared"]
20
+ });
21
+ }
22
+ function updateScenarioFiles(options) {
23
+ return updateResourceFiles(scenarioMeta, options);
24
+ }
25
+ function deleteScenarioFiles(options) {
26
+ return deleteResourceFiles(scenarioMeta, options);
27
+ }
28
+ function findScenarioReferences(options) {
29
+ return findResourceReferences(scenarioMeta, options);
30
+ }
31
+
32
+ export {
33
+ createScenarioFiles,
34
+ updateScenarioFiles,
35
+ deleteScenarioFiles,
36
+ findScenarioReferences
37
+ };
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ deleteTickControllerFiles,
4
+ findTickControllerReferences
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/tick-controller/delete.ts
37
+ async function deleteTickController(options) {
38
+ logger.info("\nDeleting tick controller...\n");
39
+ const identifier = "tick_controller";
40
+ loadPackageContext(options.workingDir);
41
+ const references = findTickControllerReferences({
42
+ packagePath: options.workingDir,
43
+ identifier
44
+ });
45
+ logger.info(`Tick Controller: ${identifier}`);
46
+ if (references.length > 0) {
47
+ logger.info("\nThis tick controller is referenced in:");
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 tick controller?" },
55
+ options.yes
56
+ );
57
+ if (!confirmed) {
58
+ logger.info("\nDeletion cancelled.\n");
59
+ return;
60
+ }
61
+ logger.info("");
62
+ const result = deleteTickControllerFiles({
63
+ packagePath: options.workingDir,
64
+ identifier
65
+ });
66
+ if (!result.success) {
67
+ throw operationError(result, "Failed to delete tick controller 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("Tick controller deleted successfully!");
86
+ }
87
+ export {
88
+ deleteTickController
89
+ };
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ resolveSession
4
+ } from "./cli-6K3VQQUS.js";
5
+ import "./cli-WU43JT4T.js";
6
+ import {
7
+ emit,
8
+ participantsFromArgument,
9
+ raiseIfRefused,
10
+ requireScenario,
11
+ sessionSummary,
12
+ teamCountFromFlag,
13
+ tickReport
14
+ } from "./cli-L7VYSXQK.js";
15
+ import "./cli-FQRVFGN6.js";
16
+ import "./cli-XSLNH5PR.js";
17
+ import "./cli-TDSQSCX4.js";
18
+ import "./cli-SRHBXZCN.js";
19
+ import "./cli-KGT5L7VZ.js";
20
+ import "./cli-4LKXZQ2B.js";
21
+ import "./cli-MMN4BPO4.js";
22
+ import "./cli-QUNIRH7A.js";
23
+ import "./cli-BYCHKSSH.js";
24
+ import "./cli-25RWY5BQ.js";
25
+ import "./cli-QWQMPCL6.js";
26
+ import "./cli-VQ6HVQW4.js";
27
+ import "./cli-F2D4GGUA.js";
28
+ import "./cli-4YB3ROVR.js";
29
+ import "./cli-N6H6T2E2.js";
30
+
31
+ // cli/commands/init.ts
32
+ import dotenv from "dotenv";
33
+ dotenv.config({ path: ".env", debug: false, quiet: true });
34
+ async function initCommand(options) {
35
+ const participants = options.participants === void 0 ? void 0 : participantsFromArgument(options.participants);
36
+ const teams = options.teams === void 0 ? void 0 : teamCountFromFlag(options.teams);
37
+ const scenarioId = options.scenario === void 0 ? void 0 : requireScenario(options.workingDir, options.scenario);
38
+ const session = await resolveSession({
39
+ packagePath: options.workingDir,
40
+ ...options.walkthrough ? { runKind: "walkthrough" } : {},
41
+ ...options.server === false ? { noServer: true } : {},
42
+ ...teams === void 0 ? {} : { teams },
43
+ ...participants === void 0 ? {} : { participants },
44
+ ...scenarioId === void 0 ? {} : { scenarioId },
45
+ ...options.locale === void 0 ? {} : { locale: options.locale }
46
+ });
47
+ try {
48
+ if (!session.ephemeral) {
49
+ raiseIfRefused(
50
+ await session.send({
51
+ type: "reinitialise",
52
+ ...teams === void 0 ? {} : { teams },
53
+ ...participants === void 0 ? {} : { participants },
54
+ ...scenarioId === void 0 ? {} : { scenarioId },
55
+ ...options.locale === void 0 ? {} : { locale: options.locale }
56
+ })
57
+ );
58
+ }
59
+ const state = await session.state();
60
+ const report = options.summary ? sessionSummary(state) : tickReport(state);
61
+ emit({ ...report, scenario: state.game.scenarioId });
62
+ } finally {
63
+ await session.close();
64
+ }
65
+ }
66
+ export {
67
+ initCommand
68
+ };
@@ -0,0 +1,135 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ promptForSettings
4
+ } from "./cli-ZDOTXEKL.js";
5
+ import {
6
+ loadResourceIdentifiers
7
+ } from "./cli-Q6ZBZYK2.js";
8
+ import {
9
+ readAuthoredBundle
10
+ } from "./cli-4VFZHLDG.js";
11
+ import {
12
+ resolveInputSource
13
+ } from "./cli-4UWFQNGF.js";
14
+ import {
15
+ createEngineFiles
16
+ } from "./cli-4SIWLHQO.js";
17
+ import "./cli-IUS2YCD3.js";
18
+ import "./cli-QUNIRH7A.js";
19
+ import "./cli-J4UBELKF.js";
20
+ import {
21
+ loadPackageContext
22
+ } from "./cli-XSVGKI3R.js";
23
+ import {
24
+ presentFields
25
+ } from "./cli-TT36JCU5.js";
26
+ import "./cli-OXAUOWCN.js";
27
+ import {
28
+ BUILD_COMMAND,
29
+ generateTypes,
30
+ operationError,
31
+ printOperationResult
32
+ } from "./cli-KSGB2ZLK.js";
33
+ import {
34
+ checkbox
35
+ } from "./cli-ZTWOE3ZT.js";
36
+ import "./cli-LQOHATY2.js";
37
+ import "./cli-IEMKI7J7.js";
38
+ import "./cli-OMWC75CC.js";
39
+ import "./cli-BYCHKSSH.js";
40
+ import "./cli-25RWY5BQ.js";
41
+ import "./cli-QWQMPCL6.js";
42
+ import {
43
+ validateSDKEngine
44
+ } from "./cli-VQ6HVQW4.js";
45
+ import "./cli-F2D4GGUA.js";
46
+ import {
47
+ logger
48
+ } from "./cli-4YB3ROVR.js";
49
+ import "./cli-N6H6T2E2.js";
50
+
51
+ // cli/commands/resources/engine/new.ts
52
+ async function createEngine(definitionInput, options) {
53
+ logger.info("\nCreating the engine...\n");
54
+ const aggregate = options.aggregate === true;
55
+ loadPackageContext(options.workingDir, {
56
+ suggestNewPackage: true
57
+ });
58
+ const inputSource = await resolveInputSource(definitionInput, options.file);
59
+ const jsonDefinition = inputSource.kind === "json" ? inputSource.json : null;
60
+ if (jsonDefinition) {
61
+ const engineInput = readAuthoredBundle({
62
+ json: jsonDefinition,
63
+ type: "engine",
64
+ command: "new",
65
+ validate: validateSDKEngine
66
+ });
67
+ logger.info("Creating engine files...\n");
68
+ const result2 = await createEngineFiles({
69
+ packagePath: options.workingDir,
70
+ definition: engineInput.definition,
71
+ aggregate
72
+ });
73
+ if (!result2.success) {
74
+ throw operationError(result2, "Failed to create engine files");
75
+ }
76
+ logger.success("Engine created successfully!");
77
+ printOperationResult(result2);
78
+ await generateTypes(options.workingDir);
79
+ logger.info("Next steps:");
80
+ logger.info(" 1. Edit the logic file: engine/logic.ts");
81
+ logger.info(` 2. Run "${BUILD_COMMAND}" to build your package`);
82
+ return;
83
+ }
84
+ logger.info("No JSON definition provided. Starting interactive mode...\n");
85
+ const availableCapabilities = loadResourceIdentifiers(options.workingDir, "capability");
86
+ const reads = [];
87
+ const writes = [];
88
+ if (availableCapabilities.length > 0) {
89
+ logger.info("Select capabilities for the engine.\n");
90
+ logger.info("Tip: Use arrow keys to navigate, space to select, enter to continue.\n");
91
+ const readCapabilities = await checkbox({
92
+ message: "Capabilities the engine reads from:",
93
+ choices: availableCapabilities.map((id) => ({
94
+ name: id,
95
+ value: id
96
+ })),
97
+ pageSize: 10
98
+ });
99
+ reads.push(...readCapabilities);
100
+ const remainingForWrites = availableCapabilities.filter(
101
+ (id) => !readCapabilities.includes(id)
102
+ );
103
+ if (remainingForWrites.length > 0) {
104
+ const writeCapabilities = await checkbox({
105
+ message: "Capabilities the engine writes to (provides):",
106
+ choices: remainingForWrites.map((id) => ({
107
+ name: id,
108
+ value: id
109
+ })),
110
+ pageSize: 10
111
+ });
112
+ writes.push(...writeCapabilities);
113
+ }
114
+ logger.info("");
115
+ } else {
116
+ logger.info("No existing capabilities found in this package.");
117
+ logger.info('You can add capabilities using "seriousgaming-sdk new capability".\n');
118
+ }
119
+ const settings = await promptForSettings(options.workingDir, "engine");
120
+ logger.info("Creating engine files...\n");
121
+ const result = await createEngineFiles({
122
+ packagePath: options.workingDir,
123
+ definition: presentFields({ reads, writes, settings }),
124
+ aggregate
125
+ });
126
+ if (!result.success) {
127
+ throw operationError(result, "Failed to create engine files");
128
+ }
129
+ logger.success("Engine created successfully!");
130
+ printOperationResult(result);
131
+ await generateTypes(options.workingDir);
132
+ }
133
+ export {
134
+ createEngine
135
+ };
@@ -0,0 +1,131 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ resolvePatchedDefinition
4
+ } from "./cli-5IAW3LIF.js";
5
+ import "./cli-S5IVGDDD.js";
6
+ import {
7
+ getResourceIdentifierError,
8
+ readAuthoredBundle
9
+ } from "./cli-4VFZHLDG.js";
10
+ import {
11
+ resolveInputSource
12
+ } from "./cli-4UWFQNGF.js";
13
+ import {
14
+ updateEndpointFiles
15
+ } from "./cli-4SIWLHQO.js";
16
+ import "./cli-IUS2YCD3.js";
17
+ import "./cli-QUNIRH7A.js";
18
+ import "./cli-J4UBELKF.js";
19
+ import {
20
+ loadPackageContext
21
+ } from "./cli-XSVGKI3R.js";
22
+ import "./cli-TT36JCU5.js";
23
+ import {
24
+ findBundleFile
25
+ } from "./cli-OXAUOWCN.js";
26
+ import {
27
+ operationError,
28
+ printOperationResult,
29
+ regenerateTypes
30
+ } from "./cli-KSGB2ZLK.js";
31
+ import {
32
+ input
33
+ } from "./cli-ZTWOE3ZT.js";
34
+ import "./cli-LQOHATY2.js";
35
+ import "./cli-IEMKI7J7.js";
36
+ import "./cli-OMWC75CC.js";
37
+ import "./cli-BYCHKSSH.js";
38
+ import "./cli-25RWY5BQ.js";
39
+ import "./cli-QWQMPCL6.js";
40
+ import {
41
+ validateSDKEndpoint
42
+ } from "./cli-VQ6HVQW4.js";
43
+ import "./cli-F2D4GGUA.js";
44
+ import {
45
+ logger
46
+ } from "./cli-4YB3ROVR.js";
47
+ import {
48
+ CliError
49
+ } from "./cli-N6H6T2E2.js";
50
+
51
+ // cli/commands/resources/endpoint/update.ts
52
+ import { readFileSync } from "fs";
53
+ async function updateEndpoint(identifier, definitionInput, options) {
54
+ logger.info("\nUpdating endpoint...\n");
55
+ loadPackageContext(options.workingDir);
56
+ let jsonDefinition = null;
57
+ if (options.patch) {
58
+ jsonDefinition = resolvePatchedDefinition({
59
+ patch: options.patch,
60
+ workingDir: options.workingDir,
61
+ type: "endpoint",
62
+ identifier,
63
+ resourceLabel: "Endpoint"
64
+ });
65
+ } else {
66
+ const inputSource = await resolveInputSource(definitionInput, options.file);
67
+ if (inputSource.kind === "json") jsonDefinition = inputSource.json;
68
+ }
69
+ if (jsonDefinition) {
70
+ const endpointInput = readAuthoredBundle({
71
+ json: jsonDefinition,
72
+ type: "endpoint",
73
+ command: "update",
74
+ validate: validateSDKEndpoint,
75
+ identifier
76
+ });
77
+ logger.info("Updating endpoint files...\n");
78
+ const result2 = updateEndpointFiles({
79
+ packagePath: options.workingDir,
80
+ oldIdentifier: identifier,
81
+ newDefinition: endpointInput.definition,
82
+ newIdentifier: endpointInput.definition?.identifier
83
+ });
84
+ if (!result2.success) {
85
+ throw operationError(result2, "Failed to update endpoint files");
86
+ }
87
+ logger.success("Endpoint updated successfully!");
88
+ printOperationResult(result2);
89
+ await regenerateTypes(options.workingDir);
90
+ return;
91
+ }
92
+ logger.info("No JSON definition provided. Starting interactive mode...\n");
93
+ const endpointFilePath = findBundleFile(options.workingDir, "endpoint", identifier);
94
+ if (!endpointFilePath) {
95
+ throw new CliError("RESOURCE_NOT_FOUND", `Endpoint "${identifier}" not found`);
96
+ }
97
+ let existingBundle;
98
+ try {
99
+ existingBundle = JSON.parse(readFileSync(endpointFilePath, "utf-8"));
100
+ } catch {
101
+ throw new CliError("BUNDLE_INVALID", "Could not read endpoint file");
102
+ }
103
+ const existingDef = { ...existingBundle.definition, identifier };
104
+ logger.info("Current values:");
105
+ logger.info(` Identifier: ${existingDef.identifier}`);
106
+ logger.info("");
107
+ const newIdentifier = await input({
108
+ message: "Endpoint name:",
109
+ default: existingDef.identifier,
110
+ validate: (value) => {
111
+ const error = getResourceIdentifierError(value);
112
+ return error || true;
113
+ }
114
+ });
115
+ if (newIdentifier !== existingDef.identifier) {
116
+ logger.info("\n\u26A0\uFE0F Changing the identifier will update all game and UI references.\n");
117
+ }
118
+ const result = updateEndpointFiles({
119
+ packagePath: options.workingDir,
120
+ oldIdentifier: identifier,
121
+ newDefinition: { ...existingDef, identifier: newIdentifier }
122
+ });
123
+ if (!result.success) {
124
+ throw operationError(result, "Failed to update endpoint files");
125
+ }
126
+ logger.success("Endpoint updated successfully!");
127
+ await regenerateTypes(options.workingDir);
128
+ }
129
+ export {
130
+ updateEndpoint
131
+ };