@wildshard/sdk 0.0.1 → 0.2.3

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 (687) hide show
  1. package/GUIDE.md +790 -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 +46 -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 +24 -0
  358. package/src/cli/bin.mjs +8 -0
  359. package/src/cli/delete/delete.ts +258 -0
  360. package/src/cli/help.ts +196 -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 +292 -0
  365. package/src/cli/report.ts +16 -0
  366. package/src/cli/shardfile/command.ts +50 -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/arenaView.ts +15 -0
  394. package/src/sharddev/as/groupBankV2.ts +36 -0
  395. package/src/sharddev/as/groupStepV2.ts +13 -0
  396. package/src/sharddev/as/ws.ts +30 -0
  397. package/src/sharddev/as/wsV2.ts +180 -0
  398. package/src/sharddev/assemblyscriptCompiler.d.mts +5 -0
  399. package/src/sharddev/assemblyscriptCompiler.mjs +14 -0
  400. package/src/sharddev/assetHandle.ts +84 -0
  401. package/src/sharddev/assetOwner.ts +70 -0
  402. package/src/sharddev/assetScope.ts +30 -0
  403. package/src/sharddev/assets.ts +21 -0
  404. package/src/sharddev/audio.ts +9 -0
  405. package/src/sharddev/audioEncode.ts +211 -0
  406. package/src/sharddev/author.ts +3 -0
  407. package/src/sharddev/authorError.ts +28 -0
  408. package/src/sharddev/authorManifest.ts +39 -0
  409. package/src/sharddev/bake/annulus.ts +19 -0
  410. package/src/sharddev/bake/assemblyscriptMemo.ts +76 -0
  411. package/src/sharddev/bake/assemblyscriptMemoPort.ts +4 -0
  412. package/src/sharddev/bake/authoredWorld.ts +201 -0
  413. package/src/sharddev/bake/basisEncoder.ts +95 -0
  414. package/src/sharddev/bake/basisGlb.ts +85 -0
  415. package/src/sharddev/bake/basisTool.ts +74 -0
  416. package/src/sharddev/bake/basisToolInputs.ts +476 -0
  417. package/src/sharddev/bake/byteCodec.ts +33 -0
  418. package/src/sharddev/bake/canvasAtlas.ts +406 -0
  419. package/src/sharddev/bake/coarseCopy.ts +59 -0
  420. package/src/sharddev/bake/colliders.ts +87 -0
  421. package/src/sharddev/bake/compactGlb.ts +224 -0
  422. package/src/sharddev/bake/compileScript.ts +119 -0
  423. package/src/sharddev/bake/compileScriptV2.ts +75 -0
  424. package/src/sharddev/bake/contactRows.ts +84 -0
  425. package/src/sharddev/bake/creaturePlacement.ts +117 -0
  426. package/src/sharddev/bake/export.ts +67 -0
  427. package/src/sharddev/bake/facetedGeometry.ts +379 -0
  428. package/src/sharddev/bake/farImpostor.ts +120 -0
  429. package/src/sharddev/bake/forest.ts +100 -0
  430. package/src/sharddev/bake/format-hook.mjs +2 -0
  431. package/src/sharddev/bake/generatorGlb.ts +23 -0
  432. package/src/sharddev/bake/geometryBounds.ts +77 -0
  433. package/src/sharddev/bake/geometryError.ts +48 -0
  434. package/src/sharddev/bake/glb.ts +355 -0
  435. package/src/sharddev/bake/glbCompression.ts +143 -0
  436. package/src/sharddev/bake/gltfSource.ts +59 -0
  437. package/src/sharddev/bake/groundMap.ts +142 -0
  438. package/src/sharddev/bake/image.ts +20 -0
  439. package/src/sharddev/bake/isleMap.ts +64 -0
  440. package/src/sharddev/bake/json.mjs +84 -0
  441. package/src/sharddev/bake/keyedSky.ts +47 -0
  442. package/src/sharddev/bake/keyedSkyMemo.ts +39 -0
  443. package/src/sharddev/bake/kinds.ts +137 -0
  444. package/src/sharddev/bake/lightSources.ts +31 -0
  445. package/src/sharddev/bake/mapAssembly.ts +84 -0
  446. package/src/sharddev/bake/mapRaster.ts +173 -0
  447. package/src/sharddev/bake/mapRest.ts +57 -0
  448. package/src/sharddev/bake/mapScenes.ts +234 -0
  449. package/src/sharddev/bake/materialGraph.ts +32 -0
  450. package/src/sharddev/bake/meadow.ts +27 -0
  451. package/src/sharddev/bake/meshoptChoiceMemo.ts +34 -0
  452. package/src/sharddev/bake/nativeInteractionFacts.ts +5 -0
  453. package/src/sharddev/bake/nativeLattice.ts +178 -0
  454. package/src/sharddev/bake/nativeRaster.ts +106 -0
  455. package/src/sharddev/bake/nativeTerrainField.ts +11 -0
  456. package/src/sharddev/bake/navigation-json.mjs +38 -0
  457. package/src/sharddev/bake/navigation.ts +113 -0
  458. package/src/sharddev/bake/navigationAsset.ts +18 -0
  459. package/src/sharddev/bake/nearPlaceholder.ts +206 -0
  460. package/src/sharddev/bake/normalizeRig.ts +80 -0
  461. package/src/sharddev/bake/phoneAstc.ts +93 -0
  462. package/src/sharddev/bake/placeholders.ts +581 -0
  463. package/src/sharddev/bake/placement.ts +80 -0
  464. package/src/sharddev/bake/portableBytes.ts +18 -0
  465. package/src/sharddev/bake/portableBytesMemo.ts +50 -0
  466. package/src/sharddev/bake/practiceCourse.ts +49 -0
  467. package/src/sharddev/bake/primitives.ts +96 -0
  468. package/src/sharddev/bake/props.ts +443 -0
  469. package/src/sharddev/bake/questPlacement.ts +98 -0
  470. package/src/sharddev/bake/rawTexture.ts +26 -0
  471. package/src/sharddev/bake/riderArms.ts +97 -0
  472. package/src/sharddev/bake/rig.ts +95 -0
  473. package/src/sharddev/bake/riggedHullRecipes.ts +40 -0
  474. package/src/sharddev/bake/signPlacements.ts +25 -0
  475. package/src/sharddev/bake/simplifier.ts +52 -0
  476. package/src/sharddev/bake/skinned.ts +312 -0
  477. package/src/sharddev/bake/slabChunks.ts +149 -0
  478. package/src/sharddev/bake/slabs.ts +263 -0
  479. package/src/sharddev/bake/source-loader.mjs +55 -0
  480. package/src/sharddev/bake/sourceMetadata.ts +54 -0
  481. package/src/sharddev/bake/species.ts +368 -0
  482. package/src/sharddev/bake/specimenCatalogue.ts +47 -0
  483. package/src/sharddev/bake/splatGround.ts +141 -0
  484. package/src/sharddev/bake/staticMaterials.ts +171 -0
  485. package/src/sharddev/bake/terrain.ts +195 -0
  486. package/src/sharddev/bake/texture.ts +33 -0
  487. package/src/sharddev/bake/textureWasm.ts +81 -0
  488. package/src/sharddev/bake/tileEncoder.ts +11 -0
  489. package/src/sharddev/bake/tileGrid.ts +62 -0
  490. package/src/sharddev/bake/v2Finite.ts +160 -0
  491. package/src/sharddev/bake/v2Fuel.ts +71 -0
  492. package/src/sharddev/bake/wholePartition.ts +74 -0
  493. package/src/sharddev/bake/wholePieceJoin.ts +147 -0
  494. package/src/sharddev/bake/world.ts +173 -0
  495. package/src/sharddev/bake/worldCollision.ts +128 -0
  496. package/src/sharddev/bake/worldGeometry.ts +237 -0
  497. package/src/sharddev/bake/worldGlb.ts +123 -0
  498. package/src/sharddev/bake/worldImage.ts +12 -0
  499. package/src/sharddev/bake/worldLod.ts +128 -0
  500. package/src/sharddev/bake/worldRows.ts +102 -0
  501. package/src/sharddev/bake/worldTextureMemo.ts +63 -0
  502. package/src/sharddev/bake/zstdBytesMemo.ts +52 -0
  503. package/src/sharddev/bake.ts +193 -0
  504. package/src/sharddev/bakePublication.ts +31 -0
  505. package/src/sharddev/behaviourSource.ts +94 -0
  506. package/src/sharddev/bin/wildshard.mjs +7 -0
  507. package/src/sharddev/blobBytes.ts +65 -0
  508. package/src/sharddev/blobs.ts +138 -0
  509. package/src/sharddev/bootInventory.ts +129 -0
  510. package/src/sharddev/bossProfiles.ts +18 -0
  511. package/src/sharddev/buildBehaviour.ts +77 -0
  512. package/src/sharddev/buildCacheMetrics.ts +17 -0
  513. package/src/sharddev/buildDecisionScripts.ts +122 -0
  514. package/src/sharddev/check.ts +117 -0
  515. package/src/sharddev/checkProject.ts +126 -0
  516. package/src/sharddev/cli.ts +191 -0
  517. package/src/sharddev/clientChannels.ts +169 -0
  518. package/src/sharddev/clientScripts.ts +10 -0
  519. package/src/sharddev/commons.ts +77 -0
  520. package/src/sharddev/commonsCosts.ts +11 -0
  521. package/src/sharddev/compileMovers.ts +11 -0
  522. package/src/sharddev/configBoundary.ts +6 -0
  523. package/src/sharddev/cookInput.ts +40 -0
  524. package/src/sharddev/crowds.ts +6 -0
  525. package/src/sharddev/decisionBindingMap.ts +11 -0
  526. package/src/sharddev/decisionScriptBindings.ts +117 -0
  527. package/src/sharddev/decisionScripts.ts +28 -0
  528. package/src/sharddev/decisionSource.ts +51 -0
  529. package/src/sharddev/dev.ts +113 -0
  530. package/src/sharddev/director.ts +26 -0
  531. package/src/sharddev/directorAbi.ts +77 -0
  532. package/src/sharddev/discoveryDocument.ts +97 -0
  533. package/src/sharddev/draft.ts +11 -0
  534. package/src/sharddev/eliteEntryRows.ts +29 -0
  535. package/src/sharddev/entries.ts +76 -0
  536. package/src/sharddev/entryReads.ts +73 -0
  537. package/src/sharddev/executeBundle.ts +55 -0
  538. package/src/sharddev/finds.ts +5 -0
  539. package/src/sharddev/formatJsonSchema.ts +3 -0
  540. package/src/sharddev/generationCache.ts +257 -0
  541. package/src/sharddev/generationRecipe.ts +94 -0
  542. package/src/sharddev/handwritten.ts +110 -0
  543. package/src/sharddev/immutable.ts +14 -0
  544. package/src/sharddev/interactions.ts +38 -0
  545. package/src/sharddev/kit/bakedGeometry.ts +16 -0
  546. package/src/sharddev/kit/geometryPack.ts +110 -0
  547. package/src/sharddev/ledger.ts +13 -0
  548. package/src/sharddev/looks/tileField.ts +67 -0
  549. package/src/sharddev/materialGraphFiles.ts +57 -0
  550. package/src/sharddev/materials.ts +574 -0
  551. package/src/sharddev/measure.ts +18 -0
  552. package/src/sharddev/modes.ts +115 -0
  553. package/src/sharddev/moverPrograms.ts +213 -0
  554. package/src/sharddev/movers.ts +75 -0
  555. package/src/sharddev/nativePopulationRows.ts +46 -0
  556. package/src/sharddev/newProject.ts +247 -0
  557. package/src/sharddev/noise.ts +54 -0
  558. package/src/sharddev/outputProduct.ts +188 -0
  559. package/src/sharddev/outputRuntime.ts +66 -0
  560. package/src/sharddev/performancePolicy.ts +18 -0
  561. package/src/sharddev/phasedBoss.ts +34 -0
  562. package/src/sharddev/physics.ts +194 -0
  563. package/src/sharddev/platformSections.ts +42 -0
  564. package/src/sharddev/plumbing.ts +8 -0
  565. package/src/sharddev/productOutput.ts +128 -0
  566. package/src/sharddev/project.ts +337 -0
  567. package/src/sharddev/projectCompilerIdentity.ts +94 -0
  568. package/src/sharddev/projectDecisions.ts +66 -0
  569. package/src/sharddev/projectEntryProof.ts +32 -0
  570. package/src/sharddev/projectGeneration.ts +219 -0
  571. package/src/sharddev/projectInputFiles.ts +47 -0
  572. package/src/sharddev/projectManifest.ts +108 -0
  573. package/src/sharddev/projectMap.ts +35 -0
  574. package/src/sharddev/projectOutput.ts +242 -0
  575. package/src/sharddev/projectPolicy.ts +17 -0
  576. package/src/sharddev/projectSections.ts +27 -0
  577. package/src/sharddev/questGraph.ts +25 -0
  578. package/src/sharddev/quests.ts +65 -0
  579. package/src/sharddev/random.ts +61 -0
  580. package/src/sharddev/refusals.ts +234 -0
  581. package/src/sharddev/reportCard.ts +13 -0
  582. package/src/sharddev/returnProjectionV2.ts +81 -0
  583. package/src/sharddev/rows.ts +192 -0
  584. package/src/sharddev/runtimeImports.ts +38 -0
  585. package/src/sharddev/runtimeMirrors.ts +39 -0
  586. package/src/sharddev/runtimePerformance.ts +38 -0
  587. package/src/sharddev/scene.ts +321 -0
  588. package/src/sharddev/sceneAnimation.ts +54 -0
  589. package/src/sharddev/sceneAudio.ts +64 -0
  590. package/src/sharddev/sceneDeclarations.ts +100 -0
  591. package/src/sharddev/sceneGraph.ts +139 -0
  592. package/src/sharddev/sceneTransform.ts +12 -0
  593. package/src/sharddev/schemaValidation.ts +61 -0
  594. package/src/sharddev/sections.ts +47 -0
  595. package/src/sharddev/shardSource.ts +59 -0
  596. package/src/sharddev/sourceReader.ts +26 -0
  597. package/src/sharddev/spawns.ts +38 -0
  598. package/src/sharddev/species/clips.ts +24 -0
  599. package/src/sharddev/species.ts +29 -0
  600. package/src/sharddev/speciesBrains.ts +19 -0
  601. package/src/sharddev/synth.ts +66 -0
  602. package/src/sharddev/test/compileDualScriptV2.ts +71 -0
  603. package/src/sharddev/test/compileSimV2.ts +21 -0
  604. package/src/sharddev/test/diskScriptScenario.ts +86 -0
  605. package/src/sharddev/test/scriptScenario.ts +249 -0
  606. package/src/sharddev/test/scriptSource.ts +12 -0
  607. package/src/sharddev/version.ts +4 -0
  608. package/src/sharddev/weapons/bowProfile.ts +20 -0
  609. package/src/sharddev/weapons/firearmRows.ts +11 -0
  610. package/src/sharddev/weapons/meleeProfile.ts +71 -0
  611. package/src/sharddev/weapons/thrownProfile.ts +10 -0
  612. package/src/sharddev/worldScenes.ts +308 -0
  613. package/src/sharddev/worldSource.ts +82 -0
  614. package/src/shards/_template/README.md +78 -0
  615. package/src/shards/_template/assets/2bf489fdb15f1734ddb4c4f32d500ec6da85c765ec7a4eb28dc6781160e7ec8c +0 -0
  616. package/src/shards/_template/assets/97ec4d8f75f5fa6239ee919444d6dc19fd35896bb305930c1f050ac6e0e0e6a6 +1 -0
  617. package/src/shards/_template/assets/a6a587a31327f936b1b04c05ade818c73fc8964260918662db43539465e27586 +0 -0
  618. package/src/shards/_template/assets/b4fbde0422e125b498c3dc8b9a5cc2516c8598f09e9d0e5f6b639b32f98179e6 +0 -0
  619. package/src/shards/_template/assets/bfa4dfc9c18979f904557ee8deab0058b8a399be10266f5fb1578b403f482fd4 +1 -0
  620. package/src/shards/_template/assets/ef3b7ff4fd22715771cb7d68a3977a903c5e7c3dc293542687d04b3ef3ace2cb +0 -0
  621. package/src/shards/_template/assets/f2db05998615ce1cb79ea96be32c168842eb6a2b34ec01feb86d36404603ee54 +0 -0
  622. package/src/shards/_template/assets/fef98ebb7fce6f66b26e78ac699e5c90f9bdcfaf8cabeb2b58125347eea8b4ab +0 -0
  623. package/src/shards/_template/behaviour/boss.as +39 -0
  624. package/src/shards/_template/behaviour/door.as +32 -0
  625. package/src/shards/_template/behaviour/hooks.json +129 -0
  626. package/src/shards/_template/behaviour/idle.as +75 -0
  627. package/src/shards/_template/behaviour/items.as +22 -0
  628. package/src/shards/_template/card/landscape.jpg +0 -0
  629. package/src/shards/_template/card/portrait.jpg +0 -0
  630. package/src/shards/_template/card/thumb.jpg +0 -0
  631. package/src/shards/_template/data/audio.json +45 -0
  632. package/src/shards/_template/data/bossDecision.json +83 -0
  633. package/src/shards/_template/data/budgets.json +70 -0
  634. package/src/shards/_template/data/card.json +281 -0
  635. package/src/shards/_template/data/clientScripts.json +987 -0
  636. package/src/shards/_template/data/creatures.json +65 -0
  637. package/src/shards/_template/data/director.json +39 -0
  638. package/src/shards/_template/data/encounters.json +96 -0
  639. package/src/shards/_template/data/items.json +172 -0
  640. package/src/shards/_template/data/layout.json +66 -0
  641. package/src/shards/_template/data/ledger.json +32 -0
  642. package/src/shards/_template/data/look.json +521 -0
  643. package/src/shards/_template/data/map.json +64 -0
  644. package/src/shards/_template/data/moves.json +16 -0
  645. package/src/shards/_template/data/placeholder.json +8 -0
  646. package/src/shards/_template/data/plumbing.json +32 -0
  647. package/src/shards/_template/data/quests.json +223 -0
  648. package/src/shards/_template/data/rows.json +423 -0
  649. package/src/shards/_template/data/skins.json +66 -0
  650. package/src/shards/_template/data/spawn.json +6 -0
  651. package/src/shards/_template/data/targets.json +150 -0
  652. package/src/shards/_template/data/text.json +12 -0
  653. package/src/shards/_template/data/ui.json +33 -0
  654. package/src/shards/_template/data/water.json +13 -0
  655. package/src/shards/_template/generators/behaviour.ts +34 -0
  656. package/src/shards/_template/generators/boss.ts +29 -0
  657. package/src/shards/_template/generators/buildOptions.ts +2 -0
  658. package/src/shards/_template/generators/cell.ts +224 -0
  659. package/src/shards/_template/generators/districts.ts +215 -0
  660. package/src/shards/_template/generators/farLook.ts +15 -0
  661. package/src/shards/_template/generators/generate.ts +27 -0
  662. package/src/shards/_template/generators/ground.ts +15 -0
  663. package/src/shards/_template/generators/kit.ts +69 -0
  664. package/src/shards/_template/generators/landscape.ts +59 -0
  665. package/src/shards/_template/generators/landscapeNoise.ts +62 -0
  666. package/src/shards/_template/generators/mapInputs.ts +10 -0
  667. package/src/shards/_template/generators/product.ts +100 -0
  668. package/src/shards/_template/generators/productOutput.ts +18 -0
  669. package/src/shards/_template/generators/props.ts +9 -0
  670. package/src/shards/_template/generators/templatePropsSource.ts +58 -0
  671. package/src/shards/_template/generators/terrain.ts +17 -0
  672. package/src/shards/_template/generators/world.ts +630 -0
  673. package/src/shards/_template/hero.json +10 -0
  674. package/src/shards/_template/look/entry-reads.json +20 -0
  675. package/src/shards/_template/manifest.json +281 -0
  676. package/src/shards/_template/shard.config.ts +10 -0
  677. package/src/shared/health.ts +10 -0
  678. package/src/tools/build-web.ts +59 -0
  679. package/src/tsconfig.json +30 -0
  680. package/src/web/app.tsx +53 -0
  681. package/src/web/index.html +12 -0
  682. package/src/web/main.tsx +10 -0
  683. package/src/web/tsconfig.json +13 -0
  684. package/tsconfig.author.json +23 -0
  685. package/tsconfig.commons.json +21 -0
  686. package/tsconfig.json +47 -0
  687. package/tsconfig.sharddev.json +20 -0
