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
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { compareCodeUnits, hashCanonical } from '../../core/canonical.js';
|
|
2
|
+
import { qualityMetricInfo } from './calibration.js';
|
|
3
|
+
const LISTED_FOCUS_LIMIT = 100;
|
|
4
|
+
function anchorOf(plan) {
|
|
5
|
+
return new Map(plan.focuses.map((focus) => [
|
|
6
|
+
focus.id,
|
|
7
|
+
focus.position.mode === 'relative' ? focus.position.relativeTo : null,
|
|
8
|
+
]));
|
|
9
|
+
}
|
|
10
|
+
function prerequisiteHashOf(plan) {
|
|
11
|
+
return hashCanonical([...plan.focuses]
|
|
12
|
+
.sort((left, right) => compareCodeUnits(left.id, right.id))
|
|
13
|
+
.map((focus) => [
|
|
14
|
+
focus.id,
|
|
15
|
+
focus.prerequisites.groups
|
|
16
|
+
.map(({ focusIds }) => [...focusIds].sort(compareCodeUnits).join('\0'))
|
|
17
|
+
.sort(compareCodeUnits),
|
|
18
|
+
]));
|
|
19
|
+
}
|
|
20
|
+
function exclusionHashOf(plan) {
|
|
21
|
+
return hashCanonical([...plan.focuses]
|
|
22
|
+
.sort((left, right) => compareCodeUnits(left.id, right.id))
|
|
23
|
+
.map((focus) => [focus.id, [...focus.mutuallyExclusive].sort(compareCodeUnits)]));
|
|
24
|
+
}
|
|
25
|
+
function improvement(id, before, after) {
|
|
26
|
+
const direction = qualityMetricInfo(id).direction === 'high' ? 1 : -1;
|
|
27
|
+
return direction * (before - after);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Compares two layouts of one tree. `before` is absent for a new tree. The hashes let a caller
|
|
31
|
+
* prove that a layout repair moved only coordinates: the prerequisite and exclusion hashes must be
|
|
32
|
+
* equal, and the unmoved hash must not change when the same repair is applied again.
|
|
33
|
+
*/
|
|
34
|
+
export function describeLayoutDelta(before, after) {
|
|
35
|
+
const afterAnchors = anchorOf(after.plan);
|
|
36
|
+
const beforePositions = new Map(before?.nodes.map(({ id, x, y }) => [id, { x, y }]));
|
|
37
|
+
const beforeAnchors = before === undefined ? undefined : anchorOf(before.plan);
|
|
38
|
+
const moved = [];
|
|
39
|
+
const unmoved = [];
|
|
40
|
+
for (const node of [...after.nodes].sort((left, right) => compareCodeUnits(left.id, right.id))) {
|
|
41
|
+
const original = beforePositions.get(node.id);
|
|
42
|
+
const anchor = afterAnchors.get(node.id) ?? null;
|
|
43
|
+
const sameAnchor = beforeAnchors === undefined || (beforeAnchors.get(node.id) ?? null) === anchor;
|
|
44
|
+
if (before !== undefined && (original?.x !== node.x || original.y !== node.y || !sameAnchor))
|
|
45
|
+
moved.push(node.id);
|
|
46
|
+
else if (before !== undefined)
|
|
47
|
+
unmoved.push([node.id, node.x, node.y, anchor]);
|
|
48
|
+
}
|
|
49
|
+
const prerequisiteHash = prerequisiteHashOf(after.plan);
|
|
50
|
+
const mutualExclusionHash = exclusionHashOf(after.plan);
|
|
51
|
+
const improved = [];
|
|
52
|
+
const regressed = [];
|
|
53
|
+
if (before !== undefined) {
|
|
54
|
+
const beforeRows = new Map(before.report.scorecard.map((row) => [row.id, row]));
|
|
55
|
+
for (const row of after.report.scorecard) {
|
|
56
|
+
const previous = beforeRows.get(row.id);
|
|
57
|
+
if (previous === undefined ||
|
|
58
|
+
row.status === 'not_evaluated' ||
|
|
59
|
+
previous.status === 'not_evaluated')
|
|
60
|
+
continue;
|
|
61
|
+
const gain = improvement(row.id, previous.value, row.value);
|
|
62
|
+
const noise = Math.max(1e-6, 0.02 * Math.max(Math.abs(previous.value), Math.abs(row.value)));
|
|
63
|
+
if (gain > noise)
|
|
64
|
+
improved.push(row.id);
|
|
65
|
+
else if (gain < -noise)
|
|
66
|
+
regressed.push(row.id);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
verdictBefore: before?.report.verdict ?? null,
|
|
71
|
+
verdictAfter: after.report.verdict,
|
|
72
|
+
scoreBefore: before?.report.score ?? null,
|
|
73
|
+
scoreAfter: after.report.score,
|
|
74
|
+
improved,
|
|
75
|
+
regressed,
|
|
76
|
+
movedFocusCount: moved.length,
|
|
77
|
+
movedFocusIds: moved.slice(0, LISTED_FOCUS_LIMIT),
|
|
78
|
+
unmovedFocusCount: unmoved.length,
|
|
79
|
+
unmovedHash: before === undefined ? '' : hashCanonical(unmoved),
|
|
80
|
+
prerequisiteHash,
|
|
81
|
+
prerequisitesUnchanged: before === undefined ? null : prerequisiteHashOf(before.plan) === prerequisiteHash,
|
|
82
|
+
mutualExclusionHash,
|
|
83
|
+
mutualExclusionsUnchanged: before === undefined ? null : exclusionHashOf(before.plan) === mutualExclusionHash,
|
|
84
|
+
};
|
|
85
|
+
}
|