@wildshard/sdk 0.0.1 → 0.2.4

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 (688) hide show
  1. package/GUIDE.md +895 -0
  2. package/README.md +13 -5
  3. package/bin/wildshard.mjs +38 -0
  4. package/lint/declaration-config.d.mts +2 -0
  5. package/lint/declaration-config.mjs +19 -0
  6. package/lint/engine-plugin.d.mts +2 -0
  7. package/lint/engine-plugin.mjs +40 -0
  8. package/lint/host-callbacks.d.mts +6 -0
  9. package/lint/host-callbacks.mjs +123 -0
  10. package/lint/host-files.d.mts +1 -0
  11. package/lint/host-files.mjs +7 -0
  12. package/lint/layer-exports.d.mts +2 -0
  13. package/lint/layer-exports.mjs +21 -0
  14. package/lint/legacy-line-basis.json +995 -0
  15. package/lint/nine-tiling-baseline.json +35 -0
  16. package/lint/ratchet.json +11 -0
  17. package/lint/runtime-files.d.mts +12 -0
  18. package/lint/runtime-files.json +16 -0
  19. package/lint/runtime-files.mjs +69 -0
  20. package/lint/runtime-performance.d.mts +6 -0
  21. package/lint/runtime-performance.mjs +184 -0
  22. package/lint/sdk-plugin.d.mts +4 -0
  23. package/lint/sdk-plugin.mjs +134 -0
  24. package/lint/shardfile-boundaries.d.mts +10 -0
  25. package/lint/shardfile-boundaries.mjs +122 -0
  26. package/lint/tile-bake-debt.json +556 -0
  27. package/package.json +365 -3
  28. package/scripts/agent-parity.mjs +1524 -0
  29. package/scripts/agent-sync.mjs +518 -0
  30. package/scripts/apfs-clone.mjs +67 -0
  31. package/scripts/assert-store-layout.mjs +23 -0
  32. package/scripts/astc6-phone-cap.d.mts +3 -0
  33. package/scripts/astc6-phone-cap.mjs +137 -0
  34. package/scripts/audit-assets.d.mts +10 -0
  35. package/scripts/audit-assets.mjs +151 -0
  36. package/scripts/bake/coatFiles.d.mts +6 -0
  37. package/scripts/bake/coatFiles.mjs +37 -0
  38. package/scripts/bake/environment.d.mts +2 -0
  39. package/scripts/bake/environment.mjs +58 -0
  40. package/scripts/bake/far-proxies.mjs +45 -0
  41. package/scripts/bake/keyed-sky.d.mts +4 -0
  42. package/scripts/bake/keyed-sky.mjs +34 -0
  43. package/scripts/bake/movers.mjs +56 -0
  44. package/scripts/bake/nativeWorld.d.mts +6 -0
  45. package/scripts/bake/nativeWorld.mjs +43 -0
  46. package/scripts/bake/navmeshGround.ts +22 -0
  47. package/scripts/bake/near-placeholder.mjs +331 -0
  48. package/scripts/bake/placeholderShards.mjs +41 -0
  49. package/scripts/bake/skins.mjs +15 -0
  50. package/scripts/bake/template-skins.mjs +33 -0
  51. package/scripts/bake/viewmodelBytes.ts +26 -0
  52. package/scripts/bake/viewmodelPage.ts +11 -0
  53. package/scripts/bake/worldHost.d.mts +35 -0
  54. package/scripts/bake/worldHost.mjs +110 -0
  55. package/scripts/bake-astc6.cache.json +80 -0
  56. package/scripts/bake-astc6.far-reach.cache.json +23 -0
  57. package/scripts/bake-astc6.list.json +111 -0
  58. package/scripts/bake-astc6.mjs +279 -0
  59. package/scripts/bake-astc6.nalati-grasslands.cache.json +42 -0
  60. package/scripts/bake-catalogue.mjs +44 -0
  61. package/scripts/bake-check.mjs +54 -0
  62. package/scripts/bake-chunk.mjs +124 -0
  63. package/scripts/bake-cloud-field.mjs +24 -0
  64. package/scripts/bake-coats.mjs +110 -0
  65. package/scripts/bake-data-maps.d.mts +24 -0
  66. package/scripts/bake-data-maps.mjs +72 -0
  67. package/scripts/bake-entry-programs.mjs +117 -0
  68. package/scripts/bake-geometry.mjs +106 -0
  69. package/scripts/bake-hybrid-tiles.mjs +28 -0
  70. package/scripts/bake-ktx2.cache.json +276 -0
  71. package/scripts/bake-ktx2.list.json +365 -0
  72. package/scripts/bake-ktx2.mjs +477 -0
  73. package/scripts/bake-map-glb.mjs +127 -0
  74. package/scripts/bake-map-rest.d.mts +7 -0
  75. package/scripts/bake-map-rest.mjs +50 -0
  76. package/scripts/bake-maps.mjs +200 -0
  77. package/scripts/bake-navmesh.mjs +259 -0
  78. package/scripts/bake-packs.mjs +129 -0
  79. package/scripts/bake-pickups.mjs +102 -0
  80. package/scripts/bake-query-terrain.mjs +64 -0
  81. package/scripts/bake-recurve-pool.mjs +16 -0
  82. package/scripts/bake-section-schemas.d.mts +3 -0
  83. package/scripts/bake-template-shardfile.mjs +32 -0
  84. package/scripts/bake-textures.mjs +80 -0
  85. package/scripts/bake-viewmodel-sets.json +45 -0
  86. package/scripts/bake-viewmodel-sets.mjs +137 -0
  87. package/scripts/bake-voxel-ao.mjs +119 -0
  88. package/scripts/bake-water-ripples.mjs +25 -0
  89. package/scripts/blender/README.md +129 -0
  90. package/scripts/blender/build.sh +166 -0
  91. package/scripts/blender/lib/export-scene.mjs +129 -0
  92. package/scripts/blender/lib/glb-digest.mjs +188 -0
  93. package/scripts/blender/lib/glb.py +68 -0
  94. package/scripts/blender/lib/save_blend.py +17 -0
  95. package/scripts/blender/lib/world_fixture.py +55 -0
  96. package/scripts/blender/targets.json +591 -0
  97. package/scripts/build-sdk.mjs +95 -0
  98. package/scripts/build-shardfiles.d.mts +7 -0
  99. package/scripts/build-shardfiles.mjs +206 -0
  100. package/scripts/capture-hero.mjs +137 -0
  101. package/scripts/check-lift-review.mjs +23 -0
  102. package/scripts/chromium-keychain-check.mjs +139 -0
  103. package/scripts/chromium-keychain.d.mts +1 -0
  104. package/scripts/chromium-keychain.mjs +5 -0
  105. package/scripts/compile-script.d.mts +3 -0
  106. package/scripts/compile-script.mjs +8 -0
  107. package/scripts/creature-color.mjs +255 -0
  108. package/scripts/decide/calibrate.py +127 -0
  109. package/scripts/decide/calibration/2026-10-03/labels-s1.tsv +281 -0
  110. package/scripts/decide/calibration/2026-10-03/labels-s2.tsv +97 -0
  111. package/scripts/decide/calibration/2026-10-03/labels-s3.tsv +48 -0
  112. package/scripts/decide/calibration/2026-10-03/labels-s3b.tsv +26 -0
  113. package/scripts/decide/calibration/2026-10-03/res-capture-status-v1.jsonl +376 -0
  114. package/scripts/decide/calibration/2026-10-03/res-text-garbled-strings.jsonl +48 -0
  115. package/scripts/decide/calibration/2026-10-03/res-text-garbled-v1.jsonl +73 -0
  116. package/scripts/decide/decide.py +262 -0
  117. package/scripts/decide/decide.sh +50 -0
  118. package/scripts/decide/layer-purity-pilot.mjs +41 -0
  119. package/scripts/decide/sets/capture-status.json +46 -0
  120. package/scripts/decide/sets/layer-purity.json +28 -0
  121. package/scripts/decide/sets/text-garbled.json +17 -0
  122. package/scripts/decide/test_decide.py +37 -0
  123. package/scripts/docs.mjs +15 -0
  124. package/scripts/entry-reads/crawl.ts +152 -0
  125. package/scripts/entry-reads/tsconfig.json +25 -0
  126. package/scripts/gen-format-schema.d.mts +2 -0
  127. package/scripts/gen-format-schema.mjs +21 -0
  128. package/scripts/gen-host-catalogue.d.mts +14 -0
  129. package/scripts/gen-host-catalogue.mjs +108 -0
  130. package/scripts/gen-shard-layout-doc.d.mts +4 -0
  131. package/scripts/gen-shard-layout-doc.mjs +55 -0
  132. package/scripts/gen-shards.d.mts +17 -0
  133. package/scripts/gen-shards.mjs +311 -0
  134. package/scripts/goldens/capture-inputs.d.mts +4 -0
  135. package/scripts/goldens/capture-inputs.mjs +34 -0
  136. package/scripts/goldens/colour_shift.py +27 -0
  137. package/scripts/goldens/native-residency.d.mts +10 -0
  138. package/scripts/goldens/native-residency.mjs +104 -0
  139. package/scripts/goldens/plot-inputs.d.mts +12 -0
  140. package/scripts/goldens/plot-inputs.mjs +46 -0
  141. package/scripts/gpu-texmem.mjs +98 -0
  142. package/scripts/horizon-matte/config.py +24 -0
  143. package/scripts/horizon-matte/encode.py +91 -0
  144. package/scripts/horizon-matte/key.py +141 -0
  145. package/scripts/horizon-matte/mkjobs.py +33 -0
  146. package/scripts/horizon-matte/mkjobs_day2.py +11 -0
  147. package/scripts/horizon-matte/overlap.py +80 -0
  148. package/scripts/horizon-matte/run_codex.py +57 -0
  149. package/scripts/horizon-matte/stitch.py +133 -0
  150. package/scripts/img2mesh/CC0.md +105 -0
  151. package/scripts/img2mesh/README.md +209 -0
  152. package/scripts/img2mesh/ab_board.py +102 -0
  153. package/scripts/img2mesh/birds/birds.json +255 -0
  154. package/scripts/img2mesh/birds/birds_atlas.py +150 -0
  155. package/scripts/img2mesh/birds/birds_fix_preview.mjs +103 -0
  156. package/scripts/img2mesh/birds/birds_fix_render.py +75 -0
  157. package/scripts/img2mesh/birds/birds_pack.py +110 -0
  158. package/scripts/img2mesh/birds/birds_phone_b.py +112 -0
  159. package/scripts/img2mesh/birds/birds_post.py +550 -0
  160. package/scripts/img2mesh/birds/birds_render.py +125 -0
  161. package/scripts/img2mesh/birds/birds_sheet.py +33 -0
  162. package/scripts/img2mesh/birds/birds_view.py +60 -0
  163. package/scripts/img2mesh/board.py +100 -0
  164. package/scripts/img2mesh/build_cc0.sh +52 -0
  165. package/scripts/img2mesh/build_driftwood.sh +12 -0
  166. package/scripts/img2mesh/build_faces.sh +53 -0
  167. package/scripts/img2mesh/build_props.py +81 -0
  168. package/scripts/img2mesh/cc0_export.py +186 -0
  169. package/scripts/img2mesh/driftwood_post.py +571 -0
  170. package/scripts/img2mesh/e304_faces.sh +67 -0
  171. package/scripts/img2mesh/face_remaster.py +911 -0
  172. package/scripts/img2mesh/face_views.py +95 -0
  173. package/scripts/img2mesh/faces-e304.json +9 -0
  174. package/scripts/img2mesh/faces.json +30 -0
  175. package/scripts/img2mesh/head_cut.py +100 -0
  176. package/scripts/img2mesh/hi3d_paint.py +94 -0
  177. package/scripts/img2mesh/hi3d_refine.py +161 -0
  178. package/scripts/img2mesh/hunyuan_cpu_rasterizer.sh +42 -0
  179. package/scripts/img2mesh/pine_hollow_phone.sh +13 -0
  180. package/scripts/img2mesh/props/coral-arch.json +32 -0
  181. package/scripts/img2mesh/props/ember-furnace.json +30 -0
  182. package/scripts/img2mesh/props/night-market-gate.json +10 -0
  183. package/scripts/img2mesh/render_still.py +86 -0
  184. package/scripts/img2mesh/rig_strip.mjs +46 -0
  185. package/scripts/img2mesh/rig_transfer.mjs +104 -0
  186. package/scripts/img2mesh/split_sheet.py +48 -0
  187. package/scripts/img2mesh/trellis_batch.py +110 -0
  188. package/scripts/img2mesh/versus_board.py +114 -0
  189. package/scripts/import-bundle.d.mts +2 -0
  190. package/scripts/import-bundle.mjs +20 -0
  191. package/scripts/ktx2-ab-board.py +133 -0
  192. package/scripts/ktx2-ab.mjs +111 -0
  193. package/scripts/ktx2-settings.mjs +18 -0
  194. package/scripts/land.d.mts +14 -0
  195. package/scripts/land.mjs +809 -0
  196. package/scripts/lint-dispatch.mjs +14 -0
  197. package/scripts/map-bake-frames.d.mts +4 -0
  198. package/scripts/map-bake-frames.mjs +23 -0
  199. package/scripts/map-geometry.d.mts +9 -0
  200. package/scripts/map-geometry.mjs +29 -0
  201. package/scripts/map-world.mjs +162 -0
  202. package/scripts/mockup-local.sh +46 -0
  203. package/scripts/music/export-midi.mjs +68 -0
  204. package/scripts/music/gen/analyze.py +308 -0
  205. package/scripts/music/gen/audio_jobs.py +46 -0
  206. package/scripts/music/gen/briefs.json +51 -0
  207. package/scripts/music/gen/build_page.py +334 -0
  208. package/scripts/music/gen/folk.json +3187 -0
  209. package/scripts/music/gen/gen_ace_step.py +156 -0
  210. package/scripts/music/gen/gen_heartmula.py +187 -0
  211. package/scripts/music/gen/gen_minimax.py +143 -0
  212. package/scripts/music/gen/gen_sao.py +122 -0
  213. package/scripts/music/gen/gen_sao_small.py +104 -0
  214. package/scripts/music/gen/gen_sfx.py +98 -0
  215. package/scripts/music/gen/gen_sfx_ezaudio.py +112 -0
  216. package/scripts/music/gen/gen_sfx_moss.py +112 -0
  217. package/scripts/music/gen/models.json +61 -0
  218. package/scripts/music/gen/nalati-jobs.json +104 -0
  219. package/scripts/music/gen/nalati-score-build.json +119 -0
  220. package/scripts/music/gen/nalati-score.json +3448 -0
  221. package/scripts/music/gen/ob7-fit-decisions.json +38 -0
  222. package/scripts/music/gen/ob7-score-jobs.json +152 -0
  223. package/scripts/music/gen/ob7-sfx-jobs.json +897 -0
  224. package/scripts/music/gen/ob7_build.py +469 -0
  225. package/scripts/music/gen/ob7_generate.py +67 -0
  226. package/scripts/music/gen/ob7_run.sh +42 -0
  227. package/scripts/music/gen/orchestral.json +3187 -0
  228. package/scripts/music/gen/own_score.py +486 -0
  229. package/scripts/music/gen/ph-jobs.json +27 -0
  230. package/scripts/music/gen/ph_page.py +222 -0
  231. package/scripts/music/gen/piano.json +3175 -0
  232. package/scripts/music/gen/rank_v3.py +248 -0
  233. package/scripts/music/gen/sfx-best.json +2486 -0
  234. package/scripts/music/gen/sfx-ezaudio.json +4082 -0
  235. package/scripts/music/gen/sfx-jobs.json +57 -0
  236. package/scripts/music/gen/sfx-minimax-jobs.json +16 -0
  237. package/scripts/music/gen/sfx-minimax.json +289 -0
  238. package/scripts/music/gen/sfx-moss.json +4082 -0
  239. package/scripts/music/gen/sfx-nalati-b3-jobs.json +17 -0
  240. package/scripts/music/gen/sfx-nalati-jobs.json +338 -0
  241. package/scripts/music/gen/sfx-nalati.json +11202 -0
  242. package/scripts/music/gen/sfx-nd-jobs.json +57 -0
  243. package/scripts/music/gen/sfx-nd-moss.json +2097 -0
  244. package/scripts/music/gen/sfx-nd-sa3-medium.json +2097 -0
  245. package/scripts/music/gen/sfx-nd-summary.json +38 -0
  246. package/scripts/music/gen/sfx-peaks.json +7 -0
  247. package/scripts/music/gen/sfx-ph-jobs.json +169 -0
  248. package/scripts/music/gen/sfx-ph-moss.json +6564 -0
  249. package/scripts/music/gen/sfx-ph-sa3-medium.json +7239 -0
  250. package/scripts/music/gen/sfx-ph-summary.json +63 -0
  251. package/scripts/music/gen/sfx-sa3-medium.json +4082 -0
  252. package/scripts/music/gen/sfx-sa3.json +4082 -0
  253. package/scripts/music/gen/sfx-summary.json +107 -0
  254. package/scripts/music/gen/sfx_build.py +332 -0
  255. package/scripts/music/gen/sfx_merge.py +255 -0
  256. package/scripts/music/gen/sfx_minimax.py +61 -0
  257. package/scripts/music/gen/sfx_nalati.py +331 -0
  258. package/scripts/music/gen/sfx_sprite.py +424 -0
  259. package/scripts/music/gen/stems.py +539 -0
  260. package/scripts/music/gen/test_loop_meter.py +29 -0
  261. package/scripts/music/gen/test_ob7_provenance.py +77 -0
  262. package/scripts/music/gen/v3-folk-build.json +148 -0
  263. package/scripts/music/gen/v3-folk.json +1818 -0
  264. package/scripts/music/gen/v3-jobs.json +145 -0
  265. package/scripts/music/gen/v3-orchestral-build.json +148 -0
  266. package/scripts/music/gen/v3-orchestral.json +1813 -0
  267. package/scripts/music/gen/v3-ph-folk-build.json +94 -0
  268. package/scripts/music/gen/v3-ph-folk.json +1806 -0
  269. package/scripts/music/gen/v3-ph-orchestral-build.json +94 -0
  270. package/scripts/music/gen/v3-ph-orchestral.json +1824 -0
  271. package/scripts/music/gen/v3-ph-piano-build.json +94 -0
  272. package/scripts/music/gen/v3-ph-piano.json +1818 -0
  273. package/scripts/music/gen/v3-piano-build.json +148 -0
  274. package/scripts/music/gen/v3-piano.json +1813 -0
  275. package/scripts/music/wildshard-theme.mid +0 -0
  276. package/scripts/music/wildshard-trailer30.mid +0 -0
  277. package/scripts/named-blob-output.d.mts +8 -0
  278. package/scripts/named-blob-output.mjs +48 -0
  279. package/scripts/pack-all.mjs +15 -0
  280. package/scripts/pid-lock.d.mts +1 -0
  281. package/scripts/pid-lock.mjs +63 -0
  282. package/scripts/practice/bake_dummy.py +53 -0
  283. package/scripts/practice/build_dummies.sh +43 -0
  284. package/scripts/practice/dummy_parts.py +568 -0
  285. package/scripts/practice/dummy_rig_gate.py +139 -0
  286. package/scripts/practice/gate_sheet.py +36 -0
  287. package/scripts/practice/generate_dummy_unimate.py +132 -0
  288. package/scripts/practice/pack_dummy.mjs +59 -0
  289. package/scripts/practice/repair_dummy_weights.mjs +68 -0
  290. package/scripts/practice/rig_dummy.py +828 -0
  291. package/scripts/practice/verify_unimate_skin.mjs +356 -0
  292. package/scripts/preparation-seed.mjs +15 -0
  293. package/scripts/prepare-basis-tool.mjs +6 -0
  294. package/scripts/prepare-product.d.mts +14 -0
  295. package/scripts/prepare-product.mjs +101 -0
  296. package/scripts/product-build-tools.d.mts +3 -0
  297. package/scripts/product-build-tools.json +3 -0
  298. package/scripts/product-build-tools.mjs +31 -0
  299. package/scripts/publish-public.mjs +7 -0
  300. package/scripts/push-tables.d.mts +1 -0
  301. package/scripts/push-tables.mjs +28 -0
  302. package/scripts/record-shard-mounts.mjs +133 -0
  303. package/scripts/sdk-externals.d.mts +2 -0
  304. package/scripts/sdk-externals.mjs +2 -0
  305. package/scripts/section-inventory.ts +209 -0
  306. package/scripts/select-candidate.mjs +15 -0
  307. package/scripts/shard-build-pool.d.mts +4 -0
  308. package/scripts/shard-build-pool.mjs +53 -0
  309. package/scripts/shard-line-baseline.json +17 -0
  310. package/scripts/shard-milestones.d.mts +15 -0
  311. package/scripts/shard-milestones.mjs +105 -0
  312. package/scripts/shard-output-report.d.mts +9 -0
  313. package/scripts/shard-output-report.mjs +85 -0
  314. package/scripts/shard-platform-cli.mjs +93 -0
  315. package/scripts/shard-progress.mjs +212 -0
  316. package/scripts/shard-timelapse.py +102 -0
  317. package/scripts/shardfile-cold-boot.mjs +79 -0
  318. package/scripts/shardfile-vite.d.mts +4 -0
  319. package/scripts/shardfile-vite.mjs +20 -0
  320. package/scripts/simplify-models.mjs +24 -0
  321. package/scripts/site-facts.mjs +88 -0
  322. package/scripts/test-template-gate.mjs +44 -0
  323. package/scripts/test_golden_compare.py +68 -0
  324. package/scripts/tex-tiers.cache.json +181 -0
  325. package/scripts/tex-tiers.mjs +240 -0
  326. package/scripts/texmem-probe.mjs +184 -0
  327. package/scripts/unused-assets.mjs +173 -0
  328. package/scripts/vite-tmp.d.mts +23 -0
  329. package/scripts/vite-tmp.mjs +157 -0
  330. package/scripts/wave-line-baselines.json +32 -0
  331. package/scripts/wildshard.d.mts +4 -0
  332. package/scripts/wildshard.mjs +105 -0
  333. package/scripts/witness-checkpoints.d.mts +10 -0
  334. package/scripts/witness-checkpoints.mjs +84 -0
  335. package/scripts/witness-generation.d.mts +10 -0
  336. package/scripts/witness-generation.mjs +45 -0
  337. package/scripts/witness-manifests.d.mts +8 -0
  338. package/scripts/witness-manifests.mjs +157 -0
  339. package/scripts/worktree-ignore.d.mts +4 -0
  340. package/scripts/worktree-ignore.mjs +36 -0
  341. package/scripts/worktree-reap.mjs +214 -0
  342. package/scripts/worktree.mjs +396 -0
  343. package/scripts/worldclaw/capture-front.sh +28 -0
  344. package/scripts/worldclaw/design-template.md +62 -0
  345. package/scripts/worldclaw/spec-map.py +92 -0
  346. package/scripts/worldclaw/spec.ts +96 -0
  347. package/skills/wildshard/SKILL.md +50 -0
  348. package/skills/wildshard-goldens/SKILL.md +54 -0
  349. package/skills/wildshard-mockup-to-model/SKILL.md +56 -0
  350. package/skills/wildshard-upgrade/SKILL.md +47 -0
  351. package/src/.oxfmtrc.json +50 -0
  352. package/src/.oxlintrc.json +173 -0
  353. package/src/cli/account/account.ts +199 -0
  354. package/src/cli/account/command.ts +193 -0
  355. package/src/cli/account/key.ts +154 -0
  356. package/src/cli/args.ts +97 -0
  357. package/src/cli/audio/audio.ts +39 -0
  358. package/src/cli/bin.mjs +8 -0
  359. package/src/cli/delete/delete.ts +258 -0
  360. package/src/cli/help.ts +204 -0
  361. package/src/cli/hero/adopt.ts +103 -0
  362. package/src/cli/hero/hero.ts +112 -0
  363. package/src/cli/hero/stamp.ts +298 -0
  364. package/src/cli/main.ts +291 -0
  365. package/src/cli/report.ts +20 -0
  366. package/src/cli/shardfile/command.ts +49 -0
  367. package/src/cli/shardfile/shardfile.ts +192 -0
  368. package/src/cli/upload/api.ts +246 -0
  369. package/src/cli/upload/compress.ts +55 -0
  370. package/src/cli/upload/hero.ts +62 -0
  371. package/src/cli/upload/placement.ts +115 -0
  372. package/src/cli/upload/provenance.ts +192 -0
  373. package/src/cli/upload/signature.ts +30 -0
  374. package/src/cli/upload/upload.ts +269 -0
  375. package/src/cli/upload/validate.ts +74 -0
  376. package/src/cli/upload/wire.ts +147 -0
  377. package/src/cli/version.ts +63 -0
  378. package/src/commons/bake/portableMath.ts +187 -0
  379. package/src/commons/catalogue.ts +10 -0
  380. package/src/commons/courseProgram.ts +32 -0
  381. package/src/commons/practiceCourse.ts +16 -0
  382. package/src/commons/scripts/abi.as +14 -0
  383. package/src/commons/scripts/bridge.as +14 -0
  384. package/src/commons/scripts/course.as +63 -0
  385. package/src/scripts/ask-new.sh +29 -0
  386. package/src/scripts/asks.mjs +141 -0
  387. package/src/scripts/herdr-prompt.sh +34 -0
  388. package/src/scripts/herdr-question-open.sh +67 -0
  389. package/src/scripts/md-wrap.mjs +229 -0
  390. package/src/server/app.ts +19 -0
  391. package/src/server/serve.ts +49 -0
  392. package/src/sharddev/admission.ts +7 -0
  393. package/src/sharddev/agentFiles.ts +127 -0
  394. package/src/sharddev/arenaView.ts +15 -0
  395. package/src/sharddev/as/groupBankV2.ts +36 -0
  396. package/src/sharddev/as/groupStepV2.ts +13 -0
  397. package/src/sharddev/as/ws.ts +30 -0
  398. package/src/sharddev/as/wsV2.ts +180 -0
  399. package/src/sharddev/assemblyscriptCompiler.d.mts +5 -0
  400. package/src/sharddev/assemblyscriptCompiler.mjs +14 -0
  401. package/src/sharddev/assetHandle.ts +84 -0
  402. package/src/sharddev/assetOwner.ts +70 -0
  403. package/src/sharddev/assetScope.ts +30 -0
  404. package/src/sharddev/assets.ts +21 -0
  405. package/src/sharddev/audio.ts +9 -0
  406. package/src/sharddev/audioEncode.ts +211 -0
  407. package/src/sharddev/author.ts +3 -0
  408. package/src/sharddev/authorError.ts +28 -0
  409. package/src/sharddev/authorManifest.ts +39 -0
  410. package/src/sharddev/bake/annulus.ts +19 -0
  411. package/src/sharddev/bake/assemblyscriptMemo.ts +76 -0
  412. package/src/sharddev/bake/assemblyscriptMemoPort.ts +4 -0
  413. package/src/sharddev/bake/authoredWorld.ts +201 -0
  414. package/src/sharddev/bake/basisEncoder.ts +95 -0
  415. package/src/sharddev/bake/basisGlb.ts +85 -0
  416. package/src/sharddev/bake/basisTool.ts +74 -0
  417. package/src/sharddev/bake/basisToolInputs.ts +476 -0
  418. package/src/sharddev/bake/byteCodec.ts +33 -0
  419. package/src/sharddev/bake/canvasAtlas.ts +406 -0
  420. package/src/sharddev/bake/coarseCopy.ts +59 -0
  421. package/src/sharddev/bake/colliders.ts +87 -0
  422. package/src/sharddev/bake/compactGlb.ts +224 -0
  423. package/src/sharddev/bake/compileScript.ts +119 -0
  424. package/src/sharddev/bake/compileScriptV2.ts +75 -0
  425. package/src/sharddev/bake/contactRows.ts +84 -0
  426. package/src/sharddev/bake/creaturePlacement.ts +117 -0
  427. package/src/sharddev/bake/export.ts +67 -0
  428. package/src/sharddev/bake/facetedGeometry.ts +379 -0
  429. package/src/sharddev/bake/farImpostor.ts +120 -0
  430. package/src/sharddev/bake/forest.ts +100 -0
  431. package/src/sharddev/bake/format-hook.mjs +2 -0
  432. package/src/sharddev/bake/generatorGlb.ts +23 -0
  433. package/src/sharddev/bake/geometryBounds.ts +77 -0
  434. package/src/sharddev/bake/geometryError.ts +48 -0
  435. package/src/sharddev/bake/glb.ts +355 -0
  436. package/src/sharddev/bake/glbCompression.ts +143 -0
  437. package/src/sharddev/bake/gltfSource.ts +59 -0
  438. package/src/sharddev/bake/groundMap.ts +142 -0
  439. package/src/sharddev/bake/image.ts +20 -0
  440. package/src/sharddev/bake/isleMap.ts +64 -0
  441. package/src/sharddev/bake/json.mjs +84 -0
  442. package/src/sharddev/bake/keyedSky.ts +47 -0
  443. package/src/sharddev/bake/keyedSkyMemo.ts +39 -0
  444. package/src/sharddev/bake/kinds.ts +137 -0
  445. package/src/sharddev/bake/lightSources.ts +31 -0
  446. package/src/sharddev/bake/mapAssembly.ts +84 -0
  447. package/src/sharddev/bake/mapRaster.ts +173 -0
  448. package/src/sharddev/bake/mapRest.ts +57 -0
  449. package/src/sharddev/bake/mapScenes.ts +234 -0
  450. package/src/sharddev/bake/materialGraph.ts +32 -0
  451. package/src/sharddev/bake/meadow.ts +27 -0
  452. package/src/sharddev/bake/meshoptChoiceMemo.ts +34 -0
  453. package/src/sharddev/bake/nativeInteractionFacts.ts +5 -0
  454. package/src/sharddev/bake/nativeLattice.ts +178 -0
  455. package/src/sharddev/bake/nativeRaster.ts +106 -0
  456. package/src/sharddev/bake/nativeTerrainField.ts +11 -0
  457. package/src/sharddev/bake/navigation-json.mjs +38 -0
  458. package/src/sharddev/bake/navigation.ts +113 -0
  459. package/src/sharddev/bake/navigationAsset.ts +18 -0
  460. package/src/sharddev/bake/nearPlaceholder.ts +206 -0
  461. package/src/sharddev/bake/normalizeRig.ts +80 -0
  462. package/src/sharddev/bake/phoneAstc.ts +93 -0
  463. package/src/sharddev/bake/placeholders.ts +581 -0
  464. package/src/sharddev/bake/placement.ts +80 -0
  465. package/src/sharddev/bake/portableBytes.ts +18 -0
  466. package/src/sharddev/bake/portableBytesMemo.ts +50 -0
  467. package/src/sharddev/bake/practiceCourse.ts +49 -0
  468. package/src/sharddev/bake/primitives.ts +96 -0
  469. package/src/sharddev/bake/props.ts +443 -0
  470. package/src/sharddev/bake/questPlacement.ts +98 -0
  471. package/src/sharddev/bake/rawTexture.ts +26 -0
  472. package/src/sharddev/bake/riderArms.ts +97 -0
  473. package/src/sharddev/bake/rig.ts +95 -0
  474. package/src/sharddev/bake/riggedHullRecipes.ts +40 -0
  475. package/src/sharddev/bake/signPlacements.ts +25 -0
  476. package/src/sharddev/bake/simplifier.ts +52 -0
  477. package/src/sharddev/bake/skinned.ts +312 -0
  478. package/src/sharddev/bake/slabChunks.ts +149 -0
  479. package/src/sharddev/bake/slabs.ts +263 -0
  480. package/src/sharddev/bake/source-loader.mjs +55 -0
  481. package/src/sharddev/bake/sourceMetadata.ts +54 -0
  482. package/src/sharddev/bake/species.ts +368 -0
  483. package/src/sharddev/bake/specimenCatalogue.ts +47 -0
  484. package/src/sharddev/bake/splatGround.ts +141 -0
  485. package/src/sharddev/bake/staticMaterials.ts +171 -0
  486. package/src/sharddev/bake/terrain.ts +195 -0
  487. package/src/sharddev/bake/texture.ts +33 -0
  488. package/src/sharddev/bake/textureWasm.ts +81 -0
  489. package/src/sharddev/bake/tileEncoder.ts +11 -0
  490. package/src/sharddev/bake/tileGrid.ts +62 -0
  491. package/src/sharddev/bake/v2Finite.ts +160 -0
  492. package/src/sharddev/bake/v2Fuel.ts +71 -0
  493. package/src/sharddev/bake/wholePartition.ts +74 -0
  494. package/src/sharddev/bake/wholePieceJoin.ts +147 -0
  495. package/src/sharddev/bake/world.ts +173 -0
  496. package/src/sharddev/bake/worldCollision.ts +128 -0
  497. package/src/sharddev/bake/worldGeometry.ts +237 -0
  498. package/src/sharddev/bake/worldGlb.ts +123 -0
  499. package/src/sharddev/bake/worldImage.ts +12 -0
  500. package/src/sharddev/bake/worldLod.ts +128 -0
  501. package/src/sharddev/bake/worldRows.ts +102 -0
  502. package/src/sharddev/bake/worldTextureMemo.ts +63 -0
  503. package/src/sharddev/bake/zstdBytesMemo.ts +52 -0
  504. package/src/sharddev/bake.ts +193 -0
  505. package/src/sharddev/bakePublication.ts +31 -0
  506. package/src/sharddev/behaviourSource.ts +94 -0
  507. package/src/sharddev/bin/wildshard.mjs +7 -0
  508. package/src/sharddev/blobBytes.ts +65 -0
  509. package/src/sharddev/blobs.ts +138 -0
  510. package/src/sharddev/bootInventory.ts +129 -0
  511. package/src/sharddev/bossProfiles.ts +18 -0
  512. package/src/sharddev/buildBehaviour.ts +77 -0
  513. package/src/sharddev/buildCacheMetrics.ts +17 -0
  514. package/src/sharddev/buildDecisionScripts.ts +122 -0
  515. package/src/sharddev/check.ts +118 -0
  516. package/src/sharddev/checkProject.ts +127 -0
  517. package/src/sharddev/cli.ts +200 -0
  518. package/src/sharddev/clientChannels.ts +169 -0
  519. package/src/sharddev/clientScripts.ts +10 -0
  520. package/src/sharddev/commons.ts +77 -0
  521. package/src/sharddev/commonsCosts.ts +11 -0
  522. package/src/sharddev/compileMovers.ts +11 -0
  523. package/src/sharddev/configBoundary.ts +6 -0
  524. package/src/sharddev/cookInput.ts +40 -0
  525. package/src/sharddev/crowds.ts +6 -0
  526. package/src/sharddev/decisionBindingMap.ts +11 -0
  527. package/src/sharddev/decisionScriptBindings.ts +117 -0
  528. package/src/sharddev/decisionScripts.ts +28 -0
  529. package/src/sharddev/decisionSource.ts +51 -0
  530. package/src/sharddev/dev.ts +113 -0
  531. package/src/sharddev/director.ts +26 -0
  532. package/src/sharddev/directorAbi.ts +77 -0
  533. package/src/sharddev/discoveryDocument.ts +97 -0
  534. package/src/sharddev/draft.ts +11 -0
  535. package/src/sharddev/eliteEntryRows.ts +29 -0
  536. package/src/sharddev/entries.ts +76 -0
  537. package/src/sharddev/entryReads.ts +73 -0
  538. package/src/sharddev/executeBundle.ts +55 -0
  539. package/src/sharddev/finds.ts +5 -0
  540. package/src/sharddev/formatJsonSchema.ts +3 -0
  541. package/src/sharddev/generationCache.ts +257 -0
  542. package/src/sharddev/generationRecipe.ts +94 -0
  543. package/src/sharddev/handwritten.ts +110 -0
  544. package/src/sharddev/immutable.ts +14 -0
  545. package/src/sharddev/interactions.ts +38 -0
  546. package/src/sharddev/kit/bakedGeometry.ts +16 -0
  547. package/src/sharddev/kit/geometryPack.ts +110 -0
  548. package/src/sharddev/ledger.ts +13 -0
  549. package/src/sharddev/looks/tileField.ts +67 -0
  550. package/src/sharddev/materialGraphFiles.ts +57 -0
  551. package/src/sharddev/materials.ts +574 -0
  552. package/src/sharddev/measure.ts +18 -0
  553. package/src/sharddev/modes.ts +115 -0
  554. package/src/sharddev/moverPrograms.ts +213 -0
  555. package/src/sharddev/movers.ts +75 -0
  556. package/src/sharddev/nativePopulationRows.ts +46 -0
  557. package/src/sharddev/newProject.ts +226 -0
  558. package/src/sharddev/noise.ts +54 -0
  559. package/src/sharddev/outputProduct.ts +188 -0
  560. package/src/sharddev/outputRuntime.ts +66 -0
  561. package/src/sharddev/performancePolicy.ts +29 -0
  562. package/src/sharddev/phasedBoss.ts +34 -0
  563. package/src/sharddev/physics.ts +194 -0
  564. package/src/sharddev/platformSections.ts +42 -0
  565. package/src/sharddev/plumbing.ts +8 -0
  566. package/src/sharddev/productOutput.ts +128 -0
  567. package/src/sharddev/project.ts +337 -0
  568. package/src/sharddev/projectCompilerIdentity.ts +94 -0
  569. package/src/sharddev/projectDecisions.ts +66 -0
  570. package/src/sharddev/projectEntryProof.ts +32 -0
  571. package/src/sharddev/projectGeneration.ts +219 -0
  572. package/src/sharddev/projectInputFiles.ts +47 -0
  573. package/src/sharddev/projectManifest.ts +108 -0
  574. package/src/sharddev/projectMap.ts +35 -0
  575. package/src/sharddev/projectOutput.ts +242 -0
  576. package/src/sharddev/projectPolicy.ts +17 -0
  577. package/src/sharddev/projectSections.ts +27 -0
  578. package/src/sharddev/questGraph.ts +25 -0
  579. package/src/sharddev/quests.ts +65 -0
  580. package/src/sharddev/random.ts +61 -0
  581. package/src/sharddev/refusals.ts +304 -0
  582. package/src/sharddev/reportCard.ts +13 -0
  583. package/src/sharddev/returnProjectionV2.ts +81 -0
  584. package/src/sharddev/rows.ts +192 -0
  585. package/src/sharddev/runtimeImports.ts +38 -0
  586. package/src/sharddev/runtimeMirrors.ts +39 -0
  587. package/src/sharddev/runtimePerformance.ts +38 -0
  588. package/src/sharddev/scene.ts +321 -0
  589. package/src/sharddev/sceneAnimation.ts +54 -0
  590. package/src/sharddev/sceneAudio.ts +64 -0
  591. package/src/sharddev/sceneDeclarations.ts +100 -0
  592. package/src/sharddev/sceneGraph.ts +139 -0
  593. package/src/sharddev/sceneTransform.ts +12 -0
  594. package/src/sharddev/schemaValidation.ts +61 -0
  595. package/src/sharddev/sections.ts +47 -0
  596. package/src/sharddev/shardSource.ts +59 -0
  597. package/src/sharddev/sourceReader.ts +26 -0
  598. package/src/sharddev/spawns.ts +38 -0
  599. package/src/sharddev/species/clips.ts +24 -0
  600. package/src/sharddev/species.ts +29 -0
  601. package/src/sharddev/speciesBrains.ts +19 -0
  602. package/src/sharddev/synth.ts +66 -0
  603. package/src/sharddev/test/compileDualScriptV2.ts +71 -0
  604. package/src/sharddev/test/compileSimV2.ts +21 -0
  605. package/src/sharddev/test/diskScriptScenario.ts +86 -0
  606. package/src/sharddev/test/scriptScenario.ts +249 -0
  607. package/src/sharddev/test/scriptSource.ts +12 -0
  608. package/src/sharddev/version.ts +4 -0
  609. package/src/sharddev/weapons/bowProfile.ts +20 -0
  610. package/src/sharddev/weapons/firearmRows.ts +11 -0
  611. package/src/sharddev/weapons/meleeProfile.ts +71 -0
  612. package/src/sharddev/weapons/thrownProfile.ts +10 -0
  613. package/src/sharddev/worldScenes.ts +308 -0
  614. package/src/sharddev/worldSource.ts +82 -0
  615. package/src/shards/_template/README.md +78 -0
  616. package/src/shards/_template/assets/2bf489fdb15f1734ddb4c4f32d500ec6da85c765ec7a4eb28dc6781160e7ec8c +0 -0
  617. package/src/shards/_template/assets/97ec4d8f75f5fa6239ee919444d6dc19fd35896bb305930c1f050ac6e0e0e6a6 +1 -0
  618. package/src/shards/_template/assets/a6a587a31327f936b1b04c05ade818c73fc8964260918662db43539465e27586 +0 -0
  619. package/src/shards/_template/assets/b4fbde0422e125b498c3dc8b9a5cc2516c8598f09e9d0e5f6b639b32f98179e6 +0 -0
  620. package/src/shards/_template/assets/bfa4dfc9c18979f904557ee8deab0058b8a399be10266f5fb1578b403f482fd4 +1 -0
  621. package/src/shards/_template/assets/ef3b7ff4fd22715771cb7d68a3977a903c5e7c3dc293542687d04b3ef3ace2cb +0 -0
  622. package/src/shards/_template/assets/f2db05998615ce1cb79ea96be32c168842eb6a2b34ec01feb86d36404603ee54 +0 -0
  623. package/src/shards/_template/assets/fef98ebb7fce6f66b26e78ac699e5c90f9bdcfaf8cabeb2b58125347eea8b4ab +0 -0
  624. package/src/shards/_template/behaviour/boss.as +39 -0
  625. package/src/shards/_template/behaviour/door.as +32 -0
  626. package/src/shards/_template/behaviour/hooks.json +129 -0
  627. package/src/shards/_template/behaviour/idle.as +75 -0
  628. package/src/shards/_template/behaviour/items.as +22 -0
  629. package/src/shards/_template/card/landscape.jpg +0 -0
  630. package/src/shards/_template/card/portrait.jpg +0 -0
  631. package/src/shards/_template/card/thumb.jpg +0 -0
  632. package/src/shards/_template/data/audio.json +45 -0
  633. package/src/shards/_template/data/bossDecision.json +83 -0
  634. package/src/shards/_template/data/budgets.json +70 -0
  635. package/src/shards/_template/data/card.json +281 -0
  636. package/src/shards/_template/data/clientScripts.json +987 -0
  637. package/src/shards/_template/data/creatures.json +65 -0
  638. package/src/shards/_template/data/director.json +39 -0
  639. package/src/shards/_template/data/encounters.json +96 -0
  640. package/src/shards/_template/data/items.json +172 -0
  641. package/src/shards/_template/data/layout.json +66 -0
  642. package/src/shards/_template/data/ledger.json +32 -0
  643. package/src/shards/_template/data/look.json +521 -0
  644. package/src/shards/_template/data/map.json +64 -0
  645. package/src/shards/_template/data/moves.json +16 -0
  646. package/src/shards/_template/data/placeholder.json +8 -0
  647. package/src/shards/_template/data/plumbing.json +32 -0
  648. package/src/shards/_template/data/quests.json +223 -0
  649. package/src/shards/_template/data/rows.json +423 -0
  650. package/src/shards/_template/data/skins.json +66 -0
  651. package/src/shards/_template/data/spawn.json +6 -0
  652. package/src/shards/_template/data/targets.json +150 -0
  653. package/src/shards/_template/data/text.json +12 -0
  654. package/src/shards/_template/data/ui.json +33 -0
  655. package/src/shards/_template/data/water.json +13 -0
  656. package/src/shards/_template/generators/behaviour.ts +34 -0
  657. package/src/shards/_template/generators/boss.ts +29 -0
  658. package/src/shards/_template/generators/buildOptions.ts +2 -0
  659. package/src/shards/_template/generators/cell.ts +224 -0
  660. package/src/shards/_template/generators/districts.ts +215 -0
  661. package/src/shards/_template/generators/farLook.ts +15 -0
  662. package/src/shards/_template/generators/generate.ts +27 -0
  663. package/src/shards/_template/generators/ground.ts +15 -0
  664. package/src/shards/_template/generators/kit.ts +69 -0
  665. package/src/shards/_template/generators/landscape.ts +59 -0
  666. package/src/shards/_template/generators/landscapeNoise.ts +62 -0
  667. package/src/shards/_template/generators/mapInputs.ts +10 -0
  668. package/src/shards/_template/generators/product.ts +100 -0
  669. package/src/shards/_template/generators/productOutput.ts +18 -0
  670. package/src/shards/_template/generators/props.ts +9 -0
  671. package/src/shards/_template/generators/templatePropsSource.ts +58 -0
  672. package/src/shards/_template/generators/terrain.ts +17 -0
  673. package/src/shards/_template/generators/world.ts +630 -0
  674. package/src/shards/_template/hero.json +10 -0
  675. package/src/shards/_template/look/entry-reads.json +20 -0
  676. package/src/shards/_template/manifest.json +281 -0
  677. package/src/shards/_template/shard.config.ts +10 -0
  678. package/src/shared/health.ts +10 -0
  679. package/src/tools/build-web.ts +59 -0
  680. package/src/tsconfig.json +30 -0
  681. package/src/web/app.tsx +53 -0
  682. package/src/web/index.html +12 -0
  683. package/src/web/main.tsx +10 -0
  684. package/src/web/tsconfig.json +13 -0
  685. package/tsconfig.author.json +23 -0
  686. package/tsconfig.commons.json +21 -0
  687. package/tsconfig.json +47 -0
  688. package/tsconfig.sharddev.json +20 -0
