hoi4-agent-tools 4.11.1 → 4.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/README.md +3 -3
- package/dist/bin/setup.js +38 -0
- package/dist/bin/stdio.js +12 -10
- package/dist/hoi4_agent_tools/core/configuration.js +29 -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/engine.js +18 -2
- package/dist/hoi4_agent_tools/core/job-operation-registration.js +2 -0
- package/dist/hoi4_agent_tools/core/job-store.js +1 -1
- package/dist/hoi4_agent_tools/focus/native-effects.js +1 -1
- 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 +37 -8
- package/dist/hoi4_agent_tools/map/references.js +87 -0
- package/dist/hoi4_agent_tools/map/relief/hydrology.js +7 -2
- package/dist/hoi4_agent_tools/map/relief/terrain-synthesis.js +1 -0
- package/dist/hoi4_agent_tools/map/service.js +13 -4
- package/dist/hoi4_agent_tools/map/tool-operations.js +6 -0
- package/dist/hoi4_agent_tools/map/world-edge.js +0 -25
- package/dist/hoi4_agent_tools/map/world.js +181 -64
- package/dist/hoi4_agent_tools/mcp/plugins.js +74 -0
- package/dist/hoi4_agent_tools/mcp/server/argument-errors.js +5 -0
- package/dist/hoi4_agent_tools/mcp/server/create-modern-operations.js +15 -21
- 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/mcp/transports/negotiated-stdio.js +64 -6
- package/dist/hoi4_agent_tools/probability/model.js +4 -4
- 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/mod-index.js +63 -65
- 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 +17 -2
- 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 +5 -1
- package/dist/hoi4_agent_tools/schemas/mod-tools.js +50 -0
- package/dist/hoi4_agent_tools/schemas/modder-tools.js +191 -0
- package/dist/hoi4_agent_tools/version.js +1 -1
- package/docs/configuration.md +14 -11
- package/docs/development.md +2 -0
- package/docs/jobs.md +3 -1
- package/docs/map.md +8 -4
- package/docs/reference.md +47 -5
- package/docs/research/probability-adapter-evidence.md +11 -1
- package/docs/setup.md +23 -3
- package/docs/tools.md +18 -4
- package/docs/troubleshooting.md +1 -1
- 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 +8 -8
- 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 +181 -138
- 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 +153 -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
- package/dist/hoi4_agent_tools/mcp/tools/chaosx.js +0 -509
|
@@ -1,30 +1,57 @@
|
|
|
1
|
+
import { defaultPatterns } from '../core/engine.js';
|
|
2
|
+
import { runEngineCommand } from '../core/engine-client.js';
|
|
1
3
|
import { ServiceError } from '../core/result.js';
|
|
2
4
|
import { readModDescriptor } from '../core/workspace.js';
|
|
5
|
+
import { modIndexEngineResponseSchema, } from '../schemas/mod-tools.js';
|
|
3
6
|
const MAX_NAMESPACES = 200;
|
|
4
7
|
const MAX_FOLDERS = 60;
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
8
|
+
/** A cold index of the game, its DLC and a large mod. */
|
|
9
|
+
const MOD_INDEX_TIMEOUT_MS = 180_000;
|
|
10
|
+
const MOD_INDEX_REQUEST_SCHEMA = 'hoi4-mod-index-request/1';
|
|
11
|
+
/** The roots the shared scan reads; artifacts and caches are never sources. */
|
|
12
|
+
export const SOURCE_ROOT_KINDS = [
|
|
13
|
+
'game',
|
|
14
|
+
'dlc',
|
|
15
|
+
'dependency',
|
|
16
|
+
'mod',
|
|
17
|
+
'fixture',
|
|
18
|
+
];
|
|
19
|
+
/** The engine request for the workspace's source roots of `rootKinds` (scan roots of ADR 0080). */
|
|
20
|
+
export function modIndexEngineRequest(workspace, config, rootKinds) {
|
|
21
|
+
return {
|
|
22
|
+
schema: MOD_INDEX_REQUEST_SCHEMA,
|
|
23
|
+
roots: workspace.roots
|
|
24
|
+
.filter(({ kind }) => rootKinds.includes(kind))
|
|
25
|
+
.map(({ kind, path, loadOrder, label, replacePaths }) => ({
|
|
26
|
+
kind,
|
|
27
|
+
path,
|
|
28
|
+
loadOrder,
|
|
29
|
+
...(label === undefined ? {} : { label }),
|
|
30
|
+
replacePaths,
|
|
31
|
+
})),
|
|
32
|
+
patterns: defaultPatterns(workspace),
|
|
33
|
+
limits: {
|
|
34
|
+
maxFiles: config.scanMaxFiles,
|
|
35
|
+
maxBytes: config.scanMaxBytes,
|
|
36
|
+
maxFileBytes: config.scanMaxFileBytes,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
async function runModIndex(engine, workspaceId, request, principal, signal) {
|
|
41
|
+
signal?.throwIfAborted();
|
|
42
|
+
await engine.resolver.refreshDescriptors(workspaceId, principal);
|
|
43
|
+
const workspace = engine.resolver.get(workspaceId, principal);
|
|
44
|
+
const result = await runEngineCommand('mod-index', {
|
|
45
|
+
...modIndexEngineRequest(workspace, engine.resolver.config(), request.rootKinds),
|
|
46
|
+
mode: request.mode,
|
|
47
|
+
...(request.kind === undefined ? {} : { kind: request.kind }),
|
|
48
|
+
...(request.prefix === undefined ? {} : { prefix: request.prefix }),
|
|
49
|
+
}, modIndexEngineResponseSchema, { timeoutMs: MOD_INDEX_TIMEOUT_MS, ...(signal === undefined ? {} : { signal }) });
|
|
50
|
+
if (!result.available)
|
|
51
|
+
throw new ServiceError('ENGINE_UNAVAILABLE', result.message, { reason: result.reason });
|
|
52
|
+
if (result.outcome === 'invalid_request')
|
|
53
|
+
throw new ServiceError(result.error.code, result.error.message);
|
|
54
|
+
return result.response;
|
|
28
55
|
}
|
|
29
56
|
export async function modIndex(engine, workspaceId, input, principal, signal) {
|
|
30
57
|
if (input.mode === 'next_id') {
|
|
@@ -33,51 +60,25 @@ export async function modIndex(engine, workspaceId, input, principal, signal) {
|
|
|
33
60
|
if (prefix === undefined)
|
|
34
61
|
throw new ServiceError('MOD_INDEX_PREFIX_REQUIRED', 'next_id needs prefix or namespace');
|
|
35
62
|
// Every layer: a new identifier must not collide with game or dependency definitions.
|
|
36
|
-
const
|
|
37
|
-
const used =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
continue;
|
|
41
|
-
const suffix = symbol.id.slice(prefix.length);
|
|
42
|
-
if (/^\d{1,9}$/u.test(suffix))
|
|
43
|
-
used.add(Number(suffix));
|
|
44
|
-
}
|
|
45
|
-
const highest = used.size === 0 ? undefined : Math.max(...used);
|
|
46
|
-
let firstGap;
|
|
47
|
-
for (let number = 1; highest !== undefined && number < highest; number += 1)
|
|
48
|
-
if (!used.has(number)) {
|
|
49
|
-
firstGap = number;
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
const next = (highest ?? 0) + 1;
|
|
63
|
+
const answer = await runModIndex(engine, workspaceId, { mode: 'next_id', rootKinds: SOURCE_ROOT_KINDS, kind: input.kind, prefix }, principal, signal);
|
|
64
|
+
const used = answer.next?.used ?? 0;
|
|
65
|
+
const highest = answer.next?.highest;
|
|
66
|
+
const firstGap = answer.next?.firstGap;
|
|
53
67
|
return {
|
|
54
68
|
mode: 'next_id',
|
|
55
|
-
complete:
|
|
69
|
+
complete: answer.complete,
|
|
56
70
|
next: {
|
|
57
71
|
kind: input.kind,
|
|
58
72
|
prefix,
|
|
59
|
-
used
|
|
73
|
+
used,
|
|
60
74
|
...(highest === undefined ? {} : { highest }),
|
|
61
|
-
nextId: `${prefix}${
|
|
75
|
+
nextId: `${prefix}${(highest ?? 0) + 1}`,
|
|
62
76
|
...(firstGap === undefined ? {} : { firstGapId: `${prefix}${firstGap}` }),
|
|
63
77
|
},
|
|
64
78
|
};
|
|
65
79
|
}
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
const kinds = new Map();
|
|
69
|
-
for (const symbol of symbols)
|
|
70
|
-
kinds.set(symbol.kind, (kinds.get(symbol.kind) ?? 0) + 1);
|
|
71
|
-
const folders = new Map();
|
|
72
|
-
for (const file of snapshot.files) {
|
|
73
|
-
const parts = file.relativePath.split('/');
|
|
74
|
-
const folder = parts.length > 2 && parts[0] === 'common' ? parts.slice(0, 2).join('/') : parts[0];
|
|
75
|
-
const totals = folders.get(folder) ?? { files: 0, bytes: 0 };
|
|
76
|
-
totals.files += 1;
|
|
77
|
-
totals.bytes += file.size;
|
|
78
|
-
folders.set(folder, totals);
|
|
79
|
-
}
|
|
80
|
-
const allNamespaces = namespaces(symbols);
|
|
80
|
+
const answer = await runModIndex(engine, workspaceId, { mode: 'overview', rootKinds: input.layer === 'mod' ? ['mod'] : SOURCE_ROOT_KINDS }, principal, signal);
|
|
81
|
+
const allNamespaces = [...(answer.namespaces ?? [])].sort((left, right) => left.namespace.localeCompare(right.namespace, 'en'));
|
|
81
82
|
const modRoot = engine.resolver
|
|
82
83
|
.get(workspaceId, principal)
|
|
83
84
|
.roots.find(({ kind }) => kind === 'mod')?.path;
|
|
@@ -85,14 +86,11 @@ export async function modIndex(engine, workspaceId, input, principal, signal) {
|
|
|
85
86
|
return {
|
|
86
87
|
mode: 'overview',
|
|
87
88
|
layer: input.layer,
|
|
88
|
-
complete:
|
|
89
|
+
complete: answer.complete,
|
|
89
90
|
...(descriptor === undefined ? {} : { descriptor }),
|
|
90
|
-
files:
|
|
91
|
-
kinds: [...kinds]
|
|
92
|
-
|
|
93
|
-
.sort((left, right) => right.count - left.count || left.kind.localeCompare(right.kind)),
|
|
94
|
-
folders: [...folders]
|
|
95
|
-
.map(([folder, totals]) => ({ folder, ...totals }))
|
|
91
|
+
files: answer.files ?? 0,
|
|
92
|
+
kinds: [...(answer.kinds ?? [])].sort((left, right) => right.count - left.count || left.kind.localeCompare(right.kind)),
|
|
93
|
+
folders: [...(answer.folders ?? [])]
|
|
96
94
|
.sort((left, right) => right.files - left.files || left.folder.localeCompare(right.folder))
|
|
97
95
|
.slice(0, MAX_FOLDERS),
|
|
98
96
|
namespaces: allNamespaces.slice(0, MAX_NAMESPACES),
|