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.
Files changed (101) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +32 -13
  3. package/dist/hoi4_agent_tools/core/engine-client.js +74 -5
  4. package/dist/hoi4_agent_tools/core/operation-result.js +9 -0
  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/engine-layout.js +1 -1
  11. package/dist/hoi4_agent_tools/focus/game-render.js +72 -0
  12. package/dist/hoi4_agent_tools/focus/game-view-output.js +160 -0
  13. package/dist/hoi4_agent_tools/focus/native-effects.js +4 -4
  14. package/dist/hoi4_agent_tools/focus/quality/focus-quality-calibration.json +241 -241
  15. package/dist/hoi4_agent_tools/focus/quality/orthogonal.js +30 -19
  16. package/dist/hoi4_agent_tools/focus/quality/schematic.js +5 -3
  17. package/dist/hoi4_agent_tools/focus/quality/scorecard.js +1 -1
  18. package/dist/hoi4_agent_tools/focus/render.js +21 -9
  19. package/dist/hoi4_agent_tools/focus/tool-operations.js +158 -3
  20. package/dist/hoi4_agent_tools/gui/assets.js +18 -0
  21. package/dist/hoi4_agent_tools/gui/dds.js +38 -5
  22. package/dist/hoi4_agent_tools/gui/engine-textures.js +48 -0
  23. package/dist/hoi4_agent_tools/gui/source-graph.js +7 -0
  24. package/dist/hoi4_agent_tools/gui/tool-operations.js +23 -4
  25. package/dist/hoi4_agent_tools/gui/validators.js +31 -2
  26. package/dist/hoi4_agent_tools/ideas/inspect.js +43 -0
  27. package/dist/hoi4_agent_tools/localisation/inspect.js +34 -0
  28. package/dist/hoi4_agent_tools/mcp/server/argument-errors.js +2 -0
  29. package/dist/hoi4_agent_tools/mcp/tools/event.js +2 -0
  30. package/dist/hoi4_agent_tools/mcp/tools/focus.js +1 -1
  31. package/dist/hoi4_agent_tools/mcp/tools/reference.js +18 -0
  32. package/dist/hoi4_agent_tools/probability/operations.js +27 -1
  33. package/dist/hoi4_agent_tools/probability/service.js +91 -11
  34. package/dist/hoi4_agent_tools/probability/source-analysis.js +2 -2
  35. package/dist/hoi4_agent_tools/probability/sweep.js +20 -6
  36. package/dist/hoi4_agent_tools/reference/command-phrases.json +11065 -0
  37. package/dist/hoi4_agent_tools/reference/error-log.js +24 -0
  38. package/dist/hoi4_agent_tools/reference/known-mistakes.js +8 -5
  39. package/dist/hoi4_agent_tools/reference/known-mistakes.json +4 -4
  40. package/dist/hoi4_agent_tools/reference/operations.js +68 -2
  41. package/dist/hoi4_agent_tools/reference/ranking.js +32 -0
  42. package/dist/hoi4_agent_tools/reference/script-validation.js +46 -6
  43. package/dist/hoi4_agent_tools/reference/service.js +33 -0
  44. package/dist/hoi4_agent_tools/reference/source-lookup.js +8 -0
  45. package/dist/hoi4_agent_tools/schemas/focus-requests.js +4 -0
  46. package/dist/hoi4_agent_tools/schemas/ideas.js +142 -0
  47. package/dist/hoi4_agent_tools/schemas/localisation.js +94 -0
  48. package/dist/hoi4_agent_tools/schemas/mod-tools.js +11 -0
  49. package/dist/hoi4_agent_tools/version.js +1 -1
  50. package/docs/focus.md +9 -5
  51. package/docs/research/reference-benchmark.md +41 -0
  52. package/docs/tools.md +43 -39
  53. package/docs/troubleshooting.md +13 -12
  54. package/engine/README.md +284 -0
  55. package/engine/bin/darwin-arm64/hoi4-engine +0 -0
  56. package/engine/bin/linux-arm64/hoi4-engine +0 -0
  57. package/engine/bin/linux-x64/hoi4-engine +0 -0
  58. package/engine/bin/manifest.json +26 -0
  59. package/engine/bin/win32-x64/hoi4-engine.exe +0 -0
  60. package/npm-shrinkwrap.json +2 -2
  61. package/package.json +4 -1
  62. package/schemas/configuration.schema.json +1 -1
  63. package/schemas/continuous-focus-palette.schema.json +1 -1
  64. package/schemas/custom-weighted-pool.schema.json +1 -1
  65. package/schemas/decision-inspect-input.schema.json +1 -1
  66. package/schemas/error-log-input.schema.json +1 -1
  67. package/schemas/event-feature-manifest.schema.json +1 -1
  68. package/schemas/focus-plan.schema.json +1 -1
  69. package/schemas/focus-planning-sidecar.schema.json +1 -1
  70. package/schemas/geography-model.schema.json +1 -1
  71. package/schemas/gui-animation-source.schema.json +1 -1
  72. package/schemas/gui-helper.schema.json +1 -1
  73. package/schemas/gui-scenario.schema.json +1 -1
  74. package/schemas/helper-expansion-request.schema.json +1 -1
  75. package/schemas/helper-expansion-summary.schema.json +1 -1
  76. package/schemas/impact-inspect-input.schema.json +1 -1
  77. package/schemas/map-operation.schema.json +1 -1
  78. package/schemas/mechanic-test-input.schema.json +1 -1
  79. package/schemas/mod-index-input.schema.json +1 -1
  80. package/schemas/operation-result.schema.json +1 -1
  81. package/schemas/package-check-input.schema.json +1 -1
  82. package/schemas/package-manifest.schema.json +1 -1
  83. package/schemas/probability-analysis-result.schema.json +1 -1
  84. package/schemas/probability-compare-input.schema.json +1 -1
  85. package/schemas/probability-evaluate-input.schema.json +1 -1
  86. package/schemas/probability-inspect-input.schema.json +1 -1
  87. package/schemas/probability-render-input.schema.json +1 -1
  88. package/schemas/probability-scenario-set.schema.json +1 -1
  89. package/schemas/probability-sequence-input.schema.json +1 -1
  90. package/schemas/probability-simulate-input.schema.json +1 -1
  91. package/schemas/probability-sweep-input.schema.json +1 -1
  92. package/schemas/reference-context-input.schema.json +1 -1
  93. package/schemas/reference-read-input.schema.json +1 -1
  94. package/schemas/reference-search-input.schema.json +1 -1
  95. package/schemas/reference-sheets.schema.json +1 -1
  96. package/schemas/scenario-suite.schema.json +1 -1
  97. package/schemas/scenario-test-input.schema.json +1 -1
  98. package/schemas/script-validate-input.schema.json +1 -1
  99. package/schemas/shared-scenario.schema.json +1 -1
  100. package/schemas/source-lookup-input.schema.json +1 -1
  101. package/server.json +2 -2
