@gameslate/sdk 0.3.30 → 0.3.32
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.
- package/README.md +8 -0
- package/lib/assets.d.ts +103 -68
- package/lib/assets.js +8 -0
- package/lib/catalogue.d.ts +44 -42
- package/lib/catalogue.js +5 -1
- package/lib/game-support-limitations.d.ts +2 -0
- package/lib/game-support-limitations.js +70 -0
- package/lib/game-support.d.ts +1 -1
- package/lib/game-support.js +3 -1
- package/lib/host/live-sandbox.js +15 -11
- package/lib/host/quickjs-guest.d.ts +4 -0
- package/lib/host/quickjs-guest.js +13 -7
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/mission-labels.d.ts +43 -0
- package/lib/mission-labels.js +69 -0
- package/lib/pack.d.ts +107 -98
- package/lib/pack.js +12 -5
- package/lib/plugin/sandbox-guest.js +18 -1
- package/lib/plugins-api.d.ts +2 -2
- package/lib/registry.d.ts +136 -136
- package/lib/sandbox-protocol.d.ts +67 -66
- package/package.json +1 -1
- package/template/claude/skills/build-gameslate-plugin/SKILL.md +232 -8
- package/template/claude/skills/verify-gameslate-plugin/SKILL.md +29 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type Catalogue } from './catalogue.js';
|
|
3
|
+
export declare const MISSION_LABEL_MAX_CHARS = 200;
|
|
4
|
+
export declare const MISSION_LABELS_MAX = 5000;
|
|
5
|
+
/** Mission id → the title to show for it. */
|
|
6
|
+
export declare const MissionLabelsSchema: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodString>, Record<string, string>, Record<string, string>>;
|
|
7
|
+
export type MissionLabels = z.infer<typeof MissionLabelsSchema>;
|
|
8
|
+
/** A labels file as the core writes it (`labels/<id>.json`). */
|
|
9
|
+
export declare const MissionLabelsFileSchema: z.ZodObject<{
|
|
10
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
11
|
+
missions: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodString>, Record<string, string>, Record<string, string>>;
|
|
12
|
+
}, "strict", z.ZodTypeAny, {
|
|
13
|
+
schemaVersion: 1;
|
|
14
|
+
missions: Record<string, string>;
|
|
15
|
+
}, {
|
|
16
|
+
schemaVersion: 1;
|
|
17
|
+
missions: Record<string, string>;
|
|
18
|
+
}>;
|
|
19
|
+
export type MissionLabelsFile = z.infer<typeof MissionLabelsFileSchema>;
|
|
20
|
+
/** The labelled mission ids the catalogue doesn't have: labels built for another version. */
|
|
21
|
+
export declare function unknownMissionLabels(catalogue: Catalogue, labels: MissionLabels): string[];
|
|
22
|
+
/** Throws naming the labels whose mission the catalogue doesn't have. */
|
|
23
|
+
export declare function checkMissionLabels(catalogue: Catalogue, labels: MissionLabels): void;
|
|
24
|
+
/**
|
|
25
|
+
* The catalogue with each extracted label as its mission's title. A mission without one keeps
|
|
26
|
+
* the committed, numbered title: nothing extracted yet is the normal case before a build.
|
|
27
|
+
*/
|
|
28
|
+
export declare function applyMissionLabels(catalogue: Catalogue, labels: MissionLabels): Catalogue;
|
|
29
|
+
/**
|
|
30
|
+
* What a pack's code (`describeState`, `ui.statusStrip`, `ui.timelines`) gets beside the state.
|
|
31
|
+
* The core always passes one; a caller from before sdk 0.3.31 (a plugin's own tests) may not, so
|
|
32
|
+
* a hook that names missions defaults it: `(state, context = noLabelsContext(catalogue)) => …`.
|
|
33
|
+
*/
|
|
34
|
+
export interface PackViewContext {
|
|
35
|
+
/** the labels extracted on the player's PC, by mission id (empty before a build) */
|
|
36
|
+
readonly missionLabels: Readonly<MissionLabels>;
|
|
37
|
+
/** the title the app shows for a mission: its extracted label, else the catalogue's title.
|
|
38
|
+
* Throws for an id the catalogue doesn't have. */
|
|
39
|
+
missionTitle(missionId: string): string;
|
|
40
|
+
}
|
|
41
|
+
export declare function createPackViewContext(catalogue: Catalogue, labels: MissionLabels): PackViewContext;
|
|
42
|
+
/** The context with no labels: every mission by its committed title. */
|
|
43
|
+
export declare function noLabelsContext(catalogue: Catalogue): PackViewContext;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { CatalogueIdSchema } from './catalogue.js';
|
|
3
|
+
/*
|
|
4
|
+
* Mission labels: the game's own names for a pack's missions (Super Mario 64's star names). They
|
|
5
|
+
* are the publisher's text, so a catalogue commits numbered titles ("Star 1") and the plugin's
|
|
6
|
+
* extractor reads the real names from the player's files (.claude/rules/data-licensing.md). It
|
|
7
|
+
* returns them as a `labels` asset output; the core writes `local-assets/<game>/labels/<id>.json`,
|
|
8
|
+
* and the daemon applies them to the pack it serves and hands them to the pack's code, so the
|
|
9
|
+
* app and the AI show the same titles.
|
|
10
|
+
*/
|
|
11
|
+
export const MISSION_LABEL_MAX_CHARS = 200;
|
|
12
|
+
export const MISSION_LABELS_MAX = 5000;
|
|
13
|
+
/* one line (no control characters or Unicode line/paragraph separators): a label is a row's
|
|
14
|
+
* title and is quoted to the AI */
|
|
15
|
+
const MissionLabelSchema = z
|
|
16
|
+
.string()
|
|
17
|
+
.min(1)
|
|
18
|
+
.max(MISSION_LABEL_MAX_CHARS)
|
|
19
|
+
.regex(/^[^\p{Cc}\p{Zl}\p{Zp}]+$/u, 'a label is one line of text');
|
|
20
|
+
/** Mission id → the title to show for it. */
|
|
21
|
+
export const MissionLabelsSchema = z
|
|
22
|
+
.record(CatalogueIdSchema, MissionLabelSchema)
|
|
23
|
+
.refine(labels => Object.keys(labels).length <= MISSION_LABELS_MAX, `at most ${MISSION_LABELS_MAX} labels`);
|
|
24
|
+
/** A labels file as the core writes it (`labels/<id>.json`). */
|
|
25
|
+
export const MissionLabelsFileSchema = z
|
|
26
|
+
.object({ schemaVersion: z.literal(1), missions: MissionLabelsSchema })
|
|
27
|
+
.strict();
|
|
28
|
+
/** The labelled mission ids the catalogue doesn't have: labels built for another version. */
|
|
29
|
+
export function unknownMissionLabels(catalogue, labels) {
|
|
30
|
+
const known = new Set(catalogue.missions.map(m => m.id));
|
|
31
|
+
return Object.keys(labels).filter(id => !known.has(id));
|
|
32
|
+
}
|
|
33
|
+
/** Throws naming the labels whose mission the catalogue doesn't have. */
|
|
34
|
+
export function checkMissionLabels(catalogue, labels) {
|
|
35
|
+
const unknown = unknownMissionLabels(catalogue, labels);
|
|
36
|
+
if (unknown.length > 0) {
|
|
37
|
+
throw new Error(`labels for missions the pack doesn't have: ${unknown.join(', ')}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The catalogue with each extracted label as its mission's title. A mission without one keeps
|
|
42
|
+
* the committed, numbered title: nothing extracted yet is the normal case before a build.
|
|
43
|
+
*/
|
|
44
|
+
export function applyMissionLabels(catalogue, labels) {
|
|
45
|
+
checkMissionLabels(catalogue, labels);
|
|
46
|
+
return {
|
|
47
|
+
...catalogue,
|
|
48
|
+
missions: catalogue.missions.map(m => {
|
|
49
|
+
const title = labels[m.id];
|
|
50
|
+
return title === undefined ? m : { ...m, title };
|
|
51
|
+
}),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export function createPackViewContext(catalogue, labels) {
|
|
55
|
+
const titles = new Map(applyMissionLabels(catalogue, labels).missions.map(m => [m.id, m.title]));
|
|
56
|
+
return {
|
|
57
|
+
missionLabels: labels,
|
|
58
|
+
missionTitle: id => {
|
|
59
|
+
const title = titles.get(id);
|
|
60
|
+
if (title === undefined)
|
|
61
|
+
throw new Error(`no mission "${id}" in the catalogue`);
|
|
62
|
+
return title;
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/** The context with no labels: every mission by its committed title. */
|
|
67
|
+
export function noLabelsContext(catalogue) {
|
|
68
|
+
return createPackViewContext(catalogue, {});
|
|
69
|
+
}
|