@playcraft/cli 0.1.66 → 0.1.68

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 (113) hide show
  1. package/dist/assets/client.js +4 -2
  2. package/dist/assets/messages.js +2 -0
  3. package/dist/audio-source/messages.js +35 -0
  4. package/dist/commands/assets.js +1 -1
  5. package/dist/commands/audio-program.js +82 -0
  6. package/dist/commands/audio-source.js +109 -0
  7. package/dist/commands/audio.js +13 -4
  8. package/dist/commands/build.js +4 -2
  9. package/dist/commands/tools-context.js +46 -0
  10. package/dist/commands/tools.js +2 -0
  11. package/dist/project-skills/builtin-import.js +69 -22
  12. package/dist/project-skills/commands.js +11 -2
  13. package/dist/project-skills/lifecycle.js +1 -1
  14. package/dist/project-skills/local-store.js +90 -31
  15. package/dist/project-skills/messages.js +16 -0
  16. package/dist/project-skills/migrate-lock.js +166 -0
  17. package/dist/project-skills/remote-cache.js +36 -5
  18. package/dist/utils/agent-api-client.js +18 -1
  19. package/dist/utils/agent-generation-provenance.js +8 -2
  20. package/dist/utils/audio-export.js +249 -0
  21. package/dist/utils/audio-processor.js +22 -99
  22. package/dist/utils/execution-context-bridge.js +28 -0
  23. package/dist/workspace-runtime/batch/control.js +13 -2
  24. package/dist/workspace-runtime/batch/generate.js +43 -2
  25. package/dist/workspace-runtime/batch/prepare.js +4 -0
  26. package/dist/workspace-runtime/batch/skill-artifacts.js +103 -0
  27. package/dist/workspace-runtime/batch/source-capture.js +6 -8
  28. package/dist/workspace-runtime/codex/app-server.js +26 -2
  29. package/dist/workspace-runtime/codex/execution-context-broker.js +61 -0
  30. package/dist/workspace-runtime/codex/execution-context-tools.js +37 -0
  31. package/dist/workspace-runtime/codex/generation-provenance-broker.js +9 -6
  32. package/dist/workspace-runtime/codex/level-editor-tools.js +18 -0
  33. package/dist/workspace-runtime/codex/model-broker.js +15 -2
  34. package/dist/workspace-runtime/codex/scheduled-task-tools.js +1 -1
  35. package/dist/workspace-runtime/previews/finalize.js +1 -1
  36. package/dist/workspace-runtime/previews/output.js +4 -1
  37. package/dist/workspace-runtime/previews/publish.js +5 -2
  38. package/dist/workspace-runtime/previews/runtime-preview.js +38 -3
  39. package/dist/workspace-runtime/serve.js +6 -0
  40. package/dist/workspace-runtime/server/accept-operation.js +85 -13
  41. package/dist/workspace-runtime/server/audio-assets.js +257 -0
  42. package/dist/workspace-runtime/server/audio-export.js +136 -0
  43. package/dist/workspace-runtime/server/directory-access.js +222 -67
  44. package/dist/workspace-runtime/server/dispatch.js +252 -29
  45. package/dist/workspace-runtime/server/http.js +97 -3
  46. package/dist/workspace-runtime/server/operation-record.js +1 -1
  47. package/dist/workspace-runtime/workspaces/artifact-files.js +10 -3
  48. package/dist/workspace-runtime/workspaces/artifacts.js +47 -6
  49. package/dist/workspace-runtime/workspaces/asset-library-import.js +27 -7
  50. package/dist/workspace-runtime/workspaces/audio-assets/artifact-package.js +104 -0
  51. package/dist/workspace-runtime/workspaces/audio-assets/binding-usage.js +71 -0
  52. package/dist/workspace-runtime/workspaces/audio-assets/build-inputs.js +80 -0
  53. package/dist/workspace-runtime/workspaces/audio-assets/library-import.js +149 -0
  54. package/dist/workspace-runtime/workspaces/audio-assets/library-package.js +26 -0
  55. package/dist/workspace-runtime/workspaces/audio-assets/program-artifact-audit.js +90 -0
  56. package/dist/workspace-runtime/workspaces/audio-assets/program-browser.js +194 -0
  57. package/dist/workspace-runtime/workspaces/audio-assets/program-build-inputs.js +122 -0
  58. package/dist/workspace-runtime/workspaces/audio-assets/program-engine.js +39 -0
  59. package/dist/workspace-runtime/workspaces/audio-assets/program-package.js +289 -0
  60. package/dist/workspace-runtime/workspaces/audio-assets/program-variant-build.js +217 -0
  61. package/dist/workspace-runtime/workspaces/audio-assets/references.js +107 -0
  62. package/dist/workspace-runtime/workspaces/audio-assets/render-worker.js +117 -0
  63. package/dist/workspace-runtime/workspaces/audio-assets/renderer.js +128 -0
  64. package/dist/workspace-runtime/workspaces/audio-assets/representations.js +73 -0
  65. package/dist/workspace-runtime/workspaces/audio-assets/service.js +459 -0
  66. package/dist/workspace-runtime/workspaces/audio-assets/storage.js +125 -0
  67. package/dist/workspace-runtime/workspaces/build-isolation.js +2 -0
  68. package/dist/workspace-runtime/workspaces/composer-context.js +40 -1
  69. package/dist/workspace-runtime/workspaces/empty-template.js +1 -1
  70. package/dist/workspace-runtime/workspaces/execution-context.js +24 -0
  71. package/dist/workspace-runtime/workspaces/files.js +3 -5
  72. package/dist/workspace-runtime/workspaces/git.js +7 -0
  73. package/dist/workspace-runtime/workspaces/level-editor-agent-store.js +143 -0
  74. package/dist/workspace-runtime/workspaces/level-editor-agent.js +410 -0
  75. package/dist/workspace-runtime/workspaces/level-editor-atomic.js +424 -0
  76. package/dist/workspace-runtime/workspaces/level-editor-extensions.js +140 -0
  77. package/dist/workspace-runtime/workspaces/level-editor-format.js +75 -0
  78. package/dist/workspace-runtime/workspaces/level-editor-history-store.js +250 -0
  79. package/dist/workspace-runtime/workspaces/level-editor-json5.js +132 -0
  80. package/dist/workspace-runtime/workspaces/level-editor-requests.js +724 -0
  81. package/dist/workspace-runtime/workspaces/level-editor.js +454 -0
  82. package/dist/workspace-runtime/workspaces/parameter-initialization-skill.js +62 -22
  83. package/dist/workspace-runtime/workspaces/parameter-production.js +1 -1
  84. package/dist/workspace-runtime/workspaces/remix-reference-skill.js +4 -3
  85. package/dist/workspace-runtime/workspaces/skill-artifact-loader.js +19 -5
  86. package/dist/workspace-runtime/workspaces/skills.js +48 -13
  87. package/package.json +9 -4
  88. package/project-template/.claude/skills/playcraft-audio-generation/SKILL.md +92 -4
  89. package/project-template/.claude/skills/playcraft-level-editor/SKILL.md +34 -0
  90. package/project-template/.claude/skills/playcraft-level-editor/references/authoring-contract.json +3475 -0
  91. package/project-template/.claude/skills/playcraft-level-editor/references/extensions.md +37 -0
  92. package/project-template/.claude/skills/playcraft-level-editor/references/preview.md +15 -0
  93. package/project-template/.claude/skills/playcraft-level-editor/references/protocol-v1.md +35 -0
  94. package/project-template/vite.config.ts +1 -1
  95. package/project-template-v2/.claude/skills/playcraft-audio-generation/SKILL.md +92 -4
  96. package/project-template-v2/.playcraft/skills.lock.json +9 -2
  97. package/project-template-v2/vite.config.ts +1 -1
  98. package/project-templates/empty/AGENTS.md +2 -0
  99. package/project-templates/phaser/.claude/skills/playcraft-audio-generation/SKILL.md +92 -4
  100. package/project-templates/phaser/vite.config.ts +1 -1
  101. package/project-templates/playable-template-phaser/vite.config.ts +1 -1
  102. package/project-templates/threejs/.claude/skills/playcraft-audio-generation/SKILL.md +92 -4
  103. package/project-templates/threejs/vite.config.ts +1 -1
  104. package/templates/preview-runtime/v1/README.md +12 -0
  105. package/templates/preview-runtime/v1/build-preview.mjs +17 -8
  106. package/templates/preview-runtime/v1/manifest.json +9 -6
  107. package/templates/preview-runtime/v1/release-guard.mjs +1 -1
  108. package/templates/preview-runtime/v1/runtime.d.mts +1 -3
  109. package/templates/preview-runtime/v1/runtime.d.ts +1 -3
  110. package/templates/preview-runtime/v1/runtime.mjs +1142 -257
  111. package/templates/preview-runtime/v1/types/host.d.ts +29 -0
  112. package/templates/preview-runtime/v1/types/index.d.ts +6 -0
  113. package/templates/preview-runtime/v1/types/level-editor.d.ts +123 -0
