dsh-hoi4-modding 1.0.0 → 1.1.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 ADDED
@@ -0,0 +1,32 @@
1
+ # Changelog
2
+
3
+ ## 1.1.1
4
+
5
+ - 文档同步补丁:README 增加「Publishing」小节(2026 年可用 granular token 直发;**2027-01 起该方式移除**,
6
+ 改用 stage only + `npm stage publish` 或 GitHub Actions Trusted Publishing),CHANGELOG 记录同项。
7
+ 1.1.0 已包含全部功能与脚本,本版仅同步文档,避免 npm 包与仓库不一致。
8
+
9
+ ## 1.1.0
10
+
11
+ 科技树 UI 专题(来自一次 2900 科技/多国科技页大型 Mod 的真实排障,全部结论经游戏内对照实验验证):
12
+
13
+ - **新增** `references/tech-tree-ui.md`
14
+ - `technology_folders.available` 必须用 `original_tag`:用 `has_country_flag` 时引擎建页画线阶段的
15
+ 运行时二次求值失败,**整页连线被静默丢弃**(方框在、日志干净、旧存档正常而新开档必现)。
16
+ - 大框/小框混排三件套:`force_use_small_tech_layout` + `techtree_<folder>_small_item` 模板 +
17
+ `GFX_technology_<folder>_small_*_item_bg` **指向真正的小图**(模板 size 只管排版,贴图按像素绘制)。
18
+ - 拆页/合并页 6 步配方、网格原点统一规则、跨页 path 不画线的必然性。
19
+ - 三种调试手法:留痕法(改名 gridbox 判断页面是否被建)、对半分实验、对照探针。
20
+ - **新增脚本**
21
+ - `tech_tree_audit.py`:科技页完整性审计(注册表 ↔ 页面/页签/item 模板/网格/科技/本地化)
22
+ - `tech_folder_available.py`:`has_country_flag` → `original_tag` 批量迁移(check/apply/revert)
23
+ - `item_sprite_check.py`:item 模板尺寸 vs 背景精灵实际像素(专治"小框显示成大框 + 偏位")
24
+ - `errorlog_triage.py`:error.log 分诊(科技树/贴图/scope/未知字段/本地化),并给出"日志干净即静默跳过"的判语
25
+ - **SKILL.md**:铁律新增 2 条(科技页可用性、大小框三件套);排错表新增 3 行症状;验收清单新增 2 条;
26
+ 工具与配方索引补充新内容。
27
+ - README:脚本清单、更新记录(中英)。
28
+ - README:补充 npm 发布方式说明(2027-01 起 granular token 直发被移除,改用 stage only / Trusted Publishing)。
29
+
30
+ ## 1.0.0
31
+
32
+ - 首个版本:HOI4 1.19.3 Mod 全流程技能(骨架/国策/事件/决议/理念/角色/科技/州/MIO/特殊项目/GUI/本地化/DDS/校验/安装/排错/发布)。
package/README.md CHANGED
@@ -21,6 +21,8 @@ dsh plugin --profile web add github:a1249070611/dsh-hoi4-modding
21
21
  Restart / refresh as the host asks. The skill appears in the session skill catalog; invoke it by asking
22
22
  for HOI4 modding, or explicitly “load hoi4-modding”.
23
23
 
24
+ npm: https://www.npmjs.com/package/dsh-hoi4-modding
25
+
24
26
  ## What is inside
25
27
 
26
28
  | Path | Purpose |
@@ -34,6 +36,11 @@ for HOI4 modding, or explicitly “load hoi4-modding”.
34
36
  | `skills/hoi4-modding/scripts/build_reference.py` | Generate effects/triggers/modifiers/console references from the game's `documentation/*.md` |
35
37
  | `skills/hoi4-modding/scripts/dds_helper.py` | Generate / inspect HOI4 DDS icons (needs Pillow) |
36
38
  | `skills/hoi4-modding/scripts/pdx_parser.py` | Tolerant PDX script parser used by the linter |
39
+ | `skills/hoi4-modding/references/tech-tree-ui.md` | Tech tree UI: folder availability, connection lines, big/small item layouts, split/merge recipes, debugging recipes |
40
+ | `skills/hoi4-modding/scripts/tech_tree_audit.py` | Audit a mod's tech pages: registry vs page/tab/item templates/gridboxes/techs/localisation |
41
+ | `skills/hoi4-modding/scripts/tech_folder_available.py` | Migrate `technology_folders.available` from `has_country_flag` to `original_tag` (check/apply/revert) |
42
+ | `skills/hoi4-modding/scripts/item_sprite_check.py` | Compare item template sizes with the actual item background sprite pixels ("small item looks big") |
43
+ | `skills/hoi4-modding/scripts/errorlog_triage.py` | Triage `error.log`: tech tree / textures / scopes / unknown fields / localisation |
37
44
 
38
45
  ## Requirements
39
46
 
@@ -53,6 +60,24 @@ All commands are visible in the conversation before they run.
53
60
 
54
61
  ## License
55
62
 
