Skip to content

完善翻译技能:MTool 工作流、术语校验与 Unity 文本审计 - #6

Merged
timeance merged 1 commit into
mainfrom
agent/absorb-translation-skill-workflows
Aug 13, 2026
Merged

timeance merged 1 commit into
mainfrom
agent/absorb-translation-skill-workflows

Conversation

@timeance

@timeance timeance commented Aug 12, 2026 •

Copy link
Copy Markdown
Owner

更新概览

本 PR 将参考技能中可复用的翻译、校验和运行时审计流程整合到 ainiee-translate 与 unity-text-locator。共修改 15 个文件,新增 1,586 行、删除 5 行。

ainiee-translate 的变动

MTool 扁平 JSON 工作流

  • 新增 ainiee_translate.mtool,覆盖输入检查、技术项直通、分组拆分、结果验证、进度统计、译文合并和最终键验证。
  • MTool 左侧 JSON key 始终作为不可修改的运行时匹配原文,只允许更新右侧 value。
  • 子代理只能写各自分组的临时结果;结果验证通过后再原子改名。共享 cache.json 只能由主代理串行写入。
  • 分组合并默认要求每个源分组都有通过验证的正式结果。取消或异常时不写回未验收内容,也不导出部分成品。

术语候选与词典导出

  • 新增 extract_terms.py,从 AiNiee cache.json 只读提取术语候选,归一化读音、片假名和短标签,并按出现频率筛选。
  • 资源名称等低置信度线索单独写入 resource_hints,不直接进入词典。
  • 新增 curate_terms.py,把人工确认的译名导出为 AiNiee {src,dst,info} 格式。
  • 同一原文或别名对应多个译名时阻断导出,不猜测、不静默覆盖。

源文感知质量检查(source-aware QA)

  • 新增 audit_translation.py,按 text_index 对照源文与译文,检查重复、缺失和额外记录。
  • 逐条检查控制符、标签、占位符、换行序列、日文对话引号和已锁定术语;索引映射或结构不完整时按失败关闭(fail-closed)处理。
  • 新增 apply_repairs.py。修复项必须提供 replacement,且 expected_before 必须与当前译文完全一致。
  • 修复结果写入独立文件。重复索引、不存在的索引或已经过期的 expected_before 会被拒绝,不直接覆盖原始译文或共享缓存。

unity-text-locator 的变动

Unity 内嵌 CSV 发现

  • 新增 extract_embedded_csv.py,扫描 sharedassets*.assets 和 AssetBundle 中的内嵌 CSV 数据。
  • 使用 CSV 解析器读取记录,保留重复原文对应的每个文本出现位置(occurrence)。
  • 每条记录包含游戏相对源路径、源文件 SHA-256、字节偏移、记录号、行标识和列名,便于后续定位和人工复核。
  • 该工具只负责发现与审计,不提供通用 AssetBundle 写回(writeback),也不生成全局 original_flat -> translation 映射。

AutoTranslator 运行时差异

  • 新增 diff_autotranslator_files.py,对比两份 _PreTranslated.txt,统计新增、删除、修改和未变化条目,并输出样例。
  • 任一输入存在重复 key 时,报告状态设为 blocked 并返回非零退出码。
  • 工具只生成运行时差异(runtime diff)报告,不自动合并文件、安装加载器或部署译文。删除项和大范围变更必须人工检查并进行运行时 canary 验证。

保留的安全边界

  • 现有依赖版本范围、缓存原子保存、重复 text_index 拒绝、源文指纹校验和失败时非零退出均保持不变。
  • 术语冲突、结构不一致、重复运行时 key 和过期修复清单都会阻断后续输出。
  • 运行时捕获、内嵌 CSV 结果和修复清单都需要人工确认,不能直接进入写回或发布流程。

验证结果

  • 官方 skill-creator/quick_validate.py:两个技能均通过。
  • Python 3.12 完整测试:50/50 通过,其中新增 7 个回归测试,覆盖 MTool 控制标记、术语冲突、索引与结构异常、过期修复、重复 occurrence 和重复运行时 key。
  • GitHub Actions:Ubuntu 和 Windows 共 4 个任务通过。
  • 对包含 113,321 条记录的真实 AiNiee 缓存执行只读提取,得到 1,785 个术语候选和 5,117 个独立资源提示。
  • 新增 Python 入口通过语法编译,git diff --check 通过;未发现固定个人路径或常见 GitHub 凭据。

@timeance timeance changed the title Expand translation skill QA workflows 完善翻译技能:MTool 工作流、术语校验与 Unity 文本审计 Aug 13, 2026
@timeance
timeance marked this pull request as ready for review August 13, 2026 02:56
@timeance
timeance merged commit 213815f into main Aug 13, 2026
4 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 58870812ae

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +17 to +24
line = line.strip()
if not line or line.startswith("//") or line.startswith("#") or "=" not in line:
continue
key, value = line.split("=", 1)
key = key.strip()
if key in entries:
duplicates.append(key)
entries[key] = value.strip()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve edge whitespace while parsing runtime entries

When either candidate contains keys or values with leading/trailing whitespace, stripping the entire line and both fields changes the runtime entry before comparison. The existing generator explicitly allows edge-whitespace keys and emits fields verbatim, so a change such as " foo" to "foo", or a value-only whitespace change, can be reported as unchanged or as a false duplicate even though the runtime files differ.

Useful? React with 👍 / 👎.

Comment on lines +103 to +106
parsed = parse_table(table, source_file, offset, source_hash)
if parsed:
parsed["signature"] = signature.decode("utf-8", errors="replace")
results.append(parsed)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Deduplicate overlapping signature matches

When a table header is ID,Name,Description, both the ID,Name and Name,Description signatures match the same header. Because extract_table rewinds each match to the beginning of that line, this appends the same table twice with different offsets, doubling every occurrence and producing incorrect audit counts and identities.

Useful? React with 👍 / 👎.

Comment on lines +43 to +46
end = min(len(data), offset + 65536)
null = data.find(b"\x00\x00\x00\x00", offset, end)
if null != -1:
end = null

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid silently truncating embedded tables at 64 KiB

For an embedded CSV larger than 65,536 bytes whose terminator lies beyond this window, the extractor cuts the table at an arbitrary byte boundary but still parses and reports all complete rows before the cutoff as a valid table. Large item or dialogue tables therefore yield silently incomplete occurrence manifests rather than being fully scanned or explicitly rejected as truncated.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant