hoi4-agent-tools 1.1.0 → 2.0.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +21 -18
  3. package/dist/hoi4_agent_tools/core/engine.js +12 -0
  4. package/dist/hoi4_agent_tools/core/workspace.js +31 -3
  5. package/dist/hoi4_agent_tools/event/algorithms.js +208 -0
  6. package/dist/hoi4_agent_tools/event/artifact-validation.js +572 -0
  7. package/dist/hoi4_agent_tools/event/compare.js +413 -0
  8. package/dist/hoi4_agent_tools/event/graph.js +1586 -0
  9. package/dist/hoi4_agent_tools/event/index.js +10 -0
  10. package/dist/hoi4_agent_tools/event/layout.js +218 -0
  11. package/dist/hoi4_agent_tools/event/limits.js +41 -0
  12. package/dist/hoi4_agent_tools/event/model.js +2 -0
  13. package/dist/hoi4_agent_tools/event/queries.js +643 -0
  14. package/dist/hoi4_agent_tools/event/render.js +443 -0
  15. package/dist/hoi4_agent_tools/event/scc.js +72 -0
  16. package/dist/hoi4_agent_tools/event/service.js +1147 -0
  17. package/dist/hoi4_agent_tools/event/source-analysis.js +1458 -0
  18. package/dist/hoi4_agent_tools/focus/native-effects.js +3 -1
  19. package/dist/hoi4_agent_tools/gui/layout.js +122 -27
  20. package/dist/hoi4_agent_tools/gui/renderer.js +16 -0
  21. package/dist/hoi4_agent_tools/mcp/resources/register.js +1 -1
  22. package/dist/hoi4_agent_tools/mcp/server/create.js +4 -2
  23. package/dist/hoi4_agent_tools/mcp/server/result.js +8 -14
  24. package/dist/hoi4_agent_tools/mcp/tools/event.js +459 -0
  25. package/dist/hoi4_agent_tools/mcp/tools/focus.js +6 -3
  26. package/dist/hoi4_agent_tools/mcp/tools/gui.js +6 -3
  27. package/dist/hoi4_agent_tools/mcp/tools/map.js +6 -3
  28. package/dist/hoi4_agent_tools/runtime.js +112 -2
  29. package/dist/hoi4_agent_tools/schemas/common.js +5 -1
  30. package/dist/hoi4_agent_tools/schemas/event.js +95 -0
  31. package/dist/hoi4_agent_tools/version.js +1 -1
  32. package/docs/README.md +1 -0
  33. package/docs/development.md +10 -0
  34. package/docs/events.md +113 -0
  35. package/docs/focus.md +1 -1
  36. package/docs/gui.md +3 -1
  37. package/docs/map.md +1 -1
  38. package/docs/setup.md +10 -7
  39. package/package.json +7 -3
  40. package/server.json +3 -3
  41. package/dist/hoi4_agent_tools/mcp/tools/mods.js +0 -54
@@ -1,5 +1,9 @@
1
1
  import { z } from 'zod/v4';
2
- export const workspaceIdSchema = z.string().regex(/^[a-z][a-z0-9_-]{0,63}$/u);
2
+ /** Optional for local agents: omitted means the mod containing the MCP cwd. */
3
+ export const workspaceIdSchema = z
4
+ .string()
5
+ .regex(/^[a-z][a-z0-9_-]{0,63}$/u)
6
+ .default('current');
3
7
  const diagnosticCodeSchema = z.string().min(1).max(256);
4
8
  const diagnosticMessageSchema = z.string().max(4096);
5
9
  const sourceDisplayPathSchema = z.string().min(1).max(4096);
