hoi4-agent-tools 4.12.0 → 4.14.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 +14 -0
- package/README.md +3 -3
- package/dist/bin/setup.js +38 -0
- package/dist/bin/stdio.js +5 -1
- package/dist/hoi4_agent_tools/core/configuration.js +16 -0
- package/dist/hoi4_agent_tools/core/domain-tools.js +4 -0
- package/dist/hoi4_agent_tools/core/engine-check.js +87 -0
- package/dist/hoi4_agent_tools/core/engine-client.js +1 -1
- package/dist/hoi4_agent_tools/core/job-operation-registration.js +2 -0
- package/dist/hoi4_agent_tools/localisation/job-operations.js +42 -0
- package/dist/hoi4_agent_tools/localisation/write-diff.js +96 -0
- package/dist/hoi4_agent_tools/localisation/write-format.js +329 -0
- package/dist/hoi4_agent_tools/localisation/write-operations.js +213 -0
- package/dist/hoi4_agent_tools/localisation/write-plan.js +557 -0
- package/dist/hoi4_agent_tools/map/gameplay/crossing-validation.js +17 -0
- package/dist/hoi4_agent_tools/map/model.js +31 -1
- package/dist/hoi4_agent_tools/map/operations.js +2 -1
- package/dist/hoi4_agent_tools/map/world-edge.js +0 -25
- package/dist/hoi4_agent_tools/map/world.js +124 -34
- package/dist/hoi4_agent_tools/mcp/server/argument-errors.js +5 -0
- package/dist/hoi4_agent_tools/mcp/server/create-modern-operations.js +8 -3
- package/dist/hoi4_agent_tools/mcp/server/create.js +5 -1
- package/dist/hoi4_agent_tools/mcp/server/request-lifecycle.js +10 -2
- package/dist/hoi4_agent_tools/mcp/server/task-tool-catalog.js +2 -0
- package/dist/hoi4_agent_tools/mcp/server/tool-profiles.js +83 -0
- package/dist/hoi4_agent_tools/mcp/tools/localisation-write.js +21 -0
- package/dist/hoi4_agent_tools/mcp/tools/reference.js +34 -0
- package/dist/hoi4_agent_tools/mcp/transports/http.js +6 -1
- package/dist/hoi4_agent_tools/reference/compat-patch.js +555 -0
- package/dist/hoi4_agent_tools/reference/compat.js +255 -0
- package/dist/hoi4_agent_tools/reference/docs-pack.js +164 -0
- package/dist/hoi4_agent_tools/reference/docs-pack.json +339 -0
- package/dist/hoi4_agent_tools/reference/documented-commands.js +26 -0
- package/dist/hoi4_agent_tools/reference/error-explain.js +235 -0
- package/dist/hoi4_agent_tools/reference/error-explanations.json +262 -0
- package/dist/hoi4_agent_tools/reference/error-log.js +30 -10
- package/dist/hoi4_agent_tools/reference/mod-health.js +255 -0
- package/dist/hoi4_agent_tools/reference/operations.js +435 -21
- package/dist/hoi4_agent_tools/reference/script-guard.js +109 -0
- package/dist/hoi4_agent_tools/reference/service.js +58 -20
- package/dist/hoi4_agent_tools/runtime.js +11 -0
- package/dist/hoi4_agent_tools/schemas/compat.js +153 -0
- package/dist/hoi4_agent_tools/schemas/localisation-write.js +154 -0
- package/dist/hoi4_agent_tools/schemas/map.js +13 -1
- package/dist/hoi4_agent_tools/schemas/modder-tools.js +191 -0
- package/dist/hoi4_agent_tools/version.js +1 -1
- package/docs/configuration.md +4 -1
- package/docs/jobs.md +2 -1
- package/docs/map.md +4 -2
- package/docs/reference.md +45 -5
- package/docs/setup.md +23 -3
- package/docs/tools.md +16 -1
- 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 +1 -1
- package/schemas/configuration.schema.json +140 -113
- 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 +170 -139
- package/schemas/mechanic-test-input.schema.json +1 -1
- package/schemas/mod-index-input.schema.json +1 -1
- package/schemas/operation-result.schema.json +1 -1
- package/schemas/package-check-input.schema.json +1 -1
- package/schemas/package-manifest.schema.json +1 -1
- package/schemas/probability-analysis-result.schema.json +1 -1
- package/schemas/probability-compare-input.schema.json +1 -1
- package/schemas/probability-evaluate-input.schema.json +1 -1
- package/schemas/probability-inspect-input.schema.json +1 -1
- package/schemas/probability-render-input.schema.json +1 -1
- package/schemas/probability-scenario-set.schema.json +1 -1
- package/schemas/probability-sequence-input.schema.json +1 -1
- package/schemas/probability-simulate-input.schema.json +1 -1
- package/schemas/probability-sweep-input.schema.json +1 -1
- package/schemas/reference-context-input.schema.json +1 -1
- package/schemas/reference-read-input.schema.json +1 -1
- package/schemas/reference-search-input.schema.json +1 -1
- package/schemas/reference-sheets.schema.json +1 -1
- package/schemas/scenario-suite.schema.json +1 -1
- package/schemas/scenario-test-input.schema.json +1 -1
- package/schemas/script-validate-input.schema.json +1 -1
- package/schemas/shared-scenario.schema.json +1 -1
- package/schemas/source-lookup-input.schema.json +1 -1
- package/server.json +2 -2
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"reviewed": "2026-11-06",
|
|
4
|
+
"explanations": [
|
|
5
|
+
{
|
|
6
|
+
"id": "invalid_trigger",
|
|
7
|
+
"category": "trigger",
|
|
8
|
+
"pattern": "^Invalid trigger '(?<name>[^']+)' in (?<file>\\S+\\.\\w+) line ?: ?(?<line>\\d+)",
|
|
9
|
+
"rule": "A trigger block (limit, trigger, allowed, available, visible and the like) accepts only triggers the game documents, scripted triggers that a loaded file defines, and scope changes.",
|
|
10
|
+
"fix": "Check `{name}` against the game's trigger documentation: correct the name, use the trigger that tests the value, or move an effect out of the trigger block.",
|
|
11
|
+
"evidence": "Message shape in the game's error.log, build 99a5ee557 (2026-10-28)"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"id": "invalid_effect",
|
|
15
|
+
"category": "effect",
|
|
16
|
+
"pattern": "^Invalid effect '(?<name>[^']+)' in (?<file>\\S+\\.\\w+) line ?: ?(?<line>\\d+)",
|
|
17
|
+
"rule": "An effect block (immediate, option, completion_reward, effect and the like) accepts only effects the game documents, scripted effects that a loaded file defines, and scope changes.",
|
|
18
|
+
"fix": "Check `{name}` against the game's effect documentation: correct the name, or define the scripted effect it was meant to call.",
|
|
19
|
+
"evidence": "Message shape in the game's error.log, build 99a5ee557 (2026-10-28)"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"id": "unknown_effect_type",
|
|
23
|
+
"category": "effect",
|
|
24
|
+
"pattern": "Unknown effect-type: (?<name>[^,\\s]+), near line: (?<line>\\d+)",
|
|
25
|
+
"rule": "The parser met `{name}` where it expects an effect, and no documented effect or loaded scripted effect has that name.",
|
|
26
|
+
"fix": "Correct `{name}` to a documented effect, or define the scripted effect in common/scripted_effects/.",
|
|
27
|
+
"evidence": "Message shape in the game's error.log, build 99a5ee557 (2026-10-28)"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"id": "unknown_trigger_type",
|
|
31
|
+
"category": "trigger",
|
|
32
|
+
"pattern": "Unknown trigger-type: (?<name>[^,\\s]+), near line: (?<line>\\d+)",
|
|
33
|
+
"rule": "The parser met `{name}` where it expects a trigger, and no documented trigger, loaded scripted trigger or scope change has that name.",
|
|
34
|
+
"fix": "Correct `{name}` to a documented trigger, or define the scripted trigger in common/scripted_triggers/. A country tag works here only if the tag exists and the block accepts a scope change.",
|
|
35
|
+
"evidence": "Message shape in the game's error.log, build 99a5ee557 (2026-10-28)"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"id": "unexpected_token",
|
|
39
|
+
"category": "syntax",
|
|
40
|
+
"pattern": "Unexpected token: (?<name>[^,\\s]+), near line: (?<line>\\d+)",
|
|
41
|
+
"rule": "Each block accepts a fixed set of keys. A key the parser does not expect is usually misspelled, placed in the wrong block, or left outside its block by a missing or extra brace.",
|
|
42
|
+
"fix": "Check that `{name}` belongs in this block, and that the braces before it are balanced. hoi4.script_validate on the file points at an unbalanced brace.",
|
|
43
|
+
"evidence": "Message shape in the game's error.log, build 99a5ee557 (2026-10-28)"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"id": "unexpected_token_in_file",
|
|
47
|
+
"category": "syntax",
|
|
48
|
+
"pattern": "unexpected token in file: \"(?<file>[^\"]+)\" near line: (?<line>\\d+)",
|
|
49
|
+
"rule": "The game could not read the file from this point on. A missing or extra brace, a missing `=` or an unclosed quote above the named line causes this, and what follows the problem is lost.",
|
|
50
|
+
"fix": "Find the unbalanced brace or quote above line {line}. hoi4.script_validate on the file reports where parsing breaks.",
|
|
51
|
+
"evidence": "Message shape in the game's error.log, build 99a5ee557 (2026-10-28)"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"id": "init_post_read_failed",
|
|
55
|
+
"category": "other",
|
|
56
|
+
"pattern": "InitPostRead failed in file: \"(?<file>[^\"]+)\" in object\\(s\\) between line\\(s\\): (?<line>\\d+) and (?<end>\\d+)",
|
|
57
|
+
"rule": "An object in the file failed to load because of an earlier error, which the log names on the line before this one.",
|
|
58
|
+
"fix": "Fix the error the log reports just before this line for the same file and lines {line} to {end}; this line goes away with it.",
|
|
59
|
+
"evidence": "Message shape in the game's error.log, build 99a5ee557 (2026-10-28)"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"id": "missing_modifier_localisation",
|
|
63
|
+
"category": "localisation",
|
|
64
|
+
"pattern": "^No localisation for (?<key>[A-Za-z0-9_.\\-]+)",
|
|
65
|
+
"rule": "A modifier, or another key the interface shows, has no text in the current language.",
|
|
66
|
+
"fix": "Add `{key}` to a UTF-8 file with a byte order mark under localisation/<language>/, or correct the name that produces the key.",
|
|
67
|
+
"evidence": "Message shape in the game's error.log, build 99a5ee557 (2026-10-28)"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"id": "invalid_sub_unit_modifier",
|
|
71
|
+
"category": "missing_reference",
|
|
72
|
+
"pattern": "^Invalid sub unit/category in modifier: (?<name>\\S+)",
|
|
73
|
+
"rule": "A sub-unit or unit-category modifier names a sub-unit or category that no loaded file defines.",
|
|
74
|
+
"fix": "Correct the sub-unit or category name in `{name}`, or define it under common/units/.",
|
|
75
|
+
"evidence": "Message shape in the game's error.log, build 99a5ee557 (2026-10-28)"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"id": "scripted_advisor_with_effects",
|
|
79
|
+
"category": "other",
|
|
80
|
+
"pattern": "^(?<file>\\S+\\.txt):(?<line>\\d+): advisor role created via script cannot contain any effects or triggers",
|
|
81
|
+
"rule": "An advisor role that a script effect creates cannot carry effects or triggers (such as on_add, on_remove or allowed). Only an advisor role defined in common/characters/ can.",
|
|
82
|
+
"fix": "Define the character and its advisor role in common/characters/ and recruit it from the script, or remove the effects and triggers from the role the script creates.",
|
|
83
|
+
"evidence": "Message text in the game's error.log, build 99a5ee557 (2026-10-28)"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"id": "missing_ship_entity",
|
|
87
|
+
"category": "graphics",
|
|
88
|
+
"pattern": "^Missing ship entity \"(?<name>[^\"]+)\"",
|
|
89
|
+
"rule": "A ship's model is looked up by an entity name, and no loaded .asset file defines `{name}`.",
|
|
90
|
+
"fix": "Define the entity `{name}` in a gfx/entities/*.asset file, or correct the model name the equipment or variant uses.",
|
|
91
|
+
"evidence": "Message shape in the game's error.log, build 99a5ee557 (2026-10-28)"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"id": "missing_attachment_entity",
|
|
95
|
+
"category": "graphics",
|
|
96
|
+
"pattern": "^Failed to find entity \"(?<name>[^\"]+)\" for attachment",
|
|
97
|
+
"rule": "A model attaches another entity by name, and no loaded .asset file defines `{name}`.",
|
|
98
|
+
"fix": "Define the entity `{name}` in a gfx/entities/*.asset file, or correct the attachment's name.",
|
|
99
|
+
"evidence": "Message shape in the game's error.log, build 99a5ee557 (2026-10-28)"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"id": "missing_texticon",
|
|
103
|
+
"category": "graphics",
|
|
104
|
+
"pattern": "^Couldnt find texticon: (?<name>[^|\\s]+)",
|
|
105
|
+
"rule": "Text writes an icon with `£{name}`, which the game draws from the sprite `GFX_{name}`, and no loaded .gfx file defines that sprite.",
|
|
106
|
+
"fix": "Define `GFX_{name}` in an interface/*.gfx file, or correct the icon name after `£` in the localisation.",
|
|
107
|
+
"evidence": "Message shape in the game's error.log, build 99a5ee557 (2026-10-28)"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"id": "tag_not_in_tag_list",
|
|
111
|
+
"category": "missing_reference",
|
|
112
|
+
"pattern": "^(?<tag>[A-Z][A-Z0-9]{2}) - is not in the tag list",
|
|
113
|
+
"rule": "Script names the country tag `{tag}`, which common/country_tags/ does not define for this game.",
|
|
114
|
+
"fix": "Define `{tag}` in a common/country_tags/ file, or correct the tag.",
|
|
115
|
+
"evidence": "Message shape in the game's error.log, build 99a5ee557 (2026-10-28)"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"id": "invalid_country_tag",
|
|
119
|
+
"category": "missing_reference",
|
|
120
|
+
"pattern": "^Invalid Country Tag - (?<tag>.+)$",
|
|
121
|
+
"rule": "The game expected a country tag and read `{tag}`. A value that is not a tag here (such as `{` or `color`) means a block above it is malformed.",
|
|
122
|
+
"fix": "If `{tag}` is a tag, define it in common/country_tags/. Otherwise check the braces and keys just before it.",
|
|
123
|
+
"evidence": "Message shape in the game's error.log, build 99a5ee557 (2026-10-28)"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"id": "refers_to_unknown_tag",
|
|
127
|
+
"category": "missing_reference",
|
|
128
|
+
"pattern": "refers to the unknown tag: (?<tag>[^,\\s]+)",
|
|
129
|
+
"rule": "Script names the country tag `{tag}`, which common/country_tags/ does not define.",
|
|
130
|
+
"fix": "Define `{tag}` in common/country_tags/, or correct it. A tag made at run time needs a saved scope or a variable instead of the bare tag.",
|
|
131
|
+
"evidence": "Message shape in the game's error.log, build 99a5ee557 (2026-10-28)"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"id": "faction_default_rule_replaced",
|
|
135
|
+
"category": "duplicate",
|
|
136
|
+
"pattern": "^Default rule '(?<name>[^']+)' replaces '(?<other>[^']+)' that has previously been set as default for '(?<group>[^']+)' in '(?<owner>[^']+)'",
|
|
137
|
+
"rule": "`{owner}` sets two default rules of the faction rule group `{group}`, and the later one, `{name}`, replaces `{other}`. A group has one default rule.",
|
|
138
|
+
"fix": "List one rule of the group `{group}` in the `default_rules` of `{owner}`: keep `{name}` or `{other}`, not both.",
|
|
139
|
+
"evidence": "Message shape in the game's error.log, build 99a5ee557 (2026-10-28); rule groups and default_rules in common/factions/_documentation.md"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"id": "province_in_two_rules",
|
|
143
|
+
"category": "map",
|
|
144
|
+
"pattern": "^Province (?:for icon )?is invalid or added twice to the (?:same or )?different rules: (?<province>\\d+)",
|
|
145
|
+
"rule": "Province {province} is listed in more than one map rule of the same kind, or does not exist.",
|
|
146
|
+
"fix": "List province {province} in one rule only, and check that it exists in map/definition.csv.",
|
|
147
|
+
"evidence": "Message shape in the game's error.log, build 99a5ee557 (2026-10-28)"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"id": "navy_in_landlocked_province",
|
|
151
|
+
"category": "map",
|
|
152
|
+
"pattern": "^Trying to move navy to land province with no port: (?<province>\\d+)",
|
|
153
|
+
"rule": "A fleet's location must be a sea province or a province with a naval base. Province {province} is land without a port.",
|
|
154
|
+
"fix": "Set the fleet's `location` to a province with a naval base, or build one there in the state's history.",
|
|
155
|
+
"evidence": "Message shape in the game's error.log, build 99a5ee557 (2026-10-28)"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"id": "invalid_scope",
|
|
159
|
+
"category": "scope",
|
|
160
|
+
"pattern": "^(?<file>\\S+\\.txt):(?<line>\\d+): (?<name>\\S+): Invalid Scope, supported: (?<scopes>.+)$",
|
|
161
|
+
"rule": "`{name}` runs in a scope it does not support. It supports: {scopes}.",
|
|
162
|
+
"fix": "Wrap `{name}` in a scope change to a supported scope, or move it to a block that runs in one. hoi4.script_validate on the file shows the scope at each line.",
|
|
163
|
+
"evidence": "Message shape in the game's error.log, build 99a5ee557 (2026-10-28)"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"id": "invalid_scope_state",
|
|
167
|
+
"category": "scope",
|
|
168
|
+
"pattern": "^(?<file>\\S+\\.txt):(?<line>\\d+): (?<name>\\S+) -- invalid scope (?<scope>\\w+)",
|
|
169
|
+
"rule": "`{name}` ran in a {scope} scope, which it does not support.",
|
|
170
|
+
"fix": "Change the scope before `{name}`, or use the {scope}-scope variant of the command. hoi4.script_validate on the file shows the scope at each line.",
|
|
171
|
+
"evidence": "Message shape in the game's error.log, build 99a5ee557 (2026-10-28)"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"id": "unknown_special_project",
|
|
175
|
+
"category": "missing_reference",
|
|
176
|
+
"pattern": "^sp:(?<name>\\S+) does not match any Special Project in database",
|
|
177
|
+
"rule": "Script names the special project `{name}`, which no file under common/special_projects/ defines.",
|
|
178
|
+
"fix": "Define `{name}` under common/special_projects/, or correct the name after `sp:`.",
|
|
179
|
+
"evidence": "Message shape in the game's error.log, build 99a5ee557 (2026-10-28)"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"id": "variable_without_var_prefix",
|
|
183
|
+
"category": "missing_reference",
|
|
184
|
+
"pattern": "invalid database object for effect/trigger:\\s+file: (?<file>\\S+) line: (?<line>\\d+) (?<name>\\S+)\\. use var:",
|
|
185
|
+
"rule": "`{name}` is not a database object (such as a state, country or character). A variable used where the game expects one needs the `var:` prefix.",
|
|
186
|
+
"fix": "Write `var:{name}` if `{name}` is a variable; otherwise correct the name.",
|
|
187
|
+
"evidence": "Message text in the game's error.log, build 99a5ee557 (2026-10-28)"
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"id": "invalid_compare_token",
|
|
191
|
+
"category": "trigger",
|
|
192
|
+
"pattern": "^Not a valid compare token in trigger '(?<token>[^']+)' from (?<file>\\S+\\.\\w+) line ?: ?(?<line>\\d+)",
|
|
193
|
+
"rule": "This trigger compares a value and does not accept `{token}` as its comparison.",
|
|
194
|
+
"fix": "Use the comparison the trigger documents, usually `>` or `<` for a number.",
|
|
195
|
+
"evidence": "Message shape in the game's error.log, build 99a5ee557 (2026-10-28)"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"id": "unknown_variable",
|
|
199
|
+
"category": "missing_reference",
|
|
200
|
+
"pattern": "Unknow variable '(?<name>[^']+)' in this scope",
|
|
201
|
+
"rule": "The variable `{name}` has no value in the scope that reads it at this point.",
|
|
202
|
+
"fix": "Set `{name}` in this scope before it is read, read it from the scope that holds it, or give the read a default.",
|
|
203
|
+
"evidence": "Message shape in the game's error.log, build 99a5ee557 (2026-10-28)"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"id": "collection_needs_name",
|
|
207
|
+
"category": "syntax",
|
|
208
|
+
"pattern": "Collection (?<name>\\S+) must define a name",
|
|
209
|
+
"rule": "A collection input with operators is an inner block: `input = { input = {name} operators = { ... } }`. Written flat, the game reads `{name}` as a named collection without a name, and `operators` as an unknown trigger.",
|
|
210
|
+
"fix": "Move `input = {name}` and its `operators` into an inner `input = { ... }` block, as the game's script_collection_input documentation shows.",
|
|
211
|
+
"evidence": "Message shape in the game's error.log, build 99a5ee557 (2026-10-28); documentation/script_collection_input.md, game scope"
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
"id": "raid_requirements_invalid",
|
|
215
|
+
"category": "missing_reference",
|
|
216
|
+
"pattern": "^(?<file>\\S+\\.txt):(?<line>\\d+): Missing or invalid requirements for raid type '(?<name>[^']+)'",
|
|
217
|
+
"rule": "The raid `{name}` lacks a valid requirements block, or the block names something that is not defined.",
|
|
218
|
+
"fix": "Check the raid's requirements against the game's raid documentation, with hoi4.system_inspect kind raid.",
|
|
219
|
+
"evidence": "Message shape in the game's error.log, build 99a5ee557 (2026-10-28)"
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"id": "loc_key_collisions",
|
|
223
|
+
"category": "duplicate",
|
|
224
|
+
"pattern": "The game has loc key collisions",
|
|
225
|
+
"rule": "Two localisation files define the same key in one language; one of them wins and the other text is lost.",
|
|
226
|
+
"fix": "Run hoi4.localisation_inspect with mode audit to list the duplicated keys, then keep one definition of each, or move the override to localisation/<language>/replace/.",
|
|
227
|
+
"evidence": "Message text in the game's error.log, build 99a5ee557 (2026-10-28)"
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
"id": "division_template_unreadable",
|
|
231
|
+
"category": "other",
|
|
232
|
+
"pattern": "Error reading division template \\((?<name>[^)]*)\\)",
|
|
233
|
+
"rule": "The division template `{name}` could not be read, usually because it names a sub-unit that does not exist or breaks the designer's grid.",
|
|
234
|
+
"fix": "Check the template with hoi4.unit_inspect kind oob, which lists unknown sub-units and grid problems.",
|
|
235
|
+
"evidence": "Message shape in the game's error.log, build 99a5ee557 (2026-10-28)"
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
"id": "sub_unit_missing_for_terrain",
|
|
239
|
+
"category": "missing_reference",
|
|
240
|
+
"pattern": "^sub unit not found for terrain (?<terrain>[^:]+): (?<name>\\S+)",
|
|
241
|
+
"rule": "A terrain's unit modifiers name the sub-unit `{name}`, which no loaded file defines.",
|
|
242
|
+
"fix": "Define `{name}` under common/units/, or remove it from the terrain's unit modifiers.",
|
|
243
|
+
"evidence": "Message shape in the game's error.log, build 99a5ee557 (2026-10-28)"
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
"id": "event_triggered_only_base_factor",
|
|
247
|
+
"category": "other",
|
|
248
|
+
"pattern": "Event is triggered only, but does not have a 1 base-factor",
|
|
249
|
+
"rule": "`mean_time_to_happen` only works for an event that fires by itself, and an event with `is_triggered_only = yes` never does.",
|
|
250
|
+
"fix": "Remove `mean_time_to_happen`, or remove `is_triggered_only` if the event is meant to fire by itself.",
|
|
251
|
+
"evidence": "HOI4 wiki, Event modding > Common mistakes > Unintuitive logged errors"
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
"id": "event_triggers_every_day",
|
|
255
|
+
"category": "other",
|
|
256
|
+
"pattern": "Event is set to trigger every day",
|
|
257
|
+
"rule": "An event that fires by itself, can fire more than once and has a mean time to happen of one day or less (one day when omitted) may fire every day once its trigger is true.",
|
|
258
|
+
"fix": "Add `is_triggered_only = yes` and fire it from an effect or on_action, add `fire_only_once = yes`, or set the mean time to happen to 2 days or more.",
|
|
259
|
+
"evidence": "HOI4 wiki, Event modding > Common mistakes > Unintuitive logged errors"
|
|
260
|
+
}
|
|
261
|
+
]
|
|
262
|
+
}
|
|
@@ -11,8 +11,11 @@ const MAX_MESSAGE_CHARACTERS = 600;
|
|
|
11
11
|
const SOURCE_EXTENSIONS = 'txt|gui|gfx|yml|csv|asset|lua|mod|shader|fxh|json|map|bmp|dds|tga|png';
|
|
12
12
|
const headerPattern = /^\[(\d{2}:\d{2}:\d{2})\]\[([^\]:]+?)(?:\.cpp)?(?::\d+)?\]:\s?(.*)$/u;
|
|
13
13
|
const quotedFilePattern = new RegExp(`(?:in |)file:?\\s*"([^"]+\\.(?:${SOURCE_EXTENSIONS}))"`, 'giu');
|
|
14
|
-
const
|
|
15
|
-
const
|
|
14
|
+
const CONTENT_FOLDERS = 'common|events|history|interface|gfx|localisation|localisation_synced|map|music|sound|portraits|tutorial';
|
|
15
|
+
const barePathPattern = new RegExp(`((?:[A-Za-z]:)?[\\w .\\-/\\\\]*?(?:${CONTENT_FOLDERS})[/\\\\][^\\s"',;:]+?\\.(?:${SOURCE_EXTENSIONS}))\\b`, 'gu');
|
|
16
|
+
/** `near line: 12`, `line : 12` and `line: 12`; `file.txt:12:` is read by `fileLinePattern`. */
|
|
17
|
+
const linePattern = /(?:near\s+)?line\s*:?\s*(\d{1,7})/giu;
|
|
18
|
+
const fileLinePattern = new RegExp(`\\.(?:${SOURCE_EXTENSIONS}):(\\d{1,7})\\b`, 'iu');
|
|
16
19
|
/** Rules in order; the first that matches classifies an entry. */
|
|
17
20
|
const categoryRules = [
|
|
18
21
|
[
|
|
@@ -45,7 +48,7 @@ const moduleCategories = [
|
|
|
45
48
|
[/persistent|parse|pdx_?data|script/iu, 'syntax'],
|
|
46
49
|
];
|
|
47
50
|
/** What to do about each kind of entry; names the tool that narrows it down. */
|
|
48
|
-
const categoryHints = {
|
|
51
|
+
export const categoryHints = {
|
|
49
52
|
syntax: 'Check braces, quotes and assignments near the named line; hoi4.script_validate with the file path pinpoints it.',
|
|
50
53
|
duplicate: 'Two active definitions share a name: rename one, or remove the copy that overrides the other.',
|
|
51
54
|
localisation: 'Add the key to a UTF-8 with BOM .yml under localisation/<language>/ (key: "Text", no :0), or correct the key name.',
|
|
@@ -118,7 +121,7 @@ async function compareWithPreviousLaunch(workspace, modifiedAt, entries) {
|
|
|
118
121
|
}
|
|
119
122
|
return { ...(next.previous === undefined ? {} : { previous: next.previous }), current };
|
|
120
123
|
}
|
|
121
|
-
function
|
|
124
|
+
export function classifyLogMessage(module, message) {
|
|
122
125
|
for (const [category, pattern] of categoryRules)
|
|
123
126
|
if (category !== 'missing_reference' && pattern.test(message))
|
|
124
127
|
return category;
|
|
@@ -227,7 +230,7 @@ async function readTail(file, size) {
|
|
|
227
230
|
}
|
|
228
231
|
}
|
|
229
232
|
/** The last source file a message names, relative to its source root, and its line. */
|
|
230
|
-
function
|
|
233
|
+
export function locateLogSource(message, roots) {
|
|
231
234
|
const files = [
|
|
232
235
|
...[...message.matchAll(quotedFilePattern)].map((match) => match[1]),
|
|
233
236
|
...[...message.matchAll(barePathPattern)].map((match) => match[1].trim()),
|
|
@@ -247,10 +250,27 @@ function locate(message, roots) {
|
|
|
247
250
|
const modMatch = /\/mod\/[^/]+\/(.+)$/u.exec(normalized);
|
|
248
251
|
if (modMatch !== null && path.isAbsolute(raw))
|
|
249
252
|
normalized = modMatch[1];
|
|
253
|
+
// A bare path can pick up the words before it ("... in events/a.txt"): start at its folder.
|
|
254
|
+
if (!path.isAbsolute(normalized)) {
|
|
255
|
+
const folder = new RegExp(`(?:^|[\\s/])((?:${CONTENT_FOLDERS})/)`, 'u').exec(normalized);
|
|
256
|
+
if (folder !== null && folder.index > 0)
|
|
257
|
+
normalized = normalized.slice(folder.index + folder[0].length - folder[1].length);
|
|
258
|
+
}
|
|
250
259
|
const lines = [...message.matchAll(linePattern)].map((match) => Number(match[1]));
|
|
251
|
-
|
|
260
|
+
// `common/x.txt:12: message` gives the line right after the file name.
|
|
261
|
+
const fileLine = fileLinePattern.exec(message.slice(message.lastIndexOf(raw)));
|
|
262
|
+
const line = lines.at(-1) ?? (fileLine === null ? undefined : Number(fileLine[1]));
|
|
263
|
+
return { relativePath: normalized, ...(line === undefined ? {} : { line }) };
|
|
252
264
|
}
|
|
253
265
|
async function layerOf(workspace, relativePath, logModified) {
|
|
266
|
+
const found = await sourceLayerOf(workspace, relativePath);
|
|
267
|
+
return {
|
|
268
|
+
layer: found.layer,
|
|
269
|
+
changedSinceLog: found.modified !== undefined && found.modified > logModified,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
/** The first layer, in override order, that has the file, with its root folder. */
|
|
273
|
+
export async function sourceLayerOf(workspace, relativePath) {
|
|
254
274
|
const layers = [
|
|
255
275
|
['mod', workspace.modRoot],
|
|
256
276
|
...workspace.dependencyRoots.map((root) => [
|
|
@@ -267,9 +287,9 @@ async function layerOf(workspace, relativePath, logModified) {
|
|
|
267
287
|
continue;
|
|
268
288
|
const info = await stat(candidate).catch(() => undefined);
|
|
269
289
|
if (info?.isFile() === true)
|
|
270
|
-
return { layer,
|
|
290
|
+
return { layer, root, modified: info.mtimeMs };
|
|
271
291
|
}
|
|
272
|
-
return { layer: 'unknown'
|
|
292
|
+
return { layer: 'unknown' };
|
|
273
293
|
}
|
|
274
294
|
export async function readErrorLog(workspace, input, configuredUserRoot, signal) {
|
|
275
295
|
let found;
|
|
@@ -307,7 +327,7 @@ export async function readErrorLog(workspace, input, configuredUserRoot, signal)
|
|
|
307
327
|
existing.count += 1;
|
|
308
328
|
continue;
|
|
309
329
|
}
|
|
310
|
-
const located =
|
|
330
|
+
const located = locateLogSource(message, roots);
|
|
311
331
|
const source = located === undefined
|
|
312
332
|
? undefined
|
|
313
333
|
: {
|
|
@@ -316,7 +336,7 @@ export async function readErrorLog(workspace, input, configuredUserRoot, signal)
|
|
|
316
336
|
...(await layerOf(workspace, located.relativePath, found.modified)),
|
|
317
337
|
};
|
|
318
338
|
grouped.set(key, {
|
|
319
|
-
category:
|
|
339
|
+
category: classifyLogMessage(item.module, message),
|
|
320
340
|
module: item.module.slice(0, 128),
|
|
321
341
|
message,
|
|
322
342
|
count: 1,
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
/** What each known code means for the mod, what to do, and how much it matters. */
|
|
2
|
+
const descriptions = {
|
|
3
|
+
REF_UNKNOWN_EFFECT: {
|
|
4
|
+
title: 'Effects the game does not know',
|
|
5
|
+
fix: 'Correct each name to a documented effect, or define the scripted effect; hoi4.explain_error and hoi4.reference_search name the right command.',
|
|
6
|
+
weight: 85,
|
|
7
|
+
},
|
|
8
|
+
REF_UNKNOWN_TRIGGER: {
|
|
9
|
+
title: 'Triggers the game does not know',
|
|
10
|
+
fix: 'Correct each name to a documented trigger, or define the scripted trigger; hoi4.explain_error and hoi4.reference_search name the right command.',
|
|
11
|
+
weight: 85,
|
|
12
|
+
},
|
|
13
|
+
LINT_UNKNOWN_MODIFIER: {
|
|
14
|
+
title: 'Modifiers the game does not know',
|
|
15
|
+
fix: "Use a modifier from the game's modifiers documentation, or define it in common/modifier_definitions/.",
|
|
16
|
+
weight: 60,
|
|
17
|
+
},
|
|
18
|
+
LINT_DUPLICATE_DEFINITION: {
|
|
19
|
+
title: 'Ids defined twice in the mod',
|
|
20
|
+
fix: 'Keep one definition of each id: the later one wins and the other is lost.',
|
|
21
|
+
weight: 80,
|
|
22
|
+
},
|
|
23
|
+
LINT_DUPLICATE_ACROSS_LAYERS: {
|
|
24
|
+
title: 'Ids the game or a dependency also defines',
|
|
25
|
+
fix: 'Rename the mod copy, or replace the other file (a file of the same name or replace_path), so only one loads.',
|
|
26
|
+
weight: 50,
|
|
27
|
+
},
|
|
28
|
+
LINT_EVENT_NAMESPACE_COLLISION: {
|
|
29
|
+
title: 'Event namespaces the game already declares',
|
|
30
|
+
fix: 'Use a namespace of the mod own; events in a shared namespace collide by id.',
|
|
31
|
+
weight: 70,
|
|
32
|
+
},
|
|
33
|
+
LINT_INERT_MTTH: {
|
|
34
|
+
title: 'Timers on triggered-only events, which never run',
|
|
35
|
+
fix: 'Remove mean_time_to_happen, or is_triggered_only if the event should fire by itself.',
|
|
36
|
+
weight: 45,
|
|
37
|
+
},
|
|
38
|
+
LINT_MUTUALLY_EXCLUSIVE_NOT_RECIPROCAL: {
|
|
39
|
+
title: 'Mutually exclusive focuses that exclude in one direction only',
|
|
40
|
+
fix: 'List the exclusion on both focuses.',
|
|
41
|
+
weight: 55,
|
|
42
|
+
},
|
|
43
|
+
LINT_EVENT_LOC_KEY_REUSED: {
|
|
44
|
+
title: 'Events that use one localisation key for two texts',
|
|
45
|
+
fix: 'Give each text of the event its own key.',
|
|
46
|
+
weight: 35,
|
|
47
|
+
},
|
|
48
|
+
LINT_UNKNOWN_DLC: {
|
|
49
|
+
title: 'has_dlc names a DLC the game does not know',
|
|
50
|
+
fix: "Use the DLC's exact name as the game lists it.",
|
|
51
|
+
weight: 50,
|
|
52
|
+
},
|
|
53
|
+
LINT_FLAG_NEVER_SET: {
|
|
54
|
+
title: 'Flags checked but never set',
|
|
55
|
+
fix: 'Set the flag somewhere, or correct its name; flags built at run time from parameters are counted here too.',
|
|
56
|
+
weight: 25,
|
|
57
|
+
},
|
|
58
|
+
REF_MISSING_LOCALISATION_KEY: {
|
|
59
|
+
title: 'Localisation keys the script uses that no file defines',
|
|
60
|
+
fix: 'Add the keys (hoi4.localisation_write mode add), or correct their names.',
|
|
61
|
+
weight: 65,
|
|
62
|
+
},
|
|
63
|
+
REF_CASE_MISMATCH: {
|
|
64
|
+
title: 'Names whose letter case differs from their definition',
|
|
65
|
+
fix: 'Write each name with the letter case of its definition.',
|
|
66
|
+
weight: 40,
|
|
67
|
+
},
|
|
68
|
+
OVERRIDE_BREAKS_REFERENCE: {
|
|
69
|
+
title: 'Overridden files that remove definitions other files use',
|
|
70
|
+
fix: 'Keep the definitions the rest of the game uses in the mod copy, or change the files that use them.',
|
|
71
|
+
weight: 75,
|
|
72
|
+
},
|
|
73
|
+
OVERRIDE_DROPS_DEFINITION: {
|
|
74
|
+
title: 'Overridden files that drop definitions',
|
|
75
|
+
fix: 'Copy the dropped definitions into the mod file, or confirm the drop is intended.',
|
|
76
|
+
weight: 55,
|
|
77
|
+
},
|
|
78
|
+
OVERRIDE_DROPS_ON_ACTION_HOOK: {
|
|
79
|
+
title: 'Overridden on_actions files that drop hooks',
|
|
80
|
+
fix: 'Put the mod hooks in a new on_actions file instead of replacing the game one, so both load.',
|
|
81
|
+
weight: 65,
|
|
82
|
+
},
|
|
83
|
+
SCRIPT_COMMAND_WRONG_SCOPE: {
|
|
84
|
+
title: 'Commands used in a scope they do not support',
|
|
85
|
+
fix: 'Change scope before the command, or use the variant for this scope; hoi4.script_validate on the file shows each scope.',
|
|
86
|
+
weight: 80,
|
|
87
|
+
},
|
|
88
|
+
SCRIPT_COMMAND_WRONG_KIND: {
|
|
89
|
+
title: 'Effects used as triggers, or triggers as effects',
|
|
90
|
+
fix: 'Move each command to a block of its kind.',
|
|
91
|
+
weight: 80,
|
|
92
|
+
},
|
|
93
|
+
SCRIPT_SCOPE_LINK_AS_TRIGGER: {
|
|
94
|
+
title: 'Scope links used as triggers, which the game drops',
|
|
95
|
+
fix: 'Use is_owned_by or is_controlled_by instead of owner = X or controller = X.',
|
|
96
|
+
weight: 80,
|
|
97
|
+
},
|
|
98
|
+
SCRIPT_FLAG_TOOLTIP_UNLOCALISED: {
|
|
99
|
+
title: 'Flag checks whose requirement tooltip shows the raw flag name',
|
|
100
|
+
fix: 'Add a localisation key named like the flag, or wrap the check in hidden_trigger.',
|
|
101
|
+
weight: 30,
|
|
102
|
+
},
|
|
103
|
+
SCRIPT_ARGUMENT_UNKNOWN_ID: {
|
|
104
|
+
title: 'Commands that name an idea, event, decision, focus or technology nothing defines',
|
|
105
|
+
fix: 'Correct each id, or define it.',
|
|
106
|
+
weight: 60,
|
|
107
|
+
},
|
|
108
|
+
LOC_KEY_UNDEFINED: {
|
|
109
|
+
title: 'Localisation keys the script uses that no language defines',
|
|
110
|
+
fix: 'Add the keys (hoi4.localisation_write mode add), or correct their names.',
|
|
111
|
+
weight: 65,
|
|
112
|
+
},
|
|
113
|
+
LOC_KEY_MISSING_LANGUAGE: {
|
|
114
|
+
title: 'Keys missing from a language the mod supports',
|
|
115
|
+
fix: 'Add them (hoi4.localisation_write mode fix copies the English text), or drop the language.',
|
|
116
|
+
weight: 30,
|
|
117
|
+
},
|
|
118
|
+
LOC_KEY_DUPLICATE: {
|
|
119
|
+
title: 'Localisation keys defined twice in one language',
|
|
120
|
+
fix: 'Keep one definition of each key; put intended overrides under localisation/<language>/replace/.',
|
|
121
|
+
weight: 45,
|
|
122
|
+
},
|
|
123
|
+
LOC_FILE_LANGUAGE_MISMATCH: {
|
|
124
|
+
title: 'Localisation files whose name and header name different languages',
|
|
125
|
+
fix: 'Make the file name end in _l_<language>.yml with the matching l_<language>: header.',
|
|
126
|
+
weight: 70,
|
|
127
|
+
},
|
|
128
|
+
LOC_MISSING_LANGUAGE_HEADER: {
|
|
129
|
+
title: 'Localisation files without a language header',
|
|
130
|
+
fix: 'Start each file with l_<language>: on its first line, in UTF-8 with a byte order mark.',
|
|
131
|
+
weight: 90,
|
|
132
|
+
},
|
|
133
|
+
LOC_PLACEHOLDER_MISSING: {
|
|
134
|
+
title: 'Text that refers to keys or values that do not exist',
|
|
135
|
+
fix: 'Correct each $key$ or [scope.Get...] reference.',
|
|
136
|
+
weight: 40,
|
|
137
|
+
},
|
|
138
|
+
ASSET_TEXTURE_MISSING: {
|
|
139
|
+
title: 'Sprites whose texture file is missing',
|
|
140
|
+
fix: 'Add the texture file, or correct the texturefile path (letter case matters on Linux and macOS).',
|
|
141
|
+
weight: 70,
|
|
142
|
+
},
|
|
143
|
+
ASSET_TEXTURE_UNREADABLE: {
|
|
144
|
+
title: 'Texture files the game cannot read',
|
|
145
|
+
fix: 'Save the texture again as DDS (BC3 or uncompressed RGBA) or PNG.',
|
|
146
|
+
weight: 70,
|
|
147
|
+
},
|
|
148
|
+
ASSET_TEXTURE_FORMAT_RISKY: {
|
|
149
|
+
title: 'Textures in BC7, which crashed the game in an in-game check',
|
|
150
|
+
fix: 'Save these textures as BC3 or uncompressed DDS.',
|
|
151
|
+
weight: 75,
|
|
152
|
+
},
|
|
153
|
+
ASSET_FILE_MISSING: {
|
|
154
|
+
title: 'Sounds whose audio file is missing',
|
|
155
|
+
fix: 'Add the audio file, or correct its path.',
|
|
156
|
+
weight: 55,
|
|
157
|
+
},
|
|
158
|
+
ASSET_FLAG_MISSING: {
|
|
159
|
+
title: 'Country flags missing in one of the three sizes',
|
|
160
|
+
fix: 'Add the flag at 82x52, medium 41x26 and small 10x7.',
|
|
161
|
+
weight: 50,
|
|
162
|
+
},
|
|
163
|
+
ASSET_FLAG_SIZE: {
|
|
164
|
+
title: 'Flags of the wrong size',
|
|
165
|
+
fix: 'Resize to 82x52, medium 41x26 and small 10x7.',
|
|
166
|
+
weight: 40,
|
|
167
|
+
},
|
|
168
|
+
ASSET_REFERENCE_UNKNOWN: {
|
|
169
|
+
title: 'Sound effects that play sounds nothing defines',
|
|
170
|
+
fix: 'Define the sound, or correct its name.',
|
|
171
|
+
weight: 45,
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
/** Codes two audits use for the same problem, mapped to one. */
|
|
175
|
+
const sameProblem = {
|
|
176
|
+
LOC_KEY_UNDEFINED: 'REF_MISSING_LOCALISATION_KEY',
|
|
177
|
+
};
|
|
178
|
+
const checkOrder = {
|
|
179
|
+
error_log: 0,
|
|
180
|
+
engine_check: 1,
|
|
181
|
+
script: 2,
|
|
182
|
+
localisation: 3,
|
|
183
|
+
assets: 4,
|
|
184
|
+
};
|
|
185
|
+
/** Rank the problems of every check that ran; the top `limit` come back with examples. */
|
|
186
|
+
export function rankProblems(runs, limit) {
|
|
187
|
+
// Two audits that report the same kind of problem make one problem, counted once.
|
|
188
|
+
const groups = new Map();
|
|
189
|
+
const perCheck = new Map();
|
|
190
|
+
for (const run of runs)
|
|
191
|
+
for (const finding of run.findings) {
|
|
192
|
+
const code = sameProblem[finding.code] ?? finding.code;
|
|
193
|
+
const group = groups.get(code) ?? { run, code, findings: [], count: 0 };
|
|
194
|
+
if (group.run === run)
|
|
195
|
+
group.findings.push(finding);
|
|
196
|
+
const key = `${run.check}\0${code}`;
|
|
197
|
+
perCheck.set(key, (perCheck.get(key) ?? 0) + 1);
|
|
198
|
+
group.count = Math.max(group.count, perCheck.get(key), run.counts?.[finding.code] ?? 0);
|
|
199
|
+
groups.set(code, group);
|
|
200
|
+
}
|
|
201
|
+
const problems = [];
|
|
202
|
+
for (const { run, code, findings, count } of groups.values()) {
|
|
203
|
+
const severity = findings.some((finding) => finding.severity === 'error') ? 'error' : 'warning';
|
|
204
|
+
const own = run.describe?.(code, findings);
|
|
205
|
+
const known = descriptions[code];
|
|
206
|
+
const weight = own?.weight ?? known?.weight ?? (severity === 'error' ? 60 : 30);
|
|
207
|
+
const next = own?.next ?? known?.next;
|
|
208
|
+
problems.push({
|
|
209
|
+
rank: 0,
|
|
210
|
+
check: run.check,
|
|
211
|
+
severity,
|
|
212
|
+
code,
|
|
213
|
+
title: (own?.title ?? known?.title ?? findings[0].message).slice(0, 300),
|
|
214
|
+
count,
|
|
215
|
+
examples: findings.slice(0, 2).map(({ message, path, line }) => ({
|
|
216
|
+
message: message.slice(0, 300),
|
|
217
|
+
...(path === undefined ? {} : { path: path.slice(0, 1024) }),
|
|
218
|
+
...(line === undefined || line < 1 ? {} : { line }),
|
|
219
|
+
})),
|
|
220
|
+
fix: (own?.fix ?? known?.fix ?? 'Read the examples and fix each place they name.').slice(0, 400),
|
|
221
|
+
...(next === undefined ? {} : { next }),
|
|
222
|
+
weight,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
problems.sort((left, right) => Number(right.severity === 'error') - Number(left.severity === 'error') ||
|
|
226
|
+
right.weight - left.weight ||
|
|
227
|
+
right.count - left.count ||
|
|
228
|
+
checkOrder[left.check] - checkOrder[right.check] ||
|
|
229
|
+
(left.code < right.code ? -1 : left.code > right.code ? 1 : 0));
|
|
230
|
+
const top = problems.slice(0, limit).map(({ weight: _weight, ...problem }, index) => ({
|
|
231
|
+
...problem,
|
|
232
|
+
rank: index + 1,
|
|
233
|
+
}));
|
|
234
|
+
const ran = runs.filter(({ status }) => status === 'ran' || status === 'partial');
|
|
235
|
+
const complete = runs.every(({ status }) => status === 'ran' || status === 'skipped');
|
|
236
|
+
return {
|
|
237
|
+
verdict: problems.length > 0 ? 'problems' : complete ? 'healthy' : 'incomplete',
|
|
238
|
+
problems: top,
|
|
239
|
+
totals: {
|
|
240
|
+
problems: problems.length,
|
|
241
|
+
findings: problems.reduce((sum, problem) => sum + problem.count, 0),
|
|
242
|
+
errors: problems.filter(({ severity }) => severity === 'error').length,
|
|
243
|
+
warnings: problems.filter(({ severity }) => severity === 'warning').length,
|
|
244
|
+
omitted: Math.max(0, problems.length - top.length),
|
|
245
|
+
},
|
|
246
|
+
checks: runs.map(({ check, status, ms, note, findings, counts }) => ({
|
|
247
|
+
check,
|
|
248
|
+
status,
|
|
249
|
+
ms: Math.round(ms),
|
|
250
|
+
findings: Math.max(findings.length, Object.values(counts ?? {}).reduce((sum, count) => sum + count, 0)),
|
|
251
|
+
...(note === undefined ? {} : { note: note.slice(0, 300) }),
|
|
252
|
+
})),
|
|
253
|
+
checksRun: ran.length,
|
|
254
|
+
};
|
|
255
|
+
}
|