@bendyline/molen-tooling 0.0.1 → 0.0.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 (137) hide show
  1. package/README.md +22 -4
  2. package/dist/cli.mjs +26 -4
  3. package/dist/docs-src/guide/3d-art-guidelines.md +2 -2
  4. package/dist/docs-src/guide/3d-model-assets.md +15 -11
  5. package/dist/docs-src/guide/aircraft.md +9 -10
  6. package/dist/docs-src/guide/browser-mount.md +14 -0
  7. package/dist/docs-src/guide/building-interiors.md +2 -1
  8. package/dist/docs-src/guide/determinism.md +16 -11
  9. package/dist/docs-src/guide/entities.md +16 -5
  10. package/dist/docs-src/guide/examples.md +38 -23
  11. package/dist/docs-src/guide/experience-playback.md +2 -3
  12. package/dist/docs-src/guide/game-samples.md +30 -18
  13. package/dist/docs-src/guide/project.md +22 -2
  14. package/dist/docs-src/guide/quickstart.md +37 -28
  15. package/dist/docs-src/guide/recognizable-places.md +21 -15
  16. package/dist/docs-src/guide/rendering-backends.md +5 -4
  17. package/dist/docs-src/guide/scripting.md +4 -2
  18. package/dist/docs-src/guide/sky.md +10 -9
  19. package/dist/docs-src/guide/structure-library.md +18 -8
  20. package/dist/docs-src/guide/terrain.md +6 -4
  21. package/dist/docs-src/guide/vehicles.md +9 -5
  22. package/dist/docs-src/guide/worldgen.md +31 -21
  23. package/dist/docs-src/llms.txt +26 -15
  24. package/dist/docs-src/schemas/README.md +1 -1
  25. package/dist/index.d.mts +26 -2
  26. package/dist/index.mjs +2 -2
  27. package/dist/{mcp-BFnCWrg0.mjs → mcp-AOfIp89b.mjs} +12 -2
  28. package/dist/{ops-BGxhSP6w.mjs → ops-C4BvDgP-.mjs} +267 -33
  29. package/dist/templates/city-courier/README.md +53 -0
  30. package/dist/templates/city-courier/checks.json +20 -0
  31. package/dist/templates/city-courier/commands.json +32 -0
  32. package/dist/templates/city-courier/delivery-run.replay.json +214 -0
  33. package/dist/templates/city-courier/gen/molen-types.ts +878 -0
  34. package/dist/templates/city-courier/index.html +2 -0
  35. package/dist/templates/city-courier/package.json +25 -0
  36. package/dist/templates/city-courier/project.json +8 -0
  37. package/dist/templates/city-courier/scene.json +3395 -0
  38. package/dist/templates/city-courier/scripts/game.ts +127 -0
  39. package/dist/templates/city-courier/scripts/molen-scripts.d.ts +1125 -0
  40. package/dist/templates/city-courier/scripts/tsconfig.json +16 -0
  41. package/dist/templates/city-courier/src/game-shell.css +309 -0
  42. package/dist/templates/city-courier/src/main.ts +81 -0
  43. package/dist/templates/city-courier/src/scene.ts +17 -0
  44. package/dist/templates/city-courier/src/vite-env.d.ts +1 -0
  45. package/dist/templates/city-courier/src/worker.ts +5 -0
  46. package/dist/templates/city-courier/test/headless.test.ts +95 -0
  47. package/dist/templates/city-courier/test/playthrough.test.js +52 -0
  48. package/dist/templates/city-courier/test/replay.test.ts +22 -0
  49. package/dist/templates/city-courier/tsconfig.json +17 -0
  50. package/dist/templates/city-courier/vite.config.ts +19 -0
  51. package/dist/templates/cubes/README.md +51 -0
  52. package/dist/templates/cubes/index.html +16 -0
  53. package/dist/templates/cubes/package.json +24 -0
  54. package/dist/templates/cubes/scene.json +15 -0
  55. package/dist/templates/cubes/src/cubes.ts +100 -0
  56. package/dist/templates/cubes/src/main.ts +21 -0
  57. package/dist/templates/cubes/src/worker.ts +15 -0
  58. package/dist/templates/cubes/test/headless.test.ts +98 -0
  59. package/dist/templates/cubes/tsconfig.json +17 -0
  60. package/dist/templates/cubes/vite.config.ts +17 -0
  61. package/dist/templates/data-viz/README.md +47 -0
  62. package/dist/templates/data-viz/camera-track.json +12 -0
  63. package/dist/templates/data-viz/data.json +9 -0
  64. package/dist/templates/data-viz/index.html +16 -0
  65. package/dist/templates/data-viz/package.json +25 -0
  66. package/dist/templates/data-viz/scene.json +7 -0
  67. package/dist/templates/data-viz/src/main.ts +39 -0
  68. package/dist/templates/data-viz/src/viz.ts +91 -0
  69. package/dist/templates/data-viz/src/worker.ts +12 -0
  70. package/dist/templates/data-viz/test/headless.test.ts +75 -0
  71. package/dist/templates/data-viz/tsconfig.json +17 -0
  72. package/dist/templates/data-viz/vite.config.ts +16 -0
  73. package/dist/templates/figures-gallery/README.md +46 -0
  74. package/dist/templates/figures-gallery/index.html +16 -0
  75. package/dist/templates/figures-gallery/package.json +25 -0
  76. package/dist/templates/figures-gallery/scene.json +276 -0
  77. package/dist/templates/figures-gallery/src/main.ts +44 -0
  78. package/dist/templates/figures-gallery/src/worker.ts +17 -0
  79. package/dist/templates/figures-gallery/test/headless.test.ts +90 -0
  80. package/dist/templates/figures-gallery/tsconfig.json +17 -0
  81. package/dist/templates/figures-gallery/vite.config.ts +17 -0
  82. package/dist/templates/index.json +188 -0
  83. package/dist/templates/skybound/README.md +53 -0
  84. package/dist/templates/skybound/checks.json +24 -0
  85. package/dist/templates/skybound/commands.json +32 -0
  86. package/dist/templates/skybound/first-leap.replay.json +224 -0
  87. package/dist/templates/skybound/gen/molen-types.ts +878 -0
  88. package/dist/templates/skybound/index.html +2 -0
  89. package/dist/templates/skybound/package.json +25 -0
  90. package/dist/templates/skybound/project.json +8 -0
  91. package/dist/templates/skybound/scene.json +1737 -0
  92. package/dist/templates/skybound/scripts/game.ts +119 -0
  93. package/dist/templates/skybound/scripts/molen-scripts.d.ts +1125 -0
  94. package/dist/templates/skybound/scripts/tsconfig.json +16 -0
  95. package/dist/templates/skybound/src/game-shell.css +309 -0
  96. package/dist/templates/skybound/src/main.ts +60 -0
  97. package/dist/templates/skybound/src/scene.ts +17 -0
  98. package/dist/templates/skybound/src/vite-env.d.ts +1 -0
  99. package/dist/templates/skybound/src/worker.ts +5 -0
  100. package/dist/templates/skybound/test/headless.test.ts +124 -0
  101. package/dist/templates/skybound/test/playthrough.test.js +38 -0
  102. package/dist/templates/skybound/test/replay.test.ts +22 -0
  103. package/dist/templates/skybound/tsconfig.json +17 -0
  104. package/dist/templates/skybound/vite.config.ts +19 -0
  105. package/dist/templates/terrain-flyover/README.md +46 -0
  106. package/dist/templates/terrain-flyover/index.html +16 -0
  107. package/dist/templates/terrain-flyover/package.json +26 -0
  108. package/dist/templates/terrain-flyover/src/flyover.ts +23 -0
  109. package/dist/templates/terrain-flyover/src/main.ts +93 -0
  110. package/dist/templates/terrain-flyover/terrain.json +15 -0
  111. package/dist/templates/terrain-flyover/test/headless.test.ts +72 -0
  112. package/dist/templates/terrain-flyover/tsconfig.json +17 -0
  113. package/dist/templates/terrain-flyover/vite.config.ts +15 -0
  114. package/dist/templates/top-down-arena/README.md +52 -0
  115. package/dist/templates/top-down-arena/arena-skirmish.replay.json +204 -0
  116. package/dist/templates/top-down-arena/index.html +16 -0
  117. package/dist/templates/top-down-arena/package.json +25 -0
  118. package/dist/templates/top-down-arena/project.json +10 -0
  119. package/dist/templates/top-down-arena/scene.json +162 -0
  120. package/dist/templates/top-down-arena/scripts/chase.ts +17 -0
  121. package/dist/templates/top-down-arena/scripts/combat.ts +12 -0
  122. package/dist/templates/top-down-arena/scripts/control.ts +8 -0
  123. package/dist/templates/top-down-arena/scripts/molen-scripts.d.ts +1095 -0
  124. package/dist/templates/top-down-arena/scripts/spawner.ts +11 -0
  125. package/dist/templates/top-down-arena/scripts/tsconfig.json +16 -0
  126. package/dist/templates/top-down-arena/src/arena.ts +8 -0
  127. package/dist/templates/top-down-arena/src/gen/molen-types.ts +882 -0
  128. package/dist/templates/top-down-arena/src/main.ts +31 -0
  129. package/dist/templates/top-down-arena/src/scene.ts +24 -0
  130. package/dist/templates/top-down-arena/src/vite-env.d.ts +1 -0
  131. package/dist/templates/top-down-arena/src/worker.ts +7 -0
  132. package/dist/templates/top-down-arena/test/headless.test.ts +87 -0
  133. package/dist/templates/top-down-arena/test/replay.test.ts +22 -0
  134. package/dist/templates/top-down-arena/tsconfig.json +17 -0
  135. package/dist/templates/top-down-arena/types/arena.types.json +54 -0
  136. package/dist/templates/top-down-arena/vite.config.ts +21 -0
  137. package/package.json +14 -14
