hoi4-agent-tools 4.9.0 → 4.11.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 +20 -0
- package/dist/hoi4_agent_tools/core/operation-result.js +51 -11
- package/dist/hoi4_agent_tools/core/workspace.js +22 -7
- package/dist/hoi4_agent_tools/decision/service.js +13 -1
- package/dist/hoi4_agent_tools/event/graph.js +16 -2
- package/dist/hoi4_agent_tools/event/source-analysis.js +35 -16
- package/dist/hoi4_agent_tools/impact/service.js +4 -1
- package/dist/hoi4_agent_tools/map/gameplay/reachability.js +81 -0
- package/dist/hoi4_agent_tools/map/geography/resolve.js +3 -0
- package/dist/hoi4_agent_tools/map/operations.js +8 -0
- package/dist/hoi4_agent_tools/map/partition-tuning.js +2 -1
- package/dist/hoi4_agent_tools/map/reference-world.js +17 -3
- package/dist/hoi4_agent_tools/map/relief/painted-relief.js +143 -0
- package/dist/hoi4_agent_tools/map/relief/terrain-synthesis.js +13 -0
- package/dist/hoi4_agent_tools/map/world.js +108 -23
- package/dist/hoi4_agent_tools/mcp/resources/register-modern.js +11 -4
- package/dist/hoi4_agent_tools/mcp/resources/register.js +7 -0
- package/dist/hoi4_agent_tools/mcp/server/argument-errors.js +1 -0
- package/dist/hoi4_agent_tools/mcp/tools/analysis.js +12 -0
- package/dist/hoi4_agent_tools/mcp/tools/reference.js +12 -3
- package/dist/hoi4_agent_tools/package-check/service.js +14 -1
- package/dist/hoi4_agent_tools/probability/model.js +4 -4
- package/dist/hoi4_agent_tools/probability/operations.js +6 -0
- package/dist/hoi4_agent_tools/probability/service.js +23 -0
- package/dist/hoi4_agent_tools/reference/operations.js +35 -6
- package/dist/hoi4_agent_tools/reference/service.js +118 -14
- package/dist/hoi4_agent_tools/reference/skill-resource.js +74 -0
- package/dist/hoi4_agent_tools/reference/skills.js +278 -0
- package/dist/hoi4_agent_tools/schemas/geography.js +5 -0
- package/dist/hoi4_agent_tools/schemas/map.js +29 -0
- package/dist/hoi4_agent_tools/schemas/reference.js +34 -2
- package/dist/hoi4_agent_tools/schemas/skill.js +72 -0
- package/dist/hoi4_agent_tools/version.js +1 -1
- package/docs/configuration.md +3 -3
- package/docs/map.md +12 -9
- package/docs/probability.md +1 -1
- package/docs/reference.md +27 -1
- package/docs/research/probability-adapter-evidence.md +15 -2
- package/docs/tools.md +101 -86
- package/engine/bin/manifest.json +1 -1
- package/engine/bin/win32-x64/hoi4-engine.exe +0 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -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 +4 -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 +177 -118
- 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 +3 -3
- 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,278 @@
|
|
|
1
|
+
import { lstat, readdir, readFile, realpath } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { sha256Bytes } from '../core/canonical.js';
|
|
4
|
+
import { ServiceError } from '../core/result.js';
|
|
5
|
+
import { SKILL_FILE_PATTERN, SKILL_NAME_PATTERN, SKILL_TEXT_BYTES, } from '../schemas/skill.js';
|
|
6
|
+
// Skills are served from the mod, as HOI4 Mod Setup installed them. Its lock records the kit
|
|
7
|
+
// revision and the hash of every installed file, so a file whose bytes differ is reported as
|
|
8
|
+
// edited and not served unless the caller accepts local edits. A mod without a lock gets its
|
|
9
|
+
// installed skills marked unpinned.
|
|
10
|
+
export const SETUP_LOCK_PATH = '.hoi4-mod-setup/install.lock.json';
|
|
11
|
+
const LOCK_BYTES = 8 * 1024 * 1024;
|
|
12
|
+
const SKILL_FILE_BYTES = 4 * 1024 * 1024;
|
|
13
|
+
/** Setup installs one copy per client; the agent-neutral copy wins. */
|
|
14
|
+
const SKILL_ROOTS = ['.agents/skills', '.claude/skills'];
|
|
15
|
+
const FILES_PER_SKILL = 64;
|
|
16
|
+
export async function listSkills(workspace, signal) {
|
|
17
|
+
const inventory = await readInventory(workspace.modRoot, signal);
|
|
18
|
+
const skills = [];
|
|
19
|
+
let drifted = 0;
|
|
20
|
+
for (const [name, files] of [...inventory.skills].sort(([a], [b]) => a.localeCompare(b))) {
|
|
21
|
+
signal?.throwIfAborted();
|
|
22
|
+
const states = await Promise.all(files.map(async (entry) => (await readSkillFile(workspace.modRoot, entry)).state));
|
|
23
|
+
const state = worst(states);
|
|
24
|
+
if (state === 'edited' || state === 'missing')
|
|
25
|
+
drifted += 1;
|
|
26
|
+
const main = files.find(({ file }) => file === 'SKILL.md');
|
|
27
|
+
const description = main === undefined ? '' : await frontmatterDescription(workspace.modRoot, main);
|
|
28
|
+
skills.push({ name, description, files: files.length, state });
|
|
29
|
+
}
|
|
30
|
+
return { kit: inventory.kit, skills: skills.slice(0, 128), drifted };
|
|
31
|
+
}
|
|
32
|
+
export async function loadSkill(workspace, request, signal) {
|
|
33
|
+
const inventory = await readInventory(workspace.modRoot, signal);
|
|
34
|
+
const files = inventory.skills.get(request.name);
|
|
35
|
+
if (files === undefined)
|
|
36
|
+
throw new ServiceError('SKILL_NOT_FOUND', `The mod has no skill named ${request.name}; call hoi4.skill without a name to list them`, { name: request.name });
|
|
37
|
+
const entry = files.find(({ file }) => file === request.file);
|
|
38
|
+
if (entry === undefined)
|
|
39
|
+
throw new ServiceError('SKILL_FILE_NOT_FOUND', `The skill ${request.name} has no file ${request.file}`, { name: request.name, files: files.map(({ file }) => file).slice(0, 32) });
|
|
40
|
+
const read = await readSkillFile(workspace.modRoot, entry);
|
|
41
|
+
if (read.bytes === undefined)
|
|
42
|
+
throw new ServiceError('SKILL_FILE_MISSING', `The Setup lock names ${entry.path}, but the file is not in the mod; rerun HOI4 Mod Setup to restore it`, { path: entry.path });
|
|
43
|
+
if (read.state === 'edited' && !request.acceptLocalEdits)
|
|
44
|
+
throw new ServiceError('SKILL_TEXT_DRIFTED', `${entry.path} differs from the kit revision ${inventory.kit?.revision ?? ''} the mod pins (sha256 ${read.sha256} instead of ${entry.pinnedSha256 ?? ''}); rerun HOI4 Mod Setup to restore it, or pass acceptLocalEdits to read the edited text`, { path: entry.path, sha256: read.sha256, pinnedSha256: entry.pinnedSha256 });
|
|
45
|
+
if (request.offset > read.bytes.length)
|
|
46
|
+
throw new ServiceError('SKILL_OFFSET_INVALID', `offset ${request.offset} is past the end of ${entry.path} (${read.bytes.length} bytes)`);
|
|
47
|
+
const end = pageEnd(read.bytes, request.offset);
|
|
48
|
+
return {
|
|
49
|
+
kit: inventory.kit,
|
|
50
|
+
skill: {
|
|
51
|
+
name: request.name,
|
|
52
|
+
file: entry.file,
|
|
53
|
+
path: entry.path,
|
|
54
|
+
state: read.state,
|
|
55
|
+
sha256: read.sha256,
|
|
56
|
+
pinnedSha256: entry.pinnedSha256,
|
|
57
|
+
bytes: read.bytes.length,
|
|
58
|
+
offset: request.offset,
|
|
59
|
+
nextOffset: end < read.bytes.length ? end : null,
|
|
60
|
+
text: read.bytes.subarray(request.offset, end).toString('utf8'),
|
|
61
|
+
otherFiles: files
|
|
62
|
+
.map(({ file }) => file)
|
|
63
|
+
.filter((file) => file !== entry.file)
|
|
64
|
+
.slice(0, 64),
|
|
65
|
+
},
|
|
66
|
+
drifted: read.state === 'edited' ? 1 : 0,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/** The whole text of one skill file for a resource read, with the same drift rule. */
|
|
70
|
+
export async function readSkillText(workspace, name, file, signal) {
|
|
71
|
+
const inventory = await readInventory(workspace.modRoot, signal);
|
|
72
|
+
const entry = inventory.skills.get(name)?.find((candidate) => candidate.file === file);
|
|
73
|
+
if (entry === undefined)
|
|
74
|
+
throw new ServiceError('SKILL_NOT_FOUND', `The mod has no skill file ${name}/${file}`);
|
|
75
|
+
const read = await readSkillFile(workspace.modRoot, entry);
|
|
76
|
+
if (read.bytes === undefined)
|
|
77
|
+
throw new ServiceError('SKILL_FILE_MISSING', `${entry.path} is not in the mod`);
|
|
78
|
+
if (read.state === 'edited')
|
|
79
|
+
throw new ServiceError('SKILL_TEXT_DRIFTED', `${entry.path} differs from the kit revision the mod pins; read it with hoi4.skill and acceptLocalEdits`);
|
|
80
|
+
return {
|
|
81
|
+
text: read.bytes.toString('utf8'),
|
|
82
|
+
sha256: read.sha256,
|
|
83
|
+
state: read.state,
|
|
84
|
+
kit: inventory.kit,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/** Skill names the mod has, for resource listing. */
|
|
88
|
+
export async function skillNames(workspace, signal) {
|
|
89
|
+
return [...(await readInventory(workspace.modRoot, signal)).skills.keys()].sort();
|
|
90
|
+
}
|
|
91
|
+
async function readInventory(modRoot, signal) {
|
|
92
|
+
const lock = await readLock(modRoot);
|
|
93
|
+
signal?.throwIfAborted();
|
|
94
|
+
return lock === undefined ? installedInventory(modRoot, signal) : lockedInventory(lock);
|
|
95
|
+
}
|
|
96
|
+
async function readLock(modRoot) {
|
|
97
|
+
const lockPath = path.join(modRoot, SETUP_LOCK_PATH);
|
|
98
|
+
let bytes;
|
|
99
|
+
try {
|
|
100
|
+
const info = await lstat(lockPath);
|
|
101
|
+
if (!info.isFile())
|
|
102
|
+
return undefined;
|
|
103
|
+
if (info.size > LOCK_BYTES)
|
|
104
|
+
throw new ServiceError('SKILL_LOCK_INVALID', `${SETUP_LOCK_PATH} is larger than 8 MB`);
|
|
105
|
+
bytes = await readFile(lockPath);
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
if (error.code === 'ENOENT')
|
|
109
|
+
return undefined;
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
let parsed;
|
|
113
|
+
try {
|
|
114
|
+
parsed = JSON.parse(bytes.toString('utf8'));
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
throw new ServiceError('SKILL_LOCK_INVALID', `${SETUP_LOCK_PATH} is not valid JSON`);
|
|
118
|
+
}
|
|
119
|
+
const lock = parsed;
|
|
120
|
+
const source = lock?.source;
|
|
121
|
+
if (lock === null ||
|
|
122
|
+
typeof source?.repository !== 'string' ||
|
|
123
|
+
typeof source.revision !== 'string' ||
|
|
124
|
+
typeof source.manifest_sha256 !== 'string' ||
|
|
125
|
+
!/^[a-f0-9]{64}$/u.test(source.manifest_sha256) ||
|
|
126
|
+
!Array.isArray(lock.files))
|
|
127
|
+
throw new ServiceError('SKILL_LOCK_INVALID', `${SETUP_LOCK_PATH} lacks the source revision, manifest hash or file list`);
|
|
128
|
+
return lock;
|
|
129
|
+
}
|
|
130
|
+
function lockedInventory(lock) {
|
|
131
|
+
const byRoot = new Map();
|
|
132
|
+
for (const raw of lock.files) {
|
|
133
|
+
const entry = raw;
|
|
134
|
+
if (typeof entry?.path !== 'string' ||
|
|
135
|
+
typeof entry.installed_sha256 !== 'string' ||
|
|
136
|
+
!/^[a-f0-9]{64}$/u.test(entry.installed_sha256))
|
|
137
|
+
continue;
|
|
138
|
+
const located = locate(entry.path);
|
|
139
|
+
if (located === undefined)
|
|
140
|
+
continue;
|
|
141
|
+
const skills = byRoot.get(located.root) ?? new Map();
|
|
142
|
+
byRoot.set(located.root, skills);
|
|
143
|
+
const files = skills.get(located.name) ?? [];
|
|
144
|
+
skills.set(located.name, files);
|
|
145
|
+
if (files.length < FILES_PER_SKILL)
|
|
146
|
+
files.push({ file: located.file, path: entry.path, pinnedSha256: entry.installed_sha256 });
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
kit: {
|
|
150
|
+
repository: lock.source.repository.slice(0, 200),
|
|
151
|
+
revision: lock.source.revision.slice(0, 64),
|
|
152
|
+
release: typeof lock.source.release === 'string' ? lock.source.release.slice(0, 64) : null,
|
|
153
|
+
manifestSha256: lock.source.manifest_sha256,
|
|
154
|
+
},
|
|
155
|
+
skills: merged(byRoot),
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
async function installedInventory(modRoot, signal) {
|
|
159
|
+
const byRoot = new Map();
|
|
160
|
+
for (const root of SKILL_ROOTS) {
|
|
161
|
+
let names;
|
|
162
|
+
try {
|
|
163
|
+
names = await readdir(path.join(modRoot, root));
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
const skills = new Map();
|
|
169
|
+
byRoot.set(root, skills);
|
|
170
|
+
for (const name of names.filter((candidate) => SKILL_NAME_PATTERN.test(candidate))) {
|
|
171
|
+
signal?.throwIfAborted();
|
|
172
|
+
const files = (await filesBelow(path.join(modRoot, root, name)))
|
|
173
|
+
.filter((file) => SKILL_FILE_PATTERN.test(file))
|
|
174
|
+
.sort((a, b) => (a === 'SKILL.md' ? -1 : b === 'SKILL.md' ? 1 : a.localeCompare(b)))
|
|
175
|
+
.slice(0, FILES_PER_SKILL);
|
|
176
|
+
if (!files.includes('SKILL.md'))
|
|
177
|
+
continue;
|
|
178
|
+
skills.set(name, files.map((file) => ({ file, path: `${root}/${name}/${file}`, pinnedSha256: null })));
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return { kit: null, skills: merged(byRoot) };
|
|
182
|
+
}
|
|
183
|
+
async function filesBelow(directory, prefix = '', depth = 0) {
|
|
184
|
+
if (depth > 3)
|
|
185
|
+
return [];
|
|
186
|
+
let entries;
|
|
187
|
+
try {
|
|
188
|
+
entries = await readdir(directory, { withFileTypes: true });
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
return [];
|
|
192
|
+
}
|
|
193
|
+
const found = [];
|
|
194
|
+
for (const entry of entries) {
|
|
195
|
+
const relative = `${prefix}${entry.name}`;
|
|
196
|
+
if (entry.isFile())
|
|
197
|
+
found.push(relative);
|
|
198
|
+
else if (entry.isDirectory())
|
|
199
|
+
found.push(...(await filesBelow(path.join(directory, entry.name), `${relative}/`, depth + 1)));
|
|
200
|
+
}
|
|
201
|
+
return found;
|
|
202
|
+
}
|
|
203
|
+
/** Every skill once, taken from the first root in SKILL_ROOTS that has it. */
|
|
204
|
+
function merged(byRoot) {
|
|
205
|
+
const skills = new Map();
|
|
206
|
+
for (const root of SKILL_ROOTS)
|
|
207
|
+
for (const [name, files] of byRoot.get(root) ?? [])
|
|
208
|
+
if (!skills.has(name) && files.some(({ file }) => file === 'SKILL.md'))
|
|
209
|
+
skills.set(name, files);
|
|
210
|
+
return skills;
|
|
211
|
+
}
|
|
212
|
+
function locate(lockPath) {
|
|
213
|
+
for (const root of SKILL_ROOTS) {
|
|
214
|
+
if (!lockPath.startsWith(`${root}/`))
|
|
215
|
+
continue;
|
|
216
|
+
const rest = lockPath.slice(root.length + 1);
|
|
217
|
+
const slash = rest.indexOf('/');
|
|
218
|
+
if (slash < 0)
|
|
219
|
+
return undefined;
|
|
220
|
+
const name = rest.slice(0, slash);
|
|
221
|
+
const file = rest.slice(slash + 1);
|
|
222
|
+
if (SKILL_NAME_PATTERN.test(name) && SKILL_FILE_PATTERN.test(file))
|
|
223
|
+
return { root, name, file };
|
|
224
|
+
}
|
|
225
|
+
return undefined;
|
|
226
|
+
}
|
|
227
|
+
async function readSkillFile(modRoot, entry) {
|
|
228
|
+
const absolute = path.join(modRoot, ...entry.path.split('/'));
|
|
229
|
+
let bytes;
|
|
230
|
+
try {
|
|
231
|
+
// A link could point outside the mod, so the real path must stay inside it.
|
|
232
|
+
const [real, root] = await Promise.all([realpath(absolute), realpath(modRoot)]);
|
|
233
|
+
const relative = path.relative(root, real);
|
|
234
|
+
if (relative.startsWith('..') || path.isAbsolute(relative))
|
|
235
|
+
throw new ServiceError('SKILL_PATH_OUTSIDE_MOD', `${entry.path} resolves outside the mod`);
|
|
236
|
+
const info = await lstat(real);
|
|
237
|
+
if (!info.isFile() || info.size > SKILL_FILE_BYTES)
|
|
238
|
+
return { state: 'missing' };
|
|
239
|
+
bytes = await readFile(real);
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
if (error instanceof ServiceError)
|
|
243
|
+
throw error;
|
|
244
|
+
return { state: 'missing' };
|
|
245
|
+
}
|
|
246
|
+
const sha256 = sha256Bytes(bytes);
|
|
247
|
+
const state = entry.pinnedSha256 === null ? 'unpinned' : sha256 === entry.pinnedSha256 ? 'pinned' : 'edited';
|
|
248
|
+
return { state, bytes, sha256 };
|
|
249
|
+
}
|
|
250
|
+
async function frontmatterDescription(modRoot, entry) {
|
|
251
|
+
const read = await readSkillFile(modRoot, entry);
|
|
252
|
+
if (read.bytes === undefined)
|
|
253
|
+
return '';
|
|
254
|
+
const head = read.bytes.subarray(0, 4096).toString('utf8');
|
|
255
|
+
const match = /^---\r?\n[\s\S]*?^description:\s*(.+?)\s*$/mu.exec(head);
|
|
256
|
+
const text = (match?.[1] ?? '').replace(/^["']|["']$/gu, '');
|
|
257
|
+
return text.length > 300 ? `${text.slice(0, 297)}...` : text;
|
|
258
|
+
}
|
|
259
|
+
function worst(states) {
|
|
260
|
+
for (const state of ['missing', 'edited', 'unpinned'])
|
|
261
|
+
if (states.includes(state))
|
|
262
|
+
return state;
|
|
263
|
+
return 'pinned';
|
|
264
|
+
}
|
|
265
|
+
/** The end of one page: at most SKILL_TEXT_BYTES, cut after a line break when one fits. */
|
|
266
|
+
function pageEnd(bytes, offset) {
|
|
267
|
+
const limit = offset + SKILL_TEXT_BYTES;
|
|
268
|
+
if (limit >= bytes.length)
|
|
269
|
+
return bytes.length;
|
|
270
|
+
const newline = bytes.lastIndexOf(0x0a, limit - 1);
|
|
271
|
+
if (newline >= offset)
|
|
272
|
+
return newline + 1;
|
|
273
|
+
// No line break in the page: back off to the start of a UTF-8 character.
|
|
274
|
+
let end = limit;
|
|
275
|
+
while (end > offset && (bytes[end] & 0xc0) === 0x80)
|
|
276
|
+
end -= 1;
|
|
277
|
+
return end;
|
|
278
|
+
}
|
|
@@ -149,6 +149,11 @@ const regionSchema = z
|
|
|
149
149
|
})
|
|
150
150
|
.strict()
|
|
151
151
|
.optional(),
|
|
152
|
+
/**
|
|
153
|
+
* Land inside the region's polygons that no army may enter (ZR-28): its provinces form
|
|
154
|
+
* impassable states, and the relief raises it to the highest ground.
|
|
155
|
+
*/
|
|
156
|
+
impassable: z.boolean().optional(),
|
|
152
157
|
})
|
|
153
158
|
.strict();
|
|
154
159
|
const rangeSchema = z
|
|
@@ -87,6 +87,7 @@ const referencePointSchema = z
|
|
|
87
87
|
const referenceKindSchema = z.enum([
|
|
88
88
|
'sea',
|
|
89
89
|
'land',
|
|
90
|
+
'impassable_mountain',
|
|
90
91
|
'plains',
|
|
91
92
|
'forest',
|
|
92
93
|
'desert',
|
|
@@ -260,6 +261,27 @@ export const worldReliefSchema = z
|
|
|
260
261
|
.max(1)
|
|
261
262
|
.optional()
|
|
262
263
|
.describe('Full-resolution roughness of the terrain, 0 to 1; default 0.5.'),
|
|
264
|
+
painted: z
|
|
265
|
+
.union([
|
|
266
|
+
z.boolean(),
|
|
267
|
+
z
|
|
268
|
+
.object({
|
|
269
|
+
falloffPx: z
|
|
270
|
+
.number()
|
|
271
|
+
.int()
|
|
272
|
+
.min(2)
|
|
273
|
+
.max(256)
|
|
274
|
+
.optional()
|
|
275
|
+
.describe('Blur radius of class edges in pixels; default 24.'),
|
|
276
|
+
mountainPeak: z.number().min(0).max(1).optional(),
|
|
277
|
+
hillsPeak: z.number().min(0).max(1).optional(),
|
|
278
|
+
volcanoPeak: z.number().min(0).max(1).optional(),
|
|
279
|
+
impassablePeak: z.number().min(0).max(1).optional(),
|
|
280
|
+
})
|
|
281
|
+
.strict(),
|
|
282
|
+
])
|
|
283
|
+
.optional()
|
|
284
|
+
.describe('With a reference picture and a geography model: raise the relief toward the painted mountain, hills and volcano classes before the rivers are routed, blurred over falloffPx so slopes stay natural. Peaks are 0 to 1 on the range relief scale (defaults mountain 0.82, hills 0.27, volcano 0.9, near the base game; impassable land 0.95, which is raised even when this is off). Off by default.'),
|
|
263
285
|
})
|
|
264
286
|
.strict();
|
|
265
287
|
/** River network target for a geography world: a share of the land pixels. */
|
|
@@ -353,6 +375,13 @@ export const worldPartitionTuningSchema = z
|
|
|
353
375
|
.strict()
|
|
354
376
|
.optional()
|
|
355
377
|
.describe('Sea province area in pixels near a coast and on the open sea. Defaults follow seaProvincePixels (0.5 and 2.4 times, scaled so the mean stays seaProvincePixels).'),
|
|
378
|
+
lakeArea: z
|
|
379
|
+
.number()
|
|
380
|
+
.int()
|
|
381
|
+
.min(20)
|
|
382
|
+
.max(200_000)
|
|
383
|
+
.optional()
|
|
384
|
+
.describe('Lake province area in pixels; default 6000. A lake no larger than this stays one province.'),
|
|
356
385
|
provincesPerState: z
|
|
357
386
|
.tuple([z.number().int().min(1).max(64), z.number().int().min(1).max(64)])
|
|
358
387
|
.optional()
|
|
@@ -24,8 +24,10 @@ export const referenceSearchRequestSchema = z
|
|
|
24
24
|
export const referenceReadRequestSchema = z
|
|
25
25
|
.object({
|
|
26
26
|
workspaceId: workspaceIdSchema,
|
|
27
|
-
id
|
|
28
|
-
|
|
27
|
+
/** A hit's short id, or the full SHA-256 section id. */
|
|
28
|
+
id: z.string().regex(/^[a-f0-9]{16,64}$/u),
|
|
29
|
+
/** A hit's short revision, or the full SHA-256 file revision. */
|
|
30
|
+
revision: z.string().regex(/^[a-f0-9]{12,64}$/u),
|
|
29
31
|
source: referenceSourceSchema.optional(),
|
|
30
32
|
startLine: z.number().int().min(1).optional(),
|
|
31
33
|
startColumn: z.number().int().min(1).optional(),
|
|
@@ -151,6 +153,33 @@ export const referenceSearchDataSchema = z
|
|
|
151
153
|
skipped: count,
|
|
152
154
|
})
|
|
153
155
|
.strict();
|
|
156
|
+
/** Characters of a section id and a file revision that a search or context hit carries. */
|
|
157
|
+
export const REFERENCE_HIT_ID_LENGTH = 16;
|
|
158
|
+
export const REFERENCE_HIT_REVISION_LENGTH = 12;
|
|
159
|
+
/**
|
|
160
|
+
* One search or context hit as a tool returns it. Every session reads many hits, so a hit names
|
|
161
|
+
* its file under its source's folder instead of an absolute path, carries short id and revision
|
|
162
|
+
* prefixes that `hoi4.reference_read` accepts, and leaves out the source's authority line.
|
|
163
|
+
*/
|
|
164
|
+
export const referenceHitSchema = z
|
|
165
|
+
.object({
|
|
166
|
+
id: z.string().regex(/^[a-f0-9]{16}$/u),
|
|
167
|
+
revision: z.string().regex(/^[a-f0-9]{12}$/u),
|
|
168
|
+
source: referenceSourceSchema,
|
|
169
|
+
heading: z.string().max(512),
|
|
170
|
+
/** The page, when it is not the heading itself. */
|
|
171
|
+
title: z.string().max(512).optional(),
|
|
172
|
+
/** The file under its source's folder, such as `effects.md`. */
|
|
173
|
+
path: z.string().max(1024),
|
|
174
|
+
startLine: line,
|
|
175
|
+
endLine: line,
|
|
176
|
+
excerpt: z.string().max(300),
|
|
177
|
+
matchLine: line.optional(),
|
|
178
|
+
})
|
|
179
|
+
.strict();
|
|
180
|
+
export const referenceSearchToolDataSchema = referenceSearchDataSchema
|
|
181
|
+
.extend({ results: z.array(referenceHitSchema.extend({ score: z.number() })).max(12) })
|
|
182
|
+
.strict();
|
|
154
183
|
export const referenceReadDataSchema = referenceSectionSchema
|
|
155
184
|
.extend({
|
|
156
185
|
sectionStartLine: line,
|
|
@@ -186,6 +215,9 @@ export const referenceContextDataSchema = z
|
|
|
186
215
|
.max(16),
|
|
187
216
|
})
|
|
188
217
|
.strict();
|
|
218
|
+
export const referenceContextToolDataSchema = referenceContextDataSchema
|
|
219
|
+
.extend({ sections: z.array(referenceHitSchema).max(24) })
|
|
220
|
+
.strict();
|
|
189
221
|
export const sourceLookupDataSchema = z
|
|
190
222
|
.object({
|
|
191
223
|
sourceScope: z.enum([
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
import { workspaceIdSchema } from './common.js';
|
|
3
|
+
export const SKILL_NAME_PATTERN = /^[a-z0-9][a-z0-9._-]{0,63}$/u;
|
|
4
|
+
/** A file inside one skill folder, such as SKILL.md or references/events.md. */
|
|
5
|
+
export const SKILL_FILE_PATTERN = /^(?!.*(?:^|\/)\.\.?(?:\/|$))[A-Za-z0-9._/-]{1,200}$/u;
|
|
6
|
+
/** The most text one call returns; a longer file continues from nextOffset. */
|
|
7
|
+
export const SKILL_TEXT_BYTES = 20_000;
|
|
8
|
+
export const skillRequestSchema = z
|
|
9
|
+
.object({
|
|
10
|
+
workspaceId: workspaceIdSchema,
|
|
11
|
+
/** Omit to list the mod's skills; name one to load it. */
|
|
12
|
+
name: z.string().regex(SKILL_NAME_PATTERN).optional(),
|
|
13
|
+
/** A file inside the skill folder; SKILL.md by default. */
|
|
14
|
+
file: z.string().regex(SKILL_FILE_PATTERN).default('SKILL.md'),
|
|
15
|
+
/** Byte offset to continue a long file from, as returned in nextOffset. */
|
|
16
|
+
offset: z.number().int().min(0).max(16_000_000).default(0),
|
|
17
|
+
/** Serve a file whose bytes differ from the kit version the mod pins. */
|
|
18
|
+
acceptLocalEdits: z.boolean().default(false),
|
|
19
|
+
})
|
|
20
|
+
.strict();
|
|
21
|
+
const sha256 = z.string().regex(/^[a-f0-9]{64}$/u);
|
|
22
|
+
/**
|
|
23
|
+
* pinned: the installed bytes match the kit version in the mod's Setup lock.
|
|
24
|
+
* edited: the installed bytes differ from it. missing: the lock names a file that is gone.
|
|
25
|
+
* unpinned: the mod has no Setup lock, so no kit version can be checked.
|
|
26
|
+
*/
|
|
27
|
+
const skillStateSchema = z.enum(['pinned', 'edited', 'missing', 'unpinned']);
|
|
28
|
+
export const skillDataSchema = z
|
|
29
|
+
.object({
|
|
30
|
+
/** The kit release HOI4 Mod Setup installed, or null when the mod has no Setup lock. */
|
|
31
|
+
kit: z
|
|
32
|
+
.object({
|
|
33
|
+
repository: z.string().max(200),
|
|
34
|
+
revision: z.string().max(64),
|
|
35
|
+
release: z.string().max(64).nullable(),
|
|
36
|
+
manifestSha256: sha256,
|
|
37
|
+
})
|
|
38
|
+
.strict()
|
|
39
|
+
.nullable(),
|
|
40
|
+
skills: z
|
|
41
|
+
.array(z
|
|
42
|
+
.object({
|
|
43
|
+
name: z.string().max(64),
|
|
44
|
+
description: z.string().max(300),
|
|
45
|
+
files: z.number().int().min(0),
|
|
46
|
+
state: skillStateSchema,
|
|
47
|
+
})
|
|
48
|
+
.strict())
|
|
49
|
+
.max(128)
|
|
50
|
+
.optional(),
|
|
51
|
+
skill: z
|
|
52
|
+
.object({
|
|
53
|
+
name: z.string().max(64),
|
|
54
|
+
file: z.string().max(200),
|
|
55
|
+
path: z.string().max(300),
|
|
56
|
+
state: skillStateSchema,
|
|
57
|
+
sha256,
|
|
58
|
+
/** The hash the Setup lock records for this file; null when unpinned. */
|
|
59
|
+
pinnedSha256: sha256.nullable(),
|
|
60
|
+
bytes: z.number().int().min(0),
|
|
61
|
+
offset: z.number().int().min(0),
|
|
62
|
+
nextOffset: z.number().int().min(0).nullable(),
|
|
63
|
+
text: z.string(),
|
|
64
|
+
/** Other files of this skill, such as references, loadable with file. */
|
|
65
|
+
otherFiles: z.array(z.string().max(200)).max(64),
|
|
66
|
+
})
|
|
67
|
+
.strict()
|
|
68
|
+
.optional(),
|
|
69
|
+
/** Skills with an edited or missing file. */
|
|
70
|
+
drifted: z.number().int().min(0),
|
|
71
|
+
})
|
|
72
|
+
.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.
|
|
3
|
+
export const PACKAGE_VERSION = '4.11.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/configuration.md
CHANGED
|
@@ -68,13 +68,13 @@ For `"current"`, the server asks the MCP client for its workspace roots when the
|
|
|
68
68
|
- It selects the one mod workspace that contains a client root or lies inside one.
|
|
69
69
|
- More than one match fails with `WORKSPACE_CONTEXT_AMBIGUOUS`.
|
|
70
70
|
- With no match, for example a session started in another repository, it selects the `defaultWorkspace` when it is set, or the only mod workspace when there is one.
|
|
71
|
-
- Otherwise the call fails with `WORKSPACE_CONTEXT_NOT_FOUND
|
|
71
|
+
- Otherwise the call fails with `WORKSPACE_CONTEXT_NOT_FOUND`. The error lists up to 32 mod folder names (`modFolders`) and their count (`workspaceCount`), and `fix` says in one line what to pass, for example `Pass "workspaceId":"my_mod"`.
|
|
72
72
|
|
|
73
73
|
When the client does not supply roots, the server uses its own working directory:
|
|
74
74
|
|
|
75
75
|
- It selects the one mod workspace that contains the working directory.
|
|
76
76
|
- If the working directory is in no mod, it selects the `defaultWorkspace` when it is set, or the only mod workspace when there is one.
|
|
77
|
-
- Otherwise the call fails with `WORKSPACE_CONTEXT_REQUIRED`,
|
|
77
|
+
- Otherwise the call fails with `WORKSPACE_CONTEXT_REQUIRED`, with the same `modFolders` and `fix`.
|
|
78
78
|
- With no mod workspace at all, the call fails with `WORKSPACE_CONTEXT_NOT_FOUND`.
|
|
79
79
|
|
|
80
80
|
When a tool reads a named source file with `"current"` (the `relativePath` of the focus tools, the `path` of `hoi4.script_validate`) and the selected mod lacks that file, or no mod could be selected, the server uses the one mod that has it, and fails with `WORKSPACE_SOURCE_AMBIGUOUS` if several do.
|
|
@@ -82,7 +82,7 @@ When a tool reads a named source file with `"current"` (the `relativePath` of th
|
|
|
82
82
|
To choose a mod explicitly, pass its workspace ID.
|
|
83
83
|
A configured workspace keeps the `id` you gave it.
|
|
84
84
|
A mod found under `modRoots` gets an ID of the form `mod_<folder name>_<12 hex characters>`.
|
|
85
|
-
For a mod workspace, the server also accepts a short form: the mod's folder name or workspace name in
|
|
85
|
+
For a mod workspace, the server also accepts a short form: the mod's folder name or workspace name, in any letter case and with spaces, optionally prefixed with `auto_` or `mod_`.
|
|
86
86
|
A `mod_<folder name>_<hash>` ID whose hash no longer matches resolves by its folder name in the same way.
|
|
87
87
|
A short form that matches several mods fails with `WORKSPACE_CONTEXT_AMBIGUOUS`, and an unknown ID fails with `WORKSPACE_NOT_REGISTERED`.
|
|
88
88
|
Over HTTP, a principal sees only the workspaces granted to it, and any other ID fails with `WORKSPACE_INACCESSIBLE`.
|
package/docs/map.md
CHANGED
|
@@ -37,7 +37,7 @@ Optional `reference` controls refine the same call:
|
|
|
37
37
|
| `ignoreMasks` | Polygons that exclude legends, frames or decorative areas. |
|
|
38
38
|
| `annotations` | `{kind,polygon}` semantic polygons: sea, land, plains, lake, forest, desert, mountain, snow, volcano, hills, marsh or jungle. |
|
|
39
39
|
| `riverAnnotations` | Paths for known rivers. |
|
|
40
|
-
| `palette` | `{kind,color:{r,g,b}}` color cues for the same semantic kinds.
|
|
40
|
+
| `palette` | `{kind,color:{r,g,b}}` color cues for the same semantic kinds, plus `impassable_mountain`: mountain land no army may enter (ADR 0079), which reads as mountain for terrain, colour, snow and relief and becomes impassable states. |
|
|
41
41
|
| `coastDetail` | Detail preservation from 0 to 1. |
|
|
42
42
|
| `paletteMatch` | `nearest` (default) snaps each pixel to the closest `palette` colour. `exact` requires every pixel to equal a palette colour and trusts the classes as painted (no text masking, cleanup, smoothing or political inference; thin painted water stays water); any other colour fails with `MAP_REFERENCE_PALETTE_UNKNOWN_COLOR`, listing up to 16 colours with counts and five source pixels each. |
|
|
43
43
|
| `fit` | `contain` (default) centres the picture with sea padding. `frame` maps the picture, or its `crop`, onto exactly `width` x `height` (both required, same shape within 1%, else `MAP_REFERENCE_FRAME_ASPECT`) and reads it at the frame resolution instead of the 3,072-pixel working copy. |
|
|
@@ -115,7 +115,7 @@ A model is one object with `"version": 1` and any of these arrays. Unknown keys
|
|
|
115
115
|
| ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
116
116
|
| `seas` | `polygons` (outer rings), optional `holes`, `depthClass` (`shelf`, `open`, `abyss`), `ice` 0 to 1, `kind` (`ocean`, `sea`, `gulf`, `bay`, `fjord`) |
|
|
117
117
|
| `lands` | `polygons`, `holes`, `kind` (`continent`, `island`, `archipelago`, `peninsula`), `region`, default `biome` and `fertility`, `elevationBase`, `coastDetail` |
|
|
118
|
-
| `regions` | `polygons` (optional), `terrain` target shares, `density` (`provincesPerState` as `[smallest, usual, largest]`, `provinceAreaPx`)
|
|
118
|
+
| `regions` | `polygons` (optional), `terrain` target shares, `density` (`provincesPerState` as `[smallest, usual, largest]`, `provinceAreaPx`), `impassable` (the land inside its `polygons` becomes impassable states and the highest ground) |
|
|
119
119
|
| `ranges` | `path` (points, each optionally with `halfWidth` and `peak`), `closed`, `halfWidth`, `peak`, `profile` (`ridge`, `massif`, `escarpment`, `wall`), `asymmetry`, `snowline`, `spurs`, `barrier` (`none`, `impassable`, `fort-line`) |
|
|
120
120
|
| `passes` | `range` with `at` (0 to 1 along the range), or a `position` point (the range is found for you), `width`, `depth`, `fort` 0 to 5 |
|
|
121
121
|
| `volcanoes` | `at`, `radius`, `peak`, `crater`, `active` |
|
|
@@ -141,11 +141,12 @@ A model that needs an edit is reported by `MAP_GEOGRAPHY_*` diagnostics that nam
|
|
|
141
141
|
|
|
142
142
|
`create_world` with a geography writes `heightmap.bmp`, `world_normal.bmp`, `rivers.bmp`, the land and lake mask, and the permanent-snow terrain from the model; every other output follows the usual generator. Without a geography nothing changes. [ADR 0056](adr/0056-terrain-relief-and-hydrology-synthesis.md) records the design.
|
|
143
143
|
|
|
144
|
-
| Input
|
|
145
|
-
|
|
|
146
|
-
| `relief.scale`
|
|
147
|
-
| `relief.detail`
|
|
148
|
-
| `
|
|
144
|
+
| Input | Meaning |
|
|
145
|
+
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
146
|
+
| `relief.scale` | `vanilla` (default), `low` (everything above the lowland 25% lower) or `dramatic` (15% higher). |
|
|
147
|
+
| `relief.detail` | 0 to 1, default 0.5: full-resolution roughness. |
|
|
148
|
+
| `relief.painted` | With a reference picture: `true` or `{falloffPx, mountainPeak, hillsPeak, volcanoPeak, impassablePeak}`. Raises the macro relief toward the picture's painted mountain, hills and volcano classes before the rivers are routed, so the drawn ranges stand out and the model's rivers flow around them. Each class is blurred over `falloffPx` (default 24; below 16 the slopes steepen fast), mountains follow ridged noise, a cell keeps the model's height where that is higher, and painted mountains get permanent snow above a height that falls from 232 at the equator to 140 at the poles. Peaks are 0 to 1 on the range scale (defaults 0.82, 0.27, 0.9, 0.95). Impassable land is raised even when this is off. `MAP_RELIEF_PAINTED` reports the cells raised. |
|
|
149
|
+
| `rivers` | `{ "density": 0.02 }`: the share of land pixels the unnamed network covers (0 to 0.04, default 0.02; never more than 2.5% of the land or 130,000 pixels in all). An integer instead limits the number of unnamed river systems. |
|
|
149
150
|
|
|
150
151
|
What each feature becomes. Heights are heightmap values: land from 96, sea 89 (ADR 0053), a crest of `peak` stands at `100 + 148 * peak`, a plateau of `height` at `96 + 148 * height`, and the base game reaches 239 (the synthesis stops at 252).
|
|
151
152
|
|
|
@@ -476,13 +477,15 @@ A world built from a geography also gets its gameplay facts from the model (ADR
|
|
|
476
477
|
| fertility, rivers, coast, passes | Population, state category, infrastructure, factories and the harbour score of each coastal province, with no random rolls. |
|
|
477
478
|
| names | State, strategic region, victory-point and lake-province names from sites, lake shores, river valleys, ranges, regions, lands and seas by containment; shared names get a compass adjective. |
|
|
478
479
|
|
|
480
|
+
Impassable land (ADR 0079) comes from painted `impassable_mountain` pixels and from model `regions` with `impassable: true`. A land province with most of its pixels in it becomes part of an impassable state, written as the base game writes its impassable states: `impassable = yes`, `force_link_ownership_to` the nearest passable state and its owner, category `enclave` where the mod defines it, infrastructure 0 and nothing built. Generated capitals and ports avoid it; a city on it, or a workspace capital in one of its provinces, is the error `MAP_FEATURE_IN_IMPASSABLE`. The relief raises it toward `relief.painted.impassablePeak`. Range lines with `barrier: "impassable"` and their gated passes are unchanged and work beside it. Whenever impassable land or rows exist, `MAP_REALM_CUT_OFF` (warning) lists land of a realm that impassable land or borders separate from its capital, and `MAP_REALM_ENCLOSED` (warning) a realm whose land reaches no other realm except through them; islands are never reported.
|
|
481
|
+
|
|
479
482
|
Options of `create_world`: `development: { model }` (`geography`, the default for a geography world, or `legacy` for the random economy) and `autoStraits` (`true` or `{ maxGapPx }`, default 24 pixels, about 170 km) to also write a rule-less crossing for every narrow channel the model did not declare. Both need a geography (`MAP_DEVELOPMENT_REQUIRES_GEOGRAPHY`, `MAP_AUTO_STRAITS_REQUIRES_GEOGRAPHY`).
|
|
480
483
|
|
|
481
484
|
Railways of a geography world follow a terrain-aware cost (ground, climb across the border, rivers, gates, model roads) and never cross a wall except at a gate; trunk lines of level 2 reach the cities of 8 or more victory points. The supply-node rule is unchanged.
|
|
482
485
|
|
|
483
486
|
Diagnostics raised when a world is created (they need the model): `MAP_CROSSINGS_PLANNED`, `MAP_DEVELOPMENT_PLANNED` and `MAP_INLAND_SEA_CREATED` (info), `MAP_STRAIT_UNRESOLVED`, `MAP_STRAIT_DUPLICATE`, `MAP_STRAIT_NOT_NARROW`, `MAP_PASS_BLOCKED`, `MAP_RANGE_NOT_CLOSED`, `MAP_INLAND_SEA_SEALED`, `MAP_PORT_LAKE_UNSUPPORTED`, `MAP_PORT_SITE_NOT_COASTAL`, `MAP_SITE_UNPLACED` and `MAP_NAME_PLACEHOLDER` (warnings; the last counts the states, strategic regions and victory points still called "District N", "Region N" or "Settlement N"), and `MAP_IMPASSABLE_ROW_LIMIT` (refusal above 2,000 wall rows). Raised on any map by `hoi4.map_inspect`: `MAP_ADJACENCY_RULE_MISSING`, `_DUPLICATE` and `_INVALID` (errors), `MAP_ADJACENCY_RULE_UNUSED`, `MAP_IMPASSABLE_NOT_ADJACENT` and `MAP_UNIT_POSITION_MISSING` (information, or warnings when they are a pattern), `MAP_IMPASSABLE_NOT_LAND`, `MAP_ADJACENCY_ROW_LIMIT`, `MAP_STRAIT_NOT_NARROW` and `MAP_RAILWAY_CROSSES_IMPASSABLE` (warnings). The installed game raises nothing above information.
|
|
484
487
|
|
|
485
|
-
Not done:
|
|
488
|
+
Not done: passes cut as corridors through impassable land (a pass still opens a range line only), the engine's handling of impassable rows by supply and the AI and of a naval base on an inland sea is not verified, and `positions.txt` stays empty as in the base game. Measured on the project's 5,120 x 2,560 synthetic model with about 6,000 provinces, the gameplay layer adds about 6 seconds to a 30 second `create_world` and the whole run peaks near 0.8 GiB.
|
|
486
489
|
|
|
487
490
|
## Positions and supply
|
|
488
491
|
|
|
@@ -571,7 +574,7 @@ To check all of this without a write, call `hoi4.map_rewrite` with `preview: tru
|
|
|
571
574
|
By default provinces grow evenly from spread seeds and states and regions grow by breadth-first clusters, which ignore rivers, ridges and shores. Set `partition: "feature-aware"` (default `legacy`; a world given a `geography` defaults to it) to cut along natural lines instead (ADR 0058):
|
|
572
575
|
|
|
573
576
|
- Province borders are pulled onto rivers, steep slopes and ridges, wall ranges and lake shores (a watershed whose step cost rises on them). A province that still straddles a river or wall is cut along it.
|
|
574
|
-
- Province size follows the land: small in fertile valleys, on coasts and beside rivers, large on mountains and wasteland (`landArea.fertile`, `hills`, `mountain`, `waste`, in pixels), and per geography region through its `density.provinceAreaPx`. Without bands they follow `landProvincePixels` (0.35, 1, 2.2 and 3.4 times, scaled so the mean stays `landProvincePixels`). Sea provinces are small near a coast and large on the open sea (`seaArea.coastal` and `open`, from `seaProvincePixels`), and a channel no wider than `narrowStraitPx` (24) gets two sea provinces across it.
|
|
577
|
+
- Province size follows the land: small in fertile valleys, on coasts and beside rivers, large on mountains and wasteland (`landArea.fertile`, `hills`, `mountain`, `waste`, in pixels), and per geography region through its `density.provinceAreaPx`. Without bands they follow `landProvincePixels` (0.35, 1, 2.2 and 3.4 times, scaled so the mean stays `landProvincePixels`). Sea provinces are small near a coast and large on the open sea (`seaArea.coastal` and `open`, from `seaProvincePixels`), and a channel no wider than `narrowStraitPx` (24) gets two sea provinces across it. A lake province covers about `lakeArea` pixels (default 6,000, at most an eighth of the map), so a lake no larger than that stays one province.
|
|
575
578
|
- States and strategic regions are clusters over the province graph that avoid joining across rivers and ranges, prefer like ground, never mix geography regions or named seas, and respect `provincesPerState` (`[smallest, largest]`, or a region's own `density.provincesPerState`) and `regionSize`.
|
|
576
579
|
- `barrierStrength` (0 to 60, default 20) sets how hard borders are pulled onto natural lines; `minProvincePixels` (default 40) is the smallest planned province.
|
|
577
580
|
|
package/docs/probability.md
CHANGED
|
@@ -12,7 +12,7 @@ Use them for event timing and option weights, decision and mission scores, focus
|
|
|
12
12
|
|
|
13
13
|
## Game version
|
|
14
14
|
|
|
15
|
-
The adapters apply the documented weighting rules of `ai_will_do`, `ai_chance`, mean time to happen, `random_list` and AI strategies, which are the same in every game version, so evaluation runs on whatever HOI4 version is installed. When `gameRoot` is configured, `metadata.gameVersionVerification` records the build read from `launcher-settings.json`: `workspace_verified` for the build the adapters were last reviewed against, `workspace_observed` for any other build, and `version_unknown` with a `reason` when the file cannot be read. Without a game root, results identify the adapter version (`adapter_target_only`). Proposed source is evaluated in memory.
|
|
15
|
+
The adapters apply the documented weighting rules of `ai_will_do`, `ai_chance`, mean time to happen, `random_list` and AI strategies, which are the same in every game version, so evaluation runs on whatever HOI4 version is installed. When `gameRoot` is configured, `metadata.gameVersionVerification` records the build read from `launcher-settings.json`: `workspace_verified` for the build the adapters were last reviewed against, `workspace_observed` for any other build (reported with the warning `PROBABILITY_GAME_BUILD_UNVERIFIED`), and `version_unknown` with a `reason` when the file cannot be read. Without a game root, results identify the adapter version (`adapter_target_only`). Proposed source is evaluated in memory.
|
|
16
16
|
|
|
17
17
|
## One call for current weights
|
|
18
18
|
|