hoi4-agent-tools 3.10.0 → 4.0.1

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 (163) hide show
  1. package/CHANGELOG.md +131 -0
  2. package/README.md +91 -147
  3. package/dist/bin/http.js +10 -0
  4. package/dist/bin/setup.js +3 -2
  5. package/dist/bin/stdio.js +10 -0
  6. package/dist/hoi4_agent_tools/core/artifacts.js +40 -5
  7. package/dist/hoi4_agent_tools/core/canonical.js +18 -4
  8. package/dist/hoi4_agent_tools/core/condition-evaluator.js +18 -0
  9. package/dist/hoi4_agent_tools/core/configuration.js +7 -0
  10. package/dist/hoi4_agent_tools/core/domain-scan-patterns.js +12 -0
  11. package/dist/hoi4_agent_tools/core/domain-tools.js +65 -0
  12. package/dist/hoi4_agent_tools/core/domain-validation.js +5 -2
  13. package/dist/hoi4_agent_tools/core/engine.js +29 -2
  14. package/dist/hoi4_agent_tools/core/index.js +2 -2
  15. package/dist/hoi4_agent_tools/core/job-executor.js +14 -1
  16. package/dist/hoi4_agent_tools/core/job-operation-registration.js +15 -7
  17. package/dist/hoi4_agent_tools/core/job-store.js +78 -5
  18. package/dist/hoi4_agent_tools/core/job-transactions.js +31 -2
  19. package/dist/hoi4_agent_tools/core/job-worker-host.js +314 -127
  20. package/dist/hoi4_agent_tools/core/job-worker.js +96 -37
  21. package/dist/hoi4_agent_tools/core/operation-result.js +123 -10
  22. package/dist/hoi4_agent_tools/core/operation-tasks.js +49 -89
  23. package/dist/hoi4_agent_tools/core/persistent-analysis-cache.js +25 -21
  24. package/dist/hoi4_agent_tools/core/server-registry.js +22 -5
  25. package/dist/hoi4_agent_tools/core/shared-request-capacity.js +26 -1
  26. package/dist/hoi4_agent_tools/core/source/cache.js +20 -10
  27. package/dist/hoi4_agent_tools/core/source/lexer.js +11 -3
  28. package/dist/hoi4_agent_tools/core/temporary-directories.js +293 -0
  29. package/dist/hoi4_agent_tools/core/transactions.js +114 -23
  30. package/dist/hoi4_agent_tools/core/worker-exit.js +80 -0
  31. package/dist/hoi4_agent_tools/core/workspace.js +84 -8
  32. package/dist/hoi4_agent_tools/decision/ai.js +1 -1
  33. package/dist/hoi4_agent_tools/decision/service.js +28 -0
  34. package/dist/hoi4_agent_tools/decision/source-inventory.js +7 -5
  35. package/dist/hoi4_agent_tools/event/job-operations.js +9 -5
  36. package/dist/hoi4_agent_tools/event/operations.js +14 -1
  37. package/dist/hoi4_agent_tools/focus/job-operations.js +1 -2
  38. package/dist/hoi4_agent_tools/focus/tool-operations.js +1 -1
  39. package/dist/hoi4_agent_tools/gui/assets.js +3 -0
  40. package/dist/hoi4_agent_tools/gui/dds.js +8 -4
  41. package/dist/hoi4_agent_tools/gui/layout.js +45 -5
  42. package/dist/hoi4_agent_tools/gui/native-state.js +244 -0
  43. package/dist/hoi4_agent_tools/gui/renderer.js +12 -7
  44. package/dist/hoi4_agent_tools/gui/source-graph.js +17 -4
  45. package/dist/hoi4_agent_tools/gui/studio.js +33 -21
  46. package/dist/hoi4_agent_tools/gui/validators.js +8 -6
  47. package/dist/hoi4_agent_tools/map/bmp.js +1 -1
  48. package/dist/hoi4_agent_tools/map/derived.js +748 -0
  49. package/dist/hoi4_agent_tools/map/job-operations.js +7 -3
  50. package/dist/hoi4_agent_tools/map/model.js +103 -0
  51. package/dist/hoi4_agent_tools/map/operations.js +427 -58
  52. package/dist/hoi4_agent_tools/map/references.js +483 -0
  53. package/dist/hoi4_agent_tools/map/service.js +136 -61
  54. package/dist/hoi4_agent_tools/map/tool-operations.js +2 -1
  55. package/dist/hoi4_agent_tools/map/validation.js +3 -0
  56. package/dist/hoi4_agent_tools/map/world.js +1280 -0
  57. package/dist/hoi4_agent_tools/mcp/prompts/probability.js +2 -2
  58. package/dist/hoi4_agent_tools/mcp/server/argument-errors.js +72 -0
  59. package/dist/hoi4_agent_tools/mcp/server/create-modern-operations.js +23 -5
  60. package/dist/hoi4_agent_tools/mcp/server/create.js +7 -0
  61. package/dist/hoi4_agent_tools/mcp/server/instructions.js +1 -1
  62. package/dist/hoi4_agent_tools/mcp/server/request-lifecycle.js +24 -30
  63. package/dist/hoi4_agent_tools/mcp/server/tool-listing.js +45 -0
  64. package/dist/hoi4_agent_tools/mcp/tools/analysis.js +28 -8
  65. package/dist/hoi4_agent_tools/mcp/tools/event.js +19 -30
  66. package/dist/hoi4_agent_tools/mcp/tools/focus.js +5 -13
  67. package/dist/hoi4_agent_tools/mcp/tools/gui.js +6 -6
  68. package/dist/hoi4_agent_tools/mcp/tools/job.js +4 -4
  69. package/dist/hoi4_agent_tools/mcp/tools/map.js +15 -18
  70. package/dist/hoi4_agent_tools/mcp/tools/probability.js +42 -48
  71. package/dist/hoi4_agent_tools/mcp/tools/reference.js +26 -9
  72. package/dist/hoi4_agent_tools/mcp/tools/technology.js +17 -30
  73. package/dist/hoi4_agent_tools/mcp/transports/http.js +28 -4
  74. package/dist/hoi4_agent_tools/mcp/transports/stdio-lifetime.js +31 -8
  75. package/dist/hoi4_agent_tools/probability/job-operations.js +4 -9
  76. package/dist/hoi4_agent_tools/probability/operations.js +175 -13
  77. package/dist/hoi4_agent_tools/probability/source-analysis.js +24 -1
  78. package/dist/hoi4_agent_tools/reference/error-log.js +359 -0
  79. package/dist/hoi4_agent_tools/reference/known-mistakes.js +307 -0
  80. package/dist/hoi4_agent_tools/reference/known-mistakes.json +154 -0
  81. package/dist/hoi4_agent_tools/reference/mod-index.js +101 -0
  82. package/dist/hoi4_agent_tools/reference/operations.js +88 -19
  83. package/dist/hoi4_agent_tools/reference/player-text.js +4 -3
  84. package/dist/hoi4_agent_tools/reference/script-validation.js +19 -1
  85. package/dist/hoi4_agent_tools/reference/service.js +6 -0
  86. package/dist/hoi4_agent_tools/runtime.js +14 -1
  87. package/dist/hoi4_agent_tools/schemas/event.js +78 -19
  88. package/dist/hoi4_agent_tools/schemas/focus-requests.js +10 -0
  89. package/dist/hoi4_agent_tools/schemas/lenient-arguments.js +266 -0
  90. package/dist/hoi4_agent_tools/schemas/map-requests.js +63 -20
  91. package/dist/hoi4_agent_tools/schemas/map.js +122 -3
  92. package/dist/hoi4_agent_tools/schemas/mod-tools.js +181 -0
  93. package/dist/hoi4_agent_tools/schemas/probability-requests.js +119 -9
  94. package/dist/hoi4_agent_tools/schemas/reference.js +13 -0
  95. package/dist/hoi4_agent_tools/schemas/scenarios.js +1 -3
  96. package/dist/hoi4_agent_tools/schemas/script-validation.js +13 -6
  97. package/dist/hoi4_agent_tools/schemas/technology.js +79 -21
  98. package/dist/hoi4_agent_tools/technology/job-operations.js +3 -4
  99. package/dist/hoi4_agent_tools/technology/operations.js +14 -1
  100. package/dist/hoi4_agent_tools/version.js +1 -1
  101. package/docs/README.md +7 -4
  102. package/docs/analysis.md +15 -2
  103. package/docs/configuration.md +281 -0
  104. package/docs/development.md +26 -2
  105. package/docs/events.md +29 -6
  106. package/docs/examples.md +13 -28
  107. package/docs/focus.md +127 -5
  108. package/docs/gui.md +105 -21
  109. package/docs/helper-expansion.md +9 -9
  110. package/docs/http.md +3 -1
  111. package/docs/jobs.md +23 -14
  112. package/docs/map.md +199 -7
  113. package/docs/mechanics.md +6 -2
  114. package/docs/probability.md +46 -16
  115. package/docs/reference.md +73 -5
  116. package/docs/setup.md +45 -14
  117. package/docs/technology.md +28 -4
  118. package/docs/third-party-notices.md +11 -0
  119. package/docs/tools.md +150 -42
  120. package/docs/troubleshooting.md +61 -0
  121. package/examples/clients/codex-config.toml +5 -2
  122. package/examples/clients/generic.json +2 -2
  123. package/examples/config/config.json +7 -0
  124. package/npm-shrinkwrap.json +151 -156
  125. package/package.json +13 -8
  126. package/schemas/configuration.schema.json +144 -128
  127. package/schemas/continuous-focus-palette.schema.json +1 -1
  128. package/schemas/custom-weighted-pool.schema.json +1 -1
  129. package/schemas/decision-inspect-input.schema.json +1 -1
  130. package/schemas/error-log-input.schema.json +55 -0
  131. package/schemas/event-feature-manifest.schema.json +1 -1
  132. package/schemas/focus-plan.schema.json +1 -1
  133. package/schemas/focus-planning-sidecar.schema.json +1 -1
  134. package/schemas/gui-animation-source.schema.json +1 -1
  135. package/schemas/gui-helper.schema.json +1 -1
  136. package/schemas/gui-scenario.schema.json +1 -1
  137. package/schemas/helper-expansion-request.schema.json +1 -1
  138. package/schemas/helper-expansion-summary.schema.json +1 -1
  139. package/schemas/impact-inspect-input.schema.json +1 -1
  140. package/schemas/map-operation.schema.json +597 -126
  141. package/schemas/mechanic-test-input.schema.json +1 -1
  142. package/schemas/mod-index-input.schema.json +51 -0
  143. package/schemas/operation-result.schema.json +2 -2
  144. package/schemas/package-check-input.schema.json +1 -1
  145. package/schemas/package-manifest.schema.json +1 -1
  146. package/schemas/probability-analysis-result.schema.json +1 -1
  147. package/schemas/probability-compare-input.schema.json +1 -1
  148. package/schemas/probability-evaluate-input.schema.json +1 -1
  149. package/schemas/probability-inspect-input.schema.json +1 -1
  150. package/schemas/probability-render-input.schema.json +1 -1
  151. package/schemas/probability-scenario-set.schema.json +1 -1
  152. package/schemas/probability-sequence-input.schema.json +1 -1
  153. package/schemas/probability-simulate-input.schema.json +1 -1
  154. package/schemas/probability-sweep-input.schema.json +1 -1
  155. package/schemas/reference-context-input.schema.json +1 -1
  156. package/schemas/reference-read-input.schema.json +1 -1
  157. package/schemas/reference-search-input.schema.json +1 -1
  158. package/schemas/scenario-suite.schema.json +3 -5
  159. package/schemas/scenario-test-input.schema.json +3 -5
  160. package/schemas/script-validate-input.schema.json +1 -1
  161. package/schemas/shared-scenario.schema.json +1 -1
  162. package/schemas/source-lookup-input.schema.json +1 -1
  163. package/server.json +3 -3
