@team-antioch/sc2-adjutant 0.1.0 → 0.1.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 (149) hide show
  1. package/README.md +2 -0
  2. package/data/blizzard-baseline.json +3061 -0
  3. package/data/button-hotkeys.json +5722 -0
  4. package/data/game-assets.json +50909 -0
  5. package/data/package-entries.json +32361 -2
  6. package/dist/capture/bank-fixtures.d.ts +13 -0
  7. package/dist/capture/bank-fixtures.js +35 -0
  8. package/dist/capture/bank-snapshots.d.ts +95 -0
  9. package/dist/capture/bank-snapshots.js +302 -0
  10. package/dist/capture/editor-broker-client.d.ts +27 -4
  11. package/dist/capture/editor-broker-client.js +3 -3
  12. package/dist/capture/editor-broker.js +154 -9
  13. package/dist/capture/effect-tour.d.ts +113 -0
  14. package/dist/capture/effect-tour.js +283 -0
  15. package/dist/capture/effect-video.d.ts +74 -0
  16. package/dist/capture/effect-video.js +173 -0
  17. package/dist/capture/exemplar-capture.d.ts +4 -0
  18. package/dist/capture/exemplar-capture.js +4 -1
  19. package/dist/capture/shots.d.ts +6 -1
  20. package/dist/capture/shots.js +1 -1
  21. package/dist/capture/stop-tour.d.ts +3 -1
  22. package/dist/capture/stop-tour.js +1 -1
  23. package/dist/capture/style-pack-captures.d.ts +67 -0
  24. package/dist/capture/style-pack-captures.js +172 -0
  25. package/dist/catalog/stock-catalog.d.ts +8 -0
  26. package/dist/catalog/stock-catalog.js +13 -0
  27. package/dist/cli/capture-exemplars.js +18 -32
  28. package/dist/cli/effect-tour.d.ts +2 -0
  29. package/dist/cli/effect-tour.js +378 -0
  30. package/dist/cli/make-frames.d.ts +1 -0
  31. package/dist/cli/make-frames.js +21 -0
  32. package/dist/cli/sound-mix.d.ts +1 -0
  33. package/dist/cli/sound-mix.js +75 -0
  34. package/dist/cli/study.js +6 -26
  35. package/dist/domain/blueprint-trigger.d.ts +355 -3
  36. package/dist/domain/blueprint-trigger.js +149 -8
  37. package/dist/domain/library-interface.d.ts +50 -29
  38. package/dist/domain/library-interface.js +54 -41
  39. package/dist/domain/mission-blueprint.d.ts +13 -6
  40. package/dist/domain/mission-blueprint.js +6 -0
  41. package/dist/domain/mod-blueprint.d.ts +4 -4
  42. package/dist/host/game-logs.d.ts +63 -0
  43. package/dist/host/game-logs.js +178 -0
  44. package/dist/host/game-ownership.d.ts +37 -0
  45. package/dist/host/game-ownership.js +84 -0
  46. package/dist/host/game-run-report.d.ts +63 -0
  47. package/dist/host/game-run-report.js +119 -0
  48. package/dist/host/known-errors.d.ts +34 -0
  49. package/dist/host/known-errors.js +73 -0
  50. package/dist/init/init-workspace.d.ts +3 -1
  51. package/dist/init/init-workspace.js +10 -1
  52. package/dist/map/convert-mission-triggers.d.ts +115 -7
  53. package/dist/map/convert-mission-triggers.js +527 -47
  54. package/dist/map/editor-changes.d.ts +1 -1
  55. package/dist/map/editor-form.d.ts +5 -0
  56. package/dist/map/editor-form.js +72 -0
  57. package/dist/map/game-packages.d.ts +3 -2
  58. package/dist/map/game-packages.js +5 -2
  59. package/dist/map/kept-references.js +47 -1
  60. package/dist/map/kept-session.js +3 -1
  61. package/dist/map/outline-diff.d.ts +24 -0
  62. package/dist/map/outline-diff.js +95 -0
  63. package/dist/map/outline-trigger.d.ts +7 -0
  64. package/dist/map/outline-trigger.js +29 -20
  65. package/dist/map/ownership-plan.d.ts +6 -2
  66. package/dist/map/ownership-plan.js +1 -1
  67. package/dist/map/package-output.js +13 -8
  68. package/dist/map/tune-kept-triggers.d.ts +7 -0
  69. package/dist/map/tune-kept-triggers.js +33 -6
  70. package/dist/map/write-blueprint-trigger.d.ts +9 -4
  71. package/dist/map/write-blueprint-trigger.js +46 -13
  72. package/dist/map/write-map-package.js +20 -9
  73. package/dist/mcp/capture-jobs.d.ts +2 -0
  74. package/dist/mcp/capture-jobs.js +2 -0
  75. package/dist/mcp/server.d.ts +11 -2
  76. package/dist/mcp/server.js +17 -4
  77. package/dist/mcp/tools/bank-report.d.ts +19 -0
  78. package/dist/mcp/tools/bank-report.js +51 -0
  79. package/dist/mcp/tools/blueprint.js +18 -14
  80. package/dist/mcp/tools/capture.d.ts +4 -0
  81. package/dist/mcp/tools/capture.js +22 -5
  82. package/dist/mcp/tools/catalog.d.ts +1 -1
  83. package/dist/mcp/tools/catalog.js +30 -1
  84. package/dist/mcp/tools/compile.d.ts +1 -1
  85. package/dist/mcp/tools/compile.js +100 -9
  86. package/dist/mcp/tools/editor-handoff.d.ts +4 -1
  87. package/dist/mcp/tools/editor-handoff.js +6 -3
  88. package/dist/mcp/tools/style-pack.d.ts +11 -0
  89. package/dist/mcp/tools/style-pack.js +245 -0
  90. package/dist/mcp/tools/tool-group.d.ts +9 -0
  91. package/dist/mods/button-hotkeys.d.ts +45 -0
  92. package/dist/mods/button-hotkeys.js +185 -0
  93. package/dist/mods/compile-mod.js +19 -5
  94. package/dist/mods/custom-doodads.d.ts +21 -1
  95. package/dist/mods/custom-doodads.js +53 -7
  96. package/dist/mods/data-rules.js +8 -1
  97. package/dist/mods/effective-entry.d.ts +18 -0
  98. package/dist/mods/effective-entry.js +52 -0
  99. package/dist/mods/function-search.js +12 -0
  100. package/dist/mods/library-xml.d.ts +34 -5
  101. package/dist/mods/library-xml.js +94 -22
  102. package/dist/mods/sound-mix.d.ts +92 -0
  103. package/dist/mods/sound-mix.js +195 -0
  104. package/dist/plugins/check-workspace.js +22 -3
  105. package/dist/plugins/plugin-api.d.ts +59 -5
  106. package/dist/plugins/plugin-api.js +6 -0
  107. package/dist/plugins/plugin-sdk.d.ts +13 -1
  108. package/dist/plugins/plugin-sdk.js +16 -1
  109. package/dist/plugins/plugin-sources.js +1 -0
  110. package/dist/plugins/registry.d.ts +4 -0
  111. package/dist/plugins/registry.js +6 -2
  112. package/dist/plugins/workspace.d.ts +5 -0
  113. package/dist/plugins/workspace.js +10 -2
  114. package/dist/study/blizzard-baseline.d.ts +76 -0
  115. package/dist/study/blizzard-baseline.js +137 -0
  116. package/dist/study/exemplar-report.d.ts +71 -0
  117. package/dist/study/exemplar-report.js +163 -0
  118. package/dist/study/find-places.d.ts +127 -0
  119. package/dist/study/find-places.js +306 -0
  120. package/dist/study/load-map-package.d.ts +3 -0
  121. package/dist/study/load-map-package.js +11 -0
  122. package/dist/study/map-study.d.ts +1 -0
  123. package/dist/study/map-study.js +3 -0
  124. package/dist/study/measure-lighting.d.ts +6 -0
  125. package/dist/study/measure-lighting.js +1 -1
  126. package/dist/study/measures.d.ts +225 -0
  127. package/dist/study/measures.js +366 -0
  128. package/dist/study/scaffold-style-pack.d.ts +58 -0
  129. package/dist/study/scaffold-style-pack.js +261 -0
  130. package/dist/study/study-exemplars.d.ts +67 -0
  131. package/dist/study/study-exemplars.js +133 -0
  132. package/dist/triggers/blueprint-triggers.d.ts +71 -11
  133. package/dist/triggers/blueprint-triggers.js +403 -48
  134. package/dist/triggers/kept-trigger-galaxy.d.ts +29 -0
  135. package/dist/triggers/kept-trigger-galaxy.js +103 -7
  136. package/dist/triggers/splice-map-script.d.ts +2 -0
  137. package/dist/triggers/splice-map-script.js +309 -8
  138. package/dist/triggers/write-triggers-xml.js +20 -5
  139. package/dist/ui/frame-path-check.d.ts +43 -4
  140. package/dist/ui/frame-path-check.js +121 -13
  141. package/dist/ui/frame-paths.d.ts +21 -1
  142. package/dist/ui/frame-paths.js +26 -6
  143. package/dist/ui/toast.d.ts +4 -5
  144. package/dist/ui/toast.js +6 -10
  145. package/examples/example-campaign/README.md +27 -0
  146. package/examples/example-campaign/missions/ashfall-relay/blueprint.json +11 -1
  147. package/examples/example-campaign/missions/ashfall-relay/triggers/ash-tremors.json +69 -0
  148. package/examples/example-campaign/missions/ashfall-relay/triggers/start-ash-tremors.json +31 -0
  149. package/package.json +3 -3
