@wildshard/sdk 0.0.0 → 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 +14 -4
  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 +371 -4
  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,117 @@
1
+ import { parseDecisionScripts, scriptV1Identifier, SCRIPT_V1_REFERENCE_KINDS, type DecisionScriptRow } from '@wildshard/format/decisionScripts';
2
+ import { SCRIPT_V1_EVENTS, SCRIPT_V1_COMMANDS, SCRIPT_V1_READS, SCRIPT_V1_LISTS, type ScriptV1EventName } from '@wildshard/format/scriptAbiV1';
3
+ import { decisionBindingMap, type DecisionRegistries, type DecisionBindingMap } from './decisionBindingMap';
4
+ import { WS_CORE } from './as/ws';
5
+
6
+ interface Method { args: string; values: string; result?: 'i32' | 'f64' | 'bool' }
7
+ const reads: Record<keyof typeof SCRIPT_V1_READS, Method> = {
8
+ x:{args:'actor:i32',values:'f64(actor)'},y:{args:'actor:i32',values:'f64(actor)'},z:{args:'actor:i32',values:'f64(actor)'},
9
+ yaw:{args:'actor:i32',values:'f64(actor)'},hpShare:{args:'actor:i32',values:'f64(actor)'},alive:{args:'actor:i32',values:'f64(actor)',result:'bool'},
10
+ field:{args:'actor:i32,field:i32',values:'f64(actor),f64(field)'},distance:{args:'actor:i32,target:i32',values:'f64(actor),f64(target)'},
11
+ nearestPlayer:{args:'actor:i32',values:'f64(actor)',result:'i32'},flag:{args:'flag:i32',values:'f64(flag)',result:'bool'},
12
+ timerLeft:{args:'timer:i32',values:'f64(timer)'},random:{args:'',values:''},actorInZone:{args:'actor:i32,zone:i32',values:'f64(actor),f64(zone)',result:'bool'},
13
+ playersInZone:{args:'zone:i32',values:'f64(zone)',result:'i32'},moving:{args:'actor:i32',values:'f64(actor)',result:'bool'},
14
+ strikeState:{args:'actor:i32',values:'f64(actor)',result:'i32'},playerFlag:{args:'player:i32,flag:i32',values:'f64(player),f64(flag)',result:'bool'},
15
+ spawnGroupAlive:{args:'spawn:i32',values:'f64(spawn)',result:'i32'},bearing:{args:'actor:i32,target:i32',values:'f64(actor),f64(target)'},
16
+ bodyX:{args:'body:i32',values:'f64(body)'},bodyY:{args:'body:i32',values:'f64(body)'},bodyZ:{args:'body:i32',values:'f64(body)'},
17
+ bodyAlive:{args:'body:i32',values:'f64(body)',result:'bool'},
18
+ bodyYaw:{args:'body:i32',values:'f64(body)'},bodyVisible:{args:'body:i32',values:'f64(body)',result:'bool'},
19
+ playerIntent:{args:'axis:i32',values:'f64(axis)'},
20
+ };
21
+ const lists: Record<keyof typeof SCRIPT_V1_LISTS, Method> = {
22
+ actorsInZone:{args:'zone:i32',values:'f64(zone)'},playersWithin:{args:'actor:i32,radius:f64',values:'f64(actor),radius'},
23
+ groundHeight:{args:'x:f64,z:f64',values:'x,z'},nearestWalkable:{args:'x:f64,z:f64',values:'x,z'},path:{args:'actor:i32,target:i32',values:'f64(actor),f64(target)'},
24
+ radial:{args:'angle:f64,radius:f64=1',values:'angle,radius'},
25
+ declaredFloor:{args:'x:f64,z:f64',values:'x,z'},
26
+ };
27
+ const commands: Record<keyof typeof SCRIPT_V1_COMMANDS, Method> = {
28
+ move:{args:'actor:i32,move:i32,target:i32=0',values:'actor,f64(move),f64(target)'},
29
+ strike:{args:'actor:i32,strike:i32,target:i32=0',values:'actor,f64(strike),f64(target)'},stop:{args:'actor:i32',values:'actor'},
30
+ field:{args:'actor:i32,field:i32,value:f64',values:'actor,f64(field),value'},spawn:{args:'spawn:i32',values:'0,f64(spawn)'},despawn:{args:'actor:i32',values:'actor'},
31
+ flag:{args:'flag:i32,value:bool,player:i32=0',values:'player,f64(flag),value?1.0:0.0'},timer:{args:'timer:i32,seconds:f64',values:'0,f64(timer),seconds'},
32
+ signal:{args:'signal:i32,value:f64=0',values:'0,f64(signal),value'},grant:{args:'fact:i32,player:i32=0',values:'player,f64(fact)'},
33
+ reward:{args:'reward:i32,player:i32=0',values:'player,f64(reward)'},cue:{args:'cue:i32,actor:i32=0',values:'actor,f64(cue)'},
34
+ channel:{args:'channel:i32,value:f64',values:'0,f64(channel),value'},impulse:{args:'target:i32,impulse:i32',values:'target,f64(impulse)'},
35
+ encounter:{args:'verb:i32,value:f64=0',values:'0,f64(verb),value'},weather:{args:'weather:i32',values:'0,f64(weather)'},
36
+ 'body.spawn':{args:'body:i32',values:'0,f64(body)'},
37
+ 'body.teleport':{args:'body:i32,x:f64,y:f64,z:f64',values:'body,x,y,z'},
38
+ 'collider.enabled':{args:'collider:i32,on:bool',values:'0,f64(collider),on?1.0:0.0'},
39
+ 'body.place':{args:'body:i32,x:f64,z:f64,yaw:f64',values:'body,x,z,yaw'},
40
+ 'body.visible':{args:'body:i32,on:bool',values:'body,on?1.0:0.0'},
41
+ 'body.retire':{args:'body:i32',values:'body'},
42
+ 'view.channel':{args:'channel:i32,value:f64',values:'0,f64(channel),value'},'view.clip':{args:'actor:i32,clip:i32',values:'actor,f64(clip)'},
43
+ 'view.vfx':{args:'actor:i32,cue:i32',values:'actor,f64(cue)'},'view.sound':{args:'actor:i32,cue:i32',values:'actor,f64(cue)'},
44
+ 'view.visible':{args:'actor:i32,value:bool',values:'actor,value?1.0:0.0'},
45
+ 'view.field':{args:'field:i32,value:f64',values:'0,f64(field),value'},
46
+ };
47
+ /** Handlers follow the design's implicit-subject form; Event.subject retains the full current subject for multi-actor bindings. */
48
+ export const DECISION_HANDLERS: Record<ScriptV1EventName, { name: string; args: string }> = {
49
+ start:{name:'onStart',args:''},tick:{name:'onTick',args:'Clock.dt'},timer:{name:'onTimer',args:'i32(__ws.value(1))'},
50
+ 'zone.enter':{name:'onZoneEnter',args:'i32(__ws.value(1)),i32(__ws.value(2))'},'zone.leave':{name:'onZoneLeave',args:'i32(__ws.value(1)),i32(__ws.value(2))'},
51
+ interact:{name:'onInteract',args:'i32(__ws.value(1)),i32(__ws.value(2)),i32(__ws.value(3))'},
52
+ hit:{name:'onHit',args:'i32(__ws.value(2)),__ws.value(3),__ws.value(4)'},threshold:{name:'onThreshold',args:'i32(__ws.value(2))'},death:{name:'onDeath',args:'i32(__ws.value(2))'},
53
+ 'move.done':{name:'onMoveDone',args:'i32(__ws.value(2)),__ws.value(3)==1'},'strike.done':{name:'onStrikeDone',args:'i32(__ws.value(2)),__ws.value(3)==1'},
54
+ flag:{name:'onFlag',args:'i32(__ws.value(1)),__ws.value(2)==1'},signal:{name:'onSignal',args:'i32(__ws.value(1)),__ws.value(2),i32(__ws.value(3))'},
55
+ 'strike.target':{name:'onStrikeTarget',args:'i32(__ws.value(1)),i32(__ws.value(2)),i32(__ws.value(3))'},
56
+ 'player.join':{name:'onPlayerJoin',args:'i32(__ws.value(1))'},'player.leave':{name:'onPlayerLeave',args:'i32(__ws.value(1))'},
57
+ spawned:{name:'onSpawned',args:'i32(__ws.value(2))'},stop:{name:'onStop',args:''},
58
+ field:{name:'onField',args:'i32(__ws.value(1)),i32(__ws.value(2)),__ws.value(3)'},cue:{name:'onCue',args:'i32(__ws.value(1)),i32(__ws.value(2))'},
59
+ channel:{name:'onChannel',args:'i32(__ws.value(1)),__ws.value(2)'},
60
+ };
61
+ const namespaces = {actors:'Actor',moves:'Move',strikes:'Strike',cues:'Cue',fields:'Field',flags:'Flag',zones:'Zone',spots:'Spot',targets:'Target',spawns:'Spawn',signals:'Signal',facts:'Fact',rewards:'Reward',channels:'Channel',impulses:'Impulse',weather:'Weather',bodies:'Body',colliders:'Collider'} as const;
62
+ /** Safe generated filename shared by the compiler and author imports. */
63
+ export function decisionBindingsPath(row: Pick<DecisionScriptRow,'id'>): string { return `behaviour/generated/${scriptV1Identifier(row.id)}.ts`; }
64
+ /** Allocation-free, capability-specific AssemblyScript bindings plus the only ABI entry point. */
65
+ export function generateDecisionBindings(input: unknown, registries: DecisionRegistries, options: { development?: boolean; singleSignal?: boolean } = {}): {
66
+ row: DecisionScriptRow; map: DecisionBindingMap; path: string; bindings: string; glue: string; sources: Readonly<Record<string,string>>;
67
+ } {
68
+ const row = parseDecisionScripts([input])[0]; if (row === undefined) throw new Error('Missing decision row');
69
+ const map = decisionBindingMap(row,registries), lines = ['// Generated from the admitted decision row. Never edit.',"import * as core from '../../sdk/as/ws';"];
70
+ for (const kind of [...SCRIPT_V1_REFERENCE_KINDS,'timers'] as const) {
71
+ // Unused additive namespaces must not perturb existing guest bytecode.
72
+ if ((kind === 'bodies' || kind === 'colliders') && Object.keys(map.ids[kind] ?? {}).length === 0) continue;
73
+ const name = kind === 'timers' ? 'Timer' : namespaces[kind];
74
+ lines.push(`export namespace ${name} {`,...Object.entries(map.ids[kind]??{}).map(([alias,id])=>` export const ${scriptV1Identifier(alias)}:i32=${id};`),'}');
75
+ }
76
+ lines.push('export class State {');
77
+ for (const [index,slot] of row.state.entries()) {
78
+ const name=scriptV1Identifier(slot.name), value=`core.state(${index})`, type=slot.type;
79
+ const check=options.development===false||type==='bool'?'':`assert(value>=${slot.min??(type==='i32'?-2147483648:-Number.MAX_VALUE)}&&value<=${slot.max??(type==='i32'?2147483647:Number.MAX_VALUE)});`;
80
+ lines.push(` @inline static get ${name}():${type}{return ${type==='bool'?`${value}==1`:`${type}(${value})`};}`,
81
+ ` @inline static set ${name}(value:${type}){${check}core.setState(${index},${type==='bool'?'value?1.0:0.0':'f64(value)'});}`);
82
+ }
83
+ lines.push('}','export class Params {',...map.paramNames.map((name,index)=>` @inline static get ${scriptV1Identifier(name)}():f64{return core.parameter(${index});}`),'}',
84
+ 'export class Clock {',...['tick','dt','binding','self'].map((name,index)=>` @inline static get ${name}():${name==='dt'?'f64':'i32'}{return ${name==='dt'?`core.header(${index})`:`i32(core.header(${index}))`};}`),'}',
85
+ 'export class Event {',...['kind','subject','a','b','c','d'].map((name,index)=>` @inline static get ${name}():f64{return core.event(${index});}`),'}','export class Read {');
86
+ let hasList=false;
87
+ for(const name of row.reads) {
88
+ if(Object.hasOwn(SCRIPT_V1_READS,name)) {
89
+ const key=name as keyof typeof SCRIPT_V1_READS, method=reads[key], type=method.result??'f64',call=`core.read(${SCRIPT_V1_READS[key]}${method.values?',':''}${method.values})`;
90
+ lines.push(` @inline static ${scriptV1Identifier(name)}(${method.args}):${type}{return ${type==='bool'?`${call}!=0`:type==='i32'?`i32(${call})`:call};}`);
91
+ } else {
92
+ const key=name as keyof typeof SCRIPT_V1_LISTS,method=lists[key];hasList=true;
93
+ lines.push(` @inline static ${name}(${method.args}):i32{return core.list(${SCRIPT_V1_LISTS[key]},${method.values});}`);
94
+ }
95
+ }
96
+ lines.push('}');if(hasList)lines.push('export class List {@inline static at(index:i32):f64{return core.listAt(index);}}');
97
+ lines.push('export class Do {');
98
+ for(const name of row.commands){const method=commands[name];lines.push(` @inline static ${scriptV1Identifier(name)}(${method.args}):void{core.command(${SCRIPT_V1_COMMANDS[name]},${method.values});}`);}
99
+ if(row.commands.includes('encounter'))lines.push(' @inline static encounterPhase(index:i32):void{Do.encounter(1,f64(index));}',' @inline static encounterWin():void{Do.encounter(2);}',' @inline static encounterFail():void{Do.encounter(3); }');
100
+ lines.push('}','export class __ws {',` @inline static init():void{core.init(${row.state.length},${map.paramNames.length});}`,
101
+ ' @inline static io():i32{return core.io();}',' @inline static begin():void{core.begin();}',' @inline static end():i32{return core.finish();}',
102
+ ' @inline static count():i32{return core.events();}',' @inline static select(index:i32):void{core.selectEvent(index);}',' @inline static value(field:i32):f64{return core.event(field);}','}');
103
+ const path=decisionBindingsPath(row),handlers=row.on.map(name=>DECISION_HANDLERS[name]);
104
+ let glue=[`import {${handlers.map(handler=>handler.name).join(',')}} from './${row.source.slice(0,-3)}';`,
105
+ `import {__ws,Clock} from './${path.slice(0,-3)}';`,'export function ws_abi():i32{return 1;}',
106
+ 'export function ws_init(lo:i32,hi:i32):void{__ws.init();}','export function ws_io():i32{return __ws.io();}',
107
+ 'export function ws_handle():i32{__ws.begin();for(let index:i32=0;index<__ws.count();index++){__ws.select(index);switch(i32(__ws.value(0))){',
108
+ ...row.on.map(name=>`case ${SCRIPT_V1_EVENTS[name]}:${DECISION_HANDLERS[name].name}(${DECISION_HANDLERS[name].args});break;`),
109
+ 'default:unreachable();}}return __ws.end();}'].join('\n');
110
+ // Return projections already submit exactly one stateless signal per request.
111
+ // Emit their fixed transport directly; general ABI inboxes keep their loop.
112
+ if(options.singleSignal===true){
113
+ if(row.on.length!==1||row.on[0]!=='signal'||row.state.length>0||row.tick!==null||row.timers.length>0||row.commands.some(command=>command!=='channel'))throw new Error('Single-signal transport requires a stateless return projection');
114
+ glue=`${glue.slice(0,glue.indexOf('export function ws_handle'))}export function ws_handle():i32{__ws.begin();assert(__ws.count()==1);__ws.select(0);assert(i32(__ws.value(0))==${SCRIPT_V1_EVENTS.signal});onSignal(${DECISION_HANDLERS.signal.args});return __ws.end();}`;
115
+ }
116
+ const bindings=lines.join('\n');return {row,map,path,bindings,glue,sources:{[path]:bindings,'sdk/as/ws.ts':WS_CORE}};
117
+ }
@@ -0,0 +1,28 @@
1
+ import { parseReturnProjectionV2 as parseProjection, type ReturnProjectionV2Rows as Projection } from '@wildshard/format/returnProjectionV2';
2
+ import { parseDecisionScripts as parse, SCRIPT_V1_REFERENCE_KINDS, type DecisionScriptRow as Row } from '@wildshard/format/decisionScripts';
3
+ import { SCRIPT_V2_REVISIONS } from '@wildshard/format/scriptAdmissionV2';
4
+ import { parseActorProjectionV2 as nativeActorProjection } from '@wildshard/format/actorProjectionV2';
5
+ import type { GroupStepProfileV2 } from '@wildshard/format/scriptGroupStepV2';
6
+
7
+ /** Complete group author profile, including bank, columns, signals and native actions. */
8
+ export type AuthorGroupStepProfile = GroupStepProfileV2;
9
+
10
+ /** Version stamps for source-owned projection metadata; no compiler is loaded. */
11
+ export function scriptV2Revisions(): typeof SCRIPT_V2_REVISIONS { return SCRIPT_V2_REVISIONS; }
12
+
13
+ /** Defining v1 reference maps whose empty defaults may be omitted from author wires. */
14
+ export function scriptV1ReferenceKinds(): typeof SCRIPT_V1_REFERENCE_KINDS { return SCRIPT_V1_REFERENCE_KINDS; }
15
+
16
+ /** Admitted decision-script metadata, independent of source readers and compilation services. */
17
+ export type DecisionScriptRow = Row;
18
+ /** Admit bounded script metadata with the unchanged runtime contract; no source file is read or compiled. */
19
+ export function parseDecisionScripts(input: unknown): readonly Row[] { return parse(input); }
20
+
21
+ /** Strict numeric projection metadata, with no compiler or filesystem dependency. */
22
+ export type ReturnProjectionV2Rows = Projection;
23
+ /** Admit cached or authored projection metadata through the runtime's complete contract. */
24
+ export function parseReturnProjectionV2(input: unknown): ReturnProjectionV2Rows { return parseProjection(input); }
25
+
26
+ /** Admit JSON actor columns and operations with the defining ABI2, declared
27
+ * signal/field/channel checks. No compiler, runtime or continuation is created. */
28
+ export function actorProjectionRows(input: unknown): ReturnType<typeof nativeActorProjection> { return nativeActorProjection(input); }
@@ -0,0 +1,51 @@
1
+ import { loadAssemblyScriptParser } from './assemblyscriptCompiler.mjs';
2
+ import type { DecisionScriptRow } from '@wildshard/format/decisionScripts';
3
+ import { DECISION_HANDLERS } from './decisionScriptBindings';
4
+
5
+ interface Parser {
6
+ onComment: ((kind: number, text: string, range: { start: number; end: number }) => void) | null;
7
+ parseFile: (text: string, path: string, entry: boolean) => void;
8
+ diagnostics: readonly unknown[];
9
+ sources: readonly { statements: readonly unknown[] }[];
10
+ }
11
+ interface ParserModule { Parser: new () => Parser }
12
+ function parserModule(value: unknown): value is ParserModule {
13
+ return typeof value === 'object' && value !== null && 'Parser' in value && typeof value.Parser === 'function';
14
+ }
15
+ function record(value: unknown): Record<string, unknown> {
16
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) throw new Error('Invalid AssemblyScript syntax tree');
17
+ return Object.fromEntries(Object.entries(value));
18
+ }
19
+ /** Count the pinned parser's source lines; comment-looking text inside strings remains authored code. */
20
+ export async function inspectDecisionSource(text: string, path: string): Promise<{ lines: number; handlers: readonly string[]; imports: readonly string[] }> {
21
+ if (text.length > 1_000_000) throw new Error('AssemblyScript source exceeds byte cap');
22
+ const module = await loadAssemblyScriptParser();
23
+ if (!parserModule(module)) throw new Error('Invalid pinned AssemblyScript parser');
24
+ const parser = new module.Parser(), spans: { start: number; end: number }[] = [];
25
+ parser.onComment = (_block, _text, range) => { spans.push({ start: range.start, end: range.end }); };
26
+ parser.parseFile(text, path, true);
27
+ if (parser.diagnostics.length > 0) throw new Error(`Invalid AssemblyScript source: ${path}`);
28
+ const handlers: string[] = [], imports: string[] = [];
29
+ for (const source of parser.sources) for (const statement of source.statements) {
30
+ const node = record(statement);
31
+ if (node['kind'] === 56 && typeof node['flags'] === 'number' && (node['flags'] & 2) !== 0) {
32
+ const name = record(node['name'])['text'];
33
+ if (typeof name !== 'string') throw new Error('Invalid AssemblyScript function name');
34
+
35
+ if (/^on[A-Z]/u.test(name)) handlers.push(name);
36
+ }
37
+ if (node['kind'] === 43) {
38
+ const name = record(node['path'])['value'];
39
+ if (typeof name !== 'string') throw new Error('Invalid AssemblyScript import');
40
+ imports.push(name);
41
+ }
42
+ }
43
+ let cleaned = text;
44
+ for (const span of spans.sort((a, b) => b.start - a.start)) cleaned = cleaned.slice(0, span.start) + cleaned.slice(span.start, span.end).replaceAll(/[^\r\n]/gu, ' ') + cleaned.slice(span.end);
45
+ return { lines: cleaned.split(/\r?\n/u).filter(line => line.trim().length > 0).length, handlers, imports };
46
+ }
47
+ /** A subscription must have exactly its named exported handler; extra handlers never silently sleep. */
48
+ export function checkDecisionHandlers(row: DecisionScriptRow, handlers: readonly string[]): void {
49
+ const expected = new Set(row.on.map(event => DECISION_HANDLERS[event].name));
50
+ if (handlers.length !== expected.size || handlers.some(name => !expected.has(name)) || new Set(handlers).size !== handlers.length) throw new Error(`Decision handlers must match on: ${[...expected].join(', ')}`);
51
+ }
@@ -0,0 +1,113 @@
1
+ // oxlint-disable-next-line import/no-nodejs-modules -- Serve only built static products from the local author tool.
2
+ import { createServer } from 'node:http';
3
+ // oxlint-disable-next-line import/no-nodejs-modules -- Author changes rebuild a private disposable product.
4
+ import { createReadStream, existsSync, mkdtempSync, realpathSync, readdirSync, rmSync, statSync, watch, readFileSync, writeFileSync, type Dirent } from 'node:fs';
5
+ // oxlint-disable-next-line import/no-nodejs-modules -- Own temporary build directory.
6
+ import { tmpdir } from 'node:os';
7
+ // oxlint-disable-next-line import/no-nodejs-modules -- Resolve static requests inside the product directory.
8
+ import { extname, join, resolve, sep } from 'node:path';
9
+ import { buildProject } from './project';
10
+ import { Scope } from '@wildshard/engine/app/scope';
11
+
12
+ const POLL = '<script>let wsRevision=WS_REVISION;setInterval(async()=>{try{const r=await fetch("/__wildshard_dev_revision",{cache:"no-store"});const s=await r.json();if(s.error){console.error(s.error);return}if(s.revision!==wsRevision)location.reload()}catch{}},500)</script>';
13
+ const MIME: Record<string, string> = { '.html': 'text/html', '.js': 'text/javascript', '.css': 'text/css', '.json': 'application/json', '.wasm': 'application/wasm', '.svg': 'image/svg+xml', '.png': 'image/png', '.woff2': 'font/woff2', '.ktx2': 'image/ktx2' };
14
+ // .worktrees: a shard repo's plan worktrees (DEV-SPEED DS11) are other checkouts, never this project's source.
15
+ const ignored = new Set(['node_modules', '.git', 'dist', 'public', '.worktrees']);
16
+
17
+ /** Synchronous author-source baseline: native recursive watch notifications can miss quick overwrites during startup.
18
+ * Nanosecond change time also detects same-length edits whose modification time was restored. Symlink directories
19
+ * are not traversed; output/dependency directories keep the existing watcher exclusions. */
20
+ export function projectSourceStamp(source: string): string {
21
+ const directories = [source], rows: string[] = [];
22
+ while (directories.length > 0) {
23
+ const directory = directories.pop(); if (directory === undefined) break;
24
+ let entries: Dirent[];
25
+ try { entries = readdirSync(directory, { withFileTypes: true }); }
26
+ catch (cause) { if (cause instanceof Error && 'code' in cause && cause.code === 'ENOENT') continue; throw cause; }
27
+ for (const entry of entries) {
28
+ if (ignored.has(entry.name)) continue;
29
+ const file = join(directory, entry.name);
30
+ if (entry.isDirectory()) { directories.push(file); continue; }
31
+ const metadata = statSync(file, { bigint: true, throwIfNoEntry: false });
32
+ if (metadata === undefined) continue;
33
+ if (metadata.isFile()) rows.push(`${file}\0${metadata.ino}:${metadata.size}:${metadata.mtimeNs}:${metadata.ctimeNs}`);
34
+ }
35
+ }
36
+ return rows.sort().join('\n');
37
+ }
38
+ /** A rebuilt static author client. Closing it releases its watcher, socket and private build products. */
39
+ export interface DevProject { url: string; close: () => Promise<void> }
40
+ /** Only the author command chooses DEVSERVER; requests, cookies and URL switches cannot enable it. */
41
+ export async function devProject(project: string, options: { decisionLegacyLines?: number; port?: number; client?: string } = {}): Promise<DevProject> {
42
+ const source = resolve(project), scratch = realpathSync(mkdtempSync(join(tmpdir(), 'wildshard-dev-')));
43
+ let revision = 0, error: string | null = null, current = '', previous = '', stopped = false;
44
+ const scope = new Scope('sdk.dev');
45
+ let debounce: Scope | undefined, work = Promise.resolve();
46
+ const rebuild = async (): Promise<void> => {
47
+ if (stopped) return;
48
+ const target = join(scratch, `build-${revision + 1}`);
49
+ try {
50
+ await buildProject(source, target, { devserver: true, ...(options.decisionLegacyLines === undefined ? {} : { decisionLegacyLines: options.decisionLegacyLines }), ...(options.client === undefined ? {} : { client: options.client }) });
51
+ const page = join(target, 'index.html');
52
+ if (!existsSync(page)) throw new Error('wildshard dev requires the SDK devserver client; build/pack the SDK first');
53
+ const flags: unknown = JSON.parse(readFileSync(join(target, 'build-flags.json'), 'utf8'));
54
+ if (typeof flags !== 'object' || flags === null || !('devserver' in flags) || flags.devserver !== true) throw new Error('wildshard dev requires a client compiled in devserver mode');
55
+ writeFileSync(page, readFileSync(page, 'utf8').replace('</body>', `${POLL.replace('WS_REVISION', String(revision + 1))}</body>`));
56
+ if (previous !== '') rmSync(previous, { recursive: true, force: true });
57
+ previous = current; current = target; revision++; error = null;
58
+ } catch (cause) {
59
+ rmSync(target, { recursive: true, force: true }); error = cause instanceof Error ? cause.message : String(cause);
60
+ if (current === '') throw cause;
61
+ console.error(`wildshard dev: rebuild failed; serving previous product: ${error}`);
62
+ }
63
+ };
64
+ try { await rebuild(); } catch (cause) { rmSync(scratch, { recursive: true, force: true }); throw cause; }
65
+ const server = createServer((request, response) => {
66
+ response.setHeader('Cache-Control', 'no-store');
67
+ try {
68
+ const path = decodeURIComponent(new URL(request.url ?? '/', 'http://localhost').pathname);
69
+ if (path === '/__wildshard_dev_revision') {
70
+ response.setHeader('Content-Type', 'application/json'); response.end(JSON.stringify({ revision, error })); return;
71
+ }
72
+ if (request.method !== 'GET' && request.method !== 'HEAD') { response.writeHead(405); response.end(); return; }
73
+ const local = path === '/' ? 'index.html' : path.slice(1);
74
+ const file = [current, previous].filter((dir) => dir !== '').map((dir) => ({ dir, file: resolve(dir, local) }))
75
+ .find(({ dir, file: candidate }) => candidate.startsWith(`${dir}${sep}`) && existsSync(candidate) && statSync(candidate).isFile() && realpathSync(candidate).startsWith(`${dir}${sep}`));
76
+ if (file === undefined) { response.writeHead(404); response.end(); return; }
77
+ response.setHeader('Content-Type', MIME[extname(file.file)] ?? 'application/octet-stream');
78
+ if (request.method === 'HEAD') response.end(); else createReadStream(file.file).on('error', () => { response.destroy(); }).pipe(response);
79
+ } catch { response.writeHead(400); response.end(); }
80
+ });
81
+ try {
82
+ await new Promise<void>((_resolve, reject) => { server.once('error', reject); server.listen(options.port ?? 0, '127.0.0.1', _resolve); });
83
+ } catch (cause) { rmSync(scratch, { recursive: true, force: true }); throw cause; }
84
+ let observed = projectSourceStamp(source);
85
+ const reconcile = (): void => {
86
+ const next = projectSourceStamp(source);
87
+ if (next === observed) return;
88
+ observed = next;
89
+ debounce?.dispose(); debounce = scope.child('rebuild.debounce');
90
+ debounce.timeout(100, () => { debounce?.dispose(); work = work.then(rebuild); });
91
+ };
92
+ // One recursive watch per top-level folder that isn't ignored, and a flat one on the root: a recursive watch on the
93
+ // root would still walk and watch every ignored folder on Linux (a shard repo's .worktrees/ holds whole checkouts).
94
+ // A folder made later is seen by the 250 ms poll below.
95
+ const onChange = (prefix: string) => (_event: string, filename: string | null): void => {
96
+ if (`${prefix}${filename ?? ''}`.split(/[\\/]/u).some((part) => ignored.has(part))) return;
97
+ reconcile();
98
+ };
99
+ const watchers = [watch(source, onChange('')), ...readdirSync(source, { withFileTypes: true })
100
+ .filter((entry) => entry.isDirectory() && !ignored.has(entry.name))
101
+ .map((entry) => watch(join(source, entry.name), { recursive: true }, onChange(`${entry.name}/`)))];
102
+ // Capture before returning the ready server; polling covers native-event gaps without rebuilding unchanged input.
103
+ scope.interval(250, reconcile);
104
+ const address = server.address(); if (address === null || typeof address === 'string') throw new Error('No author server address');
105
+ return { url: `http://127.0.0.1:${address.port}/`, close: async () => {
106
+ if (stopped) return;
107
+ stopped = true; for (const watcher of watchers) watcher.close(); scope.dispose();
108
+ await new Promise<void>((_resolve) => { server.close(() => { _resolve(); }); server.closeAllConnections(); });
109
+ // A build already running owns its directory until its promise finishes.
110
+ await work;
111
+ rmSync(scratch, { recursive: true, force: true });
112
+ } };
113
+ }
@@ -0,0 +1,26 @@
1
+ import type { parseDirector } from '@wildshard/format/director';
2
+ import { directorDataHostIssues, parseDirectorStages, type DirectorStagesData, type DirectorStagesDefinition } from '@wildshard/format/directorStages';
3
+ import { Object3D } from 'three';
4
+ import { parseChapterDirector } from '@wildshard/format/chapterDirector';
5
+
6
+ /** Admit closed chapter effects, observations and wake wiring before any entered director exists. */
7
+ export function chapterDirectorRows(input: unknown): ReturnType<typeof parseChapterDirector> { return parseChapterDirector(input); }
8
+
9
+ /** Typed director data with bounded observations, payloads and reserved grid subscriptions. */
10
+ export type DirectorData = ReturnType<typeof parseDirector>;
11
+
12
+ /** Author a bounded stage machine. Inputs name native owners; the build emits rows without installing gameplay. */
13
+ export class Director {
14
+ private readonly definition: DirectorStagesData;
15
+ constructor(definition: Omit<DirectorStagesDefinition, 'version'>) {
16
+ this.definition = structuredClone(parseDirectorStages({ ...definition, version: 2 }));
17
+ }
18
+ /** Emit independent JSON data, retaining stage and action registration order. */
19
+ toJSON(): DirectorStagesData { return structuredClone(this.definition); }
20
+ /** Inspect stock data-only support without granting native ownership or changing admitted rows. */
21
+ dataHostIssues(): readonly string[] { return directorDataHostIssues(this.definition); }
22
+ /** Attach this data declaration to a named graph node for scene.json transport; never installs a stage host. */
23
+ attachTo(parent: Object3D): Object3D {
24
+ const object = new Object3D(); object.name = this.definition.id; object.userData['director'] = this; parent.add(object); return object;
25
+ }
26
+ }
@@ -0,0 +1,77 @@
1
+ import { parseDirector } from '@wildshard/format/director';
2
+ import { parseDirectorStages } from '@wildshard/format/directorStages';
3
+ import { StateSchema } from '@wildshard/format/state';
4
+ import * as v from 'valibot';
5
+
6
+ const identifier = /^[A-Za-z_][A-Za-z0-9_]*$/u;
7
+ const reserved = new Set(['true', 'false', 'null', 'constructor', 'prototype', '__proto__', 'new', 'return', 'class', 'static', 'get', 'set', 'export', 'import', 'default', 'extends', 'implements', 'private', 'public', 'protected', 'this', 'super', 'if', 'else', 'for', 'while', 'switch', 'case', 'break', 'continue', 'function', 'let', 'const', 'var', 'void', 'type', 'interface', 'namespace', 'enum', 'try', 'catch', 'throw']);
8
+ function camel(key: string): string { return key.replaceAll(/[.-]([a-z0-9])/gu, (_match: string, letter: string) => letter.toUpperCase()); }
9
+ /** Generate readable, allocation-free AssemblyScript accessors from admitted v1 numeric or v2 boolean director inputs.
10
+ * v1 inputs remain f64 even at bounds 0..1: a bounded channel is not implicitly a boolean (night can be fractional).
11
+ * Input aliases use camelCase; collisions and reserved words refuse before compilation.
12
+ * Clock and incomingEvents expose the unchanged ABI-v0 host channels. */
13
+ export function generateDirectorAbi(input: unknown): string {
14
+ const boolean = typeof input === 'object' && input !== null && 'version' in input && input.version === 2;
15
+ const names = boolean ? Object.keys(parseDirectorStages(input).inputs) : parseDirector(input).inputs.map(row => camel(row.key));
16
+ if (names.some(name => name.length > 128 || !identifier.test(name) || reserved.has(name)) || new Set(names).size !== names.length) throw new Error('Director ABI names must be unique AssemblyScript identifiers');
17
+ const getter = (name: string, address: number): string => ` @inline static get ${name}(): f64 { return load<f64>(${address}); }`;
18
+ return [
19
+ '// DO-NOT-EDIT: generated by @wildshard/sharddev/directorAbi from the admitted director declaration.',
20
+ '// ABI v0: the host validates observations, event counts and parameter values before this module runs.',
21
+ 'export class inputs {', ...names.map((name, index) => boolean
22
+ ? ` @inline static get ${name}(): bool { return load<f64>(${16384 + (6 + index) * 8}) === 1; }`
23
+ : getter(name, 16384 + (6 + index) * 8)), '}',
24
+ 'export class clock {', getter('tick', 16384), getter('dt', 16392), getter('self', 16408), '}',
25
+ 'export class incomingEvents {',
26
+ ' @inline static get count(): i32 { return i32(load<f64>(16640)); }',
27
+ ' @inline static type(index: i32): f64 { return load<f64>(16648 + index * 48); }', '}',
28
+ ].join('\n');
29
+ }
30
+
31
+ /** An executable numeric ABI-v0 module and its exact byte/record layout, generated from admitted state rows. */
32
+ export interface GeneratedScriptModule {
33
+ source: string;
34
+ layout: { version: 0; inputBytes: number; outputRecords: number; outputBytes: number; eventCountOffset: 256; eventOffset: 264; eventStride: 48; effectStride: 40; minimumPages: 1 };
35
+ }
36
+
37
+ /** Generate a complete typed AS handler: host exports, allocated buffers, clocks, events and actor-scoped state effects.
38
+ * Capacities are bytes for in_cap and five-f64 records for out_cap. Native actor binding is never authored here.
39
+ * State getters follow stable field-ID order; strings have no numeric ABI and refuse. The handler is the on_tick body. */
40
+ export function generateScriptModule(state: unknown, handler: string, options: { events?: number; effects?: number } = {}): GeneratedScriptModule {
41
+ const row = v.parse(StateSchema, state), events = options.events ?? 32, effects = options.effects ?? 8;
42
+ if (!Number.isInteger(events) || events < 0 || events > 32 || !Number.isInteger(effects) || effects < 1 || effects > 128) throw new Error('ABI event/effect capacity outside host limits');
43
+ if ([...row.shared, ...row.player].some(field => field.type === 'string')) throw new Error('Strings have no numeric script ABI');
44
+ const shared = [...row.shared].sort((a, b) => a.id - b.id), player = [...row.player].sort((a, b) => a.id - b.id);
45
+ const fields = (list: typeof shared, start: number, operation: number): string[] => {
46
+ const names = list.map(field => camel(field.name));
47
+ if (names.some(name => !identifier.test(name) || reserved.has(name)) || new Set(names).size !== names.length) throw new Error('State ABI aliases must be unique AssemblyScript identifiers');
48
+ return list.flatMap((field, index) => {
49
+ const name = names[index], type = field.type === 'bool' ? 'bool' : field.type;
50
+ if (name === undefined) throw new Error('Missing state ABI alias');
51
+ const read = `load<f64>(INPUT + ${8 * (start + index)})`;
52
+ return [` @inline static get ${name}(): ${type} { return ${type === 'bool' ? `${read} === 1` : `${type}(${read})`}; }`,
53
+ ` @inline static set ${name}(value: ${type}) { ${operation === 6 ? 'assert(clock.actorToken > 0); ' : ''}effects.write(${operation}, ${field.id}, f64(value), 0, 0); }`];
54
+ });
55
+ };
56
+ const inputBytes = 264 + events * 48, outputBytes = effects * 40;
57
+ const source = [
58
+ '// DO-NOT-EDIT: generated by @wildshard/sharddev/directorAbi#generateScriptModule from admitted state rows.',
59
+ '// ABI v0: in_cap is BYTES; out_cap is RECORDS. Host-owned actor provenance cannot be supplied by an effect.',
60
+ `const INPUT: usize = memory.data(${inputBytes});`, `const OUTPUT: usize = memory.data(${outputBytes});`, 'let count: i32 = 0;',
61
+ 'export function abi_version(): i32 { return 0; }', 'export function init(seedLo: i32, seedHi: i32): void {}',
62
+ 'export function in_ptr(): i32 { return i32(INPUT); }', `export function in_cap(): i32 { return ${inputBytes}; }`,
63
+ 'export function out_ptr(): i32 { return i32(OUTPUT); }', `export function out_cap(): i32 { return ${effects}; }`,
64
+ 'export function out_count(): i32 { return count; }',
65
+ 'class clock {',
66
+ ...['tick', 'dt', 'command', 'self', 'actorToken', 'role', 'sharedCount', 'playerCount'].map((name, index) => ` @inline static get ${name}(): f64 { return load<f64>(INPUT + ${index * 8}); }`), '}',
67
+ 'class incomingEvents {', ' @inline static get count(): i32 { return i32(load<f64>(INPUT + 256)); }',
68
+ ...['type', 'target', 'value'].map((name, index) => ` @inline static ${name}(index: i32): f64 { assert(index >= 0 && index < incomingEvents.count); return load<f64>(INPUT + 264 + usize(index) * 48 + ${index * 8}); }`), '}',
69
+ 'class effects {', ' @inline static write(op: f64, a: f64, b: f64, c: f64, d: f64): void {',
70
+ ` assert(count < ${effects}); const at = OUTPUT + usize(count++) * 40;`,
71
+ ...['op', 'a', 'b', 'c', 'd'].map((name, index) => ` store<f64>(at + ${index * 8}, ${name});`), ' }',
72
+ ' @inline static event(type: i32, target: i32, value: f64): void { effects.write(3, type, target, value, 0); }', '}',
73
+ 'class shared {', ...fields(shared, 8, 5), '}', 'class player {', ...fields(player, 8 + shared.length, 6), '}',
74
+ 'export function on_tick(): void { count = 0;', handler, '}', '',
75
+ ].join('\n');
76
+ return { source, layout: { version: 0, inputBytes, outputRecords: effects, outputBytes, eventCountOffset: 256, eventOffset: 264, eventStride: 48, effectStride: 40, minimumPages: 1 } };
77
+ }
@@ -0,0 +1,97 @@
1
+ import type { DiscoveryValues } from '@wildshard/format/discoveryValues';
2
+
3
+ /** C3 (J61): what a page needs of a shard before its product admits, as data in the product. `data` is the packed `ui/level`
4
+ * manifest; `rows` and `native` are what its bindings resolve to, with `{$call}` naming a game function the reader applies
5
+ * (`src/client/game/shard/discovery.ts`). A binding that needs a shard's own code at runtime has no row here and refuses. */
6
+ export interface DiscoveryCall {readonly $call: string; readonly args: readonly unknown[]}
7
+ export interface DiscoveryDocument {
8
+ readonly version: 1;
9
+ readonly slug: string;
10
+ readonly data: unknown;
11
+ readonly rows: Readonly<Record<string, unknown>>;
12
+ readonly native: Readonly<Record<string, unknown>>;
13
+ /** Each image URL the manifest names and its bytes, for a boot's download totals. */
14
+ readonly art?: Readonly<Record<string, number>>;
15
+ }
16
+ /** A binding's module export: `(module, export)`, read from the author's project. */
17
+ export type ProjectValue = (module: string, name: string) => Promise<unknown>;
18
+ export const discoveryUrl = (folder: string): string => `/shardfiles/${folder}/discovery.json`;
19
+
20
+ type Row = Readonly<Record<string, unknown>>;
21
+ const isRow = (value: unknown): value is Row => typeof value === 'object' && value !== null && !Array.isArray(value);
22
+ const call = ($call: string, ...args: readonly unknown[]): DiscoveryCall => ({$call, args});
23
+ const SAMPLED = ['runtimeCost', 'mapPalette', 'poses', 'groundRows', 'groundColourSamples', 'surfaceSamples', 'forestMaskSamples', 'mapGroundSamples', 'navmesh'] as const;
24
+ const BOOT = ['files', 'sources', 'lateReads', 'bakedUnread', 'explore'] as const;
25
+
26
+ /** The manifest's bindings as data: `read` stands where a generated module's import stood. */
27
+ export async function discoveryDocument(slug: string, data: unknown, values: DiscoveryValues | undefined, read: ProjectValue): Promise<DiscoveryDocument> {
28
+ if (!isRow(data) || !isRow(data['bindings'])) throw new Error(`${slug}: discovery needs a level manifest with bindings`);
29
+ const b = data['bindings'], rows: Record<string, unknown> = {accent: b['accent']}, native: Record<string, unknown> = {};
30
+ const row = (key: string): Row | undefined => { const value = b[key]; return isRow(value) ? value : undefined; };
31
+ const text = (value: unknown, label: string): string => { if (typeof value !== 'string') throw new Error(`${slug}: ${label} needs a name`); return value; };
32
+ const value = (ref: unknown, key?: string): Promise<unknown> => {
33
+ if (isRow(ref) && ref['program'] === true) {
34
+ if (key === undefined || values === undefined || !Object.hasOwn(values, key)) throw new Error(`${slug}: no program value ${key ?? ''}`);
35
+ return Promise.resolve(Reflect.get(values, key));
36
+ }
37
+ if (!isRow(ref)) throw new Error(`${slug}: invalid binding ${key ?? ''}`);
38
+ return read(text(ref['module'], 'a binding'), text(ref['export'] ?? 'default', 'a binding'));
39
+ };
40
+ rows['budgets'] = await value(b['budgets'], 'budgets');
41
+ for (const key of SAMPLED) if (b[key] !== undefined) rows[key] = await value(b[key], key);
42
+ const forest = row('forestQueries');
43
+ if (forest?.['platform'] === 'fixed') rows['forestQueries'] = call('forestFixed', forest);
44
+ else if (forest?.['platform'] === 'declared') rows['forestRows'] = await value(forest['rows'], 'forestQueries.rows');
45
+ else if (forest !== undefined) rows['forestQueries'] = await value(forest, 'forestQueries');
46
+ const pond = row('pondClip');
47
+ if (pond?.['platform'] === 'declared') rows['pondClip'] = call('pondDeclared', await value(pond['rows'], 'pondClip.rows'));
48
+ else if (pond !== undefined) rows['pondClip'] = await value(pond, 'pondClip');
49
+ if (b['spawns'] !== undefined) rows['spawns'] = await value(b['spawns'], 'spawns');
50
+ if (b['navigation'] !== undefined) {
51
+ const held = await value(b['navigation'], 'navigation');
52
+ if (!isRow(held)) throw new Error(`${slug}: invalid navigation`);
53
+ rows['navigation'] = {row: held['navigation'], url: held['url']};
54
+ }
55
+ if (b['audioPreload'] !== undefined) throw new Error(`${slug}: an audio preload is shard code`);
56
+ if (b['audioCues'] !== undefined) rows['audioBindings'] = {cues: await value(b['audioCues'], 'audioCues')};
57
+ const sword = row('sword');
58
+ if (sword?.['platform'] === 'graph') rows['sword'] = call('swordGraph', slug, sword['file']);
59
+ else if (sword?.['rows'] !== undefined) rows['sword'] = call('swordRows', await value({module: sword['rows']}));
60
+ else if (sword !== undefined) throw new Error(`${slug}: a sword factory is shard code`);
61
+ const boot = row('boot');
62
+ if (boot?.['platform'] === 'page-mode') rows['bootBindings'] = call('pageModeBoot', await value(boot['rows'], 'boot.pageModes'));
63
+ else if (boot !== undefined) {
64
+ if (boot['audio'] !== undefined) throw new Error(`${slug}: a boot audio factory is shard code`);
65
+ const bindings: Record<string, unknown> = {};
66
+ for (const key of BOOT) if (boot[key] !== undefined) bindings[key] = await value(boot[key], `boot.${key}`);
67
+ rows['bootBindings'] = bindings;
68
+ }
69
+ const render = row('render');
70
+ if (render?.['platform'] === 'toon') native['render'] = call('renderToon');
71
+ else if (render?.['platform'] === 'painted') native['render'] = call('renderPainted');
72
+ else if (render?.['platform'] === 'post') native['render'] = call('renderPost', {file: render['file'], field: render['field']});
73
+ else if (render?.['platform'] === 'keyed') {
74
+ const trim = await value(render['trim']);
75
+ if (!isRow(trim)) throw new Error(`${slug}: invalid sky trim`);
76
+ native['render'] = call('renderKeyed', {channels: render['channels'], looks: await value(render['looks']), trim: trim[text(render['trimRow'], 'a trim row')]});
77
+ } else if (render !== undefined) throw new Error(`${slug}: a look factory is shard code`);
78
+ const ground = row('ground');
79
+ if (ground?.['platform'] === 'declared') native['ground'] = call('groundDeclared', await value(ground['rows'], 'ground.rows'), data['ground'] ?? {});
80
+ else if (ground !== undefined) native['ground'] = await value(ground, 'ground');
81
+ const roster = row('roster');
82
+ if (roster?.['platform'] === 'held') native['roster'] = call('rosterHeld', await value({module: roster['rows']}));
83
+ else if (roster !== undefined) throw new Error(`${slug}: a roster factory is shard code`);
84
+ const entry = row('entry');
85
+ if (b['load'] !== undefined) throw new Error(`${slug}: a load module is shard code`);
86
+ if (entry !== undefined) {
87
+ const styles = Array.isArray(entry['styles']) ? entry['styles'] : [];
88
+ native['load'] = call('planEntry', {retainHomeRuntime: entry['retainHomeRuntime'], stagesOwner: entry['stagesOwner']},
89
+ await Promise.all(styles.map(style => read(text(style, 'a style'), 'css'))));
90
+ }
91
+ const ktx2 = row('ktx2');
92
+ if (ktx2?.['program'] === true) native['ktx2'] = {GPU_FILES: await value(ktx2, 'ktx2')};
93
+ else if (ktx2?.['platform'] === 'page-mode') native['ktx2'] = call('pageModeKtx2', await value(ktx2['rows'], 'ktx2.pageModes'));
94
+ else if (ktx2 !== undefined) native['ktx2'] = {GPU_FILES: await value({module: ktx2['module'], export: ktx2['export'] ?? 'GPU_FILES'}, 'ktx2')};
95
+ if (b['posesLoader'] !== undefined) throw new Error(`${slug}: a poses loader is shard code`);
96
+ return {version: 1, slug, data, rows, native};
97
+ }
@@ -0,0 +1,11 @@
1
+ // QA-FEEDBACK 11-13 row 2 (J198, J259): `wildshard build` writes a draft shard file, `sdk: "0.2"`. Only `wildshard prepare`
2
+ // (J198, scripts/prepare-product.mjs) makes it `"0.3"`, and api-server refuses a draft at commit (422). So build and check
3
+ // warn, and upload refuses a draft before a byte is sent (rule `shardfile-draft` in refusals.ts).
4
+
5
+ /** The `sdk` marker of an unprepared draft; a prepared shard file says `0.3`. */
6
+ export const DRAFT_SDK = '0.2';
7
+
8
+ /** The words build and check warn with and upload refuses with. */
9
+ export function draftMessage(slug: string): string {
10
+ return `${slug} is an unprepared draft (sdk 0.2): api-server refuses a draft at commit, so prepare its folder and build it again before upload`;
11
+ }
@@ -0,0 +1,29 @@
1
+ import { parseEliteEntryRows as parseRows, parseEliteEntryPageRows as parsePage,
2
+ ELITE_BODY_COLUMNS as bodyColumns, ELITE_CONDITION_COLUMNS as conditionColumns,
3
+ type EliteEntryRows as Rows, type EliteEntryPageRows as Page } from '@wildshard/format/eliteEntryRows';
4
+ import { parseEliteOutputActions as parseActions, type EliteOutputAction as Action,
5
+ ELITE_VIEW_FIELDS as viewFields, eliteViewSource as viewSource, eliteViewTell as viewTell } from '@wildshard/format/eliteFeature';
6
+
7
+ /** Defining ordered input columns lent by each elite's native presentation owner. */
8
+ export const ELITE_VIEW_FIELDS: typeof viewFields = viewFields;
9
+ /** Native named input source; constructing its label installs no view owner. */
10
+ export function eliteViewSource(elite: string): string { return viewSource(elite); }
11
+ /** Native named lane tell; its lifetime remains with the entered owner. */
12
+ export function eliteViewTell(elite: string): string { return viewTell(elite); }
13
+
14
+ /** Admitted native elite-construction rows. */
15
+ export type EliteEntryRows = Rows;
16
+ /** Admitted page-owned elite-construction rows. */
17
+ export type EliteEntryPageRows = Page;
18
+ /** An admitted bounded output action. */
19
+ export type EliteOutputAction = Action;
20
+ /** Stable observation columns used by the defining construction host. */
21
+ export const ELITE_BODY_COLUMNS: typeof bodyColumns = bodyColumns;
22
+ /** Stable condition columns used by the defining construction host. */
23
+ export const ELITE_CONDITION_COLUMNS: typeof conditionColumns = conditionColumns;
24
+ /** Admit native construction data with the unchanged runtime parser. */
25
+ export function parseEliteEntryRows(input: unknown): Rows { return parseRows(input); }
26
+ /** Admit page construction data with the unchanged runtime parser. */
27
+ export function parseEliteEntryPageRows(input: unknown): Page { return parsePage(input); }
28
+ /** Admit ordered output actions against the original controller bound. */
29
+ export function parseEliteOutputActions(input: unknown, controllers: number): readonly Action[] { return parseActions(input, controllers); }