63
+ ## Publishing
64
+
65
+ - **Now – December 2026**: a granular access token with **Read and write (publish and stage)** and
66
+ **Bypass 2FA** enabled can publish directly with `npm publish --access public`.
67
+ npm deprecates this path in **January 2027**.
68
+ - **From January 2027**: use a **stage only** token plus `npm stage publish`, or GitHub Actions
69
+ **Trusted Publishing** (the bundled `release.yml` already runs on `v*` tags).
70
+
71
+ ## Changelog
72
+
73
+ - **1.1.0** — Tech tree UI knowledge from a real large-mod debugging session: `technology_folders.available`
74
+ must use `original_tag` (flag-based conditions silently drop every connection line on a page in new games),
75
+ big/small item mixing requires the small item background **sprites** to point at real small textures,
76
+ plus three debugging recipes (marker rename, half-split experiment, control probe) and four new scripts.
77
+ - 1.0.0 — Initial release.
78
+
79
+ ## License
80
+
56
81
  MIT. The skill text and scripts are original; no Paradox game assets are included.
57
82
 
58
83
  ---
@@ -74,6 +99,17 @@ dsh plugin --profile web add github:a1249070611/dsh-hoi4-modding
74
99
  刷新/重启后,技能出现在技能目录;直接说「做个 HOI4 mod」「加个国策树」「mod 报错了」即可触发,
75
100
  也可以显式说「加载 hoi4-modding 技能」。
76
101
 
102
+ ### 本次新增(1.1.0)
103
+ - `references/tech-tree-ui.md`:科技树页面可用性 / 连线 / 大小框混排 / 拆页合并 / 三种调试手法(留痕法、对半分、对照探针)
104
+ - 4 个新脚本:`tech_tree_audit.py`(科技页完整性审计)、`tech_folder_available.py`(旗帜判定→国家标签,批量修复整页无连线)、
105
+ `item_sprite_check.py`(模板尺寸 vs 背景精灵像素,专治"小框显示成大框")、`errorlog_triage.py`(error.log 分诊)
106
+
107
+ ### 发布方式(npm)
108
+ - 2026 年内:Granular token 选 **Read and write (publish and stage)** 并勾选 **Bypass 2FA**,可 `npm publish --access public` 直发;
109
+ npm 已在页面上提示该方式将于 **2027 年 1 月**移除。
110
+ - 2027 年起:改用 **stage only** token + `npm stage publish`,或 GitHub Actions **Trusted Publishing**
111
+ (仓库里的 `release.yml` 已在 `v*` 标签触发)。
112
+
77
113
  ### 依赖
78
114
 
79
115
  - DeepSeek Harness(含技能注册表,0.2.x)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-hoi4-modding",
3
- "version": "1.0.0",
4
- "description": "HOI4 1.19.3 modding skill bundle for DeepSeek Harness: create, edit, validate, install and debug Hearts of Iron IV mods (focus trees, events, decisions, ideas, characters, technologies, MIO, special projects, GUI, localisation, DDS) with bundled verifier/installer scripts.",
3
+ "version": "1.1.1",
4
+ "description": "HOI4 1.19.3 modding skill bundle for DeepSeek Harness: create, edit, validate, install and debug Hearts of Iron IV mods (focus trees, events, decisions, ideas, characters, technologies, MIO, special projects, GUI, localisation, DDS) with bundled verifier/installer scripts; plus tech tree UI diagnostics (page availability, connection lines, big/small item layouts).",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -15,7 +15,8 @@
15
15
  "skills/**/*",
16
16
  "README.md",
17
17
  "LICENSE",
18
- "icon.svg"
18
+ "icon.svg",
19
+ "CHANGELOG.md"
19
20
  ],
