hoi4-agent-tools 3.7.0 → 3.8.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 (75) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +59 -57
  3. package/dist/hoi4_agent_tools/core/configuration.js +2 -0
  4. package/dist/hoi4_agent_tools/core/job-store.js +19 -40
  5. package/dist/hoi4_agent_tools/core/job-worker-host.js +57 -8
  6. package/dist/hoi4_agent_tools/core/operation-tasks.js +2 -7
  7. package/dist/hoi4_agent_tools/core/scanner.js +3 -0
  8. package/dist/hoi4_agent_tools/core/shared-request-capacity.js +27 -13
  9. package/dist/hoi4_agent_tools/core/transactions.js +31 -2
  10. package/dist/hoi4_agent_tools/core/windows-sharing.js +42 -0
  11. package/dist/hoi4_agent_tools/core/workspace.js +114 -8
  12. package/dist/hoi4_agent_tools/event/artifact-validation.js +1 -1
  13. package/dist/hoi4_agent_tools/event/service.js +1 -1
  14. package/dist/hoi4_agent_tools/focus/service.js +2 -2
  15. package/dist/hoi4_agent_tools/gui/studio.js +16 -3
  16. package/dist/hoi4_agent_tools/map/model.js +81 -2
  17. package/dist/hoi4_agent_tools/map/service.js +1 -0
  18. package/dist/hoi4_agent_tools/map/validation.js +60 -4
  19. package/dist/hoi4_agent_tools/mcp/tools/reference.js +1 -1
  20. package/dist/hoi4_agent_tools/package-check/service.js +1 -1
  21. package/dist/hoi4_agent_tools/reference/ranking.js +309 -0
  22. package/dist/hoi4_agent_tools/reference/script-validation.js +3 -13
  23. package/dist/hoi4_agent_tools/reference/service.js +152 -116
  24. package/dist/hoi4_agent_tools/reference/source-locate.js +156 -0
  25. package/dist/hoi4_agent_tools/reference/source-lookup.js +37 -6
  26. package/dist/hoi4_agent_tools/reference/suggestions.js +38 -0
  27. package/dist/hoi4_agent_tools/schemas/reference.js +80 -2
  28. package/dist/hoi4_agent_tools/schemas/transaction.js +1 -1
  29. package/dist/hoi4_agent_tools/technology/service.js +1 -1
  30. package/dist/hoi4_agent_tools/version.js +1 -1
  31. package/docs/development.md +6 -0
  32. package/docs/examples.md +3 -3
  33. package/docs/map.md +10 -0
  34. package/docs/reference.md +5 -3
  35. package/docs/research/reference-benchmark.md +39 -0
  36. package/docs/setup.md +15 -0
  37. package/docs/tools.md +37 -37
  38. package/npm-shrinkwrap.json +18 -5
  39. package/package.json +2 -2
  40. package/schemas/configuration.schema.json +95 -88
  41. package/schemas/continuous-focus-palette.schema.json +1 -1
  42. package/schemas/custom-weighted-pool.schema.json +1 -1
  43. package/schemas/decision-inspect-input.schema.json +1 -1
  44. package/schemas/event-feature-manifest.schema.json +1 -1
  45. package/schemas/focus-plan.schema.json +1 -1
  46. package/schemas/focus-planning-sidecar.schema.json +1 -1
  47. package/schemas/gui-animation-source.schema.json +1 -1
  48. package/schemas/gui-helper.schema.json +1 -1
  49. package/schemas/gui-scenario.schema.json +1 -1
  50. package/schemas/helper-expansion-request.schema.json +1 -1
  51. package/schemas/helper-expansion-summary.schema.json +1 -1
  52. package/schemas/impact-inspect-input.schema.json +1 -1
  53. package/schemas/map-operation.schema.json +1 -1
  54. package/schemas/mechanic-test-input.schema.json +1 -1
  55. package/schemas/operation-result.schema.json +1 -1
  56. package/schemas/package-check-input.schema.json +1 -1
  57. package/schemas/package-manifest.schema.json +1 -1
  58. package/schemas/probability-analysis-result.schema.json +1 -1
  59. package/schemas/probability-compare-input.schema.json +1 -1
  60. package/schemas/probability-evaluate-input.schema.json +1 -1
  61. package/schemas/probability-inspect-input.schema.json +1 -1
  62. package/schemas/probability-render-input.schema.json +1 -1
  63. package/schemas/probability-scenario-set.schema.json +1 -1
  64. package/schemas/probability-sequence-input.schema.json +1 -1
  65. package/schemas/probability-simulate-input.schema.json +1 -1
  66. package/schemas/probability-sweep-input.schema.json +1 -1
  67. package/schemas/reference-context-input.schema.json +1 -1
  68. package/schemas/reference-read-input.schema.json +1 -1
  69. package/schemas/reference-search-input.schema.json +1 -1
  70. package/schemas/scenario-suite.schema.json +1 -1
  71. package/schemas/scenario-test-input.schema.json +1 -1
  72. package/schemas/script-validate-input.schema.json +1 -1
  73. package/schemas/shared-scenario.schema.json +1 -1
  74. package/schemas/source-lookup-input.schema.json +113 -50
  75. package/server.json +2 -2
