@wildshard/sdk 0.2.13 → 0.3.1

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 (88) hide show
  1. package/GUIDE.md +26 -13
  2. package/bin/wildshard.mjs +2 -1
  3. package/docs/api/EXPORT-TIERS.md +16 -4
  4. package/lint/export-tiers.json +12 -0
  5. package/lint/host-callbacks.mjs +1 -1
  6. package/package.json +22 -6
  7. package/scripts/bake/template-skins.mjs +6 -3
  8. package/scripts/bake/template-warden.mjs +25 -0
  9. package/scripts/build-shardfiles.mjs +7 -2
  10. package/scripts/export-ci21-guests.mjs +89 -0
  11. package/scripts/prepare-product.mjs +2 -2
  12. package/scripts/scratch-sweep.mjs +182 -0
  13. package/scripts/wildshard.mjs +1 -1
  14. package/skills/wildshard-mockup-to-model/SKILL.md +5 -3
  15. package/skills/wildshard-upgrade/SKILL.md +4 -4
  16. package/src/cli/help.ts +9 -5
  17. package/src/cli/upload/validate.ts +7 -5
  18. package/src/sharddev/as/prelude.ts +67 -0
  19. package/src/sharddev/assets.ts +1 -1
  20. package/src/sharddev/authorLint.ts +45 -0
  21. package/src/sharddev/bake/compactGlb.ts +1 -1
  22. package/src/sharddev/bake/compileScript.ts +6 -0
  23. package/src/sharddev/bake/glbCompression.ts +1 -1
  24. package/src/sharddev/bake/gltfSource.ts +1 -1
  25. package/src/sharddev/bake/placeholders.ts +1 -1
  26. package/src/sharddev/bake/terrain.ts +12 -3
  27. package/src/sharddev/blobBytes.ts +1 -1
  28. package/src/sharddev/blobs.ts +2 -2
  29. package/src/sharddev/checkProject.ts +7 -18
  30. package/src/sharddev/cli.ts +17 -4
  31. package/src/sharddev/engineMusic.ts +23 -0
  32. package/src/sharddev/formatJsonSchema.ts +1 -1
  33. package/src/sharddev/materialGraphFiles.ts +1 -1
  34. package/src/sharddev/materials.ts +7 -3
  35. package/src/sharddev/newProject.ts +18 -10
  36. package/src/sharddev/outputProduct.ts +2 -2
  37. package/src/sharddev/productOutput.ts +2 -2
  38. package/src/sharddev/project.ts +6 -1
  39. package/src/sharddev/projectMap.ts +1 -1
  40. package/src/sharddev/refusals.ts +5 -3
  41. package/src/sharddev/reportCard.ts +1 -1
  42. package/src/sharddev/scene/author.ts +184 -0
  43. package/src/sharddev/scene/canvas.ts +212 -0
  44. package/src/sharddev/scene/description.ts +223 -0
  45. package/src/sharddev/scene/hash.ts +23 -0
  46. package/src/sharddev/scene/lower.ts +341 -0
  47. package/src/sharddev/scene/shard.ts +41 -0
  48. package/src/sharddev/scene/shardfile.ts +621 -0
  49. package/src/sharddev/threeGate.mjs +14 -0
  50. package/src/sharddev/threePin.mjs +40 -0
  51. package/src/sharddev/watch/page.ts +284 -0
  52. package/src/sharddev/watch/pageEntry.ts +59 -0
  53. package/src/sharddev/watch/parity-baseline.json +22 -0
  54. package/src/sharddev/watch/parity.mjs +168 -0
  55. package/src/sharddev/watch/proof.mjs +199 -0
  56. package/src/sharddev/watch/protocol.ts +166 -0
  57. package/src/sharddev/watch/socket.ts +57 -0
  58. package/src/sharddev/watch/watch.ts +373 -0
  59. package/src/shards/_template/assets/3058c100bc477fd6fe8268f33b53756b8a2556e7e41c58b2216c703ca7b042c6 +1 -0
  60. package/src/shards/_template/assets/8a0440f392737a31cf0926a3c7dc011c320144972882945a5462c893e817d94a +0 -0
  61. package/src/shards/_template/behaviour/door.as +16 -26
  62. package/src/shards/_template/card/landscape.jpg +0 -0
  63. package/src/shards/_template/card/portrait.jpg +0 -0
  64. package/src/shards/_template/card/thumb.jpg +0 -0
  65. package/src/shards/_template/data/clientScripts.json +43 -43
  66. package/src/shards/_template/data/creatures.json +2 -2
  67. package/src/shards/_template/data/look.json +141 -13
  68. package/src/shards/_template/data/rows.json +20 -2
  69. package/src/shards/_template/data/skins.json +32 -0
  70. package/src/shards/_template/data/water.json +18 -0
  71. package/src/shards/_template/generators/product.ts +5 -1
  72. package/src/shards/_template/generators/warden.ts +273 -0
  73. package/src/shards/_template/generators/world.ts +52 -21
  74. package/src/shards/_template/hero.json +6 -6
  75. package/src/shards/authoring-slice/generators/shard.ts +14 -0
  76. package/src/shards/authoring-slice/generators/sky.ts +64 -0
  77. package/src/shards/authoring-slice/generators/template-sky.ts +27 -0
  78. package/src/shards/authoring-slice/generators/textures.ts +232 -0
  79. package/src/shards/authoring-slice/generators/world.ts +518 -0
  80. package/src/shards/authoring-slice/shard.config.ts +7 -0
  81. package/src/shards/mossgate/generators/shard.ts +6 -0
  82. package/src/shards/mossgate/generators/sky.ts +64 -0
  83. package/src/shards/mossgate/generators/textures.ts +249 -0
  84. package/src/shards/mossgate/generators/world.ts +998 -0
  85. package/src/shards/mossgate/shard.config.ts +7 -0
  86. package/scripts/shard-output-report.d.mts +0 -9
  87. package/scripts/shard-output-report.mjs +0 -85
  88. package/scripts/shard-platform-cli.mjs +0 -93
