hoi4-agent-tools 4.6.5 → 4.8.0
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/CHANGELOG.md +40 -5
- package/README.md +32 -13
- package/dist/hoi4_agent_tools/core/engine-client.js +342 -0
- package/dist/hoi4_agent_tools/core/operation-result.js +33 -5
- package/dist/hoi4_agent_tools/core/resident-engine.js +273 -0
- package/dist/hoi4_agent_tools/core/temporary-directories.js +3 -2
- package/dist/hoi4_agent_tools/decision/service.js +7 -0
- package/dist/hoi4_agent_tools/event/service.js +18 -6
- package/dist/hoi4_agent_tools/event/summary.js +9 -0
- package/dist/hoi4_agent_tools/focus/compact.js +197 -18
- package/dist/hoi4_agent_tools/focus/engine-layout.js +201 -0
- package/dist/hoi4_agent_tools/focus/game-render.js +72 -0
- package/dist/hoi4_agent_tools/focus/game-view-output.js +160 -0
- package/dist/hoi4_agent_tools/focus/job-operations.js +3 -1
- package/dist/hoi4_agent_tools/focus/layout.js +3 -2
- package/dist/hoi4_agent_tools/focus/native-effects.js +4 -4
- package/dist/hoi4_agent_tools/focus/quality/branches.js +32 -0
- package/dist/hoi4_agent_tools/focus/quality/calibration.js +364 -0
- package/dist/hoi4_agent_tools/focus/quality/delta.js +85 -0
- package/dist/hoi4_agent_tools/focus/quality/focus-quality-calibration.json +2265 -0
- package/dist/hoi4_agent_tools/focus/quality/graph.js +170 -0
- package/dist/hoi4_agent_tools/focus/quality/index.js +24 -0
- package/dist/hoi4_agent_tools/focus/quality/inline-images.js +132 -0
- package/dist/hoi4_agent_tools/focus/quality/metrics.js +424 -0
- package/dist/hoi4_agent_tools/focus/quality/orthogonal.js +213 -0
- package/dist/hoi4_agent_tools/focus/quality/positions.js +41 -0
- package/dist/hoi4_agent_tools/focus/quality/schematic.js +243 -0
- package/dist/hoi4_agent_tools/focus/quality/scorecard.js +549 -0
- package/dist/hoi4_agent_tools/focus/quality/stored-calibration.js +7 -0
- package/dist/hoi4_agent_tools/focus/quality/tool-output.js +113 -0
- package/dist/hoi4_agent_tools/focus/quality/types.js +5 -0
- package/dist/hoi4_agent_tools/focus/render.js +21 -9
- package/dist/hoi4_agent_tools/focus/tool-operations.js +364 -25
- package/dist/hoi4_agent_tools/focus/tool-support.js +1 -1
- package/dist/hoi4_agent_tools/gui/assets.js +18 -0
- package/dist/hoi4_agent_tools/gui/dds.js +38 -5
- package/dist/hoi4_agent_tools/gui/engine-textures.js +48 -0
- package/dist/hoi4_agent_tools/gui/source-graph.js +7 -0
- package/dist/hoi4_agent_tools/gui/tool-operations.js +23 -4
- package/dist/hoi4_agent_tools/gui/validators.js +31 -2
- package/dist/hoi4_agent_tools/ideas/inspect.js +43 -0
- package/dist/hoi4_agent_tools/localisation/inspect.js +34 -0
- package/dist/hoi4_agent_tools/mcp/server/argument-errors.js +2 -0
- package/dist/hoi4_agent_tools/mcp/server/instructions.js +1 -1
- package/dist/hoi4_agent_tools/mcp/tools/event.js +2 -0
- package/dist/hoi4_agent_tools/mcp/tools/focus.js +76 -4
- package/dist/hoi4_agent_tools/mcp/tools/reference.js +18 -0
- package/dist/hoi4_agent_tools/probability/operations.js +27 -1
- package/dist/hoi4_agent_tools/probability/service.js +91 -11
- package/dist/hoi4_agent_tools/probability/source-analysis.js +2 -2
- package/dist/hoi4_agent_tools/probability/sweep.js +20 -6
- package/dist/hoi4_agent_tools/reference/command-phrases.json +11065 -0
- package/dist/hoi4_agent_tools/reference/error-log.js +24 -0
- package/dist/hoi4_agent_tools/reference/game-text.js +109 -0
- package/dist/hoi4_agent_tools/reference/known-mistakes.js +8 -5
- package/dist/hoi4_agent_tools/reference/known-mistakes.json +4 -4
- package/dist/hoi4_agent_tools/reference/operations.js +68 -2
- package/dist/hoi4_agent_tools/reference/ranking.js +92 -2
- package/dist/hoi4_agent_tools/reference/script-validation.js +46 -6
- package/dist/hoi4_agent_tools/reference/service.js +125 -21
- package/dist/hoi4_agent_tools/reference/source-lookup.js +8 -0
- package/dist/hoi4_agent_tools/schemas/focus-requests.js +68 -7
- package/dist/hoi4_agent_tools/schemas/focus.js +121 -6
- package/dist/hoi4_agent_tools/schemas/ideas.js +142 -0
- package/dist/hoi4_agent_tools/schemas/localisation.js +94 -0
- package/dist/hoi4_agent_tools/schemas/mod-tools.js +11 -0
- package/dist/hoi4_agent_tools/version.js +1 -1
- package/docs/configuration.md +17 -17
- package/docs/focus.md +104 -4
- package/docs/reference.md +1 -1
- package/docs/research/reference-benchmark.md +152 -1
- package/docs/setup.md +1 -1
- package/docs/tools.md +48 -44
- package/docs/troubleshooting.md +13 -12
- package/engine/README.md +284 -0
- package/engine/bin/darwin-arm64/hoi4-engine +0 -0
- package/engine/bin/linux-arm64/hoi4-engine +0 -0
- package/engine/bin/linux-x64/hoi4-engine +0 -0
- package/engine/bin/manifest.json +26 -0
- package/engine/bin/win32-x64/hoi4-engine.exe +0 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +5 -1
- package/schemas/configuration.schema.json +1 -1
- package/schemas/continuous-focus-palette.schema.json +1 -1
- package/schemas/custom-weighted-pool.schema.json +1 -1
- package/schemas/decision-inspect-input.schema.json +1 -1
- package/schemas/error-log-input.schema.json +1 -1
- package/schemas/event-feature-manifest.schema.json +1 -1
- package/schemas/focus-plan.schema.json +146 -120
- package/schemas/focus-planning-sidecar.schema.json +15 -7
- package/schemas/geography-model.schema.json +1 -1
- package/schemas/gui-animation-source.schema.json +1 -1
- package/schemas/gui-helper.schema.json +1 -1
- package/schemas/gui-scenario.schema.json +1 -1
- package/schemas/helper-expansion-request.schema.json +1 -1
- package/schemas/helper-expansion-summary.schema.json +1 -1
- package/schemas/impact-inspect-input.schema.json +1 -1
- package/schemas/map-operation.schema.json +1 -1
- package/schemas/mechanic-test-input.schema.json +1 -1
- package/schemas/mod-index-input.schema.json +1 -1
- package/schemas/operation-result.schema.json +1 -1
- package/schemas/package-check-input.schema.json +1 -1
- package/schemas/package-manifest.schema.json +1 -1
- package/schemas/probability-analysis-result.schema.json +1 -1
- package/schemas/probability-compare-input.schema.json +1 -1
- package/schemas/probability-evaluate-input.schema.json +1 -1
- package/schemas/probability-inspect-input.schema.json +1 -1
- package/schemas/probability-render-input.schema.json +1 -1
- package/schemas/probability-scenario-set.schema.json +1 -1
- package/schemas/probability-sequence-input.schema.json +1 -1
- package/schemas/probability-simulate-input.schema.json +1 -1
- package/schemas/probability-sweep-input.schema.json +1 -1
- package/schemas/reference-context-input.schema.json +1 -1
- package/schemas/reference-read-input.schema.json +1 -1
- package/schemas/reference-search-input.schema.json +1 -1
- package/schemas/reference-sheets.schema.json +1 -1
- package/schemas/scenario-suite.schema.json +1 -1
- package/schemas/scenario-test-input.schema.json +1 -1
- package/schemas/script-validate-input.schema.json +1 -1
- package/schemas/shared-scenario.schema.json +1 -1
- package/schemas/source-lookup-input.schema.json +1 -1
- package/server.json +2 -2
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
import { RenderBudget, RENDER_MAX_DECODED_PIXELS } from '../core/render-budget.js';
|
|
2
2
|
import { sha256Bytes } from '../core/canonical.js';
|
|
3
|
+
/**
|
|
4
|
+
* The DX10 formats this decoder reads itself: 8-bit RGBA and BGRA layouts and BC1 to BC3. The
|
|
5
|
+
* rest (BC4, BC5, BC7 and packed 16-bit formats) is decoded by the Rust engine
|
|
6
|
+
* (`gui/engine-textures.ts`).
|
|
7
|
+
*/
|
|
8
|
+
const DX10_FORMATS = {
|
|
9
|
+
27: { format: 'dx10-rgba8', layout: 'rgba' },
|
|
10
|
+
28: { format: 'dx10-rgba8', layout: 'rgba' },
|
|
11
|
+
29: { format: 'dx10-rgba8-srgb', layout: 'rgba' },
|
|
12
|
+
30: { format: 'dx10-rgba8', layout: 'rgba' },
|
|
13
|
+
70: { format: 'dx10-bc1', layout: 'dxt1' },
|
|
14
|
+
71: { format: 'dx10-bc1', layout: 'dxt1' },
|
|
15
|
+
72: { format: 'dx10-bc1', layout: 'dxt1' },
|
|
16
|
+
73: { format: 'dx10-bc2', layout: 'dxt3' },
|
|
17
|
+
74: { format: 'dx10-bc2', layout: 'dxt3' },
|
|
18
|
+
75: { format: 'dx10-bc2', layout: 'dxt3' },
|
|
19
|
+
76: { format: 'dx10-bc3', layout: 'dxt5' },
|
|
20
|
+
77: { format: 'dx10-bc3', layout: 'dxt5' },
|
|
21
|
+
78: { format: 'dx10-bc3', layout: 'dxt5' },
|
|
22
|
+
87: { format: 'dx10-bgra8', layout: 'bgra' },
|
|
23
|
+
88: { format: 'dx10-bgrx8', layout: 'bgrx' },
|
|
24
|
+
90: { format: 'dx10-bgra8', layout: 'bgra' },
|
|
25
|
+
91: { format: 'dx10-bgra8-srgb', layout: 'bgra' },
|
|
26
|
+
92: { format: 'dx10-bgrx8', layout: 'bgrx' },
|
|
27
|
+
93: { format: 'dx10-bgrx8', layout: 'bgrx' },
|
|
28
|
+
};
|
|
3
29
|
const DDS_MAGIC = 0x2053_4444;
|
|
4
30
|
const DDSD_PITCH = 0x8;
|
|
5
31
|
const DDPF_FOURCC = 0x4;
|
|
@@ -200,9 +226,16 @@ export function decodeDds(bytes, budget = new RenderBudget(), operationKey = `dd
|
|
|
200
226
|
const arraySize = bytes.readUInt32LE(140);
|
|
201
227
|
if (arraySize !== 1)
|
|
202
228
|
return unsupported(`DX10/${dxgiFormat}`, 'DDS texture arrays are not supported by the offline GUI renderer.');
|
|
203
|
-
const
|
|
204
|
-
if (
|
|
205
|
-
return unsupported(`DX10/${dxgiFormat}`, `DXGI format ${dxgiFormat} is not one of the
|
|
229
|
+
const known = DX10_FORMATS[dxgiFormat];
|
|
230
|
+
if (known === undefined)
|
|
231
|
+
return unsupported(`DX10/${dxgiFormat}`, `DXGI format ${dxgiFormat} is not one of the 8-bit RGBA, BGRA or BC1 to BC3 formats this decoder reads.`);
|
|
232
|
+
const { format, layout } = known;
|
|
233
|
+
if (layout === 'dxt1' || layout === 'dxt3' || layout === 'dxt5') {
|
|
234
|
+
const output = decodeDxt(bytes, 148, width, height, layout);
|
|
235
|
+
return output === undefined
|
|
236
|
+
? unsupported(format, 'The DDS block data is truncated.')
|
|
237
|
+
: { width, height, data: output, format };
|
|
238
|
+
}
|
|
206
239
|
const required = 148 + width * height * 4;
|
|
207
240
|
if (bytes.length < required)
|
|
208
241
|
return unsupported(format, 'The DDS pixel data is truncated.');
|
|
@@ -210,7 +243,7 @@ export function decodeDds(bytes, budget = new RenderBudget(), operationKey = `dd
|
|
|
210
243
|
for (let index = 0; index < width * height; index += 1) {
|
|
211
244
|
const source = 148 + index * 4;
|
|
212
245
|
const target = index * 4;
|
|
213
|
-
if (
|
|
246
|
+
if (layout === 'rgba') {
|
|
214
247
|
output[target] = byte(bytes, source);
|
|
215
248
|
output[target + 1] = byte(bytes, source + 1);
|
|
216
249
|
output[target + 2] = byte(bytes, source + 2);
|
|
@@ -220,7 +253,7 @@ export function decodeDds(bytes, budget = new RenderBudget(), operationKey = `dd
|
|
|
220
253
|
output[target + 1] = byte(bytes, source + 1);
|
|
221
254
|
output[target + 2] = byte(bytes, source);
|
|
222
255
|
}
|
|
223
|
-
output[target + 3] = byte(bytes, source + 3);
|
|
256
|
+
output[target + 3] = layout === 'bgrx' ? 255 : byte(bytes, source + 3);
|
|
224
257
|
}
|
|
225
258
|
return { width, height, data: output, format };
|
|
226
259
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { sharedResidentEngine } from '../core/resident-engine.js';
|
|
2
|
+
/** Formats the game is known to mishandle, with the evidence; a preview still draws them. */
|
|
3
|
+
export const RISKY_TEXTURE_FORMATS = {
|
|
4
|
+
BC7_UNORM: 'In an in-game check on game 1.19.4.1 a BC7 texture failed with "Expected more data in the texture mipmaps" and "Failed to create 2D texture", and the game then crashed. Convert it to DXT5 or 32-bit uncompressed, or check it in game.',
|
|
5
|
+
BC7_UNORM_SRGB: 'In an in-game check on game 1.19.4.1 a BC7 texture failed with "Expected more data in the texture mipmaps" and "Failed to create 2D texture", and the game then crashed. Convert it to DXT5 or 32-bit uncompressed, or check it in game.',
|
|
6
|
+
BC7_TYPELESS: 'In an in-game check on game 1.19.4.1 a BC7 texture failed with "Expected more data in the texture mipmaps" and "Failed to create 2D texture", and the game then crashed. Convert it to DXT5 or 32-bit uncompressed, or check it in game.',
|
|
7
|
+
};
|
|
8
|
+
export const ENGINE_TEXTURE_HINT = 'Install a hoi4-agent-tools release that ships the hoi4-engine binary, or set HOI4_ENGINE to its absolute path, to decode this format.';
|
|
9
|
+
export async function decodeTextureWithEngine(bytes, extension, maxPixels, options = {}) {
|
|
10
|
+
const engine = options.engine ?? sharedResidentEngine();
|
|
11
|
+
const outcome = await engine.request('texture.decode', { extension, maxPixels }, bytes, options.signal === undefined ? {} : { signal: options.signal });
|
|
12
|
+
if (outcome.ok) {
|
|
13
|
+
const { width, height, format } = outcome.response.result;
|
|
14
|
+
const data = outcome.response.payload;
|
|
15
|
+
if (typeof width === 'number' &&
|
|
16
|
+
typeof height === 'number' &&
|
|
17
|
+
Number.isSafeInteger(width) &&
|
|
18
|
+
Number.isSafeInteger(height) &&
|
|
19
|
+
width > 0 &&
|
|
20
|
+
height > 0 &&
|
|
21
|
+
width * height <= maxPixels &&
|
|
22
|
+
data.length === width * height * 4)
|
|
23
|
+
return {
|
|
24
|
+
decoded: { width, height, data, format: typeof format === 'string' ? format : extension },
|
|
25
|
+
};
|
|
26
|
+
return {
|
|
27
|
+
unsupported: true,
|
|
28
|
+
format: extension,
|
|
29
|
+
reason: 'The engine returned a texture whose size does not match its pixels.',
|
|
30
|
+
engineAvailable: true,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (outcome.kind === 'error') {
|
|
34
|
+
const format = typeof outcome.details.format === 'string' ? outcome.details.format : extension;
|
|
35
|
+
return {
|
|
36
|
+
unsupported: true,
|
|
37
|
+
format,
|
|
38
|
+
reason: `${format}: ${outcome.message}`,
|
|
39
|
+
engineAvailable: true,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
unsupported: true,
|
|
44
|
+
format: extension,
|
|
45
|
+
reason: `The Rust engine is unavailable (${outcome.message}). ${ENGINE_TEXTURE_HINT}`,
|
|
46
|
+
engineAvailable: false,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -1090,6 +1090,13 @@ function linkGraph(nodes, edges, elements, sprites, fonts, scriptedGuis, scripte
|
|
|
1090
1090
|
for (const definition of scriptedLocalisation) {
|
|
1091
1091
|
for (const key of definition.localisationKeys) {
|
|
1092
1092
|
const entry = localisationByKey.get(key);
|
|
1093
|
+
// Vanilla returns sprite names from defined_text (`localization_key = GFX_...`) to pick a
|
|
1094
|
+
// sprite or frame at runtime, so a key that names a sprite is a sprite reference.
|
|
1095
|
+
const sprite = entry === undefined ? spriteByName.get(key.toLocaleLowerCase('en-US')) : undefined;
|
|
1096
|
+
if (sprite !== undefined) {
|
|
1097
|
+
addEdge(edges, 'uses_sprite', definition.id, sprite.id, true, { spriteName: key }, definition.location);
|
|
1098
|
+
continue;
|
|
1099
|
+
}
|
|
1093
1100
|
addEdge(edges, 'uses_localisation', definition.id, entry === undefined ? `localisation:${key}` : deterministicId('gui_loc', entry), entry !== undefined, { key }, definition.location);
|
|
1094
1101
|
}
|
|
1095
1102
|
}
|
|
@@ -2,7 +2,7 @@ import { z } from 'zod/v4';
|
|
|
2
2
|
import { boundedSourceHashEvidence, publicArtifactLink } from '../core/artifacts.js';
|
|
3
3
|
import { canonicalJson, compareCodeUnits, hashCanonical } from '../core/canonical.js';
|
|
4
4
|
import { autonomousResultArtifacts, } from '../core/transaction-execution.js';
|
|
5
|
-
import { emptyServiceResult } from '../core/result.js';
|
|
5
|
+
import { emptyServiceResult, ServiceError } from '../core/result.js';
|
|
6
6
|
import { setInlineFilesScanned } from '../core/operation-result.js';
|
|
7
7
|
import { PACKAGE_VERSION } from '../version.js';
|
|
8
8
|
import { compileGuiHelpers } from './helpers.js';
|
|
@@ -21,6 +21,20 @@ const guiRewriteRecipeSchema = z
|
|
|
21
21
|
.optional(),
|
|
22
22
|
})
|
|
23
23
|
.strict();
|
|
24
|
+
const INLINE_DIAGNOSTIC_LIMIT = 100;
|
|
25
|
+
/**
|
|
26
|
+
* Inline results carry a bounded diagnostic list. When it overflows, errors and blockers keep
|
|
27
|
+
* their places ahead of warnings so a flood of low-severity findings cannot hide a defect.
|
|
28
|
+
*/
|
|
29
|
+
export function inlineDiagnostics(diagnostics) {
|
|
30
|
+
if (diagnostics.length <= INLINE_DIAGNOSTIC_LIMIT)
|
|
31
|
+
return [...diagnostics];
|
|
32
|
+
const hard = (diagnostic) => diagnostic.severity === 'error' || diagnostic.severity === 'blocker';
|
|
33
|
+
return [
|
|
34
|
+
...diagnostics.filter(hard),
|
|
35
|
+
...diagnostics.filter((diagnostic) => !hard(diagnostic)),
|
|
36
|
+
].slice(0, INLINE_DIAGNOSTIC_LIMIT);
|
|
37
|
+
}
|
|
24
38
|
function validationSummary(validation) {
|
|
25
39
|
return {
|
|
26
40
|
passed: validation.checks.every(({ passed }) => passed) &&
|
|
@@ -97,7 +111,7 @@ export function completeGuiRewrite(workspaceId, execution, recipe) {
|
|
|
97
111
|
setInlineFilesScanned(result, parsed.filesScanned);
|
|
98
112
|
result.proposedFiles = transaction.files.slice(0, 100).map(({ relativePath }) => relativePath);
|
|
99
113
|
result.changedFiles = transaction.appliedFiles.slice(0, 100);
|
|
100
|
-
result.diagnostics = transaction.diagnostics
|
|
114
|
+
result.diagnostics = inlineDiagnostics(transaction.diagnostics);
|
|
101
115
|
result.artifacts = autonomousResultArtifacts(execution);
|
|
102
116
|
result.validation = transaction.validation;
|
|
103
117
|
result.blockers = transaction.diagnostics
|
|
@@ -134,6 +148,11 @@ export async function inspectGui(engine, studio, input, context) {
|
|
|
134
148
|
return { graph: linted.graph, linted };
|
|
135
149
|
})();
|
|
136
150
|
const { graph, linted } = inspected;
|
|
151
|
+
// A window the scene could not find is a small not-found, before any artifact is written.
|
|
152
|
+
// The lint scans only the sources of the named window, so it has no names to suggest.
|
|
153
|
+
if (input.windowName !== undefined &&
|
|
154
|
+
linted?.scene.diagnostics.some(({ code }) => code === 'GUI_WINDOW_MISSING') === true)
|
|
155
|
+
throw new ServiceError('GUI_WINDOW_NOT_FOUND', `No GUI window named ${input.windowName.slice(0, 256)} is defined; hoi4.reference_search or hoi4.source_lookup can find window names`, { windowName: input.windowName.slice(0, 256) });
|
|
137
156
|
const sharedRevision = hashCanonical(graph.sourceHashes);
|
|
138
157
|
const workspace = engine.resolver.get(context.workspaceId, context.principal);
|
|
139
158
|
const sourceEvidence = boundedSourceHashEvidence(graph.sourceHashes);
|
|
@@ -197,7 +216,7 @@ export async function inspectGui(engine, studio, input, context) {
|
|
|
197
216
|
});
|
|
198
217
|
result.code = graph.complete ? 'GUI_INSPECTED' : 'GUI_INSPECTED_PARTIAL';
|
|
199
218
|
setInlineFilesScanned(result, graph.filesScanned);
|
|
200
|
-
result.diagnostics = diagnostics
|
|
219
|
+
result.diagnostics = inlineDiagnostics(diagnostics);
|
|
201
220
|
result.artifacts = [publicArtifactLink(artifact)];
|
|
202
221
|
result.validation =
|
|
203
222
|
linted === undefined
|
|
@@ -277,7 +296,7 @@ export async function renderGui(studio, input, context) {
|
|
|
277
296
|
});
|
|
278
297
|
result.code = 'GUI_RENDERED';
|
|
279
298
|
setInlineFilesScanned(result, rendered.filesScanned);
|
|
280
|
-
result.diagnostics = diagnostics
|
|
299
|
+
result.diagnostics = inlineDiagnostics(diagnostics);
|
|
281
300
|
result.artifacts = rendered.artifacts.map(publicArtifactLink);
|
|
282
301
|
result.validation = validationSummary({ diagnostics, checks: rendered.validation.checks });
|
|
283
302
|
await context.progress(4, 4, 'GUI render complete');
|
|
@@ -3,6 +3,7 @@ import { sortDiagnostics } from '../core/diagnostics.js';
|
|
|
3
3
|
import { sha256Bytes } from '../core/canonical.js';
|
|
4
4
|
import { assertRenderDimensions } from '../core/render-budget.js';
|
|
5
5
|
import { GuiAssetCatalog } from './assets.js';
|
|
6
|
+
import { RISKY_TEXTURE_FORMATS } from './engine-textures.js';
|
|
6
7
|
import { GUI_GRAPH_MAX_EDGES, GUI_GRAPH_MAX_NODES, GUI_SCENE_MAX_ELEMENTS, GUI_VALIDATION_MAX_ANCESTOR_HOPS, GUI_VALIDATION_MAX_DIAGNOSTICS, GUI_VALIDATION_MAX_PAIR_COMPARISONS, } from './limits.js';
|
|
7
8
|
/** Horizontal offsets from a parent's centre above rounding and up to a few pixels look accidental. */
|
|
8
9
|
const NEAR_CENTRE_TOLERANCE_PX = 0.5;
|
|
@@ -434,6 +435,31 @@ function validateSourceCosts(graph, scene, diagnostics) {
|
|
|
434
435
|
}
|
|
435
436
|
}
|
|
436
437
|
}
|
|
438
|
+
/**
|
|
439
|
+
* A plain image drawn beneath an element that lies wholly inside it is a background, frame or
|
|
440
|
+
* fill layer, not a collision: panels sit under their titles and frames sit over their fills.
|
|
441
|
+
*/
|
|
442
|
+
function isBackdropLayering(left, right) {
|
|
443
|
+
const isBackdrop = (candidate, other) => candidate.text === undefined &&
|
|
444
|
+
!candidate.clickable &&
|
|
445
|
+
candidate.sprite !== undefined &&
|
|
446
|
+
candidate.zIndex <= other.zIndex &&
|
|
447
|
+
contains(candidate.rect, other.rect, 0.5);
|
|
448
|
+
return isBackdrop(left, right) || isBackdrop(right, left);
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Meters slide a fill image through a clipping window: an icon parked beyond the leading edge
|
|
452
|
+
* is the empty state. Only an image that never reaches past the window's far edges counts, so
|
|
453
|
+
* an icon overflowing to the right or bottom is still reported.
|
|
454
|
+
*/
|
|
455
|
+
function isSlidingFill(element) {
|
|
456
|
+
const clip = element.clipRect;
|
|
457
|
+
if (clip === undefined || element.text !== undefined || element.clickable)
|
|
458
|
+
return false;
|
|
459
|
+
const rect = element.unclippedRect;
|
|
460
|
+
return (rect.x + rect.width <= clip.x + clip.width + 0.5 &&
|
|
461
|
+
rect.y + rect.height <= clip.y + clip.height + 0.5);
|
|
462
|
+
}
|
|
437
463
|
function validateOverlapAndGeometry(scene, diagnostics, work) {
|
|
438
464
|
const visible = scene.elements.filter((element) => element.visible && area(element.rect) > 0);
|
|
439
465
|
const byId = new Map(scene.elements.map((element) => [element.id, element]));
|
|
@@ -454,7 +480,7 @@ function validateOverlapAndGeometry(scene, diagnostics, work) {
|
|
|
454
480
|
if (element.unclippedRect.width <= 0 || element.unclippedRect.height <= 0) {
|
|
455
481
|
diagnostics.push(issue('GUI_INVALID_SIZE', 'warning', 'layout', `${element.name} has a non-positive ${element.unclippedRect.width}x${element.unclippedRect.height} size.`, element));
|
|
456
482
|
}
|
|
457
|
-
if (element.clipped)
|
|
483
|
+
if (element.clipped && !isSlidingFill(element))
|
|
458
484
|
diagnostics.push(issue('GUI_ACCIDENTAL_CLIPPING', 'warning', 'layout', `${element.name} is clipped from ${element.unclippedRect.width}x${element.unclippedRect.height} to ${element.rect.width}x${element.rect.height}.`, element));
|
|
459
485
|
if (element.text?.overflowX === true || element.text?.overflowY === true) {
|
|
460
486
|
diagnostics.push(issue('GUI_TEXT_OVERFLOW', 'warning', 'layout', `${element.name} text measures ${element.text.measuredWidth.toFixed(2)}x${element.text.measuredHeight.toFixed(2)} inside ${element.unclippedRect.width.toFixed(2)}x${element.unclippedRect.height.toFixed(2)}.`, element));
|
|
@@ -501,7 +527,7 @@ function validateOverlapAndGeometry(scene, diagnostics, work) {
|
|
|
501
527
|
if (left.clickable && right.clickable && ratio > 0.02) {
|
|
502
528
|
diagnostics.push(issue('GUI_CONFLICTING_CLICK_REGIONS', 'error', 'design', `${left.name} and ${right.name} have overlapping click regions (${(ratio * 100).toFixed(1)}%).`, right, { left: left.id, right: right.id, ratio }));
|
|
503
529
|
}
|
|
504
|
-
if (left.depth === right.depth && ratio > 0.2) {
|
|
530
|
+
if (left.depth === right.depth && ratio > 0.2 && !isBackdropLayering(left, right)) {
|
|
505
531
|
diagnostics.push(issue('GUI_VISIBLE_OVERLAP', 'warning', 'layout', `${left.name} and ${right.name} overlap by ${(ratio * 100).toFixed(1)}% of the smaller element.`, right, { left: left.id, right: right.id, ratio }));
|
|
506
532
|
}
|
|
507
533
|
const later = left.zIndex > right.zIndex ? left : right;
|
|
@@ -966,6 +992,9 @@ async function validateGuiAnimationsInto(graph, files, selectedSpriteNames, cata
|
|
|
966
992
|
add(sprite.frameAnimated ? 'GUI_ANIMATION_TEXTURE_UNSUPPORTED' : 'GUI_TEXTURE_UNSUPPORTED', 'error', `${sprite.name}: ${raster.reason ?? 'texture unsupported'}`);
|
|
967
993
|
continue;
|
|
968
994
|
}
|
|
995
|
+
const risk = RISKY_TEXTURE_FORMATS[raster.format];
|
|
996
|
+
if (risk !== undefined)
|
|
997
|
+
add('GUI_TEXTURE_FORMAT_RISKY', 'warning', `${sprite.name}: ${sprite.texturePath} is ${raster.format}, which the preview draws. ${risk}`);
|
|
969
998
|
const safeFrameCount = Math.max(1, sprite.frameCount);
|
|
970
999
|
if (raster.width % safeFrameCount !== 0)
|
|
971
1000
|
add(sprite.frameAnimated
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { runEngineCommand } from '../core/engine-client.js';
|
|
2
|
+
import { ServiceError } from '../core/result.js';
|
|
3
|
+
import { ideaEngineAuditSchema, ideaEngineInspectionSchema, } from '../schemas/ideas.js';
|
|
4
|
+
/** A whole-mod audit of a large mod reads every idea, character, sprite and name. */
|
|
5
|
+
const IDEAS_TIMEOUT_MS = 180_000;
|
|
6
|
+
/**
|
|
7
|
+
* `hoi4.idea_inspect` on the shared Rust engine (`hoi4-engine ideas`). This side passes the
|
|
8
|
+
* workspace's roots and turns the engine's answer into the tool's data. A missing engine is
|
|
9
|
+
* `ENGINE_UNAVAILABLE`, with no TypeScript fallback.
|
|
10
|
+
*/
|
|
11
|
+
export async function inspectIdeas(workspace, input, signal) {
|
|
12
|
+
const started = Date.now();
|
|
13
|
+
const request = {
|
|
14
|
+
...(workspace.gameRoot === undefined ? {} : { game: workspace.gameRoot }),
|
|
15
|
+
...(workspace.registration.kind === 'game' ? {} : { mod: workspace.modRoot }),
|
|
16
|
+
dependencies: workspace.dependencyRoots,
|
|
17
|
+
includeDlc: workspace.dlcLayers.length > 0,
|
|
18
|
+
kind: input.kind,
|
|
19
|
+
...(input.id === undefined ? {} : { id: input.id }),
|
|
20
|
+
audit: input.audit,
|
|
21
|
+
limit: input.limit,
|
|
22
|
+
};
|
|
23
|
+
const options = { timeoutMs: IDEAS_TIMEOUT_MS, ...(signal === undefined ? {} : { signal }) };
|
|
24
|
+
if (input.audit) {
|
|
25
|
+
const result = await runEngineCommand('ideas', request, ideaEngineAuditSchema, options);
|
|
26
|
+
if (!result.available)
|
|
27
|
+
throw new ServiceError('ENGINE_UNAVAILABLE', result.message, { reason: result.reason });
|
|
28
|
+
if (result.outcome === 'invalid_request')
|
|
29
|
+
throw new ServiceError(result.error.code, result.error.message);
|
|
30
|
+
return { audit: result.response, durationMs: Date.now() - started };
|
|
31
|
+
}
|
|
32
|
+
const result = await runEngineCommand('ideas', request, ideaEngineInspectionSchema, options);
|
|
33
|
+
if (!result.available)
|
|
34
|
+
throw new ServiceError('ENGINE_UNAVAILABLE', result.message, { reason: result.reason });
|
|
35
|
+
if (result.outcome === 'invalid_request')
|
|
36
|
+
throw new ServiceError(result.error.code, result.error.message);
|
|
37
|
+
const inspection = result.response;
|
|
38
|
+
if (!inspection.found) {
|
|
39
|
+
const suggestions = inspection.suggestions ?? [];
|
|
40
|
+
throw new ServiceError(input.kind === 'idea' ? 'IDEA_NOT_FOUND' : 'CHARACTER_NOT_FOUND', `No loaded file defines the ${input.kind} ${input.id ?? ''}${suggestions.length === 0 ? '' : `; did you mean ${suggestions.join(', ')}?`}`, { id: input.id ?? '', suggestions });
|
|
41
|
+
}
|
|
42
|
+
return { inspection, durationMs: Date.now() - started };
|
|
43
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { runEngineCommand } from '../core/engine-client.js';
|
|
2
|
+
import { ServiceError } from '../core/result.js';
|
|
3
|
+
import { localisationEngineResponseSchema, } from '../schemas/localisation.js';
|
|
4
|
+
/** A whole-mod audit of a large mod reads every localisation file and the mod's script. */
|
|
5
|
+
const LOCALISATION_TIMEOUT_MS = 180_000;
|
|
6
|
+
/**
|
|
7
|
+
* `hoi4.localisation_inspect` on the shared Rust engine. The engine reads the workspace's layers
|
|
8
|
+
* in load order; this side only passes the roots and turns its answer into the tool's data. A
|
|
9
|
+
* missing engine is `ENGINE_UNAVAILABLE`, with no TypeScript fallback.
|
|
10
|
+
*/
|
|
11
|
+
export async function inspectLocalisation(workspace, input, signal) {
|
|
12
|
+
const started = Date.now();
|
|
13
|
+
const isGame = workspace.registration.kind === 'game';
|
|
14
|
+
const result = await runEngineCommand('localisation', {
|
|
15
|
+
...(workspace.gameRoot === undefined ? {} : { game: workspace.gameRoot }),
|
|
16
|
+
...(isGame ? {} : { mod: workspace.modRoot }),
|
|
17
|
+
dependencies: workspace.dependencyRoots,
|
|
18
|
+
includeDlc: workspace.dlcLayers.length > 0,
|
|
19
|
+
mode: input.mode,
|
|
20
|
+
...(input.key === undefined ? {} : { key: input.key }),
|
|
21
|
+
...(input.language === undefined ? {} : { language: input.language }),
|
|
22
|
+
limit: input.limit,
|
|
23
|
+
}, localisationEngineResponseSchema, { timeoutMs: LOCALISATION_TIMEOUT_MS, ...(signal === undefined ? {} : { signal }) });
|
|
24
|
+
if (!result.available)
|
|
25
|
+
throw new ServiceError('ENGINE_UNAVAILABLE', result.message, { reason: result.reason });
|
|
26
|
+
if (result.outcome === 'invalid_request')
|
|
27
|
+
throw new ServiceError(result.error.code, result.error.message);
|
|
28
|
+
const answer = result.response;
|
|
29
|
+
if (answer.key?.found === false) {
|
|
30
|
+
const suggestions = answer.key.suggestions ?? [];
|
|
31
|
+
throw new ServiceError('LOCALISATION_KEY_NOT_FOUND', `No language defines ${input.key ?? ''}${suggestions.length === 0 ? '' : `; did you mean ${suggestions.join(', ')}?`}`, { key: input.key ?? '', suggestions, mentions: answer.key.mentions.length });
|
|
32
|
+
}
|
|
33
|
+
return { ...answer, durationMs: Date.now() - started };
|
|
34
|
+
}
|
|
@@ -13,6 +13,8 @@ export const ARGUMENT_EXAMPLES = {
|
|
|
13
13
|
'hoi4.script_validate': '{"path":"events/my_events.txt"} or {"source":"add_political_power = 10","kind":"effect","scope":"country"}',
|
|
14
14
|
'hoi4.error_log': '{"scope":"mod","category":"effect"}',
|
|
15
15
|
'hoi4.mod_index': '{"mode":"overview"} or {"mode":"next_id","kind":"event","namespace":"my_mod"}',
|
|
16
|
+
'hoi4.localisation_inspect': '{"mode":"key","key":"my_event.1.t"} or {"mode":"audit"}',
|
|
17
|
+
'hoi4.idea_inspect': '{"kind":"idea","id":"my_idea"} or {"kind":"character","audit":true}',
|
|
16
18
|
'hoi4.event_inspect': '{"mode":"lint","selector":"chaosx.nr14"} or {"mode":"trace","selector":"chaosx.nr14.1","direction":"downstream"}',
|
|
17
19
|
'hoi4.event_render': '{"view":"overview","selector":"chaosx.nr14"}',
|
|
18
20
|
'hoi4.focus_inspect': '{"treeId":"my_focus_tree"}',
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Shared agent-facing guidance for both MCP protocol generations. */
|
|
2
|
-
export const SERVER_INSTRUCTIONS = 'Start with the matching inspect tool; use hoi4.probability_inspect for weights and timing. Find local documentation with hoi4.reference_context, hoi4.reference_search and hoi4.reference_read, and source definitions with hoi4.source_lookup. Rewrite tools edit mod source. Results describe offline source and scenario models, not observed game behavior. Unresolved states are not confirmed coverage. Read linked artifacts when summaries omit detail. Long operations support negotiated MCP tasks and hoi4.job_inspect/hoi4.job_cancel; background rewrites need a stable requestKey.';
|
|
2
|
+
export const SERVER_INSTRUCTIONS = 'Start with the matching inspect tool; use hoi4.probability_inspect for weights and timing. Find local documentation with hoi4.reference_context, hoi4.reference_search and hoi4.reference_read, and source definitions with hoi4.source_lookup. Rewrite tools edit mod source. For focus trees: plan lanes first, place with auto positions, render and look, read the layout verdict (revise and blocked mean not finished), then revise only the failing branch. Results describe offline source and scenario models, not observed game behavior. Unresolved states are not confirmed coverage. Read linked artifacts when summaries omit detail. Long operations support negotiated MCP tasks and hoi4.job_inspect/hoi4.job_cancel; background rewrites need a stable requestKey.';
|
|
@@ -104,6 +104,8 @@ const eventInspectSummarySchema = z
|
|
|
104
104
|
edges: nonNegativeIntegerSchema,
|
|
105
105
|
events: nonNegativeIntegerSchema,
|
|
106
106
|
eventIds: inlineIdsSchema,
|
|
107
|
+
entryPoints: inlineIdsSchema,
|
|
108
|
+
helpers: inlineIdsSchema,
|
|
107
109
|
boundaryNodes: nonNegativeIntegerSchema,
|
|
108
110
|
truncated: z.boolean(),
|
|
109
111
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { registerLegacyTaskTools } from '../server/legacy-task-tools.js';
|
|
2
2
|
import { z } from 'zod/v4';
|
|
3
3
|
import { computeFocusVisualRevisions as computeCoreFocusVisualRevisions, } from '../../focus/tool-operations.js';
|
|
4
|
-
import { focusLayoutMetricsSchema } from '../../schemas/focus.js';
|
|
4
|
+
import { focusLayoutDeltaSchema, focusLayoutMetricsSchema, focusLayoutQualitySchema, } from '../../schemas/focus.js';
|
|
5
5
|
import { focusInspectRequestSchema, focusRenderRequestSchema, focusRewriteRequestSchema, } from '../../schemas/focus-requests.js';
|
|
6
6
|
import { nonNegativeIntegerSchema, renderHashesSchema, sha256Schema, } from '../server/output-schemas.js';
|
|
7
7
|
import { strictOperationResultSchema } from '../server/result.js';
|
|
@@ -9,6 +9,7 @@ const focusInspectOutputSchema = strictOperationResultSchema(z
|
|
|
9
9
|
.object({
|
|
10
10
|
mode: z.enum(['national', 'continuous']),
|
|
11
11
|
revision: sha256Schema,
|
|
12
|
+
layoutVerdict: z.enum(['blocked', 'revise', 'review', 'pass']).optional(),
|
|
12
13
|
treeCount: nonNegativeIntegerSchema,
|
|
13
14
|
paletteCount: nonNegativeIntegerSchema,
|
|
14
15
|
trees: z
|
|
@@ -29,6 +30,8 @@ const focusInspectOutputSchema = strictOperationResultSchema(z
|
|
|
29
30
|
layoutHash: sha256Schema,
|
|
30
31
|
layoutDecisionCount: nonNegativeIntegerSchema,
|
|
31
32
|
layoutMetrics: focusLayoutMetricsSchema,
|
|
33
|
+
layoutQuality: focusLayoutQualitySchema.optional(),
|
|
34
|
+
layoutDelta: focusLayoutDeltaSchema.optional(),
|
|
32
35
|
diagnosticCount: nonNegativeIntegerSchema,
|
|
33
36
|
scenarioSummary: z
|
|
34
37
|
.object({
|
|
@@ -64,6 +67,28 @@ const focusRenderOutputSchema = strictOperationResultSchema(z.discriminatedUnion
|
|
|
64
67
|
hashes: renderHashesSchema,
|
|
65
68
|
width: nonNegativeIntegerSchema,
|
|
66
69
|
height: nonNegativeIntegerSchema,
|
|
70
|
+
layoutQuality: focusLayoutQualitySchema.optional(),
|
|
71
|
+
inlineImages: z
|
|
72
|
+
.array(z
|
|
73
|
+
.object({
|
|
74
|
+
kind: z.enum(['overview', 'branch', 'focus', 'problem', 'game']),
|
|
75
|
+
label: z.string().max(300),
|
|
76
|
+
focusIds: z.array(z.string().max(256)).max(50),
|
|
77
|
+
region: z
|
|
78
|
+
.object({
|
|
79
|
+
minimumX: z.number().int(),
|
|
80
|
+
maximumX: z.number().int(),
|
|
81
|
+
minimumY: z.number().int(),
|
|
82
|
+
maximumY: z.number().int(),
|
|
83
|
+
})
|
|
84
|
+
.strict(),
|
|
85
|
+
width: nonNegativeIntegerSchema,
|
|
86
|
+
height: nonNegativeIntegerSchema,
|
|
87
|
+
bytes: nonNegativeIntegerSchema,
|
|
88
|
+
})
|
|
89
|
+
.strict())
|
|
90
|
+
.max(6)
|
|
91
|
+
.optional(),
|
|
67
92
|
})
|
|
68
93
|
.strict(),
|
|
69
94
|
z
|
|
@@ -93,6 +118,42 @@ const focusDriftOutputSchema = z
|
|
|
93
118
|
planChanged: z.boolean(),
|
|
94
119
|
})
|
|
95
120
|
.strict();
|
|
121
|
+
const engineShiftOutputSchema = z
|
|
122
|
+
.object({
|
|
123
|
+
fromX: z.number().int(),
|
|
124
|
+
columns: z.number().int().min(1),
|
|
125
|
+
direction: z.enum(['right', 'left']),
|
|
126
|
+
focusIds: z.array(z.string().max(256)),
|
|
127
|
+
})
|
|
128
|
+
.strict();
|
|
129
|
+
/** What the focus layout engine did (layoutMode engine or placement). */
|
|
130
|
+
const focusEngineLayoutOutputSchema = z
|
|
131
|
+
.object({
|
|
132
|
+
operation: z.enum(['layout', 'insert']),
|
|
133
|
+
status: z.literal('ok'),
|
|
134
|
+
hashes: z
|
|
135
|
+
.object({
|
|
136
|
+
layout: sha256Schema.nullable(),
|
|
137
|
+
untouched: sha256Schema,
|
|
138
|
+
prerequisites: sha256Schema,
|
|
139
|
+
exclusions: sha256Schema,
|
|
140
|
+
})
|
|
141
|
+
.strict(),
|
|
142
|
+
metrics: z
|
|
143
|
+
.object({
|
|
144
|
+
columns: nonNegativeIntegerSchema,
|
|
145
|
+
rows: nonNegativeIntegerSchema,
|
|
146
|
+
orthogonalCrossings: nonNegativeIntegerSchema,
|
|
147
|
+
stemsThroughPlaques: nonNegativeIntegerSchema,
|
|
148
|
+
mergedBars: nonNegativeIntegerSchema,
|
|
149
|
+
})
|
|
150
|
+
.strict(),
|
|
151
|
+
movedFocusIds: z.array(z.string().max(256)).max(100),
|
|
152
|
+
movedFocusCount: nonNegativeIntegerSchema,
|
|
153
|
+
shifted: z.array(engineShiftOutputSchema).optional(),
|
|
154
|
+
binarySource: z.enum(['environment', 'package']),
|
|
155
|
+
})
|
|
156
|
+
.strict();
|
|
96
157
|
const focusPlanOutputSchema = strictOperationResultSchema(z.discriminatedUnion('mode', [
|
|
97
158
|
z
|
|
98
159
|
.object({
|
|
@@ -102,6 +163,17 @@ const focusPlanOutputSchema = strictOperationResultSchema(z.discriminatedUnion('
|
|
|
102
163
|
created: z.boolean(),
|
|
103
164
|
execution: z.enum(['applied', 'blocked', 'unchanged']),
|
|
104
165
|
layoutHash: sha256Schema,
|
|
166
|
+
layoutQuality: focusLayoutQualitySchema.optional(),
|
|
167
|
+
layoutDelta: focusLayoutDeltaSchema.optional(),
|
|
168
|
+
compactOutcome: z
|
|
169
|
+
.object({
|
|
170
|
+
outcome: z.literal('nothing_to_improve'),
|
|
171
|
+
reason: z.enum(['verdict_pass', 'no_better_candidate', 'candidates_regress']),
|
|
172
|
+
blockedBy: z.array(z.string().max(64)).max(10),
|
|
173
|
+
})
|
|
174
|
+
.strict()
|
|
175
|
+
.optional(),
|
|
176
|
+
engine: focusEngineLayoutOutputSchema.optional(),
|
|
105
177
|
fileCount: nonNegativeIntegerSchema,
|
|
106
178
|
artifactCount: nonNegativeIntegerSchema,
|
|
107
179
|
})
|
|
@@ -135,7 +207,7 @@ export const focusTaskTools = [
|
|
|
135
207
|
{
|
|
136
208
|
name: 'hoi4.focus_inspect',
|
|
137
209
|
title: 'Inspect focus trees',
|
|
138
|
-
description: '
|
|
210
|
+
description: 'Check a focus tree\'s structure and layout. Returns blocking errors, a layout verdict (pass, review, revise, blocked) with the metrics behind it, a fix for each failing metric and next actions. Revise or blocked means the tree is not finished, however clean its structure; review is advisory, so look at hoi4.focus_render. Example: {"treeId":"my_focus_tree"}. The full report is a linked resource.',
|
|
139
211
|
inputSchema: focusInspectRequestSchema,
|
|
140
212
|
outputSchema: focusInspectOutputSchema,
|
|
141
213
|
annotations: artifactProducing,
|
|
@@ -143,7 +215,7 @@ export const focusTaskTools = [
|
|
|
143
215
|
{
|
|
144
216
|
name: 'hoi4.focus_render',
|
|
145
217
|
title: 'Preview a focus tree or continuous palette',
|
|
146
|
-
description: '
|
|
218
|
+
description: 'Render a focus tree in the in-game style (right-angle connectors) and return it inline, with close-ups of the worst places; cropBranchIds and cropFocusIds add more. Look before you judge a layout: metrics cannot see composition. Also exports PNG with icons, HTML, SVG and JSON as linked artifacts. Example: {"relativePath":"common/national_focus/my_tree.txt","treeId":"my_focus_tree"}.',
|
|
147
219
|
inputSchema: focusRenderRequestSchema,
|
|
148
220
|
outputSchema: focusRenderOutputSchema,
|
|
149
221
|
annotations: artifactProducing,
|
|
@@ -151,7 +223,7 @@ export const focusTaskTools = [
|
|
|
151
223
|
{
|
|
152
224
|
name: 'hoi4.focus_rewrite',
|
|
153
225
|
title: 'Build or arrange a focus tree',
|
|
154
|
-
description: 'Create focus trees and
|
|
226
|
+
description: 'Create or repair a focus tree or palette. New trees: lanes and position mode auto; x/y only for exact anchors. layoutMode compact repairs a layout (compactFocusIds picks a branch, pinnedFocusIds keeps neighbours); engine lays out with the Rust engine; placement adds focuses, moving no others; both need hoi4-engine. Keeps prerequisites and rewards. Returns files, layout verdict and delta. Example: {"relativePath":"common/national_focus/my_tree.txt","treeId":"my_focus_tree","layoutMode":"compact"}.',
|
|
155
227
|
inputSchema: focusRewriteRequestSchema,
|
|
156
228
|
outputSchema: focusPlanOutputSchema,
|
|
157
229
|
annotations: {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { errorResult, strictOperationResultSchema } from '../../core/operation-result.js';
|
|
2
2
|
import { ReferenceToolService } from '../../reference/operations.js';
|
|
3
3
|
import { referenceContextRequestSchema, referenceReadRequestSchema, referenceSearchRequestSchema, sourceLookupRequestSchema, referenceContextDataSchema, referenceReadDataSchema, referenceSearchDataSchema, sourceLookupDataSchema, } from '../../schemas/reference.js';
|
|
4
|
+
import { localisationInspectDataSchema, localisationInspectRequestSchema, } from '../../schemas/localisation.js';
|
|
5
|
+
import { ideaInspectDataSchema, ideaInspectRequestSchema } from '../../schemas/ideas.js';
|
|
4
6
|
import { errorLogDataSchema, errorLogRequestSchema, modIndexDataSchema, modIndexRequestSchema, } from '../../schemas/mod-tools.js';
|
|
5
7
|
import { scriptValidateDataSchema, scriptValidateRequestSchema, } from '../../schemas/script-validation.js';
|
|
6
8
|
const readOnly = {
|
|
@@ -66,6 +68,22 @@ export const referenceTools = [
|
|
|
66
68
|
outputSchema: strictOperationResultSchema(modIndexDataSchema),
|
|
67
69
|
annotations: readOnly,
|
|
68
70
|
},
|
|
71
|
+
{
|
|
72
|
+
name: 'hoi4.localisation_inspect',
|
|
73
|
+
title: 'Check localisation in every language',
|
|
74
|
+
description: 'Read localisation in every language the game and mod ship. key: one key per language with file, line and layer, the languages lacking it and the files mentioning it. audit: keys the mod uses that no language defines, keys missing from a supported language, keys defined twice in one language, and file problems. coverage: keys per language. Example: {"mode":"key","key":"my_event.1.t"} or {"mode":"audit"}. Returns counts per problem and a few examples of each.',
|
|
75
|
+
inputSchema: localisationInspectRequestSchema,
|
|
76
|
+
outputSchema: strictOperationResultSchema(localisationInspectDataSchema),
|
|
77
|
+
annotations: readOnly,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: 'hoi4.idea_inspect',
|
|
81
|
+
title: 'Inspect ideas and characters',
|
|
82
|
+
description: 'Read an idea or character across the game, DLC and mod. idea: category, picture sprite and texture, modifiers checked against the game docs, conditions, name in every language, the advisor it belongs to, and files mentioning it. character: name, roles with traits checked, portraits checked. audit: true checks every idea or character of the mod. Example: {"kind":"idea","id":"GER_mefo_bills_1"} or {"kind":"character","audit":true}.',
|
|
83
|
+
inputSchema: ideaInspectRequestSchema,
|
|
84
|
+
outputSchema: strictOperationResultSchema(ideaInspectDataSchema),
|
|
85
|
+
annotations: readOnly,
|
|
86
|
+
},
|
|
69
87
|
];
|
|
70
88
|
export function registerReferenceTools(server, engine, context) {
|
|
71
89
|
const service = new ReferenceToolService(engine);
|
|
@@ -185,11 +185,26 @@ export async function inspectProbabilities(analyzer, input, context) {
|
|
|
185
185
|
let inspected = await analyzer.inspect(runtime(context, input.refresh), input.adapter, source, candidatePool, customPoolManifest);
|
|
186
186
|
// A wrong adapter guess, such as a mission named as a decision, should not cost another call.
|
|
187
187
|
const suggested = inspected.discovery?.suggestedAdapter;
|
|
188
|
+
// Without an adapter, an identifier or pool that names weighted blocks picks its own adapter:
|
|
189
|
+
// an event id evaluates its options rather than returning the whole source inventory.
|
|
190
|
+
const namedBySource = input.adapter === undefined &&
|
|
191
|
+
inspected.discovery?.reason === 'source_inventory' &&
|
|
192
|
+
inspected.discovery.availableAdapters.some(({ adapterId, identifierMatchCount, candidatePoolMatchCount }) => adapterId === suggested && (identifierMatchCount > 0 || candidatePoolMatchCount > 0)) &&
|
|
193
|
+
(source?.identifier !== undefined || candidatePool.length > 0);
|
|
194
|
+
const alternatives = namedBySource
|
|
195
|
+
? inspected
|
|
196
|
+
.discovery.availableAdapters.filter(({ adapterId, identifierMatchCount, candidatePoolMatchCount }) => adapterId !== suggested &&
|
|
197
|
+
(source?.identifier === undefined
|
|
198
|
+
? candidatePoolMatchCount > 0
|
|
199
|
+
: identifierMatchCount > 0))
|
|
200
|
+
.map(({ adapterId }) => adapterId)
|
|
201
|
+
: [];
|
|
188
202
|
if (input.evaluate !== false &&
|
|
189
203
|
inspected.surface === undefined &&
|
|
190
204
|
suggested !== undefined &&
|
|
191
205
|
suggested !== input.adapter &&
|
|
192
|
-
(
|
|
206
|
+
(namedBySource ||
|
|
207
|
+
inspected.discovery?.reason === 'candidate_pool_not_found' ||
|
|
193
208
|
inspected.discovery?.reason === 'requested_adapter_empty' ||
|
|
194
209
|
inspected.discovery?.reason === 'identifier_not_found'))
|
|
195
210
|
inspected = await analyzer.inspect(runtime(context), suggested, source, candidatePool, customPoolManifest);
|
|
@@ -221,6 +236,17 @@ export async function inspectProbabilities(analyzer, input, context) {
|
|
|
221
236
|
});
|
|
222
237
|
const result = probabilityAnalysisServiceResult(context.workspaceId, analyzed);
|
|
223
238
|
result.artifacts = [...result.artifacts, ...inspected.artifacts];
|
|
239
|
+
if (namedBySource && alternatives.length > 0)
|
|
240
|
+
result.diagnostics = [
|
|
241
|
+
{
|
|
242
|
+
code: 'PROBABILITY_ADAPTER_SELECTED',
|
|
243
|
+
severity: 'info',
|
|
244
|
+
category: 'configuration',
|
|
245
|
+
message: `No adapter was requested, so ${surface.adapter.id} was used; pass adapter to evaluate ${alternatives.join(', ')} instead`,
|
|
246
|
+
details: { adapterId: surface.adapter.id, alternatives },
|
|
247
|
+
},
|
|
248
|
+
...result.diagnostics,
|
|
249
|
+
];
|
|
224
250
|
if (input.scenarioSet === undefined)
|
|
225
251
|
result.diagnostics = [
|
|
226
252
|
{
|