package/dist/index.d.mts CHANGED
@@ -945,6 +945,11 @@ interface ScaffoldInput {
945
945
  dir?: string;
946
946
  /** Replace scaffold-owned files that already exist. Default false. */
947
947
  force?: boolean;
948
+ /**
949
+ * Copy a shipped sample instead of the built-in starter: a template id from `listTemplates()`
950
+ * (`molen templates`), e.g. `cubes` or `top-down-arena`.
951
+ */
952
+ template?: string;
948
953
  }
949
954
  interface ScaffoldOutput {
950
955
  ok: boolean;
@@ -953,7 +958,11 @@ interface ScaffoldOutput {
953
958
  nextSteps?: string[];
954
959
  error?: string;
955
960
  }
956
- /** Scaffold a complete, runnable project (manifest + scene + types + scripts + setup + browser app). */
961
+ /**
962
+ * Scaffold a complete, runnable project: the built-in starter (manifest + scene + types + scripts
963
+ * + setup + browser app), or with `template` a copy of one of the shipped samples. Either way the
964
+ * project gets an AGENTS.md pointing a coding agent at the version-locked docs and its loop.
965
+ */
957
966
  declare function scaffoldExperience(input: ScaffoldInput): Promise<ScaffoldOutput>;
958
967
  //#endregion
959
968
  //#region src/ops/schema.d.ts
@@ -1021,6 +1030,21 @@ interface SimulateOutput {
1021
1030
  /** Run a scene headlessly for N ticks, applying commands and evaluating assertions. */
1022
1031
  declare function runSimulation(input: SimulateInput): Promise<SimulateOutput>;
1023
1032
  //#endregion
1033
+ //#region src/ops/templates.d.ts
1034
+ interface TemplateEntry {
1035
+ /** Template id: the sample's directory name in the engine repository (e.g. `cubes`). */
1036
+ id: string;
1037
+ /** One line on what the sample shows. */
1038
+ description: string;
1039
+ }
1040
+ interface ListTemplatesOutput {
1041
+ ok: boolean;
1042
+ templates: TemplateEntry[];
1043
+ error?: string;
1044
+ }
1045
+ /** The sample templates `molen new --template <id>` can scaffold. */
1046
+ declare function listTemplates(): Promise<ListTemplatesOutput>;
1047
+ //#endregion
1024
1048
  //#region src/ops/types-test.d.ts
1025
1049
  interface TestTypesInput {
1026
1050
  projectPath?: string;
@@ -1268,4 +1292,4 @@ declare function schemaToTsType(schema: unknown, indent?: string): string;
1268
1292
  //#region src/index.d.ts
1269
1293
  declare const TOOLING_PACKAGE = "@bendyline/molen-tooling";
1270
1294
  //#endregion
1271
- export { ASSET_INDEX_FILE, type ApplyUvPaintInput, type ApplyUvPaintOutput, type AssetShotInput, type AssetShotOutput, type CameraSpec, type CheckTypesOutput, type DiffSnapshotsInput, type DiffSnapshotsOutput, type DocHit, type DriveAction, type DriveFrame, type DriveInput, type DriveOutput, type ExperiencePlayAction, type ExperiencePlayDiagnostic, type ExperiencePlayFrame, type ExperiencePlayInput, type ExperiencePlayOutput, type ExperiencePlayScenario, type ExportFramesInput, type ExportFramesOutput, type GenerateTypesInput, type GenerateTypesOutput, type GetComponentOutput, type GetSchemaOutput, type GoldenOptions, type GoldenResult, type ImageDiff, type ImportAssetInput, type ImportAssetOutput, type InspectAssetInput, type InspectAssetOutput, type ListAssetsOutput, type ListTypesOutput, type LoadSceneOptions, type LoadedScene, OPS_CATALOG, type OpDescriptor, type OpParam, type PackAssetInput, type PackAssetOutput, type PackTextureMode, type PackedAsset, type PackedTexture, type ProjectContext, type ProjectInfoInput, type ProjectInfoOutput, type RasterizeInput, type RasterizeOutput, type RenderStats, type ReserveNamespaceInput, type ReserveNamespaceOutput, type RunReplayInput, type RunReplayOutput, type ScaffoldInput, type ScaffoldOutput, type ScreenshotInput, type ScreenshotOutput, type ScriptDiagnostic, type SearchDocsInput, type SearchDocsOutput, type SimWatchHandle, type SimWatchInput, type SimulateInput, type SimulateOutput, type StageAssetsInput, type StageAssetsOutput, type StagedAsset, TOOLING_PACKAGE, type TestTypesInput, type TestTypesOutput, type TypeTestResult, type ValidateInput, type ValidateOutput, type WorldgenBakeInput, type WorldgenBakeOutput, type WorldgenPreviewInput, type WorldgenPreviewOutput, type WorldgenStatsInput, type WorldgenStatsOutput, applyUvPaintOp, assetFileIndex, bakeWorldgen, buildContentPack, checkScripts, checkTypesOp, compareGolden, describeOps, diffImages, diffSnapshots, driveScene, exportFrames, extractContentPack, fetchContentPack, findProjectFile, formatOp, generateTypes, getComponentOp, getSchemaOp, importAsset, inspectAsset, inspectContentPack, lineupBatchDoc, listAssets, listComponentsOp, listSchemasOp, listTypes, loadProject, loadSceneDocument, loadSetupLike, loadStylePackFromDisk, locateDocsRoot, packAsset, parseExperiencePlayScenario, playExperience, previewWorldgen, projectInfo, rasterizeMaterial, registerExperiencePlaySchema, renderTypesModule, reserveNamespace, runReplayFile, runSimulation, scaffoldExperience, schemaToTsType, screenshotAsset, screenshotScene, searchDocs, simWatch, stageAssets, testTypes, updateProjectFile, validateAsset, verifyContentPack, worldgenStats };
1295
+ export { ASSET_INDEX_FILE, type ApplyUvPaintInput, type ApplyUvPaintOutput, type AssetShotInput, type AssetShotOutput, type CameraSpec, type CheckTypesOutput, type DiffSnapshotsInput, type DiffSnapshotsOutput, type DocHit, type DriveAction, type DriveFrame, type DriveInput, type DriveOutput, type ExperiencePlayAction, type ExperiencePlayDiagnostic, type ExperiencePlayFrame, type ExperiencePlayInput, type ExperiencePlayOutput, type ExperiencePlayScenario, type ExportFramesInput, type ExportFramesOutput, type GenerateTypesInput, type GenerateTypesOutput, type GetComponentOutput, type GetSchemaOutput, type GoldenOptions, type GoldenResult, type ImageDiff, type ImportAssetInput, type ImportAssetOutput, type InspectAssetInput, type InspectAssetOutput, type ListAssetsOutput, type ListTemplatesOutput, type ListTypesOutput, type LoadSceneOptions, type LoadedScene, OPS_CATALOG, type OpDescriptor, type OpParam, type PackAssetInput, type PackAssetOutput, type PackTextureMode, type PackedAsset, type PackedTexture, type ProjectContext, type ProjectInfoInput, type ProjectInfoOutput, type RasterizeInput, type RasterizeOutput, type RenderStats, type ReserveNamespaceInput, type ReserveNamespaceOutput, type RunReplayInput, type RunReplayOutput, type ScaffoldInput, type ScaffoldOutput, type ScreenshotInput, type ScreenshotOutput, type ScriptDiagnostic, type SearchDocsInput, type SearchDocsOutput, type SimWatchHandle, type SimWatchInput, type SimulateInput, type SimulateOutput, type StageAssetsInput, type StageAssetsOutput, type StagedAsset, TOOLING_PACKAGE, type TemplateEntry, type TestTypesInput, type TestTypesOutput, type TypeTestResult, type ValidateInput, type ValidateOutput, type WorldgenBakeInput, type WorldgenBakeOutput, type WorldgenPreviewInput, type WorldgenPreviewOutput, type WorldgenStatsInput, type WorldgenStatsOutput, applyUvPaintOp, assetFileIndex, bakeWorldgen, buildContentPack, checkScripts, checkTypesOp, compareGolden, describeOps, diffImages, diffSnapshots, driveScene, exportFrames, extractContentPack, fetchContentPack, findProjectFile, formatOp, generateTypes, getComponentOp, getSchemaOp, importAsset, inspectAsset, inspectContentPack, lineupBatchDoc, listAssets, listComponentsOp, listSchemasOp, listTemplates, listTypes, loadProject, loadSceneDocument, loadSetupLike, loadStylePackFromDisk, locateDocsRoot, packAsset, parseExperiencePlayScenario, playExperience, previewWorldgen, projectInfo, rasterizeMaterial, registerExperiencePlaySchema, renderTypesModule, reserveNamespace, runReplayFile, runSimulation, scaffoldExperience, schemaToTsType, screenshotAsset, screenshotScene, searchDocs, simWatch, stageAssets, testTypes, updateProjectFile, validateAsset, verifyContentPack, worldgenStats };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as importAsset, A as verifyContentPack, B as describeOps, C as listTypes, D as extractContentPack, E as buildContentPack, F as exportFrames, G as stageAssets, H as checkScripts, I as driveScene, K as screenshotAsset, L as locateDocsRoot, M as renderTypesModule, O as fetchContentPack, Q as assetFileIndex, R as searchDocs, S as checkTypesOp, T as reserveNamespace, U as schemaToTsType, V as formatOp, W as ASSET_INDEX_FILE, X as inspectAsset, Y as packAsset, Z as listAssets, a as lineupBatchDoc, at as parseExperiencePlayScenario, b as runReplayFile, c as validateAsset, d as runSimulation, et as findProjectFile, f as screenshotScene, g as listSchemasOp, h as listComponentsOp, i as bakeWorldgen, it as updateProjectFile, j as generateTypes, k as inspectContentPack, l as applyUvPaintOp, m as getSchemaOp, n as worldgenStats, nt as loadSceneDocument, o as loadStylePackFromDisk, ot as playExperience, p as getComponentOp, r as previewWorldgen, rt as loadSetupLike, s as simWatch, st as registerExperiencePlaySchema, tt as loadProject, u as testTypes, v as scaffoldExperience, w as projectInfo, x as rasterizeMaterial, y as diffSnapshots, z as OPS_CATALOG } from "./ops-BGxhSP6w.mjs";
1
+ import { $ as assetFileIndex, A as inspectContentPack, B as OPS_CATALOG, C as checkTypesOp, D as buildContentPack, E as reserveNamespace, G as ASSET_INDEX_FILE, H as formatOp, I as exportFrames, K as stageAssets, L as driveScene, M as generateTypes, N as renderTypesModule, O as extractContentPack, Q as listAssets, R as locateDocsRoot, S as rasterizeMaterial, T as projectInfo, U as checkScripts, V as describeOps, W as schemaToTsType, X as packAsset, Z as inspectAsset, a as lineupBatchDoc, at as updateProjectFile, b as diffSnapshots, c as validateAsset, ct as registerExperiencePlaySchema, d as runSimulation, et as importAsset, f as screenshotScene, g as listSchemasOp, h as listComponentsOp, i as bakeWorldgen, it as loadSetupLike, j as verifyContentPack, k as fetchContentPack, l as applyUvPaintOp, m as getSchemaOp, n as worldgenStats, nt as loadProject, o as loadStylePackFromDisk, ot as parseExperiencePlayScenario, p as getComponentOp, q as screenshotAsset, r as previewWorldgen, rt as loadSceneDocument, s as simWatch, st as playExperience, tt as findProjectFile, u as testTypes, v as scaffoldExperience, w as listTypes, x as runReplayFile, y as listTemplates, z as searchDocs } from "./ops-C4BvDgP-.mjs";
2
2
  import { access, copyFile, mkdir, readFile, writeFile } from "node:fs/promises";
3
3
  import { dirname } from "node:path";
4
4
  import pixelmatch from "pixelmatch";
@@ -75,4 +75,4 @@ async function compareGolden(candidatePath, goldenPath, diffPath, opts = {}) {
75
75
  //#region src/index.ts
76
76
  const TOOLING_PACKAGE = "@bendyline/molen-tooling";
77
77
  //#endregion
78
- export { ASSET_INDEX_FILE, OPS_CATALOG, TOOLING_PACKAGE, applyUvPaintOp, assetFileIndex, bakeWorldgen, buildContentPack, checkScripts, checkTypesOp, compareGolden, describeOps, diffImages, diffSnapshots, driveScene, exportFrames, extractContentPack, fetchContentPack, findProjectFile, formatOp, generateTypes, getComponentOp, getSchemaOp, importAsset, inspectAsset, inspectContentPack, lineupBatchDoc, listAssets, listComponentsOp, listSchemasOp, listTypes, loadProject, loadSceneDocument, loadSetupLike, loadStylePackFromDisk, locateDocsRoot, packAsset, parseExperiencePlayScenario, playExperience, previewWorldgen, projectInfo, rasterizeMaterial, registerExperiencePlaySchema, renderTypesModule, reserveNamespace, runReplayFile, runSimulation, scaffoldExperience, schemaToTsType, screenshotAsset, screenshotScene, searchDocs, simWatch, stageAssets, testTypes, updateProjectFile, validateAsset, verifyContentPack, worldgenStats };
78
+ export { ASSET_INDEX_FILE, OPS_CATALOG, TOOLING_PACKAGE, applyUvPaintOp, assetFileIndex, bakeWorldgen, buildContentPack, checkScripts, checkTypesOp, compareGolden, describeOps, diffImages, diffSnapshots, driveScene, exportFrames, extractContentPack, fetchContentPack, findProjectFile, formatOp, generateTypes, getComponentOp, getSchemaOp, importAsset, inspectAsset, inspectContentPack, lineupBatchDoc, listAssets, listComponentsOp, listSchemasOp, listTemplates, listTypes, loadProject, loadSceneDocument, loadSetupLike, loadStylePackFromDisk, locateDocsRoot, packAsset, parseExperiencePlayScenario, playExperience, previewWorldgen, projectInfo, rasterizeMaterial, registerExperiencePlaySchema, renderTypesModule, reserveNamespace, runReplayFile, runSimulation, scaffoldExperience, schemaToTsType, screenshotAsset, screenshotScene, searchDocs, simWatch, stageAssets, testTypes, updateProjectFile, validateAsset, verifyContentPack, worldgenStats };
@@ -1,4 +1,4 @@
1
- import { $ as importAsset, A as verifyContentPack, B as describeOps, C as listTypes, D as extractContentPack, E as buildContentPack, F as exportFrames, G as stageAssets, H as checkScripts, I as driveScene, J as formatPacked, K as screenshotAsset, N as previewFigure, O as fetchContentPack, P as listFigurePresets, R as searchDocs, S as checkTypesOp, T as reserveNamespace, V as formatOp, X as inspectAsset, Y as packAsset, Z as listAssets, _ as loadComponentRegistry, b as runReplayFile, c as validateAsset, d as runSimulation, f as screenshotScene, g as listSchemasOp, h as listComponentsOp, i as bakeWorldgen, j as generateTypes, k as inspectContentPack, l as applyUvPaintOp, m as getSchemaOp, n as worldgenStats, ot as playExperience, p as getComponentOp, r as previewWorldgen, u as testTypes, v as scaffoldExperience, w as projectInfo, x as rasterizeMaterial, y as diffSnapshots } from "./ops-BGxhSP6w.mjs";
1
+ import { A as inspectContentPack, C as checkTypesOp, D as buildContentPack, E as reserveNamespace, F as listFigurePresets, H as formatOp, I as exportFrames, K as stageAssets, L as driveScene, M as generateTypes, O as extractContentPack, P as previewFigure, Q as listAssets, S as rasterizeMaterial, T as projectInfo, U as checkScripts, V as describeOps, X as packAsset, Y as formatPacked, Z as inspectAsset, _ as loadComponentRegistry, b as diffSnapshots, c as validateAsset, d as runSimulation, et as importAsset, f as screenshotScene, g as listSchemasOp, h as listComponentsOp, i as bakeWorldgen, j as verifyContentPack, k as fetchContentPack, l as applyUvPaintOp, m as getSchemaOp, n as worldgenStats, p as getComponentOp, q as screenshotAsset, r as previewWorldgen, st as playExperience, u as testTypes, v as scaffoldExperience, w as listTypes, x as runReplayFile, y as listTemplates, z as searchDocs } from "./ops-C4BvDgP-.mjs";
2
2
  import { mkdtemp, readFile, rm } from "node:fs/promises";
3
3
  import { join } from "node:path";
4
4
  import { z } from "zod";
@@ -744,9 +744,10 @@ function createMcpServer() {
744
744
  });
745
745
  server.registerTool("new_experience", {
746
746
  title: "New experience",
747
- description: "Scaffold a runnable experience (scene + scripts + setup + commands + checks) on disk.",
747
+ description: "Scaffold a runnable experience (scene + scripts + setup + commands + checks + AGENTS.md) on disk, or pass `template` to copy a shipped sample as a standalone npm project (list_templates lists the ids).",
748
748
  inputSchema: {
749
749
  name: z.string(),
750
+ template: z.string().optional(),
750
751
  dir: z.string().optional(),
751
752
  force: z.boolean().optional()
752
753
  }
@@ -755,6 +756,15 @@ function createMcpServer() {
755
756
  if (!r.ok) return text(r.error ?? "scaffold failed", true);
756
757
  return text(`created ${r.dir}\n${(r.files ?? []).join("\n")}\n\nnext:\n${(r.nextSteps ?? []).join("\n")}`);
757
758
  });
759
+ server.registerTool("list_templates", {
760
+ title: "List templates",
761
+ description: "List the sample templates new_experience can copy with `template`: id + one-line description, as JSON.",
762
+ inputSchema: {}
763
+ }, async () => {
764
+ const r = await listTemplates();
765
+ if (!r.ok) return text(r.error ?? "failed to list templates", true);
766
+ return text(JSON.stringify(r.templates, null, 2));
767
+ });
758
768
  return server;
759
769
  }
760
770
  /**
@@ -2967,15 +2967,23 @@ const OPS_CATALOG = [
2967
2967
  },
2968
2968
  {
2969
2969
  name: "new_experience",
2970
- summary: "Scaffold a new experience (scene + scripts + commands + checks) ready for the loop.",
2971
- cli: "molen new <name> [--dir <path>] [--force]",
2970
+ summary: "Scaffold a new experience (scene + scripts + commands + checks + AGENTS.md) ready for the loop, or a standalone copy of a shipped sample with --template.",
2971
+ cli: "molen new <name> [--template <id>] [--dir <path>] [--force]",
2972
2972
  mcpTool: "new_experience",
2973
2973
  params: [
2974
2974
  p("name", "string", true, "Experience name (also the output folder name)."),
2975
+ p("template", "string", false, "Copy this sample instead of the built-in starter (list_templates / molen templates lists the ids)."),
2975
2976
  p("dir", "string", false, "Parent directory (default: cwd)."),
2976
2977
  p("force", "boolean", false, "Replace existing scaffold-owned files (default false).")
2977
2978
  ]
2978
2979
  },
2980
+ {
2981
+ name: "list_templates",
2982
+ summary: "List the sample templates new_experience can copy (id + one-line description); each scaffolds as a standalone npm project.",
2983
+ cli: "molen templates [--json]",
2984
+ mcpTool: "list_templates",
2985
+ params: []
2986
+ },
2979
2987
  {
2980
2988
  name: "drive_scene",
2981
2989
  summary: "PLAY a scene deterministically: commands in at chosen ticks, screenshot frames out — a repeatable scenario the agent can look at.",
@@ -3303,7 +3311,7 @@ function formatOp(op) {
3303
3311
  }
3304
3312
  //#endregion
3305
3313
  //#region src/ops/docs.ts
3306
- async function exists(p) {
3314
+ async function exists$1(p) {
3307
3315
  try {
3308
3316
  await access(p);
3309
3317
  return true;
@@ -3319,14 +3327,14 @@ async function exists(p) {
3319
3327
  async function locateDocsRoot(start = process.cwd()) {
3320
3328
  let dir = resolve(start);
3321
3329
  for (;;) {
3322
- if (await exists(join(dir, "docs-src", "llms.txt"))) return dir;
3330
+ if (await exists$1(join(dir, "docs-src", "llms.txt"))) return dir;
3323
3331
  const parent = dirname(dir);
3324
3332
  if (parent === dir) break;
3325
3333
  dir = parent;
3326
3334
  }
3327
3335
  dir = dirname(fileURLToPath(import.meta.url));
3328
3336
  for (;;) {
3329
- if (await exists(join(dir, "docs-src", "llms.txt"))) return dir;
3337
+ if (await exists$1(join(dir, "docs-src", "llms.txt"))) return dir;
3330
3338
  const parent = dirname(dir);
3331
3339
  if (parent === dir) throw new Error("Molen documentation bundle is missing; reinstall @bendyline/molen-tooling");
3332
3340
  dir = parent;
@@ -3348,7 +3356,7 @@ async function searchDocs(input) {
3348
3356
  const k = input.k ?? 5;
3349
3357
  const terms = input.query.toLowerCase().split(/\s+/).filter(Boolean);
3350
3358
  const root = input.baseDir ?? await locateDocsRoot();
3351
- if (!await exists(join(root, "docs-src", "llms.txt"))) return {
3359
+ if (!await exists$1(join(root, "docs-src", "llms.txt"))) return {
3352
3360
  ok: false,
3353
3361
  hits: [],
3354
3362
  root,
@@ -4904,6 +4912,57 @@ async function diffSnapshots(input) {
4904
4912
  };
4905
4913
  }
4906
4914
  //#endregion
4915
+ //#region src/ops/templates.ts
4916
+ async function exists(path) {
4917
+ try {
4918
+ await access(path);
4919
+ return true;
4920
+ } catch {
4921
+ return false;
4922
+ }
4923
+ }
4924
+ /**
4925
+ * Walk up from this module to the template bundle: `templates/` beside the built entry points
4926
+ * (dist/), or `dist/templates/` above the sources (a workspace build, as the tests run it).
4927
+ */
4928
+ async function locateTemplates() {
4929
+ let dir = dirname(fileURLToPath(import.meta.url));
4930
+ for (;;) {
4931
+ for (const candidate of [join(dir, "templates"), join(dir, "dist", "templates")]) if (await exists(join(candidate, "index.json"))) return candidate;
4932
+ const parent = dirname(dir);
4933
+ if (parent === dir) return void 0;
4934
+ dir = parent;
4935
+ }
4936
+ }
4937
+ /** Read the shipped template bundle; throws when it is missing. */
4938
+ async function loadTemplateBundle() {
4939
+ const root = await locateTemplates();
4940
+ if (root === void 0) throw new Error("Molen template bundle is missing; reinstall @bendyline/molen-tooling (in the engine repository, build the tooling package)");
4941
+ return {
4942
+ root,
4943
+ templates: JSON.parse(await readFile(join(root, "index.json"), "utf8")).templates
4944
+ };
4945
+ }
4946
+ /** The sample templates `molen new --template <id>` can scaffold. */
4947
+ async function listTemplates() {
4948
+ try {
4949
+ const { templates } = await loadTemplateBundle();
4950
+ return {
4951
+ ok: true,
4952
+ templates: templates.map(({ id, description }) => ({
4953
+ id,
4954
+ description
4955
+ }))
4956
+ };
4957
+ } catch (error) {
4958
+ return {
4959
+ ok: false,
4960
+ templates: [],
4961
+ error: error.message
4962
+ };
4963
+ }
4964
+ }
4965
+ //#endregion
4907
4966
  //#region src/ops/scaffold.ts
4908
4967
  /** Scene names must be lower_snake; the scaffold namespace doubles as the types namespace. */
4909
4968
  function slug$1(name) {
@@ -5314,7 +5373,14 @@ export default defineConfig({
5314
5373
  plugins: [molenScripts()],
5315
5374
  // Worker bundles get their own plugin pipeline in Vite, and the kernel runs in the Worker.
5316
5375
  worker: { format: 'es', plugins: () => [molenScripts()] },
5317
- build: { target: 'es2022' },
5376
+ build: {
5377
+ target: 'es2022',
5378
+ // src/main.ts mounts with a top-level \`await\`, and the client lazy-loads its WebGPU driver.
5379
+ // Left in the entry chunk, three.js and the client would make that lazy chunk import the entry
5380
+ // while the entry is still suspended at the \`await\`, and the built page would stay blank in
5381
+ // every browser with WebGPU. Their own chunk breaks the cycle.
5382
+ rollupOptions: { output: { manualChunks: { vendor: ['three', '@bendyline/molen-client'] } } },
5383
+ },
5318
5384
  });
5319
5385
  `;
5320
5386
  const TSCONFIG = `{
@@ -5442,7 +5508,176 @@ function actionsJson() {
5442
5508
  }
5443
5509
  ], null, 2)}\n`;
5444
5510
  }
5445
- /** Scaffold a complete, runnable project (manifest + scene + types + scripts + setup + browser app). */
5511
+ const AGENTS_MD = "AGENTS.md";
5512
+ /** Project-relative, `/`-separated. */
5513
+ function projectRelative(dir, path) {
5514
+ return relative(dir, path).split(sep).join("/");
5515
+ }
5516
+ /** The scaffold-owned files already in `dir` (the force check). */
5517
+ async function existingFiles(dir, paths) {
5518
+ const existing = [];
5519
+ for (const rel of paths) try {
5520
+ await stat(join(dir, rel));
5521
+ existing.push(rel);
5522
+ } catch (error) {
5523
+ if (error.code !== "ENOENT") throw error;
5524
+ }
5525
+ return existing;
5526
+ }
5527
+ async function writeScaffoldFiles(dir, files, force) {
5528
+ for (const [rel, content] of files) {
5529
+ const abs = join(dir, rel);
5530
+ await mkdir(dirname(abs), { recursive: true });
5531
+ await writeFile(abs, content, force ? void 0 : { flag: "wx" });
5532
+ }
5533
+ }
5534
+ /** Refresh the typed handles and the scripts' ambient declarations from the installed registry. */
5535
+ async function refreshGeneratedTypes(dir) {
5536
+ const generated = await generateTypes({ projectPath: join(dir, "project.json") });
5537
+ if (!generated.ok) return { error: generated.error ?? "failed to generate types for the new project" };
5538
+ return { files: [projectRelative(dir, generated.outPath), ...(generated.scriptArtifacts ?? []).map((a) => projectRelative(dir, a.path))] };
5539
+ }
5540
+ /**
5541
+ * Word-wrap Markdown prose at 100 columns without breaking an inline code span. `first` prefixes
5542
+ * the first line (a bullet's `- `); continuation lines are indented to match it.
5543
+ */
5544
+ function wrap(text, first = "") {
5545
+ const indent = " ".repeat(first.length);
5546
+ const lines = [];
5547
+ let line = "";
5548
+ for (const token of text.match(/(?:[^\s`]*`[^`]*`)+[^\s`]*|\S+/g) ?? []) if (line.length === 0) line = `${lines.length === 0 ? first : indent}${token}`;
5549
+ else if (line.length + 1 + token.length > 100) {
5550
+ lines.push(line);
5551
+ line = `${indent}${token}`;
5552
+ } else line = `${line} ${token}`;
5553
+ lines.push(line);
5554
+ return lines.join("\n");
5555
+ }
5556
+ /**
5557
+ * The signpost for a coding agent working in the new project: where the version-locked docs are,
5558
+ * how to discover the ops, this project's own loop, and the rules that are cheap to break.
5559
+ */
5560
+ function agentsMd({ name, template, loop, generated }) {
5561
+ const origin = template === void 0 ? "the `molen new` starter" : `the \`${template.id}\` sample`;
5562
+ const generatedRule = generated.length > 0 ? `Generated files are never hand-edited: ${generated.map((f) => `\`${f}\``).join(", ")}. Change the scene or its type documents, then run \`npx molen types gen\` (\`npx molen types gen --check\` reports staleness).` : "Generated files are never hand-edited. Once the project has a `project.json` (https://molen.dev/guide/project), `npx molen types gen` writes its typed handles and each scripts directory's `molen-scripts.d.ts`; regenerate them instead.";
5563
+ return [
5564
+ `# AGENTS.md — ${name}`,
5565
+ "",
5566
+ wrap(`${name} is a Molen experience built from npm packages (engine ${ENGINE_VERSION}), scaffolded from ${origin}. Run every command below from this directory.`),
5567
+ "",
5568
+ "## Docs for this exact engine version",
5569
+ "",
5570
+ wrap("Start at `node_modules/@bendyline/molen-tooling/dist/docs-src/llms.txt`, then `guide/agent-loop.md` and `guide/scripting.md` beside it. They ship with the installed CLI, so they match the engine you are running; https://molen.dev/guide/agent-loop is the online copy.", "- "),
5571
+ wrap("`npx molen docs search <query>` searches that bundle offline.", "- "),
5572
+ wrap("`npx molen describe [op]` prints every operation's contract; `npx molen mcp` serves the same operations as MCP tools over stdio. `npx molen schema get <kind>` and `npx molen component <name>` give exact document and component shapes.", "- "),
5573
+ "",
5574
+ "## The headless loop",
5575
+ "",
5576
+ wrap("Install once with `npm install` (and `npx playwright install chromium` for `shot` and `drive`), then validate after every edit — a failure names the field and how to fix it:"),
5577
+ "",
5578
+ "```sh",
5579
+ ...loop,
5580
+ "```",
5581
+ "",
5582
+ "## Rules",
5583
+ "",
5584
+ wrap(generatedRule, "- "),
5585
+ wrap("Scene scripts run with the authority of the process that loads them; the CLI and the MCP server evaluate them in-process. Treat `scene.json` like source code and only run scenes you would run as a program.", "- "),
5586
+ wrap("Determinism: randomness through `molen.rng` and math through `molen.math` (in setup code, the world RNG and `dmath`); never `Math.random`, `Date` or wall-clock time in simulation code.", "- "),
5587
+ wrap("Reads are immutable: never mutate what `molen.get` / `world.get` returns; write with `set` / `patch`.", "- "),
5588
+ ""
5589
+ ].join("\n");
5590
+ }
5591
+ /** The built-in starter's loop, run from the project directory. */
5592
+ const STARTER_LOOP = [
5593
+ "npx molen validate scenes/main.scene.json",
5594
+ "npx molen types check",
5595
+ "npx molen scripts check",
5596
+ "npx molen sim run main --ticks 30 --commands cmds.json --assert checks.json --hash",
5597
+ "npx molen shot main --ticks 30 --out shot.png",
5598
+ "npx molen drive main --actions actions.json --out-dir shots"
5599
+ ];
5600
+ /** A template's loop: validate, check scripts, simulate (+ assert), replay, then its tests. */
5601
+ function templateLoop(template, scriptsCheck) {
5602
+ return [
5603
+ ...template.validate.map((doc) => `npx molen validate ${doc}`),
5604
+ ...scriptsCheck ? ["npx molen scripts check"] : [],
5605
+ ...template.sim !== null ? [`npx molen ${template.sim}`] : [],
5606
+ ...template.replays.map((fixture) => `npx molen replay ${fixture}`),
5607
+ ...template.tests ? ["npm test"] : []
5608
+ ];
5609
+ }
5610
+ /** The template's manifest as the new project's: its name, engine deps on this CLI's version line. */
5611
+ function templatePackageJson(source, name) {
5612
+ const { name: _name, ...manifest } = JSON.parse(source);
5613
+ const onEngineLine = (deps) => deps === void 0 ? void 0 : Object.fromEntries(Object.entries(deps).map(([dep, spec]) => [dep, spec.startsWith("workspace:") ? `^${ENGINE_VERSION}` : spec]));
5614
+ const pkg = {
5615
+ name,
5616
+ ...manifest,
5617
+ dependencies: onEngineLine(manifest.dependencies),
5618
+ devDependencies: onEngineLine(manifest.devDependencies)
5619
+ };
5620
+ return `${JSON.stringify(pkg, null, 2)}\n`;
5621
+ }
5622
+ async function scaffoldTemplate(input, dir) {
5623
+ const bundle = await loadTemplateBundle();
5624
+ const template = bundle.templates.find((t) => t.id === input.template);
5625
+ if (template === void 0) return {
5626
+ ok: false,
5627
+ error: `unknown template "${input.template}"; available templates: ${bundle.templates.map((t) => t.id).join(", ")} (molen templates describes them)`
5628
+ };
5629
+ const force = input.force === true;
5630
+ const files = [];
5631
+ for (const rel of template.files) {
5632
+ const source = await readFile(join(bundle.root, template.id, rel));
5633
+ files.push([rel, rel === "package.json" ? templatePackageJson(source.toString("utf8"), input.name) : source]);
5634
+ }
5635
+ if (!force) {
5636
+ const existing = await existingFiles(dir, [...files.map(([rel]) => rel), AGENTS_MD]);
5637
+ if (existing.length > 0) return {
5638
+ ok: false,
5639
+ error: `${dir} already contains scaffold files: ${existing.join(", ")} (pass force: true to replace them)`
5640
+ };
5641
+ }
5642
+ await writeScaffoldFiles(dir, files, force);
5643
+ let generated = [];
5644
+ if (template.project) {
5645
+ const refreshed = await refreshGeneratedTypes(dir);
5646
+ if (refreshed.error !== void 0) return {
5647
+ ok: false,
5648
+ error: refreshed.error
5649
+ };
5650
+ generated = refreshed.files ?? [];
5651
+ }
5652
+ const loop = templateLoop(template, generated.some((f) => f.endsWith("molen-scripts.d.ts")));
5653
+ await writeScaffoldFiles(dir, [[AGENTS_MD, agentsMd({
5654
+ name: input.name,
5655
+ template,
5656
+ loop,
5657
+ generated
5658
+ })]], force);
5659
+ return {
5660
+ ok: true,
5661
+ dir,
5662
+ files: [...new Set([
5663
+ ...files.map(([rel]) => rel),
5664
+ ...generated,
5665
+ AGENTS_MD
5666
+ ])].sort(),
5667
+ nextSteps: [
5668
+ `cd ${dir}`,
5669
+ "npm install # the engine, the molen CLI, TypeScript and Vite",
5670
+ "npx playwright install chromium # once per machine, for shot and drive",
5671
+ ...loop,
5672
+ "npm run dev"
5673
+ ]
5674
+ };
5675
+ }
5676
+ /**
5677
+ * Scaffold a complete, runnable project: the built-in starter (manifest + scene + types + scripts
5678
+ * + setup + browser app), or with `template` a copy of one of the shipped samples. Either way the
5679
+ * project gets an AGENTS.md pointing a coding agent at the version-locked docs and its loop.
5680
+ */
5446
5681
  async function scaffoldExperience(input) {
5447
5682
  if (!/^[a-zA-Z][\w-]*$/.test(input.name)) return {
5448
5683
  ok: false,
@@ -5450,6 +5685,10 @@ async function scaffoldExperience(input) {
5450
5685
  };
5451
5686
  const dir = resolve(input.dir ?? process.cwd(), input.name);
5452
5687
  try {
5688
+ if (input.template !== void 0) return await scaffoldTemplate({
5689
+ ...input,
5690
+ template: input.template
5691
+ }, dir);
5453
5692
  const files = [
5454
5693
  ["project.json", projectJson(input.name)],
5455
5694
  ["scenes/main.scene.json", sceneJson(input.name)],
@@ -5470,44 +5709,39 @@ async function scaffoldExperience(input) {
5470
5709
  ["package.json", packageJson(input.name)],
5471
5710
  ["README.md", readme(input.name)]
5472
5711
  ];
5473
- if (input.force !== true) {
5474
- const existing = [];
5475
- for (const [rel] of files) try {
5476
- await stat(join(dir, rel));
5477
- existing.push(rel);
5478
- } catch (error) {
5479
- if (error.code !== "ENOENT") throw error;
5480
- }
5712
+ const force = input.force === true;
5713
+ if (!force) {
5714
+ const existing = await existingFiles(dir, [...files.map(([rel]) => rel), AGENTS_MD]);
5481
5715
  if (existing.length > 0) return {
5482
5716
  ok: false,
5483
5717
  error: `${dir} already contains scaffold files: ${existing.join(", ")} (pass force: true to replace them)`
5484
5718
  };
5485
5719
  }
5486
- for (const [rel, content] of files) {
5487
- const abs = join(dir, rel);
5488
- await mkdir(dirname(abs), { recursive: true });
5489
- await writeFile(abs, content, input.force === true ? void 0 : { flag: "wx" });
5490
- }
5491
- const generated = await generateTypes({ projectPath: join(dir, "project.json") });
5492
- if (!generated.ok) return {
5720
+ await writeScaffoldFiles(dir, files, force);
5721
+ const generated = await refreshGeneratedTypes(dir);
5722
+ if (generated.error !== void 0) return {
5493
5723
  ok: false,
5494
- error: generated.error ?? "failed to generate types for the new project"
5724
+ error: generated.error
5495
5725
  };
5496
- const generatedFiles = [relative(dir, generated.outPath), ...(generated.scriptArtifacts ?? []).map((a) => relative(dir, a.path))];
5726
+ const generatedFiles = generated.files ?? [];
5727
+ await writeScaffoldFiles(dir, [[AGENTS_MD, agentsMd({
5728
+ name: input.name,
5729
+ loop: STARTER_LOOP,
5730
+ generated: generatedFiles
5731
+ })]], force);
5497
5732
  return {
5498
5733
  ok: true,
5499
5734
  dir,
5500
- files: [...files.map(([rel]) => rel), ...generatedFiles],
5735
+ files: [
5736
+ ...files.map(([rel]) => rel),
5737
+ ...generatedFiles,
5738
+ AGENTS_MD
5739
+ ],
5501
5740
  nextSteps: [
5502
5741
  `cd ${dir}`,
5503
5742
  "npm install # the engine, the molen CLI and TypeScript",
5504
5743
  "npx playwright install chromium # once per machine, for shot and drive",
5505
- "npx molen validate scenes/main.scene.json",
5506
- "npx molen types check",
5507
- "npx molen scripts check",
5508
- "npx molen sim run main --ticks 30 --commands cmds.json --assert checks.json --hash",
5509
- "npx molen shot main --ticks 30 --out shot.png",
5510
- "npx molen drive main --actions actions.json --out-dir shots"
5744
+ ...STARTER_LOOP
5511
5745
  ]
5512
5746
  };
5513
5747
  } catch (e) {
@@ -7243,4 +7477,4 @@ function formatWorldgenStats(result) {
7243
7477
  registerCameraTrackSchema();
7244
7478
  registerExperiencePlaySchema();
7245
7479
  //#endregion
7246
- export { importAsset as $, verifyContentPack as A, describeOps as B, listTypes as C, extractContentPack as D, buildContentPack as E, exportFrames as F, stageAssets as G, checkScripts as H, driveScene as I, formatPacked as J, screenshotAsset as K, locateDocsRoot as L, renderTypesModule as M, previewFigure as N, fetchContentPack as O, listFigurePresets as P, assetFileIndex as Q, searchDocs as R, checkTypesOp as S, reserveNamespace as T, schemaToTsType as U, formatOp as V, ASSET_INDEX_FILE as W, inspectAsset as X, packAsset as Y, listAssets as Z, loadComponentRegistry as _, lineupBatchDoc as a, parseExperiencePlayScenario as at, runReplayFile as b, validateAsset as c, runSimulation as d, findProjectFile as et, screenshotScene as f, listSchemasOp as g, listComponentsOp as h, bakeWorldgen as i, updateProjectFile as it, generateTypes as j, inspectContentPack as k, applyUvPaintOp as l, getSchemaOp as m, worldgenStats as n, loadSceneDocument as nt, loadStylePackFromDisk as o, playExperience as ot, getComponentOp as p, formatBytes as q, previewWorldgen as r, loadSetupLike as rt, simWatch as s, registerExperiencePlaySchema as st, formatWorldgenStats as t, loadProject as tt, testTypes as u, scaffoldExperience as v, projectInfo as w, rasterizeMaterial as x, diffSnapshots as y, OPS_CATALOG as z };
7480
+ export { assetFileIndex as $, inspectContentPack as A, OPS_CATALOG as B, checkTypesOp as C, buildContentPack as D, reserveNamespace as E, listFigurePresets as F, ASSET_INDEX_FILE as G, formatOp as H, exportFrames as I, formatBytes as J, stageAssets as K, driveScene as L, generateTypes as M, renderTypesModule as N, extractContentPack as O, previewFigure as P, listAssets as Q, locateDocsRoot as R, rasterizeMaterial as S, projectInfo as T, checkScripts as U, describeOps as V, schemaToTsType as W, packAsset as X, formatPacked as Y, inspectAsset as Z, loadComponentRegistry as _, lineupBatchDoc as a, updateProjectFile as at, diffSnapshots as b, validateAsset as c, registerExperiencePlaySchema as ct, runSimulation as d, importAsset as et, screenshotScene as f, listSchemasOp as g, listComponentsOp as h, bakeWorldgen as i, loadSetupLike as it, verifyContentPack as j, fetchContentPack as k, applyUvPaintOp as l, getSchemaOp as m, worldgenStats as n, loadProject as nt, loadStylePackFromDisk as o, parseExperiencePlayScenario as ot, getComponentOp as p, screenshotAsset as q, previewWorldgen as r, loadSceneDocument as rt, simWatch as s, playExperience as st, formatWorldgenStats as t, findProjectFile as tt, testTypes as u, scaffoldExperience as v, listTypes as w, runReplayFile as x, listTemplates as y, searchDocs as z };
@@ -0,0 +1,53 @@
1
+ # City Courier
2
+
3
+ Complete five deliveries in a compact city before the clock runs out. Traffic and buildings damage your car; follow the mint beacon and the route map. Arcade acceleration, reverse, steering, braking, collision damage, victory and loss all run in a deterministic Worker simulation.
4
+
5
+ ![City Courier](https://raw.githubusercontent.com/bendyline/molen/main/examples/city-courier/preview.png)
6
+
7
+ ## Play
8
+
9
+ Play it in the browser at [molen.dev/play/city-courier](https://molen.dev/play/city-courier/). To run and change
10
+ your own copy, make one from the npm packages (no clone of the engine repository needed):
11
+
12
+ ```sh
13
+ npx @bendyline/molen-tooling new my-city-courier --template city-courier
14
+ cd my-city-courier
15
+ npm install
16
+ npm run dev
17
+ ```
18
+
19
+ W/S or Up/Down: accelerate and reverse. A/D or Left/Right: steer. Space: handbrake. R: restart.
20
+
21
+ ## Authoring map
22
+
23
+ - `scene.json`: validated prefabs, level entities, component schemas, command payloads, input bindings, camera, physics, and gameplay configuration.
24
+ - `scripts/game.ts`: the complete game rules, with persistent state in components / `molen.state` and `checkpoint: "state"`.
25
+ - `src/scene.ts` and `src/worker.ts`: the same `buildWorld` path used by the CLI; no game-specific setup module.
26
+ - `src/main.ts`: HUD and browser presentation. It reads mirrored state and sends commands. No Three.js imports or simulation mutations.
27
+ - `commands.json` + `checks.json`: a short reproducible headless smoke scenario.
28
+ - `test/playthrough.test.js`: a bounded agent that wins with **only player commands**, then restarts. It never teleports entities or grants inventory.
29
+
30
+ The car is an arcade controller with a conservative circular collision footprint in XZ. It is not a suspension/tire simulation. Change handling and the delivery route in `scripts[0].config`, vehicle dimensions in the `vehicle` prefab, and traffic routes in `trafficCar` components.
31
+
32
+ ## Verify
33
+
34
+ From this directory:
35
+
36
+ ```sh
37
+ npx molen validate scene.json
38
+ npx molen sim run scene.json --ticks 90 --commands commands.json --assert checks.json --hash
39
+ npx molen replay delivery-run.replay.json
40
+ npx molen shot scene.json --ticks 3 --out city-courier.png
41
+ npm test
42
+ ```
43
+
44
+ `npm test` includes the command-only playthrough and replays `delivery-run.replay.json`, so a behaviour
45
+ change reports the first divergent tick. Visuals are original primitive-based art with palette
46
+ materials; no downloads, API keys, licensed asset packs, or runtime asset generation are required.
47
+ `npm run build` writes a static `dist/` with relative URLs, so it can be hosted beneath any
48
+ subdirectory (molen.dev/play hosts this exact build).
49
+
50
+ In the engine repository this sample lives in `examples/city-courier/`. There, a browser test plays the
51
+ built Worker app (HUD, restart, resizing) under `pnpm --filter @bendyline/molen-examples-city-courier test:golden`,
52
+ and the [shared asset and startup contract](https://github.com/bendyline/molen/blob/main/examples/ASSETS.md)
53
+ explains editing masters and checked-in runtime files.
@@ -0,0 +1,20 @@
1
+ {
2
+ "format": "molen/assert@1",
3
+ "assertions": [
4
+ {
5
+ "select": "#game .courierGame.status",
6
+ "op": "eq",
7
+ "value": "playing"
8
+ },
9
+ {
10
+ "select": "#player .transform.pos[2]",
11
+ "op": "lt",
12
+ "value": 8
13
+ },
14
+ {
15
+ "select": "#game .courierGame.health",
16
+ "op": "gt",
17
+ "value": 0
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,32 @@
1
+ [
2
+ {
3
+ "kind": "command",
4
+ "source": "example",
5
+ "seq": 0,
6
+ "tick": 0,
7
+ "type": "drive",
8
+ "payload": {
9
+ "dir": [0, -1]
10
+ }
11
+ },
12
+ {
13
+ "kind": "command",
14
+ "source": "example",
15
+ "seq": 1,
16
+ "tick": 60,
17
+ "type": "drive",
18
+ "payload": {
19
+ "dir": [0, 0]
20
+ }
21
+ },
22
+ {
23
+ "kind": "command",
24
+ "source": "example",
25
+ "seq": 2,
26
+ "tick": 60,
27
+ "type": "brake",
28
+ "payload": {
29
+ "held": true
30
+ }
31
+ }
32
+ ]