hoi4-agent-tools 4.11.1 → 4.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +3 -3
  3. package/dist/bin/setup.js +38 -0
  4. package/dist/bin/stdio.js +12 -10
  5. package/dist/hoi4_agent_tools/core/configuration.js +29 -0
  6. package/dist/hoi4_agent_tools/core/domain-tools.js +4 -0
  7. package/dist/hoi4_agent_tools/core/engine-check.js +87 -0
  8. package/dist/hoi4_agent_tools/core/engine-client.js +1 -1
  9. package/dist/hoi4_agent_tools/core/engine.js +18 -2
  10. package/dist/hoi4_agent_tools/core/job-operation-registration.js +2 -0
  11. package/dist/hoi4_agent_tools/core/job-store.js +1 -1
  12. package/dist/hoi4_agent_tools/focus/native-effects.js +1 -1
  13. package/dist/hoi4_agent_tools/localisation/job-operations.js +42 -0
  14. package/dist/hoi4_agent_tools/localisation/write-diff.js +96 -0
  15. package/dist/hoi4_agent_tools/localisation/write-format.js +329 -0
  16. package/dist/hoi4_agent_tools/localisation/write-operations.js +213 -0
  17. package/dist/hoi4_agent_tools/localisation/write-plan.js +557 -0
  18. package/dist/hoi4_agent_tools/map/gameplay/crossing-validation.js +17 -0
  19. package/dist/hoi4_agent_tools/map/model.js +31 -1
  20. package/dist/hoi4_agent_tools/map/operations.js +37 -8
  21. package/dist/hoi4_agent_tools/map/references.js +87 -0
  22. package/dist/hoi4_agent_tools/map/relief/hydrology.js +7 -2
  23. package/dist/hoi4_agent_tools/map/relief/terrain-synthesis.js +1 -0
  24. package/dist/hoi4_agent_tools/map/service.js +13 -4
  25. package/dist/hoi4_agent_tools/map/tool-operations.js +6 -0
  26. package/dist/hoi4_agent_tools/map/world-edge.js +0 -25
  27. package/dist/hoi4_agent_tools/map/world.js +181 -64
  28. package/dist/hoi4_agent_tools/mcp/plugins.js +74 -0
  29. package/dist/hoi4_agent_tools/mcp/server/argument-errors.js +5 -0
  30. package/dist/hoi4_agent_tools/mcp/server/create-modern-operations.js +15 -21
  31. package/dist/hoi4_agent_tools/mcp/server/create.js +5 -1
  32. package/dist/hoi4_agent_tools/mcp/server/request-lifecycle.js +10 -2
  33. package/dist/hoi4_agent_tools/mcp/server/task-tool-catalog.js +2 -0
  34. package/dist/hoi4_agent_tools/mcp/server/tool-profiles.js +83 -0
  35. package/dist/hoi4_agent_tools/mcp/tools/localisation-write.js +21 -0
  36. package/dist/hoi4_agent_tools/mcp/tools/reference.js +34 -0
  37. package/dist/hoi4_agent_tools/mcp/transports/http.js +6 -1
  38. package/dist/hoi4_agent_tools/mcp/transports/negotiated-stdio.js +64 -6
  39. package/dist/hoi4_agent_tools/probability/model.js +4 -4
  40. package/dist/hoi4_agent_tools/reference/compat-patch.js +555 -0
  41. package/dist/hoi4_agent_tools/reference/compat.js +255 -0
  42. package/dist/hoi4_agent_tools/reference/docs-pack.js +164 -0
  43. package/dist/hoi4_agent_tools/reference/docs-pack.json +339 -0
  44. package/dist/hoi4_agent_tools/reference/documented-commands.js +26 -0
  45. package/dist/hoi4_agent_tools/reference/error-explain.js +235 -0
  46. package/dist/hoi4_agent_tools/reference/error-explanations.json +262 -0
  47. package/dist/hoi4_agent_tools/reference/error-log.js +30 -10
  48. package/dist/hoi4_agent_tools/reference/mod-health.js +255 -0
  49. package/dist/hoi4_agent_tools/reference/mod-index.js +63 -65
  50. package/dist/hoi4_agent_tools/reference/operations.js +435 -21
  51. package/dist/hoi4_agent_tools/reference/script-guard.js +109 -0
  52. package/dist/hoi4_agent_tools/reference/service.js +58 -20
  53. package/dist/hoi4_agent_tools/runtime.js +17 -2
  54. package/dist/hoi4_agent_tools/schemas/compat.js +153 -0
  55. package/dist/hoi4_agent_tools/schemas/localisation-write.js +154 -0
  56. package/dist/hoi4_agent_tools/schemas/map.js +5 -1
  57. package/dist/hoi4_agent_tools/schemas/mod-tools.js +50 -0
  58. package/dist/hoi4_agent_tools/schemas/modder-tools.js +191 -0
  59. package/dist/hoi4_agent_tools/version.js +1 -1
  60. package/docs/configuration.md +14 -11
  61. package/docs/development.md +2 -0
  62. package/docs/jobs.md +3 -1
  63. package/docs/map.md +8 -4
  64. package/docs/reference.md +47 -5
  65. package/docs/research/probability-adapter-evidence.md +11 -1
  66. package/docs/setup.md +23 -3
  67. package/docs/tools.md +18 -4
  68. package/docs/troubleshooting.md +1 -1
  69. package/engine/bin/darwin-arm64/hoi4-engine +0 -0
  70. package/engine/bin/linux-arm64/hoi4-engine +0 -0
  71. package/engine/bin/linux-x64/hoi4-engine +0 -0
  72. package/engine/bin/manifest.json +8 -8
  73. package/engine/bin/win32-x64/hoi4-engine.exe +0 -0
  74. package/npm-shrinkwrap.json +2 -2
  75. package/package.json +1 -1
  76. package/schemas/configuration.schema.json +181 -138
  77. package/schemas/continuous-focus-palette.schema.json +1 -1
  78. package/schemas/custom-weighted-pool.schema.json +1 -1
  79. package/schemas/decision-inspect-input.schema.json +1 -1
  80. package/schemas/error-log-input.schema.json +1 -1
  81. package/schemas/event-feature-manifest.schema.json +1 -1
  82. package/schemas/focus-plan.schema.json +1 -1
  83. package/schemas/focus-planning-sidecar.schema.json +1 -1
  84. package/schemas/geography-model.schema.json +1 -1
  85. package/schemas/gui-animation-source.schema.json +1 -1
  86. package/schemas/gui-helper.schema.json +1 -1
  87. package/schemas/gui-scenario.schema.json +1 -1
  88. package/schemas/helper-expansion-request.schema.json +1 -1
  89. package/schemas/helper-expansion-summary.schema.json +1 -1
  90. package/schemas/impact-inspect-input.schema.json +1 -1
  91. package/schemas/map-operation.schema.json +153 -139
  92. package/schemas/mechanic-test-input.schema.json +1 -1
  93. package/schemas/mod-index-input.schema.json +1 -1
  94. package/schemas/operation-result.schema.json +1 -1
  95. package/schemas/package-check-input.schema.json +1 -1
  96. package/schemas/package-manifest.schema.json +1 -1
  97. package/schemas/probability-analysis-result.schema.json +1 -1
  98. package/schemas/probability-compare-input.schema.json +1 -1
  99. package/schemas/probability-evaluate-input.schema.json +1 -1
  100. package/schemas/probability-inspect-input.schema.json +1 -1
  101. package/schemas/probability-render-input.schema.json +1 -1
  102. package/schemas/probability-scenario-set.schema.json +1 -1
  103. package/schemas/probability-sequence-input.schema.json +1 -1
  104. package/schemas/probability-simulate-input.schema.json +1 -1
  105. package/schemas/probability-sweep-input.schema.json +1 -1
  106. package/schemas/reference-context-input.schema.json +1 -1
  107. package/schemas/reference-read-input.schema.json +1 -1
  108. package/schemas/reference-search-input.schema.json +1 -1
  109. package/schemas/reference-sheets.schema.json +1 -1
  110. package/schemas/scenario-suite.schema.json +1 -1
  111. package/schemas/scenario-test-input.schema.json +1 -1
  112. package/schemas/script-validate-input.schema.json +1 -1
  113. package/schemas/shared-scenario.schema.json +1 -1
  114. package/schemas/source-lookup-input.schema.json +1 -1
  115. package/server.json +2 -2
  116. package/dist/hoi4_agent_tools/mcp/tools/chaosx.js +0 -509