@@ -54,7 +54,11 @@ export const sourceKeyPathSchema = z
54
54
  export const sourceLookupRequestSchema = z
55
55
  .object({
56
56
  workspaceId: workspaceIdSchema,
57
- symbol: z.string().trim().min(1).max(256),
57
+ symbol: z.string().trim().min(1).max(256).optional(),
58
+ /** Locate mode: a scanned source path (`mod:events/a.txt`, `events/a.txt`, or absolute). */
59
+ path: z.string().trim().min(1).max(4096).optional(),
60
+ line: z.number().int().min(1).optional(),
61
+ column: z.number().int().min(1).optional(),
58
62
  kind: z
59
63
  .string()
60
64
  .regex(/^[a-z][a-z0-9_]{0,63}$/u)
@@ -74,7 +78,39 @@ export const sourceLookupRequestSchema = z
74
78
  .regex(/^[a-f0-9]{64}$/u)
75
79
  .optional(),
76
80
  })
77
- .strict();
81
+ .strict()
82
+ .superRefine((value, context) => {
83
+ const locating = value.path !== undefined || value.line !== undefined;
84
+ if (locating === (value.symbol !== undefined))
85
+ context.addIssue({
86
+ code: 'custom',
87
+ path: ['symbol'],
88
+ message: 'Provide either symbol, or path and line to locate a source position',
89
+ });
90
+ if (locating && (value.path === undefined || value.line === undefined))
91
+ context.addIssue({
92
+ code: 'custom',
93
+ path: ['line'],
94
+ message: 'Locating a source position requires both path and line',
95
+ });
96
+ if (!locating && value.column !== undefined)
97
+ context.addIssue({
98
+ code: 'custom',
99
+ path: ['column'],
100
+ message: 'column applies only with path and line',
101
+ });
102
+ if (locating &&
103
+ (value.keyPath !== undefined ||
104
+ value.view === 'structure' ||
105
+ value.fromLine !== undefined ||
106
+ value.fromColumn !== undefined ||
107
+ value.expectedRevision !== undefined))
108
+ context.addIssue({
109
+ code: 'custom',
110
+ path: ['path'],
111
+ message: 'Navigation options apply to a symbol lookup; locate first, then pass its keyPath',
112
+ });
113
+ });
78
114
  const hash = z.string().regex(/^[a-f0-9]{64}$/u);
79
115
  const line = z.number().int().min(1);
80
116
  const count = z.number().int().min(0);
@@ -101,6 +137,8 @@ export const referenceSectionSchema = z
101
137
  endLine: line,
102
138
  excerpt: z.string().max(300),
103
139
  authority: z.string().max(80),
140
+ /** The cited line that best matches the query; start a bounded read here. */
141
+ matchLine: line.optional(),
104
142
  })
105
143
  .strict();
106
144
  export const referenceSearchDataSchema = z
@@ -142,6 +180,7 @@ export const sourceLookupDataSchema = z
142
180
  'event_definitions',
143
181
  'event_consumers',
144
182
  'helper_definitions',
183
+ 'source_location',
145
184
  ]),
146
185
  revision: hash,
147
186
  complete: z.boolean(),
@@ -153,6 +192,45 @@ export const sourceLookupDataSchema = z
153
192
  referencesTruncated: z.boolean(),
154
193
  referencesComplete: z.boolean(),
155
194
  unresolvedReferenceCount: count,
195
+ /** Indexed identifiers within three edits of a symbol that has no definition. */
196
+ suggestions: z.array(z.string().max(1024)).max(5).optional(),
197
+ location: z
198
+ .object({
199
+ path: z.string().max(4096),
200
+ rootKind: z.string().max(32),
201
+ loadOrder: count,
202
+ shadowed: z.boolean(),
203
+ line,
204
+ column: line,
205
+ text: z.string().max(300),
206
+ owners: z
207
+ .array(z
208
+ .object({
209
+ kind: z.string().max(64),
210
+ id: z.string().max(1024),
211
+ startLine: line,
212
+ endLine: line,
213
+ overridden: z.boolean(),
214
+ })
215
+ .strict())
216
+ .max(8),
217
+ chain: z
218
+ .array(z
219
+ .object({
220
+ key: z.string().max(128).nullable(),
221
+ occurrence: count,
222
+ index: count,
223
+ startLine: line,
224
+ endLine: line,
225
+ })
226
+ .strict())
227
+ .max(24),
228
+ chainTruncated: z.boolean(),
229
+ keyPath: sourceKeyPathSchema.nullable(),
230
+ structureAvailable: z.boolean(),
231
+ })
232
+ .strict()
233
+ .optional(),
156
234
  definitions: z
