hoi4-agent-tools 4.10.0 → 4.11.1
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 +16 -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/map/gameplay/crossings.js +55 -16
- package/dist/hoi4_agent_tools/map/partition-fields.js +14 -0
- package/dist/hoi4_agent_tools/map/partition-geography.js +55 -6
- package/dist/hoi4_agent_tools/map/partition-provinces.js +105 -24
- package/dist/hoi4_agent_tools/map/relief/hydrology.js +9 -0
- package/dist/hoi4_agent_tools/map/relief/macro-relief.js +21 -1
- package/dist/hoi4_agent_tools/map/relief/painted-relief.js +8 -5
- package/dist/hoi4_agent_tools/map/world-provinces.js +36 -19
- 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/map.md +16 -16
- 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
|
@@ -33,6 +33,13 @@ export function peakHeight(peak, scale) {
|
|
|
33
33
|
export function plateauHeight(height, scale) {
|
|
34
34
|
return Math.min(HEIGHT_CEILING, LAND_FLOOR + PEAK_SPAN * height * scale);
|
|
35
35
|
}
|
|
36
|
+
/** Lower `height` toward a pass cap: unchanged outside a corridor or where it is already lower. */
|
|
37
|
+
export function cappedAtPass(caps, cell, height) {
|
|
38
|
+
if (caps === undefined)
|
|
39
|
+
return height;
|
|
40
|
+
const level = caps.level[cell];
|
|
41
|
+
return level < height ? height + (level - height) * caps.weight[cell] : height;
|
|
42
|
+
}
|
|
36
43
|
/** Kind of each macro cell: the majority of its four pixels, with lake before land before sea. */
|
|
37
44
|
function downsampleKind(kind, width, height) {
|
|
38
45
|
const mw = width / 2;
|
|
@@ -487,6 +494,7 @@ function applyVolcano(volcano, base, kind, mw, mh, scale, seed, targets) {
|
|
|
487
494
|
* sides wherever it lies.
|
|
488
495
|
*/
|
|
489
496
|
function carvePassSaddles(geography, tables, heights, kind, mw, mh) {
|
|
497
|
+
let caps;
|
|
490
498
|
const aspect = mh / mw;
|
|
491
499
|
// The line of every range in cell units, one point per table entry, with its footprint.
|
|
492
500
|
const lines = new Map();
|
|
@@ -579,10 +587,21 @@ function carvePassSaddles(geography, tables, heights, kind, mw, mh) {
|
|
|
579
587
|
const weight = nearestDistance <= corridor ? 1 : 1 - smoothstep((nearestDistance - corridor) / edge);
|
|
580
588
|
if (cap < heights[cell])
|
|
581
589
|
heights[cell] = heights[cell] + (cap - heights[cell]) * weight;
|
|
590
|
+
// Kept for the stages that raise the relief afterwards (painted relief), so they
|
|
591
|
+
// cannot fill the saddle back up to the crest.
|
|
592
|
+
caps ??= {
|
|
593
|
+
level: new Float32Array(mw * mh).fill(Infinity),
|
|
594
|
+
weight: new Float32Array(mw * mh),
|
|
595
|
+
};
|
|
596
|
+
if (cap < caps.level[cell])
|
|
597
|
+
caps.level[cell] = cap;
|
|
598
|
+
if (weight > caps.weight[cell])
|
|
599
|
+
caps.weight[cell] = weight;
|
|
582
600
|
}
|
|
583
601
|
}
|
|
584
602
|
}
|
|
585
603
|
void aspect;
|
|
604
|
+
return caps;
|
|
586
605
|
}
|
|
587
606
|
/** Build the macro relief of the model. */
|
|
588
607
|
export function synthesizeMacroRelief(input) {
|
|
@@ -625,7 +644,7 @@ export function synthesizeMacroRelief(input) {
|
|
|
625
644
|
heights[index] = Math.min(HEIGHT_CEILING, heights[index] + targets.delta[index]);
|
|
626
645
|
footprint[index] = Math.max(footprint[index], targets.footprint[index]);
|
|
627
646
|
}
|
|
628
|
-
carvePassSaddles(geography, ranges, heights, kind, mw, mh);
|
|
647
|
+
const passCap = carvePassSaddles(geography, ranges, heights, kind, mw, mh);
|
|
629
648
|
return {
|
|
630
649
|
width: mw,
|
|
631
650
|
height: mh,
|
|
@@ -636,6 +655,7 @@ export function synthesizeMacroRelief(input) {
|
|
|
636
655
|
snowLine: targets.snow,
|
|
637
656
|
crest: targets.crest,
|
|
638
657
|
barrier: targets.barrier,
|
|
658
|
+
...(passCap === undefined ? {} : { passCap }),
|
|
639
659
|
ranges,
|
|
640
660
|
scale,
|
|
641
661
|
};
|
|
@@ -11,12 +11,14 @@
|
|
|
11
11
|
* - a cell keeps the model's height where that is higher, and every other cell keeps the model's
|
|
12
12
|
* broad elevation untouched;
|
|
13
13
|
* - impassable land (ZR-28) rises toward `impassablePeak`, the highest ground of the map;
|
|
14
|
+
* - a declared pass keeps the saddle the macro relief carved for it: the raise is capped there
|
|
15
|
+
* as the carving capped the model's own heights, so a painted range never fills its pass;
|
|
14
16
|
* - painted mountains and volcanoes get permanent snow above a height that falls from the
|
|
15
17
|
* equator toward the poles, and weight the full-resolution detail as model ranges do.
|
|
16
18
|
*/
|
|
17
19
|
import { LAND } from './grid.js';
|
|
18
20
|
import { fractal2, ridged2, smoothstep } from './math.js';
|
|
19
|
-
import { HEIGHT_CEILING, PEAK_BASE, PEAK_SPAN } from './macro-relief.js';
|
|
21
|
+
import { cappedAtPass, HEIGHT_CEILING, PEAK_BASE, PEAK_SPAN, } from './macro-relief.js';
|
|
20
22
|
/** Reference terrain codes the stage reads (`REFERENCE_TERRAIN` of the reference interpretation). */
|
|
21
23
|
export const PAINTED_MOUNTAIN = 3;
|
|
22
24
|
export const PAINTED_VOLCANO = 5;
|
|
@@ -112,11 +114,12 @@ export function applyPaintedRelief(target, input) {
|
|
|
112
114
|
const goal = Math.min(HEIGHT_CEILING, Math.max(PEAK_BASE + lift(input.settings.mountainPeak) * m * ridges, PEAK_BASE + lift(input.settings.hillsPeak) * h * swell, PEAK_BASE + lift(input.settings.volcanoPeak) * v,
|
|
113
115
|
// Impassable land keeps its crests but never sinks below most of its peak.
|
|
114
116
|
PEAK_BASE + lift(input.settings.impassablePeak) * i * (0.8 + 0.2 * ridges)));
|
|
115
|
-
|
|
116
|
-
|
|
117
|
+
const raised = cappedAtPass(target.passCap, cell, goal);
|
|
118
|
+
if (raised > target.heights[cell]) {
|
|
119
|
+
target.heights[cell] = raised;
|
|
117
120
|
raisedCells += 1;
|
|
118
|
-
if (
|
|
119
|
-
highest =
|
|
121
|
+
if (raised > highest)
|
|
122
|
+
highest = raised;
|
|
120
123
|
}
|
|
121
124
|
const weight = Math.max(m, 0.6 * h, v, i);
|
|
122
125
|
if (weight > target.footprint[cell])
|
|
@@ -1,4 +1,30 @@
|
|
|
1
1
|
import { ServiceError } from '../core/result.js';
|
|
2
|
+
/** True when two pixels lie on different sides of a wall line (or one on it). */
|
|
3
|
+
function acrossWall(input, p, q) {
|
|
4
|
+
const side = input.wallSide;
|
|
5
|
+
if (side === undefined)
|
|
6
|
+
return false;
|
|
7
|
+
const a = side[p];
|
|
8
|
+
const b = side[q];
|
|
9
|
+
return a !== 0 && b !== 0 && a !== b;
|
|
10
|
+
}
|
|
11
|
+
/** Repair stages, strictest first; with a wall side field every stage but a last fallback keeps to its side. */
|
|
12
|
+
function repairStages(input) {
|
|
13
|
+
const stages = [];
|
|
14
|
+
if (input.group !== undefined && input.line !== undefined)
|
|
15
|
+
stages.push({ sameGroup: true, avoidLine: true });
|
|
16
|
+
if (input.line !== undefined)
|
|
17
|
+
stages.push({ sameGroup: false, avoidLine: true });
|
|
18
|
+
if (input.group !== undefined)
|
|
19
|
+
stages.push({ sameGroup: true, avoidLine: false });
|
|
20
|
+
stages.push({ sameGroup: false, avoidLine: false });
|
|
21
|
+
if (input.wallSide === undefined)
|
|
22
|
+
return stages.map((stage) => ({ ...stage, avoidWall: false }));
|
|
23
|
+
return [
|
|
24
|
+
...stages.map((stage) => ({ ...stage, avoidWall: true })),
|
|
25
|
+
{ sameGroup: false, avoidLine: false, avoidWall: false },
|
|
26
|
+
];
|
|
27
|
+
}
|
|
2
28
|
function invalid(message) {
|
|
3
29
|
throw new ServiceError('MAP_WORLD_INVALID_PROVINCES', message);
|
|
4
30
|
}
|
|
@@ -270,15 +296,7 @@ function absorbSlivers(input, parts) {
|
|
|
270
296
|
// repeated because a previously isolated fragment may become mergeable afterwards. With groups
|
|
271
297
|
// or lines, the first stages merge inside a group and not across a line, and the last stage
|
|
272
298
|
// takes what is left.
|
|
273
|
-
const
|
|
274
|
-
if (input.group !== undefined && input.line !== undefined)
|
|
275
|
-
stages.push({ sameGroup: true, avoidLine: true });
|
|
276
|
-
if (input.line !== undefined)
|
|
277
|
-
stages.push({ sameGroup: false, avoidLine: true });
|
|
278
|
-
if (input.group !== undefined)
|
|
279
|
-
stages.push({ sameGroup: true, avoidLine: false });
|
|
280
|
-
stages.push({ sameGroup: false, avoidLine: false });
|
|
281
|
-
for (const { sameGroup, avoidLine } of stages) {
|
|
299
|
+
for (const { sameGroup, avoidLine, avoidWall } of repairStages(input)) {
|
|
282
300
|
for (let pass = 0; pass < 4; pass++) {
|
|
283
301
|
let changed = false;
|
|
284
302
|
for (let p = 0; p < parts.pixel.length; p++) {
|
|
@@ -289,6 +307,8 @@ function absorbSlivers(input, parts) {
|
|
|
289
307
|
continue;
|
|
290
308
|
if (avoidLine && (input.line[p] !== 0 || input.line[q] !== 0))
|
|
291
309
|
continue;
|
|
310
|
+
if (avoidWall && acrossWall(input, p, q))
|
|
311
|
+
continue;
|
|
292
312
|
const a = root(parts, parts.pixel[p]);
|
|
293
313
|
const b = root(parts, parts.pixel[q]);
|
|
294
314
|
if (a === b || (parts.size[a] >= 20 && parts.size[b] >= 20))
|
|
@@ -356,7 +376,7 @@ function rebalanceSlivers(input, parts) {
|
|
|
356
376
|
for (const p of cells) {
|
|
357
377
|
const x = p % width;
|
|
358
378
|
for (const q of [x > 0 ? p - 1 : -1, x + 1 < width ? p + 1 : -1, p - width, p + width]) {
|
|
359
|
-
if (q < 0 || q >= kind.length || kind[q] !== kind[p])
|
|
379
|
+
if (q < 0 || q >= kind.length || kind[q] !== kind[p] || acrossWall(input, p, q))
|
|
360
380
|
continue;
|
|
361
381
|
const donor = root(parts, parts.pixel[q]);
|
|
362
382
|
if (donor === id || parts.size[donor] <= 20 || !removable(parts, q, width, height))
|
|
@@ -387,14 +407,7 @@ function rebalanceSlivers(input, parts) {
|
|
|
387
407
|
}
|
|
388
408
|
function repairCrossings(input, parts) {
|
|
389
409
|
const { width, height, kind } = input;
|
|
390
|
-
const
|
|
391
|
-
if (input.group !== undefined && input.line !== undefined)
|
|
392
|
-
repairStages.push({ sameGroup: true, avoidLine: true });
|
|
393
|
-
if (input.line !== undefined)
|
|
394
|
-
repairStages.push({ sameGroup: false, avoidLine: true });
|
|
395
|
-
if (input.group !== undefined)
|
|
396
|
-
repairStages.push({ sameGroup: true, avoidLine: false });
|
|
397
|
-
repairStages.push({ sameGroup: false, avoidLine: false });
|
|
410
|
+
const stages = repairStages(input);
|
|
398
411
|
for (let pass = 0; pass < 12; pass++) {
|
|
399
412
|
let changed = false;
|
|
400
413
|
for (let y = 0; y + 1 < height; y++) {
|
|
@@ -414,10 +427,12 @@ function repairCrossings(input, parts) {
|
|
|
414
427
|
let repaired = false;
|
|
415
428
|
// Whole-cell unions cannot introduce crossings or disconnected provinces. With groups or
|
|
416
429
|
// lines, the repairs inside one group and not across a line come first.
|
|
417
|
-
for (const { sameGroup, avoidLine } of
|
|
430
|
+
for (const { sameGroup, avoidLine, avoidWall } of stages) {
|
|
418
431
|
for (const [i, j] of edges) {
|
|
419
432
|
if (avoidLine && (input.line[corners[i]] !== 0 || input.line[corners[j]] !== 0))
|
|
420
433
|
continue;
|
|
434
|
+
if (avoidWall && acrossWall(input, corners[i], corners[j]))
|
|
435
|
+
continue;
|
|
421
436
|
if (merge(parts, ids[i], ids[j], width, height, sameGroup)) {
|
|
422
437
|
repaired = true;
|
|
423
438
|
break;
|
|
@@ -433,6 +448,8 @@ function repairCrossings(input, parts) {
|
|
|
433
448
|
const q = corners[j];
|
|
434
449
|
if (avoidLine && (input.line[p] !== 0 || input.line[q] !== 0))
|
|
435
450
|
continue;
|
|
451
|
+
if (avoidWall && acrossWall(input, p, q))
|
|
452
|
+
continue;
|
|
436
453
|
if (kind[p] !== kind[q] || !removable(parts, p, width, height))
|
|
437
454
|
continue;
|
|
438
455
|
if (sameGroup &&
|
|
@@ -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.
|