@@ -0,0 +1,281 @@
1
+ # Configuration
2
+
3
+ Most users need no configuration file: start the server inside a mod folder and it configures itself for that mod.
4
+ When you want fixed game and mod paths or several mods, `hoi4-agent-tools-setup --init` writes a file for you, as described in [Setup](setup.md).
5
+
6
+ ## Where the file lives
7
+
8
+ The server reads one JSON file, chosen in this order:
9
+
10
+ 1. the path after `--config`, for example `hoi4-agent-tools --config /srv/hoi4/config.json`;
11
+ 2. the path in the `HOI4_AGENT_CONFIG` environment variable;
12
+ 3. the default path for your system.
13
+
14
+ | System | Default configuration path |
15
+ | --------------- | ---------------------------------------------------------------------------------------------------------------------------- |
16
+ | Windows | `%APPDATA%\hoi4-agent-tools\config.json` |
17
+ | Linux and macOS | `$XDG_CONFIG_HOME/hoi4-agent-tools/config.json`, or `~/.config/hoi4-agent-tools/config.json` when `XDG_CONFIG_HOME` is unset |
18
+
19
+ `APPDATA` takes precedence over `XDG_CONFIG_HOME` when both are set.
20
+
21
+ The server builds an automatic configuration only when all of these hold: `HOI4_AGENT_CONFIG` is unset, `--config` is absent or names the default path, and no file exists at the default path.
22
+ In every other case a missing or unreadable file stops startup with `CONFIG_READ_FAILED`, and a file that fails validation stops it with `CONFIG_INVALID`.
23
+
24
+ The automatic configuration works like this:
25
+
26
+ - Starting from the server's working directory and moving up through its parents, the server takes the first folder that looks like a mod: it has `descriptor.mod`, a standard `common/` subfolder such as `common/national_focus`, or a standard content folder such as `events/` or `localisation/` with matching files.
27
+ The search stops at a game installation (a folder with `hoi4.exe`, `run_hoi4` or `steam_appid.txt`), and startup fails with `AUTO_MOD_ROOT_NOT_FOUND` when nothing is found.
28
+ - That folder becomes the only workspace, with the ID `auto_<folder name>`.
29
+ - The game folder is the first existing folder among `HOI4_GAME_ROOT` and the standard Steam locations on Windows, Linux and macOS.
30
+ - Server state and generated files use the default storage locations below.
31
+
32
+ | Storage | Default location |
33
+ | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
34
+ | `serverStateRoot` | `$XDG_STATE_HOME/hoi4-agent-tools/state`, else `%LOCALAPPDATA%\hoi4-agent-tools\state`, else `~/.local/state/hoi4-agent-tools/state` |
35
+ | `workspaceStorageRoot` | `$XDG_DATA_HOME/hoi4-agent-tools/workspaces`, else `%LOCALAPPDATA%\hoi4-agent-tools\workspaces`, else `~/.local/share/hoi4-agent-tools/workspaces` |
36
+
37
+ `hoi4-agent-tools-setup --init` writes these same two locations into the file it creates.
38
+ A hand-written file has no storage defaults: set `serverStateRoot` yourself, and leave out `workspaceStorageRoot` only if generated files may live inside each mod.
39
+
40
+ What each location holds:
41
+
42
+ - `serverStateRoot` holds the persistent index and parsed-source cache (`analysis-cache/`), background jobs (`jobs/`, `job-workers/`), the records of running server processes (`servers/`) and the key that authenticates rewrite journals.
43
+ - `workspaceStorageRoot` holds one folder per workspace ID, with `artifacts/` for rendered images and other generated results and `cache/` for rewrite transactions and locks.
44
+ - Without `workspaceStorageRoot`, a mod workspace keeps these in `.hoi4-agent/artifacts` and `.hoi4-agent/cache` inside the mod folder.
45
+
46
+ ## A minimal file
47
+
48
+ ```json
49
+ {
50
+ "version": 1,
51
+ "serverStateRoot": "D:/hoi4-agent-tools/state",
52
+ "modRoots": ["D:/hoi4-mods"],
53
+ "gameRoot": "C:/Program Files (x86)/Steam/steamapps/common/Hearts of Iron IV",
54
+ "workspaceStorageRoot": "D:/hoi4-agent-tools/workspaces"
55
+ }
56
+ ```
57
+
58
+ Every subfolder of a `modRoots` entry becomes a mod workspace, and every key not shown takes its default.
59
+ Unknown keys are rejected at every level, so a misspelled key stops startup instead of being ignored.
60
+ The full machine-readable definition is the [configuration JSON schema](../schemas/configuration.schema.json), and [config.json](../examples/config/config.json) is the same example with Linux paths.
61
+
62
+ ## How the server picks your mod
63
+
64
+ Every tool takes a `workspaceId` argument, which defaults to `"current"`.
65
+
66
+ For `"current"`, the server asks the MCP client for its workspace roots when the client supports them:
67
+
68
+ - It selects the one mod workspace that contains a client root or lies inside one.
69
+ - No match fails with `WORKSPACE_CONTEXT_NOT_FOUND`, and more than one match fails with `WORKSPACE_CONTEXT_AMBIGUOUS`.
70
+
71
+ When the client does not supply roots, the server uses its own working directory:
72
+
73
+ - It selects the one mod workspace that contains the working directory.
74
+ - If the working directory is in no mod and exactly one mod workspace exists, it selects that mod.
75
+ - If the working directory is in no mod and several mod workspaces exist, the call fails with `WORKSPACE_CONTEXT_REQUIRED`, and the error lists the available workspace IDs.
76
+ - With no mod workspace at all, the call fails with `WORKSPACE_CONTEXT_NOT_FOUND`.
77
+
78
+ When a tool reads a named source file with `"current"` and the selected mod lacks that file, the server uses the one other mod that has it, and fails with `WORKSPACE_SOURCE_AMBIGUOUS` if several do.
79
+
80
+ To choose a mod explicitly, pass its workspace ID.
81
+ A configured workspace keeps the `id` you gave it.
82
+ A mod found under `modRoots` gets an ID of the form `mod_<folder name>_<12 hex characters>`.
83
+ For a mod workspace, the server also accepts a short form: the mod's folder name or workspace name in lower case with other characters replaced by `_`, optionally prefixed with `auto_` or `mod_`.
84
+ A `mod_<folder name>_<hash>` ID whose hash no longer matches resolves by its folder name in the same way.
85
+ A short form that matches several mods fails with `WORKSPACE_CONTEXT_AMBIGUOUS`, and an unknown ID fails with `WORKSPACE_NOT_REGISTERED`.
86
+ Over HTTP, a principal sees only the workspaces granted to it, and any other ID fails with `WORKSPACE_INACCESSIBLE`.
87
+
88
+ ## Paths
89
+
90
+ | Key | Type | Range | Default | Purpose |
91
+ | ---------------------- | ---------------- | ----------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
92
+ | `version` | number | `1` | none | Configuration format version; required. |
93
+ | `serverStateRoot` | absolute path | | unset | Private folder for indexes, jobs and server records. Required whenever `modRoots` or a `mod` workspace is configured. |
94
+ | `modRoots` | array of paths | up to 16 | `[]` | Parent folders whose direct subfolders each become a writable mod workspace. Hidden and linked subfolders are skipped, and a subfolder already registered under `workspaces` keeps that registration. |
95
+ | `gameRoot` | path | | unset | The installed game, used by every `mod` workspace that sets no `gameRoot` of its own. |
96
+ | `gameUserRoot` | path | | unset | The game's user-data folder holding `logs/error.log`, read by `hoi4.error_log`. When unset, the server tries the folder containing a mod's parent `mod/` folder, then `Documents/Paradox Interactive/Hearts of Iron IV` (also under `%OneDrive%` on Windows), or `~/.local/share/Paradox Interactive/Hearts of Iron IV` on Linux. |
97
+ | `workspaceStorageRoot` | path | | unset | Base folder for generated files: each workspace stores `artifacts/` and `cache/` in `<workspaceStorageRoot>/<workspace ID>/`. When unset, mods use `.hoi4-agent/` inside the mod. |
98
+ | `storageRoots` | array of paths | up to 16 | `[]` | Additional folders in which an explicit `artifactRoot` or `cacheRoot` may be placed. |
99
+ | `workspaces` | array of objects | up to 1,000 | `[]` | Explicit workspace registrations, described in the next section. |
100
+
101
+ ## Workspaces
102
+
103
+ Each entry in `workspaces` registers one source folder.
104
+
105
+ | Key | Type | Range | Default | Purpose |
106
+ | ----------------- | --------------------------- | ---------------------------------------------- | ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
107
+ | `id` | string | lower-case letter, then up to 63 of `a-z0-9_-` | none | Workspace ID used in tool calls and grants; required. `current` is reserved. |
108
+ | `name` | string | 1–200 characters | none | Display name; required. |
109
+ | `root` | path | | none | The workspace folder; required and must exist. |
110
+ | `kind` | `mod`, `game`, `dependency` | | `mod` | `mod` is writable source. `game` registers an installed game as read-only source with its DLC layered after it. `dependency` is read-only source. |
111
+ | `gameRoot` | path | | top-level `gameRoot` for `mod` | The installed game loaded beneath this workspace. |
112
+ | `includeGameDlc` | boolean | | `true` | Layer the game's `dlc/` and `integrated_dlc/` folders between the game and the mod. Set `false` to analyze the base game alone. |
113
+ | `dependencyRoots` | array of paths | up to 16 | `[]` | Read-only mods loaded after the game and DLC and before this workspace, in list order. |
114
+ | `dependencies` | array of objects | up to 16 | `[]` | The same as `dependencyRoots`, with a `replacePaths` list per dependency: `{ "root": "...", "replacePaths": ["..."] }`. Use either this or `dependencyRoots`, not both. |
115
+ | `replacePaths` | array of relative paths | up to 1,000 | `[]` | Folders whose earlier-loaded files this workspace unloads, as `replace_path` does. Entries from the folder's `descriptor.mod` are added automatically. Ignored for `kind: "game"`. |
116
+ | `wikiRoot` | absolute path | | `paradox_wiki/` in the mod | Folder of the offline wiki snapshot used by the reference tools. |
117
+ | `scriptDocsRoot` | absolute path | | `script_docs/` in the mod | Folder of a generated script documentation dump used by the reference tools. |
118
+ | `roots` | object | | see below | Folders, relative to each source layer, that the domain tools scan. |
119
+ | `artifactRoot` | path | | see below | Where rendered images and other generated results are stored. |
120
+ | `cacheRoot` | path | | see below | Where rewrite transactions and locks are stored. |
121
+ | `fixtureRoot` | path | | unset | A read-only folder of extra source files scanned with the workspace at the base game's load position and treated as workspace-owned source. |
122
+
123
+ `artifactRoot` and `cacheRoot` default to `<workspaceStorageRoot>/<id>/artifacts` and `<workspaceStorageRoot>/<id>/cache`, or, without `workspaceStorageRoot`, to `.hoi4-agent/artifacts` and `.hoi4-agent/cache` inside a `mod` workspace.
124
+ A `game` or `dependency` workspace needs both, either explicitly or through `workspaceStorageRoot`.
125
+
126
+ Relative paths in `replacePaths` and `roots` must be plain relative folders of up to 1,024 characters: no leading `/`, drive letter, `:`, `..` segment or wildcard character (`* ? [ ] { } !`).
127
+
128
+ | `roots` key | Default | Scanned for |
129
+ | -------------- | ----------------------------------------- | ----------------------------- |
130
+ | `localisation` | `["localisation", "localisation_synced"]` | Localisation files |
131
+ | `interface` | `["interface"]` | `.gui` and `.gfx` files |
132
+ | `gfx` | `["gfx"]` | Sprite definitions and images |
133
+ | `map` | `["map"]` | Map data |
134
+ | `focus` | `["common/national_focus"]` | National focus trees |
135
+ | `scriptedGui` | `["common/scripted_guis"]` | Scripted GUI definitions |
136
+ | `states` | `["history/states"]` | State history |
137
+
138
+ Each `roots` key takes up to 16 folders, and setting `roots` replaces only the keys you list.
139
+
140
+ ## Scan and storage limits
141
+
142
+ | Key | Type | Range | Default | Purpose |
143
+ | ------------------------ | ------- | -------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
144
+ | `scanMaxFiles` | integer | 1–1,000,000 | 100,000 | Most files one source scan may enumerate across all layers; more fails with `SCAN_FILE_LIMIT`. |
145
+ | `scanMaxBytes` | integer | 1 MiB or more | 268,435,456 (256 MiB) | Most bytes one source scan may read; more fails with `SCAN_BYTE_LIMIT`. |
146
+ | `scanMaxFileBytes` | integer | 64 KiB or more | 67,108,864 (64 MiB) | Largest single file a scan may read. |
147
+ | `artifactMaxBytes` | integer | 1 MiB or more | 536,870,912 (512 MiB) | Total size of one workspace's artifact store. When a new artifact would exceed it, older unpinned artifacts are removed down to three quarters of the limit. |
148
+ | `artifactMaxEntries` | integer | 1–100,000 | 5,000 | Number of artifacts one workspace keeps, pruned the same way. |
149
+ | `artifactMaxSingleBytes` | integer | 1 MiB or more | 134,217,728 (128 MiB) | Largest single artifact. |
150
+
151
+ ## Tools, jobs and lifetime
152
+
153
+ | Key | Type | Range | Default | Purpose |
154
+ | ----------------------- | ------- | ---------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
155
+ | `maxConcurrentTools` | integer | 1–32 | 2 | Expensive tool calls one server process runs at once. |
156
+ | `maxSharedTools` | integer | 1–128 | 4 | Expensive calls and job workers that run at once across every server process sharing the same `serverStateRoot`. |
157
+ | `jobDeadlineSeconds` | integer | 1–86,400 | 1,800 | A read-only job still running this long after dispatch is stopped and fails with `JOB_DEADLINE_EXCEEDED`. Rewrite jobs are never stopped this way. |
158
+ | `jobCancelGraceSeconds` | integer | 1–600 | 10 | A read-only job still running this long after cancellation is stopped and settles as cancelled. |
159
+ | `jobWorkerMaxHeapMiB` | integer | 256–65,536 | unset | Memory ceiling for each job worker's JavaScript heap, in MiB. Unset keeps Node's default. |
160
+ | `jobWorkerIdleSeconds` | integer | 0–3,600 | 180 | How long a job worker stays warm after a job so the next job reuses its loaded indexes. `0` starts a fresh worker for every job. |
161
+ | `stdioIdleExitMinutes` | integer | 0–10,080 | 0 | A stdio server with no client traffic and no open request for this many minutes exits. `0` never exits. `HOI4_AGENT_STDIO_IDLE_EXIT_MINUTES` overrides it per client. |
162
+
163
+ See [Persistent jobs and MCP tasks](jobs.md) for how jobs, cancellation and recovery behave.
164
+
165
+ ## HTTP
166
+
167
+ These keys sit inside the `http` object and are used only by `hoi4-agent-tools-http`.
168
+
169
+ | Key | Type | Range | Default | Purpose |
170
+ | ----------------------------- | --------------------- | ------------------ | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
171
+ | `host` | string | | `127.0.0.1` | Listening address, also accepted in the `Host` header. Anything other than `127.0.0.1`, `localhost` or `::1` counts as public. |
172
+ | `port` | integer | 0–65535 | 3210 | Listening port; `0` lets the system choose one. |
173
+ | `publicUrl` | URL | | unset | The address clients use: an HTTP(S) origin or its exact `/mcp` endpoint, without credentials, query or fragment. Its host name is also accepted in the `Host` header. Required with `oauth`. |
174
+ | `allowedOrigins` | array of URLs | | `[]` | Exact browser origins allowed to call the server. A request carrying any other `Origin` header is refused. |
175
+ | `trustedProxyAddresses` | array of IP addresses | | `[]` | Reverse proxies whose `X-Forwarded-For` header identifies the real client for rate limiting. |
176
+ | `tokens` | array of objects | up to 1,000 | `[]` | Static bearer tokens for loopback use; see below. |
177
+ | `principals` | array of objects | up to 1,000 | `[]` | OAuth subjects allowed to connect; see below. |
178
+ | `oauth` | object | | unset | OAuth or OpenID Connect token verification; see below. |
179
+ | `maxBodyBytes` | integer | 1,024–67,108,864 | 67,108,864 (64 MiB) | Largest request body. |
180
+ | `headersTimeoutMs` | integer | 1,000–120,000 | 10,000 | Time allowed to receive request headers. |
181
+ | `requestTimeoutMs` | integer | 1,000–300,000 | 30,000 | Time allowed to receive a complete request. |
182
+ | `keepAliveTimeoutMs` | integer | 1,000–120,000 | 5,000 | How long an idle connection stays open. |
183
+ | `maxConnections` | integer | 1–100,000 | 512 | Open connections. |
184
+ | `maxRequestsPerSocket` | integer | 1–100,000 | 100 | Requests served on one connection before it closes. |
185
+ | `maxConcurrentRequests` | integer | 1–1,024 | 128 | Requests handled at once. Up to 16 more small requests, such as cancellations, are still admitted when it is full. |
186
+ | `maxSessions` | integer | 1–10,000 | 128 | Open MCP sessions. |
187
+ | `maxSessionsPerPrincipal` | integer | 1–10,000 | 32 | Open MCP sessions per principal. |
188
+ | `maxEventStreams` | integer | 1–10,000 | 128 | Open server-to-client event streams. |
189
+ | `maxEventStreamsPerPrincipal` | integer | 1–10,000 | 32 | Open event streams per principal. |
190
+ | `maxSessionEventBytes` | integer | 65,536–67,108,864 | 2,097,152 (2 MiB) | Resumable event history kept for one session. |
191
+ | `maxEventStoreBytes` | integer | 65,536–268,435,456 | 16,777,216 (16 MiB) | Resumable event history kept for all sessions together. |
192
+ | `requestsPerMinute` | integer | 1–100,000 | 6,000 | Requests per minute from one client address before authentication, and again per principal after it. |
193
+ | `sessionTtlSeconds` | integer | 60–86,400 | 3,600 | An idle session with no active request expires after this many seconds. A session never outlives its credential. |
194
+
195
+ Each `tokens` entry:
196
+
197
+ | Key | Type | Range | Default | Purpose |
198
+ | --------------------- | ---------------- | -------------------------------------------- | ------- | --------------------------------------------------------------------------------------------- |
199
+ | `principal` | string | 1–128 of `A-Z a-z 0-9 . _ @ -` | none | Name of the client; required. |
200
+ | `tokenEnv` | string | upper-case letter, then 1–127 of `A-Z 0-9 _` | none | Environment variable holding the secret; required. The secret must be at least 32 characters. |
201
+ | `workspaceIds` | array of strings | up to 1,000 | `[]` | IDs of configured `workspaces` this client may use. |
202
+ | `allowDiscoveredMods` | boolean | | `false` | Also grant every mod found under `modRoots`. |
203
+
204
+ A static token always carries both the `hoi4:read` and `hoi4:write` scopes, so it can also run rewrite tools.
205
+
206
+ Each `principals` entry:
207
+
208
+ | Key | Type | Range | Default | Purpose |
209
+ | --------------------- | ---------------- | -------------------------------- | ------- | ---------------------------------------------------- |
210
+ | `principal` | string | 1–256 of `A-Z a-z 0-9 . _ @ : -` | none | The token subject (`sub` claim) to allow; required. |
211
+ | `workspaceIds` | array of strings | up to 1,000 | `[]` | IDs of configured `workspaces` this subject may use. |
212
+ | `allowDiscoveredMods` | boolean | | `false` | Also grant every mod found under `modRoots`. |
213
+
214
+ The `oauth` object:
215
+
216
+ | Key | Type | Range | Default | Purpose |
217
+ | ---------------------- | ---------------- | ------------------------------------------------------------- | --------------- | ------------------------------------------------------------------------------ |
218
+ | `issuer` | URL | | none | Expected `iss` claim; required. |
219
+ | `jwksUri` | URL | | none | Where the signing keys are fetched; required. |
220
+ | `audience` | string | 1 character or more | none | Expected `aud` claim; required. |
221
+ | `authorizationServers` | array of URLs | 1 or more | none | Authorization servers advertised in the protected resource metadata; required. |
222
+ | `requiredScopes` | array of strings | | `["hoi4:read"]` | Scopes every request needs. Rewrite tools also need `hoi4:write`. |
223
+ | `algorithms` | array | `RS256`, `RS384`, `RS512`, `ES256`, `ES384`, `ES512`, `EdDSA` | `["RS256"]` | Accepted token signature algorithms. |
224
+
225
+ An OAuth principal receives exactly the scopes in its token, and a token must carry an expiry.
226
+ With `oauth` and `publicUrl` set, the server publishes protected resource metadata at `/.well-known/oauth-protected-resource/mcp`.
227
+
228
+ ## Rules checked at startup
229
+
230
+ The server refuses to start when the file breaks any of these rules.
231
+
232
+ File contents:
233
+
234
+ - `version` is `1`, and no level contains an unknown key.
235
+ - `serverStateRoot` is an absolute path, and it is set whenever `modRoots` is non-empty or any workspace has `kind: "mod"`.
236
+ - `scanMaxFileBytes` is not larger than `scanMaxBytes`, and `artifactMaxSingleBytes` is not larger than `artifactMaxBytes`.
237
+ - `http.maxSessionEventBytes` is not larger than `http.maxEventStoreBytes`.
238
+ - `http.headersTimeoutMs` is not longer than `http.requestTimeoutMs`, and `http.keepAliveTimeoutMs` is shorter than `http.headersTimeoutMs`.
239
+ - A workspace uses `dependencyRoots` or `dependencies`, not both.
240
+ - Workspace IDs are unique, and no workspace uses the ID `current`.
241
+ - `http.oauth` and `http.tokens` are not both set.
242
+ - Token principals are unique, token environment variable names are unique, OAuth principals are unique, and no name appears both as a token principal and as an OAuth principal.
243
+ - Every `workspaceIds` entry in `tokens` and `principals` names a workspace listed under `workspaces`.
244
+
245
+ Folders:
246
+
247
+ - Every `modRoots` entry is an existing real folder, not a link, and no two of them overlap.
248
+ - `workspaceStorageRoot` does not overlap any `modRoots` entry.
249
+ - `serverStateRoot` does not overlap any mod, game, dependency, fixture, wiki, documentation, storage, artifact or cache folder.
250
+ - Each workspace's `root`, `gameRoot`, dependency folders and `fixtureRoot` exist, and its game, dependency and fixture folders neither overlap each other nor the workspace folder.
251
+ - `artifactRoot` and `cacheRoot` lie inside the mod's own `.hoi4-agent/artifacts` and `.hoi4-agent/cache` folders, `workspaceStorageRoot` or a `storageRoots` entry; they do not overlap each other or any source folder.
252
+ - A workspace's own folders do not overlap another workspace's folders, and its read-only folders do not overlap another workspace's mod, artifact or cache folder.
253
+ - At most 1,000 workspaces exist in total, counting mods found under `modRoots`, and a game folder lists at most 256 DLC folders.
254
+
255
+ HTTP server only:
256
+
257
+ - `http.tokens` or `http.oauth` is configured.
258
+ - With `oauth`, `publicUrl` is set and `principals` is not empty.
259
+ - Every static token's environment variable holds at least 32 characters, and no two tokens share a secret.
260
+ - When the server is public, because `host` or the `publicUrl` host is not `127.0.0.1`, `localhost` or `::1`, it must use `oauth`, `publicUrl` must use HTTPS, the issuer, signing-key and authorization server URLs must use HTTPS, and `allowedOrigins` must not be empty.
261
+
262
+ ## Environment variables
263
+
264
+ | Variable | Read by | Purpose |
265
+ | ---------------------------------------------------- | ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
266
+ | `HOI4_AGENT_CONFIG` | `hoi4-agent-tools`, `hoi4-agent-tools-http`, setup `--diagnose` and `--print-client-config` | Configuration file path when `--config` is not given. `--init` writes to `--config` or the default path and ignores this variable. |
267
+ | `HOI4_GAME_ROOT` | automatic configuration, setup `--init` and `--discover` | First game folder to try, before the standard Steam locations. |
268
+ | `HOI4_MOD_ROOTS` | setup `--init` and `--discover` | Extra mod parent folders to discover, separated by `;` on Windows and `:` elsewhere. `--init` uses discovered folders only when no `--mod-root` is given. |
269
+ | `HOI4_AGENT_STDIO_IDLE_EXIT_MINUTES` | `hoi4-agent-tools` | Overrides `stdioIdleExitMinutes` for one client registration. It must be a whole number from 0 to 10,080; an empty value keeps the configured setting, and any other value stops startup. |
270
+ | `HOI4_AGENT_TOOLS_CHAOSX` | `hoi4-agent-tools` | `1` exposes the optional Chaos Redux workflow tools listed in [Tools](tools.md). The HTTP server never exposes them. |
271
+ | the variable named by `tokenEnv` | `hoi4-agent-tools-http` | Secret for a static bearer token, at least 32 characters. |
272
+ | `APPDATA`, `XDG_CONFIG_HOME` | every command | Location of the default configuration file. |
273
+ | `XDG_STATE_HOME`, `XDG_DATA_HOME`, `LOCALAPPDATA` | automatic configuration, setup `--init` | Default `serverStateRoot` and `workspaceStorageRoot`. |
274
+ | `ProgramFiles(x86)` | automatic configuration, setup `--init` and `--discover` | Base of the standard Windows Steam location. |
275
+ | `OneDrive`, `OneDriveConsumer`, `OneDriveCommercial` | setup `--init` and `--discover`; `OneDrive` also `hoi4.error_log` | Additional `Documents` folders searched for mods and, for `OneDrive`, for the game's user-data folder. |
276
+
277
+ ## Related
278
+
279
+ - [Setup](setup.md) for installation, client registration and `hoi4-agent-tools-setup`.
280
+ - [HTTP](http.md) for loopback and remote deployments.
281
+ - [Persistent jobs and MCP tasks](jobs.md) for background work, cancellation and retention.
@@ -7,7 +7,7 @@ npm ci
7
7
  npm run check