157
235
  .array(z
158
236
  .object({
@@ -34,7 +34,7 @@ const transactionOperationSchema = z
34
34
  .strict();
35
35
  const transactionReadDependencySchema = z
36
36
  .object({
37
- rootKind: z.enum(['mod', 'game', 'dependency', 'artifact', 'cache', 'fixture']),
37
+ rootKind: z.enum(['mod', 'game', 'dlc', 'dependency', 'artifact', 'cache', 'fixture']),
38
38
  loadOrder: z.number().int().min(0),
39
39
  relativePath: workspaceRelativePathSchema,
40
40
  sha256: sha256Schema,
@@ -117,7 +117,7 @@ async function scanTechnologySources(engine, workspaceId, workspace, principal,
117
117
  const scans = await Promise.all([
118
118
  engine.scan(workspaceId, { patterns, rootKinds: ['mod', 'dependency', 'fixture'] }, principal, signal),
119
119
  ...(workspace.roots.some(({ kind }) => kind === 'game')
120
- ? [engine.scan(workspaceId, { patterns, rootKinds: ['game'] }, principal, signal)]
120
+ ? [engine.scan(workspaceId, { patterns, rootKinds: ['game', 'dlc'] }, principal, signal)]
121
121
  : []),
122
122
  ]);
123
123
  const files = scans.flatMap(({ files }) => files.map((file) => ({ ...file })));
@@ -1,6 +1,6 @@
1
1
  import { LATEST_PROTOCOL_VERSION } from '@modelcontextprotocol/sdk/types.js';
2
2
  export const PACKAGE_NAME = 'hoi4-agent-tools';
3
- export const PACKAGE_VERSION = '3.7.0';
3
+ export const PACKAGE_VERSION = '3.8.1';
4
4
  export const MCP_PROTOCOL_VERSION = LATEST_PROTOCOL_VERSION;
5
5
  export const CONFIG_VERSION = 1;
6
6
  export const TRANSACTION_VERSION = 1;
@@ -42,3 +42,9 @@ Add `HOI4_DEPENDENCY_ROOTS` as the platform path-delimited list when the externa
42
42
  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
43
 
44
44
  See the package [Security Policy](../SECURITY.md) for private vulnerability reporting.
45
+
46
+ ## Dependencies
47
+
48
+ `npm-shrinkwrap.json` is published and fixes the complete production dependency tree for every consumer, who no longer receive newer transitive releases on their own.
49
+ Run `npm audit --omit=dev` and `npm audit signatures` before each release, and publish a new version with a refreshed shrinkwrap when a production advisory is fixed upstream.
50
+ Keep `overrides` inside every dependent's declared range; consumers do not apply this package's overrides, and `tests/package/metadata.test.ts` checks each production dependency edge in the shrinkwrap against its range.
package/docs/examples.md CHANGED
@@ -16,9 +16,9 @@ Use [Local references](reference.md) to configure an offline wiki snapshot or na
16
16
 
17
17
  ## Review a large tree
18
18
 
19
- > Render the Utopia Manifesto focus tree. Check its branch connections, alternative prerequisites, missing references and crowded areas before suggesting edits.
19
+ > Render the mod's largest branching focus tree. Check its branch connections, alternative prerequisites, missing references and crowded areas before suggesting edits.
20
20
 
21
- [![Utopia Manifesto focus tree](images/comparisons/utopia-mcp.png)](images/comparisons/utopia-mcp.png)
21
+ [![Branching focus tree preview](images/comparisons/utopia-mcp.png)](images/comparisons/utopia-mcp.png)
22
22
 
23
23
  Open the image at full size for the complete layout.
24
24
  This example contains 124 focuses in the recorded source version.
@@ -31,7 +31,7 @@ The [focus guide](focus.md) covers inspecting, rendering and reorganizing trees.
31
31
  [![Infantry technology folder](images/comparisons/infantry-mcp.png)](images/comparisons/infantry-mcp.png)
32
32
 
33
33
  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 chemical folder rendered from a matching recorded source revision.
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.
35
35
  See the [technology guide](technology.md) for grants, bonuses and doctrine paths.
36
36
 
37
37
  ## Inspect an interface before editing it
package/docs/map.md CHANGED
@@ -18,6 +18,16 @@ Pass `tile: { x, y, width, height }` to `hoi4.map_render` for a reusable bounded
18
18
 
19
19
  Pass `area: { provinceIds, stateIds, regionIds, padding }` to render the exact bounding area of those map entities with optional pixel padding. The result reports the resolved tile coordinates. An unknown ID or an area larger than 2,048 pixels in either direction is explicit, so a narrower selection can be requested.
20
20
 
21
+ ## Catalog consistency
22
+
23
+ Validation reads the active `common/terrain/*.txt` categories and `map/continent.txt` (or the continent file `default.map` names) along with the map files.
24
+ A province whose terrain no category defines reports `MAP_TERRAIN_UNKNOWN`, and a land province with a continent number beyond the continents listed reports `MAP_CONTINENT_UNKNOWN`; continent IDs follow their order in the file.
25
+ Seas and lakes must use a category with `is_water = yes` (`MAP_SEA_TERRAIN_INVALID`, `MAP_LAKE_TERRAIN_INVALID`), land provinces must not (`MAP_LAND_TERRAIN_WATER`), and a strategic region's `naval_terrain` must name a category with `naval_terrain = yes` (`MAP_REGION_NAVAL_TERRAIN_INVALID`).
26
+ When no terrain category file is available, seas and lakes are checked against the base game's `ocean` and `lakes` names instead, and unknown terrain is not reported.
27
+
28
+ The engine stops reading `adjacencies.csv` at its first `-1` row.
29
+ Rows after it are not read and report `MAP_ADJACENCY_AFTER_TERMINATOR`; a file without that row reports `MAP_ADJACENCY_TERMINATOR_MISSING` as a warning, because the offline wiki describes it as required although at least one published mod omits it.
30
+
21
31
  ## Create states
22
32
 
23
33
  The compact `create_state` form needs selected provinces and a display name:
package/docs/reference.md CHANGED
@@ -10,14 +10,16 @@ The server discovers these directories for a workspace:
10
10
  | Offline wiki | `modRoot/paradox_wiki/**/*.md` | Set absolute `wikiRoot`. |
11
11
  | Generated script documentation | `modRoot/script_docs/**/*.md` and `**/*.log` | Set absolute `scriptDocsRoot` to a user-supplied dump. |
12
12
 
13
- Only Markdown headings and recognizable standalone names in generated `.log` files form sections. A dump that yields one section should be treated as insufficiently parsed; inspect its source format before relying on it. Source bytes are hashed on each request, while unchanged section indexes are reused. Missing roots are reported as unavailable. The public package contains none of these local source files.
13
+ Markdown headings and recognizable standalone names in generated `.log` files form sections. A Markdown table row whose first cell is an identifier, such as a wiki effect, trigger, modifier, define, or on action, is also its own one-line section, so a citation can name the exact entry inside a long table. A dump that yields one section should be treated as insufficiently parsed; inspect its source format before relying on it. Source bytes are hashed on each request, while unchanged section indexes are reused. Missing roots are reported as unavailable. The public package contains none of these local source files.
14
14
 
15
15
  ## Tools
16
16
 
17
17
  - `hoi4.reference_context`: request a surface such as `event`, `focus`, `technology`, `gui`, or `map`. It reserves citations for available installed documentation and offline wiki sources before adding further question matches. Supply `question` to select the best matching section within each required source. At a limit of two or more, both source kinds are represented when available; a one-result limit prioritizes installed documentation. `omittedSources` names required sources excluded by the result limit, while `missing` names sources absent from the configured roots. Increase the limit or search an omitted source directly before treating the bundle as sufficient. Citations are pointers and excerpts; read the pertinent sections before changing code.
18
- - `hoi4.reference_search`: search page names, headings, exact script tokens, and matching body lines. The default limit is six results and the maximum is twelve. Filter `sources` to `game_doc`, `wiki`, or `script_doc` when appropriate. Only selected authorities are scanned; `coverage.included = false` means that an authority was excluded from this query, not that it is missing.
18
+ - `hoi4.reference_search`: search with plain words or exact script tokens. Ranking weighs headings above body text and rare words above common ones, and it matches identifiers both whole and by their words, so "check if a state is controlled by a country" can find `is_controlled_by`. A query that names an identifier only matches sections containing it, an exact heading ranks first, and installed documentation precedes the wiki when they rank equally. Each result's `matchLine` is the cited line that best matches the query; pass it as `startLine` to `hoi4.reference_read` to land on the answer inside a long section. When several sources document the same name, the first copy keeps its place and later copies follow other distinct answers. The default limit is six results and the maximum is twelve. Filter `sources` to `game_doc`, `wiki`, or `script_doc` when appropriate. Only selected authorities are scanned; `coverage.included = false` means that an authority was excluded from this query, not that it is missing.
19
19
  - `hoi4.reference_read`: provide a search/context result's `id` and `revision`. Optionally pass its `source` for a focused authority read; resident citations provide this hint automatically. Read up to 80 lines and 8,000 UTF-8 bytes, with JSON escaping also bounded. Continue with the returned `nextLine`, `nextColumn` as `startColumn`, and the same revision. Long source lines continue without losing characters. A changed source returns `REFERENCE_REVISION_STALE`.
20
20
  - `hoi4.source_lookup`: find exact definitions and indexed usages in the installed game and configured mod source. The response includes load order, override status, up to three source blocks bounded to 2,000 bytes each, a scan revision, and explicit reference counts and truncation. Follow `nextLine` and `nextColumn` as `fromLine` and `fromColumn`, with `expectedRevision`, to read more of the active definition.
21
+ - When `hoi4.source_lookup` finds no definition, `suggestions` lists up to five indexed identifiers within three edits of the requested symbol, nearest first, which catches typos and near-miss names.
22
+ - `hoi4.source_lookup` with `path` and `line` instead of `symbol` locates a source position, such as a diagnostic or a changed line in a diff. `path` may be a result path such as `mod:events/example.txt`, a path relative to a source root, or an absolute path inside one. The result names the file's layer and whether a later layer shadows it, the indexed definitions that contain the line, innermost first, and the chain of enclosing assignments with zero-based occurrences for repeated keys. Its `keyPath` starts inside the innermost definition: pass that definition's `id` as `symbol`, its `kind`, and the `keyPath` to read or list that exact block. Without `column`, the first non-blank character of the line is used. A file with parse errors returns its definitions but no structural chain. Only the requested file's folder is scanned, in every layer.
21
23
  - `hoi4.script_validate`: check a bounded effect or trigger body against installed native-command documentation. Supply the body in `source`, its `kind`, and its current `scope`. Results cover syntax, command kind, and declared scope, with exact documentation citations. They do not validate command parameters or prove game execution.
22
24
 
23
25
  ## Navigate a definition
@@ -70,4 +72,4 @@ Call `hoi4.reference_context` with that input, then search `save_event_target_as
70
72
 
71
73
  The local index admits at most 512 files per source kind, 2 MB per file, 32 MB in total, and 20,000 sections. Search and read responses are bounded by the MCP result budget. `skipped` and per-source coverage expose incomplete ingestion instead of implying that an omitted source was checked. Registered external reference roots are operator configuration and remain private to the authorized workspace.
72
74
 
73
- See [the measured Chaos Redux reference retrieval](research/reference-benchmark.md) for actual source coverage and response sizes.
75
+ See [the measured Chaos Redux reference retrieval](research/reference-benchmark.md) for actual source coverage, held-out discovery results, and response sizes. Plain-word questions still miss when the documentation uses different vocabulary, for example "national spirit" for `ideas`; search the script name directly when it is known.
@@ -27,6 +27,45 @@ The retrieval benchmark used the local service directly. A separate real-workspa
27
27
 
28
28
  The four additional public tool definitions add approximately 6.5 KB to the one-time MCP tool discovery response. The complete list is about 72 KB in the discovery fixture and is tested against a 72 KiB ceiling. The context reduction above applies to reference retrieval after discovery.
29
29
 
30
+ ## Held-out discovery questions
31
+
32
+ Measured on 2026-10-04 against the same local Chaos Redux wiki snapshot and installed documentation.
33
+ The nine questions above were assembled alongside the previous ranking, so they cannot show whether a ranking change generalizes.
34
+ Two further sets in `scripts/reference-discovery-cases.ts` phrase tasks the way an agent asks them, mostly without the script name.
35
+ Every expected answer was checked by hand in the local files, and a case may list several acceptable sections.
36
+ A result answers a question when its cited section contains an expected answer line; it lands when its cited line is within eight lines of that answer.
37
+
38
+ The discovery set has 32 plain-word questions, five exact identifiers, and two unrelated negative queries.
39
+ The validation set has 24 plain-word questions written before any ranking adjustment and was never used to tune it.
40
+
41
+ | Set and ranking | Answer first | Within three | Within five | Lands within three | Mean reciprocal rank |
42
+ | ------------------------------ | -----------: | -----------: | ----------: | -----------------: | -------------------: |
43
+ | Discovery, previous ranking | 7/37 | 19/37 | 22/37 | 18/37 | 0.342 |
44
+ | Discovery, field-weighted BM25 | 19/37 | 28/37 | 29/37 | 26/37 | 0.628 |
45
+ | Validation, previous ranking | 4/24 | 7/24 | 12/24 | 7/24 | 0.272 |
46
+ | Validation, field-weighted | 11/24 | 16/24 | 20/24 | 16/24 | 0.588 |
47
+
48
+ The previous ranking placed four of the five exact identifiers first and did not return the `on_startup` wiki entry at all; the current one places each first, with installed documentation ahead of the wiki.
49
+ Both returned no results for the two negative queries.
50
+ On the original nine questions, all nine stay within five results, three rank first rather than five, and one moves from fourth to fifth.
51
+
52
+ In three repeated runs, the first query after a source change took 370–386 ms to index about twelve thousand sections, compared with 147–159 ms with the previous ranking.
53
+ Later queries took a median of 37 ms, compared with 49–63 ms, and the median ranked reply was about 3.7 KB in both.
54
+
55
+ Twelve plain-word questions across both sets still miss the top five.
56
+ Most use vocabulary the documentation does not: "national spirit" where script says `ideas`, "give a state" for `transfer_state`, "repeat effects" for `for_loop_effect`, and "build a factory" for `add_building_construction`.
57
+ Search the script name when it is known; the ranking does not add synonyms for individual questions.
58
+ These are 61 task questions over one documentation snapshot, not a general precision guarantee.
59
+
60
+ Run both sets with:
61
+
62
+ ```bash
63
+ npx tsx scripts/evaluate-reference-discovery.ts MOD_ROOT GAME_ROOT
64
+ npx tsx scripts/evaluate-reference-discovery.ts MOD_ROOT GAME_ROOT --validation
65
+ ```
66
+
67
+ The script exits with a failure when a case has no expected answer in the supplied sources.
68
+
30
69
  ## Compact context budgets
31
70
 
32
71
  A 2026-09-27 check of the installed 3.5.0 server found that eight GUI results could contain only wiki sections even though the installed GUI documentation was available. The 3.5.1 source qualifies limits of one, two, and eight citations across the same six work surfaces. All eighteen cases retained installed documentation; limits of two or more also retained wiki citations. Required sources excluded by the limit appeared in `omittedSources`, separately from files absent under `missing`. The nine search queries still found all expected answer-bearing sections.
package/docs/setup.md CHANGED
@@ -9,6 +9,9 @@ Keep an installed copy of Hearts of Iron IV available for vanilla references, ar
9
9
  npm install --global hoi4-agent-tools
10
10
  ```
11
11
 
12
+ The package publishes an `npm-shrinkwrap.json`, so every registry or `npx` install receives the same reviewed dependency versions.
13
+ npm installs the image library's prebuilt binaries for every supported platform from it, about 280 MiB in total; the server loads only the one for your system.
14
+
12
15
  Source inspection can work without an installed game.
13
16
  Previews need the assets and fonts referenced by the mod; missing files are reported in the result.
14
17
 
@@ -53,6 +56,18 @@ For a custom configuration location, add `--config PATH` to both setup commands.
53
56
  `--workspace-storage-root PATH` chooses where generated indexes and images are saved.
54
57
  Linked mod directories are not followed; configure their real parent directory instead.
55
58
 
59
+ ### How sources are layered
60
+
61
+ Sources load in the engine's order: the base game, then each installed folder under `dlc/` and `integrated_dlc/` in order of its internal DLC ID, then dependencies, then the mod.
62
+ A later layer replaces a file with the same path from an earlier one, so a DLC's version of an interface file is the active one and the base game's copy is reported as shadowed.
63
+ Results name a DLC layer by its folder, for example `dlc023_man_the_guns:interface/mtg_leaders.gfx`.
64
+ Only folders that contain a `dlcNNN.dlc` descriptor and resolve inside the game root are layers; archives inside a DLC folder are not unpacked.
65
+ An installed DLC folder is not proof that the DLC is enabled in a particular playset; check `has_dlc` where content depends on it.
66
+ Set `"includeGameDlc": false` on a configured workspace to analyze the base game alone.
67
+
68
+ `replace_path` entries in a mod's or dependency's `descriptor.mod` unload earlier-loaded files under that folder, as the engine does, and join any `replacePaths` configured for the workspace.
69
+ Entries that are not plain relative folders, such as `../outside` or wildcard paths, are ignored.
70
+
56
71
  ## Add local reference material
57
72
 
58
73
  Place an offline wiki snapshot in `paradox_wiki/` inside the mod.
package/docs/tools.md CHANGED
@@ -4,43 +4,43 @@ Most users can ask their agent in ordinary language; the [examples guide](exampl
4
4
  This page lists exact tool names for agents and integrations.
5
5
  Use the connected server's live schema for the fields accepted by each call.
6
6
 
7
- | Tool | Purpose |
8
- | --------------------------- | -------------------------------------------------------------------------------------------- |
9
- | `hoi4.focus_inspect` | Read focus trees, continuous-focus placement, and structural or reference problems. |
10
- | `hoi4.focus_render` | Produce fast HTML, SVG, JSON, and source-linked layout artifacts. |
11
- | `hoi4.focus_raster` | Produce a PNG preview with decoded source icons. |
12
- | `hoi4.focus_rewrite` | Create or update a focus tree. |
13
- | `hoi4.gui_inspect` | Read a scripted GUI and its linked assets and logic. |
14
- | `hoi4.gui_render` | Render generated and explicit GUI scenarios, states, resolutions, and layout diagnostics. |
15
- | `hoi4.gui_rewrite` | Create or update a GUI source package. |
16
- | `hoi4.map_inspect` | Search, click, navigate, and inspect the complete rendered map and its linked data. |
17
- | `hoi4.map_render` | Render full-map layers, overlays, names, IDs, coordinates, and source-linked catalogs. |
18
- | `hoi4.map_rewrite` | Create or update states, provinces, IDs, networks, positions, and connected map data. |
19
- | `hoi4.reference_context` | Get compact, cited wiki and installed documentation pointers for a modding surface. |
20
- | `hoi4.reference_search` | Search bounded local documentation sections. |
21
- | `hoi4.reference_read` | Read one revision-bound section, with line continuation. |
22
- | `hoi4.source_lookup` | Find exact definitions, overrides, usages, and narrow source blocks. |
23
- | `hoi4.script_validate` | Check snippet syntax, native command kinds, and declared scopes against local documentation. |
24
- | `hoi4.event_inspect` | Scan, trace, explain, lint, or assess event chains and their state flow. |
25
- | `hoi4.event_render` | Render source-linked event routes, options, timing, state, scope, and unresolved edges. |
26
- | `hoi4.event_compare` | Compare event-chain topology and diagnostics between revisions. |
27
- | `hoi4.impact_inspect` | Trace symbol and changed-file consumers across source systems and compare proposals. |
28
- | `hoi4.decision_inspect` | Inventory and evaluate decisions or missions under declared scenarios and source changes. |
29
- | `hoi4.mechanic_test` | Execute bounded source effects on a copied declared scenario and check assertions. |
30
- | `hoi4.package_check` | Check declarative package definitions, calls, registrations, assets, and case links. |
31
- | `hoi4.scenario_test` | Run named source and domain cases in resumable, revision-bound batches. |
32
- | `hoi4.job_inspect` | Inspect durable background work or retrieve its completed tool result. |
33
- | `hoi4.job_cancel` | Durably request cancellation of authorized background work. |
34
- | `hoi4.tech_inspect` | Scan, trace, explain, lint, and assess technology and doctrine systems. |
35
- | `hoi4.tech_render` | Render source layouts with real item sizes and year guides, plus dependencies and assets. |
36
- | `hoi4.tech_compare` | Compare technology graphs, placements, references, diagnostics, and source overlays. |
37
- | `hoi4.probability_inspect` | Locate weighted logic and discover compatible adapters, candidates, and required inputs. |
38
- | `hoi4.probability_evaluate` | Evaluate supported weights, probability and timing models, and missing inputs. |
39
- | `hoi4.probability_sweep` | Find sensitivity, breakpoints, cliffs, and rank reversals across declared ranges. |
40
- | `hoi4.probability_simulate` | Run deterministic sampled analysis with confidence and convergence data. |
41
- | `hoi4.probability_sequence` | Analyze declared recovery, caps, cooldowns, resets, timers, and terminal states. |
42
- | `hoi4.probability_compare` | Attribute AI-weight and MTTH changes between real or proposed source. |
43
- | `hoi4.probability_render` | Render cached rankings, matrices, timing, sensitivity, sequence, and comparisons. |
7
+ | Tool | Purpose |
8
+ | --------------------------- | ---------------------------------------------------------------------------------------------------------------- |
9
+ | `hoi4.focus_inspect` | Read focus trees, continuous-focus placement, and structural or reference problems. |
10
+ | `hoi4.focus_render` | Produce fast HTML, SVG, JSON, and source-linked layout artifacts. |
11
+ | `hoi4.focus_raster` | Produce a PNG preview with decoded source icons. |
12
+ | `hoi4.focus_rewrite` | Create or update a focus tree. |
13
+ | `hoi4.gui_inspect` | Read a scripted GUI and its linked assets and logic. |
14
+ | `hoi4.gui_render` | Render generated and explicit GUI scenarios, states, resolutions, and layout diagnostics. |
15
+ | `hoi4.gui_rewrite` | Create or update a GUI source package. |
16
+ | `hoi4.map_inspect` | Search, click, navigate, and inspect the complete rendered map and its linked data. |
17
+ | `hoi4.map_render` | Render full-map layers, overlays, names, IDs, coordinates, and source-linked catalogs. |
18
+ | `hoi4.map_rewrite` | Create or update states, provinces, IDs, networks, positions, and connected map data. |
19
+ | `hoi4.reference_context` | Get compact, cited wiki and installed documentation pointers for a modding surface. |
20
+ | `hoi4.reference_search` | Search local documentation in plain words or script names; each result names its answering line. |
21
+ | `hoi4.reference_read` | Read one revision-bound section, with line continuation. |
22
+ | `hoi4.source_lookup` | Find exact definitions, overrides and usages across game, DLC and mod, or the definition containing a file line. |
23
+ | `hoi4.script_validate` | Check snippet syntax, native command kinds, and declared scopes against local documentation. |
24
+ | `hoi4.event_inspect` | Scan, trace, explain, lint, or assess event chains and their state flow. |
25
+ | `hoi4.event_render` | Render source-linked event routes, options, timing, state, scope, and unresolved edges. |
26
+ | `hoi4.event_compare` | Compare event-chain topology and diagnostics between revisions. |
27
+ | `hoi4.impact_inspect` | Trace symbol and changed-file consumers across source systems and compare proposals. |
28
+ | `hoi4.decision_inspect` | Inventory and evaluate decisions or missions under declared scenarios and source changes. |
29
+ | `hoi4.mechanic_test` | Execute bounded source effects on a copied declared scenario and check assertions. |
30
+ | `hoi4.package_check` | Check declarative package definitions, calls, registrations, assets, and case links. |
31
+ | `hoi4.scenario_test` | Run named source and domain cases in resumable, revision-bound batches. |
32
+ | `hoi4.job_inspect` | Inspect durable background work or retrieve its completed tool result. |
33
+ | `hoi4.job_cancel` | Durably request cancellation of authorized background work. |
34
+ | `hoi4.tech_inspect` | Scan, trace, explain, lint, and assess technology and doctrine systems. |
35
+ | `hoi4.tech_render` | Render source layouts with real item sizes and year guides, plus dependencies and assets. |
36
+ | `hoi4.tech_compare` | Compare technology graphs, placements, references, diagnostics, and source overlays. |
37
+ | `hoi4.probability_inspect` | Locate weighted logic and discover compatible adapters, candidates, and required inputs. |
38
+ | `hoi4.probability_evaluate` | Evaluate supported weights, probability and timing models, and missing inputs. |
39
+ | `hoi4.probability_sweep` | Find sensitivity, breakpoints, cliffs, and rank reversals across declared ranges. |
40
+ | `hoi4.probability_simulate` | Run deterministic sampled analysis with confidence and convergence data. |
41
+ | `hoi4.probability_sequence` | Analyze declared recovery, caps, cooldowns, resets, timers, and terminal states. |
42
+ | `hoi4.probability_compare` | Attribute AI-weight and MTTH changes between real or proposed source. |
43
+ | `hoi4.probability_render` | Render cached rankings, matrices, timing, sensitivity, sequence, and comparisons. |
44
44
 
45
45
  ## Reading results
46
46
 
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "hoi4-agent-tools",
3
- "version": "3.7.0",
3
+ "version": "3.8.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "hoi4-agent-tools",
9
- "version": "3.7.0",
9
+ "version": "3.8.1",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "@fontsource-variable/roboto": "5.3.0",
@@ -42,6 +42,7 @@
42
42
  "fast-check": "4.9.0",
43
43
  "pixelmatch": "7.2.0",
44
44
  "prettier": "3.9.6",
45
+ "semver": "7.8.5",
45
46
  "tsx": "4.23.11",
46
47
  "typescript": "6.0.3",
47
48
  "typescript-eslint": "8.66.0",
@@ -715,9 +716,9 @@
715
716
  }
716
717
  },
717
718
  "node_modules/@hono/node-server": {
718
- "version": "2.1.0",
719
- "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-2.1.0.tgz",
720
- "integrity": "sha512-XovyyCCnBzW+zKu+z/zq8hwNs4KOR5rEMAOxo2f40Q5xoOI37IMm6MIg2COOUtUApo0i6850MTBKH2u4QLGIqg==",
719
+ "version": "2.1.3",
720
+ "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-2.1.3.tgz",
721
+ "integrity": "sha512-TA//nWMqPhbfdfneACk6t5a9eqbS9lABEPyKn0/xZTah3H3U2XaVg85rJFl0/Fyit0I552YDHgXGVSf3GwqbUw==",
721
722
  "license": "MIT",
722
723
  "engines": {
723
724
  "node": ">=20"
@@ -1755,6 +1756,18 @@
1755
1756
  }
1756
1757
  }
1757
1758
  },
1759
+ "node_modules/@modelcontextprotocol/node/node_modules/@hono/node-server": {
1760
+ "version": "1.19.17",
1761
+ "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-1.19.17.tgz",
1762
+ "integrity": "sha512-dSneS5qhiauZWGDCeK4o695Xd9nUNjviSZCMQrj10eetr8Uln1ucn6bbphOM6UynAMMtNIzZNSpL9vnASJwrPQ==",
1763
+ "license": "MIT",
1764
+ "engines": {
1765
+ "node": ">=18.14.1"
1766
+ },
1767
+ "peerDependencies": {
1768
+ "hono": "^4"
1769
+ }
1770
+ },
1758
1771
  "node_modules/@modelcontextprotocol/sdk": {
1759
1772
  "version": "1.30.0",
1760
1773
  "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.30.0.tgz",
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": "3.7.0",
4
+ "version": "3.8.1",
5
5
  "description": "HOI4 modding tools for agents: local references, visual previews, focus trees, interfaces and maps.",
6
6
  "type": "module",
7
7
  "license": "Apache-2.0",
@@ -137,13 +137,13 @@
137
137
  "fast-check": "4.9.0",
138
138
  "pixelmatch": "7.2.0",
139
139
  "prettier": "3.9.6",
140
+ "semver": "7.8.5",
140
141
  "tsx": "4.23.11",
141
142
  "typescript": "6.0.3",
142
143
  "typescript-eslint": "8.66.0",
143
144
  "vitest": "4.1.11"
144
145
  },
145
146
  "overrides": {
146
- "@hono/node-server": "2.1.0",
147
147
  "brace-expansion": "5.0.12",
148
148
  "fast-uri": "3.1.8",
149
149
  "qs": "6.16.0",