package/GUIDE.md CHANGED
@@ -54,9 +54,10 @@ with `rule`, `fix` and `guide`) for agents and scripts.
54
54
 
55
55
  | Verb | What it is for |
56
56
  |---|---|
57
- | `wildshard new <dir> [slug] [--template sdk\|blender] [--empty]` | Start a shard repo in a folder that does not exist yet, its shard source at `src/`. The slug is the folder's name unless you give one. `--template sdk` (the default) copies the reference world; `--template blender` copies the hand-written Blender template (below); any other template refuses before writing. `--empty` writes a bare shard source instead of the reference world |
57
+ | `wildshard new <dir> [slug] [--template sdk] [--empty]` | Start a shard repo in a folder that does not exist yet, its shard source at `src/`. The slug is the folder's name unless you give one. It copies the reference world (`--template sdk`, the only template); any other template refuses before writing, and `--template blender` is retired (below). `--empty` writes a bare shard source instead of the reference world |
58
58
  | `wildshard update [dir] [--pins[=<version>]]` | Rewrite this guide and the four `wildshard` skills from the installed sdk. `--pins` first moves the repo to a newer sdk release (npm's latest, or `--pins=<version>`), installs it and applies its codemods, and runs `check` after (section 7) |
59
59
  | `wildshard dev <source>` | Serve the shard source on localhost and rebuild on every save (section 4). The first run fetches engine's dev client once ("Walking your shard") |
60
+ | `wildshard watch <source>` | For a shard written as a three.js scene (`@wildshard/sdk/scene/shard`): serve it once, then swap each edited part into the running page in about a second, no reload. A look, ground or spawn edit still reloads |
60
61
  | `wildshard check <source> [folder] [--json]` | The loop's check: lint, build, validate, prove, report card, verdict |
61
62
  | `wildshard hero <source> --base <url>` | Capture the hero from a served build and stamp `hero.json`. `--stamp-existing` marks the images already there as current: only when you have looked at them and they show the current world |
62
63
  | `wildshard upload <file> --channel staging\|prod` | Send a prepared shard file to the API (section 5) |
@@ -199,6 +200,13 @@ Blender files (`.blend`), mockups and other working files never ship: keep them
199
200
  runs in the game is data, or Wasm compiled from `behaviour/`. `shard.config.ts` and `generators/` run only at build
200
201
  time; lint refuses runtime code there (section 6).
201
202
 
203
+ **Behaviour scripts read and write by name.** A `behaviour/` script imports the sdk's prelude, `./wildshard`, which
204
+ build supplies: `shared(i)` and `player(i)` read state fields in their declared order, `eventCount()` and
205
+ `eventType(i)` read the call's events, and `setShared(id, value)`, `setPlayer`, `setField`, `emit`, `spawn` and
206
+ `moveTo` write its commands (four a call). Start `on_tick` with `begin()`, and re-export the ABI from it:
207
+ `export { abi_version, init, in_ptr, in_cap, out_ptr, out_cap, out_count } from './wildshard';`. The Template's
208
+ `behaviour/door.as` is the example. A script with its own addresses still builds.
209
+
202
210
  **Repo layout (J317).** A repo with one shard keeps its shard source at `src/` (`src/shard.config.ts`,
203
211
  `src/data/`, ...); a repo with several keeps `src/shards/<slug>/`. Commands take the repo (`.`) and find the shard
204
212
  source at `src/`, or at the one `src/shards/<slug>/` a repo holds; in a repo with several, name the shard source
@@ -206,14 +214,11 @@ source at `src/`, or at the one `src/shards/<slug>/` a repo holds; in a repo wit
206
214
  into the repo's `public/shardfiles/`; a `src/shards/<slug>/` source into its own folder's. SA24 moves the existing
207
215
  single-shard repos to `src/`.
208
216
 
209
- **The hand-written template (`--template blender`).** shard-format's `blender-template`: no sdk at runtime, no
210
- three.js, no `shard.config.ts`. Its `src/` is a shard file folder held by hand: `shard.json` (the index),
211
- `sections/` (the JSON you edit), `blobs/` (baked files, Blender models among them, each named by its SHA-256),
212
- `mounts/` (what the boot reads first, with its receipt) and `validation.json`. `check` lint skips it (no code); its
213
- build runs shard-format's `shard-format pack`, which settles every hash and size the sections measure and validates
214
- the whole folder, then writes the built folder and shard file as any build does. A changed blob is a new file under
215
- its new hash, with every row that names it changed to match. `package.json` lists only `@wildshard/sdk` (the CLI) and
216
- shard-format, as dev dependencies; there is no `tsconfig.json`.
217
+ **Blender makes models, not shards (J341).** A shard is TypeScript three.js scene source: `shard.config.ts`, its
218
+ `generators/` and `data/`. Blender makes the `.glb` models that code loads; export them into `assets/`. The old
219
+ hand-written template (`new --template blender`, a shard file folder held by hand) is retired, and `new` refuses it.
220
+ A repo started that way before still checks and uploads: `wildshard check .` packs and validates its `src/` folder as
221
+ it always did.
217
222
 
218
223
  **What a shard may declare.** The runtime contract lists every section, `client/plan` kind, named file, script rule,
219
224
  budget and limit a shard file may carry, and what validation refuses:
@@ -320,6 +325,12 @@ the rule is chosen by that code, and each heading below that one names lists its
320
325
 
321
326
  ### Any command
322
327
 
328
+ #### three-version
329
+
330
+ `three` is a peer of the sdk, pinned exact (J317): every `wildshard` run first checks that the `three` the sdk would
331
+ import is the version it pins, and refuses naming both before anything else runs. Install that version:
332
+ `pnpm add three@<version> --save-exact`. `wildshard --version` prints the chain the sdk pins, `three` included.
333
+
323
334
  #### usage
324
335
 
325
336
  A verb got arguments or flags it does not take. `wildshard <verb> --help` prints what it takes.
@@ -333,8 +344,9 @@ an existing folder.
333
344
 
334
345
  #### new-template
335
346
 
336
- `--template` names `sdk` (the reference world, the default) or `blender` (the hand-written Blender template). Any
337
- other name refuses before `new` writes anything. Leave the flag out or pass `--template sdk` or `--template blender`.
347
+ `--template` names `sdk` (the reference world, the default and only template). Any other name refuses before `new`
348
+ writes anything. `--template blender` is retired (J341): a shard is TypeScript three.js scene source, and Blender
349
+ makes the `.glb` models it loads (section 2). Leave the flag out or pass `--template sdk`.
338
350
 
339
351
  #### new-refused
340
352
 
@@ -722,11 +734,12 @@ message says which.
722
734
  ### Lint
723
735
 
724
736
  `check` lints the shard source with the sdk's rules. Each wildshard lint rule keeps a shard to data and build-time
725
- code; its printed fix says what to change.
737
+ code; its printed fix says what to change. In a shard repo it runs the repo's own `.oxlintrc.author.json` from the repo
738
+ root, as the repo's `pnpm lint` does (with its `lint/ratchet.json`); a repo without one skips lint and says so.
726
739
 
727
740
  #### lint-not-run
728
741
 
729
- The linter that ships with the sdk did not run. Reinstall the sdk.
742
+ The linter did not run: the repo's oxlint, or the one that ships with the sdk. Reinstall (`pnpm install`).
730
743
 
731
744
  #### lint-refused
732
745
 
package/bin/wildshard.mjs CHANGED
@@ -2,12 +2,13 @@
2
2
  // `wildshard`: the author commands run through scripts/wildshard.mjs, which bundles the CLI once; pack, upload and serve are
3
3
  // this repo's own, and so is `build <folder>` (SA3): a built shard file folder needs no author bundle, only its shard file.
4
4
  // Node strips no types under node_modules, so J82's hook goes first and every import below it is dynamic.
5
+ import '../src/sharddev/threeGate.mjs';
5
6
  import { pathToFileURL } from 'node:url';
6
7
  import { resolve } from 'node:path';
7
8
  import { existsSync } from 'node:fs';
8
9
  import '../src/sharddev/bake/format-hook.mjs';
9
10
 
10
- const AUTHOR = new Set(['new', 'update', 'check', 'synth', 'build', 'validate', 'prove', 'dev', 'schema', '--prepare-compiler']);
11
+ const AUTHOR = new Set(['new', 'update', 'check', 'synth', 'build', 'validate', 'prove', 'dev', 'watch', 'schema', '--prepare-compiler']);
11
12
  const [command, operand] = process.argv.slice(2);
12
13
  // SA2: `wildshard <verb> --help` and `wildshard help [verb]` print help (src/cli/help.ts) before any verb runs.
13
14
  const verbHelp = command === 'help' || (command !== undefined && !command.startsWith('-') && process.argv.slice(3).some(arg => arg === '--help' || arg === '-h'));
@@ -2,7 +2,7 @@
2
2
 
3
3
  <!-- generated by scripts/export-tiers.mjs from package.json exports and lint/export-tiers.json: do not edit -->
4
4
 
5
- 164 exports. A shard project imports from contract, rows, scripts and the bake kit; internal may change in any release. A new export needs a row in `lint/export-tiers.json` (`test/export-tiers.test.ts` fails without one); then run `node scripts/export-tiers.mjs`.
5
+ 176 exports. A shard project imports from contract, rows, scripts and the bake kit; internal may change in any release. A new export needs a row in `lint/export-tiers.json` (`test/export-tiers.test.ts` fails without one); then run `node scripts/export-tiers.mjs`.
6
6
 
7
7
  ## contract (28)
8
8
 
@@ -81,7 +81,7 @@ Content rows: typed helpers that write a section of the shardfile (species, ques
81
81
  | `@wildshard/sdk/weapons/thrownProfile` | rows | `./src/sharddev/weapons/thrownProfile.ts` |
82
82
  | `@wildshard/sdk/worldScenes` | rows | `./src/sharddev/worldScenes.ts` |
83
83
 
84
- ## scripts (17)
84
+ ## scripts (18)
85
85
 
86
86
  Scripts: the decision and client script compilers, their AssemblyScript helpers and the director ABI.
87
87
 
@@ -89,6 +89,7 @@ Scripts: the decision and client script compilers, their AssemblyScript helpers
89
89
  |---|---|---|
90
90
  | `@wildshard/sdk/as/groupBankV2` | scripts | `./src/sharddev/as/groupBankV2.ts` |
91
91
  | `@wildshard/sdk/as/groupStepV2` | scripts | `./src/sharddev/as/groupStepV2.ts` |
92
+ | `@wildshard/sdk/as/prelude` | scripts | `./src/sharddev/as/prelude.ts` |
92
93
  | `@wildshard/sdk/as/ws` | scripts | `./src/sharddev/as/ws.ts` |
93
94
  | `@wildshard/sdk/as/wsV2` | scripts | `./src/sharddev/as/wsV2.ts` |
94
95
  | `@wildshard/sdk/buildBehaviour` | scripts | `./src/sharddev/buildBehaviour.ts` |
@@ -105,7 +106,7 @@ Scripts: the decision and client script compilers, their AssemblyScript helpers
105
106
  | `@wildshard/sdk/directorAbi` | scripts | `./src/sharddev/directorAbi.ts` |
106
107
  | `@wildshard/sdk/returnProjectionV2` | scripts | `./src/sharddev/returnProjectionV2.ts` |
107
108
 
108
- ## bake kit (78)
109
+ ## bake kit (86)
109
110
 
110
111
  The bake kit: build-time geometry, texture, map and commons helpers; nothing here runs in the game.
111
112
 
@@ -162,6 +163,7 @@ The bake kit: build-time geometry, texture, map and commons helpers; nothing her
162
163
  | `@wildshard/sdk/bake/signPlacements` | bake kit | `./src/sharddev/bake/signPlacements.ts` |
163
164
  | `@wildshard/sdk/bake/simplifier` | bake kit | `./src/sharddev/bake/simplifier.ts` |
164
165
  | `@wildshard/sdk/bake/skinned` | bake kit | `./src/sharddev/bake/skinned.ts` |
166
+ | `@wildshard/sdk/bake/slabChunks` | bake kit | `./src/sharddev/bake/slabChunks.ts` |
165
167
  | `@wildshard/sdk/bake/slabs` | bake kit | `./src/sharddev/bake/slabs.ts` |
166
168
  | `@wildshard/sdk/bake/sourceMetadata` | bake kit | `./src/sharddev/bake/sourceMetadata.ts` |
167
169
  | `@wildshard/sdk/bake/species` | bake kit | `./src/sharddev/bake/species.ts` |
@@ -189,8 +191,15 @@ The bake kit: build-time geometry, texture, map and commons helpers; nothing her
189
191
  | `@wildshard/sdk/kit/geometryPack` | bake kit | `./src/sharddev/kit/geometryPack.ts` |
190
192
  | `@wildshard/sdk/noise` | bake kit | `./src/sharddev/noise.ts` |
191
193
  | `@wildshard/sdk/random` | bake kit | `./src/sharddev/random.ts` |
194
+ | `@wildshard/sdk/scene/author` | bake kit | `./src/sharddev/scene/author.ts` |
195
+ | `@wildshard/sdk/scene/canvas` | bake kit | `./src/sharddev/scene/canvas.ts` |
196
+ | `@wildshard/sdk/scene/description` | bake kit | `./src/sharddev/scene/description.ts` |
197
+ | `@wildshard/sdk/scene/lower` | bake kit | `./src/sharddev/scene/lower.ts` |
198
+ | `@wildshard/sdk/scene/shard` | bake kit | `./src/sharddev/scene/shard.ts` |
199
+ | `@wildshard/sdk/scene/shardfile` | bake kit | `./src/sharddev/scene/shardfile.ts` |
200
+ | `@wildshard/sdk/watch/protocol` | bake kit | `./src/sharddev/watch/protocol.ts` |
192
201
 
193
- ## internal (6)
202
+ ## internal (9)
194
203
 
195
204
  Internal: exported for sharddev's own tools and tests; a shard project must not import it, and it may change in any release.
196
205
 
@@ -202,3 +211,6 @@ Internal: exported for sharddev's own tools and tests; a shard project must not
202
211
  | `@wildshard/sdk/scripts/*` | internal | `./scripts/*` |
203
212
  | `@wildshard/sdk/sourceReader` | internal | `./src/sharddev/sourceReader.ts` |
204
213
  | `@wildshard/sdk/test/compileDualScriptV2` | internal | `./src/sharddev/test/compileDualScriptV2.ts` |
214
+ | `@wildshard/sdk/test/scriptScenario` | internal | `./src/sharddev/test/scriptScenario.ts` |
215
+ | `@wildshard/sdk/watch/page` | internal | `./src/sharddev/watch/page.ts` |
216
+ | `@wildshard/sdk/watch/watch` | internal | `./src/sharddev/watch/watch.ts` |
@@ -11,6 +11,15 @@
11
11
  "./package.json": "contract",
12
12
  "./entryReads": "contract",
13
13
  "./immutable": "contract",
14
+ "./scene/shard": "bake kit",
15
+ "./scene/author": "bake kit",
16
+ "./scene/canvas": "bake kit",
17
+ "./scene/lower": "bake kit",
18
+ "./scene/description": "bake kit",
19
+ "./scene/shardfile": "bake kit",
20
+ "./watch/watch": "internal",
21
+ "./watch/protocol": "bake kit",
22
+ "./watch/page": "internal",
14
23
  "./bake/tileEncoder": "bake kit",
15
24
  "./bake/wholePartition": "bake kit",
16
25
  "./bake/basisGlb": "bake kit",
@@ -138,6 +147,7 @@
138
147
  "./blobBytes": "contract",
139
148
  "./schemaValidation": "contract",
140
149
  "./outputProduct": "contract",
150
+ "./as/prelude": "scripts",
141
151
  "./as/ws": "scripts",
142
152
  "./as/wsV2": "scripts",
143
153
  "./decisionScriptBindings": "scripts",
@@ -163,6 +173,7 @@
163
173
  "./bake/nativeInteractionFacts": "bake kit",
164
174
  "./bake/geometryError": "bake kit",
165
175
  "./bake/slabs": "bake kit",
176
+ "./bake/slabChunks": "bake kit",
166
177
  "./bake/wholePieceJoin": "bake kit",
167
178
  "./configBoundary": "internal",
168
179
  "./executeBundle": "internal",
@@ -171,6 +182,7 @@
171
182
  "./commons/courseProgram": "bake kit",
172
183
  "./commons/scripts/course.as": "scripts",
173
184
  "./commons/bake/portableMath": "bake kit",
185
+ "./test/scriptScenario": "internal",
174
186
  "./scripts/*": "internal"
175
187
  }
176
188
  }
