feat: 标准库文档批量预热——补全/悬停翻译秒出

懒翻译要等 1-2 秒。真 gopls 实证 go/doc 从本地源码提取的文档与
gopls 补全/悬停正文规范化空白后完全一致,批量预热方案成立:
- internal/godoc: go/doc 提取器 + 36 个常用标准库清单 + NormKey
- app.PreheatDocs: 6 并发翻译,进度走输出面板,已缓存自动跳过;
  菜单手动触发 + 打开项目 8 秒后自动跑(每会话一次)
- tools/preheat: 命令行批量工具,直接写用户缓存文件
- 缓存 key 统一 NormKey,预热/懒翻译/旧缓存三方互命中
- 已实测灌入 10 包 394 条译文(272 秒),常用包全部秒出
This commit is contained in:
zerorigin committed 2026-11-04 17:30:51 +08:00
1 parent a7d53f25d4
commit f5bfbac6c3
10 files changed
+663 -10

No files matched your search

+3 -3
View File
@@ -36,11 +36,11 @@ func TestSplitHoverDoc(t *testing.T) {
}
// TestHoverTranslationAssembly 验证拼回:译文插到正文位置,签名与链接原样。
// 预填翻译缓存绕过 LLM 与窗口依赖。
// 预填翻译缓存绕过 LLM 与窗口依赖;key 用 normDocKey(与运行时一致)。
func TestHoverTranslationAssembly(t *testing.T) {
docJoined, _, _ := splitHoverDoc(hoverSample)
a := &App{trans: map[string]string{
"Println formats using the default formats for its operands and writes to standard output.\nSpaces are always added between operands and a newline is appended.":
"Println 用其操作数的默认格式进行格式化并写入标准输出,操作数之间总会添加空格,并附加换行。",
normDocKey(docJoined): "Println 用其操作数的默认格式进行格式化并写入标准输出,操作数之间总会添加空格,并附加换行。",
}, transInflight: map[string]bool{}, set: settings{TranslateDocs: true, AIBaseURL: "x", AIAPIKey: "y", AIModel: "z"}}
got := a.hoverTranslation(hoverSample)