dsh-kbar 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.
- package/CHANGELOG.md +17 -0
- package/LICENSE +21 -0
- package/README.md +27 -2
- package/client.js +657 -0
- package/cordis.patch.yml +4 -0
- package/docs/DETAIL.md +40 -0
- package/icon.svg +17 -0
- package/index.js +2 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +62 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# 更新记录
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
- 新增**模型搜索与切换**:列出当前会话可用的全部模型(按厂商分组),选中即切换,沿用模型默认推理强度;
|
|
6
|
+
- 新增**插件搜索**:从插件管理器读取已安装/可用的 bundle,选中打开对应的插件详情页;
|
|
7
|
+
- 会话列表为空时仍可用命令、模型、插件与内置动作。
|
|
8
|
+
|
|
9
|
+
## 0.1.0
|
|
10
|
+
|
|
11
|
+
- 首个版本:`Ctrl+Shift+P`(macOS `Cmd+Shift+P`)打开命令面板;
|
|
12
|
+
- 搜索并跳转会话(按标题、工作目录、最近更新排序);
|
|
13
|
+
- 搜索并执行 DSH 已注册的快捷键命令(新建会话、设置、侧栏、终端、文件等);
|
|
14
|
+
- 最近使用过的条目会排在前面(本机 localStorage 记忆);
|
|
15
|
+
- 中文输入法合成期间不误触发回车/Esc;
|
|
16
|
+
- 动作:新建会话、打开插件页;
|
|
17
|
+
- 键盘导航与焦点恢复,关闭后焦点回到原控件。
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 adengou
|
|
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,28 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-kbar
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A command palette for DeepSeek Harness. One shortcut to search sessions and run common actions.
|
|
4
|
+
|
|
5
|
+
- Default shortcut: `Ctrl+Shift+P` on Windows/Linux, `Cmd+Shift+P` on macOS.
|
|
6
|
+
- Searches sessions by title and working directory, runs any registered DSH shortcut command, switches the session model, and opens any installed bundle's detail page from the palette.
|
|
7
|
+
- `↑`/`↓` to select, `Enter` to run, `Esc` to close.
|
|
8
|
+
|
|
9
|
+
> `Ctrl+K` is already DSH's own session search, so KBar uses `Ctrl+Shift+P` to avoid a shortcut conflict. Rebind it in Settings → Shortcuts if you prefer.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
# npm
|
|
15
|
+
dsh plugin --profile web add dsh-kbar
|
|
16
|
+
|
|
17
|
+
# GitHub
|
|
18
|
+
dsh plugin --profile web add "git+https://github.com/adengou/dsh-kbar.git"
|
|
19
|
+
|
|
20
|
+
# Gitee mirror
|
|
21
|
+
dsh plugin --profile web add "git+https://gitee.com/adengou/dsh-kbar.git"
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
DSH Desktop manages its own profile in the app: install it from **Settings → Plugins**.
|
|
25
|
+
|
|
26
|
+
## License
|
|
27
|
+
|
|
28
|
+
MIT
|
package/client.js
ADDED
|
@@ -0,0 +1,657 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: 'dsh-kbar',
|
|
3
|
+
factory(require) {
|
|
4
|
+
const React = require('react')
|
|
5
|
+
const { useEffect, useRef, useSyncExternalStore } = React
|
|
6
|
+
const h = React.createElement
|
|
7
|
+
|
|
8
|
+
const ZH = typeof navigator !== 'undefined' && /^zh/i.test(navigator.language || '')
|
|
9
|
+
const TEXT = ZH
|
|
10
|
+
? {
|
|
11
|
+
title: 'KBar 命令面板',
|
|
12
|
+
openLabel: '打开命令面板',
|
|
13
|
+
placeholder: '搜索会话,或输入动作…',
|
|
14
|
+
empty: '没有匹配的结果',
|
|
15
|
+
actionGroup: '动作',
|
|
16
|
+
sessionTag: '会话',
|
|
17
|
+
actionTag: '动作',
|
|
18
|
+
commandTag: '命令',
|
|
19
|
+
newSession: '新建会话',
|
|
20
|
+
pluginsPage: '打开插件页',
|
|
21
|
+
hintNavigate: '↑↓ 选择',
|
|
22
|
+
hintRun: '↵ 执行',
|
|
23
|
+
hintClose: 'Esc 关闭',
|
|
24
|
+
results: '{n} 条结果',
|
|
25
|
+
}
|
|
26
|
+
: {
|
|
27
|
+
title: 'KBar command palette',
|
|
28
|
+
openLabel: 'Open the command palette',
|
|
29
|
+
placeholder: 'Search sessions or type an action…',
|
|
30
|
+
empty: 'No matching results',
|
|
31
|
+
actionGroup: 'Action',
|
|
32
|
+
sessionTag: 'session',
|
|
33
|
+
actionTag: 'action',
|
|
34
|
+
commandTag: 'command',
|
|
35
|
+
newSession: 'New session',
|
|
36
|
+
pluginsPage: 'Open the plugins page',
|
|
37
|
+
hintNavigate: '↑↓ select',
|
|
38
|
+
hintRun: '↵ run',
|
|
39
|
+
hintClose: 'Esc close',
|
|
40
|
+
results: '{n} results',
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const IS_MAC = (() => {
|
|
44
|
+
try {
|
|
45
|
+
const p = (navigator.platform || '') + ' ' + (navigator.userAgent || '')
|
|
46
|
+
return /Mac|iPhone|iPad/i.test(p)
|
|
47
|
+
} catch {
|
|
48
|
+
return false
|
|
49
|
+
}
|
|
50
|
+
})()
|
|
51
|
+
const PRIMARY = IS_MAC ? '⌘' : 'Ctrl'
|
|
52
|
+
const OPEN_LABEL = PRIMARY + '+⇧+P'
|
|
53
|
+
|
|
54
|
+
function score(query, item) {
|
|
55
|
+
const title = String(item.title || '').toLowerCase()
|
|
56
|
+
const extra = String(item.secondary || '').toLowerCase() + ' ' + String(item.keywords || '').toLowerCase()
|
|
57
|
+
if (title.startsWith(query)) return 120
|
|
58
|
+
if (title.includes(query)) return 100 - Math.min(20, title.indexOf(query))
|
|
59
|
+
if (extra.includes(query)) return 70 - Math.min(20, extra.indexOf(query))
|
|
60
|
+
let i = 0
|
|
61
|
+
let last = -1
|
|
62
|
+
let gaps = 0
|
|
63
|
+
for (let j = 0; j < title.length && i < query.length; j++) {
|
|
64
|
+
if (title[j] === query[i]) {
|
|
65
|
+
if (last >= 0) gaps += j - last - 1
|
|
66
|
+
last = j
|
|
67
|
+
i++
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (i < query.length) return 0
|
|
71
|
+
return 50 - Math.min(40, gaps)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function createStore(ctx) {
|
|
75
|
+
let state = { open: false, query: '', index: 0, rows: [] }
|
|
76
|
+
let models = []
|
|
77
|
+
let plugins = null
|
|
78
|
+
let loading = false
|
|
79
|
+
const listeners = new Set()
|
|
80
|
+
let lastFocus = null
|
|
81
|
+
let closing = false
|
|
82
|
+
|
|
83
|
+
const emit = () => {
|
|
84
|
+
for (const listener of listeners) listener()
|
|
85
|
+
}
|
|
86
|
+
const snapshot = () => state
|
|
87
|
+
const subscribe = (listener) => {
|
|
88
|
+
listeners.add(listener)
|
|
89
|
+
return () => listeners.delete(listener)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function sessionItems() {
|
|
93
|
+
let snap
|
|
94
|
+
try {
|
|
95
|
+
snap = ctx.sessions.list.getSnapshot()
|
|
96
|
+
} catch {
|
|
97
|
+
return []
|
|
98
|
+
}
|
|
99
|
+
const byId = snap && snap.byId ? snap.byId : {}
|
|
100
|
+
const items = []
|
|
101
|
+
for (const id of Object.keys(byId)) {
|
|
102
|
+
const row = byId[id]
|
|
103
|
+
if (!row || row.blank) continue
|
|
104
|
+
items.push({
|
|
105
|
+
kind: 'session',
|
|
106
|
+
id,
|
|
107
|
+
title: String(row.title || '').trim() || id.slice(0, 8),
|
|
108
|
+
secondary: String(row.cwd || ''),
|
|
109
|
+
keywords: '',
|
|
110
|
+
updatedAt: Number(row.updatedAt) || 0,
|
|
111
|
+
run: () => ctx.uiWorkspace.openSession(id),
|
|
112
|
+
})
|
|
113
|
+
}
|
|
114
|
+
items.sort((a, b) => b.updatedAt - a.updatedAt)
|
|
115
|
+
return items
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function actionItems() {
|
|
119
|
+
return [
|
|
120
|
+
{
|
|
121
|
+
kind: 'action',
|
|
122
|
+
id: 'action:new-session',
|
|
123
|
+
title: TEXT.newSession,
|
|
124
|
+
secondary: TEXT.actionGroup,
|
|
125
|
+
keywords: 'new session new chat 新建 新会话 聊天',
|
|
126
|
+
updatedAt: 0,
|
|
127
|
+
run: () => ctx.uiWorkspace.startSession(),
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
kind: 'action',
|
|
131
|
+
id: 'action:plugins',
|
|
132
|
+
title: TEXT.pluginsPage,
|
|
133
|
+
secondary: TEXT.actionGroup,
|
|
134
|
+
keywords: 'plugins plugin manager 插件 管理 市场',
|
|
135
|
+
updatedAt: 0,
|
|
136
|
+
run: () => ctx.layout.selectPanel('plugins'),
|
|
137
|
+
},
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function commandItems() {
|
|
142
|
+
let rows
|
|
143
|
+
try {
|
|
144
|
+
rows = ctx.shortcuts.catalog.getSnapshot()
|
|
145
|
+
} catch {
|
|
146
|
+
return []
|
|
147
|
+
}
|
|
148
|
+
const focus = lastFocus
|
|
149
|
+
const items = []
|
|
150
|
+
for (const row of rows || []) {
|
|
151
|
+
if (!row || !row.id || row.id === 'kbar.open') continue
|
|
152
|
+
const keys = Array.isArray(row.keys) ? row.keys.join('') : ''
|
|
153
|
+
items.push({
|
|
154
|
+
kind: 'command',
|
|
155
|
+
id: 'cmd:' + row.id,
|
|
156
|
+
commandId: row.id,
|
|
157
|
+
title: String(row.label || '').trim() || row.id,
|
|
158
|
+
secondary: keys,
|
|
159
|
+
keywords: Array.isArray(row.aliases) ? row.aliases.join(' ') : '',
|
|
160
|
+
updatedAt: 0,
|
|
161
|
+
run: () => ctx.shortcuts.invoke(row.id, { modal: null, target: focus }),
|
|
162
|
+
})
|
|
163
|
+
}
|
|
164
|
+
return items
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const RECENT_KEY = 'dsh-kbar.recent.v1'
|
|
168
|
+
|
|
169
|
+
function readRecent() {
|
|
170
|
+
try {
|
|
171
|
+
const raw = localStorage.getItem(RECENT_KEY)
|
|
172
|
+
const list = raw ? JSON.parse(raw) : []
|
|
173
|
+
return Array.isArray(list) ? list.filter((value) => typeof value === 'string').slice(0, 20) : []
|
|
174
|
+
} catch {
|
|
175
|
+
return []
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function remember(id) {
|
|
180
|
+
try {
|
|
181
|
+
const list = readRecent().filter((value) => value !== id)
|
|
182
|
+
list.unshift(id)
|
|
183
|
+
localStorage.setItem(RECENT_KEY, JSON.stringify(list.slice(0, 20)))
|
|
184
|
+
} catch {
|
|
185
|
+
/* storage unavailable */
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function currentSession() {
|
|
190
|
+
try {
|
|
191
|
+
const rows = Object.values(ctx.sessions.list.getSnapshot().byId || {})
|
|
192
|
+
return rows.find((row) => row && row.retainedBy && (row.retainedBy.mainView || 0) > 0) || null
|
|
193
|
+
} catch {
|
|
194
|
+
return null
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
async function loadModels() {
|
|
199
|
+
const row = currentSession()
|
|
200
|
+
const directories = ctx.get ? ctx.get('modelDirectories') : undefined
|
|
201
|
+
if (!row || !directories) return
|
|
202
|
+
try {
|
|
203
|
+
const directory = directories.directoryFor(row.id)
|
|
204
|
+
await directory.load()
|
|
205
|
+
const snapshot = directory.store.getSnapshot()
|
|
206
|
+
const items = []
|
|
207
|
+
for (const group of snapshot.groups || []) {
|
|
208
|
+
for (const model of group.models || []) {
|
|
209
|
+
const effort = model.reasoning && model.reasoning.defaultEffort
|
|
210
|
+
items.push({
|
|
211
|
+
kind: 'model',
|
|
212
|
+
id: 'model:' + group.id + ':' + model.id,
|
|
213
|
+
title: String(model.name || model.label || model.id),
|
|
214
|
+
secondary: String(group.name || group.id),
|
|
215
|
+
keywords: String(group.id) + ' ' + String(model.id) + ' 模型 model',
|
|
216
|
+
updatedAt: 0,
|
|
217
|
+
run: () => {
|
|
218
|
+
const selection = { provider: group.id, model: model.id }
|
|
219
|
+
if (effort !== undefined) selection.reasoningEffort = effort
|
|
220
|
+
return directory.select(selection)
|
|
221
|
+
},
|
|
222
|
+
})
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
models = items
|
|
226
|
+
if (state.open) refreshRows()
|
|
227
|
+
} catch {
|
|
228
|
+
/* models unavailable for this session */
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
async function loadPlugins() {
|
|
233
|
+
if (plugins !== null || loading) return
|
|
234
|
+
loading = true
|
|
235
|
+
try {
|
|
236
|
+
const result = await ctx.remote.pluginManager.listBundles()
|
|
237
|
+
if (result && result.ok && Array.isArray(result.value)) {
|
|
238
|
+
plugins = result.value
|
|
239
|
+
.filter((bundle) => bundle && bundle.name)
|
|
240
|
+
.map((bundle) => ({
|
|
241
|
+
kind: 'plugin',
|
|
242
|
+
id: 'plugin:' + bundle.name,
|
|
243
|
+
title: String(bundle.displayName || bundle.name),
|
|
244
|
+
secondary: bundle.version ? 'v' + bundle.version : '',
|
|
245
|
+
keywords: String(bundle.name) + ' ' + String(bundle.description || '') + ' 插件 plugin',
|
|
246
|
+
updatedAt: 0,
|
|
247
|
+
run: () => ctx.pluginNavigation.openBundle(bundle.name),
|
|
248
|
+
}))
|
|
249
|
+
}
|
|
250
|
+
} catch {
|
|
251
|
+
/* plugin manager unavailable */
|
|
252
|
+
} finally {
|
|
253
|
+
loading = false
|
|
254
|
+
}
|
|
255
|
+
if (state.open) refreshRows()
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function compute() {
|
|
259
|
+
const query = state.query.trim().toLowerCase()
|
|
260
|
+
const actions = actionItems()
|
|
261
|
+
const commands = commandItems()
|
|
262
|
+
const sessions = sessionItems()
|
|
263
|
+
const recent = readRecent()
|
|
264
|
+
const boost = (item) => (recent.includes(item.id) ? 15 : 0)
|
|
265
|
+
if (!query) {
|
|
266
|
+
return actions
|
|
267
|
+
.concat(models.slice(0, 6))
|
|
268
|
+
.concat(commands.slice(0, 8))
|
|
269
|
+
.concat(sessions.slice(0, 8))
|
|
270
|
+
.concat((plugins || []).slice(0, 8))
|
|
271
|
+
}
|
|
272
|
+
const scored = []
|
|
273
|
+
for (const item of actions.concat(models, commands, sessions, plugins || [])) {
|
|
274
|
+
const value = score(query, item)
|
|
275
|
+
if (value > 0) scored.push({ item, value: value + boost(item) })
|
|
276
|
+
}
|
|
277
|
+
scored.sort((a, b) => b.value - a.value || b.item.updatedAt - a.item.updatedAt)
|
|
278
|
+
return scored.slice(0, 50).map((entry) => entry.item)
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function set(patch) {
|
|
282
|
+
state = Object.assign({}, state, patch)
|
|
283
|
+
emit()
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function refreshRows() {
|
|
287
|
+
if (!state.open) return
|
|
288
|
+
const rows = compute()
|
|
289
|
+
set({ rows, index: Math.min(state.index, Math.max(0, rows.length - 1)) })
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
return {
|
|
293
|
+
subscribe,
|
|
294
|
+
getSnapshot: snapshot,
|
|
295
|
+
open() {
|
|
296
|
+
if (state.open) return
|
|
297
|
+
try {
|
|
298
|
+
lastFocus = document.activeElement
|
|
299
|
+
} catch {
|
|
300
|
+
lastFocus = null
|
|
301
|
+
}
|
|
302
|
+
set({ open: true, query: '', index: 0, rows: compute() })
|
|
303
|
+
loadModels()
|
|
304
|
+
loadPlugins()
|
|
305
|
+
},
|
|
306
|
+
close() {
|
|
307
|
+
if (!state.open || closing) return
|
|
308
|
+
closing = true
|
|
309
|
+
set({ open: false, query: '', index: 0, rows: [] })
|
|
310
|
+
closing = false
|
|
311
|
+
if (lastFocus && typeof lastFocus.focus === 'function') {
|
|
312
|
+
try {
|
|
313
|
+
lastFocus.focus()
|
|
314
|
+
} catch {
|
|
315
|
+
/* ignore */
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
lastFocus = null
|
|
319
|
+
},
|
|
320
|
+
toggle() {
|
|
321
|
+
if (state.open) this.close()
|
|
322
|
+
else this.open()
|
|
323
|
+
},
|
|
324
|
+
setQuery(value) {
|
|
325
|
+
state = Object.assign({}, state, { query: value })
|
|
326
|
+
const rows = compute()
|
|
327
|
+
state = Object.assign({}, state, { rows, index: 0 })
|
|
328
|
+
emit()
|
|
329
|
+
},
|
|
330
|
+
setIndex(index) {
|
|
331
|
+
const max = state.rows.length - 1
|
|
332
|
+
const next = Math.max(0, Math.min(max, index))
|
|
333
|
+
if (next !== state.index) set({ index: next })
|
|
334
|
+
},
|
|
335
|
+
move(delta) {
|
|
336
|
+
if (!state.rows.length) return
|
|
337
|
+
const next = (state.index + delta + state.rows.length) % state.rows.length
|
|
338
|
+
set({ index: next })
|
|
339
|
+
},
|
|
340
|
+
run(index) {
|
|
341
|
+
const item = state.rows[index]
|
|
342
|
+
if (!item) return
|
|
343
|
+
remember(item.id)
|
|
344
|
+
this.close()
|
|
345
|
+
const run = item.run
|
|
346
|
+
setTimeout(() => {
|
|
347
|
+
try {
|
|
348
|
+
const result = run()
|
|
349
|
+
if (result && typeof result.then === 'function') {
|
|
350
|
+
result.catch((error) => console.error('[kbar] action failed', error))
|
|
351
|
+
}
|
|
352
|
+
} catch (error) {
|
|
353
|
+
console.error('[kbar] action failed', error)
|
|
354
|
+
}
|
|
355
|
+
}, 0)
|
|
356
|
+
},
|
|
357
|
+
refresh() {
|
|
358
|
+
refreshRows()
|
|
359
|
+
},
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
const styles = {
|
|
364
|
+
backdrop: {
|
|
365
|
+
position: 'fixed',
|
|
366
|
+
inset: 0,
|
|
367
|
+
zIndex: 2147483000,
|
|
368
|
+
display: 'flex',
|
|
369
|
+
alignItems: 'flex-start',
|
|
370
|
+
justifyContent: 'center',
|
|
371
|
+
paddingTop: '12vh',
|
|
372
|
+
background: 'var(--dsw-alias-bg-mask-2, rgba(0, 0, 0, 0.35))',
|
|
373
|
+
backdropFilter: 'blur(2px)',
|
|
374
|
+
},
|
|
375
|
+
panel: {
|
|
376
|
+
width: 'min(680px, 92vw)',
|
|
377
|
+
maxHeight: '62vh',
|
|
378
|
+
display: 'flex',
|
|
379
|
+
flexDirection: 'column',
|
|
380
|
+
overflow: 'hidden',
|
|
381
|
+
borderRadius: 14,
|
|
382
|
+
border: '1px solid var(--dsw-alias-border-l2, rgba(127, 127, 127, 0.22))',
|
|
383
|
+
background: 'var(--dsw-alias-bg-layer-3, var(--dsw-alias-bg-base, #ffffff))',
|
|
384
|
+
color: 'var(--dsw-alias-label-primary, inherit)',
|
|
385
|
+
boxShadow: '0 24px 64px rgba(0, 0, 0, 0.28)',
|
|
386
|
+
fontFamily: 'inherit',
|
|
387
|
+
},
|
|
388
|
+
header: {
|
|
389
|
+
display: 'flex',
|
|
390
|
+
alignItems: 'center',
|
|
391
|
+
gap: 10,
|
|
392
|
+
padding: '12px 14px',
|
|
393
|
+
borderBottom: '1px solid var(--dsw-alias-border-l1, rgba(127, 127, 127, 0.16))',
|
|
394
|
+
},
|
|
395
|
+
input: {
|
|
396
|
+
flex: 1,
|
|
397
|
+
minWidth: 0,
|
|
398
|
+
border: 'none',
|
|
399
|
+
outline: 'none',
|
|
400
|
+
background: 'transparent',
|
|
401
|
+
color: 'inherit',
|
|
402
|
+
fontSize: 16,
|
|
403
|
+
lineHeight: '24px',
|
|
404
|
+
},
|
|
405
|
+
kbd: {
|
|
406
|
+
flex: 'none',
|
|
407
|
+
fontSize: 11,
|
|
408
|
+
padding: '2px 6px',
|
|
409
|
+
borderRadius: 6,
|
|
410
|
+
border: '1px solid var(--dsw-alias-border-l2, rgba(127, 127, 127, 0.3))',
|
|
411
|
+
color: 'var(--dsw-alias-label-secondary, #808080)',
|
|
412
|
+
},
|
|
413
|
+
list: {
|
|
414
|
+
overflowY: 'auto',
|
|
415
|
+
padding: 6,
|
|
416
|
+
},
|
|
417
|
+
row: (selected) => ({
|
|
418
|
+
display: 'flex',
|
|
419
|
+
alignItems: 'center',
|
|
420
|
+
gap: 12,
|
|
421
|
+
padding: '8px 10px',
|
|
422
|
+
borderRadius: 8,
|
|
423
|
+
cursor: 'pointer',
|
|
424
|
+
background: selected
|
|
425
|
+
? 'var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.14))'
|
|
426
|
+
: 'transparent',
|
|
427
|
+
}),
|
|
428
|
+
rowMain: {
|
|
429
|
+
flex: 1,
|
|
430
|
+
minWidth: 0,
|
|
431
|
+
},
|
|
432
|
+
rowTitle: {
|
|
433
|
+
fontSize: 14,
|
|
434
|
+
lineHeight: '20px',
|
|
435
|
+
overflow: 'hidden',
|
|
436
|
+
textOverflow: 'ellipsis',
|
|
437
|
+
whiteSpace: 'nowrap',
|
|
438
|
+
},
|
|
439
|
+
rowSecondary: {
|
|
440
|
+
fontSize: 12,
|
|
441
|
+
lineHeight: '16px',
|
|
442
|
+
marginTop: 2,
|
|
443
|
+
color: 'var(--dsw-alias-label-secondary, #808080)',
|
|
444
|
+
overflow: 'hidden',
|
|
445
|
+
textOverflow: 'ellipsis',
|
|
446
|
+
whiteSpace: 'nowrap',
|
|
447
|
+
},
|
|
448
|
+
badge: {
|
|
449
|
+
flex: 'none',
|
|
450
|
+
fontSize: 11,
|
|
451
|
+
color: 'var(--dsw-alias-label-secondary, #808080)',
|
|
452
|
+
},
|
|
453
|
+
empty: {
|
|
454
|
+
padding: '22px 12px',
|
|
455
|
+
textAlign: 'center',
|
|
456
|
+
fontSize: 13,
|
|
457
|
+
color: 'var(--dsw-alias-label-secondary, #808080)',
|
|
458
|
+
},
|
|
459
|
+
footer: {
|
|
460
|
+
display: 'flex',
|
|
461
|
+
alignItems: 'center',
|
|
462
|
+
gap: 14,
|
|
463
|
+
padding: '8px 14px',
|
|
464
|
+
fontSize: 11,
|
|
465
|
+
color: 'var(--dsw-alias-label-secondary, #808080)',
|
|
466
|
+
borderTop: '1px solid var(--dsw-alias-border-l1, rgba(127, 127, 127, 0.16))',
|
|
467
|
+
},
|
|
468
|
+
count: {
|
|
469
|
+
marginLeft: 'auto',
|
|
470
|
+
},
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
function Glyph() {
|
|
474
|
+
return h(
|
|
475
|
+
'svg',
|
|
476
|
+
{ width: 16, height: 16, viewBox: '0 0 16 16', fill: 'none', 'aria-hidden': true },
|
|
477
|
+
h('circle', { cx: 7, cy: 7, r: 4.6, stroke: 'currentColor', strokeWidth: 1.5 }),
|
|
478
|
+
h('path', { d: 'M10.4 10.4 14 14', stroke: 'currentColor', strokeWidth: 1.5, strokeLinecap: 'round' }),
|
|
479
|
+
)
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
function KBar(props) {
|
|
483
|
+
const store = props.kbar
|
|
484
|
+
const state = useSyncExternalStore(store.subscribe, store.getSnapshot)
|
|
485
|
+
const inputRef = useRef(null)
|
|
486
|
+
const listRef = useRef(null)
|
|
487
|
+
|
|
488
|
+
useEffect(() => {
|
|
489
|
+
if (!state.open) return undefined
|
|
490
|
+
const timer = setTimeout(() => {
|
|
491
|
+
const input = inputRef.current
|
|
492
|
+
if (input) {
|
|
493
|
+
input.focus()
|
|
494
|
+
input.select()
|
|
495
|
+
}
|
|
496
|
+
}, 0)
|
|
497
|
+
return () => clearTimeout(timer)
|
|
498
|
+
}, [state.open])
|
|
499
|
+
|
|
500
|
+
useEffect(() => {
|
|
501
|
+
if (!state.open) return undefined
|
|
502
|
+
const onKeyDown = (event) => {
|
|
503
|
+
if (event.isComposing) return
|
|
504
|
+
if (event.key !== 'Escape') return
|
|
505
|
+
event.preventDefault()
|
|
506
|
+
event.stopPropagation()
|
|
507
|
+
store.close()
|
|
508
|
+
}
|
|
509
|
+
window.addEventListener('keydown', onKeyDown, true)
|
|
510
|
+
return () => window.removeEventListener('keydown', onKeyDown, true)
|
|
511
|
+
}, [state.open, store])
|
|
512
|
+
|
|
513
|
+
useEffect(() => {
|
|
514
|
+
if (!state.open) return
|
|
515
|
+
const list = listRef.current
|
|
516
|
+
if (!list) return
|
|
517
|
+
const row = list.querySelector('[data-index="' + state.index + '"]')
|
|
518
|
+
if (row && typeof row.scrollIntoView === 'function') row.scrollIntoView({ block: 'nearest' })
|
|
519
|
+
}, [state.index, state.open, state.rows])
|
|
520
|
+
|
|
521
|
+
if (!state.open) return null
|
|
522
|
+
const rows = state.rows
|
|
523
|
+
const results = TEXT.results.replace('{n}', String(rows.length))
|
|
524
|
+
|
|
525
|
+
return h(
|
|
526
|
+
'div',
|
|
527
|
+
{
|
|
528
|
+
style: styles.backdrop,
|
|
529
|
+
onMouseDown: (event) => {
|
|
530
|
+
if (event.target === event.currentTarget) store.close()
|
|
531
|
+
},
|
|
532
|
+
},
|
|
533
|
+
h(
|
|
534
|
+
'div',
|
|
535
|
+
{ style: styles.panel, role: 'dialog', 'aria-modal': 'true', 'aria-label': TEXT.title },
|
|
536
|
+
h(
|
|
537
|
+
'div',
|
|
538
|
+
{ style: styles.header },
|
|
539
|
+
h('span', { style: { display: 'flex', color: 'var(--dsw-alias-label-secondary, #808080)' } }, h(Glyph)),
|
|
540
|
+
h('input', {
|
|
541
|
+
ref: inputRef,
|
|
542
|
+
value: state.query,
|
|
543
|
+
placeholder: TEXT.placeholder,
|
|
544
|
+
'aria-label': TEXT.placeholder,
|
|
545
|
+
style: styles.input,
|
|
546
|
+
spellCheck: false,
|
|
547
|
+
onChange: (event) => store.setQuery(event.target.value),
|
|
548
|
+
onKeyDown: (event) => {
|
|
549
|
+
if (event.isComposing || event.keyCode === 229) return
|
|
550
|
+
if (event.key === 'ArrowDown') {
|
|
551
|
+
event.preventDefault()
|
|
552
|
+
store.move(1)
|
|
553
|
+
} else if (event.key === 'ArrowUp') {
|
|
554
|
+
event.preventDefault()
|
|
555
|
+
store.move(-1)
|
|
556
|
+
} else if (event.key === 'Enter') {
|
|
557
|
+
event.preventDefault()
|
|
558
|
+
store.run(state.index)
|
|
559
|
+
} else if (event.key === 'Tab') {
|
|
560
|
+
event.preventDefault()
|
|
561
|
+
}
|
|
562
|
+
},
|
|
563
|
+
}),
|
|
564
|
+
h('kbd', { style: styles.kbd }, OPEN_LABEL),
|
|
565
|
+
),
|
|
566
|
+
h(
|
|
567
|
+
'div',
|
|
568
|
+
{ ref: listRef, style: styles.list, role: 'listbox' },
|
|
569
|
+
rows.length === 0
|
|
570
|
+
? h('div', { style: styles.empty }, TEXT.empty)
|
|
571
|
+
: rows.map((item, index) =>
|
|
572
|
+
h(
|
|
573
|
+
'div',
|
|
574
|
+
{
|
|
575
|
+
key: item.id,
|
|
576
|
+
'data-index': index,
|
|
577
|
+
role: 'option',
|
|
578
|
+
'aria-selected': index === state.index,
|
|
579
|
+
style: styles.row(index === state.index),
|
|
580
|
+
onMouseEnter: () => store.setIndex(index),
|
|
581
|
+
onMouseDown: (event) => {
|
|
582
|
+
event.preventDefault()
|
|
583
|
+
store.run(index)
|
|
584
|
+
},
|
|
585
|
+
},
|
|
586
|
+
h(
|
|
587
|
+
'div',
|
|
588
|
+
{ style: styles.rowMain },
|
|
589
|
+
h('div', { style: styles.rowTitle }, item.title),
|
|
590
|
+
item.secondary ? h('div', { style: styles.rowSecondary }, item.secondary) : null,
|
|
591
|
+
),
|
|
592
|
+
h('span', { style: styles.badge }, item.kind === 'session' ? TEXT.sessionTag : item.kind === 'command' ? TEXT.commandTag : TEXT.actionTag),
|
|
593
|
+
),
|
|
594
|
+
),
|
|
595
|
+
),
|
|
596
|
+
h(
|
|
597
|
+
'div',
|
|
598
|
+
{ style: styles.footer },
|
|
599
|
+
h('span', null, TEXT.hintNavigate),
|
|
600
|
+
h('span', null, TEXT.hintRun),
|
|
601
|
+
h('span', null, TEXT.hintClose),
|
|
602
|
+
h('span', { style: styles.count }, results),
|
|
603
|
+
),
|
|
604
|
+
),
|
|
605
|
+
)
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
return {
|
|
609
|
+
inject: ['slots', 'shortcuts', 'sessions', 'uiWorkspace', 'layout'],
|
|
610
|
+
apply(ctx) {
|
|
611
|
+
const store = createStore(ctx)
|
|
612
|
+
|
|
613
|
+
ctx.effect(() => {
|
|
614
|
+
const off = ctx.sessions.list.subscribe(() => store.refresh())
|
|
615
|
+
return () => {
|
|
616
|
+
if (typeof off === 'function') off()
|
|
617
|
+
}
|
|
618
|
+
}, 'kbar: session catalog')
|
|
619
|
+
|
|
620
|
+
ctx.effect(() => {
|
|
621
|
+
const off = ctx.shortcuts.catalog.subscribe(() => store.refresh())
|
|
622
|
+
return () => {
|
|
623
|
+
if (typeof off === 'function') off()
|
|
624
|
+
}
|
|
625
|
+
}, 'kbar: shortcut catalog')
|
|
626
|
+
|
|
627
|
+
ctx.effect(
|
|
628
|
+
() =>
|
|
629
|
+
ctx.shortcuts.register({
|
|
630
|
+
id: 'kbar.open',
|
|
631
|
+
label: () => TEXT.openLabel,
|
|
632
|
+
aliases: ['command palette', 'quick open', 'kbar', '命令面板', '快速打开', '搜索会话'],
|
|
633
|
+
defaults: {
|
|
634
|
+
'desktop:macos': { code: 'KeyP', modifiers: ['primary', 'shift'] },
|
|
635
|
+
'desktop:windows': { code: 'KeyP', modifiers: ['primary', 'shift'] },
|
|
636
|
+
'desktop:linux': { code: 'KeyP', modifiers: ['primary', 'shift'] },
|
|
637
|
+
'web:macos': { code: 'KeyP', modifiers: ['primary', 'shift'] },
|
|
638
|
+
'web:windows': { code: 'KeyP', modifiers: ['primary', 'shift'] },
|
|
639
|
+
'web:linux': { code: 'KeyP', modifiers: ['primary', 'shift'] },
|
|
640
|
+
},
|
|
641
|
+
regions: ['page', 'editable'],
|
|
642
|
+
modals: [],
|
|
643
|
+
resolve: () => ({ status: 'handled', run: () => store.toggle() }),
|
|
644
|
+
}),
|
|
645
|
+
'kbar: shortcut',
|
|
646
|
+
)
|
|
647
|
+
|
|
648
|
+
ctx.slots.inject('shell.overlay', () =>
|
|
649
|
+
ctx.slots.register(
|
|
650
|
+
{ name: 'shell.overlay', id: 'kbar', inject: () => ({ kbar: store }) },
|
|
651
|
+
KBar,
|
|
652
|
+
),
|
|
653
|
+
)
|
|
654
|
+
},
|
|
655
|
+
}
|
|
656
|
+
},
|
|
657
|
+
})
|
package/cordis.patch.yml
ADDED
package/docs/DETAIL.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# KBar 命令面板
|
|
2
|
+
|
|
3
|
+
KBar 在 DSH 界面之上加一个命令面板:按一次快捷键,输入几个字,就能跳到任意会话,或执行常用动作。
|
|
4
|
+
|
|
5
|
+
## 使用
|
|
6
|
+
|
|
7
|
+
- 默认快捷键:**Windows/Linux `Ctrl+Shift+P`**,**macOS `Cmd+Shift+P`**。
|
|
8
|
+
- 输入即过滤:会话按标题和工作目录匹配,动作按名称匹配;支持连续字符(如输入 `xs` 可命中「新建会话」的拼音首字母组合不保证,但英文分词可用)。
|
|
9
|
+
- `↑` / `↓` 选择,`Enter` 执行,`Esc` 关闭;点击空白处也会关闭。
|
|
10
|
+
- 打开时输入框自动聚焦,关闭后焦点回到原来的控件。
|
|
11
|
+
|
|
12
|
+
## 能做什么
|
|
13
|
+
|
|
14
|
+
| 类型 | 内容 |
|
|
15
|
+
| --- | --- |
|
|
16
|
+
| 会话 | 当前会话目录里列出的所有会话(标题、工作目录),按最近更新排序,选中即切换 |
|
|
17
|
+
| 命令 | DSH 里所有已注册的快捷键命令(新建会话、设置、侧栏、终端、文件等),选中即执行 |
|
|
18
|
+
| 模型 | 当前会话可用的模型(按厂商分组),选中即切换,并沿用该模型的默认推理强度 |
|
|
19
|
+
| 插件 | 插件管理器里的 bundle(名称、版本),选中打开对应的插件详情页 |
|
|
20
|
+
| 动作 | 新建会话;打开插件页 |
|
|
21
|
+
|
|
22
|
+
## 为什么不占 Ctrl+K
|
|
23
|
+
|
|
24
|
+
`Ctrl+K` 在 DSH 里已经是官方的「搜索会话」快捷键(`session.search`)。两个功能同时抢一个组合键会导致插件注册冲突,所以 KBar 默认用 `Ctrl+Shift+P`。
|
|
25
|
+
|
|
26
|
+
你可以在 **设置 → 快捷键** 里把 KBar 改到自己喜欢的组合;如果改成 `Ctrl+K`,会与官方会话搜索冲突,请先把官方那个改走。
|
|
27
|
+
|
|
28
|
+
## 已知限制
|
|
29
|
+
|
|
30
|
+
- 命令来自 DSH 的快捷键注册表,只包含带快捷键定义的应用命令;斜杠命令与技能尚未进入搜索范围(后续版本计划)。
|
|
31
|
+
- 模型列表只在存在当前会话时加载;没有会话时该分组为空。
|
|
32
|
+
- 插件列表来自插件管理器的 bundle 列表,选中后打开插件详情页,不在面板内直接启停。
|
|
33
|
+
- 部分命令依赖当前焦点所在的控件,通过面板执行时可能提示“不可用”(例如需要选中某个侧栏标签的命令)。
|
|
34
|
+
- 会话列表来自客户端已加载的目录快照;尚未被加载的历史会话不会出现。
|
|
35
|
+
- 面板是覆盖层,关闭后不会改变当前页面;执行动作会先关闭面板再执行。
|
|
36
|
+
- 不联网、不收集数据。
|
|
37
|
+
|
|
38
|
+
## 配置
|
|
39
|
+
|
|
40
|
+
当前版本没有可配置项。快捷键沿用 DSH 的快捷键服务,改键后保存在本机。
|
package/icon.svg
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256" viewBox="0 0 256 256" role="img" aria-label="KBar">
|
|
2
|
+
<defs>
|
|
3
|
+
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
|
|
4
|
+
<stop offset="0" stop-color="#1b2a4a"/>
|
|
5
|
+
<stop offset="1" stop-color="#0b1220"/>
|
|
6
|
+
</linearGradient>
|
|
7
|
+
<linearGradient id="lens" x1="0" y1="0" x2="1" y2="1">
|
|
8
|
+
<stop offset="0" stop-color="#4cc9f0"/>
|
|
9
|
+
<stop offset="1" stop-color="#4361ee"/>
|
|
10
|
+
</linearGradient>
|
|
11
|
+
</defs>
|
|
12
|
+
<rect width="256" height="256" rx="56" fill="url(#bg)"/>
|
|
13
|
+
<circle cx="112" cy="112" r="52" fill="none" stroke="url(#lens)" stroke-width="14"/>
|
|
14
|
+
<path d="M152 152 196 196" stroke="url(#lens)" stroke-width="16" stroke-linecap="round"/>
|
|
15
|
+
<path d="M96 92v40M96 112l26-20M96 112l26 20" stroke="#e8f1ff" stroke-width="12" stroke-linecap="round" stroke-linejoin="round" fill="none"/>
|
|
16
|
+
<rect x="64" y="176" width="128" height="16" rx="8" fill="#2a3f66"/>
|
|
17
|
+
</svg>
|
package/index.js
ADDED
package/locale/en.json
ADDED
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,64 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-kbar",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "KBar: a command palette for DeepSeek Harness — one shortcut to search sessions and run common actions.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./index.js",
|
|
9
|
+
"./client": "./client.js",
|
|
10
|
+
"./locale/*.json": "./locale/*.json",
|
|
11
|
+
"./icon": "./icon.svg"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"index.js",
|
|
15
|
+
"client.js",
|
|
16
|
+
"cordis.patch.yml",
|
|
17
|
+
"locale/*.json",
|
|
18
|
+
"docs",
|
|
19
|
+
"icon.svg",
|
|
20
|
+
"README.md",
|
|
21
|
+
"CHANGELOG.md",
|
|
22
|
+
"LICENSE"
|
|
23
|
+
],
|
|
24
|
+
"keywords": [
|
|
25
|
+
"dsh",
|
|
26
|
+
"dsh-plugin",
|
|
27
|
+
"deepseek-harness",
|
|
28
|
+
"command-palette",
|
|
29
|
+
"quick-open",
|
|
30
|
+
"search"
|
|
31
|
+
],
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=20.12",
|
|
35
|
+
"dsh": ">=0.2.1"
|
|
36
|
+
},
|
|
37
|
+
"dsh": {
|
|
38
|
+
"bundle": {
|
|
39
|
+
"patch": "./cordis.patch.yml"
|
|
40
|
+
},
|
|
41
|
+
"client": {
|
|
42
|
+
"platform": "web",
|
|
43
|
+
"immediately": true,
|
|
44
|
+
"inject": [
|
|
45
|
+
"@deepseek-ai/dsh-client-ui-session",
|
|
46
|
+
"@deepseek-ai/dsh-client-ui-workspace",
|
|
47
|
+
"@deepseek-ai/dsh-client-shortcuts",
|
|
48
|
+
"@deepseek-ai/dsh-client-ui-layout"
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"repository": {
|
|
53
|
+
"type": "git",
|
|
54
|
+
"url": "https://github.com/adengou/dsh-kbar.git"
|
|
55
|
+
},
|
|
56
|
+
"homepage": "https://github.com/adengou/dsh-kbar",
|
|
57
|
+
"bugs": {
|
|
58
|
+
"url": "https://github.com/adengou/dsh-kbar/issues"
|
|
59
|
+
},
|
|
60
|
+
"author": "adengou",
|
|
61
|
+
"publishConfig": {
|
|
62
|
+
"access": "public"
|
|
63
|
+
}
|
|
64
|
+
}
|