@dreamboard-games/cli 0.1.30-alpha.0 → 0.1.30-alpha.2

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 (114) hide show
  1. package/README.md +179 -22
  2. package/dist/{chunk-TSJVWTJO.js → chunk-N7XPNNUI.js} +14 -12
  3. package/dist/chunk-N7XPNNUI.js.map +1 -0
  4. package/dist/chunk-SEGVTWSK.js +44 -0
  5. package/dist/{chunk-3XNJT3RK.js → chunk-TAQKH67O.js} +21279 -35845
  6. package/dist/chunk-TAQKH67O.js.map +1 -0
  7. package/dist/{global-config-UKSWNDTX.js → global-config-S4ZIPECE.js} +3 -3
  8. package/dist/index.js +955 -230
  9. package/dist/index.js.map +1 -1
  10. package/dist/internal.js +3 -4
  11. package/dist/{agent-verifier/keychain-backend-TNOPQV3Z.mjs → keychain-backend-HDF4TZDL.js} +2 -1
  12. package/dist/{agent-verifier/prompt-3BAINGAQ.mjs → prompt-NDV3AE5L.js} +2 -1
  13. package/package.json +6 -6
  14. package/skills/dreamboard/references/building-your-first-game.md +510 -0
  15. package/skills/dreamboard/references/cli.md +104 -0
  16. package/skills/dreamboard/references/game-interface.md +548 -0
  17. package/skills/dreamboard/references/manifest-authoring.md +597 -0
  18. package/skills/dreamboard/references/quickstart.md +66 -0
  19. package/skills/dreamboard/references/reducer.md +864 -0
  20. package/skills/dreamboard/references/rule-authoring.md +147 -0
  21. package/skills/dreamboard/references/testing.md +249 -0
  22. package/skills/dreamboard/scripts/events-extract.mjs +218 -0
  23. package/dist/agent-verifier/agent-workspace-verifier.mjs +0 -227
  24. package/dist/agent-verifier/chunk-2E5P5NWG.mjs +0 -835
  25. package/dist/agent-verifier/chunk-2GBBP27W.mjs +0 -301
  26. package/dist/agent-verifier/chunk-2NZNKIND.mjs +0 -166
  27. package/dist/agent-verifier/chunk-2QMNAVV4.mjs +0 -14522
  28. package/dist/agent-verifier/chunk-2SZHMP6F.mjs +0 -264
  29. package/dist/agent-verifier/chunk-54TAYXUD.mjs +0 -12
  30. package/dist/agent-verifier/chunk-6A5HRJMQ.mjs +0 -3174
  31. package/dist/agent-verifier/chunk-6UUJEYDV.mjs +0 -213
  32. package/dist/agent-verifier/chunk-7653FPGJ.mjs +0 -381
  33. package/dist/agent-verifier/chunk-BVVNBJM4.mjs +0 -221
  34. package/dist/agent-verifier/chunk-CEDUHGNH.mjs +0 -74
  35. package/dist/agent-verifier/chunk-CEQ2VJWN.mjs +0 -149
  36. package/dist/agent-verifier/chunk-CFU5EWIC.mjs +0 -69
  37. package/dist/agent-verifier/chunk-DTMJCPS4.mjs +0 -730
  38. package/dist/agent-verifier/chunk-EIQWDQWJ.mjs +0 -186
  39. package/dist/agent-verifier/chunk-EOQIV6PS.mjs +0 -649
  40. package/dist/agent-verifier/chunk-HBNDKQT5.mjs +0 -8381
  41. package/dist/agent-verifier/chunk-HJFQDSTU.mjs +0 -225
  42. package/dist/agent-verifier/chunk-LI3ZR3BI.mjs +0 -41
  43. package/dist/agent-verifier/chunk-LM3OZLZG.mjs +0 -48
  44. package/dist/agent-verifier/chunk-MINCYHXN.mjs +0 -106
  45. package/dist/agent-verifier/chunk-MRCUP5SW.mjs +0 -128
  46. package/dist/agent-verifier/chunk-PM3SVG6R.mjs +0 -38
  47. package/dist/agent-verifier/chunk-RBDDIIPM.mjs +0 -19
  48. package/dist/agent-verifier/chunk-RJBLBYHX.mjs +0 -1681
  49. package/dist/agent-verifier/chunk-SHUMAVAP.mjs +0 -59
  50. package/dist/agent-verifier/chunk-SYPLYRGB.mjs +0 -2812
  51. package/dist/agent-verifier/chunk-U6OJN7XS.mjs +0 -8092
  52. package/dist/agent-verifier/chunk-VYJTHSYR.mjs +0 -44
  53. package/dist/agent-verifier/chunk-XYDL7GY6.mjs +0 -10
  54. package/dist/agent-verifier/compile-WNCQQVOF.mjs +0 -313
  55. package/dist/agent-verifier/global-config-WX3ZZIVU.mjs +0 -17
  56. package/dist/agent-verifier/local-files-MTPLP62S.mjs +0 -46
  57. package/dist/agent-verifier/local-typecheck-QFYYAZOK.mjs +0 -9
  58. package/dist/agent-verifier/materialize-workspace-EWGZIVOY.mjs +0 -90
  59. package/dist/agent-verifier/project-state-7GR6BQTQ.mjs +0 -32
  60. package/dist/agent-verifier/reducer-bundle-preflight-C73LEXI2.mjs +0 -23
  61. package/dist/agent-verifier/reducer-contract-preflight-22X7DSZW.mjs +0 -10
  62. package/dist/agent-verifier/reducer-native-test-harness-GMWBUISX.mjs +0 -53
  63. package/dist/agent-verifier/static-scaffold-4YEQME5N.mjs +0 -28
  64. package/dist/agent-verifier/sync-LOQAH4RC.mjs +0 -594
  65. package/dist/agent-verifier/test-YOJERVHN.mjs +0 -356
  66. package/dist/agent-verifier/testing-5K2BJYF2.mjs +0 -674
  67. package/dist/agent-verifier/workspace-codegen-JDZJRSDV.mjs +0 -11
  68. package/dist/agent-verifier/workspace-dependencies-HZ6VVS4G.mjs +0 -14
  69. package/dist/chunk-2H7UOFLK.js +0 -11
  70. package/dist/chunk-3XNJT3RK.js.map +0 -1
  71. package/dist/chunk-7FOO4AJI.js +0 -50
  72. package/dist/chunk-7FOO4AJI.js.map +0 -1
  73. package/dist/chunk-TSJVWTJO.js.map +0 -1
  74. package/dist/internal.d.ts +0 -311
  75. package/dist/keychain-backend-JHTXAKWC.js +0 -135
  76. package/dist/prompt-GMZABCJC.js +0 -756
  77. package/dist/runtime-packages/ui-host-runtime/src/actor-principal.ts +0 -71
  78. package/dist/runtime-packages/ui-host-runtime/src/browser-interaction.ts +0 -139
  79. package/dist/runtime-packages/ui-host-runtime/src/components/host-controls.tsx +0 -374
  80. package/dist/runtime-packages/ui-host-runtime/src/components/host-feedback-toaster.tsx +0 -266
  81. package/dist/runtime-packages/ui-host-runtime/src/components/host-feedback.tsx +0 -212
  82. package/dist/runtime-packages/ui-host-runtime/src/components/host-primitives.tsx +0 -271
  83. package/dist/runtime-packages/ui-host-runtime/src/components/host-session-metadata.tsx +0 -135
  84. package/dist/runtime-packages/ui-host-runtime/src/components/index.ts +0 -5
  85. package/dist/runtime-packages/ui-host-runtime/src/components/perf-overlay.tsx +0 -194
  86. package/dist/runtime-packages/ui-host-runtime/src/gameplay-authority-transport.ts +0 -626
  87. package/dist/runtime-packages/ui-host-runtime/src/host-controls.tsx +0 -1
  88. package/dist/runtime-packages/ui-host-runtime/src/host-feedback.tsx +0 -1
  89. package/dist/runtime-packages/ui-host-runtime/src/host-session-transport.ts +0 -294
  90. package/dist/runtime-packages/ui-host-runtime/src/index.ts +0 -3
  91. package/dist/runtime-packages/ui-host-runtime/src/logger.ts +0 -11
  92. package/dist/runtime-packages/ui-host-runtime/src/perf.ts +0 -324
  93. package/dist/runtime-packages/ui-host-runtime/src/plugin-bridge.ts +0 -195
  94. package/dist/runtime-packages/ui-host-runtime/src/plugin-health-check.ts +0 -138
  95. package/dist/runtime-packages/ui-host-runtime/src/plugin-messages.ts +0 -159
  96. package/dist/runtime-packages/ui-host-runtime/src/plugin-session-gateway.ts +0 -551
  97. package/dist/runtime-packages/ui-host-runtime/src/runtime/index.ts +0 -13
  98. package/dist/runtime-packages/ui-host-runtime/src/screenshot/projection-to-snapshot.ts +0 -122
  99. package/dist/runtime-packages/ui-host-runtime/src/screenshot/static-store-api.ts +0 -26
  100. package/dist/runtime-packages/ui-host-runtime/src/session-ingress-controller.ts +0 -583
  101. package/dist/runtime-packages/ui-host-runtime/src/session-ingress.ts +0 -219
  102. package/dist/runtime-packages/ui-host-runtime/src/session-live-runtime.ts +0 -117
  103. package/dist/runtime-packages/ui-host-runtime/src/session-model.ts +0 -431
  104. package/dist/runtime-packages/ui-host-runtime/src/session-projection.ts +0 -211
  105. package/dist/runtime-packages/ui-host-runtime/src/session-recovery.ts +0 -80
  106. package/dist/runtime-packages/ui-host-runtime/src/session-state-reducer.ts +0 -1034
  107. package/dist/runtime-packages/ui-host-runtime/src/sse-manager.ts +0 -416
  108. package/dist/runtime-packages/ui-host-runtime/src/unified-session-store.ts +0 -184
  109. package/dist/testing-KLSV6CPJ.js +0 -674
  110. package/dist/testing-KLSV6CPJ.js.map +0 -1
  111. /package/dist/{chunk-2H7UOFLK.js.map → chunk-SEGVTWSK.js.map} +0 -0
  112. /package/dist/{global-config-UKSWNDTX.js.map → global-config-S4ZIPECE.js.map} +0 -0
  113. /package/dist/{keychain-backend-JHTXAKWC.js.map → keychain-backend-HDF4TZDL.js.map} +0 -0
  114. /package/dist/{prompt-GMZABCJC.js.map → prompt-NDV3AE5L.js.map} +0 -0
