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.
Files changed (122) hide show
  1. package/CHANGELOG.md +40 -5
  2. package/README.md +32 -13
  3. package/dist/hoi4_agent_tools/core/engine-client.js +342 -0
  4. package/dist/hoi4_agent_tools/core/operation-result.js +33 -5
  5. package/dist/hoi4_agent_tools/core/resident-engine.js +273 -0
  6. package/dist/hoi4_agent_tools/core/temporary-directories.js +3 -2
  7. package/dist/hoi4_agent_tools/decision/service.js +7 -0
  8. package/dist/hoi4_agent_tools/event/service.js +18 -6
  9. package/dist/hoi4_agent_tools/event/summary.js +9 -0
  10. package/dist/hoi4_agent_tools/focus/compact.js +197 -18
  11. package/dist/hoi4_agent_tools/focus/engine-layout.js +201 -0
  12. package/dist/hoi4_agent_tools/focus/game-render.js +72 -0
  13. package/dist/hoi4_agent_tools/focus/game-view-output.js +160 -0
  14. package/dist/hoi4_agent_tools/focus/job-operations.js +3 -1
  15. package/dist/hoi4_agent_tools/focus/layout.js +3 -2
  16. package/dist/hoi4_agent_tools/focus/native-effects.js +4 -4
  17. package/dist/hoi4_agent_tools/focus/quality/branches.js +32 -0
  18. package/dist/hoi4_agent_tools/focus/quality/calibration.js +364 -0
  19. package/dist/hoi4_agent_tools/focus/quality/delta.js +85 -0
  20. package/dist/hoi4_agent_tools/focus/quality/focus-quality-calibration.json +2265 -0
  21. package/dist/hoi4_agent_tools/focus/quality/graph.js +170 -0
  22. package/dist/hoi4_agent_tools/focus/quality/index.js +24 -0
  23. package/dist/hoi4_agent_tools/focus/quality/inline-images.js +132 -0
  24. package/dist/hoi4_agent_tools/focus/quality/metrics.js +424 -0
  25. package/dist/hoi4_agent_tools/focus/quality/orthogonal.js +213 -0
  26. package/dist/hoi4_agent_tools/focus/quality/positions.js +41 -0
  27. package/dist/hoi4_agent_tools/focus/quality/schematic.js +243 -0
  28. package/dist/hoi4_agent_tools/focus/quality/scorecard.js +549 -0
  29. package/dist/hoi4_agent_tools/focus/quality/stored-calibration.js +7 -0
  30. package/dist/hoi4_agent_tools/focus/quality/tool-output.js +113 -0
  31. package/dist/hoi4_agent_tools/focus/quality/types.js +5 -0
  32. package/dist/hoi4_agent_tools/focus/render.js +21 -9
  33. package/dist/hoi4_agent_tools/focus/tool-operations.js +364 -25
  34. package/dist/hoi4_agent_tools/focus/tool-support.js +1 -1
  35. package/dist/hoi4_agent_tools/gui/assets.js +18 -0
  36. package/dist/hoi4_agent_tools/gui/dds.js +38 -5
  37. package/dist/hoi4_agent_tools/gui/engine-textures.js +48 -0
  38. package/dist/hoi4_agent_tools/gui/source-graph.js +7 -0
  39. package/dist/hoi4_agent_tools/gui/tool-operations.js +23 -4
  40. package/dist/hoi4_agent_tools/gui/validators.js +31 -2
  41. package/dist/hoi4_agent_tools/ideas/inspect.js +43 -0
  42. package/dist/hoi4_agent_tools/localisation/inspect.js +34 -0
  43. package/dist/hoi4_agent_tools/mcp/server/argument-errors.js +2 -0
  44. package/dist/hoi4_agent_tools/mcp/server/instructions.js +1 -1
  45. package/dist/hoi4_agent_tools/mcp/tools/event.js +2 -0
  46. package/dist/hoi4_agent_tools/mcp/tools/focus.js +76 -4
  47. package/dist/hoi4_agent_tools/mcp/tools/reference.js +18 -0
  48. package/dist/hoi4_agent_tools/probability/operations.js +27 -1
  49. package/dist/hoi4_agent_tools/probability/service.js +91 -11
  50. package/dist/hoi4_agent_tools/probability/source-analysis.js +2 -2
  51. package/dist/hoi4_agent_tools/probability/sweep.js +20 -6
  52. package/dist/hoi4_agent_tools/reference/command-phrases.json +11065 -0
  53. package/dist/hoi4_agent_tools/reference/error-log.js +24 -0
  54. package/dist/hoi4_agent_tools/reference/game-text.js +109 -0
  55. package/dist/hoi4_agent_tools/reference/known-mistakes.js +8 -5
  56. package/dist/hoi4_agent_tools/reference/known-mistakes.json +4 -4
  57. package/dist/hoi4_agent_tools/reference/operations.js +68 -2
  58. package/dist/hoi4_agent_tools/reference/ranking.js +92 -2
  59. package/dist/hoi4_agent_tools/reference/script-validation.js +46 -6
  60. package/dist/hoi4_agent_tools/reference/service.js +125 -21
  61. package/dist/hoi4_agent_tools/reference/source-lookup.js +8 -0
  62. package/dist/hoi4_agent_tools/schemas/focus-requests.js +68 -7
  63. package/dist/hoi4_agent_tools/schemas/focus.js +121 -6
  64. package/dist/hoi4_agent_tools/schemas/ideas.js +142 -0
  65. package/dist/hoi4_agent_tools/schemas/localisation.js +94 -0
  66. package/dist/hoi4_agent_tools/schemas/mod-tools.js +11 -0
  67. package/dist/hoi4_agent_tools/version.js +1 -1
  68. package/docs/configuration.md +17 -17
  69. package/docs/focus.md +104 -4
  70. package/docs/reference.md +1 -1
  71. package/docs/research/reference-benchmark.md +152 -1
  72. package/docs/setup.md +1 -1
  73. package/docs/tools.md +48 -44
  74. package/docs/troubleshooting.md +13 -12
  75. package/engine/README.md +284 -0
  76. package/engine/bin/darwin-arm64/hoi4-engine +0 -0
  77. package/engine/bin/linux-arm64/hoi4-engine +0 -0
  78. package/engine/bin/linux-x64/hoi4-engine +0 -0
  79. package/engine/bin/manifest.json +26 -0
  80. package/engine/bin/win32-x64/hoi4-engine.exe +0 -0
  81. package/npm-shrinkwrap.json +2 -2
  82. package/package.json +5 -1
  83. package/schemas/configuration.schema.json +1 -1
  84. package/schemas/continuous-focus-palette.schema.json +1 -1
  85. package/schemas/custom-weighted-pool.schema.json +1 -1
  86. package/schemas/decision-inspect-input.schema.json +1 -1
  87. package/schemas/error-log-input.schema.json +1 -1
  88. package/schemas/event-feature-manifest.schema.json +1 -1
  89. package/schemas/focus-plan.schema.json +146 -120
  90. package/schemas/focus-planning-sidecar.schema.json +15 -7
  91. package/schemas/geography-model.schema.json +1 -1
  92. package/schemas/gui-animation-source.schema.json +1 -1
  93. package/schemas/gui-helper.schema.json +1 -1
  94. package/schemas/gui-scenario.schema.json +1 -1
  95. package/schemas/helper-expansion-request.schema.json +1 -1
  96. package/schemas/helper-expansion-summary.schema.json +1 -1
  97. package/schemas/impact-inspect-input.schema.json +1 -1
  98. package/schemas/map-operation.schema.json +1 -1
  99. package/schemas/mechanic-test-input.schema.json +1 -1
  100. package/schemas/mod-index-input.schema.json +1 -1
  101. package/schemas/operation-result.schema.json +1 -1
  102. package/schemas/package-check-input.schema.json +1 -1
  103. package/schemas/package-manifest.schema.json +1 -1
  104. package/schemas/probability-analysis-result.schema.json +1 -1
  105. package/schemas/probability-compare-input.schema.json +1 -1
  106. package/schemas/probability-evaluate-input.schema.json +1 -1
  107. package/schemas/probability-inspect-input.schema.json +1 -1
  108. package/schemas/probability-render-input.schema.json +1 -1
  109. package/schemas/probability-scenario-set.schema.json +1 -1
  110. package/schemas/probability-sequence-input.schema.json +1 -1
  111. package/schemas/probability-simulate-input.schema.json +1 -1
  112. package/schemas/probability-sweep-input.schema.json +1 -1
  113. package/schemas/reference-context-input.schema.json +1 -1
  114. package/schemas/reference-read-input.schema.json +1 -1
  115. package/schemas/reference-search-input.schema.json +1 -1
  116. package/schemas/reference-sheets.schema.json +1 -1
  117. package/schemas/scenario-suite.schema.json +1 -1
  118. package/schemas/scenario-test-input.schema.json +1 -1
  119. package/schemas/script-validate-input.schema.json +1 -1
  120. package/schemas/shared-scenario.schema.json +1 -1
  121. package/schemas/source-lookup-input.schema.json +1 -1
  122. 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
+ }