@@ -3,7 +3,7 @@ import { existsSync } from 'node:fs';
3
3
  import { relative, resolve } from 'node:path';
4
4
  import ts from '@typescript/typescript6';
5
5
  import { hostPlayFile } from './host-files.mjs';
6
- import { formatSource } from '../scripts/format-package.mjs';
6
+ import { formatSource } from '@wildshard/engine/scripts/format-package.mjs';
7
7
 
8
8
  const projects = new Map();
9
9
  const localPath = (root, file) => relative(root, file).replaceAll('\\', '/');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildshard/sdk",
3
- "version": "0.2.13",
3
+ "version": "0.3.1",
4
4
  "description": "The author's toolbox: the `wildshard` CLI that bakes shard source into a shardfile, the author SDK, the local dev server (engine client against engine server), the explorers, arena and drafts tool.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -63,7 +63,8 @@
63
63
  "agents:sync": "node scripts/agent-sync.mjs",
64
64
  "md:wrap": "node kit/scripts/md-wrap.mjs",
65
65
  "test:hooks": "node --test '.githooks/*.test.mjs'",
66
- "check": "pnpm typecheck && pnpm lint && pnpm format:check && pnpm test && pnpm check:asks && pnpm check:agents && pnpm check:agent-sync && pnpm test:agent-hooks && pnpm check:parity && node --check scripts/chromium-keychain-check.mjs && node --test test/tooling/chrome-keychain.test.mjs test/tooling/worktree-guard.test.mjs",
66
+ "check": "pnpm typecheck && pnpm lint && pnpm format:check && pnpm test && pnpm check:watch-build && pnpm check:asks && pnpm check:agents && pnpm check:agent-sync && pnpm test:agent-hooks && pnpm check:parity && node --check scripts/chromium-keychain-check.mjs && node --test test/tooling/chrome-keychain.test.mjs test/tooling/worktree-guard.test.mjs",
67
+ "check:watch-build": "node src/sharddev/watch/parity.mjs --check",
67
68
  "typecheck:kit": "tsc -p src/tsconfig.json && tsc -p src/web/tsconfig.json",