@@ -0,0 +1,191 @@
1
+ import { z } from 'zod/v4';
2
+ import { workspaceIdSchema } from './common.js';
3
+ import { errorLogCategorySchema } from './mod-tools.js';
4
+ const count = z.number().int().min(0);
5
+ const line = z.number().int().min(1);
6
+ const logLine = z.string().trim().min(3).max(4000);
7
+ export const explainErrorRequestSchema = z
8
+ .object({
9
+ workspaceId: workspaceIdSchema,
10
+ /** One error.log line, as the game writes it or as hoi4.error_log returns it. */
11
+ line: logLine.optional(),
12
+ /** Up to 10 lines explained in one call. */
13
+ lines: z.array(logLine).min(1).max(10).optional(),
14
+ })
15
+ .strict()
16
+ .superRefine((value, context) => {
17
+ if ((value.line === undefined) === (value.lines === undefined))
18
+ context.addIssue({
19
+ code: 'custom',
20
+ path: ['line'],
21
+ message: 'Provide either line or lines',
22
+ });
23
+ });
24
+ const sourceLayerSchema = z.enum(['mod', 'dependency', 'game', 'unknown']);
25
+ export const errorExplanationSchema = z
26
+ .object({
27
+ /** The message explained; a wrapped parser error yields one explanation per message. */
28
+ message: z.string().max(600),
29
+ category: errorLogCategorySchema,
30
+ /** `catalogue`: a reviewed explanation; `known_mistake`: a reviewed rule; `category`: only the category's advice. */
31
+ matched: z.enum(['catalogue', 'known_mistake', 'category']),
32
+ id: z.string().max(64).optional(),
33
+ /** What the game requires. */
34
+ rule: z.string().max(600),
35
+ fix: z.string().max(600),
36
+ /** The command, key, tag or name the message is about. */
37
+ subject: z.string().max(256).optional(),
38
+ /** The kinds of command the game's documentation lists the subject as. */
39
+ documentedAs: z
40
+ .array(z.enum(['effect', 'trigger', 'modifier']))
41
+ .max(3)
42
+ .optional(),
43
+ /** The scripted helpers a loaded file defines with the subject's name. */
44
+ definedBy: z
45
+ .array(z.enum(['scripted_effect', 'scripted_trigger']))
46
+ .max(2)
47
+ .optional(),
48
+ /** Documented or defined names close to the subject. */
49
+ suggestions: z.array(z.string().max(256)).max(3).optional(),
50
+ source: z
51
+ .object({
52
+ relativePath: z.string().max(1024),
53
+ line: line.optional(),
54
+ layer: sourceLayerSchema,
55
+ /** Up to 5 lines around the named line, from the layer that has the file. */
56
+ excerpt: z
57
+ .array(z.object({ line, text: z.string().max(200) }).strict())
58
+ .max(5)
59
+ .optional(),
60
+ })
61
+ .strict()
62
+ .optional(),
63
+ /** What the documentation and the loaded files say about the subject. */
64
+ note: z.string().max(400).optional(),
65
+ /** The tool call that narrows it down. */
66
+ next: z
67
+ .object({
68
+ tool: z.string().max(64),
69
+ arguments: z.record(z.string().max(64), z.union([z.string().max(1024), z.number()])),
70
+ })
71
+ .strict()
72
+ .optional(),
73
+ })
74
+ .strict();
75
+ export const explainErrorDataSchema = z
76
+ .object({
77
+ explanations: z.array(errorExplanationSchema).max(20),
78
+ /** Explanations from the reviewed catalogue or a reviewed rule, not only a category. */
79
+ explained: count,
80
+ /** Reviewed explanations the catalogue holds. */
81
+ catalogue: count,
82
+ })
83
+ .strict();
84
+ export const healthCheckSchema = z.enum([
85
+ 'error_log',
86
+ 'engine_check',
87
+ 'script',
88
+ 'localisation',
89
+ 'assets',
90
+ ]);
91
+ export const modHealthRequestSchema = z
92
+ .object({
93
+ workspaceId: workspaceIdSchema,
94
+ /** The audits to run; all five by default. */
95
+ checks: z.array(healthCheckSchema).min(1).max(5).optional(),
96
+ limit: z.number().int().min(1).max(10).default(10),
97
+ })
98
+ .strict();
99
+ const nextCallSchema = z
100
+ .object({
101
+ tool: z.string().max(64),
102
+ arguments: z.record(z.string().max(64), z.union([z.string().max(1024), z.number(), z.boolean()])),
103
+ })
104
+ .strict();
105
+ export const modHealthDataSchema = z
106
+ .object({
107
+ /** `healthy`: every audit ran and found nothing; `incomplete`: nothing found, but an audit could not run. */
108
+ verdict: z.enum(['healthy', 'problems', 'incomplete']),
109
+ problems: z
110
+ .array(z
111
+ .object({
112
+ rank: line,
113
+ check: healthCheckSchema,
114
+ severity: z.enum(['error', 'warning']),
115
+ code: z.string().max(128),
116
+ title: z.string().max(300),
117
+ /** Findings of this kind in the mod. */
118
+ count: count,
119
+ examples: z
120
+ .array(z
121
+ .object({
122
+ message: z.string().max(300),
123
+ path: z.string().max(1024).optional(),
124
+ line: line.optional(),
125
+ })
126
+ .strict())
127
+ .max(2),
128
+ fix: z.string().max(400),
129
+ next: nextCallSchema.optional(),
130
+ })
131
+ .strict())
132
+ .max(10),
133
+ totals: z
134
+ .object({
135
+ problems: count,
136
+ findings: count,
137
+ errors: count,
138
+ warnings: count,
139
+ omitted: count,
140
+ })
141
+ .strict(),
142
+ checks: z
143
+ .array(z
144
+ .object({
145
+ check: healthCheckSchema,
146
+ status: z.enum(['ran', 'partial', 'unavailable', 'skipped']),
147
+ ms: count,
148
+ findings: count,
149
+ note: z.string().max(300).optional(),
150
+ })
151
+ .strict())
152
+ .max(5),
153
+ checksRun: count,
154
+ })
155
+ .strict();
156
+ export const scriptGuardRequestSchema = z
157
+ .object({
158
+ workspaceId: workspaceIdSchema,
159
+ /** Mod files to check, such as events/my_events.txt. */
160
+ paths: z.array(z.string().trim().min(1).max(1024)).min(1).max(50).optional(),
161
+ /** Without paths: the mod's script files changed in the last this many minutes. */
162
+ sinceMinutes: z.number().int().min(1).max(10_080).default(120),
163
+ })
164
+ .strict();
165
+ export const scriptGuardDataSchema = z
166
+ .object({
167
+ /** `clean`: every name in the checked files is documented or defined. */
168
+ verdict: z.enum(['clean', 'invented']),
169
+ filesChecked: count,
170
+ /** Changed files beyond the 200 newest. */
171
+ filesOmitted: count,
172
+ counts: z.object({ effect: count, trigger: count, modifier: count }).strict(),
173
+ files: z.array(z.object({ path: z.string().max(1024), invented: count }).strict()).max(50),
174
+ invented: z
175
+ .array(z
176
+ .object({
177
+ name: z.string().max(256),
178
+ kind: z.enum(['effect', 'trigger', 'modifier']),
179
+ path: z.string().max(1024),
180
+ line,
181
+ /** The definition it is in, such as `event:my.1`. */
182
+ context: z.string().max(256).optional(),
183
+ /** The closest documented or defined name. */
184
+ suggestion: z.string().max(256).optional(),
185
+ message: z.string().max(300),
186
+ })
187
+ .strict())
188
+ .max(40),
189
+ inventedOmitted: count,
190
+ })
191
+ .strict();
@@ -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.11.1';
3
+ export const PACKAGE_VERSION = '4.13.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;
@@ -32,9 +32,10 @@ The automatic configuration works like this:
32
32
  | Storage | Default location |
