dsh-kbar 0.3.0 → 0.3.1
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/client.js +36 -26
- package/docs/DETAIL.md +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/client.js
CHANGED
|
@@ -98,6 +98,17 @@ window.__ModuleLoader__.load({
|
|
|
98
98
|
return 50 - Math.min(40, gaps)
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
function copyText(text) {
|
|
102
|
+
try {
|
|
103
|
+
if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
|
|
104
|
+
return navigator.clipboard.writeText(text)
|
|
105
|
+
}
|
|
106
|
+
} catch {
|
|
107
|
+
/* clipboard unavailable */
|
|
108
|
+
}
|
|
109
|
+
return undefined
|
|
110
|
+
}
|
|
111
|
+
|
|
101
112
|
function createStore(ctx) {
|
|
102
113
|
let state = { open: false, query: '', index: 0, rows: [] }
|
|
103
114
|
let models = []
|
|
@@ -290,25 +301,30 @@ window.__ModuleLoader__.load({
|
|
|
290
301
|
try {
|
|
291
302
|
const result = await ctx.remote.commands.list(row.id)
|
|
292
303
|
if (!result || !result.ok || !Array.isArray(result.value)) return
|
|
293
|
-
slashCommands = result.value.map((command) =>
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
304
|
+
slashCommands = result.value.map((command) => {
|
|
305
|
+
const needsInput = command.input !== undefined
|
|
306
|
+
const hint = needsInput ? String((command.input && command.input.hint) || '') : ''
|
|
307
|
+
return {
|
|
308
|
+
kind: 'slash',
|
|
309
|
+
id: 'slash:' + command.name,
|
|
310
|
+
title: '/' + command.name,
|
|
311
|
+
secondary: String(command.description || hint || '') + (needsInput ? ' · 需要参数,选中复制' : ''),
|
|
312
|
+
keywords: String(command.description || '') + ' ' + hint + ' 命令 command 斜杠 slash',
|
|
313
|
+
updatedAt: 0,
|
|
314
|
+
run: () => {
|
|
315
|
+
if (needsInput) return copyText('/' + command.name + ' ')
|
|
316
|
+
const pending = ctx.remote.commands.execute(row.id, '/' + command.name, [])
|
|
317
|
+
if (pending && typeof pending.then === 'function') {
|
|
318
|
+
return pending.then((outcome) => {
|
|
319
|
+
if (!outcome || outcome.ok !== true) {
|
|
320
|
+
throw new Error((outcome && outcome.error && outcome.error.message) || 'command execution failed')
|
|
321
|
+
}
|
|
322
|
+
})
|
|
323
|
+
}
|
|
324
|
+
return undefined
|
|
325
|
+
},
|
|
326
|
+
}
|
|
327
|
+
})
|
|
312
328
|
if (state.open) refreshRows()
|
|
313
329
|
} catch {
|
|
314
330
|
/* command catalog unavailable */
|
|
@@ -328,13 +344,7 @@ window.__ModuleLoader__.load({
|
|
|
328
344
|
secondary: String(skill.description || '') + ' · 复制调用命令',
|
|
329
345
|
keywords: String(skill.description || '') + ' 技能 skill 斜杠 slash',
|
|
330
346
|
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
|
-
},
|
|
347
|
+
run: () => copyText('/' + skill.name),
|
|
338
348
|
}))
|
|
339
349
|
if (state.open) refreshRows()
|
|
340
350
|
} catch {
|
package/docs/DETAIL.md
CHANGED
|
@@ -30,7 +30,7 @@ KBar 在 DSH 界面之上加一个命令面板:按一次快捷键,输入几
|
|
|
30
30
|
## 已知限制
|
|
31
31
|
|
|
32
32
|
- 快捷键命令只包含带快捷键定义的应用命令;斜杠命令与技能来自当前会话,需要会话处于打开状态。
|
|
33
|
-
-
|
|
33
|
+
- 需要参数的斜杠命令不会直接执行,选中后把 `/name ` 复制到剪贴板,由你补参数再发送。
|
|
34
34
|
- 技能只提供“复制 /技能名”,不直接替用户发送,避免误触模型调用。
|
|
35
35
|
- 模型列表只在存在当前会话时加载;没有会话时该分组为空。
|
|
36
36
|
- 插件列表来自插件管理器的 bundle 列表,选中后打开插件详情页,不在面板内直接启停。
|