@@ -0,0 +1,95 @@
1
+ #!/usr/bin/env node
2
+ // Build author tools against the same public contract as the game; pnpm pack uses these portable JS modules.
3
+ import { build } from 'vite';
4
+ import { join, relative, resolve } from 'node:path';
5
+ import { cpSync, existsSync, readFileSync, readdirSync, rmSync, writeFileSync, mkdirSync } from 'node:fs';
6
+ import { execFileSync } from 'node:child_process';
7
+ import { rapierAlias } from '@wildshard/engine/vite/rapier.ts';
8
+ import { assertHeavyLease } from '@wildshard/engine/scripts/heavy-lane-lease.mjs';
9
+ import { shardfileValidationRevision } from '@wildshard/engine/scripts/shardfile-validation-revision.mjs';
10
+ import { SDK_EXTERNALS } from './sdk-externals.mjs';
11
+
12
+ // This package also compiles the two real app clients; acquire the build lane before generation or type emission.
13
+ assertHeavyLease('build');
14
+ const root = resolve(import.meta.dirname, '..');
15
+ process.chdir(root);
16
+ execFileSync('node', ['scripts/gen.mjs', '--inputs-only'], { cwd: root, stdio: 'inherit' });
17
+ // P1-F4: the package is @wildshard/sharddev; the host stays @wildshard/sdk until P3 and ships bundled inside it.
18
+ const layers = ['sharddev', 'sdk'].map(layer => ({ layer, manifest: JSON.parse(readFileSync(resolve(root, `src/${layer}/package.json`), 'utf8')) }));
19
+ const modules = layers.flatMap(({ layer, manifest }) => Object.entries(manifest.exports).map(([specifier, target]) => {
20
+ if (!specifier.startsWith('./') || typeof target !== 'string' || !target.endsWith('.ts')) throw new Error('SDK workspace exports must name defining TypeScript modules');
21
+ return { layer, name: specifier.slice(2), source: resolve(root, `src/${layer}`, target), declaration: target.slice(2, -3) };
22
+ }));
23
+ await build({ configFile: false, publicDir: false, resolve: { alias: rapierAlias }, logLevel: 'warn', define: { __SHARDFILE_VALIDATOR__: JSON.stringify(shardfileValidationRevision(root)) }, build: { outDir: resolve(root, 'src/sharddev', 'dist') /* build output, git-ignored: check-paths only checks committed paths */, emptyOutDir: true, minify: false, lib: {
24
+ entry: Object.fromEntries([...modules.map(({ name, source }) => [name, source]), ['cli', resolve(root, 'src/sharddev/cli.ts')], ['headlessWorker', resolve(root, 'src/sdk/bake/headlessWorker.ts')]]), formats: ['es'], fileName: (_format, name) => `${name}.js`,
25
+ }, rolldownOptions: { platform: 'node', external: SDK_EXTERNALS } } });
26
+
27
+ // Ship declarations without requiring the repository's internal workspace packages.
28
+ execFileSync('pnpm', ['exec', 'tsc', '-b', '--force', 'tsconfig.layers.json'], { cwd: root, stdio: 'inherit' });
29
+ const seen = new Set();
30
+ // SF79 publishes some modules under an older specifier (`./shardfile/moverRuntime` → `./plugin/mover.ts`): a declaration
31
+ // is emitted at, and points to, the module its layer's exports name, never a path built from the specifier.
32
+ const layerExports = new Map();
33
+ function defining(layer, module) {
34
+ if (!layerExports.has(layer)) layerExports.set(layer, JSON.parse(readFileSync(resolve(root, `src/${layer}/package.json`), 'utf8')).exports ?? {});
35
+ const target = layerExports.get(layer)[`./${module}`];
36
+ return typeof target === 'string' && target.startsWith('./') && target.endsWith('.ts') && !target.endsWith('.d.ts') ? target.slice(2, -3) : module;
37
+ }
38
+ function declaration(layer, module) {
39
+ const key = `${layer}/${module}`;
40
+ if (seen.has(key)) return;
41
+ seen.add(key);
42
+ const source = resolve(root, `.tsc-layers/${layer}/src/${layer}/${module}.d.ts`);
43
+ const output = resolve(root, `src/sharddev/dist/types/${key}.d.ts`);
44
+ // Ambient defining leaves are compiler inputs, so tsc does not emit a second copy of them.
45
+ let text = readFileSync(existsSync(source) ? source : resolve(root, `src/${layer}/${module}.d.ts`), 'utf8');
46
+ // Relative import declarations are illegal inside ambient modules; the equivalent type query remains portable.
47
+ if (key === 'engine/client/types/n8ao') text = text.replace("import type { Renderer } from '@wildshard/engine/render/renderer';", "type Renderer = import('@wildshard/engine/render/renderer').Renderer;");
48
+ // @wildshard/format stays a package import: the SDK depends on the shardfile repo's own files.
49
+ text = text.replaceAll(/(['"])@wildshard\/(engine|game|sdk|sharddev)\/([^'"]+)\1/gu, (_match, quote, dependencyLayer, specifier) => {
50
+ const dependency = defining(dependencyLayer, specifier);
51
+ declaration(dependencyLayer, dependency);
52
+ const from = resolve(root, `src/sharddev/dist/types/${layer}`, module, '..');
53
+ const to = resolve(root, `src/sharddev/dist/types/${dependencyLayer}/${dependency}`);
54
+ // Public declarations may only refer to packaged files or third-party dependencies.
55
+ return `${quote}${relative(from, to).replaceAll('\\', '/')}${quote}`;
56
+ });
57
+ // Relative declaration imports remain in the same copied module tree.
58
+ // Doc comments may quote example imports (game/client/shard/manifest.ts: `import('./look/render')`); only code is scanned.
59
+ const code = text.replaceAll(/\/\*[\s\S]*?\*\//gu, '').replaceAll(/^\s*\/\/.*$/gmu, '');
60
+ for (const match of code.matchAll(/(?:from\s*|import\s*\()(['"])(\.[^'"]+)\1/gu)) {
61
+ const dependency = relative(resolve(root, `src/${layer}`), resolve(root, `src/${layer}`, module, '..', match[2]));
62
+ if (!dependency.startsWith('..')) declaration(layer, dependency.replace(/\.js$/u, ''));
63
+ }
64
+ if (/from\s*['"]n8ao['"]/u.test(text)) {
65
+ declaration('engine', 'types/n8ao');
66
+ // declaration() above generates this packaged output; only src/sdk is a committed input path.
67
+ const vendor = relative(resolve(output, '..'), resolve(root, 'src/sharddev', 'dist', 'types/engine/types/n8ao.d.ts')).replaceAll('\\', '/');
68
+ text = `/// <reference path="${vendor}" />\n${text}`;
69
+ }
70
+ mkdirSync(resolve(output, '..'), { recursive: true }); writeFileSync(output, text);
71
+ }
72
+ for (const module of modules) declaration(module.layer, module.declaration);
73
+
74
+ // Both clients use the normal Game bundle. Author dev is a separate compiled mode, never enabled by requests. They build
75
+ // through the app build script, as every app build does (its generators, tables, boot bank and worker, D24), with the
76
+ // repo's config minus the public/ copy; the hidden source maps its checks read do not ship.
77
+ for (const [mode, folder] of [['production', 'client'], ['devserver', 'client-devserver']]) {
78
+ const outDir = resolve(root, `src/sharddev/dist/${folder}`), config = resolve(root, 'tmp', `sdk-${folder}.vite.mjs`);
79
+ mkdirSync(resolve(root, 'tmp'), { recursive: true });
80
+ writeFileSync(config, `import { mergeConfig } from 'vite';\nimport base from ${JSON.stringify(resolve(root, 'vite.config.ts'))};\n`
81
+ + `export default async env => mergeConfig(typeof base === 'function' ? await base(env) : base, { build: { copyPublicDir: false } });\n`);
82
+ execFileSync(process.execPath, ['scripts/build-app.mjs', '--mode', mode, '--config', config, '--outDir', outDir, '--emptyOutDir'], { cwd: root, stdio: 'inherit' });
83
+ rmSync(config, { force: true });
84
+ for (const entry of readdirSync(outDir, { recursive: true, withFileTypes: true })) if (entry.isFile() && entry.name.endsWith('.map')) rmSync(join(entry.parentPath, entry.name));
85
+ for (const entry of ['fonts', 'favicon.png', 'apple-touch-icon.png', 'manifest.webmanifest', 'basis/r186', 'assets/physics', 'assets/sfx/best', 'assets/music/piano', 'assets/music/orchestral', 'assets/music/folk']) cpSync(resolve(root, 'public', entry), resolve(root, `src/sharddev/dist/${folder}`, entry), { recursive: true });
86
+ }
87
+
88
+ // Ship retained readable author inputs, not one-time baked outputs or workspace symlinks.
89
+ const template = resolve(root, 'src/sharddev', 'dist', 'author-template');
90
+ cpSync(resolve(root, 'scripts/docs/author-project'), template, { recursive: true });
91
+ // The host ships bundled in this package until P3, so a packed project names one package.
92
+ for (const name of readdirSync(template, { recursive: true, encoding: 'utf8' })) {
93
+ const file = resolve(template, name);
94
+ if (/\.(?:ts|mjs)$/u.test(name)) writeFileSync(file, readFileSync(file, 'utf8').replaceAll('@wildshard/engine/host/', '@wildshard/sharddev/'));
95
+ }
@@ -0,0 +1,7 @@
1
+ /** Build every live first-party product with its charged immutable map, enforcing recorded raster and world freshness.
2
+ * `reuse` keeps a product whose content key is unchanged; `only` builds just those shards.
3
+ * `copyRuntime` proves selected runtime copies without changing discovery. */
4
+ export function buildShardfiles(root: string, options?: { strict?: boolean; build?: (args: string[]) => Promise<void>; reuse?: boolean; only?: string[]; /** Explicit generation phase scope, also enforced in strict builds. */ scope?: string[]; copyRuntime?: boolean | 'closed'; onFailure?:(slug:string,error:unknown)=>void }): Promise<number>;
5
+
6
+ /** Read CI's built output or a content-key-matching local product; never runs a producer or build. */
7
+ export function readBuiltShardfile(root: string, name: string, options?: { cacheRoot?: string; env?: NodeJS.ProcessEnv }): string;
@@ -0,0 +1,206 @@
1
+ #!/usr/bin/env node
2
+ // Every source project is built before Vite copies public/. Legacy shards without a config remain on their runtime.
3
+ // SF66 (G247): a shard whose baked map (look/map.baked.json) no longer matches its world is refused in CI and on Vercel,
4
+ // so a stale map never deploys; a local build only warns, since the rebake itself needs a served build of that world
5
+ // (node scripts/bake-maps.mjs --url=<scripts/serve-build.sh --head> --shards=<slug>). test/baked-maps.test.ts is the gate's check.
6
+ import { createBuildCacheCounters, observeBuildCache, formatBuildCacheReport } from '@wildshard/engine/scripts/build-cache-report.mjs';
7
+ import { existsSync, readFileSync, readdirSync, rmSync } from 'node:fs';
8
+ import { resolve } from 'node:path';
9
+ import { pathToFileURL } from 'node:url';
10
+ import { runWildshard } from './wildshard.mjs';
11
+ import { mapInputHashes, mapTilesHash, verifyMapPixels } from '@wildshard/engine/scripts/map-hash.mjs';
12
+ import { borrowShardfileEntry, readBuildKey, reuseOrBuild, shardfileCacheRoot, shardfileKey, treeHashes } from '@wildshard/engine/scripts/shardfile-cache.mjs';
13
+ import { randomBytes } from 'node:crypto';
14
+ import { InputHashMemo } from '@wildshard/engine/scripts/bake-input-hashes.mjs';
15
+ import { productInputKey, productToolchainKey, matchingProductInputKey, publishProductInputs } from '@wildshard/engine/scripts/shardfile-inputs.mjs';
16
+ import { quietCli } from '@wildshard/engine/scripts/quiet-cli.mjs';
17
+ import { outputManifest, shardOutputs } from '@wildshard/engine/scripts/shard-outputs.mjs';
18
+ import { usesProgramDiscovery } from '@wildshard/engine/scripts/program-discovery.mjs';
19
+ import { shardfileValidationRevision } from '@wildshard/engine/scripts/shardfile-validation-revision.mjs';
20
+ import { runShardBuild, runShardBuildPool } from './shard-build-pool.mjs';
21
+ import { orderProductBuilds, readProductBuildTimes, recordProductBuildTimes } from '@wildshard/engine/scripts/product-build-times.mjs';
22
+ import { prepareProductBuildTools } from './product-build-tools.mjs';
23
+ import { checkTileBake } from '@wildshard/engine/scripts/tile-bakes.mjs';
24
+ import { reportTileBake } from '@wildshard/engine/scripts/tile-bake-report.mjs';
25
+ import { runtimeCopyIssues, productMapInput, publishProductMap, productFlags, productRecipe, retainProductInputs, readBuiltShardfile as selectBuiltShardfile } from '@wildshard/engine/scripts/built-product.mjs';
26
+ import { isWorktreePath } from './worktree-ignore.mjs';
27
+
28
+ /** Read CI's output or a matching immutable product without invoking the builder.
29
+ * @param {string} root @param {string} name
30
+ * @param {{cacheRoot?:string,env?:NodeJS.ProcessEnv}} [options] */
31
+ export function readBuiltShardfile(root, name, options = {}) { return selectBuiltShardfile(root, name, options); }
32
+
33
+ // --reuse (fast proofs: serve-build.sh, `pnpm build:proof`): a shard whose inputs are unchanged keeps its product, from
34
+ // the slot or the shared content-keyed cache (scripts/shardfile-cache.mjs). The plain `pnpm build` (the push gate)
35
+ // rebuilds every shard into a fresh folder. CI may explicitly reuse exact input receipts, then fully validates each hit.
36
+ // --shard=<slug>[,<slug>] builds only those shards: another shard's product stays only while its key still matches,
37
+ // else it is removed, so a one-shard preview never serves a stale product of a changed shard. A product whose discovery
38
+ // is program-bound (scripts/program-discovery.mjs) is always built too: the app build writes its discovery module from
39
+ // that product's current receipt, so it cannot be left stale (unchanged inputs reuse it at once).
40
+ /** Pack every first-party map through the existing charged SDK row; missing maps keep the old no-map build path.
41
+ * @param {string} root @param {{strict?:boolean, build?:typeof runWildshard, reuse?:boolean, only?:string[], scope?:string[], copyRuntime?:boolean|'closed',onFailure?:(slug:string,error:unknown)=>void}} options */
42
+ async function buildShardfilesWork(root, { strict = [process.env.CI, process.env.VERCEL].some(flag => flag !== undefined && flag !== '' && flag !== 'false'), build = runWildshard, reuse = false, only, scope, copyRuntime = 'closed',onFailure } = {}, counters = createBuildCacheCounters()) {
43
+ if(onFailure!==undefined&&strict)throw new Error('Product failure collection is report-only; strict builds must fail');
44
+ if (scope !== undefined && only !== undefined) throw new Error('Product phase scope and CLI only filter cannot be combined');
45
+ const outputRoot = resolve(root, 'out');
46
+ // Discard the retired discovery artifact left by older builds.
47
+ rmSync(resolve(outputRoot, 'catalog.json'), { force: true });
48
+ const projects = resolve(root, 'src/shards');
49
+ let count = 0;
50
+ const stale = [], runtimeReport = [];
51
+ // A folder may emit many products. Its shared source closure and prerequisite
52
+ // generation are one immutable build-phase fact; output stamps/pixels stay
53
+ // product-specific and are still checked for every output below.
54
+ /** @type {Map<string,{file:string,message:string}[]>} */
55
+ const runtimeChecks=new Map();
56
+ /** @type {Map<string,string>} */
57
+ const mapTileHashes=new Map();
58
+ const runtimeIssues = project => {
59
+ let issues = runtimeChecks.get(project);
60
+ if (issues === undefined) { issues = runtimeCopyIssues(root, project); runtimeChecks.set(project, issues); }
61
+ return issues;
62
+ };
63
+ const folders = readdirSync(projects, { withFileTypes: true }).filter(entry => entry.isDirectory() && existsSync(resolve(projects, entry.name, 'shard.config.ts'))).map(entry => entry.name).sort((a, b) => a.localeCompare(b));
64
+ // SF88g: a folder with declared outputs (scripts/shard-outputs.mjs) builds one product per output, each to out/<slug>
65
+ const products = folders.flatMap(folder => (shardOutputs(root, folder) ?? [{ slug: folder }]).map(row => ({ name: row.slug, folder, output: row.slug === folder ? undefined : row.slug })));
66
+ const built = products.map(row => row.name).sort((a, b) => a.localeCompare(b));
67
+ // A product folder no source declares any more (a folder that now emits outputs, a dropped output) never ships stale
68
+ for (const entry of existsSync(outputRoot) ? readdirSync(outputRoot, { withFileTypes: true }) : []) {
69
+ if (entry.isDirectory() && !entry.name.startsWith('.') && !built.includes(entry.name) && existsSync(resolve(outputRoot, entry.name, 'shard.json'))) {
70
+ rmSync(resolve(outputRoot, entry.name), { recursive: true, force: true }); console.info(`wildshard build: ${entry.name} is no longer built here; its folder removed`);
71
+ }
72
+ }
73
+ for (const slug of scope ?? only ?? []) if (!built.includes(slug)) throw new Error(`wildshard build: --shard=${slug} is not an output this repo builds (${built.join(', ')})`);
74
+ const bound = (only === undefined || strict ? [] : products).filter(({ folder, output }) => {
75
+ const manifest = resolve(projects, folder, 'manifest.json');
76
+ if (!existsSync(manifest)) return false;
77
+ const row = output === undefined ? undefined : shardOutputs(root, folder)?.find(entry => entry.slug === output);
78
+ return usesProgramDiscovery(row === undefined ? JSON.parse(readFileSync(manifest, 'utf8')) : outputManifest(root, folder, row));
79
+ }).map(row => row.name).filter(name => only?.includes(name) !== true);
80
+ if (bound.length > 0) console.info(`wildshard build: --shard also keeps the program-bound discovery folders current: ${bound.join(', ')}`);
81
+ const selected = scope ?? (strict || only === undefined ? undefined : [...only, ...bound]);
82
+ if (only !== undefined && strict) console.warn('wildshard build: --shard ignored in CI; building every shard');
83
+ const recorded = build === runWildshard;
84
+ /** @type {Map<string,number>} */
85
+ const buildTimes=new Map();
86
+ /** @type {Map<string,number>} */
87
+ const validationTimes=new Map();
88
+ const ordered=recorded?orderProductBuilds(products,readProductBuildTimes(shardfileCacheRoot())):products;
89
+ // The engine pin's treeHashes skips .worktrees/ only from engine 03d4d79; drop plan worktrees here either way (DS11).
90
+ const files = recorded ? undefined : new Map([...treeHashes(root)].filter(([path]) => !isWorktreePath(path)));
91
+ const inputHashes = new InputHashMemo(root,resolve(root,'.cache/shardfile-input-hashes.json'));
92
+ // The validation receipt every product carries is checked against this revision (vite.config.ts, the ruler). The
93
+ // cached author CLI computes it once per compiler child, so a traced read set may miss its sources: key it directly,
94
+ // or a product reused after the revision moved ships a stale receipt.
95
+ const toolchainOf = () => `${productToolchainKey(root,inputHashes)}:${shardfileValidationRevision(root)}`;
96
+ const toolchain = recorded ? toolchainOf() : '';
97
+ try {
98
+ await runShardBuildPool(ordered, async ({ name, folder, output }, signal) => {
99
+ if (scope !== undefined && !scope.includes(name)) return;
100
+ const buildOne = args => build === runWildshard ? runShardBuild(args, signal, report=>{counters.merge(report);}) : build(args);
101
+ const project = resolve(projects, folder);
102
+ try {
103
+ const started = performance.now();
104
+ const map = productMapInput(project, output), expected = map?.tilesHash ?? null;
105
+ let actual=mapTileHashes.get(project);
106
+ if(actual===undefined){actual=mapTilesHash(project);mapTileHashes.set(project,actual);}
107
+ if (expected !== actual) {
108
+ stale.push(name);
109
+ console.error(`wildshard map inputs: ${JSON.stringify({ shard: name, expected, actual, files: mapInputHashes(project) })}`);
110
+ }
111
+ if (map?.image !== undefined && map.image !== `/assets/${name}/map/top.webp`) throw new Error(`Unexpected baked map path for ${name}`);
112
+ if (map?.image !== undefined) {
113
+ if (map.pixelHash === undefined) throw new Error(`Missing baked map pixel identity for ${name}`);
114
+ await verifyMapPixels(resolve(root, 'public', map.image.slice(1)), map.pixelHash);
115
+ }
116
+ const issues = copyRuntime === 'closed' ? runtimeIssues(project) : [];
117
+ runtimeReport.push({ slug: name, runtime: issues.length > 0 ? 'source' : 'output', issues });
118
+ const flags = productFlags(root, output, map, copyRuntime === true || copyRuntime === 'closed' && issues.length === 0);
119
+ // --no-placeholders (G348): a first-party product keeps its own bytes; its near / far views come from the repo bakes
120
+ // until the grid reads a shardfile's `near`. The CLI's default baked a near row into Signal Dunes' product, whose play
121
+ // stage then never ran (677bd1cf1: "Shardfile requires the normal play stage", the page held at 82 %).
122
+ const destination = resolve(root, 'out', name);
123
+ const { normalized, recipe, receipts } = productRecipe(root, name, flags, toolchain, shardfileCacheRoot());
124
+ if (recorded) borrowShardfileEntry(receipts, true);
125
+ const currentKey = () => recorded ? matchingProductInputKey(root,receipts,recipe,inputHashes) : shardfileKey(files ?? new Map(),name,folders.filter(other=>other!==folder),normalized);
126
+ const key = currentKey();
127
+ if (selected !== undefined && !selected.includes(name)) {
128
+ const here = readBuildKey(destination);
129
+ if (here !== key && existsSync(destination)) { rmSync(destination, { recursive: true, force: true }); console.info(`wildshard build: ${name} skipped (--shard), stale folder removed`); }
130
+ else console.info(`wildshard build: ${name} skipped (--shard)${here === key ? ', folder current' : ''}`);
131
+ return;
132
+ }
133
+ const how = await reuseOrBuild({ slug: name, key:key ?? randomBytes(32).toString('hex'), destination, fresh:!reuse && (strict || only === undefined), build: async out => {
134
+ const receipt=resolve(shardfileCacheRoot(),'.input-traces',`${process.pid}-${randomBytes(8).toString('hex')}.json`);
135
+ try {
136
+ await buildOne(['build',project,out,'--folder-only','--no-placeholders','--format=2',...flags,...(recorded?[`--input-receipt=${receipt}`]:[])]);
137
+ if (recorded && toolchainOf() !== toolchain) throw new Error('Product toolchain changed during build');
138
+ const next = recorded ? productInputKey(root,receipt,recipe,inputHashes) : currentKey();
139
+ if (next === undefined) throw new Error(`Missing complete product input receipt: ${name}`);
140
+ if(recorded) {
141
+ retainProductInputs(root,name,receipt,next,recipe,inputHashes);
142
+ publishProductInputs(receipts,receipt,next);
143
+ }
144
+ return next;
145
+ } finally { if(recorded)rmSync(receipt,{force:true}); }
146
+ } });
147
+ if (recorded && how !== 'built') {
148
+ const retained = readBuildKey(destination);
149
+ retainProductInputs(root,name,resolve(receipts,`${retained}.json`),retained,recipe,inputHashes);
150
+ }
151
+ // Cache transport never substitutes for current strict admission, including
152
+ // file hashes, schemas, budgets and executing the admitted script bytes.
153
+ if (strict && how !== 'built') await buildOne(['validate',destination]);
154
+ const tiles = checkTileBake(root, name, destination);
155
+ reportTileBake(root, name, destination);
156
+ if (map !== undefined && map.image === undefined) await publishProductMap(root, name, destination, map.tilesHash);
157
+ console.info(`tile bake: ${name} ${tiles.l0} L0/${tiles.l1} L1, 16 full 5x5 windows checked, ${Object.keys(tiles.debt).length} existing debt metrics`);
158
+ console.info(`wildshard build: ${name} ${how === 'built' ? 'built' : `reused (${how})`} in ${((performance.now() - started) / 1000).toFixed(1)}s`);
159
+ count++;
160
+ counters.product(how==='built');
161
+ if(how==='built')buildTimes.set(name,performance.now()-started);
162
+ else if(strict)validationTimes.set(name,performance.now()-started);
163
+ } catch(error) {
164
+ counters.failure();
165
+ if(onFailure===undefined)throw error;
166
+ // A previous product cannot vouch for a failed rebuild or grant a census user.
167
+ rmSync(resolve(outputRoot,name),{recursive:true,force:true});
168
+ onFailure(name,error);
169
+ }
170
+ }, recorded ? async () => {
171
+ await prepareProductBuildTools(products.filter(row => selected === undefined || selected.includes(row.name)).map(row => row.name));
172
+ // Keep the compiler receipt independent of modules loaded by generation's
173
+ // parent. Otherwise unrelated table generators become every product's input.
174
+ await runShardBuild(['--prepare-compiler'],new AbortController().signal,report=>{counters.merge(report);});
175
+ } : undefined);
176
+ } finally { inputHashes.flush(); }
177
+ runtimeReport.sort((a,b)=>a.slug.localeCompare(b.slug));
178
+ if (copyRuntime === 'closed') for (const report of runtimeReport) console.info(`runtime copy: ${JSON.stringify(report)}`);
179
+ console.info(`wildshard build: ${count} shard file folder(s)`);
180
+ if (stale.length > 0) {
181
+ const message = `wildshard build: the baked map of ${stale.join(', ')} does not match its world (SF66); rebake: node scripts/bake-maps.mjs --url=<scripts/serve-build.sh --head> --shards=${stale.join(',')}`;
182
+ if (strict) throw new Error(message);
183
+ console.warn(message);
184
+ }
185
+ if(recorded)recordProductBuildTimes(shardfileCacheRoot(),buildTimes,validationTimes);
186
+ return count;
187
+ }
188
+
189
+ /** The phase report is observational: payload bytes, not time saved. Zero
190
+ * lookups means not invoked, including whole-product reuse. All failures and
191
+ * strict admission still belong to the unchanged build path.
192
+ * @param {string} root
193
+ * @param {Parameters<typeof buildShardfilesWork>[1]} [options] */
194
+ export async function buildShardfiles(root,options={}) {
195
+ const counters=createBuildCacheCounters(),stop=observeBuildCache(counters);
196
+ let complete=false;
197
+ try {const result=await buildShardfilesWork(root,options,counters);complete=true;return result;}
198
+ finally {stop();console.info(formatBuildCacheReport(counters.snapshot(complete)));}
199
+ }
200
+
201
+ if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
202
+ quietCli('build-shardfiles');
203
+ const only = process.argv.find(arg => arg.startsWith('--shard='))?.slice('--shard='.length).split(',').filter(Boolean);
204
+ try { await buildShardfiles(process.cwd(), { copyRuntime: process.argv.includes('--copy-runtime') ? true : 'closed', reuse: process.argv.includes('--reuse'), ...(only === undefined ? {} : { only }) }); }
205
+ catch (error) { console.error(error instanceof Error ? error.message : String(error)); process.exitCode = 1; }
206
+ }
@@ -0,0 +1,137 @@
1
+ #!/usr/bin/env node
2
+ // `wildshard hero <shard-dir> --base <served-build-url>`: capture a shard's hero (its SHARD SELECT card) from a served
3
+ // build of this exact candidate, write it over the card files the manifest names, and stamp `hero.json` with the
4
+ // content it shows. `wildshard build` refuses a cut whose stamp no longer matches the content (src/cli/hero/hero.ts).
5
+ // Jake, 2026-11-12 17:14 Cancún: "you have to update the hero images for the templates."
6
+ //
7
+ // Serve the candidate first (engine: `scripts/serve-build.sh --shard <slug>`), and run this from the shard project
8
+ // root. Headless Chromium on the real GPU (Metal), never a visible window. The view is `hero.json`'s `camera`
9
+ // ({ pos: [x,y,z], look: [x,y,z], fov, center }, engine scripts/hero-shots.mjs's view shape) when the shard declares
10
+ // one, else the player's own spawn view. Sizes: thumb 640x360, portrait 804x1626, landscape 1600x900.
11
+ //
12
+ // `wildshard hero <shard-dir> --stamp-existing` captures nothing: it stamps the hero files already there as showing
13
+ // the content now. It exists for a shard repo that gains this check with curated heroes and no stamp. WARNING: use it
14
+ // only when those images match the current content; a wrong stamp hides a stale hero until the next content change.
15
+ import { existsSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
16
+ import { basename, dirname, join, resolve } from 'node:path';
17
+ import { heroSlotFiles, writeHeroStamp } from '../src/cli/hero/stamp.ts';
18
+ import { stampExistingHero } from '../src/cli/hero/adopt.ts';
19
+ import { findShardSource, shardFolderName } from '../src/sharddev/shardSource.ts';
20
+
21
+ const SCALE = 2;
22
+ const VIEWS = { portrait: { width: 402, height: 813 }, landscape: { width: 800, height: 450 }, thumb: { width: 320, height: 180 } };
23
+ const QUALITY = 86;
24
+ const sleep = ms => new Promise(done => { setTimeout(done, ms); });
25
+
26
+ /** A baseline or progressive JPEG's pixel size, from its SOF0 or SOF2 frame header. */
27
+ function jpegSize(bytes) {
28
+ for (let at = 2; at + 9 < bytes.length;) {
29
+ const marker = bytes[at + 1], length = (bytes[at + 2] << 8) | bytes[at + 3];
30
+ if (marker === 0xc0 || marker === 0xc2) return [(bytes[at + 7] << 8) | bytes[at + 8], (bytes[at + 5] << 8) | bytes[at + 6]];
31
+ at += 2 + length;
32
+ }
33
+ throw new Error('No JPEG frame header');
34
+ }
35
+
36
+ /** The name SHARD SELECT shows this shard under: its built product's, else the manifest's. */
37
+ function servedName(shard) {
38
+ const product = resolve(shard, '../../../out', basename(shard), 'shard.json');
39
+ if (existsSync(product)) return JSON.parse(readFileSync(product, 'utf8')).identity.name;
40
+ return String(JSON.parse(readFileSync(join(shard, 'manifest.json'), 'utf8')).name);
41
+ }
42
+
43
+ /** Enter the shard the way a player does: SHARD SELECT, its card, ENTER WORLD (hidden shards are Developer cards). */
44
+ async function enter(page, base, name, log) {
45
+ const url = `${base.replace(/\/+$/u, '')}/?mute=1&sw=0&tier=desktop&nolock=1&perf=0`;
46
+ log(`hero: loading ${url}, card "${name}"`);
47
+ await page.goto(url, { waitUntil: 'load' });
48
+ await page.locator('.ws-main-select').click({ timeout: 120000 });
49
+ await page.locator('.ws-menu-card').first().waitFor({ timeout: 60000 });
50
+ const names = await page.evaluate(() => [...document.querySelectorAll('.ws-menu-card')].map(card => card.querySelector('b')?.textContent?.trim() ?? ''));
51
+ const at = names.indexOf(name);
52
+ if (at < 0) throw new Error(`no SHARD SELECT card named "${name}" on ${base} (cards: ${names.join(', ')}); serve a build that carries this candidate`);
53
+ await page.evaluate(index => document.querySelector(`.ws-menu-dots i[data-i="${index}"]`)?.click(), at);
54
+ await sleep(1000);
55
+ await page.locator('.ws-menu-play').click();
56
+ await page.waitForFunction(() => Boolean(window.__wildshard?.world?.hud?.entered && window.__wildshard?.world?.game) && document.querySelector('.ws-load') === null,
57
+ undefined, { timeout: 240000, polling: 500 });
58
+ if (await page.evaluate(() => window.__wildshard.world.hud.paused)) await page.keyboard.press('Escape');
59
+ }
60
+
61
+ export async function captureHero(shard, base, { name = servedName(shard), log = console.info } = {}) {
62
+ // Loaded here, so --stamp-existing needs no browser or engine to resolve.
63
+ const [{ chromium }, { NAME_ASKED, saveFixture }, { KEYCHAIN_ARGS }] = await Promise.all([
64
+ import('playwright'), import('@wildshard/engine/scripts/debug-settings.mjs'), import('./chromium-keychain.mjs')]);
65
+ const files = await heroSlotFiles(shard);
66
+ const missing = Object.keys(VIEWS).filter(slot => files[slot] === undefined);
67
+ if (missing.length > 0) throw new Error(`${join(shard, 'manifest.json')}: card.${missing.join(', card.')} must name a file in the shard folder (e.g. /src/shards/${shardFolderName(shard)}/card/${missing[0]}.jpg), not a data: url`);
68
+ const stampFile = join(shard, 'hero.json');
69
+ const camera = existsSync(stampFile) ? JSON.parse(readFileSync(stampFile, 'utf8')).camera : undefined;
70
+ const errors = [], shots = {};
71
+ const browser = await chromium.launch({ headless: true, args: [...KEYCHAIN_ARGS, '--mute-audio', '--use-angle=metal', '--ignore-gpu-blocklist'] });
72
+ try {
73
+ const context = await browser.newContext({ viewport: VIEWS.portrait, deviceScaleFactor: SCALE });
74
+ await saveFixture(context, { scope: 'device', key: 'devMode', data: true }); // hidden and experimental shards enter only in developer mode
75
+ await saveFixture(context, { scope: 'global', key: 'gfx', data: { dpr: 'native', aa: 'on' } });
76
+ await saveFixture(context, NAME_ASKED);
77
+ const page = await context.newPage();
78
+ page.on('pageerror', error => errors.push(error.message.slice(0, 200)));
79
+ await enter(page, base, name, log);
80
+ await page.evaluate(view => {
81
+ const world = window.__wildshard.world, cam = world.game.camera;
82
+ try { world.animals.calm = true; } catch { /* a shard without animals */ }
83
+ const style = document.createElement('style');
84
+ style.textContent = 'body *{visibility:hidden!important} canvas.__hero{visibility:visible!important}';
85
+ world.game.renderer.domElement.classList.add('__hero'); document.head.append(style);
86
+ // Posed last in the frame, as engine scripts/hero-shots.mjs does; with no declared camera only the held
87
+ // weapon and hands go, and the player's spawn view stays.
88
+ world.game.onLate(() => {
89
+ for (const child of cam.children) child.visible = false;
90
+ if (view === undefined) return;
91
+ cam.position.set(...view.pos); cam.up.set(0, 1, 0); cam.lookAt(...view.look);
92
+ const center = view.center ?? 0.5, span = 2 * Math.tan(((view.fov ?? 60) * Math.PI) / 360), aspect = innerWidth / innerHeight;
93
+ const height = 2 * Math.max(center, 1 - center), offset = center < 0.5 ? 1 - 2 * center : 0;
94
+ cam.fov = (2 * Math.atan((height / 2) * span) * 180) / Math.PI;
95
+ cam.far = Math.max(cam.far, 6000);
96
+ cam.setViewOffset(aspect, height, 0, offset, aspect, 1);
97
+ cam.updateMatrixWorld(true);
98
+ });
99
+ }, camera);
100
+ await sleep(8000);
101
+ for (const [slot, viewport] of Object.entries(VIEWS)) {
102
+ await page.setViewportSize(viewport);
103
+ await sleep(3000);
104
+ shots[slot] = await page.screenshot({ type: 'jpeg', quality: QUALITY });
105
+ const [width, height] = jpegSize(shots[slot]);
106
+ if (width !== viewport.width * SCALE || height !== viewport.height * SCALE) throw new Error(`${slot} came out ${width}x${height}`);
107
+ log(`hero: ${slot} ${width}x${height}`);
108
+ }
109
+ await context.close();
110
+ } finally { await browser.close(); }
111
+ if (errors.length > 0) throw new Error(`page errors during capture, nothing written: ${errors.slice(0, 3).join(' | ')}`);
112
+ // Write every file, then the stamp, so a failed capture leaves the old hero and its old stamp.
113
+ for (const [slot, bytes] of Object.entries(shots)) {
114
+ const partial = `${files[slot]}.partial`;
115
+ try { writeFileSync(partial, bytes); renameSync(partial, files[slot]); } finally { rmSync(partial, { force: true }); }
116
+ log(`hero: wrote ${files[slot]}`);
117
+ }
118
+ return await writeHeroStamp(shard, { base, ...(camera === undefined ? {} : { camera }) });
119
+ }
120
+
121
+ if (process.argv[1] !== undefined && resolve(process.argv[1]) === resolve(import.meta.filename)) {
122
+ const [dir, flag, base] = process.argv.slice(2);
123
+ const adopt = flag === '--stamp-existing' && base === undefined;
124
+ if (dir === undefined || (!adopt && (flag !== '--base' || base === undefined))) {
125
+ console.error('usage: wildshard hero <source> --base <served-build-url> (serve the candidate first: engine scripts/serve-build.sh --shard <slug>)');
126
+ console.error(' wildshard hero <source> --stamp-existing WARNING: no capture; stamps the hero images already there as current.');
127
+ console.error(' Use it ONLY when you have looked at those images and they show the current content; a wrong stamp hides a stale hero.');
128
+ process.exit(2);
129
+ }
130
+ // SA16 (J317): a repo path names its shard source at src/ or its one src/shards/<slug>/, as the other verbs do.
131
+ const shard = findShardSource(dir);
132
+ if (!existsSync(join(shard, 'manifest.json'))) throw new Error(`${shard}: no manifest.json`);
133
+ if (adopt) console.warn('hero: --stamp-existing: NO capture. Stamping the images already there as showing this content. Only right if they do.');
134
+ const stamp = adopt ? await stampExistingHero(shard) : { written: true, ...(await captureHero(shard, base)) };
135
+ const file = join(dirname(shard), basename(shard), 'hero.json');
136
+ console.info(stamp.written ? `hero: stamped ${file} (content ${stamp.content.slice(0, 12)})` : `hero: ${file} is already current; nothing stamped`);
137
+ }
@@ -0,0 +1,23 @@
1
+ // CI only: pending work is explicit, present, and cannot silently grow.
2
+ import assert from 'node:assert/strict';
3
+ import { existsSync, readFileSync } from 'node:fs';
4
+
5
+ const pending = JSON.parse(readFileSync('test/lift-pending.json', 'utf8'));
6
+ const review = JSON.parse(readFileSync('test/lift-review.json', 'utf8')).files;
7
+ assert.equal(new Set(pending).size, pending.length, 'Duplicate pending path');
8
+ assert.equal(new Set(review.map(row => row.file)).size, review.length, 'Duplicate review');
9
+ assert.ok(pending.length <= 40, 'The reviewed queue must shrink');
10
+ for (const file of pending) {
11
+ assert.ok(existsSync(file), `Absent pending test: ${file}`);
12
+ const row = review.find(row => row.file === file);
13
+ assert.ok(row && ['engine-candidate', 'sdk-candidate', 'graphical-owner'].includes(row.action), `Unjudged pending test: ${file}`);
14
+ assert.ok(row.reason.length > 20, `Missing disposition: ${file}`);
15
+ }
16
+ for (const row of review.filter(row => row.action === 'run')) assert.ok(existsSync(row.successor), `Absent successor: ${row.file}`);
17
+ // A ported test is retired here: its successor runs in its owner's CI, recorded by repo, file and commit.
18
+ for (const row of review.filter(row => row.action === 'ported')) {
19
+ assert.ok(!pending.includes(row.file) && !existsSync(row.file), `Ported test still here: ${row.file}`);
20
+ assert.ok(row.successorProofs?.length > 0 && row.successorProofs.every(proof => proof.repo && proof.file && /^[0-9a-f]{40}$/u.test(proof.commit)),
21
+ `Ported without a recorded successor: ${row.file}`);
22
+ }
23
+ console.log(`lift review: ${pending.length} waiting; under-50 target met; retained owner work remains`);
@@ -0,0 +1,139 @@
1
+ // Conservative source guard for Chromium launchers, without a parser dependency.
2
+ const childMethods = ['spawn', 'spawnSync', 'execFile', 'execFileSync', 'exec', 'execSync'];
3
+ const browserBinary = /chrom(?:e|ium)|executablePath\s*\(/iu;
4
+
5
+ /** A literal shell executable or a named executable variable must carry both flags. */
6
+ function shellProblems(/** @type {string} */ text) {
7
+ if (!/^#![^\n]*\b(?:ba|z|da)?sh\b/u.test(text)) return [];
8
+ const variables = new Map([...text.matchAll(/^\s*(\w+)=(?:['"]([^'"\n]+)['"]|([^\s\n]+))/gmu)].map(match => [match[1], match[2] ?? match[3]]));
9
+ return text.replace(/\\\n\s*/gu, ' ').split('\n').flatMap(line => {
10
+ const command = /^\s*(?:exec\s+)?("[^"]+"|'[^']+'|[^\s;]+)(.*)$/u.exec(line);
11
+ if (!command || command[1].startsWith('#') || command[1].includes('=')) return [];
12
+ const program = command[1].replace(/\$\{?(\w+)\}?/gu, (_all, name) => variables.get(name) ?? name);
13
+ if (!browserBinary.test(program)) return [];
14
+ return ['--use-mock-keychain', '--password-store=basic'].every(flag => command[2].includes(flag)) ? [] : ['bare Chromium shell executable'];
15
+ });
16
+ }
17
+
18
+ // Keep offsets while preventing examples, comments and generated source strings
19
+ // from being mistaken for executable calls in the containing file.
20
+ function codeMask(/** @type {string} */ text) {
21
+ let quote = '', escaped = false, line = false, block = false;
22
+ let regex = false, characterClass = false;
23
+ return text.split('').map((char, index) => {
24
+ const next = text[index + 1];
25
+ if (line) { if (char === '\n') line = false; return char === '\n' ? char : ' '; }
26
+ if (block) { if (char === '*' && next === '/') block = false; return ' '; }
27
+ if (regex) {
28
+ if (escaped) escaped = false;
29
+ else if (char === '\\') escaped = true;
30
+ else if (char === '[') characterClass = true;
31
+ else if (char === ']') characterClass = false;
32
+ else if (char === '/' && !characterClass) regex = false;
33
+ return ' ';
34
+ }
35
+ if (quote) {
36
+ if (escaped) escaped = false;
37
+ else if (char === '\\') escaped = true;
38
+ else if (char === quote) quote = '';
39
+ return char === '\n' ? char : ' ';
40
+ }
41
+ if (char === '/' && next === '/') { line = true; return ' '; }
42
+ if (char === '/' && next === '*') { block = true; return ' '; }
43
+ if (char === '/' && /(?:^|[=(:,![?&|{};]|=>|\breturn|\bcase)\s*$/u.test(text.slice(Math.max(0, index - 30), index))) {
44
+ regex = true; return ' ';
45
+ }
46
+ if (char === '"' || char === "'" || char === '`') { quote = char; return ' '; }
47
+ return char;
48
+ }).join('');
49
+ }
50
+
51
+ /** Read a balanced expression, retaining strings but ignoring their punctuation. */
52
+ function expression(/** @type {string} */ text, /** @type {number} */ start, stopAtComma = false) {
53
+ let depth = 0, quote = '', escaped = false, i = start;
54
+ for (; i < text.length; i++) {
55
+ const char = text[i];
56
+ if (quote) {
57
+ if (escaped) escaped = false;
58
+ else if (char === '\\') escaped = true;
59
+ else if (char === quote) quote = '';
60
+ continue;
61
+ }
62
+ if (char === '"' || char === "'" || char === '`') { quote = char; continue; }
63
+ if (char === '/' && text[i + 1] === '/') { i = text.indexOf('\n', i); if (i < 0) return text.length; continue; }
64
+ if (char === '/' && text[i + 1] === '*') { const end = text.indexOf('*/', i + 2); i = end < 0 ? text.length : end + 1; continue; }
65
+ if ('([{'.includes(char)) depth++;
66
+ if (')]}'.includes(char)) { if (depth === 0) break; depth--; }
67
+ if (depth === 0 && (char === ';' || stopAtComma && char === ',')) break;
68
+ }
69
+ return i;
70
+ }
71
+
72
+ /** Return actionable failures; aliases keep raw executable spawns visible. */
73
+ export function keychainProblems(/** @type {string} */ text) {
74
+ const problems = shellProblems(text);
75
+ const code = codeMask(text);
76
+ let ownsSafeChromium = false;
77
+ if (text.includes('ignore' + 'DefaultArgs')) problems.push('drops Playwright default arguments');
78
+ const bindings = new Map();
79
+ for (const match of code.matchAll(/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=/gu)) {
80
+ const start = match.index + match[0].length;
81
+ bindings.set(match[1], text.slice(start, expression(text, start, true)));
82
+ }
83
+ const expand = (/** @type {string} */ value) => {
84
+ const seen = new Set();
85
+ for (let pass = 0; pass < 12; pass++) {
86
+ let changed = false;
87
+ const mask = codeMask(value);
88
+ value = value.replace(/\b[A-Za-z_$][\w$]*\b/gu, (name, offset) => {
89
+ if (mask[offset] === ' ' && value.slice(offset - 2, offset) !== '${') return name;
90
+ if (name === 'KEYCHAIN_ARGS' || seen.has(name) || !bindings.has(name)) return name;
91
+ seen.add(name); changed = true; return `(${bindings.get(name)})`;
92
+ });
93
+ if (!changed) break;
94
+ }
95
+ return value;
96
+ };
97
+ const safe = (/** @type {string} */ value) => /\.\.\.\s*KEYCHAIN_ARGS\b/u.test(expand(value))
98
+ || ['--use-mock-keychain', '--password-store=basic'].every(flag => expand(value).includes(flag));
99
+ const names = [...childMethods];
100
+ const namespaces = new Set([...text.matchAll(/import\s+\*\s+as\s+(\w+)\s+from\s+['"](?:node:)?child_process['"]/gu)].map(match => match[1]));
101
+ for (const match of text.matchAll(/import\s+(\w+)\s+from\s+['"](?:node:)?child_process['"]/gu)) namespaces.add(match[1]);
102
+ for (const match of text.matchAll(/\b(spawn(?:Sync)?|execFile(?:Sync)?|exec(?:Sync)?)\s+(?:as\s+|:\s*)(\w+)/gu)) names.push(match[2]);
103
+ for (const match of text.matchAll(/\b(spawn(?:Sync)?|execFile(?:Sync)?|exec(?:Sync)?)\s*:\s*(\w+)/gu)) names.push(match[2]);
104
+ const childCall = new RegExp(`\\b(?:${names.join('|')})\\s*\\(`, 'gu');
105
+ let childCode = code;
106
+ for (const match of text.matchAll(/(\brequire\s*\(\s*['"](?:node:)?child_process['"]\s*\)|\b\w+)\s*\[\s*['"](spawn(?:Sync)?|execFile(?:Sync)?|exec(?:Sync)?)['"]\s*\]\s*\(/gu)) {
107
+ if (code[match.index] === ' ' || !/child_process/u.test(expand(match[1])) && !namespaces.has(match[1])) continue;
108
+ const replacement = ' '.repeat(match[0].length - match[2].length - 1) + match[2] + '(';
109
+ childCode = childCode.slice(0, match.index) + replacement + childCode.slice(match.index + match[0].length);
110
+ }
111
+ for (const match of childCode.matchAll(childCall)) {
112
+ const receiver = /(\w+)\s*\.\s*$/u.exec(code.slice(Math.max(0, match.index - 80), match.index))?.[1];
113
+ if (receiver && !namespaces.has(receiver) && !/child_process/u.test(expand(receiver))) continue;
114
+ const start = match.index + match[0].length;
115
+ const first = text.slice(start, expression(text, start, true));
116
+ const call = text.slice(start, expression(text, start));
117
+ if (browserBinary.test(expand(first))) {
118
+ if (safe(call)) ownsSafeChromium = true;
119
+ else problems.push(`bare Chromium child process at offset ${match.index}`);
120
+ }
121
+ }
122
+ if (/playwright/u.test(text) && /chromium|Desktop Chrome/u.test(text)) {
123
+ for (const match of code.matchAll(/\.\s*(?:launch|launchPersistentContext|launchServer)\s*\(/gu)) {
124
+ const before = text.slice(Math.max(0, match.index - 20), match.index);
125
+ if (/\bwebkit\s*$/u.test(before)) continue;
126
+ // A typed injected author host is an interface call, not a browser start.
127
+ const receiver = /\b(\w+)\s*$/u.exec(before)?.[1];
128
+ if (receiver && new RegExp(`\\b${receiver}\\s*:\\s*NativeRasterHost\\b`, 'u').test(text)) continue;
129
+ const start = match.index + match[0].length;
130
+ if (!safe(text.slice(start, expression(text, start)))) problems.push(`bare Playwright launch at offset ${match.index}`);
131
+ else ownsSafeChromium = true;
132
+ }
133
+ if (/\.\s*(?:connect|connectOverCDP)\s*\(/u.test(code) && !ownsSafeChromium
134
+ && (!text.includes('Browser.getBrowserCommandLine') || !text.includes('KEYCHAIN_ARGS.every'))) problems.push('Chromium attachment must verify the connected process command line');
135
+ if (/\bdefineConfig\s*\(/u.test(code) && /Desktop Chrome/u.test(text)
136
+ && !/launchOptions\s*:\s*\{\s*args\s*:\s*\[\s*\.\.\.KEYCHAIN_ARGS/u.test(text)) problems.push('Desktop Chrome project lacks safe launchOptions');
137
+ }
138
+ return problems;
139
+ }
@@ -0,0 +1 @@
1
+ export const KEYCHAIN_ARGS: readonly ['--use-mock-keychain', '--password-store=basic'];
@@ -0,0 +1,5 @@
1
+ // Every Chromium this repo starts passes these two (Jake, 2026-11-09). Without them Chrome for Testing asks the macOS
2
+ // keychain for "Chrome for Testing Safe Storage" and a dialog lands on the desktop at each launch. Playwright adds them
3
+ // by default, but a raw `spawn` of the executable skips its defaults, so every launch site spreads them explicitly and
4
+ // test/tooling/chrome-keychain.test.mjs refuses a launch file that does not.
5
+ export const KEYCHAIN_ARGS = Object.freeze(['--use-mock-keychain', '--password-store=basic']);