hoi4-agent-tools 1.1.0 → 1.2.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/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
+ Start with `hoi4.mods` to obtain the workspace ID, then use the three event tools as needed.
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/setup.md CHANGED
@@ -5,11 +5,11 @@ HOI4 Agent Tools requires Node.js 22 or 24.
5
5
  ## Install and initialize
6
6
 
7
7
  ```bash
8
- npm install --global hoi4-agent-tools@1.1.0
8
+ npm install --global hoi4-agent-tools@1.2.0
9
9
  hoi4-agent-tools-setup --init
10
10
  ```
11
11
 
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.
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 available through the focus, GUI, map, and read-only event tools without per-mod setup. The game root supplies vanilla references.
13
13
 
14
14
  After connecting the MCP server, call `hoi4.mods` to confirm which mods are available.
15
15
 
@@ -22,7 +22,7 @@ hoi4-agent-tools-setup --init --mod-root /projects/hoi4-mods --mod-root /worksho
22
22
  ```
23
23
 
24
24
  - `--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.
25
+ - `--game-root PATH` selects the installed game folder used for vanilla references.
26
26
  - `--workspace-storage-root PATH` selects where indexes, renders, and other generated workspace files are stored.
27
27
  - `--config PATH` writes or reads a config at a custom path instead of the default per-user location.
28
28
 
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": "1.2.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": "1.2.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": "1.2.0",
17
17
  "transport": {
18
18
  "type": "stdio"
19
19
  }