@@ -0,0 +1,356 @@
1
+ /** E336: evaluate the original skins against every baked UniMate frame without rendering.
2
+ * Usage: node scripts/practice/verify_unimate_skin.mjs [motion.glb] [report.json]
3
+ * Textures are replaced only in memory; real geometry, bind matrices and weights are loaded.
4
+ */
5
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
6
+ import { createHash } from 'node:crypto';
7
+ import { execFileSync } from 'node:child_process';
8
+ import { registerHooks, stripTypeScriptTypes } from 'node:module';
9
+ import { fileURLToPath } from 'node:url';
10
+ import * as THREE from 'three';
11
+ import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
12
+ import { MeshoptDecoder } from 'meshoptimizer';
13
+ import { NodeIO } from '@gltf-transform/core';
14
+ import { ALL_EXTENSIONS } from '@gltf-transform/extensions';
15
+
16
+ const [motionPath = 'public/assets/practice/dummies/unimate-motion.glb',
17
+ reportPath = 'docs/audits/dummy-unimate-skin.json'] = process.argv.slice(2);
18
+ const previousReport = existsSync(reportPath) ? JSON.parse(readFileSync(reportPath, 'utf8')) : null;
19
+ const originalRevision = previousReport?.originalRevision ?? execFileSync('git', ['rev-parse', 'HEAD'], { encoding: 'utf8' }).trim();
20
+ const minRestTriangleArea = 1e-8;
21
+ // E388: no invented tolerance. A weight sum can only be off by its storage's rounding, half a quantum per weight (glTF
22
+ // stores WEIGHTS_0 as float32 or as normalized unsigned byte / short): for float32 4 × 2⁻²⁴ ≈ 2.4e-7, img2-character G4's 2e-7.
23
+ const weightSumTolerance = (array, normalized) => 4 * (normalized && !(array instanceof Float32Array) ? 0.5 / (2 ** (8 * array.BYTES_PER_ELEMENT) - 1) : 2 ** -24);
24
+ // The skin's deformation and the clips' joint speed are held to what the figure's shipped reactions already do: the
25
+ // existing hit springs alone, measured in this run on the same figure (springBaseline). The first take (stretch 3.7–5.1×,
26
+ // area down to 0.3 %) fails that bar; the approved bake passes it.
27
+ const firstTake = previousReport?.beforeSkinRepair ?? (previousReport?.variants?.every((v) => v.unchangedFromHEAD)
28
+ ? previousReport.variants.map((v) => ({ variant: v.variant, sourceSHA256: v.sha256, skins: v.skins,
29
+ clips: v.clips.map((c) => ({ name: c.name, maxEdgeStretch: c.maxEdgeStretch,
30
+ minTriangleAreaRatio: c.minTriangleAreaRatio, collapsedTriangleSamples: c.collapsedTriangleSamples,
31
+ worstStretch: c.worstStretch, worstCollapse: c.worstCollapse })), springComparison: v.springComparison })) : null);
32
+ // Exercise the same TypeScript springs and sampler as the arena, without copying their formulas.
33
+ registerHooks({
34
+ resolve(specifier, context, next) {
35
+ try { return next(specifier, context); }
36
+ catch (error) {
37
+ if (specifier.startsWith('.') && context.parentURL) return next(`${specifier}.ts`, context);
38
+ throw error;
39
+ }
40
+ },
41
+ load(url, context, next) {
42
+ if (url.endsWith('.ts')) return { format: 'module', shortCircuit: true,
43
+ source: stripTypeScriptTypes(readFileSync(fileURLToPath(url), 'utf8'), { mode: 'transform' }) };
44
+ return next(url, context);
45
+ },
46
+ });
47
+ const { DummyMotion, DummyPose } = await import('@wildshard/engine/practice/DummyMotion');
48
+ const { DummyClips } = await import('@wildshard/engine/practice/DummyClips');
49
+ const { DUMMY_BONE_NAMES } = await import('@wildshard/engine/practice/TrainingDummy');
50
+ const loader = new GLTFLoader().setMeshoptDecoder(MeshoptDecoder);
51
+ await MeshoptDecoder.ready;
52
+ const rawIO = new NodeIO().registerExtensions(ALL_EXTENSIONS).registerDependencies({ 'meshopt.decoder': MeshoptDecoder });
53
+ loader.register((parser) => {
54
+ parser.loadTextureImage = () => Promise.resolve(new THREE.DataTexture(new Uint8Array([255, 255, 255, 255]), 1, 1));
55
+ return { name: 'HEADLESS_TEXTURE_SUBSTITUTE' };
56
+ });
57
+ const load = (path) => {
58
+ const data = readFileSync(path);
59
+ return loader.parseAsync(data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength), '');
60
+ };
61
+ const sha = (path) => createHash('sha256').update(readFileSync(path)).digest('hex');
62
+ const fixedNames = new Set(['Root', 'LeftThigh', 'LeftShin', 'RightThigh', 'RightShin']);
63
+ const motions = await load(motionPath), rows = [];
64
+ const failures = [];
65
+ if (motions.animations.length !== 18) failures.push('Motion library must contain 18 clips');
66
+ const round = (value) => Number(value.toFixed(9));
67
+ const a = new THREE.Vector3(), b = new THREE.Vector3(), c = new THREE.Vector3();
68
+ const e1 = new THREE.Vector3(), e2 = new THREE.Vector3();
69
+ function positions(mesh) {
70
+ const out = new Float64Array(mesh.geometry.attributes.position.count * 3);
71
+ for (let i = 0; i < out.length / 3; i++) mesh.getVertexPosition(i, a).toArray(out, i * 3);
72
+ return out;
73
+ }
74
+ function triangleMeasure(values, triangle) {
75
+ a.fromArray(values, triangle[0] * 3); b.fromArray(values, triangle[1] * 3); c.fromArray(values, triangle[2] * 3);
76
+ const edges = [a.distanceTo(b), b.distanceTo(c), c.distanceTo(a)];
77
+ const area = e1.subVectors(b, a).cross(e2.subVectors(c, a)).length() * 0.5;
78
+ return { edges, area };
79
+ }
80
+ for (const [variant, filename] of [['wood', 'wood-wood'], ['straw-cloth', 'straw-cloth'], ['wood-steel', 'wood-steel']]) {
81
+ const source = `public/assets/practice/dummies/${filename}.glb`;
82
+ const gltf = await load(source), scene = gltf.scene;
83
+ scene.updateMatrixWorld(true);
84
+ const meshes = [];
85
+ scene.traverse((object) => { if (object.isSkinnedMesh) meshes.push(object); });
86
+ const clips = motions.animations.filter((clip) => clip.name.startsWith(`${variant}:`));
87
+ const row = { variant, source, sha256: sha(source), unchangedFromHEAD: false, skins: [], clips: [] };
88
+ const rawDocument = await rawIO.read(source);
89
+ row.rawSkinAttributes = [];
90
+ for (const node of rawDocument.getRoot().listNodes()) {
91
+ const skin = node.getSkin(), mesh = node.getMesh();
92
+ if (!skin || !mesh) continue;
93
+ for (const primitive of mesh.listPrimitives()) {
94
+ const weights = primitive.getAttribute('WEIGHTS_0'), indices = primitive.getAttribute('JOINTS_0');
95
+ if (!weights || !indices) throw new Error('Source skin attributes missing');
96
+ const weight = [], index = [];
97
+ let maxWeightSumError = 0, invalidWeights = 0, invalidIndices = 0;
98
+ for (let v = 0; v < weights.getCount(); v++) {
99
+ weights.getElement(v, weight); indices.getElement(v, index);
100
+ maxWeightSumError = Math.max(maxWeightSumError, Math.abs(weight.reduce((sum, w) => sum + w, 0) - 1));
101
+ for (let j = 0; j < 4; j++) {
102
+ if (!Number.isFinite(weight[j]) || weight[j] < 0) invalidWeights++;
103
+ if (weight[j] > 0 && (!Number.isInteger(index[j]) || index[j] < 0 || index[j] >= skin.listJoints().length)) invalidIndices++;
104
+ }
105
+ }
106
+ const tolerance = weightSumTolerance(weights.getArray(), weights.getNormalized());
107
+ row.rawSkinAttributes.push({ maxWeightSumError, tolerance, invalidWeights, invalidIndices });
108
+ if (maxWeightSumError > tolerance || invalidWeights || invalidIndices) failures.push(`${variant}: invalid raw source skin attributes`);
109
+ }
110
+ }
111
+ try {
112
+ const committed = execFileSync('git', ['show', `${originalRevision}:${source}`], { maxBuffer: 8 * 1024 * 1024 });
113
+ row.unchangedFromHEAD = createHash('sha256').update(committed).digest('hex') === row.sha256;
114
+ const original = await loader.parseAsync(committed.buffer.slice(committed.byteOffset, committed.byteOffset + committed.byteLength), '');
115
+ const oldMeshes = []; original.scene.traverse((object) => { if (object.isSkinnedMesh) oldMeshes.push(object); });
116
+ let maxPositionDelta = 0, maxBindMatrixDelta = 0, maxJointRestMatrixDelta = 0, sameIndices = true, sameOrientedTriangles = true, sameJointOrder = true;
117
+ if (oldMeshes.length !== meshes.length) throw new Error('Skin count changed');
118
+ for (let m = 0; m < meshes.length; m++) {
119
+ const old = oldMeshes[m], current = meshes[m];
120
+ const p = current.geometry.attributes.position, op = old.geometry.attributes.position;
121
+ if (p.count !== op.count) throw new Error('Vertex count changed');
122
+ for (let v = 0; v < p.count; v++) for (let axis = 0; axis < 3; axis++) maxPositionDelta = Math.max(maxPositionDelta, Math.abs(p.getComponent(v, axis) - op.getComponent(v, axis)));
123
+ const ix = current.geometry.index, oix = old.geometry.index;
124
+ sameIndices &&= ix?.count === oix?.count;
125
+ if (ix && oix) for (let v = 0; v < ix.count; v++) sameIndices &&= ix.getX(v) === oix.getX(v);
126
+ const canonical = (index, v) => {
127
+ const first = index.getX(v), second = index.getX(v + 1), third = index.getX(v + 2);
128
+ return [`${first},${second},${third}`, `${second},${third},${first}`, `${third},${first},${second}`].sort()[0];
129
+ };
130
+ sameOrientedTriangles &&= ix?.count === oix?.count;
131
+ if (ix && oix) for (let v = 0; v < ix.count; v += 3) sameOrientedTriangles &&= canonical(ix, v) === canonical(oix, v);
132
+ sameJointOrder &&= current.skeleton.bones.map((joint) => joint.name).join('|') === old.skeleton.bones.map((joint) => joint.name).join('|');
133
+ for (let j = 0; j < current.skeleton.bones.length; j++) {
134
+ const bone = current.skeleton.bones[j], ob = old.skeleton.bones[j]; bone.updateMatrix(); ob.updateMatrix();
135
+ for (let k = 0; k < 16; k++) {
136
+ maxJointRestMatrixDelta = Math.max(maxJointRestMatrixDelta, Math.abs(bone.matrix.elements[k] - ob.matrix.elements[k]));
137
+ maxBindMatrixDelta = Math.max(maxBindMatrixDelta, Math.abs(current.skeleton.boneInverses[j].elements[k] - old.skeleton.boneInverses[j].elements[k]));
138
+ }
139
+ }
140
+ }
141
+ row.originalGeometryParity = { maxPositionDelta, maxBindMatrixDelta, maxJointRestMatrixDelta, sameIndices, sameOrientedTriangles, sameJointOrder };
142
+ if (maxPositionDelta > 1e-7 || maxBindMatrixDelta > 1e-7 || maxJointRestMatrixDelta > 1e-7 || !sameOrientedTriangles || !sameJointOrder) failures.push(`${variant}: geometry/topology/bind changed from original HEAD`);
143
+ } catch { /* Standalone exports can lack git metadata; false is explicit. */ }
144
+ if (!row.originalGeometryParity) failures.push(`${variant}: original HEAD geometry could not be checked`);
145
+ const restBones = new Map();
146
+ for (const mesh of meshes) for (const bone of mesh.skeleton.bones) restBones.set(bone, bone.quaternion.clone());
147
+ const bind = meshes.map((mesh) => positions(mesh));
148
+ const triangles = meshes.map((mesh) => {
149
+ const count = mesh.geometry.index?.count ?? mesh.geometry.attributes.position.count;
150
+ return Array.from({ length: count / 3 }, (_, i) => [0, 1, 2].map((k) => mesh.geometry.index?.getX(i * 3 + k) ?? i * 3 + k));
151
+ });
152
+ const baseline = triangles.map((list, m) => list.map((triangle) => triangleMeasure(bind[m], triangle)));
153
+ for (const [m, mesh] of meshes.entries()) {
154
+ const p = mesh.geometry.attributes.position, w = mesh.geometry.attributes.skinWeight, ix = mesh.geometry.attributes.skinIndex;
155
+ let bindError = 0, weightError = 0, invalidWeights = 0, invalidIndices = 0;
156
+ for (let v = 0; v < p.count; v++) {
157
+ a.fromBufferAttribute(p, v); b.fromArray(bind[m], v * 3); bindError = Math.max(bindError, a.distanceTo(b));
158
+ let sum = 0;
159
+ for (let j = 0; j < 4; j++) {
160
+ const weight = w.getComponent(v, j), index = ix.getComponent(v, j); sum += weight;
161
+ if (!Number.isFinite(weight) || weight < 0) invalidWeights++;
162
+ if (weight > 0 && (!Number.isInteger(index) || index < 0 || index >= mesh.skeleton.bones.length)) invalidIndices++;
163
+ }
164
+ weightError = Math.max(weightError, Math.abs(sum - 1));
165
+ }
166
+ row.skins.push({ mesh: mesh.name, vertices: p.count, triangles: triangles[m].length,
167
+ jointOrder: mesh.skeleton.bones.map((bone) => bone.name), maxBindPositionError: round(bindError),
168
+ maxWeightSumError: round(weightError), invalidWeights, invalidIndices,
169
+ existingDegenerateTriangles: baseline[m].filter((t) => t.area < 1e-10).length,
170
+ existingNumericalSliverTriangles: baseline[m].filter((t) => t.area >= 1e-10 && t.area < minRestTriangleArea).length });
171
+ if (bindError > 1e-4 || weightError > weightSumTolerance(w.array, w.normalized) || invalidWeights || invalidIndices) failures.push(`${variant}: invalid bind or weights`);
172
+ }
173
+ const deformations = [];
174
+ for (const clip of clips) {
175
+ for (const [bone, rest] of restBones) bone.quaternion.copy(rest);
176
+ const mixer = new THREE.AnimationMixer(scene), action = mixer.clipAction(clip);
177
+ action.setLoop(THREE.LoopOnce, 1); action.clampWhenFinished = true; action.play();
178
+ let maxQuaternionError = 0, missingBindings = 0, forbiddenTracks = 0, finiteKeyframes = true,
179
+ maxKeyframeRotationStep = 0, maxKeyframeAngularSpeed = 0;
180
+ for (const track of clip.tracks) {
181
+ const name = track.name.replace(/\.quaternion$/, '');
182
+ if (!scene.getObjectByName(name)) missingBindings++;
183
+ if (!track.name.endsWith('.quaternion') || fixedNames.has(name)) forbiddenTracks++;
184
+ for (let i = 0; i < track.values.length; i += 4) {
185
+ const q = new THREE.Quaternion().fromArray(track.values, i);
186
+ finiteKeyframes &&= Number.isFinite(q.x) && Number.isFinite(q.y) && Number.isFinite(q.z) && Number.isFinite(q.w);
187
+ maxQuaternionError = Math.max(maxQuaternionError, Math.abs(q.length() - 1));
188
+ if (i >= 4) {
189
+ const angle = q.clone().normalize().angleTo(new THREE.Quaternion().fromArray(track.values, i - 4).normalize());
190
+ const dt = track.times[i / 4] - track.times[i / 4 - 1];
191
+ maxKeyframeRotationStep = Math.max(maxKeyframeRotationStep, angle);
192
+ maxKeyframeAngularSpeed = Math.max(maxKeyframeAngularSpeed, angle / dt);
193
+ }
194
+ }
195
+ }
196
+ let finite = true, maxEdgeStretch = 1, minAreaRatio = 1;
197
+ let maxFixedJointRotation = 0, seamPositionError = 0, maxDisplacement = 0, maxBaseDisplacement = 0;
198
+ let worstStretch, worstCollapse;
199
+ let firstPositions;
200
+ for (let frame = 0; frame <= 60; frame++) {
201
+ mixer.setTime(clip.duration * frame / 60);
202
+ scene.updateMatrixWorld(true);
203
+ for (const [bone, rest] of restBones) if (fixedNames.has(bone.name)) maxFixedJointRotation = Math.max(maxFixedJointRotation, bone.quaternion.clone().normalize().angleTo(rest.clone().normalize()));
204
+ const current = meshes.map((mesh) => positions(mesh));
205
+ if (frame === 0) firstPositions = current;
206
+ for (let m = 0; m < meshes.length; m++) {
207
+ const values = current[m];
208
+ for (let v = 0; v < values.length; v += 3) {
209
+ a.fromArray(values, v); b.fromArray(bind[m], v);
210
+ finite &&= Number.isFinite(a.x) && Number.isFinite(a.y) && Number.isFinite(a.z);
211
+ maxDisplacement = Math.max(maxDisplacement, a.distanceTo(b));
212
+ if (b.y < 0.2) maxBaseDisplacement = Math.max(maxBaseDisplacement, a.distanceTo(b));
213
+ if (frame === 60) { b.fromArray(firstPositions[m], v); seamPositionError = Math.max(seamPositionError, a.distanceTo(b)); }
214
+ }
215
+ for (let t = 0; t < triangles[m].length; t++) {
216
+ const base = baseline[m][t];
217
+ if (base.area < minRestTriangleArea) continue;
218
+ const sample = triangleMeasure(values, triangles[m][t]);
219
+ const ratio = sample.area / base.area;
220
+ const detail = () => ({ mesh: meshes[m].name, frame, indices: triangles[m][t], restArea: base.area,
221
+ vertices: triangles[m][t].map((v) => ({ position: Array.from(bind[m].slice(v * 3, v * 3 + 3)),
222
+ weights: [0, 1, 2, 3].map((j) => ({ bone: meshes[m].skeleton.bones[meshes[m].geometry.attributes.skinIndex.getComponent(v, j)]?.name,
223
+ weight: meshes[m].geometry.attributes.skinWeight.getComponent(v, j) })).filter((w) => w.weight > 0) })) });
224
+ if (ratio < minAreaRatio) worstCollapse = detail();
225
+ minAreaRatio = Math.min(minAreaRatio, ratio);
226
+ for (let e = 0; e < 3; e++) if (base.edges[e] > 1e-7) {
227
+ const stretch = sample.edges[e] / base.edges[e];
228
+ if (stretch > maxEdgeStretch) worstStretch = { ...detail(), edge: e, restEdgeLength: base.edges[e] };
229
+ maxEdgeStretch = Math.max(maxEdgeStretch, stretch);
230
+ }
231
+ }
232
+ }
233
+ }
234
+ // An arena yaw and uniform game scale must transform skinned positions rigidly.
235
+ mixer.setTime(clip.duration * 0.5); scene.updateMatrixWorld(true);
236
+ const beforeYaw = meshes.map((mesh) => positions(mesh));
237
+ scene.rotation.y = Math.PI / 2; scene.scale.setScalar(1.8 / 2.65); scene.updateMatrixWorld(true);
238
+ let yawLocalError = 0;
239
+ for (let m = 0; m < meshes.length; m++) {
240
+ const afterYaw = positions(meshes[m]);
241
+ for (let i = 0; i < afterYaw.length; i++) yawLocalError = Math.max(yawLocalError, Math.abs(afterYaw[i] - beforeYaw[m][i]));
242
+ }
243
+ scene.rotation.y = 0; scene.scale.setScalar(1); scene.updateMatrixWorld(true);
244
+ mixer.stopAllAction(); mixer.uncacheRoot(scene);
245
+ const measured = { name: clip.name, durationSeconds: clip.duration, samples: 61, tracks: clip.tracks.length,
246
+ finite, finiteKeyframes, missingBindings, forbiddenTracks, maxQuaternionLengthError: round(maxQuaternionError),
247
+ maxKeyframeRotationStepDegrees: round(maxKeyframeRotationStep * 180 / Math.PI),
248
+ maxKeyframeAngularSpeedDegreesPerSecond: round(maxKeyframeAngularSpeed * 180 / Math.PI),
249
+ maxFixedJointRotationRadians: round(maxFixedJointRotation), seamPositionError: round(seamPositionError),
250
+ maxVertexDisplacement: round(maxDisplacement), maxBaseDisplacement: round(maxBaseDisplacement), maxEdgeStretch: round(maxEdgeStretch),
251
+ minTriangleAreaRatio: round(minAreaRatio),
252
+ maxYawScaleLocalPositionError: round(yawLocalError), worstStretch, worstCollapse };
253
+ row.clips.push(measured);
254
+ deformations.push({ name: clip.name, maxEdgeStretch, minAreaRatio, speed: maxKeyframeAngularSpeed * 180 / Math.PI });
255
+ if (!finite || !finiteKeyframes || missingBindings || forbiddenTracks || maxQuaternionError > 1e-5 || maxFixedJointRotation > 1e-5 ||
256
+ seamPositionError > 1e-4 || maxBaseDisplacement > 1e-4 || yawLocalError > 1e-5) failures.push(`${clip.name}: numerical gate failed`);
257
+ console.log(variant, clip.name, `stretch ${maxEdgeStretch.toFixed(4)}, minimum area ${minAreaRatio.toFixed(4)}, displacement ${maxDisplacement.toFixed(4)}`);
258
+ }
259
+ row.springComparison = [];
260
+ const joints = Object.fromEntries(Object.entries(DUMMY_BONE_NAMES).map(([logical, name]) => [logical, scene.getObjectByName(name)]));
261
+ const mass = variant === 'straw-cloth' ? 0.8 : variant === 'wood-steel' ? 1.3 : 1;
262
+ const gain = 0.2;
263
+ for (const scenario of [
264
+ { name: 'light-sword', amount: 12, py: 1.2, headshot: false, stagger: 0, clip: 'body-hit' },
265
+ { name: 'charged-sword', amount: 24, py: 1.2, headshot: false, stagger: 1, clip: 'heavy-hit' },
266
+ { name: 'body-bolt', amount: 38, py: 1.05, headshot: false, stagger: null, clip: 'body-hit' },
267
+ { name: 'head-bolt', amount: 83, py: 1.58, headshot: true, stagger: null, clip: 'head-hit' },
268
+ ]) {
269
+ const result = { scenario: scenario.name, mass, samples: 61 };
270
+ for (const combined of [false, true]) {
271
+ for (const [bone, rest] of restBones) bone.quaternion.copy(rest);
272
+ scene.updateMatrixWorld(true);
273
+ const pose = new DummyPose(scene, joints), motion = new DummyMotion(1);
274
+ motion.leftSign = DummyPose.leftSign(scene, joints);
275
+ const controller = combined ? new DummyClips(scene, clips, variant) : null;
276
+ for (let frame = 0; frame < 120; frame++) {
277
+ motion.update(1 / 60); controller?.update(1 / 60); pose.apply(motion, combined, combined ? gain : 1);
278
+ }
279
+ const weight = Math.min(3, Math.max(0.3, scenario.amount / 25)) / mass;
280
+ motion.hit({ px: 0.05, py: scenario.py, pz: 0.3, dx: 0.3, dz: -0.95, weight, headshot: scenario.headshot });
281
+ if (scenario.stagger !== null) motion.shove(scenario.py, 0.5, -0.85, scenario.stagger, mass);
282
+ controller?.hit(scenario.headshot ? 'head-hit' : 'body-hit', scenario.amount / 25, mass);
283
+ if (scenario.stagger !== null && scenario.stagger >= 0.7) controller?.hit('heavy-hit', 1 + scenario.stagger, mass);
284
+ let maxEdgeStretch = 1, minAreaRatio = 1, finite = true, worstStretch, worstCollapse, maxBaseDisplacement = 0, maxJointSpeed = 0;
285
+ const previousPose = new Map();
286
+ for (let frame = 0; frame <= 120; frame++) {
287
+ if (frame > 0) motion.update(1 / 60);
288
+ controller?.update(frame > 0 ? 1 / 60 : 0);
289
+ pose.apply(motion, combined, combined ? gain : 1);
290
+ for (const bone of restBones.keys()) {
291
+ const before = previousPose.get(bone);
292
+ if (before) maxJointSpeed = Math.max(maxJointSpeed, before.angleTo(bone.quaternion) * 60);
293
+ previousPose.set(bone, bone.quaternion.clone());
294
+ }
295
+ if (frame % 2 !== 0) continue;
296
+ scene.updateMatrixWorld(true);
297
+ for (let m = 0; m < meshes.length; m++) {
298
+ const values = positions(meshes[m]);
299
+ finite &&= values.every(Number.isFinite);
300
+ for (let v = 0; v < values.length; v += 3) if (bind[m][v + 1] < 0.2) {
301
+ a.fromArray(values, v); b.fromArray(bind[m], v);
302
+ maxBaseDisplacement = Math.max(maxBaseDisplacement, a.distanceTo(b));
303
+ }
304
+ for (let t = 0; t < triangles[m].length; t++) {
305
+ const base = baseline[m][t];
306
+ if (base.area < minRestTriangleArea) continue;
307
+ const sample = triangleMeasure(values, triangles[m][t]), ratio = sample.area / base.area;
308
+ const detail = () => ({ frame, indices: triangles[m][t], restArea: base.area,
309
+ vertices: triangles[m][t].map((v) => ({ position: Array.from(bind[m].slice(v * 3, v * 3 + 3)),
310
+ weights: [0, 1, 2, 3].map((j) => ({ bone: meshes[m].skeleton.bones[meshes[m].geometry.attributes.skinIndex.getComponent(v, j)]?.name,
311
+ weight: meshes[m].geometry.attributes.skinWeight.getComponent(v, j) })).filter((w) => w.weight > 0) })) });
312
+ if (ratio < minAreaRatio) worstCollapse = detail();
313
+ minAreaRatio = Math.min(minAreaRatio, ratio);
314
+ for (let e = 0; e < 3; e++) if (base.edges[e] > 1e-7) {
315
+ const stretch = sample.edges[e] / base.edges[e];
316
+ if (stretch > maxEdgeStretch) worstStretch = { ...detail(), edge: e, restEdgeLength: base.edges[e] };
317
+ maxEdgeStretch = Math.max(maxEdgeStretch, stretch);
318
+ }
319
+ }
320
+ }
321
+ }
322
+ result[combined ? 'clipsPlusSprings' : 'existingSpringsOnly'] = { finite,
323
+ gain: combined ? gain : 1, maxEdgeStretch: round(maxEdgeStretch), minTriangleAreaRatio: round(minAreaRatio),
324
+ maxJointSpeedDegreesPerSecond: round(maxJointSpeed * 180 / Math.PI), maxBaseDisplacement: round(maxBaseDisplacement),
325
+ worstStretch, worstCollapse };
326
+ if (combined && (!finite || maxBaseDisplacement > 1e-4)) failures.push(`${variant}:${scenario.name}: combined runtime skin gate failed`);
327
+ if (combined) deformations.push({ name: `${variant}:${scenario.name} clips + springs`, maxEdgeStretch, minAreaRatio, speed: maxJointSpeed * 180 / Math.PI });
328
+ }
329
+ row.springComparison.push(result);
330
+ console.log(variant, scenario.name, `existing ${result.existingSpringsOnly.maxEdgeStretch}x / combined ${result.clipsPlusSprings.maxEdgeStretch}x`);
331
+ }
332
+ const shipped = row.springComparison.map((r) => r.existingSpringsOnly);
333
+ row.springBaseline = { maxEdgeStretch: Math.max(...shipped.map((r) => r.maxEdgeStretch)),
334
+ minTriangleAreaRatio: Math.min(...shipped.map((r) => r.minTriangleAreaRatio)),
335
+ maxJointSpeedDegreesPerSecond: Math.max(...shipped.map((r) => r.maxJointSpeedDegreesPerSecond)) };
336
+ for (const d of deformations) {
337
+ if (round(d.maxEdgeStretch) > row.springBaseline.maxEdgeStretch || round(d.minAreaRatio) < row.springBaseline.minTriangleAreaRatio) failures.push(`${d.name}: deforms the skin more than the shipped springs (stretch ${round(d.maxEdgeStretch)} vs ${row.springBaseline.maxEdgeStretch}, area ${round(d.minAreaRatio)} vs ${row.springBaseline.minTriangleAreaRatio})`);
338
+ if (round(d.speed) > row.springBaseline.maxJointSpeedDegreesPerSecond) failures.push(`${d.name}: turns a joint faster than the shipped springs (${round(d.speed)} vs ${row.springBaseline.maxJointSpeedDegreesPerSecond} °/s)`);
339
+ }
340
+ if (sha(source) !== row.sha256) failures.push(`${variant}: source GLB changed during verification`);
341
+ rows.push(row);
342
+ }
343
+ const report = { schema: 1, originalRevision, motionPath, motionSHA256: sha(motionPath),
344
+ method: 'Three.js GLTFLoader with original Meshopt geometry and bind matrices; all vertices and all nondegenerate triangles, 61 samples per clip. Texture pixels substituted in memory only. Clips evaluated through AnimationMixer by bone name. Separate springComparison uses the actual DummyMotion, DummyPose and DummyClips TypeScript classes on four weapon hits at the arena material masses; existing springs alone and the new clips plus springs are sampled over two seconds at 30 Hz.',
345
+ runtimeSourceSHA256: { dummyMotion: sha('src/client/engine/practice/DummyMotion.ts'), dummyClips: sha('src/client/engine/practice/DummyClips.ts') },
346
+ units: 'original GLB model units, before TrainingDummyAssets game scaling',
347
+ limits: { maxBindPositionError: 0.0001, maxWeightSumError: 'half a storage quantum per weight, × 4 (float32: 4 × 2^-24)',
348
+ deformationAndJointSpeed: 'no worse than the variant\'s shipped springs alone, measured in this run (springBaseline): max edge stretch, min triangle area ratio, max joint speed',
349
+ minRestTriangleArea, excludedSliverReason: 'Area below 1e-8 model units squared is already a numerical sliver in the original bind. These are counted separately; the same cutoff is used by the existing Blender dummy rig gate.',
350
+ maxSeamPositionError: 0.0001, maxQuaternionLengthError: 0.00001, maxFixedJointRotationRadians: 0.00001,
351
+ maxYawScaleLocalPositionError: 0.00001 },
352
+ historyNote: 'beforeSkinRepair records the first complete trial with original weights, earlier clip caps, and full spring gain. Comparing it with this report measures the whole remaster; it does not isolate the effect of weight repair alone.',
353
+ beforeSkinRepair: firstTake, variants: rows, passed: failures.length === 0, failures };
354
+ writeFileSync(reportPath, `${JSON.stringify(report, null, 2)}\n`);
355
+ console.log(`Report ${reportPath}: ${report.passed ? 'PASS' : 'FAIL'}`);
356
+ if (!report.passed) process.exitCode = 1;
@@ -0,0 +1,15 @@
1
+ // The save a fresh `wildshard prepare` context starts from (SENTRY-TRIAGE S12): the phone tier, quiet, and a device that has
2
+ // played and answered the Name prompt, so PLAY goes straight to SHARD SELECT on engine main (firstPlay.ts, MP2.4).
3
+ import { NAME_ASKED } from '@wildshard/engine/scripts/debug-settings.mjs';
4
+
5
+ /** localStorage rows by key, for the served save epoch. @param {number} epoch @returns {Record<string, string>} */
6
+ export function preparationSaveSeed(epoch) {
7
+ const prefix = `wildshard.save.v2${epoch === 0 ? '' : `@${epoch}`}.`, row = (/** @type {unknown} */ data) => ({ v: 1, data });
8
+ return {
9
+ [`${prefix}global`]: JSON.stringify({ keys: { settings: row({ tier: 'phone', volume: 0, time: 'midday', weather: 'clear' }), gfx: row({ dpr: '2', aa: 'auto' }) } }),
10
+ [`${prefix}${NAME_ASKED.scope}`]: JSON.stringify({ keys: {
11
+ devMode: row(true), firstPlayDone: row(true), [NAME_ASKED.key]: row(NAME_ASKED.data),
12
+ 'debug.global.holdLoading': row('off'), 'debug.earlyPrograms': row('off'),
13
+ } }),
14
+ };
15
+ }
@@ -0,0 +1,6 @@
1
+ // The same checked SDK installer used by author contexts, outside the product CPU pool.
2
+ import { prepareBasisTool } from '../src/sharddev/bake/basisTool.ts';
3
+
4
+ const started = performance.now();
5
+ const tool = await prepareBasisTool();
6
+ console.info(JSON.stringify({ prerequisite: 'basis', milliseconds: Math.round(performance.now() - started), identity: tool.identity }));
@@ -0,0 +1,14 @@
1
+ /** J198: what `wildshard prepare` records in phone WebKit; tests pass a fixture recording. */
2
+ export interface PreparationRecording {
3
+ readonly headerHash: string;
4
+ readonly renderer: string;
5
+ readonly reads: readonly string[];
6
+ readonly hashes?: readonly string[];
7
+ readonly programs: unknown;
8
+ }
9
+ /** Finish preparing the exact candidate in `dir` from a recording: sdk 0.3 with a version 3 cook, validated. */
10
+ export function finishPreparation(dir: string, recording: PreparationRecording, originalHeader: Uint8Array): Promise<{ slug: string; fence: number; programs: number; renderer: string; document: string }>;
11
+ /** Record the candidate served at `base` in phone WebKit, then finish its preparation. */
12
+ export function prepareProduct(dir: string, base: string): Promise<{ slug: string; fence: number; programs: number; renderer: string; document: string }>;
13
+ /** The producer's dependency fence plus the recording's cold reads. */
14
+ export function preparationFence(index: unknown, sections: ReadonlyMap<string, unknown>, recording: PreparationRecording, mounts: readonly unknown[]): string[];
@@ -0,0 +1,101 @@
1
+ #!/usr/bin/env node
2
+ // J198: prepare an already built candidate using actual phone WebKit links.
3
+ // Draft sdk 0.2 output is not relabelled until this exact product enters.
4
+ import {createHash} from 'node:crypto';
5
+ import {spawnSync} from 'node:child_process';
6
+ import {readFileSync,writeFileSync,mkdirSync,mkdtempSync,rmSync,readdirSync,statSync,lstatSync} from 'node:fs';
7
+ import {tmpdir} from 'node:os';
8
+ import {join,resolve,dirname} from 'node:path';
9
+ import {fileURLToPath} from 'node:url';
10
+ import '@wildshard/format/formatHook';
11
+ import {readCookData,cookMountPath} from '@wildshard/format/cookData';
12
+ import {cookPreparationBytes,readEntryPrograms,requireCookPreparation} from '@wildshard/format/cookPreparation';
13
+ import {parseOutputIndex,assembleOutputShardfile} from '@wildshard/format/outputIndex';
14
+ import {controlFileHashes,playLibrarySteps} from '@wildshard/format/admissionControl';
15
+ import {entryFileSteps} from '@wildshard/format/tierSelection';
16
+ import {validationSourceBytes} from '@wildshard/format/validationReceipt';
17
+ import {prepareAssetDecoders} from '@wildshard/format/product';
18
+ import {validateShardfileProduct} from '@wildshard/format/productValidation';
19
+
20
+ const hash=bytes=>createHash('sha256').update(bytes).digest('hex');
21
+ const json=(dir,name)=>JSON.parse(readFileSync(join(dir,name),'utf8'));
22
+ const bytesOf=value=>validationSourceBytes(value);
23
+ const drain=steps=>{for(;;){const row=steps.next();if(row.done)return row.value;}};
24
+
25
+ function productPaths(dir){
26
+ if(lstatSync(dir).isSymbolicLink())throw new Error('The shard file folder to prepare must be a regular directory');
27
+ const entries=readdirSync(dir,{recursive:true,withFileTypes:true});
28
+ if(entries.some(row=>!row.isDirectory()&&!row.isFile()))throw new Error('The shard file folder to prepare must hold regular files, not symlinks');
29
+ return entries.filter(row=>row.isFile()).map(row=>join(row.parentPath,row.name).slice(dir.length+1).split('\\').join('/'));
30
+ }
31
+ async function validateFinished(dir,index){
32
+ const paths=productPaths(dir);
33
+ await prepareAssetDecoders();
34
+ validateShardfileProduct({paths:()=>paths,read:(path,cap)=>{
35
+ const file=join(dir,path);if(statSync(file).size>cap)throw new Error(`Preparation read exceeds byte cap: ${path}`);
36
+ return readFileSync(file);
37
+ }},{hash});
38
+ // This is the same admitted source and validator revision; only the index
39
+ // transport digest changed. Never invent a new cost or revision receipt.
40
+ const receipt=json(dir,'validation.json');
41
+ if(receipt.indexHash!==undefined){
42
+ receipt.indexHash=hash(bytesOf(index));
43
+ writeFileSync(join(dir,'validation.json'),bytesOf(receipt));
44
+ }
45
+ }
46
+
47
+ /** The producer's computed conservative dependency fence plus actual cold reads. */
48
+ export function preparationFence(index,sections,recording,mounts){
49
+ const source=assembleOutputShardfile(index,sections),descriptor={index,sections};
50
+ const cold=drain(playLibrarySteps(source,descriptor));
51
+ const required=controlFileHashes({...source,library:source.library.filter(row=>!cold.has(row))});
52
+ const excluded=drain(entryFileSteps(source,'phone',descriptor));
53
+ const known=new Set([...index.files.map(row=>row.hash),...mounts.map(row=>row.hash),...index.requires.commons]);
54
+ return [...new Set([...required,...(recording.hashes??[]).filter(row=>known.has(row)),...index.files.filter(row=>recording.reads.some(url=>url.endsWith(`/${row.path}`))).map(row=>row.hash),...mounts.filter(row=>recording.reads.some(url=>url.endsWith(row.url))).map(row=>row.hash)])].filter(row=>!excluded.has(row)).sort();
55
+ }
56
+
57
+ /** Only the measured recorder envelope can finish the exact candidate. */
58
+ export async function finishPreparation(dir,recording,originalHeader){
59
+ dir=resolve(dir);
60
+ productPaths(dir); // Refuse linked output paths before any file is written.
61
+ const header=readFileSync(join(dir,'shard.json'));
62
+ if(hash(header)!==hash(originalHeader)||recording.headerHash!==hash(header))throw new Error('Candidate changed during preparation; rerun wildshard prepare');
63
+ const held=parseOutputIndex(JSON.parse(header)),programs=readEntryPrograms(recording.programs),renderer=recording.renderer;
64
+ if(typeof renderer!=='string'||!/^[a-f0-9]{64}$/u.test(renderer))throw new Error('Recording has no engine renderer revision; use a D5 preparation preview');
65
+ const sections=new Map(held.sections.map(row=>[row.name,json(dir,row.path)]));
66
+ const old=held.cook===undefined?{mounts:[]}:readCookData(json(dir,'cook.json'));
67
+ const url=`/programs/${held.identity.slug}.json`,path=cookMountPath(url),programBytes=bytesOf(programs);
68
+ const mounts=[...old.mounts.filter(row=>row.url!==url),{url,path,hash:hash(programBytes),bytes:programBytes.length}].sort((a,b)=>a.url.localeCompare(b.url));
69
+ const index={...held,sdk:'0.3'},fence=preparationFence(index,sections,recording,mounts);
70
+ // A full phone set contains every admitted non-desktop file. Only a strict
71
+ // measured subset needs the existing fence policy; desktop stays whole.
72
+ const all=index.files.filter(row=>row.tier!=='desktop'),selected=new Set(fence);
73
+ const packs=all.some(row=>!selected.has(row.hash))?'fence':'whole';
74
+ const cook={version:3,mounts,packs,fence,programs,renderer,inputHash:hash(cookPreparationBytes(index,mounts,renderer))};
75
+ const bytes=bytesOf(cook),next={...index,cook:{path:'cook.json',hash:hash(bytes),bytes:bytes.length}};
76
+ requireCookPreparation(parseOutputIndex(next),readCookData(cook),hash);
77
+ mkdirSync(dirname(join(dir,path)),{recursive:true});writeFileSync(join(dir,path),programBytes);
78
+ writeFileSync(join(dir,'cook.json'),bytes);writeFileSync(join(dir,'shard.json'),bytesOf(next));
79
+ await validateFinished(dir,next);
80
+ return {slug:index.identity.slug,fence:fence.length,programs:programs.programs.length,renderer,document:programs.build};
81
+ }
82
+
83
+ export async function prepareProduct(dir,base){
84
+ const header=readFileSync(join(dir,'shard.json')),index=parseOutputIndex(JSON.parse(header));
85
+ const scratch=mkdtempSync(join(tmpdir(),'wildshard-prepare-'));
86
+ try{
87
+ const out=join(scratch,'recording.json');
88
+ const script=fileURLToPath(new URL('./bake-entry-programs.mjs',import.meta.url));
89
+ // Like the existing recorder, the operator runs this command through the
90
+ // engine browser-lane wrapper. Do not acquire a second nested browser slot.
91
+ const run=spawnSync(process.execPath,[script,'--base',base,'--out',out,'--header',hash(header),'--title',index.identity.name,index.identity.slug],{stdio:'inherit',timeout:300000});
92
+ if(run.error!==undefined||run.status!==0)throw new Error('Phone WebKit preparation did not pass; candidate left as a draft');
93
+ return await finishPreparation(dir,json(scratch,'recording.json'),header);
94
+ }finally{rmSync(scratch,{recursive:true,force:true});}
95
+ }
96
+
97
+ if(process.argv[1]!==undefined&&resolve(process.argv[1])===fileURLToPath(import.meta.url)){
98
+ const [dir,flag,base]=process.argv.slice(2);
99
+ if(dir===undefined||flag!=='--base'||base===undefined)throw new Error('usage: wildshard prepare <folder> --base <exact-preview-url>');
100
+ console.log(JSON.stringify(await prepareProduct(resolve(dir),base)));
101
+ }
@@ -0,0 +1,3 @@
1
+ /** Await each selected native tool exactly once; failed preparation refuses before worker startup. */
2
+ export function prepareProductBuildTools(products: readonly string[], input?: unknown,
3
+ ports?: Readonly<Record<'basis', () => Promise<unknown>>>): Promise<readonly 'basis'[]>;
@@ -0,0 +1,3 @@
1
+ {
2
+ "far-reach": ["basis"]
3
+ }
@@ -0,0 +1,31 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { readFileSync } from 'node:fs';
3
+ import { resolve as resolvePath } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ import * as v from 'valibot';
6
+
7
+ const Product = v.pipe(v.string(), v.regex(/^[a-z_][a-z0-9_-]*$/u));
8
+ const Registry = v.pipe(v.custom(value => value !== null && typeof value === 'object' && !Array.isArray(value)),
9
+ v.record(Product, v.pipe(v.array(v.literal('basis')), v.minLength(1), v.maxLength(1))));
10
+ const preparers = { basis: () => new Promise((resolve, reject) => {
11
+ const child = spawn(process.execPath, ['--import', fileURLToPath(import.meta.resolve('@wildshard/engine/scripts/bake-loader.mjs')),
12
+ fileURLToPath(new URL('prepare-basis-tool.mjs', import.meta.url))], { cwd: resolvePath(import.meta.dirname, '..'), stdio: 'inherit' });
13
+ child.on('error', reject);
14
+ child.on('close', (code, signal) => code === 0 ? resolve(undefined) : reject(new Error(`Pinned Basis prerequisite exited ${String(code ?? signal)}`)));
15
+ }) };
16
+
17
+ /** Await only selected products' explicit native prerequisites before starting CPU-heavy workers.
18
+ * Registry absence, unknown tools and failed checked preparation refuse the phase.
19
+ * @param {readonly string[]} products
20
+ * @param {unknown} [input]
21
+ * @param {Readonly<Record<'basis',()=>Promise<unknown>>>} [ports]
22
+ * @returns {Promise<readonly 'basis'[]>} */
23
+ export async function prepareProductBuildTools(products,
24
+ input = JSON.parse(readFileSync(new URL('product-build-tools.json', import.meta.url), 'utf8')), ports = preparers) {
25
+ const selected = v.parse(v.array(Product), products), registry = v.parse(Registry, input);
26
+ const tools = [...new Set(selected.flatMap(product => registry[product] ?? []))].sort();
27
+ const started = performance.now();
28
+ for (const tool of tools) await ports[tool]();
29
+ if (tools.length > 0) console.info(`Product build prerequisites: ${tools.join(', ')} ready in ${Math.round(performance.now() - started)} ms (before product workers)`);
30
+ return tools;
31
+ }
@@ -0,0 +1,7 @@
1
+ // A gathered shard's published files, copied to the public URLs a build reads. The aliases are gitignored.
2
+ import { cpSync, existsSync } from 'node:fs';
3
+
4
+ for (const slug of ["_template","ink-cel-valley","pastel-plain"]) {
5
+ const tree = `src/shards/${slug}/assets/public`;
6
+ if (existsSync(tree)) cpSync(tree, `public/assets/${slug}`, { recursive: true, force: true });
7
+ }
@@ -0,0 +1 @@
1
+ export function pushTables(root:string):void;
@@ -0,0 +1,28 @@
1
+ // D8 exception: small source declarations only, never asset/product generation.
2
+ import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
3
+ import { dirname, resolve } from 'node:path';
4
+ import { authoredManifestSource, productManifestPath } from '@wildshard/engine/scripts/authored-manifest.mjs';
5
+ import { manifestFolders, outputManifest, shardProducts } from '@wildshard/engine/scripts/shard-outputs.mjs';
6
+ import { genStarterArmClips } from '@wildshard/engine/scripts/gen-starter-arm-clips.mjs';
7
+ import { genStarterWeapons } from '@wildshard/engine/scripts/gen-starter-weapons.mjs';
8
+ import { genStarterBag } from '@wildshard/engine/scripts/gen-starter-bag.mjs';
9
+ import { genStarterEffects } from '@wildshard/engine/scripts/gen-starter-effects.mjs';
10
+ import { relocateDiscoverySource } from './gen-shards.mjs';
11
+
12
+ /** @param {string} root */
13
+ export function pushTables(root) {
14
+ genStarterArmClips(root); genStarterWeapons(root); genStarterBag(root); genStarterEffects(root);
15
+ for (const product of shardProducts(root, manifestFolders(root))) {
16
+ if (!existsSync(resolve(root, 'src/shards', product.folder, 'manifest.json'))) continue;
17
+ const composed = product.output === null ? null : outputManifest(root, product.folder, product.output);
18
+ const path = resolve(root, productManifestPath(root, product));
19
+ mkdirSync(dirname(path), { recursive: true });
20
+ writeFileSync(path, relocateDiscoverySource(root, product, authoredManifestSource(root, product.slug, {
21
+ folder: product.folder, composed, generation: true, metadataOnly: true,
22
+ })));
23
+ }
24
+ }
25
+
26
+ if (process.argv[1] && resolve(process.argv[1]) === resolve(import.meta.filename)) {
27
+ pushTables(resolve(process.argv[2] ?? '.'));
28
+ }