8
8
  ```
9
9
 
10
- `npm run check` runs formatting, type checks, tests, fixture checks, schema generation checks, build checks, and package validation. Use narrower commands during iteration:
10
+ `npm run check` runs formatting, lint, type checks, tests, fixture checks, schema generation checks, build checks, package validation, and MCP Registry metadata validation. Use narrower commands during iteration:
11
11
 
12
12
  ```bash
13
13
  npm run test
@@ -19,11 +19,13 @@ npm run inspector
19
19
 
20
20
  Keep changes focused and include tests for behavior changes. CI fixtures must be synthetic and project-owned; never commit installed-game or third-party-mod content. Public tool or schema changes require compatibility review and a versioned release.
21
21
 
22
+ Vitest tracks temporary fixtures created with `mkdtemp` and removes them after each test or suite teardown, with process-exit cleanup as a fallback. Fixture writes and truncations reserve a 256 MiB aggregate disk budget. Test oversized inputs with a small injected limit or mocked metadata; do not allocate gigabyte fixtures. Startup recovery preserves live owners, locks and dated benchmark evidence; see [temporary fixture ownership](adr/0048-temporary-fixture-lifetimes.md).
23
+
22
24
  The event-chain acceptance fixture contains more than 300 project-owned event definitions and exercises routes, options, timing, state flow, scope changes, unresolved dynamic calls, rendering, and comparison.
