hoi4-agent-tools 4.10.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 +9 -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/impact/service.js +4 -1
- 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/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/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/reference.md +27 -1
- 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 +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 +1 -1
- 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
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 4.11.0 - 2026-11-07
|
|
6
|
+
|
|
7
|
+
- Add `hoi4.skill` and the skill resources (#108, M-1). The tool lists the skills HOI4 Mod Setup installed in the mod or loads one by name, and the same `SKILL.md` text is the resource `hoi4-agent://workspace/{workspaceId}/skill/{name}`. Both serve the kit version the mod's Setup lock pins, with the kit revision and each file's SHA-256. A file edited since Setup installed it is refused with `SKILL_TEXT_DRIFTED` unless the caller accepts local edits, and a mod without a lock gets its installed skills marked unpinned.
|
|
8
|
+
- Smaller answers (maintainer decision R-4). The reference tools (`reference_search`, `reference_read`, `reference_context`, `source_lookup`, `script_validate`, `error_log`, `mod_index` and the `*_inspect` tools beside them), which agents call most, leave out `filesScanned`, `proposedFiles`, `changedFiles`, `diagnostics`, `artifacts` and `blockers` when they are empty, and `validation.checks` when there are none. An absent list means an empty one, and the advertised output schema marks them optional for every tool. The other tools keep the full envelope for now. A `reference_search` or `reference_context` hit names its file under its source's folder (`wiki:event_modding.md`, `game_doc:documentation/effects_documentation.md`) instead of an absolute path, carries a 16-character id and a 12-character revision instead of two 64-character hashes, leaves out the source's authority line, and repeats the page title only when it differs from the heading. `reference_read` accepts these short forms and still accepts the full ones. A stale revision is still caught. When no mod is selected, `WORKSPACE_CONTEXT_NOT_FOUND` and `WORKSPACE_CONTEXT_REQUIRED` list the mod folder names (`modFolders`) and one line that says what to pass (`fix`), instead of opaque workspace ids. A `workspaceId` that names a mod folder now matches in any letter case and with spaces, as the folder appears in a file manager.
|
|
9
|
+
- Generate the tool tables and example calls in `docs/tools.md` from `tools/list` (#109, M-5). `npm run docs:tools` rewrites them, and `tests/integration/tool-docs.test.ts` fails when the page drifts from the tool definitions, when two tools share a name, when a tool has no section, or when a description has no example call. The first run added the missing `hoi4.asset_inspect` row, updated four example calls that no longer matched their descriptions, and dropped three second calls that no description carries.
|
|
10
|
+
- More answers come inline, with less unrelated noise (part of #66). `package_check` names every item that is not present in `data.notPresent` (category, id, status, reason and path, up to 32), so the answer needs no report. `filesScanned` of `package_check`, of a `decision_inspect` inspection or comparison, and of `impact_inspect` now lists the files that hold the checked items, the decision or the symbol and its consumers, instead of the first twelve files of the workspace. The tools list budget in the discovery test moves from 80 to 84 KiB, as in #104 and #105.
|
|
11
|
+
- Record the 2026-11-01 head-to-head with cpntodd/HOI4-MCP in `docs/research/hoi4-mcp-head-to-head-2026-11-01.md` (part of #111, M-7). The record says that it predates the accuracy fixes and that its seeded `owner = ROOT` control was wrong ground truth, because `owner` is not a trigger.
|
|
12
|
+
|
|
5
13
|
## 4.10.0 - 2026-11-06
|
|
6
14
|
|
|
7
15
|
- Size lake provinces: `create_world.partitionTuning.lakeArea` (default 6,000 pixels, capped at the largest province the map allows) sets the area of a lake province, so a drawn lake no larger than it stays one province.
|
|
@@ -12,6 +20,7 @@
|
|
|
12
20
|
- `MAP_REALM_CUT_OFF` and `MAP_REALM_ENCLOSED` warn when impassable land or borders cut a realm apart or box it in.
|
|
13
21
|
- `EVENT_TARGET_READ_BEFORE_SAVE` no longer reports correct script (#60). A `has_event_target` or `has_global_event_target` check tests whether a target exists. Without a visible producer it is now the design warning `EVENT_GATE_WITHOUT_WRITER`, not a probable defect. A read that such a check guards in the same event, focus or decision is not reported. Names built in a `meta_effect` or with `$parameter$`s are no longer cut at their first bracket. Names far into a long block are read in full instead of being cut at the display limit. The event graph now reads shared and joint focuses and the `completion_reward_joint_originator` and `completion_reward_joint_member` rewards, where vanilla saves `SSB_leader`. On Chaos Redux with vanilla 1.19.4.1 the findings drop from 33 to 2. Both remaining ones are real: vanilla reads `demanded_prov_target` in `events/Generic.txt` and saves it nowhere.
|
|
14
22
|
- Check the hand-kept game data against the installed build (#70). The probability adapters were re-checked on 1.19.4.1: five of the six documentation files they rest on are byte-identical to 1.19.2.0, and the two AI strategy sections they use say the same, so the target moves to `Operation Postern 1.19.4.1 (f584)` and the adapter version to `hoi4-1.19.4.1.v1`. A result on another build now carries the warning `PROBABILITY_GAME_BUILD_UNVERIFIED` instead of only recording `workspace_observed` in its metadata. The nightly game-update watcher lists the adapters or the native-effects list under "Checked against another build" on every run while their pin differs from the installed build, not only on the night the build changes.
|
|
23
|
+
- Keep the kit wiki's maintenance text out of reference answers. `hoi4.reference_search`, `hoi4.reference_read` and `hoi4.reference_context` never index `LICENSE.txt`, `SOURCES.json` (or `SOURCES.md`) and `manifest.json` (or `manifest.md`) in the wiki folder, whatever their extension, and no longer serve HTML comments from Markdown sources. Kit wiki pages from before the kit made them lean carry `<!-- kit:begin ... -->` markers, and a search excerpt could open with one. A comment is blanked outside code fences and inline code, and every line is kept, so cited line numbers still match the file. On the 163 hand-checked questions of the discovery benchmark the kit's lean wiki answers as well as before (131 rather than 130 within five results) and the median reply is 9 percent smaller.
|
|
15
24
|
|
|
16
25
|
## 4.9.0 - 2026-11-05
|
|
17
26
|
|
|
@@ -57,22 +57,61 @@ const compactPublicOperationResultSchema = z
|
|
|
57
57
|
status: z.enum(['ok', 'blocked', 'error']),
|
|
58
58
|
code: z.string(),
|
|
59
59
|
workspaceId: z.string(),
|
|
60
|
-
filesScanned: z.array(z.unknown()),
|
|
61
|
-
proposedFiles: z.array(z.unknown()),
|
|
62
|
-
changedFiles: z.array(z.unknown()),
|
|
63
|
-
diagnostics: z.array(z.unknown()).max(MAX_INLINE_DIAGNOSTICS),
|
|
64
|
-
artifacts: z.array(z.unknown()).max(MAX_INLINE_ARTIFACT_LINKS),
|
|
60
|
+
filesScanned: z.array(z.unknown()).optional(),
|
|
61
|
+
proposedFiles: z.array(z.unknown()).optional(),
|
|
62
|
+
changedFiles: z.array(z.unknown()).optional(),
|
|
63
|
+
diagnostics: z.array(z.unknown()).max(MAX_INLINE_DIAGNOSTICS).optional(),
|
|
64
|
+
artifacts: z.array(z.unknown()).max(MAX_INLINE_ARTIFACT_LINKS).optional(),
|
|
65
65
|
validation: z.unknown(),
|
|
66
|
-
blockers: z.array(z.unknown()),
|
|
66
|
+
blockers: z.array(z.unknown()).optional(),
|
|
67
67
|
data: z.object({}).catchall(z.unknown()),
|
|
68
68
|
})
|
|
69
69
|
.strict();
|
|
70
|
+
/**
|
|
71
|
+
* Collections a compact tool result leaves out when they are empty. The reference tools answer
|
|
72
|
+
* most often, so their answers do not repeat six empty lists; an absent list is empty.
|
|
73
|
+
*/
|
|
74
|
+
const OMITTED_WHEN_EMPTY = [
|
|
75
|
+
'filesScanned',
|
|
76
|
+
'proposedFiles',
|
|
77
|
+
'changedFiles',
|
|
78
|
+
'diagnostics',
|
|
79
|
+
'artifacts',
|
|
80
|
+
'blockers',
|
|
81
|
+
];
|
|
82
|
+
/** The published envelope: the same fields, with empty collections and empty checks optional. */
|
|
83
|
+
const publicOperationResultBaseSchema = operationResultBaseSchema
|
|
84
|
+
.partial({
|
|
85
|
+
filesScanned: true,
|
|
86
|
+
proposedFiles: true,
|
|
87
|
+
changedFiles: true,
|
|
88
|
+
diagnostics: true,
|
|
89
|
+
artifacts: true,
|
|
90
|
+
blockers: true,
|
|
91
|
+
})
|
|
92
|
+
.extend({ validation: validationSummarySchema.partial({ checks: true }) })
|
|
93
|
+
.strict();
|
|
94
|
+
/** Drop the empty collections and empty validation checks from a structured result. */
|
|
95
|
+
export function withoutEmptyCollections(structured) {
|
|
96
|
+
const omitted = new Set(OMITTED_WHEN_EMPTY);
|
|
97
|
+
const result = Object.fromEntries(Object.entries(structured).filter(([key, value]) => !(omitted.has(key) && Array.isArray(value) && value.length === 0)));
|
|
98
|
+
const validation = result.validation;
|
|
99
|
+
if (validation !== null &&
|
|
100
|
+
typeof validation === 'object' &&
|
|
101
|
+
'checks' in validation &&
|
|
102
|
+
Array.isArray(validation.checks) &&
|
|
103
|
+
validation.checks.length === 0) {
|
|
104
|
+
const { checks: _checks, ...rest } = validation;
|
|
105
|
+
result.validation = rest;
|
|
106
|
+
}
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
70
109
|
/**
|
|
71
110
|
* Advertise one compact operation envelope while retaining exact per-tool runtime validation.
|
|
72
111
|
* The generic operation-result schema remains available for stored envelopes.
|
|
73
112
|
*/
|
|
74
113
|
export function strictOperationResultSchema(successDataSchema) {
|
|
75
|
-
const exactSchema =
|
|
114
|
+
const exactSchema = publicOperationResultBaseSchema
|
|
76
115
|
.extend({ data: z.union([emptyToolDataSchema, successDataSchema]) })
|
|
77
116
|
.strict();
|
|
78
117
|
return compactPublicOperationResultSchema.superRefine((value, context) => {
|
|
@@ -421,8 +460,9 @@ function compactDescriptions(unfiltered) {
|
|
|
421
460
|
})),
|
|
422
461
|
};
|
|
423
462
|
}
|
|
424
|
-
function buildToolResult(selected, imageCount = 0) {
|
|
425
|
-
const
|
|
463
|
+
function buildToolResult(selected, imageCount = 0, compact = false) {
|
|
464
|
+
const parsed = operationResultSchema.parse(selected);
|
|
465
|
+
const structuredContent = compact ? withoutEmptyCollections(parsed) : parsed;
|
|
426
466
|
const shown = selected.artifacts
|
|
427
467
|
.map((artifact, order) => ({ artifact, order }))
|
|
428
468
|
.sort((left, right) => linkPriority(left.artifact.mimeType) - linkPriority(right.artifact.mimeType) ||
|
|
@@ -487,10 +527,10 @@ export function toolResult(result, options = {}) {
|
|
|
487
527
|
? Buffer.byteLength(canonicalJson(compact), 'utf8')
|
|
488
528
|
: MAX_TOOL_RESULT_BYTES + 1;
|
|
489
529
|
const selected = estimatedBytes > MAX_TOOL_RESULT_BYTES ? boundedResult(compact, estimatedBytes) : compact;
|
|
490
|
-
let output = buildToolResult(selected, images.length);
|
|
530
|
+
let output = buildToolResult(selected, images.length, options.compact);
|
|
491
531
|
const wireBytes = Buffer.byteLength(canonicalJson(output), 'utf8');
|
|
492
532
|
if (wireBytes > MAX_TOOL_RESULT_BYTES) {
|
|
493
|
-
output = buildToolResult(boundedResult(compact, wireBytes), images.length);
|
|
533
|
+
output = buildToolResult(boundedResult(compact, wireBytes), images.length, options.compact);
|
|
494
534
|
}
|
|
495
535
|
const finalBytes = Buffer.byteLength(canonicalJson(output), 'utf8');
|
|
496
536
|
if (finalBytes > MAX_TOOL_RESULT_BYTES) {
|
|
@@ -207,15 +207,23 @@ function workspaceAliases(workspace) {
|
|
|
207
207
|
`mod_${nameSlug}`,
|
|
208
208
|
]);
|
|
209
209
|
}
|
|
210
|
-
const WORKSPACE_CONTEXT_FIX = 'Pass workspaceId with
|
|
210
|
+
const WORKSPACE_CONTEXT_FIX = 'Pass workspaceId with a mod folder name from modFolders, start the client in the mod folder, or set defaultWorkspace in the server configuration';
|
|
211
211
|
const WORKSPACE_CANDIDATE_LIMIT = 32;
|
|
212
|
-
/**
|
|
212
|
+
/**
|
|
213
|
+
* The mods a caller could name, bounded and without host paths: their folder names, which
|
|
214
|
+
* `workspaceId` accepts, and one line that says what to pass.
|
|
215
|
+
*/
|
|
213
216
|
function workspaceCandidates(workspaces) {
|
|
214
|
-
const
|
|
217
|
+
const modFolders = workspaces
|
|
218
|
+
.slice(0, WORKSPACE_CANDIDATE_LIMIT)
|
|
219
|
+
.map(({ modRoot }) => path.basename(modRoot));
|
|
220
|
+
const example = modFolders[0];
|
|
215
221
|
return {
|
|
216
|
-
|
|
217
|
-
workspaceNames: listed.map(({ name }) => name),
|
|
222
|
+
modFolders,
|
|
218
223
|
workspaceCount: workspaces.length,
|
|
224
|
+
fix: example === undefined
|
|
225
|
+
? 'Add a mod folder to modRoots in the server configuration'
|
|
226
|
+
: `Pass "workspaceId":${JSON.stringify(example)} (or another folder in modFolders)`,
|
|
219
227
|
};
|
|
220
228
|
}
|
|
221
229
|
function requestedWorkspaceAlias(value) {
|
|
@@ -383,7 +391,7 @@ export class WorkspaceResolver {
|
|
|
383
391
|
resolveCurrentWorkspaceId(principal) {
|
|
384
392
|
const workspaces = this.list(principal).filter(({ registration }) => registration.kind === 'mod');
|
|
385
393
|
if (workspaces.length === 0) {
|
|
386
|
-
throw new ServiceError('WORKSPACE_CONTEXT_NOT_FOUND', 'No writable mod workspace is configured for the MCP server');
|
|
394
|
+
throw new ServiceError('WORKSPACE_CONTEXT_NOT_FOUND', 'No writable mod workspace is configured for the MCP server', workspaceCandidates(workspaces));
|
|
387
395
|
}
|
|
388
396
|
const currentDirectory = path.normalize(process.cwd());
|
|
389
397
|
const containing = workspaces.filter((workspace) => isWithin(workspace.modRoot, currentDirectory));
|
|
@@ -455,7 +463,14 @@ export class WorkspaceResolver {
|
|
|
455
463
|
if (this.#byId.has(workspaceId))
|
|
456
464
|
return workspaceId;
|
|
457
465
|
const alias = requestedWorkspaceAlias(workspaceId);
|
|
458
|
-
|
|
466
|
+
// A folder name as the file manager shows it ("My Mod") names the same mod as its slug.
|
|
467
|
+
const slug = workspaceAliasSlug(alias);
|
|
468
|
+
const matches = this.list(principal).filter((workspace) => {
|
|
469
|
+
if (workspace.registration.kind !== 'mod')
|
|
470
|
+
return false;
|
|
471
|
+
const aliases = workspaceAliases(workspace);
|
|
472
|
+
return aliases.has(alias) || (slug !== '' && aliases.has(slug));
|
|
473
|
+
});
|
|
459
474
|
if (matches.length === 1)
|
|
460
475
|
return matches[0].id;
|
|
461
476
|
if (matches.length > 1) {
|
|
@@ -226,7 +226,19 @@ export class DecisionAnalyzer {
|
|
|
226
226
|
result.code = complete ? 'DECISION_ANALYZED' : 'DECISION_ANALYZED_PARTIAL';
|
|
227
227
|
result.artifacts = [publicArtifactLink(artifact)];
|
|
228
228
|
result.proposedFiles = overlay?.changes.map(({ path }) => path).slice(0, 64) ?? [];
|
|
229
|
-
|
|
229
|
+
// A decision's own files answer an inspection; an inventory spans the workspace (#66).
|
|
230
|
+
setInlineFilesScanned(result, input.mode === 'inventory'
|
|
231
|
+
? before.files.map(({ displayPath }) => displayPath)
|
|
232
|
+
: [
|
|
233
|
+
...new Set(inventory.decisions
|
|
234
|
+
.filter(({ id }) => id === input.id)
|
|
235
|
+
.flatMap(({ path, category }) => [
|
|
236
|
+
path,
|
|
237
|
+
...inventory.categories
|
|
238
|
+
.filter((entry) => entry.id === category)
|
|
239
|
+
.map((entry) => entry.path),
|
|
240
|
+
])),
|
|
241
|
+
]);
|
|
230
242
|
result.validation = {
|
|
231
243
|
passed: complete,
|
|
232
244
|
checks: [
|
|
@@ -125,7 +125,10 @@ export class ImpactAnalyzer {
|
|
|
125
125
|
result.code = complete ? 'IMPACT_ANALYZED' : 'IMPACT_ANALYZED_PARTIAL';
|
|
126
126
|
result.artifacts = [publicArtifactLink(artifact)];
|
|
127
127
|
result.proposedFiles = overlay?.changes.map(({ path }) => path).slice(0, 64) ?? [];
|
|
128
|
-
|
|
128
|
+
// The seed files and the files of the consumers, not the first files of the workspace (#66).
|
|
129
|
+
setInlineFilesScanned(result, [
|
|
130
|
+
...new Set([...(query.changedFiles ?? []), ...suiteGraph.affectedFiles]),
|
|
131
|
+
]);
|
|
129
132
|
result.validation = {
|
|
130
133
|
passed: complete,
|
|
131
134
|
checks: [
|
|
@@ -3,15 +3,19 @@ import { ProtocolError, ProtocolErrorCode, ResourceNotFoundError, } from '@model
|
|
|
3
3
|
import { artifactResourceDefinition, readArtifactResource } from '../../core/artifact-resource.js';
|
|
4
4
|
import { readServerStatus, serverStatusResource } from '../../core/server-status-resource.js';
|
|
5
5
|
import { ServiceError } from '../../core/result.js';
|
|
6
|
+
import { listSkillResources, readSkillResource, skillResourceDefinition, } from '../../reference/skill-resource.js';
|
|
6
7
|
/** Modern wire projection of the same non-enumerating, authorization-bound resource reader. */
|
|
7
8
|
export function registerModernResources(server, engine, context) {
|
|
8
9
|
// Process details are offered to the local client only, never to authenticated remote ones.
|
|
9
10
|
const local = context.principal === undefined;
|
|
10
|
-
server.setRequestHandler('resources/list', () => ({
|
|
11
|
-
resources:
|
|
11
|
+
server.setRequestHandler('resources/list', async (_request, extra) => ({
|
|
12
|
+
resources: [
|
|
13
|
+
...(local ? [serverStatusResource] : []),
|
|
14
|
+
...(await listSkillResources(engine, context, extra.mcpReq.signal)),
|
|
15
|
+
],
|
|
12
16
|
}));
|
|
13
17
|
server.setRequestHandler('resources/templates/list', () => ({
|
|
14
|
-
resourceTemplates: [artifactResourceDefinition],
|
|
18
|
+
resourceTemplates: [artifactResourceDefinition, skillResourceDefinition],
|
|
15
19
|
}));
|
|
16
20
|
server.setRequestHandler('resources/read', async (request, extra) => {
|
|
17
21
|
if (local && request.params.uri === serverStatusResource.uri)
|
|
@@ -23,7 +27,9 @@ export function registerModernResources(server, engine, context) {
|
|
|
23
27
|
});
|
|
24
28
|
try {
|
|
25
29
|
return ReadResourceResultSchema.parse({
|
|
26
|
-
...(
|
|
30
|
+
...(/^hoi4-agent:\/\/workspace\/[^/]+\/skill\//u.test(request.params.uri)
|
|
31
|
+
? await readSkillResource(engine, request.params.uri, context, extra.mcpReq.signal)
|
|
32
|
+
: await readArtifactResource(engine, request.params.uri, context, extra.mcpReq.signal)),
|
|
27
33
|
resultType: 'complete',
|
|
28
34
|
ttlMs: 0,
|
|
29
35
|
cacheScope: 'private',
|
|
@@ -34,6 +40,7 @@ export function registerModernResources(server, engine, context) {
|
|
|
34
40
|
throw error;
|
|
35
41
|
if (error instanceof ServiceError) {
|
|
36
42
|
if (error.code.startsWith('RESOURCE_') ||
|
|
43
|
+
error.code === 'SKILL_TEXT_DRIFTED' ||
|
|
37
44
|
['ARTIFACT_URI_INVALID', 'ARTIFACT_RANGE_INVALID', 'ARTIFACT_METADATA_INVALID'].includes(error.code))
|
|
38
45
|
throw new ProtocolError(ProtocolErrorCode.InvalidParams, error.message, {
|
|
39
46
|
code: error.code,
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { artifactResourceDefinition, readArtifactResource } from '../../core/artifact-resource.js';
|
|
3
3
|
import { readServerStatus, serverStatusResource } from '../../core/server-status-resource.js';
|
|
4
|
+
import { listSkillResources, readSkillResource, skillResourceDefinition, } from '../../reference/skill-resource.js';
|
|
4
5
|
/** SDK-v1 registration only; ownership and byte-range behavior live in the shared core. */
|
|
5
6
|
export function registerMcpResources(server, engine, context) {
|
|
6
7
|
const { name, uriTemplate, ...metadata } = artifactResourceDefinition;
|
|
7
8
|
server.registerResource(name, new ResourceTemplate(uriTemplate, { list: undefined }), metadata, (uri, _variables, extra) => readArtifactResource(engine, uri.href, context, extra.signal));
|
|
9
|
+
const { name: skillName, uriTemplate: skillTemplate, ...skillMetadata } = skillResourceDefinition;
|
|
10
|
+
server.registerResource(skillName, new ResourceTemplate(skillTemplate, {
|
|
11
|
+
list: async (extra) => ({
|
|
12
|
+
resources: await listSkillResources(engine, context, extra.signal),
|
|
13
|
+
}),
|
|
14
|
+
}), skillMetadata, (uri, _variables, extra) => readSkillResource(engine, uri.href, context, extra.signal));
|
|
8
15
|
// Process details are offered to the local client only, never to authenticated remote ones.
|
|
9
16
|
if (context.principal !== undefined)
|
|
10
17
|
return;
|
|
@@ -18,6 +18,7 @@ export const ARGUMENT_EXAMPLES = {
|
|
|
18
18
|
'hoi4.system_inspect': '{"kind":"mio","id":"my_organization"} or {"kind":"on_actions","audit":true}',
|
|
19
19
|
'hoi4.unit_inspect': '{"kind":"oob","id":"GER_1936"} or {"kind":"variant","audit":true}',
|
|
20
20
|
'hoi4.asset_inspect': '{"kind":"sprite","id":"GFX_my_icon"} or {"kind":"flag","audit":true}',
|
|
21
|
+
'hoi4.skill': '{} or {"name":"hoi4-events"}',
|
|
21
22
|
'hoi4.event_inspect': '{"mode":"lint","selector":"chaosx.nr14"} or {"mode":"trace","selector":"chaosx.nr14.1","direction":"downstream"}',
|
|
22
23
|
'hoi4.event_render': '{"view":"overview","selector":"chaosx.nr14"}',
|
|
23
24
|
'hoi4.focus_inspect': '{"treeId":"my_focus_tree"}',
|
|
@@ -83,6 +83,18 @@ const packageOutputSchema = strictOperationResultSchema(z
|
|
|
83
83
|
absent: nonNegativeIntegerSchema,
|
|
84
84
|
shadowed: nonNegativeIntegerSchema,
|
|
85
85
|
unresolved: nonNegativeIntegerSchema,
|
|
86
|
+
notPresent: z
|
|
87
|
+
.array(z
|
|
88
|
+
.object({
|
|
89
|
+
category: z.string().max(64),
|
|
90
|
+
id: z.string().max(1024),
|
|
91
|
+
status: z.enum(['absent', 'shadowed', 'unresolved']),
|
|
92
|
+
reason: z.string().max(256).optional(),
|
|
93
|
+
path: z.string().max(1024).optional(),
|
|
94
|
+
})
|
|
95
|
+
.strict())
|
|
96
|
+
.max(32),
|
|
97
|
+
notPresentTruncated: z.boolean(),
|
|
86
98
|
})
|
|
87
99
|
.strict());
|
|
88
100
|
const scenarioOutputSchema = strictOperationResultSchema(z
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { errorResult, strictOperationResultSchema } from '../../core/operation-result.js';
|
|
2
2
|
import { ReferenceToolService } from '../../reference/operations.js';
|
|
3
|
-
import { referenceContextRequestSchema, referenceReadRequestSchema, referenceSearchRequestSchema, sourceLookupRequestSchema,
|
|
3
|
+
import { referenceContextRequestSchema, referenceReadRequestSchema, referenceSearchRequestSchema, sourceLookupRequestSchema, referenceContextToolDataSchema, referenceReadDataSchema, referenceSearchToolDataSchema, sourceLookupDataSchema, } from '../../schemas/reference.js';
|
|
4
4
|
import { localisationInspectDataSchema, localisationInspectRequestSchema, } from '../../schemas/localisation.js';
|
|
5
5
|
import { systemInspectDataSchema, systemInspectRequestSchema, unitInspectDataSchema, unitInspectRequestSchema, assetInspectDataSchema, assetInspectRequestSchema, } from '../../schemas/system.js';
|
|
6
6
|
import { ideaInspectDataSchema, ideaInspectRequestSchema } from '../../schemas/ideas.js';
|
|
7
7
|
import { errorLogDataSchema, errorLogRequestSchema, modIndexDataSchema, modIndexRequestSchema, } from '../../schemas/mod-tools.js';
|
|
8
8
|
import { scriptValidateDataSchema, scriptValidateRequestSchema, } from '../../schemas/script-validation.js';
|
|
9
|
+
import { skillDataSchema, skillRequestSchema } from '../../schemas/skill.js';
|
|
9
10
|
const readOnly = {
|
|
10
11
|
readOnlyHint: true,
|
|
11
12
|
destructiveHint: false,
|
|
@@ -18,7 +19,7 @@ export const referenceTools = [
|
|
|
18
19
|
title: 'Find a modding rule',
|
|
19
20
|
description: 'Find the right modding rule in the offline wiki and installed game docs using ordinary words or script names. Each hit includes its file, lines, revision and answering line. Example: {"query":"add_timed_idea"}. Returns 6 hits by default (up to 12); read one with hoi4.reference_read using its id and revision.',
|
|
20
21
|
inputSchema: referenceSearchRequestSchema,
|
|
21
|
-
outputSchema: strictOperationResultSchema(
|
|
22
|
+
outputSchema: strictOperationResultSchema(referenceSearchToolDataSchema),
|
|
22
23
|
annotations: readOnly,
|
|
23
24
|
},
|
|
24
25
|
{
|
|
@@ -34,7 +35,7 @@ export const referenceTools = [
|
|
|
34
35
|
title: 'Find docs for a modding task',
|
|
35
36
|
description: 'Find documentation for the content you are building: events, decisions, ideas, focuses, technology, GUI, maps, localisation or AI. Example: {"surface":"event","question":"fire an event after a delay"}. Returns up to 16 short sections; read more with hoi4.reference_read.',
|
|
36
37
|
inputSchema: referenceContextRequestSchema,
|
|
37
|
-
outputSchema: strictOperationResultSchema(
|
|
38
|
+
outputSchema: strictOperationResultSchema(referenceContextToolDataSchema),
|
|
38
39
|
annotations: readOnly,
|
|
39
40
|
},
|
|
40
41
|
{
|
|
@@ -109,6 +110,14 @@ export const referenceTools = [
|
|
|
109
110
|
outputSchema: strictOperationResultSchema(assetInspectDataSchema),
|
|
110
111
|
annotations: readOnly,
|
|
111
112
|
},
|
|
113
|
+
{
|
|
114
|
+
name: 'hoi4.skill',
|
|
115
|
+
title: "Read the mod's modding skills",
|
|
116
|
+
description: 'List the modding skills installed in the mod, or load one by name, at the kit version HOI4 Mod Setup pinned, with its hash. A file edited since Setup installed it is refused unless acceptLocalEdits. Example: {"name":"hoi4-events"}. Returns up to 20,000 bytes of text; continue from nextOffset.',
|
|
117
|
+
inputSchema: skillRequestSchema,
|
|
118
|
+
outputSchema: strictOperationResultSchema(skillDataSchema),
|
|
119
|
+
annotations: readOnly,
|
|
120
|
+
},
|
|
112
121
|
];
|
|
113
122
|
export function registerReferenceTools(server, engine, context) {
|
|
114
123
|
const service = new ReferenceToolService(engine);
|
|
@@ -201,6 +201,7 @@ export class PackageAnalyzer {
|
|
|
201
201
|
sourceHashes: evidence.sourceHashes,
|
|
202
202
|
metadata: { beforeRevision: snapshot.revision, sourceInventory: evidence.inventory },
|
|
203
203
|
}, 'Revision-pinned package connection inventory', input.signal);
|
|
204
|
+
const missing = results.filter(({ status }) => status !== 'present');
|
|
204
205
|
const result = emptyServiceResult(input.workspaceId, {
|
|
205
206
|
sourceRevision: snapshot.revision,
|
|
206
207
|
reportHash,
|
|
@@ -210,10 +211,22 @@ export class PackageAnalyzer {
|
|
|
210
211
|
absent: results.filter(({ status }) => status === 'absent').length,
|
|
211
212
|
shadowed: results.filter(({ status }) => status === 'shadowed').length,
|
|
212
213
|
unresolved: results.filter(({ status }) => status === 'unresolved').length,
|
|
214
|
+
// The answer is which items are missing; name them inline, not only in the report (#66).
|
|
215
|
+
notPresent: missing.slice(0, 32).map(({ category, id, status, reason, path }) => ({
|
|
216
|
+
category,
|
|
217
|
+
id: id.slice(0, 1024),
|
|
218
|
+
status: status,
|
|
219
|
+
...(reason === undefined ? {} : { reason: reason.slice(0, 256) }),
|
|
220
|
+
...(path === undefined ? {} : { path: path.slice(0, 1024) }),
|
|
221
|
+
})),
|
|
222
|
+
notPresentTruncated: missing.length > 32,
|
|
213
223
|
});
|
|
214
224
|
result.code = report.complete ? 'PACKAGE_CHECK_PASSED' : 'PACKAGE_CHECK_INCOMPLETE';
|
|
215
225
|
result.artifacts = [publicArtifactLink(artifact)];
|
|
216
|
-
|
|
226
|
+
// The files that hold the checked items, not the first files of the workspace (#66).
|
|
227
|
+
setInlineFilesScanned(result, [
|
|
228
|
+
...new Set(results.flatMap(({ path }) => (path === undefined ? [] : [path]))),
|
|
229
|
+
]);
|
|
217
230
|
result.validation = {
|
|
218
231
|
passed: report.complete,
|
|
219
232
|
checks: [
|
|
@@ -10,6 +10,8 @@ import { scriptValidateDataSchema, scriptValidateRequestSchema, } from '../schem
|
|
|
10
10
|
import { identifierArgumentCommands, validateScript, } from './script-validation.js';
|
|
11
11
|
import { modChangedAfter, readErrorLog } from './error-log.js';
|
|
12
12
|
import { modIndex } from './mod-index.js';
|
|
13
|
+
import { listSkills, loadSkill } from './skills.js';
|
|
14
|
+
import { skillDataSchema, skillRequestSchema } from '../schemas/skill.js';
|
|
13
15
|
import { inspectLocalisation } from '../localisation/inspect.js';
|
|
14
16
|
import { inspectIdeas } from '../ideas/inspect.js';
|
|
15
17
|
import { ideaInspectDataSchema, ideaInspectRequestSchema } from '../schemas/ideas.js';
|
|
@@ -59,6 +61,7 @@ const schemas = {
|
|
|
59
61
|
'hoi4.system_inspect': systemInspectRequestSchema,
|
|
60
62
|
'hoi4.unit_inspect': unitInspectRequestSchema,
|
|
61
63
|
'hoi4.asset_inspect': assetInspectRequestSchema,
|
|
64
|
+
'hoi4.skill': skillRequestSchema,
|
|
62
65
|
};
|
|
63
66
|
/** Asset findings players would not notice: uneven frames, sprites the game fills itself, hidden pictures and flags one pixel off. */
|
|
64
67
|
const ASSET_INFORMATION = new Set([
|
|
@@ -88,11 +91,11 @@ export class ReferenceToolService {
|
|
|
88
91
|
const workspaceId = await resolveOperationWorkspaceForSource(this.engine, context, parsed.workspaceId, name === 'hoi4.script_validate' ? scriptValidateRequestSchema.parse(parsed).path : undefined, signal);
|
|
89
92
|
const workspace = this.engine.resolver.get(workspaceId, context.principal);
|
|
90
93
|
const data = name === 'hoi4.reference_search'
|
|
91
|
-
? await this.references.
|
|
94
|
+
? await this.references.searchHits(workspace, referenceSearchRequestSchema.parse(parsed), signal)
|
|
92
95
|
: name === 'hoi4.reference_read'
|
|
93
96
|
? await this.references.read(workspace, referenceReadRequestSchema.parse(parsed), signal)
|
|
94
97
|
: name === 'hoi4.reference_context'
|
|
95
|
-
? await this.references.
|
|
98
|
+
? await this.references.contextHits(workspace, referenceContextRequestSchema.parse(parsed), signal)
|
|
96
99
|
: name === 'hoi4.error_log'
|
|
97
100
|
? await readErrorLog(workspace, errorLogRequestSchema.parse(parsed), this.engine.resolver.config().gameUserRoot, signal)
|
|
98
101
|
: name === 'hoi4.mod_index'
|
|
@@ -107,9 +110,11 @@ export class ReferenceToolService {
|
|
|
107
110
|
? await inspectAssets(workspace, assetInspectRequestSchema.parse(parsed), signal)
|
|
108
111
|
: name === 'hoi4.unit_inspect'
|
|
109
112
|
? await inspectUnits(workspace, unitInspectRequestSchema.parse(parsed), signal)
|
|
110
|
-
: name === 'hoi4.
|
|
111
|
-
? await
|
|
112
|
-
:
|
|
113
|
+
: name === 'hoi4.skill'
|
|
114
|
+
? await this.skill(workspace, skillRequestSchema.parse(parsed), signal)
|
|
115
|
+
: name === 'hoi4.localisation_inspect'
|
|
116
|
+
? await inspectLocalisation(workspace, localisationInspectRequestSchema.parse(parsed), signal)
|
|
117
|
+
: await sourceLookup(this.engine, workspaceId, sourceLookupRequestSchema.parse(parsed), context.principal, signal);
|
|
113
118
|
const result = emptyServiceResult(workspaceId, data);
|
|
114
119
|
if (name === 'hoi4.error_log') {
|
|
115
120
|
const log = errorLogDataSchema.parse(data);
|
|
@@ -149,6 +154,25 @@ export class ReferenceToolService {
|
|
|
149
154
|
],
|
|
150
155
|
};
|
|
151
156
|
}
|
|
157
|
+
if (name === 'hoi4.skill') {
|
|
158
|
+
const served = skillDataSchema.parse(data);
|
|
159
|
+
result.code = served.skill === undefined ? 'SKILLS_LISTED' : 'SKILL_LOADED';
|
|
160
|
+
// A skill that differs from the kit version the mod pins is not the shared text.
|
|
161
|
+
result.validation = {
|
|
162
|
+
passed: served.drifted === 0,
|
|
163
|
+
checks: [
|
|
164
|
+
{
|
|
165
|
+
id: 'skill-pinned',
|
|
166
|
+
passed: served.drifted === 0,
|
|
167
|
+
message: served.kit === null
|
|
168
|
+
? 'The mod has no HOI4 Mod Setup lock, so the skills are served unpinned'
|
|
169
|
+
: served.drifted === 0
|
|
170
|
+
? `Every served file matches kit revision ${served.kit.revision}`
|
|
171
|
+
: `${served.drifted} skills differ from kit revision ${served.kit.revision}`,
|
|
172
|
+
},
|
|
173
|
+
],
|
|
174
|
+
};
|
|
175
|
+
}
|
|
152
176
|
if (name === 'hoi4.mod_index') {
|
|
153
177
|
const index = modIndexDataSchema.parse(data);
|
|
154
178
|
result.code = index.complete ? 'MOD_INDEXED' : 'MOD_INDEXED_PARTIAL';
|
|
@@ -303,12 +327,17 @@ export class ReferenceToolService {
|
|
|
303
327
|
result.diagnostics.length > 1)
|
|
304
328
|
result.diagnostics.pop();
|
|
305
329
|
}
|
|
306
|
-
return toolResult(result);
|
|
330
|
+
return toolResult(result, { compact: true });
|
|
307
331
|
}
|
|
308
332
|
#eventPopups = new Map();
|
|
309
333
|
/** The latest player-text context of each workspace, keyed by its source files' hashes. */
|
|
310
334
|
#playerText = new Map();
|
|
311
335
|
/** File mode reads the scanned file and the mod's scripted helper names from one scan. */
|
|
336
|
+
async skill(workspace, request, signal) {
|
|
337
|
+
return request.name === undefined
|
|
338
|
+
? listSkills(workspace, signal)
|
|
339
|
+
: loadSkill(workspace, { ...request, name: request.name }, signal);
|
|
340
|
+
}
|
|
312
341
|
async validateScript(workspaceId, workspace, request, principal, signal) {
|
|
313
342
|
// Every file check of the supported families shares one scan, so checking files across
|
|
314
343
|
// folders reuses one snapshot and its incremental index; other folders add their own.
|