@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.
- package/dist/agent/guidance.md +350 -0
- package/dist/bundling/ui-bundler.d.ts +12 -0
- package/dist/cli-25RWY5BQ.js +41 -0
- package/dist/cli-2BH7FX27.js +52 -0
- package/dist/cli-2GZYGRVL.js +36 -0
- package/dist/cli-2NU2LPEE.js +97 -0
- package/dist/cli-3BRC32CP.js +132 -0
- package/dist/cli-3D3ZXWOV.js +111 -0
- package/dist/cli-3ZKWV3PN.js +96 -0
- package/dist/cli-45OCBG53.js +60 -0
- package/dist/cli-4LKXZQ2B.js +48 -0
- package/dist/cli-4PXNOJQX.js +81 -0
- package/dist/cli-4SIWLHQO.js +717 -0
- package/dist/cli-4UWFQNGF.js +54 -0
- package/dist/cli-4VFZHLDG.js +202 -0
- package/dist/cli-4YB3ROVR.js +78 -0
- package/dist/cli-5ACDPCXI.js +21 -0
- package/dist/cli-5IAW3LIF.js +38 -0
- package/dist/cli-5SM367K7.js +30 -0
- package/dist/cli-64AB62PM.js +25 -0
- package/dist/cli-6K3VQQUS.js +307 -0
- package/dist/cli-6QB2VFPY.js +80 -0
- package/dist/cli-6SGCYEEC.js +649 -0
- package/dist/cli-6UTPHWRQ.js +207 -0
- package/dist/cli-6VNKQ3OX.js +391 -0
- package/dist/cli-72XDEFU3.js +61 -0
- package/dist/cli-7A6MKCUJ.js +463 -0
- package/dist/cli-7XLHO2FE.js +226 -0
- package/dist/cli-AV2FYC5G.js +225 -0
- package/dist/cli-B6YHEKIJ.js +248 -0
- package/dist/cli-BJMS3VX3.js +1837 -0
- package/dist/cli-BUQI5UU4.js +43 -0
- package/dist/cli-BWX5E7TQ.js +23 -0
- package/dist/cli-BYCHKSSH.js +1331 -0
- package/dist/cli-C3CMJSNL.js +89 -0
- package/dist/cli-C47GJATR.js +42 -0
- package/dist/cli-C5QOJJWX.js +46 -0
- package/dist/cli-C6ZLPK2U.js +124 -0
- package/dist/cli-CD5CIJZI.js +72 -0
- package/dist/cli-DDJYUKQG.js +36 -0
- package/dist/cli-DFBTZEBX.js +167 -0
- package/dist/cli-DOXRQ3S5.js +60 -0
- package/dist/cli-EVI36HEM.js +79 -0
- package/dist/cli-F2D4GGUA.js +549 -0
- package/dist/cli-FQRVFGN6.js +0 -0
- package/dist/cli-FWFRKQNE.js +11 -0
- package/dist/cli-G6CANSPL.js +88 -0
- package/dist/cli-GFNDW2DL.js +124 -0
- package/dist/cli-HCRTYQQS.js +16 -0
- package/dist/cli-HFX3YPUL.js +76 -0
- package/dist/cli-HKORECAG.js +53 -0
- package/dist/cli-HOE3WLFH.js +73 -0
- package/dist/cli-HSIHDN6K.js +187 -0
- package/dist/cli-HW53ICZC.js +89 -0
- package/dist/cli-IDVUHGKG.js +218 -0
- package/dist/cli-IEMKI7J7.js +1387 -0
- package/dist/cli-ILFDANBR.js +101 -0
- package/dist/cli-ILKCQNM6.js +8 -0
- package/dist/cli-IP4RXGHM.js +2847 -0
- package/dist/cli-IUS2YCD3.js +31 -0
- package/dist/cli-J4DKUUTK.js +138 -0
- package/dist/cli-J4UBELKF.js +37 -0
- package/dist/cli-JJSWBW4H.js +89 -0
- package/dist/cli-JVI24FI6.js +68 -0
- package/dist/cli-JZCLIT3O.js +135 -0
- package/dist/cli-JZOZOEZM.js +131 -0
- package/dist/cli-KGM6RRQW.js +185 -0
- package/dist/cli-KGT5L7VZ.js +13641 -0
- package/dist/cli-KOGRWFN7.js +89 -0
- package/dist/cli-KSGB2ZLK.js +101 -0
- package/dist/cli-L7VYSXQK.js +243 -0
- package/dist/cli-LK3V4RI5.js +36 -0
- package/dist/cli-LQOHATY2.js +126 -0
- package/dist/cli-MJUYJIEP.js +13 -0
- package/dist/cli-MJV47HKI.js +143 -0
- package/dist/cli-MMN4BPO4.js +145 -0
- package/dist/cli-MOPSZ3CS.js +88 -0
- package/dist/cli-MU5LB43S.js +136 -0
- package/dist/cli-MYJGMA6U.js +40 -0
- package/dist/cli-N24OHSAN.js +36 -0
- package/dist/cli-N45DREM4.js +99 -0
- package/dist/cli-N6H6T2E2.js +616 -0
- package/dist/cli-NROTDF5Y.js +182 -0
- package/dist/cli-O5ABH2WK.js +226 -0
- package/dist/cli-OMWC75CC.js +256 -0
- package/dist/cli-OXAUOWCN.js +50 -0
- package/dist/cli-PGCIHPU7.js +143 -0
- package/dist/cli-Q6ZBZYK2.js +35 -0
- package/dist/cli-QUNIRH7A.js +57 -0
- package/dist/cli-QUSCIUOM.js +142 -0
- package/dist/cli-QVASWX2A.js +187 -0
- package/dist/cli-QWQMPCL6.js +253 -0
- package/dist/cli-QY5NZAR7.js +97 -0
- package/dist/cli-R2MUZQE2.js +62 -0
- package/dist/cli-RCIWBCXD.js +36 -0
- package/dist/cli-RLEGRWFM.js +81 -0
- package/dist/cli-RSW6EBBD.js +89 -0
- package/dist/cli-RZITKPJX.js +367 -0
- package/dist/cli-S5IVGDDD.js +32 -0
- package/dist/cli-SRHBXZCN.js +159 -0
- package/dist/cli-TDSQSCX4.js +131 -0
- package/dist/cli-TIDQ4WUE.js +257 -0
- package/dist/cli-TT36JCU5.js +370 -0
- package/dist/cli-TTKICM5P.js +100 -0
- package/dist/cli-TTMBBEJC.js +131 -0
- package/dist/cli-UMEBPAZQ.js +16 -0
- package/dist/cli-UNAJ2OTE.js +15 -0
- package/dist/cli-UZZFNXRX.js +226 -0
- package/dist/cli-VDBW23SS.js +81 -0
- package/dist/cli-VL2P354N.js +46 -0
- package/dist/cli-VPRRICZA.js +304 -0
- package/dist/cli-VQ6HVQW4.js +4010 -0
- package/dist/cli-WR3NOY74.js +36 -0
- package/dist/cli-WU43JT4T.js +52 -0
- package/dist/cli-XAT25PRU.js +117 -0
- package/dist/cli-XOTNXEJA.js +124 -0
- package/dist/cli-XSLNH5PR.js +6417 -0
- package/dist/cli-XSVGKI3R.js +39 -0
- package/dist/cli-XZCJIKIV.js +124 -0
- package/dist/cli-Y3DDNMPX.js +97 -0
- package/dist/cli-Y3O5F4JN.js +90 -0
- package/dist/cli-YOTGR3NB.js +82 -0
- package/dist/cli-Z56ZIVA6.js +97 -0
- package/dist/cli-ZBN5KAIB.js +59 -0
- package/dist/cli-ZDOTXEKL.js +31 -0
- package/dist/cli-ZDUADFBY.js +88 -0
- package/dist/cli-ZJFQ7EEA.js +131 -0
- package/dist/cli-ZTWOE3ZT.js +65 -0
- package/dist/cli.js +148 -43093
- package/dist/client/build-surfaces.d.ts +33 -0
- package/dist/client/dev-server.d.ts +6 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/playwright.d.ts +62 -0
- package/dist/client.js +228 -48
- package/dist/core/session.d.ts +15 -1
- package/dist/dev/console/assets/{index-BVF8exas.js → index-CuMOOH9m.js} +1 -1
- package/dist/dev/console/index.html +1 -1
- package/dist/dev/shell.d.ts +19 -0
- package/dist/dev/surfaces.d.ts +7 -0
- package/dist/docs/ai-agents.md +1 -1
- package/dist/docs/api/index.md +14 -12
- package/dist/docs/api/sdk-tools-client.md +29 -0
- package/dist/docs/api/sdk-tools-playwright.md +104 -0
- package/dist/docs/changelog.md +34 -0
- package/dist/docs/cli-and-dev-server.md +21 -0
- package/dist/docs/cli-reference.md +45 -31
- package/dist/docs/environment-variables.md +6 -0
- package/dist/docs/getting-started.md +1 -1
- package/dist/docs/guides/designing-a-game.md +29 -4
- package/dist/docs/guides/starter-game.md +3 -3
- package/dist/docs/guides/testing.md +33 -18
- package/dist/docs/guides/upgrading.md +19 -2
- package/dist/docs/page-index.md +10 -9
- package/dist/docs/recipes/e2e-testing.md +19 -20
- package/dist/playwright.js +32232 -0
- package/dist/templates/package/CLAUDE.md.template +7 -346
- package/dist/templates/package/claude/rules/workflow-create-engine.md +2 -2
- package/dist/templates/package/claude/rules/workflow-create-guide.md +2 -2
- package/dist/templates/package/claude/rules/workflow-create-user-interface.md +1 -1
- package/dist/templates/package/claude/rules/workflow-test-engine-or-ui.md +1 -1
- package/dist/templates/package/claude/rules/workflow-update-sdk-version.md +3 -3
- package/dist/templates/package/global-setup.ts.template +7 -18
- package/dist/templates/package/playwright.config.ts.liquid +8 -11
- package/dist/templates/starter-game/playwright.config.ts +8 -11
- package/dist/templates/starter-game/testing/e2e/game.spec.ts +1 -1
- package/dist/templates/starter-game/testing/e2e/global-setup.ts +7 -18
- package/dist/utils/prompt.d.ts +5 -5
- package/dist/utils/resource-scan.d.ts +39 -0
- package/package.json +7 -3
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
getResourceMeta
|
|
4
|
+
} from "./cli-VQ6HVQW4.js";
|
|
5
|
+
|
|
6
|
+
// cli/utils/resource-scan.ts
|
|
7
|
+
import { existsSync, readdirSync } from "fs";
|
|
8
|
+
import { join } from "path";
|
|
9
|
+
function bundlePath(meta, name) {
|
|
10
|
+
if (meta.slot) return `${meta.slot}/${meta.bundleFile}`;
|
|
11
|
+
return `${meta.pluralDir}/${name}/${meta.bundleFile}`;
|
|
12
|
+
}
|
|
13
|
+
function distPath(meta, identifier) {
|
|
14
|
+
if (meta.slot) return meta.slot;
|
|
15
|
+
return `${meta.pluralDir}/${identifier}`;
|
|
16
|
+
}
|
|
17
|
+
function resourceNames(packagePath, meta) {
|
|
18
|
+
if (meta.slot) {
|
|
19
|
+
return existsSync(join(packagePath, meta.slot, meta.bundleFile)) ? [meta.slot] : [];
|
|
20
|
+
}
|
|
21
|
+
const pluralPath = join(packagePath, meta.pluralDir);
|
|
22
|
+
if (!existsSync(pluralPath)) return [];
|
|
23
|
+
return readdirSync(pluralPath, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).filter((name) => existsSync(join(pluralPath, name, meta.bundleFile))).sort();
|
|
24
|
+
}
|
|
25
|
+
function bundlePaths(packagePath, meta) {
|
|
26
|
+
if (meta.slot) {
|
|
27
|
+
const relPath = bundlePath(meta);
|
|
28
|
+
return existsSync(join(packagePath, relPath)) ? [relPath] : [];
|
|
29
|
+
}
|
|
30
|
+
return resourceNames(packagePath, meta).map((name) => bundlePath(meta, name));
|
|
31
|
+
}
|
|
32
|
+
function slotBundleFile(packagePath, type) {
|
|
33
|
+
const meta = getResourceMeta(type);
|
|
34
|
+
if (!meta.slot) throw new Error(`${meta.label} is not a slot resource`);
|
|
35
|
+
const bundleFile = join(packagePath, meta.slot, meta.bundleFile);
|
|
36
|
+
return existsSync(bundleFile) ? bundleFile : void 0;
|
|
37
|
+
}
|
|
38
|
+
function findBundleFile(packagePath, type, identifier) {
|
|
39
|
+
const meta = getResourceMeta(type);
|
|
40
|
+
if (meta.slot) return slotBundleFile(packagePath, type);
|
|
41
|
+
const bundleFile = join(packagePath, meta.pluralDir, identifier ?? "", meta.bundleFile);
|
|
42
|
+
return existsSync(bundleFile) ? bundleFile : void 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export {
|
|
46
|
+
distPath,
|
|
47
|
+
resourceNames,
|
|
48
|
+
bundlePaths,
|
|
49
|
+
findBundleFile
|
|
50
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
promptForSchemaProperties
|
|
4
|
+
} from "./cli-RZITKPJX.js";
|
|
5
|
+
import {
|
|
6
|
+
readAuthoredBundle
|
|
7
|
+
} from "./cli-4VFZHLDG.js";
|
|
8
|
+
import {
|
|
9
|
+
resolveInputSource
|
|
10
|
+
} from "./cli-4UWFQNGF.js";
|
|
11
|
+
import {
|
|
12
|
+
createCapabilityFiles
|
|
13
|
+
} from "./cli-4SIWLHQO.js";
|
|
14
|
+
import "./cli-IUS2YCD3.js";
|
|
15
|
+
import "./cli-QUNIRH7A.js";
|
|
16
|
+
import "./cli-J4UBELKF.js";
|
|
17
|
+
import {
|
|
18
|
+
loadPackageContext
|
|
19
|
+
} from "./cli-XSVGKI3R.js";
|
|
20
|
+
import {
|
|
21
|
+
presentFields
|
|
22
|
+
} from "./cli-TT36JCU5.js";
|
|
23
|
+
import "./cli-OXAUOWCN.js";
|
|
24
|
+
import {
|
|
25
|
+
BUILD_COMMAND,
|
|
26
|
+
generateTypes,
|
|
27
|
+
operationError,
|
|
28
|
+
printOperationResult
|
|
29
|
+
} from "./cli-KSGB2ZLK.js";
|
|
30
|
+
import {
|
|
31
|
+
input
|
|
32
|
+
} from "./cli-ZTWOE3ZT.js";
|
|
33
|
+
import "./cli-LQOHATY2.js";
|
|
34
|
+
import "./cli-IEMKI7J7.js";
|
|
35
|
+
import "./cli-OMWC75CC.js";
|
|
36
|
+
import "./cli-BYCHKSSH.js";
|
|
37
|
+
import "./cli-25RWY5BQ.js";
|
|
38
|
+
import "./cli-QWQMPCL6.js";
|
|
39
|
+
import {
|
|
40
|
+
validateSDKCapability
|
|
41
|
+
} from "./cli-VQ6HVQW4.js";
|
|
42
|
+
import "./cli-F2D4GGUA.js";
|
|
43
|
+
import {
|
|
44
|
+
logger
|
|
45
|
+
} from "./cli-4YB3ROVR.js";
|
|
46
|
+
import {
|
|
47
|
+
CliError
|
|
48
|
+
} from "./cli-N6H6T2E2.js";
|
|
49
|
+
|
|
50
|
+
// cli/commands/resources/capability/new.ts
|
|
51
|
+
var CAPABILITY_SCOPES = Object.keys({
|
|
52
|
+
team: true,
|
|
53
|
+
"team-readable": true,
|
|
54
|
+
shared: true,
|
|
55
|
+
private: true
|
|
56
|
+
});
|
|
57
|
+
async function createCapability(definitionInput, options) {
|
|
58
|
+
logger.info("\nCreating new capability...\n");
|
|
59
|
+
if (options.scope !== void 0 && !CAPABILITY_SCOPES.includes(options.scope)) {
|
|
60
|
+
throw new CliError(
|
|
61
|
+
"USAGE_BAD_ARGUMENT",
|
|
62
|
+
`Invalid scope "${options.scope}". Must be one of: ${CAPABILITY_SCOPES.join(", ")}.`
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
const scopeOption = options.scope;
|
|
66
|
+
loadPackageContext(options.workingDir, {
|
|
67
|
+
suggestNewPackage: true
|
|
68
|
+
});
|
|
69
|
+
const inputSource = await resolveInputSource(definitionInput, options.file);
|
|
70
|
+
const jsonDefinition = inputSource.kind === "json" ? inputSource.json : null;
|
|
71
|
+
if (jsonDefinition) {
|
|
72
|
+
const capabilityInput = readAuthoredBundle({
|
|
73
|
+
json: jsonDefinition,
|
|
74
|
+
type: "capability",
|
|
75
|
+
command: "new",
|
|
76
|
+
validate: validateSDKCapability
|
|
77
|
+
});
|
|
78
|
+
const definition = capabilityInput.definition;
|
|
79
|
+
const scope = definition.scope ?? scopeOption;
|
|
80
|
+
logger.info("Creating capability files...\n");
|
|
81
|
+
const result2 = await createCapabilityFiles({
|
|
82
|
+
packagePath: options.workingDir,
|
|
83
|
+
identifier: definition.identifier,
|
|
84
|
+
definition: { ...definition, ...presentFields({ scope }) }
|
|
85
|
+
});
|
|
86
|
+
if (!result2.success) {
|
|
87
|
+
throw operationError(result2, "Failed to create capability files");
|
|
88
|
+
}
|
|
89
|
+
logger.success("Capability created successfully!");
|
|
90
|
+
printOperationResult(result2);
|
|
91
|
+
await generateTypes(options.workingDir);
|
|
92
|
+
logger.info("Next steps:");
|
|
93
|
+
logger.info(" 1. Use this capability in the engine by adding it to reads or writes");
|
|
94
|
+
logger.info(` 2. Run "${BUILD_COMMAND}" to build your package`);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
logger.info("No JSON definition provided. Starting interactive mode...\n");
|
|
98
|
+
const capabilityName = await input({
|
|
99
|
+
message: 'Capability name (e.g., "price", "inventory"):',
|
|
100
|
+
default: "mycapability",
|
|
101
|
+
validate: (value) => {
|
|
102
|
+
if (!value.trim()) {
|
|
103
|
+
return "Capability name is required";
|
|
104
|
+
}
|
|
105
|
+
const trimmed = value.trim();
|
|
106
|
+
if (!/^[a-z][a-z0-9_]*$/.test(trimmed)) {
|
|
107
|
+
return "Capability name must start with a lowercase letter and contain only lowercase letters, numbers, and underscores";
|
|
108
|
+
}
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
const identifier = capabilityName.trim();
|
|
113
|
+
logger.info("\u2713 This capability will be initialized with schema defaults");
|
|
114
|
+
logger.info("");
|
|
115
|
+
const variableProps = await promptForSchemaProperties({
|
|
116
|
+
context: "variable",
|
|
117
|
+
minProperties: 1
|
|
118
|
+
});
|
|
119
|
+
const variablesSchema = {
|
|
120
|
+
type: "object",
|
|
121
|
+
properties: variableProps,
|
|
122
|
+
required: Object.keys(variableProps),
|
|
123
|
+
additionalProperties: false
|
|
124
|
+
};
|
|
125
|
+
logger.info("\nCreating capability files...\n");
|
|
126
|
+
const result = await createCapabilityFiles({
|
|
127
|
+
packagePath: options.workingDir,
|
|
128
|
+
identifier,
|
|
129
|
+
definition: { variablesSchema, ...presentFields({ scope: scopeOption }) }
|
|
130
|
+
});
|
|
131
|
+
if (!result.success) {
|
|
132
|
+
throw operationError(result, "Failed to create capability files");
|
|
133
|
+
}
|
|
134
|
+
logger.success("Capability created successfully!");
|
|
135
|
+
printOperationResult(result);
|
|
136
|
+
await generateTypes(options.workingDir);
|
|
137
|
+
logger.info("Next steps:");
|
|
138
|
+
logger.info(" 1. Use this capability in the engine by adding it to reads or writes");
|
|
139
|
+
logger.info(` 2. Run "${BUILD_COMMAND}" to build your package`);
|
|
140
|
+
}
|
|
141
|
+
export {
|
|
142
|
+
createCapability
|
|
143
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
resourceNames
|
|
4
|
+
} from "./cli-OXAUOWCN.js";
|
|
5
|
+
import {
|
|
6
|
+
checkbox
|
|
7
|
+
} from "./cli-ZTWOE3ZT.js";
|
|
8
|
+
import {
|
|
9
|
+
getResourceMeta
|
|
10
|
+
} from "./cli-VQ6HVQW4.js";
|
|
11
|
+
|
|
12
|
+
// cli/utils/resource-discovery.ts
|
|
13
|
+
function loadResourceIdentifiers(workingDir, type) {
|
|
14
|
+
return resourceNames(workingDir, getResourceMeta(type));
|
|
15
|
+
}
|
|
16
|
+
async function promptForCapabilities(message, availableCapabilities, currentCapabilities = []) {
|
|
17
|
+
if (availableCapabilities.length === 0) {
|
|
18
|
+
console.log("No capabilities available in this package.");
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
return await checkbox({
|
|
22
|
+
message,
|
|
23
|
+
choices: availableCapabilities.map((cap) => ({
|
|
24
|
+
name: cap,
|
|
25
|
+
value: cap,
|
|
26
|
+
checked: currentCapabilities.includes(cap)
|
|
27
|
+
})),
|
|
28
|
+
pageSize: 15
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
loadResourceIdentifiers,
|
|
34
|
+
promptForCapabilities
|
|
35
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// cli/utils/schema-properties.ts
|
|
4
|
+
function extractSchemaProperties(schema) {
|
|
5
|
+
if (!schema?.properties) return {};
|
|
6
|
+
return schema.properties;
|
|
7
|
+
}
|
|
8
|
+
function wrapAsFullSchema(properties) {
|
|
9
|
+
return {
|
|
10
|
+
type: "object",
|
|
11
|
+
properties,
|
|
12
|
+
required: Object.keys(properties),
|
|
13
|
+
additionalProperties: false
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function normalizeVariablesSchema(schema) {
|
|
17
|
+
if (!schema) return schema;
|
|
18
|
+
if (schema.properties) return schema;
|
|
19
|
+
const entries = Object.entries(schema);
|
|
20
|
+
if (entries.length === 0) return schema;
|
|
21
|
+
const looksFlat = entries.every(([key, value]) => {
|
|
22
|
+
if (["type", "required", "additionalProperties", "$schema", "$id", "description"].includes(
|
|
23
|
+
key
|
|
24
|
+
)) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) && "type" in value;
|
|
28
|
+
});
|
|
29
|
+
if (!looksFlat) return schema;
|
|
30
|
+
const jsonSchemaKeywords = /* @__PURE__ */ new Set([
|
|
31
|
+
"type",
|
|
32
|
+
"required",
|
|
33
|
+
"additionalProperties",
|
|
34
|
+
"$schema",
|
|
35
|
+
"$id",
|
|
36
|
+
"description"
|
|
37
|
+
]);
|
|
38
|
+
const properties = {};
|
|
39
|
+
for (const [key, value] of entries) {
|
|
40
|
+
if (!jsonSchemaKeywords.has(key)) {
|
|
41
|
+
properties[key] = value;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (Object.keys(properties).length === 0) return schema;
|
|
45
|
+
return {
|
|
46
|
+
type: "object",
|
|
47
|
+
properties,
|
|
48
|
+
required: Object.keys(properties),
|
|
49
|
+
additionalProperties: false
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export {
|
|
54
|
+
extractSchemaProperties,
|
|
55
|
+
wrapAsFullSchema,
|
|
56
|
+
normalizeVariablesSchema
|
|
57
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
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
|
+
createHookFiles
|
|
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
|
+
input,
|
|
36
|
+
select
|
|
37
|
+
} from "./cli-ZTWOE3ZT.js";
|
|
38
|
+
import "./cli-LQOHATY2.js";
|
|
39
|
+
import "./cli-IEMKI7J7.js";
|
|
40
|
+
import "./cli-OMWC75CC.js";
|
|
41
|
+
import "./cli-BYCHKSSH.js";
|
|
42
|
+
import "./cli-25RWY5BQ.js";
|
|
43
|
+
import "./cli-QWQMPCL6.js";
|
|
44
|
+
import {
|
|
45
|
+
validateSDKHook
|
|
46
|
+
} from "./cli-VQ6HVQW4.js";
|
|
47
|
+
import "./cli-F2D4GGUA.js";
|
|
48
|
+
import {
|
|
49
|
+
logger
|
|
50
|
+
} from "./cli-4YB3ROVR.js";
|
|
51
|
+
import "./cli-N6H6T2E2.js";
|
|
52
|
+
|
|
53
|
+
// cli/commands/resources/hook/new.ts
|
|
54
|
+
var HOOK_SIGNALS = ["participantJoin", "participantMove"];
|
|
55
|
+
async function createHook(definitionInput, options) {
|
|
56
|
+
logger.info("\nCreating new hook...\n");
|
|
57
|
+
loadPackageContext(options.workingDir);
|
|
58
|
+
const inputSource = await resolveInputSource(definitionInput, options.file);
|
|
59
|
+
const jsonDefinition = inputSource.kind === "json" ? inputSource.json : null;
|
|
60
|
+
if (jsonDefinition) {
|
|
61
|
+
const hookInput = readAuthoredBundle({
|
|
62
|
+
json: jsonDefinition,
|
|
63
|
+
type: "hook",
|
|
64
|
+
command: "new",
|
|
65
|
+
validate: validateSDKHook
|
|
66
|
+
});
|
|
67
|
+
logger.info("Creating hook files...\n");
|
|
68
|
+
const result2 = await createHookFiles({
|
|
69
|
+
packagePath: options.workingDir,
|
|
70
|
+
identifier: hookInput.definition.identifier,
|
|
71
|
+
definition: hookInput.definition
|
|
72
|
+
});
|
|
73
|
+
if (!result2.success) {
|
|
74
|
+
throw operationError(result2, "Failed to create hook files");
|
|
75
|
+
}
|
|
76
|
+
logger.success("Hook created successfully!");
|
|
77
|
+
printOperationResult(result2);
|
|
78
|
+
await generateTypes(options.workingDir);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
logger.info("No JSON definition provided. Starting interactive mode...\n");
|
|
82
|
+
const shortIdentifier = await input({
|
|
83
|
+
message: 'Hook identifier (short name, e.g., "assignroles"):',
|
|
84
|
+
validate: (value) => {
|
|
85
|
+
if (!value.trim()) return "Identifier is required";
|
|
86
|
+
if (value.includes(".")) {
|
|
87
|
+
return 'In interactive mode, use short identifier (e.g., "assignroles" instead of "com.example.assignroles")';
|
|
88
|
+
}
|
|
89
|
+
if (!/^[a-z][a-z0-9_]*$/.test(value)) {
|
|
90
|
+
return "Identifier must start with lowercase letter and contain only lowercase letters, numbers, and underscores";
|
|
91
|
+
}
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
const identifier = shortIdentifier.trim();
|
|
96
|
+
const signal = await select({
|
|
97
|
+
message: "Lifecycle signal this hook fires on:",
|
|
98
|
+
choices: HOOK_SIGNALS.map((s) => ({ name: s, value: s }))
|
|
99
|
+
});
|
|
100
|
+
const availableCapabilities = loadResourceIdentifiers(options.workingDir, "capability");
|
|
101
|
+
const reads = [];
|
|
102
|
+
const writes = [];
|
|
103
|
+
if (availableCapabilities.length > 0) {
|
|
104
|
+
const readCapabilities = await checkbox({
|
|
105
|
+
message: "Capabilities this hook reads from:",
|
|
106
|
+
choices: availableCapabilities.map((id) => ({ name: id, value: id })),
|
|
107
|
+
pageSize: 10
|
|
108
|
+
});
|
|
109
|
+
reads.push(...readCapabilities);
|
|
110
|
+
const remainingForWrites = availableCapabilities.filter(
|
|
111
|
+
(id) => !readCapabilities.includes(id)
|
|
112
|
+
);
|
|
113
|
+
if (remainingForWrites.length > 0) {
|
|
114
|
+
const writeCapabilities = await checkbox({
|
|
115
|
+
message: "Capabilities this hook writes to:",
|
|
116
|
+
choices: remainingForWrites.map((id) => ({ name: id, value: id })),
|
|
117
|
+
pageSize: 10
|
|
118
|
+
});
|
|
119
|
+
writes.push(...writeCapabilities);
|
|
120
|
+
}
|
|
121
|
+
logger.info("");
|
|
122
|
+
}
|
|
123
|
+
const settings = await promptForSettings(options.workingDir, "hook");
|
|
124
|
+
logger.info("Creating hook files...\n");
|
|
125
|
+
const result = await createHookFiles({
|
|
126
|
+
packagePath: options.workingDir,
|
|
127
|
+
identifier,
|
|
128
|
+
definition: { signal, ...presentFields({ reads, writes, settings }) }
|
|
129
|
+
});
|
|
130
|
+
if (!result.success) {
|
|
131
|
+
throw operationError(result, "Failed to create hook files");
|
|
132
|
+
}
|
|
133
|
+
logger.success("Hook created successfully!");
|
|
134
|
+
printOperationResult(result);
|
|
135
|
+
await generateTypes(options.workingDir);
|
|
136
|
+
logger.info("Next steps:");
|
|
137
|
+
logger.info(` 1. Edit the hook logic: hooks/${identifier}/logic/logic.ts`);
|
|
138
|
+
logger.info(` 2. Run "${BUILD_COMMAND}" to build your package`);
|
|
139
|
+
}
|
|
140
|
+
export {
|
|
141
|
+
createHook
|
|
142
|
+
};
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
SEMVER_PATTERN
|
|
4
|
+
} from "./cli-ILKCQNM6.js";
|
|
5
|
+
import {
|
|
6
|
+
logger
|
|
7
|
+
} from "./cli-4YB3ROVR.js";
|
|
8
|
+
import {
|
|
9
|
+
CliError,
|
|
10
|
+
reportResult
|
|
11
|
+
} from "./cli-N6H6T2E2.js";
|
|
12
|
+
|
|
13
|
+
// cli/commands/package-version.ts
|
|
14
|
+
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
15
|
+
import { join, resolve } from "path";
|
|
16
|
+
var BUMP_KEYWORDS = ["patch", "minor", "major", "prerelease"];
|
|
17
|
+
function isBumpKeyword(value) {
|
|
18
|
+
return BUMP_KEYWORDS.includes(value);
|
|
19
|
+
}
|
|
20
|
+
function parseSemver(version) {
|
|
21
|
+
const match = SEMVER_PATTERN.exec(version);
|
|
22
|
+
if (!match) {
|
|
23
|
+
throw new CliError(
|
|
24
|
+
"USAGE_BAD_ARGUMENT",
|
|
25
|
+
`Invalid semver "${version}". Expected MAJOR.MINOR.PATCH with optional pre-release and build metadata.`
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
const [, major, minor, patch] = match;
|
|
29
|
+
const dashIndex = version.indexOf("-");
|
|
30
|
+
const plusIndex = version.indexOf("+");
|
|
31
|
+
const prereleaseEnd = plusIndex === -1 ? version.length : plusIndex;
|
|
32
|
+
const prerelease = dashIndex !== -1 && dashIndex < prereleaseEnd ? version.substring(dashIndex + 1, prereleaseEnd).split(".") : null;
|
|
33
|
+
return {
|
|
34
|
+
major: Number(major),
|
|
35
|
+
minor: Number(minor),
|
|
36
|
+
patch: Number(patch),
|
|
37
|
+
prerelease
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function formatSemver(parsed) {
|
|
41
|
+
const base = `${parsed.major}.${parsed.minor}.${parsed.patch}`;
|
|
42
|
+
return parsed.prerelease && parsed.prerelease.length > 0 ? `${base}-${parsed.prerelease.join(".")}` : base;
|
|
43
|
+
}
|
|
44
|
+
function bumpVersion(current, keyword) {
|
|
45
|
+
const parsed = parseSemver(current);
|
|
46
|
+
switch (keyword) {
|
|
47
|
+
case "major":
|
|
48
|
+
return formatSemver({ major: parsed.major + 1, minor: 0, patch: 0, prerelease: null });
|
|
49
|
+
case "minor":
|
|
50
|
+
return formatSemver({
|
|
51
|
+
major: parsed.major,
|
|
52
|
+
minor: parsed.minor + 1,
|
|
53
|
+
patch: 0,
|
|
54
|
+
prerelease: null
|
|
55
|
+
});
|
|
56
|
+
case "patch":
|
|
57
|
+
return formatSemver({
|
|
58
|
+
major: parsed.major,
|
|
59
|
+
minor: parsed.minor,
|
|
60
|
+
patch: parsed.patch + 1,
|
|
61
|
+
prerelease: null
|
|
62
|
+
});
|
|
63
|
+
case "prerelease": {
|
|
64
|
+
if (!parsed.prerelease) {
|
|
65
|
+
return formatSemver({
|
|
66
|
+
major: parsed.major,
|
|
67
|
+
minor: parsed.minor,
|
|
68
|
+
patch: parsed.patch + 1,
|
|
69
|
+
prerelease: ["0"]
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
const last = parsed.prerelease.at(-1);
|
|
73
|
+
if (last !== void 0 && /^\d+$/.test(last)) {
|
|
74
|
+
const next = [...parsed.prerelease];
|
|
75
|
+
next[next.length - 1] = String(Number(last) + 1);
|
|
76
|
+
return formatSemver({ ...parsed, prerelease: next });
|
|
77
|
+
}
|
|
78
|
+
return formatSemver({
|
|
79
|
+
...parsed,
|
|
80
|
+
prerelease: [...parsed.prerelease, "0"]
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function readJsonFile(path, label) {
|
|
86
|
+
let raw;
|
|
87
|
+
try {
|
|
88
|
+
raw = readFileSync(path, "utf-8");
|
|
89
|
+
} catch (error) {
|
|
90
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
91
|
+
throw new CliError("MANIFEST_INVALID", `Failed to read ${label} at ${path}: ${message}`);
|
|
92
|
+
}
|
|
93
|
+
let parsed;
|
|
94
|
+
try {
|
|
95
|
+
parsed = JSON.parse(raw);
|
|
96
|
+
} catch (error) {
|
|
97
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
98
|
+
throw new CliError("MANIFEST_INVALID", `Failed to parse ${label} at ${path}: ${message}`);
|
|
99
|
+
}
|
|
100
|
+
return { raw, parsed };
|
|
101
|
+
}
|
|
102
|
+
function detectIndent(raw) {
|
|
103
|
+
const match = /\n(\s+)/.exec(raw);
|
|
104
|
+
return match?.[1] ?? " ";
|
|
105
|
+
}
|
|
106
|
+
function getTrailingNewline(raw) {
|
|
107
|
+
return raw.endsWith("\n") ? "\n" : "";
|
|
108
|
+
}
|
|
109
|
+
function serialise(value, indent, trailingNewline) {
|
|
110
|
+
return `${JSON.stringify(value, null, indent)}${trailingNewline}`;
|
|
111
|
+
}
|
|
112
|
+
async function packageVersionCommand(value, options) {
|
|
113
|
+
const fail = (code, message) => {
|
|
114
|
+
throw new CliError(code, message);
|
|
115
|
+
};
|
|
116
|
+
if (!value || value.trim() === "") {
|
|
117
|
+
fail(
|
|
118
|
+
"USAGE_MISSING_ARGUMENT",
|
|
119
|
+
'A version value is required. Provide a semver string (e.g. "1.2.3") or a bump keyword (patch, minor, major, prerelease).'
|
|
120
|
+
);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const sdkPath = resolve(options.workingDir, "seriousgaming.sdk.json");
|
|
124
|
+
if (!existsSync(sdkPath)) {
|
|
125
|
+
fail(
|
|
126
|
+
"MANIFEST_NOT_FOUND",
|
|
127
|
+
`seriousgaming.sdk.json not found at ${sdkPath}. Run this command in a Serious Gaming package directory.`
|
|
128
|
+
);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const packageJsonPath = join(options.workingDir, "package.json");
|
|
132
|
+
if (!existsSync(packageJsonPath)) {
|
|
133
|
+
fail(
|
|
134
|
+
"MANIFEST_NOT_FOUND",
|
|
135
|
+
`package.json not found at ${packageJsonPath}. The package version lives there, alongside npm's own copy.`
|
|
136
|
+
);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const packageFile = readJsonFile(packageJsonPath, "package.json");
|
|
140
|
+
const previous = packageFile.parsed.version;
|
|
141
|
+
if (typeof previous !== "string" || previous === "") {
|
|
142
|
+
fail(
|
|
143
|
+
"MANIFEST_INVALID",
|
|
144
|
+
`package.json at ${packageJsonPath} is missing a version. Set an initial semver string (e.g. "0.0.0") before bumping.`
|
|
145
|
+
);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
let next;
|
|
149
|
+
try {
|
|
150
|
+
next = isBumpKeyword(value) ? bumpVersion(previous, value) : value;
|
|
151
|
+
} catch (error) {
|
|
152
|
+
throw error instanceof CliError ? new CliError("MANIFEST_INVALID", error.message, { cause: error }) : error;
|
|
153
|
+
}
|
|
154
|
+
if (!SEMVER_PATTERN.test(next)) {
|
|
155
|
+
fail(
|
|
156
|
+
"USAGE_BAD_ARGUMENT",
|
|
157
|
+
`"${next}" is not a valid semver string. Expected MAJOR.MINOR.PATCH with optional pre-release and build metadata.`
|
|
158
|
+
);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const nextContent = serialise(
|
|
162
|
+
{ ...packageFile.parsed, version: next },
|
|
163
|
+
detectIndent(packageFile.raw),
|
|
164
|
+
getTrailingNewline(packageFile.raw)
|
|
165
|
+
);
|
|
166
|
+
const files = [];
|
|
167
|
+
try {
|
|
168
|
+
writeFileSync(packageJsonPath, nextContent, "utf-8");
|
|
169
|
+
files.push(packageJsonPath);
|
|
170
|
+
} catch (error) {
|
|
171
|
+
fail(
|
|
172
|
+
"WRITE_FAILED",
|
|
173
|
+
`Failed to write ${packageJsonPath}: ${error instanceof Error ? error.message : String(error)}`
|
|
174
|
+
);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
const result = { previous, next, files };
|
|
178
|
+
reportResult(result, () => {
|
|
179
|
+
logger.success(`Version updated: ${previous} \u2192 ${next}`);
|
|
180
|
+
for (const file of files) {
|
|
181
|
+
console.log(` ${file}`);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
export {
|
|
186
|
+
packageVersionCommand
|
|
187
|
+
};
|