33
33
  | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
34
34
  | `serverStateRoot` | `$XDG_STATE_HOME/hoi4-agent-tools/state`, else `%LOCALAPPDATA%\hoi4-agent-tools\state`, else `~/.local/state/hoi4-agent-tools/state` |
35
+ | `docsRoot` | `$XDG_DATA_HOME/hoi4-agent-tools/docs`, else `%LOCALAPPDATA%\hoi4-agent-tools\docs`, else `~/.local/share/hoi4-agent-tools/docs` |
35
36
  | `workspaceStorageRoot` | `$XDG_DATA_HOME/hoi4-agent-tools/workspaces`, else `%LOCALAPPDATA%\hoi4-agent-tools\workspaces`, else `~/.local/share/hoi4-agent-tools/workspaces` |
36
37
 
37
- `hoi4-agent-tools-setup --init` writes these same two locations into the file it creates.
38
+ `hoi4-agent-tools-setup --init` writes the first two locations into the file it creates. The command-line servers use the `docsRoot` default when the file names none, and read the docs pack that `hoi4-agent-tools-setup --fetch-docs` installs there.
38
39
  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
 
40
41
  What each location holds:
@@ -99,6 +100,7 @@ Over HTTP, a principal sees only the workspaces granted to it, and any other ID
99
100
  | `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. |
100
101
  | `storageRoots` | array of paths | up to 16 | `[]` | Additional folders in which an explicit `artifactRoot` or `cacheRoot` may be placed. |
101
102
  | `workspaces` | array of objects | up to 1,000 | `[]` | Explicit workspace registrations, described in the next section. |
103
+ | `profiles` | array of strings | 1–4 | unset | The tool profiles each session lists: `core`, `map`, `advanced` or `all` ([tool profiles](setup.md#choose-tool-profiles)). The stdio server lists `core` when this is unset; the HTTP server lists every tool. |
102
104
  | `defaultWorkspace` | string | workspace ID | unset | The mod workspace, by ID or short form, used for `"current"` when neither the client roots nor the working directory identify one. It must name a registered mod workspace, and over HTTP it applies only to principals granted that workspace. |
103
105
 
104
106
  ## Workspaces
@@ -153,15 +155,16 @@ Each `roots` key takes up to 16 folders, and setting `roots` replaces only the k
153
155
 
154
156
  ## Tools, jobs and lifetime
155
157
 
156
- | Key | Type | Range | Default | Purpose |
157
- | ----------------------- | ------- | ---------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
158
- | `maxConcurrentTools` | integer | 1–32 | 2 | Expensive tool calls one server process runs at once. |
159
- | `maxSharedTools` | integer | 1–128 | 4 | Expensive calls and job workers that run at once across every server process sharing the same `serverStateRoot`. |
160
- | `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. |
161
- | `jobCancelGraceSeconds` | integer | 1–600 | 10 | A read-only job still running this long after cancellation is stopped and settles as cancelled. |
162
- | `jobWorkerMaxHeapMiB` | integer | 256–65,536 | unset | Memory ceiling for each job worker's JavaScript heap, in MiB. Unset keeps Node's default. |
163
- | `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. |
164
- | `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. |
158
+ | Key | Type | Range | Default | Purpose |
159
+ | ----------------------- | -------- | ---------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
160
+ | `maxConcurrentTools` | integer | 1–32 | 2 | Expensive tool calls one server process runs at once. |
161
+ | `maxSharedTools` | integer | 1–128 | 4 | Expensive calls and job workers that run at once across every server process sharing the same `serverStateRoot`. |
162
+ | `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. |
163
+ | `jobCancelGraceSeconds` | integer | 1–600 | 10 | A read-only job still running this long after cancellation is stopped and settles as cancelled. |
164
+ | `jobWorkerMaxHeapMiB` | integer | 256–65,536 | unset | Memory ceiling for each job worker's JavaScript heap, in MiB. Unset keeps Node's default. |
165
+ | `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. |
166
+ | `plugins` | string[] | up to 8 absolute paths | `[]` | Plugin modules (`.mjs` or `.js`) the stdio server loads to add its own tools. The server loads nothing from a mod folder or the environment, only these paths; a listed file that does not exist is skipped with a warning on stderr, so one shared configuration can name a plugin that exists on one machine. The HTTP server never loads plugins. See [Tools](tools.md#plugins). |
167
+ | `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. |
165
168
 
166
169
  See [Persistent jobs and MCP tasks](jobs.md) for how jobs, cancellation and recovery behave.
167
170
 
@@ -269,8 +272,8 @@ HTTP server only:
269
272
  | `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. |
270
273
  | `HOI4_GAME_ROOT` | automatic configuration, setup `--init` and `--discover` | First game folder to try, before the standard Steam locations. |
271
274
  | `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. |
275
+ | `HOI4_AGENT_TOOLS_PROFILES` | `hoi4-agent-tools`, `hoi4-agent-tools-http` | Overrides `profiles` for one client registration: a comma-separated list of `core`, `map`, `advanced` and `all`. An unknown name stops startup. |
272
276
  | `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. |
273
- | `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. |
274
277
  | the variable named by `tokenEnv` | `hoi4-agent-tools-http` | Secret for a static bearer token, at least 32 characters. |
275
278
  | `APPDATA`, `XDG_CONFIG_HOME` | every command | Location of the default configuration file. |
276
279
  | `XDG_STATE_HOME`, `XDG_DATA_HOME`, `LOCALAPPDATA` | automatic configuration, setup `--init` | Default `serverStateRoot` and `workspaceStorageRoot`. |
@@ -17,6 +17,8 @@ npm run build
17
17
  npm run inspector
18
18
  ```
19
19
 
20
+ Tools on the shared Rust engine (`hoi4.mod_index`, `hoi4.localisation_inspect`, `hoi4.idea_inspect`, `hoi4.system_inspect`, `hoi4.unit_inspect`, `hoi4.asset_inspect`) need a `hoi4-engine` binary in the tests. Build it once with `cargo build -p hoi4-engine-cli` in `engine/`; the test setup uses that build (in `CARGO_TARGET_DIR` or `engine/target`) unless `HOI4_ENGINE` names another binary.
21
+
20
22
  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
23
 
22
24
  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).
