dsh-think-translate 1.0.13 → 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 +1 -1
- package/README.md +108 -97
- package/lib/client.js +685 -33
- package/lib/index.js +527 -33
- package/package.json +52 -49
package/LICENSE
CHANGED
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
|
-
[](https://www.npmjs.com/package/dsh-think-translate)
|
|
8
|
-
[](LICENSE)
|
|
9
|
-
[](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
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
# Option
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
#
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
#
|
|
52
|
-
#
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
+
[](https://www.npmjs.com/package/dsh-think-translate)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
[](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
|
+
- **🔗 Dynamic provider chain** — order providers by drag-and-drop, enable/disable each one, and set an independent fallback chain. Built-ins (google gtx, bing, local Ollama) plus any number of custom providers
|
|
27
|
+
- **🔌 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
|
|
28
|
+
- **🪄 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; keys are resolved from `.credentials.yaml` at runtime and never written to the plugin's config
|
|
29
|
+
- **🔒 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
|
|
30
|
+
- **🧠 Zero context cost** — pure display layer: the model still sees the original text, and translated text never consumes the context window
|
|
31
|
+
- **☁️ 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)
|
|
32
|
+
- **🛡️ Code-safe** — file paths, commands, URLs, regexes and pure-code lines are never translated
|
|
33
|
+
- **🧩 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
|
|
34
|
+
- **⏱️ Resilient** — 3× backoff retries, per-provider test buttons, failed results never cached
|
|
35
|
+
- **🎚️ Adjustable translation timing** — pre-translate everything, lazy-load historical chains (default), or translate only the expanded chain
|
|
36
|
+
|
|
37
|
+
## 📦 Installation
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# Option 1: npm (recommended)
|
|
41
|
+
dsh plugin --profile web add dsh-think-translate
|
|
42
|
+
# then restart web
|
|
43
|
+
|
|
44
|
+
# Option 2: GitHub
|
|
45
|
+
dsh plugin --profile web add github:UncleK/dsh-think-translate
|
|
46
|
+
|
|
47
|
+
# Option 3: manual (junction + patch)
|
|
48
|
+
# 1. link the package into the profile's node_modules
|
|
49
|
+
New-Item -ItemType Junction -Path "$HOME\.dsh\profiles\node_modules\dsh-think-translate" `
|
|
50
|
+
-Target "<repo path>"
|
|
51
|
+
# 2. add to "$HOME\.dsh\profiles\web\cordis.patch.yml":
|
|
52
|
+
# - insert:
|
|
53
|
+
# - id: dsh-think-translate
|
|
54
|
+
# name: dsh-think-translate
|
|
55
|
+
# 3. restart web
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## 🧯 After a DSH upgrade
|
|
59
|
+
|
|
60
|
+
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:
|
|
61
|
+
|
|
62
|
+
- **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.
|
|
63
|
+
- **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.
|
|
64
|
+
- **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.
|
|
65
|
+
|
|
66
|
+
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).
|
|
67
|
+
|
|
68
|
+
## 🚀 Usage
|
|
69
|
+
|
|
70
|
+
1. Open **Settings → Think Translation**
|
|
71
|
+
2. Pick the **target language** (e.g. 日本語) — the settings panel, thinking rows and task cards all switch to it
|
|
72
|
+
3. **Manage the provider chain** (drag to reorder):
|
|
73
|
+
- 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
|
|
74
|
+
- **DSH providers**: endpoints already configured in DSH (`llm-pi-ai.providers`) appear automatically as read-only entries (badge "DSH"); enable them to route translation through your existing gateway accounts
|
|
75
|
+
- **Custom providers**: click "Add custom provider" to register any OpenAI-compatible endpoint or a native Anthropic Messages endpoint (base URL, API key, model); each row has a **test** button to verify it live. Instead of typing the key you can name an **environment variable** (`apiKeyEnv`) — the key is then read from the environment at request time and never written to `config.json`; a row using one shows an `env:NAME` badge
|
|
76
|
+
- Use the **fallback chain** toggle to keep a backup set (e.g. google/bing) when the primary chain fails
|
|
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 (independent, e.g. google/bing) tried when the primary chain fails
|
|
91
|
+
→ browser-direct fallback
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
- **Provider config** lives in `config.json` (runtime, gitignored): `chain` (ordered ids), `fallback` (enabled + chain), `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`.
|
|
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
|