@leiyi-works/dsh-feature-tweaks 0.1.3 → 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.
- package/README.md +16 -4
- package/client.js +190 -0
- package/index.js +141 -7
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +8 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @leiyi-works/dsh-feature-tweaks · 功能微调
|
|
2
2
|
|
|
3
|
-
> DeepSeek Harness(DSH)plugin: a bundle patch that collects version-to-version functional/default tweaks (overrides official rows by id, never touches core packages). Currently: new root sessions start with Agent Teams enabled.
|
|
3
|
+
> DeepSeek Harness(DSH)plugin: a bundle patch that collects version-to-version functional/default tweaks (overrides official rows by id, never touches core packages). Currently: new root sessions start with Agent Teams enabled; a configurable "Reload page" shortcut (F5 on desktop), moved here from dsh-sidebar-folders 0.13.4.
|
|
4
4
|
|
|
5
5
|
DSH 每次版本变化都会带来或多或少的官方行为差异、默认值不合意的地方。本包是这些**功能层面微调**的固定落点:按官方行 id 覆盖配置、或补一行,**不改任何核心包**。
|
|
6
6
|
|
|
@@ -16,23 +16,32 @@ DSH 每次版本变化都会带来或多或少的官方行为差异、默认值
|
|
|
16
16
|
| # | 目标行 | 官方默认 | 本包值 | 效果 / 理由 |
|
|
17
17
|
|---|---|---|---|---|
|
|
18
18
|
| 1 | `agent-team` | `defaultEnabled: false` | `defaultEnabled: true` | 新根会话(含普通 fork)在第一次模型步前默认开「智能体团队协作」;已在会话里保存过选择的会话不受影响;单会话仍可在「模型与推理等级」菜单里手动关 |
|
|
19
|
+
| 2 | `feature-tweaks.reload` | 桌面壳不绑刷新键(开发构建才有 Reload 菜单) | 桌面端 F5 / 网页端 Ctrl+Shift+R | 整页刷新快捷键,可配置;带「启动后插件已重建就先别刷新」的保护。从 `dsh-sidebar-folders` 0.13.4 迁移过来 |
|
|
19
20
|
|
|
20
21
|
团队模式会往上下文注入协作提示词和 `team_task_*` 工具,**token 开销更高**;简单任务随手关掉即可。
|
|
21
22
|
|
|
23
|
+
### 刷新页面快捷键(F5)
|
|
24
|
+
|
|
25
|
+
- **键位**:桌面端 <kbd>F5</kbd>,网页端 <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>R</kbd>;快捷键服务要求同一个组合只能有一个注册者,所以 F5 只在本包里注册(已从 `dsh-sidebar-folders` 移除)。
|
|
26
|
+
- **改键/清除**:设置 → <kbd>Ctrl</kbd>+<kbd>/</kbd>「快捷键」,搜「刷新页面 / Reload page」;桌面端覆盖保存在 `userData/keybindings.json`,网页端在该源站 localStorage 的 `dsh.keybindings.v1`。
|
|
27
|
+
- **安全刷新**:刷新前先问 Host `GET /__dsh-feature-tweaks/reload-safe`。若本次启动后有任何 Client bundle 被重建(例如刚 `pnpm install` 了新插件),直接刷新会因桌面壳仍用启动时的 boot manifest 而弹「应用无法启动」;此时只在页面上提示「请完全退出 DSH 再打开一次」,不刷新。
|
|
28
|
+
- **兜底**:桌面壳的按键桥接可能晚到,所以另有 document 级 F5 监听;桥接先处理时该监听不会重复触发。
|
|
29
|
+
|
|
22
30
|
## 安装
|
|
23
31
|
|
|
24
32
|
```powershell
|
|
25
|
-
dsh plugin --profile <profile> add @leiyi-works/dsh-feature-tweaks@0.
|
|
33
|
+
dsh plugin --profile <profile> add @leiyi-works/dsh-feature-tweaks@0.2.0
|
|
26
34
|
```
|
|
27
35
|
|
|
28
36
|
装完后确认 profile 的 `dsh.profile.bundles` 含 `@leiyi-works/dsh-feature-tweaks`,且排在 `@deepseek-ai/dsh-base` 之后。**重启 DSH** 生效(配置在启动时合成)。
|
|
29
37
|
|
|
30
38
|
## 实现机制
|
|
31
39
|
|
|
32
|
-
|
|
40
|
+
本包以配置为主,只有一项需要运行时代码:
|
|
33
41
|
|
|
34
42
|
- `cordis.patch.yml` —— bundle patch,在 `dsh-base` 插入官方行之后按 id 覆盖。效果与手改 profile 的 `cordis.patch.yml` 完全一致,但能整体启停、单独删除、换机/重装后随插件恢复。
|
|
35
|
-
- `index.js` ——
|
|
43
|
+
- `index.js` —— Host 行 `feature-tweaks`:让 bundle 在插件页显示为运行中,并提供刷新快捷键的安全探针路由 `GET /__dsh-feature-tweaks/reload-safe`(返回 live Client 模块图的 revs 和启动后被重建的 bundle)。
|
|
44
|
+
- `client.js` —— Web 侧半边:注册「刷新页面」快捷键、F5 兜底监听、安全刷新逻辑;诊断日志写到 `<DSH_HOME>/data/feature-tweaks-diag.log`。
|
|
36
45
|
|
|
37
46
|
**关键坑**:loader 的 patch 会**整段替换**目标行的 `config`(不是深合并)。覆盖时必须把该行原本的其它字段一起重述——例如 `agent-team` 要带上 `maxTasks: 256`,否则会退回 schema 默认值。
|
|
38
47
|
|
|
@@ -49,11 +58,14 @@ dsh plugin --profile <profile> add @leiyi-works/dsh-feature-tweaks@0.1.2
|
|
|
49
58
|
- 重启后新建一个会话,打开「模型与推理等级」菜单,底部「启用智能体团队协作」应为开;该会话应带 `team_task_*` 工具;
|
|
50
59
|
- 已存在的会话(保存过选择)行为不变;
|
|
51
60
|
- 手动关掉某一会话的开关后,该会话保持关闭。
|
|
61
|
+
- 桌面端按 <kbd>F5</kbd> 应刷新页面;设置 → 快捷键里能看到「刷新页面」并改了生效。
|
|
62
|
+
- 若刚装/更新过插件,按 F5 应弹出「请完全退出 DSH 再打开一次」而不是刷新(这是保护,不是故障);重启后再按即正常刷新。
|
|
52
63
|
|
|
53
64
|
## 撤回
|
|
54
65
|
|
|
55
66
|
- **整体**:从 profile 的 `dsh.profile.bundles` 移除 `@leiyi-works/dsh-feature-tweaks`,一步回到官方默认;
|
|
56
67
|
- **单项**:在 profile 的 `cordis.patch.yml`(更晚应用)里把对应行覆盖回去;
|
|
68
|
+
- **刷新快捷键**:设置 → 快捷键里清除「刷新页面」绑定即可,不影响本包其它微调;
|
|
57
69
|
- **单会话**:团队那一项直接在「模型与推理等级」菜单里关(仅本会话生效)。
|
|
58
70
|
|
|
59
71
|
## License
|
package/client.js
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client half of dsh-feature-tweaks.
|
|
3
|
+
*
|
|
4
|
+
* Contributes one configurable "Reload page" shortcut (F5 on desktop,
|
|
5
|
+
* Ctrl+Shift+R in a browser), moved here from
|
|
6
|
+
* @leiyi-works/dsh-sidebar-folders 0.13.4 so functional tweaks live in one
|
|
7
|
+
* bundle. The core shortcut service rejects overlapping default combinations,
|
|
8
|
+
* so the key exists in exactly one plugin.
|
|
9
|
+
*
|
|
10
|
+
* The key reloads through this bundle's Host probe (`reload-safe`): when any
|
|
11
|
+
* Client bundle was rebuilt after the app started, a reload would fail the
|
|
12
|
+
* Desktop boot audit, so the key explains the restart instead of reloading.
|
|
13
|
+
* A failed probe falls back to a plain reload.
|
|
14
|
+
*/
|
|
15
|
+
window.__ModuleLoader__.load({
|
|
16
|
+
id: '@leiyi-works/dsh-feature-tweaks',
|
|
17
|
+
factory() {
|
|
18
|
+
/** Locale namespace owned by this bundle. */
|
|
19
|
+
const NS = 'featureTweaks'
|
|
20
|
+
/** Host route prefix owned by the Host half. */
|
|
21
|
+
const API_PREFIX = '__dsh-feature-tweaks/api/'
|
|
22
|
+
|
|
23
|
+
/** Chinese dictionary. */
|
|
24
|
+
const zh = {
|
|
25
|
+
'reload.label': '刷新页面',
|
|
26
|
+
'reload.blocked': '插件代码在本次启动后更新过({names}),现在刷新会弹启动报错。请完全退出 DSH 再打开一次。',
|
|
27
|
+
}
|
|
28
|
+
/** English dictionary, complete against the zh key set. */
|
|
29
|
+
const en = {
|
|
30
|
+
'reload.label': 'Reload page',
|
|
31
|
+
'reload.blocked': 'Plugin code changed after this app started ({names}); reloading now would fail with a startup error. Quit DSH completely and open it again.',
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Page base that keeps requests on the page's own origin. */
|
|
35
|
+
function pageBase() {
|
|
36
|
+
if (typeof document !== 'undefined' && typeof document.baseURI === 'string' && document.baseURI !== '') return document.baseURI
|
|
37
|
+
if (typeof location !== 'undefined' && typeof location.href === 'string') return location.href
|
|
38
|
+
return 'http://localhost/'
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Resolve one Host route against the page base. */
|
|
42
|
+
function apiUrl(suffix) {
|
|
43
|
+
try {
|
|
44
|
+
return new URL(API_PREFIX + suffix, pageBase()).href
|
|
45
|
+
} catch {
|
|
46
|
+
return API_PREFIX + suffix
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Fire-and-forget diagnostic line for this bundle's Host half. */
|
|
51
|
+
function reportDiag(message) {
|
|
52
|
+
try {
|
|
53
|
+
void fetch(apiUrl('diag'), {
|
|
54
|
+
method: 'POST',
|
|
55
|
+
headers: { 'content-type': 'application/json' },
|
|
56
|
+
body: JSON.stringify({ time: Date.now(), message: String(message).slice(0, 3000) }),
|
|
57
|
+
}).catch(() => {})
|
|
58
|
+
} catch {
|
|
59
|
+
// Diagnostics must never disturb the page.
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Human-readable error text for diagnostics. */
|
|
64
|
+
function errorText(error) {
|
|
65
|
+
if (error instanceof Error) return error.stack ? error.stack : error.message
|
|
66
|
+
return String(error)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Transient toast for a reload that was refused on purpose. */
|
|
70
|
+
function showNotice(text) {
|
|
71
|
+
try {
|
|
72
|
+
const box = document.createElement('div')
|
|
73
|
+
box.textContent = text
|
|
74
|
+
box.setAttribute('role', 'status')
|
|
75
|
+
box.style.cssText = 'position:fixed;left:50%;bottom:96px;transform:translateX(-50%);z-index:200;'
|
|
76
|
+
+ 'max-width:560px;padding:10px 14px;border-radius:10px;'
|
|
77
|
+
+ 'background:var(--dsw-alias-bg-overlay,rgba(30,30,30,.96));color:var(--dsw-alias-label-primary,#fff);'
|
|
78
|
+
+ 'border:1px solid var(--dsw-alias-state-warning-primary,#c98a2a);'
|
|
79
|
+
+ 'box-shadow:0 10px 28px rgba(0,0,0,.22);font-size:13px;line-height:1.5;pointer-events:none'
|
|
80
|
+
document.body.appendChild(box)
|
|
81
|
+
window.setTimeout(() => {
|
|
82
|
+
try { box.remove() } catch { /* the toast removes itself */ }
|
|
83
|
+
}, 9000)
|
|
84
|
+
} catch {
|
|
85
|
+
// A notice must never break the key.
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Whether the page's boot manifest differs from the Host's live graph. */
|
|
90
|
+
function changedSinceBoot(revs) {
|
|
91
|
+
const bootRevs = new Map()
|
|
92
|
+
const boot = globalThis.__DSH_BOOT__
|
|
93
|
+
if (boot !== null && typeof boot === 'object' && Array.isArray(boot.entries)) {
|
|
94
|
+
for (const row of boot.entries) {
|
|
95
|
+
if (row !== null && typeof row === 'object' && typeof row.id === 'string') bootRevs.set(row.id, String(row.rev))
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return [...new Set([...Object.keys(revs), ...bootRevs.keys()])]
|
|
99
|
+
.filter((id) => bootRevs.get(id) !== revs[id])
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
name: '@leiyi-works/dsh-feature-tweaks',
|
|
104
|
+
inject: ['locale'],
|
|
105
|
+
apply(ctx) {
|
|
106
|
+
ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'feature-tweaks: dictionaries')
|
|
107
|
+
const t = ctx.locale.bind(NS)
|
|
108
|
+
|
|
109
|
+
let reloading = false
|
|
110
|
+
/** Probe the Host, then reload only when no Client bundle is stale. */
|
|
111
|
+
const scheduleReload = async () => {
|
|
112
|
+
if (reloading) return
|
|
113
|
+
reloading = true
|
|
114
|
+
reportDiag('reload-shortcut-fired')
|
|
115
|
+
let changed = null
|
|
116
|
+
try {
|
|
117
|
+
const response = await fetch(apiUrl('reload-safe'), { cache: 'no-store' })
|
|
118
|
+
if (response.ok) {
|
|
119
|
+
const data = await response.json()
|
|
120
|
+
if (data !== null && typeof data === 'object'
|
|
121
|
+
&& data.revs !== null && typeof data.revs === 'object') {
|
|
122
|
+
changed = changedSinceBoot(data.revs)
|
|
123
|
+
} else if (Array.isArray(data?.changed)) {
|
|
124
|
+
changed = data.changed
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
} catch {
|
|
128
|
+
// An unreachable probe falls back to a plain reload.
|
|
129
|
+
}
|
|
130
|
+
if (changed !== null && changed.length > 0) {
|
|
131
|
+
const names = changed.slice(0, 3).join('、') + (changed.length > 3 ? ' 等' : '')
|
|
132
|
+
showNotice(t('reload.blocked', { names }))
|
|
133
|
+
reportDiag('reload-shortcut-blocked changed=' + changed.join(','))
|
|
134
|
+
reloading = false
|
|
135
|
+
return
|
|
136
|
+
}
|
|
137
|
+
window.setTimeout(() => {
|
|
138
|
+
try { globalThis.location.reload() } catch { /* the page is going away anyway */ }
|
|
139
|
+
}, 120)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
ctx.inject(['shortcuts'], (scope) => {
|
|
143
|
+
scope.effect(() => {
|
|
144
|
+
try {
|
|
145
|
+
const dispose = scope.shortcuts.register({
|
|
146
|
+
id: 'feature-tweaks.reload',
|
|
147
|
+
label: () => t('reload.label'),
|
|
148
|
+
aliases: ['reload', 'refresh', '刷新'],
|
|
149
|
+
defaults: {
|
|
150
|
+
'desktop:windows': { code: 'F5', modifiers: [] },
|
|
151
|
+
'desktop:macos': { code: 'F5', modifiers: [] },
|
|
152
|
+
'web:windows': { code: 'KeyR', modifiers: ['primary', 'shift'] },
|
|
153
|
+
'web:macos': { code: 'KeyR', modifiers: ['primary', 'shift'] },
|
|
154
|
+
},
|
|
155
|
+
regions: ['page', 'editable', 'terminal'],
|
|
156
|
+
modals: [],
|
|
157
|
+
resolve: () => ({
|
|
158
|
+
status: 'handled',
|
|
159
|
+
run: () => { void scheduleReload() },
|
|
160
|
+
}),
|
|
161
|
+
})
|
|
162
|
+
reportDiag('reload-shortcut-ready')
|
|
163
|
+
return dispose
|
|
164
|
+
} catch (error) {
|
|
165
|
+
reportDiag('reload-shortcut-failed: ' + errorText(error))
|
|
166
|
+
return () => {}
|
|
167
|
+
}
|
|
168
|
+
}, 'feature-tweaks: reload shortcut')
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
// Fallback for the desktop shell: its native shortcut bridge only
|
|
172
|
+
// forwards a key once the shell has received this command's definition,
|
|
173
|
+
// and that hand-off can lag a page load. A plain DOM listener reloads the
|
|
174
|
+
// page anyway; when the bridge does forward the key, the shell consumes
|
|
175
|
+
// it first and this listener never sees it, so reload never runs twice.
|
|
176
|
+
ctx.effect(() => {
|
|
177
|
+
const onKeyDown = (event) => {
|
|
178
|
+
if (event.key !== 'F5' || event.ctrlKey || event.altKey || event.shiftKey || event.metaKey) return
|
|
179
|
+
if (event.defaultPrevented) return
|
|
180
|
+
event.preventDefault()
|
|
181
|
+
event.stopPropagation()
|
|
182
|
+
void scheduleReload()
|
|
183
|
+
}
|
|
184
|
+
document.addEventListener('keydown', onKeyDown, true)
|
|
185
|
+
return () => document.removeEventListener('keydown', onKeyDown, true)
|
|
186
|
+
}, 'feature-tweaks: reload key fallback')
|
|
187
|
+
},
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
})
|
package/index.js
CHANGED
|
@@ -1,12 +1,146 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* dsh-feature-tweaks —
|
|
2
|
+
* dsh-feature-tweaks — Host half.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Most tweaks live in this package's `cordis.patch.yml` (a bundle patch that
|
|
5
|
+
* overrides official rows by id). This row is the Host half for the one tweak
|
|
6
|
+
* that needs runtime code: the "Reload page" shortcut (moved here from
|
|
7
|
+
* @leiyi-works/dsh-sidebar-folders 0.13.4 in 0.2.0).
|
|
8
|
+
*
|
|
9
|
+
* The Desktop shell keeps the boot manifest it captured at startup, so a page
|
|
10
|
+
* reload after a Client bundle was rebuilt asks for a stale artifact and fails
|
|
11
|
+
* the boot audit (the "应用无法启动" dialog). The shortcut therefore asks
|
|
12
|
+
* `GET /__dsh-feature-tweaks/reload-safe` first and gets `{ ok, revs, changed }`:
|
|
13
|
+
* `revs` is the live Client module graph, `changed` lists bundles rebuilt since
|
|
14
|
+
* this Host started. A differing revision is exactly what a reload would fail,
|
|
15
|
+
* so the Client half explains the restart instead of reloading blindly.
|
|
16
|
+
*
|
|
17
|
+
* Diagnostics: <DSH_HOME>/data/feature-tweaks-diag.log
|
|
8
18
|
*/
|
|
19
|
+
import fsp from 'node:fs/promises'
|
|
20
|
+
import os from 'node:os'
|
|
21
|
+
import path from 'node:path'
|
|
22
|
+
|
|
9
23
|
export const name = 'feature-tweaks'
|
|
10
24
|
|
|
11
|
-
/**
|
|
12
|
-
|
|
25
|
+
/** Route prefix claimed on the Web carrier. */
|
|
26
|
+
const ROUTE_PREFIX = '/__dsh-feature-tweaks'
|
|
27
|
+
/** Upper bound for one diagnostic body, in bytes. */
|
|
28
|
+
const MAX_BODY_BYTES = 64 * 1024
|
|
29
|
+
|
|
30
|
+
/** Absolute path of the Client-half diagnostics log. */
|
|
31
|
+
function diagFile() {
|
|
32
|
+
const home = process.env.DSH_HOME || path.join(os.homedir(), '.dsh')
|
|
33
|
+
return path.join(home, 'data', 'feature-tweaks-diag.log')
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Append one Client-half diagnostic line so a failed apply stays visible. */
|
|
37
|
+
async function appendDiag(message) {
|
|
38
|
+
try {
|
|
39
|
+
const line = `[${new Date().toISOString()}] ${String(message).slice(0, 4000)}\n`
|
|
40
|
+
await fsp.mkdir(path.dirname(diagFile()), { recursive: true })
|
|
41
|
+
await fsp.appendFile(diagFile(), line, 'utf8')
|
|
42
|
+
} catch {
|
|
43
|
+
// Diagnostics must never break the route.
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Answer one request with a JSON document. */
|
|
48
|
+
function sendJson(res, status, payload) {
|
|
49
|
+
const body = JSON.stringify(payload)
|
|
50
|
+
res.statusCode = status
|
|
51
|
+
res.setHeader('content-type', 'application/json; charset=utf-8')
|
|
52
|
+
res.setHeader('cache-control', 'no-store')
|
|
53
|
+
res.end(body)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Read a bounded request body as UTF-8 text. */
|
|
57
|
+
function readBody(req) {
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
const chunks = []
|
|
60
|
+
let size = 0
|
|
61
|
+
req.on('data', (chunk) => {
|
|
62
|
+
size += chunk.length
|
|
63
|
+
if (size > MAX_BODY_BYTES) {
|
|
64
|
+
reject(new Error('request body too large'))
|
|
65
|
+
req.destroy()
|
|
66
|
+
return
|
|
67
|
+
}
|
|
68
|
+
chunks.push(chunk)
|
|
69
|
+
})
|
|
70
|
+
req.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')))
|
|
71
|
+
req.on('error', reject)
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Host plugin entry.
|
|
77
|
+
* @param ctx - Host root context; the Web carrier and Client module graph are
|
|
78
|
+
* optional so a headless profile still mounts the row.
|
|
79
|
+
*/
|
|
80
|
+
export function apply(ctx) {
|
|
81
|
+
// Client bundles rebuilt since this Host started. The desktop shell keeps the
|
|
82
|
+
// boot manifest captured at startup, so a page reload after a rebuild asks
|
|
83
|
+
// for a stale artifact and fails the boot audit; the reload key asks this
|
|
84
|
+
// list first instead of reloading blindly.
|
|
85
|
+
const rebuiltClientIds = new Set()
|
|
86
|
+
try {
|
|
87
|
+
ctx.inject(['clientModules'], (scope) => {
|
|
88
|
+
scope.effect(() => {
|
|
89
|
+
const dispose = scope.clientModules.onRebuilt((id) => {
|
|
90
|
+
rebuiltClientIds.add(String(id))
|
|
91
|
+
})
|
|
92
|
+
return typeof dispose === 'function' ? dispose : () => {}
|
|
93
|
+
}, 'feature-tweaks: track client bundle rebuilds')
|
|
94
|
+
})
|
|
95
|
+
} catch (error) {
|
|
96
|
+
void appendDiag('rebuild-listener-failed: ' + String(error?.message ?? error))
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
try {
|
|
100
|
+
ctx.inject(['webServer'], (scope) => {
|
|
101
|
+
scope.effect(() => scope.webServer.register({
|
|
102
|
+
kind: 'prefix',
|
|
103
|
+
path: ROUTE_PREFIX,
|
|
104
|
+
handler: async (req, res) => {
|
|
105
|
+
const pathname = String(req.url ?? '').split('?')[0]
|
|
106
|
+
try {
|
|
107
|
+
if (pathname.endsWith('/reload-safe') && req.method === 'GET') {
|
|
108
|
+
const clientModules = ctx.get('clientModules')
|
|
109
|
+
const graph = clientModules !== undefined && typeof clientModules.graph === 'function'
|
|
110
|
+
? clientModules.graph()
|
|
111
|
+
: null
|
|
112
|
+
const revs = {}
|
|
113
|
+
if (graph !== null && Array.isArray(graph.entries)) {
|
|
114
|
+
for (const row of graph.entries) {
|
|
115
|
+
if (row !== null && typeof row === 'object' && typeof row.id === 'string') revs[row.id] = String(row.rev)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
sendJson(res, 200, { ok: true, revs, changed: [...rebuiltClientIds] })
|
|
119
|
+
return
|
|
120
|
+
}
|
|
121
|
+
if (pathname.endsWith('/diag') && req.method === 'POST') {
|
|
122
|
+
const body = await readBody(req)
|
|
123
|
+
let message = body.slice(0, 4000)
|
|
124
|
+
try {
|
|
125
|
+
const parsed = JSON.parse(body)
|
|
126
|
+
if (parsed !== null && typeof parsed === 'object' && typeof parsed.message === 'string') {
|
|
127
|
+
message = `${String(parsed.time ?? '')} ${parsed.message}`.trim()
|
|
128
|
+
}
|
|
129
|
+
} catch {
|
|
130
|
+
// A plain text body is still worth recording.
|
|
131
|
+
}
|
|
132
|
+
await appendDiag(message)
|
|
133
|
+
sendJson(res, 200, { ok: true })
|
|
134
|
+
return
|
|
135
|
+
}
|
|
136
|
+
sendJson(res, 404, { ok: false, error: 'unknown feature-tweaks route' })
|
|
137
|
+
} catch (error) {
|
|
138
|
+
sendJson(res, 500, { ok: false, error: String(error?.message ?? error) })
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
}), 'feature-tweaks: reload-safe route')
|
|
142
|
+
})
|
|
143
|
+
} catch (error) {
|
|
144
|
+
void appendDiag('route-failed: ' + String(error?.message ?? error))
|
|
145
|
+
}
|
|
146
|
+
}
|
package/locale/en.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "Feature tweaks",
|
|
4
|
-
"description": "Cross-version fixes for DSH behaviour and defaults, kept apart from dsh-ui-tweaks (which owns UI and DOM tweaks): the bundle overrides official rows by id in its own patch, never in core packages. Currently: new root sessions start with Agent Teams enabled."
|
|
4
|
+
"description": "Cross-version fixes for DSH behaviour and defaults, kept apart from dsh-ui-tweaks (which owns UI and DOM tweaks): the bundle overrides official rows by id in its own patch, never in core packages. Currently: new root sessions start with Agent Teams enabled; a configurable Reload page shortcut (F5 on desktop), moved here from dsh-sidebar-folders 0.13.4."
|
|
5
5
|
}
|
|
6
6
|
}
|
package/locale/zh.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "功能微调",
|
|
4
|
-
"description": "功能微调:DSH 跨版本的功能/默认值修补合集(与界面微调 dsh-ui-tweaks 分开)。官方版本变化带来的行为差异、默认值不合意的地方,都在这里按官方行 id
|
|
4
|
+
"description": "功能微调:DSH 跨版本的功能/默认值修补合集(与界面微调 dsh-ui-tweaks 分开)。官方版本变化带来的行为差异、默认值不合意的地方,都在这里按官方行 id 覆盖,不改核心包。当前含:新根会话默认开启「智能体团队协作」;「刷新页面」快捷键(桌面端 F5,从 dsh-sidebar-folders 0.13.4 迁移)。"
|
|
5
5
|
}
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leiyi-works/dsh-feature-tweaks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"title": "功能微调",
|
|
6
|
-
"description": "功能微调:DSH 跨版本的功能/默认值修补合集(与界面微调 dsh-ui-tweaks 分开)。官方版本变化带来的行为差异、默认值不合意的地方,都在这里按官方行 id
|
|
6
|
+
"description": "功能微调:DSH 跨版本的功能/默认值修补合集(与界面微调 dsh-ui-tweaks 分开)。官方版本变化带来的行为差异、默认值不合意的地方,都在这里按官方行 id 覆盖,不改核心包。当前含:新根会话默认开启「智能体团队协作」;「刷新页面」快捷键(桌面端 F5,从 dsh-sidebar-folders 0.13.4 迁移过来)。",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./index.js",
|
|
9
|
+
"./client": "./client.js",
|
|
9
10
|
"./locale/*.json": "./locale/*.json",
|
|
10
11
|
"./icon": "./icon.svg",
|
|
11
12
|
"./package.json": "./package.json"
|
|
12
13
|
},
|
|
13
14
|
"files": [
|
|
14
15
|
"index.js",
|
|
16
|
+
"client.js",
|
|
15
17
|
"cordis.patch.yml",
|
|
16
18
|
"README.md",
|
|
17
19
|
"locale/*.json",
|
|
@@ -20,6 +22,10 @@
|
|
|
20
22
|
"dsh": {
|
|
21
23
|
"bundle": {
|
|
22
24
|
"patch": "./cordis.patch.yml"
|
|
25
|
+
},
|
|
26
|
+
"client": {
|
|
27
|
+
"platform": "web",
|
|
28
|
+
"immediately": true
|
|
23
29
|
}
|
|
24
30
|
},
|
|
25
31
|
"license": "MIT",
|