68
69
  "typecheck:author": "tsc -p tsconfig.author.json",
69
70
  "lint:author": "WILDSHARD_RATCHET_FILE=lint/ratchet.json oxlint -c .oxlintrc.author.json --deny-warnings src/sharddev src/commons src/shards",
@@ -83,8 +84,8 @@
83
84
  "@types/three": "0.186.0",
84
85
  "@typescript/typescript6": "6.0.2",
85
86
  "@valibot/to-json-schema": "1.8.0",
86
- "@wildshard/engine": "0.1.18",
87
- "@wildshard/format": "npm:@wildshard/shard-format@0.4.10",
87
+ "@wildshard/engine": "0.1.21",
88
+ "@wildshard/format": "npm:@wildshard/shard-format@0.5.7",
88
89
  "ajv": "6.15.0",
89
90
  "assemblyscript": "0.28.20",
90
91
  "binaryen": "132.0.0",
@@ -97,11 +98,13 @@
97
98
  "postprocessing": "6.39.5",
98
99
  "preact": "11.1.1",
99
100
  "sharp": "0.35.5",
100
- "three": "0.186.0",
101
101
  "valibot": "1.5.0",
102
102
  "vite": "8.3.0",
103
103
  "vitest": "5.0.1"
104
104
  },
105
+ "peerDependencies": {
106
+ "three": "0.186.0"
107
+ },
105
108
  "devDependencies": {
106
109
  "@playwright/test": "1.65.0",
107
110
  "@types/node": "24.3.1",
@@ -110,6 +113,7 @@
110
113
  "oxfmt": "0.74.0",
111
114
  "oxlint": "1.89.0",
112
115
  "oxlint-tsgolint": "7.0.2004",
116
+ "three": "0.186.0",
113
117
  "typescript": "7.0.2"
114
118
  },