package/docs/jobs.md CHANGED
@@ -15,13 +15,14 @@ A modern native task handoff ends that request's heartbeat without declaring the
15
15
 
16
16
  ## Supported tools
17
17
 
18
- Optional tasks are available for all 19 domain tools; the 7 reference tools and the 2 job tools always answer in the foreground.
18
+ Optional tasks are available for all 20 domain tools; the 7 reference tools and the 2 job tools always answer in the foreground.
19
19
 
20
20
  - `hoi4.event_inspect` and `hoi4.event_render`
21
21
  - `hoi4.impact_inspect`, `hoi4.decision_inspect`, `hoi4.mechanic_test`, `hoi4.package_check`, and `hoi4.scenario_test`
22
22
  - `hoi4.tech_inspect` and `hoi4.tech_render`
23
23
  - `hoi4.probability_inspect` and `hoi4.probability_analyze`
24
24
  - `hoi4.map_inspect` and `hoi4.map_rewrite`
25
+ - `hoi4.localisation_write`
25
26
  - `hoi4.gui_inspect`, `hoi4.gui_render`, and `hoi4.gui_rewrite`
26
27
  - `hoi4.focus_inspect`, `hoi4.focus_render`, and `hoi4.focus_rewrite`
27
28
 
@@ -48,6 +49,7 @@ Both native and ordinary calls use that same receipt, while a conflicting retry
48
49
 
49
50
  The server binds an applied rewrite to its authenticated transaction journal before source replacement starts.
50
51
  If execution stops after a commit, recovery reads that journal and reconstructs the domain result without planning or applying the rewrite again.
52
+ At startup the server checks every retained journal and recovers interrupted ones before any call reads or writes a workspace. A stdio server answers `initialize`, `ping`, `server/discover`, `tools/list`, `prompts/list` and `logging/setLevel` meanwhile and holds other requests, in arrival order, until the check ends; more than 128 held requests, or a failed check, closes the connection. The HTTP server finishes the check before it listens.
51
53
  Blocked and unchanged plans do not bind a transaction because they never mutate source.
52
54
 
53
55
  ## Cancellation and recovery
package/docs/map.md CHANGED
@@ -19,7 +19,7 @@ The server generates the complete map and supporting country/state files in one
19
19
 
20
20
  Add `"preview": true` at the top level to return offline reference, terrain and political PNGs, a comparison and counts without changing mod files. Repeat the request without `preview` to apply it. Preview uses the same extraction, generation and validation as application, and never launches the game.
21
21
 
