@followbin/dsh-selection 0.0.0-stage → 0.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.
Files changed (44) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +151 -2
  3. package/README.zh-CN.md +152 -0
  4. package/THIRD_PARTY_NOTICES.md +22 -0
  5. package/client.js +1070 -0
  6. package/cordis.patch.yml +4 -0
  7. package/icon.svg +1 -0
  8. package/index.js +41 -0
  9. package/locale/en.json +6 -0
  10. package/locale/zh.json +6 -0
  11. package/package.json +90 -4
  12. package/src/host/files.mjs +29 -0
  13. package/src/host/http.mjs +153 -0
  14. package/src/host/llm.mjs +194 -0
  15. package/src/host/log.mjs +40 -0
  16. package/src/host/service.mjs +334 -0
  17. package/src/host/settings.mjs +282 -0
  18. package/src/host/skills.mjs +88 -0
  19. package/src/host/supervisor.mjs +126 -0
  20. package/src/host/usage.mjs +128 -0
  21. package/src/shared/icons.mjs +66 -0
  22. package/src/shared/open-with-system.mjs +15 -0
  23. package/src/shared/paths.mjs +7 -0
  24. package/src/shared/protocol.mjs +4 -0
  25. package/src/worker/controller.mjs +274 -0
  26. package/src/worker/main.mjs +147 -0
  27. package/src/worker/native-window.mjs +319 -0
  28. package/src/worker/open-url.mjs +20 -0
  29. package/src/worker/overlay.mjs +266 -0
  30. package/src/worker/page.mjs +14 -0
  31. package/src/worker/placement.mjs +58 -0
  32. package/src/worker/speech.mjs +136 -0
  33. package/ui/markdown.js +122 -0
  34. package/ui/toolbar.css +162 -0
  35. package/ui/toolbar.html +54 -0
  36. package/ui/toolbar.js +552 -0
  37. package/vendor/selection-hook/LICENSE +21 -0
  38. package/vendor/selection-hook/index.d.ts +517 -0
  39. package/vendor/selection-hook/index.js +662 -0
  40. package/vendor/selection-hook/package.json +10 -0
  41. package/vendor/selection-hook/prebuilds/darwin-arm64/selection-hook.node +0 -0
  42. package/vendor/selection-hook/prebuilds/darwin-x64/selection-hook.node +0 -0
  43. package/vendor/selection-hook/prebuilds/win32-arm64/selection-hook.node +0 -0
  44. package/vendor/selection-hook/prebuilds/win32-x64/selection-hook.node +0 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dsh-selection contributors
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 CHANGED
@@ -1,3 +1,152 @@
1
- # Temporary Holding Version
1
+ # dsh-selection
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [中文](README.zh-CN.md)
4
+
5
+ Select text in any app and a small toolbar appears next to it: translate, summarize, explain, ask about it, read it aloud, copy, polish or search, with the models you already use in [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (DSH).
6
+
7
+ ![Select text, choose Explain, then ask a follow-up question](docs/images/en/walkthrough.gif)
8
+
9
+ ## Install
10
+
11
+ You need DSH Desktop 0.2.2 or later on macOS 14 or later. Windows support is written but not tested yet; see [Known limitations](#known-limitations). The screenshots below show DSH in Chinese; the English interface is laid out the same way.
12
+
13
+ 1. In DSH, open **Plugins** in the sidebar and click **Add plugin**.
14
+ 2. Enter `@followbin/dsh-selection` and click **Install**.
15
+
16
+ <img src="docs/images/zh/install-add.webp" alt="The Add plugin dialog with @followbin/dsh-selection entered" width="430">
17
+
18
+ 3. When the dialog says **Installed**, click **Enable now**.
19
+
20
+ <img src="docs/images/zh/install-enable.webp" alt="The Installed dialog with its Enable now button" width="430">
21
+
22
+ 4. macOS asks whether "DeepSeek Harness" may control your computer using accessibility features. Choose *Open System Settings* (the highlighted default button is *Deny*) and switch DeepSeek Harness on ([why](#permissions-macos)).
23
+
24
+ <img src="docs/images/zh/install-permission.webp" alt="macOS asking whether DeepSeek Harness may use accessibility features, with Selection assistant now in DSH's sidebar" width="700">
25
+
26
+ Now select some text in any app. Settings are under **Selection assistant** in DSH's sidebar.
27
+
28
+ To install the newest code from GitHub instead, enter `https://github.com/followbin/dsh-selection` in step 2.
29
+
30
+ **Updating**: when a new version is published, the plugin's page under **Plugins** lists it in **Versions**; click **Update**. A copy installed from GitHub or a local folder has no **Versions** section: uninstall it and install it again. Your settings and usage are kept, because they are stored in `~/.dsh/selection`, outside the plugin.
31
+
32
+ ## Features
33
+
34
+ - **Toolbar**: the first few skills sit on the toolbar, the rest live in the ⋯ menu together with "Disable in this app" and "More settings…".
35
+ - **Mini toolbar**: a single icon instead; rest the pointer on it and every skill drops down. Switch between the two from the toolbar's menu or the settings page.
36
+ - **Built-in skills**: Translate, Summarize, Explain, Ask DSH, Read aloud, Copy, Polish, Search.
37
+ - **Custom skills**: a name, an icon and an instruction. Try them on sample text before saving.
38
+ - **Answers stream in** with Markdown, can be copied, regenerated, translated into another language or pinned on screen. When an answer is complete, a box below it takes follow-up questions, for every skill.
39
+ - **Token usage**: the settings page counts requests and tokens per day, model and skill (numbers only, never text).
40
+ - **Uses DSH's own models**: requests go through the account or API key configured in DSH. DeepSeek Flash is preferred, with thinking off for speed, and you can pick any other model DSH offers.
41
+ - **Stays out of the way**: the toolbar never takes focus from the app you are working in, never shows a Dock icon, and floats above full-screen apps.
42
+
43
+ ## Permissions (macOS)
44
+
45
+ When the plugin first runs, macOS asks whether **"DeepSeek Harness" may control your computer using accessibility features**. Choose *Open System Settings* and switch DeepSeek Harness on. The toolbar starts working within a second, without restarting anything. Without this permission macOS hides the selection from every app, so the toolbar cannot appear.
46
+
47
+ The permission is granted to the DeepSeek Harness app as a whole. macOS attributes it to every process DSH starts, including commands run by agents. If that is not acceptable for you, do not grant it. You can revoke it at any time in System Settings → Privacy & Security → Accessibility.
48
+
49
+ Windows needs no extra permission.
50
+
51
+ ## Using it
52
+
53
+ ![The toolbar below a selection](docs/images/en/toolbar.png)
54
+
55
+ - Select text and the toolbar appears below the selection. Press **Esc**, click elsewhere or start typing to dismiss it.
56
+ - With the mini toolbar, rest the pointer on the icon (or click it) to open the skills; they close once the pointer has left.
57
+ - **Ask DSH** opens a small chat about the selection. Type a question and press Enter; follow-up questions keep the context.
58
+ - Drag the toolbar, or a panel by its header, to move it; it stays where you put it.
59
+ - In a result panel, the pin keeps it open while you click elsewhere (a new selection still replaces it); the language menu re-translates into another language. Click into the answer to select part of it and copy with ⌘C.
60
+ - Once an answer is complete, type a follow-up in the box below it, for example "more formal" after a translation. Regenerating, or choosing another language, starts the conversation over.
61
+ - **⋯ → Use the mini toolbar** turns the toolbar into a single icon, and **Use the full toolbar** in its menu turns it back. **⋯ → Disable in this app** stops the toolbar in the current app. **⋯ → More settings…** opens the settings page in DSH.
62
+
63
+ ![An explanation, then a follow-up question and its answer](docs/images/en/follow-up.png)
64
+
65
+ ## Settings
66
+
67
+ Open **Selection assistant** in DSH's sidebar. The page has tabs: General, Skills, Model, Capture & search, Apps and Usage. Changes save automatically and apply immediately.
68
+
69
+ <p>
70
+ <img src="docs/images/en/settings-skills.png" alt="The Skills tab: built-in and custom skills in toolbar order" width="49%">
71
+ <img src="docs/images/en/settings-usage.png" alt="The Usage tab: requests and tokens by model and by skill" width="49%">
72
+ </p>
73
+
74
+ | Setting | Default | Notes |
75
+ | --- | --- | --- |
76
+ | Show the toolbar when text is selected | on | |
77
+ | Skills, their order, on/off | 8 built-ins | Drag, or focus the handle and press ↑ ↓. Custom skills can be edited and deleted. |
78
+ | Toolbar style | full | Mini is a single icon whose menu holds every skill. Also switchable from the toolbar's menu. |
79
+ | Show the toolbar | automatically | Or only while holding ⌥ / Alt during the selection. |
80
+ | Skills on the toolbar | 5 | The rest go into the ⋯ menu. Full toolbar only. |
81
+ | My language | 简体中文 | Auto translation goes into this language, or into English if the text is already in it. |
82
+ | Translate into | auto | |
83
+ | Summaries, explanations and answers in | my language | Or the language of the selected text, or a fixed language. |
84
+ | Model | auto | Auto prefers DeepSeek Flash. **Test** sends one short request. |
85
+ | Fall back to copying | on | For apps that do not expose the selection; your clipboard is restored afterwards. |
86
+ | Maximum characters sent | 4000 | |
87
+ | Search engine | Google | Bing, Baidu, DuckDuckGo, or any URL containing `%s`. |
88
+ | Never show in these apps | none | Recently used apps are offered for one-click adding. |
89
+
90
+ The **Usage** tab shows requests and input, output, cached and reasoning tokens for today, the last 7 days, the last 30 days and everything kept, split by model and by skill. It is stored in `selection/usage.json` (90 days, counts only) and can be cleared there.
91
+
92
+ Settings are stored in `selection/settings.json` under the DSH data directory.
93
+
94
+ ## Privacy
95
+
96
+ - The selected text stays on your machine until you click a skill that needs a model. Only then is it sent, to the model route you chose in DSH.
97
+ - The toolbar process never talks to the network. Model calls are made by the DSH Host on its behalf.
98
+ - Selected text is treated as untrusted input: it is wrapped in `<selection>` tags and the model is told never to follow instructions inside it. Model output is rendered with a renderer that never emits raw HTML, and links open in your browser only after a click.
99
+ - The settings API answers only DSH's signed-in session, through the same check DSH's own routes use.
100
+ - The log (`selection/host.log` under the DSH data directory, usually `~/.dsh`) records events and counts, never text.
101
+ - No telemetry.
102
+
103
+ ## Troubleshooting
104
+
105
+ - **"Cannot access GitHub" while installing**: enter the package name `@followbin/dsh-selection` instead of the GitHub address.
106
+ - **Installed, but no toolbar**: on the **Plugins** page, check that the plugin is switched on; closing the install dialog without **Enable now** leaves it off. If DSH says a change takes effect after a restart, restart DSH.
107
+ - **No toolbar on macOS**: check System Settings → Privacy & Security → Accessibility for DeepSeek Harness. The settings page shows a banner while the permission is missing.
108
+ - **No toolbar in one app**: check the disabled apps list. Some apps expose nothing to accessibility APIs; keep "Fall back to copying" on.
109
+ - **Model errors**: use **Test** on the settings page. "No model" means DSH has no usable model yet; sign in or add an API key in DSH.
110
+ - **Anything else**: look at `~/.dsh/selection/host.log`, then use **Restart the assistant** on the settings page.
111
+
112
+ ## Known limitations
113
+
114
+ - **Windows has not been run on real hardware yet.** The code paths exist, covering hooks, WebView2, non-activating windows and SAPI speech, but expect rough edges. Windows-specific notes:
115
+ - with displays at different scale factors the toolbar can land on the wrong display or off the selection, and clicks on it may count as clicks outside;
116
+ - the transparent margin around the toolbar may take clicks instead of passing them to the app below;
117
+ - apps running as administrator cannot be read;
118
+ - Smart App Control may block unsigned native modules.
119
+ - On macOS the toolbar does not appear while secure input is on (password fields), by design of the OS.
120
+ - The toolbar process is DSH's own Electron executable in Node mode. Electron Framework and the web view library both define an Objective-C class named `NotificationCenterDelegate`, which prints a harmless warning at start.
121
+ - Text-to-speech uses the system voices; quality depends on what is installed.
122
+
123
+ ## Development
124
+
125
+ DSH Desktop runs plugins on Electron 44 in Node mode (Node 24), and `@webviewjs/webview` needs Node 24. Install the dependencies with DSH's own runtime:
126
+
127
+ ```bash
128
+ env ELECTRON_RUN_AS_NODE=1 "/Applications/DeepSeek Harness.app/Contents/MacOS/DeepSeek Harness" \
129
+ "/Applications/DeepSeek Harness.app/Contents/Resources/runtime/primary-runtime/dependencies/pnpm/bin/pnpm.mjs" install
130
+ ```
131
+
132
+ To run your checkout inside DSH, quit DSH and link the checkout with DSH's command-line tool:
133
+
134
+ ```bash
135
+ "/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh" plugin --profile desktop add link:/path/to/dsh-selection
136
+ ```
137
+
138
+ After changing `src/worker/` or `ui/`, click **Restart the assistant** on the settings page. Changes to `index.js`, `client.js` or `src/host/` need a DSH restart.
139
+
140
+ | Command | What it does |
141
+ | --- | --- |
142
+ | `pnpm test` | Unit tests for the Host (settings, prompts, model client, HTTP guards, worker messages), the worker's rules, the toolbar page and the settings page (the pages run in jsdom). Plain Node 20 or later is fine. |
143
+ | `pnpm selftest` | Opens the toolbar, the ⋯ menu and both panel types, then checks native window state, layout and that the frontmost app never changes. No permission needed. Add `--interactive` to click around for 20 seconds. |
144
+ | `pnpm dev` | Runs the real toolbar outside DSH with a demo model. Settings go to `~/.dsh/selection-dev`. On macOS the accessibility prompt is for your terminal app. |
145
+ | `pnpm screenshots` | Redraws the toolbar, follow-up, settings and walkthrough images in `docs/images/` from the real pages with sample text; the install screenshots are taken by hand. Add `en` or `zh` for one language. Needs Google Chrome and ffmpeg. |
146
+ | `pnpm vendor:selection-hook [version]` | Refreshes `vendor/selection-hook` from npm. |
147
+
148
+ How the pieces fit together, and why some unusual choices were made, is in [docs/architecture.md](docs/architecture.md).
149
+
150
+ ## License
151
+
152
+ MIT. See [LICENSE](LICENSE) and [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
@@ -0,0 +1,152 @@
1
+ # dsh-selection 划词助手
2
+
3
+ [English](README.md)
4
+
5
+ 在任意应用里选中文字,旁边就会出现一个小工具栏:翻译、总结、解释、追问、朗读、复制、润色、搜索。用的是你在 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)(DSH)里已经配好的模型。
6
+
7
+ ![选中文字,点翻译,再接着追问](docs/images/zh/walkthrough.gif)
8
+
9
+ ## 安装
10
+
11
+ 需要 DSH 桌面版 0.2.2 及以上、macOS 14 及以上。Windows 的支持已经写好,但还没测过,见[已知限制](#已知限制)。
12
+
13
+ 1. 在 DSH 侧边栏打开「插件」,点「添加插件」。
14
+ 2. 输入 `@followbin/dsh-selection`,点「安装」。
15
+
16
+ <img src="docs/images/zh/install-add.webp" alt="「添加插件」里填好 @followbin/dsh-selection" width="430">
17
+
18
+ 3. 显示「已安装」后,点「立即启用」。
19
+
20
+ <img src="docs/images/zh/install-enable.webp" alt="安装完成,点「立即启用」" width="430">
21
+
22
+ 4. macOS 会询问是否允许「DeepSeek Harness」使用辅助功能控制这台电脑。点「打开系统设置」(高亮的默认按钮是「拒绝」,别直接按回车),把 DeepSeek Harness 打开([为什么需要](#权限macos))。
23
+
24
+ <img src="docs/images/zh/install-permission.webp" alt="macOS 请求辅助功能权限,DSH 侧边栏已出现「划词助手」" width="700">
25
+
26
+ 然后在任意应用里选中一段文字试试。设置在 DSH 侧边栏的「划词助手」里。
27
+
28
+ 想装 GitHub 上的最新代码,第 2 步改填 `https://github.com/followbin/dsh-selection`。
29
+
30
+ **更新**:发布新版本后,在「插件」里打开它,「版本」一栏会列出新版本,点「更新」即可。从 GitHub 或本地目录装的没有「版本」一栏,要先卸载再重新安装。设置和用量存在 `~/.dsh/selection`,不在插件目录里,卸载不会丢。
31
+
32
+ ## 功能
33
+
34
+ - **工具栏**:前几个技能直接显示,其余收进「⋯」菜单;菜单里还有「在此应用中禁用」和「更多设置…」。
35
+ - **迷你模式**:工具栏换成一个小图标,鼠标停在上面就展开全部技能。在工具栏菜单或设置页里随时切换。
36
+ - **内置技能**:翻译、总结、解释、问问 DSH、朗读、复制、润色、搜索。
37
+ - **自定义技能**:起个名字、选个图标、写一句指令,保存前可以拿示例文字试一试。
38
+ - **结果面板**:流式显示,支持 Markdown,可以复制、重新生成、切换翻译语言、固定在屏幕上。每个技能回答完后,下面都有输入框可以接着问。
39
+ - **token 用量**:设置页按天、模型、技能统计请求次数和 token(只记数字,不记文字)。
40
+ - **用 DSH 自己的模型**:请求走 DSH 里配置的账号或 API Key。默认优先 DeepSeek Flash 并关闭思考以加快速度,也可以选 DSH 里的其他模型。
41
+ - **不打扰**:工具栏不抢当前应用的焦点,不出现 Dock 图标,能浮在全屏应用之上。
42
+
43
+ ## 权限(macOS)
44
+
45
+ 插件第一次运行时,macOS 会询问:**「DeepSeek Harness」想使用辅助功能来控制这台电脑**。点「打开系统设置」,把 DeepSeek Harness 打开即可。一秒内生效,不用重启任何东西。没有这项权限,macOS 不会把任何应用里选中的文字交出来,工具栏也就无法出现。
46
+
47
+ 这项权限是授给整个 DeepSeek Harness 的。macOS 会把它算到 DSH 启动的所有进程头上,包括 agent 执行的命令。如果你不能接受,就别授权;之后也可以随时在「系统设置 → 隐私与安全性 → 辅助功能」里关掉。
48
+
49
+ Windows 不需要额外权限。
50
+
51
+ ## 使用
52
+
53
+ ![选区下方的工具栏](docs/images/zh/toolbar.png)
54
+
55
+ - 选中文字后,工具栏出现在选区下方。按 **Esc**、点别处或开始打字都会收起它。
56
+ - 迷你模式下,鼠标停在图标上(或点一下)就展开技能,移开后自动收起。
57
+ - **问问 DSH** 会打开一个针对这段文字的小对话框。输入问题后按回车,追问会保留上下文。
58
+ - 按住工具栏,或按住面板的标题栏拖动,可以把它移开;放下后就停在那里。
59
+ - 结果面板上的图钉可以把面板固定住,点别处也不会收起(再次划词仍会替换它);翻译面板的语言下拉框可以换一种语言重新翻译。在回答里点一下,就能选中其中一部分并用 ⌘C 复制。
60
+ - 回答完成后,可以在下方输入框里接着问,比如翻译完问「再正式一点」。点重新生成或换一种语言时,对话会从头开始。
61
+ - **⋯ → 切换为迷你模式** 把工具栏换成一个图标,图标菜单里的 **切换为常规模式** 换回来;**⋯ → 在此应用中禁用** 会让当前应用里不再弹出;**⋯ → 更多设置…** 会打开 DSH 里的设置页。
62
+
63
+ ![翻译完成后接着追问](docs/images/zh/follow-up.png)
64
+
65
+ ## 设置项
66
+
67
+ 在 DSH 侧边栏打开「划词助手」。页面分成常规、技能、模型、取词与搜索、应用、用量几个页签。改动会自动保存并立即生效。
68
+
69
+ <p>
70
+ <img src="docs/images/zh/settings-skills.png" alt="技能页签:内置和自定义技能,按工具栏顺序排列" width="49%">
71
+ <img src="docs/images/zh/settings-usage.png" alt="用量页签:按模型和技能统计请求次数与 token" width="49%">
72
+ </p>
73
+
74
+ | 设置 | 默认值 | 说明 |
75
+ | --- | --- | --- |
76
+ | 选中文字时显示工具栏 | 开 | |
77
+ | 技能、顺序与开关 | 8 个内置技能 | 拖动排序,也可以聚焦拖动把手后按 ↑ ↓。自定义技能可以编辑、删除。 |
78
+ | 工具栏样式 | 常规 | 迷你模式只有一个图标,菜单里是全部技能;也可以在工具栏菜单里切换。 |
79
+ | 弹出方式 | 选中后自动弹出 | 也可以设为按住 ⌥ / Alt 选中时才弹出。 |
80
+ | 工具栏上的技能数 | 5 | 其余收进「⋯」菜单。只在常规模式下有效。 |
81
+ | 我的母语 | 简体中文 | 自动翻译会译成母语;原文已经是母语时译成英文。 |
82
+ | 翻译成 | 自动 | |
83
+ | 总结、解释和回答使用 | 我的母语 | 也可以跟随原文的语言,或固定某种语言。 |
84
+ | 模型 | 自动 | 自动时优先 DeepSeek Flash。点「测试」会发一次简短请求。 |
85
+ | 读不到选区时用复制兜底 | 开 | 有些应用不提供选中文字,这时会模拟一次复制,之后恢复你原来的剪贴板。 |
86
+ | 最多发送的字数 | 4000 | |
87
+ | 搜索引擎 | Google | 也可以选 Bing、百度、DuckDuckGo,或任何带 `%s` 的地址。 |
88
+ | 不在这些应用里弹出 | 无 | 最近划过词的应用可以一键加入。 |
89
+
90
+ 「用量」页签按今天、近 7 天、近 30 天和全部,显示请求次数和输入、输出、缓存命中、推理 token,并按模型、按技能拆开。数据存在 `selection/usage.json`,只记数字、保留 90 天,可以在页面上清空。
91
+
92
+ 设置保存在 DSH 数据目录下的 `selection/settings.json`。
93
+
94
+ ## 隐私
95
+
96
+ - 选中的文字留在本机。只有你点了要用模型的技能,它才会发给你在 DSH 里选的模型。
97
+ - 工具栏进程本身不联网,模型请求由 DSH Host 代为发出。
98
+ - 选中的文字被当作不可信输入:包在 `<selection>` 标签里,并告诉模型不要执行其中的任何指令。模型输出经过一个不会产生原始 HTML 的渲染器;链接只有在点击后才会用浏览器打开。
99
+ - 设置接口只响应 DSH 已登录的会话,用的是和 DSH 自带接口相同的校验。
100
+ - 日志(DSH 数据目录下的 `selection/host.log`,通常在 `~/.dsh`)只记录事件和计数,不记录文字内容。
101
+ - 没有任何遥测。
102
+
103
+ ## 常见问题
104
+
105
+ - **安装时提示「无法访问 GitHub」**:点「改用国内镜像」,再填包名 `@followbin/dsh-selection` 安装。镜像只提供 npm 包,不提供 GitHub 仓库。
106
+ - **装好了但不弹工具栏**:到「插件」页确认这个插件的开关已打开;安装完没点「立即启用」就关掉对话框,插件是关着的。如果 DSH 提示重启后生效,重启一下 DSH。
107
+ - **macOS 上不弹工具栏**:到「系统设置 → 隐私与安全性 → 辅助功能」确认 DeepSeek Harness 已打开。缺这项权限时,设置页顶部会有提示。
108
+ - **某个应用里不弹**:先检查是否在禁用列表里。有些应用不向辅助功能接口提供任何内容,这种情况保持「复制兜底」开启即可。
109
+ - **模型报错**:在设置页点「测试」。提示「没有可用的模型」时,去 DSH 里登录或填写 API Key。
110
+ - **其他问题**:查看 `~/.dsh/selection/host.log`,再在设置页点「重启划词进程」。
111
+
112
+ ## 已知限制
113
+
114
+ - **Windows 还没在真机上跑过**。钩子、WebView2、不抢焦点的窗口、SAPI 朗读都写了,但可能还有毛病。另外几点:
115
+ - 多显示器且缩放比不同时,工具栏可能落到别的显示器上或偏离选区,点它也可能被当成点在外面;
116
+ - 工具栏四周的透明边距可能挡住对下面应用的点击;
117
+ - 以管理员身份运行的应用读不到选区;
118
+ - 开了「智能应用控制」的系统可能会拦截未签名的原生模块。
119
+ - macOS 开启安全输入时(比如焦点在密码框里),系统不会交出选区,工具栏不会出现。
120
+ - 工具栏进程用的是 DSH 自己的 Electron 可执行文件(Node 模式)。Electron Framework 和 webview 库都定义了名为 `NotificationCenterDelegate` 的 Objective-C 类,启动时会打一条无害的警告。
121
+ - 朗读用的是系统语音,效果取决于系统里装了哪些语音。
122
+
123
+ ## 开发
124
+
125
+ DSH 桌面版在 Electron 44 的 Node 模式(Node 24)里运行插件,而 `@webviewjs/webview` 要求 Node 24,所以装依赖用 DSH 自带的运行时:
126
+
127
+ ```bash
128
+ env ELECTRON_RUN_AS_NODE=1 "/Applications/DeepSeek Harness.app/Contents/MacOS/DeepSeek Harness" \
129
+ "/Applications/DeepSeek Harness.app/Contents/Resources/runtime/primary-runtime/dependencies/pnpm/bin/pnpm.mjs" install
130
+ ```
131
+
132
+ 要在 DSH 里跑本地代码,先退出 DSH,再用 DSH 自带的命令行工具把目录链接进去:
133
+
134
+ ```bash
135
+ "/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh" plugin --profile desktop add link:/path/to/dsh-selection
136
+ ```
137
+
138
+ 改了 `src/worker/` 或 `ui/`,在设置页点「重启划词进程」即可;改了 `index.js`、`client.js` 或 `src/host/`,要重启 DSH。
139
+
140
+ | 命令 | 作用 |
141
+ | --- | --- |
142
+ | `pnpm test` | 单元测试:Host(设置、提示词、模型调用、HTTP 防护、worker 消息)、worker 的行为规则、工具栏页面和设置页(页面跑在 jsdom 里)。普通 Node 20 及以上就能跑。 |
143
+ | `pnpm selftest` | 依次打开工具栏、「⋯」菜单和两种结果面板,检查原生窗口状态、布局,以及前台应用始终没变。不需要权限。加 `--interactive` 可以手动点 20 秒。 |
144
+ | `pnpm dev` | 不经过 DSH、用演示模型运行真实的工具栏,设置存在 `~/.dsh/selection-dev`。在 macOS 上,授权弹窗针对的是你的终端应用。 |
145
+ | `pnpm screenshots` | 用真实的工具栏页面和设置页、配上示例文字,重新生成 `docs/images/` 里的工具栏、追问、设置页截图和动图;安装步骤的截图是手工截的。加 `en` 或 `zh` 只生成一种语言。需要 Google Chrome 和 ffmpeg。 |
146
+ | `pnpm vendor:selection-hook [版本]` | 从 npm 更新 `vendor/selection-hook`。 |
147
+
148
+ 各部分怎么协作、为什么有些做法不寻常,见 [docs/architecture.md](docs/architecture.md)。
149
+
150
+ ## 许可证
151
+
152
+ MIT,见 [LICENSE](LICENSE) 和 [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)。
@@ -0,0 +1,22 @@
1
+ # Third-party notices
2
+
3
+ dsh-selection ships or depends on the following software. Each is used under its own license.
4
+
5
+ | Component | Use | License | Copyright |
6
+ | --- | --- | --- | --- |
7
+ | [selection-hook](https://github.com/0xfullex/selection-hook) 2.1.2 | Vendored in `vendor/selection-hook` (JavaScript loader and N-API prebuilds for macOS and Windows): global input hooks and reading the selected text | MIT | © 2025 0xfullex |
8
+ | [@webviewjs/webview](https://github.com/webviewjs/webview) 0.6.0 | npm dependency: system web view windows (built on tao and wry) | MIT | © 2024 Twilight |
9
+ | [koffi](https://koffi.dev/) 3.3.6 (`@koromix/koffi-*` platform packages) | npm dependency: calling macOS and Windows system APIs | MIT | © 2026 Niels Martignène |
10
+ | [Lucide](https://lucide.dev/) icons | Path data copied into `src/shared/icons.mjs` | ISC (portions MIT, from Feather) | © Lucide Contributors 2022; portions © Cole Bemis 2013–2022 |
11
+
12
+ The full MIT text for selection-hook is in `vendor/selection-hook/LICENSE`; the other packages include their license files in `node_modules`.
13
+
14
+ ## Lucide license
15
+
16
+ ISC License
17
+
18
+ Copyright (c) for portions of Lucide are held by Cole Bemis 2013-2022 as part of Feather (MIT). All other copyright (c) for Lucide are held by Lucide Contributors 2022.
19
+
20
+ Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.