dsh-wdx-relief 0.3.0 → 0.3.2
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/CHANGELOG.md +13 -0
- package/README.md +12 -1
- package/RELEASING.md +18 -3
- package/client/client.js +336 -213
- package/cordis.patch.yml +1 -1
- package/docs/guide.md +25 -10
- package/index.js +1 -1
- package/package.json +15 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.2 — 2026-11-09
|
|
4
|
+
|
|
5
|
+
- 修复:Tab 填入预测后把输入删空,建议不会重新出现;现在只收起当前建议,同一轮缓存会重新给出,Esc 仍忽略本轮。
|
|
6
|
+
|
|
7
|
+
## 0.3.1 — 2026-11-09
|
|
8
|
+
|
|
9
|
+
- 保留 Codex 式输入框灰字预测:建议仍注册在 `conversation.input.overlay`,不改成输入框外的一行。
|
|
10
|
+
- 样式改为随 React 组件挂载/卸载,移除模块级 `document.head` 副作用;移除内联颜色 fallback。
|
|
11
|
+
- 配置页改用官方 `SettingsFormModel` + `SettingsForm`:编辑先暂存,点「保存」才写入;离开页面丢弃草稿。
|
|
12
|
+
- 修正 `dsh.client.inject`:补上 `ui-plugin-manager`,保留 `ui-settings`(`configForms` 的提供方);移除 `immediately`。
|
|
13
|
+
- 打包元数据:`@deepseek-ai/schemastery` 改为运行时依赖;Cordis 保持 peer/dev 同范围;`engines.dsh` 增加 `<0.3.0` 上界;图标改用 SVG。
|
|
14
|
+
- 修正 RELEASING.md 中被占位符替换的版本示例。
|
|
15
|
+
|
|
3
16
|
## 0.3.0 — 2026-11-09
|
|
4
17
|
|
|
5
18
|
- 精简回复设置:长度 3 档(短/标准/详细);风格 5 选 1(默认/专业/亲和/直接/跟随我的风格);保留「便于行动」开关和自定义指令。
|
package/README.md
CHANGED
|
@@ -11,6 +11,11 @@
|
|
|
11
11
|
- **回复风格**:长度 **短 / 标准 / 详细**;风格 **默认 / 专业 / 亲和 / 直接 / 跟随我的风格**;可加最多 2000 字的自定义指令。
|
|
12
12
|
- **便于行动**(默认开启):先给结果和下一步;能一句说清的不写一段,术语先用白话说明;保留风险、失败条件和已授权该做的工作。
|
|
13
13
|
|
|
14
|
+
## 运行要求
|
|
15
|
+
|
|
16
|
+
- DSH Web profile;插件依赖 `connection` 与 `sessions` 服务。
|
|
17
|
+
- 已配置默认模型。预测会把最近几轮对话作为 prompt 发给当前默认模型;结果只用于输入框建议,不写入会话日志,也不触发 agent loop。
|
|
18
|
+
|
|
14
19
|
## 安装
|
|
15
20
|
|
|
16
21
|
在 DSH 侧边栏 **插件 → 添加插件** 输入:
|
|
@@ -25,7 +30,13 @@ dsh-wdx-relief
|
|
|
25
30
|
plugin_manager install_bundle target = "dsh-wdx-relief"
|
|
26
31
|
```
|
|
27
32
|
|
|
28
|
-
|
|
33
|
+
或命令行:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
dsh plugin --profile <profile> add dsh-wdx-relief
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
安装后启用;客户端模块会在下次页面加载时挂载。
|
|
29
40
|
|
|
30
41
|
本地开发时用 `link:` 安装当前目录的方式见 [docs/guide.md](docs/guide.md)。
|
|
31
42
|
|
package/RELEASING.md
CHANGED
|
@@ -21,6 +21,20 @@
|
|
|
21
21
|
返回 404 才表示可用;如果被占用,把 `package.json` 的 `name` 改成
|
|
22
22
|
`@wdxtub/dsh-wdx-relief`,并同步改本文命令。
|
|
23
23
|
|
|
24
|
+
## 浏览器 2FA 发布(固定方式)
|
|
25
|
+
|
|
26
|
+
npm 账号开启了 `auth-and-writes` 2FA,非交互运行 `npm publish` 会直接报 `EOTP`。
|
|
27
|
+
本仓库用 `expect` 提供 PTY,让 npm 走浏览器认证:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
expect scripts/publish-npm.exp > /tmp/npm-publish-pty.log 2>&1 &
|
|
31
|
+
tail -f /tmp/npm-publish-pty.log
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
看到 `AUTH_BROWSER_OPENED` 后,在浏览器的 npm 认证页完成 2FA/Passkey;npm 会自动
|
|
35
|
+
取到 OTP 并继续发布。不要重复启动另一个发布。没有浏览器窗口时,从日志里取出
|
|
36
|
+
`https://www.npmjs.com/auth/cli/...` 手动打开。
|
|
37
|
+
|
|
24
38
|
## 首次发布
|
|
25
39
|
|
|
26
40
|
先提交干净(`npm version` 需要干净的工作区):
|
|
@@ -35,7 +49,7 @@ npm pack --dry-run
|
|
|
35
49
|
npm pack
|
|
36
50
|
# 插件页 → 添加插件 → 输入 tarball 绝对路径 → 安装 → 立即启用
|
|
37
51
|
|
|
38
|
-
|
|
52
|
+
expect scripts/publish-npm.exp
|
|
39
53
|
git tag -a v0.1.0 -m "v0.1.0"
|
|
40
54
|
git push origin main --tags
|
|
41
55
|
```
|
|
@@ -57,11 +71,12 @@ git status
|
|
|
57
71
|
# 更新 CHANGELOG.md 并提交
|
|
58
72
|
npm test
|
|
59
73
|
npm version minor -m "chore: release v%s"
|
|
60
|
-
|
|
74
|
+
expect scripts/publish-npm.exp
|
|
61
75
|
git push --follow-tags
|
|
62
76
|
```
|
|
63
77
|
|
|
64
|
-
|
|
78
|
+
预发布:把 `scripts/publish-npm.exp` 里的 `npm publish` 参数改为 `--tag next`,
|
|
79
|
+
或直接运行:
|
|
65
80
|
|
|
66
81
|
```bash
|
|
67
82
|
npm version 0.2.0-rc.1
|
package/client/client.js
CHANGED
|
@@ -7,7 +7,13 @@
|
|
|
7
7
|
* 2. `plugins.bundle.config`:侧边栏「插件」里 dsh-wdx-relief 的配置页(预测 + 回复风格)。
|
|
8
8
|
*
|
|
9
9
|
* 预测由 Host 侧 `/api/wdx-relief/predict` 生成;这里只负责节流触发、
|
|
10
|
-
*
|
|
10
|
+
* 渲染建议、处理 Tab/Escape,以及开关的读写。
|
|
11
|
+
*
|
|
12
|
+
* 约束:
|
|
13
|
+
* - 工厂函数不产生模块级副作用;样式随组件挂载,卸载时由 React 移除。
|
|
14
|
+
* - 配置页使用官方 SettingsFormModel / SettingsForm 的暂存-保存模型。
|
|
15
|
+
* - 输入框灰字是用户选择的 Codex 式体验,定位会测量 composer 布局;
|
|
16
|
+
* 这是本插件已知的宿主 DOM 耦合点。
|
|
11
17
|
*/
|
|
12
18
|
window.__ModuleLoader__.load({
|
|
13
19
|
id: 'dsh-wdx-relief',
|
|
@@ -22,23 +28,24 @@ window.__ModuleLoader__.load({
|
|
|
22
28
|
var h = React.createElement
|
|
23
29
|
var useState = React.useState
|
|
24
30
|
var useEffect = React.useEffect
|
|
25
|
-
var useLayoutEffect = React.useLayoutEffect
|
|
26
31
|
var useRef = React.useRef
|
|
32
|
+
var useLayoutEffect = React.useLayoutEffect
|
|
27
33
|
|
|
28
34
|
var NS = 'wdx-relief'
|
|
29
35
|
var RPC_PATH = '/api/wdx-relief/predict'
|
|
36
|
+
var MAX_CUSTOM_CHARS = 2000
|
|
30
37
|
var SWITCH = primitives && primitives.Switch
|
|
31
38
|
var MENU = primitives && primitives.Menu
|
|
32
39
|
var CHEVRON = primitives && primitives.IconChevronDownOutlineRegular
|
|
40
|
+
var SETTINGS_FORM = primitives && primitives.SettingsForm
|
|
41
|
+
var SETTINGS_FORM_MODEL = primitives && primitives.SettingsFormModel
|
|
42
|
+
|
|
43
|
+
var VERBOSITY_OPTIONS = ['low', 'medium', 'high']
|
|
44
|
+
var STYLE_OPTIONS = ['default', 'professional', 'friendly', 'blunt', 'follow']
|
|
33
45
|
|
|
34
46
|
// ------------------------------------------------------------------ CSS
|
|
35
47
|
|
|
36
48
|
var CSS = [
|
|
37
|
-
'.wdxr-row{border-bottom:.5px solid var(--dsw-alias-border-l2);justify-content:space-between;align-items:center;gap:24px;padding:16px 0;display:flex}',
|
|
38
|
-
'.wdxr-text{min-width:0}',
|
|
39
|
-
'.wdxr-title{font-size:14px;line-height:20px}',
|
|
40
|
-
'.wdxr-desc{color:var(--dsw-alias-label-secondary);margin-top:4px;font-size:12px;line-height:18px}',
|
|
41
|
-
'.wdxr-error{color:var(--dsw-alias-state-error-primary);margin-top:4px;font-size:12px;line-height:18px}',
|
|
42
49
|
'.wdxs-page{width:100%;display:flex;flex-direction:column;color:var(--dsw-alias-label-primary)}',
|
|
43
50
|
'.wdxs-intro{color:var(--dsw-alias-label-tertiary);margin:-4px 0 4px;font-size:12px;line-height:18px}',
|
|
44
51
|
'.wdxs-groupHead{color:var(--dsw-alias-label-secondary);margin:24px 0 0;font-size:13px;font-weight:600;line-height:20px}',
|
|
@@ -49,6 +56,8 @@ window.__ModuleLoader__.load({
|
|
|
49
56
|
'.wdxs-rowText{flex:1;min-width:0}',
|
|
50
57
|
'.wdxs-title{font-size:14px;line-height:20px}',
|
|
51
58
|
'.wdxs-desc{color:var(--dsw-alias-label-secondary);margin-top:4px;font-size:12px;line-height:18px}',
|
|
59
|
+
'.wdxs-reset{color:var(--dsw-alias-label-tertiary);background:none;border:0;padding:0;margin-top:6px;font:inherit;font-size:12px;line-height:18px;cursor:pointer;text-decoration:underline}',
|
|
60
|
+
'@media (hover:hover){.wdxs-reset:hover{color:var(--dsw-alias-label-primary)}}',
|
|
52
61
|
'.wdxs-select{border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-module-platform);height:36px;color:var(--dsw-alias-label-primary);cursor:pointer;border:none;align-items:center;gap:12px;padding:0 14px;font:inherit;font-size:14px;line-height:22px;display:inline-flex}',
|
|
53
62
|
'@media (hover:hover){.wdxs-select:hover{background:var(--dsw-alias-interactive-bg-hover)}}',
|
|
54
63
|
'.wdxs-chevron{flex:none}',
|
|
@@ -56,16 +65,11 @@ window.__ModuleLoader__.load({
|
|
|
56
65
|
'.wdxs-textarea{box-sizing:border-box;width:100%;min-height:104px;resize:vertical;border-radius:var(--dsw-radius-md);border:.5px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-module-platform);color:var(--dsw-alias-label-primary);outline:none;margin-top:10px;padding:10px 12px;font:inherit;font-size:13px;line-height:20px}',
|
|
57
66
|
'.wdxs-textarea:focus-visible{border-color:var(--dsw-alias-state-business-primary)}',
|
|
58
67
|
'.wdxs-textarea::placeholder{color:var(--dsw-alias-label-caption)}',
|
|
59
|
-
'.wdxs-
|
|
60
|
-
'.wdxs-error{color:var(--dsw-alias-state-error-primary);margin-top:6px;font-size:12px;line-height:18px}',
|
|
68
|
+
'.wdxs-fallback{border:0;padding:0;margin:0}',
|
|
61
69
|
].join('')
|
|
62
70
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
tag.dataset.plugin = 'dsh-wdx-relief'
|
|
66
|
-
tag.dataset.pluginCss = 'dsh-wdx-relief'
|
|
67
|
-
tag.textContent = CSS
|
|
68
|
-
document.head.appendChild(tag)
|
|
71
|
+
function PluginStyles() {
|
|
72
|
+
return h('style', { 'data-plugin-css': NS }, CSS)
|
|
69
73
|
}
|
|
70
74
|
|
|
71
75
|
// -------------------------------------------------------------- locale
|
|
@@ -97,12 +101,17 @@ window.__ModuleLoader__.load({
|
|
|
97
101
|
'reply.custom.title': '自定义指令',
|
|
98
102
|
'reply.custom.description': '补充只影响回复表达的指令,优先级高于上面的长度和风格',
|
|
99
103
|
'reply.custom.placeholder': '例如:先给结论;用中文解释术语;不要使用「首先/其次」。',
|
|
100
|
-
'reply.saved': '已保存',
|
|
101
|
-
'reply.saveError': '保存失败,请重试',
|
|
102
104
|
'settings.title': '显示预测消息',
|
|
103
105
|
'settings.description': '根据对话预测你接下来要发送的消息',
|
|
104
|
-
'settings.
|
|
105
|
-
'
|
|
106
|
+
'settings.summary': '预测下一句,并设置回复长度、风格和便于行动。',
|
|
107
|
+
'prediction.label': '下一句',
|
|
108
|
+
'prediction.accept': '按 Tab 填入预测',
|
|
109
|
+
'form.unavailable': '配置暂不可用。',
|
|
110
|
+
'form.readOnly': '当前部署只读。',
|
|
111
|
+
'form.saveFailed': '本部署没有接受这些值;已保留供你修改。',
|
|
112
|
+
'form.save': '保存',
|
|
113
|
+
'form.saving': '保存中…',
|
|
114
|
+
'form.reset': '恢复默认',
|
|
106
115
|
}
|
|
107
116
|
|
|
108
117
|
var en = {
|
|
@@ -132,12 +141,25 @@ window.__ModuleLoader__.load({
|
|
|
132
141
|
'reply.custom.title': 'Custom instructions',
|
|
133
142
|
'reply.custom.description': 'Extra instructions about expression; override the length and style settings above',
|
|
134
143
|
'reply.custom.placeholder': 'e.g. Lead with the conclusion; explain terms in one Chinese sentence; avoid "firstly/secondly".',
|
|
135
|
-
'reply.saved': 'Saved',
|
|
136
|
-
'reply.saveError': 'Could not save. Try again.',
|
|
137
144
|
'settings.title': 'Show predicted messages',
|
|
138
145
|
'settings.description': 'Predict what you might send next based on the conversation',
|
|
139
|
-
'settings.
|
|
140
|
-
'
|
|
146
|
+
'settings.summary': 'Predict the next message, and set reply length, style, and actionable replies.',
|
|
147
|
+
'prediction.label': 'Next',
|
|
148
|
+
'prediction.accept': 'Press Tab to insert the prediction',
|
|
149
|
+
'form.unavailable': 'Configuration is unavailable.',
|
|
150
|
+
'form.readOnly': 'This deployment stores settings read-only.',
|
|
151
|
+
'form.saveFailed': 'The deployment did not accept these values; they were left for you to correct.',
|
|
152
|
+
'form.save': 'Save',
|
|
153
|
+
'form.saving': 'Saving…',
|
|
154
|
+
'form.reset': 'Reset to default',
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function tr(t, key, fallback) {
|
|
158
|
+
if (t) {
|
|
159
|
+
var value = t(key)
|
|
160
|
+
if (value !== key) return value
|
|
161
|
+
}
|
|
162
|
+
return fallback
|
|
141
163
|
}
|
|
142
164
|
|
|
143
165
|
// --------------------------------------------------------------- host
|
|
@@ -165,11 +187,13 @@ window.__ModuleLoader__.load({
|
|
|
165
187
|
return typeof value === 'string' && value !== '' ? value : null
|
|
166
188
|
}
|
|
167
189
|
|
|
168
|
-
//
|
|
190
|
+
// ---------------------------------------------------------- prediction
|
|
169
191
|
|
|
170
192
|
/**
|
|
171
|
-
*
|
|
172
|
-
*
|
|
193
|
+
* 输入框里的灰字预测(Codex 式)。
|
|
194
|
+
* 这是用户明确选择保留的体验:建议叠在空输入框的光标起点上,而不是变成输入框外的一行。
|
|
195
|
+
* 定位仍读取 composer 的布局矩形;这是该视觉方案的代价,组件只在
|
|
196
|
+
* `conversation.input.overlay` 自己的浮层里读写,不改动宿主 DOM 的结构。
|
|
173
197
|
*/
|
|
174
198
|
function PredictionOverlay(props) {
|
|
175
199
|
var useSession = props.useSession
|
|
@@ -291,7 +315,8 @@ window.__ModuleLoader__.load({
|
|
|
291
315
|
} catch (error) {
|
|
292
316
|
// 编辑器锁定时 setDraft 会失败;保持预测可见即可。
|
|
293
317
|
}
|
|
294
|
-
|
|
318
|
+
// 只收起当前建议,不把这条建议标记为“忽略”;用户把填入内容删空后,
|
|
319
|
+
// 同一轮缓存会重新给出它,体验和 Codex 一致。
|
|
295
320
|
setPrediction(null)
|
|
296
321
|
var card = anchorRef.current && anchorRef.current.closest('[data-composer-card]')
|
|
297
322
|
var editor = card && card.querySelector('[data-composer-input]')
|
|
@@ -331,8 +356,7 @@ window.__ModuleLoader__.load({
|
|
|
331
356
|
visible
|
|
332
357
|
? h('div', {
|
|
333
358
|
'data-wdx-prediction': true,
|
|
334
|
-
'
|
|
335
|
-
title: t ? t('hint.accept') : undefined,
|
|
359
|
+
title: tr(t, 'prediction.accept', 'Press Tab to insert the prediction'),
|
|
336
360
|
style: {
|
|
337
361
|
position: 'absolute',
|
|
338
362
|
top: box.top + 'px',
|
|
@@ -348,8 +372,9 @@ window.__ModuleLoader__.load({
|
|
|
348
372
|
}, [
|
|
349
373
|
h('span', {
|
|
350
374
|
key: 'text',
|
|
375
|
+
'aria-hidden': true,
|
|
351
376
|
style: {
|
|
352
|
-
color: 'var(--dsw-alias-label-caption
|
|
377
|
+
color: 'var(--dsw-alias-label-caption)',
|
|
353
378
|
fontSize: box.fontSize,
|
|
354
379
|
lineHeight: box.lineHeight,
|
|
355
380
|
fontFamily: box.fontFamily,
|
|
@@ -361,14 +386,20 @@ window.__ModuleLoader__.load({
|
|
|
361
386
|
opacity: 0.9,
|
|
362
387
|
},
|
|
363
388
|
}, suggestion),
|
|
364
|
-
h('
|
|
389
|
+
h('button', {
|
|
365
390
|
key: 'key',
|
|
391
|
+
type: 'button',
|
|
392
|
+
title: tr(t, 'prediction.accept', 'Press Tab to insert the prediction'),
|
|
393
|
+
'aria-label': tr(t, 'prediction.accept', 'Press Tab to insert the prediction') + ': ' + suggestion,
|
|
366
394
|
onPointerDown: function (event) {
|
|
367
395
|
if (event.button !== 0) return
|
|
368
396
|
event.preventDefault()
|
|
369
397
|
event.stopPropagation()
|
|
370
398
|
accept()
|
|
371
399
|
},
|
|
400
|
+
onClick: function (event) {
|
|
401
|
+
if (event.detail === 0) accept()
|
|
402
|
+
},
|
|
372
403
|
style: {
|
|
373
404
|
pointerEvents: 'auto',
|
|
374
405
|
cursor: 'pointer',
|
|
@@ -378,8 +409,9 @@ window.__ModuleLoader__.load({
|
|
|
378
409
|
lineHeight: '18px',
|
|
379
410
|
padding: '0 4px',
|
|
380
411
|
borderRadius: '4px',
|
|
381
|
-
border: '0.5px solid var(--dsw-alias-border-l2
|
|
382
|
-
|
|
412
|
+
border: '0.5px solid var(--dsw-alias-border-l2)',
|
|
413
|
+
background: 'transparent',
|
|
414
|
+
color: 'var(--dsw-alias-label-caption)',
|
|
383
415
|
fontSize: '10px',
|
|
384
416
|
fontFamily: 'ui-monospace, Menlo, monospace',
|
|
385
417
|
opacity: 0.75,
|
|
@@ -389,29 +421,153 @@ window.__ModuleLoader__.load({
|
|
|
389
421
|
: null)
|
|
390
422
|
}
|
|
391
423
|
|
|
392
|
-
//
|
|
424
|
+
// --------------------------------------------------------- settings UI
|
|
393
425
|
|
|
394
|
-
|
|
426
|
+
function oneOf(value, allowed) {
|
|
427
|
+
return typeof value === 'string' && allowed.indexOf(value) !== -1 ? value : undefined
|
|
428
|
+
}
|
|
395
429
|
|
|
396
|
-
function
|
|
397
|
-
|
|
398
|
-
var
|
|
399
|
-
if (value
|
|
430
|
+
function readConfig(scope) {
|
|
431
|
+
try {
|
|
432
|
+
var snapshot = scope.getSnapshot()
|
|
433
|
+
if (snapshot && snapshot.value && typeof snapshot.value === 'object') return snapshot.value
|
|
434
|
+
} catch (error) {
|
|
435
|
+
// 配置尚未就绪时按默认值显示。
|
|
436
|
+
}
|
|
437
|
+
return {}
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function legacyStyle(scope) {
|
|
441
|
+
var value = readConfig(scope)
|
|
442
|
+
if (value.writingStyle === true) return 'follow'
|
|
443
|
+
if (value.baseStyle === 'professional' || value.baseStyle === 'friendly' || value.baseStyle === 'blunt') return value.baseStyle
|
|
444
|
+
return 'default'
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
function booleanText(value) {
|
|
448
|
+
return value === false ? 'false' : 'true'
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
function parseBoolean(text) {
|
|
452
|
+
if (text === 'true') return { kind: 'set', value: true }
|
|
453
|
+
if (text === 'false') return { kind: 'set', value: false }
|
|
454
|
+
return undefined
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
function choiceField(name, allowed, fallback) {
|
|
458
|
+
return {
|
|
459
|
+
field: name,
|
|
460
|
+
format: function (value) {
|
|
461
|
+
return oneOf(value, allowed) || fallback
|
|
462
|
+
},
|
|
463
|
+
parse: function (text) {
|
|
464
|
+
var value = oneOf(text, allowed)
|
|
465
|
+
return value === undefined ? undefined : { kind: 'set', value: value }
|
|
466
|
+
},
|
|
400
467
|
}
|
|
401
|
-
return fallback
|
|
402
468
|
}
|
|
403
469
|
|
|
404
|
-
function
|
|
470
|
+
function createSettingsModel(scope) {
|
|
471
|
+
var model = new SETTINGS_FORM_MODEL(scope, [
|
|
472
|
+
{ field: 'enabled', format: booleanText, parse: parseBoolean },
|
|
473
|
+
choiceField('verbosity', VERBOSITY_OPTIONS, 'low'),
|
|
474
|
+
{ field: 'actionable', format: booleanText, parse: parseBoolean },
|
|
475
|
+
{
|
|
476
|
+
field: 'style',
|
|
477
|
+
format: function (value) {
|
|
478
|
+
return oneOf(value, STYLE_OPTIONS) || legacyStyle(scope)
|
|
479
|
+
},
|
|
480
|
+
parse: function (text) {
|
|
481
|
+
var value = oneOf(text, STYLE_OPTIONS)
|
|
482
|
+
return value === undefined ? undefined : { kind: 'set', value: value }
|
|
483
|
+
},
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
field: 'customInstructions',
|
|
487
|
+
format: function (value) {
|
|
488
|
+
return typeof value === 'string' ? value.slice(0, MAX_CUSTOM_CHARS) : ''
|
|
489
|
+
},
|
|
490
|
+
parse: function (text) {
|
|
491
|
+
var value = text.slice(0, MAX_CUSTOM_CHARS)
|
|
492
|
+
return value === '' ? { kind: 'clear' } : { kind: 'set', value: value }
|
|
493
|
+
},
|
|
494
|
+
},
|
|
495
|
+
])
|
|
496
|
+
|
|
497
|
+
var store = model.bind(function () {
|
|
498
|
+
return {
|
|
499
|
+
...model.shell(),
|
|
500
|
+
enabled: model.field('enabled'),
|
|
501
|
+
verbosity: model.field('verbosity'),
|
|
502
|
+
actionable: model.field('actionable'),
|
|
503
|
+
style: model.field('style'),
|
|
504
|
+
customInstructions: model.field('customInstructions'),
|
|
505
|
+
}
|
|
506
|
+
})
|
|
507
|
+
|
|
508
|
+
return { model: model, store: store }
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
function FieldText(props) {
|
|
512
|
+
var t = props.t
|
|
513
|
+
return h('div', { className: 'wdxs-rowText' }, [
|
|
514
|
+
h('div', { key: 'title', className: 'wdxs-title' }, props.title),
|
|
515
|
+
props.description ? h('div', { key: 'desc', className: 'wdxs-desc' }, props.description) : null,
|
|
516
|
+
props.overridden
|
|
517
|
+
? h('button', {
|
|
518
|
+
key: 'reset',
|
|
519
|
+
type: 'button',
|
|
520
|
+
className: 'wdxs-reset',
|
|
521
|
+
onClick: props.onReset,
|
|
522
|
+
}, tr(t, 'form.reset', '恢复默认'))
|
|
523
|
+
: null,
|
|
524
|
+
])
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
function ToggleField(props) {
|
|
528
|
+
var field = props.field
|
|
529
|
+
var checked = field.text !== 'false'
|
|
530
|
+
var disabled = props.disabled === true
|
|
531
|
+
return h('div', { className: 'wdxs-row' }, [
|
|
532
|
+
h(FieldText, {
|
|
533
|
+
key: 'text',
|
|
534
|
+
t: props.t,
|
|
535
|
+
title: props.title,
|
|
536
|
+
description: props.description,
|
|
537
|
+
overridden: field.overridden === true,
|
|
538
|
+
onReset: props.onReset,
|
|
539
|
+
}),
|
|
540
|
+
SWITCH
|
|
541
|
+
? h(SWITCH, {
|
|
542
|
+
key: 'switch',
|
|
543
|
+
checked: checked,
|
|
544
|
+
label: props.title,
|
|
545
|
+
disabled: disabled,
|
|
546
|
+
onChange: function (next) { props.onChange(next) },
|
|
547
|
+
})
|
|
548
|
+
: h('button', {
|
|
549
|
+
key: 'fallback',
|
|
550
|
+
type: 'button',
|
|
551
|
+
'aria-pressed': checked,
|
|
552
|
+
disabled: disabled,
|
|
553
|
+
onClick: function () { props.onChange(!checked) },
|
|
554
|
+
className: 'wdxs-select',
|
|
555
|
+
}, checked ? 'On' : 'Off'),
|
|
556
|
+
])
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
function SelectField(props) {
|
|
405
560
|
var [open, setOpen] = useState(false)
|
|
406
561
|
var options = props.options
|
|
407
562
|
var selected = options.filter(function (option) { return option.id === props.value })[0] || options[0]
|
|
563
|
+
var disabled = props.disabled === true
|
|
408
564
|
var anchor = h('button', {
|
|
409
565
|
type: 'button',
|
|
410
566
|
className: 'wdxs-select',
|
|
411
567
|
'aria-label': props.title || undefined,
|
|
412
568
|
'aria-haspopup': 'menu',
|
|
413
569
|
'aria-expanded': open,
|
|
414
|
-
disabled:
|
|
570
|
+
disabled: disabled,
|
|
415
571
|
onClick: function () { setOpen(function (value) { return !value }) },
|
|
416
572
|
}, [
|
|
417
573
|
h('span', { key: 'label' }, selected ? (selected.text || selected.label) : ''),
|
|
@@ -437,130 +593,75 @@ window.__ModuleLoader__.load({
|
|
|
437
593
|
key: 'select',
|
|
438
594
|
className: 'wdxs-select',
|
|
439
595
|
value: props.value,
|
|
440
|
-
disabled:
|
|
596
|
+
disabled: disabled,
|
|
441
597
|
onChange: function (event) { props.onChange(event.target.value) },
|
|
442
598
|
}, options.map(function (option) {
|
|
443
599
|
return h('option', { key: option.id, value: option.id }, option.label)
|
|
444
600
|
}))
|
|
445
601
|
|
|
446
|
-
|
|
447
602
|
return h('div', { className: 'wdxs-row' }, [
|
|
448
|
-
h(
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
603
|
+
h(FieldText, {
|
|
604
|
+
key: 'text',
|
|
605
|
+
t: props.t,
|
|
606
|
+
title: props.title,
|
|
607
|
+
description: props.description,
|
|
608
|
+
overridden: props.overridden === true,
|
|
609
|
+
onReset: props.onReset,
|
|
610
|
+
}),
|
|
452
611
|
control,
|
|
453
612
|
])
|
|
454
613
|
}
|
|
455
614
|
|
|
456
|
-
function
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
h('div', { key: 'title', className: 'wdxs-title' }, props.title),
|
|
460
|
-
props.description ? h('div', { key: 'desc', className: 'wdxs-desc' }, props.description) : null,
|
|
461
|
-
]),
|
|
462
|
-
SWITCH
|
|
463
|
-
? h(SWITCH, {
|
|
464
|
-
key: 'switch',
|
|
465
|
-
checked: props.value === true,
|
|
466
|
-
label: props.title,
|
|
467
|
-
onChange: props.onChange,
|
|
468
|
-
})
|
|
469
|
-
: h('button', {
|
|
470
|
-
key: 'fallback',
|
|
471
|
-
type: 'button',
|
|
472
|
-
'aria-pressed': props.value === true,
|
|
473
|
-
onClick: function () { props.onChange(props.value !== true) },
|
|
474
|
-
className: 'wdxs-select',
|
|
475
|
-
}, props.value === true ? 'On' : 'Off'),
|
|
476
|
-
])
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
function CustomInstructionsRow(props) {
|
|
480
|
-
var value = typeof props.value === 'string' ? props.value : ''
|
|
481
|
-
var [draft, setDraft] = useState(value)
|
|
482
|
-
var focused = useRef(false)
|
|
483
|
-
var timer = useRef(null)
|
|
484
|
-
|
|
485
|
-
useEffect(function () {
|
|
486
|
-
if (!focused.current) setDraft(value)
|
|
487
|
-
}, [value])
|
|
488
|
-
|
|
489
|
-
useEffect(function () {
|
|
490
|
-
return function () {
|
|
491
|
-
if (timer.current !== null) clearTimeout(timer.current)
|
|
492
|
-
}
|
|
493
|
-
}, [])
|
|
494
|
-
|
|
495
|
-
function commit(next) {
|
|
496
|
-
if (next === value) return
|
|
497
|
-
props.onChange(next)
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
function schedule(next) {
|
|
501
|
-
var clipped = next.slice(0, 2000)
|
|
502
|
-
setDraft(clipped)
|
|
503
|
-
if (timer.current !== null) clearTimeout(timer.current)
|
|
504
|
-
timer.current = setTimeout(function () {
|
|
505
|
-
timer.current = null
|
|
506
|
-
commit(clipped)
|
|
507
|
-
}, 700)
|
|
508
|
-
}
|
|
509
|
-
|
|
615
|
+
function CustomTextField(props) {
|
|
616
|
+
var field = props.field
|
|
617
|
+
var disabled = props.disabled === true
|
|
510
618
|
return h('div', { className: 'wdxs-custom' }, [
|
|
511
|
-
h(
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
619
|
+
h(FieldText, {
|
|
620
|
+
key: 'text',
|
|
621
|
+
t: props.t,
|
|
622
|
+
title: props.title,
|
|
623
|
+
description: props.description,
|
|
624
|
+
overridden: field.overridden === true,
|
|
625
|
+
onReset: props.onReset,
|
|
626
|
+
}),
|
|
515
627
|
h('textarea', {
|
|
516
628
|
key: 'input',
|
|
517
629
|
className: 'wdxs-textarea',
|
|
518
|
-
value:
|
|
519
|
-
maxLength:
|
|
630
|
+
value: field.text,
|
|
631
|
+
maxLength: MAX_CUSTOM_CHARS,
|
|
520
632
|
placeholder: props.placeholder,
|
|
521
633
|
spellCheck: false,
|
|
522
|
-
|
|
523
|
-
onChange: function (event) {
|
|
524
|
-
onBlur: function () {
|
|
525
|
-
focused.current = false
|
|
526
|
-
if (timer.current !== null) {
|
|
527
|
-
clearTimeout(timer.current)
|
|
528
|
-
timer.current = null
|
|
529
|
-
}
|
|
530
|
-
commit(draft)
|
|
531
|
-
},
|
|
634
|
+
disabled: disabled,
|
|
635
|
+
onChange: function (event) { props.onChange(event.target.value) },
|
|
532
636
|
}),
|
|
533
637
|
])
|
|
534
638
|
}
|
|
535
639
|
|
|
536
640
|
function BundleSettingsPage(props) {
|
|
537
|
-
var useSettings = props.useSettings
|
|
538
|
-
var setField = props.setField
|
|
539
641
|
var t = props.t
|
|
540
|
-
|
|
541
|
-
var value = settings && settings.value ? settings.value : {}
|
|
542
|
-
var [error, setError] = useState('')
|
|
543
|
-
var [saved, setSaved] = useState(false)
|
|
544
|
-
var savedTimer = useRef(null)
|
|
642
|
+
if (props.view === 'summary') return tr(t, 'settings.summary', '预测下一句,并设置回复长度、风格和便于行动。')
|
|
545
643
|
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
644
|
+
var useSettings = props.useSettings
|
|
645
|
+
var state = useSettings ? useSettings(function (s) { return s }) : undefined
|
|
646
|
+
if (!state) return null
|
|
647
|
+
|
|
648
|
+
var disabled = state.writable === false || state.saving === true
|
|
649
|
+
var emptyField = { text: '', overridden: false, invalid: false }
|
|
650
|
+
var enabled = state.enabled || emptyField
|
|
651
|
+
var verbosity = state.verbosity || emptyField
|
|
652
|
+
var actionable = state.actionable || emptyField
|
|
653
|
+
var style = state.style || emptyField
|
|
654
|
+
var customInstructions = state.customInstructions || emptyField
|
|
655
|
+
|
|
656
|
+
function edit(name, value) {
|
|
657
|
+
if (typeof props.edit === 'function') props.edit(name, value)
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
function reset(name) {
|
|
661
|
+
if (typeof props.resetField === 'function') props.resetField(name)
|
|
561
662
|
}
|
|
562
663
|
|
|
563
|
-
var verbosityOptions =
|
|
664
|
+
var verbosityOptions = VERBOSITY_OPTIONS.map(function (id) {
|
|
564
665
|
return { id: id, label: tr(t, 'reply.verbosity.' + id, id) }
|
|
565
666
|
})
|
|
566
667
|
var styleOptions = STYLE_OPTIONS.map(function (id) {
|
|
@@ -575,70 +676,93 @@ window.__ModuleLoader__.load({
|
|
|
575
676
|
}
|
|
576
677
|
})
|
|
577
678
|
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
679
|
+
var formLabels = {
|
|
680
|
+
unavailable: tr(t, 'form.unavailable', '配置暂不可用。'),
|
|
681
|
+
readOnly: tr(t, 'form.readOnly', '当前部署只读。'),
|
|
682
|
+
saveFailed: tr(t, 'form.saveFailed', '保存失败,请重试。'),
|
|
683
|
+
save: tr(t, 'form.save', '保存'),
|
|
684
|
+
saving: tr(t, 'form.saving', '保存中…'),
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
var Form = SETTINGS_FORM || function (formProps) {
|
|
688
|
+
return h('div', { className: 'wdxs-fallback' }, formProps.children)
|
|
584
689
|
}
|
|
585
690
|
|
|
586
691
|
return h('div', { className: 'wdxs-page' }, [
|
|
692
|
+
h(PluginStyles, { key: 'style' }),
|
|
587
693
|
h('div', { key: 'intro', className: 'wdxs-intro' }, tr(t, 'reply.intro', '')),
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
694
|
+
h(Form, {
|
|
695
|
+
key: 'form',
|
|
696
|
+
labels: formLabels,
|
|
697
|
+
state: state,
|
|
698
|
+
onSave: function () { if (typeof props.save === 'function') props.save() },
|
|
699
|
+
onDiscard: function () { if (typeof props.discard === 'function') props.discard() },
|
|
700
|
+
}, [
|
|
701
|
+
h('div', { key: 'input', className: 'wdxs-group' }, [
|
|
702
|
+
h('div', { key: 'head', className: 'wdxs-groupHead' }, tr(t, 'reply.group.input', '输入')),
|
|
703
|
+
h(ToggleField, {
|
|
704
|
+
key: 'prediction',
|
|
705
|
+
t: t,
|
|
706
|
+
title: tr(t, 'settings.title', '显示预测消息'),
|
|
707
|
+
description: tr(t, 'settings.description', '根据对话预测你接下来要发送的消息'),
|
|
708
|
+
field: enabled,
|
|
709
|
+
disabled: disabled,
|
|
710
|
+
onChange: function (next) { edit('enabled', String(next)) },
|
|
711
|
+
onReset: function () { reset('enabled') },
|
|
712
|
+
}),
|
|
713
|
+
]),
|
|
714
|
+
h('div', { key: 'length', className: 'wdxs-group' }, [
|
|
715
|
+
h('div', { key: 'head', className: 'wdxs-groupHead' }, tr(t, 'reply.group.length', '回复长度')),
|
|
716
|
+
h(SelectField, {
|
|
717
|
+
key: 'verbosity',
|
|
718
|
+
t: t,
|
|
719
|
+
title: tr(t, 'reply.verbosity.title', '输出详细程度'),
|
|
720
|
+
description: tr(t, 'reply.verbosity.description', ''),
|
|
721
|
+
options: verbosityOptions,
|
|
722
|
+
value: verbosity.text || 'low',
|
|
723
|
+
overridden: verbosity.overridden === true,
|
|
724
|
+
disabled: disabled,
|
|
725
|
+
onChange: function (next) { edit('verbosity', next) },
|
|
726
|
+
onReset: function () { reset('verbosity') },
|
|
727
|
+
}),
|
|
728
|
+
]),
|
|
729
|
+
h('div', { key: 'writing', className: 'wdxs-group' }, [
|
|
730
|
+
h('div', { key: 'head', className: 'wdxs-groupHead' }, tr(t, 'reply.group.writing', '写作')),
|
|
731
|
+
h(ToggleField, {
|
|
732
|
+
key: 'actionable',
|
|
733
|
+
t: t,
|
|
734
|
+
title: tr(t, 'reply.actionable.title', '便于行动'),
|
|
735
|
+
description: tr(t, 'reply.actionable.description', ''),
|
|
736
|
+
field: actionable,
|
|
737
|
+
disabled: disabled,
|
|
738
|
+
onChange: function (next) { edit('actionable', String(next)) },
|
|
739
|
+
onReset: function () { reset('actionable') },
|
|
740
|
+
}),
|
|
741
|
+
h(SelectField, {
|
|
742
|
+
key: 'style',
|
|
743
|
+
t: t,
|
|
744
|
+
title: tr(t, 'reply.style.title', '回复风格'),
|
|
745
|
+
description: tr(t, 'reply.style.description', ''),
|
|
746
|
+
options: styleOptions,
|
|
747
|
+
value: style.text,
|
|
748
|
+
overridden: style.overridden === true,
|
|
749
|
+
disabled: disabled,
|
|
750
|
+
onChange: function (next) { edit('style', next) },
|
|
751
|
+
onReset: function () { reset('style') },
|
|
752
|
+
}),
|
|
753
|
+
]),
|
|
754
|
+
h(CustomTextField, {
|
|
755
|
+
key: 'custom',
|
|
756
|
+
t: t,
|
|
757
|
+
title: tr(t, 'reply.custom.title', '自定义指令'),
|
|
758
|
+
description: tr(t, 'reply.custom.description', ''),
|
|
759
|
+
placeholder: tr(t, 'reply.custom.placeholder', ''),
|
|
760
|
+
field: customInstructions,
|
|
761
|
+
disabled: disabled,
|
|
762
|
+
onChange: function (next) { edit('customInstructions', next) },
|
|
763
|
+
onReset: function () { reset('customInstructions') },
|
|
628
764
|
}),
|
|
629
765
|
]),
|
|
630
|
-
|
|
631
|
-
h(CustomInstructionsRow, {
|
|
632
|
-
key: 'custom',
|
|
633
|
-
title: tr(t, 'reply.custom.title', '自定义指令'),
|
|
634
|
-
description: tr(t, 'reply.custom.description', ''),
|
|
635
|
-
placeholder: tr(t, 'reply.custom.placeholder', ''),
|
|
636
|
-
value: typeof value.customInstructions === 'string' ? value.customInstructions : '',
|
|
637
|
-
onChange: function (next) { update('customInstructions', next) },
|
|
638
|
-
}),
|
|
639
|
-
|
|
640
|
-
error ? h('div', { key: 'error', className: 'wdxs-error', role: 'alert' }, error) : null,
|
|
641
|
-
saved && !error ? h('div', { key: 'saved', className: 'wdxs-status', role: 'status' }, tr(t, 'reply.saved', '已保存')) : null,
|
|
642
766
|
])
|
|
643
767
|
}
|
|
644
768
|
|
|
@@ -653,10 +777,17 @@ window.__ModuleLoader__.load({
|
|
|
653
777
|
}, 'wdx-relief: dictionaries')
|
|
654
778
|
|
|
655
779
|
var form = ctx.configForms.get(NS)
|
|
780
|
+
var settings = createSettingsModel(form)
|
|
781
|
+
ctx.effect(function () {
|
|
782
|
+
return function () { settings.model.dispose() }
|
|
783
|
+
}, 'wdx-relief: settings form')
|
|
784
|
+
|
|
785
|
+
// 预测组件只需要只读的配置快照;配置页使用上面的暂存 model。
|
|
656
786
|
var formSource = {
|
|
657
787
|
getSnapshot: function () { return form.getSnapshot() },
|
|
658
788
|
subscribe: function (listener) { return form.subscribe(listener) },
|
|
659
789
|
}
|
|
790
|
+
|
|
660
791
|
ctx.slots.inject('conversation.input.overlay', function () {
|
|
661
792
|
return ctx.slots.register({
|
|
662
793
|
name: 'conversation.input.overlay',
|
|
@@ -669,27 +800,19 @@ window.__ModuleLoader__.load({
|
|
|
669
800
|
}, PredictionOverlay)
|
|
670
801
|
})
|
|
671
802
|
|
|
672
|
-
var configInjected = function () {
|
|
673
|
-
return {
|
|
674
|
-
hooks: { settings: formSource },
|
|
675
|
-
setField: function (field, next) {
|
|
676
|
-
return form.set(field, next).then(function (accepted) {
|
|
677
|
-
if (accepted !== true) throw new Error('settings write refused')
|
|
678
|
-
return accepted
|
|
679
|
-
})
|
|
680
|
-
},
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
|
|
684
803
|
ctx.slots.inject('plugins.bundle.config', function () {
|
|
685
804
|
return ctx.slots.register({
|
|
686
805
|
name: 'plugins.bundle.config',
|
|
687
806
|
key: 'dsh-wdx-relief',
|
|
688
807
|
locale: NS,
|
|
689
|
-
inject:
|
|
808
|
+
inject: function () {
|
|
809
|
+
return {
|
|
810
|
+
hooks: { settings: settings.store },
|
|
811
|
+
...settings.model.actions(),
|
|
812
|
+
}
|
|
813
|
+
},
|
|
690
814
|
}, BundleSettingsPage)
|
|
691
815
|
})
|
|
692
|
-
|
|
693
816
|
}
|
|
694
817
|
|
|
695
818
|
exports.name = name
|
package/cordis.patch.yml
CHANGED
package/docs/guide.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# WDX Relief 开发与验证
|
|
2
2
|
|
|
3
|
-

|
|
4
|
+
|
|
5
|
+
> 截图为 0.3.0;0.3.1 起配置页改为「先编辑、再保存」,底部会多出保存按钮。
|
|
4
6
|
|
|
5
7
|
## 独立 web profile 安装
|
|
6
8
|
|
|
@@ -15,12 +17,15 @@ dsh plugin --profile web add link:/path/to/dsh-wdx-relief
|
|
|
15
17
|
|
|
16
18
|
## 配置页在哪里
|
|
17
19
|
|
|
18
|
-
`
|
|
19
|
-
`
|
|
20
|
-
|
|
20
|
+
配置页通过 `ctx.slots.inject('plugins.bundle.config', …)` 注册,key 是包名 `dsh-wdx-relief`;
|
|
21
|
+
`dsh.client.inject` 因此声明 `@deepseek-ai/dsh-client-ui-plugin-manager`;同时保留
|
|
22
|
+
`@deepseek-ai/dsh-client-ui-settings`,因为 `configForms` 由它提供。插件管理页加载后,bundle 页面在 README 下方渲染这个 keyed slot;插件关闭时
|
|
23
|
+
整个浏览器半身卸载,配置页也随之消失。
|
|
21
24
|
|
|
22
|
-
所有字段都是 Host `Config` 的 `.volatile()`
|
|
23
|
-
|
|
25
|
+
所有字段都是 Host `Config` 的 `.volatile()` 引用。客户端用
|
|
26
|
+
`SettingsFormModel(ctx.configForms.get('wdx-relief'), …)` 暂存编辑,点 **保存** 才通过
|
|
27
|
+
`form.mutate()` 写入;离开页面会丢弃未保存草稿。写入落到 profile 的 `cordis.patch.yml`,
|
|
28
|
+
HMR 生效。
|
|
24
29
|
|
|
25
30
|
| 字段 | 默认 | 说明 |
|
|
26
31
|
|---|---|---|
|
|
@@ -44,12 +49,13 @@ bundle 层只声明入口和预测开关,其余字段由 schema 默认值提
|
|
|
44
49
|
|
|
45
50
|
## 输入预测
|
|
46
51
|
|
|
47
|
-
1.
|
|
52
|
+
1. 客户端注册在 `conversation.input.overlay`,观察 `useSession.running`、`useInput` 和设置;
|
|
48
53
|
空闲、空输入时以 350ms 防抖请求 `POST /api/wdx-relief/predict`。
|
|
49
54
|
2. Host 用 `ctx.sessions.get(sessionId).deriveMessages()` 取最近几轮真人用户/助手文本,
|
|
50
55
|
要求最后一条是助手消息;用 `agentDefaultModel` 的最低推理档位生成一条短句。
|
|
51
56
|
3. 结果按 `session.seq` 缓存;客户端把灰字绝对定位到 `[data-composer-input]` 的文字起点,
|
|
52
57
|
Tab 通过标准 prop `inputActions.setDraft()` 写入 Lexical 编辑器。
|
|
58
|
+
这条 Codex 式体验依赖 composer 的布局矩形,是本插件已知的 DOM 耦合点。
|
|
53
59
|
|
|
54
60
|
## 回复风格
|
|
55
61
|
|
|
@@ -71,7 +77,7 @@ Host 在 `ctx.systemPrompt` 注册:
|
|
|
71
77
|
按内容比例组织(句 > 段 > 清单)、术语先用白话说明、保留风险与失败条件、不复述、
|
|
72
78
|
不把已获授权的工作交回用户。
|
|
73
79
|
|
|
74
|
-
## 实机验证记录(DSH 0.2.2-rc.1
|
|
80
|
+
## 实机验证记录(DSH 0.2.2-rc.1,历史配置页)
|
|
75
81
|
|
|
76
82
|
- 侧边栏「插件」→ **WDX Relief** bundle 页出现配置区:输入开关、回复长度、便于行动开关、回复风格、自定义指令;
|
|
77
83
|
- 下拉框、开关、textarea 均可写入;关闭再打开设置后保持;`--dump-config` 能看到 `verbosity`、`actionable`、`style`、`customInstructions`;
|
|
@@ -79,11 +85,20 @@ Host 在 `ctx.systemPrompt` 注册:
|
|
|
79
85
|
- 输入框灰字出现、打字隐藏、清空重现,Tab 真正写入 Lexical;
|
|
80
86
|
- 关闭预测开关后不再发预测请求;
|
|
81
87
|
- Host 日志确认预测路由与 `wdx-relief:reply-style` prompt section 注册成功;
|
|
82
|
-
-
|
|
88
|
+
- Node 单测通过。
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
## 0.3.1 验证
|
|
92
|
+
|
|
93
|
+
- `conversation.input.overlay` 下 `wdx-prediction`(registrant `wdx-relief`,active);保持 Codex 式输入框灰字。
|
|
94
|
+
- `plugins.bundle.config` 下 `dsh-wdx-relief` 条目仍 active。
|
|
95
|
+
- 配置页改用 `SettingsFormModel` 暂存、`SettingsForm` 保存;`node --test` 27 项通过。
|
|
96
|
+
- `npm pack --dry-run` 确认 `client/client.js`、`locale`、`icon.svg`、`cordis.patch.yml` 都在发布文件里。
|
|
97
|
+
- 浏览器内交互(实际点击、保存、开关、Tab)尚未在本次会话中用浏览器控制复核。
|
|
83
98
|
|
|
84
99
|
## 已知限制
|
|
85
100
|
|
|
86
101
|
- 回复风格是 prompt 软约束,不是硬截断;复杂任务仍可能写长。
|
|
87
102
|
- 写作风格只看当前对话;没有跨会话风格档案,也不读取工作区文件或外部应用。
|
|
88
103
|
- 风格设置全局生效,暂不支持 per-session。
|
|
89
|
-
- 灰字定位依赖 composer 的 DOM
|
|
104
|
+
- 灰字定位依赖 composer 的 DOM 属性(`data-composer-card/input/placeholder`),DSH 改版时需要同步。
|
package/index.js
CHANGED
|
@@ -23,7 +23,7 @@ export const Config = Schema.object({
|
|
|
23
23
|
enabled: Schema.boolean()
|
|
24
24
|
.default(true)
|
|
25
25
|
.volatile()
|
|
26
|
-
.description('
|
|
26
|
+
.description('根据对话在输入框下方显示下一条消息预测,Tab 填入'),
|
|
27
27
|
verbosity: Schema.union(VERBOSITY_VALUES)
|
|
28
28
|
.default('low')
|
|
29
29
|
.volatile()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-wdx-relief",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Take the friction out of daily DSH work: predicted next messages in the composer, plus reply length, tone, and writing style controls.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"./client": "./client/client.js",
|
|
10
10
|
"./package.json": "./package.json",
|
|
11
11
|
"./locale/*.json": "./locale/*.json",
|
|
12
|
-
"./icon": "./icon.
|
|
12
|
+
"./icon": "./icon.svg"
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
15
|
"index.js",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"client": {
|
|
33
33
|
"platform": "web",
|
|
34
34
|
"inject": [
|
|
35
|
-
"@deepseek-ai/dsh-client-ui-settings",
|
|
36
35
|
"@deepseek-ai/dsh-client-ui-conversation",
|
|
36
|
+
"@deepseek-ai/dsh-client-ui-settings",
|
|
37
|
+
"@deepseek-ai/dsh-client-ui-plugin-manager",
|
|
37
38
|
"@deepseek-ai/dsh-client-locale"
|
|
38
|
-
]
|
|
39
|
-
"immediately": true
|
|
39
|
+
]
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
@@ -44,16 +44,15 @@
|
|
|
44
44
|
"prepublishOnly": "npm test"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@deepseek-ai/cordis": "^4.0.1"
|
|
48
|
-
"@deepseek-ai/schemastery": "^3.19.0"
|
|
47
|
+
"@deepseek-ai/cordis": "^4.0.1"
|
|
49
48
|
},
|
|
50
49
|
"engines": {
|
|
51
50
|
"node": ">=22",
|
|
52
|
-
"dsh": ">=0.2.0"
|
|
51
|
+
"dsh": ">=0.2.0 <0.3.0"
|
|
53
52
|
},
|
|
54
53
|
"license": "MIT",
|
|
55
54
|
"devDependencies": {
|
|
56
|
-
"@deepseek-ai/
|
|
55
|
+
"@deepseek-ai/cordis": "^4.0.1"
|
|
57
56
|
},
|
|
58
57
|
"author": "wdxtub",
|
|
59
58
|
"keywords": [
|
|
@@ -63,9 +62,11 @@
|
|
|
63
62
|
"prediction",
|
|
64
63
|
"reply-style",
|
|
65
64
|
"web-ui",
|
|
66
|
-
"productivity"
|
|
65
|
+
"productivity",
|
|
66
|
+
"dsh-plugin",
|
|
67
|
+
"dsh-bundle"
|
|
67
68
|
],
|
|
68
|
-
"icon": "./icon.
|
|
69
|
+
"icon": "./icon.svg",
|
|
69
70
|
"repository": {
|
|
70
71
|
"type": "git",
|
|
71
72
|
"url": "git+https://github.com/wdxtub/dsh-wdx-relief.git"
|
|
@@ -77,5 +78,8 @@
|
|
|
77
78
|
"publishConfig": {
|
|
78
79
|
"access": "public",
|
|
79
80
|
"registry": "https://registry.npmjs.org/"
|
|
81
|
+
},
|
|
82
|
+
"dependencies": {
|
|
83
|
+
"@deepseek-ai/schemastery": "3.19.0"
|
|
80
84
|
}
|
|
81
85
|
}
|