hoi4-agent-tools 4.7.0 → 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 +24 -0
- package/README.md +32 -13
- package/dist/hoi4_agent_tools/core/engine-client.js +74 -5
- package/dist/hoi4_agent_tools/core/operation-result.js +9 -0
- 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/engine-layout.js +1 -1
- 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/native-effects.js +4 -4
- package/dist/hoi4_agent_tools/focus/quality/focus-quality-calibration.json +241 -241
- package/dist/hoi4_agent_tools/focus/quality/orthogonal.js +30 -19
- package/dist/hoi4_agent_tools/focus/quality/schematic.js +5 -3
- package/dist/hoi4_agent_tools/focus/quality/scorecard.js +1 -1
- package/dist/hoi4_agent_tools/focus/render.js +21 -9
- package/dist/hoi4_agent_tools/focus/tool-operations.js +158 -3
- 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/tools/event.js +2 -0
- package/dist/hoi4_agent_tools/mcp/tools/focus.js +1 -1
- 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/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 +32 -0
- package/dist/hoi4_agent_tools/reference/script-validation.js +46 -6
- package/dist/hoi4_agent_tools/reference/service.js +33 -0
- package/dist/hoi4_agent_tools/reference/source-lookup.js +8 -0
- package/dist/hoi4_agent_tools/schemas/focus-requests.js +4 -0
- 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/focus.md +9 -5
- package/docs/research/reference-benchmark.md +41 -0
- package/docs/tools.md +43 -39
- 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 +4 -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 +1 -1
- package/schemas/focus-planning-sidecar.schema.json +1 -1
- 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,18 +1,25 @@
|
|
|
1
1
|
import { compareCodeUnits } from '../../core/canonical.js';
|
|
2
2
|
import { FOCUS_PAIR_COMPARISON_MAX } from '../limits.js';
|
|
3
3
|
/**
|
|
4
|
-
* Orthogonal connector model "O1". The game draws right-angle connectors: a stem leaves the
|
|
5
|
-
* of the parent, a horizontal bar runs
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* Orthogonal connector model "O1". The game draws right-angle connectors: a short stem leaves the
|
|
5
|
+
* bottom centre of the parent's plaque, a horizontal bar runs just under the parent (0.28 rows
|
|
6
|
+
* below the parent's row), and a long vertical drops in the child's column from the bar into the
|
|
7
|
+
* top of the child's icon. All-to-all bundles and OR groups share one bar at that height. A focus's
|
|
8
|
+
* plaque is centred on its (x, y); it is 1.61 columns wide and 0.28 rows high, and the icon sits
|
|
9
|
+
* above it, so icon and plaque together reach 0.66 rows above the focus's row.
|
|
10
|
+
*
|
|
11
|
+
* Plaque width and bar placement were confirmed by the in-game run of 2026-11-02 on game 1.19.4.1
|
|
12
|
+
* at the default UI scale and zoom (1 column = 96 px, 1 row = 130 px), including multi-row
|
|
13
|
+
* connectors. Other UI scales and zoom levels are unverified.
|
|
9
14
|
*/
|
|
10
|
-
export const ORTHOGONAL_PLAQUE_WIDTH = 1.
|
|
11
|
-
export const ORTHOGONAL_PLAQUE_HEIGHT = 0.
|
|
12
|
-
/** A
|
|
15
|
+
export const ORTHOGONAL_PLAQUE_WIDTH = 1.61;
|
|
16
|
+
export const ORTHOGONAL_PLAQUE_HEIGHT = 0.28;
|
|
17
|
+
/** A vertical closer than this many columns to another plaque's centre runs through that plaque. */
|
|
13
18
|
export const ORTHOGONAL_STEM_CLEARANCE = ORTHOGONAL_PLAQUE_WIDTH / 2;
|
|
14
|
-
/** Distance of the horizontal bar
|
|
15
|
-
export const ORTHOGONAL_BAR_OFFSET = 0.
|
|
19
|
+
/** Distance of the horizontal bar below the parent's row. */
|
|
20
|
+
export const ORTHOGONAL_BAR_OFFSET = 0.28;
|
|
21
|
+
/** Distance of the top of a focus's icon above its row, where the child's vertical ends. */
|
|
22
|
+
export const ORTHOGONAL_ICON_TOP = 0.66;
|
|
16
23
|
export const ORTHOGONAL_MINIMUM_SHARED_BAR = 0.5;
|
|
17
24
|
export const ORTHOGONAL_MINIMUM_SHARED_STEM = 0.3;
|
|
18
25
|
const BUNDLE_CANDIDATE_PARENT_MAX = 800;
|
|
@@ -24,9 +31,11 @@ export function orthogonalConnector(parent, child) {
|
|
|
24
31
|
childX: child.x,
|
|
25
32
|
parentY: parent.y,
|
|
26
33
|
childY: child.y,
|
|
27
|
-
|
|
34
|
+
stemFrom: parent.y + ORTHOGONAL_PLAQUE_HEIGHT / 2,
|
|
35
|
+
barY: parent.y + ORTHOGONAL_BAR_OFFSET,
|
|
28
36
|
barFrom: Math.min(parent.x, child.x),
|
|
29
37
|
barTo: Math.max(parent.x, child.x),
|
|
38
|
+
dropTo: child.y - ORTHOGONAL_ICON_TOP,
|
|
30
39
|
};
|
|
31
40
|
}
|
|
32
41
|
function intersection(left, right) {
|
|
@@ -104,11 +113,12 @@ export function measureOrthogonalConnectors(graph) {
|
|
|
104
113
|
'The tree is too large for an exact connector comparison; crossing and merged-bar counts are partial';
|
|
105
114
|
return false;
|
|
106
115
|
};
|
|
116
|
+
// Every bar runs just under its parent's row, so bars are grouped by the parent's row.
|
|
107
117
|
const barsByRow = new Map();
|
|
108
118
|
for (const [index, connector] of connectors.entries()) {
|
|
109
|
-
const row = barsByRow.get(connector.
|
|
119
|
+
const row = barsByRow.get(connector.parentY) ?? [];
|
|
110
120
|
row.push(index);
|
|
111
|
-
barsByRow.set(connector.
|
|
121
|
+
barsByRow.set(connector.parentY, row);
|
|
112
122
|
}
|
|
113
123
|
const nodesByRow = new Map();
|
|
114
124
|
for (const node of graph.nodes) {
|
|
@@ -119,7 +129,8 @@ export function measureOrthogonalConnectors(graph) {
|
|
|
119
129
|
const crossings = [];
|
|
120
130
|
const stems = [];
|
|
121
131
|
for (const [index, connector] of connectors.entries()) {
|
|
122
|
-
// The
|
|
132
|
+
// The child's vertical drops from the bar just under the parent's row to the child's icon, so
|
|
133
|
+
// it passes every row strictly between the two and the bars just under those rows.
|
|
123
134
|
for (let row = connector.parentY + 1; row <= connector.childY - 1; row += 1) {
|
|
124
135
|
for (const otherIndex of barsByRow.get(row) ?? []) {
|
|
125
136
|
if (!spend())
|
|
@@ -127,8 +138,8 @@ export function measureOrthogonalConnectors(graph) {
|
|
|
127
138
|
if (otherIndex === index)
|
|
128
139
|
continue;
|
|
129
140
|
const other = connectors[otherIndex];
|
|
130
|
-
if (other.barFrom < connector.
|
|
131
|
-
connector.
|
|
141
|
+
if (other.barFrom < connector.childX &&
|
|
142
|
+
connector.childX < other.barTo &&
|
|
132
143
|
!exempt(index, otherIndex))
|
|
133
144
|
crossings.push({ firstIndex: index, secondIndex: otherIndex });
|
|
134
145
|
}
|
|
@@ -137,7 +148,7 @@ export function measureOrthogonalConnectors(graph) {
|
|
|
137
148
|
break;
|
|
138
149
|
if (node.id === connector.parent || node.id === connector.child)
|
|
139
150
|
continue;
|
|
140
|
-
if (Math.abs(node.x - connector.
|
|
151
|
+
if (Math.abs(node.x - connector.childX) >= ORTHOGONAL_STEM_CLEARANCE)
|
|
141
152
|
continue;
|
|
142
153
|
const inOwnBundle = (bundleIdsOfEdge[index] ?? []).some((bundleIndex) => bundleMembers[bundleIndex].has(node.id));
|
|
143
154
|
if (!inOwnBundle)
|
|
@@ -170,8 +181,8 @@ export function measureOrthogonalConnectors(graph) {
|
|
|
170
181
|
verticals.set(x, group);
|
|
171
182
|
};
|
|
172
183
|
for (const [index, connector] of connectors.entries()) {
|
|
173
|
-
addVertical(connector.parentX, index, connector.
|
|
174
|
-
addVertical(connector.childX, index, connector.barY, connector.
|
|
184
|
+
addVertical(connector.parentX, index, connector.stemFrom, connector.barY);
|
|
185
|
+
addVertical(connector.childX, index, connector.barY, connector.dropTo);
|
|
175
186
|
}
|
|
176
187
|
for (const group of verticals.values()) {
|
|
177
188
|
for (const [position, first] of group.entries()) {
|
|
@@ -5,7 +5,7 @@ import { DeterministicSvgTextRenderer } from '../../core/svg-text.js';
|
|
|
5
5
|
import { orthogonalConnector, ORTHOGONAL_PLAQUE_HEIGHT, ORTHOGONAL_PLAQUE_WIDTH, } from './orthogonal.js';
|
|
6
6
|
/**
|
|
7
7
|
* A no-icon schematic of a focus layout in the in-game connector model: right-angle connectors, a
|
|
8
|
-
* plaque 1.
|
|
8
|
+
* plaque 1.61 columns wide and 0.28 rows high, red marks between exclusive choices and dotted
|
|
9
9
|
* connectors for alternative prerequisites. It is cheap, and it draws what the metrics measure, so
|
|
10
10
|
* an agent that looks at it judges the same picture the scorecard describes. It is a tool render,
|
|
11
11
|
* never a game screenshot.
|
|
@@ -141,7 +141,9 @@ function schematicDocument(graph, options) {
|
|
|
141
141
|
fontSize: 9,
|
|
142
142
|
fill: '#7d8aa0',
|
|
143
143
|
}));
|
|
144
|
-
// Connectors: stem down, bar just
|
|
144
|
+
// Connectors: a short stem down, a bar just under the parent's row, a vertical in the child's
|
|
145
|
+
// column. A plaque is drawn from py(y) down, so a model height h maps to py(h) + half a plaque.
|
|
146
|
+
// The schematic has no icons, so the vertical runs on to the top of the child's plaque.
|
|
145
147
|
const connectors = graph.edges.map((edge) => {
|
|
146
148
|
const parent = graph.position.get(edge.parent);
|
|
147
149
|
const child = graph.position.get(edge.child);
|
|
@@ -156,7 +158,7 @@ function schematicDocument(graph, options) {
|
|
|
156
158
|
!inRegion(connector.childX, connector.childY))
|
|
157
159
|
continue;
|
|
158
160
|
const startY = py(connector.parentY) + plaqueHeight;
|
|
159
|
-
const barY = py(connector.barY);
|
|
161
|
+
const barY = py(connector.barY) + plaqueHeight / 2;
|
|
160
162
|
const endY = py(connector.childY);
|
|
161
163
|
const d = `M ${px(connector.parentX)} ${startY} V ${barY} H ${px(connector.childX)} V ${endY}`;
|
|
162
164
|
parts.push(`<path d="${d}" stroke="${edge.or ? '#8ab4e8' : '#9aa6b8'}" stroke-width="2"${edge.or ? ' stroke-dasharray="3 4"' : ''} data-parent="${escapeXml(edge.parent)}" data-child="${escapeXml(edge.child)}"/>`);
|
|
@@ -15,7 +15,7 @@ const STATUS_ORDER = {
|
|
|
15
15
|
export const QUALITY_NOT_EVALUATED = [
|
|
16
16
|
'gameplay and balance',
|
|
17
17
|
'visual review: call hoi4.focus_render and look at the image',
|
|
18
|
-
'in-game connector geometry: the orthogonal model is
|
|
18
|
+
'in-game connector geometry at other UI scales and zoom levels: the orthogonal model is confirmed in game 1.19.4.1 at the default scale and zoom only',
|
|
19
19
|
];
|
|
20
20
|
function format(value) {
|
|
21
21
|
if (Number.isInteger(value))
|
|
@@ -452,7 +452,14 @@ export async function renderFocusTree(plan, layout, diagnostics, options = {}) {
|
|
|
452
452
|
const json = `${canonicalJson({ ...rendered.graph, generatedSourceMap: compiled.sourceMap })}\n`;
|
|
453
453
|
const html = htmlDocument(plan, rendered.svg, json, diagnostics);
|
|
454
454
|
let png = Buffer.alloc(0);
|
|
455
|
-
|
|
455
|
+
const raster = options.raster;
|
|
456
|
+
const outputWidth = raster?.width ?? rendered.width;
|
|
457
|
+
const outputHeight = raster?.height ?? rendered.height;
|
|
458
|
+
if (raster !== undefined && options.rasterize !== false) {
|
|
459
|
+
assertRenderDimensions(raster.width, raster.height, 'focus tree game view');
|
|
460
|
+
png = raster.png;
|
|
461
|
+
}
|
|
462
|
+
else if (options.rasterize !== false) {
|
|
456
463
|
assertRenderDimensions(rendered.width, rendered.height, 'focus tree Sharp raster');
|
|
457
464
|
budget.reserveRasterOperation(`focus-tree:${sha256Bytes(rendered.svg)}`, 'focus tree SVG rasterization');
|
|
458
465
|
png = await sharp(Buffer.from(rendered.svg, 'utf8'), {
|
|
@@ -481,13 +488,18 @@ export async function renderFocusTree(plan, layout, diagnostics, options = {}) {
|
|
|
481
488
|
focusId,
|
|
482
489
|
});
|
|
483
490
|
const origin = focusNodeOrigin(node, minimumX, minimumY, padding, horizontal, vertical);
|
|
484
|
-
const
|
|
485
|
-
const
|
|
486
|
-
|
|
487
|
-
|
|
491
|
+
const box = raster?.boxes.get(focusId);
|
|
492
|
+
const centerX = box === undefined
|
|
493
|
+
? Math.round((origin.x + FOCUS_NODE_WIDTH_PIXELS / 2) * scale)
|
|
494
|
+
: Math.round(box.x + box.width / 2);
|
|
495
|
+
const centerY = box === undefined
|
|
496
|
+
? Math.round((origin.y + FOCUS_NODE_HEIGHT_PIXELS / 2) * scale)
|
|
497
|
+
: Math.round(box.y + box.height / 2);
|
|
498
|
+
const width = Math.min(outputWidth, 640);
|
|
499
|
+
const height = Math.min(outputHeight, 440);
|
|
488
500
|
budget.reserve(width, height, 'focus problem crop PNG');
|
|
489
|
-
const x = Math.max(0, Math.min(
|
|
490
|
-
const y = Math.max(0, Math.min(
|
|
501
|
+
const x = Math.max(0, Math.min(outputWidth - width, centerX - Math.floor(width / 2)));
|
|
502
|
+
const y = Math.max(0, Math.min(outputHeight - height, centerY - Math.floor(height / 2)));
|
|
491
503
|
const crop = await sharp(png)
|
|
492
504
|
.extract({ left: x, top: y, width, height })
|
|
493
505
|
.png({ compressionLevel: 9, adaptiveFiltering: false, palette: false })
|
|
@@ -515,8 +527,8 @@ export async function renderFocusTree(plan, layout, diagnostics, options = {}) {
|
|
|
515
527
|
json: sha256Bytes(json),
|
|
516
528
|
},
|
|
517
529
|
sourceMap: compiled.sourceMap,
|
|
518
|
-
width:
|
|
519
|
-
height:
|
|
530
|
+
width: outputWidth,
|
|
531
|
+
height: outputHeight,
|
|
520
532
|
...(problemCrops.length === 0 ? {} : { problemCrops }),
|
|
521
533
|
};
|
|
522
534
|
}
|
|
@@ -2,7 +2,10 @@ 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 { focusDomainScanPatterns } from '../core/domain-scan-patterns.js';
|
|
5
|
-
import { RenderBudget } from '../core/render-budget.js';
|
|
5
|
+
import { RenderBudget, RENDER_MAX_PIXELS } from '../core/render-budget.js';
|
|
6
|
+
import { sharedResidentEngine } from '../core/resident-engine.js';
|
|
7
|
+
import { renderFocusGameView } from './game-render.js';
|
|
8
|
+
import { gameViewBundle, storeGameViewArtifacts } from './game-view-output.js';
|
|
6
9
|
import { emptyServiceResult, ServiceError } from '../core/result.js';
|
|
7
10
|
import { parseClausewitz } from '../core/source/index.js';
|
|
8
11
|
import { autonomousResultArtifacts, } from '../core/transaction-execution.js';
|
|
@@ -736,6 +739,116 @@ export async function inspectFocus(engine, workbench, input, context) {
|
|
|
736
739
|
await context.progress(3, 3, 'Focus inspection complete');
|
|
737
740
|
return { result, sourceRevision: snapshot.revision };
|
|
738
741
|
}
|
|
742
|
+
/** Most missing game-view assets listed inline; the PNG artifact's report is complete. */
|
|
743
|
+
const GAME_VIEW_MISSING_DIAGNOSTICS = 20;
|
|
744
|
+
/** What the game view could not draw, and why it is absent when the engine failed. */
|
|
745
|
+
function gameViewDiagnostics(gameView, location) {
|
|
746
|
+
if (gameView === undefined)
|
|
747
|
+
return [];
|
|
748
|
+
const at = location === undefined ? {} : { location };
|
|
749
|
+
if (!gameView.ok)
|
|
750
|
+
return [
|
|
751
|
+
{
|
|
752
|
+
code: 'FOCUS_GAME_VIEW_UNAVAILABLE',
|
|
753
|
+
category: 'rendering',
|
|
754
|
+
severity: 'warning',
|
|
755
|
+
message: `The game view could not be drawn (${gameView.code}: ${gameView.message}); the PNG is the schematic.`,
|
|
756
|
+
...at,
|
|
757
|
+
},
|
|
758
|
+
];
|
|
759
|
+
return gameView.report.missing.slice(0, GAME_VIEW_MISSING_DIAGNOSTICS).map((missing) => ({
|
|
760
|
+
code: 'FOCUS_GAME_VIEW_ASSET_MISSING',
|
|
761
|
+
category: 'rendering',
|
|
762
|
+
severity: 'warning',
|
|
763
|
+
message: `${missing.message}${missing.focusIds.length === 0 ? '' : ` (focuses: ${missing.focusIds.slice(0, 5).join(', ')}${missing.focusIds.length > 5 ? ', ...' : ''})`}`,
|
|
764
|
+
details: { kind: missing.kind, name: missing.name, focusIds: missing.focusIds.slice(0, 50) },
|
|
765
|
+
...at,
|
|
766
|
+
}));
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* `view: "game"`: the game view alone, for an in-app preview that renders on every edit. No
|
|
770
|
+
* presentation pass, schematic SVG or schematic raster: titles are localised here, icons and
|
|
771
|
+
* everything else are resolved by the resident engine.
|
|
772
|
+
*/
|
|
773
|
+
async function renderGameViewOnly(workbench, input, context, source) {
|
|
774
|
+
const { snapshot, workspace, plan } = source;
|
|
775
|
+
await context.progress(2, 4, 'Drawing the game view');
|
|
776
|
+
const layout = await workbench.layoutAsync(plan, context.signal === undefined ? {} : { signal: context.signal });
|
|
777
|
+
const scale = input.reviewScale ?? automaticFocusRenderScale(plan.focuses.length);
|
|
778
|
+
const view = await renderFocusGameView({
|
|
779
|
+
workspace,
|
|
780
|
+
plan,
|
|
781
|
+
layout,
|
|
782
|
+
index: snapshot.index,
|
|
783
|
+
language: 'l_english',
|
|
784
|
+
scale,
|
|
785
|
+
maxPixels: RENDER_MAX_PIXELS,
|
|
786
|
+
...(context.signal === undefined ? {} : { signal: context.signal }),
|
|
787
|
+
});
|
|
788
|
+
if (!view.ok)
|
|
789
|
+
throw new ServiceError('FOCUS_GAME_VIEW_UNAVAILABLE', `The game view could not be drawn: ${view.message}`, { reason: view.code });
|
|
790
|
+
const bundle = await gameViewBundle(plan, layout, view.png, view.report, view.titles, view.request);
|
|
791
|
+
const stored = await storeGameViewArtifacts(workspace, plan, bundle, { sourceRevision: snapshot.revision, reviewScale: scale, output: 'game' }, context.signal);
|
|
792
|
+
const quality = evaluateFocusLayoutQuality(plan, layout.nodes);
|
|
793
|
+
const diagnostics = [
|
|
794
|
+
...[layoutVerdictDiagnostic(plan.id, quality.report, plan.sourceLocation)].filter((entry) => entry !== undefined),
|
|
795
|
+
...gameViewDiagnostics(view, plan.sourceLocation),
|
|
796
|
+
...source.diagnostics,
|
|
797
|
+
];
|
|
798
|
+
const xs = layout.nodes.map(({ x }) => x);
|
|
799
|
+
const ys = layout.nodes.map(({ y }) => y);
|
|
800
|
+
const result = emptyServiceResult(context.workspaceId, {
|
|
801
|
+
mode: 'national',
|
|
802
|
+
treeId: plan.id,
|
|
803
|
+
layoutHash: layout.layoutHash,
|
|
804
|
+
hashes: bundle.hashes,
|
|
805
|
+
width: view.report.width,
|
|
806
|
+
height: view.report.height,
|
|
807
|
+
layoutQuality: layoutQualityOutput(quality.report, 'compact'),
|
|
808
|
+
...(input.inline === false
|
|
809
|
+
? {}
|
|
810
|
+
: {
|
|
811
|
+
inlineImages: [
|
|
812
|
+
{
|
|
813
|
+
kind: 'game',
|
|
814
|
+
label: `${plan.id} as the game draws it`,
|
|
815
|
+
focusIds: [],
|
|
816
|
+
region: {
|
|
817
|
+
minimumX: Math.min(...xs),
|
|
818
|
+
maximumX: Math.max(...xs),
|
|
819
|
+
minimumY: Math.min(...ys),
|
|
820
|
+
maximumY: Math.max(...ys),
|
|
821
|
+
},
|
|
822
|
+
width: bundle.inline.width,
|
|
823
|
+
height: bundle.inline.height,
|
|
824
|
+
bytes: bundle.inline.png.length,
|
|
825
|
+
},
|
|
826
|
+
],
|
|
827
|
+
}),
|
|
828
|
+
});
|
|
829
|
+
result.code = 'FOCUS_RASTERIZED';
|
|
830
|
+
setInlineFilesScanned(result, [plan.provenance.sourcePath]);
|
|
831
|
+
result.diagnostics = diagnostics.slice(0, 100);
|
|
832
|
+
result.artifacts = stored.map(publicArtifactLink);
|
|
833
|
+
const structure = validationFromDiagnostics(diagnostics);
|
|
834
|
+
result.validation = {
|
|
835
|
+
passed: structure.passed,
|
|
836
|
+
checks: [
|
|
837
|
+
...structure.checks,
|
|
838
|
+
layoutValidationCheck([{ treeId: plan.id, report: quality.report }]),
|
|
839
|
+
],
|
|
840
|
+
};
|
|
841
|
+
await context.progress(4, 4, 'Game view complete');
|
|
842
|
+
return {
|
|
843
|
+
result,
|
|
844
|
+
sourceRevision: snapshot.revision,
|
|
845
|
+
...(input.inline === false
|
|
846
|
+
? {}
|
|
847
|
+
: {
|
|
848
|
+
images: [{ data: bundle.inline.png.toString('base64'), mimeType: 'image/png' }],
|
|
849
|
+
}),
|
|
850
|
+
};
|
|
851
|
+
}
|
|
739
852
|
export async function renderFocus(engine, workbench, input, context, rasterize) {
|
|
740
853
|
const outputName = rasterize ? 'raster' : 'render';
|
|
741
854
|
if (!rasterize && (input.cropFocusIds?.length ?? 0) > 0)
|
|
@@ -793,21 +906,61 @@ export async function renderFocus(engine, workbench, input, context, rasterize)
|
|
|
793
906
|
const imported = importFocusFile(snapshot, selectedFocusFile(snapshot, workspace.registration.roots.focus, input.relativePath), paletteImport.palettes);
|
|
794
907
|
const plan = selectPlan(imported, input.treeId);
|
|
795
908
|
const linkedPalettes = paletteImport.palettes.filter(({ id }) => plan.continuousFocusPaletteIds.includes(id));
|
|
796
|
-
|
|
909
|
+
if (input.view === 'game')
|
|
910
|
+
return renderGameViewOnly(workbench, input, context, {
|
|
911
|
+
snapshot,
|
|
912
|
+
workspace,
|
|
913
|
+
plan,
|
|
914
|
+
diagnostics: [...paletteImport.diagnostics, ...imported.diagnostics],
|
|
915
|
+
});
|
|
916
|
+
// The PNG is the game view the engine draws from the game's own assets (#75). Without the
|
|
917
|
+
// engine it is the schematic SVG rasterized here, which needs the icons decoded.
|
|
918
|
+
const gameViewWanted = rasterize && sharedResidentEngine().available();
|
|
919
|
+
const resolvePresentation = (decodeIcons) => resolveFocusPresentation({
|
|
797
920
|
plans: [plan],
|
|
798
921
|
palettes: linkedPalettes,
|
|
799
922
|
files: snapshot.files,
|
|
800
923
|
index: snapshot.index,
|
|
801
924
|
scanner: engine.scanner,
|
|
802
925
|
workspace,
|
|
803
|
-
decodeIcons
|
|
926
|
+
decodeIcons,
|
|
804
927
|
budget: renderBudget,
|
|
805
928
|
...(context.signal === undefined ? {} : { signal: context.signal }),
|
|
806
929
|
});
|
|
930
|
+
let presentation = await resolvePresentation(rasterize && !gameViewWanted);
|
|
807
931
|
await context.progress(2, 4, `Producing focus ${outputName} artifacts`);
|
|
808
932
|
const effectiveReviewScale = input.reviewScale ?? automaticFocusRenderScale(plan.focuses.length);
|
|
933
|
+
let gameView;
|
|
934
|
+
let layout;
|
|
935
|
+
if (gameViewWanted) {
|
|
936
|
+
layout = await workbench.layoutAsync(plan, context.signal === undefined ? {} : { signal: context.signal });
|
|
937
|
+
gameView = await renderFocusGameView({
|
|
938
|
+
workspace,
|
|
939
|
+
plan,
|
|
940
|
+
layout,
|
|
941
|
+
index: snapshot.index,
|
|
942
|
+
language: presentation.language,
|
|
943
|
+
scale: effectiveReviewScale,
|
|
944
|
+
maxPixels: RENDER_MAX_PIXELS,
|
|
945
|
+
...(context.signal === undefined ? {} : { signal: context.signal }),
|
|
946
|
+
});
|
|
947
|
+
if (!gameView.ok)
|
|
948
|
+
presentation = await resolvePresentation(true);
|
|
949
|
+
}
|
|
950
|
+
const game = gameView?.ok === true ? gameView : undefined;
|
|
809
951
|
const rendered = await workbench.renderAndStore(context.workspaceId, plan, {
|
|
810
952
|
...(context.principal === undefined ? {} : { principal: context.principal }),
|
|
953
|
+
...(layout === undefined ? {} : { layout }),
|
|
954
|
+
...(game === undefined
|
|
955
|
+
? {}
|
|
956
|
+
: {
|
|
957
|
+
raster: {
|
|
958
|
+
png: game.png,
|
|
959
|
+
width: game.report.width,
|
|
960
|
+
height: game.report.height,
|
|
961
|
+
boxes: new Map(game.report.focuses.map((box) => [box.id, box])),
|
|
962
|
+
},
|
|
963
|
+
}),
|
|
811
964
|
index: snapshot.index,
|
|
812
965
|
references: referenceCatalog(snapshot),
|
|
813
966
|
presentation,
|
|
@@ -824,6 +977,7 @@ export async function renderFocus(engine, workbench, input, context, rasterize)
|
|
|
824
977
|
sourceRevision: snapshot.revision,
|
|
825
978
|
reviewScale: effectiveReviewScale,
|
|
826
979
|
output: outputName,
|
|
980
|
+
...(game === undefined ? {} : { renderer: 'hoi4-engine game view' }),
|
|
827
981
|
},
|
|
828
982
|
budget: renderBudget,
|
|
829
983
|
...(context.signal === undefined ? {} : { signal: context.signal }),
|
|
@@ -846,6 +1000,7 @@ export async function renderFocus(engine, workbench, input, context, rasterize)
|
|
|
846
1000
|
...diagnostic,
|
|
847
1001
|
...(plan.sourceLocation === undefined ? {} : { location: plan.sourceLocation }),
|
|
848
1002
|
})),
|
|
1003
|
+
...gameViewDiagnostics(gameView, plan.sourceLocation),
|
|
849
1004
|
...paletteImport.diagnostics,
|
|
850
1005
|
...imported.diagnostics,
|
|
851
1006
|
...withoutCurvedConnectorDiagnostics(rendered.diagnostics),
|
|
@@ -6,6 +6,7 @@ import { RenderBudget, RENDER_MAX_DECODED_PIXELS } from '../core/render-budget.j
|
|
|
6
6
|
import { ServiceError } from '../core/result.js';
|
|
7
7
|
import { DETERMINISTIC_TOOL_FONT_HASH, shapeFontkitOutline } from '../core/svg-text.js';
|
|
8
8
|
import { decodeDds } from './dds.js';
|
|
9
|
+
import { decodeTextureWithEngine, ENGINE_TEXTURE_HINT } from './engine-textures.js';
|
|
9
10
|
import { GUI_BMFONT_MAX_CHARACTERS, GUI_BINARY_FONT_MAX_BYTES, GUI_BMFONT_MAX_BYTES, GUI_BMFONT_MAX_FIELDS_PER_RECORD, GUI_BMFONT_MAX_KERNING_PAIRS, GUI_BMFONT_MAX_PAGES, GUI_BMFONT_MAX_RECORDS, GUI_TEXT_MAX_CHARACTERS, GUI_TEXT_MAX_MISSING_GLYPH_SAMPLES, } from './limits.js';
|
|
10
11
|
import { decodeTga } from './tga.js';
|
|
11
12
|
import { compileGuiProgressEffect, compileGuiShaderEffect, GUI_SHADER_MAX_BYTES, } from './shader.js';
|
|
@@ -1042,6 +1043,23 @@ export class GuiAssetCatalog {
|
|
|
1042
1043
|
const operationKey = `gui-raster:${file.displayPath}:${file.sha256}`;
|
|
1043
1044
|
if (extension === '.dds') {
|
|
1044
1045
|
const decoded = decodeDds(file.bytes, this.budget, operationKey);
|
|
1046
|
+
// Formats the TypeScript decoder does not read go to the Rust engine; the decoder has
|
|
1047
|
+
// already reserved the pixel budget. RXGB is a swizzled map format, not GUI colour art.
|
|
1048
|
+
if ('unsupported' in decoded && decoded.format !== 'RXGB') {
|
|
1049
|
+
const engine = await decodeTextureWithEngine(file.bytes, 'dds', RENDER_MAX_DECODED_PIXELS);
|
|
1050
|
+
return 'decoded' in engine
|
|
1051
|
+
? { ...engine.decoded, supported: true }
|
|
1052
|
+
: {
|
|
1053
|
+
width: 0,
|
|
1054
|
+
height: 0,
|
|
1055
|
+
data: Buffer.alloc(0),
|
|
1056
|
+
format: engine.engineAvailable ? engine.format : decoded.format,
|
|
1057
|
+
supported: false,
|
|
1058
|
+
reason: engine.engineAvailable
|
|
1059
|
+
? engine.reason
|
|
1060
|
+
: `${decoded.reason} ${ENGINE_TEXTURE_HINT}`,
|
|
1061
|
+
};
|
|
1062
|
+
}
|
|
1045
1063
|
return 'unsupported' in decoded
|
|
1046
1064
|
? {
|
|
1047
1065
|
width: 0,
|
|
@@ -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');
|