dsh-think-translate 1.0.13 → 1.2.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/README.md CHANGED
@@ -1,97 +1,108 @@
1
- <div align="center">
2
-
3
- # 🐋 dsh-think-translate
4
-
5
- **Languages:** [English](README.md) · [中文](README.zh-CN.md) · [日本語](README.ja.md) · [한국어](README.ko.md) · [Español](README.es.md) · [Français](README.fr.md) · [Deutsch](README.de.md) · [Русский](README.ru.md)
6
-
7
- [![npm version](https://img.shields.io/npm/v/dsh-think-translate?color=4D6BFE&label=npm)](https://www.npmjs.com/package/dsh-think-translate)
8
- [![license](https://img.shields.io/npm/l/dsh-think-translate?color=4D6BFE)](LICENSE)
9
- [![dsh](https://img.shields.io/badge/powered_by-dsh-4D6BFE?style=flat-square&logo=deepseek&logoColor=white)](https://github.com/deepseek-ai/deepseek-harness)
10
-
11
- <img src="demo/demo.gif" width="46%" alt="dsh-think-translate demo" style="border:1px solid #4D6BFE;border-radius:8px;margin:4px" />
12
- <img src="demo/demo2.gif" width="46%" alt="dsh-think-translate demo 2" style="border:1px solid #4D6BFE;border-radius:8px;margin:4px" />
13
-
14
- </div>
15
-
16
- ---
17
-
18
- Translate the **reasoning / thinking chain (chain-of-thought), task cards and answers** of the [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) Web UI into one of **8 target languages** — in real time, on the display layer only. The originals stay untouched in the transcript, and the translated text **never enters the model context**.
19
-
20
- ## ✨ Why dsh-think-translate
21
-
22
- DeepSeek-class models often reason in Chinese — or in whatever language they happen to think in. dsh-think-translate renders the **Think row, task cards and answer** in *your* language while you watch, like subtitles for the model's thinking.
23
-
24
- - **🕵️ Read any thinking chain** — reasoning, chain-of-thought, task cards and answers translated in real time, streamed batch by batch
25
- - **🌍 8 languages, one consistent UI** — 中文 / English / 日本語 / 한국어 / Español / Français / Deutsch / Русский; the settings panel, thinking rows and task cards all follow your choice, and it persists across reloads
26
- - **🔒 Private & offline-first** — local Ollama (qwen2.5:7b / 14b or custom) is the default provider: free, unlimited, nothing leaves your machine. First local-model selection **auto-downloads** the model with a live progress bar and enables it when done
27
- - **🧠 Zero context cost** — pure display layer: the model still sees the original text, and translated text never consumes the context window
28
- - **☁️ Google / Bing fallback** — automatic switch when the local model is unavailable (google goes through a Node CONNECT tunnel using the system proxy, bypassing anti-bot blocks)
29
- - **🛡️ Code-safe** — file paths, commands, URLs, regexes and pure-code lines are never translated
30
- - **🧩 Paragraph & sentence-aware chunking** — long thinking chains are split on blank lines (paragraph structure preserved) and further batched by sentence, so even a small local model keeps quality
31
- - **⏱️ Resilient** — 3× backoff retries, browser-direct fallback, failed results never cached
32
- - **🎚️ Adjustable translation timing** — pre-translate everything, lazy-load historical chains (default), or translate only the expanded chain
33
-
34
- ## 📦 Installation
35
-
36
- ```bash
37
- # Option 1: npm (recommended)
38
- dsh plugin --profile web add dsh-think-translate
39
- # then restart web
40
-
41
- # Option 2: GitHub
42
- dsh plugin --profile web add github:UncleK/dsh-think-translate
43
-
44
- # Option 3: manual (junction + patch)
45
- # 1. link the package into the profile's node_modules
46
- New-Item -ItemType Junction -Path "$HOME\.dsh\profiles\node_modules\dsh-think-translate" `
47
- -Target "<repo path>"
48
- # 2. add to "$HOME\.dsh\profiles\web\cordis.patch.yml":
49
- # - insert:
50
- # - id: dsh-think-translate
51
- # name: dsh-think-translate
52
- # 3. restart web
53
- ```
54
-
55
- ## 🧯 After a DSH upgrade
56
-
57
- Third-party client plugins load through DSH's client module graph, and that graph is composed **once per process** — a composition that failed is remembered in memory until the process restarts. So these three things commonly bite right after an upgrade:
58
-
59
- - **Starting from a source checkout fails with** `client bundles not found; run \`pnpm run build\` before launch` — the new client packages ship unbuilt: run `pnpm run build` in the harness checkout, then start `dsh web` again.
60
- - **The plugin's UI is gone** (no translated Think row, no *Think Translation* section in Settings) — **restart `dsh web`**; refreshing the page alone is sometimes not enough.
61
- - **The local model list is empty** — the `ollama` service is not serving that model directory: check `ollama list` (or `GET /api/tags`) and the `OLLAMA_MODELS` the running service actually uses. When the model files live on another drive, a directory junction can point the service's default directory at them.
62
-
63
- Nothing to configure on the plugin side: it declares no ordering dependency on DSH internals (it binds only to the `slots` service, plus an optional `@deepseek-ai/dsh-client-ui-primitives`), so it runs on both older DSH (≤ 0.1.1-rc) and the current line (≥ 0.1.2-alpha.1, 0.1.5-rc.1 included).
64
-
65
- ## 🚀 Usage
66
-
67
- 1. Open **Settings → Think Translation**
68
- 2. Pick the **target language** (e.g. 日本語) — the settings panel, thinking rows and task cards all switch to it
69
- 3. Pick the **preferred provider**:
70
- - **Local model (Ollama)** — on first selection a download prompt appears (qwen2.5:7b / 14b or custom); it auto-enables when finished. The "+" button next to the model picker downloads more models anytime
71
- - **google gtx / bing** — works out of the box (auto system proxy / VPN)
72
- 4. Send a message that makes the model think, then expand the **Think row** to read the translation and compare with the original
73
-
74
- ## ⚙️ How it works
75
-
76
- ```
77
- browser → POST /_xlate/translate (same-origin, no CORS)
78
- → host provider chain (fail-open):
79
- openai-compatible (local Ollama, Node fetch to loopback)
80
- → google gtx (Node https + CONNECT tunnel through system proxy)
81
- → bing (curl form)
82
- → browser-direct fallback
83
- ```
84
-
85
- - **Host half** (`lib/index.js`): provider adapters, LRU cache (600), `/_xlate/models` listing, `/_xlate/model/pull` + `pull-status` model download management (auto-configures on completion)
86
- - **Client half** (`lib/client.js`): 8-language UI, sentence/paragraph-batched translation, streaming Think rows, localStorage persistence (settings + translation cache)
87
- - Pure display layer: originals remain in the transcript and model context
88
-
89
- ## 🛠 Development
90
-
91
- - No build step: `lib/client.js` is the browser bundle (source = artifact), `lib/index.js` is the host ESM
92
- - Client changes apply on page refresh; host changes need a web restart
93
- - The 8-language strings live in the `UI_TEXT` dictionary in `lib/client.js`
94
-
95
- ## 📄 License
96
-
97
- MIT
1
+ <div align="center">
2
+
3
+ # 🐋 dsh-think-translate
4
+
5
+ **Languages:** [English](README.md) · [中文](README.zh-CN.md) · [日本語](README.ja.md) · [한국어](README.ko.md) · [Español](README.es.md) · [Français](README.fr.md) · [Deutsch](README.de.md) · [Русский](README.ru.md)
6
+
7
+ [![npm version](https://img.shields.io/npm/v/dsh-think-translate?color=4D6BFE&label=npm)](https://www.npmjs.com/package/dsh-think-translate)
8
+ [![license](https://img.shields.io/npm/l/dsh-think-translate?color=4D6BFE)](LICENSE)
9
+ [![dsh](https://img.shields.io/badge/powered_by-dsh-4D6BFE?style=flat-square&logo=deepseek&logoColor=white)](https://github.com/deepseek-ai/deepseek-harness)
10
+
11
+ <img src="demo/demo.gif?v=2" width="46%" alt="dsh-think-translate demo" style="border:1px solid #4D6BFE;border-radius:8px;margin:4px" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="demo/demo2.gif?v=2" width="41%" alt="dsh-think-translate demo 2" style="border:1px solid #4D6BFE;border-radius:8px;margin:4px" />
12
+
13
+ </div>
14
+
15
+ ---
16
+
17
+ Translate the **reasoning / thinking chain (chain-of-thought), task cards and answers** of the [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) Web UI into one of **8 target languages** — in real time, on the display layer only. The originals stay untouched in the transcript, and the translated text **never enters the model context**.
18
+
19
+ ## ✨ Why dsh-think-translate
20
+
21
+ DeepSeek-class models often reason in Chinese — or in whatever language they happen to think in. dsh-think-translate renders the **Think row, task cards and answer** in *your* language while you watch, like subtitles for the model's thinking.
22
+
23
+ - **🕵️ Read any thinking chain** — reasoning, chain-of-thought, task cards and answers translated in real time, streamed batch by batch
24
+ - **🌍 8 languages, one consistent UI** — 中文 / English / 日本語 / 한국어 / Español / Français / Deutsch / Русский; the settings panel, thinking rows and task cards all follow your choice, and it persists across reloads
25
+ - **🔗 Dynamic provider chain** — order providers by drag-and-drop and enable/disable each one. Built-ins (google gtx, bing, local Ollama) plus any number of custom providers; the chain already ends with the free providers, so a second fallback pass is a config-file option, not a UI one
26
+ - **🔌 Custom providers (OpenAI & Anthropic)** — add arbitrary OpenAI-compatible endpoints (any `/v1/chat/completions` gateway) or native **Anthropic Messages API** endpoints (Claude) from the settings panel: name, type, base URL, API key, model
27
+ - **🪄 DSH provider discovery** — providers already configured in DSH's `settings.yaml` (`llm-pi-ai.providers`, e.g. linuxdo-hub, coding-hub) are auto-discovered and appear in the chain as read-only "DSH" entries, and **one button in settings rescans and adds them all at once**; keys are resolved from `.credentials.yaml` at runtime and never written to the plugin's config
28
+ - **🔒 Private & offline-first** — local Ollama (qwen2.5:7b / 14b or custom) is a first-class provider: free, unlimited, nothing leaves your machine. First local-model selection **auto-downloads** the model with a live progress bar and enables it when done
29
+ - **🧠 Zero context cost** — pure display layer: the model still sees the original text, and translated text never consumes the context window
30
+ - **☁️ Google / Bing fallback** — automatic switch when other providers are unavailable (google goes through a Node CONNECT tunnel using the system proxy, bypassing anti-bot blocks)
31
+ - **🛡️ Code-safe** — file paths, commands, URLs, regexes and pure-code lines are never translated
32
+ - **🧩 Paragraph & sentence-aware chunking** — long thinking chains are split on blank lines (paragraph structure preserved) and further batched by sentence, so even a small local model keeps quality
33
+ - **⏱️ Resilient** — 3× backoff retries, per-provider test buttons, failed results never cached
34
+ - **🎚️ Adjustable translation timing** — pre-translate everything, lazy-load historical chains (default), or translate only the expanded chain
35
+
36
+ ## 📦 Installation
37
+
38
+ ```bash
39
+ # Option 1: npm (recommended)
40
+ dsh plugin --profile web add dsh-think-translate
41
+ # then restart web
42
+
43
+ # Option 2: GitHub
44
+ dsh plugin --profile web add github:UncleK/dsh-think-translate
45
+
46
+ # Option 3: manual (junction + patch)
47
+ # 1. link the package into the profile's node_modules
48
+ New-Item -ItemType Junction -Path "$HOME\.dsh\profiles\node_modules\dsh-think-translate" `
49
+ -Target "<repo path>"
50
+ # 2. add to "$HOME\.dsh\profiles\web\cordis.patch.yml":
51
+ # - insert:
52
+ # - id: dsh-think-translate
53
+ # name: dsh-think-translate
54
+ # 3. restart web
55
+ ```
56
+
57
+ ## 🧯 After a DSH upgrade
58
+
59
+ Third-party client plugins load through DSH's client module graph, and that graph is composed **once per process** — a composition that failed is remembered in memory until the process restarts. So these three things commonly bite right after an upgrade:
60
+
61
+ - **Starting from a source checkout fails with** `client bundles not found; run \`pnpm run build\` before launch` — the new client packages ship unbuilt: run `pnpm run build` in the harness checkout, then start `dsh web` again.
62
+ - **The plugin's UI is gone** (no translated Think row, no *Think Translation* section in Settings) — **restart `dsh web`**; refreshing the page alone is sometimes not enough.
63
+ - **The local model list is empty** — the `ollama` service is not serving that model directory: check `ollama list` (or `GET /api/tags`) and the `OLLAMA_MODELS` the running service actually uses. When the model files live on another drive, a directory junction can point the service's default directory at them.
64
+
65
+ Nothing to configure on the plugin side: it declares no ordering dependency on DSH internals (it binds only to the `slots` service, plus an optional `@deepseek-ai/dsh-client-ui-primitives`), so it runs on both older DSH (≤ 0.1.1-rc) and the current line (≥ 0.1.2-alpha.1, 0.1.5-rc.1 included).
66
+
67
+ ## 🚀 Usage
68
+
69
+ 1. Open **Settings → Think Translation**
70
+ 2. Pick the **target language** (e.g. 日本語) — the settings panel, thinking rows and task cards all switch to it
71
+ 3. **Manage the provider chain** — the list below it *is* the delivery order; drag rows to reorder, and the checkbox is the on/off switch:
72
+ - Built-ins: **google gtx / bing** (free, works out of the box via system proxy) and **local Ollama** — on first local-model selection a download prompt appears (qwen2.5:7b / 14b or custom); it auto-enables when finished. Built-ins are permanent: uncheck one to stop using it, there is nothing to delete
73
+ - **DSH providers**: endpoints already configured in DSH (`llm-pi-ai.providers`) appear automatically as read-only entries (badge "DSH"); their checkbox adds/removes them from the chain. The **Import from DSH config** button right below the list rescans on click and adds all of them in one go — there is no base URL and no key to retype, because the key is resolved from DSH's own credentials at request time
74
+ - **Custom providers**: "Add custom provider" registers any **OpenAI-compatible** or **Anthropic Messages** endpoint; the form offers **presets** for common low-cost models (DeepSeek, OpenAI, Qwen, GLM, Kimi, SiliconFlow, OpenRouter, Anthropic) that fill base URL + model + env name, all still editable; the model lists were checked against the vendors' documentation in September 2026 and are suggestions only — any model id can be typed in. Each row has a **test** button, an edit form and a **×** to delete it (a DSH row cannot be deleted — it is managed by the harness)
75
+ - A provider can name an **environment variable** (`apiKeyEnv`) instead of carrying the key: presets fill that in, and a DSH row brings its own. The key is resolved per request and never written to `config.json`, and such a row shows an `env:NAME` badge. The edit form has no env field (the value survives an edit untouched), but emptying a field really removes it — the field is sent as an explicit delete
76
+ - The former **fallback chain** option is gone: it was redundant once the chain itself ends with the free providers, and unchecking a provider is how you opt out of it. `fallback` still exists in `config.json` for anyone who wants it (off by default)
77
+ 4. Send a message that makes the model think, then expand the **Think row** to read the translation and compare with the original
78
+
79
+ ## ⚙️ How it works
80
+
81
+ ```
82
+ browser → POST /_xlate/translate (same-origin, no CORS)
83
+ → host provider chain (fail-open, user-ordered):
84
+ chain: [provider1, provider2, ...] ← drag-reordered in settings
85
+ each provider is one of:
86
+ google (gtx via Node CONNECT tunnel / curl through system proxy)
87
+ bing (ttranslatev3 via curl)
88
+ openai (OpenAI-compatible /chat/completions — Ollama local or any gateway)
89
+ anthropic(Anthropic Messages API /v1/messages)
90
+ fallback chain (config-only, off by default) tried when the primary chain fails entirely
91
+ → browser-direct fallback
92
+ ```
93
+
94
+ - **Provider config** lives in `config.json` (runtime, gitignored): `chain` (ordered ids), `fallback` (enabled + chain, config-only), `providers` (per-provider `type`/`enabled`/`baseURL`/`apiKey`/`apiKeyEnv`/`model`). Old `priority`-based configs auto-migrate. A provider that declares `apiKeyEnv` resolves its key from that environment variable at request time (the literal `apiKey` stays as the fallback), and no env-resolved key is ever written back to `config.json`. A `null` field in a config patch deletes that field, which is how the UI clears one.
95
+ - **DSH discovery** reads the harness `settings.yaml` (`llm-pi-ai.providers`) and `.credentials.yaml` (`refs`) on load; discovered providers are marked `source: "dsh"`, resolved keys stay in memory (never written to `config.json`), and a `/_xlate/dsh-scan` route re-reads them on demand.
96
+ - **Host half** (`lib/index.js`): provider adapters, ordered chain + fallback execution, LRU cache (600), per-provider override for tests, `/_xlate/models` listing, `/_xlate/model/pull` + `pull-status` model download management (auto-configures on completion)
97
+ - **Client half** (`lib/client.js`): 8-language UI, drag-reorderable provider list, add/edit/delete custom providers, per-provider test buttons, sentence/paragraph-batched translation, streaming Think rows, localStorage persistence (settings + translation cache)
98
+ - Pure display layer: originals remain in the transcript and model context
99
+
100
+ ## 🛠 Development
101
+
102
+ - No build step: `lib/client.js` is the browser bundle (source = artifact), `lib/index.js` is the host ESM
103
+ - Client changes apply on page refresh; host changes need a web restart
104
+ - The 8-language strings live in the `UI_TEXT` dictionary in `lib/client.js`
105
+
106
+ ## 📄 License
107
+
108
+ MIT
package/README.ru.md CHANGED
@@ -8,8 +8,7 @@
8
8
  [![license](https://img.shields.io/npm/l/dsh-think-translate?color=4D6BFE)](LICENSE)
9
9
  [![dsh](https://img.shields.io/badge/powered_by-dsh-4D6BFE?style=flat-square&logo=deepseek&logoColor=white)](https://github.com/deepseek-ai/deepseek-harness)
10
10
 
11
- <img src="demo/demo.gif" width="46%" alt="dsh-think-translate demo" style="border:1px solid #4D6BFE;border-radius:8px;margin:4px" />
12
- <img src="demo/demo2.gif" width="46%" alt="dsh-think-translate demo 2" style="border:1px solid #4D6BFE;border-radius:8px;margin:4px" />
11
+ <img src="demo/demo.gif?v=2" width="46%" alt="dsh-think-translate demo" style="border:1px solid #4D6BFE;border-radius:8px;margin:4px" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="demo/demo2.gif?v=2" width="41%" alt="dsh-think-translate demo 2" style="border:1px solid #4D6BFE;border-radius:8px;margin:4px" />
13
12
 
14
13
  </div>
15
14
 
@@ -21,6 +20,7 @@
21
20
 
22
21
  Модели семейства DeepSeek часто рассуждают на китайском — или на том языке, на котором им случилось думать. dsh-think-translate показывает строку Think, карточки задач и ответ на *вашем* языке в реальном времени — как субтитры к размышлениям модели.
23
22
 
23
+ - **🕵️ Читайте любую цепочку рассуждений** — рассуждения, цепочка мыслей, карточки задач и ответы переводятся в реальном времени, потоком по батчам
24
24
  - **8 целевых языков** — 中文 / English / 日本語 / 한국어 / Español / Français / Deutsch / Русский
25
25
  - **Одноязычный интерфейс** — панель настроек, строки размышлений и карточки задач следуют целевому языку (без смешения zh/en); выбор сохраняется
26
26
  - **Локальная модель в приоритете** — использует вашу локальную модель Ollama (qwen и др.): приватно, офлайн, бесплатно. При первом выборе **автоматически запускается загрузка** с индикатором прогресса; модель настраивается и активируется по завершении
@@ -30,8 +30,11 @@
30
30
  - **Пакетный перевод по предложениям** — длинные цепочки переводятся небольшими пакетами, чтобы локальные малые модели сохраняли качество
31
31
  - **🧩 Разбивка по абзацам и предложениям** — длинные цепочки делятся по пустым строкам (структура абзацев сохраняется) и дополнительно по предложениям, чтобы локальные малые модели сохраняли качество
32
32
  - **Потоковый вывод** — переводы появляются пакет за пакетом во время размышления; разверните строку Think для сравнения с оригиналом
33
- - **Устойчивость** — повторные попытки с backoff (3×), прямой запасной вариант из браузера, неудачи не кэшируются
34
33
  - **🎚️ Настраиваемый момент перевода** — переводить всё / ленивая загрузка старых цепочек (по умолчанию) / только при раскрытии
34
+ - **🔗 Динамическая цепочка провайдеров** — порядок списка и есть порядок обращения: перетаскивайте для сортировки, включайте и выключайте каждую строку. Встроенные google gtx / bing / локальный Ollama плюс любые свои эндпоинты
35
+ - **🔌 Свои провайдеры (OpenAI и Anthropic)** — из панели можно добавить любой OpenAI-совместимый эндпоинт (`/v1/chat/completions`) или **Anthropic Messages API** (Claude): тип, шаблон, базовый URL, ключ API, модель
36
+ - **🪄 Наследование провайдеров из DSH** — читает из `settings.yaml` (`llm-pi-ai.providers`) строки DSH только для чтения; одна кнопка заново сканирует и добавляет их все в цепочку. Ключ разрешается на каждый запрос из `.credentials.yaml` и никогда не попадает в конфиг плагина
37
+ - **⏱️ Устойчивость** — 3 повтора с backoff + прямой запрос из браузера, кнопка проверки в каждой строке, ошибки не кэшируются
35
38
 
36
39
  ## 📦 Установка
37
40
 
@@ -68,22 +71,26 @@ New-Item -ItemType Junction -Path "$HOME\.dsh\profiles\node_modules\dsh-think-tr
68
71
 
69
72
  1. Откройте **Настройки → Перевод цепочки размышлений**
70
73
  2. Выберите **целевой язык** (например, Русский) — панель, строки и карточки переключатся на этот язык
71
- 3. Выберите **предпочтительного провайдера**:
72
- - **Локальная модель (Ollama)** — при первом выборе появится кнопка загрузки (qwen2.5:7b / 14b или своя); активируется автоматически по завершении. Кнопка "+" рядом с выбором скачивает другие модели
73
- - **google gtx / bing** — работает сразу (автоматический системный прокси / VPN)
74
+ 3. Управляйте **цепочкой провайдеров** (перетаскивание — порядок, галочка — включение):
75
+ - Встроенные: **google gtx / bing** (бесплатно, сразу работает, системный прокси) и **локальная модель (Ollama)** (при первом выборе скачиваются 7b/14b или своя модель)
76
+ - **Провайдеры DSH**: настроенные в `settings.yaml` эндпоинты появляются сами (только чтение; галочка добавляет их в цепочку). Кнопка **Импортировать из конфигурации DSH** сразу под списком заново сканирует конфигурацию и добавляет их все за один раз — ни baseURL, ни ключ вводить не нужно: ключ берётся из учётных данных DSH
77
+ - Ключ вводится вручную или приходит как **`apiKeyEnv`** из шаблона либо строки DSH: у такой строки появляется значок `env:NAME`, а ключ разрешается на каждый запрос и никогда не пишется в `config.json`. В форме редактирования нет поля переменной окружения (значение сохраняется как есть), но очистка поля действительно его удаляет (отправляется как явное удаление)
78
+ - Снятая галочка означает, что провайдер пропускается. Подробности — в [README.md](README.md)
74
79
  4. Отправьте сообщение и разверните строку Think, чтобы увидеть перевод
75
80
 
76
81
  ## ⚙️ Как это работает
77
82
 
78
83
  ```
79
- браузер → POST /_xlate/translate (тот же источник, без CORS)
80
- → цепочка провайдеров host (fail-open):
81
- совместимо с OpenAI (локальная Ollama, Node fetch к loopback)
82
- → google gtx (Node https + CONNECT-туннель через системный прокси)
83
- → bing (curl form)
84
- → прямой запасной вариант из браузера
84
+ браузер → POST /_xlate/translate (тот же origin, без CORS)
85
+ → цепочка провайдеров на host (fail-open, с изменяемым порядком):
86
+ chain: [provider1, provider2, ...] ← порядок перетаскиванием в настройках
87
+ google / bing / OpenAI-совместимый / Anthropic
88
+ fallback-цепочка (необязательно, по умолчанию выключена, включается в конфиге)
89
+ → прямой запасной путь из браузера
85
90
  ```
86
91
 
92
+ - **Конфигурация провайдеров** живёт в `config.json` (создаётся во время работы, в gitignore): `chain` (упорядоченные id), `fallback` (enabled + chain, только в файле), `providers` (у каждого `type`/`enabled`/`baseURL`/`apiKey`/`apiKeyEnv`/`model`). Старые конфиги с `priority` мигрируют автоматически; провайдер с `apiKeyEnv` разрешает ключ из этой переменной на каждый запрос (литеральный `apiKey` остаётся запасным), и разрешённый ключ никогда не пишется обратно в `config.json`; `null` в патче удаляет поле — так интерфейс и очищает значения
93
+ - **Обнаружение DSH** при загрузке читает `settings.yaml` (`llm-pi-ai.providers`) и `.credentials.yaml` (`refs`) харнесса; найденные провайдеры помечаются `source: "dsh"`, разрешённые ключи остаются в памяти (никогда в `config.json`), а маршрут `/_xlate/dsh-scan` перечитывает их по запросу
87
94
  - **Host-часть** (`lib/index.js`): адаптеры провайдеров, LRU-кэш (600), `/_xlate/models`, `/_xlate/model/pull` + `pull-status` (автонастройка по завершении)
88
95
  - **Client-часть** (`lib/client.js`): интерфейс на 8 языках, пакетный перевод, потоковые строки Think, localStorage
89
96
  - Чистый слой отображения: оригиналы остаются в истории и контексте модели
package/README.zh-CN.md CHANGED
@@ -8,8 +8,7 @@
8
8
  [![license](https://img.shields.io/npm/l/dsh-think-translate?color=4D6BFE)](LICENSE)
9
9
  [![dsh](https://img.shields.io/badge/powered_by-dsh-4D6BFE?style=flat-square&logo=deepseek&logoColor=white)](https://github.com/deepseek-ai/deepseek-harness)
10
10
 
11
- <img src="demo/demo.gif" width="46%" alt="dsh-think-translate demo" style="border:1px solid #4D6BFE;border-radius:8px;margin:4px" />
12
- <img src="demo/demo2.gif" width="46%" alt="dsh-think-translate demo 2" style="border:1px solid #4D6BFE;border-radius:8px;margin:4px" />
11
+ <img src="demo/demo.gif?v=2" width="46%" alt="dsh-think-translate demo" style="border:1px solid #4D6BFE;border-radius:8px;margin:4px" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="demo/demo2.gif?v=2" width="41%" alt="dsh-think-translate demo 2" style="border:1px solid #4D6BFE;border-radius:8px;margin:4px" />
13
12
 
14
13
  </div>
15
14
 
@@ -21,6 +20,7 @@
21
20
 
22
21
  DeepSeek 系模型经常用中文思考——或者用它们碰巧习惯的语言。dsh-think-translate 在你观看时把 Think 行、任务卡片和回答渲染成*你的*语言,就像给模型的思考配上字幕。
23
22
 
23
+ - **🕵️ 任意思考链都能读** — 推理、思维链、任务卡片与回答实时翻译,按批流式出现
24
24
  - **8 种目标语言** — 中文 / English / 日本語 / 한국어 / Español / Français / Deutsch / Русский
25
25
  - **单一语言界面** — 设置面板、思考行、任务卡片全部跟随目标语言(不混中英),选择持久化
26
26
  - **本地模型为主力** — 优先使用本地 Ollama 模型(qwen 等),隐私离线免费;首次选择本地模型时**自动触发下载**(实时进度条),完成后自动配置启用
@@ -30,8 +30,11 @@ DeepSeek 系模型经常用中文思考——或者用它们碰巧习惯的语
30
30
  - **句子分批翻译** — 长思考链按句子分批串行翻译,本地小模型也能保持质量
31
31
  - **🧩 段落与句子感知切分** — 长思考链按空行切分(保留段落结构)再按句分批,本地小模型也能保持质量
32
32
  - **流式输出** — 思考过程中译文逐批出现,展开 Think 行可对照原文
33
- - **失败韧性** — host 请求 3 次退避重试 + 浏览器直连兜底,失败结果不缓存
34
33
  - **🎚️ 可调翻译时机** — 三档:全部预翻译 / 懒加载历史(默认)/ 仅展开时翻译
34
+ - **🔗 动态提供方链** — 列表顺序就是投递顺序:拖动排序、逐行开关;内置 google gtx / bing / 本地 Ollama,外加任意数量的自定义端点
35
+ - **🔌 自定义提供方(OpenAI 与 Anthropic)** — 设置面板里可添加任意 OpenAI 兼容端点(任何 `/v1/chat/completions` 网关)或原生 **Anthropic Messages API**(Claude):类型、预设、接口地址、API 密钥、模型
36
+ - **🪄 继承 DSH 已配置的提供方** — 自动发现 `settings.yaml`(`llm-pi-ai.providers`)里的只读 DSH 行,一个按钮重新扫描并全部加入链;密钥在请求时从 `.credentials.yaml` 解析,绝不写入插件配置
37
+ - **⏱️ 失败韧性** — host 请求 3 次退避重试 + 浏览器直连兜底、每行独立的测试按钮、失败结果不缓存
35
38
 
36
39
  ## 📦 安装
37
40
 
@@ -68,22 +71,26 @@ New-Item -ItemType Junction -Path "$HOME\.dsh\profiles\node_modules\dsh-think-tr
68
71
 
69
72
  1. 打开 **设置 → 思考链翻译**
70
73
  2. 选择**目标语言**(比如日本語)——设置面板、思考行、任务卡片全部切换为该语言
71
- 3. 选择**首选提供方**:
72
- - **本地部署模型(Ollama)**:首次选择时显示下载按钮(qwen2.5:7b / 14b 或自定义),下载完成后自动启用;模型下拉旁 "+" 可随时下载更多
73
- - **google gtx / bing**:开箱即用(自动走系统代理/VPN)
74
+ 3. 管理**供应商链**(拖动排序,勾选即启用):
75
+ - 内置:**google gtx / bing**(免费,开箱即用,自动走系统代理)与**本地模型(Ollama)**(首次选中提示下载 7b/14b 或自定义)
76
+ - **DSH 供应商**:`settings.yaml` 里已配置的端点会自动出现(只读,勾选即加入链);列表下方的 **继承 DSH 已配置的 API** 会重新扫描并一键全部加入——不用重填 baseURL 或密钥(密钥在请求时从 DSH 自己的凭据里解析)
77
+ - 密钥可以直接填,也可以由预设或 DSH 行带上 **`apiKeyEnv`**:那类行显示 `env:NAME` 徽标,密钥在请求时解析、绝不写入 `config.json`。编辑表单里没有环境变量输入框(值会原样保留),清空某个字段会真的删除它(以显式删除提交),所以从环境变量名切回字面密钥是可行的
78
+ - 取消勾选即跳过该供应商;更细的说明以 [README.md](README.md) 为准
74
79
  4. 发消息让模型思考,展开 Think 行查看译文
75
80
 
76
81
  ## ⚙️ 工作原理
77
82
 
78
83
  ```
79
84
  浏览器 → POST /_xlate/translate(同源,无 CORS)
80
- → host 供应商链(fail-open):
81
- openai 兼容(本地 Ollama,Node fetch 直连回环)
82
- → google gtx(Node https + CONNECT 隧道走系统代理)
83
- → bing(curl form)
84
- → 失败回退浏览器直连
85
+ → host 供应商链(fail-open,可排序):
86
+ chain: [provider1, provider2, ...] ← 设置里拖拽排序
87
+ google / bing / openai 兼容 / anthropic 任选
88
+ fallback 链(可选,默认关闭,配置里开启)
89
+ → 浏览器直连兜底
85
90
  ```
86
91
 
92
+ - **提供方配置** 存在 `config.json`(运行期生成,已 gitignore):`chain`(有序 id)、`fallback`(enabled + chain,仅配置文件)、`providers`(每项的 `type`/`enabled`/`baseURL`/`apiKey`/`apiKeyEnv`/`model`)。旧的 `priority` 配置会自动迁移;声明 `apiKeyEnv` 的提供方在请求时从该环境变量解析密钥(字面 `apiKey` 作为兜底),解析出的密钥绝不写回 `config.json`;patch 里显式的 `null` 表示删除该字段,UI 就是用它清空字段的
93
+ - **DSH 发现** 在加载时读取 harness 的 `settings.yaml`(`llm-pi-ai.providers`)与 `.credentials.yaml`(`refs`);被发现的提供方标记为 `source: "dsh"`,解析出的密钥只留在内存中(绝不写入 `config.json`),`/_xlate/dsh-scan` 路由可按需重新读取
87
94
  - **host 半边**(`lib/index.js`):供应商适配器、LRU 缓存(600)、`/_xlate/models` 模型列表、`/_xlate/model/pull` + `pull-status` 模型下载管理(完成后自动配置启用)
88
95
  - **client 半边**(`lib/client.js`):8 语言 UI、段落/句子分批翻译、流式 Think 行、设置与译文缓存持久化(localStorage)
89
96
  - 纯显示层:原文完整保留在会话日志与模型上下文中
package/demo/demo.gif CHANGED
Binary file
package/demo/demo2.gif CHANGED
Binary file