115
119
  "pnpm": {
@@ -198,7 +202,7 @@
198
202
  "overrides": {
199
203
  "binaryen": "npm:@pre-bundled/binaryen@132.0.0-patch-1",
200
204
  "assemblyscript>binaryen": "npm:@pre-bundled/binaryen@131.0.0-nightly.20260721-patch-1",
201
- "@wildshard/format": "npm:@wildshard/shard-format@0.4.10"
205
+ "@wildshard/format": "npm:@wildshard/shard-format@0.5.7"
202
206
  }
203
207
  },
204
208
  "exports": {
@@ -295,9 +299,20 @@
295
299
  "./species/clips": "./src/sharddev/species/clips.ts",
296
300
  "./compileScript": "./src/sharddev/bake/compileScript.ts",
297
301
  "./compileScriptV2": "./src/sharddev/bake/compileScriptV2.ts",
302
+ "./bake/slabChunks": "./src/sharddev/bake/slabChunks.ts",
298
303
  "./test/compileDualScriptV2": "./src/sharddev/test/compileDualScriptV2.ts",
304
+ "./test/scriptScenario": "./src/sharddev/test/scriptScenario.ts",
299
305
  "./buildBehaviour": "./src/sharddev/buildBehaviour.ts",
300
306
  "./scene": "./src/sharddev/scene.ts",
307
+ "./scene/shard": "./src/sharddev/scene/shard.ts",
308
+ "./scene/author": "./src/sharddev/scene/author.ts",
309
+ "./scene/canvas": "./src/sharddev/scene/canvas.ts",
310
+ "./scene/lower": "./src/sharddev/scene/lower.ts",
311
+ "./scene/description": "./src/sharddev/scene/description.ts",
312
+ "./scene/shardfile": "./src/sharddev/scene/shardfile.ts",
313
+ "./watch/watch": "./src/sharddev/watch/watch.ts",
314
+ "./watch/protocol": "./src/sharddev/watch/protocol.ts",
315
+ "./watch/page": "./src/sharddev/watch/page.ts",
301
316
  "./physics": "./src/sharddev/physics.ts",
302
317
  "./entries": "./src/sharddev/entries.ts",
303
318
  "./spawns": "./src/sharddev/spawns.ts",
@@ -332,6 +347,7 @@
332
347
  "./blobBytes": "./src/sharddev/blobBytes.ts",
333
348
  "./schemaValidation": "./src/sharddev/schemaValidation.ts",
334
349
  "./outputProduct": "./src/sharddev/outputProduct.ts",
350
+ "./as/prelude": "./src/sharddev/as/prelude.ts",
335
351
  "./as/ws": "./src/sharddev/as/ws.ts",
336
352
  "./as/wsV2": "./src/sharddev/as/wsV2.ts",
337
353
  "./decisionScriptBindings": "./src/sharddev/decisionScriptBindings.ts",
@@ -3,7 +3,7 @@
3
3
  // (public/assets/baked/skin-fixture, made by scripts/bake/skins.mjs) into the template's content-addressed assets: each
4
4
  // GLB, plus one `json` skin file ({ row, binding }) that depends on it, and writes data/skins.json for shard.config.ts.
5
5
  // P1-S1: it lives in scripts/, beside the fixture's own producer, since that fixture stays when the template moves out.
6
- import { readFileSync, writeFileSync, mkdirSync } from 'node:fs';
6
+ import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
7
7
  import { createHash } from 'node:crypto';
8
8
  import { resolve } from 'node:path';
9
9
 
@@ -29,5 +29,8 @@ const out = species.map(({ species: id, look, skin }) => {
29
29
  { hash: row.file, kind: 'glb', compressed: glb.length, decoded: row.cost.decoded, gpu: row.cost.gpu, triangles: row.cost.triangles, draws: row.cost.draws, dependencies: [], critical: false },
30
30
  ] };
31
31
  });