@@ -0,0 +1,284 @@
1
+ # HOI4 engine
2
+
3
+ A Rust workspace with the one shared Hearts of Iron IV engine for hoi4-agent-tools, the Agentic
4
+ HOI4 Modding Kit, Chaos Redux and HOI4 Factory (ADR 0074). It reads a mod with the game and its
5
+ dependencies in load order, and reports what the game would reject or silently lose.
6
+
7
+ | Crate | What it does |
8
+ | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
9
+ | `hoi4-syntax` | Lossless Clausewitz parser (`.txt`, `.gui`, `.gfx`, `.asset`, `descriptor.mod`) and localisation reader (`.yml`). Every byte belongs to one token, every node has a byte span, and the tree rebuilds the input byte for byte. UTF-8, UTF-8 with a byte order mark and Windows-1252 |
10
+ | `hoi4-engine` | Layers and load order, symbol index, reference closure, lints, override audit, findings baseline, finding delta and hash-guarded repair plans |
11
+ | `hoi4-drawio` | Imports a draw.io sketch of a focus tree into focus ids, grid positions and prerequisite links |
12
+ | `hoi4-focus-layout` | Lays out focus trees and inserts branches on the focus grid with an in-game connector model ([README](crates/focus/README.md)) |
13
+ | `hoi4-texture` | Decodes the textures the game draws: DDS (legacy RGB and luminance masks, DXT1 to DXT5, ATI1, ATI2, RXGB, and the DX10 header with 8-bit and packed formats, BC1 to BC5 and BC7), TGA and PNG, to RGBA, and encodes PNG. Synthetic fixtures with reference decodes in `crates/texture/tests/fixtures` |
14
+ | `hoi4-preview` | Game-like previews drawn from the game's own sprites, textures, bitmap fonts and `.gui` layouts in load order. The national focus view: plaques by state, icons, titles, connector tiles and exclusive marks, with geometry from `nationalfocusview.gui` checked against in-game screenshots. Caches parsed `.gfx` files, folder listings, textures and fonts per workspace and refreshes only what changed |
15
+ | `hoi4-engine-cli` | The `hoi4-engine` command |
16
+
17
+ ## Build
18
+
19
+ ```sh
20
+ cd engine
21
+ cargo build --release -p hoi4-engine-cli
22
+ ```
23
+
24
+ The binary is `target/release/hoi4-engine` (`.exe` on Windows). Rust is pinned by
25
+ `rust-toolchain.toml`. The workspace has six dependencies: `serde`, `serde_json`, `sha2`,
26
+ `rayon`, `roxmltree` and `png`.
27
+
28
+ ## Commands
29
+
30
+ ```sh
31
+ hoi4-engine check --game "<game>" --mod "<mod>" [--dependency "<mod>"]... [--baseline baseline.json] [--fail-on error|warning|never] [--format text|json] [--all]
32
+ hoi4-engine baseline init --game "<game>" --mod "<mod>" --baseline baseline.json
33
+ hoi4-engine baseline update --game "<game>" --mod "<mod>" --baseline baseline.json
34
+ hoi4-engine roundtrip <folder>...
35
+ hoi4-engine delta before.json after.json
36
+ hoi4-engine vocab --game "<game>"
37
+ hoi4-engine sprites --game "<game>" [--mod "<mod>"] [--allowlist sprites-allow.json] [--all-layers] [--index] [--format text|json] [--fail-on error|warning|never]
38
+ hoi4-engine drawio sketch.drawio --prefix GER
39
+ hoi4-engine focus-layout --request request.json
40
+ hoi4-engine localisation --request request.json
41
+ hoi4-engine ideas --request request.json
42
+ hoi4-engine texture <file or folder>... [--format text|json] [--output out.png]
43
+ hoi4-engine focus-render [--game DIR] [--mod DIR] [--dependency DIR]... --output out.png [--request FILE]
44
+ hoi4-engine serve
45
+ ```
46
+
47
+ `focus-layout` reads one JSON request (`hoi4-focus-layout-request/1`) from `--request` or stdin and
48
+ writes the layout (`hoi4-focus-layout/1`) to stdout; see [the crate README](crates/focus/README.md).
49
+
50
+ `localisation` reads one JSON request from `--request` or stdin, with `game`, `mod`,
51
+ `dependencies`, `includeDlc`, `mode` (`key`, `audit` or `coverage`), `key`, `language` and `limit`,
52
+ and writes its answer to stdout. It backs `hoi4.localisation_inspect`; see `crates/engine/src/localisation.rs`.
53
+
54
+ `ideas` reads one JSON request with `game`, `mod`, `dependencies`, `includeDlc`, `kind` (`idea` or `character`), `id` or `audit`, and `limit`. It backs `hoi4.idea_inspect`; see `crates/engine/src/ideas.rs`.
55
+
56
+ `--game` defaults to the `HOI4_GAME_DIR` environment variable. Without `--mod` the game itself is
57
+ checked. `--dependency` adds a mod loaded before the checked one; repeat it in load order.
58
+
59
+ Exit codes: `0` when no new finding reaches `--fail-on` (default `warning`), `1` when one does,
60
+ `2` for a usage or input error.
61
+
62
+ ### Verdicts
63
+
64
+ - `fail`: a new finding at or above `--fail-on`.
65
+ - `incomplete`: nothing fails, but something could not be checked: no game folder, names built at
66
+ run time (`$PARAM$`, `@x`, `[?var]`), or script folders without a context model. They are listed
67
+ in `coverage`. Unknown is never reported as a pass.
68
+ - `pass`: everything was checked and nothing fails.
69
+
70
+ ### Calling it from `check.py`
71
+
72
+ ```python
73
+ result = subprocess.run(
74
+ [engine, "check", "--game", game, "--mod", mod_root, "--baseline", baseline, "--format", "json"],
75
+ capture_output=True, text=True, encoding="utf-8",
76
+ )
77
+ report = json.loads(result.stdout) # exit code 1 means new findings, 2 a usage error
78
+ ```
79
+
80
+ The report (`schema: hoi4-engine-report/1`) has `verdict`, `summary` (counts by severity and
81
+ code), `baseline` (entries, still present, new, fixed), `coverage` (references by kind with
82
+ resolved, unresolved and unknown counts, including kinds with none; effect and trigger commands;
83
+ folders without a model), `overrides` (each replaced file and the layer that wins) and
84
+ `findings`. Each finding has `code`, `severity`, `message`, `path`, `layer`, `line`, `column`,
85
+ byte `start` and `end`, `subject`, `context` (such as `event:my.1`), `suggestion`, `fingerprint`
86
+ and `status` (`new` or `baselined`). `--repair-plans` adds a hash-guarded replacement plan to
87
+ findings that have a suggestion; the command never edits files.
88
+
89
+ ### Baseline
90
+
91
+ `baseline init` records the current warnings and errors by fingerprint. A fingerprint is the
92
+ code, path, enclosing definition, subject and ordinal, not the line, so moving code does not make
93
+ an old finding new. `check --baseline` fails only on findings the baseline does not cover and
94
+ shows how many entries are fixed. `baseline update` removes fixed entries and never adds any.
95
+
96
+ ## Checks
97
+
98
+ The documented vocabulary is read from the installed game's `documentation/effects_documentation.md`,
99
+ `triggers_documentation.md` and `modifiers_documentation.md` at run time (templated modifiers such
100
+ as `<Ideology>_drift` are expanded from their "Modified types" lists). Nothing from the game is
101
+ stored in this repository.
102
+
103
+ | Code | Severity | Meaning |
104
+ | ------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
105
+ | `REF_UNKNOWN_EFFECT`, `REF_UNKNOWN_TRIGGER` | error | A command that is neither documented, nor control flow, nor a scope, nor a scripted effect or trigger defined in a loaded file. The game reports these as "Unknown effect-type" and "Unknown trigger-type" |
106
+ | `REF_MISSING_<KIND>` | error | A reference to an event, focus, idea, decision, character, sprite, localisation key, country tag, opinion or dynamic modifier, technology and other kinds that no loaded file defines |
107
+ | `REF_CASE_MISMATCH` | warning | The name is defined only with other letter case |
108
+ | `LINT_MUTUALLY_EXCLUSIVE_NOT_RECIPROCAL` | warning | Focus A excludes B but B does not exclude A |
109
+ | `LINT_EVENT_NAMESPACE_COLLISION` | warning | The mod declares a namespace the game declares in another file |
110
+ | `LINT_INERT_MTTH` | warning | A triggered-only event has a `mean_time_to_happen` that never runs |
111
+ | `LINT_EVENT_LOC_KEY_REUSED` | warning | One event shows the same localisation key for two texts |
112
+ | `LINT_UNKNOWN_MODIFIER` | warning | A modifier block uses a name the game does not document or derive |
113
+ | `LINT_FLAG_NEVER_SET` | warning | A flag is checked but nothing sets it, so the check is always false |
114
+ | `LINT_FLAG_NEVER_CHECKED` | info | A flag is set but nothing checks it |
115
+ | `LINT_UNKNOWN_DLC` | error | `has_dlc` names no DLC the game knows |
116
+ | `LINT_DUPLICATE_DEFINITION` | error | The mod defines the same event, scripted effect or trigger, focus, idea, decision, character or technology twice. The same localisation key twice in one language is a warning, and the same sprite twice is information; the later one wins |
117
+ | `LINT_DUPLICATE_ACROSS_LAYERS` | error | A dependency or the game defines the same event id in a file the mod does not replace, so both load and the ids collide. Other kinds are a warning |
118
+ | `OVERRIDE_DROPS_DEFINITION` | warning | A same-path copy of a game file lacks a definition the original had, and nothing else defines it |
119
+ | `OVERRIDE_DROPS_ON_ACTION_HOOK` | warning | A copied `on_actions` file no longer hooks an event or effect the original hooked |
120
+ | `OVERRIDE_BREAKS_REFERENCE` | error | A file that still loads calls a scripted effect or trigger whose only definition the mod unloaded |
121
+ | `OVERRIDE_CASE_ONLY_SHADOW` | warning | The override differs from the replaced path only in letter case, so it replaces it on Windows only |
122
+ | `OVERRIDE_REPLACE_PATH_EMPTY` | error | `replace_path` unloads a folder and the mod puts nothing there |
123
+ | `OVERRIDE_REPLACE_PATH_DROPS` | info | How many definitions a `replace_path` unloads that nothing else provides |
124
+ | `OVERRIDE_REPLACES_FILE` | info | The file replaces a game or dependency file entirely |
125
+ | `SYNTAX_*` | error | Unclosed block, stray `}`, missing value, stray operator, unterminated string, nesting deeper than 256 |
126
+ | `LOC_*` | warning | Missing byte order mark or language header, several headers, malformed lines |
127
+
128
+ `replace_path` unloads only files directly in the named folder, not its subfolders, as the
129
+ offline wiki's Modding page states.
130
+
131
+ ### Folders with a context model
132
+
133
+ Effects, triggers and references are checked in `events/`, `common/scripted_effects/`,
134
+ `common/scripted_triggers/`, `common/decisions/` (and `categories/`), `common/national_focus/`,
135
+ `common/continuous_focus/`, `common/ideas/`, `common/on_actions/`, `common/characters/`,
136
+ `common/dynamic_modifiers/`, `common/scripted_localisation/` and `common/scripted_guis/`. Other
137
+ script folders are listed under `coverage.unmodelled_script_folders` and keep the verdict at
138
+ `incomplete`. Definitions are indexed from more folders (technologies, country tags and aliases,
139
+ states, ideologies, traits, opinion and static modifiers, units, equipment, buildings, terrain,
140
+ resources, combat tactics, sprites and localisation).
141
+
142
+ ## Sprites
143
+
144
+ `hoi4-engine sprites` (library: `hoi4_engine::sprites`, `sprite_trace`, `sprite_audit`) is the one
145
+ implementation of the sprite index and the content-to-sprite trace. HOI4 Factory's image tools and
146
+ the planned GFX validation call it instead of keeping their own copies. The crates are
147
+ `publish = false` and build standalone, so another workspace can depend on them from Git:
148
+
149
+ ```toml
150
+ hoi4-engine = { git = "https://github.com/klimPaskov/hoi4-agent-tools", package = "hoi4-engine" }
151
+ ```
152
+
153
+ ```rust
154
+ use hoi4_engine::sprite_audit::{Allowlist, SpriteReport};
155
+ use hoi4_engine::sprite_trace::TraceOptions;
156
+ use hoi4_engine::{Workspace, WorkspaceOptions};
157
+
158
+ let ws = Workspace::load(&WorkspaceOptions { game: Some(game), target: Some(mod_dir), include_dlc: true, ..Default::default() });
159
+ let (index, report) = SpriteReport::run(&ws, &Allowlist::default(), &TraceOptions::default());
160
+ let sprite = index.get("GFX_goal_unknown"); // by name, without case
161
+ let sharing = index.by_texture("gfx/interface/goals/x.dds"); // by texture path
162
+ for u in &report.uses { println!("{} {:?} {}:{}", u.sprite, u.family, u.path, u.line); }
163
+ ```
164
+
165
+ API summary:
166
+
167
+ - `SpriteIndex::build(&Workspace)`, `get(name)`, `definitions_of(name)`, `effective()`,
168
+ `by_texture(path)`, `texture(path)` (resolves any texture path), `texture_of(&SpriteDef)`.
169
+ `SpriteDef` has `name`, `kind` and `block_type`, `texturefile`, `frames`, `effect_file`,
170
+ `legacy_lazy_load`, `load_type`, `animation_blocks`, the defining `layer`/`path`/`line` and
171
+ `effective` (the last loaded definition of a name wins). `ResolvedTexture` has `exists`, the
172
+ supplying `layer` and a `TextureHeader` (DDS size, mip count, fourcc or DXGI format, TGA bits and
173
+ origin, PNG; headers only, no pixels are decoded).
174
+ - `sprite_trace::trace(&Workspace, &SpriteIndex, &TraceOptions)` returns `SpriteUse` values: sprite
175
+ name, resolved texture, `content_type`, `family` (`Family`, serialised as the id string), file,
176
+ line, column and the enclosing definition. `Family::ALL` lists the 41 ids.
177
+ - `sprite_audit::audit` and `SpriteReport::run` return findings and a summary.
178
+
179
+ A texture path is looked up in the layers from last to first without regard to case; a layer's file
180
+ is skipped when a later layer's `replace_path` unloads its folder. By default only the checked
181
+ layer's files are traced (the mod, or the game without `--mod`); `--all-layers` traces everything
182
+ loaded. `--index` adds every sprite definition to the JSON.
183
+
184
+ ### Content to family rules
185
+
186
+ Each rule was checked against Hearts of Iron IV 1.19.4.1. The example is a vanilla `file:line`.
187
+
188
+ | Content key | Family | Prefix rule | Vanilla example |
189
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------- |
190
+ | focus `icon` (scalar, or conditional block `GFX_x = { trigger }`, `GFX_y = yes`) | `focus` | none; every name in a conditional block is a use | `common/national_focus/TSR_lingguang_incident_joint_branch.txt:4`; conditional `afghanistan.txt:335` |
191
+ | continuous focus `icon` | `focus` | none | `common/continuous_focus/generic.txt:16` |
192
+ | idea `picture = x` | by slot, below | `GFX_idea_<x>` unless `x` starts with `GFX_`; no picture means `GFX_idea_<idea key>` (implicit, only when defined) | `common/ideas/GER.txt:46` (`can_wartime_prices_and_trade_board`), `GER.txt:4` (explicit) |
193
+ | ideas in `country`, laws and other slots | `idea_spirit` | as above | `common/ideas/GER.txt:4` |
194
+ | `industrial_concern`, `*_manufacturer` slots | `idea_concern` | as above | `common/ideas/CSA.txt:8`, `GER.txt:4389` |
195
+ | `political_advisor`, `theorist`, `army_chief`, `navy_chief`, `air_chief`, `high_command` slots (and `character_slot` names from loaded `idea_tags`) | `advisor_card` | as above | `common/ideas/andalusia.txt:9` |
196
+ | `academy_spirit`, `army_spirit`, `division_command_spirit`, navy and air equivalents (slots of `type = army_spirit`, `navy_spirit`, `air_spirit` categories) | `officer_corps_spirit` | as above | `common/ideas/air_spirits.txt:3`, `army_spirits.txt:846` |
197
+ | character `portraits = { civilian = { large } }` | `leader_portrait` (`operative_portrait` for operatives, `scientist_portrait` for scientists without a country leader role) | none; a texture path is also allowed | `common/characters/ABK.txt:6`, scientist `JAP.txt:1881` |
198
+ | character `portraits = { army or navy = { large } }` | `commander_portrait` | none | `common/characters/AFG.txt:93`, navy `CRO.txt:116` |
199
+ | character `portraits = { any = { small } }` | `advisor_card` | none | `common/characters/AFA.txt:9` |
200
+ | advisor `idea_token` | `advisor_card` | `GFX_idea_<token>` only when the character has no `small` portrait and the sprite is defined (implicit) | `common/characters/GER.txt` advisors |
201
+ | decision `icon` (missions have `days_mission_timeout`; same family) | `decision` | `GFX_decision_<x>` unless `GFX_` | `common/decisions/ARG.txt:764` (`oil`), mission `ARG.txt:1026`, explicit `AFG.txt:5` |
202
+ | decision category `icon` | `decision_category_icon` | `GFX_decision_category_<x>` unless `GFX_` | `common/decisions/categories/00_decision_categories.txt:16` |
203
+ | decision category `picture` | `decision_category_picture` | `GFX_decision_cat_picture_<x>`, then `GFX_<x>`; `GFX_` as written | `00_decision_categories.txt:23`, unprefixed `CHI_decision_categories.txt:166` |
204
+ | dynamic modifier `icon` | `state_modifier` | none | `common/dynamic_modifiers/0_dynamic_modifiers.txt:36` |
205
+ | MIO organization `icon`; `set_mio_icon` | `mio_department` | none | `.../organizations/00_generic_organization.txt:15`, `common/decisions/FRA.txt:1381` |
206
+ | MIO `add_trait`, `override_trait`, `initial_trait`, `trait` `icon` | `mio_trait`; `mio_department` when the sprite name contains `mio_department` | none | `00_generic_organization.txt:140`, department `:198` |
207
+ | MIO policy `icon` | `mio_policy` | none | `.../policies/_air_policies.txt:2` |
208
+ | balance of power `side = { icon }`; `set_power_balance_gfx = { gfx }` | `bop_side` | none (`[...]` names are dynamic and not resolved) | `common/bop/BRA.txt:27`, `CZE.txt:143` |
209
+ | special project `icon` | `special_project_icon` | none | `common/special_projects/projects/air_projects.txt:11` |
210
+ | operation `icon`, `map_icon`; phase `icon`; token `icon` | `operation_icon` | none | `common/operations/00_operations.txt:7`, `:8` |
211
+ | operation phase `picture` | `operation_picture` | none | `common/operation_phases/00_operation_phases.txt:5` |
212
+ | intelligence agency upgrade `picture` | `agency_upgrade` | none | `common/intelligence_agency_upgrades/intelligence_agency_upgrades.txt:8` |
213
+ | intelligence agency `picture` | `agency_logo` | none | `common/intelligence_agencies/00_intelligence_agencies.txt:7` |
214
+ | raid `target_icon`, `custom_map_icon` | `raid` | none | `common/raids/air_raids.txt:67`, `:69` |
215
+ | unit medal `icon` | `medal` | none | `common/unit_medals/00_default.txt:41` |
216
+ | faction `icon` | `faction_logo` | none | `common/factions/member_upgrades/member_groups/member_upgrade_groups.txt:16` |
217
+ | doctrine `icon` | `doctrine` | none | `common/doctrines/grand_doctrines/air_grand_doctrines.txt:6` |
218
+ | technology `icon`; otherwise the tech key | `technology` | `GFX_<tech key>_medium` (implicit, only when defined) | `common/technologies/MTG_naval.txt:10` |
219
+ | scientist trait `icon` | `personal_trait` | none | `common/scientist_traits/00_traits.txt:27` |
220
+ | event `picture` | `report_event`, or `news_event` for `news_event` blocks | none | `events/AAT_Denmark.txt:22`, news `AAT_NewsEvents.txt:15` |
221
+ | `create_country_leader` `picture`; `create_corps_commander`, `create_field_marshal`, `create_navy_leader` `portrait_path` | `leader_portrait`, `commander_portrait` | none | `common/decisions/ENG.txt:3201`, `common/national_focus/portugal.txt:4367` |
222
+ | `technology_sharing` `picture`, `occupation_laws` `icon`, `abilities` `icon` | `unknown` | none | `common/abilities/CHI_abilities.txt:5` |
223
+
224
+ Texture sizes on the installed game back the split: focus icons 100x88 (52%), decision icons
225
+ 33x32 (69%), report events 210x176 (87%), news events 397x153 (91%), leader and commander portraits
226
+ 156x210, advisor cards 65x67, idea spirits 60x68, concerns 64x64, officer corps spirits mostly 45x45.
227
+ Two caveats: an MIO organization icon is idea-sized (64x64) while department and trait icons are
228
+ 48x48, and the engine-bound families (flags, counters, buildings, achievements, GUI textures,
229
+ super events, modifier stat icons, division emblems, commander traits) have no script slot, so the
230
+ trace never produces them. Many vanilla characters name `GFX_portrait_*` sprites that no file
231
+ defines; they are reported as `GFX-SPRITE-UNDEFINED`.
232
+
233
+ The implicit fallbacks (`GFX_idea_<idea key>`, `GFX_<key>_medium`, `GFX_idea_<idea_token>`) are
234
+ reported only when the sprite is defined, so a missing fallback is never a finding.
235
+
236
+ ### Sprite findings
237
+
238
+ | Code | Severity | Meaning |
239
+ | ------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------- |
240
+ | `GFX-FAMILY-REUSE` | warning | A sprite name, or a resolved texture reached through two or more sprites, is used by two or more families. The message lists every use |
241
+ | `GFX-TEXTURE-MISSING` | warning | A sprite's `texturefile` (or a texture path a script names) resolves to no file in any layer |
242
+ | `GFX-SPRITE-UNDEFINED` | warning | A script names a sprite that no loaded `.gfx` file defines |
243
+ | `GFX-FOCUS-SHINE-MISSING` | error | A focus sprite has no `<name>_shine` sprite; the game then draws a ? instead of the icon (seen in game on 1.19.4.1) |
244
+
245
+ `--allowlist file.json` records intentional aliases:
246
+
247
+ ```json
248
+ {
249
+ "aliases": [
250
+ {
251
+ "sprite": "GFX_idea_shared",
252
+ "families": ["idea_spirit", "decision"],
253
+ "reason": "same art on purpose"
254
+ },
255
+ { "texture": "gfx/interface/shared.dds" }
256
+ ],
257
+ "no_shine": ["GFX_goal_special"],
258
+ "missing_textures": ["GFX_placeholder"]
259
+ }
260
+ ```
261
+
262
+ An alias without `families` covers any combination; with `families` it covers reuse only when every
263
+ family involved is listed. Unknown family ids are an error (exit code 2).
264
+
265
+ ## Tests
266
+
267
+ ```sh
268
+ cd engine
269
+ cargo test --no-fail-fast
270
+ cargo clippy --all-targets -- -D warnings
271
+ cargo fmt --all -- --check
272
+ ```
273
+
274
+ `crates/engine/tests/rules.rs` has an invalid and a valid fixture for every rule, the Chaos Redux
275
+ B001 classes (an unknown scripted trigger and an undefined effect) and a copied `00_on_actions.txt`
276
+ that drops hooks. They run against the synthetic game in `fixtures/game`. Measurements on the
277
+ installed game and on public mods are in `docs/research/engine-w4-evidence.md`.
278
+
279
+ ## Limits
280
+
281
+ - Scopes are not checked: a country effect used in a state scope is not reported.
282
+ - Arguments of documented commands are not type-checked, apart from the references listed above.
283
+ - Variables, event targets and other names built at run time are counted as unknown.
284
+ - Sprites inside zipped DLC archives are not read.
Binary file
@@ -0,0 +1,26 @@
1
+ {
2
+ "schema": "hoi4-engine-bundle/1",
3
+ "engineVersion": "0.1.0",
4
+ "binaries": {
5
+ "darwin-arm64": {
6
+ "file": "darwin-arm64/hoi4-engine",
7
+ "sha256": "a4f149373732c99e3cedf879a8364e8d4e4072f448841d28d1a7cd11f1e7fc7f",
8
+ "size": 3775040
9
+ },
10
+ "linux-arm64": {
11
+ "file": "linux-arm64/hoi4-engine",
12
+ "sha256": "d892fb924b864fa902668a76d9bf4005454ca760415213aab7fc902ef3770636",
13
+ "size": 4054824
14
+ },
15
+ "linux-x64": {
16
+ "file": "linux-x64/hoi4-engine",
17
+ "sha256": "a71b2c673ee007a28512ef84cede4714681faa023d025e776445a4101267e8dd",
18
+ "size": 4397064
19
+ },
20
+ "win32-x64": {
21
+ "file": "win32-x64/hoi4-engine.exe",
22
+ "sha256": "e9171a5664629e71bb7a49a35b3e13f098de5cf5ecd685820fdd3dcb2f6dddc5",
23
+ "size": 3631616
24
+ }
25
+ }
26
+ }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "hoi4-agent-tools",
3
- "version": "4.7.0",
3
+ "version": "4.8.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "hoi4-agent-tools",
9
- "version": "4.7.0",
9
+ "version": "4.8.0",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "@fontsource-variable/roboto": "5.3.0",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hoi4-agent-tools",
3
3
  "mcpName": "io.github.klimPaskov/hoi4-agent-tools",
