dsh-plugin-trim 0.3.9 → 0.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/client.js +56 -10
- package/dist/index.js +6 -1
- package/package.json +42 -1
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ npm i dsh-plugin-trim
|
|
|
13
13
|
从 GitHub Release 安装(备用):
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
npm i "https://github.com/Starlit-Sky-code/dsh-experience-optimizer/releases/download/v0.3.
|
|
16
|
+
npm i "https://github.com/Starlit-Sky-code/dsh-experience-optimizer/releases/download/v0.3.10/dsh-plugin-trim-0.3.10.tgz"
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
本地包:
|
|
@@ -50,6 +50,7 @@ npm i /absolute/path/to/packages/plugin-trim
|
|
|
50
50
|
## 安全边界
|
|
51
51
|
|
|
52
52
|
- 默认只建议,不自动禁用。
|
|
53
|
+
- Web API 需要 DSH 连接认证、同源请求和 `x-dsh-trim-client: 1` 请求头;未通过时不返回数据。
|
|
53
54
|
- `trim_apply_profile` 必须 `confirm: true`,但默认还要宿主审批返回 `allowed-once` 才真正写入;`confirm` 只是提案标记。
|
|
54
55
|
- `trim_rollback_profile` 始终需要宿主审批。
|
|
55
56
|
- 只应用 `risk: low`、非受保护的 disable/enable 项。
|
package/client.js
CHANGED
|
@@ -427,7 +427,8 @@ window.__ModuleLoader__.load({
|
|
|
427
427
|
.eo-toast-error{border-color:color-mix(in srgb,var(--eo-error) 45%,transparent)}
|
|
428
428
|
.eo-loading{display:flex;align-items:center;justify-content:center;gap:8px;padding:24px;color:var(--eo-tertiary);font-size:12px}
|
|
429
429
|
.eo-spinner{width:13px;height:13px;border-radius:50%;border:2px solid var(--eo-border-strong);border-top-color:var(--eo-primary);animation:eo-spin .8s linear infinite}
|
|
430
|
-
.eo-
|
|
430
|
+
.eo-crash{padding:16px}
|
|
431
|
+
.eo-error{padding:10px 12px;border-radius:var(--dsw-radius-md,8px);background:color-mix(in srgb,var(--eo-error) 7%,transparent);border:.5px solid color-mix(in srgb,var(--eo-error) 35%,transparent);color:var(--eo-error);font-size:12px;line-height:18px;display:flex;gap:10px;align-items:center;justify-content:space-between}
|
|
431
432
|
.eo-muted{color:var(--eo-tertiary);font-size:12px;line-height:18px}
|
|
432
433
|
.eo-note{padding:9px 12px;border:1px solid var(--dsw-alias-border-l3);border-radius:8px;background:var(--dsw-alias-bg-layer-3);color:var(--eo-secondary);font-size:12px;line-height:19px}
|
|
433
434
|
.eo-code{font:400 11px/16px var(--eo-code);color:var(--eo-secondary);word-break:break-all}
|
|
@@ -901,6 +902,7 @@ window.__ModuleLoader__.load({
|
|
|
901
902
|
...options,
|
|
902
903
|
headers: { ...(options && options.headers ? options.headers : {}) },
|
|
903
904
|
}
|
|
905
|
+
request.headers['x-dsh-trim-client'] = '1'
|
|
904
906
|
if (request.body !== undefined) request.headers['content-type'] = 'application/json'
|
|
905
907
|
const response = await fetch(path, request)
|
|
906
908
|
let body = null
|
|
@@ -1002,6 +1004,31 @@ window.__ModuleLoader__.load({
|
|
|
1002
1004
|
)
|
|
1003
1005
|
}
|
|
1004
1006
|
|
|
1007
|
+
class PluginErrorBoundary extends React.Component {
|
|
1008
|
+
constructor(props) {
|
|
1009
|
+
super(props)
|
|
1010
|
+
this.state = { error: null }
|
|
1011
|
+
}
|
|
1012
|
+
static getDerivedStateFromError(error) {
|
|
1013
|
+
return { error }
|
|
1014
|
+
}
|
|
1015
|
+
componentDidCatch(error) {
|
|
1016
|
+
try {
|
|
1017
|
+
console.error('[dsh-plugin-trim] UI render failed', error)
|
|
1018
|
+
} catch {
|
|
1019
|
+
// Logging must never mask the fallback.
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
render() {
|
|
1023
|
+
if (this.state.error) {
|
|
1024
|
+
return h('div', { className: 'eo-root eo-crash' },
|
|
1025
|
+
h('div', { className: 'eo-error' }, tr('界面渲染失败;插件本身仍在运行。', 'The UI failed to render; the plugin is still running.')),
|
|
1026
|
+
)
|
|
1027
|
+
}
|
|
1028
|
+
return this.props.children
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1005
1032
|
function OnboardingModal({ step, setStep, onFinish, onTutorial, onClose }) {
|
|
1006
1033
|
const steps = [
|
|
1007
1034
|
{
|
|
@@ -1372,6 +1399,21 @@ window.__ModuleLoader__.load({
|
|
|
1372
1399
|
setSettingsDraft((current) => current ? { ...current, [field]: value } : current)
|
|
1373
1400
|
}, [])
|
|
1374
1401
|
|
|
1402
|
+
const loadRecommendedSettings = useCallback(() => {
|
|
1403
|
+
setSettingsDraft((current) => current ? {
|
|
1404
|
+
...current,
|
|
1405
|
+
mode: 'advise',
|
|
1406
|
+
approvalMode: 'always',
|
|
1407
|
+
suggestionPolicy: 'conservative',
|
|
1408
|
+
approvalThreshold: 5,
|
|
1409
|
+
trackUsage: true,
|
|
1410
|
+
usageRetentionDays: 30,
|
|
1411
|
+
maxDrafts: 20,
|
|
1412
|
+
protect: [],
|
|
1413
|
+
pinned: [],
|
|
1414
|
+
} : current)
|
|
1415
|
+
}, [])
|
|
1416
|
+
|
|
1375
1417
|
const discardSettings = useCallback(() => {
|
|
1376
1418
|
setSettingsDraft(settings ? { ...settings } : null)
|
|
1377
1419
|
setSettingsError('')
|
|
@@ -1414,7 +1456,7 @@ window.__ModuleLoader__.load({
|
|
|
1414
1456
|
} catch (err) {
|
|
1415
1457
|
const message = err instanceof Error ? err.message : String(err)
|
|
1416
1458
|
setUpdateInfo({
|
|
1417
|
-
current: '0.3.
|
|
1459
|
+
current: '0.3.10',
|
|
1418
1460
|
latest: null,
|
|
1419
1461
|
updateAvailable: false,
|
|
1420
1462
|
error: /unknown endpoint/i.test(message)
|
|
@@ -2002,6 +2044,7 @@ window.__ModuleLoader__.load({
|
|
|
2002
2044
|
{
|
|
2003
2045
|
title: tr('插件设置', 'Plugin settings'),
|
|
2004
2046
|
subtitle: tr('改动后才会出现应用按钮;应用会重载插件', 'The apply button appears after changes; applying reloads the plugin'),
|
|
2047
|
+
extra: h(Button, { variant: 'ghost', onClick: loadRecommendedSettings }, tr('推荐默认值', 'Recommended')),
|
|
2005
2048
|
},
|
|
2006
2049
|
h(
|
|
2007
2050
|
'div',
|
|
@@ -2066,7 +2109,7 @@ window.__ModuleLoader__.load({
|
|
|
2066
2109
|
h(
|
|
2067
2110
|
Card,
|
|
2068
2111
|
{ title: tr('更新与反馈', 'Updates & feedback'), subtitle: tr('检查 npm 最新版本;反馈请走 GitHub Issues', 'Check the latest npm version; feedback via GitHub Issues') },
|
|
2069
|
-
h('div', { className: 'eo-settings-row' }, h('span', null, tr('当前版本', 'Current version')), h('code', null, updateInfo?.current || '0.3.
|
|
2112
|
+
h('div', { className: 'eo-settings-row' }, h('span', null, tr('当前版本', 'Current version')), h('code', null, updateInfo?.current || '0.3.10')),
|
|
2070
2113
|
h('div', { className: 'eo-settings-row' }, h('span', null, tr('最新版本', 'Latest version')), h('code', null, updateInfo ? (updateInfo.latest || tr('检查失败', 'Check failed')) : tr('未检查', 'Not checked'))),
|
|
2071
2114
|
updateInfo && updateInfo.updateAvailable
|
|
2072
2115
|
? h('div', { className: 'eo-issue' }, h('span', null, tr('发现新版本:', 'New version available: ') + updateInfo.latest + ' · '), h('a', { href: updateInfo.url, target: '_blank', rel: 'noreferrer' }, tr('查看 npm', 'View npm')))
|
|
@@ -2125,7 +2168,7 @@ window.__ModuleLoader__.load({
|
|
|
2125
2168
|
{ className: 'eo-about-card' },
|
|
2126
2169
|
h('div', { className: 'eo-inline', style: { marginBottom: '8px' } }, h(Icon, { name: 'shield', size: 24 }), h('strong', null, 'DSH Plugin Checkup')),
|
|
2127
2170
|
h('p', null, tr('少一点插件负担,多一点兼容确定性。', 'Less plugin overhead, more compatibility certainty.')),
|
|
2128
|
-
h('p', null, tr('版本:', 'Version: ') + '0.3.
|
|
2171
|
+
h('p', null, tr('版本:', 'Version: ') + '0.3.10 · AGPL-3.0-only'),
|
|
2129
2172
|
h('p', null, tr('作者:Starlit Sky', 'Author: Starlit Sky')),
|
|
2130
2173
|
),
|
|
2131
2174
|
h(
|
|
@@ -3369,6 +3412,9 @@ window.__ModuleLoader__.load({
|
|
|
3369
3412
|
function apply(ctx) {
|
|
3370
3413
|
CURRENT_LOCALE = detectLocale()
|
|
3371
3414
|
injectCss()
|
|
3415
|
+
const guard = (Component) => function Guarded(props) {
|
|
3416
|
+
return h(PluginErrorBoundary, null, h(Component, props))
|
|
3417
|
+
}
|
|
3372
3418
|
ctx.slots.inject('conversation.composer.dock', () =>
|
|
3373
3419
|
ctx.slots.register(
|
|
3374
3420
|
{
|
|
@@ -3376,7 +3422,7 @@ window.__ModuleLoader__.load({
|
|
|
3376
3422
|
id: 'experience-optimizer-checkup',
|
|
3377
3423
|
order: 20,
|
|
3378
3424
|
},
|
|
3379
|
-
CheckupBubble,
|
|
3425
|
+
guard(CheckupBubble),
|
|
3380
3426
|
),
|
|
3381
3427
|
)
|
|
3382
3428
|
ctx.slots.inject('conversation.chat.reasoning.body', () =>
|
|
@@ -3385,7 +3431,7 @@ window.__ModuleLoader__.load({
|
|
|
3385
3431
|
name: 'conversation.chat.reasoning.body',
|
|
3386
3432
|
priority: 90,
|
|
3387
3433
|
},
|
|
3388
|
-
ReasoningCheckup,
|
|
3434
|
+
guard(ReasoningCheckup),
|
|
3389
3435
|
),
|
|
3390
3436
|
)
|
|
3391
3437
|
ctx.slots.inject('plugins.bundle.activation', () =>
|
|
@@ -3394,7 +3440,7 @@ window.__ModuleLoader__.load({
|
|
|
3394
3440
|
name: 'plugins.bundle.activation',
|
|
3395
3441
|
key: 'dsh-plugin-trim',
|
|
3396
3442
|
},
|
|
3397
|
-
ActivationGuide,
|
|
3443
|
+
guard(ActivationGuide),
|
|
3398
3444
|
),
|
|
3399
3445
|
)
|
|
3400
3446
|
ctx.slots.inject('shell.overlay', () =>
|
|
@@ -3404,7 +3450,7 @@ window.__ModuleLoader__.load({
|
|
|
3404
3450
|
id: 'experience-optimizer-guide',
|
|
3405
3451
|
order: 10,
|
|
3406
3452
|
},
|
|
3407
|
-
MainGuide,
|
|
3453
|
+
guard(MainGuide),
|
|
3408
3454
|
),
|
|
3409
3455
|
)
|
|
3410
3456
|
ctx.slots.inject('settings.plugins.tab', () =>
|
|
@@ -3415,7 +3461,7 @@ window.__ModuleLoader__.load({
|
|
|
3415
3461
|
order: 40,
|
|
3416
3462
|
label: () => '插件体检',
|
|
3417
3463
|
},
|
|
3418
|
-
ExperiencePanel,
|
|
3464
|
+
guard(ExperiencePanel),
|
|
3419
3465
|
),
|
|
3420
3466
|
)
|
|
3421
3467
|
ctx.slots.inject('settings.section', () =>
|
|
@@ -3426,7 +3472,7 @@ window.__ModuleLoader__.load({
|
|
|
3426
3472
|
order: 25,
|
|
3427
3473
|
label: () => '插件体检',
|
|
3428
3474
|
},
|
|
3429
|
-
ExperiencePanel,
|
|
3475
|
+
guard(ExperiencePanel),
|
|
3430
3476
|
),
|
|
3431
3477
|
)
|
|
3432
3478
|
ctx.slots.inject('settings.section.icon', () =>
|
package/dist/index.js
CHANGED
|
@@ -4588,7 +4588,8 @@ function registerCompatTool(ctx, config) {
|
|
|
4588
4588
|
}
|
|
4589
4589
|
// src/api.ts
|
|
4590
4590
|
const API_PREFIX = "/api/dsh-experience-optimizer";
|
|
4591
|
-
const
|
|
4591
|
+
const CLIENT_HEADER = "x-dsh-trim-client";
|
|
4592
|
+
const CURRENT_VERSION = "0.3.10";
|
|
4592
4593
|
let updateCache;
|
|
4593
4594
|
const TASK_TAGS = [
|
|
4594
4595
|
"bugfix",
|
|
@@ -4634,6 +4635,10 @@ async function handleTrimRequest(req, res, ctx, config, ledger) {
|
|
|
4634
4635
|
sendError(res, 403, "cross-site request rejected");
|
|
4635
4636
|
return;
|
|
4636
4637
|
}
|
|
4638
|
+
if (req.headers[CLIENT_HEADER] !== "1") {
|
|
4639
|
+
sendError(res, 403, "client header required");
|
|
4640
|
+
return;
|
|
4641
|
+
}
|
|
4637
4642
|
const path = new URL(req.url ?? "/", "http://localhost").pathname.slice(29) || "/";
|
|
4638
4643
|
try {
|
|
4639
4644
|
if (req.method === "GET" && path === "/overview") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-trim",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.10",
|
|
4
4
|
"description": "DSH plugin checkup and compatibility analyzer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -69,6 +69,47 @@
|
|
|
69
69
|
"@deepseek-ai/dsh-tools": "^0.2.2-rc.1",
|
|
70
70
|
"@deepseek-ai/schemastery": "~3.19.0"
|
|
71
71
|
},
|
|
72
|
+
"peerDependenciesMeta": {
|
|
73
|
+
"@deepseek-ai/cordis": {
|
|
74
|
+
"optional": true
|
|
75
|
+
},
|
|
76
|
+
"@deepseek-ai/cordis-plugin-loader": {
|
|
77
|
+
"optional": true
|
|
78
|
+
},
|
|
79
|
+
"@deepseek-ai/dsh": {
|
|
80
|
+
"optional": true
|
|
81
|
+
},
|
|
82
|
+
"@deepseek-ai/dsh-agent": {
|
|
83
|
+
"optional": true
|
|
84
|
+
},
|
|
85
|
+
"@deepseek-ai/dsh-app-boot": {
|
|
86
|
+
"optional": true
|
|
87
|
+
},
|
|
88
|
+
"@deepseek-ai/dsh-host-plugin-inventory": {
|
|
89
|
+
"optional": true
|
|
90
|
+
},
|
|
91
|
+
"@deepseek-ai/dsh-llm": {
|
|
92
|
+
"optional": true
|
|
93
|
+
},
|
|
94
|
+
"@deepseek-ai/dsh-plugin-manager": {
|
|
95
|
+
"optional": true
|
|
96
|
+
},
|
|
97
|
+
"@deepseek-ai/dsh-scope": {
|
|
98
|
+
"optional": true
|
|
99
|
+
},
|
|
100
|
+
"@deepseek-ai/dsh-session": {
|
|
101
|
+
"optional": true
|
|
102
|
+
},
|
|
103
|
+
"@deepseek-ai/dsh-system-prompt": {
|
|
104
|
+
"optional": true
|
|
105
|
+
},
|
|
106
|
+
"@deepseek-ai/dsh-tools": {
|
|
107
|
+
"optional": true
|
|
108
|
+
},
|
|
109
|
+
"@deepseek-ai/schemastery": {
|
|
110
|
+
"optional": true
|
|
111
|
+
}
|
|
112
|
+
},
|
|
72
113
|
"devDependencies": {
|
|
73
114
|
"@deepseek-ai/cordis": "~4.1.0",
|
|
74
115
|
"@deepseek-ai/cordis-plugin-loader": "~1.1.0",
|