@@ -1,594 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- assertReducerContractPreflight
4
- } from "./chunk-VYJTHSYR.mjs";
5
- import {
6
- assertReducerBundleSmoke
7
- } from "./chunk-2SZHMP6F.mjs";
8
- import "./chunk-HBNDKQT5.mjs";
9
- import "./chunk-CEDUHGNH.mjs";
10
- import {
11
- resolveRemoteProject
12
- } from "./chunk-PM3SVG6R.mjs";
13
- import {
14
- CONFIG_FLAG_ARGS,
15
- createGameRevisionSdk,
16
- mapUpsertBlobContentsByContentHash,
17
- materializeSourceChangeOperations,
18
- parseSyncCommandArgs,
19
- uploadProjectSourceBlobsSdk
20
- } from "./chunk-EOQIV6PS.mjs";
21
- import "./chunk-BVVNBJM4.mjs";
22
- import {
23
- getProjectAuthoringState,
24
- getProjectLocalMaintainerRegistry,
25
- getProjectPendingAuthoringSync,
26
- updateProjectAuthoringState,
27
- updateProjectLocalMaintainerRegistry
28
- } from "./chunk-MRCUP5SW.mjs";
29
- import {
30
- runLocalTypecheck
31
- } from "./chunk-CEQ2VJWN.mjs";
32
- import "./chunk-LI3ZR3BI.mjs";
33
- import {
34
- assertReleaseEnvironmentPortableDependencies,
35
- consola,
36
- resolveProjectContext
37
- } from "./chunk-RJBLBYHX.mjs";
38
- import "./chunk-HJFQDSTU.mjs";
39
- import {
40
- collectLocalFiles,
41
- getLocalDiff,
42
- loadManifest,
43
- loadRule,
44
- writeSnapshot
45
- } from "./chunk-EIQWDQWJ.mjs";
46
- import {
47
- assertCliStaticScaffoldComplete,
48
- scaffoldStaticWorkspace
49
- } from "./chunk-DTMJCPS4.mjs";
50
- import "./chunk-2GBBP27W.mjs";
51
- import {
52
- BUILD_CHANNEL,
53
- IS_PUBLISHED_BUILD,
54
- updateProjectState
55
- } from "./chunk-2NZNKIND.mjs";
56
- import {
57
- computeManifestHash
58
- } from "./chunk-SYPLYRGB.mjs";
59
- import "./chunk-2QMNAVV4.mjs";
60
- import {
61
- resolveCliRepoRoot
62
- } from "./chunk-6UUJEYDV.mjs";
63
- import "./chunk-2E5P5NWG.mjs";
64
- import "./chunk-MINCYHXN.mjs";
65
- import {
66
- applyWorkspaceCodegen
67
- } from "./chunk-CFU5EWIC.mjs";
68
- import {
69
- isAllowedGamePath,
70
- isAuthoritativeGeneratedPath
71
- } from "./chunk-U6OJN7XS.mjs";
72
- import "./chunk-54TAYXUD.mjs";
73
- import "./chunk-LM3OZLZG.mjs";
74
- import {
75
- reconcileWorkspaceDependencies
76
- } from "./chunk-7653FPGJ.mjs";
77
- import "./chunk-RBDDIIPM.mjs";
78
- import {
79
- ENVIRONMENT_CONFIGS,
80
- RULE_FILE
81
- } from "./chunk-SHUMAVAP.mjs";
82
- import "./chunk-XYDL7GY6.mjs";
83
-
84
- // src/commands/sync.ts
85
- import { defineCommand } from "citty";
86
-
87
- // src/services/project/source-revision-paths.ts
88
- function isSourceRevisionPath(filePath) {
89
- return filePath !== RULE_FILE && isAllowedGamePath(filePath);
90
- }
91
- function shouldAlwaysUpsertSourcePath(filePath) {
92
- return filePath === ".npmrc" || isAuthoritativeGeneratedPath(filePath);
93
- }
94
-
95
- // src/services/project/local-maintainer-registry.ts
96
- import { spawn } from "child_process";
97
- import { existsSync, readFileSync } from "fs";
98
- import path2 from "path";
99
- import { fileURLToPath } from "url";
100
-
101
- // src/services/project/local-maintainer-registry-shared.ts
102
- import crypto from "crypto";
103
- import path from "path";
104
- var localRegistryAddress = readLocalRegistryAddress();
105
- var LOCAL_REGISTRY_HOST = localRegistryAddress.host;
106
- var LOCAL_REGISTRY_PORT = localRegistryAddress.port;
107
- var LOCAL_REGISTRY_URL = `http://${LOCAL_REGISTRY_HOST}:${LOCAL_REGISTRY_PORT}`;
108
- var LOCAL_SCOPE_NPMRC_CONTENT = `@dreamboard-games:registry=${LOCAL_REGISTRY_URL}
109
- `;
110
- function readLocalRegistryAddress() {
111
- const urlOverride = process.env.DREAMBOARD_LOCAL_REGISTRY_URL?.trim();
112
- const hostOverride = process.env.DREAMBOARD_LOCAL_REGISTRY_HOST?.trim();
113
- const portOverride = process.env.DREAMBOARD_LOCAL_REGISTRY_PORT?.trim();
114
- if (urlOverride) {
115
- let parsed;
116
- try {
117
- parsed = new URL(urlOverride);
118
- } catch {
119
- throw new Error(
120
- `Invalid DREAMBOARD_LOCAL_REGISTRY_URL '${urlOverride}'. Expected an http://host:port URL.`
121
- );
122
- }
123
- if (parsed.protocol !== "http:" || !parsed.hostname || !parsed.port) {
124
- throw new Error(
125
- `Invalid DREAMBOARD_LOCAL_REGISTRY_URL '${urlOverride}'. Expected an http://host:port URL.`
126
- );
127
- }
128
- return {
129
- host: hostOverride || parsed.hostname,
130
- port: parseLocalRegistryPort(portOverride || parsed.port)
131
- };
132
- }
133
- return {
134
- host: hostOverride || "127.0.0.1",
135
- port: portOverride ? parseLocalRegistryPort(portOverride) : 4873
136
- };
137
- }
138
- function parseLocalRegistryPort(raw) {
139
- const port = Number.parseInt(raw, 10);
140
- if (!Number.isInteger(port) || port < 1 || port > 65535) {
141
- throw new Error(
142
- `Invalid DREAMBOARD_LOCAL_REGISTRY_PORT '${raw}'. Expected a TCP port from 1 to 65535.`
143
- );
144
- }
145
- return port;
146
- }
147
- function shortHash(value) {
148
- return crypto.createHash("sha256").update(value).digest("hex").slice(0, 12);
149
- }
150
- function isLocalMaintainerRegistryEnabled(apiBaseUrl) {
151
- let isLocalLoopbackUrl = false;
152
- try {
153
- const parsed = new URL(apiBaseUrl);
154
- isLocalLoopbackUrl = parsed.protocol === "http:" && (parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1");
155
- } catch {
156
- isLocalLoopbackUrl = false;
157
- }
158
- return !IS_PUBLISHED_BUILD && (apiBaseUrl === ENVIRONMENT_CONFIGS.local?.apiBaseUrl || isLocalLoopbackUrl) && BUILD_CHANNEL === "development";
159
- }
160
- function didLocalMaintainerSnapshotChange(previous, next) {
161
- if (!next) {
162
- return false;
163
- }
164
- return previous?.snapshotId !== next.snapshotId;
165
- }
166
-
167
- // src/services/project/local-maintainer-registry.ts
168
- var MODULE_DIR = path2.dirname(fileURLToPath(import.meta.url));
169
- function getCliPackageRoot() {
170
- try {
171
- return path2.join(
172
- resolveCliRepoRoot(import.meta.url),
173
- "apps",
174
- "dreamboard-cli"
175
- );
176
- } catch {
177
- return resolveInstalledCliPackageRoot(MODULE_DIR);
178
- }
179
- }
180
- function resolveInstalledCliPackageRoot(moduleDir) {
181
- let current = moduleDir;
182
- while (true) {
183
- const packageJsonPath = path2.join(current, "package.json");
184
- if (existsSync(packageJsonPath)) {
185
- try {
186
- const packageJson = JSON.parse(
187
- readFileSync(packageJsonPath, "utf8")
188
- );
189
- if (packageJson.name === "@dreamboard-games/cli" || packageJson.name === "dreamboard" || packageJson.name === "dreamboard-cli") {
190
- return current;
191
- }
192
- } catch {
193
- }
194
- }
195
- const parent = path2.dirname(current);
196
- if (parent === current) {
197
- return moduleDir;
198
- }
199
- current = parent;
200
- }
201
- }
202
- function getScriptInvocation() {
203
- const cliPackageRoot = getCliPackageRoot();
204
- const scriptPath = getLocalMaintainerScriptPath(cliPackageRoot);
205
- if (!existsSync(scriptPath)) {
206
- throw new Error(
207
- [
208
- "Dreamboard local maintainer registry support is only available from a source checkout.",
209
- `Expected helper script at ${scriptPath}.`
210
- ].join(" ")
211
- );
212
- }
213
- const command = process.platform === "win32" ? "pnpm.cmd" : "pnpm";
214
- const args = ["exec", "tsx", scriptPath];
215
- return {
216
- command,
217
- args,
218
- attemptedCommand: `${command} ${args.join(" ")}`,
219
- cwd: cliPackageRoot
220
- };
221
- }
222
- function getLocalMaintainerScriptPath(cliPackageRoot) {
223
- return path2.join(cliPackageRoot, "scripts", "local-maintainer-registry.ts");
224
- }
225
- function isInstalledCliPackageRoot(cliPackageRoot) {
226
- return cliPackageRoot.split(path2.sep).includes("node_modules");
227
- }
228
- function shouldSkipLocalMaintainerHelper() {
229
- const cliPackageRoot = getCliPackageRoot();
230
- const scriptPath = getLocalMaintainerScriptPath(cliPackageRoot);
231
- return !existsSync(scriptPath) && isInstalledCliPackageRoot(cliPackageRoot);
232
- }
233
- function buildInstalledCliLocalMaintainerSnapshot(packageJson, registryUrl = LOCAL_REGISTRY_URL) {
234
- const sdkVersion = packageJson.dependencies?.["@dreamboard-games/sdk"];
235
- if (typeof sdkVersion !== "string" || !sdkVersion.includes("-local.")) {
236
- return null;
237
- }
238
- return {
239
- registryUrl,
240
- snapshotId: shortHash(sdkVersion),
241
- fingerprint: shortHash(sdkVersion),
242
- publishedAt: "",
243
- packages: {
244
- "@dreamboard-games/sdk": sdkVersion
245
- }
246
- };
247
- }
248
- function readInstalledCliLocalMaintainerSnapshot() {
249
- const cliPackageRoot = getCliPackageRoot();
250
- if (!isInstalledCliPackageRoot(cliPackageRoot)) {
251
- return null;
252
- }
253
- const packageJsonPath = path2.join(cliPackageRoot, "package.json");
254
- if (!existsSync(packageJsonPath)) {
255
- return null;
256
- }
257
- const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
258
- return buildInstalledCliLocalMaintainerSnapshot(packageJson);
259
- }
260
- function buildScriptSetupError(options) {
261
- return new Error(
262
- [
263
- "Dreamboard local maintainer registry support requires the source-checkout CLI tooling.",
264
- options.message,
265
- `Attempted command: ${options.attemptedCommand}`,
266
- options.stderr?.trim() ? `stderr:
267
- ${options.stderr.trim()}` : null
268
- ].filter(Boolean).join("\n")
269
- );
270
- }
271
- function parseJsonPayload(output) {
272
- const payload = output.trim().split(/\r?\n/).map((line) => line.trim()).reverse().find(
273
- (line) => line === "null" || line.startsWith("{") || line.startsWith("[")
274
- );
275
- if (!payload) {
276
- throw new Error("completed without returning a JSON payload");
277
- }
278
- return JSON.parse(payload);
279
- }
280
- async function runLocalMaintainerScript(args) {
281
- const invocation = getScriptInvocation();
282
- return new Promise((resolve, reject) => {
283
- const child = spawn(invocation.command, [...invocation.args, ...args], {
284
- cwd: invocation.cwd,
285
- stdio: ["ignore", "pipe", "pipe"],
286
- env: process.env
287
- });
288
- let stdout = "";
289
- let stderr = "";
290
- child.stdout.on("data", (chunk) => {
291
- stdout += chunk.toString();
292
- });
293
- child.stderr.on("data", (chunk) => {
294
- stderr += chunk.toString();
295
- });
296
- child.on("error", (error) => {
297
- const errnoError = error;
298
- if (errnoError.code === "ENOENT") {
299
- reject(
300
- buildScriptSetupError({
301
- attemptedCommand: invocation.attemptedCommand,
302
- message: "`pnpm` was not found on PATH, so the source-checkout local maintainer helper could not run."
303
- })
304
- );
305
- return;
306
- }
307
- reject(error);
308
- });
309
- child.on("close", (code) => {
310
- if (code !== 0) {
311
- const missingTsx = stderr.includes('Command "tsx" not found') || stderr.includes("tsx: command not found") || stderr.includes("tsx: not found");
312
- reject(
313
- buildScriptSetupError({
314
- attemptedCommand: invocation.attemptedCommand,
315
- message: missingTsx ? "`tsx` is not available for the source-checkout CLI package." : "The source-checkout local maintainer helper failed.",
316
- stderr
317
- })
318
- );
319
- return;
320
- }
321
- const trimmedStdout = stdout.trim();
322
- if (!trimmedStdout) {
323
- reject(
324
- buildScriptSetupError({
325
- attemptedCommand: invocation.attemptedCommand,
326
- message: "The source-checkout local maintainer helper completed without returning JSON.",
327
- stderr
328
- })
329
- );
330
- return;
331
- }
332
- try {
333
- resolve(parseJsonPayload(trimmedStdout));
334
- } catch (error) {
335
- reject(
336
- buildScriptSetupError({
337
- attemptedCommand: invocation.attemptedCommand,
338
- message: `Failed to parse JSON from the source-checkout local maintainer helper: ${error instanceof Error ? error.message : String(error)}`,
339
- stderr: [stderr.trim(), trimmedStdout].filter(Boolean).join("\n")
340
- })
341
- );
342
- }
343
- });
344
- });
345
- }
346
- async function ensureLocalMaintainerSnapshot(apiBaseUrl) {
347
- if (!isLocalMaintainerRegistryEnabled(apiBaseUrl)) {
348
- return null;
349
- }
350
- if (shouldSkipLocalMaintainerHelper()) {
351
- return readInstalledCliLocalMaintainerSnapshot();
352
- }
353
- return runLocalMaintainerScript([
354
- "ensure-snapshot",
355
- "--api-base-url",
356
- apiBaseUrl
357
- ]);
358
- }
359
-
360
- // src/commands/sync.ts
361
- async function runLoggedStep(message, task) {
362
- consola.start(message);
363
- return task();
364
- }
365
- async function persistProjectConfig(options) {
366
- await updateProjectState(options.projectRoot, options.projectConfig);
367
- return options.projectConfig;
368
- }
369
- async function finalizeLocalSync(options) {
370
- const { projectRoot, projectConfig } = options;
371
- await scaffoldStaticWorkspace(projectRoot, "update", {
372
- localMaintainerRegistry: getProjectLocalMaintainerRegistry(projectConfig)
373
- });
374
- await applyWorkspaceCodegen({
375
- projectRoot,
376
- manifest: await loadManifest(projectRoot)
377
- });
378
- const finalizedProjectConfig = await persistProjectConfig({
379
- projectRoot,
380
- projectConfig
381
- });
382
- await writeSnapshot(projectRoot);
383
- return finalizedProjectConfig;
384
- }
385
- function buildSourceSnapshotChanges(localFiles) {
386
- return Object.entries(localFiles).filter(
387
- ([filePath]) => isSourceRevisionPath(filePath) || shouldAlwaysUpsertSourcePath(filePath)
388
- ).sort(([left], [right]) => left.localeCompare(right)).map(([path3, content]) => ({
389
- kind: "upsert",
390
- path: path3,
391
- content
392
- }));
393
- }
394
- var sync_default = defineCommand({
395
- meta: {
396
- name: "sync",
397
- description: "Upload authored changes and advance the remote authoring head"
398
- },
399
- args: {
400
- force: {
401
- type: "boolean",
402
- description: "Replace the full authored source tree, manifest, and rules, overwriting the remote head with the local copy even when the remote has moved",
403
- default: false
404
- },
405
- yes: {
406
- type: "boolean",
407
- alias: "y",
408
- description: "Reserved for non-interactive scaffold flows",
409
- default: false
410
- },
411
- ...CONFIG_FLAG_ARGS
412
- },
413
- async run({ args }) {
414
- const parsedArgs = parseSyncCommandArgs(args);
415
- const { projectRoot, projectConfig, config } = await resolveProjectContext(parsedArgs);
416
- let nextProjectConfig = projectConfig;
417
- await assertReleaseEnvironmentPortableDependencies({
418
- projectRoot,
419
- projectConfig: nextProjectConfig,
420
- environment: config.environment
421
- });
422
- const localMaintainerEnabled = isLocalMaintainerRegistryEnabled(
423
- config.apiBaseUrl
424
- );
425
- const existingLocalMaintainerRegistry = getProjectLocalMaintainerRegistry(projectConfig);
426
- const refreshedLocalMaintainerRegistry = localMaintainerEnabled ? await runLoggedStep(
427
- "Checking local SDK snapshot...",
428
- () => ensureLocalMaintainerSnapshot(config.apiBaseUrl)
429
- ) : await ensureLocalMaintainerSnapshot(config.apiBaseUrl);
430
- const localMaintainerRegistry = refreshedLocalMaintainerRegistry ?? (localMaintainerEnabled ? existingLocalMaintainerRegistry ?? null : null);
431
- const localMaintainerSnapshotChanged = didLocalMaintainerSnapshotChange(
432
- existingLocalMaintainerRegistry,
433
- refreshedLocalMaintainerRegistry
434
- );
435
- if (refreshedLocalMaintainerRegistry) {
436
- nextProjectConfig = updateProjectLocalMaintainerRegistry(
437
- nextProjectConfig,
438
- refreshedLocalMaintainerRegistry
439
- );
440
- consola.info(
441
- localMaintainerSnapshotChanged ? "Local SDK snapshot refreshed." : "Using existing local SDK snapshot."
442
- );
443
- } else if (localMaintainerRegistry) {
444
- consola.info("Using workspace-pinned local SDK snapshot.");
445
- }
446
- await runLoggedStep(
447
- "Refreshing static scaffold...",
448
- () => scaffoldStaticWorkspace(projectRoot, "update", {
449
- localMaintainerRegistry
450
- })
451
- );
452
- const localManifest = await loadManifest(projectRoot);
453
- await runLoggedStep(
454
- "Applying workspace codegen...",
455
- async () => applyWorkspaceCodegen({
456
- projectRoot,
457
- manifest: localManifest
458
- })
459
- );
460
- const dependencyState = await runLoggedStep(
461
- "Reconciling workspace dependencies...",
462
- () => reconcileWorkspaceDependencies(projectRoot)
463
- );
464
- if (dependencyState.packageManagerNormalized || dependencyState.lockfileGenerated || dependencyState.installed || localMaintainerSnapshotChanged) {
465
- consola.info("Workspace dependencies reconciled.");
466
- } else {
467
- consola.info("Workspace dependencies already up to date.");
468
- }
469
- await runLoggedStep(
470
- "Validating reducer contract...",
471
- () => assertReducerContractPreflight(projectRoot)
472
- );
473
- const typecheckResult = await runLoggedStep(
474
- "Running local typecheck...",
475
- () => runLocalTypecheck(projectRoot)
476
- );
477
- if (typecheckResult.skipped) {
478
- if (typecheckResult.output) {
479
- consola.warn(typecheckResult.output);
480
- }
481
- } else if (!typecheckResult.success) {
482
- if (typecheckResult.output) {
483
- consola.error(typecheckResult.output);
484
- }
485
- throw new Error(
486
- "Local typecheck failed. Fix the diagnostics before syncing."
487
- );
488
- }
489
- await runLoggedStep(
490
- "Smoke-testing reducer bundle...",
491
- async () => assertReducerBundleSmoke({
492
- projectRoot,
493
- manifest: localManifest
494
- })
495
- );
496
- consola.success("Reducer bundle smoke test passed.");
497
- const remoteProject = await runLoggedStep(
498
- "Ensuring remote project...",
499
- () => resolveRemoteProject({
500
- projectRoot,
501
- projectConfig: nextProjectConfig,
502
- config
503
- })
504
- );
505
- nextProjectConfig = remoteProject.projectConfig;
506
- const localDiff = await getLocalDiff(projectRoot);
507
- await assertCliStaticScaffoldComplete(projectRoot, localDiff.deleted);
508
- const localAuthoring = getProjectAuthoringState(nextProjectConfig);
509
- const pendingSync = getProjectPendingAuthoringSync(nextProjectConfig);
510
- const remoteHeadDigest = remoteProject.project.head?.revisionDigest;
511
- const localHeadDigest = localAuthoring.revisionDigest ?? nextProjectConfig.remoteHeadDigest;
512
- if (pendingSync && !parsedArgs.force) {
513
- throw new Error(
514
- "This workspace has an unfinished legacy sync checkpoint. Run 'dreamboard sync --force' to replace it with an atomic project revision."
515
- );
516
- }
517
- if (remoteHeadDigest && localHeadDigest && remoteHeadDigest !== localHeadDigest) {
518
- if (parsedArgs.force) {
519
- consola.warn(
520
- `Remote project head has moved to ${remoteHeadDigest}. --force will overwrite it with this workspace's local copy.`
521
- );
522
- } else {
523
- throw new Error(
524
- `Remote project head has moved to ${remoteHeadDigest}. Run 'dreamboard pull' before syncing local changes, or pass --force to overwrite the remote with the local copy.`
525
- );
526
- }
527
- }
528
- if (remoteHeadDigest && !localHeadDigest) {
529
- if (parsedArgs.force) {
530
- consola.warn(
531
- `This workspace has no authored base but the remote project head is ${remoteHeadDigest}. --force will overwrite it with this workspace's local copy.`
532
- );
533
- } else {
534
- throw new Error(
535
- `This workspace has no authored base but the remote project head is ${remoteHeadDigest}. Re-clone, run 'dreamboard pull --force' into a clean workspace, or pass --force to overwrite the remote with the local copy.`
536
- );
537
- }
538
- }
539
- const hasChanges = localDiff.modified.length > 0 || localDiff.added.length > 0 || localDiff.deleted.length > 0;
540
- const localManifestContentHash = computeManifestHash(localManifest);
541
- const manifestOutOfSync = localAuthoring.localManifestContentHash !== localManifestContentHash;
542
- if (!hasChanges && !parsedArgs.force && localHeadDigest != null && remoteHeadDigest === localHeadDigest && !pendingSync && !manifestOutOfSync) {
543
- consola.info("No local authored changes to sync.");
544
- return;
545
- }
546
- const localFiles = await collectLocalFiles(projectRoot);
547
- const sourceChanges = buildSourceSnapshotChanges(localFiles);
548
- const { changes } = await materializeSourceChangeOperations(sourceChanges);
549
- const uploadBlobs = mapUpsertBlobContentsByContentHash(
550
- sourceChanges,
551
- changes
552
- );
553
- await uploadProjectSourceBlobsSdk(
554
- nextProjectConfig.projectId,
555
- Array.from(uploadBlobs.values())
556
- );
557
- const sourceFiles = changes.filter((change) => change.kind === "upsert").map(({ path: path3, contentHash, byteSize }) => ({
558
- path: path3,
559
- contentHash,
560
- byteSize
561
- }));
562
- const revision = await createGameRevisionSdk({
563
- projectId: nextProjectConfig.projectId,
564
- request: {
565
- ...remoteHeadDigest ? { baseRevisionDigest: remoteHeadDigest } : {},
566
- source: { files: sourceFiles },
567
- ruleText: await loadRule(projectRoot),
568
- manifest: localManifest
569
- }
570
- });
571
- nextProjectConfig = await persistProjectConfig({
572
- projectRoot,
573
- projectConfig: {
574
- ...updateProjectAuthoringState(nextProjectConfig, {
575
- revisionDigest: revision.revisionDigest,
576
- sourceTreeHash: revision.sourceTreeHash,
577
- manifestContentHash: revision.manifestContentHash,
578
- localManifestContentHash
579
- }),
580
- remoteHeadDigest: revision.revisionDigest
581
- }
582
- });
583
- nextProjectConfig = await finalizeLocalSync({
584
- projectRoot,
585
- projectConfig: nextProjectConfig
586
- });
587
- consola.success(
588
- `Synced revision ${revision.revisionDigest}. Run 'dreamboard compile' when you're ready.`
589
- );
590
- }
591
- });
592
- export {
593
- sync_default as default
594
- };