hoi4-agent-tools 4.12.0 → 4.14.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 +14 -0
- package/README.md +3 -3
- package/dist/bin/setup.js +38 -0
- package/dist/bin/stdio.js +5 -1
- package/dist/hoi4_agent_tools/core/configuration.js +16 -0
- package/dist/hoi4_agent_tools/core/domain-tools.js +4 -0
- package/dist/hoi4_agent_tools/core/engine-check.js +87 -0
- package/dist/hoi4_agent_tools/core/engine-client.js +1 -1
- package/dist/hoi4_agent_tools/core/job-operation-registration.js +2 -0
- package/dist/hoi4_agent_tools/localisation/job-operations.js +42 -0
- package/dist/hoi4_agent_tools/localisation/write-diff.js +96 -0
- package/dist/hoi4_agent_tools/localisation/write-format.js +329 -0
- package/dist/hoi4_agent_tools/localisation/write-operations.js +213 -0
- package/dist/hoi4_agent_tools/localisation/write-plan.js +557 -0
- package/dist/hoi4_agent_tools/map/gameplay/crossing-validation.js +17 -0
- package/dist/hoi4_agent_tools/map/model.js +31 -1
- package/dist/hoi4_agent_tools/map/operations.js +2 -1
- package/dist/hoi4_agent_tools/map/world-edge.js +0 -25
- package/dist/hoi4_agent_tools/map/world.js +124 -34
- package/dist/hoi4_agent_tools/mcp/server/argument-errors.js +5 -0
- package/dist/hoi4_agent_tools/mcp/server/create-modern-operations.js +8 -3
- package/dist/hoi4_agent_tools/mcp/server/create.js +5 -1
- package/dist/hoi4_agent_tools/mcp/server/request-lifecycle.js +10 -2
- package/dist/hoi4_agent_tools/mcp/server/task-tool-catalog.js +2 -0
- package/dist/hoi4_agent_tools/mcp/server/tool-profiles.js +83 -0
- package/dist/hoi4_agent_tools/mcp/tools/localisation-write.js +21 -0
- package/dist/hoi4_agent_tools/mcp/tools/reference.js +34 -0
- package/dist/hoi4_agent_tools/mcp/transports/http.js +6 -1
- package/dist/hoi4_agent_tools/reference/compat-patch.js +555 -0
- package/dist/hoi4_agent_tools/reference/compat.js +255 -0
- package/dist/hoi4_agent_tools/reference/docs-pack.js +164 -0
- package/dist/hoi4_agent_tools/reference/docs-pack.json +339 -0
- package/dist/hoi4_agent_tools/reference/documented-commands.js +26 -0
- package/dist/hoi4_agent_tools/reference/error-explain.js +235 -0
- package/dist/hoi4_agent_tools/reference/error-explanations.json +262 -0
- package/dist/hoi4_agent_tools/reference/error-log.js +30 -10
- package/dist/hoi4_agent_tools/reference/mod-health.js +255 -0
- package/dist/hoi4_agent_tools/reference/operations.js +435 -21
- package/dist/hoi4_agent_tools/reference/script-guard.js +109 -0
- package/dist/hoi4_agent_tools/reference/service.js +58 -20
- package/dist/hoi4_agent_tools/runtime.js +11 -0
- package/dist/hoi4_agent_tools/schemas/compat.js +153 -0
- package/dist/hoi4_agent_tools/schemas/localisation-write.js +154 -0
- package/dist/hoi4_agent_tools/schemas/map.js +13 -1
- package/dist/hoi4_agent_tools/schemas/modder-tools.js +191 -0
- package/dist/hoi4_agent_tools/version.js +1 -1
- package/docs/configuration.md +4 -1
- package/docs/jobs.md +2 -1
- package/docs/map.md +4 -2
- package/docs/reference.md +45 -5
- package/docs/setup.md +23 -3
- package/docs/tools.md +16 -1
- 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 +1 -1
- package/schemas/configuration.schema.json +140 -113
- 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 +170 -139
- 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
|
@@ -13,6 +13,7 @@ import { activeKnownMistakes } from './known-mistakes.js';
|
|
|
13
13
|
import { readBoundedJsonLines } from './lines.js';
|
|
14
14
|
import { commandTexts, readGameText } from './game-text.js';
|
|
15
15
|
import { RankingIndex, sectionTerms, textTerms } from './ranking.js';
|
|
16
|
+
import { installedDocsPackWiki } from './docs-pack.js';
|
|
16
17
|
const MAX_FILES = 512;
|
|
17
18
|
const MAX_FILE_BYTES = 2_000_000;
|
|
18
19
|
const MAX_TOTAL_BYTES = 32_000_000;
|
|
@@ -214,19 +215,42 @@ function sectionize(root, canonicalRoot, filePath, content, revision) {
|
|
|
214
215
|
/** The kit's HOI4 wiki folder, and the name it had before the kit renamed it. */
|
|
215
216
|
const WIKI_FOLDER = 'hoi4_wiki';
|
|
216
217
|
const LEGACY_WIKI_FOLDER = 'paradox_wiki';
|
|
217
|
-
|
|
218
|
-
function defaultWikiRoot(modRoot) {
|
|
219
|
-
const current = path.join(modRoot, WIKI_FOLDER);
|
|
218
|
+
function isDirectory(candidate) {
|
|
220
219
|
try {
|
|
221
|
-
|
|
222
|
-
return current;
|
|
220
|
+
return statSync(candidate).isDirectory();
|
|
223
221
|
}
|
|
224
222
|
catch {
|
|
225
|
-
|
|
223
|
+
return false;
|
|
226
224
|
}
|
|
227
|
-
return path.join(modRoot, LEGACY_WIKI_FOLDER);
|
|
228
225
|
}
|
|
229
|
-
|
|
226
|
+
/** `hoi4_wiki/` when the mod has it, otherwise the older `paradox_wiki/` of a mod the kit has not updated. */
|
|
227
|
+
function modWikiRoot(modRoot) {
|
|
228
|
+
return [WIKI_FOLDER, LEGACY_WIKI_FOLDER]
|
|
229
|
+
.map((folder) => path.join(modRoot, folder))
|
|
230
|
+
.find(isDirectory);
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* The wiki a workspace reads: a configured folder, the mod's own copy, or else the docs pack.
|
|
234
|
+
* Without any of them it is the legacy folder name, which is reported unavailable.
|
|
235
|
+
*/
|
|
236
|
+
function wikiRoot(workspace, docsPackWiki) {
|
|
237
|
+
const own = workspace.wikiRoot ?? modWikiRoot(workspace.modRoot);
|
|
238
|
+
if (own === undefined && docsPackWiki !== undefined)
|
|
239
|
+
return {
|
|
240
|
+
kind: 'wiki',
|
|
241
|
+
root: docsPackWiki,
|
|
242
|
+
patterns: ['**/*.md'],
|
|
243
|
+
authority: 'HOI4 wiki (docs pack)',
|
|
244
|
+
authorityRoot: docsPackWiki,
|
|
245
|
+
};
|
|
246
|
+
return {
|
|
247
|
+
kind: 'wiki',
|
|
248
|
+
root: own ?? path.join(workspace.modRoot, LEGACY_WIKI_FOLDER),
|
|
249
|
+
patterns: ['**/*.md'],
|
|
250
|
+
authority: 'HOI4 wiki (kit)',
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
function sourceRoots(workspace, docsPackWiki) {
|
|
230
254
|
const gameRoot = workspace.gameRoot ?? (workspace.registration.kind === 'game' ? workspace.modRoot : undefined);
|
|
231
255
|
return [
|
|
232
256
|
...(gameRoot === undefined
|
|
@@ -239,12 +263,7 @@ function sourceRoots(workspace) {
|
|
|
239
263
|
authority: 'Installed game documentation',
|
|
240
264
|
},
|
|
241
265
|
]),
|
|
242
|
-
|
|
243
|
-
kind: 'wiki',
|
|
244
|
-
root: workspace.wikiRoot ?? defaultWikiRoot(workspace.modRoot),
|
|
245
|
-
patterns: ['**/*.md'],
|
|
246
|
-
authority: 'HOI4 wiki (kit)',
|
|
247
|
-
},
|
|
266
|
+
wikiRoot(workspace, docsPackWiki),
|
|
248
267
|
{
|
|
249
268
|
kind: 'script_doc',
|
|
250
269
|
root: workspace.scriptDocsRoot ?? path.join(workspace.modRoot, 'script_docs'),
|
|
@@ -373,6 +392,24 @@ export class ReferenceService {
|
|
|
373
392
|
#cache = new Map();
|
|
374
393
|
#indexes = new Map();
|
|
375
394
|
#cacheBytes = 0;
|
|
395
|
+
#docsRoot;
|
|
396
|
+
/** `docsRoot`: where a fetched docs pack lives; without it no pack is read. */
|
|
397
|
+
constructor(options = {}) {
|
|
398
|
+
this.#docsRoot = options.docsRoot;
|
|
399
|
+
}
|
|
400
|
+
/** The wiki folder of the installed docs pack this package version pins, if there is one. */
|
|
401
|
+
async docsPackWiki() {
|
|
402
|
+
const wiki = await installedDocsPackWiki(this.#docsRoot);
|
|
403
|
+
if (wiki === undefined)
|
|
404
|
+
return undefined;
|
|
405
|
+
// The canonical path: a data folder named by its 8.3 short form (a Windows user name can
|
|
406
|
+
// be shortened) must not look like a root that resolves outside itself.
|
|
407
|
+
return realpath(wiki).catch(() => wiki);
|
|
408
|
+
}
|
|
409
|
+
/** Whether a docs pack location is configured, so a missing pack can be named as the fix. */
|
|
410
|
+
get docsPackConfigured() {
|
|
411
|
+
return this.#docsRoot !== undefined;
|
|
412
|
+
}
|
|
376
413
|
retain(key, value) {
|
|
377
414
|
this.#cacheBytes -= this.#cache.get(key)?.bytes ?? 0;
|
|
378
415
|
this.#cache.delete(key);
|
|
@@ -410,7 +447,7 @@ export class ReferenceService {
|
|
|
410
447
|
};
|
|
411
448
|
let skipped = 0;
|
|
412
449
|
let bytes = 0;
|
|
413
|
-
for (const root of sourceRoots(workspace)) {
|
|
450
|
+
for (const root of sourceRoots(workspace, await this.docsPackWiki())) {
|
|
414
451
|
if (sources !== undefined && !sources.includes(root.kind))
|
|
415
452
|
continue;
|
|
416
453
|
signal?.throwIfAborted();
|
|
@@ -422,11 +459,12 @@ export class ReferenceService {
|
|
|
422
459
|
coverage[root.kind].unavailable = true;
|
|
423
460
|
continue;
|
|
424
461
|
}
|
|
425
|
-
const configuredAuthorityRoot = root.
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
462
|
+
const configuredAuthorityRoot = root.authorityRoot ??
|
|
463
|
+
(root.kind === 'game_doc'
|
|
464
|
+
? root.root
|
|
465
|
+
: root.kind === 'wiki'
|
|
466
|
+
? (workspace.wikiRoot ?? workspace.modRoot)
|
|
467
|
+
: (workspace.scriptDocsRoot ?? workspace.modRoot));
|
|
430
468
|
if (!isWithin(configuredAuthorityRoot, canonicalRoot)) {
|
|
431
469
|
throw new ServiceError('REFERENCE_ROOT_ESCAPE', 'Reference root resolves outside its configured workspace');
|
|
432
470
|
}
|
|
@@ -7,6 +7,8 @@ import { ServiceError } from './core/result.js';
|
|
|
7
7
|
import { WorkspaceResolver } from './core/workspace.js';
|
|
8
8
|
import { CONFIG_VERSION } from './version.js';
|
|
9
9
|
import { sweepTemporaryDirectories } from './core/temporary-directories.js';
|
|
10
|
+
import { PROFILES_ENV, parseProfilesEnv, } from './mcp/server/tool-profiles.js';
|
|
11
|
+
import { defaultDocsRoot } from './reference/docs-pack.js';
|
|
10
12
|
export function defaultConfigurationPath() {
|
|
11
13
|
const configRoot = process.env.APPDATA ?? process.env.XDG_CONFIG_HOME ?? path.join(homedir(), '.config');
|
|
12
14
|
return path.join(configRoot, 'hoi4-agent-tools', 'config.json');
|
|
@@ -236,6 +238,15 @@ export async function createEngine(configPath = configurationPath(), options = {
|
|
|
236
238
|
throw error;
|
|
237
239
|
configuration = await automaticConfiguration();
|
|
238
240
|
}
|
|
241
|
+
// The stdio server lists the core tools unless the client or the file asks for more.
|
|
242
|
+
const profiles = parseProfilesEnv(process.env[PROFILES_ENV]) ??
|
|
243
|
+
configuration.profiles ??
|
|
244
|
+
options.defaultProfiles;
|
|
245
|
+
if (profiles !== undefined)
|
|
246
|
+
configuration = { ...configuration, profiles: [...profiles] };
|
|
247
|
+
// The command-line servers read a fetched docs pack from the user's data folder by default.
|
|
248
|
+
if (configuration.docsRoot === undefined)
|
|
249
|
+
configuration = { ...configuration, docsRoot: defaultDocsRoot() };
|
|
239
250
|
const resolver = await WorkspaceResolver.create(configuration);
|
|
240
251
|
await sweepTemporaryDirectories(tmpdir(), {
|
|
241
252
|
protectedRoots: [
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
import { workspaceIdSchema } from './common.js';
|
|
3
|
+
/** `hoi4.compat_check`: how the mod fits another mod, and what a game patch changed under its overrides. */
|
|
4
|
+
export const COMPAT_DEFAULT_LIMIT = 10;
|
|
5
|
+
export const COMPAT_MAX_LIMIT = 50;
|
|
6
|
+
const buildSchema = z.string().min(1).max(64);
|
|
7
|
+
export const compatCheckRequestSchema = z
|
|
8
|
+
.object({
|
|
9
|
+
workspaceId: workspaceIdSchema,
|
|
10
|
+
/** mod: the mod against another mod, in both load orders. patch: the mod's overrides across game builds. */
|
|
11
|
+
mode: z.enum(['mod', 'patch']),
|
|
12
|
+
/** mod only: the other mod's folder name or workspace id. */
|
|
13
|
+
other: z.string().min(1).max(128).optional(),
|
|
14
|
+
/** patch only: the older stored game build; default is the newest stored build other than `to`. */
|
|
15
|
+
from: buildSchema.optional(),
|
|
16
|
+
/** patch only: the newer game build; default is the installed build. */
|
|
17
|
+
to: buildSchema.optional(),
|
|
18
|
+
/** Items listed per list; the counts are always complete. */
|
|
19
|
+
limit: z.number().int().min(1).max(COMPAT_MAX_LIMIT).default(COMPAT_DEFAULT_LIMIT),
|
|
20
|
+
})
|
|
21
|
+
.strict()
|
|
22
|
+
.superRefine((input, context) => {
|
|
23
|
+
if (input.mode === 'mod' && input.other === undefined)
|
|
24
|
+
context.addIssue({ code: 'custom', path: ['other'], message: 'mode mod needs other' });
|
|
25
|
+
if (input.mode === 'patch' && input.other !== undefined)
|
|
26
|
+
context.addIssue({
|
|
27
|
+
code: 'custom',
|
|
28
|
+
path: ['other'],
|
|
29
|
+
message: 'other belongs to mode mod',
|
|
30
|
+
});
|
|
31
|
+
if (input.mode === 'mod' && (input.from !== undefined || input.to !== undefined))
|
|
32
|
+
context.addIssue({
|
|
33
|
+
code: 'custom',
|
|
34
|
+
path: [input.from === undefined ? 'to' : 'from'],
|
|
35
|
+
message: 'from and to belong to mode patch',
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
const modRefSchema = z.object({ id: z.string().max(64), name: z.string().max(256) }).strict();
|
|
39
|
+
const findingSchema = z
|
|
40
|
+
.object({
|
|
41
|
+
code: z.string().max(64),
|
|
42
|
+
severity: z.enum(['error', 'warning', 'info']),
|
|
43
|
+
subject: z.string().max(256).nullable(),
|
|
44
|
+
layer: z.string().max(256),
|
|
45
|
+
path: z.string().max(512),
|
|
46
|
+
message: z.string().max(400),
|
|
47
|
+
})
|
|
48
|
+
.strict();
|
|
49
|
+
const listSchema = (item) => z
|
|
50
|
+
.object({
|
|
51
|
+
count: z.number().int().min(0),
|
|
52
|
+
omitted: z.number().int().min(0),
|
|
53
|
+
items: z.array(item).max(COMPAT_MAX_LIMIT),
|
|
54
|
+
})
|
|
55
|
+
.strict();
|
|
56
|
+
const loadOrderSchema = z
|
|
57
|
+
.object({
|
|
58
|
+
/** Loads first; its files lose a clash. */
|
|
59
|
+
first: modRefSchema,
|
|
60
|
+
/** Loads last; its files win a clash. */
|
|
61
|
+
second: modRefSchema,
|
|
62
|
+
errors: z.number().int().min(0),
|
|
63
|
+
warnings: z.number().int().min(0),
|
|
64
|
+
sameFile: listSchema(z.object({ path: z.string().max(512), winner: z.string().max(256) }).strict()),
|
|
65
|
+
duplicateDefinitions: listSchema(findingSchema),
|
|
66
|
+
dropped: listSchema(findingSchema),
|
|
67
|
+
replacePathDrops: listSchema(z
|
|
68
|
+
.object({
|
|
69
|
+
folder: z.string().max(512),
|
|
70
|
+
fileCount: z.number().int().min(1),
|
|
71
|
+
files: z.array(z.string().max(512)).max(5),
|
|
72
|
+
})
|
|
73
|
+
.strict()),
|
|
74
|
+
})
|
|
75
|
+
.strict();
|
|
76
|
+
export const compatModDataSchema = z
|
|
77
|
+
.object({
|
|
78
|
+
mode: z.literal('mod'),
|
|
79
|
+
workspace: modRefSchema,
|
|
80
|
+
other: modRefSchema,
|
|
81
|
+
verdict: z.enum(['no_conflicts', 'conflicts']),
|
|
82
|
+
/** The load order that loses less, from its error and warning counts against the other order; null when they match. */
|
|
83
|
+
lessLoss: z
|
|
84
|
+
.object({
|
|
85
|
+
loadsLast: modRefSchema,
|
|
86
|
+
errors: z.number().int().min(0),
|
|
87
|
+
warnings: z.number().int().min(0),
|
|
88
|
+
otherOrderErrors: z.number().int().min(0),
|
|
89
|
+
otherOrderWarnings: z.number().int().min(0),
|
|
90
|
+
})
|
|
91
|
+
.strict()
|
|
92
|
+
.nullable(),
|
|
93
|
+
summary: z.string().max(600),
|
|
94
|
+
loadOrders: z.array(loadOrderSchema).length(2),
|
|
95
|
+
notes: z.array(z.string().max(400)).max(8),
|
|
96
|
+
durationMs: z.number().int().min(0),
|
|
97
|
+
})
|
|
98
|
+
.strict();
|
|
99
|
+
const hunkFileSchema = z
|
|
100
|
+
.object({
|
|
101
|
+
path: z.string().max(512),
|
|
102
|
+
layer: z.string().max(256),
|
|
103
|
+
change: z.enum(['changed', 'added', 'removed']),
|
|
104
|
+
binary: z.boolean(),
|
|
105
|
+
oldLines: z.number().int().min(0).nullable(),
|
|
106
|
+
newLines: z.number().int().min(0).nullable(),
|
|
107
|
+
linesAdded: z.number().int().min(0).nullable(),
|
|
108
|
+
linesRemoved: z.number().int().min(0).nullable(),
|
|
109
|
+
firstHunk: z.string().max(2400).nullable(),
|
|
110
|
+
})
|
|
111
|
+
.strict();
|
|
112
|
+
const snapshotInfoSchema = z
|
|
113
|
+
.object({
|
|
114
|
+
build: z.string().max(64),
|
|
115
|
+
files: z.number().int().min(0),
|
|
116
|
+
copiedFiles: z.number().int().min(0),
|
|
117
|
+
uncopiedFiles: z.number().int().min(0),
|
|
118
|
+
bytes: z.number().int().min(0),
|
|
119
|
+
})
|
|
120
|
+
.strict();
|
|
121
|
+
export const compatPatchDataSchema = z
|
|
122
|
+
.object({
|
|
123
|
+
mode: z.literal('patch'),
|
|
124
|
+
workspace: modRefSchema,
|
|
125
|
+
/** The installed build; null when only stored snapshots were compared. */
|
|
126
|
+
installedBuild: z.string().max(64).nullable(),
|
|
127
|
+
/** The snapshot this call stored; null when only stored snapshots were compared. */
|
|
128
|
+
recorded: snapshotInfoSchema.nullable(),
|
|
129
|
+
pruned: z.array(z.string().max(64)).max(16),
|
|
130
|
+
stored: z.array(snapshotInfoSchema).max(8),
|
|
131
|
+
comparison: z
|
|
132
|
+
.object({
|
|
133
|
+
from: z.string().max(64),
|
|
134
|
+
to: z.string().max(64),
|
|
135
|
+
changed: z.number().int().min(0),
|
|
136
|
+
added: z.number().int().min(0),
|
|
137
|
+
removed: z.number().int().min(0),
|
|
138
|
+
unchanged: z.number().int().min(0),
|
|
139
|
+
/** Overridden in the older snapshot, gone from the newer one, and no longer shipped by the mod. */
|
|
140
|
+
noLongerOverridden: z.number().int().min(0),
|
|
141
|
+
omitted: z.number().int().min(0),
|
|
142
|
+
files: z.array(hunkFileSchema).max(COMPAT_MAX_LIMIT),
|
|
143
|
+
})
|
|
144
|
+
.strict()
|
|
145
|
+
.nullable(),
|
|
146
|
+
summary: z.string().max(600),
|
|
147
|
+
durationMs: z.number().int().min(0),
|
|
148
|
+
})
|
|
149
|
+
.strict();
|
|
150
|
+
export const compatCheckDataSchema = z.discriminatedUnion('mode', [
|
|
151
|
+
compatModDataSchema,
|
|
152
|
+
compatPatchDataSchema,
|
|
153
|
+
]);
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
import { backgroundRequestKeySchema, workspaceIdSchema, workspaceRelativePathSchema, } from './common.js';
|
|
3
|
+
/** The languages the game ships (`localisation/languages.yml`). */
|
|
4
|
+
export const LOCALISATION_LANGUAGES = [
|
|
5
|
+
'english',
|
|
6
|
+
'french',
|
|
7
|
+
'german',
|
|
8
|
+
'spanish',
|
|
9
|
+
'polish',
|
|
10
|
+
'russian',
|
|
11
|
+
'braz_por',
|
|
12
|
+
'japanese',
|
|
13
|
+
'simp_chinese',
|
|
14
|
+
'korean',
|
|
15
|
+
];
|
|
16
|
+
export const localisationLanguageSchema = z.enum(LOCALISATION_LANGUAGES);
|
|
17
|
+
export const LOCALISATION_FIXES = ['bom', 'quotes', 'missing_languages'];
|
|
18
|
+
export const localisationFixSchema = z.enum(LOCALISATION_FIXES);
|
|
19
|
+
export const LOCALISATION_KEY_PATTERN = /^[A-Za-z0-9_.-]{1,256}$/u;
|
|
20
|
+
// A value is one line: no line break, tab or other control character.
|
|
21
|
+
const FORBIDDEN_TEXT = /[\p{Cc}\p{Zl}\p{Zp}]/u;
|
|
22
|
+
export const localisationEntrySchema = z
|
|
23
|
+
.object({
|
|
24
|
+
key: z.string().regex(LOCALISATION_KEY_PATTERN),
|
|
25
|
+
text: z
|
|
26
|
+
.string()
|
|
27
|
+
.max(2000)
|
|
28
|
+
.refine((value) => !FORBIDDEN_TEXT.test(value), {
|
|
29
|
+
message: 'text must be one line; write a line break as \\n',
|
|
30
|
+
}),
|
|
31
|
+
})
|
|
32
|
+
.strict();
|
|
33
|
+
export const localisationWriteRequestSchema = z
|
|
34
|
+
.object({
|
|
35
|
+
workspaceId: workspaceIdSchema,
|
|
36
|
+
mode: z.enum(['add', 'fix']),
|
|
37
|
+
apply: z
|
|
38
|
+
.boolean()
|
|
39
|
+
.default(false)
|
|
40
|
+
.describe('false returns the diff and writes nothing; true makes the same change.'),
|
|
41
|
+
entries: z.array(localisationEntrySchema).min(1).max(200).optional(),
|
|
42
|
+
language: localisationLanguageSchema.default('english'),
|
|
43
|
+
file: workspaceRelativePathSchema.max(512).optional(),
|
|
44
|
+
replace: z.boolean().default(false),
|
|
45
|
+
fixes: z
|
|
46
|
+
.array(localisationFixSchema)
|
|
47
|
+
.min(1)
|
|
48
|
+
.max(3)
|
|
49
|
+
.default([...LOCALISATION_FIXES]),
|
|
50
|
+
paths: z.array(workspaceRelativePathSchema.max(512)).min(1).max(200).optional(),
|
|
51
|
+
requestKey: backgroundRequestKeySchema.optional(),
|
|
52
|
+
})
|
|
53
|
+
.strict()
|
|
54
|
+
.superRefine((value, context) => {
|
|
55
|
+
const misplaced = (field) => context.addIssue({
|
|
56
|
+
code: 'custom',
|
|
57
|
+
path: [field],
|
|
58
|
+
message: `${field} belongs to the other mode`,
|
|
59
|
+
});
|
|
60
|
+
if (value.mode === 'add') {
|
|
61
|
+
if (value.entries === undefined)
|
|
62
|
+
context.addIssue({ code: 'custom', path: ['entries'], message: 'mode add needs entries' });
|
|
63
|
+
else {
|
|
64
|
+
const seen = new Set();
|
|
65
|
+
for (const [index, entry] of value.entries.entries()) {
|
|
66
|
+
if (seen.has(entry.key))
|
|
67
|
+
context.addIssue({
|
|
68
|
+
code: 'custom',
|
|
69
|
+
path: ['entries', index, 'key'],
|
|
70
|
+
message: `${entry.key} appears twice in entries`,
|
|
71
|
+
});
|
|
72
|
+
seen.add(entry.key);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (value.paths !== undefined)
|
|
76
|
+
misplaced('paths');
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
if (value.entries !== undefined)
|
|
80
|
+
misplaced('entries');
|
|
81
|
+
if (value.file !== undefined)
|
|
82
|
+
misplaced('file');
|
|
83
|
+
if (value.replace)
|
|
84
|
+
misplaced('replace');
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
const countSchema = z.number().int().min(0);
|
|
88
|
+
const changeKindSchema = z.enum([
|
|
89
|
+
'add_key',
|
|
90
|
+
'replace_key',
|
|
91
|
+
'override_key',
|
|
92
|
+
'create_file',
|
|
93
|
+
'add_bom',
|
|
94
|
+
'reencode_utf16',
|
|
95
|
+
'fix_quote',
|
|
96
|
+
'copy_missing_key',
|
|
97
|
+
]);
|
|
98
|
+
export const localisationWriteDataSchema = z
|
|
99
|
+
.object({
|
|
100
|
+
mode: z.enum(['add', 'fix']),
|
|
101
|
+
applied: z.boolean(),
|
|
102
|
+
files: z
|
|
103
|
+
.array(z
|
|
104
|
+
.object({
|
|
105
|
+
path: z.string().max(1024),
|
|
106
|
+
action: z.enum(['create', 'update']),
|
|
107
|
+
diff: z.string().max(12_000),
|
|
108
|
+
diffTruncated: z.boolean(),
|
|
109
|
+
changes: z
|
|
110
|
+
.array(z
|
|
111
|
+
.object({
|
|
112
|
+
kind: changeKindSchema,
|
|
113
|
+
key: z.string().max(256).optional(),
|
|
114
|
+
line: z.number().int().min(1).optional(),
|
|
115
|
+
})
|
|
116
|
+
.strict())
|
|
117
|
+
.max(8),
|
|
118
|
+
changesOmitted: countSchema,
|
|
119
|
+
})
|
|
120
|
+
.strict())
|
|
121
|
+
.max(12),
|
|
122
|
+
skipped: z
|
|
123
|
+
.array(z.object({ key: z.string().max(256), reason: z.string().max(300) }).strict())
|
|
124
|
+
.max(20),
|
|
125
|
+
unfixable: z
|
|
126
|
+
.array(z
|
|
127
|
+
.object({
|
|
128
|
+
kind: z.string().max(64),
|
|
129
|
+
path: z.string().max(1024).optional(),
|
|
130
|
+
key: z.string().max(256).optional(),
|
|
131
|
+
reason: z.string().max(300),
|
|
132
|
+
})
|
|
133
|
+
.strict())
|
|
134
|
+
.max(20),
|
|
135
|
+
notes: z.array(z.string().max(400)).max(10),
|
|
136
|
+
counts: z
|
|
137
|
+
.object({
|
|
138
|
+
filesChanged: countSchema,
|
|
139
|
+
filesCreated: countSchema,
|
|
140
|
+
filesOmitted: countSchema,
|
|
141
|
+
keysAdded: countSchema,
|
|
142
|
+
keysReplaced: countSchema,
|
|
143
|
+
keysOverridden: countSchema,
|
|
144
|
+
keysSkipped: countSchema,
|
|
145
|
+
skippedOmitted: countSchema,
|
|
146
|
+
bomsAdded: countSchema,
|
|
147
|
+
quotesFixed: countSchema,
|
|
148
|
+
keysCopied: countSchema,
|
|
149
|
+
unfixable: countSchema,
|
|
150
|
+
unfixableOmitted: countSchema,
|
|
151
|
+
})
|
|
152
|
+
.strict(),
|
|
153
|
+
})
|
|
154
|
+
.strict();
|
|
@@ -196,7 +196,7 @@ export const worldEdgeSchema = z
|
|
|
196
196
|
mode: z
|
|
197
197
|
.enum(['sea-band', 'rim', 'wall', 'none'])
|
|
198
198
|
.optional()
|
|
199
|
-
.describe('sea-band (default when edge is given) clears land from the east and west edges and the poles to open sea; rim ends land at the seam in an impassable snow range
|
|
199
|
+
.describe('sea-band (default when edge is given) clears land from the east and west edges and the poles to open sea; rim ends land at the seam in an impassable snow range whose seam provinces are impassable states, but sea at the seam stays sailable; wall fills rimPx at the east and west edges with land over the full height, in impassable states, so nothing crosses the seam by land or sea; none keeps the picture and warns about land cut by the wrapping seam.'),
|
|
200
200
|
bandPx: z
|
|
201
201
|
.number()
|
|
202
202
|
.int()
|
|
@@ -1072,6 +1072,18 @@ export const mapOperationSchema = z.discriminatedUnion('kind', [
|
|
|
1072
1072
|
.enum(['keep', 'drop'])
|
|
1073
1073
|
.optional()
|
|
1074
1074
|
.describe('keep (the default) also lists the continents of the active continent.txt after the generated ones; drop writes only the generated continents and warns about every active script that still names a dropped one (MAP_CONTINENT_DROPPED_REFERENCED).'),
|
|
1075
|
+
permanentSnow: z
|
|
1076
|
+
.union([
|
|
1077
|
+
z.literal('snowlines'),
|
|
1078
|
+
z
|
|
1079
|
+
.object({
|
|
1080
|
+
iceCapLatitude: z.number().min(0).max(1).optional(),
|
|
1081
|
+
peakHeight: z.number().int().min(96).max(256).optional(),
|
|
1082
|
+
})
|
|
1083
|
+
.strict(),
|
|
1084
|
+
])
|
|
1085
|
+
.optional()
|
|
1086
|
+
.describe('Where land drawn as snow in the reference keeps permanent snow; other drawn snow is ordinary land with seasonal snow. iceCapLatitude (default 0.8; 0 is the middle row, 1 the top and bottom edge, 1 turns ice caps off) and peakHeight (heightmap value, default 150; 256 turns it off). snowlines keeps permanent snow only above the snow lines of ranges and painted mountains. MAP_PERMANENT_SNOW_SHARE reports the result against the base game.'),
|
|
1075
1087
|
startDate: z
|
|
1076
1088
|
.string()
|
|
1077
1089
|
.regex(/^\d{3,4}\.\d{1,2}\.\d{1,2}$/u)
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
import { workspaceIdSchema } from './common.js';
|
|
3
|
+
import { errorLogCategorySchema } from './mod-tools.js';
|
|
4
|
+
const count = z.number().int().min(0);
|
|
5
|
+
const line = z.number().int().min(1);
|
|
6
|
+
const logLine = z.string().trim().min(3).max(4000);
|
|
7
|
+
export const explainErrorRequestSchema = z
|
|
8
|
+
.object({
|
|
9
|
+
workspaceId: workspaceIdSchema,
|
|
10
|
+
/** One error.log line, as the game writes it or as hoi4.error_log returns it. */
|
|
11
|
+
line: logLine.optional(),
|
|
12
|
+
/** Up to 10 lines explained in one call. */
|
|
13
|
+
lines: z.array(logLine).min(1).max(10).optional(),
|
|
14
|
+
})
|
|
15
|
+
.strict()
|
|
16
|
+
.superRefine((value, context) => {
|
|
17
|
+
if ((value.line === undefined) === (value.lines === undefined))
|
|
18
|
+
context.addIssue({
|
|
19
|
+
code: 'custom',
|
|
20
|
+
path: ['line'],
|
|
21
|
+
message: 'Provide either line or lines',
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
const sourceLayerSchema = z.enum(['mod', 'dependency', 'game', 'unknown']);
|
|
25
|
+
export const errorExplanationSchema = z
|
|
26
|
+
.object({
|
|
27
|
+
/** The message explained; a wrapped parser error yields one explanation per message. */
|
|
28
|
+
message: z.string().max(600),
|
|
29
|
+
category: errorLogCategorySchema,
|
|
30
|
+
/** `catalogue`: a reviewed explanation; `known_mistake`: a reviewed rule; `category`: only the category's advice. */
|
|
31
|
+
matched: z.enum(['catalogue', 'known_mistake', 'category']),
|
|
32
|
+
id: z.string().max(64).optional(),
|
|
33
|
+
/** What the game requires. */
|
|
34
|
+
rule: z.string().max(600),
|
|
35
|
+
fix: z.string().max(600),
|
|
36
|
+
/** The command, key, tag or name the message is about. */
|
|
37
|
+
subject: z.string().max(256).optional(),
|
|
38
|
+
/** The kinds of command the game's documentation lists the subject as. */
|
|
39
|
+
documentedAs: z
|
|
40
|
+
.array(z.enum(['effect', 'trigger', 'modifier']))
|
|
41
|
+
.max(3)
|
|
42
|
+
.optional(),
|
|
43
|
+
/** The scripted helpers a loaded file defines with the subject's name. */
|
|
44
|
+
definedBy: z
|
|
45
|
+
.array(z.enum(['scripted_effect', 'scripted_trigger']))
|
|
46
|
+
.max(2)
|
|
47
|
+
.optional(),
|
|
48
|
+
/** Documented or defined names close to the subject. */
|
|
49
|
+
suggestions: z.array(z.string().max(256)).max(3).optional(),
|
|
50
|
+
source: z
|
|
51
|
+
.object({
|
|
52
|
+
relativePath: z.string().max(1024),
|
|
53
|
+
line: line.optional(),
|
|
54
|
+
layer: sourceLayerSchema,
|
|
55
|
+
/** Up to 5 lines around the named line, from the layer that has the file. */
|
|
56
|
+
excerpt: z
|
|
57
|
+
.array(z.object({ line, text: z.string().max(200) }).strict())
|
|
58
|
+
.max(5)
|
|
59
|
+
.optional(),
|
|
60
|
+
})
|
|
61
|
+
.strict()
|
|
62
|
+
.optional(),
|
|
63
|
+
/** What the documentation and the loaded files say about the subject. */
|
|
64
|
+
note: z.string().max(400).optional(),
|
|
65
|
+
/** The tool call that narrows it down. */
|
|
66
|
+
next: z
|
|
67
|
+
.object({
|
|
68
|
+
tool: z.string().max(64),
|
|
69
|
+
arguments: z.record(z.string().max(64), z.union([z.string().max(1024), z.number()])),
|
|
70
|
+
})
|
|
71
|
+
.strict()
|
|
72
|
+
.optional(),
|
|
73
|
+
})
|
|
74
|
+
.strict();
|
|
75
|
+
export const explainErrorDataSchema = z
|
|
76
|
+
.object({
|
|
77
|
+
explanations: z.array(errorExplanationSchema).max(20),
|
|
78
|
+
/** Explanations from the reviewed catalogue or a reviewed rule, not only a category. */
|
|
79
|
+
explained: count,
|
|
80
|
+
/** Reviewed explanations the catalogue holds. */
|
|
81
|
+
catalogue: count,
|
|
82
|
+
})
|
|
83
|
+
.strict();
|
|
84
|
+
export const healthCheckSchema = z.enum([
|
|
85
|
+
'error_log',
|
|
86
|
+
'engine_check',
|
|
87
|
+
'script',
|
|
88
|
+
'localisation',
|
|
89
|
+
'assets',
|
|
90
|
+
]);
|
|
91
|
+
export const modHealthRequestSchema = z
|
|
92
|
+
.object({
|
|
93
|
+
workspaceId: workspaceIdSchema,
|
|
94
|
+
/** The audits to run; all five by default. */
|
|
95
|
+
checks: z.array(healthCheckSchema).min(1).max(5).optional(),
|
|
96
|
+
limit: z.number().int().min(1).max(10).default(10),
|
|
97
|
+
})
|
|
98
|
+
.strict();
|
|
99
|
+
const nextCallSchema = z
|
|
100
|
+
.object({
|
|
101
|
+
tool: z.string().max(64),
|
|
102
|
+
arguments: z.record(z.string().max(64), z.union([z.string().max(1024), z.number(), z.boolean()])),
|
|
103
|
+
})
|
|
104
|
+
.strict();
|
|
105
|
+
export const modHealthDataSchema = z
|
|
106
|
+
.object({
|
|
107
|
+
/** `healthy`: every audit ran and found nothing; `incomplete`: nothing found, but an audit could not run. */
|
|
108
|
+
verdict: z.enum(['healthy', 'problems', 'incomplete']),
|
|
109
|
+
problems: z
|
|
110
|
+
.array(z
|
|
111
|
+
.object({
|
|
112
|
+
rank: line,
|
|
113
|
+
check: healthCheckSchema,
|
|
114
|
+
severity: z.enum(['error', 'warning']),
|
|
115
|
+
code: z.string().max(128),
|
|
116
|
+
title: z.string().max(300),
|
|
117
|
+
/** Findings of this kind in the mod. */
|
|
118
|
+
count: count,
|
|
119
|
+
examples: z
|
|
120
|
+
.array(z
|
|
121
|
+
.object({
|
|
122
|
+
message: z.string().max(300),
|
|
123
|
+
path: z.string().max(1024).optional(),
|
|
124
|
+
line: line.optional(),
|
|
125
|
+
})
|
|
126
|
+
.strict())
|
|
127
|
+
.max(2),
|
|
128
|
+
fix: z.string().max(400),
|
|
129
|
+
next: nextCallSchema.optional(),
|
|
130
|
+
})
|
|
131
|
+
.strict())
|
|
132
|
+
.max(10),
|
|
133
|
+
totals: z
|
|
134
|
+
.object({
|
|
135
|
+
problems: count,
|
|
136
|
+
findings: count,
|
|
137
|
+
errors: count,
|
|
138
|
+
warnings: count,
|
|
139
|
+
omitted: count,
|
|
140
|
+
})
|
|
141
|
+
.strict(),
|
|
142
|
+
checks: z
|
|
143
|
+
.array(z
|
|
144
|
+
.object({
|
|
145
|
+
check: healthCheckSchema,
|
|
146
|
+
status: z.enum(['ran', 'partial', 'unavailable', 'skipped']),
|
|
147
|
+
ms: count,
|
|
148
|
+
findings: count,
|
|
149
|
+
note: z.string().max(300).optional(),
|
|
150
|
+
})
|
|
151
|
+
.strict())
|
|
152
|
+
.max(5),
|
|
153
|
+
checksRun: count,
|
|
154
|
+
})
|
|
155
|
+
.strict();
|
|
156
|
+
export const scriptGuardRequestSchema = z
|
|
157
|
+
.object({
|
|
158
|
+
workspaceId: workspaceIdSchema,
|
|
159
|
+
/** Mod files to check, such as events/my_events.txt. */
|
|
160
|
+
paths: z.array(z.string().trim().min(1).max(1024)).min(1).max(50).optional(),
|
|
161
|
+
/** Without paths: the mod's script files changed in the last this many minutes. */
|
|
162
|
+
sinceMinutes: z.number().int().min(1).max(10_080).default(120),
|
|
163
|
+
})
|
|
164
|
+
.strict();
|
|
165
|
+
export const scriptGuardDataSchema = z
|
|
166
|
+
.object({
|
|
167
|
+
/** `clean`: every name in the checked files is documented or defined. */
|
|
168
|
+
verdict: z.enum(['clean', 'invented']),
|
|
169
|
+
filesChecked: count,
|
|
170
|
+
/** Changed files beyond the 200 newest. */
|
|
171
|
+
filesOmitted: count,
|
|
172
|
+
counts: z.object({ effect: count, trigger: count, modifier: count }).strict(),
|
|
173
|
+
files: z.array(z.object({ path: z.string().max(1024), invented: count }).strict()).max(50),
|
|
174
|
+
invented: z
|
|
175
|
+
.array(z
|
|
176
|
+
.object({
|
|
177
|
+
name: z.string().max(256),
|
|
178
|
+
kind: z.enum(['effect', 'trigger', 'modifier']),
|
|
179
|
+
path: z.string().max(1024),
|
|
180
|
+
line,
|
|
181
|
+
/** The definition it is in, such as `event:my.1`. */
|
|
182
|
+
context: z.string().max(256).optional(),
|
|
183
|
+
/** The closest documented or defined name. */
|
|
184
|
+
suggestion: z.string().max(256).optional(),
|
|
185
|
+
message: z.string().max(300),
|
|
186
|
+
})
|
|
187
|
+
.strict())
|
|
188
|
+
.max(40),
|
|
189
|
+
inventedOmitted: count,
|
|
190
|
+
})
|
|
191
|
+
.strict();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LATEST_PROTOCOL_VERSION } from '@modelcontextprotocol/sdk/types.js';
|
|
2
2
|
export const PACKAGE_NAME = 'hoi4-agent-tools';
|
|
3
|
-
export const PACKAGE_VERSION = '4.
|
|
3
|
+
export const PACKAGE_VERSION = '4.14.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;
|