hoi4-agent-tools 4.7.0 → 4.9.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 +34 -0
- package/README.md +32 -13
- package/dist/hoi4_agent_tools/core/engine-client.js +74 -5
- package/dist/hoi4_agent_tools/core/index.js +28 -0
- 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 +46 -2
- package/dist/hoi4_agent_tools/event/queries.js +25 -2
- package/dist/hoi4_agent_tools/event/service.js +78 -11
- 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/impact/service.js +15 -0
- package/dist/hoi4_agent_tools/localisation/inspect.js +34 -0
- package/dist/hoi4_agent_tools/map/appearance-validation.js +14 -2
- package/dist/hoi4_agent_tools/map/geography/resolve.js +3 -2
- package/dist/hoi4_agent_tools/map/tool-operations.js +41 -0
- package/dist/hoi4_agent_tools/map/world-edge.js +117 -15
- package/dist/hoi4_agent_tools/map/world.js +158 -34
- package/dist/hoi4_agent_tools/mcp/server/argument-errors.js +59 -9
- package/dist/hoi4_agent_tools/mcp/server/create-modern-operations.js +1 -1
- package/dist/hoi4_agent_tools/mcp/server/request-lifecycle.js +1 -1
- package/dist/hoi4_agent_tools/mcp/tools/analysis.js +4 -2
- package/dist/hoi4_agent_tools/mcp/tools/event.js +15 -0
- package/dist/hoi4_agent_tools/mcp/tools/focus.js +1 -1
- package/dist/hoi4_agent_tools/mcp/tools/gui.js +1 -1
- package/dist/hoi4_agent_tools/mcp/tools/reference.js +43 -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 +59 -1
- 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 +205 -12
- package/dist/hoi4_agent_tools/reference/ranking.js +32 -0
- package/dist/hoi4_agent_tools/reference/script-validation.js +159 -8
- 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/map.js +32 -4
- package/dist/hoi4_agent_tools/schemas/mod-tools.js +11 -0
- package/dist/hoi4_agent_tools/schemas/script-validation.js +8 -1
- package/dist/hoi4_agent_tools/schemas/system.js +157 -0
- package/dist/hoi4_agent_tools/system/inspect.js +55 -0
- package/dist/hoi4_agent_tools/version.js +1 -1
- package/docs/analysis.md +2 -2
- package/docs/events.md +1 -1
- package/docs/focus.md +9 -5
- package/docs/map.md +19 -8
- package/docs/research/reference-benchmark.md +41 -0
- package/docs/tools.md +49 -39
- package/docs/troubleshooting.md +13 -12
- package/engine/README.md +293 -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 +165 -101
- 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,157 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
import { workspaceIdSchema } from './common.js';
|
|
3
|
+
import { fieldSchema, placeSchema, problemSchema, textSchema } from './ideas.js';
|
|
4
|
+
/** The systems `hoi4.system_inspect` reads, one engine kind each. */
|
|
5
|
+
export const systemKinds = [
|
|
6
|
+
'on_actions',
|
|
7
|
+
'mio',
|
|
8
|
+
'balance_of_power',
|
|
9
|
+
'special_project',
|
|
10
|
+
'operation',
|
|
11
|
+
'raid',
|
|
12
|
+
];
|
|
13
|
+
/** `hoi4.system_inspect`, answered by `hoi4-engine system`. */
|
|
14
|
+
export const systemInspectRequestSchema = z
|
|
15
|
+
.object({
|
|
16
|
+
workspaceId: workspaceIdSchema,
|
|
17
|
+
/** on_actions: a hook. mio: an organization or policy. special_project: a project, prototype reward, specialization or tag. operation: an operation, phase or token. raid: a raid or raid category. */
|
|
18
|
+
kind: z.enum(systemKinds),
|
|
19
|
+
/** The definition (or on_actions hook) to inspect. Leave it out with audit. */
|
|
20
|
+
id: z.string().min(1).max(256).optional(),
|
|
21
|
+
/** Check every definition of this system the mod makes instead of one. */
|
|
22
|
+
audit: z.boolean().default(false),
|
|
23
|
+
/** One: mentions listed. Audit: examples kept per problem code. */
|
|
24
|
+
limit: z.number().int().min(1).max(50).default(5),
|
|
25
|
+
})
|
|
26
|
+
.strict()
|
|
27
|
+
.refine((input) => input.audit || input.id !== undefined, {
|
|
28
|
+
message: 'pass an id, or audit: true',
|
|
29
|
+
path: ['id'],
|
|
30
|
+
});
|
|
31
|
+
/** The kinds `hoi4.unit_inspect` reads, answered by `hoi4-engine units`. */
|
|
32
|
+
export const unitKinds = ['oob', 'sub_unit', 'equipment', 'variant'];
|
|
33
|
+
/** One definition, as the engine answers it. */
|
|
34
|
+
const engineInspectionShape = (kinds) => z
|
|
35
|
+
.object({
|
|
36
|
+
kind: z.enum(kinds),
|
|
37
|
+
id: z.string().max(256),
|
|
38
|
+
found: z.boolean(),
|
|
39
|
+
definitions: z.array(placeSchema.extend({ what: z.string().max(64) })).max(512),
|
|
40
|
+
fields: z.array(fieldSchema).max(32),
|
|
41
|
+
parts: z
|
|
42
|
+
.array(z
|
|
43
|
+
.object({ what: z.string().max(64), id: z.string().max(256), line: z.number().int() })
|
|
44
|
+
.strict())
|
|
45
|
+
.max(100),
|
|
46
|
+
partsTruncated: z.boolean(),
|
|
47
|
+
references: z
|
|
48
|
+
.array(z
|
|
49
|
+
.object({
|
|
50
|
+
field: z.string().max(128),
|
|
51
|
+
target: z.string().max(64),
|
|
52
|
+
value: z.string().max(512),
|
|
53
|
+
known: z.boolean(),
|
|
54
|
+
line: z.number().int(),
|
|
55
|
+
})
|
|
56
|
+
.strict())
|
|
57
|
+
.max(100),
|
|
58
|
+
referencesTruncated: z.boolean(),
|
|
59
|
+
texts: z
|
|
60
|
+
.array(z.object({ key: z.string().max(512), texts: z.array(textSchema).max(64) }).strict())
|
|
61
|
+
.max(8),
|
|
62
|
+
mentions: z
|
|
63
|
+
.array(z
|
|
64
|
+
.object({ path: z.string().max(1024), line: z.number().int(), layer: z.string() })
|
|
65
|
+
.strict())
|
|
66
|
+
.max(100),
|
|
67
|
+
mentionsTruncated: z.boolean(),
|
|
68
|
+
problems: z.array(problemSchema).max(1000),
|
|
69
|
+
suggestions: z.array(z.string().max(256)).max(3).optional(),
|
|
70
|
+
})
|
|
71
|
+
.strict();
|
|
72
|
+
export const systemEngineInspectionSchema = engineInspectionShape(systemKinds);
|
|
73
|
+
/** Every definition of the system the mod makes, as the engine answers an audit. */
|
|
74
|
+
const engineAuditShape = (kinds) => z
|
|
75
|
+
.object({
|
|
76
|
+
kind: z.enum(kinds),
|
|
77
|
+
checked: z.number().int().min(0),
|
|
78
|
+
counts: z.record(z.string(), z.number().int().min(0)),
|
|
79
|
+
problems: z
|
|
80
|
+
.array(z
|
|
81
|
+
.object({
|
|
82
|
+
code: z.string().max(64),
|
|
83
|
+
severity: z.enum(['warning', 'info']),
|
|
84
|
+
id: z.string().max(256),
|
|
85
|
+
path: z.string().max(1024),
|
|
86
|
+
line: z.number().int().min(0),
|
|
87
|
+
message: z.string().max(1200),
|
|
88
|
+
})
|
|
89
|
+
.strict())
|
|
90
|
+
.max(5000),
|
|
91
|
+
truncated: z.boolean(),
|
|
92
|
+
})
|
|
93
|
+
.strict();
|
|
94
|
+
export const systemEngineAuditSchema = engineAuditShape(systemKinds);
|
|
95
|
+
export const systemInspectDataSchema = z
|
|
96
|
+
.object({
|
|
97
|
+
inspection: systemEngineInspectionSchema.optional(),
|
|
98
|
+
audit: systemEngineAuditSchema.optional(),
|
|
99
|
+
durationMs: z.number().int().min(0),
|
|
100
|
+
})
|
|
101
|
+
.strict();
|
|
102
|
+
/** `hoi4.unit_inspect`, answered by `hoi4-engine units`. */
|
|
103
|
+
export const unitInspectRequestSchema = z
|
|
104
|
+
.object({
|
|
105
|
+
workspaceId: workspaceIdSchema,
|
|
106
|
+
/** oob: a history/units file name without .txt. sub_unit, equipment (or module): its id. variant: its name. */
|
|
107
|
+
kind: z.enum(unitKinds),
|
|
108
|
+
/** The definition to inspect. Leave it out with audit. */
|
|
109
|
+
id: z.string().min(1).max(256).optional(),
|
|
110
|
+
/** Check every definition of this kind the mod makes instead of one. */
|
|
111
|
+
audit: z.boolean().default(false),
|
|
112
|
+
/** One: mentions listed. Audit: examples kept per problem code. */
|
|
113
|
+
limit: z.number().int().min(1).max(50).default(5),
|
|
114
|
+
})
|
|
115
|
+
.strict()
|
|
116
|
+
.refine((input) => input.audit || input.id !== undefined, {
|
|
117
|
+
message: 'pass an id, or audit: true',
|
|
118
|
+
path: ['id'],
|
|
119
|
+
});
|
|
120
|
+
export const unitEngineInspectionSchema = engineInspectionShape(unitKinds);
|
|
121
|
+
export const unitEngineAuditSchema = engineAuditShape(unitKinds);
|
|
122
|
+
export const unitInspectDataSchema = z
|
|
123
|
+
.object({
|
|
124
|
+
inspection: unitEngineInspectionSchema.optional(),
|
|
125
|
+
audit: unitEngineAuditSchema.optional(),
|
|
126
|
+
durationMs: z.number().int().min(0),
|
|
127
|
+
})
|
|
128
|
+
.strict();
|
|
129
|
+
/** The kinds `hoi4.asset_inspect` reads, answered by `hoi4-engine assets`. */
|
|
130
|
+
export const assetKinds = ['sprite', 'sound', 'flag'];
|
|
131
|
+
/** `hoi4.asset_inspect`, answered by `hoi4-engine assets`. */
|
|
132
|
+
export const assetInspectRequestSchema = z
|
|
133
|
+
.object({
|
|
134
|
+
workspaceId: workspaceIdSchema,
|
|
135
|
+
/** sprite: a sprite name. sound: a sound, sound effect, category or music name. flag: TAG or TAG_ideology. */
|
|
136
|
+
kind: z.enum(assetKinds),
|
|
137
|
+
/** The asset to inspect. Leave it out with audit. */
|
|
138
|
+
id: z.string().min(1).max(256).optional(),
|
|
139
|
+
/** Check every asset of this kind the mod defines instead of one. */
|
|
140
|
+
audit: z.boolean().default(false),
|
|
141
|
+
/** One: mentions listed. Audit: examples kept per problem code. */
|
|
142
|
+
limit: z.number().int().min(1).max(50).default(5),
|
|
143
|
+
})
|
|
144
|
+
.strict()
|
|
145
|
+
.refine((input) => input.audit || input.id !== undefined, {
|
|
146
|
+
message: 'pass an id, or audit: true',
|
|
147
|
+
path: ['id'],
|
|
148
|
+
});
|
|
149
|
+
export const assetEngineInspectionSchema = engineInspectionShape(assetKinds);
|
|
150
|
+
export const assetEngineAuditSchema = engineAuditShape(assetKinds);
|
|
151
|
+
export const assetInspectDataSchema = z
|
|
152
|
+
.object({
|
|
153
|
+
inspection: assetEngineInspectionSchema.optional(),
|
|
154
|
+
audit: assetEngineAuditSchema.optional(),
|
|
155
|
+
durationMs: z.number().int().min(0),
|
|
156
|
+
})
|
|
157
|
+
.strict();
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { runEngineCommand } from '../core/engine-client.js';
|
|
2
|
+
import { ServiceError } from '../core/result.js';
|
|
3
|
+
import { assetEngineAuditSchema, assetEngineInspectionSchema, systemEngineAuditSchema, systemEngineInspectionSchema, unitEngineAuditSchema, unitEngineInspectionSchema, } from '../schemas/system.js';
|
|
4
|
+
/** An audit reads the system's files, the sprites and every localisation file. */
|
|
5
|
+
const SYSTEM_TIMEOUT_MS = 180_000;
|
|
6
|
+
/**
|
|
7
|
+
* Runs one engine command that answers a definition or an audit. This side passes the workspace's
|
|
8
|
+
* roots and turns the engine's answer into the tool's data. A missing engine is
|
|
9
|
+
* `ENGINE_UNAVAILABLE`, with no TypeScript fallback.
|
|
10
|
+
*/
|
|
11
|
+
async function inspectDefinitions(command, schemas, notFound, workspace, input, signal) {
|
|
12
|
+
const started = Date.now();
|
|
13
|
+
const request = {
|
|
14
|
+
...(workspace.gameRoot === undefined ? {} : { game: workspace.gameRoot }),
|
|
15
|
+
...(workspace.registration.kind === 'game' ? {} : { mod: workspace.modRoot }),
|
|
16
|
+
dependencies: workspace.dependencyRoots,
|
|
17
|
+
includeDlc: workspace.dlcLayers.length > 0,
|
|
18
|
+
kind: input.kind,
|
|
19
|
+
...(input.id === undefined ? {} : { id: input.id }),
|
|
20
|
+
audit: input.audit,
|
|
21
|
+
limit: input.limit,
|
|
22
|
+
};
|
|
23
|
+
const options = { timeoutMs: SYSTEM_TIMEOUT_MS, ...(signal === undefined ? {} : { signal }) };
|
|
24
|
+
if (input.audit) {
|
|
25
|
+
const result = await runEngineCommand(command, request, schemas.audit, options);
|
|
26
|
+
if (!result.available)
|
|
27
|
+
throw new ServiceError('ENGINE_UNAVAILABLE', result.message, { reason: result.reason });
|
|
28
|
+
if (result.outcome === 'invalid_request')
|
|
29
|
+
throw new ServiceError(result.error.code, result.error.message);
|
|
30
|
+
return { audit: result.response, durationMs: Date.now() - started };
|
|
31
|
+
}
|
|
32
|
+
const result = await runEngineCommand(command, request, schemas.inspection, options);
|
|
33
|
+
if (!result.available)
|
|
34
|
+
throw new ServiceError('ENGINE_UNAVAILABLE', result.message, { reason: result.reason });
|
|
35
|
+
if (result.outcome === 'invalid_request')
|
|
36
|
+
throw new ServiceError(result.error.code, result.error.message);
|
|
37
|
+
const inspection = result.response;
|
|
38
|
+
if (!inspection.found) {
|
|
39
|
+
const suggestions = inspection.suggestions ?? [];
|
|
40
|
+
throw new ServiceError(notFound, `No loaded ${input.kind} file defines ${input.id ?? ''}${suggestions.length === 0 ? '' : `; did you mean ${suggestions.join(', ')}?`}`, { kind: input.kind, id: input.id ?? '', suggestions });
|
|
41
|
+
}
|
|
42
|
+
return { inspection: result.response, durationMs: Date.now() - started };
|
|
43
|
+
}
|
|
44
|
+
/** `hoi4.system_inspect` on the shared Rust engine (`hoi4-engine system`). */
|
|
45
|
+
export async function inspectSystem(workspace, input, signal) {
|
|
46
|
+
return inspectDefinitions('system', { inspection: systemEngineInspectionSchema, audit: systemEngineAuditSchema }, 'SYSTEM_DEFINITION_NOT_FOUND', workspace, input, signal);
|
|
47
|
+
}
|
|
48
|
+
/** `hoi4.unit_inspect` on the shared Rust engine (`hoi4-engine units`). */
|
|
49
|
+
export async function inspectUnits(workspace, input, signal) {
|
|
50
|
+
return inspectDefinitions('units', { inspection: unitEngineInspectionSchema, audit: unitEngineAuditSchema }, 'UNIT_DEFINITION_NOT_FOUND', workspace, input, signal);
|
|
51
|
+
}
|
|
52
|
+
/** `hoi4.asset_inspect` on the shared Rust engine (`hoi4-engine assets`). */
|
|
53
|
+
export async function inspectAssets(workspace, input, signal) {
|
|
54
|
+
return inspectDefinitions('assets', { inspection: assetEngineInspectionSchema, audit: assetEngineAuditSchema }, 'ASSET_NOT_FOUND', workspace, input, signal);
|
|
55
|
+
}
|
|
@@ -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.9.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/analysis.md
CHANGED
|
@@ -31,7 +31,7 @@ Each entry is an object with `relativePath` and `content`, and a request takes b
|
|
|
31
31
|
|
|
32
32
|
Impact and decision proposals name the text field `content`.
|
|
33
33
|
Event and technology proposals for `hoi4.event_inspect` and `hoi4.tech_inspect` with `mode: compare` name the same field `source` and also accept an optional `expectedSourceHash`.
|
|
34
|
-
When `changedFiles` is omitted, each proposed file seeds all its active definitions alongside any selected symbols.
|
|
34
|
+
When `changedFiles` is omitted, each proposed file seeds all its active definitions alongside any selected symbols. A symbol that nothing defines or uses, in the source or the proposal, answers `IMPACT_SYMBOL_NOT_FOUND` with close names.
|
|
35
35
|
The report compares the original and proposed consumer graph, including added and removed consumers and affected files.
|
|
36
36
|
Moving a source location within one file does not count an unchanged reference as a new or removed consumer.
|
|
37
37
|
`expectedRevision` prevents analysis against a source revision different from the one the caller reviewed.
|
|
@@ -97,7 +97,7 @@ Inspect one decision under declared actor and target state:
|
|
|
97
97
|
```
|
|
98
98
|
|
|
99
99
|
`ROOT` is the actor country and `FROM` is the declared target country or state.
|
|
100
|
-
The inventory lists active decisions, category fragments, overridden source definitions, and each decision's explicit targets, target arrays, state filters, and target trigger declarations.
|
|
100
|
+
The inventory lists active decisions, category fragments, overridden source definitions, and each decision's explicit targets, target arrays, state filters, and target trigger declarations. With an `id`, it lists only that category's decisions, or that one decision, and returns their ids inline in `data.decisionIds`. Any other id answers `DECISION_NOT_FOUND` with close names.
|
|
101
101
|
Category and decision `allowed`, `visible`, and `available` results remain separate; mission visibility is reported as ignored where documented.
|
|
102
102
|
Target selection covers explicit lists and arrays plus supported state ownership, control, and continent filters.
|
|
103
103
|
When a target, flag, variable, or helper input is unknown, the corresponding gate remains unresolved.
|
package/docs/events.md
CHANGED
|
@@ -49,7 +49,7 @@ Selectors use one of these forms:
|
|
|
49
49
|
{ "kind": "manifest", "manifest": { "eventIds": ["namespace.1", "namespace.2"] } }
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
`trace` uses `selector`; `explain_path` uses `from` and `to`; and `state_flow` may add a `stateSubject` object with `kind` and `name`. Allowed state kinds are `country_flag`, `global_flag`, `state_flag`, `variable`, `global_variable`, `array`, `event_target`, `global_event_target`, and `saved_scope`.
|
|
52
|
+
`trace` uses `selector`; `explain_path` uses `from` and `to`; and `state_flow` may add a `stateSubject` object with `kind` and `name`. Allowed state kinds are `country_flag`, `global_flag`, `state_flag`, `variable`, `global_variable`, `array`, `event_target`, `global_event_target`, and `saved_scope`. A subject narrows the findings as well as the flow, and `data.summary.flow` gives its producers and readers inline. `scan`, `roots`, `lint` and `state_flow` apply a `selector` too. A selector that matches nothing answers `EVENT_NOT_FOUND`, `EVENT_NAMESPACE_NOT_FOUND`, `EVENT_NODE_NOT_FOUND` or `EVENT_SOURCE_NOT_FOUND` with close names, and a subject nothing uses answers `EVENT_STATE_NOT_FOUND`.
|
|
53
53
|
|
|
54
54
|
`impact` requires an `impactSubject` object with `kind` and `name`. Allowed impact kinds are `event`, `helper`, `flag`, `variable`, `array`, `event_target`, and `saved_scope`. Set `refresh: true` after source changes when a prior graph may be cached.
|
|
55
55
|
|
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.
|
package/docs/map.md
CHANGED
|
@@ -133,7 +133,7 @@ Every feature also takes `id` (letters, digits, `_`, `.`, `-`; unique across the
|
|
|
133
133
|
|
|
134
134
|
A model that needs an edit is reported by `MAP_GEOGRAPHY_*` diagnostics that name the feature. Errors: `ID_DUPLICATE`, `RING_DEGENERATE`, `RING_SELF_INTERSECTION`, `POLYGONS_OVERLAP`, `HOLE_OUTSIDE`, `HOLES_WITHOUT_POLYGONS`, `REF_UNKNOWN`, `REF_KIND`, `PASS_SHAPE`, `PASS_OFF_RANGE`, `RIVER_SOURCE_NOT_LAND`, `RIVER_MOUTH_NOT_WATER`, `RIVER_CYCLE`, `LAKE_SHAPE`, `LAKE_NOT_IN_LAND`, `LAKE_OUT_OF_FRAME`, `VOLCANO_NOT_ON_LAND`, `VOLCANO_CRATER_RADIUS`, `STRAIT_SHAPE`, `STRAIT_ENDPOINT`, `STRAIT_SAME_LAND`, `SITE_IN_WATER`, `BIOME_CONFLICT` (different kinds overlap at the same `z`), `BIOME_OVER_WATER`, `PATH_DEGENERATE`, `CLIMATE_TEMPERATURE_ORDER`, `REGION_DENSITY_ORDER`, `NO_LAND` (no lands and no reference picture), `LIMIT_FEATURES` and `LIMIT_POINTS`. Warnings: `LAND_OVERLAP`, `SEA_OVER_LAND`, `LAKE_TOO_SMALL`, `LAKE_OUTFLOW_MISMATCH`, `PASS_OVERLAP`, `VOLCANO_OVERLAP`, `RANGE_ON_WATER`, `PATH_SELF_INTERSECTION`, `RIVER_VIA_NOT_LAND`, `STRAIT_PATH_ON_LAND`, `STRAIT_NO_WATER`, `SITE_DUPLICATE_POSITION`, `REGION_EMPTY`, `REGION_TERRAIN_SUM`, `NAME_DUPLICATE`, `RING_DUPLICATE_VERTEX`, `PATH_DUPLICATE_VERTEX`, `FEATURE_IN_EDGE_BAND` and `DIAGNOSTICS_TRUNCATED` (more than 1,000 findings; the worst severity is kept). A file that cannot be used at all fails the call instead, with `MAP_GEOGRAPHY_PATH_INVALID`, `SOURCE_TOO_LARGE`, `JSON_INVALID`, `SCHEMA_INVALID` or `SOURCE_AMBIGUOUS`. A point within 0.003 map widths of a coast counts as land, so a river mouth or a port drawn on the shore does not fail on a simplified coastline; the error for an inland mouth reports its `inlandDistance` so it can be snapped.
|
|
135
135
|
|
|
136
|
-
`FEATURE_IN_EDGE_BAND` marks land, plateaus, ranges, volcanoes, sites, passes and river points inside `max(192 pixels, 4% of the width)` east and west or 64 pixels north and south of the frame, because the game wraps the map horizontally. It is a warning, and an error when the request sets `edge.mode` to `sea-band` (`rim` and `none` skip it).
|
|
136
|
+
`FEATURE_IN_EDGE_BAND` marks land, plateaus, ranges, volcanoes, sites, passes and river points inside `max(192 pixels, 4% of the width)` east and west or 64 pixels north and south of the frame, because the game wraps the map horizontally. It is a warning, and an error when the request sets `edge.mode` to `sea-band` (`rim`, `wall` and `none` skip it).
|
|
137
137
|
|
|
138
138
|
`geographyPath` follows the rules of `reference.imagePath`: relative paths inside the authorized mod workspace only; URLs, absolute paths, traversal, symlink and junction escapes are refused; the file is read once, its SHA-256 is taken from the bytes that are parsed, and a change after preparation blocks the write as stale. A file that is not JSON or does not match the schema is an error, not a partial preview. CI models are synthetic and project-owned.
|
|
139
139
|
|
|
@@ -169,7 +169,7 @@ Not synthesised yet: biomes, climate, fertility, tree and colour-map classes fro
|
|
|
169
169
|
|
|
170
170
|
The linked JSON catalog contains every active province definition, state, and strategic region with resolved names, alternate localisation values, source paths and lines, raster bounds and centers, memberships, neighbors, victory points, resources, buildings, ports, supply nodes, railways, normal and special adjacencies, building positions, unit positions, weather positions, and entity locators. Large catalog and render data remain in MCP resources instead of filling the agent prompt.
|
|
171
171
|
|
|
172
|
-
Use `query` for a compact name or ID result list and `coordinates` for exact pixel or map-coordinate lookup. Use `provinceIds`, `stateIds`, and `regionIds` for focused records. Up to 32 selected provinces can also produce exact geometry as maximal `[y, startX, endXExclusive]` row runs.
|
|
172
|
+
Use `query` for a compact name or ID result list and `coordinates` for exact pixel or map-coordinate lookup. Use `provinceIds`, `stateIds`, and `regionIds` for focused records. Up to 32 selected provinces can also produce exact geometry as maximal `[y, startX, endXExclusive]` row runs. When none of the requested ids exists, the call answers `MAP_ENTITY_ID_NOT_FOUND` with the highest id of each kind, before any validation or render. A selection with some known ids reports the unknown ones.
|
|
173
173
|
|
|
174
174
|
Set `lookupOnly: true` for coordinate, query, and selected-ID lookups without full validation, the complete catalog artifact, overview rendering, or province geometry export. The lookup artifact contains only the requested matches and source revision. Use full inspection for allocation previews or province row runs.
|
|
175
175
|
|
|
@@ -626,15 +626,25 @@ Water that does not read as a lake is not written as one. Enclosed water below 6
|
|
|
626
626
|
|
|
627
627
|
The engine wraps the map horizontally, so land that touches the first or last column is cut by a straight line where the world repeats. Without `edge` nothing changes and validation reports `MAP_EDGE_LAND_CUT` for such rows. With `edge`:
|
|
628
628
|
|
|
629
|
-
| `edge` field
|
|
630
|
-
|
|
|
631
|
-
| `mode`
|
|
632
|
-
| `bandPx`
|
|
633
|
-
| `polarPx`
|
|
634
|
-
| `rimPx`
|
|
629
|
+
| `edge` field | Default | Meaning |
|
|
630
|
+
| ------------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
631
|
+
| `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. |
|
|
632
|
+
| `bandPx` | `max(192, 4% of the width)`, at most a quarter of the width | East and west sea band. |
|
|
633
|
+
| `polarPx` | 64, at most a quarter of the height | North and south sea band; 0 lets land reach the top and bottom edges. |
|
|
634
|
+
| `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. |
|
|
635
|
+
| `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`. |
|
|
635
636
|
|
|
636
637
|
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.
|
|
637
638
|
|
|
639
|
+
A `rim` leaves sea at the seam as sea, and ships sail across it, because the sea at both edges is one connected sea and an `impassable` adjacency is only known to separate land provinces (the base game's 93 all do). `wall` closes the seam for armies and fleets alike:
|
|
640
|
+
|
|
641
|
+
- 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.
|
|
642
|
+
- 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.
|
|
643
|
+
- 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.
|
|
644
|
+
- 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.
|
|
645
|
+
- 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`.
|
|
646
|
+
- 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.
|
|
647
|
+
|
|
638
648
|
### Appearance validation
|
|
639
649
|
|
|
640
650
|
`hoi4.map_inspect` and every `create_world` check the files that decide the look, for the files the mod ships: `heightmap.bmp`, `terrain.bmp`, `rivers.bmp`, `trees.bmp`, `cities.bmp`, `world_normal.bmp` and the colour maps. Format and size defects are errors; statistical deviations are warnings. Severities are set so the installed base game raises no error.
|
|
@@ -653,6 +663,7 @@ A band wider than a quarter of the world is refused (`MAP_EDGE_BAND_TOO_WIDE`).
|
|
|
653
663
|
| `MAP_COLORMAP_RANGE`, `MAP_WATER_COLORMAP_FLAT` | warning | Land mean value outside 50 to 100, fewer than 400 distinct 5-bit colours or a deviation under 15; a flat water map. |
|
|
654
664
|
| `MAP_NORMAL_SIZE`, `_NOT_UNIT`, `_RESPONSE`, `MAP_CITIES_SIZE`, `_INDEX_UNDEFINED` | error or warning | Normal map size and unit length, its response to the height step (the base game's is about 2.6) and the city map. |
|
|
655
665
|
| `MAP_EDGE_LAND_CUT` | warning or error | Land on the first or last column; an error when the world was created with `sea-band`. |
|
|
666
|
+
| `MAP_EDGE_WALL_OPEN` | error | Water on the first or last column of a world created with `wall`. |
|
|
656
667
|
| `MAP_SEAM_LAND_ADJACENCY`, `MAP_POLAR_LAND`, `MAP_COLORMAP_ALPHA_CITY` | info | Land provinces that meet across the seam (and how many are blocked), land in the top and bottom rows, city lights over water. |
|
|
657
668
|
|
|
658
669
|
Not implemented: a check that river widths never narrow downstream (it needs a flow direction the file does not hold), and a mesh check for `trees.bmp` beyond the declared palette. Bitmaps are read in row strips and validation yields between strips, so a 13-million-pixel map stays cancellable and within memory.
|
|
@@ -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,20 @@ 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. | — |
|
|
29
|
+
| `hoi4.system_inspect` | Read one definition of a newer system (an on_actions hook, a MIO or policy, a balance of power, a special project, reward, specialization or tag, an operation, phase or token, a raid or raid category) with its parts, each reference and whether something defines it, pictures and names in every language, or audit every one the mod makes. Runs on the Rust engine. | — |
|
|
30
|
+
| `hoi4.unit_inspect` | Read an order of battle (templates on the designer grid, divisions, fleets, air wings), a sub-unit, equipment or module (slots, default modules, upgrades), or an equipment variant, with each name it uses and whether something defines it, or audit every one the mod makes. The audit also finds `oob` and `set_oob` names no history/units file has. Runs on the Rust engine. | — |
|
|
31
|
+
| `hoi4.asset_inspect` | Read a sprite (its texture with size, format and mipmaps, and its frames), a sound, sound effect, category or music track (its audio file and the sounds it plays), or a flag (all three sizes), or audit every one the mod defines. The flag audit also finds country tags without any flag. Runs on the Rust engine. | — |
|
|
27
32
|
|
|
28
33
|
## Focus trees
|
|
29
34
|
|
|
@@ -110,36 +115,41 @@ Every tool description in `tools/list` ends with a call like these, and an inval
|
|
|
110
115
|
Fields not shown take their defaults; `workspaceId` is `"current"` unless you pass one.
|
|
111
116
|
The CI stdio smoke suite sends each of these shapes to a real server process.
|
|
112
117
|
|
|
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.
|
|
118
|
+
| Tool | Example arguments |
|
|
119
|
+
| --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
120
|
+
| `hoi4.reference_context` | `{"surface":"event","question":"fire an event after a delay"}` |
|
|
121
|
+
| `hoi4.reference_search` | `{"query":"add_timed_idea"}` |
|
|
122
|
+
| `hoi4.reference_read` | `{"id":"<hit id>","revision":"<hit revision>"}` from a search or context hit |
|
|
123
|
+
| `hoi4.source_lookup` | `{"symbol":"my_scripted_effect"}` or `{"path":"events/my_events.txt","line":42}` |
|
|
124
|
+
| `hoi4.script_validate` | `{"source":"add_political_power = 10","kind":"effect","scope":"country"}` or `{"path":"events/my_events.txt"}` |
|
|
125
|
+
| `hoi4.error_log` | `{"scope":"mod","category":"effect"}` |
|
|
126
|
+
| `hoi4.mod_index` | `{"mode":"overview"}` or `{"mode":"next_id","kind":"event","namespace":"my_mod"}` |
|
|
127
|
+
| `hoi4.localisation_inspect` | `{"mode":"key","key":"my_event.1.t"}` or `{"mode":"audit"}` |
|
|
128
|
+
| `hoi4.idea_inspect` | `{"kind":"idea","id":"my_idea"}` or `{"kind":"character","audit":true}` |
|
|
129
|
+
| `hoi4.system_inspect` | `{"kind":"mio","id":"my_organization"}` or `{"kind":"on_actions","audit":true}` |
|
|
130
|
+
| `hoi4.unit_inspect` | `{"kind":"oob","id":"GER_1936"}` or `{"kind":"variant","audit":true}` |
|
|
131
|
+
| `hoi4.asset_inspect` | `{"kind":"sprite","id":"GFX_my_icon"}` or `{"kind":"flag","audit":true}` |
|
|
132
|
+
| `hoi4.focus_inspect` | `{"treeId":"my_focus_tree"}` |
|
|
133
|
+
| `hoi4.focus_render` | `{"relativePath":"common/national_focus/my_tree.txt","treeId":"my_focus_tree"}` |
|
|
134
|
+
| `hoi4.focus_rewrite` | `{"relativePath":"common/national_focus/my_tree.txt","treeId":"my_focus_tree","layoutMode":"compact"}` |
|
|
135
|
+
| `hoi4.gui_inspect` | `{"windowName":"my_window"}` |
|
|
136
|
+
| `hoi4.gui_render` | `{"windowName":"my_window","scenario":{"id":"normal"}}` |
|
|
137
|
+
| `hoi4.gui_rewrite` | `{"mode":"helpers","relativePath":"interface/my_window.gui","windowName":"my_window","scenario":{"id":"normal"},"helper":{"root":{"id":"my_window","kind":"column","name":"my_window","width":320,"height":200,"children":[]}}}` |
|
|
138
|
+
| `hoi4.map_inspect` | `{"query":"Brandenburg","lookupOnly":true}` or `{"layer":"state","tile":{"x":2600,"y":500,"width":256,"height":256}}` |
|
|
139
|
+
| `hoi4.map_rewrite` | `{"operations":[{"id":"s1","kind":"create_state","provinceIds":[120,121],"displayName":"New State"}]}` |
|
|
140
|
+
| `hoi4.event_inspect` | `{"mode":"trace","selector":"my_mod.1","direction":"downstream"}` |
|
|
141
|
+
| `hoi4.event_render` | `{"view":"overview","selector":"my_mod"}` |
|
|
142
|
+
| `hoi4.tech_inspect` | `{"mode":"explain","technologyId":"my_tech"}` |
|
|
143
|
+
| `hoi4.tech_render` | `{"view":"folder","folderId":"my_folder"}` |
|
|
144
|
+
| `hoi4.probability_inspect` | `{"candidatePool":["my_decision"],"scenarioSet":[{"actor":"GER","state":{"has_war":false}}]}` |
|
|
145
|
+
| `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}}` |
|
|
146
|
+
| `hoi4.impact_inspect` | `{"symbols":[{"kind":"scripted_effect","id":"my_effect"}]}` |
|
|
147
|
+
| `hoi4.decision_inspect` | `{"mode":"inspect","id":"my_decision","scenarios":[{"id":"base","actor":"GER","state":{}}]}` |
|
|
148
|
+
| `hoi4.mechanic_test` | `{"test":{"id":"t","scenario":{"schemaVersion":"1.0","id":"t","state":{}},"steps":[{"kind":"effect","source":{"kind":"scripted_effect","id":"e"}}],"assertions":[{"id":"a","kind":"conservation","paths":[{"key":"x"},{"key":"y"}]}]}}`, see [Mechanic tests](mechanics.md) |
|
|
149
|
+
| `hoi4.package_check` | `{"manifest":{"schemaVersion":"1.0","id":"my_package","definitions":[{"kind":"scripted_effect","id":"my_effect"}]}}` |
|
|
150
|
+
| `hoi4.scenario_test` | `{"suitePath":"tests/my_suite.json","maxCases":20}` |
|
|
151
|
+
| `hoi4.job_inspect` | `{"jobId":"job_<64 hex characters>"}` from a native task id |
|
|
152
|
+
| `hoi4.job_cancel` | `{"jobId":"job_<64 hex characters>"}` |
|
|
143
153
|
|
|
144
154
|
## Result sizes
|
|
145
155
|
|