From 73cc023b1a1941572740c62b7e2fe4e972955bd2 Mon Sep 17 00:00:00 2001 From: wdjwxh Date: Sun, 22 Mar 2026 11:18:51 +0800 Subject: [PATCH] fix --- .claude/skills/wiki-sync-translate/SKILL.md | 59 +++++++++++++-------- 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/.claude/skills/wiki-sync-translate/SKILL.md b/.claude/skills/wiki-sync-translate/SKILL.md index 2bc5a5e..14cf3b6 100644 --- a/.claude/skills/wiki-sync-translate/SKILL.md +++ b/.claude/skills/wiki-sync-translate/SKILL.md @@ -36,16 +36,18 @@ scripts/wiki_sync.py --title "<页面名称>" --since <上次同步时间> --run - `--since`: 起始时间,格式如 `2026-01-02T12:07:05Z` - `--run`: 必须提供此参数才会执行 -### Step 2: 读取输出文件 +### Step 2: 读取输出文件 -脚本会在 `wiki_sync_output/<时间戳>/changed_pages/` 目录下生成: +脚本会在 `wiki_sync_output/<时间戳>/changed_pages/` 目录下生成: -| 文件 | 说明 | 用途 | -|------|------|------| -| `*.comparison.json` | 结构化变更信息 | **AI 读取,包含行号和变更内容** | -| `*.full.txt` | 英文最新版本 | 参考对照 | -| `*.cn.txt` | 中文原文 | **基于此文件进行修改** | -| `*.old.txt` | 英文历史版本 | 参考对照 | +| 文件 | 说明 | 用途 | +|------|------|------| +| `*.comparison.json` | 结构化变更信息 | **必须读取,包含行号和变更内容** | +| `*.full.txt` | 英文最新版本 | 需要时参考 | +| `*.cn.txt` | 中文原文 | **复制到 result_pages,不直接读取** | +| `*.old.txt` | 英文历史版本 | 需要时参考 | + +**重要:** 只读取 `comparison.json`,不要读取整个 `*.cn.txt` 文件以节省 token。 ### Step 3: 解析 comparison.json @@ -80,21 +82,36 @@ scripts/wiki_sync.py --title "<页面名称>" --since <上次同步时间> --run ### Step 4: 更新中文文档 -**核心原则:行号必须完全一致** +**核心原则:行号必须完全一致,使用增量修改减少 token 消耗** -1. 创建 `wiki_sync_output/<时间戳>/result_pages/` 目录(如不存在) -2. 复制 `*.cn.txt` 内容到 `result_pages/<页面名>.cn.txt` -3. 根据 `changes` 中的行号定位对应行 -4. 智能更新: - - 仅同步变更的内容 - - 保留中文翻译(如 "赛季 12" 不改为 "Season 12") - - 新增的英文内容智能翻译成中文,可以用`grep` 命令在`references/PatchString.txt` 搜索技能或物品的中文名称,搜索不到的则智能翻译按照暗黑破坏神2的常用命名。 - - 保持 MediaWiki 语法正确,语法可以参照`mediawiki-wikitest` skill. -5. 保存到 `wiki_sync_output/<时间戳>/result_pages/<页面名>.cn.txt` +1. 创建 `wiki_sync_output/<时间戳>/result_pages/` 目录(如不存在) +2. **判断页面类型**: + - **已有中文翻译**(`has_cn_translation: true`):复制 `*.cn.txt` 到 result_pages,然后用 Edit 增量修改 + - **新页面**(`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") + - 新增的英文内容智能翻译成中文,可以用 `Grep` 工具在 `references/PatchString.txt` 搜索技能或物品的中文名称 + - 保持 MediaWiki 语法正确 +4. 每次变更使用一次 Edit 调用 -### Step 5: 输出结果 - -将更新后的文档保存到 `wiki_sync_output/<时间戳>/result_pages/<页面名>.cn.txt`,用户可直接复制到 Wiki。 +**示例操作流程:** +```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: 输出结果 + +更新后的文档位于 `wiki_sync_output/<时间戳>/result_pages/<页面名>.cn.txt`,用户可直接复制到 Wiki。 ## 示例