dsh-kbar 0.1.0 → 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 +6 -0
- package/README.md +1 -1
- package/client.js +91 -9
- package/docs/DETAIL.md +5 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
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 by title and working directory,
|
|
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
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
|
@@ -73,6 +73,9 @@ window.__ModuleLoader__.load({
|
|
|
73
73
|
|
|
74
74
|
function createStore(ctx) {
|
|
75
75
|
let state = { open: false, query: '', index: 0, rows: [] }
|
|
76
|
+
let models = []
|
|
77
|
+
let plugins = null
|
|
78
|
+
let loading = false
|
|
76
79
|
const listeners = new Set()
|
|
77
80
|
let lastFocus = null
|
|
78
81
|
let closing = false
|
|
@@ -183,6 +186,75 @@ window.__ModuleLoader__.load({
|
|
|
183
186
|
}
|
|
184
187
|
}
|
|
185
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
|
+
|
|
186
258
|
function compute() {
|
|
187
259
|
const query = state.query.trim().toLowerCase()
|
|
188
260
|
const actions = actionItems()
|
|
@@ -191,12 +263,14 @@ window.__ModuleLoader__.load({
|
|
|
191
263
|
const recent = readRecent()
|
|
192
264
|
const boost = (item) => (recent.includes(item.id) ? 15 : 0)
|
|
193
265
|
if (!query) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
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))
|
|
197
271
|
}
|
|
198
272
|
const scored = []
|
|
199
|
-
for (const item of actions.concat(commands, sessions)) {
|
|
273
|
+
for (const item of actions.concat(models, commands, sessions, plugins || [])) {
|
|
200
274
|
const value = score(query, item)
|
|
201
275
|
if (value > 0) scored.push({ item, value: value + boost(item) })
|
|
202
276
|
}
|
|
@@ -209,6 +283,12 @@ window.__ModuleLoader__.load({
|
|
|
209
283
|
emit()
|
|
210
284
|
}
|
|
211
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
|
+
|
|
212
292
|
return {
|
|
213
293
|
subscribe,
|
|
214
294
|
getSnapshot: snapshot,
|
|
@@ -220,6 +300,8 @@ window.__ModuleLoader__.load({
|
|
|
220
300
|
lastFocus = null
|
|
221
301
|
}
|
|
222
302
|
set({ open: true, query: '', index: 0, rows: compute() })
|
|
303
|
+
loadModels()
|
|
304
|
+
loadPlugins()
|
|
223
305
|
},
|
|
224
306
|
close() {
|
|
225
307
|
if (!state.open || closing) return
|
|
@@ -263,17 +345,17 @@ window.__ModuleLoader__.load({
|
|
|
263
345
|
const run = item.run
|
|
264
346
|
setTimeout(() => {
|
|
265
347
|
try {
|
|
266
|
-
run()
|
|
348
|
+
const result = run()
|
|
349
|
+
if (result && typeof result.then === 'function') {
|
|
350
|
+
result.catch((error) => console.error('[kbar] action failed', error))
|
|
351
|
+
}
|
|
267
352
|
} catch (error) {
|
|
268
353
|
console.error('[kbar] action failed', error)
|
|
269
354
|
}
|
|
270
355
|
}, 0)
|
|
271
356
|
},
|
|
272
357
|
refresh() {
|
|
273
|
-
|
|
274
|
-
const rows = compute()
|
|
275
|
-
set({ rows, index: Math.min(state.index, Math.max(0, rows.length - 1)) })
|
|
276
|
-
}
|
|
358
|
+
refreshRows()
|
|
277
359
|
},
|
|
278
360
|
}
|
|
279
361
|
}
|
package/docs/DETAIL.md
CHANGED
|
@@ -15,6 +15,8 @@ KBar 在 DSH 界面之上加一个命令面板:按一次快捷键,输入几
|
|
|
15
15
|
| --- | --- |
|
|
16
16
|
| 会话 | 当前会话目录里列出的所有会话(标题、工作目录),按最近更新排序,选中即切换 |
|
|
17
17
|
| 命令 | DSH 里所有已注册的快捷键命令(新建会话、设置、侧栏、终端、文件等),选中即执行 |
|
|
18
|
+
| 模型 | 当前会话可用的模型(按厂商分组),选中即切换,并沿用该模型的默认推理强度 |
|
|
19
|
+
| 插件 | 插件管理器里的 bundle(名称、版本),选中打开对应的插件详情页 |
|
|
18
20
|
| 动作 | 新建会话;打开插件页 |
|
|
19
21
|
|
|
20
22
|
## 为什么不占 Ctrl+K
|
|
@@ -25,7 +27,9 @@ KBar 在 DSH 界面之上加一个命令面板:按一次快捷键,输入几
|
|
|
25
27
|
|
|
26
28
|
## 已知限制
|
|
27
29
|
|
|
28
|
-
- 命令来自 DSH
|
|
30
|
+
- 命令来自 DSH 的快捷键注册表,只包含带快捷键定义的应用命令;斜杠命令与技能尚未进入搜索范围(后续版本计划)。
|
|
31
|
+
- 模型列表只在存在当前会话时加载;没有会话时该分组为空。
|
|
32
|
+
- 插件列表来自插件管理器的 bundle 列表,选中后打开插件详情页,不在面板内直接启停。
|
|
29
33
|
- 部分命令依赖当前焦点所在的控件,通过面板执行时可能提示“不可用”(例如需要选中某个侧栏标签的命令)。
|
|
30
34
|
- 会话列表来自客户端已加载的目录快照;尚未被加载的历史会话不会出现。
|
|
31
35
|
- 面板是覆盖层,关闭后不会改变当前页面;执行动作会先关闭面板再执行。
|