20
21
  "dsh": {
21
22
  "bundle": {
@@ -1,167 +1,190 @@
1
- ---
2
- name: hoi4-modding
3
- description: 《钢铁雄心4》(Hearts of Iron IV, HOI4) 1.19.3 Mod 开发全流程技能:读游戏文件、新建 Mod、写国策/事件/决议/理念/角色/科技/州/MIO/特殊项目/scripted GUI、本地化与 DDS 图标、静态校验、安装启用、按 error.log 排错、发布创意工坊。Use whenever the user asks to create, edit, fix, validate, install, publish, or debug an HOI4 mod or asks about HOI4 scripting (scopes, effects, triggers, variables, focus trees, events, decisions, ideas, characters, MIO, special projects, GUI, localisation, DDS), even if they only say "做个国策树"/"加个事件"/"mod 报错了".
4
- whenToUse: 用户要做/改/修/校验/安装/发布 HOI4 Mod,或问 HOI4 脚本写法(scope/effect/trigger/变量/国策/事件/决议/理念/角色/MIO/特殊项目/GUI/本地化/DDS)时。
5
- ---
6
-
7
- # HOI4 1.19.3 Mod 制作全流程
8
-
9
- 面向 **1.19.3.0 "Operation Postern"**(`E:\Steam\steamapps\common\Hearts of Iron IV`)实测整理。
10
- 目标不是讲概念,而是**一次把可运行的 Mod 做出来**:放对文件 → 写对语法 → 本地化齐全 → 校验通过 → 装进游戏 → error.log 干净。
11
-
12
- > 本机还保留了一套 57 篇的深度知识库(见文末「深度资料」):需要查字段细节时读它;本 SKILL 与 `references/` 是压缩版,足够完成 90% 任务。
13
-
14
- ## 0. 开始前先确认 3 件事
15
-
16
- 1. **游戏路径**:`E:\Steam\steamapps\common\Hearts of Iron IV`(`HOI4_GAME` 环境变量可覆盖)。
17
- 2. **版本**:`launcher-settings.json` 里 `rawVersion` 应为 `1.19.3.0`;不是就按对应版本调整语法(尤其学说/特殊项目)。
18
- 3. **目标国家有没有专属国策树**:**1.19 每个国家同一时间只有一棵激活国策树**(`country = { }` 是打分,取最高分)。
19
- - 没有专属树(用 `generic_focus`,如 LUX、IRE、BHU):可以新建一整棵树,`add = 10` 就接管。
20
- - 已有专属树(SWE、GER、SOV…):不能"再加一棵";只能覆盖原树文件、或 `load_focus_tree` 换树(会顶掉原树)。先向用户确认接受哪种。
21
-
22
- ## 1. 铁律(违反任何一条都会踩坑)
23
-
24
- 1. **永不改游戏安装目录**;所有内容写在 Mod 目录,装到 `Documents/Paradox Interactive/Hearts of Iron IV/mod/`。
25
- 2. **同名文件 = 整体替换**(不是合并)。优先**新增文件**,不要复制整份原版文件。
26
- 3. **同 ID = 后者覆盖前者**;ID 用你的 `NS_` 前缀,事件用独立 `add_namespace`。
27
- 4. **本地化 `.yml` 必须 UTF-8 with BOM**;目录名与首行根键一致(`english` → `l_english:`,`simp_chinese` → `l_simp_chinese:`)。
28
- 5. **2D sprite 定义放 `interface/*.gfx`**,DDS 文件放 `gfx/interface/...`;`gfx/` 下的 `.gfx` 是 3D 用的。
29
- 6. **图标尺寸**:国策 100×88(+ `_shine`)、理念 60×68、决议 32×33、决议类别 40×51、肖像 156×210、旗帜 82×52 TGA。
30
- 7. **DDS 用未压缩 raw32 最稳**(原版 UI 同构:`dwFlags=0x81007`、无 mipmap);DXT 要求宽高为 4 的倍数。
31
- 8. **`.mod` 的 `path` 用纯 ASCII 正斜杠**;中文路径可能加载失败 → 用 `install_mod.py` 复制到玩家目录。
32
- 9. **`.mod` 字段是 `picture=`**,不是 `thumbnail=`;`supported_version` 写 `"1.19.*"` 或 `"1.19.3.0"`,写 `*`/`1.*` 会报错。
33
- 10. **不要依赖 DLC**:需要 DLC 内容时用 `has_dlc = "..."` 分支并标注;特殊项目依赖 `Gotterdammerung`。
34
- 11. **错误看 `logs/error.log`**(`[时间][游戏日期][文件:行]: 消息`),只 grep 自己的文件名/ID;原版噪声占 95%+。
35
- 12. **脚本改动必须重启游戏**,没有完整热重载;静态校验不能替代进游戏。
36
-
37
- ## 2. 标准工作流
38
-
39
- ```
40
- 0) 侦察 读游戏文件确认目标系统/字段/原版参考(grep 原版用例)
41
- 1) 骨架 scripts/new_mod.py 生成 descriptor.mod + .mod + 本地化 + 示例内容
42
- 2) 内容 按 references/cheatsheet.md 的配方逐类添加(国策/事件/决议/理念/角色/科技/州/GUI…)
43
- 3) 本地化 每个 ID 同时补 english + simp_chinese(BOM),key 规则见 cheatsheet §2
44
- 4) 校验 python scripts/hoi4_lint.py <Mod目录>
45
- 5) 安装 python scripts/install_mod.py <Mod目录> --yes --enable
46
- 6) 实测 启动游戏(-debug_mode)→ 新开档 → 控制台触发 → 看 error.log
47
- 7) 发布 descriptor.mod 的 name/supported_version/tags/picture 齐全;干净 playset 复测
48
- ```
49
-
50
- 每次只加一类内容、加完就校验;不要一次写 2000 行再排错。
51
-
52
- ## 3. 配方索引(代码在 `references/cheatsheet.md`)
53
-
54
- | 任务 | 章节 |
55
- |---|---|
56
- | 新建 Mod 骨架 / `.mod` 与 `descriptor.mod` | cheatsheet §1 |
57
- | 本地化规则、key 命名、颜色/变量/图标 | §2 |
58
- | 国家精神(idea) | §3 |
59
- | 国策树(含一国一树规则、互斥/前置/奖励) | §4 |
60
- | 事件(MTTH / is_triggered_only / 选项 / 事件链) | §5 |
61
- | 决议(category / decision / targeted / 任务型) | §6 |
62
- | 角色(领袖/顾问/将领/科学家) | §7 |
63
- | 科技(folder / dependencies / on_research_complete) | §8 |
64
- | 州、资源、建筑 | §9 |
65
- | 动态变量 + 动态修正 | §10 |
66
- | scripted GUI 面板(4 文件挂载) | §11 |
67
- | MIO / 特殊项目 | §12 |
68
- | 贴图、DDS、GFX 注册 | §13 |
69
- | 调试命令与 error.log 对照表 | §14 |
70
- | 1.19 与旧教程差异清单 | §15 |
71
-
72
- ## 4. 工具(`scripts/`,仅标准库;DDS 工具需 Pillow)
73
-
74
- `$S` = **本技能资源目录**下的 `scripts`(加载技能时返回的 Base directory;本地安装通常是
75
- `~/.agents/skills/hoi4-modding/scripts`,从插件市场安装时在插件包的 `skills/hoi4-modding/scripts`)。
76
- Windows PowerShell 示例(`python` 不可用时换成本机 Python 绝对路径):
77
-
78
- ```powershell
79
- $S = "$env:USERPROFILE\.agents\skills\hoi4-modding\scripts" # 市场安装:换成技能返回的 Base directory\scripts
80
- $GAME = "E:\Steam\steamapps\common\Hearts of Iron IV"
81
-
82
- # 新建 Mod 骨架(--focus 可选;--tag 默认 LUX,因为 LUX 没有专属国策树)
83
- & python "$S\new_mod.py" "D:\mods\MyMod" --name "My Mod" --prefix MY --tag LUX --focus
84
-
85
- # 静态校验(语法/编码/本地化/GFX/ID冲突/.mod 结构;首次约 20s 建原版索引)
86
- & python "$S\hoi4_lint.py" "D:\mods\MyMod" --game $GAME
87
-
88
- # 只查语法、不建原版索引(快)
89
- & python "$S\hoi4_lint.py" "D:\mods\MyMod" --no-vanilla
90
-
91
- # 从官方 documentation/*.md 生成 effects/triggers/modifiers/console 参考
92
- & python "$S\build_reference.py" --game $GAME --out .\reference
93
-
94
- # 安装到玩家 mod 目录并启用(复制安装;不要 --link,路径含中文时会被警告)
95
- & python "$S\install_mod.py" "D:\mods\MyMod" --yes --enable
96
-
97
- # 卸载
98
- & python "$S\install_mod.py" "D:\mods\MyMod" --uninstall --yes
99
-
100
- # DDS 图标:生成/检查(Pillow)
101
- & python "$S\dds_helper.py" make icon.png out.dds --width 60 --height 68
102
- & python "$S\dds_helper.py" check out.dds
103
- ```
104
-
105
- > Git Bash 中把 `$S\x.py` 写成 `"$S/x.py"`、`$GAME` 写成 `/e/Steam/...` 即可。
106
- > 本机 DSH 自带 Python:`C:\Users\17876\.dsh\dsh-runtimes\dsh-primary-runtime\dependencies\python\python.exe`(含 Pillow)。
107
-
108
- `new_mod.py` 会生成:`descriptor.mod`、同级 `.mod`(path 指向目标目录)、`localisation/{english,simp_chinese}`(BOM)、1 个理念、`events/` 1 个可触发事件、可选国策树;并自动跑一次 lint。
109
-
110
- ## 5. 排错:从 error.log 反推
111
-
112
- 先确认「只启用原版 + 你的 Mod」,再 grep 自己的文件/ID:
113
-
114
- | error.log 关键字 | 常见原因 | 修法 |
115
- |---|---|---|
116
- | `Invalid Scope, supported: Country, provided: None` | effect/trigger 用错 scope | 查效果文档的 `Supported Scopes`;用 `every_country`/`GER = { }` 切 scope |
117
- | `Unknown effect-type: xxx` | 关键字拼错/版本没有/不在该 scope | `grep xxx reference/effects.json`;对照 1.19 官方文档 |
118
- | `Unknown trigger-type` / `Not a valid value` | trigger 名或参数值错误 | 查 `reference/triggers.json`;值看文档枚举 |
119
- | `Unknown modifier: xxx` | 修正名拼错(静态修正/动态修正都会) | `grep xxx reference/modifiers.json` |
120
- | `Unexpected token` | 括号/引号不平衡;`.mod` 字段拼错(如 `thumbnail`) | 跑 lint;检查 `picture=`/`path=` |
121
- | `Tried to get dynamic token` / `dynamic token ... OOS` | 本地化/脚本拼接 key 未注册 | 改用普通 loc key 或 `synchronized_dynamic_tokens` |
122
- | 图标空白/黑块 | GFX 未注册、texturefile 不存在、DDS 头不对 | `dds_helper.py check`;确认 sprite 在 `interface/*.gfx` |
123
- | 中文方框 | GUI 用了没有中文 `bitmapfont_override` 的字体名 | 换有中文覆盖的字体(见知识库 `05_presentation/chinese_fonts.md`) |
124
- | 国策树不显示 | 原版树分数更高;或树 id/坐标错误 | 按 §4 规则选「无专属树国家」或覆盖原树 |
125
-
126
- 游戏内调试:`-debug_mode` 启动,控制台(`~`/`^`)常用 `event hho.1`、`focus.autocomplete`、`debug_events`、`tag SWE`、`pp 500`;完整命令见 `reference/CHEATSHEET_console.md`(若已生成)。
127
-
128
- ## 6. 验收清单
129
-
130
- - [ ] `hoi4_lint.py` 0 error(warning 尽量清零)。
131
- - [ ] 所有新增 ID 有 en + zh 本地化,`.yml` 带 BOM。
132
- - [ ] 所有 `GFX_` 引用真实存在;自绘 DDS 尺寸/格式正确。
133
- - [ ] 没有覆盖原版整文件(除非有意);`.mod` path 为 ASCII。
134
- - [ ] 干净 playset 进游戏:新开档、触发全部内容、`error.log` 无自己文件的报错。
135
- - [ ] 发布信息(name/supported_version/tags/picture/README/依赖 DLC)齐全;联机 checksum 一致。
136
-
137
- ## 7. 深度资料
138
-
139
- 本机知识库(若存在,优先读具体主题文档):
140
-
141
- ```
142
- C:\Users\17876\Desktop\DeepseekHarness\钢铁雄心4\
143
- ├─ PLAYBOOK.md # 14 个任务配方(最常用)
144
- ├─ knowledge/00_environment.md # 两个根目录、加载顺序、覆盖语义、日志、性能
145
- ├─ knowledge/01_script/ # scope / effect/trigger / 变量 / 动态变量 / on_actions
146
- ├─ knowledge/02_content/ # 国策/事件/决议/理念/角色/科技/MIO/特殊项目…
147
- ├─ knowledge/03_military/、04_world_map/、05_presentation/、06_workflow/
148
- ├─ reference/ # 自动生成的 effects/triggers/modifiers/console 数据
149
- └─ example_mods/ # 两个可运行示例(hello_hoi4 / advanced_systems)
150
- ```
151
-
152
- 不在本机时:用 `references/cheatsheet.md` + 游戏自带 `documentation/*.md`(官方字段参考,但注意它**不是全集**:`unit_modifiers`、`is_fighting_in_strategic_region`、`is_deployed` 等 1.19 可用写法未收录,冲突时以游戏文件为准)。
153
-
154
- ## 8. 跨平台与共享
155
-
156
- 本技能是标准 Agent Skills 目录(`SKILL.md` + 可选 `scripts/`、`references/`),复制即可迁移:
157
-
158
- | 平台 | 安装位置 |
159
- |---|---|
160
- | DeepSeek Harness | `~/.agents/skills/hoi4-modding/` |
161
- | Claude Code | `~/.claude/skills/hoi4-modding/` 或项目内 `.claude/skills/hoi4-modding/` |
162
- | 其他兼容客户端 | 其 Skills 设置/目录;zip 根目录必须是 `hoi4-modding/` |
163
-
164
- - 游戏/玩家目录会**自动探测**;探测失败时设 `HOI4_GAME` / `HOI4_USER_DIR`(Linux Proton 必须设 `HOI4_USER_DIR`)。
165
- - 依赖:Python 3.10+(标准库;DDS 需 Pillow)+ 本机 HOI4 1.19.3。
166
- - 共享边界:不含游戏本体资源,只有原创笔记/脚本;不依赖本机知识库也能运行(`references/cheatsheet.md` 自足)。
167
- - 详细安装/自检/更新说明见同目录 `INSTALL.md`。
1
+ ---
2
+ name: hoi4-modding
3
+ description: 《钢铁雄心4》(Hearts of Iron IV, HOI4) 1.19.3 Mod 开发全流程技能:读游戏文件、新建 Mod、写国策/事件/决议/理念/角色/科技/州/MIO/特殊项目/scripted GUI、本地化与 DDS 图标、静态校验、安装启用、按 error.log 排错、发布创意工坊。Use whenever the user asks to create, edit, fix, validate, install, publish, or debug an HOI4 mod or asks about HOI4 scripting (scopes, effects, triggers, variables, focus trees, events, decisions, ideas, characters, MIO, special projects, GUI, localisation, DDS), even if they only say "做个国策树"/"加个事件"/"mod 报错了".
4
+ whenToUse: 用户要做/改/修/校验/安装/发布 HOI4 Mod,或问 HOI4 脚本写法(scope/effect/trigger/变量/国策/事件/决议/理念/角色/MIO/特殊项目/GUI/本地化/DDS)时。
5
+ ---
6
+
7
+ # HOI4 1.19.3 Mod 制作全流程
8
+
9
+ 面向 **1.19.3.0 "Operation Postern"**(`E:\Steam\steamapps\common\Hearts of Iron IV`)实测整理。
10
+ 目标不是讲概念,而是**一次把可运行的 Mod 做出来**:放对文件 → 写对语法 → 本地化齐全 → 校验通过 → 装进游戏 → error.log 干净。
11
+
12
+ > 本机还保留了一套 57 篇的深度知识库(见文末「深度资料」):需要查字段细节时读它;本 SKILL 与 `references/` 是压缩版,足够完成 90% 任务。
13
+
14
+ ## 0. 开始前先确认 3 件事
15
+
16
+ 1. **游戏路径**:`E:\Steam\steamapps\common\Hearts of Iron IV`(`HOI4_GAME` 环境变量可覆盖)。
17
+ 2. **版本**:`launcher-settings.json` 里 `rawVersion` 应为 `1.19.3.0`;不是就按对应版本调整语法(尤其学说/特殊项目)。
18
+ 3. **目标国家有没有专属国策树**:**1.19 每个国家同一时间只有一棵激活国策树**(`country = { }` 是打分,取最高分)。
19
+ - 没有专属树(用 `generic_focus`,如 LUX、IRE、BHU):可以新建一整棵树,`add = 10` 就接管。
20
+ - 已有专属树(SWE、GER、SOV…):不能"再加一棵";只能覆盖原树文件、或 `load_focus_tree` 换树(会顶掉原树)。先向用户确认接受哪种。
21
+
22
+ ## 1. 铁律(违反任何一条都会踩坑)
23
+
24
+ 1. **永不改游戏安装目录**;所有内容写在 Mod 目录,装到 `Documents/Paradox Interactive/Hearts of Iron IV/mod/`。
25
+ 2. **同名文件 = 整体替换**(不是合并)。优先**新增文件**,不要复制整份原版文件。
26
+ 3. **同 ID = 后者覆盖前者**;ID 用你的 `NS_` 前缀,事件用独立 `add_namespace`。
27
+ 4. **本地化 `.yml` 必须 UTF-8 with BOM**;目录名与首行根键一致(`english` → `l_english:`,`simp_chinese` → `l_simp_chinese:`)。
28
+ 5. **2D sprite 定义放 `interface/*.gfx`**,DDS 文件放 `gfx/interface/...`;`gfx/` 下的 `.gfx` 是 3D 用的。
29
+ 6. **图标尺寸**:国策 100×88(+ `_shine`)、理念 60×68、决议 32×33、决议类别 40×51、肖像 156×210、旗帜 82×52 TGA。
30
+ 7. **DDS 用未压缩 raw32 最稳**(原版 UI 同构:`dwFlags=0x81007`、无 mipmap);DXT 要求宽高为 4 的倍数。
31
+ 8. **`.mod` 的 `path` 用纯 ASCII 正斜杠**;中文路径可能加载失败 → 用 `install_mod.py` 复制到玩家目录。
32
+ 9. **`.mod` 字段是 `picture=`**,不是 `thumbnail=`;`supported_version` 写 `"1.19.*"` 或 `"1.19.3.0"`,写 `*`/`1.*` 会报错。
33
+ 10. **不要依赖 DLC**:需要 DLC 内容时用 `has_dlc = "..."` 分支并标注;特殊项目依赖 `Gotterdammerung`。
34
+ 11. **错误看 `logs/error.log`**(`[时间][游戏日期][文件:行]: 消息`),只 grep 自己的文件名/ID;原版噪声占 95%+。
35
+ 12. **脚本改动必须重启游戏**,没有完整热重载;静态校验不能替代进游戏。
36
+ 13. **科技页(`technology_folders`)的 `available` 只用 `original_tag`,不要用 `has_country_flag`**:
37
+ 引擎建页画线时会对该触发器做二次运行时求值,旗帜判定失败时**整页连线被静默丢弃**(方框还在、日志干净、旧存档可能正常而新开档必现)。见 `references/tech-tree-ui.md` §3。
38
+ 14. **大框/小框混排是三件套**:科技加 `force_use_small_tech_layout = yes` + 页面有 `techtree_<folder>_small_item` 模板 +
39
+ `GFX_technology_<folder>_small_*_item_bg` 精灵**指向真正的小图**。模板 size 只管排版,背景贴图按自身像素绘制——精灵还指着 203×84 大图时,画面就是"小框模板 + 大框外观 + 整体偏位"。
40
+
41
+ ## 2. 标准工作流
42
+
43
+ ```
44
+ 0) 侦察 读游戏文件确认目标系统/字段/原版参考(grep 原版用例)
45
+ 1) 骨架 scripts/new_mod.py 生成 descriptor.mod + .mod + 本地化 + 示例内容
46
+ 2) 内容 按 references/cheatsheet.md 的配方逐类添加(国策/事件/决议/理念/角色/科技/州/GUI…)
47
+ 3) 本地化 每个 ID 同时补 english + simp_chinese(BOM),key 规则见 cheatsheet §2
48
+ 4) 校验 python scripts/hoi4_lint.py <Mod目录>
49
+ 5) 安装 python scripts/install_mod.py <Mod目录> --yes --enable
50
+ 6) 实测 启动游戏(-debug_mode)→ 新开档 → 控制台触发 → 看 error.log
51
+ 7) 发布 descriptor.mod 的 name/supported_version/tags/picture 齐全;干净 playset 复测
52
+ ```
53
+
54
+ 每次只加一类内容、加完就校验;不要一次写 2000 行再排错。
55
+
56
+ ## 3. 配方索引(代码在 `references/cheatsheet.md`)
57
+
58
+ | 任务 | 章节 |
59
+ |---|---|
60
+ | 新建 Mod 骨架 / `.mod` 与 `descriptor.mod` | cheatsheet §1 |
61
+ | 本地化规则、key 命名、颜色/变量/图标 | §2 |
62
+ | 国家精神(idea) | §3 |
63
+ | 国策树(含一国一树规则、互斥/前置/奖励) | §4 |
64
+ | 事件(MTTH / is_triggered_only / 选项 / 事件链) | §5 |
65
+ | 决议(category / decision / targeted / 任务型) | §6 |
66
+ | 角色(领袖/顾问/将领/科学家) | §7 |
67
+ | 科技(folder / dependencies / on_research_complete) | §8 |
68
+ | **科技树 UI:页面可用性 / 连线 / 大小框 / 拆页合并 / 调试手法** | `references/tech-tree-ui.md` |
69
+ | 州、资源、建筑 | §9 |
70
+ | 动态变量 + 动态修正 | §10 |
71
+ | scripted GUI 面板(4 文件挂载) | §11 |
72
+ | MIO / 特殊项目 | §12 |
73
+ | 贴图、DDS、GFX 注册 | §13 |
74
+ | 调试命令与 error.log 对照表 | §14 |
75
+ | 1.19 与旧教程差异清单 | §15 |
76
+
77
+ ## 4. 工具(`scripts/`,仅标准库;DDS 工具需 Pillow)
78
+
79
+ `$S` = **本技能资源目录**下的 `scripts`(加载技能时返回的 Base directory;本地安装通常是
80
+ `~/.agents/skills/hoi4-modding/scripts`,从插件市场安装时在插件包的 `skills/hoi4-modding/scripts`)。
81
+ Windows PowerShell 示例(`python` 不可用时换成本机 Python 绝对路径):
82
+
83
+ ```powershell
84
+ $S = "$env:USERPROFILE\.agents\skills\hoi4-modding\scripts" # 市场安装:换成技能返回的 Base directory\scripts
85
+ $GAME = "E:\Steam\steamapps\common\Hearts of Iron IV"
86
+
87
+ # 新建 Mod 骨架(--focus 可选;--tag 默认 LUX,因为 LUX 没有专属国策树)
88
+ & python "$S\new_mod.py" "D:\mods\MyMod" --name "My Mod" --prefix MY --tag LUX --focus
89
+
90
+ # 静态校验(语法/编码/本地化/GFX/ID冲突/.mod 结构;首次约 20s 建原版索引)
91
+ & python "$S\hoi4_lint.py" "D:\mods\MyMod" --game $GAME
92
+
93
+ # 只查语法、不建原版索引(快)
94
+ & python "$S\hoi4_lint.py" "D:\mods\MyMod" --no-vanilla
95
+
96
+ # 从官方 documentation/*.md 生成 effects/triggers/modifiers/console 参考
97
+ & python "$S\build_reference.py" --game $GAME --out .\reference
98
+
99
+ # 安装到玩家 mod 目录并启用(复制安装;不要 --link,路径含中文时会被警告)
100
+ & python "$S\install_mod.py" "D:\mods\MyMod" --yes --enable
101
+
102
+ # 卸载
103
+ & python "$S\install_mod.py" "D:\mods\MyMod" --uninstall --yes
104
+
105
+ # DDS 图标:生成/检查(Pillow)
106
+ & python "$S\dds_helper.py" make icon.png out.dds --width 60 --height 68
107
+ & python "$S\dds_helper.py" check out.dds
108
+
109
+ # 科技页完整性审计(注册表 <-> 页面/页签/item 模板/网格/科技/本地化)
110
+ & python "$S/tech_tree_audit.py" "D:/mods/MyMod"
111
+
112
+ # 科技页可用性:has_country_flag -> original_tag(--check 先看,--apply 写入并备份,--revert 回滚)
113
+ & python "$S/tech_folder_available.py" "D:/mods/MyMod" --check
114
+ & python "$S/tech_folder_available.py" "D:/mods/MyMod" --apply
115
+
116
+ # item 模板尺寸 vs 背景精灵像素(专治"小框显示成大框")
117
+ & python "$S/item_sprite_check.py" "D:/mods/MyMod" --folder my_folder
118
+
119
+ # error.log 分诊(科技树 / 贴图 / scope / 未知字段 / 本地化)
120
+ & python "$S/errorlog_triage.py"
121
+ ```
122
+
123
+ > Git Bash 中把 `$S\x.py` 写成 `"$S/x.py"`、`$GAME` 写成 `/e/Steam/...` 即可。
124
+ > 本机 DSH 自带 Python:`C:\Users\17876\.dsh\dsh-runtimes\dsh-primary-runtime\dependencies\python\python.exe`(含 Pillow)。
125
+
126
+ `new_mod.py` 会生成:`descriptor.mod`、同级 `.mod`(path 指向目标目录)、`localisation/{english,simp_chinese}`(BOM)、1 个理念、`events/` 1 个可触发事件、可选国策树;并自动跑一次 lint。
127
+
128
+ ## 5. 排错:从 error.log 反推
129
+
130
+ 先确认「只启用原版 + 你的 Mod」,再 grep 自己的文件/ID:
131
+
132
+ | error.log 关键字 | 常见原因 | 修法 |
133
+ |---|---|---|
134
+ | `Invalid Scope, supported: Country, provided: None` | effect/trigger 用错 scope | 查效果文档的 `Supported Scopes`;用 `every_country`/`GER = { }` 切 scope |
135
+ | `Unknown effect-type: xxx` | 关键字拼错/版本没有/不在该 scope | `grep xxx reference/effects.json`;对照 1.19 官方文档 |
136
+ | `Unknown trigger-type` / `Not a valid value` | trigger 名或参数值错误 | 查 `reference/triggers.json`;值看文档枚举 |
137
+ | `Unknown modifier: xxx` | 修正名拼错(静态修正/动态修正都会) | `grep xxx reference/modifiers.json` |
138
+ | `Unexpected token` | 括号/引号不平衡;`.mod` 字段拼错(如 `thumbnail`) | 跑 lint;检查 `picture=`/`path=` |
139
+ | `Tried to get dynamic token` / `dynamic token ... OOS` | 本地化/脚本拼接 key 未注册 | 改用普通 loc key 或 `synchronized_dynamic_tokens` |
140
+ | 图标空白/黑块 | GFX 未注册、texturefile 不存在、DDS 头不对 | `dds_helper.py check`;确认 sprite 在 `interface/*.gfx` |
141
+ | 中文方框 | GUI 用了没有中文 `bitmapfont_override` 的字体名 | 换有中文覆盖的字体(见知识库 `05_presentation/chinese_fonts.md`) |
142
+ | 国策树不显示 | 原版树分数更高;或树 id/坐标错误 | 按 §4 规则选「无专属树国家」或覆盖原树 |
143
+ | 科技页**方框全在、连线一条没有**、日志干净 | `technology_folders.available` 用了 `has_country_flag`,建页画线阶段判定失败 → 整页 path 静默丢弃 | 改成 `original_tag = <TAG>`(`tech_folder_available.py`),**新开档**验证 |
144
+ | 小框科技显示成大框且整体偏位 | 小框模板生效了,但 `GFX_technology_<folder>_small_*_item_bg` 指向 203×84 大图 | `item_sprite_check.py` 定位后把 textureFile 换成 72×72 小图 |
145
+ | 某页永远不显示 | `available = { always = no NOT = {...} }`(AND 关系恒 false) | 去掉 `always = no`,只留 `NOT = {...}` 或 `original_tag` |
146
+
147
+ 游戏内调试:`-debug_mode` 启动,控制台(`~`/`^`)常用 `event hho.1`、`focus.autocomplete`、`debug_events`、`tag SWE`、`pp 500`;完整命令见 `reference/CHEATSHEET_console.md`(若已生成)。
148
+
149
+ ## 6. 验收清单
150
+
151
+ - [ ] `hoi4_lint.py` 0 error(warning 尽量清零)。
152
+ - [ ] 所有新增 ID 有 en + zh 本地化,`.yml` 带 BOM。
153
+ - [ ] 所有 `GFX_` 引用真实存在;自绘 DDS 尺寸/格式正确。
154
+ - [ ] 没有覆盖原版整文件(除非有意);`.mod` path 为 ASCII。
155
+ - [ ] 干净 playset 进游戏:新开档、触发全部内容、`error.log` 无自己文件的报错。
156
+ - [ ] **新开档**逐个相关国家打开科技页确认连线(旧存档会掩盖 available 触发器的时机问题)。
157
+ - [ ] `tech_tree_audit.py` 报告 0 问题;大小框混排页跑 `item_sprite_check.py` 无可疑项。
158
+ - [ ] 发布信息(name/supported_version/tags/picture/README/依赖 DLC)齐全;联机 checksum 一致。
159
+
160
+ ## 7. 深度资料
161
+
162
+ 本机知识库(若存在,优先读具体主题文档):
163
+
164
+ ```
165
+ C:\Users\17876\Desktop\DeepseekHarness\钢铁雄心4\
166
+ ├─ PLAYBOOK.md # 14 个任务配方(最常用)
167
+ ├─ knowledge/00_environment.md # 两个根目录、加载顺序、覆盖语义、日志、性能
168
+ ├─ knowledge/01_script/ # scope / effect/trigger / 变量 / 动态变量 / on_actions
169
+ ├─ knowledge/02_content/ # 国策/事件/决议/理念/角色/科技/MIO/特殊项目…
170
+ ├─ knowledge/03_military/、04_world_map/、05_presentation/、06_workflow/
171
+ ├─ reference/ # 自动生成的 effects/triggers/modifiers/console 数据
172
+ └─ example_mods/ # 两个可运行示例(hello_hoi4 / advanced_systems)
173
+ ```
174
+
175
+ 不在本机时:用 `references/cheatsheet.md` + 游戏自带 `documentation/*.md`(官方字段参考,但注意它**不是全集**:`unit_modifiers`、`is_fighting_in_strategic_region`、`is_deployed` 等 1.19 可用写法未收录,冲突时以游戏文件为准)。
176
+
177
+ ## 8. 跨平台与共享
178
+
179
+ 本技能是标准 Agent Skills 目录(`SKILL.md` + 可选 `scripts/`、`references/`),复制即可迁移:
180
+
181
+ | 平台 | 安装位置 |
182
+ |---|---|
183
+ | DeepSeek Harness | `~/.agents/skills/hoi4-modding/` |
184
+ | Claude Code | `~/.claude/skills/hoi4-modding/` 或项目内 `.claude/skills/hoi4-modding/` |
185
+ | 其他兼容客户端 | 其 Skills 设置/目录;zip 根目录必须是 `hoi4-modding/` |
186
+
187
+ - 游戏/玩家目录会**自动探测**;探测失败时设 `HOI4_GAME` / `HOI4_USER_DIR`(Linux Proton 必须设 `HOI4_USER_DIR`)。
188
+ - 依赖:Python 3.10+(标准库;DDS 需 Pillow)+ 本机 HOI4 1.19.3。
189
+ - 共享边界:不含游戏本体资源,只有原创笔记/脚本;不依赖本机知识库也能运行(`references/cheatsheet.md` 自足)。
190
+ - 详细安装/自检/更新说明见同目录 `INSTALL.md`。