hoi4-agent-tools 4.7.0 → 4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/README.md +32 -13
- package/dist/hoi4_agent_tools/core/engine-client.js +74 -5
- package/dist/hoi4_agent_tools/core/operation-result.js +9 -0
- package/dist/hoi4_agent_tools/core/resident-engine.js +273 -0
- package/dist/hoi4_agent_tools/core/temporary-directories.js +3 -2
- package/dist/hoi4_agent_tools/decision/service.js +7 -0
- package/dist/hoi4_agent_tools/event/service.js +18 -6
- package/dist/hoi4_agent_tools/event/summary.js +9 -0
- package/dist/hoi4_agent_tools/focus/engine-layout.js +1 -1
- package/dist/hoi4_agent_tools/focus/game-render.js +72 -0
- package/dist/hoi4_agent_tools/focus/game-view-output.js +160 -0
- package/dist/hoi4_agent_tools/focus/native-effects.js +4 -4
- package/dist/hoi4_agent_tools/focus/quality/focus-quality-calibration.json +241 -241
- package/dist/hoi4_agent_tools/focus/quality/orthogonal.js +30 -19
- package/dist/hoi4_agent_tools/focus/quality/schematic.js +5 -3
- package/dist/hoi4_agent_tools/focus/quality/scorecard.js +1 -1
- package/dist/hoi4_agent_tools/focus/render.js +21 -9
- package/dist/hoi4_agent_tools/focus/tool-operations.js +158 -3
- package/dist/hoi4_agent_tools/gui/assets.js +18 -0
- package/dist/hoi4_agent_tools/gui/dds.js +38 -5
- package/dist/hoi4_agent_tools/gui/engine-textures.js +48 -0
- package/dist/hoi4_agent_tools/gui/source-graph.js +7 -0
- package/dist/hoi4_agent_tools/gui/tool-operations.js +23 -4
- package/dist/hoi4_agent_tools/gui/validators.js +31 -2
- package/dist/hoi4_agent_tools/ideas/inspect.js +43 -0
- package/dist/hoi4_agent_tools/localisation/inspect.js +34 -0
- package/dist/hoi4_agent_tools/mcp/server/argument-errors.js +2 -0
- package/dist/hoi4_agent_tools/mcp/tools/event.js +2 -0
- package/dist/hoi4_agent_tools/mcp/tools/focus.js +1 -1
- package/dist/hoi4_agent_tools/mcp/tools/reference.js +18 -0
- package/dist/hoi4_agent_tools/probability/operations.js +27 -1
- package/dist/hoi4_agent_tools/probability/service.js +91 -11
- package/dist/hoi4_agent_tools/probability/source-analysis.js +2 -2
- package/dist/hoi4_agent_tools/probability/sweep.js +20 -6
- package/dist/hoi4_agent_tools/reference/command-phrases.json +11065 -0
- package/dist/hoi4_agent_tools/reference/error-log.js +24 -0
- package/dist/hoi4_agent_tools/reference/known-mistakes.js +8 -5
- package/dist/hoi4_agent_tools/reference/known-mistakes.json +4 -4
- package/dist/hoi4_agent_tools/reference/operations.js +68 -2
- package/dist/hoi4_agent_tools/reference/ranking.js +32 -0
- package/dist/hoi4_agent_tools/reference/script-validation.js +46 -6
- package/dist/hoi4_agent_tools/reference/service.js +33 -0
- package/dist/hoi4_agent_tools/reference/source-lookup.js +8 -0
- package/dist/hoi4_agent_tools/schemas/focus-requests.js +4 -0
- package/dist/hoi4_agent_tools/schemas/ideas.js +142 -0
- package/dist/hoi4_agent_tools/schemas/localisation.js +94 -0
- package/dist/hoi4_agent_tools/schemas/mod-tools.js +11 -0
- package/dist/hoi4_agent_tools/version.js +1 -1
- package/docs/focus.md +9 -5
- package/docs/research/reference-benchmark.md +41 -0
- package/docs/tools.md +43 -39
- package/docs/troubleshooting.md +13 -12
- package/engine/README.md +284 -0
- package/engine/bin/darwin-arm64/hoi4-engine +0 -0
- package/engine/bin/linux-arm64/hoi4-engine +0 -0
- package/engine/bin/linux-x64/hoi4-engine +0 -0
- package/engine/bin/manifest.json +26 -0
- package/engine/bin/win32-x64/hoi4-engine.exe +0 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +4 -1
- package/schemas/configuration.schema.json +1 -1
- package/schemas/continuous-focus-palette.schema.json +1 -1
- package/schemas/custom-weighted-pool.schema.json +1 -1
- package/schemas/decision-inspect-input.schema.json +1 -1
- package/schemas/error-log-input.schema.json +1 -1
- package/schemas/event-feature-manifest.schema.json +1 -1
- package/schemas/focus-plan.schema.json +1 -1
- package/schemas/focus-planning-sidecar.schema.json +1 -1
- package/schemas/geography-model.schema.json +1 -1
- package/schemas/gui-animation-source.schema.json +1 -1
- package/schemas/gui-helper.schema.json +1 -1
- package/schemas/gui-scenario.schema.json +1 -1
- package/schemas/helper-expansion-request.schema.json +1 -1
- package/schemas/helper-expansion-summary.schema.json +1 -1
- package/schemas/impact-inspect-input.schema.json +1 -1
- package/schemas/map-operation.schema.json +1 -1
- package/schemas/mechanic-test-input.schema.json +1 -1
- package/schemas/mod-index-input.schema.json +1 -1
- package/schemas/operation-result.schema.json +1 -1
- package/schemas/package-check-input.schema.json +1 -1
- package/schemas/package-manifest.schema.json +1 -1
- package/schemas/probability-analysis-result.schema.json +1 -1
- package/schemas/probability-compare-input.schema.json +1 -1
- package/schemas/probability-evaluate-input.schema.json +1 -1
- package/schemas/probability-inspect-input.schema.json +1 -1
- package/schemas/probability-render-input.schema.json +1 -1
- package/schemas/probability-scenario-set.schema.json +1 -1
- package/schemas/probability-sequence-input.schema.json +1 -1
- package/schemas/probability-simulate-input.schema.json +1 -1
- package/schemas/probability-sweep-input.schema.json +1 -1
- package/schemas/reference-context-input.schema.json +1 -1
- package/schemas/reference-read-input.schema.json +1 -1
- package/schemas/reference-search-input.schema.json +1 -1
- package/schemas/reference-sheets.schema.json +1 -1
- package/schemas/scenario-suite.schema.json +1 -1
- package/schemas/scenario-test-input.schema.json +1 -1
- package/schemas/script-validate-input.schema.json +1 -1
- package/schemas/shared-scenario.schema.json +1 -1
- package/schemas/source-lookup-input.schema.json +1 -1
- package/server.json +2 -2
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
import { workspaceIdSchema } from './common.js';
|
|
3
|
+
/** `hoi4.localisation_inspect`, answered by `hoi4-engine localisation` (ADR 0074). */
|
|
4
|
+
export const localisationInspectRequestSchema = z
|
|
5
|
+
.object({
|
|
6
|
+
workspaceId: workspaceIdSchema,
|
|
7
|
+
/** key: one key in every language. audit: the mod's problems. coverage: keys per language. */
|
|
8
|
+
mode: z.enum(['key', 'audit', 'coverage']).default('audit'),
|
|
9
|
+
key: z.string().min(1).max(256).optional(),
|
|
10
|
+
/** Restricts audit and coverage to one language, for example `german`. */
|
|
11
|
+
language: z
|
|
12
|
+
.string()
|
|
13
|
+
.regex(/^[a-z_]{2,32}$/u)
|
|
14
|
+
.optional(),
|
|
15
|
+
/** key: mentions listed. audit: examples kept per problem code. */
|
|
16
|
+
limit: z.number().int().min(1).max(50).default(5),
|
|
17
|
+
})
|
|
18
|
+
.strict()
|
|
19
|
+
.refine((input) => input.mode !== 'key' || input.key !== undefined, {
|
|
20
|
+
message: 'mode key needs a key',
|
|
21
|
+
path: ['key'],
|
|
22
|
+
});
|
|
23
|
+
const definitionSchema = z
|
|
24
|
+
.object({
|
|
25
|
+
language: z.string().max(64),
|
|
26
|
+
text: z.string().max(2400),
|
|
27
|
+
path: z.string().max(1024),
|
|
28
|
+
line: z.number().int().min(0),
|
|
29
|
+
layer: z.string().max(256),
|
|
30
|
+
layerKind: z.enum(['game', 'dlc', 'dependency', 'mod']),
|
|
31
|
+
replace: z.boolean(),
|
|
32
|
+
})
|
|
33
|
+
.strict();
|
|
34
|
+
const problemSchema = z
|
|
35
|
+
.object({
|
|
36
|
+
code: z.string().max(64),
|
|
37
|
+
severity: z.enum(['warning', 'info']),
|
|
38
|
+
key: z.string().max(256).nullable(),
|
|
39
|
+
language: z.string().max(64).nullable(),
|
|
40
|
+
path: z.string().max(1024),
|
|
41
|
+
line: z.number().int().min(0),
|
|
42
|
+
message: z.string().max(1200),
|
|
43
|
+
})
|
|
44
|
+
.strict();
|
|
45
|
+
/** The engine's answer, checked as it arrives. */
|
|
46
|
+
export const localisationEngineResponseSchema = z
|
|
47
|
+
.object({
|
|
48
|
+
mode: z.enum(['key', 'audit', 'coverage']),
|
|
49
|
+
shippedLanguages: z.array(z.string().max(64)).max(64),
|
|
50
|
+
supportedLanguages: z.array(z.string().max(64)).max(64),
|
|
51
|
+
mainLanguage: z.string().max(64).nullable(),
|
|
52
|
+
filesRead: z.number().int().min(0),
|
|
53
|
+
key: z
|
|
54
|
+
.object({
|
|
55
|
+
key: z.string().max(256),
|
|
56
|
+
found: z.boolean(),
|
|
57
|
+
definitions: z.array(definitionSchema).max(512),
|
|
58
|
+
missingLanguages: z.array(z.string().max(64)).max(64),
|
|
59
|
+
mentions: z
|
|
60
|
+
.array(z
|
|
61
|
+
.object({ path: z.string().max(1024), line: z.number().int(), layer: z.string() })
|
|
62
|
+
.strict())
|
|
63
|
+
.max(200),
|
|
64
|
+
mentionsTruncated: z.boolean(),
|
|
65
|
+
suggestions: z.array(z.string().max(256)).max(3).optional(),
|
|
66
|
+
})
|
|
67
|
+
.strict()
|
|
68
|
+
.optional(),
|
|
69
|
+
audit: z
|
|
70
|
+
.object({
|
|
71
|
+
counts: z.record(z.string(), z.number().int().min(0)),
|
|
72
|
+
problems: z.array(problemSchema).max(4000),
|
|
73
|
+
truncated: z.boolean(),
|
|
74
|
+
})
|
|
75
|
+
.strict()
|
|
76
|
+
.optional(),
|
|
77
|
+
coverage: z
|
|
78
|
+
.array(z
|
|
79
|
+
.object({
|
|
80
|
+
language: z.string().max(64),
|
|
81
|
+
files: z.number().int().min(0),
|
|
82
|
+
keys: z.number().int().min(0),
|
|
83
|
+
missing: z.number().int().min(0),
|
|
84
|
+
supported: z.boolean(),
|
|
85
|
+
})
|
|
86
|
+
.strict())
|
|
87
|
+
.max(64)
|
|
88
|
+
.optional(),
|
|
89
|
+
})
|
|
90
|
+
.strict();
|
|
91
|
+
/** The tool's data: the engine's answer with the problem examples bounded for the inline reply. */
|
|
92
|
+
export const localisationInspectDataSchema = localisationEngineResponseSchema.extend({
|
|
93
|
+
durationMs: z.number().int().min(0),
|
|
94
|
+
});
|
|
@@ -35,6 +35,17 @@ export const errorLogDataSchema = z
|
|
|
35
35
|
entries: z.number().int().min(0),
|
|
36
36
|
})
|
|
37
37
|
.strict(),
|
|
38
|
+
/**
|
|
39
|
+
* The mods the launch that wrote the log ran with, from `logs/system.log` of the same launch.
|
|
40
|
+
* Absent when that log is missing; `modLoaded` is absent when the mod has no descriptor name.
|
|
41
|
+
*/
|
|
42
|
+
launch: z
|
|
43
|
+
.object({
|
|
44
|
+
activeMods: z.array(z.string().max(256)).max(64),
|
|
45
|
+
modLoaded: z.boolean().optional(),
|
|
46
|
+
})
|
|
47
|
+
.strict()
|
|
48
|
+
.optional(),
|
|
38
49
|
scope: z.enum(['all', 'mod', 'unlocated']),
|
|
39
50
|
totalEntries: z.number().int().min(0),
|
|
40
51
|
distinctEntries: z.number().int().min(0),
|
|
@@ -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 = '4.
|
|
3
|
+
export const PACKAGE_VERSION = '4.8.0';
|
|
4
4
|
export const MCP_PROTOCOL_VERSION = LATEST_PROTOCOL_VERSION;
|
|
5
5
|
export const CONFIG_VERSION = 1;
|
|
6
6
|
export const TRANSACTION_VERSION = 2;
|
package/docs/focus.md
CHANGED
|
@@ -153,13 +153,13 @@ The result also carries a **scorecard** (at most 12 rows inline, the full list i
|
|
|
153
153
|
| D1, D2 | Longest run of single-successor focuses, and the fraction of leaves. |
|
|
154
154
|
| D3, D4 | Exclusive choices that rejoin six or more rows later, and a canvas taller than 2.5 rows per plaque column. |
|
|
155
155
|
|
|
156
|
-
The limits of S1 to S11, H4, H5, D1 and D2 are computed from the installed game's national focus trees (67 trees of 8 or more focuses, in two size buckets: 40 to 120 and over 120 focuses) and stored as derived numbers in `src/hoi4_agent_tools/focus/quality/focus-quality-calibration.json`. `review` starts at the edge of the vanilla range; `revise` starts a margin beyond it. H4, H5 and S9 can raise a tree to `review` at most
|
|
156
|
+
The limits of S1 to S11, H4, H5, D1 and D2 are computed from the installed game's national focus trees (67 trees of 8 or more focuses, in two size buckets: 40 to 120 and over 120 focuses) and stored as derived numbers in `src/hoi4_agent_tools/focus/quality/focus-quality-calibration.json`. `review` starts at the edge of the vanilla range; `revise` starts a margin beyond it. H4, H5 and S9 can raise a tree to `review` at most (`advisoryMetrics` in the calibration file). Design flags (D1 to D4) are proxies for the question "does the player choose anything?" and always go to a person: the tool never changes prerequisites, rewards or names for them.
|
|
157
157
|
|
|
158
|
-
`npm run focus:calibrate -- --write` recomputes the file from the installed game. The local test `tests/local/focus-quality-calibration.test.ts` recomputes it whenever the game is found and fails when the stored file differs. `npm run focus:calibrate -- --report` prints how often an unseen vanilla-quality tree is flagged: about
|
|
158
|
+
`npm run focus:calibrate -- --write` recomputes the file from the installed game. The local test `tests/local/focus-quality-calibration.test.ts` recomputes it whenever the game is found and fails when the stored file differs. `npm run focus:calibrate -- --report` prints how often an unseen vanilla-quality tree is flagged: about 80 percent `pass`, 17 percent `review` and 3 percent `revise` with the limits fitted without that tree (game 1.19.4.1).
|
|
159
159
|
|
|
160
160
|
### Connector model
|
|
161
161
|
|
|
162
|
-
The game draws right-angle connectors: a stem leaves the parent, a horizontal bar runs in the
|
|
162
|
+
The game draws right-angle connectors: a short stem leaves the bottom of the parent's plaque, a horizontal bar runs just under the parent (0.28 rows below its row), and a long vertical drops in the child's column from the bar into the top of the child's icon. A plaque is centred on its focus's coordinates, about 1.61 columns wide and 0.28 rows high, with the icon above it (icon and plaque span about 0.8 rows). A connector across several rows therefore runs down the child's column past the rows in between, and that vertical is what crosses other bars or passes through other plaques. Crossings, connector-through-plaque and shared-bar counts use that model, not the curved connector of the icon render, which over-reported crossings by a factor of nine on vanilla trees. All connectors between the parents and children of an **all-to-all bundle** (two or more parents that are each a prerequisite of the same two or more children) share one bar in the game and are never counted against each other, and neither are the members of an OR group. All-to-all bundles and OR groups share one dotted bar at the same height under the parents, and each child gets one vertical in its own column. The in-game run of 2026-11-02 on 1.19.4.1, at the default UI scale and zoom (1 column = 96 px, 1 row = 130 px), confirmed the plaque width and this bar placement, including multi-row connectors, and showed that an exclusive mark sits midway between the two focuses on the plaque line and fits at a spacing of 2. Other UI scales and zoom levels are unverified. The Rust layout engine uses the same rules (`engine/crates/focus/src/geometry.rs`), and `engine/crates/focus/tests/fixtures/connector-parity.json` holds hand-counted trees that both implementations check.
|
|
163
163
|
|
|
164
164
|
`FOCUS_LAYOUT_CONNECTOR_CROSSING_UNSATISFIED`, `FOCUS_AVOIDABLE_CONNECTOR_CROSSING` and `FOCUS_LAYOUT_CONNECTOR_THROUGH_NODE` come from the curved model and are no longer shown in inspect and render results; the linked artifact keeps them.
|
|
165
165
|
|
|
@@ -237,7 +237,7 @@ The result has the usual `layoutQuality` verdict and `layoutDelta`, plus `data.e
|
|
|
237
237
|
Nothing is written when the engine refuses:
|
|
238
238
|
|
|
239
239
|
- `FOCUS_ENGINE_BLOCKED`: the tree cannot be placed without breaking a layout rule. The message names the engine's reasons (`FOCUS_ENGINE_NO_CORRIDOR`, `FOCUS_ENGINE_SPACING_CONFLICT` or `FOCUS_ENGINE_PARENT_NOT_ABOVE`) and, for a placement with no free place, `needsRoom`: the shift that would make room (`fromX`, `columns`, `direction` and the focuses that would move). Retry with `allowShift: true` to apply it.
|
|
240
|
-
- `FOCUS_ENGINE_UNAVAILABLE`: no usable `hoi4-engine` binary. The tool uses `HOI4_ENGINE` (an absolute path) and otherwise the binary
|
|
240
|
+
- `FOCUS_ENGINE_UNAVAILABLE`: no usable `hoi4-engine` binary. The tool uses `HOI4_ENGINE` (an absolute path) and otherwise the binary the package ships under `engine/bin/<platform>-<arch>/` for Windows x64, macOS arm64 and Linux x64 and arm64 (glibc), which runs only when its SHA-256 matches `engine/bin/manifest.json`. The message gives the reason (`binary_not_found`, `binary_path_invalid`, `binary_checksum_mismatch`, `spawn_failed`, `timeout` after 30 seconds, `output_too_large`, `exit_status` or `invalid_output`). On another platform, or from a source checkout, set `HOI4_ENGINE` to a built binary (`cargo build --release -p hoi4-engine-cli` in `engine/`); after `binary_checksum_mismatch`, reinstall the package. There is no silent fallback to the TypeScript solver. `authored` and `compact` do not need the engine.
|
|
241
241
|
- `FOCUS_ENGINE_REQUEST_INVALID`: the engine refused the tree, for example for a prerequisite or relative-position cycle. The message has the engine's code.
|
|
242
242
|
- `FOCUS_ENGINE_LAYOUT_MISMATCH`: the coordinates prepared for the source differ from the engine's result.
|
|
243
243
|
|
|
@@ -280,6 +280,10 @@ Pass up to 16 `cropFocusIds` to `hoi4.focus_render` for source-linked problem cr
|
|
|
280
280
|
|
|
281
281
|
The layout JSON reports horizontal, vertical, and Manhattan grid spans for every prerequisite connector in `layout.connectorMeasurements`.
|
|
282
282
|
|
|
283
|
-
`hoi4.focus_render` returns an in-game-style schematic of the layout inline (no second call): an overview of at most 1,500 pixels and up to five close-ups of the places the scorecard blames, or of the branches named in `cropBranchIds` (up to 8; a derived branch is named by its first focus) and the focuses named in `cropFocusIds`. Failing focuses are outlined (red for hard defects, amber otherwise), exclusive choices are joined by red dashes, OR prerequisites are dotted, and a ruler shows the grid coordinates. Pass `inline: false` for linked artifacts only. The inline pictures are tool renders, not game screenshots, and carry no icons; the result lists each image in `data.inlineImages` with its region. It also writes complete HTML, SVG, JSON and source-map artifacts and a
|
|
283
|
+
`hoi4.focus_render` returns an in-game-style schematic of the layout inline (no second call): an overview of at most 1,500 pixels and up to five close-ups of the places the scorecard blames, or of the branches named in `cropBranchIds` (up to 8; a derived branch is named by its first focus) and the focuses named in `cropFocusIds`. Failing focuses are outlined (red for hard defects, amber otherwise), exclusive choices are joined by red dashes, OR prerequisites are dotted, and a ruler shows the grid coordinates. Pass `inline: false` for linked artifacts only. The inline pictures are tool renders, not game screenshots, and carry no icons; the result lists each image in `data.inlineImages` with its region. It also writes complete HTML, SVG, JSON and source-map artifacts and a PNG.
|
|
284
|
+
|
|
285
|
+
The PNG is the game view when the `hoi4-engine` binary is available (shipped with releases, or `HOI4_ENGINE`): the focus tree drawn from the game's own sprites, textures, bitmap font and `interface/nationalfocusview.gui` in load order, so it shows the tree window background, the plaques, icons, titles, connector tiles and exclusive marks as the game does at the default UI scale. Titles are localised; a title without localisation shows its raw key, like the game, and scripted localisation (`[...]`) is shown as written. Every sprite, texture, font or glyph the view cannot draw is reported as `FOCUS_GAME_VIEW_ASSET_MISSING` with the focuses it affects. Focuses are drawn as at the start of a game: `can start` without prerequisites, `unavailable` otherwise; `available` and `bypass` triggers are not evaluated. Without the engine the PNG is the schematic with decoded icons. The game view is a tool render, never a game screenshot.
|
|
286
|
+
|
|
287
|
+
Pass `view: "game"` for the game view alone: the PNG, a JSON report with each focus's box and every missing asset, an SVG hover map on the same pixels, an HTML viewer with wheel zoom, drag and hover titles, and one inline overview of at most 1,500 pixels. It skips the schematic SVG, the schematic pictures and the presentation pass, so it is fast enough to call after every edit, and the layout verdict is still computed. It needs the engine and answers `FOCUS_GAME_VIEW_UNAVAILABLE` without it. The engine process stays running between calls (ADR 0077) and keeps the parsed `.gfx` files, folder listings, decoded textures and fonts of each workspace, checking them against the disk on every call, so a repeat render costs the drawing alone. Pass `png: false` for the faster structural view without decoding icons. National trees with 200 or more focuses raster at half scale by default; pass `reviewScale` from `0.25` through `1` when a different PNG size is needed.
|
|
284
288
|
|
|
285
289
|
The public workflow is regression-tested with 1,024-focus creation, compact rewrites, deterministic repeat runs, inspection, vector rendering, and raster rendering. A separate 1,024-icon test decodes a distinct texture for every focus. Large source diffs use the same deterministic review-artifact path instead of blocking at the quadratic matrix size.
|
|
@@ -176,6 +176,47 @@ A warm read took 13 ms rather than 25–84 ms.
|
|
|
176
176
|
Later end-to-end runs shared the machine with other heavy work: three alternating rounds of the old and new code measured warm search medians of 145–183 ms and 84–583 ms, so no end-to-end speed gain is claimed from them.
|
|
177
177
|
The first `hoi4.source_lookup` still builds the whole game and mod symbol index: 53–66 seconds in three runs before this change on a lightly loaded machine, 108–192 seconds under the later load. This change does not touch it, and moving that index to the shared Rust engine is planned separately.
|
|
178
178
|
|
|
179
|
+
## Command phrasings, verb direction and a fresh blind set
|
|
180
|
+
|
|
181
|
+
Measured on 2026-11-02 against the kit's `hoi4_wiki/` at `93d010f` and the installed 1.19.4.1 documentation (ADR 0078).
|
|
182
|
+
Each change was developed on the discovery, validation and held-out sets (85 questions), scored on the blind test set, and kept only if it improved that set.
|
|
183
|
+
Before any change the sets scored as on 1.19.4.1 above, apart from wiki edits since: blind test 21 of 40 first, mean reciprocal rank 0.611.
|
|
184
|
+
|
|
185
|
+
| Change | Development first | Blind first | Blind within three | Blind mean reciprocal rank | Kept |
|
|
186
|
+
| ------------------------------------------------- | ----------------: | ----------: | -----------------: | -------------------------: | ---- |
|
|
187
|
+
| None | 40/85 | 21/40 | 27/40 | 0.611 | |
|
|
188
|
+
| Verb direction | 42/85 | 22/40 | 27/40 | 0.628 | Yes |
|
|
189
|
+
| Abbreviations, spellings, page topic, plural keys | +1 | no change | no change | no change | No |
|
|
190
|
+
| Command phrasings (with verb direction) | 53/85 | 25/40 | 31/40 | 0.694 | Yes |
|
|
191
|
+
|
|
192
|
+
With all five candidate changes in place, each was left out in turn and the blind set rescored. Only leaving out the verb direction changed it. Together the four dropped changes placed one more development answer first, four more within three and three more within five.
|
|
193
|
+
The phrase weight was chosen on the development sets: 0.25, 0.5, 1, 2, 3, 4 and 6 times a game-text word placed 43, 45, 45, 47, 48, 53 and 53 answers first, and 4 was kept.
|
|
194
|
+
Two cross-encoder rerankers reordered the first twelve word results on the development sets: `Xenova/ms-marco-MiniLM-L-6-v2` placed 34 of 85 first on its own and 46 fused with the word ranking (against 43), at 0.4 seconds per query, and `Xenova/bge-reranker-base` 31 and 45, at 1.6 seconds. Neither was scored on the blind set.
|
|
195
|
+
|
|
196
|
+
On the blind set the phrasings moved "raise war support by a few percent", "switch a country over to a different focus tree", "queue up tanks or rifles in a country's equipment production", "tell the AI to prioritise or avoid something towards another country", "check whether a country owns a particular state" and "give a general or advisor a new trait" to first, and "make all buildings construct faster" into the first three.
|
|
197
|
+
"Check if a country is at war with anyone" fell from first to third, "check whether a decision is currently active" and "decision that works as a timed mission with a deadline" from first to second, and "make my army use less supply" (third) and "create a new start date with its own description and list of featured countries" (fifth) left the first five.
|
|
198
|
+
|
|
199
|
+
A fresh blind set, `--fresh`, was written for this round by an agent that saw no ranking code, no results and no other set: 34 plain-word questions, four exact names and two negative queries.
|
|
200
|
+
It was scored once, after every choice above was final.
|
|
201
|
+
|
|
202
|
+
| Fresh blind set (38 scored) | Answer first | Within three | Within five | Lands within three | Mean reciprocal rank |
|
|
203
|
+
| --------------------------- | -----------: | -----------: | ----------: | -----------------: | -------------------: |
|
|
204
|
+
| Before | 9/38 | 12/38 | 16/38 | 9/38 | 0.294 |
|
|
205
|
+
| Verb direction only | 9/38 | 12/38 | 16/38 | 9/38 | 0.294 |
|
|
206
|
+
| After | 17/38 | 23/38 | 26/38 | 20/38 | 0.526 |
|
|
207
|
+
|
|
208
|
+
Three of its four exact names rank first before and after. For `set_country_flag` the console command of the same name ranks first and the effect second, because both are exact headings and the console penalty applies only to inexact matches.
|
|
209
|
+
The negative query "how to fix a flat bicycle tire" returns five results rather than two, because "flat" names `special_forces_cap_flat`; the other returns none.
|
|
210
|
+
Its writer flagged some answer lists as narrow: "is this country a vassal of anyone" accepts only `is_subject`, and "does the country possess a particular state" only `owns_state`.
|
|
211
|
+
|
|
212
|
+
The maintainer's target is still far off: 25 of 40 blind answers first, and 17 of 38 on the fresh set, which has now been used once.
|
|
213
|
+
|
|
214
|
+
Run the fresh set with:
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
npx tsx scripts/evaluate-reference-discovery.ts MOD_ROOT GAME_ROOT --fresh
|
|
218
|
+
```
|
|
219
|
+
|
|
179
220
|
## Compact context budgets
|
|
180
221
|
|
|
181
222
|
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/tools.md
CHANGED
|
@@ -15,15 +15,17 @@ MCP clients may ask for approval to create review files.
|
|
|
15
15
|
|
|
16
16
|
## References and source
|
|
17
17
|
|
|
18
|
-
| Tool
|
|
19
|
-
|
|
|
20
|
-
| `hoi4.reference_context`
|
|
21
|
-
| `hoi4.reference_search`
|
|
22
|
-
| `hoi4.reference_read`
|
|
23
|
-
| `hoi4.source_lookup`
|
|
24
|
-
| `hoi4.script_validate`
|
|
25
|
-
| `hoi4.error_log`
|
|
26
|
-
| `hoi4.mod_index`
|
|
18
|
+
| Tool | Purpose | Writes |
|
|
19
|
+
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------ |
|
|
20
|
+
| `hoi4.reference_context` | Get compact, cited wiki and installed documentation pointers for a modding surface. | — |
|
|
21
|
+
| `hoi4.reference_search` | Search local documentation in plain words or script names; each result names its answering line. | — |
|
|
22
|
+
| `hoi4.reference_read` | Read one revision-bound section: up to 80 lines (40 by default) and 8,000 bytes, with line continuation. | — |
|
|
23
|
+
| `hoi4.source_lookup` | Find exact definitions, overrides and usages across game, DLC and mod, or the definition containing a file line. | — |
|
|
24
|
+
| `hoi4.script_validate` | Check a snippet or a whole mod file for syntax, command kinds, and scopes against local documentation. | — |
|
|
25
|
+
| `hoi4.error_log` | Group the game's `error.log` from its last launch by category, with the source file, line and layer, and whether that file changed since. | — |
|
|
26
|
+
| `hoi4.mod_index` | Summarize the mod's descriptor and definitions, or find the next free numbered ID for an event namespace or prefix across every layer. | — |
|
|
27
|
+
| `hoi4.localisation_inspect` | Read localisation in every language: one key per language with file, line and layer, or audit the mod for undefined, untranslated and duplicate keys and file problems. Runs on the Rust engine. | — |
|
|
28
|
+
| `hoi4.idea_inspect` | Read an idea (picture, modifiers, conditions, name in every language, advisor) or a character (roles, traits, portraits), or audit every idea or character of the mod. Runs on the Rust engine. | — |
|
|
27
29
|
|
|
28
30
|
## Focus trees
|
|
29
31
|
|
|
@@ -110,36 +112,38 @@ Every tool description in `tools/list` ends with a call like these, and an inval
|
|
|
110
112
|
Fields not shown take their defaults; `workspaceId` is `"current"` unless you pass one.
|
|
111
113
|
The CI stdio smoke suite sends each of these shapes to a real server process.
|
|
112
114
|
|
|
113
|
-
| Tool
|
|
114
|
-
|
|
|
115
|
-
| `hoi4.reference_context`
|
|
116
|
-
| `hoi4.reference_search`
|
|
117
|
-
| `hoi4.reference_read`
|
|
118
|
-
| `hoi4.source_lookup`
|
|
119
|
-
| `hoi4.script_validate`
|
|
120
|
-
| `hoi4.error_log`
|
|
121
|
-
| `hoi4.mod_index`
|
|
122
|
-
| `hoi4.
|
|
123
|
-
| `hoi4.
|
|
124
|
-
| `hoi4.
|
|
125
|
-
| `hoi4.
|
|
126
|
-
| `hoi4.
|
|
127
|
-
| `hoi4.
|
|
128
|
-
| `hoi4.
|
|
129
|
-
| `hoi4.
|
|
130
|
-
| `hoi4.
|
|
131
|
-
| `hoi4.
|
|
132
|
-
| `hoi4.
|
|
133
|
-
| `hoi4.
|
|
134
|
-
| `hoi4.
|
|
135
|
-
| `hoi4.
|
|
136
|
-
| `hoi4.
|
|
137
|
-
| `hoi4.
|
|
138
|
-
| `hoi4.
|
|
139
|
-
| `hoi4.
|
|
140
|
-
| `hoi4.
|
|
141
|
-
| `hoi4.
|
|
142
|
-
| `hoi4.
|
|
115
|
+
| Tool | Example arguments |
|
|
116
|
+
| --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
117
|
+
| `hoi4.reference_context` | `{"surface":"event","question":"fire an event after a delay"}` |
|
|
118
|
+
| `hoi4.reference_search` | `{"query":"add_timed_idea"}` |
|
|
119
|
+
| `hoi4.reference_read` | `{"id":"<hit id>","revision":"<hit revision>"}` from a search or context hit |
|
|
120
|
+
| `hoi4.source_lookup` | `{"symbol":"my_scripted_effect"}` or `{"path":"events/my_events.txt","line":42}` |
|
|
121
|
+
| `hoi4.script_validate` | `{"source":"add_political_power = 10","kind":"effect","scope":"country"}` or `{"path":"events/my_events.txt"}` |
|
|
122
|
+
| `hoi4.error_log` | `{"scope":"mod","category":"effect"}` |
|
|
123
|
+
| `hoi4.mod_index` | `{"mode":"overview"}` or `{"mode":"next_id","kind":"event","namespace":"my_mod"}` |
|
|
124
|
+
| `hoi4.localisation_inspect` | `{"mode":"key","key":"my_event.1.t"}` or `{"mode":"audit"}` |
|
|
125
|
+
| `hoi4.idea_inspect` | `{"kind":"idea","id":"my_idea"}` or `{"kind":"character","audit":true}` |
|
|
126
|
+
| `hoi4.focus_inspect` | `{"treeId":"my_focus_tree"}` |
|
|
127
|
+
| `hoi4.focus_render` | `{"relativePath":"common/national_focus/my_tree.txt","treeId":"my_focus_tree"}` |
|
|
128
|
+
| `hoi4.focus_rewrite` | `{"relativePath":"common/national_focus/my_tree.txt","treeId":"my_focus_tree","layoutMode":"compact"}` |
|
|
129
|
+
| `hoi4.gui_inspect` | `{"windowName":"my_window"}` |
|
|
130
|
+
| `hoi4.gui_render` | `{"windowName":"my_window","scenario":{"id":"normal"}}` |
|
|
131
|
+
| `hoi4.gui_rewrite` | `{"mode":"helpers","relativePath":"interface/my_window.gui","windowName":"my_window","scenario":{"id":"normal"},"helper":{…}}` |
|
|
132
|
+
| `hoi4.map_inspect` | `{"query":"Brandenburg","lookupOnly":true}` or `{"layer":"state","tile":{"x":2600,"y":500,"width":256,"height":256}}` |
|
|
133
|
+
| `hoi4.map_rewrite` | `{"operations":[{"id":"s1","kind":"create_state","provinceIds":[120,121],"displayName":"New State"}]}` |
|
|
134
|
+
| `hoi4.event_inspect` | `{"mode":"trace","selector":"my_mod.1","direction":"downstream"}` |
|
|
135
|
+
| `hoi4.event_render` | `{"view":"overview","selector":"my_mod"}` |
|
|
136
|
+
| `hoi4.tech_inspect` | `{"mode":"explain","technologyId":"my_tech"}` |
|
|
137
|
+
| `hoi4.tech_render` | `{"view":"folder","folderId":"my_folder"}` |
|
|
138
|
+
| `hoi4.probability_inspect` | `{"candidatePool":["my_decision"],"scenarioSet":[{"actor":"GER","state":{"has_war":false}}]}` |
|
|
139
|
+
| `hoi4.probability_analyze` | `{"analysis":"sweep","source":"common/decisions/my_decisions.txt","candidatePool":["my_decision"],"scenarioSet":[{"actor":"GER","state":{"variable.pressure":10}}],"sweep":{"paths":["variable.pressure"],"steps":10}}` |
|
|
140
|
+
| `hoi4.impact_inspect` | `{"symbols":[{"kind":"scripted_effect","id":"my_effect"}]}` |
|
|
141
|
+
| `hoi4.decision_inspect` | `{"mode":"inspect","id":"my_decision","scenarios":[{"id":"base","actor":"GER","state":{}}]}` |
|
|
142
|
+
| `hoi4.mechanic_test` | `{"test":{"id":"t","scenario":{…},"steps":[…],"assertions":[…]}}`, see [Mechanic tests](mechanics.md) |
|
|
143
|
+
| `hoi4.package_check` | `{"manifest":{"schemaVersion":"1.0","id":"my_package","definitions":[{"kind":"scripted_effect","id":"my_effect"}]}}` |
|
|
144
|
+
| `hoi4.scenario_test` | `{"suitePath":"tests/my_suite.json","maxCases":20}` |
|
|
145
|
+
| `hoi4.job_inspect` | `{"jobId":"job_<64 hex characters>"}` from a native task id |
|
|
146
|
+
| `hoi4.job_cancel` | `{"jobId":"job_<64 hex characters>"}` |
|
|
143
147
|
|
|
144
148
|
## Result sizes
|
|
145
149
|
|
package/docs/troubleshooting.md
CHANGED
|
@@ -37,18 +37,19 @@ This page lists the codes you are most likely to meet, then the checks for probl
|
|
|
37
37
|
|
|
38
38
|
Use the error code to find what prevented a focus, GUI or map edit.
|
|
39
39
|
|
|
40
|
-
| Code | Cause and fix
|
|
41
|
-
| ---------------------------------------- |
|
|
42
|
-
| `TRANSACTION_STALE` | A source file changed after the review was made. Inspect again and repeat the rewrite on the current source.
|
|
43
|
-
| `TRANSACTION_RECOVERY_REQUIRED` | An earlier rewrite was interrupted and its journal could not be recovered yet. Reads still work; the message names the reason. Restart the server, and repair the named file if it persists.
|
|
44
|
-
| `TRANSACTION_ROLLBACK_STALE` | A file changed since the rewrite, so it cannot be rolled back safely. Restore the file from version control.
|
|
45
|
-
| `MAP_STATE_DISTRIBUTION_REQUIRED` | A state operation was given an incomplete explicit policy. Omit `distribution` for the automatic land-share policy, or send every field (see [Maps](map.md)).
|
|
46
|
-
| `MAP_STATE_REGION_DISTRIBUTION_CONFLICT` | Moved or merged provinces lie in different strategic regions. Use `strategicRegion: "move-to-target-region"`, or move the provinces between regions first.
|
|
47
|
-
| `MAP_EXTERNAL_REFERENCE_READ_ONLY` | Base-game or dependency scripts name a changed state. Repeat with `remapReferences` or `readOnlySources` set to `override` to copy them into the mod with the numbers changed.
|
|
48
|
-
| `MAP_DATED_STATE_HISTORY_CONFLICT` | A dated block (`1939.1.1 = { ... }`) overrides the value you are changing. Edit that block, or change the later date's value deliberately.
|
|
49
|
-
| `MAP_SCRIPT_REFERENCE_MISSING` (error) | A script names a state, province or region the map does not define. Remap it with `remap_map_references`, or correct the script.
|
|
50
|
-
| `MAP_SCRIPT_PRIORITIZE_PROVINCE` | A `prioritize = { ... }` list holds a province id where the effects documentation gives state ids only (vanilla pairs states with ports, `prioritize = { 521 7564 }`). Replace it with the state that holds the province.
|
|
51
|
-
| `MAP_REFERENCE_NEEDS_REVIEW` (info) | A single-valued argument such as `capital = 64` had no single successor and was left as it was. Choose its new target by hand.
|
|
40
|
+
| Code | Cause and fix |
|
|
41
|
+
| ---------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
42
|
+
| `TRANSACTION_STALE` | A source file changed after the review was made. Inspect again and repeat the rewrite on the current source. |
|
|
43
|
+
| `TRANSACTION_RECOVERY_REQUIRED` | An earlier rewrite was interrupted and its journal could not be recovered yet. Reads still work; the message names the reason. Restart the server, and repair the named file if it persists. |
|
|
44
|
+
| `TRANSACTION_ROLLBACK_STALE` | A file changed since the rewrite, so it cannot be rolled back safely. Restore the file from version control. |
|
|
45
|
+
| `MAP_STATE_DISTRIBUTION_REQUIRED` | A state operation was given an incomplete explicit policy. Omit `distribution` for the automatic land-share policy, or send every field (see [Maps](map.md)). |
|
|
46
|
+
| `MAP_STATE_REGION_DISTRIBUTION_CONFLICT` | Moved or merged provinces lie in different strategic regions. Use `strategicRegion: "move-to-target-region"`, or move the provinces between regions first. |
|
|
47
|
+
| `MAP_EXTERNAL_REFERENCE_READ_ONLY` | Base-game or dependency scripts name a changed state. Repeat with `remapReferences` or `readOnlySources` set to `override` to copy them into the mod with the numbers changed. |
|
|
48
|
+
| `MAP_DATED_STATE_HISTORY_CONFLICT` | A dated block (`1939.1.1 = { ... }`) overrides the value you are changing. Edit that block, or change the later date's value deliberately. |
|
|
49
|
+
| `MAP_SCRIPT_REFERENCE_MISSING` (error) | A script names a state, province or region the map does not define. Remap it with `remap_map_references`, or correct the script. |
|
|
50
|
+
| `MAP_SCRIPT_PRIORITIZE_PROVINCE` | A `prioritize = { ... }` list holds a province id where the effects documentation gives state ids only (vanilla pairs states with ports, `prioritize = { 521 7564 }`). Replace it with the state that holds the province. |
|
|
51
|
+
| `MAP_REFERENCE_NEEDS_REVIEW` (info) | A single-valued argument such as `capital = 64` had no single successor and was left as it was. Choose its new target by hand. |
|
|
52
|
+
| `FOCUS_ENGINE_UNAVAILABLE` | `layoutMode: "engine"` or `placement` found no usable `hoi4-engine`. The package bundles it for Windows x64, macOS arm64 and Linux x64 and arm64; after `binary_checksum_mismatch`, reinstall the package. Elsewhere set `HOI4_ENGINE` to a built binary. |
|
|
52
53
|
|
|
53
54
|
## Game and live testing
|
|
54
55
|
|