@gameslate/sdk 0.3.17 → 0.3.19

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.
@@ -296,7 +296,8 @@ Anything with a place to move through, a track or a board still gets one.
296
296
 
297
297
  - `listAssets(inputs, pick)` must be cheap: name what can be built.
298
298
  - `buildAsset(id, inputs)` returns outputs in the SDK's shapes: floorplan, location, nav, mesh
299
- (GS3D), and image.
299
+ (GS3D), image, and notes (the text of one JSON object, written as `notes/<id>.json` for a
300
+ pack's `localSource`, e.g. `{ file: 'notes/check-notes.json', key: 'collectibleSets.gs' }`).
300
301
 
301
302
  Images have a `purpose` (`atlas`, `map`, `icon`, `actor`, which picks the folder) and an `encoding`:
302
303
 
@@ -313,6 +314,15 @@ Every image of a game uses one format. In the sandbox:
313
314
  - Inputs are named relative to the folder the player picked (`mods/pack.o2r`). The core also hands
314
315
  in the game's registry manifest as `registry/manifest.json` when there is one, so renders line up
315
316
  with the registry's maps.
317
+ - **Data from the web is a download, never a fetch.** Plugin code has no network and nothing
318
+ runs outside the sandbox (`extract.ts` fails the build). Declare the file in the game's
319
+ manifest entry, `downloads: [{ id, url, sha256 }]` with an exact https URL (a release asset, a
320
+ commit's tarball), and read it as the input `downloads/<id>`. The core fetches it when a build
321
+ starts (at most 64 MB), checks the hash and caches it; the player sees it as a permission, and
322
+ changing the URL or hash asks them again. A tarball is fine to unpack in the sandbox: SoH's
323
+ 11 MB `.tar.gz` (97 MB of tar) gunzips with `fflate/browser`'s streaming `Gunzip` in about 10 s.
324
+ Read the input in chunks and keep only the members you need. A plugin with no assets code can't
325
+ declare downloads.
316
326
  - **Data licensing:** ship the extractor, never its output. Textures, models and renders are
317
327
  built on the player's machine and never committed.
318
328
 
@@ -351,7 +361,8 @@ bundles; a package without a licence file fails the build) and copies the repo's
351
361
  game collides with, apply the same filters (section flags that drop flat or upright triangles,
352
362
  vertices flagged "no collision"), keep floors facing up by winding, and colour by surface type.
353
363
  Shade by height and draw higher floors later so bridges sit over roads.
354
- 4. **Location ids are asset ids:** lower-case words, dots and dashes, **no underscores**. The
364
+ 4. **Location ids are asset ids:** lower case, digits, `.`, `_` and `-`, starting with a letter or
365
+ digit (`AssetIdSchema`; its message says "dots and dashes", but `g5_building` is valid). The
355
366
  `locationId` the live reader reports must equal them.
356
367
  5. **Place the player:** the layer's affine maps world x/z onto the drawing exactly as it was
357
368
  drawn. Find the heading convention live: drive straight, then steer one way, and compare the
@@ -486,8 +497,30 @@ yarn check
486
497
  ```
487
498
 
488
499
  That's the typecheck, the tests, the build, then `validate dist/<id>`, which checks the built
489
- plugin exactly as the core will before running it. Then bump `version`, tag `vX.Y.Z`, and publish the release bundle. GameSlate installs presets from
490
- `plugins.lock.json` (an entry with the release URL and its sha256).
500
+ plugin exactly as the core will before running it. Then bump `version` in `package.json` and
501
+ `plugin/manifest.json`, and push a `vX.Y.Z` tag. `.github/workflows/release.yml` runs
502
+ `yarn build --release release`, which writes three files beside each other and uploads them:
503
+
504
+ - `<id>-X.Y.Z.zip`: the built plugin under `<id>/`, made by the build itself, so its hash is known;
505
+ - `<id>-X.Y.Z.zip.sha256`;
506
+ - `manifest.json`: the **published manifest**, the built one plus `bundle: { url, sha256 }`
507
+ naming the zip (by name, resolved against the URL the player gives) and its sha256. Upload it with every release:
508
+ without it, players can't add the plugin by URL or get updates.
509
+
510
+ **How players get it.** In GameSlate's settings (the cog), "Add plugin" takes
511
+ `https://github.com/<owner>/<repo>/releases/latest/download/manifest.json`. The core shows the
512
+ plugin's games and permissions, then downloads the zip, refuses it unless its sha256 matches, checks
513
+ the zip's own manifest is the published one, and unpacks it. It re-reads that URL about hourly: a
514
+ newer version that asks for **no new permissions** installs itself (once none of its games is
515
+ running); one that asks for more (a new game's memory, a new folder) waits for the player to
516
+ confirm. A manifest naming an `extract` module (code outside the sandbox, removed in sdk 0.3.19)
517
+ fails the schema everywhere, presets included (docs/plugin-architecture.md, "Closing the
518
+ sandbox"). So adding a game, a folder or a download in a release
519
+ means every player is asked again: say why in the release notes. A plain zip URL works too
520
+ (validated the same way, its `.zip.sha256` used when present), but gets no updates.
521
+
522
+ GameSlate also builds a few plugins in as presets, from `plugins.lock.json` (the release URL and the
523
+ zip's sha256).
491
524
 
492
525
  ## Pitfalls seen in real plugins
493
526
 
@@ -495,6 +528,12 @@ plugin exactly as the core will before running it. Then bump `version`, tag `vX.
495
528
  game could repeat, add it here (in `@gameslate/sdk`'s `template/claude/skills`, then copy it into
496
529
  the plugin repos) in the same change as the fix. The next game should not have to find it again.
497
530
 
531
+ - **Write JSON whose key order matters as text, not as an object.** JavaScript objects list
532
+ number-like keys (`"3"`, `"12"`) first and in ascending order, whatever order they were added
533
+ in, so `JSON.stringify`, `JSON.parse` and every trip across the sandbox boundary reorder them.
534
+ SoH's check notes key chests and Gold Skulltulas by flag in Python's insertion order: they're
535
+ built as `Map`s and serialised by hand, then returned as a `notes` output's `json` text, which
536
+ the core writes unchanged (2026-12-05).
498
537
  - **Run the support check in `check` once the repo has a support table.** Add `"support":
499
538
  "gameslate-plugin support plugin --built dist/<id>"` and `&& yarn support` to `check`. Without
500
539
  it, gameslate-n64's README frontmatter said Harvest Moon 64 had no missions for a release after
@@ -884,3 +923,104 @@ the plugin repos) in the same change as the fix. The next game should not have t
884
923
  file on the player's PC or an asset extractor. Then grep your hint prose for quoted game strings:
885
924
  Perfect Dark's hints quoted an objective verbatim, and MM's objective labels carried the boss
886
925
  title cards (2026-12-05).
926
+ - **A floorplan drawing is not an SVG.** It has no text, no fill opacity, and fills and strokes are
927
+ separate layers (every stroke above every fill). Porting a hand-written SVG drops its title,
928
+ needs a group's opacity blended into the fill colour by hand, and shows outlines a later fill
929
+ used to cover. Check the port against the old output by geometry (each polygon's points), not
930
+ by bytes (TS2, 2026-12-05).
931
+ - **A local location replaces the registry's fields one level deep** (`{ ...registry, ...local }`),
932
+ and `name` is required. Leave `objectives` out of it to keep the registry's numbered ones; send
933
+ them only with the real labels and every difficulty rule (TS2, 2026-12-05).
934
+ - **Read archives by range, and know inputs by their contents.** A pak's names and directory may
935
+ sit at its end (TS2's P8CK): read the header and that tail, then only the entries you build
936
+ from, so `listAssets` stays cheap on a 20 MB pak. Match a file by its magic and the entries it
937
+ holds, not by the name a dump tool gave it (`_gs_tmp_l_20_ST.pak` is `l_20_ST.pak`) (2026-12-05).
938
+ - **Files the game ships encrypted can't be inputs.** Homefront keeps TS2's level paks inside an
939
+ encrypted `lsao_cached.pak`, so the extractor takes paks the player has extracted, and its
940
+ "nothing found" note and the README say where they come from (2026-12-05).
941
+ - **Objective text may live in the executable, not the level files.** TS2's Story paks hold no
942
+ strings; the labels are in `TimeSplitters2.exe`'s `.data` string table. Search the exe too
943
+ before reporting the text missing (2026-12-05).
944
+ - **Expected pixels in tests follow the port's rounding.** A Python-faithful port rounds half to
945
+ even (401.25 → 401.2): write the expected numbers out rather than computing them with
946
+ `Math.round` (2026-12-05).
947
+ - **Run a mutation's test green first.** A test that already fails "kills" every mutant: a TS2
948
+ test asserting the wrong note passed a mutation run until the full check caught it (2026-12-05).
949
+ - **An extractor is only offered from `plugin/assets.ts`.** The build looks for that file (default
950
+ export: `{ id, extractors: new Map([[gameId, factory]]) }`); a game's `assets.ts` elsewhere is
951
+ never bundled, and `validate` prints `assets: none`. Perfect Dark's objective-text extractor sat
952
+ unoffered for a release, blamed on underscores in its ids, which were valid (2026-12-05).
953
+ - **Read a level's setup from the ROM's binary, not the decomp's C text.** Text heuristics drift
954
+ from what the game does: Perfect Dark's `tag(id, n)` names the prop `n` commands on from the tag
955
+ (`setup.c`), not the next `PAD_` within a few lines, which put 563 tags on the wrong pad, and
956
+ text skips `#if VERSION` blocks (an Escape guard that exists only before NTSC 1.0) and literal
957
+ ids. Size each command from the engine's own length table, check the result against the C text
958
+ on every stage once, and explain each difference (2026-12-05).
959
+ - **Generate opcode tables from the engine, not the macros.** Perfect Dark's `g_CommandLengths`
960
+ has `#if VERSION` entries and a ternary, and four `commands.h` macros disagree with it in size;
961
+ the engine's length wins, the macro gives only operand roles, and a variable-length command
962
+ (`print`, 0x00b5) is sized by scanning to its terminator. Fail loud on an unknown opcode rather
963
+ than guessing a length (2026-12-05).
964
+ - **One background can serve several stages, under another stage's code.** Mr. Blonde's Revenge
965
+ uses Defection's `ame` pads under setup code `wax`: name pads by number from the file the stage
966
+ loads, not by the setup's `PAD_WAX_…` names (the old text builder lost its spawn) (2026-12-05).
967
+ - **Check hint facts against a walkthrough, and test hints for quoted labels.** Generated hint prose
968
+ invents plausible detail: TS2's Siberia hints had the filing cabinets burnt by shooting "red fuel
969
+ drums" in "four rooms", where the game has five cabinets you open and burn with timed mines,
970
+ and a dish "console" where you stick a mine on the dish. Write each fact from a walkthrough
971
+ (a GameFAQs FAQ, often mirrored as PDFs on video-games-museum.com; the Wayback Machine serves
972
+ pages that refuse fetches; StrategyWiki answers 403), in your own words, and name it in the
973
+ commit. Add a test, gated on the local labels file, that fails when a hint holds a label whole,
974
+ a quoted multi-word piece of one, or a five-word run of one; pin its matcher on made-up labels
975
+ so it runs everywhere (TS2, 2026-12-05).
976
+ - **Fact-check every level's hints, not only the one caught.** The other nine TS2 levels were
977
+ invented the same way: a getaway car behind the club (it comes down the street early on), a
978
+ Jacque who drops the crystal (it sits on the altar), a "police precinct" upload (it's a
979
+ computer inside the lab), fire against Stone Golems (trapdoors and grenades). Walkthroughs
980
+ split by difficulty (bomb, poster and golem counts, where the crystal is), so say which
981
+ difficulty a fact holds for, or leave the number out. Drop `obj_N` ids from hint text: the
982
+ player never sees them. Then compare the hints with the walkthrough texts and reword any run
983
+ of six or more words they share; keep the texts in a scratch folder, never in the repo
984
+ (TS2, 2026-12-05). Not in a worktree either: name the sources in the commit message only.
985
+ `plugin/tracked-documents.test.ts` fails on a tracked PDF, HTML, Word, RTF, EPUB or TXT file
986
+ outside licences and `fixtures/` (data-licensing rule, 2026-12-05).
987
+ - **Pins need fact-checking as much as hints.** Seventeen TS2 pin labels named places the level
988
+ doesn't have: a "Dish Control Room" anchored on an oil drum, a "turret" that was a console.
989
+ Label a pin after what its anchor actually is, the model or object type of its setup entry
990
+ (`damfilecabinet`), not after the objective it helps with. A point called a "portal" or an
991
+ "exit" may be the player's start position, so check it. A pin whose object appears only on
992
+ some difficulties gets `hiddenWhen`, built from the setup entry's per-difficulty flags
993
+ (TS2, 2026-12-05).
994
+ - **Invented hints name the wrong tool, place and method.** Perfect Dark's hints were wrong on
995
+ almost every mission: a Data Uplink on cleaning robots (two consoles start them), Mining
996
+ Explosives on a hangar door (a technician's key card), a security "booth" with biometrics, a
997
+ saucer-hangar medpack, made-up `X=…, Z=…` coordinates. Never put coordinates or button names
998
+ in hint prose unless the plugin's own data supplies them. A game's briefings are often in its
999
+ language banks; the decomp's extracted text lets you check them locally, but cite a public
1000
+ copy (the LP Archive shows PD's). When no walkthrough covers a level (PD's Pelagic II), write
1001
+ only what the briefing says and keep it vague. Run the run-comparison after every rewrite:
1002
+ writing from a walkthrough copies its phrases (PD's first rewrite shared 41 six-word runs with
1003
+ its sources, against 6 before). Where an extractor already reads the labels from the player's
1004
+ file, the quoted-label test can call it directly, gated on the input's env var (PD, 2026-12-05).
1005
+ - **Build every published pin from the inputs; don't carry old ones forward.** The Zelda builder
1006
+ copied 201 MM exits, grottos and Pieces of Heart from the previous manifest because nothing
1007
+ made them; once the maps moved into the extractor there was no previous manifest. Each came
1008
+ from the scene: a collision polygon's surface names an exit index into the scene's exit list
1009
+ (the entrance there names the destination), and a collectible actor's params name a Piece of
1010
+ Heart. Compare the rebuild with the published pins by id, label and position, and explain each
1011
+ one you can't derive (one was placed by hand on a moving platform) (2026-12-05).
1012
+ - **Collision has no rooms.** Sort a floor into a room by where the room's own meshes are: the
1013
+ smallest room whose drawn extent holds the floor's centre, else the nearest. A floor under a
1014
+ water box isn't water when the box is a puddle a unit deep; count it as submerged only below
1015
+ wading depth (Zelda, 2026-12-05).
1016
+ - **Frame each pin on a layer that shows it.** Grottos are separate layers, each framed on its own
1017
+ room; an exit placed by height alone landed on another grotto's frame, thousands of pixels off
1018
+ screen. Pick among the layers whose frame holds the pin, then by height (Zelda, 2026-12-05).
1019
+ - **`describe.skipIf` still runs the describe body.** Work done there (opening the gated input)
1020
+ throws on a fresh clone before the skip applies. Build gated data lazily inside the tests.
1021
+ - **Round as the published data did.** Means of integer corners land exactly on .x5; JavaScript's
1022
+ `Math.round` goes up where Python's `round` goes to even, and 4 of 189 exit pins moved by 0.1.
1023
+ - **When a hint correction disagrees with the game's code, the code wins.** A reviewer said MM's
1024
+ barn defence starts at 2 AM; the invasion actor runs from `CLOCK_TIME(2, 30)`. Check timings and
1025
+ rewards in the decomp (the Oceanside Spider House's wallet is chosen by the day it's paid out),
1026
+ then name a walkthrough that agrees (2026-12-05).
@@ -0,0 +1,38 @@
1
+ name: Release
2
+
3
+ # Tag vX.Y.Z (matching package.json and plugin/manifest.json) to publish the built plugin. The
4
+ # release carries {{id}}-X.Y.Z.zip, its .sha256 and manifest.json, the published manifest naming
5
+ # the zip and its sha256. Players add the plugin in GameSlate's settings by this URL, and their
6
+ # GameSlate checks it for updates:
7
+ # https://github.com/<owner>/<repo>/releases/latest/download/manifest.json
8
+ on:
9
+ push:
10
+ tags: ['v*']
11
+
12
+ permissions:
13
+ contents: write
14
+
15
+ jobs:
16
+ release:
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+ - uses: actions/setup-node@v4
21
+ with:
22
+ node-version: 22
23
+ - run: corepack enable
24
+ - run: yarn install
25
+ - run: yarn typecheck && yarn test
26
+ - name: Check the tag matches the plugin's version
27
+ run: |
28
+ v="${GITHUB_REF_NAME#v}"
29
+ test "$(node -p "require('./plugin/manifest.json').version")" = "$v"
30
+ test "$(node -p "require('./package.json').version")" = "$v"
31
+ - run: yarn build --release release && yarn validate
32
+ - name: Publish the release
33
+ env:
34
+ GH_TOKEN: ${{ github.token }}
35
+ run: >-
36
+ gh release create "$GITHUB_REF_NAME"
37
+ release/{{id}}-*.zip release/{{id}}-*.zip.sha256 release/manifest.json
38
+ --title "{{id}} $GITHUB_REF_NAME" --generate-notes
@@ -1,5 +1,7 @@
1
1
  node_modules/
2
2
  dist/
3
+ # yarn build --release release: the zip and published manifest the release workflow uploads
4
+ release/
3
5
  .env
4
6
  .env.*
5
7
  # Yarn's generated install files (Plug'n'Play)
@@ -0,0 +1,68 @@
1
+ import { execFileSync } from 'node:child_process';
2
+ import { describe, expect, it } from 'vitest';
3
+
4
+ /*
5
+ * No walkthroughs, FAQs or briefings in the repo (.claude/rules/data-licensing.md): they are other
6
+ * people's text, read for fact-checking and kept in a scratch folder. This fails on any tracked
7
+ * document-type file outside a short allowlist.
8
+ *
9
+ * The same file is the core's `tests/tracked-documents.test.ts` and the plugin template's
10
+ * `plugin/tracked-documents.test.ts`; the template test fails when they differ.
11
+ */
12
+ const DOCUMENT = /\.(pdf|html?|docx?|rtf|epub|txt)$/i;
13
+ const ALLOWED: RegExp[] = [
14
+ /* the core web app's entry page */
15
+ /^packages\/web\/index\.html$/,
16
+ /* licence and notice texts, which must travel with what they cover */
17
+ /(^|\/)(LICENSE|COPYING|THIRD_PARTY)[^/]*\.txt$/i,
18
+ /(^|\/)OFL\.txt$/,
19
+ /* golden test fixtures (a parser's expected text output) */
20
+ /(^|\/)fixtures\/.*\.txt$/,
21
+ ];
22
+
23
+ /** Tracked paths that look like a document someone else wrote. */
24
+ export function findDocuments(paths: string[]): string[] {
25
+ return paths.filter(p => DOCUMENT.test(p) && !ALLOWED.some(allowed => allowed.test(p)));
26
+ }
27
+
28
+ function trackedPaths(): string[] {
29
+ const root = execFileSync('git', ['rev-parse', '--show-toplevel'], {
30
+ cwd: import.meta.dirname,
31
+ encoding: 'utf8',
32
+ }).trim();
33
+ return execFileSync('git', ['ls-files', '-z'], { cwd: root, encoding: 'utf8' })
34
+ .split('\0')
35
+ .filter(Boolean);
36
+ }
37
+
38
+ describe('tracked documents', () => {
39
+ it('the allowlist spares licences, fixtures and the web entry page, and nothing else', () => {
40
+ expect(
41
+ findDocuments([
42
+ 'packages/web/index.html',
43
+ 'LICENSE.txt',
44
+ 'tools/fixtures/doom/COPYING-freedoom.txt',
45
+ 'packages/web/public/fonts/OFL.txt',
46
+ 'dist/THIRD_PARTY_LICENSES.txt',
47
+ 'plugin/soh/fixtures/tiny/check-notes.golden.txt',
48
+ 'plugin/live.ts',
49
+ 'README.md',
50
+ ]),
51
+ ).toEqual([]);
52
+ expect(
53
+ findDocuments([
54
+ 'x.pdf',
55
+ 'docs/guide.txt',
56
+ 'plugin/ts2/siberia-faq.TXT',
57
+ 'scratch/bellaonline.htm',
58
+ 'plugin/index.html',
59
+ 'briefing.docx',
60
+ 'notes.rtf',
61
+ 'book.epub',
62
+ ]),
63
+ ).toHaveLength(8);
64
+ });
65
+ it('no walkthrough, FAQ or briefing is tracked', () => {
66
+ expect(findDocuments(trackedPaths())).toEqual([]);
67
+ });
68
+ });