@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,463 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
connectSession,
|
|
4
|
+
resolveSession
|
|
5
|
+
} from "./cli-6K3VQQUS.js";
|
|
6
|
+
import "./cli-WU43JT4T.js";
|
|
7
|
+
import {
|
|
8
|
+
DevShell,
|
|
9
|
+
parseRoute
|
|
10
|
+
} from "./cli-IP4RXGHM.js";
|
|
11
|
+
import "./cli-BWX5E7TQ.js";
|
|
12
|
+
import "./cli-BJMS3VX3.js";
|
|
13
|
+
import "./cli-ILKCQNM6.js";
|
|
14
|
+
import "./cli-7XLHO2FE.js";
|
|
15
|
+
import "./cli-FQRVFGN6.js";
|
|
16
|
+
import "./cli-XSLNH5PR.js";
|
|
17
|
+
import {
|
|
18
|
+
loadEnvironmentConfig
|
|
19
|
+
} from "./cli-TDSQSCX4.js";
|
|
20
|
+
import "./cli-SRHBXZCN.js";
|
|
21
|
+
import "./cli-KGT5L7VZ.js";
|
|
22
|
+
import "./cli-4LKXZQ2B.js";
|
|
23
|
+
import "./cli-MMN4BPO4.js";
|
|
24
|
+
import "./cli-YOTGR3NB.js";
|
|
25
|
+
import "./cli-QUNIRH7A.js";
|
|
26
|
+
import "./cli-OMWC75CC.js";
|
|
27
|
+
import "./cli-BYCHKSSH.js";
|
|
28
|
+
import "./cli-25RWY5BQ.js";
|
|
29
|
+
import "./cli-QWQMPCL6.js";
|
|
30
|
+
import "./cli-VQ6HVQW4.js";
|
|
31
|
+
import "./cli-F2D4GGUA.js";
|
|
32
|
+
import "./cli-4YB3ROVR.js";
|
|
33
|
+
import {
|
|
34
|
+
CliError,
|
|
35
|
+
reportResult
|
|
36
|
+
} from "./cli-N6H6T2E2.js";
|
|
37
|
+
|
|
38
|
+
// cli/commands/screenshot.ts
|
|
39
|
+
import { existsSync } from "fs";
|
|
40
|
+
import { mkdir } from "fs/promises";
|
|
41
|
+
import { createRequire } from "module";
|
|
42
|
+
import { dirname, join, resolve } from "path";
|
|
43
|
+
import { pathToFileURL } from "url";
|
|
44
|
+
|
|
45
|
+
// cli/client/dev-server.ts
|
|
46
|
+
async function startDevServer(options) {
|
|
47
|
+
const environment = loadEnvironmentConfig(options.packagePath);
|
|
48
|
+
const shell = new DevShell({
|
|
49
|
+
packagePath: options.packagePath,
|
|
50
|
+
port: options.port ?? 0,
|
|
51
|
+
isolated: true,
|
|
52
|
+
...options.teams === void 0 ? {} : { teams: options.teams },
|
|
53
|
+
...options.participants === void 0 ? {} : { participants: options.participants },
|
|
54
|
+
...options.scenarioId === void 0 ? {} : { scenarioId: options.scenarioId },
|
|
55
|
+
...options.locale === void 0 ? {} : { locale: options.locale },
|
|
56
|
+
...options.clock === void 0 ? {} : { clock: options.clock },
|
|
57
|
+
...options.callbacks === void 0 ? {} : { callbacks: options.callbacks },
|
|
58
|
+
...options.reinitOnChange ? { reinitOnChange: true } : {},
|
|
59
|
+
...options.builtSurfaces === void 0 ? {} : { builtSurfaces: options.builtSurfaces },
|
|
60
|
+
...environment.seriousGamingApiKey === void 0 ? {} : { seriousGamingApiKey: environment.seriousGamingApiKey },
|
|
61
|
+
...environment.seriousGamingApiHost === void 0 ? {} : { seriousGamingApiHost: environment.seriousGamingApiHost },
|
|
62
|
+
...environment.elevenLabsApiKey === void 0 ? {} : { elevenLabsApiKey: environment.elevenLabsApiKey }
|
|
63
|
+
});
|
|
64
|
+
try {
|
|
65
|
+
await shell.start();
|
|
66
|
+
} catch (error) {
|
|
67
|
+
await shell.stop().catch(() => {
|
|
68
|
+
});
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
let stopping = null;
|
|
72
|
+
return {
|
|
73
|
+
url: shell.url,
|
|
74
|
+
assetUrl: shell.assetUrl,
|
|
75
|
+
stop() {
|
|
76
|
+
stopping ??= shell.stop();
|
|
77
|
+
return stopping;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// cli/commands/screenshot.ts
|
|
83
|
+
var DEFAULT_WIDTH = 1280;
|
|
84
|
+
var DEFAULT_HEIGHT = 800;
|
|
85
|
+
var DEFAULT_TIMEOUT_SECONDS = 30;
|
|
86
|
+
var MAX_DIMENSION = 16384;
|
|
87
|
+
var MISSING_HINT = "Add it to the package with `pnpm add -D @playwright/test`, then run `pnpm exec playwright install chromium`.";
|
|
88
|
+
async function screenshotCommand(path, options, dependencies = {}) {
|
|
89
|
+
const packagePath = resolve(options.workingDir);
|
|
90
|
+
const plan = planScreenshot(path, options, packagePath);
|
|
91
|
+
const chromium = await (dependencies.loadPlaywright ?? loadPlaywright)(packagePath);
|
|
92
|
+
if (!chromium) {
|
|
93
|
+
throw new CliError(
|
|
94
|
+
"BROWSER_MISSING",
|
|
95
|
+
"sdk screenshot drives Playwright, and this package does not depend on it.",
|
|
96
|
+
{ hint: MISSING_HINT }
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
const result = await withServer(packagePath, plan, async (url, server) => {
|
|
100
|
+
const problems = await capture(chromium, `${url}${plan.target}`, plan);
|
|
101
|
+
return {
|
|
102
|
+
path: plan.out,
|
|
103
|
+
url: `${url}${plan.target}`,
|
|
104
|
+
width: plan.width,
|
|
105
|
+
height: plan.height,
|
|
106
|
+
fullPage: plan.fullPage,
|
|
107
|
+
server,
|
|
108
|
+
...problems
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
reportResult(result, () => {
|
|
112
|
+
console.log(`Saved ${result.path} (${result.width}x${result.height}) from ${result.url}`);
|
|
113
|
+
printProblems(result);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function planScreenshot(path, options, packagePath) {
|
|
117
|
+
if (!path.startsWith("/")) {
|
|
118
|
+
throw new CliError(
|
|
119
|
+
"USAGE_BAD_ARGUMENT",
|
|
120
|
+
`"${path}" is not a console path: it starts with /, such as /team/1/player/1`
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
const url = new URL(path, "http://localhost");
|
|
124
|
+
const route = parseRoute(url.pathname, url.search);
|
|
125
|
+
if (route.kind === "console" && url.pathname !== "/") {
|
|
126
|
+
throw new CliError(
|
|
127
|
+
"USAGE_BAD_ARGUMENT",
|
|
128
|
+
`"${url.pathname}" names no surface. Use / for the session surface, /team/<n>/player/<n>, /team/<n>/observe, /team/<n>/waiting-room, /walkthrough, /setup, /scenario-editor?scenario=<id>, /presentation, /guide or /print`
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
const scheme = options.scheme;
|
|
132
|
+
if (scheme !== void 0 && scheme !== "light" && scheme !== "dark" && scheme !== "system") {
|
|
133
|
+
throw new CliError(
|
|
134
|
+
"USAGE_BAD_FLAG",
|
|
135
|
+
`--scheme takes light, dark or system, and got "${scheme}"`
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
url.searchParams.set("bare", "");
|
|
139
|
+
if (scheme !== void 0) url.searchParams.set("scheme", scheme);
|
|
140
|
+
if (options.brand !== void 0) url.searchParams.set("brand", options.brand);
|
|
141
|
+
const width = dimension(options.width, "--width", DEFAULT_WIDTH);
|
|
142
|
+
const height = dimension(options.height, "--height", DEFAULT_HEIGHT);
|
|
143
|
+
const timeout = positive(options.timeout, "--timeout", DEFAULT_TIMEOUT_SECONDS);
|
|
144
|
+
const out = options.out === void 0 ? join(
|
|
145
|
+
packagePath,
|
|
146
|
+
".seriousgaming-sdk",
|
|
147
|
+
"screenshots",
|
|
148
|
+
`${slug(url.pathname)}-${width}x${height}.png`
|
|
149
|
+
) : resolve(packagePath, options.out);
|
|
150
|
+
if (!out.toLowerCase().endsWith(".png")) {
|
|
151
|
+
throw new CliError("USAGE_BAD_FLAG", `--out names a PNG file, and got "${options.out}"`);
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
// `bare` is a flag, not a value: `?bare=` reads as one, as the console's own links avoid.
|
|
155
|
+
target: `${url.pathname}${url.search.replace(/([?&]bare)=(?=&|$)/, "$1")}`,
|
|
156
|
+
route,
|
|
157
|
+
width,
|
|
158
|
+
height,
|
|
159
|
+
...scheme === void 0 ? {} : { scheme },
|
|
160
|
+
...options.brand === void 0 ? {} : { brand: options.brand },
|
|
161
|
+
...options.locale === void 0 ? {} : { locale: options.locale },
|
|
162
|
+
fullPage: options.fullPage === true,
|
|
163
|
+
out,
|
|
164
|
+
timeoutMs: timeout * 1e3
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function dimension(value, flag, fallback) {
|
|
168
|
+
const parsed = positive(value, flag, fallback);
|
|
169
|
+
if (!Number.isInteger(parsed) || parsed > MAX_DIMENSION) {
|
|
170
|
+
throw new CliError(
|
|
171
|
+
"USAGE_BAD_FLAG",
|
|
172
|
+
`${flag} takes a whole number of pixels up to ${MAX_DIMENSION}, and got "${value}"`
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
return parsed;
|
|
176
|
+
}
|
|
177
|
+
function positive(value, flag, fallback) {
|
|
178
|
+
if (value === void 0) return fallback;
|
|
179
|
+
const parsed = Number(value);
|
|
180
|
+
if (!/^\d+(\.\d+)?$/.test(value) || parsed <= 0) {
|
|
181
|
+
throw new CliError("USAGE_BAD_FLAG", `${flag} takes a positive number, and got "${value}"`);
|
|
182
|
+
}
|
|
183
|
+
return parsed;
|
|
184
|
+
}
|
|
185
|
+
function slug(pathname) {
|
|
186
|
+
const parts = pathname.split("/").filter(Boolean);
|
|
187
|
+
return parts.length === 0 ? "session" : parts.join("-");
|
|
188
|
+
}
|
|
189
|
+
async function loadPlaywright(packagePath, resolution = {}) {
|
|
190
|
+
const exists = resolution.exists ?? existsSync;
|
|
191
|
+
const requireFrom = resolution.requireFrom ?? createRequire;
|
|
192
|
+
for (const name of ["@playwright/test", "playwright"]) {
|
|
193
|
+
const modules = nodeModulesHolding(packagePath, name, exists);
|
|
194
|
+
if (modules === null) continue;
|
|
195
|
+
let entry;
|
|
196
|
+
try {
|
|
197
|
+
entry = requireFrom(join(modules, "package.json")).resolve(name);
|
|
198
|
+
} catch {
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
const module = await import(pathToFileURL(entry).href);
|
|
202
|
+
const chromium = module.chromium ?? module.default?.chromium;
|
|
203
|
+
if (chromium) return chromium;
|
|
204
|
+
}
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
function nodeModulesHolding(from, name, exists) {
|
|
208
|
+
let directory = resolve(from);
|
|
209
|
+
for (; ; ) {
|
|
210
|
+
const modules = join(directory, "node_modules");
|
|
211
|
+
if (exists(join(modules, name, "package.json"))) return modules;
|
|
212
|
+
const parent = dirname(directory);
|
|
213
|
+
if (parent === directory) return null;
|
|
214
|
+
directory = parent;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
async function launchBrowser(chromium) {
|
|
218
|
+
try {
|
|
219
|
+
return await chromium.launch({ headless: true });
|
|
220
|
+
} catch (error) {
|
|
221
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
222
|
+
if (/Executable doesn't exist|playwright install/i.test(message)) {
|
|
223
|
+
throw new CliError(
|
|
224
|
+
"BROWSER_MISSING",
|
|
225
|
+
"Playwright is installed, but the Chromium it drives is not.",
|
|
226
|
+
{
|
|
227
|
+
hint: "Run `pnpm exec playwright install chromium` in the package.",
|
|
228
|
+
cause: error
|
|
229
|
+
}
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
throw new CliError("BROWSER_MISSING", `Chromium did not start: ${message.split("\n")[0]}`, {
|
|
233
|
+
hint: "Run `pnpm exec playwright install chromium` in the package.",
|
|
234
|
+
cause: error
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
async function withServer(packagePath, plan, work) {
|
|
239
|
+
let found = null;
|
|
240
|
+
try {
|
|
241
|
+
found = await resolveSession({ packagePath, autoStart: false, runKind: plan.route.run });
|
|
242
|
+
} catch (error) {
|
|
243
|
+
if (!(error instanceof CliError && error.code === "NO_SESSION")) throw error;
|
|
244
|
+
}
|
|
245
|
+
if (found?.url) {
|
|
246
|
+
const url = found.url;
|
|
247
|
+
return prepared(url, found, plan, false, () => work(url, "running"));
|
|
248
|
+
}
|
|
249
|
+
console.error("No dev server is running, so one is starting for this capture.");
|
|
250
|
+
const server = await startDevServer({ packagePath });
|
|
251
|
+
try {
|
|
252
|
+
const session = connectSession(server.url, plan.route.run);
|
|
253
|
+
if (plan.route.kind !== "setup" && (await session.state()).session.inSetup) {
|
|
254
|
+
await session.send({ type: "play" });
|
|
255
|
+
}
|
|
256
|
+
return await prepared(server.url, session, plan, true, () => work(server.url, "started"));
|
|
257
|
+
} finally {
|
|
258
|
+
await server.stop();
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
async function prepared(url, session, plan, own, work) {
|
|
262
|
+
if (plan.brand !== void 0) {
|
|
263
|
+
const { brands } = await fetchJson(`${url}/api/brands`);
|
|
264
|
+
const ids = brands.map((brand) => brand.id);
|
|
265
|
+
if (!ids.includes(plan.brand)) {
|
|
266
|
+
throw new CliError(
|
|
267
|
+
"USAGE_BAD_FLAG",
|
|
268
|
+
`--brand "${plan.brand}" is not one the dev server offers (${ids.join(", ") || "none"})`
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (plan.locale === void 0) return work();
|
|
273
|
+
const locales = await fetchJson(`${url}/api/locales`);
|
|
274
|
+
if (!locales.supported.includes(plan.locale)) {
|
|
275
|
+
throw new CliError(
|
|
276
|
+
"USAGE_BAD_FLAG",
|
|
277
|
+
`--locale "${plan.locale}" is not one of this game's locales (${locales.supported.join(", ")})`
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
if (locales.active === plan.locale) return work();
|
|
281
|
+
await setLocale(session, plan.locale);
|
|
282
|
+
try {
|
|
283
|
+
return await work();
|
|
284
|
+
} finally {
|
|
285
|
+
if (!own) await setLocale(session, locales.active).catch(() => {
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
async function setLocale(session, locale) {
|
|
290
|
+
const result = await session.send({ type: "setLocale", locale });
|
|
291
|
+
if ("ok" in result && !result.ok) {
|
|
292
|
+
throw new CliError(
|
|
293
|
+
"REFUSED_DENIED",
|
|
294
|
+
result.outcome.message ?? `The session refused the locale "${locale}"`
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
async function fetchJson(url) {
|
|
299
|
+
let response;
|
|
300
|
+
try {
|
|
301
|
+
response = await fetch(url);
|
|
302
|
+
} catch (error) {
|
|
303
|
+
throw new CliError(
|
|
304
|
+
"DEV_SERVER_UNREACHABLE",
|
|
305
|
+
`The dev server at ${new URL(url).origin} did not answer: ${error instanceof Error ? error.message : String(error)}`
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
if (!response.ok) {
|
|
309
|
+
throw new CliError(
|
|
310
|
+
"DEV_SERVER_OUTDATED",
|
|
311
|
+
`The dev server did not answer ${new URL(url).pathname} (HTTP ${response.status})`,
|
|
312
|
+
{ hint: "Restart the dev server: `sdk dev stop`, then run the command again." }
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
return await response.json();
|
|
316
|
+
}
|
|
317
|
+
function readinessScript(route) {
|
|
318
|
+
const content = route.kind === "guide" ? '[data-testid="guide-content"]' : route.kind === "print" ? '[data-testid="print-sheets"]' : null;
|
|
319
|
+
return `(() => {
|
|
320
|
+
const frames = [...document.querySelectorAll('[data-surface-state]')];
|
|
321
|
+
if (frames.some((frame) => frame.dataset.surfaceState === 'lost')) return 'lost';
|
|
322
|
+
if (frames.length > 0) {
|
|
323
|
+
return frames.every((frame) => frame.dataset.surfaceState === 'rendered') ? 'rendered' : false;
|
|
324
|
+
}
|
|
325
|
+
const root = document.getElementById('root');
|
|
326
|
+
if (!root || root.childElementCount === 0) return false;
|
|
327
|
+
if (document.querySelector('[data-testid="console-loading"]')) return false;
|
|
328
|
+
return ${content === null ? "'rendered'" : `document.querySelector(${JSON.stringify(content)}) ? 'rendered' : false`};
|
|
329
|
+
})()`;
|
|
330
|
+
}
|
|
331
|
+
var SURFACE_STATE_SCRIPT = `[...document.querySelectorAll('[data-surface-state]')].map((frame) => frame.dataset.surfaceState)`;
|
|
332
|
+
async function capture(chromium, url, plan) {
|
|
333
|
+
const browser = await launchBrowser(chromium);
|
|
334
|
+
const problems = {
|
|
335
|
+
consoleErrors: [],
|
|
336
|
+
failedRequests: [],
|
|
337
|
+
uncaughtExceptions: []
|
|
338
|
+
};
|
|
339
|
+
try {
|
|
340
|
+
const context = await browser.newContext({
|
|
341
|
+
viewport: { width: plan.width, height: plan.height },
|
|
342
|
+
...plan.scheme === "light" || plan.scheme === "dark" ? { colorScheme: plan.scheme } : {}
|
|
343
|
+
});
|
|
344
|
+
const page = await context.newPage();
|
|
345
|
+
watch(page, problems);
|
|
346
|
+
const deadline = Date.now() + plan.timeoutMs;
|
|
347
|
+
try {
|
|
348
|
+
await page.goto(url, { waitUntil: "load", timeout: plan.timeoutMs });
|
|
349
|
+
const state = await page.waitForFunction(readinessScript(plan.route), void 0, {
|
|
350
|
+
timeout: Math.max(1, deadline - Date.now()),
|
|
351
|
+
polling: 100
|
|
352
|
+
});
|
|
353
|
+
if (await settled(state) === "lost") {
|
|
354
|
+
throw notRendered(
|
|
355
|
+
`The surface at ${plan.target} did not connect to the console. Check its console for an error.`,
|
|
356
|
+
problems
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
} catch (error) {
|
|
360
|
+
if (error instanceof CliError) throw error;
|
|
361
|
+
const states = await page.evaluate(SURFACE_STATE_SCRIPT).catch(() => []);
|
|
362
|
+
throw notRendered(timeoutMessage(plan, states, error), problems);
|
|
363
|
+
}
|
|
364
|
+
if (plan.fullPage) await growToContent(page, plan);
|
|
365
|
+
await mkdir(dirname(plan.out), { recursive: true });
|
|
366
|
+
await page.screenshot({ path: plan.out, fullPage: plan.fullPage, animations: "disabled" });
|
|
367
|
+
return problems;
|
|
368
|
+
} finally {
|
|
369
|
+
await browser.close().catch(() => {
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
async function settled(handle) {
|
|
374
|
+
const value = handle;
|
|
375
|
+
return typeof value?.jsonValue === "function" ? value.jsonValue() : handle;
|
|
376
|
+
}
|
|
377
|
+
function timeoutMessage(plan, states, error) {
|
|
378
|
+
const seconds = plan.timeoutMs / 1e3;
|
|
379
|
+
if (states.includes("unconfirmed")) {
|
|
380
|
+
return `The surface at ${plan.target} connected but did not report its first paint within ${seconds}s. It most likely threw while rendering: see uncaughtExceptions and consoleErrors.`;
|
|
381
|
+
}
|
|
382
|
+
if (states.length > 0) {
|
|
383
|
+
return `The surface at ${plan.target} did not connect within ${seconds}s.`;
|
|
384
|
+
}
|
|
385
|
+
const reason = error instanceof Error ? error.message.split("\n")[0] : String(error);
|
|
386
|
+
return `The page at ${plan.target} did not finish loading within ${seconds}s: ${reason}`;
|
|
387
|
+
}
|
|
388
|
+
function notRendered(message, problems) {
|
|
389
|
+
return new CliError("SURFACE_NOT_RENDERED", message, {
|
|
390
|
+
hint: "Open the same path in a browser to see it, or pass --timeout for a slower surface.",
|
|
391
|
+
details: { ...problems }
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
function watch(page, problems) {
|
|
395
|
+
page.on("console", (message) => {
|
|
396
|
+
if (message.type() !== "error") return;
|
|
397
|
+
const url = message.location().url;
|
|
398
|
+
problems.consoleErrors.push({ text: message.text(), ...url ? { url } : {} });
|
|
399
|
+
});
|
|
400
|
+
page.on("pageerror", (error) => {
|
|
401
|
+
problems.uncaughtExceptions.push({
|
|
402
|
+
message: error.message,
|
|
403
|
+
...error.stack ? { stack: error.stack } : {}
|
|
404
|
+
});
|
|
405
|
+
});
|
|
406
|
+
page.on("requestfailed", (request) => {
|
|
407
|
+
problems.failedRequests.push({
|
|
408
|
+
url: request.url(),
|
|
409
|
+
method: request.method(),
|
|
410
|
+
failure: request.failure()?.errorText ?? "failed"
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
page.on("response", (response) => {
|
|
414
|
+
if (response.status() < 400) return;
|
|
415
|
+
problems.failedRequests.push({
|
|
416
|
+
url: response.url(),
|
|
417
|
+
method: response.request().method(),
|
|
418
|
+
status: response.status()
|
|
419
|
+
});
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
var OVERFLOW_SCRIPT = `(() => {
|
|
423
|
+
let overflow = Math.max(document.documentElement.scrollHeight, document.body ? document.body.scrollHeight : 0) - window.innerHeight;
|
|
424
|
+
for (const element of document.querySelectorAll('*')) {
|
|
425
|
+
const scrolls = /^(auto|scroll)$/.test(getComputedStyle(element).overflowY);
|
|
426
|
+
if (scrolls) overflow = Math.max(overflow, element.scrollHeight - element.clientHeight);
|
|
427
|
+
}
|
|
428
|
+
return overflow;
|
|
429
|
+
})()`;
|
|
430
|
+
async function growToContent(page, plan) {
|
|
431
|
+
const frame = page.mainFrame().childFrames()[0];
|
|
432
|
+
if (!frame) return;
|
|
433
|
+
const overflow = await frame.evaluate(OVERFLOW_SCRIPT).catch(() => 0);
|
|
434
|
+
if (overflow <= 0) return;
|
|
435
|
+
await page.setViewportSize({
|
|
436
|
+
width: plan.width,
|
|
437
|
+
height: Math.min(plan.height + overflow, MAX_DIMENSION)
|
|
438
|
+
});
|
|
439
|
+
await frame.evaluate(
|
|
440
|
+
"new Promise((done) => requestAnimationFrame(() => requestAnimationFrame(() => done(true))))"
|
|
441
|
+
).catch(() => {
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
function printProblems(problems) {
|
|
445
|
+
const lines = [
|
|
446
|
+
...problems.uncaughtExceptions.map((error) => ` Uncaught: ${error.message}`),
|
|
447
|
+
...problems.consoleErrors.map((error) => ` Console error: ${error.text}`),
|
|
448
|
+
...problems.failedRequests.map(
|
|
449
|
+
(request) => ` Failed request: ${request.method} ${request.url} (${request.status ?? request.failure})`
|
|
450
|
+
)
|
|
451
|
+
];
|
|
452
|
+
if (lines.length === 0) return;
|
|
453
|
+
console.log(`
|
|
454
|
+
The page reported ${lines.length} problem${lines.length === 1 ? "" : "s"}:`);
|
|
455
|
+
for (const line of lines) console.log(line);
|
|
456
|
+
}
|
|
457
|
+
export {
|
|
458
|
+
launchBrowser,
|
|
459
|
+
loadPlaywright,
|
|
460
|
+
planScreenshot,
|
|
461
|
+
readinessScript,
|
|
462
|
+
screenshotCommand
|
|
463
|
+
};
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
validateTickControllerResult
|
|
4
|
+
} from "./cli-4LKXZQ2B.js";
|
|
5
|
+
import {
|
|
6
|
+
LOGIC_NODE_BUILTIN,
|
|
7
|
+
bundleFileOf,
|
|
8
|
+
didYouMean,
|
|
9
|
+
pointerOf,
|
|
10
|
+
readLogicExports
|
|
11
|
+
} from "./cli-VQ6HVQW4.js";
|
|
12
|
+
|
|
13
|
+
// cli/validation/resource-validator.ts
|
|
14
|
+
import { existsSync } from "fs";
|
|
15
|
+
import { relative, resolve, sep } from "path";
|
|
16
|
+
function checkCapabilityReferences(label, resource, definition, keys, config) {
|
|
17
|
+
const known = (config.capabilities ?? []).map((capability) => capability.definition.identifier);
|
|
18
|
+
const declared = new Set(known);
|
|
19
|
+
const errors = [];
|
|
20
|
+
const findings = [];
|
|
21
|
+
const file = bundleFileOf(resource.type, resource.identifier);
|
|
22
|
+
for (const key of keys) {
|
|
23
|
+
(definition[key] ?? []).forEach((capability, index) => {
|
|
24
|
+
if (declared.has(capability)) return;
|
|
25
|
+
const message = `${label} "${resource.identifier}" ${key} capability "${capability}" which is not found in configuration`;
|
|
26
|
+
const hint = didYouMean(capability, known) ?? "Create it with `pnpm run sdk new capability`, or remove the entry.";
|
|
27
|
+
errors.push(message);
|
|
28
|
+
findings.push({
|
|
29
|
+
code: "REFERENCE_UNKNOWN",
|
|
30
|
+
message,
|
|
31
|
+
...file === void 0 ? {} : { file },
|
|
32
|
+
pointer: pointerOf("definition", key, index),
|
|
33
|
+
resource,
|
|
34
|
+
hint
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return { success: errors.length === 0, errors, findings };
|
|
39
|
+
}
|
|
40
|
+
function validateEngine(engine, config) {
|
|
41
|
+
return checkCapabilityReferences(
|
|
42
|
+
"Engine",
|
|
43
|
+
{ type: "engine", identifier: engine.definition.identifier },
|
|
44
|
+
engine.definition,
|
|
45
|
+
["reads", "writes"],
|
|
46
|
+
config
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
function validateUserInterface(userInterface, config) {
|
|
50
|
+
const identifier = userInterface.definition.identifier;
|
|
51
|
+
return checkCapabilityReferences(
|
|
52
|
+
"User Interface",
|
|
53
|
+
{ type: identifier, identifier },
|
|
54
|
+
userInterface.definition,
|
|
55
|
+
["reads", "writes"],
|
|
56
|
+
config
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
function validateEndpoint(endpoint, config) {
|
|
60
|
+
return checkCapabilityReferences(
|
|
61
|
+
"Endpoint",
|
|
62
|
+
{ type: "endpoint", identifier: endpoint.definition.identifier },
|
|
63
|
+
endpoint.definition,
|
|
64
|
+
["reads"],
|
|
65
|
+
config
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
function validateHook(hook, config) {
|
|
69
|
+
return checkCapabilityReferences(
|
|
70
|
+
"Hook",
|
|
71
|
+
{ type: "hook", identifier: hook.definition.identifier },
|
|
72
|
+
hook.definition,
|
|
73
|
+
["reads", "writes"],
|
|
74
|
+
config
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
function validateValidator(validator, config) {
|
|
78
|
+
return checkCapabilityReferences(
|
|
79
|
+
"Validator",
|
|
80
|
+
{ type: "validator", identifier: validator.definition.identifier },
|
|
81
|
+
validator.definition,
|
|
82
|
+
["reads"],
|
|
83
|
+
config
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
function validateTickController(tc, config) {
|
|
87
|
+
const tcId = tc.definition.identifier;
|
|
88
|
+
const references = checkCapabilityReferences(
|
|
89
|
+
"Tick Controller",
|
|
90
|
+
{ type: "tick_controller", identifier: tcId },
|
|
91
|
+
tc.definition,
|
|
92
|
+
["reads"],
|
|
93
|
+
config
|
|
94
|
+
);
|
|
95
|
+
const errors = [...references.errors];
|
|
96
|
+
const declaredInterval = staticIntervalCandidate(tc, config);
|
|
97
|
+
if (declaredInterval !== void 0) {
|
|
98
|
+
const intervalError = validateTickControllerResult({ intervalMs: declaredInterval });
|
|
99
|
+
if (intervalError) {
|
|
100
|
+
errors.push(`Tick Controller "${tcId}" has an out-of-range interval: ${intervalError}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return { success: errors.length === 0, errors, findings: references.findings };
|
|
104
|
+
}
|
|
105
|
+
function staticIntervalCandidate(tc, config) {
|
|
106
|
+
for (const identifier of tc.definition.settings ?? []) {
|
|
107
|
+
const settings = config.settings?.find((s) => s.definition.identifier === identifier);
|
|
108
|
+
const schema = settings?.definition.settingsSchema;
|
|
109
|
+
const intervalProp = schema?.properties?.intervalMs;
|
|
110
|
+
const candidate = intervalProp?.const ?? intervalProp?.default;
|
|
111
|
+
if (typeof candidate === "number") return candidate;
|
|
112
|
+
}
|
|
113
|
+
return void 0;
|
|
114
|
+
}
|
|
115
|
+
function builtinRefusal(check) {
|
|
116
|
+
return check.failure?.includes(LOGIC_NODE_BUILTIN) ? check.failure : void 0;
|
|
117
|
+
}
|
|
118
|
+
function refusedResult(message, check, resource) {
|
|
119
|
+
const located = (check.failureDiagnostics ?? []).map(
|
|
120
|
+
({ severity: _severity, ...diagnostic }) => ({ ...diagnostic, resource })
|
|
121
|
+
);
|
|
122
|
+
return {
|
|
123
|
+
success: false,
|
|
124
|
+
errors: [message],
|
|
125
|
+
findings: located.length > 0 ? located.map((finding, i) => i === 0 ? { ...finding, message } : finding) : [{ code: "LOGIC_NODE_BUILTIN", message, resource }]
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function logicFileOf(workingDir, logicFile) {
|
|
129
|
+
return relative(workingDir, logicFile).split(sep).join("/");
|
|
130
|
+
}
|
|
131
|
+
async function validateEngineFiles(engine, workingDir) {
|
|
132
|
+
const errors = [];
|
|
133
|
+
const engineDir = resolve(workingDir, engine.rootDirectory);
|
|
134
|
+
const logicDir = resolve(engineDir, engine.logic.directory);
|
|
135
|
+
const logicFile = resolve(logicDir, engine.logic.entrypoint);
|
|
136
|
+
const isAggregate = engine.definition.aggregate === true;
|
|
137
|
+
const requiredExports = isAggregate ? ["InitAggregate", "RunAggregate"] : ["Run"];
|
|
138
|
+
const expectedExports = isAggregate ? "InitAggregate and RunAggregate" : "Run";
|
|
139
|
+
const check = await readLogicExports(logicFile, requiredExports, workingDir);
|
|
140
|
+
const resource = { type: "engine", identifier: engine.definition.identifier };
|
|
141
|
+
const file = logicFileOf(workingDir, logicFile);
|
|
142
|
+
const findings = [];
|
|
143
|
+
if (!check.exists) {
|
|
144
|
+
const message = `Engine "${engine.definition.identifier}": Logic file not found: ${logicFile}. Create it with exports for ${expectedExports} functions.`;
|
|
145
|
+
errors.push(message);
|
|
146
|
+
findings.push({ code: "LOGIC_EXPORT_MISSING", message, file, resource });
|
|
147
|
+
return { success: errors.length === 0, errors, findings };
|
|
148
|
+
}
|
|
149
|
+
const refused = builtinRefusal(check);
|
|
150
|
+
if (refused) {
|
|
151
|
+
return refusedResult(
|
|
152
|
+
`Engine "${engine.definition.identifier}": ${refused}`,
|
|
153
|
+
check,
|
|
154
|
+
resource
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
const missingExports = requiredExports.filter((name) => !check.present.has(name));
|
|
158
|
+
for (const name of missingExports) {
|
|
159
|
+
const why = isAggregate ? `This engine is aggregate because its logic exports the other of "InitAggregate" / "RunAggregate". An aggregate engine runs across every team at both initialisation and tick time, so it needs both.` : "A per-team engine must export `Run`; `Init` is optional.";
|
|
160
|
+
const message = `Engine "${engine.definition.identifier}": Logic file "${logicFile}" does not export "${name}". ` + why;
|
|
161
|
+
errors.push(message);
|
|
162
|
+
findings.push({ code: "LOGIC_EXPORT_MISSING", message, file, resource });
|
|
163
|
+
}
|
|
164
|
+
return errors.length === 0 ? { success: true, errors } : { success: false, errors, findings };
|
|
165
|
+
}
|
|
166
|
+
async function validateEndpointFiles(endpoint, workingDir) {
|
|
167
|
+
const logicFile = resolve(
|
|
168
|
+
workingDir,
|
|
169
|
+
endpoint.rootDirectory,
|
|
170
|
+
endpoint.logic.directory,
|
|
171
|
+
endpoint.logic.entrypoint
|
|
172
|
+
);
|
|
173
|
+
const identifier = endpoint.definition.identifier;
|
|
174
|
+
const check = await readLogicExports(logicFile, ["Handle", "Plan"], workingDir);
|
|
175
|
+
const resource = { type: "endpoint", identifier };
|
|
176
|
+
const missing = (message) => ({
|
|
177
|
+
success: false,
|
|
178
|
+
errors: [message],
|
|
179
|
+
findings: [
|
|
180
|
+
{
|
|
181
|
+
code: "LOGIC_EXPORT_MISSING",
|
|
182
|
+
message,
|
|
183
|
+
file: logicFileOf(workingDir, logicFile),
|
|
184
|
+
resource
|
|
185
|
+
}
|
|
186
|
+
]
|
|
187
|
+
});
|
|
188
|
+
if (!check.exists) {
|
|
189
|
+
return missing(
|
|
190
|
+
`Endpoint "${identifier}": Logic file not found: ${logicFile}. Create it exporting \`Handle\`, or \`Plan\` and \`Respond\`.`
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
const refused = builtinRefusal(check);
|
|
194
|
+
if (refused) {
|
|
195
|
+
return refusedResult(`Endpoint "${identifier}": ${refused}`, check, resource);
|
|
196
|
+
}
|
|
197
|
+
if (!check.present.has("Handle") && !check.present.has("Plan")) {
|
|
198
|
+
return missing(
|
|
199
|
+
`Endpoint "${identifier}": Logic file "${logicFile}" exports neither \`Handle\` nor \`Plan\`, so there is nothing to call. Export \`Handle\` to answer with the effects, or \`Plan\` and \`Respond\` to answer after they land.`
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
return { success: true, errors: [] };
|
|
203
|
+
}
|
|
204
|
+
function validateUIFiles(ui, workingDir) {
|
|
205
|
+
const errors = [];
|
|
206
|
+
const uiSourceDir = resolve(workingDir, ui.rootDirectory);
|
|
207
|
+
const entrypoint = resolve(uiSourceDir, ui.ui.entrypoint);
|
|
208
|
+
if (!existsSync(entrypoint)) {
|
|
209
|
+
errors.push(
|
|
210
|
+
`"${ui.definition.identifier}": UI entrypoint not found: ${entrypoint}. The UI directory "${uiSourceDir}" must contain "${ui.ui.entrypoint}".`
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
return { success: errors.length === 0, errors };
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export {
|
|
217
|
+
validateEngine,
|
|
218
|
+
validateUserInterface,
|
|
219
|
+
validateEndpoint,
|
|
220
|
+
validateHook,
|
|
221
|
+
validateValidator,
|
|
222
|
+
validateTickController,
|
|
223
|
+
validateEngineFiles,
|
|
224
|
+
validateEndpointFiles,
|
|
225
|
+
validateUIFiles
|
|
226
|
+
};
|