@@ -0,0 +1,245 @@
1
+ // The Style Pack tools (#23): the active Style Pack's Map Studies and places, built from its
2
+ // Exemplar Maps' source maps, so a mapper with a package install can study maps of their own.
3
+ import { z } from "zod";
4
+ import { brokerSocketPath, editorBrokerStatus } from "../../capture/editor-broker-client.js";
5
+ import { captureStylePack, planStylePackTours } from "../../capture/style-pack-captures.js";
6
+ import { hostContext } from "../../host/machine-config.js";
7
+ import { exemplarReport, VERDICTS } from "../../study/exemplar-report.js";
8
+ import { EXEMPLAR_PROVENANCES } from "../../plugins/plugin-api.js";
9
+ import { addExemplarMap, DEFAULT_STYLE_PACK_FOLDER, scaffoldStylePack, STYLE_PACK_IGNORES } from "../../study/scaffold-style-pack.js";
10
+ import { findStylePackPlaces, studyExemplars } from "../../study/study-exemplars.js";
11
+ import {} from "../call-context.js";
12
+ import { captureJobs, placeOf, waitLength } from "../capture-jobs.js";
13
+ import { realPathOf } from "../../util/inside.js";
14
+ import { oneAtATime } from "./mission-files.js";
15
+ import { ADDITIVE, DESTRUCTIVE, READ_ONLY, toolGroup } from "./tool-group.js";
16
+ const IdsSchema = z
17
+ .array(z.string().min(1))
18
+ .min(1)
19
+ .optional()
20
+ .describe("The Exemplar Maps to work on, by their ids in the pack's exemplars.json; every one the pack lists when not given");
21
+ const SOURCES = "Source maps are read from the folder the machine config's exemplarMaps names, else the Workspace config's exemplarMaps (relative to the Workspace, for a folder that travels with it).";
22
+ /** The tools registerStylePackTools can register, the Style Pack group. */
23
+ export const STYLE_PACK_TOOLS = ["scaffold_style_pack", "add_exemplar_map", "study_exemplar", "find_places", "capture_exemplar", "exemplar_report"];
24
+ const MapValueSchema = z.object({ id: z.string(), value: z.number() });
25
+ const ReportMeasureSchema = z.object({
26
+ id: z.string(),
27
+ description: z.string(),
28
+ verdict: z.enum(VERDICTS),
29
+ side: z.enum(["above", "below", "within"]).optional(),
30
+ spread: z.object({ min: z.number(), max: z.number(), median: z.number() }).nullable(),
31
+ agreeing: z.array(z.string()),
32
+ outliers: z.array(MapValueSchema),
33
+ unmeasured: z.array(z.string()),
34
+ evidence: z.number(),
35
+ blizzard: z.object({ maps: z.number().int(), p10: z.number(), p25: z.number(), median: z.number(), p75: z.number(), p90: z.number() }).nullable(),
36
+ percentile: z.number().nullable(),
37
+ });
38
+ /** One line of exemplar_report's text for a measure. */
39
+ function reportLine(measure) {
40
+ const { spread, blizzard } = measure;
41
+ const range = spread ? (spread.min === spread.max ? `${spread.min}` : `${spread.min} to ${spread.max}`) : "no value";
42
+ const against = blizzard ? `; Blizzard p10 ${blizzard.p10}, median ${blizzard.median}, p90 ${blizzard.p90} over ${blizzard.maps} maps${measure.percentile === null ? "" : `, the maps' median above ${Math.round(measure.percentile * 100)}% of them`}` : "; no Blizzard map has a value";
43
+ const where = measure.verdict === "question" ? `from ${range}, the largest group ${measure.agreeing.join(", ")}` : measure.agreeing.length ? `${measure.agreeing.join(", ")} at ${range}${measure.side && measure.side !== "within" ? `, ${measure.side} Blizzard's spread` : ""}` : range;
44
+ const outside = measure.outliers.length ? `; ${measure.verdict === "question" ? "outside the largest group" : "outside it"}: ${measure.outliers.map((o) => `${o.id} ${o.value}`).join(", ")}` : "";
45
+ const unmeasured = measure.unmeasured.length ? `; nothing to measure in ${measure.unmeasured.join(", ")}` : "";
46
+ return `- ${measure.id} (${measure.description}): ${where}${against}${outside}${unmeasured}`;
47
+ }
48
+ const VERDICT_HEADINGS = {
49
+ distinctive: "Distinctive: the maps agree, outside Blizzard's spread (p10 to p90)",
50
+ "common practice": "Common practice: the maps agree, as Blizzard's maps do",
51
+ question: "Questions for the mapper: the maps don't agree",
52
+ "no baseline": "Agreed, with no Blizzard value to compare",
53
+ "too few maps": "Too few maps with a value to tell",
54
+ };
55
+ /** The group's tools listed on every machine but refused where the Host Adapter lacks these capabilities. */
56
+ export const STYLE_PACK_REFUSED_WITHOUT = { capture_exemplar: ["editor.captureTour"] };
57
+ export function registerStylePackTools(server, ctx, { captureWaitMs }) {
58
+ const tool = toolGroup(server, STYLE_PACK_TOOLS);
59
+ tool("scaffold_style_pack", {
60
+ title: "Start a Style Pack in the Workspace",
61
+ annotations: DESTRUCTIVE,
62
+ description: `Makes a Style Pack Plugin in a folder of the Workspace (${DEFAULT_STYLE_PACK_FOLDER}/ by default), laid out as a Style Pack's npm package is, so the folder can later become one unchanged: sc2-adjutant-plugin.json at its root with the style-pack role and its knowledge entries, an empty exemplar-maps/exemplars.json, exemplar-maps/LESSONS.md and candidate-lessons.md with their headings and the lesson format, a knowledge/GUIDE.md stub, and exemplar-maps/.gitignore for ${STYLE_PACK_IGNORES.join(", ")}. Then names it as the Workspace config's stylePack. Refused, before anything is written, when the folder exists and isn't empty, or is outside the Workspace, and when the Workspace already names a Style Pack: ask the mapper whether to replace it, then call again with replace: true. Add its Exemplar Maps with add_exemplar_map.`,
63
+ inputSchema: {
64
+ folder: z.string().min(1).optional().describe(`The pack's folder, relative to the Workspace root; ${DEFAULT_STYLE_PACK_FOLDER} by default`),
65
+ name: z.string().min(1).optional().describe("The Plugin's name, lowercase like an npm package name; style-<campaign id> by default"),
66
+ replace: z.boolean().optional().describe("Replace the Style Pack the Workspace already names, once the mapper has agreed to"),
67
+ },
68
+ outputSchema: { name: z.string(), folder: z.string(), source: z.string(), files: z.array(z.string()), replaced: z.string().optional() },
69
+ }, async ({ folder, name, replace }) => {
70
+ const made = await scaffoldStylePack(await ctx.root(), { ...(folder ? { folder } : {}), ...(name ? { name } : {}), ...(replace ? { replace } : {}) });
71
+ const lines = [
72
+ `Made the Style Pack ${made.name} in ${made.folder}: ${made.files.join(", ")}.`,
73
+ `The Workspace's stylePack is now ${made.source}${made.replaced !== undefined ? `, in place of ${made.replaced}` : ""}.`,
74
+ "Add its Exemplar Maps with add_exemplar_map.",
75
+ ];
76
+ return ctx.reply(lines.join("\n"), { ...made, files: [...made.files] });
77
+ });
78
+ tool("add_exemplar_map", {
79
+ title: "Add an Exemplar Map to the Style Pack",
80
+ annotations: ADDITIVE,
81
+ description: `Records an Exemplar Map in the active Style Pack's exemplars.json: its id, its source map and its provenance (made, edited or approved: a map the mapper made weighs most as evidence, one they admire least). The pack must be a folder in the Workspace (scaffold_style_pack makes one). ${SOURCES} Refused, before anything is written, for an id the pack already lists or a source map that isn't there. Then study it with study_exemplar.`,
82
+ inputSchema: {
83
+ id: z.string().min(1).describe("A short id for the map, such as 1-1: letters, digits, dots, hyphens or underscores"),
84
+ map: z.string().min(1).describe("The source map's path inside the exemplarMaps folder (or absolute), such as Maps/Harbour.SC2Map"),
85
+ provenance: z.enum(EXEMPLAR_PROVENANCES).describe("made, edited or approved (a map the mapper admires)"),
86
+ note: z.string().min(1).optional().describe("Anything worth knowing about the map, such as what it reuses"),
87
+ },
88
+ outputSchema: { id: z.string(), map: z.string(), provenance: z.enum(EXEMPLAR_PROVENANCES), file: z.string(), source: z.string() },
89
+ }, async ({ id, map, provenance, note }) => {
90
+ // One add at a time per Workspace, each loading it afresh, so adds made at once all land and a repeated id is refused.
91
+ const added = await oneAtATime(`exemplars:${await realPathOf(await ctx.root())}`, async () => addExemplarMap(await ctx.workspace(), { id, map, provenance, ...(note ? { note } : {}), machine: ctx.host.machine }));
92
+ return ctx.reply(`Added Exemplar Map ${added.id} (${added.provenance}), from ${added.source}, to ${added.file}. Study it with study_exemplar.`, { ...added });
93
+ });
94
+ tool("study_exemplar", {
95
+ title: "Study Exemplar Maps",
96
+ annotations: DESTRUCTIVE,
97
+ description: `Builds the Map Study of one or more of the active Style Pack's Exemplar Maps: study.json (measurements of its texturing, cliffs, doodads, lighting and composition) and its layer images, written into the pack's exemplar-maps/<id>/ over any study already there. ${SOURCES} Refused, before anything is written, for an id the pack doesn't list or a source map that isn't there.`,
98
+ inputSchema: { ids: IdsSchema },
99
+ outputSchema: { studied: z.array(z.object({ id: z.string(), studyDir: z.string(), images: z.array(z.string()) })) },
100
+ }, async ({ ids }) => {
101
+ const workspace = await ctx.workspace();
102
+ const studied = await studyExemplars(workspace, { ...(ids ? { ids } : {}), machine: ctx.host.machine });
103
+ const lines = studied.map(({ id, studyDir, images, seconds }) => `${id}: study.json and ${images.join(", ")} in ${studyDir} (${seconds.toFixed(1)}s)`);
104
+ return ctx.reply(lines.join("\n"), { studied: studied.map(({ id, studyDir, images }) => ({ id, studyDir, images: [...images] })) });
105
+ });
106
+ tool("find_places", {
107
+ title: "Find an Exemplar Map's places",
108
+ annotations: DESTRUCTIVE,
109
+ description: `Finds the dressed places of the active Style Pack's Exemplar Maps (clusters of doodads within 2.5 cells, wide ones split into 16-cell tiles, places under 8 visible doodads dropped) and writes them, with what each is made of, to the pack's mixtures file (exemplar-maps/mixtures.json), replacing the places it held. Each place lists the frames near it when its map has tours (exemplar-maps/<id>/captures/ or frames/, or under $SC2_RESEARCH_DIR/docs/research/exemplar-maps/ when that is set). A place takes the first of the pack's moods it passes, as the mixtures file's moodRules record them (kept as they are), or no mood when the pack has none yet. ${SOURCES} Refused, before anything is written, for an id the pack doesn't list or a source map that isn't there.`,
110
+ inputSchema: { ids: IdsSchema.describe("The Exemplar Maps whose places the mixtures file is to hold, by their ids in the pack's exemplars.json; every one the pack lists when not given. The file is rewritten for these maps alone") },
111
+ outputSchema: { file: z.string(), maps: z.array(z.string()), places: z.number().int(), moods: z.record(z.string(), z.number().int()), withoutFrames: z.array(z.string()) },
112
+ }, async ({ ids }) => {
113
+ const workspace = await ctx.workspace();
114
+ const found = await findStylePackPlaces(workspace, { ...(ids ? { ids } : {}), machine: ctx.host.machine });
115
+ const moods = Object.entries(found.moods);
116
+ const lines = [
117
+ `Wrote ${found.places} place(s) from ${found.maps.join(", ")} to ${found.file}.`,
118
+ moods.length ? `By mood: ${moods.map(([mood, count]) => `${mood} ${count}`).join(", ")}.` : "The pack records no moods yet (moodRules in the mixtures file), so no place has one.",
119
+ ...(found.withoutFrames.length ? [`No tours for ${found.withoutFrames.join(", ")}, so their places list no frames.`] : []),
120
+ ];
121
+ return ctx.reply(lines.join("\n"), { ...found, maps: [...found.maps], moods: { ...found.moods }, withoutFrames: [...found.withoutFrames] });
122
+ });
123
+ tool("exemplar_report", {
124
+ title: "Report which habits the Exemplar Maps share",
125
+ annotations: READ_ONLY,
126
+ description: "The consistency report of the active Style Pack's Exemplar Maps, from their Map Studies (run study_exemplar first; no source map needed): for each lesson-neutral measure, the maps' spread, the maps outside it, and where it sits against Blizzard's campaign maps (the Blizzard baseline core ships). The maps agree on a measure when the largest group of them, by provenance weight (made 3, edited 2, approved 1), whose values lie within Blizzard's middle half (p25 to p75) of each other holds at least two maps and two thirds of every map's weight, maps with nothing to measure counted too; the rest are its outliers. Where Blizzard's middle half is a single value, the band is its p10 to p90, else its whole range, else (every Blizzard map alike, or no Blizzard value) a tenth of the maps' largest value. Ranked: distinctive first (the maps agree, wholly outside Blizzard's p10 to p90), the mapper's own taste and where candidate Design Lessons come from; then common practice (they agree, as Blizzard's maps do); then questions for the mapper (they don't agree), with the maps outside the largest group; then what it can't place. Within each, the heavier evidence first. Refused, naming them, when an Exemplar Map has no study yet, or one from before its measures.",
127
+ inputSchema: { ids: IdsSchema.describe("The Exemplar Maps to report on, by their ids in the pack's exemplars.json; every one the pack lists when not given") },
128
+ outputSchema: {
129
+ maps: z.array(z.object({ id: z.string(), provenance: z.string() })),
130
+ baseline: z.object({ maps: z.number().int(), unavailable: z.array(z.string()) }),
131
+ measures: z.array(ReportMeasureSchema),
132
+ },
133
+ }, async ({ ids }) => {
134
+ const report = await exemplarReport(await ctx.workspace(), ids ? { ids } : {});
135
+ const { baseline } = report;
136
+ const lines = [
137
+ `Exemplar Maps: ${report.maps.map(({ id, provenance }) => `${id} (${provenance})`).join(", ")}.`,
138
+ `Blizzard's spread is over ${baseline.maps} campaign maps${baseline.unavailable.length ? `; the baseline couldn't measure ${baseline.unavailable.join(", ")}, so its spreads leave them out` : ""}.`,
139
+ ...VERDICTS.flatMap((verdict) => {
140
+ const measures = report.measures.filter((m) => m.verdict === verdict);
141
+ return measures.length ? ["", `${VERDICT_HEADINGS[verdict]}:`, ...measures.map(reportLine)] : [];
142
+ }),
143
+ ];
144
+ return ctx.reply(lines.join("\n"), {
145
+ maps: report.maps.map((m) => ({ ...m })),
146
+ baseline: { maps: baseline.maps, unavailable: [...baseline.unavailable] },
147
+ measures: report.measures.map((m) => ({ ...m, agreeing: [...m.agreeing], outliers: m.outliers.map((o) => ({ ...o })), unmeasured: [...m.unmeasured] })),
148
+ });
149
+ });
150
+ // Listed whatever the Host Adapter, as capture_shots is, so a machine that can't capture hears why.
151
+ const tourJobs = captureJobs();
152
+ const waited = waitLength(captureWaitMs);
153
+ /** The job still going, if any: a new one waits for it. */
154
+ let running;
155
+ tool("capture_exemplar", {
156
+ title: "Capture Exemplar Map tours in game",
157
+ annotations: DESTRUCTIVE,
158
+ description: `Captures in-game camera tours of the active Style Pack's Exemplar Maps: place tours by default, one frame centred on each place in the pack's mixtures file (run find_places first), in the light the map's triggers set most outside cutscenes (or its exemplars.json placeLight, or placeZones by zone); or grid tours with tours: "grid", over the playable area once per lighting the map's study lists (run study_exemplar first), or its captureLights. Use grid tours for a map with little dressing. Frames go to the pack's exemplar-maps/<id>/captures/<tour>/ (git-ignored by the .gitignore it adds there), or under $SC2_RESEARCH_DIR/docs/research/exemplar-maps/ when that is set, with their 1000px copies in <id>/frames/<tour>/: every frame of every tour, place or grid. A tour that already has frames is skipped, so a rerun resumes; delete its captures folder to take it again. Each tour starts the game, which takes minutes. Every capture on the machine goes through one Editor Broker, one at a time; it waits up to ${waited}, and a job not done by then comes back as state waiting with a job id: call capture_exemplar({ job }) to wait again and collect it, or capture_exemplar({ job, cancel: true }) to cancel it; a new capture is refused while one is still going. ${SOURCES} Needs a Host Adapter with the editor.captureTour capability, and an awake screen; the Editor comes to the front while it runs, so check the author isn't mid-task in it.`,
159
+ inputSchema: {
160
+ ids: IdsSchema,
161
+ tours: z.enum(["places", "grid"]).optional().describe("places (the default): a frame on each of the pack's places; grid: the playable area, once per lighting"),
162
+ startOnInit: z.boolean().optional().describe("Start each tour at map init, for a map whose timed triggers never fire"),
163
+ showErrors: z.boolean().optional().describe("Keep data errors on screen, to debug a tour that doesn't start"),
164
+ job: z.string().min(1).optional().describe("A job id an earlier call returned: waits again, then collects its tours or says where it stands. Give it alone, or with cancel"),
165
+ cancel: z.boolean().optional().describe("With job: cancels it, whether it waits in the queue or runs"),
166
+ },
167
+ outputSchema: {
168
+ state: z.enum(["done", "waiting", "cancelled"]),
169
+ job: z.string(),
170
+ place: z.string().optional(),
171
+ captureDir: z.string().optional(),
172
+ tours: z.array(z.object({ id: z.string(), label: z.string(), outcome: z.string(), frames: z.number().int(), reason: z.string().optional() })).optional(),
173
+ withoutPlaces: z.array(z.string()).optional(),
174
+ frames: z.object({ made: z.number().int(), removed: z.number().int(), kept: z.number().int(), unreadable: z.array(z.string()) }).optional(),
175
+ },
176
+ }, async ({ ids, tours, startOnInit, showErrors, job, cancel }, extra) => {
177
+ if (!ctx.host.has("editor.captureTour")) {
178
+ const adapter = ctx.host.adapter ? ctx.host.adapter.name : "none";
179
+ return ctx.fail(`capture_exemplar needs a Host Adapter that can run editor.captureTour, and this machine's (${adapter}) can't: set hostAdapter in the machine config ${ctx.host.machine.file} to a Host Adapter that has it (bundled:host-macos or bundled:host-windows), on a machine with the StarCraft II Editor. No tours were captured; the studies and places work without them.`);
180
+ }
181
+ if (job !== undefined) {
182
+ if (ids !== undefined || tours !== undefined || startOnInit !== undefined || showErrors !== undefined)
183
+ return ctx.fail("Give job alone, to collect it, or with cancel; a new capture takes ids, tours, startOnInit and showErrors.");
184
+ if (cancel) {
185
+ if (!tourJobs.cancel(job))
186
+ return toursReply(job, undefined);
187
+ const state = await tourJobs.wait(job, captureWaitMs);
188
+ if (state?.state === "failed")
189
+ return ctx.reply(`Cancelled capture job ${job}: ${state.message}`, { state: "cancelled", job });
190
+ return toursReply(job, state);
191
+ }
192
+ return toursReply(job, await tourJobs.wait(job, captureWaitMs, extra.signal));
193
+ }
194
+ if (cancel)
195
+ return ctx.fail("cancel goes with job: the id of the capture to cancel.");
196
+ const workspace = await ctx.workspace();
197
+ const options = { ...(ids ? { ids } : {}), tours: tours ?? "places", machine: ctx.host.machine, ...(startOnInit ? { startOnInit } : {}), ...(showErrors ? { showErrors } : {}) };
198
+ // Planned here first, so what can't be planned is refused at once rather than as a failed job.
199
+ await planStylePackTours(workspace, options);
200
+ // Tours go to fixed folders, so a second job would take the first one's tours again. Checked
201
+ // with no await before the start, so two calls can't both pass.
202
+ if (running !== undefined) {
203
+ return ctx.fail(`Capture job ${running} is still going: call capture_exemplar({ job: "${running}" }) to wait for it and collect its tours, or cancel it, before starting another.`);
204
+ }
205
+ const id = tourJobs.start(({ onQueued, log, signal }) => captureStylePack(workspace, ctx.host, { ...options, onQueued, log, signal }).finally(() => {
206
+ if (running === id)
207
+ running = undefined;
208
+ }));
209
+ running = id;
210
+ return toursReply(id, await tourJobs.wait(id, captureWaitMs, extra.signal));
211
+ });
212
+ /** capture_exemplar's reply for a job where it stands. */
213
+ async function toursReply(job, state) {
214
+ if (!state)
215
+ return ctx.fail(`No capture job ${job} on this server: it never started here, or finished over an hour ago (its frames stay in its folder), or the server restarted, which drops a job still waiting.`);
216
+ if (state.state === "failed")
217
+ return ctx.fail(`Capture job ${job} failed: ${state.message}`);
218
+ if (state.state === "waiting") {
219
+ const place = placeOf(await editorBrokerStatus(brokerSocketPath(hostContext(ctx.host.machine).requirePath("cacheDir"))), state.brokerId);
220
+ const lines = [
221
+ `Capture job ${job} is still going (${place}) after waiting ${waited}. Call capture_exemplar({ job: "${job}" }) to wait again and collect the tours.`,
222
+ ...(state.lastLine ? [`Last: ${state.lastLine}`] : []),
223
+ ];
224
+ return ctx.reply(lines.join("\n"), { state: "waiting", job, place });
225
+ }
226
+ const { captureDir, outcomes, withoutPlaces, frames } = state.result;
227
+ const lines = [
228
+ `Tours in ${captureDir}:`,
229
+ ...outcomes.map((tour) => `${tour.id}/${tour.label}: ${tour.outcome}${tour.outcome === "failed" ? `: ${tour.reason}` : tour.outcome === "already captured" ? "" : `, ${tour.frames} frames`}`),
230
+ ...(outcomes.length === 0 ? ["None to take."] : []),
231
+ ...(withoutPlaces.length ? [`No places for ${withoutPlaces.join(", ")} in the mixtures file, so no place tour: run find_places, or capture grid tours.`] : []),
232
+ `1000px frames in <id>/frames/: ${frames.made} made, ${frames.removed} removed, ${frames.kept} in all.`,
233
+ ...(frames.unreadable.length ? [`Couldn't read ${frames.unreadable.length} capture(s), so they have no frame: ${frames.unreadable.join(", ")}`] : []),
234
+ "Run find_places so each place lists the frames near it.",
235
+ ];
236
+ return ctx.reply(lines.join("\n"), {
237
+ state: "done",
238
+ job,
239
+ captureDir,
240
+ tours: outcomes.map((tour) => ({ ...tour })),
241
+ withoutPlaces: [...withoutPlaces],
242
+ frames: { ...frames, unreadable: [...frames.unreadable] },
243
+ });
244
+ }
245
+ }
@@ -1,6 +1,7 @@
1
1
  import type { McpServer, RegisteredTool, ToolCallback } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  import type { AnySchema, ZodRawShapeCompat } from "@modelcontextprotocol/sdk/server/zod-compat.js";
