dsh-kbar 0.1.0 → 0.3.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 +12 -0
- package/README.md +1 -1
- package/client.js +183 -10
- package/docs/DETAIL.md +9 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# 更新记录
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
- 新增**斜杠命令搜索与执行**:读取当前会话的命令目录,选中即通过 `commands.execute` 执行 `/name`;
|
|
6
|
+
- 新增**技能搜索**:读取当前会话的可用技能,选中把 `/技能名` 复制到剪贴板,粘到输入框即可调用;
|
|
7
|
+
- 分类标签(模型/插件/命令/技能)与中文提示。
|
|
8
|
+
|
|
9
|
+
## 0.2.0
|
|
10
|
+
|
|
11
|
+
- 新增**模型搜索与切换**:列出当前会话可用的全部模型(按厂商分组),选中即切换,沿用模型默认推理强度;
|
|
12
|
+
- 新增**插件搜索**:从插件管理器读取已安装/可用的 bundle,选中打开对应的插件详情页;
|
|
13
|
+
- 会话列表为空时仍可用命令、模型、插件与内置动作。
|
|
14
|
+
|
|
3
15
|
## 0.1.0
|
|
4
16
|
|
|
5
17
|
- 首个版本:`Ctrl+Shift+P`(macOS `Cmd+Shift+P`)打开命令面板;
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
A command palette for DeepSeek Harness. One shortcut to search sessions and run common actions.
|
|
4
4
|
|
|
5
5
|
- Default shortcut: `Ctrl+Shift+P` on Windows/Linux, `Cmd+Shift+P` on macOS.
|
|
6
|
-
- Searches sessions
|
|
6
|
+
- Searches sessions, slash commands, skills, models and installed bundles, and runs any registered DSH shortcut command from one palette.
|
|
7
7
|
- `↑`/`↓` to select, `Enter` to run, `Esc` to close.
|
|
8
8
|
|
|
9
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.
|
package/client.js
CHANGED
|
@@ -16,6 +16,10 @@ window.__ModuleLoader__.load({
|
|
|
16
16
|
sessionTag: '会话',
|
|
17
17
|
actionTag: '动作',
|
|
18
18
|
commandTag: '命令',
|
|
19
|
+
modelTag: '模型',
|
|
20
|
+
pluginTag: '插件',
|
|
21
|
+
slashTag: '命令',
|
|
22
|
+
skillTag: '技能',
|
|
19
23
|
newSession: '新建会话',
|
|
20
24
|
pluginsPage: '打开插件页',
|
|
21
25
|
hintNavigate: '↑↓ 选择',
|
|
@@ -32,6 +36,10 @@ window.__ModuleLoader__.load({
|
|
|
32
36
|
sessionTag: 'session',
|
|
33
37
|
actionTag: 'action',
|
|
34
38
|
commandTag: 'command',
|
|
39
|
+
modelTag: 'model',
|
|
40
|
+
pluginTag: 'plugin',
|
|
41
|
+
slashTag: 'command',
|
|
42
|
+
skillTag: 'skill',
|
|
35
43
|
newSession: 'New session',
|
|
36
44
|
pluginsPage: 'Open the plugins page',
|
|
37
45
|
hintNavigate: '↑↓ select',
|
|
@@ -40,6 +48,25 @@ window.__ModuleLoader__.load({
|
|
|
40
48
|
results: '{n} results',
|
|
41
49
|
}
|
|
42
50
|
|
|
51
|
+
function kindLabel(kind) {
|
|
52
|
+
switch (kind) {
|
|
53
|
+
case 'session':
|
|
54
|
+
return TEXT.sessionTag
|
|
55
|
+
case 'command':
|
|
56
|
+
return TEXT.commandTag
|
|
57
|
+
case 'model':
|
|
58
|
+
return TEXT.modelTag
|
|
59
|
+
case 'plugin':
|
|
60
|
+
return TEXT.pluginTag
|
|
61
|
+
case 'slash':
|
|
62
|
+
return TEXT.slashTag
|
|
63
|
+
case 'skill':
|
|
64
|
+
return TEXT.skillTag
|
|
65
|
+
default:
|
|
66
|
+
return TEXT.actionTag
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
43
70
|
const IS_MAC = (() => {
|
|
44
71
|
try {
|
|
45
72
|
const p = (navigator.platform || '') + ' ' + (navigator.userAgent || '')
|
|
@@ -73,6 +100,11 @@ window.__ModuleLoader__.load({
|
|
|
73
100
|
|
|
74
101
|
function createStore(ctx) {
|
|
75
102
|
let state = { open: false, query: '', index: 0, rows: [] }
|
|
103
|
+
let models = []
|
|
104
|
+
let plugins = null
|
|
105
|
+
let slashCommands = []
|
|
106
|
+
let skills = []
|
|
107
|
+
let loading = false
|
|
76
108
|
const listeners = new Set()
|
|
77
109
|
let lastFocus = null
|
|
78
110
|
let closing = false
|
|
@@ -183,6 +215,133 @@ window.__ModuleLoader__.load({
|
|
|
183
215
|
}
|
|
184
216
|
}
|
|
185
217
|
|
|
218
|
+
function currentSession() {
|
|
219
|
+
try {
|
|
220
|
+
const rows = Object.values(ctx.sessions.list.getSnapshot().byId || {})
|
|
221
|
+
return rows.find((row) => row && row.retainedBy && (row.retainedBy.mainView || 0) > 0) || null
|
|
222
|
+
} catch {
|
|
223
|
+
return null
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
async function loadModels() {
|
|
228
|
+
const row = currentSession()
|
|
229
|
+
const directories = ctx.get ? ctx.get('modelDirectories') : undefined
|
|
230
|
+
if (!row || !directories) return
|
|
231
|
+
try {
|
|
232
|
+
const directory = directories.directoryFor(row.id)
|
|
233
|
+
await directory.load()
|
|
234
|
+
const snapshot = directory.store.getSnapshot()
|
|
235
|
+
const items = []
|
|
236
|
+
for (const group of snapshot.groups || []) {
|
|
237
|
+
for (const model of group.models || []) {
|
|
238
|
+
const effort = model.reasoning && model.reasoning.defaultEffort
|
|
239
|
+
items.push({
|
|
240
|
+
kind: 'model',
|
|
241
|
+
id: 'model:' + group.id + ':' + model.id,
|
|
242
|
+
title: String(model.name || model.label || model.id),
|
|
243
|
+
secondary: String(group.name || group.id),
|
|
244
|
+
keywords: String(group.id) + ' ' + String(model.id) + ' 模型 model',
|
|
245
|
+
updatedAt: 0,
|
|
246
|
+
run: () => {
|
|
247
|
+
const selection = { provider: group.id, model: model.id }
|
|
248
|
+
if (effort !== undefined) selection.reasoningEffort = effort
|
|
249
|
+
return directory.select(selection)
|
|
250
|
+
},
|
|
251
|
+
})
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
models = items
|
|
255
|
+
if (state.open) refreshRows()
|
|
256
|
+
} catch {
|
|
257
|
+
/* models unavailable for this session */
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
async function loadPlugins() {
|
|
262
|
+
if (plugins !== null || loading) return
|
|
263
|
+
loading = true
|
|
264
|
+
try {
|
|
265
|
+
const result = await ctx.remote.pluginManager.listBundles()
|
|
266
|
+
if (result && result.ok && Array.isArray(result.value)) {
|
|
267
|
+
plugins = result.value
|
|
268
|
+
.filter((bundle) => bundle && bundle.name)
|
|
269
|
+
.map((bundle) => ({
|
|
270
|
+
kind: 'plugin',
|
|
271
|
+
id: 'plugin:' + bundle.name,
|
|
272
|
+
title: String(bundle.displayName || bundle.name),
|
|
273
|
+
secondary: bundle.version ? 'v' + bundle.version : '',
|
|
274
|
+
keywords: String(bundle.name) + ' ' + String(bundle.description || '') + ' 插件 plugin',
|
|
275
|
+
updatedAt: 0,
|
|
276
|
+
run: () => ctx.pluginNavigation.openBundle(bundle.name),
|
|
277
|
+
}))
|
|
278
|
+
}
|
|
279
|
+
} catch {
|
|
280
|
+
/* plugin manager unavailable */
|
|
281
|
+
} finally {
|
|
282
|
+
loading = false
|
|
283
|
+
}
|
|
284
|
+
if (state.open) refreshRows()
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
async function loadSlashCommands() {
|
|
288
|
+
const row = currentSession()
|
|
289
|
+
if (!row) return
|
|
290
|
+
try {
|
|
291
|
+
const result = await ctx.remote.commands.list(row.id)
|
|
292
|
+
if (!result || !result.ok || !Array.isArray(result.value)) return
|
|
293
|
+
slashCommands = result.value.map((command) => ({
|
|
294
|
+
kind: 'slash',
|
|
295
|
+
id: 'slash:' + command.name,
|
|
296
|
+
title: '/' + command.name,
|
|
297
|
+
secondary: String(command.description || (command.input && command.input.hint) || ''),
|
|
298
|
+
keywords: String(command.description || '') + ' 命令 command 斜杠 slash',
|
|
299
|
+
updatedAt: 0,
|
|
300
|
+
run: () => {
|
|
301
|
+
const pending = ctx.remote.commands.execute(row.id, '/' + command.name, [])
|
|
302
|
+
if (pending && typeof pending.then === 'function') {
|
|
303
|
+
return pending.then((outcome) => {
|
|
304
|
+
if (!outcome || outcome.ok !== true) {
|
|
305
|
+
throw new Error((outcome && outcome.error && outcome.error.message) || 'command execution failed')
|
|
306
|
+
}
|
|
307
|
+
})
|
|
308
|
+
}
|
|
309
|
+
return undefined
|
|
310
|
+
},
|
|
311
|
+
}))
|
|
312
|
+
if (state.open) refreshRows()
|
|
313
|
+
} catch {
|
|
314
|
+
/* command catalog unavailable */
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
async function loadSkills() {
|
|
319
|
+
const row = currentSession()
|
|
320
|
+
if (!row) return
|
|
321
|
+
try {
|
|
322
|
+
const result = await ctx.remote.skills.list({ sessionId: row.id })
|
|
323
|
+
if (!result || !result.ok || !result.value || !Array.isArray(result.value.skills)) return
|
|
324
|
+
skills = result.value.skills.map((skill) => ({
|
|
325
|
+
kind: 'skill',
|
|
326
|
+
id: 'skill:' + skill.name,
|
|
327
|
+
title: '/' + skill.name,
|
|
328
|
+
secondary: String(skill.description || '') + ' · 复制调用命令',
|
|
329
|
+
keywords: String(skill.description || '') + ' 技能 skill 斜杠 slash',
|
|
330
|
+
updatedAt: 0,
|
|
331
|
+
run: () => {
|
|
332
|
+
const text = '/' + skill.name
|
|
333
|
+
if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
|
|
334
|
+
return navigator.clipboard.writeText(text)
|
|
335
|
+
}
|
|
336
|
+
return undefined
|
|
337
|
+
},
|
|
338
|
+
}))
|
|
339
|
+
if (state.open) refreshRows()
|
|
340
|
+
} catch {
|
|
341
|
+
/* skill catalog unavailable */
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
186
345
|
function compute() {
|
|
187
346
|
const query = state.query.trim().toLowerCase()
|
|
188
347
|
const actions = actionItems()
|
|
@@ -191,12 +350,16 @@ window.__ModuleLoader__.load({
|
|
|
191
350
|
const recent = readRecent()
|
|
192
351
|
const boost = (item) => (recent.includes(item.id) ? 15 : 0)
|
|
193
352
|
if (!query) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
353
|
+
return actions
|
|
354
|
+
.concat(models.slice(0, 6))
|
|
355
|
+
.concat(slashCommands.slice(0, 8))
|
|
356
|
+
.concat(skills.slice(0, 8))
|
|
357
|
+
.concat(commands.slice(0, 6))
|
|
358
|
+
.concat(sessions.slice(0, 8))
|
|
359
|
+
.concat((plugins || []).slice(0, 8))
|
|
197
360
|
}
|
|
198
361
|
const scored = []
|
|
199
|
-
for (const item of actions.concat(commands, sessions)) {
|
|
362
|
+
for (const item of actions.concat(models, slashCommands, skills, commands, sessions, plugins || [])) {
|
|
200
363
|
const value = score(query, item)
|
|
201
364
|
if (value > 0) scored.push({ item, value: value + boost(item) })
|
|
202
365
|
}
|
|
@@ -209,6 +372,12 @@ window.__ModuleLoader__.load({
|
|
|
209
372
|
emit()
|
|
210
373
|
}
|
|
211
374
|
|
|
375
|
+
function refreshRows() {
|
|
376
|
+
if (!state.open) return
|
|
377
|
+
const rows = compute()
|
|
378
|
+
set({ rows, index: Math.min(state.index, Math.max(0, rows.length - 1)) })
|
|
379
|
+
}
|
|
380
|
+
|
|
212
381
|
return {
|
|
213
382
|
subscribe,
|
|
214
383
|
getSnapshot: snapshot,
|
|
@@ -220,6 +389,10 @@ window.__ModuleLoader__.load({
|
|
|
220
389
|
lastFocus = null
|
|
221
390
|
}
|
|
222
391
|
set({ open: true, query: '', index: 0, rows: compute() })
|
|
392
|
+
loadModels()
|
|
393
|
+
loadPlugins()
|
|
394
|
+
loadSlashCommands()
|
|
395
|
+
loadSkills()
|
|
223
396
|
},
|
|
224
397
|
close() {
|
|
225
398
|
if (!state.open || closing) return
|
|
@@ -263,17 +436,17 @@ window.__ModuleLoader__.load({
|
|
|
263
436
|
const run = item.run
|
|
264
437
|
setTimeout(() => {
|
|
265
438
|
try {
|
|
266
|
-
run()
|
|
439
|
+
const result = run()
|
|
440
|
+
if (result && typeof result.then === 'function') {
|
|
441
|
+
result.catch((error) => console.error('[kbar] action failed', error))
|
|
442
|
+
}
|
|
267
443
|
} catch (error) {
|
|
268
444
|
console.error('[kbar] action failed', error)
|
|
269
445
|
}
|
|
270
446
|
}, 0)
|
|
271
447
|
},
|
|
272
448
|
refresh() {
|
|
273
|
-
|
|
274
|
-
const rows = compute()
|
|
275
|
-
set({ rows, index: Math.min(state.index, Math.max(0, rows.length - 1)) })
|
|
276
|
-
}
|
|
449
|
+
refreshRows()
|
|
277
450
|
},
|
|
278
451
|
}
|
|
279
452
|
}
|
|
@@ -507,7 +680,7 @@ window.__ModuleLoader__.load({
|
|
|
507
680
|
h('div', { style: styles.rowTitle }, item.title),
|
|
508
681
|
item.secondary ? h('div', { style: styles.rowSecondary }, item.secondary) : null,
|
|
509
682
|
),
|
|
510
|
-
h('span', { style: styles.badge }, item.kind
|
|
683
|
+
h('span', { style: styles.badge }, kindLabel(item.kind)),
|
|
511
684
|
),
|
|
512
685
|
),
|
|
513
686
|
),
|
package/docs/DETAIL.md
CHANGED
|
@@ -15,6 +15,10 @@ KBar 在 DSH 界面之上加一个命令面板:按一次快捷键,输入几
|
|
|
15
15
|
| --- | --- |
|
|
16
16
|
| 会话 | 当前会话目录里列出的所有会话(标题、工作目录),按最近更新排序,选中即切换 |
|
|
17
17
|
| 命令 | DSH 里所有已注册的快捷键命令(新建会话、设置、侧栏、终端、文件等),选中即执行 |
|
|
18
|
+
| 斜杠命令 | 当前会话的命令目录(`/compact` 等),选中即执行 |
|
|
19
|
+
| 技能 | 当前会话可用的技能,选中把 `/技能名` 复制到剪贴板(粘到输入框即可调用) |
|
|
20
|
+
| 模型 | 当前会话可用的模型(按厂商分组),选中即切换,并沿用该模型的默认推理强度 |
|
|
21
|
+
| 插件 | 插件管理器里的 bundle(名称、版本),选中打开对应的插件详情页 |
|
|
18
22
|
| 动作 | 新建会话;打开插件页 |
|
|
19
23
|
|
|
20
24
|
## 为什么不占 Ctrl+K
|
|
@@ -25,7 +29,11 @@ KBar 在 DSH 界面之上加一个命令面板:按一次快捷键,输入几
|
|
|
25
29
|
|
|
26
30
|
## 已知限制
|
|
27
31
|
|
|
28
|
-
-
|
|
32
|
+
- 快捷键命令只包含带快捷键定义的应用命令;斜杠命令与技能来自当前会话,需要会话处于打开状态。
|
|
33
|
+
- 需要参数的斜杠命令直接执行可能提示参数缺失,请改用输入框补全参数。
|
|
34
|
+
- 技能只提供“复制 /技能名”,不直接替用户发送,避免误触模型调用。
|
|
35
|
+
- 模型列表只在存在当前会话时加载;没有会话时该分组为空。
|
|
36
|
+
- 插件列表来自插件管理器的 bundle 列表,选中后打开插件详情页,不在面板内直接启停。
|
|
29
37
|
- 部分命令依赖当前焦点所在的控件,通过面板执行时可能提示“不可用”(例如需要选中某个侧栏标签的命令)。
|
|
30
38
|
- 会话列表来自客户端已加载的目录快照;尚未被加载的历史会话不会出现。
|
|
31
39
|
- 面板是覆盖层,关闭后不会改变当前页面;执行动作会先关闭面板再执行。
|