22
- Use a cleaned, unlabelled raster for production generation. Handwriting, sheet joins and map frames can become false islands or relief. Keep the original unchanged, remove these marks in a separate reference, compare its coastlines with the original, then inspect the terrain preview before writing. Supply reviewed names through `reference.labels` and `reference.cities`; an explicit label list, including an empty list, prevents OCR from adding unreviewed names. The server does not automatically redraw artwork or promise lossless interpretation of every map.
22
+ Use a cleaned, unlabelled raster for production generation. Handwriting, sheet joins and map frames can become false islands or relief. Keep the original unchanged, remove these marks in a separate reference, compare its coastlines with the original, then inspect the terrain preview before writing. Supply reviewed names through `reference.labels` and `reference.cities`; an explicit label list, including an empty list, prevents OCR from adding unreviewed names. The server does not automatically redraw artwork or promise lossless interpretation of every map. Offline validation is separate from [native campaign acceptance](https://github.com/klimPaskov/hoi4-agent-tools/blob/v4.1.0/docs/evaluations/worldgen_acceptance_2026-10-15.md).
23
23
 
24
24
  Reference worlds enable `startingScenario` by default; procedural worlds keep it off unless requested. The starter includes a bookmark, country histories, provisional councils, recruitable infantry templates, two equipped divisions per country, stockpiles, an infantry production line, supply and building positions. `worldName` sets the bookmark title. Demographics, industry and ownership remain provisional. Existing world events, decisions, startup hooks and country-specific AI strategy folders are replaced; shared game systems remain dependencies and can report unused-definition warnings. Generated names use the localisation replacement folder, and explicit country color declarations match the flags. Inherited country tags receive inactive histories. The adjacent launcher `.mod` file must mirror the generated `descriptor.mod` replacement paths. The server cannot enable a launcher playset or test a campaign.
25
25
 
@@ -519,6 +519,10 @@ Width and height are multiples of 256 with at most 13,238,272 pixels. Land comes
519
519
 
520
520
  The operation writes `provinces.bmp`, `definition.csv`, `default.map`, `continent.txt`, `heightmap.bmp`, `terrain.bmp`, `rivers.bmp` (rivers run downhill to the coast), `trees.bmp`, `cities.bmp`, `world_normal.bmp`, the land and water colour maps, `adjacencies.csv`, strategic regions (`landProvincesPerRegion`, `seaProvincesPerRegion`) with weather by latitude, states (`provincesPerState`) with population, category, buildings, resources, victory points and ports, country tags, country files, history and three-band flags, a bookmark, localisation, and every position, supply node and railway. Countries grow from spread-out capitals in proportion to `share`; each state lies within one country and one strategic region.
521
521
 
522
+ Continents are the largest landmasses, numbered `world_continent_1` and up and named by `continentNames`; smaller islands join the nearest one. Impassable land (the `wall` edge, painted `impassable_mountain` and impassable model regions) joins no landmass: two lands that only impassable land connects get separate continents, and each connected piece of impassable land takes the continent of the largest landmass it borders, or of the nearest passable province when it borders only water. Strategic regions never cross impassable land either: a piece no larger than a region joins the passable region it borders most, and a larger piece, or one beside only water, forms regions of its own, so no region or state spans the seam over the wall. Countries, generated or workspace realms, grow over passable land only and never cross impassable land or the wall from one edge to the other; land reached only that way follows the island rule (`realms.islands` for workspace realms, the nearest capital otherwise). Impassable provinces take no owner while countries grow: their states take the owner of the passable state they link to with `force_link_ownership_to`.
523
+
524
+ `continent.txt` lists the generated continents first, then by default every continent of the active `continent.txt`, so scripts and portraits that name the base game's continents still load; the in-game trade window then shows a filter for each of them. Set `inheritedContinents: "drop"` (default `"keep"`) to write only the generated continents. The call then reads the scripts that stay active after the write (all of `common`, `events`, `history/countries` and `portraits`, after the `replace_path` folders the world adds) and reports every reference to a dropped continent as `MAP_CONTINENT_DROPPED_REFERENCED` (warning) with its file and line: `is_on_continent = europe`, `continent = europe` (the state set of `any_state_in` and its effects), an AI area's `continents = { europe }` and a portrait pool's `continent = { name = europe }`. `MAP_CONTINENTS_DROPPED` (information) lists the dropped keys and counts the references. An AI strategy's `area = europe` names an AI area, not a continent, and is not reported; localisation keys of the dropped continents are not read.
525
+
522
526
  Each write records its generated files in `.hoi4-agent-world.json`. A later `create_world` deletes the recorded files it no longer writes (retires them) in the same transaction and refuses with `MANAGED_OUTPUT_EDITED` when a recorded file was edited since. `MAP_WORLD_OUTPUTS_RECONCILED` and `data.outputs` give the counts of written, retired and released files with up to 200 paths each; `map-world-outputs.json` lists them all.
523
527
 
524
528
  Every applied map rewrite also returns `data.changedSummary` with the number of changed files (`total`, `created`, `removed`, `modified`) and the same counts for the 40 folders with the most changes (two levels deep, `.` for the mod root, `omittedFolders` for the rest), so the size of a write is visible even when the inline `changedFiles` list is cut.
@@ -567,7 +571,7 @@ Only a course that cannot exist is refused with `MAP_RIVER_UNREACHABLE_MOUTH`: a
567
571
 
568
572
  A declared pass is a saddle lower than the crest on both sides (ADR 0072): the heights in its corridor are capped at the saddle level after all relief is composed, so a volcano cone or plateau on the pass is cut down there (move the volcano if the cone should stay whole). Another range's body is not touched.
569
573
 
570
- To check all of this without a write, call `hoi4.map_rewrite` with `preview: true` and `synthesisCheck: true` on the `create_world` operation: it runs the relief and river synthesis only, writes nothing and returns `MAP_SYNTHESIS_CHECK_READY` or `MAP_SYNTHESIS_CHECK_BLOCKED` with `data.synthesisCheck` (unreachable rivers, carved crossings and passes that are not lower than their crest). It does not run the partition, the countries or the climate stage (ADR 0070). A world that fails to generate returns only its own blockers, never the findings of the map it would replace.
574
+ To check all of this without a write, call `hoi4.map_rewrite` with `preview: true` and `synthesisCheck: true` on the `create_world` operation: it runs the relief and river synthesis only, writes nothing and returns `MAP_SYNTHESIS_CHECK_READY` or `MAP_SYNTHESIS_CHECK_BLOCKED` with `data.synthesisCheck` (unreachable rivers, carved crossings and passes that are not lower than their crest). It reports every blocking problem it finds in one answer, each in `blockers`: realm points that cannot be placed, cities and capitals on impassable land, rivers that cannot reach their mouths, and passes that are not lower than their crest, checked after a river fails too. A write still stops at its first blocking problem. Leaks through a wall (`MAP_RANGE_NOT_CLOSED`) and capitals in provinces that are only mostly impassable need the partition, so only a write finds them. It does not run the partition, the countries or the climate stage (ADR 0070). A world that fails to generate returns only its own blockers, never the findings of the map it would replace.
571
575
 
572
576
  ### Feature-aware provinces, states and strategic regions
573
577
 
@@ -634,7 +638,7 @@ The engine wraps the map horizontally, so land that touches the first or last co
634
638
  | `mode` | `sea-band` when `edge` is given | `sea-band` clears land from the east and west edges and the poles to open sea with a ragged outline; `rim` ends land at the seam in an impassable snow range; `wall` closes the seam with impassable land over the full height; `none` opts out. |
635
639
  | `bandPx` | `max(192, 4% of the width)`, at most a quarter of the width | East and west sea band. |
636
640
  | `polarPx` | 64, at most a quarter of the height | North and south sea band; 0 lets land reach the top and bottom edges. |
637
- | `rimPx` | 160 for `rim`, 48 for `wall`, at most a quarter of the width | Width of the rim range for `rim` or of the wall for `wall`. Heights rise from 150 to 230, the colour map darkens and `adjacencies.csv` gets one `impassable` row per pair of land provinces across the seam. |
641
+ | `rimPx` | 160 for `rim`, 48 for `wall`, at most a quarter of the width | Width of the rim range for `rim` or of the wall for `wall`. Heights rise from 150 to 230, the colour map darkens, and every land province on the first or last column becomes an impassable state. No adjacency row crosses the seam: the game draws one as a line across the whole map (`MAP_ADJACENCY_ACROSS_SEAM`, error). |
638
642
  | `wallTerrain` | `auto` | `wall` only: the look of the wall. `auto` takes, for each row and side, the terrain of the nearest land beyond the wall within four wall widths (snow where the land is snowy), or snow in the outer fifths of the map and mountain elsewhere where it meets only water, smoothed over about half a wall width of rows. A list of `{y0, y1, kind}` segments (rows from the top, inclusive; kind one of `snow`, `mountain`, `hills`, `desert`, `forest`, `plains`, `marsh`, `jungle`) sets it by rows; uncovered rows stay `auto`. |
639
643
 
640
644
  A band wider than a quarter of the world is refused (`MAP_EDGE_BAND_TOO_WIDE`). A city inside a band that would be cleared is an error (`MAP_EDGE_FEATURE_IN_BAND`) naming it; land that is cleared is reported with its pixel count (`MAP_EDGE_LAND_CLEARED`). `ambientFrame: true` writes the north and south frame borders and the logo frame into `ambient_object.txt` at the base map's positions scaled to the world height (the north frame at `z = height + 142`, the south frame at `z = -140`); by default the file is a comment, which drops the frame. The wrap cannot be removed with data; the band makes it invisible and the rim makes it a wall. Which looks better in the game is for you to judge with a probe map. Rivers are routed before the rim is raised, so keep them out of a rim.
@@ -643,7 +647,7 @@ A `rim` leaves sea at the seam as sea, and ships sail across it, because the sea
643
647
 
644
648
  - A band between 60% and 100% of `rimPx` wide at the east and west edges, over the full height, becomes land; sea and lakes in it are filled (`MAP_EDGE_WALL_FILLED`, information). Its inner edge follows fractal noise, so it reads as a coast or cliff line rather than a ruled line. It gets the rim's heights and darker colours, the look `wallTerrain` sets, and the impassable rows across the seam.
645
649
  - The seam is closed at any width, because the seam columns themselves are land. The default of 48 pixels keeps the wall at least one default land province (400 pixels, about 20 across) wide even where it is narrowest; for other province sizes, about 1.7 times the square root of `landProvincePixels` does the same.
646
- - A land province with most of its pixels in the band belongs to the wall. The wall's provinces form their own states with `impassable = yes`, `force_link_ownership_to` the nearest passable state (counted in province steps over land and water) and that state's owner, as the base game's 21 impassable states do; the category is `enclave` where the mod defines it, with infrastructure 0 and no buildings, resources, victory points, ports or forts. A province that straddles the inner edge of the band goes wholly to the side holding most of its pixels.
650
+ - A land province with most of its pixels in the band belongs to the wall. The wall joins no landmass, strategic region or country across the seam (see [Create a new world](#create-a-new-world)): each side of it takes the continent of the land beside it, and its states the owner of the state they link to. The wall's provinces form their own states with `impassable = yes`, `force_link_ownership_to` the nearest passable state (counted in province steps over land and water) and that state's owner, as the base game's 21 impassable states do; the category is `enclave` where the mod defines it, with infrastructure 0 and no buildings, resources, victory points, ports or forts. A province that straddles the inner edge of the band goes wholly to the side holding most of its pixels.
647
651
  - A city in the band (`MAP_EDGE_FEATURE_IN_BAND`) or a workspace capital in a wall province is an error. Capitals are never placed in the wall.
648
652
  - Validation of a `wall` world reports water on the first or last column as `MAP_EDGE_WALL_OPEN` (error) instead of `MAP_EDGE_LAND_CUT`.
649
653
  - With `polarPx: 0` land runs off the top and bottom edges, which validation reports as `MAP_POLAR_LAND` (information); the frame borders are drawn over those rows.
package/docs/reference.md CHANGED
@@ -5,14 +5,16 @@ The installed game docs define current syntax; the wiki supplies broader guidanc
5
5
 
6
6
  The server discovers these directories for a workspace:
7
7
 
8
- | Source | Default location | Optional workspace registration |
9
- | ------------------------------ | --------------------------------------------------------------------------- | ------------------------------------------------------ |
10
- | Installed game documentation | `gameRoot/documentation/**/*.md` and `gameRoot/common/**/*documentation.md` | Configure `gameRoot`. |
11
- | HOI4 wiki (kit) | `modRoot/hoi4_wiki/**/*.md`, else `modRoot/paradox_wiki/**/*.md` | Set absolute `wikiRoot`. |
12
- | Generated script documentation | `modRoot/script_docs/**/*.md` and `**/*.log` | Set absolute `scriptDocsRoot` to a user-supplied dump. |
8
+ | Source | Default location | Optional workspace registration |
9
+ | ------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------ |
10
+ | Installed game documentation | `gameRoot/documentation/**/*.md` and `gameRoot/common/**/*documentation.md` | Configure `gameRoot`. |
11
+ | HOI4 wiki (kit) | `modRoot/hoi4_wiki/**/*.md`, else `modRoot/paradox_wiki/**/*.md`, else the docs pack | Set absolute `wikiRoot`. |
12
+ | Generated script documentation | `modRoot/script_docs/**/*.md` and `**/*.log` | Set absolute `scriptDocsRoot` to a user-supplied dump. |
13
13
 
14
14
  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.
15
15
 
16
+ With no mod selected, `hoi4.reference_search`, `hoi4.reference_read` and `hoi4.reference_context` still answer, from the installed game documentation and the docs pack that `hoi4-agent-tools-setup --fetch-docs` installs. Such an answer has the workspace ID `docs` and the information `REFERENCE_DOCUMENTATION_ONLY`, and `"workspaceId":"docs"` asks for it explicitly. When no wiki page is available at all, `REFERENCE_WIKI_UNAVAILABLE` names the fetch step.
17
+
16
18
  ## Tools
17
19
 
18
20
  - `hoi4.reference_context`: request one surface: `general`, `event`, `decision`, `idea`, `focus`, `technology`, `gui`, `map`, `localisation`, or `ai`. The default limit is 16 citations and the maximum is 24. 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.
@@ -149,6 +151,44 @@ Filter with `scope` (`all`, `mod` for entries in the mod's own files, or `unloca
149
151
  The tool reads the log the game wrote at its last launch; it never starts the game.
150
152
  Run `hoi4.script_validate` with `path` on the reported file to check the same body before the next launch.
151
153
 
154
+ ## Explain an error.log line
155
+
156
+ `hoi4.explain_error` takes one `line`, or up to 10 `lines`, as the game writes them or as `hoi4.error_log` returns them.
157
+ A parser error that wraps several messages (`Error: "... near line: 11 ... near line: 12" in file: "..."`) gives one explanation per message, each at its own line.
158
+ Each explanation carries:
159
+
160
+ - `rule`: what the game requires, and `fix`: what to change. Both come from a reviewed catalogue (`error-explanations.json`) of the messages the game's own log writes, each with its evidence: the log of a named game build or the game's documentation. `matched` says where they came from: `catalogue`, a reviewed `known_mistake`, or only the message's `category`.
161
+ - `source`: the file, the line and its layer (`mod`, `dependency`, `game`), with up to 5 lines around it. A line from the game's own files says so in `note`: it appears without the mod too.
162
+ - `subject`, the command, key or tag the message names, with `documentedAs` (whether the installed documentation lists it as an effect, trigger or modifier), `definedBy` (a scripted effect or trigger that a loaded file defines) and up to 3 `suggestions`. A value read as a trigger suggests its `has_` trigger first, such as `has_stability` for `stability`.
163
+ - `next`: the call that narrows it down, `hoi4.script_validate` on a mod file.
164
+
165
+ ```json
166
+ { "line": "Invalid trigger 'stability' in events/my_events.txt line : 12" }
167
+ ```
168
+
169
+ ## Find invented commands in new script
170
+
171
+ `hoi4.script_guard` checks the files an agent wrote: every effect, trigger and modifier in them that the installed game's documentation does not list and no loaded file defines as a scripted effect, scripted trigger or modifier. Each invented name comes with its kind, file, line, the definition it is in and the closest real name. Pass `paths` (up to 50 mod files), or leave them out to check the mod's script files changed in the last `sinceMinutes` (120 by default). File times choose the files, so no Git command runs in the mod. The engine's whole-mod check (`hoi4-engine check`) judges every `name = value` command, and `hoi4.script_validate` adds the names it cannot resolve, such as a trigger compared with `>`. Without the engine the tool answers `ENGINE_UNAVAILABLE`.
172
+
173
+ ```json
174
+ { "paths": ["events/my_events.txt"] }
175
+ ```
176
+
177
+ ## Check a whole mod
178
+
179
+ `hoi4.mod_health` runs the existing audits in one call and returns the 10 problems that matter most (`limit` lowers it):
180
+
181
+ - `error_log`: the mod's own entries of the last launch's `error.log`. A log from a launch without the mod is ignored, and a log older than the mod's files counts for less.
182
+ - `engine_check`: the engine's whole-mod check: unknown effects, triggers and modifiers, duplicate ids, event namespace collisions, broken and dropping overrides and missing localisation keys.
183
+ - `script`: `hoi4.script_validate` on the mod's script files, those the other audits named first and the newest after them, within 30 seconds.
184
+ - `localisation` and `assets`: the localisation audit and the sprite and flag audits.
185
+
186
+ Findings of one kind form one problem with its count, two examples, its fix and the tool to call next. Two audits that report the same kind, such as a missing localisation key, count once. Problems rank by severity, then by how much they hurt a player (the game failing to read a file first), then by count. `checks` says which audits ran, which ran partly and why, and which could not run (the engine audits need `hoi4-engine`). `verdict` is `healthy` only when every audit ran and found nothing, and `incomplete` when nothing was found but an audit could not run. Choose audits with `checks`. A large mod takes up to a minute.
187
+
188
+ ```json
189
+ { "limit": 5 }
190
+ ```
191
+
152
192
  ## Index the mod and pick free IDs
153
193
 
154
194
  `hoi4.mod_index` with `mode: "overview"` summarizes the mod without reading every file:
@@ -168,6 +208,8 @@ The result gives `nextId` after the highest used number, and `firstGapId` when a
168
208
  { "mode": "next_id", "kind": "event", "namespace": "my_mod" }
169
209
  ```
170
210
 
211
+ Both modes run on the shared Rust engine (`hoi4-engine mod-index`). Without a usable engine binary the call answers `ENGINE_UNAVAILABLE`; nothing is counted in TypeScript instead.
212
+
171
213
  ## Read the mod's skills
172
214
 
173
215
  `hoi4.skill` serves the modding skills HOI4 Mod Setup installed in the mod, so every client reads the same text.
@@ -1,6 +1,16 @@
1
1
  # Probability adapter evidence
2
2
 
3
- The AI and MTTH Scenario Analyzer targets Hearts of Iron IV **Operation Postern 1.19.4.1 (checksum f584)**. Adapter behavior is versioned as `hoi4-1.19.4.1.v1`. Results always include that adapter version and game build. When the installed build differs, results carry the warning `PROBABILITY_GAME_BUILD_UNVERIFIED`, and the nightly game-update watcher lists the adapters under "Checked against another build" on every run until the pin moves.
3
+ The AI and MTTH Scenario Analyzer targets Hearts of Iron IV **Operation Postern 1.19.4.2 (checksum 0bdb)**. Adapter behavior is versioned as `hoi4-1.19.4.2.v1`. Results always include that adapter version and game build. When the installed build differs, results carry the warning `PROBABILITY_GAME_BUILD_UNVERIFIED`, and the nightly game-update watcher lists the adapters under "Checked against another build" on every run until the pin moves.
4
+
5
+ ## Re-check for 1.19.4.2 (2026-11-08)
6
+
7
+ Every reviewed file was hashed again on the installed game 1.19.4.2:
8
+
9
+ - **Unchanged:** all six reviewed documentation files are byte-identical to the 1.19.4.1 review: `common/decisions/_documentation.md`, `common/doctrines/_documentation.md`, `common/script_constants/documentation.md`, `documentation/script_concept_documentation.md`, `documentation/effects_documentation.md` and `common/ai_strategy/_documentation.md` (`cd19fa14…c715`).
10
+ - **Examples:** each vanilla example below keeps its construct at the line given for 1.19.4.1: `events/Yugoslavia.txt:49`, `events/AAT_Generic_Events.txt:44`, `common/decisions/_generic_decisions.txt:56`, `common/national_focus/austria.txt:122`, `common/technologies/industry.txt:30`, `common/doctrines/grand_doctrines/land_grand_doctrines.txt:14`, `events/AAT_Sweden.txt:1760`, `events/BBA_Switzerland.txt:1205` and the `research_weight_factor` strategy at `common/ai_strategy/ENG.txt:3202`.
11
+ - **Installed build:** `launcher-settings.json` reads `Operation Postern v1.19.4.2.2da5 (0bdb)`, raw version `1.19.4.2`.
12
+
13
+ No adapter rule changed, so only the version pin moved.
4
14
 
5
15
  ## Re-check for 1.19.4.1 (2026-11-06)
6
16
 
package/docs/setup.md CHANGED
@@ -36,6 +36,18 @@ The [client examples](../examples/clients) show the same entries without your pa
36
36
 
37
37
  Open the mod as your agent's workspace.
38
38
 
39
+ ### Choose tool profiles
40
+
41
+ Every tool the server lists costs the agent context on every turn, so a session lists the `core` profile unless it asks for more:
42
+
43
+ | Profile | Tools |
44
+ | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
45
+ | `core` | Documentation search and reading, source lookup, script validation and the invented-command guard, the error log and its explanations, the mod health check, the mod index, localisation and kit skills |
46
+ | `map` | The world map builder (`map_inspect`, `map_rewrite`) and the job controls |
47
+ | `advanced` | Focus, GUI, event, technology, decision and probability editors, renders and analyses, the other inspect tools, compatibility checks and the job controls |
48
+
49
+ Set `HOI4_AGENT_TOOLS_PROFILES` in the client's server entry to list more, for example `"env": { "HOI4_AGENT_TOOLS_PROFILES": "core,map" }`, or `all` for every tool. The `profiles` key of the configuration file does the same for every client. A tool outside the listed profiles still answers when a call names it.
50
+
39
51
  ### How the server picks your mod
40
52
 
41
53
  Every tool takes an optional `workspaceId`; the default, `"current"`, means the mod that contains the client's workspace root or, when the client sends no roots, the server's working directory.
@@ -83,10 +95,18 @@ Entries that are not plain relative folders, such as `../outside` or wildcard pa
83
95
 
84
96
  ## Add local reference material
85
97
 
86
- Place the kit's HOI4 wiki in `hoi4_wiki/` inside the mod. A mod the kit has not updated yet keeps working with the older `paradox_wiki/` name; when both exist, `hoi4_wiki/` wins.
98
+ Documentation search works with no mod open once the HOI4 wiki pages are installed. Run this once:
99
+
100
+ ```bash
101
+ hoi4-agent-tools-setup --fetch-docs
102
+ ```
103
+
104
+ It downloads the docs pack: the modding kit's HOI4 wiki pages at the kit commit this version pins (about 3.6 MB), with their licence and sources, checked against pinned SHA-256 hashes. It installs them in `docsRoot` (the user's data folder by default) and replaces an older pack. Run it again after an update of `hoi4-agent-tools`. With no mod selected, the reference tools then answer from the game documentation (`gameRoot`) and the pack. A mod without its own wiki copy reads the pack too.
105
+
106
+ A mod that has the kit's wiki in `hoi4_wiki/` reads its own copy instead. A mod the kit has not updated yet keeps working with the older `paradox_wiki/` name; when both exist, `hoi4_wiki/` wins.
87
107
  An optional generated documentation dump can go in `script_docs/`.
88
108
  For a configured workspace, `wikiRoot` and `scriptDocsRoot` can point to other absolute directories.
89
- The server reads these local files; it does not download the wiki.
109
+ The server itself never downloads anything; only `--fetch-docs` does.
90
110
  See [Local references](reference.md) for source selection and missing-source reports.
91
111
 
92
112
  ## Common problems
@@ -109,7 +129,7 @@ hoi4-agent-tools-setup --diagnose
109
129
  ```
110
130
 
111
131
  `--discover` prints the mod and game folders the server can detect, without writing anything.
112
- `--diagnose` checks the configured paths and their permissions, the Node.js version and the image library, and accepts `--config PATH`.
132
+ `--diagnose` checks the configured paths and their permissions, the Node.js version, the image library and whether the docs pack is installed, and accepts `--config PATH`.
113
133
  `--help` lists every option.
114
134
 
115
135
  For remote or shared deployments, use the [HTTP guide](http.md).
package/docs/tools.md CHANGED
@@ -28,6 +28,10 @@ A test fails when this page differs from `tools/list`, so edit the tool descript
28
28
  | `hoi4.source_lookup` | Find where a script symbol is defined and used across the game, DLC and mod. Pass a symbol, or a file path and line. | — |
29
29
  | `hoi4.script_validate` | Find broken syntax, commands and scopes in an effect, trigger or mod file using the installed docs. Unknown helpers and native argument blocks stay unresolved. | — |
30
30
  | `hoi4.error_log` | Find errors from the last game launch and group them by category, with source files, lines and fix hints. Show which files changed since the log and which errors appeared after a relaunch; mod entries come first. | — |
31
+ | `hoi4.explain_error` | Explain error.log lines: the rule each one breaks, its file and line with the lines around it, and the fix, from a reviewed catalogue of the game's messages. Says whether the game documents the command a line names, and the closest documented names. | — |
32
+ | `hoi4.mod_health` | Check a whole mod in one call: the last error.log, the engine check (unknown effects, triggers and modifiers, duplicate ids, broken overrides), script validation, and the localisation and asset audits. Returns the 10 problems that matter most, each counted with 2 examples, its fix and the tool to use next, and which audits ran. | — |
33
+ | `hoi4.script_guard` | Check the files you wrote for invented commands: every effect, trigger and modifier that the installed game documentation does not list and no loaded file defines, with its file, line and the closest real name. Checks the named paths, or the mod script files changed in the last 120 minutes. Needs hoi4-engine. | — |
34
+ | `hoi4.compat_check` | mod: compare this mod with another in both load orders: files at the same path and who wins, duplicate ids, definitions and hooks dropped, replace_path losses, and which order loses less. patch: store the vanilla files the mod overrides and list those a game update changed. | — |
31
35
  | `hoi4.mod_index` | Summarize the content in a mod or find a free event ID across the mod, game and dependencies. Use overview for descriptors, folders and definitions, or next_id with a namespace or prefix. | — |
32
36
  | `hoi4.localisation_inspect` | Read localisation in every language the game and mod ship. key: one key per language with file, line and layer, the languages lacking it and the files mentioning it. audit: keys the mod uses that no language defines, keys missing from a supported language, keys defined twice in one language, and file problems. coverage: keys per language. | — |
33
37
  | `hoi4.idea_inspect` | Read an idea or character across the game, DLC and mod. idea: category, picture sprite and texture, modifiers checked against the game docs, conditions, name in every language, the advisor it belongs to, and files mentioning it. character: name, roles with traits checked, portraits checked. audit: true checks every idea or character of the mod. | — |
@@ -36,6 +40,12 @@ A test fails when this page differs from `tools/list`, so edit the tool descript
36
40
  | `hoi4.asset_inspect` | Read one sprite (texture size, format and frames), sound, sound effect or music track (audio file, sounds it plays), or flag (all three sizes), or audit every one the mod defines. Flags BC7 textures, missing files and wrong flag sizes. | — |
37
41
  | `hoi4.skill` | List the modding skills installed in the mod, or load one by name, at the kit version HOI4 Mod Setup pinned, with its hash. A file edited since Setup installed it is refused unless acceptLocalEdits. | — |
38
42
 
43
+ ## Localisation
44
+
45
+ | Tool | Purpose | Writes |
46
+ | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- |
47
+ | `hoi4.localisation_write` | Add localisation keys (mode add: key and text; language, file, replace) or repair localisation files (mode fix: BOM, broken quotes, keys missing from supported languages). Game keys are overridden from a replace folder. apply false returns the diff and writes nothing; apply true writes it. Returns up to 10 files with diffs. | mod files |
48
+
39
49
  ## Focus trees
40
50
 
41
51
  | Tool | Purpose | Writes |
@@ -135,6 +145,10 @@ The CI stdio smoke suite sends each of these shapes to a real server process.
135
145
  | `hoi4.source_lookup` | `{"symbol":"my_scripted_effect"}` |
136
146
  | `hoi4.script_validate` | `{"source":"add_political_power = 10","kind":"effect","scope":"country"}` or `{"path":"events/a.txt"}` |
137
147
  | `hoi4.error_log` | `{"scope":"mod","category":"effect"}` |
148
+ | `hoi4.explain_error` | `{"line":"Invalid trigger 'stability' in events/my_events.txt line : 12"}` |
149
+ | `hoi4.mod_health` | `{"limit":5}` or `{"checks":["error_log","engine_check"]}` |
150
+ | `hoi4.script_guard` | `{"paths":["events/my_events.txt"]}` |
151
+ | `hoi4.compat_check` | `{"mode":"mod","other":"my_other_mod"}` or `{"mode":"patch"}` |
138
152
  | `hoi4.mod_index` | `{"mode":"next_id","kind":"event","namespace":"my_mod"}` |
139
153
  | `hoi4.localisation_inspect` | `{"mode":"key","key":"my_event.1.t"}` or `{"mode":"audit"}` |
140
154
  | `hoi4.idea_inspect` | `{"kind":"idea","id":"GER_mefo_bills_1"}` or `{"kind":"character","audit":true}` |
@@ -142,6 +156,7 @@ The CI stdio smoke suite sends each of these shapes to a real server process.
142
156
  | `hoi4.unit_inspect` | `{"kind":"oob","id":"GER_1936"}` or `{"kind":"variant","audit":true}` |
143
157
  | `hoi4.asset_inspect` | `{"kind":"sprite","id":"GFX_my_icon"}` or `{"kind":"flag","audit":true}` |
144
158
  | `hoi4.skill` | `{"name":"hoi4-events"}` |
159
+ | `hoi4.localisation_write` | `{"mode":"add","entries":[{"key":"my_focus","text":"My focus"}]}` |
145
160
  | `hoi4.focus_inspect` | `{"treeId":"my_focus_tree"}` |
146
161
  | `hoi4.focus_render` | `{"relativePath":"common/national_focus/my_tree.txt","treeId":"my_focus_tree"}` |
147
162
  | `hoi4.focus_rewrite` | `{"relativePath":"common/national_focus/my_tree.txt","treeId":"my_focus_tree","layoutMode":"compact"}` |
@@ -186,13 +201,12 @@ Archive images you need to keep rather than relying on temporary server storage.
186
201
 
187
202
  ## Longer operations
188
203
 
189
- All 19 domain tools accept negotiated MCP tasks, so a client that supports tasks can retrieve a long operation after reconnecting.
204
+ All 20 domain tools accept negotiated MCP tasks, so a client that supports tasks can retrieve a long operation after reconnecting.
190
205
  The 7 reference tools and the 2 job tools always answer in the foreground.
191
206
  Other clients receive the ordinary synchronous result.
192
207
  Use `hoi4.job_inspect` to inspect an authorized job or retrieve its result, and `hoi4.job_cancel` to request cancellation.
193
208
  See [Background jobs](jobs.md) for request keys, cancellation and recovery.
194
209
 
195
- ## Optional ChaosX tools
210
+ ## Plugins
196
211
 
197
- On the stdio server (`hoi4-agent-tools`), setting `HOI4_AGENT_TOOLS_CHAOSX=1` exposes `chaosx.focus_country_assets` and `chaosx.visual_revision`.
198
- These workflow-specific tools are absent from the default list, and the HTTP server never exposes them.
212
+ A private extension can add tools to the stdio server (`hoi4-agent-tools`). List its module (`.mjs` or `.js`, absolute path) in the configuration key `plugins`; the server loads plugins only from those paths, never from a mod folder or the environment, and the HTTP server never loads them. A plugin tool is named `<plugin>.<tool>` and never starts with `hoi4.`, which this package reserves. A plugin exports a default function that receives a host (`importServerModule` to borrow the server's own modules, `dependency` for the shared `zod` and `sharp`) and returns a factory of tools; each tool has the same definition as a built-in one (name, title, description, input and optional output schema, annotations) and a `call` function. A plugin file that does not exist is skipped with a warning on stderr; a file that is a link, is not a `.mjs` or `.js` file, or exports no factory stops the server at startup.