@@ -96,6 +96,18 @@ The report also records raw hashes of actual workspace module inputs and known c
96
96
 
97
97
  The platform embeds its immutable build profile after checking the report. The runtime reads the exact host origin and binding from platform context, validates the build profile, and then completes a real versioned handshake. A build report never declares live capability.
98
98
 
99
+ ## Declarative level editor
100
+
101
+ `runtime.mjs` also exports `connectLevelEditorRuntime` and `readLevelEditorPreviewContext`. The level-editor protocol has its own message namespace and does not require registering level arrays as primitive parameter fields. A project can support parameters, level editing, or both.
102
+
103
+ Declare `levelEditor: {version: 1, definition: '<actual-definition-path>'}` beside `previewRuntime`. The definition's `preview.entry` and `preview.adapter` name real development files. A level-only project can omit `parameters`; retain the actual `previewRuntime` entry and build settings. Invoke the build through the platform so its context comes from current source files, rather than constructing a profile manually.
104
+
105
+ `readLevelEditorPreviewContext()` returns `{binding, parentOrigin}` from the immutable build stamp and authorized host context. Pass those to `connectLevelEditorRuntime({...context, commands: [<actual-command-identifiers>], adapter})`. The adapter implements `enterEdit(context)`, `loadLevel(context)`, `afterRender(context)` and `dispose()`. Each load context contains the author `documents`, stable `selection`, `draftRevision`, `mode` and abort `signal`.
106
+
107
+ Use the production game's real resolver and level loading in those callbacks. Keep authored initial data separate from playtest state; stop obsolete instances and wait for a real frame before acknowledging application. Declaring a command or returning from an empty callback does not establish that the game consumed the data. The platform separately records saved data, successful build, capability handshake and applied snapshots.
108
+
109
+ The checked development build receives `script#playcraft-level-editor-profile` containing the actual editor identity and execution contract. A historical build retains its own contract and cannot receive edits for changed game code. Ordinary data edits can reuse a compatible build; changes to code or integration need a new development build. Keep the development entry, runtime and profile outside production output using the guard below.
110
+
99
111
  ## Independent production build
