@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.
- package/README.md +2 -0
- package/data/blizzard-baseline.json +3061 -0
- package/data/button-hotkeys.json +5722 -0
- package/data/game-assets.json +50909 -0
- package/data/package-entries.json +32361 -2
- package/dist/capture/bank-fixtures.d.ts +13 -0
- package/dist/capture/bank-fixtures.js +35 -0
- package/dist/capture/bank-snapshots.d.ts +95 -0
- package/dist/capture/bank-snapshots.js +302 -0
- package/dist/capture/editor-broker-client.d.ts +27 -4
- package/dist/capture/editor-broker-client.js +3 -3
- package/dist/capture/editor-broker.js +154 -9
- package/dist/capture/effect-tour.d.ts +113 -0
- package/dist/capture/effect-tour.js +283 -0
- package/dist/capture/effect-video.d.ts +74 -0
- package/dist/capture/effect-video.js +173 -0
- package/dist/capture/exemplar-capture.d.ts +4 -0
- package/dist/capture/exemplar-capture.js +4 -1
- package/dist/capture/shots.d.ts +6 -1
- package/dist/capture/shots.js +1 -1
- package/dist/capture/stop-tour.d.ts +3 -1
- package/dist/capture/stop-tour.js +1 -1
- package/dist/capture/style-pack-captures.d.ts +67 -0
- package/dist/capture/style-pack-captures.js +172 -0
- package/dist/catalog/stock-catalog.d.ts +8 -0
- package/dist/catalog/stock-catalog.js +13 -0
- package/dist/cli/capture-exemplars.js +18 -32
- package/dist/cli/effect-tour.d.ts +2 -0
- package/dist/cli/effect-tour.js +378 -0
- package/dist/cli/make-frames.d.ts +1 -0
- package/dist/cli/make-frames.js +21 -0
- package/dist/cli/sound-mix.d.ts +1 -0
- package/dist/cli/sound-mix.js +75 -0
- package/dist/cli/study.js +6 -26
- package/dist/domain/blueprint-trigger.d.ts +355 -3
- package/dist/domain/blueprint-trigger.js +149 -8
- package/dist/domain/library-interface.d.ts +50 -29
- package/dist/domain/library-interface.js +54 -41
- package/dist/domain/mission-blueprint.d.ts +13 -6
- package/dist/domain/mission-blueprint.js +6 -0
- package/dist/domain/mod-blueprint.d.ts +4 -4
- package/dist/host/game-logs.d.ts +63 -0
- package/dist/host/game-logs.js +178 -0
- package/dist/host/game-ownership.d.ts +37 -0
- package/dist/host/game-ownership.js +84 -0
- package/dist/host/game-run-report.d.ts +63 -0
- package/dist/host/game-run-report.js +119 -0
- package/dist/host/known-errors.d.ts +34 -0
- package/dist/host/known-errors.js +73 -0
- package/dist/init/init-workspace.d.ts +3 -1
- package/dist/init/init-workspace.js +10 -1
- package/dist/map/convert-mission-triggers.d.ts +115 -7
- package/dist/map/convert-mission-triggers.js +527 -47
- package/dist/map/editor-changes.d.ts +1 -1
- package/dist/map/editor-form.d.ts +5 -0
- package/dist/map/editor-form.js +72 -0
- package/dist/map/game-packages.d.ts +3 -2
- package/dist/map/game-packages.js +5 -2
- package/dist/map/kept-references.js +47 -1
- package/dist/map/kept-session.js +3 -1
- package/dist/map/outline-diff.d.ts +24 -0
- package/dist/map/outline-diff.js +95 -0
- package/dist/map/outline-trigger.d.ts +7 -0
- package/dist/map/outline-trigger.js +29 -20
- package/dist/map/ownership-plan.d.ts +6 -2
- package/dist/map/ownership-plan.js +1 -1
- package/dist/map/package-output.js +13 -8
- package/dist/map/tune-kept-triggers.d.ts +7 -0
- package/dist/map/tune-kept-triggers.js +33 -6
- package/dist/map/write-blueprint-trigger.d.ts +9 -4
- package/dist/map/write-blueprint-trigger.js +46 -13
- package/dist/map/write-map-package.js +20 -9
- package/dist/mcp/capture-jobs.d.ts +2 -0
- package/dist/mcp/capture-jobs.js +2 -0
- package/dist/mcp/server.d.ts +11 -2
- package/dist/mcp/server.js +17 -4
- package/dist/mcp/tools/bank-report.d.ts +19 -0
- package/dist/mcp/tools/bank-report.js +51 -0
- package/dist/mcp/tools/blueprint.js +18 -14
- package/dist/mcp/tools/capture.d.ts +4 -0
- package/dist/mcp/tools/capture.js +22 -5
- package/dist/mcp/tools/catalog.d.ts +1 -1
- package/dist/mcp/tools/catalog.js +30 -1
- package/dist/mcp/tools/compile.d.ts +1 -1
- package/dist/mcp/tools/compile.js +100 -9
- package/dist/mcp/tools/editor-handoff.d.ts +4 -1
- package/dist/mcp/tools/editor-handoff.js +6 -3
- package/dist/mcp/tools/style-pack.d.ts +11 -0
- package/dist/mcp/tools/style-pack.js +245 -0
- package/dist/mcp/tools/tool-group.d.ts +9 -0
- package/dist/mods/button-hotkeys.d.ts +45 -0
- package/dist/mods/button-hotkeys.js +185 -0
- package/dist/mods/compile-mod.js +19 -5
- package/dist/mods/custom-doodads.d.ts +21 -1
- package/dist/mods/custom-doodads.js +53 -7
- package/dist/mods/data-rules.js +8 -1
- package/dist/mods/effective-entry.d.ts +18 -0
- package/dist/mods/effective-entry.js +52 -0
- package/dist/mods/function-search.js +12 -0
- package/dist/mods/library-xml.d.ts +34 -5
- package/dist/mods/library-xml.js +94 -22
- package/dist/mods/sound-mix.d.ts +92 -0
- package/dist/mods/sound-mix.js +195 -0
- package/dist/plugins/check-workspace.js +22 -3
- package/dist/plugins/plugin-api.d.ts +59 -5
- package/dist/plugins/plugin-api.js +6 -0
- package/dist/plugins/plugin-sdk.d.ts +13 -1
- package/dist/plugins/plugin-sdk.js +16 -1
- package/dist/plugins/plugin-sources.js +1 -0
- package/dist/plugins/registry.d.ts +4 -0
- package/dist/plugins/registry.js +6 -2
- package/dist/plugins/workspace.d.ts +5 -0
- package/dist/plugins/workspace.js +10 -2
- package/dist/study/blizzard-baseline.d.ts +76 -0
- package/dist/study/blizzard-baseline.js +137 -0
- package/dist/study/exemplar-report.d.ts +71 -0
- package/dist/study/exemplar-report.js +163 -0
- package/dist/study/find-places.d.ts +127 -0
- package/dist/study/find-places.js +306 -0
- package/dist/study/load-map-package.d.ts +3 -0
- package/dist/study/load-map-package.js +11 -0
- package/dist/study/map-study.d.ts +1 -0
- package/dist/study/map-study.js +3 -0
- package/dist/study/measure-lighting.d.ts +6 -0
- package/dist/study/measure-lighting.js +1 -1
- package/dist/study/measures.d.ts +225 -0
- package/dist/study/measures.js +366 -0
- package/dist/study/scaffold-style-pack.d.ts +58 -0
- package/dist/study/scaffold-style-pack.js +261 -0
- package/dist/study/study-exemplars.d.ts +67 -0
- package/dist/study/study-exemplars.js +133 -0
- package/dist/triggers/blueprint-triggers.d.ts +71 -11
- package/dist/triggers/blueprint-triggers.js +403 -48
- package/dist/triggers/kept-trigger-galaxy.d.ts +29 -0
- package/dist/triggers/kept-trigger-galaxy.js +103 -7
- package/dist/triggers/splice-map-script.d.ts +2 -0
- package/dist/triggers/splice-map-script.js +309 -8
- package/dist/triggers/write-triggers-xml.js +20 -5
- package/dist/ui/frame-path-check.d.ts +43 -4
- package/dist/ui/frame-path-check.js +121 -13
- package/dist/ui/frame-paths.d.ts +21 -1
- package/dist/ui/frame-paths.js +26 -6
- package/dist/ui/toast.d.ts +4 -5
- package/dist/ui/toast.js +6 -10
- package/examples/example-campaign/README.md +27 -0
- package/examples/example-campaign/missions/ashfall-relay/blueprint.json +11 -1
- package/examples/example-campaign/missions/ashfall-relay/triggers/ash-tremors.json +69 -0
- package/examples/example-campaign/missions/ashfall-relay/triggers/start-ash-tremors.json +31 -0
- package/package.json +3 -3
|
@@ -27,6 +27,9 @@ import { formatFixed } from "../triggers/write-triggers-xml.js";
|
|
|
27
27
|
import { child, children, elementKey, elementOf, readTriggersFile, referenced, refKey, triggerStringNames } from "../triggers/triggers-file.js";
|
|
28
28
|
import { packageContents } from "./kept-references.js";
|
|
29
29
|
import { openKeptSession, withMissionPackageLock } from "./kept-session.js";
|
|
30
|
+
import { outlineDiff } from "./outline-diff.js";
|
|
31
|
+
import { outlineKeptTriggerFrom } from "./outline-trigger.js";
|
|
32
|
+
import { missionTriggerReach } from "./write-blueprint-trigger.js";
|
|
30
33
|
import { missionMapPackage, readCompileRecord } from "./mission-package.js";
|
|
31
34
|
import { readDependencies } from "./read-dependencies.js";
|
|
32
35
|
const ElementId = z.string().regex(/^[0-9A-F]{8}$/, "An element Id is 8 uppercase hex digits, as Triggers has it");
|
|
@@ -60,7 +63,9 @@ export const KeptTriggerEditSchema = z.discriminatedUnion("op", [
|
|
|
60
63
|
})
|
|
61
64
|
.strict(),
|
|
62
65
|
]);
|
|
63
|
-
const TRIGGER_STRINGS =
|
|
66
|
+
const TRIGGER_STRINGS = "enUS.SC2Data/LocalizedData/TriggerStrings.txt";
|
|
67
|
+
/** A file of the package by its path inside it, which is always written with forward slashes (as the Kept session keys files). */
|
|
68
|
+
const inPackage = (dir, file) => path.join(dir, ...file.split("/"));
|
|
64
69
|
/** core's catalog and every Mechanic's primitives in the Workspace. */
|
|
65
70
|
export function keptCatalog(workspace) {
|
|
66
71
|
const functions = new Map(CORE_PRIMITIVES.functions);
|
|
@@ -77,20 +82,21 @@ export function keptCatalog(workspace) {
|
|
|
77
82
|
}
|
|
78
83
|
async function readPackage(dir) {
|
|
79
84
|
for (const file of ["Triggers", "MapScript.galaxy", TRIGGER_STRINGS]) {
|
|
80
|
-
if (!existsSync(
|
|
85
|
+
if (!existsSync(inPackage(dir, file)))
|
|
81
86
|
throw new Error(`${dir} has no ${file}, so it has no Kept triggers to tune`);
|
|
82
87
|
}
|
|
83
88
|
const gameStrings = new Map();
|
|
84
89
|
for (const entry of await readdir(dir, { withFileTypes: true })) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
90
|
+
// Keyed with forward slashes on every OS: the session finds what it read by this key, and a Windows path's backslashes would match nothing.
|
|
91
|
+
const file = `${entry.name}/LocalizedData/GameStrings.txt`;
|
|
92
|
+
if (entry.isDirectory() && entry.name.endsWith(".SC2Data") && existsSync(inPackage(dir, file)))
|
|
93
|
+
gameStrings.set(file, await readFile(inPackage(dir, file), "utf8"));
|
|
88
94
|
}
|
|
89
95
|
return {
|
|
90
96
|
dir,
|
|
91
97
|
triggers: await readFile(path.join(dir, "Triggers"), "utf8"),
|
|
92
98
|
script: await readFile(path.join(dir, "MapScript.galaxy"), "utf8"),
|
|
93
|
-
names: triggerStringNames(await readFile(
|
|
99
|
+
names: triggerStringNames(await readFile(inPackage(dir, TRIGGER_STRINGS), "utf8")),
|
|
94
100
|
gameStrings,
|
|
95
101
|
placed: await packageContents(dir, new Set(["unit", "point", "camera", "region"])),
|
|
96
102
|
};
|
|
@@ -487,12 +493,14 @@ async function tuneKeptTriggersLocked(workspace, blueprintPath, edits, options)
|
|
|
487
493
|
const kept = blueprint.kept ?? [];
|
|
488
494
|
const galaxies = new Map();
|
|
489
495
|
const changed = [];
|
|
496
|
+
const touched = new Map();
|
|
490
497
|
const texts = () => textKeys(pkg);
|
|
491
498
|
parsed.forEach((edit, index) => {
|
|
492
499
|
try {
|
|
493
500
|
const file = readTriggersFile(pkg.triggers);
|
|
494
501
|
const target = resolveTarget(file, pkg.names, kept, edit.trigger);
|
|
495
502
|
refuseCompiled(target, compiled);
|
|
503
|
+
touched.set(elementKey(target.type, target.id), target);
|
|
496
504
|
// By type and Id: an older map's trigger and function can share an Id.
|
|
497
505
|
const galaxyKey = elementKey(target.type, target.id);
|
|
498
506
|
if (!galaxies.has(galaxyKey)) {
|
|
@@ -514,6 +522,8 @@ async function tuneKeptTriggersLocked(workspace, blueprintPath, edits, options)
|
|
|
514
522
|
throw new Error(`Edit ${index + 1} (${edit.op}): ${error instanceof Error ? error.message : String(error)}. Nothing was written`, { cause: error });
|
|
515
523
|
}
|
|
516
524
|
});
|
|
525
|
+
if (options.dryRun)
|
|
526
|
+
return { changed, files: [], mapPackage, diffs: await dryRunDiffs(workspace, blueprintPath, [...touched.values()], original.triggers, pkg) };
|
|
517
527
|
// Only the files the edits changed, written together so the XML, the script and the strings never disagree.
|
|
518
528
|
const candidates = [
|
|
519
529
|
["Triggers", pkg.triggers, original.triggers],
|
|
@@ -525,6 +535,23 @@ async function tuneKeptTriggersLocked(workspace, blueprintPath, edits, options)
|
|
|
525
535
|
const files = changedFiles.length > 0 ? await session.commit(changedFiles) : [];
|
|
526
536
|
return { changed, files: files.map((file) => file.split(path.sep).join("/")), mapPackage };
|
|
527
537
|
}
|
|
538
|
+
/**
|
|
539
|
+
* Each trigger edited, as the Editor shows it after the edits with its changed lines marked
|
|
540
|
+
* (outline-diff.ts). A trigger the Editor's form can't read is named with why; a function has none.
|
|
541
|
+
*/
|
|
542
|
+
async function dryRunDiffs(workspace, blueprintPath, targets, was, now) {
|
|
543
|
+
const reach = await missionTriggerReach(workspace, blueprintPath);
|
|
544
|
+
return targets.map((target) => {
|
|
545
|
+
if (target.type !== "Trigger")
|
|
546
|
+
return { trigger: target.name, diff: `${target.name} is a function: outline_trigger reads triggers, so its change isn't shown in the Editor's form` };
|
|
547
|
+
try {
|
|
548
|
+
return { trigger: target.name, diff: outlineDiff(outlineKeptTriggerFrom(reach, target.id, was, reach.gameStrings), outlineKeptTriggerFrom(reach, target.id, now.triggers, now.gameStrings)) };
|
|
549
|
+
}
|
|
550
|
+
catch (error) {
|
|
551
|
+
return { trigger: target.name, diff: `${target.name}: no Editor-form diff: ${error instanceof Error ? error.message : String(error)}` };
|
|
552
|
+
}
|
|
553
|
+
});
|
|
554
|
+
}
|
|
528
555
|
/**
|
|
529
556
|
* A Kept trigger's or function's calls and parameters with their element Ids and Galaxy values, to
|
|
530
557
|
* pick what to tune; and whether it can be tuned (else why not).
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BlueprintTrigger } from "../domain/blueprint-trigger.js";
|
|
1
|
+
import type { BlueprintFunction, BlueprintPreset, BlueprintRecord, BlueprintTrigger } from "../domain/blueprint-trigger.js";
|
|
2
2
|
import type { MissionBlueprint } from "../domain/mission-blueprint.js";
|
|
3
3
|
import { type GuiVariable } from "../domain/library-interface.js";
|
|
4
4
|
import type { GameLibrary } from "../mods/library-galaxy.js";
|
|
@@ -26,8 +26,8 @@ export type PackageTriggerFiles = {
|
|
|
26
26
|
/**
|
|
27
27
|
* The map's own elements a trigger may name, for the authoring tool (MapReach): the `kept` items'
|
|
28
28
|
* functions (their interfaces; one that can't be read is left out, so a call to it is refused as
|
|
29
|
-
* one not in reach), globals, triggers
|
|
30
|
-
* Blueprint's own globals and
|
|
29
|
+
* one not in reach), globals, triggers, preset types and records, by their names in TriggerStrings; the
|
|
30
|
+
* Blueprint's own globals, triggers, functions, preset types and records; and the enUS GameStrings' words, for a Kept function's
|
|
31
31
|
* text defaults.
|
|
32
32
|
*/
|
|
33
33
|
export declare function authoringMapReach(files: {
|
|
@@ -40,6 +40,9 @@ export declare function authoringMapReach(files: {
|
|
|
40
40
|
}[], blueprint: {
|
|
41
41
|
readonly triggers: readonly AuthoredTrigger[];
|
|
42
42
|
readonly variables: readonly GuiVariable[];
|
|
43
|
+
readonly functions?: readonly BlueprintFunction[];
|
|
44
|
+
readonly presets?: readonly BlueprintPreset[];
|
|
45
|
+
readonly records?: readonly BlueprintRecord[];
|
|
43
46
|
}): MapReach;
|
|
44
47
|
/** What a Mission's own triggers may name, read from its Blueprint, its package and its compile record. */
|
|
45
48
|
export type MissionTriggerReach = {
|
|
@@ -81,4 +84,6 @@ export declare function writeBlueprintTrigger(workspace: Workspace, blueprintPat
|
|
|
81
84
|
export declare function authoredTriggerGalaxy(trigger: BlueprintTrigger, others: readonly AuthoredTrigger[], globals: readonly GuiVariable[], files: {
|
|
82
85
|
readonly triggers: string;
|
|
83
86
|
readonly gameStrings: readonly string[];
|
|
84
|
-
}, keptNames: ReadonlyMap<string, string>, libraries: Readonly<Record<string, GameLibrary
|
|
87
|
+
}, keptNames: ReadonlyMap<string, string>, libraries: Readonly<Record<string, GameLibrary>>,
|
|
88
|
+
/** The Blueprint's functions, which stand over the package's copies as its triggers do. */
|
|
89
|
+
functions?: readonly BlueprintFunction[]): string;
|
|
@@ -11,10 +11,10 @@ import { existsSync } from "node:fs";
|
|
|
11
11
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
12
12
|
import path from "node:path";
|
|
13
13
|
import { heldIds } from "../domain/library-interface.js";
|
|
14
|
-
import { ElementWriter, mapElements, readMapFunction, stringTable, UnconvertibleFunctionError } from "../mods/library-xml.js";
|
|
14
|
+
import { ElementWriter, functionStrings, mapElements, readMapFunction, stringTable, UnconvertibleFunctionError } from "../mods/library-xml.js";
|
|
15
15
|
import { parseMissionBlueprint } from "../plugins/workspace.js";
|
|
16
16
|
import { AuthoringError, AuthoringTriggerSchema, authorTrigger } from "../triggers/author-trigger.js";
|
|
17
|
-
import { blueprintReferenceProblems, blueprintTriggerFile, blueprintTriggerIds, blueprintTriggerXml, readAuthoredTriggers, unknownParts } from "../triggers/blueprint-triggers.js";
|
|
17
|
+
import { blueprintFunctionIds, blueprintFunctionXml, blueprintPresetIds, blueprintRecordIds, blueprintReferenceProblems, blueprintTriggerFile, blueprintTriggerIds, blueprintTriggerXml, libraryForm, readAuthoredTriggers, unknownParts } from "../triggers/blueprint-triggers.js";
|
|
18
18
|
import { KeptGalaxyRenderer, textValueKeys } from "../triggers/kept-trigger-galaxy.js";
|
|
19
19
|
import { libraryItems, recordedItemKeys } from "../triggers/splice-triggers.js";
|
|
20
20
|
import { CORE_PRIMITIVES } from "../triggers/trigger-catalog.js";
|
|
@@ -70,14 +70,15 @@ function keptVariableType(node) {
|
|
|
70
70
|
/**
|
|
71
71
|
* The map's own elements a trigger may name, for the authoring tool (MapReach): the `kept` items'
|
|
72
72
|
* functions (their interfaces; one that can't be read is left out, so a call to it is refused as
|
|
73
|
-
* one not in reach), globals, triggers
|
|
74
|
-
* Blueprint's own globals and
|
|
73
|
+
* one not in reach), globals, triggers, preset types and records, by their names in TriggerStrings; the
|
|
74
|
+
* Blueprint's own globals, triggers, functions, preset types and records; and the enUS GameStrings' words, for a Kept function's
|
|
75
75
|
* text defaults.
|
|
76
76
|
*/
|
|
77
77
|
export function authoringMapReach(files, kept, blueprint) {
|
|
78
78
|
const strings = stringTable(files.triggerStrings);
|
|
79
79
|
const elements = mapElements(files.triggers);
|
|
80
|
-
|
|
80
|
+
// The Blueprint's own functions, as a Kept one's interface is read.
|
|
81
|
+
const functions = (blueprint.functions ?? []).map((fn) => libraryForm(fn).fn);
|
|
81
82
|
for (const item of kept.filter((each) => each.type === "FunctionDef")) {
|
|
82
83
|
try {
|
|
83
84
|
functions.push(readMapFunction(elements, strings, item.id));
|
|
@@ -99,7 +100,11 @@ export function authoringMapReach(files, kept, blueprint) {
|
|
|
99
100
|
});
|
|
100
101
|
return [{ id: item.id, name: strings.get(`Preset/Name/${item.id}`), base: base && xmlAttribute(base, "Value"), bits: child(node, "PresetAsBits") !== undefined, values }];
|
|
101
102
|
});
|
|
102
|
-
|
|
103
|
+
// The Blueprint's own preset types and records, as the Kept ones are read.
|
|
104
|
+
for (const preset of blueprint.presets ?? [])
|
|
105
|
+
presets.push({ id: preset.id, name: preset.name, base: preset.baseType, bits: false, values: preset.values.flatMap((value) => ("name" in value ? [{ id: value.id, name: value.name }] : [])) });
|
|
106
|
+
const structures = (blueprint.records ?? []).map((record) => ({ id: record.id, members: record.members.map((member) => ({ id: member.id, name: member.name, type: member.type })) }));
|
|
107
|
+
structures.push(...kept.flatMap((item) => {
|
|
103
108
|
const node = item.type === "Structure" ? elements.get(`Structure/${item.id}`) : undefined;
|
|
104
109
|
if (!node)
|
|
105
110
|
return [];
|
|
@@ -112,7 +117,7 @@ export function authoringMapReach(files, kept, blueprint) {
|
|
|
112
117
|
return [{ id, name, ...(type ? { type } : {}) }];
|
|
113
118
|
});
|
|
114
119
|
return [{ id: item.id, members }];
|
|
115
|
-
});
|
|
120
|
+
}));
|
|
116
121
|
const texts = new Map();
|
|
117
122
|
for (const text of files.gameStrings)
|
|
118
123
|
for (const [key, words] of stringTable(text))
|
|
@@ -147,8 +152,17 @@ export async function missionTriggerReach(workspace, blueprintPath) {
|
|
|
147
152
|
const { files, gameStrings } = await packageFiles(blueprintPath);
|
|
148
153
|
const record = await readCompileRecord(blueprintPath);
|
|
149
154
|
const compiled = record ? recordedItemKeys(record.entries) : new Set();
|
|
150
|
-
|
|
151
|
-
const
|
|
155
|
+
// The Blueprint's own elements are read from it, not the package's copies.
|
|
156
|
+
const owned = new Set([
|
|
157
|
+
...authored.triggers.map(({ trigger }) => `Trigger/${trigger.id}`),
|
|
158
|
+
...(authored.functions ?? []).map(({ fn }) => `FunctionDef/${fn.id}`),
|
|
159
|
+
...(authored.variables ?? []).map((variable) => `Variable/${variable.id}`),
|
|
160
|
+
...(authored.comments ?? []).map(({ comment }) => `Comment/${comment.id}`),
|
|
161
|
+
...(authored.presets ?? []).map(({ item }) => `Preset/${item.id}`),
|
|
162
|
+
...(authored.records ?? []).map(({ item }) => `Structure/${item.id}`),
|
|
163
|
+
...(authored.customScripts ?? []).map(({ item }) => `CustomScript/${item.id}`),
|
|
164
|
+
]);
|
|
165
|
+
const kept = [...libraryItems(files.triggers)].filter(([key]) => !compiled.has(key) && !owned.has(key)).map(([, item]) => item);
|
|
152
166
|
return { blueprint, authored, libraries: await missionLibraries(workspace, blueprint.dependencies ?? []), files, gameStrings, record, compiled, kept };
|
|
153
167
|
}
|
|
154
168
|
/**
|
|
@@ -156,7 +170,13 @@ export async function missionTriggerReach(workspace, blueprintPath) {
|
|
|
156
170
|
* `except` (one outlined, as it will be once converted), the Blueprint's globals, and `others`, its
|
|
157
171
|
* triggers but the one written.
|
|
158
172
|
*/
|
|
159
|
-
export const missionMapReach = ({ files, kept, authored }, others, except) => authoringMapReach(files, kept.filter((item) => !(item.type === "Trigger" && item.id === except)), {
|
|
173
|
+
export const missionMapReach = ({ files, kept, authored }, others, except) => authoringMapReach(files, kept.filter((item) => !(item.type === "Trigger" && item.id === except)), {
|
|
174
|
+
triggers: others,
|
|
175
|
+
variables: authored.variables ?? [],
|
|
176
|
+
functions: (authored.functions ?? []).map(({ fn }) => fn),
|
|
177
|
+
presets: (authored.presets ?? []).map(({ item }) => item),
|
|
178
|
+
records: (authored.records ?? []).map(({ item }) => item),
|
|
179
|
+
});
|
|
160
180
|
/**
|
|
161
181
|
* Writes (or, for a Blueprint trigger of the same name, rewrites) the trigger `input` gives in the
|
|
162
182
|
* Editor's terms, as above. Refused (AuthoringError), with every problem in the Editor's terms, when
|
|
@@ -190,6 +210,11 @@ export async function writeBlueprintTrigger(workspace, blueprintPath, given) {
|
|
|
190
210
|
...(record?.entries ?? []).flatMap((entry) => ("id" in entry && typeof entry.id === "string" && /^[0-9A-F]{8}$/.test(entry.id) ? [entry.id] : [])),
|
|
191
211
|
...others.flatMap(({ trigger }) => blueprintTriggerIds(trigger)),
|
|
192
212
|
...(authored.variables ?? []).flatMap((variable) => [variable.id, ...(variable.value ? heldIds(variable.value) : [])]),
|
|
213
|
+
...(authored.functions ?? []).flatMap(({ fn }) => blueprintFunctionIds(fn)),
|
|
214
|
+
...(authored.comments ?? []).map(({ comment }) => comment.id),
|
|
215
|
+
...(authored.presets ?? []).flatMap(({ item }) => blueprintPresetIds(item)),
|
|
216
|
+
...(authored.records ?? []).flatMap(({ item }) => blueprintRecordIds(item)),
|
|
217
|
+
...(authored.customScripts ?? []).map(({ item }) => item.id),
|
|
193
218
|
...authored.folders.map((folder) => folder.id),
|
|
194
219
|
]);
|
|
195
220
|
const { trigger, calls, keptCalls } = authorTrigger(input, { libraries, map, taken, ...(previous ? { previous: previous.trigger } : {}) });
|
|
@@ -209,7 +234,7 @@ export async function writeBlueprintTrigger(workspace, blueprintPath, given) {
|
|
|
209
234
|
const own = problems.filter((problem) => problem.startsWith(prefix)).map((problem) => problem.slice(prefix.length));
|
|
210
235
|
if (own.length > 0)
|
|
211
236
|
throw new AuthoringError(input.name, own.map((problem) => `it ${problem}`));
|
|
212
|
-
authoredTriggerGalaxy(trigger, others, authored.variables ?? [], files, names, libraries);
|
|
237
|
+
authoredTriggerGalaxy(trigger, others, authored.variables ?? [], files, names, libraries, (authored.functions ?? []).map(({ fn }) => fn));
|
|
213
238
|
await mkdir(path.join(dir, "triggers"), { recursive: true });
|
|
214
239
|
await writeFile(path.join(dir, ...file.split("/")), blueprintTriggerFile(trigger));
|
|
215
240
|
if (!previous) {
|
|
@@ -224,18 +249,26 @@ export async function writeBlueprintTrigger(workspace, blueprintPath, given) {
|
|
|
224
249
|
* Blueprint's, as the compile renders it ("" for a disabled one). Refused (AuthoringError) where
|
|
225
250
|
* the engine can't write it as the Editor does.
|
|
226
251
|
*/
|
|
227
|
-
export function authoredTriggerGalaxy(trigger, others, globals, files, keptNames, libraries
|
|
252
|
+
export function authoredTriggerGalaxy(trigger, others, globals, files, keptNames, libraries,
|
|
253
|
+
/** The Blueprint's functions, which stand over the package's copies as its triggers do. */
|
|
254
|
+
functions = []) {
|
|
228
255
|
const base = files.triggers;
|
|
229
256
|
const eol = base.includes("\r\n") ? "\r\n" : "\n";
|
|
230
257
|
const writer = new ElementWriter(undefined, " ");
|
|
231
258
|
for (const variable of globals)
|
|
232
259
|
writer.variable(variable);
|
|
233
260
|
// Later elements stand over the package's of the same key: a converted trigger's Kept copy, a compiled global.
|
|
234
|
-
const added = [...writer.elements, ...others.flatMap(({ trigger: other }) => blueprintTriggerXml(other)), ...blueprintTriggerXml(trigger)].map((element) => `${element.replace(/\r?\n/g, eol)}${eol}`).join("");
|
|
261
|
+
const added = [...writer.elements, ...functions.flatMap(blueprintFunctionXml), ...others.flatMap(({ trigger: other }) => blueprintTriggerXml(other)), ...blueprintTriggerXml(trigger)].map((element) => `${element.replace(/\r?\n/g, eol)}${eol}`).join("");
|
|
235
262
|
const combined = readTriggersFile(base.replace(/^<\/TriggerData>/m, `${added}</TriggerData>`));
|
|
236
263
|
const names = new Map(keptNames);
|
|
237
264
|
for (const variable of globals)
|
|
238
265
|
names.set(`Variable/${variable.id}`, variable.name);
|
|
266
|
+
for (const fn of functions) {
|
|
267
|
+
const { fn: form, body } = libraryForm(fn);
|
|
268
|
+
for (const [key, name] of Object.entries(functionStrings(undefined, form, body)))
|
|
269
|
+
if (key.includes("/Name/"))
|
|
270
|
+
names.set(key.replace("/Name/", "/"), name);
|
|
271
|
+
}
|
|
239
272
|
for (const each of [...others.map(({ trigger: other }) => other), trigger]) {
|
|
240
273
|
names.set(`Trigger/${each.id}`, each.name);
|
|
241
274
|
for (const variable of each.variables)
|
|
@@ -128,7 +128,9 @@ export async function writeMapPackage(given) {
|
|
|
128
128
|
// compile that builds them, and only in the Mission's own package: its record keeps the Kept
|
|
129
129
|
// triggers they name from being written over, and elsewhere what they name isn't there.
|
|
130
130
|
const buildsMissionTriggers = triggersRequested && !triggerOverride;
|
|
131
|
-
|
|
131
|
+
// The Blueprint's own triggers' element Ids (ADR-0026): a reference or a hold naming one names nothing in the package.
|
|
132
|
+
const blueprintTriggers = new Set((options.authoredTriggers?.triggers ?? []).map(({ trigger }) => trigger.id));
|
|
133
|
+
const referencesRefusal = plan.keptReferencesRefusal(buildsMissionTriggers, options.previousRecord !== undefined, blueprintTriggers);
|
|
132
134
|
if (referencesRefusal)
|
|
133
135
|
throw new Error(referencesRefusal);
|
|
134
136
|
// Each Kept Reference found in the package, a Kept trigger or variable called by the Editor's names.
|
|
@@ -744,12 +746,20 @@ export async function writeMapPackage(given) {
|
|
|
744
746
|
const withAuthored = authored ? compileBlueprintTriggers({ ...authored, triggers: holdBlueprintTriggers(authored.triggers, keptHolds(resolved)) }, generated, { ...(options.libraries ? { libraries: options.libraries } : {}), ...(await keptTriggersOf(outputDir, options.previousRecord)) }) : undefined;
|
|
745
747
|
if (withAuthored && authored) {
|
|
746
748
|
// Written where the package has them, a converted one in place of its Kept original, under the Equivalence Check.
|
|
747
|
-
out.placeTriggers([
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
749
|
+
out.placeTriggers([
|
|
750
|
+
...authored.triggers.map(({ trigger }) => `Trigger/${trigger.id}`),
|
|
751
|
+
...(authored.functions ?? []).map(({ fn }) => `FunctionDef/${fn.id}`),
|
|
752
|
+
...(authored.comments ?? []).map(({ comment }) => `Comment/${comment.id}`),
|
|
753
|
+
...(authored.variables ?? []).map((variable) => `Variable/${variable.id}`),
|
|
754
|
+
...authored.folders.map((folder) => `Category/${folder.id}`),
|
|
755
|
+
...(authored.presets ?? []).map(({ item }) => `Preset/${item.id}`),
|
|
756
|
+
...(authored.records ?? []).map(({ item }) => `Structure/${item.id}`),
|
|
757
|
+
...(authored.customScripts ?? []).map(({ item }) => `CustomScript/${item.id}`),
|
|
758
|
+
]);
|
|
759
|
+
for (const { kind, id, blocks } of withAuthored.converted) {
|
|
760
|
+
convertedTriggerParts.add(`${kind}:${id}`);
|
|
761
|
+
for (const block of blocks)
|
|
762
|
+
convertedTriggerParts.add(`galaxy:MapScript.galaxy:${block}`);
|
|
753
763
|
}
|
|
754
764
|
}
|
|
755
765
|
out.write("Triggers", withAuthored?.triggers ?? generated.triggers, "triggers");
|
|
@@ -797,13 +807,14 @@ export async function writeMapPackage(given) {
|
|
|
797
807
|
const holdNotes = [];
|
|
798
808
|
const previousHolds = (options.previousRecord?.entries ?? []).filter((entry) => entry.kind === "kept-hold");
|
|
799
809
|
const holds = keptHolds(resolved);
|
|
800
|
-
|
|
810
|
+
// A hold whose call sits in a Blueprint trigger is switched off in its body (holdBlueprintTriggers), so only the others need the package's Kept triggers.
|
|
811
|
+
const anyHoldInPackage = holds.some((hold) => !blueprintTriggers.has((hold.from ?? hold.trigger).id)) || previousHolds.some((entry) => !blueprintTriggers.has(entry.trigger));
|
|
812
|
+
if (buildsMissionTriggers && anyHoldInPackage) {
|
|
801
813
|
const holdsRefusal = plan.holdsRefusal(existsSync(path.join(outputDir, "Triggers")));
|
|
802
814
|
if (holdsRefusal)
|
|
803
815
|
throw new Error(holdsRefusal);
|
|
804
816
|
const read = (file) => readFile(path.join(outputDir, ...file.split("/")), "utf8");
|
|
805
817
|
const names = triggerStringNames(existsSync(path.join(outputDir, ...TRIGGER_STRINGS.split("/"))) ? await read(TRIGGER_STRINGS) : "");
|
|
806
|
-
const blueprintTriggers = new Set((authored?.triggers ?? []).map(({ trigger }) => trigger.id));
|
|
807
818
|
const held = applyKeptHolds(await read("Triggers"), await read("MapScript.galaxy"), names, holds, previousHolds, options.previousRecord ? recordedIds(options.previousRecord, "trigger") : new Set(), blueprintTriggers);
|
|
808
819
|
// Merged with the Compiled triggers when there are any; written as they are when the compile writes none.
|
|
809
820
|
out.amendKept("Triggers", () => held.triggers, { merged: true });
|
|
@@ -7,6 +7,8 @@ import type { BrokerStatus } from "../capture/editor-broker-client.js";
|
|
|
7
7
|
* conversation moves to the background after 2 minutes, so a long wait doesn't block the session.
|
|
8
8
|
*/
|
|
9
9
|
export declare const CAPTURE_WAIT_MS: number;
|
|
10
|
+
/** A wait limit in words, for a tool's description and its waiting reply. */
|
|
11
|
+
export declare const waitLength: (ms: number) => string;
|
|
10
12
|
/** How long a finished job's result is kept to collect: an hour. */
|
|
11
13
|
export declare const FINISHED_KEEP_MS: number;
|
|
12
14
|
export type Settled<Result> = {
|
package/dist/mcp/capture-jobs.js
CHANGED
|
@@ -15,6 +15,8 @@ import { randomUUID } from "node:crypto";
|
|
|
15
15
|
* conversation moves to the background after 2 minutes, so a long wait doesn't block the session.
|
|
16
16
|
*/
|
|
17
17
|
export const CAPTURE_WAIT_MS = 10 * 60 * 1000;
|
|
18
|
+
/** A wait limit in words, for a tool's description and its waiting reply. */
|
|
19
|
+
export const waitLength = (ms) => (ms >= 60_000 ? `${Math.round(ms / 60_000)} minutes` : `${(ms / 1000).toFixed(1)} seconds`);
|
|
18
20
|
/** How long a finished job's result is kept to collect: an hour. */
|
|
19
21
|
export const FINISHED_KEEP_MS = 60 * 60 * 1000;
|
|
20
22
|
export function captureJobs({ keepMs = FINISHED_KEEP_MS, now = () => Date.now() } = {}) {
|
package/dist/mcp/server.d.ts
CHANGED
|
@@ -9,11 +9,20 @@ import type { OpenDoodadFinderTool } from "./open-doodad-finder.js";
|
|
|
9
9
|
* generated reference to group tools by. Every tool the server can list is in exactly one group.
|
|
10
10
|
*/
|
|
11
11
|
export declare const TOOL_GROUPS: {
|
|
12
|
-
readonly catalog: readonly ["asset_catalog", "show_entry", "search_doodads", "find_doodads", "find_sets", "open_doodad_finder", "decal_variations", "build_doodad_search_page", "build_doodad_sheets", "add_doodad_note", "contribute_doodad_notes", "index_mod_doodads", "record_model_anims", "texture_sheet", "texture_usage"];
|
|
13
|
-
readonly compile: readonly ["compile_map", "import_map", "import_mod", "compile_mod", "convert_sound_set", "convert_entries", "convert_files", "convert_assets", "convert_library", "convert_triggers", "convert_screenplay", "propose_removals", "kept_report", "compile_melee_map", "test_mission"];
|
|
12
|
+
readonly catalog: readonly ["asset_catalog", "show_entry", "search_doodads", "find_doodads", "find_sets", "open_doodad_finder", "decal_variations", "build_doodad_search_page", "build_doodad_sheets", "add_doodad_note", "contribute_doodad_notes", "index_mod_doodads", "record_model_anims", "texture_sheet", "texture_usage", "sound_mix"];
|
|
13
|
+
readonly compile: readonly ["compile_map", "import_map", "import_mod", "compile_mod", "convert_sound_set", "convert_entries", "convert_files", "convert_assets", "convert_library", "convert_triggers", "convert_screenplay", "propose_removals", "kept_report", "compile_melee_map", "test_mission", "bank_changes", "save_bank_fixture"];
|
|
14
14
|
readonly blueprint: readonly ["check_layout", "get_blueprint", "patch_blueprint", "set_zone_polygon", "move_zone", "move_anchor", "preview", "generate_terrain", "sync", "sync_mod", "edit_kept_objects", "survey", "outline_kept_trigger", "outline_trigger", "search_trigger_functions", "write_blueprint_trigger", "tune_kept_triggers", "edit_kept_terrain"];
|
|
15
15
|
readonly capture: readonly ["speak_placeholder_voices", "capture_composite", "capture_shots", "freeze_set_piece", "compile_cutscene", "import_set"];
|
|
16
16
|
readonly session: readonly ["list_plugins", "check_workspace", "get_session_state", "sign_off_stage", "reopen_stage"];
|
|
17
|
+
readonly stylePack: readonly ["scaffold_style_pack", "add_exemplar_map", "study_exemplar", "find_places", "capture_exemplar", "exemplar_report"];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The tools listed on every machine but refused, with the reason, where the Host Adapter lacks these
|
|
21
|
+
* capabilities (the groups' `*_REFUSED_WITHOUT`), for the generated reference to say what they need.
|
|
22
|
+
*/
|
|
23
|
+
export declare const REFUSED_WITHOUT: {
|
|
24
|
+
readonly capture_exemplar: readonly ["editor.captureTour"];
|
|
25
|
+
readonly capture_shots: readonly ["editor.captureTour"];
|
|
17
26
|
};
|
|
18
27
|
export type ServerOptions = {
|
|
19
28
|
/** The folder holding the Workspace config. */
|
package/dist/mcp/server.js
CHANGED
|
@@ -22,10 +22,11 @@ import { createCallContext, withWorkspaceInput } from "./call-context.js";
|
|
|
22
22
|
import { CAPTURE_WAIT_MS } from "./capture-jobs.js";
|
|
23
23
|
import { CORE_VERSION } from "./core-version.js";
|
|
24
24
|
import { BLUEPRINT_TOOLS, registerBlueprintTools } from "./tools/blueprint.js";
|
|
25
|
-
import { CAPTURE_TOOLS, registerCaptureTools } from "./tools/capture.js";
|
|
25
|
+
import { CAPTURE_REFUSED_WITHOUT, CAPTURE_TOOLS, registerCaptureTools } from "./tools/capture.js";
|
|
26
26
|
import { CATALOG_TOOLS, registerCatalogTools } from "./tools/catalog.js";
|
|
27
27
|
import { COMPILE_TOOLS, registerCompileTools } from "./tools/compile.js";
|
|
28
28
|
import { registerSessionTools, SESSION_TOOLS } from "./tools/session.js";
|
|
29
|
+
import { registerStylePackTools, STYLE_PACK_REFUSED_WITHOUT, STYLE_PACK_TOOLS } from "./tools/style-pack.js";
|
|
29
30
|
/**
|
|
30
31
|
* The tools each group can register, keyed by the group createServer registers them in (#976), for the
|
|
31
32
|
* generated reference to group tools by. Every tool the server can list is in exactly one group.
|
|
@@ -36,7 +37,13 @@ export const TOOL_GROUPS = {
|
|
|
36
37
|
blueprint: BLUEPRINT_TOOLS,
|
|
37
38
|
capture: CAPTURE_TOOLS,
|
|
38
39
|
session: SESSION_TOOLS,
|
|
40
|
+
stylePack: STYLE_PACK_TOOLS,
|
|
39
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* The tools listed on every machine but refused, with the reason, where the Host Adapter lacks these
|
|
44
|
+
* capabilities (the groups' `*_REFUSED_WITHOUT`), for the generated reference to say what they need.
|
|
45
|
+
*/
|
|
46
|
+
export const REFUSED_WITHOUT = { ...CAPTURE_REFUSED_WITHOUT, ...STYLE_PACK_REFUSED_WITHOUT };
|
|
40
47
|
export function createServer({ workspaceRoot, host = bareHost(), followRoots: following = false, captureWaitMs = CAPTURE_WAIT_MS, doodadFinder, openDoodadFinder, setFinder }) {
|
|
41
48
|
const server = new McpServer({ name: "sc2-adjutant", version: CORE_VERSION });
|
|
42
49
|
// First, so every tool registered below takes the `workspace` input.
|
|
@@ -48,6 +55,7 @@ export function createServer({ workspaceRoot, host = bareHost(), followRoots: fo
|
|
|
48
55
|
registerBlueprintTools(server, ctx);
|
|
49
56
|
registerCaptureTools(server, ctx, { captureWaitMs });
|
|
50
57
|
registerSessionTools(server, ctx);
|
|
58
|
+
registerStylePackTools(server, ctx, { captureWaitMs });
|
|
51
59
|
const pluginsWorkspace = cachedWorkspace(ctx.root);
|
|
52
60
|
registerKnowledge(server, pluginsWorkspace);
|
|
53
61
|
registerPrompts(server, pluginsWorkspace);
|
|
@@ -55,14 +63,19 @@ export function createServer({ workspaceRoot, host = bareHost(), followRoots: fo
|
|
|
55
63
|
}
|
|
56
64
|
/**
|
|
57
65
|
* The Workspace for resource and prompt calls, which clients make often (a list on every turn):
|
|
58
|
-
* loaded again only when the Workspace folder has changed, or the Workspace config
|
|
59
|
-
* local Plugin's manifest
|
|
66
|
+
* loaded again only when the Workspace folder has changed, or the Workspace config, a loaded
|
|
67
|
+
* local Plugin's manifest or an Exemplar Map's study.json (which the registry serves as a document
|
|
68
|
+
* only once it exists) has changed since. Tools still load it fresh at each call. A Plugin's
|
|
60
69
|
* document and prompt files are read at each call either way.
|
|
61
70
|
*/
|
|
62
71
|
function cachedWorkspace(currentRoot) {
|
|
63
72
|
let cached;
|
|
64
73
|
const stampOf = async (root, workspace) => {
|
|
65
|
-
const files = [
|
|
74
|
+
const files = [
|
|
75
|
+
path.join(root, WORKSPACE_FILE),
|
|
76
|
+
...(workspace?.registry.plugins ?? []).flatMap((plugin) => (plugin.folder ? [path.join(plugin.folder, MANIFEST_FILE)] : [])),
|
|
77
|
+
...(workspace?.registry.contributions("exemplarMaps") ?? []).map((exemplar) => path.join(exemplar.studyDir, "study.json")),
|
|
78
|
+
];
|
|
66
79
|
const times = await Promise.all(files.map((file) => stat(file).then((stats) => stats.mtimeMs, () => -1)));
|
|
67
80
|
return files.map((file, index) => `${file}@${times[index]}`).join("\n");
|
|
68
81
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type BankRun } from "../../capture/bank-snapshots.js";
|
|
2
|
+
import { type Host } from "../../host/host.js";
|
|
3
|
+
export type BankChoices = {
|
|
4
|
+
readonly keep?: readonly string[] | undefined;
|
|
5
|
+
readonly rollback?: readonly string[] | undefined;
|
|
6
|
+
readonly keepAll?: boolean | undefined;
|
|
7
|
+
readonly rollbackAll?: boolean | undefined;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* The newest test game's bank changes still waiting for the author, as lines (none when nothing
|
|
11
|
+
* waits), after applying `choices` to them. A run whose game hasn't been seen to quit is recorded
|
|
12
|
+
* first when the Host Adapter says the game is gone; while it runs, the changes so far are shown and no choice is applied; when the host can't tell, they are shown
|
|
13
|
+
* until the author makes a choice, which is taken as their word that the game has quit.
|
|
14
|
+
*/
|
|
15
|
+
export declare function bankReport(host: Host, choices?: BankChoices): Promise<{
|
|
16
|
+
readonly lines: string[];
|
|
17
|
+
readonly run?: BankRun;
|
|
18
|
+
readonly refused?: boolean;
|
|
19
|
+
}>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// What a test game changed in the game's Banks folder (#54): the report test_mission and bank_changes give, and the author's keep or roll-back choices.
|
|
2
|
+
import { describeBankRun, finishBankRun, pendingBankRun, resolveBanks } from "../../capture/bank-snapshots.js";
|
|
3
|
+
import {} from "../../host/host.js";
|
|
4
|
+
import { hostContext } from "../../host/machine-config.js";
|
|
5
|
+
/**
|
|
6
|
+
* The newest test game's bank changes still waiting for the author, as lines (none when nothing
|
|
7
|
+
* waits), after applying `choices` to them. A run whose game hasn't been seen to quit is recorded
|
|
8
|
+
* first when the Host Adapter says the game is gone; while it runs, the changes so far are shown and no choice is applied; when the host can't tell, they are shown
|
|
9
|
+
* until the author makes a choice, which is taken as their word that the game has quit.
|
|
10
|
+
*/
|
|
11
|
+
export async function bankReport(host, choices = {}) {
|
|
12
|
+
let cacheDir;
|
|
13
|
+
try {
|
|
14
|
+
cacheDir = hostContext(host.machine).requirePath("cacheDir");
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return { lines: [] };
|
|
18
|
+
}
|
|
19
|
+
let run = await pendingBankRun(cacheDir);
|
|
20
|
+
if (!run)
|
|
21
|
+
return { lines: [] };
|
|
22
|
+
const asked = Boolean(choices.keep?.length || choices.rollback?.length || choices.keepAll || choices.rollbackAll);
|
|
23
|
+
if (run.state === "running") {
|
|
24
|
+
const canTell = host.has("game.running");
|
|
25
|
+
// A host that can't tell takes the author's keep or rollback as their word that the game has quit.
|
|
26
|
+
const playing = canTell ? await host.run("game.running", {}).catch(() => true) : !asked;
|
|
27
|
+
if (playing) {
|
|
28
|
+
const soFar = await finishBankRun(cacheDir, run, false);
|
|
29
|
+
const restoring = run.fixture !== undefined ? [` The test game plays on the bank fixture ${run.fixture}: the Banks folder holds its banks until the game quits, then the author's own are put back${canTell ? "." : ": call bank_changes with rollbackAll to say it has quit."}`] : [];
|
|
30
|
+
const why = canTell ? "the game is still running" : "this machine's Host Adapter can't tell whether the game has quit, so keep or rollback is taken as the author's word that it has";
|
|
31
|
+
const lines = [`Banks, so far (${why}):`, ...(soFar.changes.length > 0 ? describeBankRun({ ...soFar, state: "running" }) : [" no bank has changed yet."])];
|
|
32
|
+
return { lines: asked ? [`Nothing kept or rolled back: ${why}. Quit the game, then ask again.`, ...lines] : [...lines, ...restoring], run: soFar, refused: asked };
|
|
33
|
+
}
|
|
34
|
+
run = await finishBankRun(cacheDir, run);
|
|
35
|
+
if (run.changes.length === 0)
|
|
36
|
+
return { lines: [] };
|
|
37
|
+
}
|
|
38
|
+
// A fixture run's banks went back when the game quit; there is nothing to keep or roll back.
|
|
39
|
+
if (asked && run.fixture === undefined) {
|
|
40
|
+
const open = run.changes.filter((change) => !change.resolution).map((change) => change.bank);
|
|
41
|
+
const rollback = new Set([...(choices.rollback ?? []), ...(choices.rollbackAll ? open : [])]);
|
|
42
|
+
const keep = new Set([...(choices.keep ?? []), ...(choices.keepAll ? open : [])]);
|
|
43
|
+
// A bank named on its own side stays there when the other side asked for all.
|
|
44
|
+
for (const name of choices.keep ?? [])
|
|
45
|
+
rollback.delete(name);
|
|
46
|
+
for (const name of choices.rollback ?? [])
|
|
47
|
+
keep.delete(name);
|
|
48
|
+
run = await resolveBanks(cacheDir, run, { keep: [...keep], rollback: [...rollback] });
|
|
49
|
+
}
|
|
50
|
+
return { lines: describeBankRun(run), run };
|
|
51
|
+
}
|
|
@@ -25,7 +25,7 @@ import { renderSvgToPng } from "../../preview/render-png.js";
|
|
|
25
25
|
import { writePreview } from "../../preview/write-preview.js";
|
|
26
26
|
import { formatSyncReport, syncMission } from "../../sync/sync-mission.js";
|
|
27
27
|
import { AuthoringTriggerSchema } from "../../triggers/author-trigger.js";
|
|
28
|
-
import {
|
|
28
|
+
import { writeBlueprintTriggerShowingChange } from "../../map/outline-diff.js";
|
|
29
29
|
import { outlineHeading, outlineTrigger } from "../../map/outline-trigger.js";
|
|
30
30
|
import { formatModSync, syncMod } from "../../mods/sync-mod.js";
|
|
31
31
|
import { realPathOf } from "../../util/inside.js";
|
|
@@ -316,38 +316,42 @@ export function registerBlueprintTools(server, ctx) {
|
|
|
316
316
|
tool("write_blueprint_trigger", {
|
|
317
317
|
title: "Write a Blueprint trigger",
|
|
318
318
|
annotations: DESTRUCTIVE,
|
|
319
|
-
description: "Writes one of the Mission Blueprint's own triggers (ADR-0026) from calls given in the Editor's terms, or rewrites the Blueprint trigger of that name (or of `id`, to rename it). A call is { function, library?, params?, blocks?, disabled? }: the function by its name as the Editor shows it (Periodic Event), its identifier (TriggerAddEventTimePeriodic) or <library>/<id>, with library (Ntve or Built-In, or map for the map's own) only when the name is ambiguous (where functions share a name, the one whose kind fits where the call stands is taken); params by parameter name (or by <library>/<id> where two share a name), each left out taking the default a new call gets in the Editor (a text's words too), null leaving it unset in a disabled statement, a list giving a parameter its template repeats (Combine Text Multiple's Text) each value; blocks by slot name (If, Then, Else), each a list of statements, in the order given. A value is a number, true/false, or a string read by the parameter's type (a preset value's name such as Game Time, the map's own too, a text's words, a String, a trigger's name, a game link's id); or { function, … } for a call's value, { preset } (a library's or the map's preset value by name or reference), { bits: [value names], preset? } for a set of bits (preset naming its bits preset type where the parameter takes any), { variable, library?, index?, member? } (a local, a Blueprint or Kept global, or a library's global, by name or reference; member a structure's member by name), { trigger }, { text }, { value?, type, gameType?, valueId?, typeInfo?, context? } for a literal as the Editor writes it (valueId a placed unit's, point's or region's number), { expression, type, slots? } for an Arithmetic or Expression value (type Integer, Real, String or Text; expression its text with ~<code>~ slots, a Text one's words; slots each code's value), { customScript, type? }. A statement is a call, { comment } or { customScript } (Galaxy text, written only where asked for); events may hold comments. The trigger is { name, id?, initiallyOff?, disabled?, identifier?, label?, section?, variables?: [{ name, type (Unit Group, or a preset type's name), value?, array?, constant?, identifier? }], events, conditions, actions }. Each value is checked against its parameter's type, and every name against the libraries in reach and the map's own; an unknown, ambiguous or wrongly typed one is refused in the Editor's terms, and nothing is written. When no game function does the job, the refusal says so: write custom script only where the mapper asks, and offer a Missing-Feature Report (report-missing-feature). outline_trigger reads a trigger back in this form, to edit and rewrite. Rewriting keeps the trigger's Id, its locals' and every unchanged call's. Writes missions/<id>/triggers/<name>.json and lists it in the Blueprint's triggers; compile_map writes it into the Map Package.",
|
|
319
|
+
description: "Writes one of the Mission Blueprint's own triggers (ADR-0026) from calls given in the Editor's terms, or rewrites the Blueprint trigger of that name (or of `id`, to rename it). A call is { function, library?, params?, blocks?, disabled? }: the function by its name as the Editor shows it (Periodic Event), its identifier (TriggerAddEventTimePeriodic) or <library>/<id>, with library (Ntve or Built-In, or map for the map's own) only when the name is ambiguous (where functions share a name, the one whose kind fits where the call stands is taken); params by parameter name (or by <library>/<id> where two share a name), each left out taking the default a new call gets in the Editor (a text's words too), null leaving it unset in a disabled statement, a list giving a parameter its template repeats (Combine Text Multiple's Text) each value; blocks by slot name (If, Then, Else), each a list of statements, in the order given. A value is a number, true/false, or a string read by the parameter's type (a preset value's name such as Game Time, the map's own too, a text's words, a String, a trigger's name, a game link's id); or { function, … } for a call's value, { preset } (a library's or the map's preset value by name or reference), { bits: [value names], preset? } for a set of bits (preset naming its bits preset type where the parameter takes any), { variable, library?, index?, member? } (a local, a Blueprint or Kept global, or a library's global, by name or reference; member a structure's member by name), { trigger }, { text }, { value?, type, gameType?, valueId?, typeInfo?, context? } for a literal as the Editor writes it (valueId a placed unit's, point's or region's number), { expression, type, slots? } for an Arithmetic or Expression value (type Integer, Real, String or Text; expression its text with ~<code>~ slots, a Text one's words; slots each code's value), { customScript, type? }. A statement is a call, { comment } or { customScript } (Galaxy text, written only where asked for); events may hold comments. The trigger is { name, id?, initiallyOff?, disabled?, identifier?, label?, section?, variables?: [{ name, type (Unit Group, or a preset type's name), value?, array?, constant?, identifier? }], events, conditions, actions }. Each value is checked against its parameter's type, and every name against the libraries in reach and the map's own; an unknown, ambiguous or wrongly typed one is refused in the Editor's terms, and nothing is written. When no game function does the job, the refusal says so: write custom script only where the mapper asks, and offer a Missing-Feature Report (report-missing-feature). outline_trigger reads a trigger back in this form, to edit and rewrite. Rewriting keeps the trigger's Id, its locals' and every unchanged call's, and returns the rewrite as the trigger after it in the Editor's form (each call by its function's name and every argument, one to a line, a block's statements under its slot's name) with each line it changed marked: \"← new\", \"← was: <the old line>\" or \"← remove\" (a removed line stays in its place), to show the mapper before and after in the Editor's form. Writes missions/<id>/triggers/<name>.json and lists it in the Blueprint's triggers; compile_map writes it into the Map Package.",
|
|
320
320
|
inputSchema: {
|
|
321
321
|
mission: MissionSchema,
|
|
322
322
|
trigger: AuthoringTriggerSchema.describe("The trigger: { name, id?, initiallyOff?, disabled?, identifier?, section?, variables?, events, conditions, actions }, its calls in the Editor's terms"),
|
|
323
323
|
},
|
|
324
|
-
outputSchema: { name: z.string(), id: z.string(), file: z.string(), created: z.boolean(), calls: z.number(), keptCalls: z.number() },
|
|
324
|
+
outputSchema: { name: z.string(), id: z.string(), file: z.string(), created: z.boolean(), calls: z.number(), keptCalls: z.number(), diff: z.string().optional() },
|
|
325
325
|
}, async ({ mission, trigger }) => {
|
|
326
326
|
const workspace = await ctx.workspace();
|
|
327
|
-
const
|
|
327
|
+
const blueprintPath = await missionBlueprintPath(workspace, mission);
|
|
328
|
+
const { written, diff } = await writeBlueprintTriggerShowingChange(workspace, blueprintPath, trigger);
|
|
328
329
|
const kept = written.created ? "" : `, ${written.keptCalls} of its ${written.calls} calls keeping their Ids`;
|
|
329
|
-
return ctx.reply(`${written.created ? "Wrote" : "Rewrote"} the trigger ${written.name} (${written.id}) to ${written.file}${kept}. Compile the Mission to write it into the Map Package.`, { ...written });
|
|
330
|
+
return ctx.reply([`${written.created ? "Wrote" : "Rewrote"} the trigger ${written.name} (${written.id}) to ${written.file}${kept}. Compile the Mission to write it into the Map Package.`, ...(diff ? [diff] : [])].join("\n"), { ...written, ...(diff ? { diff } : {}) });
|
|
330
331
|
});
|
|
331
332
|
tool("tune_kept_triggers", {
|
|
332
333
|
title: "Tune Kept triggers",
|
|
333
334
|
annotations: DESTRUCTIVE,
|
|
334
|
-
description: "Tunes Kept triggers and functions in the Mission's own Map Package (ADR-0010), changing each one's XML in Triggers and its Galaxy in MapScript.galaxy together, so Test Document runs the change without an Editor save. Edits, applied in order: set (a parameter's value in the form it has: a number, true/false or text; { preset: \"<library>/<id>\" }; { id } for a placed unit, point, region or camera; { trigger } for a trigger), remove (a call or comment) and copy (a call, after itself or `after`, with `set` giving the copy's parameters new values by the copied parameters' Ids). Ids come from outline_kept_trigger. A trigger is refused, naming each function or preset by library and id, unless the trigger catalog knows every one it uses; then edit it in the Editor and save there. It is refused too when the script's Galaxy for it isn't the Editor's for its XML (save in the Editor first), when it is Compiled Content, and while the Editor has the map open. All edits are checked before anything is written.",
|
|
335
|
+
description: "Tunes Kept triggers and functions in the Mission's own Map Package (ADR-0010), changing each one's XML in Triggers and its Galaxy in MapScript.galaxy together, so Test Document runs the change without an Editor save. Edits, applied in order: set (a parameter's value in the form it has: a number, true/false or text; { preset: \"<library>/<id>\" }; { id } for a placed unit, point, region or camera; { trigger } for a trigger), remove (a call or comment) and copy (a call, after itself or `after`, with `set` giving the copy's parameters new values by the copied parameters' Ids). Ids come from outline_kept_trigger. A trigger is refused, naming each function or preset by library and id, unless the trigger catalog knows every one it uses; then edit it in the Editor and save there. It is refused too when the script's Galaxy for it isn't the Editor's for its XML (save in the Editor first), when it is Compiled Content, and while the Editor has the map open. All edits are checked before anything is written. dryRun checks and applies every edit in memory, writes nothing (so it runs with the Editor having the map open) and returns, for each trigger edited, the trigger after the edits in the Editor's form (each call by its function's name and every argument, one to a line, a block's statements under its slot's name) with each line they changed marked: \"← new\", \"← was: <the old line>\" or \"← remove\" (a removed line stays in its place), to show the mapper before and after in the Editor's form; a function has none, and a trigger the Editor's form can't read says why.",
|
|
335
336
|
inputSchema: {
|
|
336
337
|
mission: MissionSchema,
|
|
337
338
|
edits: z.array(KeptTriggerEditSchema).min(1).describe("The edits, applied in order, each { op, trigger, ... }"),
|
|
339
|
+
dryRun: z.boolean().optional().describe("Check and apply the edits in memory and return each trigger's change in the Editor's form, writing nothing"),
|
|
338
340
|
},
|
|
339
|
-
outputSchema: { changed: z.array(z.string()), files: z.array(z.string()) },
|
|
340
|
-
}, async ({ mission, edits }) => {
|
|
341
|
+
outputSchema: { changed: z.array(z.string()), files: z.array(z.string()), diffs: z.array(z.object({ trigger: z.string(), diff: z.string() })).optional() },
|
|
342
|
+
}, async ({ mission, edits, dryRun }) => {
|
|
341
343
|
const workspace = await ctx.workspace();
|
|
342
344
|
const blueprintPath = await missionBlueprintPath(workspace, mission);
|
|
343
345
|
const mapPackage = await missionMapPackage(blueprintPath);
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
346
|
+
if (!dryRun) {
|
|
347
|
+
const open = await editorHasOpen(ctx.host, mapPackage, "tune_kept_triggers", "Not tuned");
|
|
348
|
+
if (open)
|
|
349
|
+
return ctx.fail(open.text);
|
|
350
|
+
}
|
|
351
|
+
const result = await oneAtATime(await realPathOf(mapPackage), () => tuneKeptTriggers(workspace, blueprintPath, edits, { host: ctx.host, ...(dryRun ? { dryRun } : {}) }));
|
|
348
352
|
const where = path.relative(workspace.root, result.mapPackage).split(path.sep).join("/");
|
|
349
|
-
const lines = [...result.changed, result.files.length ? `Wrote ${result.files.join(", ")} in ${where}` : "Nothing changed"];
|
|
350
|
-
return ctx.reply(lines.join("\n"), { changed: [...result.changed], files: [...result.files] });
|
|
353
|
+
const lines = dryRun ? [...result.changed, "Dry run: nothing written", ...(result.diffs ?? []).map(({ diff }) => diff)] : [...result.changed, result.files.length ? `Wrote ${result.files.join(", ")} in ${where}` : "Nothing changed"];
|
|
354
|
+
return ctx.reply(lines.join("\n"), { changed: [...result.changed], files: [...result.files], ...(result.diffs ? { diffs: result.diffs.map((each) => ({ ...each })) } : {}) });
|
|
351
355
|
});
|
|
352
356
|
tool("edit_kept_terrain", {
|
|
353
357
|
title: "Edit Kept terrain",
|
|
@@ -2,6 +2,10 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
2
2
|
import { type CallContext } from "../call-context.js";
|
|
3
3
|
/** The tools registerCaptureTools can register, the capture group: speak_placeholder_voices only on a Host that can run tts.speak. */
|
|
4
4
|
export declare const CAPTURE_TOOLS: readonly ["speak_placeholder_voices", "capture_composite", "capture_shots", "freeze_set_piece", "compile_cutscene", "import_set"];
|
|
5
|
+
/** The group's tools listed on every machine but refused where the Host Adapter lacks these capabilities. */
|
|
6
|
+
export declare const CAPTURE_REFUSED_WITHOUT: {
|
|
7
|
+
readonly capture_shots: readonly ["editor.captureTour"];
|
|
8
|
+
};
|
|
5
9
|
export declare function registerCaptureTools(server: McpServer, ctx: CallContext, { captureWaitMs }: {
|
|
6
10
|
captureWaitMs: number;
|
|
7
11
|
}): void;
|