3
3
  import type { ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
4
+ import type { HostCapabilityName } from "../../plugins/plugin-api.js";
4
5
  /** A tool's two hints. A read-only tool is never destructive. */
5
6
  export type ToolHints = {
6
7
  readonly readOnlyHint: true;
@@ -24,6 +25,14 @@ export declare const DESTRUCTIVE: {
24
25
  readonly readOnlyHint: false;
25
26
  readonly destructiveHint: true;
26
27
  };
28
+ /**
29
+ * A group's tools that are listed on every machine, so an agent on one that can't run them hears
30
+ * why, and refused where the Host Adapter lacks these capabilities. A tool listed only on a capable
31
+ * host needs no entry: the reference finds what it needs from the listing.
32
+ */
33
+ export type RefusedWithout<N extends string> = {
34
+ readonly [Name in N]?: readonly HostCapabilityName[];
35
+ };
27
36
  /** `server.registerTool` for one group's tools: `name` is one of the group's, and the hints are required. */
28
37
  export type GroupRegistrar<N extends string> = <OutputArgs extends ZodRawShapeCompat | AnySchema, InputArgs extends undefined | ZodRawShapeCompat | AnySchema = undefined>(name: N, config: {
29
38
  title?: string;
@@ -0,0 +1,45 @@
1
+ import { type GenericEntry } from "./generic-entries.js";
2
+ /** The prefix of a hotkey's key in GameHotkeys.txt. */
3
+ export declare const HOTKEY_KEY_PREFIX = "Button/Hotkey/";
4
+ export declare const BUTTON_HOTKEYS_PATH: string;
5
+ /** What the game's stock data says of hotkeys (data/button-hotkeys.json). */
6
+ export type StockHotkeys = {
7
+ /** The keys stock GameHotkeys.txt files have a line for (Button/Hotkey/<key>). */
8
+ readonly keys: ReadonlySet<string>;
9
+ /** The stock buttons with a Hotkey of their own, by id, as the key it names. */
10
+ readonly buttons: ReadonlyMap<string, string>;
11
+ };
12
+ /** The game's stock hotkey keys and the buttons that point at another key, read once; a missing or damaged file is refused, naming how to make it again. */
13
+ export declare function stockHotkeys(): StockHotkeys;
14
+ /**
15
+ * The key a Button entry's hotkey is in GameHotkeys.txt, as the game merges it: its own Hotkey, else
16
+ * its parent's (a Blueprint button, else a stock one), else its class default's (the Blueprint's
17
+ * CButton default, else Core's `Button/Hotkey/##id##`), with `##id##` the entry's own id. An empty
18
+ * Hotkey is a button that chose none, so no key. `entries` are the Blueprint's, to find parents.
19
+ */
20
+ export declare function buttonHotkeyKey(entry: GenericEntry, entries: readonly GenericEntry[], stockData?: StockHotkeys): string | undefined;
21
+ /** The keys the mod's own hotkey lines give: its entries' and the Blueprint's strings in enUS GameHotkeys.txt, and the lines `kept` (the package's Kept GameHotkeys.txt text) has. */
22
+ export declare function modHotkeyKeys(sources: readonly {
23
+ readonly entries: readonly GenericEntry[];
24
+ }[], blueprintStrings: Readonly<Record<string, Readonly<Record<string, string>>>>, kept?: readonly string[]): Set<string>;
25
+ /** A button the Blueprint's entries use as a command, and where. */
26
+ export type CommandButton = {
27
+ readonly button: string;
28
+ readonly where: string;
29
+ };
30
+ /**
31
+ * The buttons the entries use as commands on a card: the face of a `LayoutButtons` item of type
32
+ * AbilCmd (when it gives none, the DefaultButtonFace of the Blueprint's ability command it names),
33
+ * and the button of a train, build or research ability's `InfoArray` item. A passive button, or a
34
+ * submenu's, isn't one.
35
+ */
36
+ export declare function commandButtons(entries: readonly GenericEntry[]): CommandButton[];
37
+ /**
38
+ * A warning for each Button the entries write that a card or an ability uses as a command and whose
39
+ * hotkey key has no line: not in `modKeys` (modHotkeyKeys) or the game's stock GameHotkeys.txt. A
40
+ * button the Blueprint doesn't write (a stock or Kept one) isn't checked.
41
+ */
42
+ export declare function missingHotkeyWarnings(sources: readonly {
43
+ readonly from: string;
44
+ readonly entries: readonly GenericEntry[];
45
+ }[], modKeys: ReadonlySet<string>, stockData?: StockHotkeys): string[];
@@ -0,0 +1,185 @@
1
+ // A command button's hotkey (issue #48, docs/reference/data-rules.md). A button used as a command
2
+ // needs a `Button/Hotkey/<key>` line in enUS GameHotkeys.txt, in the mod or its dependencies, or it
3
+ // shows and answers no key. The key is the button's merged Hotkey field: Core's class default gives
4
+ // every CButton `Button/Hotkey/##id##`, a button may point its own at another key (stock BurrowMove
5
+ // has Button/Hotkey/BurrowDown), and a parent's is inherited. buttonHotkeyKey resolves it, for this
6
+ // check and for any that needs a button's key (two buttons aliased on one card, #57).
7
+ //
8
+ // Not backed by an Editor check: that a command button with no line has no key in the game is what
9
+ // the stock data suggests (977 of Liberty's 1,324 buttons have none, mostly passives), and the docs
10
+ // say what is unconfirmed.
11
+ import { readFileSync } from "node:fs";
12
+ import path from "node:path";
13
+ import { CORE_DATA_DIR } from "../catalog/stock-catalog.js";
14
+ import { isCommentItem, isCommentKey } from "../domain/catalog-fields.js";
15
+ import { genericEntryKey } from "./generic-entries.js";
16
+ /** The prefix of a hotkey's key in GameHotkeys.txt. */
17
+ export const HOTKEY_KEY_PREFIX = "Button/Hotkey/";
18
+ /** Core's CButton class default's Hotkey: every button's own key, by its id. */
19
+ const DEFAULT_HOTKEY = `${HOTKEY_KEY_PREFIX}##id##`;
20
+ /** The GameHotkeys.txt whose lines count: the English one, as the stock keys are. */
21
+ const HOTKEYS_FILE = /(^|\/)enUS\.SC2Data\/LocalizedData\/GameHotkeys\.txt$/i;
22
+ export const BUTTON_HOTKEYS_PATH = path.join(CORE_DATA_DIR, "button-hotkeys.json");
23
+ let stock;
24
+ /** The game's stock hotkey keys and the buttons that point at another key, read once; a missing or damaged file is refused, naming how to make it again. */
25
+ export function stockHotkeys() {
26
+ stock ??= (() => {
27
+ let stored;
28
+ try {
29
+ stored = JSON.parse(readFileSync(BUTTON_HOTKEYS_PATH, "utf8"));
30
+ }
31
+ catch (error) {
32
+ throw new Error(`${BUTTON_HOTKEYS_PATH} can't be read (${error instanceof Error ? error.message : String(error)}): make it again with node packages/core/scripts/build-button-hotkeys.mjs`);
33
+ }
34
+ return { keys: new Set(stored.keys.map((key) => `${HOTKEY_KEY_PREFIX}${key}`)), buttons: new Map(Object.entries(stored.buttons)) };
35
+ })();
36
+ return stock;
37
+ }
38
+ /** The text of a field written as a value (`"Hotkey": "x"` or `{ "value": "x" }`), if it is one. */
39
+ function textOf(value) {
40
+ const one = Array.isArray(value) ? value.find((item) => !isCommentItem(item)) : value;
41
+ if (typeof one === "string")
42
+ return one;
43
+ if (typeof one === "object" && one !== null && !Array.isArray(one)) {
44
+ const inner = one.value;
45
+ return typeof inner === "string" ? inner : undefined;
46
+ }
47
+ return undefined;
48
+ }
49
+ /**
50
+ * The key a Button entry's hotkey is in GameHotkeys.txt, as the game merges it: its own Hotkey, else
51
+ * its parent's (a Blueprint button, else a stock one), else its class default's (the Blueprint's
52
+ * CButton default, else Core's `Button/Hotkey/##id##`), with `##id##` the entry's own id. An empty
53
+ * Hotkey is a button that chose none, so no key. `entries` are the Blueprint's, to find parents.
54
+ */
55
+ export function buttonHotkeyKey(entry, entries, stockData = stockHotkeys()) {
56
+ if (entry.id === undefined)
57
+ return undefined;
58
+ const buttons = entries.filter((other) => other.catalog === "Button");
59
+ const classDefault = buttons.find((other) => other.id === undefined && other.class === entry.class && other.attributes?.default === "1");
60
+ const seen = new Set();
61
+ /** The Hotkey text the entry or its parents write, ## tokens unfilled. */
62
+ const written = (current, parent) => {
63
+ if (current !== undefined) {
64
+ if (seen.has(current))
65
+ return undefined;
66
+ seen.add(current);
67
+ const own = textOf(current.fields.Hotkey);
68
+ if (own !== undefined)
69
+ return own;
70
+ parent = current.parent;
71
+ }
72
+ if (parent === undefined)
73
+ return undefined;
74
+ const inBlueprint = buttons.find((other) => other.id === parent);
75
+ return inBlueprint ? written(inBlueprint, undefined) : stockData.buttons.get(parent);
76
+ };
77
+ const text = written(entry, undefined) ?? textOf(classDefault?.fields.Hotkey) ?? DEFAULT_HOTKEY;
78
+ return text === "" ? undefined : text.replaceAll("##id##", entry.id);
79
+ }
80
+ /** The keys the mod's own hotkey lines give: its entries' and the Blueprint's strings in enUS GameHotkeys.txt, and the lines `kept` (the package's Kept GameHotkeys.txt text) has. */
81
+ export function modHotkeyKeys(sources, blueprintStrings, kept = []) {
82
+ const keys = new Set();
83
+ const add = (strings) => {
84
+ for (const [file, lines] of Object.entries(strings ?? {}))
85
+ if (HOTKEYS_FILE.test(file))
86
+ for (const key of Object.keys(lines))
87
+ keys.add(key);
88
+ };
89
+ add(blueprintStrings);
90
+ for (const { entries } of sources)
91
+ for (const entry of entries)
92
+ add(entry.strings);
93
+ for (const text of kept)
94
+ for (const line of text.split(/\r?\n/))
95
+ keys.add(line.replace(/^/, "").split("=")[0].trim());
96
+ return keys;
97
+ }
98
+ /** The items of a field written once or as an array, comments left out. */
99
+ const items = (value) => (value === undefined ? [] : (Array.isArray(value) ? [...value] : [value]).filter((item) => !isCommentItem(item)));
100
+ const struct = (value) => (typeof value === "object" && value !== null && !Array.isArray(value) ? value : undefined);
101
+ /** Each `LayoutButtons` item anywhere in a field's structure (a CUnit's CardLayouts hold them). */
102
+ function layoutButtons(value, out = []) {
103
+ if (Array.isArray(value))
104
+ value.forEach((item) => layoutButtons(item, out));
105
+ else if (typeof value === "object" && value !== null) {
106
+ for (const [name, member] of Object.entries(value)) {
107
+ if (isCommentKey(name))
108
+ continue;
109
+ if (name === "LayoutButtons")
110
+ for (const item of items(member)) {
111
+ const button = struct(item);
112
+ if (button)
113
+ out.push(button);
114
+ }
115
+ else
116
+ layoutButtons(member, out);
117
+ }
118
+ }
119
+ return out;
120
+ }
121
+ /**
122
+ * The buttons the entries use as commands on a card: the face of a `LayoutButtons` item of type
123
+ * AbilCmd (when it gives none, the DefaultButtonFace of the Blueprint's ability command it names),
124
+ * and the button of a train, build or research ability's `InfoArray` item. A passive button, or a
125
+ * submenu's, isn't one.
126
+ */
127
+ export function commandButtons(entries) {
128
+ const out = [];
129
+ const abilities = new Map(entries.filter((entry) => entry.catalog === "Abil" && entry.id !== undefined).map((entry) => [entry.id, entry]));
130
+ const commandFace = (abilCmd) => {
131
+ const [abil, command] = abilCmd.split(",");
132
+ for (const item of items(abilities.get(abil ?? "")?.fields.CmdButtonArray)) {
133
+ const one = struct(item);
134
+ if (one && String(one.index) === command && typeof one.DefaultButtonFace === "string")
135
+ return one.DefaultButtonFace;
136
+ }
137
+ return undefined;
138
+ };
139
+ for (const entry of entries) {
140
+ const name = genericEntryKey(entry);
141
+ for (const field of Object.values(entry.fields)) {
142
+ for (const item of layoutButtons(field)) {
143
+ if (item.Type !== "AbilCmd" || typeof item.AbilCmd !== "string")
144
+ continue;
145
+ const face = typeof item.Face === "string" ? item.Face : commandFace(item.AbilCmd);
146
+ if (face !== undefined)
147
+ out.push({ button: face, where: `${name}'s card (${item.AbilCmd})` });
148
+ }
149
+ }
150
+ if (entry.catalog === "Abil" && ["CAbilTrain", "CAbilBuild", "CAbilResearch"].includes(entry.class)) {
151
+ for (const item of items(entry.fields.InfoArray)) {
152
+ const face = struct(struct(item)?.Button)?.DefaultButtonFace;
153
+ if (typeof face === "string")
154
+ out.push({ button: face, where: `${name}'s InfoArray` });
155
+ }
156
+ }
157
+ }
158
+ return out;
159
+ }
160
+ /**
161
+ * A warning for each Button the entries write that a card or an ability uses as a command and whose
162
+ * hotkey key has no line: not in `modKeys` (modHotkeyKeys) or the game's stock GameHotkeys.txt. A
163
+ * button the Blueprint doesn't write (a stock or Kept one) isn't checked.
164
+ */
165
+ export function missingHotkeyWarnings(sources, modKeys, stockData = stockHotkeys()) {
166
+ const all = sources.flatMap(({ entries }) => entries);
167
+ const uses = new Map();
168
+ for (const { button, where } of commandButtons(all))
169
+ uses.set(button, [...(uses.get(button) ?? []), where]);
170
+ const out = [];
171
+ for (const { from, entries } of sources) {
172
+ for (const entry of entries) {
173
+ if (entry.catalog !== "Button" || entry.id === undefined)
174
+ continue;
175
+ const where = uses.get(entry.id);
176
+ if (where === undefined)
177
+ continue;
178
+ const key = buttonHotkeyKey(entry, all, stockData);
179
+ if (key === undefined || modKeys.has(key) || stockData.keys.has(key))
180
+ continue;
181
+ out.push(`${from}: ${genericEntryKey(entry)} is a command button (${[...new Set(where)].join(", ")}) whose hotkey key ${key} has no line in the mod's or the game's enUS GameHotkeys.txt, so it has no hotkey: add "${key}" to the button's strings in enUS.SC2Data/LocalizedData/GameHotkeys.txt, or point its Hotkey at a key that has one`);
182
+ }
183
+ }
184
+ return out;
185
+ }
@@ -55,9 +55,10 @@ import { triggerItemTexts } from "../triggers/splice-triggers.js";
55
55
  import { isInside } from "../util/inside.js";
56
56
  import { makeAssets, PLACEHOLDERS_DIR, planAssets, trackedByGit } from "./asset-sources.js";
57
57
  import { CatalogSchemaError, catalogSchema, entryFile, schemaProblems } from "./catalog-schema.js";
58
+ import { missingHotkeyWarnings, modHotkeyKeys } from "./button-hotkeys.js";
58
59
  import { dataRuleWarnings } from "./data-rules.js";
59
60
  import { shapeEntries } from "./characters.js";
60
- import { hostGameModels, modDoodadWarnings } from "./custom-doodads.js";
61
+ import { entryAssetPaths, genericEntryAssetWarnings, hostGameModels, modDoodadWarnings, modFileFinder, samePath } from "./custom-doodads.js";
61
62
  import { CONVERSATION_STRINGS, conversationEntry, conversationStrings, readModScreenplays } from "./conversations.js";
62
63
  import { CUTSCENE_ASPECTS, cutsceneDifferences } from "../cutscene/compare-cutscenes.js";
63
64
  import { EquivalenceCheck } from "./equivalence.js";
@@ -238,10 +239,18 @@ export async function compileMod(blueprintPath, options = {}) {
238
239
  // A gameModel's swaps read the game's .m3 through the Host Adapter, loaded only when one does.
239
240
  const doodads = blueprint.doodads.length > 0 ? await modDoodadWarnings(blueprint.doodads, await workspace(), blueprint.id, async () => hostGameModels(await machineHost())) : undefined;
240
241
  const doodadWarnings = doodads?.warnings ?? [];
241
- const { byFile: generic, strings: entryStrings, warnings: dataWarnings } = await genericEntries(blueprint, source, doodads?.swaps ?? new Map(), [
242
+ // The hotkey lines the package Keeps, which the missing-hotkey check counts (button-hotkeys.ts).
243
+ const keptHotkeys = await Promise.all(existing.filter((file) => /(^|\/)enUS\.SC2Data\/LocalizedData\/GameHotkeys\.txt$/i.test(file)).map((file) => readFile(path.join(pkg, ...file.split("/")), "utf8")));
244
+ // The files an entry's asset path can name: the mod packages, and what this compile writes (not on disk yet).
245
+ const blueprintFiles = new Set([...blueprint.files, ...blueprint.assets].map(({ path: file }) => samePath(file.replace(/^Base\.SC2Assets[\\/]/i, ""))));
246
+ const assetFiles = async () => {
247
+ const { find, lookedIn } = await modFileFinder(await workspace(), blueprint.id);
248
+ return { find: (storagePath) => find(storagePath) ?? (blueprintFiles.has(samePath(storagePath)) ? { data: new Uint8Array(), where: "the Blueprint's files" } : undefined), lookedIn };
249
+ };
250
+ const { byFile: generic, strings: entryStrings, warnings: dataWarnings } = await genericEntries(blueprint, source, doodads?.swaps ?? new Map(), assetFiles, [
242
251
  { from: "screenplays", entries: scripts.map(conversationEntry) },
243
252
  { from: "soundSets", entries: await soundSetEntries(blueprint, name, scripts, workspace) },
244
- ]);
253
+ ], keptHotkeys);
245
254
  for (const [asked, entries] of generic) {
246
255
  const file = spelled(asked);
247
256
  if (!queued.has(file))
@@ -577,7 +586,7 @@ async function stillNamed(pkg, removed) {
577
586
  * file each goes in: its catalog's own unless it names one. Throws CatalogSchemaError, listing
578
587
  * every problem, when any entry doesn't fit.
579
588
  */
580
- async function genericEntries(blueprint, source, swapSlots, shapes) {
589
+ async function genericEntries(blueprint, source, swapSlots, assetFiles, shapes, keptHotkeys) {
581
590
  const schema = catalogSchema();
582
591
  const byFile = new Map();
583
592
  const strings = [];
@@ -586,6 +595,8 @@ async function genericEntries(blueprint, source, swapSlots, shapes) {
586
595
  const sources = [];
587
596
  for (const { source: from } of blueprint.entries)
588
597
  sources.push({ from, list: readGenericEntries((await source(from)).toString("utf8"), from) });
598
+ // The Blueprint's own entries' asset paths are checked (custom-doodads.ts); the shapes' are the Blueprint's other checks'.
599
+ const own = sources.flatMap(({ list }) => list);
589
600
  // Purpose-level shapes, as the generic entries they compile down to.
590
601
  for (const { from, entries } of [...shapeEntries(blueprint, swapSlots), ...shapes])
591
602
  sources.push({ from, list: entries });
@@ -612,7 +623,10 @@ async function genericEntries(blueprint, source, swapSlots, shapes) {
612
623
  }
613
624
  if (problems.length > 0)
614
625
  throw new CatalogSchemaError(problems);
615
- return { byFile, strings, warnings: dataRuleWarnings(sources.map(({ from, list }) => ({ from, entries: list }))) };
626
+ const written = sources.map(({ from, list }) => ({ from, entries: list }));
627
+ // The files are looked for only when an entry names one.
628
+ const assetWarnings = own.some((entry) => entryAssetPaths(entry).length > 0) ? await assetFiles().then(({ find, lookedIn }) => genericEntryAssetWarnings(own, find, lookedIn)) : [];
629
+ return { byFile, strings, warnings: [...dataRuleWarnings(written), ...missingHotkeyWarnings(written, modHotkeyKeys(written, blueprint.strings, keptHotkeys)), ...assetWarnings] };
616
630
  }
617
631
  /** The game strings file a mod's DocInfo strings are in. */
618
632
  const GAME_STRINGS = "enUS.SC2Data/LocalizedData/GameStrings.txt";
@@ -1,6 +1,6 @@
1
1
  import type { CustomDoodad, MissionDoodad } from "../domain/custom-doodad.js";
2
2
  import type { Workspace } from "../plugins/workspace.js";
3
- import type { GenericEntry } from "./generic-entries.js";
3
+ import { type GenericEntry } from "./generic-entries.js";
4
4
  import type { Host } from "../host/host.js";
5
5
  import { type SwapSlot } from "./texture-swaps.js";
6
6
  /** A storage path to compare: one slash, any case, as the game matches it. */
@@ -24,6 +24,26 @@ export type FoundFile = {
24
24
  * file missing, when the model or a texture isn't found, and when its id is a game doodad's or unit's; returns the warnings.
25
25
  */
26
26
  export declare function checkCustomDoodadFiles(doodad: CustomDoodad, label: string, find: (storagePath: string) => FoundFile | undefined, lookedIn: string): string[];
27
+ /**
28
+ * Finds a file by its storage path in the mod packages the game loads under the mod `id`, the mod's
29
+ * own among them (its Asset Mod's too, once compiled): `lookedIn` says where, for messages.
30
+ */
31
+ export declare function modFileFinder(workspace: Pick<Workspace, "root" | "mods">, id: string): Promise<{
32
+ readonly find: (storagePath: string) => FoundFile | undefined;
33
+ readonly lookedIn: string;
34
+ }>;
35
+ /** The asset paths `entry`'s fields name, each with its field's name (a nested one dotted, as `TextureDeclares.Prefix`). */
36
+ export declare function entryAssetPaths(entry: GenericEntry): {
37
+ readonly field: string;
38
+ readonly path: string;
39
+ }[];
40
+ /**
41
+ * Warns about each asset path `entries`' fields name (entryAssetPaths) that is no file the game
42
+ * loads under the mod: not found by `find` (as checkCustomDoodadFiles finds a model or texture), not
43
+ * a model core knows of (isGameModel), and for an image not one the game's data names (isGameAsset, every stock mod).
44
+ * The game may still have a file those lists lack, so it is advice. Names the entry, field and path.
45
+ */
46
+ export declare function genericEntryAssetWarnings(entries: readonly GenericEntry[], find: (storagePath: string) => FoundFile | undefined, lookedIn: string): string[];
27
47
  /**
28
48
  * Checks the files of a Campaign Mod's doodads (its Blueprint `doodads`, its folder's id `id`) in
29
49
  * the Workspace's mod packages the game loads under it (its Asset Mod among them), as