100
112
 
101
113
  Keep the original production entry and output under `dist/`. Never import the preview entry or runtime from production.
@@ -1182,11 +1182,19 @@ async function buildWorkspacePreview({ entry, config, mountId = "game", root = p
1182
1182
  const entryPath = await inside(root, entry);
1183
1183
  const configPath = config ? await inside(root, config) : false;
1184
1184
  if (!/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(mountId)) throw new Error("preview_runtime_mount_invalid");
1185
- const schemaPath = await inside(root, manifest.parameters?.schemaPath);
1186
- const dataPath = await inside(root, manifest.parameters?.dataPath);
1187
- const schema = await readFile(schemaPath);
1188
- const data = await readFile(dataPath);
1189
- if (hash(schema) !== context.binding.schemaVersion || hash(data) !== context.baseline.dataHash)
1185
+ const parameterFiles = manifest.parameters?.schemaPath && manifest.parameters?.dataPath;
1186
+ if (!parameterFiles && !context.levelEditor) throw new Error("preview_runtime_source_missing");
1187
+ const schemaPath = parameterFiles ? await inside(root, manifest.parameters.schemaPath) : void 0;
1188
+ const dataPath = parameterFiles ? await inside(root, manifest.parameters.dataPath) : void 0;
1189
+ const schema = schemaPath ? await readFile(schemaPath) : void 0;
1190
+ const data = dataPath ? await readFile(dataPath) : void 0;
1191
+ const schemaHash = schema ? hash(schema) : context.levelEditor.schemaHash;
1192
+ const dataHash = data ? hash(data) : context.levelEditor.dataHash;
1193
+ if (schemaHash !== context.binding.schemaVersion || dataHash !== context.baseline.dataHash)
1194
+ throw new Error("preview_runtime_source_changed");
1195
+ const levelInputs = context.levelEditor?.inputs ?? [];
1196
+ if (context.levelEditor && (!Array.isArray(levelInputs) || !levelInputs.length)) throw new Error("preview_runtime_level_inputs_missing");
1197
+ for (const input of levelInputs) if (hash(await readFile(await inside(root, input.path))) !== input.sha256)
1190
1198
  throw new Error("preview_runtime_source_changed");
1191
1199
  const sdkPath = await realpath(path.join(sdkDirectory, "runtime.mjs"));
1192
1200
  const sdkRelativePath = slash(path.relative(root, sdkPath));
@@ -1239,6 +1247,7 @@ async function buildWorkspacePreview({ entry, config, mountId = "game", root = p
1239
1247
  path.join(root, "package.json"),
1240
1248
  schemaPath,
1241
1249
  dataPath,
1250
+ ...levelInputs.map((input2) => path.join(root, input2.path)),
1242
1251
  path.join(root, ".playcraft/workspace.json"),
1243
1252
  ...["pnpm-lock.yaml", "package-lock.json", "yarn.lock"].map((name) => path.join(root, name))
1244
1253
  ])
@@ -1290,14 +1299,14 @@ async function buildWorkspacePreview({ entry, config, mountId = "game", root = p
1290
1299
  throw new Error("preview_runtime_external_resource");
1291
1300
  const css = outputs.filter((output) => output.type === "asset").map((output) => typeof output.source === "string" ? output.source : Buffer.from(output.source).toString()).join("\n");
1292
1301
  const html = '<!doctype html><html><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>PlayCraft preview</title><style>' + css.replace(/<\/style/gi, "<\\/style") + '</style></head><body><div id="' + mountId + '"></div><script type="module">' + chunks[0].code.replace(/<\/script/gi, "<\\/script") + "</script></body></html>";
1293
- if (hash(await readFile(schemaPath)) !== hash(schema) || hash(await readFile(dataPath)) !== hash(data) || hash(await readFile(await inside(root, ".playcraft/workspace.json"))) !== hash(manifestBytes) || hash(await readFile(sdkPath)) !== hash(sdkBytes)) throw new Error("preview_runtime_source_changed");
1302
+ if (schemaPath && hash(await readFile(schemaPath)) !== hash(schema) || dataPath && hash(await readFile(dataPath)) !== hash(data) || hash(await readFile(await inside(root, ".playcraft/workspace.json"))) !== hash(manifestBytes) || hash(await readFile(sdkPath)) !== hash(sdkBytes)) throw new Error("preview_runtime_source_changed");
1294
1303
  const report = {
1295
1304
  target: "editor-static",
1296
1305
  buildId: context.buildId,
1297
1306
  htmlDigest: hash(html),
1298
- schemaDigest: hash(schema),
1307
+ schemaDigest: schemaHash,
1299
1308
  sourceFingerprint: context.sourceFingerprint,
1300
- dataHash: hash(data),
1309
+ dataHash,
1301
1310
  dataRevision: context.baseline.dataRevision,
1302
1311
  schemaRevision: context.baseline.schemaRevision,
1303
1312
  moduleIds,
@@ -3,13 +3,16 @@
3
3
  "sdkVersion": "0.0.1",
4
4
  "protocolVersion": 1,
5
5
  "files": {
6
- "build-preview.mjs": "2bd512675d829cc07ceddcb58365a6f74d36ff93690f8d72f4bbaa1d45511c91",
7
- "README.md": "907bb956f939b3d957ba83789e6131b2f4366fb22a239acda776df4ed22b7db2",
8
- "release-guard.mjs": "0c33d1559c68844f3760c3e754ee36ca70dc27151ef6f7ad62f29f95239679cc",
9
- "runtime.d.mts": "a366552166a4a93103306997058951416740eaf6d6f3d0a34854386b4f1e02f5",
10
- "runtime.d.ts": "a366552166a4a93103306997058951416740eaf6d6f3d0a34854386b4f1e02f5",
11
- "runtime.mjs": "700c6cb0859ef4b4390d7a1dae41f7e8fa7be7c8dad90b5b48a7e7ee5f90a6a1",
6
+ "build-preview.mjs": "c72ab758e39bb419cc194dce1ee711bd6f9bfda322e15198d4657d61742af386",
7
+ "README.md": "61a4dcf4dc5b6ae4000578cb2d369bb5f6a999c30e1c9c2dac44e3035bcd0a4b",
8
+ "release-guard.mjs": "728ac088f8d885a50a1c9bcdddad724fa80afd06e66a6dd3658756034e563055",
9
+ "runtime.d.mts": "a90c69a8b72105e8dc8fe0b3bcd272f038ed255f7daf5ec6c1aefc293a1e84b2",
10
+ "runtime.d.ts": "a90c69a8b72105e8dc8fe0b3bcd272f038ed255f7daf5ec6c1aefc293a1e84b2",
11
+ "runtime.mjs": "50dc53ff94effedf10903df708c1ecdb51bd8145a5a6ec1eac9449cad7424a24",
12
12
  "types/adapters.d.ts": "f5e70c4bb9043de1c590eada14266f613286360c809faf26680b0bbbd1cc7b2c",
13
+ "types/host.d.ts": "9ea867d5485a66aba7da86ea7e5583bca6b9a7a89618afd0eb70ace58e06faf9",
14
+ "types/index.d.ts": "210d24a767f260bc8944d917b50dae1357cba31b8b5d499bea7bcc99b1051e6c",
15
+ "types/level-editor.d.ts": "7f1a8c348e23b186c1f64e4f38fcb08fa663b0cfc2655a4acb86c640e0172a72",
13
16
  "types/preview.d.ts": "db2e7eb1fa3406ca53fc7c3a4352da061c05af714ead978111ab5118de58db32",
14
17
  "types/protocol.d.ts": "b298d1d35d6e261bbf6a0500f9029f38cad1532bb46475566180b3b92833c507",
15
18
  "types/runtime.d.ts": "f52d08d7b53ff84394381f9d1741a624142f75fac468abf9a5029e98fe172ca4"
@@ -4,7 +4,7 @@ import path from 'node:path';
4
4
 
5
5
  const slash = value => value.replaceAll('\\', '/').replaceAll('\0', '').split('?')[0];
6
6
  const hash = value => createHash('sha256').update(value).digest('hex');
7
- const marker = /runtime\.parameters\.|playcraft-preview-storage:|__playcraft_preview_context__/i;
7
+ const marker = /runtime\.(?:parameters|levelEditor|level-editor)\.|playcraft-preview-storage:|__playcraft_(?:preview|level_editor)_context__|playcraft-level-editor-profile/i;
8
8
  /** A production-only Vite module boundary, separate from the development preview builder. */
9
9
  export function previewRuntimeReleaseGuard({ root = process.cwd(), previewEntries = [], reportPath = '.playcraft-editor-preview/release-report.json' } = {}) {
10
10
  root = path.resolve(root);
@@ -1,3 +1 @@
1
- export { connectPreviewRuntime, readWorkspacePreviewContext, ResourceLoadError } from './types/preview.js';
2
- export type * from './types/adapters.js';
3
- export type * from './types/protocol.js';
1
+ export * from './types/index.js';
@@ -1,3 +1 @@
1
- export { connectPreviewRuntime, readWorkspacePreviewContext, ResourceLoadError } from './types/preview.js';
2
- export type * from './types/adapters.js';
3
- export type * from './types/protocol.js';
1
+ export * from './types/index.js';