@lynn123411/dsh-chat-translate 1.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ChuanTianML
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # @lynn123411/dsh-chat-translate
2
+
3
+ DeepSeek Harness Web 界面的工具调用与思考摘要智能翻译插件。自动将当前会话中工具调用标题与思考折叠摘要翻译为中文,采用非侵入式双语对照渲染(点击译文可切换原文),不污染会话上下文。内置 OpenAI 兼容 AI 翻译与免 Key Bing 兜底双通道。
4
+
5
+ ## 特性
6
+
7
+ - **工具调用与思考摘要自动翻译**:仅在渲染层将工具调用动作描述(如 `Locate DSH home directory structure`)与思考折叠摘要自动翻译为中文,对话正文永不翻译,保持思考正文原生不干扰。
8
+ - **AI 翻译通道(OpenAI 兼容协议)**:对接任意 OpenAI 兼容的 `chat/completions` 服务(OpenAI、DeepSeek、通义、Ollama 等),Base URL 与模型可在设置面板配置;API Key 从 `~/.dsh/.credentials.yaml` 的 `TRANSLATE_API_KEY` 读取,填写后立即生效。
9
+ - **Bing 免 Key 兜底通道**:内置微软 Bing 网页翻译(免 Key、国内直连),AI 未配置或请求失败时自动兜底;双通道均有独立开关,同时关闭则不翻译。
10
+ - **非侵入式 DOM 挂载与双语对照**:非侵入式包装保留原始 DOM 节点与 React Fiber 事件系统;点击译文可原地在原文与中文之间切换。
11
+ - **智能内容脱敏与占位符保护**:翻译前对多行代码块、内联代码、URL 链接、文件路径及 CLI 命令行参数进行占位符脱敏与鲁棒还原,杜绝代码与路径被误翻译。
12
+ - **当前会话作用域**:仅翻译当前查看的会话,切换会话自动跟随新内容;视口懒加载(150px 缓冲)与文档顺序排队,译文按阅读顺序出现。
13
+ - **智能调度与熔断保护**:1–100 动态并发限流队列、AI 30s / Bing 2s 超时、连续失败熔断自愈、在途请求合并去重、7 天 LRU 双级缓存(Client `localStorage` + Host 磁盘持久化)。
14
+ - **设置面板集成**:在「设置 - 聊天翻译」中提供总开关、AI/Bing 通道开关、Base URL 与模型配置、通道测试与并发数调节。
15
+
16
+ ## 安装
17
+
18
+ ```bash
19
+ dsh plugin --profile web add @lynn123411/dsh-chat-translate
20
+ ```
21
+
22
+ ## 配置
23
+
24
+ 1. **API Key**:打开「设置 - 聊天翻译」,在 AI 翻译卡片中直接填写 API Key 并保存(写入 `~/.dsh/.credentials.yaml` 的 `TRANSLATE_API_KEY`,权限 0600,保存后立即生效;留空保存 = 清除该键)。也可以手动编辑该文件:
25
+
26
+ ```yaml
27
+ refs:
28
+ TRANSLATE_API_KEY: sk-xxx
29
+ ```
30
+
31
+ > ⚠️ **注意**:DSH 的凭据加载器要求 refs 键值非空。手动编辑时要么填写真实 Key,要么**直接删除该行**——不要写成 `TRANSLATE_API_KEY: ""` 这类空值,否则 DSH 启动会失败。未配置时插件自动由 Bing 通道兜底,不会报错。
32
+
33
+ 2. **Base URL 与模型**:在「设置 - 聊天翻译」中填写 Base URL(如 `https://api.openai.com/v1` 或 `https://api.deepseek.com/v1`)与模型名(如 `gpt-4o-mini`、`deepseek-chat`),点击「测试 AI 通道」验证。
34
+
35
+ 3. **通道行为**:AI 开启且已配置 → AI 优先、失败降级 Bing;AI 开启但未配置 + Bing 开启 → Bing 翻译;AI 未配置 + Bing 关闭 → 不翻译;AI 关闭 + Bing 开启 → 直接 Bing;双关 → 不翻译。
@@ -0,0 +1,6 @@
1
+ # @lynn123411/dsh-chat-translate bundle patch
2
+ # 声明在 package.json 的 dsh.bundle.patch,`dsh plugin add` 后自动并入 profile 层栈。
3
+ # 浏览器半区(lib/client.js)由 client-modules 依据 dsh.client 声明自动发现。
4
+ - insert:
5
+ - id: dsh-chat-translate
6
+ name: '@lynn123411/dsh-chat-translate'
@@ -0,0 +1,13 @@
1
+ {
2
+ "id": "dsh-chat-translate",
3
+ "version": "1.1.0",
4
+ "main": "lib/index.js",
5
+ "description": "Tool-call & think-summary translation with dual AI (OpenAI-compatible) + Bing channels for the DeepSeek Harness Web UI.",
6
+ "engines": {
7
+ "dsh": ">=0.1.0-rc.6"
8
+ },
9
+ "contributes": {
10
+ "tools": [],
11
+ "skills": []
12
+ }
13
+ }