32
- writeFileSync(resolve(project, 'data/skins.json'), `${JSON.stringify(out, null, 2)}\n`);
33
- console.info(`template skins: ${out.map((entry) => `${entry.species} ${entry.skin.slice(0, 8)}`).join(', ')}`);
32
+ // entries this script does not make (the Barrow Warden, scripts/bake/template-warden.mjs) stay, after the fixture's
33
+ const path = resolve(project, 'data/skins.json'), made = new Set(out.map((entry) => entry.species));
34
+ const kept = (existsSync(path) ? JSON.parse(readFileSync(path, 'utf8')) : []).filter((entry) => !made.has(entry.species));
35
+ writeFileSync(path, `${JSON.stringify([...out, ...kept], null, 2)}\n`);
36
+ console.info(`template skins: ${out.map((entry) => `${entry.species} ${entry.skin.slice(0, 8)}`).join(', ')}${kept.length === 0 ? '' : `; kept ${kept.map((entry) => entry.species).join(', ')}`}`);
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ // SHARD-SOURCE M4.10: bake the Template's Barrow Warden skin (src/shards/_template/generators/warden.ts) into its
3
+ // content-addressed assets (the GLB and its { row, binding } skin file) and its data/skins.json entry. The generator is
4
+ // TypeScript, so it is bundled first, as scripts/bake/skins.mjs bundles the skin fixture; generators/warden.test.ts
5
+ // re-bakes and refuses committed bytes that differ.
6
+ import { build } from 'vite';
7
+ import { mkdirSync, readFileSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';
8
+ import { join, resolve } from 'node:path';
9
+ import { pathToFileURL } from 'node:url';
10
+
11
+ const repo = resolve(import.meta.dirname, '../..'), project = resolve(repo, 'src/shards/_template'), scratch = resolve(repo, `tmp/bake-warden-${process.pid}`);
12
+ try {
13
+ mkdirSync(scratch, { recursive: true }); symlinkSync(join(repo, 'node_modules'), join(scratch, 'node_modules'));
14
+ await build({ configFile: false, logLevel: 'silent', build: { target: 'esnext', outDir: join(scratch, 'generator'), emptyOutDir: true, lib: { entry: join(project, 'generators/warden.ts'), formats: ['es'], fileName: 'warden' }, rolldownOptions: { platform: 'node', external: [/^node:/u, 'vite', '@gltf-transform/core', '@gltf-transform/extensions', 'meshoptimizer'] } } });
15
+ const { bakeWardenSkin } = await import(pathToFileURL(join(scratch, 'generator/warden.js')).href);
16
+ const { glb, json, entry } = await bakeWardenSkin();
17
+ writeFileSync(resolve(project, 'assets', entry.glb), glb); writeFileSync(resolve(project, 'assets', entry.skin), json);
18
+ const path = resolve(project, 'data/skins.json'), skins = JSON.parse(readFileSync(path, 'utf8')), at = skins.findIndex((row) => row.species === entry.species);
19
+ const previous = at === -1 ? undefined : skins[at];
20
+ if (at === -1) skins.push(entry); else skins[at] = entry;
21
+ writeFileSync(path, `${JSON.stringify(skins, null, 2)}\n`);
22
+ for (const hash of [previous?.glb, previous?.skin]) if (hash !== undefined && hash !== entry.glb && hash !== entry.skin) rmSync(resolve(project, 'assets', hash), { force: true });
23
+ const glbRow = entry.files[1];
24
+ console.info(`template warden: skin ${entry.skin.slice(0, 8)}, glb ${entry.glb.slice(0, 8)} (${glb.length} bytes, ${glbRow.triangles} triangles, ${glbRow.draws} draws)`);
25
+ } finally { rmSync(scratch, { recursive: true, force: true }); }
@@ -14,7 +14,7 @@ import { randomBytes } from 'node:crypto';
14
14
  import { InputHashMemo } from '@wildshard/engine/scripts/bake-input-hashes.mjs';
15
15
  import { productInputKey, productToolchainKey, matchingProductInputKey, publishProductInputs } from '@wildshard/engine/scripts/shardfile-inputs.mjs';
16
16
  import { quietCli } from '@wildshard/engine/scripts/quiet-cli.mjs';
17
- import { outputManifest, shardOutputs, shardSourceDir, shardSourceFolders } from '@wildshard/engine/scripts/shard-outputs.mjs';
17
+ import { manifestFolders, outputManifest, shardOutputs, shardSourceDir, shardSourceFolders } from '@wildshard/engine/scripts/shard-outputs.mjs';
18
18
  import { usesProgramDiscovery } from '@wildshard/engine/scripts/program-discovery.mjs';
19
19
  import { shardfileValidationRevision } from '@wildshard/engine/scripts/shardfile-validation-revision.mjs';
20
20
  import { runShardBuild, runShardBuildPool } from './shard-build-pool.mjs';
@@ -61,7 +61,12 @@ async function buildShardfilesWork(root, { strict = [process.env.CI, process.env
61
61
  };
62
62
  // SA42 (SA16's rule): a single-shard repo's source is `src/` (its folder named by its slug), a multi-shard repo's is
63
63
  // `src/shards/<folder>/`. The engine's shard-outputs owns the layout, so every product helper below agrees with it.
64
- const folders = shardSourceFolders(root, ['shard.config.ts']).sort((a, b) => a.localeCompare(b));
64
+ // SHARD-SOURCE AP7: a `src/shards/<folder>` with no manifest declares no product (the products tests read the manifests),
65
+ // so it is a source proof that `wildshard check` and `watch` take by path (src/shards/authoring-slice), never built here.
66
+ const declared = new Set(manifestFolders(root));
67
+ const proofs = shardSourceFolders(root, ['shard.config.ts']).filter(folder => !declared.has(folder) && existsSync(resolve(root, 'src/shards', folder)));
68
+ for (const folder of proofs) console.info(`build-shards: src/shards/${folder} has no manifest: a source proof, not a product; skipped`);
69
+ const folders = shardSourceFolders(root, ['shard.config.ts']).filter(folder => !proofs.includes(folder)).sort((a, b) => a.localeCompare(b));
65
70
  // SF88g: a folder with declared outputs (scripts/shard-outputs.mjs) builds one product per output, each to out/<slug>
66
71
  const products = folders.flatMap(folder => (shardOutputs(root, folder) ?? [{ slug: folder }]).map(row => ({ name: row.slug, folder, output: row.slug === folder ? undefined : row.slug })));
67
72
  const built = products.map(row => row.name).sort((a, b) => a.localeCompare(b));
@@ -0,0 +1,89 @@
1
+ import { mkdirSync, writeFileSync } from 'node:fs';
2
+ import { resolve } from 'node:path';
3
+ import { returnProjectionV2Layout } from '@wildshard/format/returnProjectionV2';
4
+ import { compileScript } from '../src/sharddev/bake/compileScript.ts';
5
+ import { compileScriptV2 } from '../src/sharddev/bake/compileScriptV2.ts';
6
+ import { v2CoreSource } from '../src/sharddev/as/wsV2.ts';
7
+
8
+ const target = resolve(process.argv[2] ?? '../engine/test/fixtures/wasm');
9
+ const ioBytes = returnProjectionV2Layout(2).bytes;
10
+ const source = `import * as core from './core';
11
+ export function ws_abi():i32{return 2;}export function ws_io():i32{return 0;}
12
+ export function ws_init(lo:i32,hi:i32,fuel:i32):i32{return fuel;}
13
+ export function ws_project(fuel:i32):i32{
14
+ core.beginState();assert(core.beginBinding(0));
15
+ core.pageOutput(2,core.field(0));core.pageOutput(1,core.parameter(0));
16
+ core.endBinding();return fuel;
17
+ }`;
18
+
19
+ mkdirSync(target, { recursive: true });
20
+ const bytes = await compileScriptV2(source, { lane: 'project', ioBytes, sources: { 'core.ts': v2CoreSource(0) } });
21
+ writeFileSync(resolve(target, 'return-projection-template.wasm'), bytes);
22
+ writeFileSync(resolve(target, 'return-projection-template.json'), `${JSON.stringify({ source, fixture: 'return-projection-template.wasm', ioBytes }, null, 2)}\n`);
23
+
24
+ const groupRngSource = `import * as core from './sdk/as/wsV2';
25
+ export function ws_abi():i32{return 2;}export function ws_io():i32{return 0;}
26
+ export function ws_init(lo:i32,hi:i32,fuel:i32):i32{return fuel;}
27
+ export function ws_project(fuel:i32):i32{core.beginState();assert(core.beginBinding(0));
28
+ core.setState(0,core.random(1));core.setState(1,core.random(2));
29
+ core.setState(2,core.random(1));core.setState(3,core.random(2));
30
+ if(core.parameter(0)==2)core.pageOutput(99);
31
+ core.endBinding();return fuel;}`;
32
+ const groupRngIoBytes = 1216;
33
+ writeFileSync(resolve(target, 'script-v2-group-rng.wasm'), await compileScriptV2(groupRngSource, {
34
+ lane: 'project', ioBytes: groupRngIoBytes, sources: { 'sdk/as/wsV2.ts': v2CoreSource(0) },
35
+ }));
36
+ writeFileSync(resolve(target, 'script-v2-group-rng.json'), `${JSON.stringify({ source: groupRngSource, fixture: 'script-v2-group-rng.wasm', ioBytes: groupRngIoBytes }, null, 2)}\n`);
37
+
38
+ const groupMembersSource = `import * as core from './sdk/as/wsV2';
39
+ export function ws_abi():i32{return 2;}export function ws_io():i32{return 0;}
40
+ export function ws_init(lo:i32,hi:i32,fuel:i32):i32{return fuel;}
41
+ export function ws_project(fuel:i32):i32{core.beginState();assert(core.beginBinding(0));
42
+ core.setState(0,core.state(0)+1);const signal=i32(core.parameter(0));
43
+ if(signal==4){core.pageOutput(6,3,4);core.pageOutput(2,0,1);core.endBinding();return fuel;}
44
+ core.pageOutput(1,0,core.field(1),signal==3?2:core.field(0));
45
+ core.pageOutput(2,0,signal==2?99:1);core.pageOutput(3,0,1.2,2.3,3.4);
46
+ core.pageOutput(4,0,6,7,8);core.pageOutput(5,0,.5);core.pageOutput(6,3,4);
47
+ core.endBinding();return fuel;}`;
48
+ const groupMembersIoBytes = 1408;
49
+ writeFileSync(resolve(target, 'script-v2-group-members.wasm'), await compileScriptV2(groupMembersSource, {
50
+ lane: 'project', ioBytes: groupMembersIoBytes, sources: { 'sdk/as/wsV2.ts': v2CoreSource(0) },
51
+ }));
52
+ writeFileSync(resolve(target, 'script-v2-group-members.json'), `${JSON.stringify({ source: groupMembersSource, fixture: 'script-v2-group-members.wasm', ioBytes: groupMembersIoBytes }, null, 2)}\n`);
53
+
54
+ const legacyGuests = {
55
+ 'script-call-results': `let calls:i32=0;
56
+ export function abi_version():i32{return 0;}
57
+ export function init(lo:i32,hi:i32):void{calls=lo;}
58
+ export function in_ptr():i32{return 16384;}export function in_cap():i32{return 4096;}
59
+ export function out_ptr():i32{return 24576;}export function out_cap():i32{return 32;}
60
+ export function out_count():i32{return 2;}
61
+ export function on_tick():void{
62
+ calls++;let value=load<f64>(16416);if(value==99)unreachable();
63
+ store<f64>(24576,1);store<f64>(24584,1);store<f64>(24592,value);
64
+ store<f64>(24616,3);store<f64>(24624,9);store<f64>(24632,1);store<f64>(24640,load<f64>(16384));
65
+ }`,
66
+ 'script-lane-results': `let calls:i32=0;
67
+ export function abi_version():i32{return 0;}
68
+ export function init(lo:i32,hi:i32):void{calls=lo;}
69
+ export function in_ptr():i32{return 16384;}export function in_cap():i32{return 4096;}
70
+ export function out_ptr():i32{return 24576;}export function out_cap():i32{return 32;}
71
+ export function out_count():i32{return 2;}
72
+ export function on_tick():void{
73
+ calls++;let value=load<f64>(16400);if(value==99)unreachable();
74
+ store<f64>(24576,1);store<f64>(24584,1);store<f64>(24592,value);
75
+ store<f64>(24616,3);store<f64>(24624,9);store<f64>(24632,1);store<f64>(24640,load<f64>(16384));
76
+ }`,
77
+ 'script-virgin-memory': `let value:i32=0;
78
+ export function abi_version():i32{return 0;}
79
+ export function init(lo:i32,hi:i32):void{value=lo;store<i32>(32768,value);}
80
+ export function in_ptr():i32{return 16384;}export function in_cap():i32{return 4096;}
81
+ export function out_ptr():i32{return 24576;}export function out_cap():i32{return 32;}
82
+ export function out_count():i32{return 0;}
83
+ export function on_tick():void{value++;store<i32>(32768,value);}`,
84
+ };
85
+ for (const [name, guest] of Object.entries(legacyGuests)) {
86
+ const maximumPages = name === 'script-virgin-memory' ? 2 : 1;
87
+ writeFileSync(resolve(target, `${name}.wasm`), await compileScript(guest, { maximumPages }));
88
+ }
89
+ writeFileSync(resolve(target, 'legacy-guests.json'), `${JSON.stringify({ legacyGuests }, null, 2)}\n`);
@@ -14,8 +14,8 @@ import {parseOutputIndex,assembleOutputShardfile} from '@wildshard/format/output
14
14
  import {controlFileHashes,playLibrarySteps} from '@wildshard/format/admissionControl';
15
15
  import {entryFileSteps} from '@wildshard/format/tierSelection';
16
16
  import {validationSourceBytes} from '@wildshard/format/validationReceipt';
17
- import {prepareAssetDecoders} from '@wildshard/format/product';
18
- import {validateShardfileProduct} from '@wildshard/format/productValidation';
17
+ import {prepareAssetDecoders} from '@wildshard/format/shardfileAssets';
18
+ import {validateShardfileFolder as validateShardfileProduct} from '@wildshard/format/shardfileValidation';
19
19
 
20
20
  const hash=bytes=>createHash('sha256').update(bytes).digest('hex');
21
21
  const json=(dir,name)=>JSON.parse(readFileSync(join(dir,name),'utf8'));