4
- "version": "4.7.0",
4
+ "version": "4.8.0",
5
5
  "description": "Build HOI4 mods: focus trees, events, decisions, worlds, GUI previews, docs and AI balance.",
6
6
  "type": "module",
7
7
  "license": "Apache-2.0",
@@ -38,6 +38,7 @@
38
38
  },
39
39
  "files": [
40
40
  "dist/",
41
+ "engine/bin/",
41
42
  "docs/README.md",
42
43
  "docs/setup.md",
43
44
  "docs/troubleshooting.md",
@@ -92,6 +93,7 @@
92
93
  "test:coverage": "vitest run --coverage",
93
94
  "benchmark": "node --expose-gc --import tsx scripts/benchmark.ts",
94
95
  "benchmark:cold": "tsx scripts/benchmark-cold-paths.ts",
96
+ "bench": "tsx scripts/bench/cli.ts",
95
97
  "docs:examples": "tsx scripts/generate-readme-examples.ts",
96
98
  "docs:comparison-examples": "tsx scripts/generate-real-visual-comparisons.ts",
97
99
  "fixtures:generate": "npm run fixtures:generate:focus && npm run fixtures:generate:gui && npm run fixtures:generate:map && npm run fixtures:generate:event && npm run fixtures:generate:technology && npm run fixtures:generate:probability",
@@ -108,6 +110,7 @@
108
110
  "registry:validate": "tsx scripts/validate-registry.ts",
109
111
  "publication:verify": "tsx scripts/verify-publication.ts",
110
112
  "publication:install": "tsx scripts/verify-public-install.ts",
113
+ "engine:bundle": "tsx scripts/bundle-engine.ts",
111
114
  "release:artifact:verify": "tsx scripts/verify-release-artifact.ts",
112
115
  "release:order:verify": "tsx scripts/verify-npm-release-order.ts",
113
116
  "pack:check": "tsx scripts/check-package.ts",
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.7.0/schemas/configuration.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.8.0/schemas/configuration.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.7.0/schemas/continuous-focus-palette.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.8.0/schemas/continuous-focus-palette.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.7.0/schemas/custom-weighted-pool.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.8.0/schemas/custom-weighted-pool.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.7.0/schemas/decision-inspect-input.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.8.0/schemas/decision-inspect-input.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.7.0/schemas/error-log-input.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.8.0/schemas/error-log-input.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.7.0/schemas/event-feature-manifest.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.8.0/schemas/event-feature-manifest.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.7.0/schemas/focus-plan.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.8.0/schemas/focus-plan.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.7.0/schemas/focus-planning-sidecar.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.8.0/schemas/focus-planning-sidecar.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.7.0/schemas/geography-model.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.8.0/schemas/geography-model.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.7.0/schemas/gui-animation-source.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.8.0/schemas/gui-animation-source.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.7.0/schemas/gui-helper.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.8.0/schemas/gui-helper.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.7.0/schemas/gui-scenario.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.8.0/schemas/gui-scenario.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.7.0/schemas/helper-expansion-request.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.8.0/schemas/helper-expansion-request.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.7.0/schemas/helper-expansion-summary.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.8.0/schemas/helper-expansion-summary.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.7.0/schemas/impact-inspect-input.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.8.0/schemas/impact-inspect-input.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.7.0/schemas/map-operation.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.8.0/schemas/map-operation.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "oneOf": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.7.0/schemas/mechanic-test-input.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.8.0/schemas/mechanic-test-input.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.7.0/schemas/mod-index-input.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.8.0/schemas/mod-index-input.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.7.0/schemas/operation-result.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.8.0/schemas/operation-result.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.7.0/schemas/package-check-input.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.8.0/schemas/package-check-input.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.7.0/schemas/package-manifest.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.8.0/schemas/package-manifest.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.7.0/schemas/probability-analysis-result.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.8.0/schemas/probability-analysis-result.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.7.0/schemas/probability-compare-input.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.8.0/schemas/probability-compare-input.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.7.0/schemas/probability-evaluate-input.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.8.0/schemas/probability-evaluate-input.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {