This commit is contained in:
wdjwxh 2026-03-22 11:18:51 +08:00
parent c3e28bf7de
commit 73cc023b1a
1 changed files with 38 additions and 21 deletions

View File

@ -42,10 +42,12 @@ scripts/wiki_sync.py --title "<页面名称>" --since <上次同步时间> --run
| 文件 | 说明 | 用途 | | 文件 | 说明 | 用途 |
|------|------|------| |------|------|------|
| `*.comparison.json` | 结构化变更信息 | **AI 读取,包含行号和变更内容** | | `*.comparison.json` | 结构化变更信息 | **必须读取,包含行号和变更内容** |
| `*.full.txt` | 英文最新版本 | 参考对照 | | `*.full.txt` | 英文最新版本 | 需要时参考 |
| `*.cn.txt` | 中文原文 | **基于此文件进行修改** | | `*.cn.txt` | 中文原文 | **复制到 result_pages不直接读取** |
| `*.old.txt` | 英文历史版本 | 参考对照 | | `*.old.txt` | 英文历史版本 | 需要时参考 |
**重要:** 只读取 `comparison.json`,不要读取整个 `*.cn.txt` 文件以节省 token。
### Step 3: 解析 comparison.json ### Step 3: 解析 comparison.json
@ -80,21 +82,36 @@ scripts/wiki_sync.py --title "<页面名称>" --since <上次同步时间> --run
### Step 4: 更新中文文档 ### Step 4: 更新中文文档
**核心原则:行号必须完全一致** **核心原则:行号必须完全一致,使用增量修改减少 token 消耗**
1. 创建 `wiki_sync_output/<时间戳>/result_pages/` 目录(如不存在) 1. 创建 `wiki_sync_output/<时间戳>/result_pages/` 目录(如不存在)
2. 复制 `*.cn.txt` 内容到 `result_pages/<页面名>.cn.txt` 2. **判断页面类型**
3. 根据 `changes` 中的行号定位对应行 - **已有中文翻译**`has_cn_translation: true`):复制 `*.cn.txt` 到 result_pages然后用 Edit 增量修改
4. 智能更新: - **新页面**`has_cn_translation: false` 或 `is_new_page: true`):读取 `*.full.txt` 英文版本,翻译后直接 Write 到 result_pages
- 仅同步变更的内容 3. **使用 Edit 工具**增量修改(仅适用于已有翻译的页面):
- 根据 `old_line` 定位要修改的行
- 从 `*.cn.txt` 中提取该行的**完整内容**作为 `old_string`
- 构造新的行内容作为 `new_string`
- 智能更新规则:
- 仅同步变更的内容(如日期、数值)
- 保留中文翻译(如 "赛季 12" 不改为 "Season 12" - 保留中文翻译(如 "赛季 12" 不改为 "Season 12"
- 新增的英文内容智能翻译成中文,可以用`grep` 命令在`references/PatchString.txt` 搜索技能或物品的中文名称,搜索不到的则智能翻译按照暗黑破坏神2的常用命名。 - 新增的英文内容智能翻译成中文,可以用 `Grep` 工具在 `references/PatchString.txt` 搜索技能或物品的中文名称
- 保持 MediaWiki 语法正确,语法可以参照`mediawiki-wikitest` skill. - 保持 MediaWiki 语法正确
5. 保存到 `wiki_sync_output/<时间戳>/result_pages/<页面名>.cn.txt` 4. 每次变更使用一次 Edit 调用
**示例操作流程:**
```bash
# 1. 复制文件
cp wiki_sync_output/<时间戳>/changed_pages/*.cn.txt wiki_sync_output/<时间戳>/result_pages/<页面名>.cn.txt
```
```json
// 2. 从 comparison.json 获取变更假设第66行需要修改
// 3. 只读取该行附近内容确认,然后用 Edit 修改
```
### Step 5: 输出结果 ### Step 5: 输出结果
将更新后的文档保存到 `wiki_sync_output/<时间戳>/result_pages/<页面名>.cn.txt`,用户可直接复制到 Wiki。 更新后的文档位于 `wiki_sync_output/<时间戳>/result_pages/<页面名>.cn.txt`,用户可直接复制到 Wiki。
## 示例 ## 示例