dsh-question 0.0.0-stage → 0.1.3
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 +21 -0
- package/README.en.md +149 -0
- package/README.md +131 -2
- package/cordis.patch.yml +7 -0
- package/docs/card.png +0 -0
- package/docs/hover.png +0 -0
- package/docs/multi.png +0 -0
- package/docs/radio-zoom.png +0 -0
- package/lib/client.js +433 -0
- package/lib/dsh-question.css +154 -0
- package/lib/index.js +6 -0
- package/package.json +56 -4
- package/scripts/build.cjs +44 -0
- package/src/10-helpers.js +60 -0
- package/src/20-tooltip.js +72 -0
- package/src/30-mount.js +156 -0
- package/src/40-keys.js +125 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 1234ab484
|
|
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.en.md
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# dsh-question
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/dsh-question)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](https://github.com/1234ab484/dsh-question/actions/workflows/ci.yml)
|
|
6
|
+
|
|
7
|
+
Ask-and-wait question cards for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (DSH).
|
|
8
|
+
|
|
9
|
+
`dsh-question` renders a question from the model as a card you answer in place: pick an option, hover
|
|
10
|
+
for the full explanation, or type your own answer. The card holds the turn until you submit, then the
|
|
11
|
+
answer goes back to the model and work continues.
|
|
12
|
+
|
|
13
|
+
[English](README.en.md) | [中文](README.md)
|
|
14
|
+
|
|
15
|
+

|
|
16
|
+
|
|
17
|
+

|
|
18
|
+
|
|
19
|
+
| Single-select radio (8×) | Multi-select |
|
|
20
|
+
| --- | --- |
|
|
21
|
+
|  |  |
|
|
22
|
+
|
|
23
|
+
## Features
|
|
24
|
+
|
|
25
|
+
- **Key-point options** — each option row shows only the short label, clamped to two lines;
|
|
26
|
+
- **Hover details** — hovering or focusing an option opens a floating tooltip with the full
|
|
27
|
+
explanation; a truncated label gets its complete text on the tooltip's first line;
|
|
28
|
+
- **Free-form answers** — the custom row reads “其他:” or “Other: ” and takes typed input directly,
|
|
29
|
+
no pencil icon needed;
|
|
30
|
+
- **Single & multi select** — 26px circular radios for single-select, native checkboxes for multi-select;
|
|
31
|
+
- **Keyboard shortcuts** — `1`–`9` select/toggle, `Enter` runs the primary action (submit / next),
|
|
32
|
+
`←`/`→` switch between questions of a multi-question batch, `Esc` collapses the card without
|
|
33
|
+
cancelling the batch;
|
|
34
|
+
- **Multiple questions, switchable** — a batch shows one question at a time; use the visible pager
|
|
35
|
+
buttons or `←`/`→` to move back and forth, and every answer draft is kept;
|
|
36
|
+
- **Waits for you** — the turn stays paused until you submit; countdown, skip and paging keep working;
|
|
37
|
+
- **Automatic Chinese / English** — the UI string follows the DSH interface language, switching live;
|
|
38
|
+
no manual edit or config.
|
|
39
|
+
|
|
40
|
+
The plugin only renders the question card and its interactions; the model-facing tool contract is
|
|
41
|
+
unchanged.
|
|
42
|
+
|
|
43
|
+
## Installation
|
|
44
|
+
|
|
45
|
+
### From npm
|
|
46
|
+
|
|
47
|
+
```powershell
|
|
48
|
+
dsh plugin --profile <profile> add dsh-question
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### From GitHub
|
|
52
|
+
|
|
53
|
+
```powershell
|
|
54
|
+
dsh plugin --profile <profile> add github:1234ab484/dsh-question
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### From a local checkout
|
|
58
|
+
|
|
59
|
+
```powershell
|
|
60
|
+
git clone https://github.com/1234ab484/dsh-question
|
|
61
|
+
dsh plugin --profile <profile> add "link:<path-to-this-repo>"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Manual
|
|
65
|
+
|
|
66
|
+
1. Add `"dsh-question": "<npm version | github spec | link:<path>>"` to the profile's `package.json`
|
|
67
|
+
dependencies;
|
|
68
|
+
2. Append `dsh-question` to `dsh.profile.bundles`;
|
|
69
|
+
3. Run `pnpm install` in the profile directory.
|
|
70
|
+
|
|
71
|
+
Uninstall: `dsh plugin --profile <profile> remove dsh-question`.
|
|
72
|
+
|
|
73
|
+
The package carries `dsh.bundle.patch` (`cordis.patch.yml`, which inserts the `question-card` loader
|
|
74
|
+
entry) and `dsh.client` (`platform: "web"`, serving `./client` → `lib/client.js`). Profiles with client
|
|
75
|
+
HMR apply it live.
|
|
76
|
+
|
|
77
|
+
## Language
|
|
78
|
+
|
|
79
|
+
The plugin follows the DSH interface language automatically:
|
|
80
|
+
|
|
81
|
+
| DSH language | Custom row prefix |
|
|
82
|
+
| --- | --- |
|
|
83
|
+
| 中文 | 其他: |
|
|
84
|
+
| English | Other: |
|
|
85
|
+
|
|
86
|
+
All other text on the card (question, options, descriptions) comes from the model and is shown as-is.
|
|
87
|
+
|
|
88
|
+
## Keyboard shortcuts
|
|
89
|
+
|
|
90
|
+
| Key | Action |
|
|
91
|
+
| --- | --- |
|
|
92
|
+
| `1`–`9` | Select the Nth option (single-select) / toggle it (multi-select) |
|
|
93
|
+
| `Enter` | Run the primary footer action: submit on the last question, next otherwise |
|
|
94
|
+
| `←` / `→` (or `PageUp` / `PageDown`) | Switch to the previous / next question in the same batch |
|
|
95
|
+
| `Esc` | Collapse the card (same as the header collapse button; never cancels the batch) |
|
|
96
|
+
|
|
97
|
+
Shortcuts only act while a question card is visible, never while focus is inside `input`,
|
|
98
|
+
`textarea`, or a content-editable area, and never with `Ctrl`/`Alt`/`Cmd` held.
|
|
99
|
+
|
|
100
|
+
## How it works
|
|
101
|
+
|
|
102
|
+
1. **Stylesheet** (`lib/dsh-question.css`, injected as `<style data-plugin="dsh-question">`) — scoped to
|
|
103
|
+
`[data-question-key]`; hides the inline `*_description`, clamps labels, draws the circular radios,
|
|
104
|
+
the `其他/Other` prefix and the tooltip.
|
|
105
|
+
2. **Interaction** (`lib/client.js`) — delegated `mouseover`/`focusin` listeners plus a `position: fixed`
|
|
106
|
+
tooltip reading the description text still present in the DOM; keyboard handling; the prefix follows
|
|
107
|
+
`<html lang>` through a `MutationObserver`.
|
|
108
|
+
3. **HMR-safe** — `apply()` disposes the previous generation (`window.__DSH_QUESTION_CARD__`), so a
|
|
109
|
+
reloaded bundle never stacks listeners.
|
|
110
|
+
|
|
111
|
+
## Requirements
|
|
112
|
+
|
|
113
|
+
- DSH **0.2.1-rc.x** Web / Desktop client;
|
|
114
|
+
- Node.js ≥ 20 only when building the bundle yourself (the published bundle is plain JavaScript).
|
|
115
|
+
|
|
116
|
+
Selectors match DSH's CSS-module class **suffixes** (`_optionLabel`, `_description`, `_customRow`, …)
|
|
117
|
+
and the `data-question-key` attribute, so a DSH CSS hash change is harmless — a structural UI refactor
|
|
118
|
+
is not.
|
|
119
|
+
|
|
120
|
+
## Development
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
npm run build # src/*.js + lib/dsh-question.css -> lib/client.js
|
|
124
|
+
npm run check # node --check
|
|
125
|
+
npm test # node:test static contract tests
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Open `dev/preview.html` in a browser for a standalone replica of the card DOM (no DSH required); hover
|
|
129
|
+
an option to see the tooltip.
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
src/10-helpers.js DOM helpers and language detection
|
|
133
|
+
src/20-tooltip.js tooltip element, stylesheet injection
|
|
134
|
+
src/30-mount.js apply(): listeners, language sync, idempotent teardown
|
|
135
|
+
src/40-keys.js keyboard shortcuts
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Known limitations
|
|
139
|
+
|
|
140
|
+
- The custom-row prefix is Chinese or English only; other locales fall back to English.
|
|
141
|
+
- Tooltip content comes from the asker's `description`; without one, only a truncated label falls back
|
|
142
|
+
to the tooltip.
|
|
143
|
+
- Plan-review (`exit_plan_mode`) cards are intentionally untouched.
|
|
144
|
+
- Depends on DSH's internal class suffixes and `data-question-key`; a structural refactor of the question
|
|
145
|
+
card needs selector updates.
|
|
146
|
+
|
|
147
|
+
## License
|
|
148
|
+
|
|
149
|
+
[MIT](LICENSE)
|
package/README.md
CHANGED
|
@@ -1,3 +1,132 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-question
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/dsh-question)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](https://github.com/1234ab484/dsh-question/actions/workflows/ci.yml)
|
|
6
|
+
|
|
7
|
+
给 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)(DSH)的提问卡片插件。
|
|
8
|
+
|
|
9
|
+
`dsh-question` 把模型发起的提问渲染成一张可就地作答的卡片:选择选项、悬停查看详细说明,或者直接输入
|
|
10
|
+
自己的答案。你提交之前它会一直等你,答案回传给模型后继续工作。
|
|
11
|
+
|
|
12
|
+
[中文](README.md) | [English](README.en.md)
|
|
13
|
+
|
|
14
|
+

|
|
15
|
+
|
|
16
|
+

|
|
17
|
+
|
|
18
|
+
| 单选圆钮(8×) | 多选 |
|
|
19
|
+
| --- | --- |
|
|
20
|
+
|  |  |
|
|
21
|
+
|
|
22
|
+
## 功能介绍
|
|
23
|
+
|
|
24
|
+
- **选项只显示重点** —— 每个选项行只留简短 label,最多两行,超出省略;
|
|
25
|
+
- **悬停看详细说明** —— 鼠标悬停或键盘聚焦选项时,浮层展示完整说明;label 被截断时浮层第一行补完整 label;
|
|
26
|
+
- **自由输入一行搞定** —— 自定义答案行显示「其他:」/“Other: ”并直接给输入框,不再需要铅笔图标;
|
|
27
|
+
- **单选与多选** —— 单选是 26px 圆形单选框,多选保留原生方框;
|
|
28
|
+
- **键盘操作** —— `1`–`9` 选择/勾选,`Enter` 触发主按钮(提交/下一题),`←`/`→` 在多题之间来回切换,`Esc` 收起卡片且不会取消整组问题;
|
|
29
|
+
- **多题可来回切换** —— 一批问题一次显示一题,底部翻页按钮或 `←`/`→` 在问题间前后移动,已选草稿不丢;
|
|
30
|
+
- **等你作答** —— 未提交前这一轮保持等待;倒计时、跳过、翻页等行为照常;
|
|
31
|
+
- **中英文自动切换** —— 界面语言变,卡片文案跟着变,无需手动改配置。
|
|
32
|
+
|
|
33
|
+
插件负责提问卡片的呈现与交互,不改变模型可见的工具约定。
|
|
34
|
+
|
|
35
|
+
## 安装说明
|
|
36
|
+
|
|
37
|
+
### 从 npm 安装
|
|
38
|
+
|
|
39
|
+
```powershell
|
|
40
|
+
dsh plugin --profile <profile> add dsh-question
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 从 GitHub 安装
|
|
44
|
+
|
|
45
|
+
```powershell
|
|
46
|
+
dsh plugin --profile <profile> add github:1234ab484/dsh-question
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 从本地 checkout 安装
|
|
50
|
+
|
|
51
|
+
```powershell
|
|
52
|
+
git clone https://github.com/1234ab484/dsh-question
|
|
53
|
+
dsh plugin --profile <profile> add "link:<path-to-this-repo>"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### 手动安装
|
|
57
|
+
|
|
58
|
+
1. 在 profile 的 `package.json` 依赖里加 `"dsh-question": "<npm 版本 | GitHub spec | link:<路径>>"`;
|
|
59
|
+
2. 把 `dsh-question` 追加到 `dsh.profile.bundles`;
|
|
60
|
+
3. 在 profile 目录执行 `pnpm install`。
|
|
61
|
+
|
|
62
|
+
卸载:`dsh plugin --profile <profile> remove dsh-question`。
|
|
63
|
+
|
|
64
|
+
包内声明了 `dsh.bundle.patch`(`cordis.patch.yml`,插入 `question-card` 这条 Loader 条目)和
|
|
65
|
+
`dsh.client`(`platform: "web"`,把 `./client` 指向 `lib/client.js`)。启用了客户端 HMR 的 profile 会在线生效。
|
|
66
|
+
|
|
67
|
+
## 语言
|
|
68
|
+
|
|
69
|
+
插件自动跟随 DSH 的界面语言:
|
|
70
|
+
|
|
71
|
+
| DSH 界面语言 | 自定义答案行前缀 |
|
|
72
|
+
| --- | --- |
|
|
73
|
+
| 中文 | 其他: |
|
|
74
|
+
| English | Other: |
|
|
75
|
+
|
|
76
|
+
卡片上的其它文字(问题、选项、说明)来自模型,按原样展示。
|
|
77
|
+
|
|
78
|
+
## 键盘快捷键
|
|
79
|
+
|
|
80
|
+
| 按键 | 行为 |
|
|
81
|
+
| --- | --- |
|
|
82
|
+
| `1`–`9` | 选中第 N 个选项(单选)/ 勾选或取消(多选) |
|
|
83
|
+
| `Enter` | 触发右下角主按钮:最后一题提交,多题时下一题 |
|
|
84
|
+
| `←` / `→`(或 `PageUp` / `PageDown`) | 在同一批问题里切换到上一题 / 下一题 |
|
|
85
|
+
| `Esc` | 收起卡片(等同标题栏收起按钮;**不会**放弃整组问题) |
|
|
86
|
+
|
|
87
|
+
快捷键只在提问卡片可见时生效;焦点在 `input`、`textarea` 或可编辑区域时不拦截;带 `Ctrl`/`Alt`/`Cmd`
|
|
88
|
+
的组合键不处理。
|
|
89
|
+
|
|
90
|
+
## 实现原理
|
|
91
|
+
|
|
92
|
+
1. **样式层**(`lib/dsh-question.css`,以 `<style data-plugin="dsh-question">` 注入)—— 作用域限定在
|
|
93
|
+
`[data-question-key]`;隐藏行内 `*_description`、截断 label、画圆形单选框、「其他/Other」前缀和浮层。
|
|
94
|
+
2. **交互层**(`lib/client.js`)—— 委托的 `mouseover`/`focusin` 监听 + `position: fixed` 浮层,读取 DOM 里
|
|
95
|
+
仍然存在的 description 文本;键盘处理;前缀通过 `MutationObserver` 跟随 `<html lang>`。
|
|
96
|
+
3. **HMR 安全** —— `apply()` 先销毁上一代(`window.__DSH_QUESTION_CARD__`),热重载不叠加监听器。
|
|
97
|
+
|
|
98
|
+
## 环境要求
|
|
99
|
+
|
|
100
|
+
- DSH **0.2.1-rc.x** 的 Web / 桌面客户端;
|
|
101
|
+
- 只有自己构建 bundle 时才需要 Node.js ≥ 20(发布出来的 bundle 是纯 JavaScript)。
|
|
102
|
+
|
|
103
|
+
选择器匹配 DSH CSS Module 的**类名后缀**(`_optionLabel`、`_description`、`_customRow` 等)和
|
|
104
|
+
`data-question-key` 属性,DSH 改变 CSS 哈希不影响插件;但卡片结构大改时需要更新选择器。
|
|
105
|
+
|
|
106
|
+
## 开发
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
npm run build # src/*.js + lib/dsh-question.css -> lib/client.js
|
|
110
|
+
npm run check # node --check
|
|
111
|
+
npm test # node:test 静态契约测试
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
浏览器打开 `dev/preview.html` 可以脱离 DSH 预览卡片 DOM(悬停选项可看浮层)。
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
src/10-helpers.js DOM 辅助与语言判断
|
|
118
|
+
src/20-tooltip.js 浮层元素、样式注入
|
|
119
|
+
src/30-mount.js apply():监听器、语言同步、幂等销毁
|
|
120
|
+
src/40-keys.js 键盘快捷键
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## 已知限制
|
|
124
|
+
|
|
125
|
+
- 自定义答案行前缀只覆盖中文和英文,其它语言回退到英文;
|
|
126
|
+
- 浮层内容来自提问方的 `description`;没有 description 时,只有 label 被截断才会回退到浮层显示完整 label;
|
|
127
|
+
- plan-review(`exit_plan_mode`)卡片不在改动范围内,保持原样;
|
|
128
|
+
- 依赖 DSH 内部的类名后缀和 `data-question-key`,卡片结构大改时需要更新选择器。
|
|
129
|
+
|
|
130
|
+
## 许可证
|
|
131
|
+
|
|
132
|
+
[MIT](LICENSE)
|
package/cordis.patch.yml
ADDED
package/docs/card.png
ADDED
|
Binary file
|
package/docs/hover.png
ADDED
|
Binary file
|
package/docs/multi.png
ADDED
|
Binary file
|
|
Binary file
|