23
25
 
24
26
  The technology acceptance fixture contains 1,040 project-owned technologies across 13 folders and exercises classic and current doctrines, prerequisites, exclusive branches, multiple placements, unlocks, bonuses, grants, assets, unresolved references, rendering, and comparison.
25
27
 
26
- `npx vitest run tests/integration/mcp-concurrent-workloads.test.ts` tests simultaneous production calls across all six domains over six HTTP sessions and four independent stdio processes, including artifact retrieval and queued cancellation. Execution limits and connection behavior are described in [HTTP](http.md) and the [concurrency decision](https://github.com/klimPaskov/hoi4-agent-tools/blob/main/docs/adr/0026-concurrent-request-execution.md).
28
+ `npx vitest run tests/integration/mcp-concurrent-workloads.test.ts` tests simultaneous production calls across the tool domains over six HTTP sessions and four independent stdio processes, including artifact retrieval and queued cancellation. Execution limits and connection behavior are described in [HTTP](http.md) and the [concurrency decision](https://github.com/klimPaskov/hoi4-agent-tools/blob/main/docs/adr/0026-concurrent-request-execution.md).
27
29
 
28
30
  Persistent-job qualification covers authenticated record publication, request-key conflicts, read-result checkpoints, transaction-journal reconciliation, stopped-owner takeover, native task negotiation, ordinary-call parity, reconnect isolation, rewrite cancellation before source application, and fixed-entry worker execution. The public lifecycle contract is documented in [Persistent jobs and MCP tasks](jobs.md).
29
31
 
@@ -39,8 +41,30 @@ npm run test:local
39
41
 
40
42
  Add `HOI4_DEPENDENCY_ROOTS` as the platform path-delimited list when the external mod has dependencies. Local tests remain read-only.
41
43
 
44
+ `tests/integration/mcp-stdio-smoke.test.ts` starts the real `src/bin/stdio.ts` entry point and calls every exposed tool once with the argument shape an agent sends, then once with a deliberately wrong field.
45
+ Each success must be a non-error `ok` result whose inline structured content stays under 40 KB, and each wrong call must be a `INVALID_ARGUMENTS` tool error that names the field and shows a working example.
46
+ The suite also builds a world with `create_world`, splits and merges a state with `create_state` and `merge_states`, repairs script references with `remap_map_references`, and load-checks the resulting `definition.csv`, state, strategic region, supply and railway files independently of the server's own validator.
47
+ `tests/local/mcp-stdio-smoke.test.ts` repeats the read-only calls against the installed game (through an empty mod) and the external mod above; set `HOI4_SMOKE_REPORT` to a file path to receive the per-tool coverage table with timings.
48
+ Set `HOI4_SMOKE_STDIO_ENTRY` to the absolute `dist/bin/stdio.js` path in a clean tarball installation to test the packaged server instead of the TypeScript source. Rewrites receive invalid inputs on the real mod; successful writes are exercised only on synthetic fixtures.
49
+ `npm run benchmark:cold` times the slow first calls (`hoi4.mod_index`, an event lint and a decision inventory) of a real mod in a fresh server process and again in a second process on the same state folder; the maintainer checklist for tagging a release is `docs/RELEASING.md` in the repository.
50
+
42
51
  The installed-game qualification also parses every shipped bitmap-font descriptor, resolves every atlas page, shapes native and enlarged glyphs, verifies deterministic raster output, and checks HOI4 localisation colours across base fonts and language overrides.
43
52
 
53
+ ## Adding a known mistake
54
+
55
+ `src/hoi4_agent_tools/reference/known-mistakes.json` is the reviewed list behind `known_mistakes` in `hoi4.script_validate`, the `knownMistakes` of `hoi4.reference_context`, and the `knownMistake` of `hoi4.error_log`.
56
+ It is not written at run time: a mistake enters it through a commit.
57
+
58
+ 1. Find the mistake in the offline wiki, the game documentation, or a reproduced `error.log` message, and note the page, heading and item.
59
+ A rule without a source is not accepted.
60
+ 2. Add the rule: a unique snake_case `id`, `severity` (`error` when the definition cannot work, `warning` otherwise), the `surfaces` it belongs to, a `title`, the `mistake`, its `symptom`, the `fix`, the `sources`, and, when the game logs a fixed message, a `logPattern` regular expression.
61
+ 3. Add the detector with the same id in `known-mistakes.ts`, working on the parsed file, and the families it applies to.
62
+ `tests/unit/known-mistakes.test.ts` fails when a rule has no detector or a detector has no rule; add a case that flags the mistake and one that accepts the corrected script.
63
+ 4. When the rule is written from a recurring `error.log` pattern, run `hoi4.error_log` first: its `patterns` show the shapes, and the new `logPattern` makes later logs name the fix.
64
+
65
+ When the game fixes the behaviour, or the rule turns out to be wrong, set `status` to `resolved` and add `resolution` with the date and the reason, and leave the entry in the file.
66
+ A resolved rule is not applied and its detector is skipped; deleting it would lose why it was removed.
67
+
44
68
  See the package [Security Policy](../SECURITY.md) for private vulnerability reporting.
45
69
 
46
70
  ## Dependencies
package/docs/events.md CHANGED
@@ -1,11 +1,12 @@
1
1
  # Event chains
2
2
 
3
- The Event Chain Viewer analyzes event definitions and call sites across the active mod, configured dependencies, and vanilla sources. It is read-only: it does not rewrite event files or simulate the game.
4
-
5
- Use the three event tools directly from the target mod.
3
+ Follow event chains, see the choices they offer and find broken calls.
4
+ The event tools analyze the mod, its dependencies and vanilla sources. The agent uses the results with its file editor to create or fix events.
6
5
 
7
6
  ## Inspect
8
7
 
8
+ A selector may also be a plain string: an event ID such as `my_mod.12`, a namespace such as `my_mod`, or a file path such as `events/my_events.txt`. An object without `kind` is read the same way from its `eventId`, `namespace`, `path` and `line` fields.
9
+
9
10
  `hoi4.event_inspect` provides eight focused modes:
10
11
 
11
12
  - `scan`: inventory event definitions, namespaces, call sites, and unresolved references.
@@ -40,6 +41,11 @@ Selectors use one of these forms:
40
41
 
41
42
  `impact` requires an `impactSubject` object with `kind` and `name`. Allowed impact kinds are `event`, `helper`, `flag`, `variable`, `array`, `event_target`, and `saved_scope`. Set `refresh: true` after source changes when a prior graph may be cached.
42
43
 
44
+ `maxDepth` defaults to 8 (range 1 to 64), `maxNodes` defaults to 500 (range 1 to 5,000), and `maxEdges` defaults to 2,000 (range 1 to 20,000).
45
+ `direction` defaults to `both`.
46
+ `expandHelpers` defaults to `true` for `explain_path` and `false` for the other modes.
47
+ `refresh` defaults to `true` for `scan` and `false` for the other modes.
48
+
43
49
  Example `hoi4.event_inspect` arguments:
44
50
 
45
51
  ```json
@@ -55,6 +61,19 @@ Example `hoi4.event_inspect` arguments:
55
61
  }
56
62
  ```
57
63
 
64
+ Example `explain_path` arguments, which explain the route from one event to another:
65
+
66
+ ```json
67
+ {
68
+ "mode": "explain_path",
69
+ "from": { "kind": "event", "eventId": "my_namespace.1" },
70
+ "to": { "kind": "event", "eventId": "my_namespace.5" },
71
+ "maxDepth": 8
72
+ }
73
+ ```
74
+
75
+ `from` and `to` accept any selector form and are both required in this mode.
76
+
58
77
  ## Render
59
78
 
60
79
  `hoi4.event_render` produces deterministic, source-linked views of a chain. The exact `view` values are `overview`, `neighborhood`, `options`, `entries`, `reachability`, `timing`, `state`, `targets`, `scope`, `terminals`, and `unresolved`. JSON is the authoritative graph; SVG and PNG provide visual review, with HTML available for bundled navigation when requested.
@@ -63,6 +82,9 @@ Large overview requests return a compact overview plus bounded branch JSON/SVG/P
63
82
 
64
83
  Dynamic and meta-generated targets that cannot be resolved statically remain explicit unresolved edges. The renderer never invents a destination.
65
84
 
85
+ `maxDepth` defaults to 4 (range 1 to 64) and `maxNodes` defaults to 120 (range 1 to 240).
86
+ `direction` defaults to `both`, and `expandHelpers`, `includeHtml`, and `refresh` default to `false`.
87
+
66
88
  Example `hoi4.event_render` arguments:
67
89
 
68
90
  ```json
@@ -80,16 +102,17 @@ Example `hoi4.event_render` arguments:
80
102
 
81
103
  ## Compare
82
104
 
83
- `hoi4.event_compare` compares whole workspace event graphs. `before` and `after` each accept exactly one graph reference: `{ "revision": "<sha256>" }` or `{ "artifactUri": "hoi4-agent://..." }`. If no reference or overlay is supplied, the tool compares the previous cached revision with a fresh scan of the current source and reports an error when no prior revision is available. Comparisons refresh current source by default so normal agent file edits are detected; set `refresh: false` only when intentionally comparing cached graphs.
105
+ `hoi4.event_inspect` with `mode: compare` compares whole workspace event graphs. `before` and `after` each accept exactly one graph reference: `{ "revision": "<sha256>" }` or `{ "artifactUri": "hoi4-agent://..." }`. If no reference or overlay is supplied, the tool compares the previous cached revision with a fresh scan of the current source and reports an error when no prior revision is available. Comparisons refresh current source by default so normal agent file edits are detected; set `refresh: false` only when intentionally comparing cached graphs.
84
106
 
85
107
  Set `selector` to an event, namespace, file, source location, node, or manifest to view the downstream chain in both revisions. `maxChainNodes` bounds each traversal, defaults to 1,000, and reports `selectionTruncated` when the chain exceeds the boundary. The artifact retains the full comparison and graph hashes, and its `selection` reports selected, omitted, and unattributed changes explicitly. Diagnostics without a chain owner remain unattributed. The rendered view uses the selected changed nodes.
86
108
 
87
109
  Alternatively, compare the current graph with `proposedSources`, an in-memory list of `{ relativePath, source, expectedSourceHash? }` overlays. Set `source` to a string to add or replace source, or to `null` to delete an existing mod source. `after` and `proposedSources` are mutually exclusive. Proposed sources are analyzed without being written. The result reports added, removed, and changed definitions, edges, options, state operations, diagnostics, and route reachability.
88
110
 
89
- Example `hoi4.event_compare` arguments:
111
+ Example `hoi4.event_inspect` comparison arguments:
90
112
 
91
113
  ```json
92
114
  {
115
+ "mode": "compare",
93
116
  "proposedSources": [
94
117
  {
95
118
  "relativePath": "events/example.txt",
@@ -114,6 +137,6 @@ A coding agent can combine the viewer with repository instructions, skills, and
114
137
  2. use `trace`, `explain_path`, `state_flow`, or `impact` for the current task;
115
138
  3. read linked JSON evidence only when the compact summary is insufficient;
116
139
  4. edit event source with the agent's normal file-editing workflow;
117
- 5. call `hoi4.event_compare`, `lint`, and `hoi4.event_render` to review the result; comparison refreshes the edited source by default.
140
+ 5. call `hoi4.event_inspect` with `mode: compare` and `lint`, then `hoi4.event_render` to review the result; comparison refreshes the edited source by default.
118
141
 
119
142
  Static analysis cannot prove runtime conditions, random outcomes, delayed scheduling, or arbitrary meta-generated text. Those limits are reported in diagnostics and artifacts rather than hidden or guessed. The server never launches or captures Hearts of Iron IV.
package/docs/examples.md CHANGED
@@ -1,13 +1,10 @@
1
1
  # Examples
2
2
 
3
- Start with a task you would normally give your coding agent.
4
- The agent chooses the MCP tools and opens the resulting images or source references.
5
- The renders below use actual Chaos Redux and installed HOI4 files; use names from your own mod when trying the prompts.
3
+ Describe what you want to make or fix and the agent chooses the tools.
4
+ The previews below come from real mod and installed HOI4 files.
6
5
 
7
6
  ## Find a rule without reading a whole wiki
8
7
 
9
- > Find the installed documentation for `save_event_target_as`, read the relevant section, and show a vanilla usage. Keep the file and line references.
10
-
11
8
  The reference tools find the section, read a small excerpt, and retain its source revision so the agent can return to it later.
12
9
  In the [measured reference example](research/reference-benchmark.md), the search found the installed effect documentation first and a 12-line read supplied the command and supported scopes.
13
10
  No wiki download or game launch was needed.
@@ -16,54 +13,42 @@ Use [Local references](reference.md) to configure an offline wiki snapshot or na
16
13
 
17
14
  ## Review a large tree
18
15
 
19
- > Render the mod's largest branching focus tree. Check its branch connections, alternative prerequisites, missing references and crowded areas before suggesting edits.
20
-
21
16
  [![Branching focus tree preview](images/comparisons/utopia-mcp.png)](images/comparisons/utopia-mcp.png)
22
17
 
23
18
  Open the image at full size for the complete layout.
24
- This example contains 124 focuses in the recorded source version.
25
19
  The [focus guide](focus.md) covers inspecting, rendering and reorganizing trees.
26
20
 
27
21
  ## Preview technology layouts and artwork
28
22
 
29
- > Render the infantry technology folder using this mod and its installed game assets. Check card sizes, icons, prerequisite links and missing placements.
30
-
31
23
  [![Infantry technology folder](images/comparisons/infantry-mcp.png)](images/comparisons/infantry-mcp.png)
32
24
 
33
25
  The preview follows the loaded technology and GUI definitions, including wide equipment cards.
34
- The [technology comparisons](visual-comparisons.md#technology-folders) also show a mod folder with wide equipment cards rendered from a matching recorded source revision.
26
+ The [technology comparisons](https://github.com/klimPaskov/hoi4-agent-tools/blob/main/docs/visual-comparisons.md#technology-folders) also show a mod folder with wide equipment cards rendered from a matching recorded source revision.
35
27
  See the [technology guide](technology.md) for grants, bonuses and doctrine paths.
36
28
 
37
- ## Inspect an interface before editing it
38
-
39
- > Find the Video options window in the installed interface files. Render it with labelled control regions, then check its text, spacing and clipping.
29
+ ## Preview a window
40
30
 
41
31
  | Supplied in-game capture | MCP source preview |
42
32
  | ------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
43
33
  | ![Video options in game](images/comparisons/gui/options-video-ingame.png) | ![Video options preview](images/comparisons/gui/options-video-mcp.png) |
44
34
 
45
- For a mod window, ask for the same view at 100% and 125% UI scale and supply the state values needed by its controls.
35
+ The agent can preview mod windows at different UI scales and work out which state values their controls need.
46
36
  Unknown state values must stay unresolved; a visible button alone does not establish that it is enabled in the game.
47
- The [interface gallery](gui-comparisons.md) includes Škoda Priority, Chaos Redux Settings, Event Log, Chaos Meter, decisions and occupation views.
37
+ The [interface gallery](https://github.com/klimPaskov/hoi4-agent-tools/blob/main/docs/gui-comparisons.md) includes a vanilla priority panel, a mod settings window, an event log, a status panel, and the decision and occupation views.
48
38
 
49
- ## Locate map data and plan an edit
50
-
51
- > Find Brandenburg by name, show it on the map, and inspect its provinces, neighbours and railway connections. Show the affected files before changing anything.
39
+ ## Reshape a map
52
40
 
53
41
  [![Map rendered from installed source](images/comparisons/source/map-mcp.png)](images/comparisons/source/map-mcp.png)
54
42
 
55
- After reviewing the selection, you can ask for a specific change such as moving named provinces into a state or updating a railway path.
56
- The map tools check connected records and preserve dated state history when the operation can be represented safely.
43
+ The agent finds the state, splits its provinces and updates connected map records and script references.
44
+ It can also generate a whole new world.
57
45
  See [Maps](map.md) for supported edits.
58
46
 
59
47
  ## Trace an event or compare AI weights
60
48
 
61
- > Trace this event's options and follow-up events. Point out unresolved calls and link each route to its source.
62
-
63
- [![Chaos Redux event options](images/comparisons/source/event-chain-mcp.png)](images/comparisons/source/event-chain-mcp.png)
64
-
65
- > Compare this decision's `ai_will_do` score before and after my change in peace and war. List missing conditions separately from known results.
49
+ [![Mod event options](images/comparisons/source/event-chain-mcp.png)](images/comparisons/source/event-chain-mcp.png)
66
50
 
51
+ The AI tools show why a route is favoured or ignored.
67
52
  Use [Events](events.md) for route graphs and [AI analysis](probability.md) for supported weights, chances and timing models.
68
53
  A decision score is not automatically a percentage chance of an AI click.
69
54
 
@@ -71,5 +56,5 @@ A decision score is not automatically a percentage chance of an AI click.
71
56
 
72
57
  The images are source previews, not recordings of the server running the game.
73
58
  Supplied game screenshots are identified separately and published with permission.
74
- The [comparison pages](visual-comparisons.md) and [interface gallery](gui-comparisons.md) keep source details, reproducible inputs and known differences alongside the images.
75
- The package does not include HOI4 or Chaos Redux source files or artwork.
59
+ The [comparison pages](https://github.com/klimPaskov/hoi4-agent-tools/blob/main/docs/visual-comparisons.md) and [interface gallery](https://github.com/klimPaskov/hoi4-agent-tools/blob/main/docs/gui-comparisons.md) keep source details, reproducible inputs and known differences alongside the images.
60
+ The package does not include HOI4 or mod source files or artwork.