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
|
@@ -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,16 +2,21 @@ 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';
|
|
9
12
|
import { readDependenciesFromScannedFiles, } from '../core/transactions.js';
|
|
10
13
|
import { setInlineFilesScanned } from '../core/operation-result.js';
|
|
11
14
|
import { PACKAGE_VERSION } from '../version.js';
|
|
12
|
-
import { focusPlanHash, focusPresentationEvidence, importContinuousFocusPalettes, assertCompactLayoutQuality, compactFocusTreePlanAsync, linkContinuousFocusPalettes, resolveFocusPresentation, } from './index.js';
|
|
15
|
+
import { focusPlanHash, focusPresentationEvidence, importFocusTrees, importContinuousFocusPalettes, assertCompactLayoutQuality, compactFocusTreePlanAsync, linkContinuousFocusPalettes, resolveFocusPresentation, } from './index.js';
|
|
13
16
|
import { activeContinuousFocusFiles, activeFocusFiles, activeSidecar, continuousPalettes, importFocusFile, referenceCatalog, selectContinuousPlan, selectedContinuousFocusFile, selectedFocusFile, selectPlan, underConfiguredRoot, validationFromDiagnostics, } from './tool-support.js';
|
|
14
17
|
import { inspectFocusScenario } from './scenario.js';
|
|
18
|
+
import { assertFocusEngineLayoutWritten, layoutFocusTreeWithEngine, } from './engine-layout.js';
|
|
19
|
+
import { describeLayoutDelta, evaluateFocusLayoutQuality, layoutQualityOutput, layoutValidationCheck, layoutVerdictDiagnostic, withoutCurvedConnectorDiagnostics, worstVerdict, renderInlineImages, } from './quality/index.js';
|
|
15
20
|
const LARGE_FOCUS_RENDER_NODE_THRESHOLD = 200;
|
|
16
21
|
const LARGE_FOCUS_RENDER_SCALE = 0.5;
|
|
17
22
|
function automaticFocusRenderScale(focusCount) {
|
|
@@ -69,6 +74,10 @@ export function normalizeFocusRenderRequest(input) {
|
|
|
69
74
|
export function normalizeFocusRewriteRequest(input) {
|
|
70
75
|
return input;
|
|
71
76
|
}
|
|
77
|
+
/** Many trees in one result share the response budget, so each gets less of its scorecard. */
|
|
78
|
+
function inspectDetail(treeCount) {
|
|
79
|
+
return treeCount === 1 ? 'full' : treeCount <= 4 ? 'compact' : 'minimal';
|
|
80
|
+
}
|
|
72
81
|
function compactDrift(drift) {
|
|
73
82
|
return {
|
|
74
83
|
status: drift.status,
|
|
@@ -209,15 +218,19 @@ export async function prepareFocusRewrite(engine, workbench, input, context) {
|
|
|
209
218
|
}
|
|
210
219
|
else {
|
|
211
220
|
if (imported === undefined)
|
|
212
|
-
throw new ServiceError('FOCUS_COMPACT_SOURCE_REQUIRED', 'Plan-free compact
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
+
throw new ServiceError('FOCUS_COMPACT_SOURCE_REQUIRED', 'Plan-free compact or engine layout requires an existing national focus source', { relativePath });
|
|
222
|
+
if (input.layoutMode === 'engine')
|
|
223
|
+
plan = selectPlan(imported.result, input.treeId);
|
|
224
|
+
else {
|
|
225
|
+
compactSourcePlan = selectPlan(imported.result, input.treeId);
|
|
226
|
+
compactPlanning = await compactFocusTreePlanAsync(compactSourcePlan, {
|
|
227
|
+
...(context.signal === undefined ? {} : { signal: context.signal }),
|
|
228
|
+
...(input.compactFocusIds === undefined ? {} : { focusIds: input.compactFocusIds }),
|
|
229
|
+
...(input.pinnedFocusIds === undefined ? {} : { pinnedFocusIds: input.pinnedFocusIds }),
|
|
230
|
+
...(input.symmetryGroups === undefined ? {} : { symmetryGroups: input.symmetryGroups }),
|
|
231
|
+
});
|
|
232
|
+
plan = compactPlanning.plan;
|
|
233
|
+
}
|
|
221
234
|
}
|
|
222
235
|
const currentPlan = imported?.result.plans.find(({ id }) => id === plan.id);
|
|
223
236
|
if (currentPlan === undefined && !createIfMissing) {
|
|
@@ -260,6 +273,28 @@ export async function prepareFocusRewrite(engine, workbench, input, context) {
|
|
|
260
273
|
: await workbench.layoutAsync(currentPlan, {
|
|
261
274
|
...(context.signal === undefined ? {} : { signal: context.signal }),
|
|
262
275
|
});
|
|
276
|
+
let engineLayout;
|
|
277
|
+
if (input.layoutMode === 'engine' || input.placement !== undefined) {
|
|
278
|
+
await context.progress(1, 5, 'Laying out the tree with the focus layout engine');
|
|
279
|
+
// Raw source coordinates, without the planning sidecar's automatic-placement intent.
|
|
280
|
+
const sourcePlan = imported === undefined
|
|
281
|
+
? undefined
|
|
282
|
+
: importFocusTrees(imported.document).plans.find(({ id }) => id === plan.id);
|
|
283
|
+
engineLayout = await layoutFocusTreeWithEngine({
|
|
284
|
+
plan,
|
|
285
|
+
layoutMode: input.layoutMode === 'engine' ? 'engine' : 'authored',
|
|
286
|
+
...(input.placement === undefined ? {} : { placement: input.placement }),
|
|
287
|
+
...(sourcePlan === undefined
|
|
288
|
+
? {}
|
|
289
|
+
: {
|
|
290
|
+
currentSourcePositions: new Map(sourcePlan.focuses.map(({ id, position }) => [id, position])),
|
|
291
|
+
}),
|
|
292
|
+
...(currentPlan === undefined
|
|
293
|
+
? {}
|
|
294
|
+
: { currentFocusIds: new Set(currentPlan.focuses.map(({ id }) => id)) }),
|
|
295
|
+
}, context.signal === undefined ? {} : { signal: context.signal });
|
|
296
|
+
plan = engineLayout.plan;
|
|
297
|
+
}
|
|
263
298
|
await context.progress(1, 5, 'Building proposed focus review');
|
|
264
299
|
const proposedPlanHash = focusPlanHash(plan);
|
|
265
300
|
const reviewPlan = {
|
|
@@ -274,8 +309,13 @@ export async function prepareFocusRewrite(engine, workbench, input, context) {
|
|
|
274
309
|
(await workbench.layoutAsync(reviewPlan, {
|
|
275
310
|
...(context.signal === undefined ? {} : { signal: context.signal }),
|
|
276
311
|
}));
|
|
312
|
+
if (engineLayout !== undefined)
|
|
313
|
+
assertFocusEngineLayoutWritten(engineLayout.response, proposedLayout.nodes);
|
|
277
314
|
if (input.layoutMode === 'compact')
|
|
278
|
-
assertCompactLayoutQuality(currentLayout, proposedLayout, input.compactFocusIds !== undefined
|
|
315
|
+
assertCompactLayoutQuality(currentLayout, proposedLayout, input.compactFocusIds !== undefined, {
|
|
316
|
+
...(currentPlan === undefined ? {} : { current: currentPlan }),
|
|
317
|
+
proposed: plan,
|
|
318
|
+
});
|
|
279
319
|
const proposed = await workbench.renderAndStore(context.workspaceId, reviewPlan, {
|
|
280
320
|
...(context.principal === undefined ? {} : { principal: context.principal }),
|
|
281
321
|
index: snapshot.index,
|
|
@@ -312,6 +352,14 @@ export async function prepareFocusRewrite(engine, workbench, input, context) {
|
|
|
312
352
|
...(context.signal === undefined ? {} : { signal: context.signal }),
|
|
313
353
|
});
|
|
314
354
|
await context.progress(4, 5, 'Focus rewrite prepared for journaled application');
|
|
355
|
+
const after = evaluateFocusLayoutQuality(plan, planned.layout.nodes);
|
|
356
|
+
const delta = describeLayoutDelta(currentPlan === undefined || currentLayout === undefined
|
|
357
|
+
? undefined
|
|
358
|
+
: {
|
|
359
|
+
plan: currentPlan,
|
|
360
|
+
nodes: currentLayout.nodes,
|
|
361
|
+
report: evaluateFocusLayoutQuality(currentPlan, currentLayout.nodes).report,
|
|
362
|
+
}, { plan, nodes: planned.layout.nodes, report: after.report });
|
|
315
363
|
return {
|
|
316
364
|
transaction: planned.transaction,
|
|
317
365
|
recipe: focusRewriteRecipeSchema.parse({
|
|
@@ -321,6 +369,24 @@ export async function prepareFocusRewrite(engine, workbench, input, context) {
|
|
|
321
369
|
drift: compactDrift(planned.drift),
|
|
322
370
|
created: planned.drift.status === 'target_missing',
|
|
323
371
|
layoutHash: planned.layout.layoutHash,
|
|
372
|
+
layoutQuality: layoutQualityOutput(after.report, 'full'),
|
|
373
|
+
layoutDelta: delta,
|
|
374
|
+
sourcePath: plan.provenance.sourcePath,
|
|
375
|
+
...(engineLayout === undefined
|
|
376
|
+
? {}
|
|
377
|
+
: {
|
|
378
|
+
engine: engineLayout.summary,
|
|
379
|
+
engineDiagnostics: engineLayout.diagnostics.slice(0, 50),
|
|
380
|
+
}),
|
|
381
|
+
...(compactPlanning?.outcome === 'nothing_to_improve'
|
|
382
|
+
? {
|
|
383
|
+
compactOutcome: {
|
|
384
|
+
outcome: 'nothing_to_improve',
|
|
385
|
+
reason: compactPlanning.reason ?? 'no_better_candidate',
|
|
386
|
+
blockedBy: compactPlanning.blockedBy ?? [],
|
|
387
|
+
},
|
|
388
|
+
}
|
|
389
|
+
: {}),
|
|
324
390
|
}),
|
|
325
391
|
filesScanned: [
|
|
326
392
|
...new Set([
|
|
@@ -331,17 +397,25 @@ export async function prepareFocusRewrite(engine, workbench, input, context) {
|
|
|
331
397
|
}),
|
|
332
398
|
};
|
|
333
399
|
}
|
|
400
|
+
/** A string recorded in a write recipe, or an empty one. */
|
|
401
|
+
function recipeText(value) {
|
|
402
|
+
return typeof value === 'string' ? value : '';
|
|
403
|
+
}
|
|
334
404
|
export function completeFocusRewrite(workspaceId, execution, recipe) {
|
|
335
405
|
const parsed = focusRewriteRecipeSchema.parse(recipe);
|
|
336
406
|
const transaction = execution.transaction;
|
|
337
407
|
const mode = parsed.data.mode;
|
|
408
|
+
// Engine diagnostics travel in the recipe and join the result's diagnostics, not its data.
|
|
409
|
+
const { engineDiagnostics, ...data } = parsed.data;
|
|
338
410
|
const result = emptyServiceResult(workspaceId, {
|
|
339
|
-
...
|
|
411
|
+
...data,
|
|
340
412
|
execution: execution.outcome,
|
|
341
413
|
fileCount: transaction.files.length,
|
|
342
414
|
artifactCount: transaction.artifacts.length,
|
|
343
415
|
});
|
|
344
416
|
result.status = transaction.validation.passed ? 'ok' : 'blocked';
|
|
417
|
+
const quality = parsed.data.layoutQuality;
|
|
418
|
+
const compactOutcome = parsed.data.compactOutcome;
|
|
345
419
|
result.code =
|
|
346
420
|
mode === 'continuous'
|
|
347
421
|
? execution.outcome === 'applied'
|
|
@@ -357,9 +431,57 @@ export function completeFocusRewrite(workspaceId, execution, recipe) {
|
|
|
357
431
|
setInlineFilesScanned(result, parsed.filesScanned);
|
|
358
432
|
result.proposedFiles = transaction.files.slice(0, 100).map(({ relativePath }) => relativePath);
|
|
359
433
|
result.changedFiles = transaction.appliedFiles.slice(0, 100);
|
|
360
|
-
|
|
434
|
+
const sourcePath = recipeText(parsed.data.sourcePath);
|
|
435
|
+
const treeId = recipeText(parsed.data.treeId);
|
|
436
|
+
const noteLocation = sourcePath === ''
|
|
437
|
+
? undefined
|
|
438
|
+
: {
|
|
439
|
+
path: sourcePath,
|
|
440
|
+
start: { line: 1, column: 1, offset: 0 },
|
|
441
|
+
end: { line: 1, column: 1, offset: 0 },
|
|
442
|
+
};
|
|
443
|
+
const layoutNotes = [
|
|
444
|
+
...(compactOutcome === undefined
|
|
445
|
+
? []
|
|
446
|
+
: [
|
|
447
|
+
{
|
|
448
|
+
code: 'FOCUS_COMPACT_NOTHING_TO_IMPROVE',
|
|
449
|
+
severity: 'info',
|
|
450
|
+
category: 'layout',
|
|
451
|
+
message: compactOutcome.reason === 'verdict_pass'
|
|
452
|
+
? 'The layout already passes every calibrated metric, so compact reflow has nothing to improve; the source is unchanged'
|
|
453
|
+
: compactOutcome.blockedBy.length === 0
|
|
454
|
+
? 'Compact reflow found no layout that beats the current one under the in-game connector model; the source is unchanged'
|
|
455
|
+
: `Compact reflow found no layout that is at least as good as the current one (${compactOutcome.blockedBy.join(', ')}); the source is unchanged`,
|
|
456
|
+
...(noteLocation === undefined ? {} : { location: noteLocation }),
|
|
457
|
+
details: {
|
|
458
|
+
reason: compactOutcome.reason,
|
|
459
|
+
blockedBy: compactOutcome.blockedBy,
|
|
460
|
+
verdict: quality?.verdict ?? null,
|
|
461
|
+
},
|
|
462
|
+
},
|
|
463
|
+
]),
|
|
464
|
+
...(quality === undefined
|
|
465
|
+
? []
|
|
466
|
+
: [layoutVerdictDiagnostic(treeId, quality, noteLocation)].filter((entry) => entry !== undefined)),
|
|
467
|
+
];
|
|
468
|
+
result.diagnostics = [
|
|
469
|
+
...layoutNotes,
|
|
470
|
+
...(engineDiagnostics ?? []),
|
|
471
|
+
...transaction.diagnostics,
|
|
472
|
+
].slice(0, 100);
|
|
361
473
|
result.artifacts = autonomousResultArtifacts(execution);
|
|
362
|
-
result.validation =
|
|
474
|
+
result.validation =
|
|
475
|
+
quality === undefined
|
|
476
|
+
? transaction.validation
|
|
477
|
+
: {
|
|
478
|
+
passed: transaction.validation.passed,
|
|
479
|
+
// First, because the inline list of checks is capped and the layout verdict must stay.
|
|
480
|
+
checks: [
|
|
481
|
+
layoutValidationCheck([{ treeId, report: quality }]),
|
|
482
|
+
...transaction.validation.checks,
|
|
483
|
+
],
|
|
484
|
+
};
|
|
363
485
|
result.blockers = transaction.diagnostics
|
|
364
486
|
.filter(({ severity }) => severity === 'error' || severity === 'blocker')
|
|
365
487
|
.map(({ code, message, details }) => ({
|
|
@@ -490,10 +612,21 @@ export async function inspectFocus(engine, workbench, input, context) {
|
|
|
490
612
|
layout,
|
|
491
613
|
});
|
|
492
614
|
diagnostics.push(...lintDiagnostics);
|
|
615
|
+
const quality = evaluateFocusLayoutQuality(plan, layout.nodes);
|
|
616
|
+
const previousLayout = input.previous;
|
|
617
|
+
const delta = previousLayout === undefined
|
|
618
|
+
? undefined
|
|
619
|
+
: describeLayoutDelta({
|
|
620
|
+
plan,
|
|
621
|
+
nodes: previousLayout.nodes,
|
|
622
|
+
report: evaluateFocusLayoutQuality(plan, previousLayout.nodes).report,
|
|
623
|
+
}, { plan, nodes: layout.nodes, report: quality.report });
|
|
493
624
|
inspectedPlans.push({
|
|
494
625
|
plan,
|
|
495
626
|
layout,
|
|
496
|
-
diagnosticCount: lintDiagnostics.length,
|
|
627
|
+
diagnosticCount: withoutCurvedConnectorDiagnostics(lintDiagnostics).length,
|
|
628
|
+
quality,
|
|
629
|
+
...(delta === undefined ? {} : { delta }),
|
|
497
630
|
...(input.scenario === undefined
|
|
498
631
|
? {}
|
|
499
632
|
: { scenario: inspectFocusScenario(plan, input.scenario.completedFocusIds) }),
|
|
@@ -520,10 +653,12 @@ export async function inspectFocus(engine, workbench, input, context) {
|
|
|
520
653
|
schemaVersion: 1,
|
|
521
654
|
revision: snapshot.revision,
|
|
522
655
|
plans,
|
|
523
|
-
layouts: inspectedPlans.map(({ plan, layout, diagnosticCount, scenario }) => ({
|
|
656
|
+
layouts: inspectedPlans.map(({ plan, layout, diagnosticCount, scenario, quality, delta }) => ({
|
|
524
657
|
treeId: plan.id,
|
|
525
658
|
layout,
|
|
526
659
|
diagnosticCount,
|
|
660
|
+
layoutQuality: quality.report,
|
|
661
|
+
...(delta === undefined ? {} : { layoutDelta: delta }),
|
|
527
662
|
...(scenario === undefined ? {} : { scenario }),
|
|
528
663
|
})),
|
|
529
664
|
continuousFocusPalettes: paletteImport.palettes,
|
|
@@ -542,7 +677,10 @@ export async function inspectFocus(engine, workbench, input, context) {
|
|
|
542
677
|
revision: snapshot.revision,
|
|
543
678
|
treeCount: plans.length,
|
|
544
679
|
paletteCount: paletteImport.palettes.length,
|
|
545
|
-
|
|
680
|
+
layoutVerdict: worstVerdict(inspectedPlans.map(({ quality }) => quality.report.verdict)),
|
|
681
|
+
trees: inspectedPlans
|
|
682
|
+
.slice(0, 100)
|
|
683
|
+
.map(({ plan, layout, diagnosticCount, scenario, quality, delta }) => ({
|
|
546
684
|
id: plan.id,
|
|
547
685
|
sourcePath: plan.provenance.sourcePath,
|
|
548
686
|
focusCount: plan.focuses.length,
|
|
@@ -555,6 +693,8 @@ export async function inspectFocus(engine, workbench, input, context) {
|
|
|
555
693
|
layoutHash: layout.layoutHash,
|
|
556
694
|
layoutDecisionCount: layout.decisions.length,
|
|
557
695
|
layoutMetrics: layout.metrics,
|
|
696
|
+
layoutQuality: layoutQualityOutput(quality.report, inspectDetail(inspectedPlans.length)),
|
|
697
|
+
...(delta === undefined ? {} : { layoutDelta: delta }),
|
|
558
698
|
diagnosticCount,
|
|
559
699
|
...(scenario === undefined
|
|
560
700
|
? {}
|
|
@@ -576,12 +716,139 @@ export async function inspectFocus(engine, workbench, input, context) {
|
|
|
576
716
|
...presentation.filesScanned,
|
|
577
717
|
]),
|
|
578
718
|
].sort((left, right) => compareCodeUnits(left, right)));
|
|
579
|
-
|
|
719
|
+
// The curved-connector findings are replaced by the in-game connector model in the scorecard;
|
|
720
|
+
// the linked report keeps every raw diagnostic.
|
|
721
|
+
// The verdicts come first: the inline list is capped, and a verdict must never be cut off.
|
|
722
|
+
const reported = [
|
|
723
|
+
...inspectedPlans.flatMap(({ plan, quality }) => {
|
|
724
|
+
const verdict = layoutVerdictDiagnostic(plan.id, quality.report, plan.sourceLocation);
|
|
725
|
+
return verdict === undefined ? [] : [verdict];
|
|
726
|
+
}),
|
|
727
|
+
...withoutCurvedConnectorDiagnostics(diagnostics),
|
|
728
|
+
];
|
|
729
|
+
result.diagnostics = reported.slice(0, 100);
|
|
580
730
|
result.artifacts = [publicArtifactLink(artifact)];
|
|
581
|
-
|
|
731
|
+
const structure = validationFromDiagnostics(reported);
|
|
732
|
+
result.validation = {
|
|
733
|
+
passed: structure.passed,
|
|
734
|
+
checks: [
|
|
735
|
+
...structure.checks,
|
|
736
|
+
layoutValidationCheck(inspectedPlans.map(({ plan, quality }) => ({ treeId: plan.id, report: quality.report }))),
|
|
737
|
+
],
|
|
738
|
+
};
|
|
582
739
|
await context.progress(3, 3, 'Focus inspection complete');
|
|
583
740
|
return { result, sourceRevision: snapshot.revision };
|
|
584
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
|
+
}
|
|
585
852
|
export async function renderFocus(engine, workbench, input, context, rasterize) {
|
|
586
853
|
const outputName = rasterize ? 'raster' : 'render';
|
|
587
854
|
if (!rasterize && (input.cropFocusIds?.length ?? 0) > 0)
|
|
@@ -639,21 +906,61 @@ export async function renderFocus(engine, workbench, input, context, rasterize)
|
|
|
639
906
|
const imported = importFocusFile(snapshot, selectedFocusFile(snapshot, workspace.registration.roots.focus, input.relativePath), paletteImport.palettes);
|
|
640
907
|
const plan = selectPlan(imported, input.treeId);
|
|
641
908
|
const linkedPalettes = paletteImport.palettes.filter(({ id }) => plan.continuousFocusPaletteIds.includes(id));
|
|
642
|
-
|
|
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({
|
|
643
920
|
plans: [plan],
|
|
644
921
|
palettes: linkedPalettes,
|
|
645
922
|
files: snapshot.files,
|
|
646
923
|
index: snapshot.index,
|
|
647
924
|
scanner: engine.scanner,
|
|
648
925
|
workspace,
|
|
649
|
-
decodeIcons
|
|
926
|
+
decodeIcons,
|
|
650
927
|
budget: renderBudget,
|
|
651
928
|
...(context.signal === undefined ? {} : { signal: context.signal }),
|
|
652
929
|
});
|
|
930
|
+
let presentation = await resolvePresentation(rasterize && !gameViewWanted);
|
|
653
931
|
await context.progress(2, 4, `Producing focus ${outputName} artifacts`);
|
|
654
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;
|
|
655
951
|
const rendered = await workbench.renderAndStore(context.workspaceId, plan, {
|
|
656
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
|
+
}),
|
|
657
964
|
index: snapshot.index,
|
|
658
965
|
references: referenceCatalog(snapshot),
|
|
659
966
|
presentation,
|
|
@@ -670,14 +977,33 @@ export async function renderFocus(engine, workbench, input, context, rasterize)
|
|
|
670
977
|
sourceRevision: snapshot.revision,
|
|
671
978
|
reviewScale: effectiveReviewScale,
|
|
672
979
|
output: outputName,
|
|
980
|
+
...(game === undefined ? {} : { renderer: 'hoi4-engine game view' }),
|
|
673
981
|
},
|
|
674
982
|
budget: renderBudget,
|
|
675
983
|
...(context.signal === undefined ? {} : { signal: context.signal }),
|
|
676
984
|
});
|
|
985
|
+
const quality = evaluateFocusLayoutQuality(plan, rendered.layout.nodes);
|
|
986
|
+
// The inline pictures are the in-game-style schematic the scorecard measures: right-angle
|
|
987
|
+
// connectors, 1.6-column plaques, cropped to branches and to the places the metrics blame.
|
|
988
|
+
const inline = input.inline === false
|
|
989
|
+
? undefined
|
|
990
|
+
: await renderInlineImages(quality.graph, quality.report, {
|
|
991
|
+
...(input.cropBranchIds === undefined ? {} : { cropBranchIds: input.cropBranchIds }),
|
|
992
|
+
...(input.cropFocusIds === undefined ? {} : { cropFocusIds: input.cropFocusIds }),
|
|
993
|
+
budget: renderBudget,
|
|
994
|
+
}, `${plan.id} · ${plan.focuses.length} focuses · layout ${quality.report.verdict}`);
|
|
995
|
+
// The layout verdict and the crop notes come first: the inline list is capped.
|
|
677
996
|
const diagnostics = [
|
|
997
|
+
...[layoutVerdictDiagnostic(plan.id, quality.report, plan.sourceLocation)].filter((entry) => entry !== undefined),
|
|
998
|
+
// A location keeps these in the group of the mod's own findings, which the inline list shows first.
|
|
999
|
+
...(inline?.diagnostics ?? []).map((diagnostic) => ({
|
|
1000
|
+
...diagnostic,
|
|
1001
|
+
...(plan.sourceLocation === undefined ? {} : { location: plan.sourceLocation }),
|
|
1002
|
+
})),
|
|
1003
|
+
...gameViewDiagnostics(gameView, plan.sourceLocation),
|
|
678
1004
|
...paletteImport.diagnostics,
|
|
679
1005
|
...imported.diagnostics,
|
|
680
|
-
...rendered.diagnostics,
|
|
1006
|
+
...withoutCurvedConnectorDiagnostics(rendered.diagnostics),
|
|
681
1007
|
];
|
|
682
1008
|
const result = emptyServiceResult(context.workspaceId, {
|
|
683
1009
|
mode: 'national',
|
|
@@ -686,12 +1012,25 @@ export async function renderFocus(engine, workbench, input, context, rasterize)
|
|
|
686
1012
|
hashes: rendered.bundle.hashes,
|
|
687
1013
|
width: rendered.bundle.width,
|
|
688
1014
|
height: rendered.bundle.height,
|
|
1015
|
+
layoutQuality: layoutQualityOutput(quality.report, 'compact'),
|
|
1016
|
+
...(inline === undefined ? {} : { inlineImages: inline.descriptions }),
|
|
689
1017
|
});
|
|
690
1018
|
result.code = rasterize ? 'FOCUS_RASTERIZED' : 'FOCUS_RENDERED';
|
|
691
1019
|
setInlineFilesScanned(result, [...new Set([plan.provenance.sourcePath, ...presentation.filesScanned])].sort((left, right) => compareCodeUnits(left, right)));
|
|
692
1020
|
result.diagnostics = diagnostics.slice(0, 100);
|
|
693
1021
|
result.artifacts = rendered.artifacts.map(publicArtifactLink);
|
|
694
|
-
|
|
1022
|
+
const structure = validationFromDiagnostics(diagnostics);
|
|
1023
|
+
result.validation = {
|
|
1024
|
+
passed: structure.passed,
|
|
1025
|
+
checks: [
|
|
1026
|
+
...structure.checks,
|
|
1027
|
+
layoutValidationCheck([{ treeId: plan.id, report: quality.report }]),
|
|
1028
|
+
],
|
|
1029
|
+
};
|
|
695
1030
|
await context.progress(4, 4, `Focus ${outputName} complete`);
|
|
696
|
-
return {
|
|
1031
|
+
return {
|
|
1032
|
+
result,
|
|
1033
|
+
sourceRevision: snapshot.revision,
|
|
1034
|
+
...(inline === undefined || inline.images.length === 0 ? {} : { images: inline.images }),
|
|
1035
|
+
};
|
|
697
1036
|
}
|
|
@@ -124,7 +124,7 @@ export function validationFromDiagnostics(diagnostics) {
|
|
|
124
124
|
id: 'focus-diagnostics',
|
|
125
125
|
passed: blocking.length === 0,
|
|
126
126
|
message: blocking.length === 0
|
|
127
|
-
? '
|
|
127
|
+
? 'Structure ok: focus source, references, prerequisites and positions have no blocking diagnostics. This is not a layout verdict'
|
|
128
128
|
: `${blocking.length} blocking focus diagnostics`,
|
|
129
129
|
},
|
|
130
130
|
],
|
|
@@ -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,
|