@@ -0,0 +1,95 @@
1
+ import { z } from 'zod/v4';
2
+ import { SOURCE_MAX_BYTES } from '../core/source/index.js';
3
+ import { workspaceRelativePathSchema } from './common.js';
4
+ const eventIdSchema = z.string().min(1).max(256);
5
+ const eventSourcePathSchema = z.string().min(1).max(1024);
6
+ const eventNodeIdSchema = z.string().min(1).max(1024);
7
+ const eventSha256Schema = z.string().regex(/^[a-f0-9]{64}$/u);
8
+ export const eventInspectModeSchema = z.enum([
9
+ 'scan',
10
+ 'roots',
11
+ 'trace',
12
+ 'explain_path',
13
+ 'state_flow',
14
+ 'lint',
15
+ 'impact',
16
+ ]);
17
+ export const eventDirectionSchema = z.enum(['upstream', 'downstream', 'both']);
18
+ export const eventRenderViewSchema = z.enum([
19
+ 'overview',
20
+ 'neighborhood',
21
+ 'options',
22
+ 'entries',
23
+ 'reachability',
24
+ 'timing',
25
+ 'state',
26
+ 'targets',
27
+ 'scope',
28
+ 'terminals',
29
+ 'unresolved',
30
+ ]);
31
+ export const eventFeatureManifestSchema = z
32
+ .object({
33
+ id: z.string().min(1).max(128).optional(),
34
+ eventIds: z.array(eventIdSchema).max(2_000).optional(),
35
+ namespaces: z.array(z.string().min(1).max(256)).max(500).optional(),
36
+ sourcePaths: z.array(eventSourcePathSchema).max(2_000).optional(),
37
+ nodeIds: z.array(eventNodeIdSchema).max(5_000).optional(),
38
+ })
39
+ .strict();
40
+ export const eventSelectorSchema = z.discriminatedUnion('kind', [
41
+ z.object({ kind: z.literal('event'), eventId: eventIdSchema }).strict(),
42
+ z.object({ kind: z.literal('namespace'), namespace: z.string().min(1).max(256) }).strict(),
43
+ z.object({ kind: z.literal('file'), sourcePath: eventSourcePathSchema }).strict(),
44
+ z
45
+ .object({
46
+ kind: z.literal('source'),
47
+ sourcePath: eventSourcePathSchema,
48
+ line: z.number().int().positive(),
49
+ column: z.number().int().positive().optional(),
50
+ })
51
+ .strict(),
52
+ z.object({ kind: z.literal('node'), nodeId: eventNodeIdSchema }).strict(),
53
+ z.object({ kind: z.literal('manifest'), manifest: eventFeatureManifestSchema }).strict(),
54
+ ]);
55
+ export const eventStateSubjectSchema = z
56
+ .object({
57
+ kind: z.enum([
58
+ 'country_flag',
59
+ 'global_flag',
60
+ 'state_flag',
61
+ 'variable',
62
+ 'global_variable',
63
+ 'array',
64
+ 'event_target',
65
+ 'global_event_target',
66
+ 'saved_scope',
67
+ ]),
68
+ name: z.string().min(1).max(512),
69
+ })
70
+ .strict();
71
+ export const eventImpactSubjectSchema = z
72
+ .object({
73
+ kind: z.enum(['event', 'helper', 'flag', 'variable', 'array', 'event_target', 'saved_scope']),
74
+ name: z.string().min(1).max(512),
75
+ })
76
+ .strict();
77
+ export const eventGraphReferenceSchema = z
78
+ .object({
79
+ revision: eventSha256Schema.optional(),
80
+ artifactUri: z
81
+ .string()
82
+ .min(1)
83
+ .max(8_192)
84
+ .regex(/^hoi4-agent:\/\//u)
85
+ .optional(),
86
+ })
87
+ .strict()
88
+ .refine(({ revision, artifactUri }) => Number(revision !== undefined) + Number(artifactUri !== undefined) === 1, 'Provide exactly one event graph revision or artifact URI');
89
+ export const eventProposedSourceSchema = z
90
+ .object({
91
+ relativePath: workspaceRelativePathSchema,
92
+ source: z.string().max(SOURCE_MAX_BYTES).nullable(),
93
+ expectedSourceHash: eventSha256Schema.optional(),
94
+ })
95
+ .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 = '1.1.0';
3
+ export const PACKAGE_VERSION = '2.0.0';
4
4
  export const MCP_PROTOCOL_VERSION = LATEST_PROTOCOL_VERSION;
5
5
  export const CONFIG_VERSION = 1;
6
6
  export const TRANSACTION_VERSION = 1;
package/docs/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Documentation
2
2
 
3
3
  - [Setup](setup.md): install the server, configure HOI4 paths, and connect an MCP client.
4
+ - [Event chains](events.md): inspect, trace, lint, render, and compare event chains.
4
5
  - [Focus trees](focus.md): inspect, create, render, and clean national or continuous focus content.
5
6
  - [Scripted GUIs](gui.md): inspect linked UI source, render states, and create or repair GUIs.
6
7
  - [Maps](map.md): inspect and edit provinces, states, regions, adjacency, supply, and railways.
@@ -19,4 +19,14 @@ npm run inspector
19
19
 
20
20
  Keep changes focused and include tests for behavior changes. CI fixtures must be synthetic and project-owned; never commit installed-game or third-party-mod content. Public tool or schema changes require compatibility review and a versioned release.
21
21
 
22
+ The event-chain acceptance fixture contains more than 300 project-owned event definitions and exercises routes, options, timing, state flow, scope changes, unresolved dynamic calls, rendering, and comparison. Local opt-in tests can also read an installed game and an external mod without copying their sources:
23
+
24
+ ```bash
25
+ HOI4_GAME_ROOT="/games/Hearts of Iron IV" \
26
+ HOI4_EXTERNAL_MOD_ROOT="/projects/hoi4-mod" \
27
+ npm run test:local
28
+ ```
29
+
30
+ Add `HOI4_DEPENDENCY_ROOTS` as the platform path-delimited list when the external mod has dependencies. Local tests remain read-only.
31
+
22
32
  See the package [Security Policy](../SECURITY.md) for private vulnerability reporting.
package/docs/events.md ADDED
@@ -0,0 +1,113 @@
1
+ # Event chains
2
+
3
+ The Event Chain Viewer analyzes event definitions and call sites across the active mod, configured dependencies, and vanilla sources. It is read-only: it does not rewrite event files or simulate the game.
4
+
5
+ Use the three event tools directly; omit `workspaceId` when the MCP working directory is inside the target mod.
6
+
7
+ ## Inspect
8
+
9
+ `hoi4.event_inspect` provides seven focused modes:
10
+
11
+ - `scan`: inventory event definitions, namespaces, call sites, and unresolved references.
12
+ - `roots`: find likely entry points and explain why they are roots.
13
+ - `trace`: follow bounded incoming or outgoing routes from an event.
14
+ - `explain_path`: explain a selected route edge by edge with exact source locations.
15
+ - `state_flow`: report flags, variables, targets, scopes, and other tracked state read or changed along a route.
16
+ - `lint`: find missing targets, unreachable events, suspicious cycles, conflicting definitions, invalid timing, and unresolved dynamic calls.
17
+ - `impact`: identify callers, descendants, state dependencies, and files affected by a proposed event change.
18
+
19
+ Use narrow identifiers, direction, and depth limits when the task concerns one chain. The compact response summarizes the result; complete graphs and diagnostics are returned as linked resources.
20
+
21
+ Selectors use one of these forms:
22
+
23
+ ```json
24
+ { "kind": "event", "eventId": "namespace.1" }
25
+ { "kind": "namespace", "namespace": "namespace" }
26
+ { "kind": "file", "sourcePath": "events/example.txt" }
27
+ { "kind": "source", "sourcePath": "events/example.txt", "line": 40 }
28
+ { "kind": "node", "nodeId": "event:namespace.1" }
29
+ { "kind": "manifest", "manifest": { "eventIds": ["namespace.1", "namespace.2"] } }
30
+ ```
31
+
32
+ `trace` uses `selector`; `explain_path` uses `from` and `to`; and `state_flow` may add a `stateSubject` object with `kind` and `name`. Allowed state kinds are `country_flag`, `global_flag`, `state_flag`, `variable`, `global_variable`, `array`, `event_target`, `global_event_target`, and `saved_scope`.
33
+
34
+ `impact` requires an `impactSubject` object with `kind` and `name`. Allowed impact kinds are `event`, `helper`, `flag`, `variable`, `array`, `event_target`, and `saved_scope`. Set `refresh: true` after source changes when a prior graph may be cached.
35
+
36
+ Example `hoi4.event_inspect` arguments:
37
+
38
+ ```json
39
+ {
40
+ "workspaceId": "my-mod",
41
+ "mode": "trace",
42
+ "selector": { "kind": "event", "eventId": "namespace.1" },
43
+ "direction": "downstream",
44
+ "maxDepth": 8,
45
+ "maxNodes": 500,
46
+ "maxEdges": 2000,
47
+ "expandHelpers": false,
48
+ "refresh": false
49
+ }
50
+ ```
51
+
52
+ ## Render
53
+
54
+ `hoi4.event_render` produces deterministic, source-linked views of a chain. The exact `view` values are `overview`, `neighborhood`, `options`, `entries`, `reachability`, `timing`, `state`, `targets`, `scope`, `terminals`, and `unresolved`. JSON is the authoritative graph; SVG and PNG provide visual review, with HTML available for bundled navigation when requested.
55
+
56
+ Large overview requests return a compact overview plus bounded branch JSON/SVG/PNG resources and a coverage manifest. The manifest indexes every generated data artifact by canonical MCP resource URI, including artifacts omitted from the compact tool response. Follow those links instead of asking the agent to reason from one unreadable all-node image.
57
+
58
+ Dynamic and meta-generated targets that cannot be resolved statically remain explicit unresolved edges. The renderer never invents a destination.
59
+
60
+ Example `hoi4.event_render` arguments:
61
+
62
+ ```json
63
+ {
64
+ "workspaceId": "my-mod",
65
+ "view": "neighborhood",
66
+ "selector": { "kind": "event", "eventId": "namespace.1" },
67
+ "direction": "both",
68
+ "maxDepth": 4,
69
+ "maxNodes": 120,
70
+ "expandHelpers": false,
71
+ "includeHtml": false,
72
+ "refresh": false
73
+ }
74
+ ```
75
+
76
+ ## Compare
77
+
78
+ `hoi4.event_compare` compares whole workspace event graphs; it does not accept a chain selector. `before` and `after` each accept exactly one graph reference: `{ "revision": "<sha256>" }` or `{ "artifactUri": "hoi4-agent://..." }`. If no reference or overlay is supplied, the tool compares the previous cached revision with a fresh scan of the current source and reports an error when no prior revision is available. Comparisons refresh current source by default so normal agent file edits are detected; set `refresh: false` only when intentionally comparing cached graphs.
79
+
80
+ Alternatively, compare the current graph with `proposedSources`, an in-memory list of `{ relativePath, source, expectedSourceHash? }` overlays. Set `source` to a string to add or replace source, or to `null` to delete an existing mod source. `after` and `proposedSources` are mutually exclusive. Proposed sources are analyzed without being written. The result reports added, removed, and changed definitions, edges, options, state operations, diagnostics, and route reachability.
81
+
82
+ Example `hoi4.event_compare` arguments:
83
+
84
+ ```json
85
+ {
86
+ "workspaceId": "my-mod",
87
+ "proposedSources": [
88
+ {
89
+ "relativePath": "events/example.txt",
90
+ "source": "add_namespace = namespace\ncountry_event = { id = namespace.1 }\n"
91
+ },
92
+ {
93
+ "relativePath": "events/obsolete.txt",
94
+ "source": null
95
+ }
96
+ ],
97
+ "render": true,
98
+ "maxRenderNodes": 120,
99
+ "refresh": true
100
+ }
101
+ ```
102
+
103
+ ## Agent workflow
104
+
105
+ A coding agent can combine the viewer with repository instructions, skills, and other tools:
106
+
107
+ 1. call `hoi4.event_inspect` with `scan` or `roots` to locate the chain;
108
+ 2. use `trace`, `explain_path`, `state_flow`, or `impact` for the current task;
109
+ 3. read linked JSON evidence only when the compact summary is insufficient;
110
+ 4. edit event source with the agent's normal file-editing workflow;
111
+ 5. call `hoi4.event_compare`, `lint`, and `hoi4.event_render` to review the result; comparison refreshes the edited source by default.
112
+
113
+ Static analysis cannot prove runtime conditions, random outcomes, delayed scheduling, or arbitrary meta-generated text. Those limits are reported in diagnostics and artifacts rather than hidden or guessed. The server never launches or captures Hearts of Iron IV.
package/docs/focus.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Focus trees
2
2
 
3
- Use `hoi4.focus_inspect`, `hoi4.focus_render`, and `hoi4.focus_rewrite` for national focus trees and continuous focus palettes. Start with `hoi4.mods` when the mod ID is not known.
3
+ Use `hoi4.focus_inspect`, `hoi4.focus_render`, and `hoi4.focus_rewrite` for national focus trees and continuous focus palettes. Omit `workspaceId` when the MCP working directory is inside the target mod.
4
4
 
5
5
  ## Create a tree
6
6
 
package/docs/gui.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Scripted GUIs
2
2
 
3
- Use `hoi4.gui_inspect`, `hoi4.gui_render`, and `hoi4.gui_rewrite` for `.gui`, `.gfx`, `common/scripted_guis`, localisation, sprites, fonts, and linked decision entry points. Start with `hoi4.mods` when the mod ID is not known.
3
+ Use `hoi4.gui_inspect`, `hoi4.gui_render`, and `hoi4.gui_rewrite` for `.gui`, `.gfx`, `common/scripted_guis`, localisation, sprites, fonts, and linked decision entry points. Omit `workspaceId` when the MCP working directory is inside the target mod.
4
4
 
5
5
  ## Create a GUI
6
6
 
@@ -34,4 +34,6 @@ Inspection checks missing assets and localisation, invalid sizes, overlap, clipp
34
34
 
35
35
  The renderer does not run the game engine. Each render includes a fidelity report that separates fields it models from fields it approximates, ignores, cannot resolve, or does not support. Treat that report as part of the review.
36
36
 
37
+ Unresolved runtime localisation expressions such as `[GetValue]` and `[?variable|format]` render as the compact placeholder `[X]`; provide scenario values when the exact text matters. Supported HOI4 `§` localisation colour controls are applied to preview text and `§!` restores the default colour.
38
+
37
39
  A rewrite stops if malformed or unsupported GUI script makes the requested change ambiguous. Runtime animation, masking, tiling, hardcoded controls, and dynamic values may require exact game precedents even when a useful offline preview is available.
package/docs/map.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Maps
2
2
 
3
- Use `hoi4.map_inspect`, `hoi4.map_render`, and `hoi4.map_rewrite` for provinces, states, strategic regions, adjacency, supply nodes, railways, positions, ownership, cores, claims, resources, buildings, and localisation. Start with `hoi4.mods` when the mod ID is not known.
3
+ Use `hoi4.map_inspect`, `hoi4.map_render`, and `hoi4.map_rewrite` for provinces, states, strategic regions, adjacency, supply nodes, railways, positions, ownership, cores, claims, resources, buildings, and localisation. Omit `workspaceId` when the MCP working directory is inside the target mod.
4
4
 
5
5
  ## Create or reshape map content
6
6
 
package/docs/setup.md CHANGED
@@ -2,18 +2,21 @@
2
2
 
3
3
  HOI4 Agent Tools requires Node.js 22 or 24.
4
4
 
5
- ## Install and initialize
5
+ ## Install
6
6
 
7
7
  ```bash
8
- npm install --global hoi4-agent-tools@1.1.0
9
- hoi4-agent-tools-setup --init
8
+ npm install --global hoi4-agent-tools
10
9
  ```
11
10
 
12
- The setup command discovers standard HOI4 game and mod locations, creates a separate storage folder for generated workspace data, and writes the default per-user config. Each configured mod root is a parent folder whose immediate child directories are individual mods. Every discovered mod is writable through the three rewrite tools; no per-mod write switch or approval step is required. The installed game remains reference-only.
11
+ Set the MCP process working directory to the mod being edited. The server creates its local workspace in memory, keeps generated artifacts in the per-user data directory, and starts without a config file. The installed game is detected when available for vanilla references; it is not required for source inspection or offline rendering.
13
12
 
14
- After connecting the MCP server, call `hoi4.mods` to confirm which mods are available.
13
+ When the MCP server starts with its working directory inside a mod, every focus, GUI, map, and event call uses that mod automatically. Omit `workspaceId`. Explicit `workspaceId` values remain available for configured multi-mod or remote deployments.
15
14
 
16
- ## Override discovered paths
15
+ ## Optional persistent configuration
16
+
17
+ Use `--init` only when you need several mod roots, a fixed game path, or a shared/remote process:
18
+
19
+ ### Configure explicit paths
17
20
 
18
21
  Use explicit paths when discovery is incomplete or when you want to expose more than one mod root:
19
22
 
@@ -22,7 +25,7 @@ hoi4-agent-tools-setup --init --mod-root /projects/hoi4-mods --mod-root /worksho
22
25
  ```
23
26
 
24
27
  - `--mod-root PATH` adds a parent folder containing mods. Repeat it for additional locations.
25
- - `--game-root PATH` selects the installed game folder used as a read-only reference.
28
+ - `--game-root PATH` selects the installed game folder used for vanilla references.
26
29
  - `--workspace-storage-root PATH` selects where indexes, renders, and other generated workspace files are stored.
27
30
  - `--config PATH` writes or reads a config at a custom path instead of the default per-user location.
28
31
 
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "hoi4-agent-tools",
3
3
  "mcpName": "io.github.klimPaskov/hoi4-agent-tools",
4
- "version": "1.1.0",
5
- "description": "MCP tools for coding agents to create and clean HOI4 focus trees, scripted GUIs, and maps",
4
+ "version": "2.0.0",
5
+ "description": "Analyze HOI4 event chains; create and clean focus trees, scripted GUIs, and maps with coding agents.",
6
6
  "type": "module",
7
7
  "license": "Apache-2.0",
8
8
  "author": "HOI4 Agent Tools contributors",
@@ -21,6 +21,8 @@
21
21
  "coding-agents",
22
22
  "clausewitz",
23
23
  "focus-trees",
24
+ "event-chains",
25
+ "hoi4-events",
24
26
  "scripted-gui",
25
27
  "hoi4-map"
26
28
  ],
@@ -31,6 +33,7 @@
31
33
  "dist/",
32
34
  "docs/README.md",
33
35
  "docs/setup.md",
36
+ "docs/events.md",
34
37
  "docs/focus.md",
35
38
  "docs/gui.md",
36
39
  "docs/map.md",
@@ -60,10 +63,11 @@
60
63
  "test:local": "tsx scripts/run-local-tests.ts",
61
64
  "test:coverage": "vitest run --coverage",
62
65
  "benchmark": "node --expose-gc --import tsx scripts/benchmark.ts",
63
- "fixtures:generate": "npm run fixtures:generate:focus && npm run fixtures:generate:gui && npm run fixtures:generate:map",
66
+ "fixtures:generate": "npm run fixtures:generate:focus && npm run fixtures:generate:gui && npm run fixtures:generate:map && npm run fixtures:generate:event",
64
67
  "fixtures:generate:focus": "tsx scripts/generate-fixtures.ts",
65
68
  "fixtures:generate:gui": "tsx scripts/generate-gui-fixture.ts",
66
69
  "fixtures:generate:map": "tsx scripts/generate-map-fixture.ts",
70
+ "fixtures:generate:event": "tsx scripts/generate-event-fixture.ts",
67
71
  "fixtures:check": "npm run fixtures:generate && tsx scripts/check-generated.ts fixtures",
68
72
  "schemas:generate": "tsx scripts/generate-schemas.ts",
69
73
  "schemas:check": "tsx scripts/generate-schemas.ts && tsx scripts/check-generated.ts schemas",
package/server.json CHANGED
@@ -2,8 +2,8 @@
2
2
  "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
3
  "name": "io.github.klimPaskov/hoi4-agent-tools",
4
4
  "title": "HOI4 Agent Tools",
5
- "description": "Create and clean HOI4 focus trees, scripted GUIs, and maps with coding agents.",
6
- "version": "1.1.0",
5
+ "description": "Analyze HOI4 event chains; create and clean focus trees, scripted GUIs, and maps with coding agents.",
6
+ "version": "2.0.0",
7
7
  "repository": {
8
8
  "url": "https://github.com/klimPaskov/hoi4-agent-tools",
9
9
  "source": "github"
@@ -13,7 +13,7 @@
13
13
  {
14
14
  "registryType": "npm",
15
15
  "identifier": "hoi4-agent-tools",
16
- "version": "1.1.0",
16
+ "version": "2.0.0",
17
17
  "transport": {
18
18
  "type": "stdio"
19
19
  }
@@ -1,54 +0,0 @@
1
- import { z } from 'zod/v4';
2
- import { compareCodeUnits } from '../../core/canonical.js';
3
- import { emptyServiceResult } from '../../core/result.js';
4
- import { nonNegativeIntegerSchema } from '../server/output-schemas.js';
5
- import { errorResult, strictOperationResultSchema, toolResult } from '../server/result.js';
6
- const modsOutputSchema = strictOperationResultSchema(z
7
- .object({
8
- count: nonNegativeIntegerSchema,
9
- mods: z
10
- .array(z
11
- .object({
12
- id: z.string().min(1).max(64),
13
- name: z.string().min(1).max(256),
14
- writable: z.boolean(),
15
- })
16
- .strict())
17
- .max(1_000),
18
- })
19
- .strict());
20
- export function registerModsTool(server, engine, context) {
21
- server.registerTool('hoi4.mods', {
22
- title: 'List available HOI4 mods',
23
- description: 'List configured HOI4 mod workspaces, optionally selecting one by ID.',
24
- inputSchema: z.object({ workspaceId: z.string().min(1).max(64).optional() }).strict(),
25
- outputSchema: modsOutputSchema,
26
- annotations: {
27
- readOnlyHint: true,
28
- destructiveHint: false,
29
- idempotentHint: true,
30
- openWorldHint: false,
31
- },
32
- }, ({ workspaceId }) => {
33
- try {
34
- const mods = (workspaceId === undefined
35
- ? engine.list(context.principal)
36
- : [engine.status(workspaceId, context.principal)])
37
- .filter(({ kind }) => kind === 'mod')
38
- .sort((left, right) => compareCodeUnits(left.id, right.id));
39
- const result = emptyServiceResult(workspaceId ?? '', {
40
- count: mods.length,
41
- mods: mods.map(({ id, name, writable }) => ({
42
- id,
43
- name,
44
- writable,
45
- })),
46
- });
47
- result.code = 'MODS_LISTED';
48
- return toolResult(result);
49
- }
50
- catch (error) {
51
- return errorResult(error, workspaceId ?? '');
52
- }
53
- });
54
- }