@gameslate/sdk 0.3.29 → 0.3.31
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/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.js +3 -2
- package/lib/host/live-sandbox.js +12 -9
- 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 +141 -141
- package/lib/registry.js +5 -5
- package/lib/sandbox-protocol.d.ts +67 -66
- package/package.json +1 -1
- package/template/claude/skills/build-gameslate-plugin/SKILL.md +113 -6
- package/template/claude/skills/verify-gameslate-plugin/SKILL.md +29 -1
package/lib/catalogue.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { Condition } from './condition.js';
|
|
3
|
+
/** A catalogue id: an item, counter, mission, … */
|
|
4
|
+
export declare const CatalogueIdSchema: z.ZodString;
|
|
3
5
|
export declare const ItemSchema: z.ZodObject<{
|
|
4
6
|
id: z.ZodString;
|
|
5
7
|
label: z.ZodString;
|
|
@@ -49,17 +51,17 @@ export declare const CounterSchema: z.ZodObject<{
|
|
|
49
51
|
id: string;
|
|
50
52
|
icon?: string | undefined;
|
|
51
53
|
max?: string | number | undefined;
|
|
52
|
-
format?: "number" | "duration" | "percent" | undefined;
|
|
53
54
|
display?: Record<string, string> | undefined;
|
|
54
55
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
56
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
55
57
|
}, {
|
|
56
58
|
label: string;
|
|
57
59
|
id: string;
|
|
58
60
|
icon?: string | undefined;
|
|
59
61
|
max?: string | number | undefined;
|
|
60
|
-
format?: "number" | "duration" | "percent" | undefined;
|
|
61
62
|
display?: Record<string, string> | undefined;
|
|
62
63
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
64
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
63
65
|
}>;
|
|
64
66
|
export type CatalogueCounter = z.infer<typeof CounterSchema>;
|
|
65
67
|
export type CounterRole = NonNullable<CatalogueCounter['role']>;
|
|
@@ -232,9 +234,9 @@ export declare const ReferenceEntrySchema: z.ZodObject<{
|
|
|
232
234
|
}, "strict", z.ZodTypeAny, {
|
|
233
235
|
id: string;
|
|
234
236
|
title: string;
|
|
235
|
-
notes?: string[] | undefined;
|
|
236
237
|
badge?: string | undefined;
|
|
237
238
|
sequence?: string[] | undefined;
|
|
239
|
+
notes?: string[] | undefined;
|
|
238
240
|
rows?: {
|
|
239
241
|
label: string;
|
|
240
242
|
detail: string;
|
|
@@ -243,9 +245,9 @@ export declare const ReferenceEntrySchema: z.ZodObject<{
|
|
|
243
245
|
}, {
|
|
244
246
|
id: string;
|
|
245
247
|
title: string;
|
|
246
|
-
notes?: string[] | undefined;
|
|
247
248
|
badge?: string | undefined;
|
|
248
249
|
sequence?: string[] | undefined;
|
|
250
|
+
notes?: string[] | undefined;
|
|
249
251
|
rows?: {
|
|
250
252
|
label: string;
|
|
251
253
|
detail: string;
|
|
@@ -280,9 +282,9 @@ export declare const ReferenceSectionSchema: z.ZodObject<{
|
|
|
280
282
|
}, "strict", z.ZodTypeAny, {
|
|
281
283
|
id: string;
|
|
282
284
|
title: string;
|
|
283
|
-
notes?: string[] | undefined;
|
|
284
285
|
badge?: string | undefined;
|
|
285
286
|
sequence?: string[] | undefined;
|
|
287
|
+
notes?: string[] | undefined;
|
|
286
288
|
rows?: {
|
|
287
289
|
label: string;
|
|
288
290
|
detail: string;
|
|
@@ -291,9 +293,9 @@ export declare const ReferenceSectionSchema: z.ZodObject<{
|
|
|
291
293
|
}, {
|
|
292
294
|
id: string;
|
|
293
295
|
title: string;
|
|
294
|
-
notes?: string[] | undefined;
|
|
295
296
|
badge?: string | undefined;
|
|
296
297
|
sequence?: string[] | undefined;
|
|
298
|
+
notes?: string[] | undefined;
|
|
297
299
|
rows?: {
|
|
298
300
|
label: string;
|
|
299
301
|
detail: string;
|
|
@@ -304,9 +306,9 @@ export declare const ReferenceSectionSchema: z.ZodObject<{
|
|
|
304
306
|
entries: {
|
|
305
307
|
id: string;
|
|
306
308
|
title: string;
|
|
307
|
-
notes?: string[] | undefined;
|
|
308
309
|
badge?: string | undefined;
|
|
309
310
|
sequence?: string[] | undefined;
|
|
311
|
+
notes?: string[] | undefined;
|
|
310
312
|
rows?: {
|
|
311
313
|
label: string;
|
|
312
314
|
detail: string;
|
|
@@ -321,9 +323,9 @@ export declare const ReferenceSectionSchema: z.ZodObject<{
|
|
|
321
323
|
entries: {
|
|
322
324
|
id: string;
|
|
323
325
|
title: string;
|
|
324
|
-
notes?: string[] | undefined;
|
|
325
326
|
badge?: string | undefined;
|
|
326
327
|
sequence?: string[] | undefined;
|
|
328
|
+
notes?: string[] | undefined;
|
|
327
329
|
rows?: {
|
|
328
330
|
label: string;
|
|
329
331
|
detail: string;
|
|
@@ -353,16 +355,16 @@ export declare const CollectibleEntrySchema: z.ZodObject<{
|
|
|
353
355
|
name: string;
|
|
354
356
|
locationId?: string | undefined;
|
|
355
357
|
pinId?: string | undefined;
|
|
356
|
-
collectedBy?: Condition | undefined;
|
|
357
358
|
locationName?: string | undefined;
|
|
359
|
+
collectedBy?: Condition | undefined;
|
|
358
360
|
needs?: string[][] | undefined;
|
|
359
361
|
}, {
|
|
360
362
|
id: string;
|
|
361
363
|
name: string;
|
|
362
364
|
locationId?: string | undefined;
|
|
363
365
|
pinId?: string | undefined;
|
|
364
|
-
collectedBy?: Condition | undefined;
|
|
365
366
|
locationName?: string | undefined;
|
|
367
|
+
collectedBy?: Condition | undefined;
|
|
366
368
|
needs?: string[][] | undefined;
|
|
367
369
|
}>;
|
|
368
370
|
export type CollectibleEntry = z.infer<typeof CollectibleEntrySchema>;
|
|
@@ -392,16 +394,16 @@ export declare const CollectibleSetSchema: z.ZodObject<{
|
|
|
392
394
|
name: string;
|
|
393
395
|
locationId?: string | undefined;
|
|
394
396
|
pinId?: string | undefined;
|
|
395
|
-
collectedBy?: Condition | undefined;
|
|
396
397
|
locationName?: string | undefined;
|
|
398
|
+
collectedBy?: Condition | undefined;
|
|
397
399
|
needs?: string[][] | undefined;
|
|
398
400
|
}, {
|
|
399
401
|
id: string;
|
|
400
402
|
name: string;
|
|
401
403
|
locationId?: string | undefined;
|
|
402
404
|
pinId?: string | undefined;
|
|
403
|
-
collectedBy?: Condition | undefined;
|
|
404
405
|
locationName?: string | undefined;
|
|
406
|
+
collectedBy?: Condition | undefined;
|
|
405
407
|
needs?: string[][] | undefined;
|
|
406
408
|
}>, "many">>;
|
|
407
409
|
/** …or loaded at runtime from a locally generated file (`local-assets/<game>/<file>`) */
|
|
@@ -425,8 +427,8 @@ export declare const CollectibleSetSchema: z.ZodObject<{
|
|
|
425
427
|
name: string;
|
|
426
428
|
locationId?: string | undefined;
|
|
427
429
|
pinId?: string | undefined;
|
|
428
|
-
collectedBy?: Condition | undefined;
|
|
429
430
|
locationName?: string | undefined;
|
|
431
|
+
collectedBy?: Condition | undefined;
|
|
430
432
|
needs?: string[][] | undefined;
|
|
431
433
|
}[] | undefined;
|
|
432
434
|
counter?: string | undefined;
|
|
@@ -444,8 +446,8 @@ export declare const CollectibleSetSchema: z.ZodObject<{
|
|
|
444
446
|
name: string;
|
|
445
447
|
locationId?: string | undefined;
|
|
446
448
|
pinId?: string | undefined;
|
|
447
|
-
collectedBy?: Condition | undefined;
|
|
448
449
|
locationName?: string | undefined;
|
|
450
|
+
collectedBy?: Condition | undefined;
|
|
449
451
|
needs?: string[][] | undefined;
|
|
450
452
|
}[] | undefined;
|
|
451
453
|
counter?: string | undefined;
|
|
@@ -640,17 +642,17 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
640
642
|
id: string;
|
|
641
643
|
icon?: string | undefined;
|
|
642
644
|
max?: string | number | undefined;
|
|
643
|
-
format?: "number" | "duration" | "percent" | undefined;
|
|
644
645
|
display?: Record<string, string> | undefined;
|
|
645
646
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
647
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
646
648
|
}, {
|
|
647
649
|
label: string;
|
|
648
650
|
id: string;
|
|
649
651
|
icon?: string | undefined;
|
|
650
652
|
max?: string | number | undefined;
|
|
651
|
-
format?: "number" | "duration" | "percent" | undefined;
|
|
652
653
|
display?: Record<string, string> | undefined;
|
|
653
654
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
655
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
654
656
|
}>, "many">;
|
|
655
657
|
/** flag sets the pack's decoder streams (bit conditions may only reference these) */
|
|
656
658
|
flagSets: z.ZodArray<z.ZodString, "many">;
|
|
@@ -797,16 +799,16 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
797
799
|
name: string;
|
|
798
800
|
locationId?: string | undefined;
|
|
799
801
|
pinId?: string | undefined;
|
|
800
|
-
collectedBy?: Condition | undefined;
|
|
801
802
|
locationName?: string | undefined;
|
|
803
|
+
collectedBy?: Condition | undefined;
|
|
802
804
|
needs?: string[][] | undefined;
|
|
803
805
|
}, {
|
|
804
806
|
id: string;
|
|
805
807
|
name: string;
|
|
806
808
|
locationId?: string | undefined;
|
|
807
809
|
pinId?: string | undefined;
|
|
808
|
-
collectedBy?: Condition | undefined;
|
|
809
810
|
locationName?: string | undefined;
|
|
811
|
+
collectedBy?: Condition | undefined;
|
|
810
812
|
needs?: string[][] | undefined;
|
|
811
813
|
}>, "many">>;
|
|
812
814
|
/** …or loaded at runtime from a locally generated file (`local-assets/<game>/<file>`) */
|
|
@@ -830,8 +832,8 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
830
832
|
name: string;
|
|
831
833
|
locationId?: string | undefined;
|
|
832
834
|
pinId?: string | undefined;
|
|
833
|
-
collectedBy?: Condition | undefined;
|
|
834
835
|
locationName?: string | undefined;
|
|
836
|
+
collectedBy?: Condition | undefined;
|
|
835
837
|
needs?: string[][] | undefined;
|
|
836
838
|
}[] | undefined;
|
|
837
839
|
counter?: string | undefined;
|
|
@@ -849,8 +851,8 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
849
851
|
name: string;
|
|
850
852
|
locationId?: string | undefined;
|
|
851
853
|
pinId?: string | undefined;
|
|
852
|
-
collectedBy?: Condition | undefined;
|
|
853
854
|
locationName?: string | undefined;
|
|
855
|
+
collectedBy?: Condition | undefined;
|
|
854
856
|
needs?: string[][] | undefined;
|
|
855
857
|
}[] | undefined;
|
|
856
858
|
counter?: string | undefined;
|
|
@@ -886,9 +888,9 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
886
888
|
}, "strict", z.ZodTypeAny, {
|
|
887
889
|
id: string;
|
|
888
890
|
title: string;
|
|
889
|
-
notes?: string[] | undefined;
|
|
890
891
|
badge?: string | undefined;
|
|
891
892
|
sequence?: string[] | undefined;
|
|
893
|
+
notes?: string[] | undefined;
|
|
892
894
|
rows?: {
|
|
893
895
|
label: string;
|
|
894
896
|
detail: string;
|
|
@@ -897,9 +899,9 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
897
899
|
}, {
|
|
898
900
|
id: string;
|
|
899
901
|
title: string;
|
|
900
|
-
notes?: string[] | undefined;
|
|
901
902
|
badge?: string | undefined;
|
|
902
903
|
sequence?: string[] | undefined;
|
|
904
|
+
notes?: string[] | undefined;
|
|
903
905
|
rows?: {
|
|
904
906
|
label: string;
|
|
905
907
|
detail: string;
|
|
@@ -910,9 +912,9 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
910
912
|
entries: {
|
|
911
913
|
id: string;
|
|
912
914
|
title: string;
|
|
913
|
-
notes?: string[] | undefined;
|
|
914
915
|
badge?: string | undefined;
|
|
915
916
|
sequence?: string[] | undefined;
|
|
917
|
+
notes?: string[] | undefined;
|
|
916
918
|
rows?: {
|
|
917
919
|
label: string;
|
|
918
920
|
detail: string;
|
|
@@ -927,9 +929,9 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
927
929
|
entries: {
|
|
928
930
|
id: string;
|
|
929
931
|
title: string;
|
|
930
|
-
notes?: string[] | undefined;
|
|
931
932
|
badge?: string | undefined;
|
|
932
933
|
sequence?: string[] | undefined;
|
|
934
|
+
notes?: string[] | undefined;
|
|
933
935
|
rows?: {
|
|
934
936
|
label: string;
|
|
935
937
|
detail: string;
|
|
@@ -1090,9 +1092,9 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
1090
1092
|
id: string;
|
|
1091
1093
|
icon?: string | undefined;
|
|
1092
1094
|
max?: string | number | undefined;
|
|
1093
|
-
format?: "number" | "duration" | "percent" | undefined;
|
|
1094
1095
|
display?: Record<string, string> | undefined;
|
|
1095
1096
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
1097
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
1096
1098
|
}[];
|
|
1097
1099
|
flagSets: string[];
|
|
1098
1100
|
items: {
|
|
@@ -1104,12 +1106,6 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
1104
1106
|
short?: string | undefined;
|
|
1105
1107
|
count?: string | undefined;
|
|
1106
1108
|
}[];
|
|
1107
|
-
chips: {
|
|
1108
|
-
label: string;
|
|
1109
|
-
id: string;
|
|
1110
|
-
prompt: string;
|
|
1111
|
-
when?: Condition | undefined;
|
|
1112
|
-
}[];
|
|
1113
1109
|
inventoryLayouts: ({
|
|
1114
1110
|
id: string;
|
|
1115
1111
|
title: string;
|
|
@@ -1153,8 +1149,8 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
1153
1149
|
name: string;
|
|
1154
1150
|
locationId?: string | undefined;
|
|
1155
1151
|
pinId?: string | undefined;
|
|
1156
|
-
collectedBy?: Condition | undefined;
|
|
1157
1152
|
locationName?: string | undefined;
|
|
1153
|
+
collectedBy?: Condition | undefined;
|
|
1158
1154
|
needs?: string[][] | undefined;
|
|
1159
1155
|
}[] | undefined;
|
|
1160
1156
|
counter?: string | undefined;
|
|
@@ -1167,9 +1163,9 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
1167
1163
|
entries: {
|
|
1168
1164
|
id: string;
|
|
1169
1165
|
title: string;
|
|
1170
|
-
notes?: string[] | undefined;
|
|
1171
1166
|
badge?: string | undefined;
|
|
1172
1167
|
sequence?: string[] | undefined;
|
|
1168
|
+
notes?: string[] | undefined;
|
|
1173
1169
|
rows?: {
|
|
1174
1170
|
label: string;
|
|
1175
1171
|
detail: string;
|
|
@@ -1181,6 +1177,12 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
1181
1177
|
badge?: string | undefined;
|
|
1182
1178
|
defaultOpen?: boolean | undefined;
|
|
1183
1179
|
}[];
|
|
1180
|
+
chips: {
|
|
1181
|
+
label: string;
|
|
1182
|
+
id: string;
|
|
1183
|
+
prompt: string;
|
|
1184
|
+
when?: Condition | undefined;
|
|
1185
|
+
}[];
|
|
1184
1186
|
pinRules: {
|
|
1185
1187
|
id: string;
|
|
1186
1188
|
match: {
|
|
@@ -1212,9 +1214,9 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
1212
1214
|
id: string;
|
|
1213
1215
|
icon?: string | undefined;
|
|
1214
1216
|
max?: string | number | undefined;
|
|
1215
|
-
format?: "number" | "duration" | "percent" | undefined;
|
|
1216
1217
|
display?: Record<string, string> | undefined;
|
|
1217
1218
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
1219
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
1218
1220
|
}[];
|
|
1219
1221
|
flagSets: string[];
|
|
1220
1222
|
items: {
|
|
@@ -1226,12 +1228,6 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
1226
1228
|
short?: string | undefined;
|
|
1227
1229
|
count?: string | undefined;
|
|
1228
1230
|
}[];
|
|
1229
|
-
chips: {
|
|
1230
|
-
label: string;
|
|
1231
|
-
id: string;
|
|
1232
|
-
prompt: string;
|
|
1233
|
-
when?: Condition | undefined;
|
|
1234
|
-
}[];
|
|
1235
1231
|
inventoryLayouts: ({
|
|
1236
1232
|
id: string;
|
|
1237
1233
|
title: string;
|
|
@@ -1275,8 +1271,8 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
1275
1271
|
name: string;
|
|
1276
1272
|
locationId?: string | undefined;
|
|
1277
1273
|
pinId?: string | undefined;
|
|
1278
|
-
collectedBy?: Condition | undefined;
|
|
1279
1274
|
locationName?: string | undefined;
|
|
1275
|
+
collectedBy?: Condition | undefined;
|
|
1280
1276
|
needs?: string[][] | undefined;
|
|
1281
1277
|
}[] | undefined;
|
|
1282
1278
|
counter?: string | undefined;
|
|
@@ -1289,9 +1285,9 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
1289
1285
|
entries: {
|
|
1290
1286
|
id: string;
|
|
1291
1287
|
title: string;
|
|
1292
|
-
notes?: string[] | undefined;
|
|
1293
1288
|
badge?: string | undefined;
|
|
1294
1289
|
sequence?: string[] | undefined;
|
|
1290
|
+
notes?: string[] | undefined;
|
|
1295
1291
|
rows?: {
|
|
1296
1292
|
label: string;
|
|
1297
1293
|
detail: string;
|
|
@@ -1303,6 +1299,12 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
1303
1299
|
badge?: string | undefined;
|
|
1304
1300
|
defaultOpen?: boolean | undefined;
|
|
1305
1301
|
}[];
|
|
1302
|
+
chips: {
|
|
1303
|
+
label: string;
|
|
1304
|
+
id: string;
|
|
1305
|
+
prompt: string;
|
|
1306
|
+
when?: Condition | undefined;
|
|
1307
|
+
}[];
|
|
1306
1308
|
pinRules: {
|
|
1307
1309
|
id: string;
|
|
1308
1310
|
match: {
|
package/lib/catalogue.js
CHANGED
|
@@ -5,7 +5,11 @@ import { collectReferences, ConditionSchema } from './condition.js';
|
|
|
5
5
|
* (.claude/rules/game-packs.md). Every status in it is a Condition; the UI renders it without
|
|
6
6
|
* knowing which game it is.
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
/** A catalogue id: an item, counter, mission, … */
|
|
9
|
+
export const CatalogueIdSchema = z
|
|
10
|
+
.string()
|
|
11
|
+
.regex(/^[A-Za-z0-9_:.-]+$/, 'ids are letters, digits and _ : . - only');
|
|
12
|
+
const Id = CatalogueIdSchema;
|
|
9
13
|
export const ItemSchema = z
|
|
10
14
|
.object({
|
|
11
15
|
id: Id,
|
package/lib/game-support.js
CHANGED
|
@@ -142,8 +142,9 @@ function checkPinsAgainstRegistry(support, ctx, problems) {
|
|
|
142
142
|
for (const pin of layer.landmarks) {
|
|
143
143
|
if (effectiveLandmarkKind(pin) !== 'poi' || isTrackedPin(pin))
|
|
144
144
|
continue;
|
|
145
|
-
/* the
|
|
146
|
-
|
|
145
|
+
/* rules see the effective kind, as the app's collected check passes it (web llm.ts) */
|
|
146
|
+
const ref = { ...pin, kind: effectiveLandmarkKind(pin) };
|
|
147
|
+
if (rules.some(r => pinRuleMatchesAt(r, ref, locationId)))
|
|
147
148
|
continue;
|
|
148
149
|
plain.push(`"${pin.label}" (${pin.id}) in ${locationId}/${layer.id}`);
|
|
149
150
|
}
|
package/lib/host/live-sandbox.js
CHANGED
|
@@ -28,6 +28,8 @@ export const SANDBOX_LIMITS = {
|
|
|
28
28
|
/** each WebAssembly module's memory (live code's modules import nothing else) */
|
|
29
29
|
wasmMemoryBytes: 16 * 1024 * 1024,
|
|
30
30
|
};
|
|
31
|
+
/* the daemon always passes a context; a caller without one (a test) means no labels */
|
|
32
|
+
const labelsOf = (context) => context?.missionLabels ?? {};
|
|
31
33
|
/** One plugin's live code in its own runtime. */
|
|
32
34
|
export class PluginSandbox {
|
|
33
35
|
quickJs;
|
|
@@ -122,13 +124,13 @@ export class PluginSandbox {
|
|
|
122
124
|
};
|
|
123
125
|
}
|
|
124
126
|
pack(data) {
|
|
125
|
-
const views = (state) => this.views(data.id, state);
|
|
127
|
+
const views = (state, labels) => this.views(data.id, state, labels);
|
|
126
128
|
return {
|
|
127
129
|
...data,
|
|
128
|
-
describeState: state => views(state).facts,
|
|
130
|
+
describeState: (state, context) => views(state, labelsOf(context)).facts,
|
|
129
131
|
ui: {
|
|
130
|
-
statusStrip: state => views(state).statusStrip,
|
|
131
|
-
timelines: state => views(state).timelines,
|
|
132
|
+
statusStrip: (state, context) => views(state, labelsOf(context)).statusStrip,
|
|
133
|
+
timelines: (state, context) => views(state, labelsOf(context)).timelines,
|
|
132
134
|
},
|
|
133
135
|
};
|
|
134
136
|
}
|
|
@@ -200,15 +202,16 @@ export class PluginSandbox {
|
|
|
200
202
|
}
|
|
201
203
|
return parsed.data;
|
|
202
204
|
}
|
|
203
|
-
views(gameId, state) {
|
|
205
|
+
views(gameId, state, missionLabels) {
|
|
206
|
+
const labels = JSON.stringify(missionLabels);
|
|
204
207
|
const cached = this.viewsCache.get(state);
|
|
205
|
-
if (cached)
|
|
206
|
-
return cached;
|
|
207
|
-
const raw = this.call('views', [gameId, JSON.stringify(state)]);
|
|
208
|
+
if (cached?.labels === labels)
|
|
209
|
+
return cached.views;
|
|
210
|
+
const raw = this.call('views', [gameId, JSON.stringify(state), labels]);
|
|
208
211
|
if (typeof raw !== 'string')
|
|
209
212
|
throw new Error(`${this.name}: views returned no text`);
|
|
210
213
|
const views = PackViewsSchema.parse(JSON.parse(raw));
|
|
211
|
-
this.viewsCache.set(state, views);
|
|
214
|
+
this.viewsCache.set(state, { labels, views });
|
|
212
215
|
return views;
|
|
213
216
|
}
|
|
214
217
|
memory(handle) {
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -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
|
+
}
|