dsh-skill-bazaar 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +92 -2
- package/client.js +1043 -0
- package/cordis.patch.yml +3 -0
- package/icon-180.png +0 -0
- package/icon.svg +13 -0
- package/index.js +1546 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +56 -4
package/client.js
ADDED
|
@@ -0,0 +1,1043 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: 'dsh-skill-bazaar',
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
const React = require('react');
|
|
5
|
+
const e = React.createElement;
|
|
6
|
+
const { useState, useEffect, useRef, useCallback } = React;
|
|
7
|
+
|
|
8
|
+
const API = {
|
|
9
|
+
sources: 'api/skill-bazaar/sources',
|
|
10
|
+
skills: 'api/skill-bazaar/skills',
|
|
11
|
+
skill: 'api/skill-bazaar/skill',
|
|
12
|
+
install: 'api/skill-bazaar/install',
|
|
13
|
+
installed: 'api/skill-bazaar/installed',
|
|
14
|
+
targets: 'api/skill-bazaar/targets',
|
|
15
|
+
resolve: 'api/skill-bazaar/resolve'
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
async function request(path, options) {
|
|
19
|
+
const res = await fetch(path, options);
|
|
20
|
+
const data = await res.json().catch(() => ({}));
|
|
21
|
+
if (!res.ok) {
|
|
22
|
+
const err = new Error(data.error || data.message || 'HTTP ' + res.status);
|
|
23
|
+
err.status = res.status;
|
|
24
|
+
err.data = data;
|
|
25
|
+
throw err;
|
|
26
|
+
}
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function sourceLabel(sources, id) {
|
|
31
|
+
const found = sources.find((s) => s.id === id);
|
|
32
|
+
return found ? found.name : id;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function displayName(item) {
|
|
36
|
+
return item.nameZh && item.nameZh !== item.name ? item.nameZh : item.name || '未命名技能';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function displayDesc(item) {
|
|
40
|
+
return item.descriptionZh || item.description || '暂无简介';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// 技能包检测:描述里带"包含 N 个"或标签含 collection 的条目安装时会展开多个技能
|
|
44
|
+
function packageCount(item) {
|
|
45
|
+
const desc = String(item.descriptionZh || item.description || '');
|
|
46
|
+
const match = desc.match(/包含\s*(\d+)\s*个/);
|
|
47
|
+
if (match) return Number(match[1]) || 0;
|
|
48
|
+
if ((item.tags || []).includes('collection')) return -1;
|
|
49
|
+
return 0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function packageLabel(item) {
|
|
53
|
+
const count = packageCount(item);
|
|
54
|
+
if (count > 0) return '技能包 · ' + count + ' 个技能';
|
|
55
|
+
if (count < 0) return '技能包';
|
|
56
|
+
return '';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// -----------------------------------------------------------------------
|
|
60
|
+
// 图标(侧边栏行只画 glyph,shell 负责按钮、标签、提示)
|
|
61
|
+
// -----------------------------------------------------------------------
|
|
62
|
+
|
|
63
|
+
function SkillBazaarIcon({ size }) {
|
|
64
|
+
return e(
|
|
65
|
+
'svg',
|
|
66
|
+
{
|
|
67
|
+
viewBox: '0 0 16 16',
|
|
68
|
+
width: size,
|
|
69
|
+
height: size,
|
|
70
|
+
fill: 'none',
|
|
71
|
+
stroke: 'currentColor',
|
|
72
|
+
strokeWidth: 1.3,
|
|
73
|
+
strokeLinecap: 'round',
|
|
74
|
+
strokeLinejoin: 'round',
|
|
75
|
+
'aria-hidden': 'true'
|
|
76
|
+
},
|
|
77
|
+
e('path', { d: 'M2.5 3.2c1.6-.7 3.2-.7 5.5.4v9.2c-2.3-1.1-3.9-1.1-5.5-.4V3.2z' }),
|
|
78
|
+
e('path', { d: 'M13.5 3.2c-1.6-.7-3.2-.7-5.5.4v9.2c2.3-1.1 3.9-1.1 5.5-.4V3.2z' }),
|
|
79
|
+
e('path', { d: 'M8 3.6v9.2' })
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// -----------------------------------------------------------------------
|
|
84
|
+
// 小组件
|
|
85
|
+
// -----------------------------------------------------------------------
|
|
86
|
+
|
|
87
|
+
function Toast({ toast }) {
|
|
88
|
+
if (!toast) return null;
|
|
89
|
+
return e('div', { className: 'sb-toast sb-toast-' + (toast.kind || 'info') }, toast.text);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function ConfirmDialog({ confirm, onCancel }) {
|
|
93
|
+
if (!confirm) return null;
|
|
94
|
+
return e(
|
|
95
|
+
'div',
|
|
96
|
+
{ className: 'sb-overlay', onClick: onCancel },
|
|
97
|
+
e(
|
|
98
|
+
'div',
|
|
99
|
+
{ className: 'sb-modal sb-confirm', onClick: (ev) => ev.stopPropagation() },
|
|
100
|
+
e('h3', null, confirm.title),
|
|
101
|
+
e('p', null, confirm.text),
|
|
102
|
+
e(
|
|
103
|
+
'div',
|
|
104
|
+
{ className: 'sb-actions' },
|
|
105
|
+
e('button', { className: 'sb-btn sb-ghost', onClick: onCancel }, '取消'),
|
|
106
|
+
e(
|
|
107
|
+
'button',
|
|
108
|
+
{
|
|
109
|
+
className: 'sb-btn sb-danger',
|
|
110
|
+
onClick: () => {
|
|
111
|
+
const run = confirm.onOk;
|
|
112
|
+
onCancel();
|
|
113
|
+
run();
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
confirm.okText || '覆盖安装'
|
|
117
|
+
)
|
|
118
|
+
)
|
|
119
|
+
)
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function DetailModal({ detail, sources, busy, onClose, onInstall }) {
|
|
124
|
+
if (!detail) return null;
|
|
125
|
+
const meta = [];
|
|
126
|
+
if (detail.author) meta.push('作者:' + detail.author);
|
|
127
|
+
if (detail.version) meta.push('v' + detail.version);
|
|
128
|
+
if (detail.installs) meta.push('热度 ' + Number(detail.installs).toLocaleString('zh-CN'));
|
|
129
|
+
if (detail.domain) meta.push(detail.domain);
|
|
130
|
+
if (packageCount(detail)) meta.push(packageLabel(detail));
|
|
131
|
+
for (const tag of detail.tags || []) meta.push(tag);
|
|
132
|
+
return e(
|
|
133
|
+
'div',
|
|
134
|
+
{ className: 'sb-overlay', onClick: onClose },
|
|
135
|
+
e(
|
|
136
|
+
'div',
|
|
137
|
+
{ className: 'sb-modal sb-detail', onClick: (ev) => ev.stopPropagation() },
|
|
138
|
+
e(
|
|
139
|
+
'div',
|
|
140
|
+
{ className: 'sb-detail-head' },
|
|
141
|
+
e('div', null,
|
|
142
|
+
e('span', { className: 'sb-source-badge sb-source-' + detail.source }, sourceLabel(sources, detail.source)),
|
|
143
|
+
e('h2', null, displayName(detail)),
|
|
144
|
+
detail.nameZh && detail.nameZh !== detail.name ? e('div', { className: 'sb-sub' }, detail.repo || detail.name) : null
|
|
145
|
+
),
|
|
146
|
+
e('button', { className: 'sb-icon-btn', onClick: onClose, title: '关闭' }, '✕')
|
|
147
|
+
),
|
|
148
|
+
e('div', { className: 'sb-detail-desc' }, displayDesc(detail)),
|
|
149
|
+
meta.length ? e('div', { className: 'sb-meta' }, meta.map((m, i) => e('span', { className: 'sb-pill', key: i }, m))) : null,
|
|
150
|
+
e(
|
|
151
|
+
'div',
|
|
152
|
+
{ className: 'sb-actions' },
|
|
153
|
+
e(
|
|
154
|
+
'button',
|
|
155
|
+
{
|
|
156
|
+
className: 'sb-btn ' + (detail.installed ? 'sb-installed' : 'sb-primary'),
|
|
157
|
+
disabled: busy,
|
|
158
|
+
onClick: () => onInstall(detail)
|
|
159
|
+
},
|
|
160
|
+
busy ? '安装中…' : detail.installed ? '已安装' : '选择安装位置…'
|
|
161
|
+
),
|
|
162
|
+
detail.url
|
|
163
|
+
? e('a', { className: 'sb-btn sb-ghost', href: detail.url, target: '_blank', rel: 'noreferrer' }, '打开源站 ↗')
|
|
164
|
+
: null
|
|
165
|
+
),
|
|
166
|
+
e('div', { className: 'sb-hint' }, packageCount(detail)
|
|
167
|
+
? '这是技能包:安装时会展开包内所有子技能,分别写入所选目录。安装完成后新开一个会话即可使用。'
|
|
168
|
+
: '默认安装到 ~/.agents/skills;选择工作区等文件夹时会自动创建其下的 .agents/skills。安装完成后新开一个会话即可使用。')
|
|
169
|
+
)
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function TargetPicker({ item, options, pickDirectory, onCancel, onConfirm }) {
|
|
174
|
+
const userFolder = (options && options.userFolder) || '';
|
|
175
|
+
const userSkillsDir = (options && options.userSkillsDir) || '';
|
|
176
|
+
const workspace = (options && options.workspace) || '';
|
|
177
|
+
const [mode, setMode] = useState(() => {
|
|
178
|
+
try {
|
|
179
|
+
return localStorage.getItem('skill-bazaar-mode') === 'project' ? 'project' : 'user';
|
|
180
|
+
} catch {
|
|
181
|
+
return 'user';
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
const [folder, setFolder] = useState(() => {
|
|
185
|
+
try {
|
|
186
|
+
return localStorage.getItem('skill-bazaar-folder') || workspace;
|
|
187
|
+
} catch {
|
|
188
|
+
return workspace;
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
const [preview, setPreview] = useState(null);
|
|
192
|
+
const [error, setError] = useState('');
|
|
193
|
+
const [picking, setPicking] = useState(false);
|
|
194
|
+
|
|
195
|
+
useEffect(() => {
|
|
196
|
+
if (mode !== 'project') {
|
|
197
|
+
setPreview(null);
|
|
198
|
+
return undefined;
|
|
199
|
+
}
|
|
200
|
+
const value = folder.trim();
|
|
201
|
+
if (!value) {
|
|
202
|
+
setPreview(null);
|
|
203
|
+
return undefined;
|
|
204
|
+
}
|
|
205
|
+
const timer = setTimeout(async () => {
|
|
206
|
+
try {
|
|
207
|
+
const data = await request(API.resolve + '?folder=' + encodeURIComponent(value));
|
|
208
|
+
setPreview(data);
|
|
209
|
+
setError('');
|
|
210
|
+
} catch (err) {
|
|
211
|
+
setPreview(null);
|
|
212
|
+
setError(err.message);
|
|
213
|
+
}
|
|
214
|
+
}, 350);
|
|
215
|
+
return () => clearTimeout(timer);
|
|
216
|
+
}, [folder, mode]);
|
|
217
|
+
|
|
218
|
+
async function chooseFolder() {
|
|
219
|
+
if (!pickDirectory) return;
|
|
220
|
+
setPicking(true);
|
|
221
|
+
try {
|
|
222
|
+
const picked = await pickDirectory();
|
|
223
|
+
if (picked) setFolder(picked);
|
|
224
|
+
} catch (err) {
|
|
225
|
+
setError(err.message || String(err));
|
|
226
|
+
} finally {
|
|
227
|
+
setPicking(false);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function confirm() {
|
|
232
|
+
try {
|
|
233
|
+
localStorage.setItem('skill-bazaar-mode', mode);
|
|
234
|
+
} catch {}
|
|
235
|
+
if (mode === 'user') {
|
|
236
|
+
onConfirm(userFolder || '');
|
|
237
|
+
} else {
|
|
238
|
+
try {
|
|
239
|
+
localStorage.setItem('skill-bazaar-folder', folder.trim());
|
|
240
|
+
} catch {}
|
|
241
|
+
onConfirm(folder.trim());
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const canConfirm = mode === 'user' ? Boolean(userFolder) : Boolean(folder.trim()) && !picking;
|
|
246
|
+
|
|
247
|
+
return e(
|
|
248
|
+
'div',
|
|
249
|
+
{ className: 'sb-overlay', onClick: onCancel },
|
|
250
|
+
e(
|
|
251
|
+
'div',
|
|
252
|
+
{ className: 'sb-modal sb-target-picker', onClick: (ev) => ev.stopPropagation() },
|
|
253
|
+
e(
|
|
254
|
+
'div',
|
|
255
|
+
{ className: 'sb-detail-head' },
|
|
256
|
+
e('h2', null, '选择安装位置'),
|
|
257
|
+
e('button', { className: 'sb-icon-btn', onClick: onCancel, title: '关闭' }, '✕')
|
|
258
|
+
),
|
|
259
|
+
e('div', { className: 'sb-target-sub' }, '「' + displayName(item) + '」安装到哪里?'),
|
|
260
|
+
e(
|
|
261
|
+
'div',
|
|
262
|
+
{ className: 'sb-mode-row' },
|
|
263
|
+
e(
|
|
264
|
+
'button',
|
|
265
|
+
{
|
|
266
|
+
className: 'sb-mode' + (mode === 'user' ? ' sb-mode-active' : ''),
|
|
267
|
+
onClick: () => setMode('user')
|
|
268
|
+
},
|
|
269
|
+
e('strong', null, '用户级(全局)'),
|
|
270
|
+
e('span', null, userSkillsDir || '~/.agents/skills'),
|
|
271
|
+
e('em', null, '所有会话都能用,推荐')
|
|
272
|
+
),
|
|
273
|
+
e(
|
|
274
|
+
'button',
|
|
275
|
+
{
|
|
276
|
+
className: 'sb-mode' + (mode === 'project' ? ' sb-mode-active' : ''),
|
|
277
|
+
onClick: () => setMode('project')
|
|
278
|
+
},
|
|
279
|
+
e('strong', null, '项目级(所选文件夹)'),
|
|
280
|
+
e('span', null, '按会话工作目录加载,仅对应工作区的会话可用'),
|
|
281
|
+
e('em', null, workspace ? '当前工作区:' + workspace : '选择一个文件夹')
|
|
282
|
+
)
|
|
283
|
+
),
|
|
284
|
+
mode === 'project'
|
|
285
|
+
? e(
|
|
286
|
+
React.Fragment,
|
|
287
|
+
null,
|
|
288
|
+
e(
|
|
289
|
+
'div',
|
|
290
|
+
{ className: 'sb-folder-row' },
|
|
291
|
+
e('input', {
|
|
292
|
+
className: 'sb-folder-input',
|
|
293
|
+
value: folder,
|
|
294
|
+
placeholder: '选择一个项目文件夹,例如 D:\\project',
|
|
295
|
+
onChange: (ev) => setFolder(ev.target.value)
|
|
296
|
+
}),
|
|
297
|
+
e(
|
|
298
|
+
'button',
|
|
299
|
+
{ className: 'sb-btn sb-ghost', onClick: chooseFolder, disabled: picking || !pickDirectory },
|
|
300
|
+
picking ? '选择中…' : '选择文件夹…'
|
|
301
|
+
)
|
|
302
|
+
),
|
|
303
|
+
e(
|
|
304
|
+
'div',
|
|
305
|
+
{ className: 'sb-folder-quick' },
|
|
306
|
+
workspace
|
|
307
|
+
? e('button', { className: 'sb-mini-btn', onClick: () => setFolder(workspace) }, '当前工作区')
|
|
308
|
+
: null
|
|
309
|
+
),
|
|
310
|
+
preview
|
|
311
|
+
? e(
|
|
312
|
+
'div',
|
|
313
|
+
{ className: 'sb-target-preview' },
|
|
314
|
+
e('span', null, '将安装到:'),
|
|
315
|
+
e('code', null, preview.skillsDir),
|
|
316
|
+
e('span', { className: 'sb-target-state' }, preview.exists ? '(已存在)' : '(将自动创建)')
|
|
317
|
+
)
|
|
318
|
+
: null,
|
|
319
|
+
preview && !preview.gitRoot
|
|
320
|
+
? e(
|
|
321
|
+
'div',
|
|
322
|
+
{ className: 'sb-target-warn' },
|
|
323
|
+
'该文件夹不在 git 仓库内:DSH 按会话工作目录加载项目级技能,只有在「工作区 = 该文件夹」的会话里才会生效。'
|
|
324
|
+
)
|
|
325
|
+
: null
|
|
326
|
+
)
|
|
327
|
+
: null,
|
|
328
|
+
error ? e('div', { className: 'sb-target-error' }, error) : null,
|
|
329
|
+
e(
|
|
330
|
+
'div',
|
|
331
|
+
{ className: 'sb-actions' },
|
|
332
|
+
e('button', { className: 'sb-btn sb-ghost', onClick: onCancel }, '取消'),
|
|
333
|
+
e('button', { className: 'sb-btn sb-primary', disabled: !canConfirm, onClick: confirm }, '安装')
|
|
334
|
+
)
|
|
335
|
+
)
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function SourceSettings({ sources, onClose, onChanged }) {
|
|
340
|
+
const [form, setForm] = useState({ name: '', type: 'cherryin', baseUrl: '', repo: '', path: 'skills', listUrl: '', fields: '' });
|
|
341
|
+
const [msg, setMsg] = useState(null);
|
|
342
|
+
const [busy, setBusy] = useState(false);
|
|
343
|
+
|
|
344
|
+
function update(key, value) {
|
|
345
|
+
setForm((prev) => ({ ...prev, [key]: value }));
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
async function addSource(ev) {
|
|
349
|
+
ev.preventDefault();
|
|
350
|
+
setBusy(true);
|
|
351
|
+
setMsg(null);
|
|
352
|
+
try {
|
|
353
|
+
const payload = { name: form.name.trim(), type: form.type };
|
|
354
|
+
if (form.type === 'github') {
|
|
355
|
+
payload.repo = form.repo.trim();
|
|
356
|
+
payload.path = form.path.trim() || 'skills';
|
|
357
|
+
} else if (form.type === 'json') {
|
|
358
|
+
payload.listUrl = form.listUrl.trim();
|
|
359
|
+
try {
|
|
360
|
+
payload.fields = form.fields.trim() ? JSON.parse(form.fields) : {};
|
|
361
|
+
} catch {
|
|
362
|
+
throw new Error('字段映射不是有效的 JSON');
|
|
363
|
+
}
|
|
364
|
+
} else {
|
|
365
|
+
payload.baseUrl = form.baseUrl.trim();
|
|
366
|
+
}
|
|
367
|
+
await request(API.sources, {
|
|
368
|
+
method: 'POST',
|
|
369
|
+
headers: { 'Content-Type': 'application/json' },
|
|
370
|
+
body: JSON.stringify(payload)
|
|
371
|
+
});
|
|
372
|
+
setMsg({ kind: 'ok', text: '已添加' });
|
|
373
|
+
setForm({ name: '', type: 'cherryin', baseUrl: '', repo: '', path: 'skills', listUrl: '', fields: '' });
|
|
374
|
+
onChanged();
|
|
375
|
+
} catch (err) {
|
|
376
|
+
setMsg({ kind: 'err', text: err.message });
|
|
377
|
+
} finally {
|
|
378
|
+
setBusy(false);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
async function toggleSource(source) {
|
|
383
|
+
try {
|
|
384
|
+
await request(API.sources, {
|
|
385
|
+
method: 'POST',
|
|
386
|
+
headers: { 'Content-Type': 'application/json' },
|
|
387
|
+
body: JSON.stringify({ id: source.id, enabled: !source.enabled })
|
|
388
|
+
});
|
|
389
|
+
onChanged();
|
|
390
|
+
} catch (err) {
|
|
391
|
+
setMsg({ kind: 'err', text: err.message });
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
async function deleteSource(source) {
|
|
396
|
+
try {
|
|
397
|
+
await request(API.sources + '?id=' + encodeURIComponent(source.id), { method: 'DELETE' });
|
|
398
|
+
onChanged();
|
|
399
|
+
} catch (err) {
|
|
400
|
+
setMsg({ kind: 'err', text: err.message });
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
return e(
|
|
405
|
+
'div',
|
|
406
|
+
{ className: 'sb-overlay', onClick: onClose },
|
|
407
|
+
e(
|
|
408
|
+
'div',
|
|
409
|
+
{ className: 'sb-modal sb-settings', onClick: (ev) => ev.stopPropagation() },
|
|
410
|
+
e(
|
|
411
|
+
'div',
|
|
412
|
+
{ className: 'sb-detail-head' },
|
|
413
|
+
e('h2', null, '源管理'),
|
|
414
|
+
e('button', { className: 'sb-icon-btn', onClick: onClose, title: '关闭' }, '✕')
|
|
415
|
+
),
|
|
416
|
+
e(
|
|
417
|
+
'div',
|
|
418
|
+
{ className: 'sb-source-list' },
|
|
419
|
+
sources.map((source) =>
|
|
420
|
+
e(
|
|
421
|
+
'div',
|
|
422
|
+
{ className: 'sb-source-row', key: source.id },
|
|
423
|
+
e(
|
|
424
|
+
'div',
|
|
425
|
+
{ className: 'sb-source-info' },
|
|
426
|
+
e('strong', null, source.name),
|
|
427
|
+
e(
|
|
428
|
+
'span',
|
|
429
|
+
null,
|
|
430
|
+
source.type === 'github'
|
|
431
|
+
? 'GitHub · ' + (source.repo || '')
|
|
432
|
+
: source.type === 'json'
|
|
433
|
+
? 'JSON · ' + (source.baseUrl || '')
|
|
434
|
+
: source.type + ' · ' + (source.baseUrl || '')
|
|
435
|
+
)
|
|
436
|
+
),
|
|
437
|
+
e(
|
|
438
|
+
'div',
|
|
439
|
+
{ className: 'sb-source-ops' },
|
|
440
|
+
e(
|
|
441
|
+
'button',
|
|
442
|
+
{ className: 'sb-mini-btn' + (source.enabled ? '' : ' sb-off'), onClick: () => toggleSource(source) },
|
|
443
|
+
source.enabled ? '停用' : '启用'
|
|
444
|
+
),
|
|
445
|
+
source.builtin
|
|
446
|
+
? null
|
|
447
|
+
: e('button', { className: 'sb-mini-btn sb-danger', onClick: () => deleteSource(source) }, '删除')
|
|
448
|
+
)
|
|
449
|
+
)
|
|
450
|
+
)
|
|
451
|
+
),
|
|
452
|
+
e('div', { className: 'sb-divider' }),
|
|
453
|
+
e('h3', { className: 'sb-section-title' }, '添加自定义源'),
|
|
454
|
+
e(
|
|
455
|
+
'form',
|
|
456
|
+
{ className: 'sb-form', onSubmit: addSource },
|
|
457
|
+
e('label', null, '名称', e('input', { value: form.name, onChange: (ev) => update('name', ev.target.value), placeholder: '例如:我的团队技能库', required: true })),
|
|
458
|
+
e(
|
|
459
|
+
'label',
|
|
460
|
+
null,
|
|
461
|
+
'类型',
|
|
462
|
+
e(
|
|
463
|
+
'select',
|
|
464
|
+
{ value: form.type, onChange: (ev) => update('type', ev.target.value) },
|
|
465
|
+
e('option', { value: 'cherryin' }, 'CherryIN 兼容(/api/skills 协议)'),
|
|
466
|
+
e('option', { value: 'skills-sh' }, 'skills.sh 兼容(首页 + 搜索 API)'),
|
|
467
|
+
e('option', { value: 'github' }, 'GitHub 仓库(skills/ 目录)'),
|
|
468
|
+
e('option', { value: 'json' }, '自定义 JSON 接口')
|
|
469
|
+
)
|
|
470
|
+
),
|
|
471
|
+
form.type === 'github'
|
|
472
|
+
? e(
|
|
473
|
+
React.Fragment,
|
|
474
|
+
null,
|
|
475
|
+
e('label', null, '仓库', e('input', { value: form.repo, onChange: (ev) => update('repo', ev.target.value), placeholder: 'owner/repo' })),
|
|
476
|
+
e('label', null, '技能目录', e('input', { value: form.path, onChange: (ev) => update('path', ev.target.value), placeholder: 'skills' }))
|
|
477
|
+
)
|
|
478
|
+
: form.type === 'json'
|
|
479
|
+
? e(
|
|
480
|
+
React.Fragment,
|
|
481
|
+
null,
|
|
482
|
+
e('label', null, '列表接口', e('input', { value: form.listUrl, onChange: (ev) => update('listUrl', ev.target.value), placeholder: 'https://example.com/api/skills' })),
|
|
483
|
+
e('label', null, '字段映射', e('input', { value: form.fields, onChange: (ev) => update('fields', ev.target.value), placeholder: '{"name":"title","description":"desc"}' }))
|
|
484
|
+
)
|
|
485
|
+
: e('label', null, '站点地址', e('input', { value: form.baseUrl, onChange: (ev) => update('baseUrl', ev.target.value), placeholder: 'https://example.com' })),
|
|
486
|
+
e(
|
|
487
|
+
'div',
|
|
488
|
+
{ className: 'sb-actions' },
|
|
489
|
+
e('button', { type: 'submit', className: 'sb-btn sb-primary', disabled: busy }, busy ? '添加中…' : '添加源'),
|
|
490
|
+
msg ? e('span', { className: 'sb-form-msg sb-' + msg.kind }, msg.text) : null
|
|
491
|
+
)
|
|
492
|
+
),
|
|
493
|
+
e(
|
|
494
|
+
'div',
|
|
495
|
+
{ className: 'sb-hint' },
|
|
496
|
+
'默认源:CherryIN(中文技能市场)与 skills.sh(Vercel 官方技能目录)。两个源均支持无代理直连;简介默认用微软翻译自动转为中文。'
|
|
497
|
+
)
|
|
498
|
+
)
|
|
499
|
+
);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
// -----------------------------------------------------------------------
|
|
503
|
+
// 主页面
|
|
504
|
+
// -----------------------------------------------------------------------
|
|
505
|
+
|
|
506
|
+
function SkillBazaarPage({ pickDirectory }) {
|
|
507
|
+
const [sources, setSources] = useState([]);
|
|
508
|
+
const [items, setItems] = useState([]);
|
|
509
|
+
const [errors, setErrors] = useState([]);
|
|
510
|
+
const [loading, setLoading] = useState(false);
|
|
511
|
+
const [query, setQuery] = useState('');
|
|
512
|
+
const [activeSource, setActiveSource] = useState('cherryin');
|
|
513
|
+
const [detail, setDetail] = useState(null);
|
|
514
|
+
const [settingsOpen, setSettingsOpen] = useState(false);
|
|
515
|
+
const [toast, setToast] = useState(null);
|
|
516
|
+
const [confirm, setConfirm] = useState(null);
|
|
517
|
+
const [busyKey, setBusyKey] = useState(null);
|
|
518
|
+
const [onlyPackage, setOnlyPackage] = useState(false);
|
|
519
|
+
const [limit, setLimit] = useState(200);
|
|
520
|
+
const [targetsData, setTargetsData] = useState({ defaultFolder: '', defaultSkillsDir: '', workspace: '', workspaceSkillsDir: '', recent: [] });
|
|
521
|
+
const [targetPicker, setTargetPicker] = useState(null);
|
|
522
|
+
const toastTimer = useRef(null);
|
|
523
|
+
const queryTimer = useRef(null);
|
|
524
|
+
const mounted = useRef(true);
|
|
525
|
+
|
|
526
|
+
useEffect(() => {
|
|
527
|
+
mounted.current = true;
|
|
528
|
+
return () => {
|
|
529
|
+
mounted.current = false;
|
|
530
|
+
};
|
|
531
|
+
}, []);
|
|
532
|
+
|
|
533
|
+
const showToast = useCallback((text, kind) => {
|
|
534
|
+
if (!mounted.current) return;
|
|
535
|
+
setToast({ text, kind });
|
|
536
|
+
clearTimeout(toastTimer.current);
|
|
537
|
+
toastTimer.current = setTimeout(() => {
|
|
538
|
+
if (mounted.current) setToast(null);
|
|
539
|
+
}, 3600);
|
|
540
|
+
}, []);
|
|
541
|
+
|
|
542
|
+
const loadSources = useCallback(async () => {
|
|
543
|
+
try {
|
|
544
|
+
const data = await request(API.sources);
|
|
545
|
+
if (!mounted.current) return;
|
|
546
|
+
const list = data.sources || [];
|
|
547
|
+
setSources(list);
|
|
548
|
+
const enabled = list.filter((s) => s.enabled !== false);
|
|
549
|
+
setActiveSource((prev) => {
|
|
550
|
+
if (enabled.some((s) => s.id === prev)) return prev;
|
|
551
|
+
return enabled.length ? enabled[0].id : prev;
|
|
552
|
+
});
|
|
553
|
+
} catch (err) {
|
|
554
|
+
showToast('源列表加载失败:' + err.message, 'err');
|
|
555
|
+
}
|
|
556
|
+
}, [showToast]);
|
|
557
|
+
|
|
558
|
+
const loadTargets = useCallback(async () => {
|
|
559
|
+
try {
|
|
560
|
+
const data = await request(API.targets);
|
|
561
|
+
if (mounted.current) setTargetsData(data);
|
|
562
|
+
} catch {}
|
|
563
|
+
}, []);
|
|
564
|
+
|
|
565
|
+
const loadSkills = useCallback(
|
|
566
|
+
async (force) => {
|
|
567
|
+
if (!mounted.current) return;
|
|
568
|
+
setLoading(true);
|
|
569
|
+
try {
|
|
570
|
+
const params = new URLSearchParams({ source: activeSource, limit: String(limit) });
|
|
571
|
+
if (query) params.set('q', query);
|
|
572
|
+
if (onlyPackage) params.set('package', '1');
|
|
573
|
+
if (force) params.set('refresh', '1');
|
|
574
|
+
const data = await request(API.skills + '?' + params.toString());
|
|
575
|
+
if (!mounted.current) return;
|
|
576
|
+
setItems(data.items || []);
|
|
577
|
+
setErrors(data.errors || []);
|
|
578
|
+
if (Array.isArray(data.sources) && data.sources.length) setSources(data.sources);
|
|
579
|
+
} catch (err) {
|
|
580
|
+
if (!mounted.current) return;
|
|
581
|
+
setItems([]);
|
|
582
|
+
setErrors([{ name: '技能市场', message: err.message }]);
|
|
583
|
+
} finally {
|
|
584
|
+
if (mounted.current) setLoading(false);
|
|
585
|
+
}
|
|
586
|
+
},
|
|
587
|
+
[activeSource, query, onlyPackage, limit]
|
|
588
|
+
);
|
|
589
|
+
|
|
590
|
+
useEffect(() => {
|
|
591
|
+
loadSources();
|
|
592
|
+
loadTargets();
|
|
593
|
+
}, [loadSources, loadTargets]);
|
|
594
|
+
|
|
595
|
+
useEffect(() => {
|
|
596
|
+
clearTimeout(queryTimer.current);
|
|
597
|
+
queryTimer.current = setTimeout(() => loadSkills(false), 300);
|
|
598
|
+
return () => clearTimeout(queryTimer.current);
|
|
599
|
+
}, [loadSkills]);
|
|
600
|
+
|
|
601
|
+
async function openDetail(item) {
|
|
602
|
+
setDetail({ ...item, loading: true });
|
|
603
|
+
try {
|
|
604
|
+
const data = await request(
|
|
605
|
+
API.skill + '?source=' + encodeURIComponent(item.source) + '&id=' + encodeURIComponent(item.id)
|
|
606
|
+
);
|
|
607
|
+
if (mounted.current) setDetail({ ...(data.item || item), installed: item.installed });
|
|
608
|
+
} catch (err) {
|
|
609
|
+
if (mounted.current) setDetail({ ...item, loading: false });
|
|
610
|
+
showToast('详情加载失败:' + err.message, 'err');
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
function requestInstall(item) {
|
|
615
|
+
setTargetPicker({ item });
|
|
616
|
+
loadTargets();
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
async function installItem(item, force, folder) {
|
|
620
|
+
const key = item.source + ':' + item.id;
|
|
621
|
+
setBusyKey(key);
|
|
622
|
+
try {
|
|
623
|
+
const data = await request(API.install, {
|
|
624
|
+
method: 'POST',
|
|
625
|
+
headers: { 'Content-Type': 'application/json' },
|
|
626
|
+
body: JSON.stringify({
|
|
627
|
+
source: item.source,
|
|
628
|
+
id: item.id,
|
|
629
|
+
force: Boolean(force),
|
|
630
|
+
folder: folder || ''
|
|
631
|
+
})
|
|
632
|
+
});
|
|
633
|
+
if (!mounted.current) return;
|
|
634
|
+
const packageMessage =
|
|
635
|
+
data.package && data.skillCount > 1
|
|
636
|
+
? '已安装技能包「' + displayName(item) + '」(' + data.skillCount + ' 个技能)到 ' + data.path
|
|
637
|
+
: '已安装「' + displayName(item) + '」到 ' + data.path;
|
|
638
|
+
showToast(packageMessage, 'ok');
|
|
639
|
+
setItems((prev) =>
|
|
640
|
+
prev.map((it) => (it.source === item.source && it.id === item.id ? { ...it, installed: true } : it))
|
|
641
|
+
);
|
|
642
|
+
setDetail((prev) => (prev && prev.source === item.source && prev.id === item.id ? { ...prev, installed: true } : prev));
|
|
643
|
+
loadTargets();
|
|
644
|
+
} catch (err) {
|
|
645
|
+
if (!mounted.current) return;
|
|
646
|
+
if (err.status === 409 && !force) {
|
|
647
|
+
setConfirm({
|
|
648
|
+
title: '技能已存在',
|
|
649
|
+
text: (() => {
|
|
650
|
+
const paths = (err.data && err.data.paths) || [];
|
|
651
|
+
if (paths.length > 1) {
|
|
652
|
+
return '有 ' + paths.length + ' 个技能已存在于目标目录,是否覆盖?';
|
|
653
|
+
}
|
|
654
|
+
return (err.data && err.data.message) || '目标目录已存在同名技能,是否覆盖?';
|
|
655
|
+
})(),
|
|
656
|
+
okText: '覆盖安装',
|
|
657
|
+
onOk: () => installItem(item, true, folder)
|
|
658
|
+
});
|
|
659
|
+
} else {
|
|
660
|
+
showToast('安装失败:' + err.message, 'err');
|
|
661
|
+
}
|
|
662
|
+
} finally {
|
|
663
|
+
if (mounted.current) setBusyKey(null);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
function refreshAll() {
|
|
668
|
+
loadSources();
|
|
669
|
+
loadSkills(true);
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
const activeSourceName = activeSource === 'all' ? '全部' : sourceLabel(sources, activeSource);
|
|
673
|
+
|
|
674
|
+
return e(
|
|
675
|
+
'div',
|
|
676
|
+
{ className: 'sb-panel' },
|
|
677
|
+
e(
|
|
678
|
+
'div',
|
|
679
|
+
{ className: 'sb-topbar' },
|
|
680
|
+
e(
|
|
681
|
+
'div',
|
|
682
|
+
{ className: 'sb-brand' },
|
|
683
|
+
e('div', { className: 'sb-logo' }, '✦'),
|
|
684
|
+
e(
|
|
685
|
+
'div',
|
|
686
|
+
{ className: 'sb-brand-text' },
|
|
687
|
+
e('h1', null, '技能市场'),
|
|
688
|
+
e('p', null, '聚合 CherryIN · skills.sh · 自定义源,一键安装到 .agents')
|
|
689
|
+
)
|
|
690
|
+
),
|
|
691
|
+
e(
|
|
692
|
+
'div',
|
|
693
|
+
{ className: 'sb-actions' },
|
|
694
|
+
e(
|
|
695
|
+
'div',
|
|
696
|
+
{ className: 'sb-search' },
|
|
697
|
+
e('span', { className: 'sb-search-icon' }, '⌕'),
|
|
698
|
+
e('input', {
|
|
699
|
+
value: query,
|
|
700
|
+
placeholder: '搜索技能,如 pdf、写作、前端设计…',
|
|
701
|
+
onChange: (ev) => setQuery(ev.target.value),
|
|
702
|
+
onKeyDown: (ev) => {
|
|
703
|
+
if (ev.key === 'Escape') setQuery('');
|
|
704
|
+
}
|
|
705
|
+
})
|
|
706
|
+
),
|
|
707
|
+
e('button', { className: 'sb-icon-btn', title: '刷新列表', onClick: refreshAll, disabled: loading }, loading ? '…' : '⟳'),
|
|
708
|
+
e('button', { className: 'sb-icon-btn', title: '源管理', onClick: () => setSettingsOpen(true) }, '⚙')
|
|
709
|
+
)
|
|
710
|
+
),
|
|
711
|
+
e(
|
|
712
|
+
'div',
|
|
713
|
+
{ className: 'sb-toolbar' },
|
|
714
|
+
e(
|
|
715
|
+
'div',
|
|
716
|
+
{ className: 'sb-chips' },
|
|
717
|
+
sources
|
|
718
|
+
.filter((s) => s.enabled)
|
|
719
|
+
.map((source) =>
|
|
720
|
+
e(
|
|
721
|
+
'button',
|
|
722
|
+
{
|
|
723
|
+
key: source.id,
|
|
724
|
+
className:
|
|
725
|
+
'sb-chip' +
|
|
726
|
+
(activeSource === source.id ? ' sb-active' : '') +
|
|
727
|
+
(errors.some((x) => x.source === source.id) ? ' sb-err' : ''),
|
|
728
|
+
onClick: () => setActiveSource(source.id)
|
|
729
|
+
},
|
|
730
|
+
e('span', { className: 'sb-dot' }),
|
|
731
|
+
source.name
|
|
732
|
+
)
|
|
733
|
+
),
|
|
734
|
+
e(
|
|
735
|
+
'button',
|
|
736
|
+
{
|
|
737
|
+
className: 'sb-chip sb-chip-toggle' + (onlyPackage ? ' sb-active' : ''),
|
|
738
|
+
onClick: () => setOnlyPackage((value) => !value),
|
|
739
|
+
title: '只看技能包(包含多个子技能的合集)'
|
|
740
|
+
},
|
|
741
|
+
e('span', { className: 'sb-dot' }),
|
|
742
|
+
'技能包'
|
|
743
|
+
)
|
|
744
|
+
),
|
|
745
|
+
e('div', { className: 'sb-stats' }, loading ? '加载中…' : items.length + ' 个技能' + (onlyPackage ? '(技能包)' : '') + ' · ' + activeSourceName)
|
|
746
|
+
),
|
|
747
|
+
errors.length
|
|
748
|
+
? e(
|
|
749
|
+
'div',
|
|
750
|
+
{ className: 'sb-banner' },
|
|
751
|
+
e('strong', null, '部分源加载失败:'),
|
|
752
|
+
errors.map((err) => err.name + ':' + err.message).join(';')
|
|
753
|
+
)
|
|
754
|
+
: null,
|
|
755
|
+
e(
|
|
756
|
+
'div',
|
|
757
|
+
{ className: 'sb-grid' },
|
|
758
|
+
loading
|
|
759
|
+
? Array.from({ length: 6 }, (_, i) => e('div', { className: 'sb-skeleton', key: i }))
|
|
760
|
+
: items.map((item) =>
|
|
761
|
+
e(
|
|
762
|
+
'article',
|
|
763
|
+
{
|
|
764
|
+
key: item.source + ':' + item.id,
|
|
765
|
+
className: 'sb-card',
|
|
766
|
+
onClick: () => openDetail(item)
|
|
767
|
+
},
|
|
768
|
+
e(
|
|
769
|
+
'div',
|
|
770
|
+
{ className: 'sb-card-head' },
|
|
771
|
+
e(
|
|
772
|
+
'div',
|
|
773
|
+
{ className: 'sb-card-title' },
|
|
774
|
+
e('h3', null, displayName(item)),
|
|
775
|
+
item.nameZh && item.nameZh !== item.name
|
|
776
|
+
? e('p', { className: 'sb-orig' }, item.repo || item.name)
|
|
777
|
+
: null
|
|
778
|
+
),
|
|
779
|
+
e('span', { className: 'sb-source-badge sb-source-' + item.source }, sourceLabel(sources, item.source))
|
|
780
|
+
),
|
|
781
|
+
e('p', { className: 'sb-card-desc' }, displayDesc(item)),
|
|
782
|
+
packageCount(item)
|
|
783
|
+
? e('div', { className: 'sb-package-line' }, e('span', { className: 'sb-package-badge' }, packageLabel(item)))
|
|
784
|
+
: null,
|
|
785
|
+
item.tags && item.tags.length
|
|
786
|
+
? e(
|
|
787
|
+
'div',
|
|
788
|
+
{ className: 'sb-tags' },
|
|
789
|
+
item.tags.slice(0, 4).map((tag, i) => e('span', { className: 'sb-tag', key: i }, tag))
|
|
790
|
+
)
|
|
791
|
+
: null,
|
|
792
|
+
e(
|
|
793
|
+
'div',
|
|
794
|
+
{ className: 'sb-card-foot' },
|
|
795
|
+
e(
|
|
796
|
+
'span',
|
|
797
|
+
{ className: 'sb-metric' },
|
|
798
|
+
item.installs
|
|
799
|
+
? '热度 ' + Number(item.installs).toLocaleString('zh-CN')
|
|
800
|
+
: item.author || item.domain || ''
|
|
801
|
+
),
|
|
802
|
+
e(
|
|
803
|
+
'button',
|
|
804
|
+
{
|
|
805
|
+
className: 'sb-btn ' + (item.installed ? 'sb-installed' : 'sb-primary'),
|
|
806
|
+
disabled: busyKey === item.source + ':' + item.id,
|
|
807
|
+
onClick: (ev) => {
|
|
808
|
+
ev.stopPropagation();
|
|
809
|
+
if (item.installed) {
|
|
810
|
+
showToast('「' + displayName(item) + '」已安装', 'ok');
|
|
811
|
+
return;
|
|
812
|
+
}
|
|
813
|
+
requestInstall(item);
|
|
814
|
+
}
|
|
815
|
+
},
|
|
816
|
+
busyKey === item.source + ':' + item.id ? '安装中…' : item.installed ? '已安装' : '安装'
|
|
817
|
+
)
|
|
818
|
+
)
|
|
819
|
+
)
|
|
820
|
+
)
|
|
821
|
+
),
|
|
822
|
+
!loading && items.length === 0
|
|
823
|
+
? e(
|
|
824
|
+
'div',
|
|
825
|
+
{ className: 'sb-empty' },
|
|
826
|
+
e('div', { className: 'sb-empty-icon' }, '∅'),
|
|
827
|
+
e('p', null, onlyPackage ? '没有找到技能包' : '没有找到匹配的技能')
|
|
828
|
+
)
|
|
829
|
+
: null,
|
|
830
|
+
e(DetailModal, {
|
|
831
|
+
detail,
|
|
832
|
+
sources,
|
|
833
|
+
busy: busyKey === (detail ? detail.source + ':' + detail.id : ''),
|
|
834
|
+
onClose: () => setDetail(null),
|
|
835
|
+
onInstall: (item) => requestInstall(item)
|
|
836
|
+
}),
|
|
837
|
+
targetPicker
|
|
838
|
+
? e(TargetPicker, {
|
|
839
|
+
item: targetPicker.item,
|
|
840
|
+
options: targetsData,
|
|
841
|
+
pickDirectory,
|
|
842
|
+
onCancel: () => setTargetPicker(null),
|
|
843
|
+
onConfirm: (folder) => {
|
|
844
|
+
const pending = targetPicker.item;
|
|
845
|
+
setTargetPicker(null);
|
|
846
|
+
try {
|
|
847
|
+
localStorage.setItem('skill-bazaar-folder', folder);
|
|
848
|
+
} catch {}
|
|
849
|
+
installItem(pending, false, folder);
|
|
850
|
+
}
|
|
851
|
+
})
|
|
852
|
+
: null,
|
|
853
|
+
settingsOpen
|
|
854
|
+
? e(SourceSettings, {
|
|
855
|
+
sources,
|
|
856
|
+
onClose: () => setSettingsOpen(false),
|
|
857
|
+
onChanged: () => {
|
|
858
|
+
loadSources();
|
|
859
|
+
loadSkills(false);
|
|
860
|
+
}
|
|
861
|
+
})
|
|
862
|
+
: null,
|
|
863
|
+
e(ConfirmDialog, {
|
|
864
|
+
confirm,
|
|
865
|
+
onCancel: () => setConfirm(null)
|
|
866
|
+
}),
|
|
867
|
+
e(Toast, { toast })
|
|
868
|
+
);
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
// -----------------------------------------------------------------------
|
|
872
|
+
// 注册:侧边栏一行 + 中栏页面
|
|
873
|
+
// -----------------------------------------------------------------------
|
|
874
|
+
|
|
875
|
+
const inject = ['slots'];
|
|
876
|
+
|
|
877
|
+
function apply(ctx) {
|
|
878
|
+
ctx.effect(() => {
|
|
879
|
+
const slots = ctx.slots;
|
|
880
|
+
const disposers = [];
|
|
881
|
+
const pickDirectory = async () => {
|
|
882
|
+
try {
|
|
883
|
+
const uiWorkspace = ctx.get?.('uiWorkspace', false);
|
|
884
|
+
if (uiWorkspace && typeof uiWorkspace.pickDirectory === 'function') {
|
|
885
|
+
return await uiWorkspace.pickDirectory();
|
|
886
|
+
}
|
|
887
|
+
} catch {}
|
|
888
|
+
return null;
|
|
889
|
+
};
|
|
890
|
+
disposers.push(
|
|
891
|
+
slots.inject('sidebar.panellist', () =>
|
|
892
|
+
slots.register(
|
|
893
|
+
{
|
|
894
|
+
name: 'sidebar.panellist',
|
|
895
|
+
id: 'skill-bazaar',
|
|
896
|
+
order: 40,
|
|
897
|
+
label: () => '技能市场'
|
|
898
|
+
},
|
|
899
|
+
SkillBazaarIcon
|
|
900
|
+
)
|
|
901
|
+
)
|
|
902
|
+
);
|
|
903
|
+
disposers.push(
|
|
904
|
+
slots.inject('main', () =>
|
|
905
|
+
slots.register(
|
|
906
|
+
{
|
|
907
|
+
name: 'main',
|
|
908
|
+
key: 'skill-bazaar',
|
|
909
|
+
inject: () => ({ pickDirectory })
|
|
910
|
+
},
|
|
911
|
+
SkillBazaarPage
|
|
912
|
+
)
|
|
913
|
+
)
|
|
914
|
+
);
|
|
915
|
+
return () => {
|
|
916
|
+
for (const dispose of disposers.splice(0)) dispose();
|
|
917
|
+
};
|
|
918
|
+
}, 'skill-bazaar: ui mounts');
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
return { inject, apply };
|
|
922
|
+
},
|
|
923
|
+
meta: () => ({
|
|
924
|
+
stylesheets: {
|
|
925
|
+
'dsh-skill-bazaar.css': {
|
|
926
|
+
text: () =>
|
|
927
|
+
[
|
|
928
|
+
'.sb-panel{height:100%;min-height:0;display:flex;flex-direction:column;background:var(--dsw-alias-bg-base,#0b0d11);color:var(--dsw-alias-label-primary,#e7eaf0);font-family:var(--dsw-font-family,-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif);font-size:13px;overflow:hidden}',
|
|
929
|
+
'.sb-topbar{flex:none;display:flex;align-items:center;justify-content:space-between;gap:16px;padding:14px 22px;border-bottom:1px solid var(--dsw-alias-border-l1,#262c37);flex-wrap:wrap}',
|
|
930
|
+
'.sb-brand{display:flex;align-items:center;gap:11px;min-width:0}',
|
|
931
|
+
'.sb-logo{width:34px;height:34px;border-radius:10px;display:grid;place-items:center;font-size:17px;color:#fff;background:linear-gradient(135deg,#5b8cff,#8b5cf6);flex:none}',
|
|
932
|
+
'.sb-brand-text h1{margin:0;font-size:16px;font-weight:650}',
|
|
933
|
+
'.sb-brand-text p{margin:1px 0 0;font-size:11.5px;color:var(--dsw-alias-label-tertiary,#6b7484)}',
|
|
934
|
+
'.sb-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap}',
|
|
935
|
+
'.sb-search{display:flex;align-items:center;gap:7px;width:min(380px,42vw);height:34px;padding:0 10px;border:1px solid var(--dsw-alias-border-l1,#262c37);border-radius:9px;background:var(--dsw-specific-input-major,#11141a)}',
|
|
936
|
+
'.sb-search:focus-within{border-color:var(--dsw-alias-state-business-primary,#7aa2ff)}',
|
|
937
|
+
'.sb-search-icon{color:var(--dsw-alias-label-tertiary,#6b7484)}',
|
|
938
|
+
'.sb-search input{flex:1;min-width:0;border:0;outline:0;background:transparent;color:inherit;font-size:13px}',
|
|
939
|
+
'.sb-search input::placeholder{color:var(--dsw-alias-label-tertiary,#6b7484)}',
|
|
940
|
+
'.sb-icon-btn{width:34px;height:34px;display:grid;place-items:center;border:1px solid var(--dsw-alias-border-l1,#262c37);border-radius:9px;background:var(--dsw-specific-input-major,#11141a);color:var(--dsw-alias-label-secondary,#9aa3b2);cursor:pointer;font-size:15px}',
|
|
941
|
+
'.sb-icon-btn:hover{color:var(--dsw-alias-label-primary,#e7eaf0)}',
|
|
942
|
+
'.sb-icon-btn:disabled{opacity:.6;cursor:default}',
|
|
943
|
+
'.sb-toolbar{flex:none;display:flex;align-items:center;justify-content:space-between;gap:14px;padding:12px 22px 6px;flex-wrap:wrap}',
|
|
944
|
+
'.sb-chips{display:flex;gap:8px;flex-wrap:wrap}',
|
|
945
|
+
'.sb-chip{display:inline-flex;align-items:center;gap:6px;height:30px;padding:0 12px;border:1px solid var(--dsw-alias-border-l1,#262c37);border-radius:999px;background:var(--dsw-specific-input-major,#11141a);color:var(--dsw-alias-label-secondary,#9aa3b2);font-size:12.5px;cursor:pointer}',
|
|
946
|
+
'.sb-chip:hover{color:var(--dsw-alias-label-primary,#e7eaf0)}',
|
|
947
|
+
'.sb-chip.sb-active{color:#fff;background:var(--dsw-alias-interactive-bg-hover,rgba(122,162,255,.14));border-color:var(--dsw-alias-state-business-primary,#7aa2ff)}',
|
|
948
|
+
'.sb-chip.sb-chip-toggle{border-style:dashed}',
|
|
949
|
+
'.sb-chip.sb-chip-toggle.sb-active{border-style:solid}',
|
|
950
|
+
'.sb-dot{width:6px;height:6px;border-radius:50%;background:currentColor;opacity:.5}',
|
|
951
|
+
'.sb-chip.sb-err .sb-dot{background:#f87171;opacity:1}',
|
|
952
|
+
'.sb-stats{font-size:11.5px;color:var(--dsw-alias-label-tertiary,#6b7484);white-space:nowrap}',
|
|
953
|
+
'.sb-banner{margin:8px 22px 0;padding:9px 13px;border:1px solid rgba(251,191,36,.35);background:rgba(251,191,36,.12);color:#fde68a;border-radius:9px;font-size:12px}',
|
|
954
|
+
'.sb-grid{flex:1;min-height:0;overflow-y:auto;display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:12px;padding:12px 22px 40px;align-content:start}',
|
|
955
|
+
'.sb-card{display:flex;flex-direction:column;gap:9px;padding:14px 14px 12px;border:1px solid var(--dsw-alias-border-l1,#262c37);border-radius:12px;background:var(--dsw-alias-bg-base,#0b0d11);cursor:pointer;transition:transform .15s,border-color .15s;min-height:170px}',
|
|
956
|
+
'.sb-card:hover{transform:translateY(-2px);border-color:var(--dsw-alias-border-l2,#333b49)}',
|
|
957
|
+
'.sb-card-head{display:flex;align-items:flex-start;justify-content:space-between;gap:8px}',
|
|
958
|
+
'.sb-card-title{min-width:0}',
|
|
959
|
+
'.sb-card-title h3{margin:0;font-size:14px;font-weight:620;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
|
|
960
|
+
'.sb-orig{margin:2px 0 0;font-size:11px;color:var(--dsw-alias-label-tertiary,#6b7484);font-family:var(--dsw-font-family-mono,Consolas,monospace);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
|
|
961
|
+
'.sb-source-badge{flex:none;display:inline-flex;align-items:center;gap:5px;height:20px;padding:0 8px;border-radius:999px;font-size:10.5px;font-family:var(--dsw-font-family-mono,Consolas,monospace);color:var(--dsw-alias-label-secondary,#9aa3b2);background:rgba(255,255,255,.05);border:1px solid var(--dsw-alias-border-l1,#262c37);white-space:nowrap}',
|
|
962
|
+
'.sb-source-badge::before{content:"";width:5px;height:5px;border-radius:50%;background:#7aa2ff}',
|
|
963
|
+
'.sb-source-cherryin::before{background:#f472b6}',
|
|
964
|
+
'.sb-source-skills-sh::before{background:#7aa2ff}',
|
|
965
|
+
'.sb-source-github::before{background:#4ade80}',
|
|
966
|
+
'.sb-card-desc{margin:0;color:var(--dsw-alias-label-secondary,#9aa3b2);font-size:12.5px;line-height:1.6;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;min-height:60px}',
|
|
967
|
+
'.sb-tags{display:flex;gap:5px;flex-wrap:wrap}',
|
|
968
|
+
'.sb-package-line{display:flex}',
|
|
969
|
+
'.sb-package-badge{display:inline-flex;align-items:center;gap:4px;height:19px;padding:0 7px;border-radius:5px;font-size:10.5px;color:#c4b5fd;background:rgba(139,92,246,.14);border:1px solid rgba(139,92,246,.35);white-space:nowrap}',
|
|
970
|
+
'.sb-tag{font-size:10px;color:var(--dsw-alias-label-tertiary,#6b7484);border:1px solid var(--dsw-alias-border-l1,#262c37);border-radius:4px;padding:0 6px;line-height:17px;background:rgba(255,255,255,.03)}',
|
|
971
|
+
'.sb-card-foot{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-top:auto;padding-top:2px}',
|
|
972
|
+
'.sb-metric{font-size:11px;color:var(--dsw-alias-label-tertiary,#6b7484);font-family:var(--dsw-font-family-mono,Consolas,monospace)}',
|
|
973
|
+
'.sb-btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;height:30px;padding:0 13px;border-radius:8px;border:1px solid var(--dsw-alias-border-l1,#262c37);background:var(--dsw-specific-input-major,#11141a);color:var(--dsw-alias-label-primary,#e7eaf0);font-size:12.5px;font-weight:550;cursor:pointer;text-decoration:none;white-space:nowrap}',
|
|
974
|
+
'.sb-btn:hover{border-color:var(--dsw-alias-border-l2,#333b49)}',
|
|
975
|
+
'.sb-btn:disabled{opacity:.55;cursor:default}',
|
|
976
|
+
'.sb-primary{border-color:rgba(122,162,255,.45);background:rgba(122,162,255,.16);color:#dbe6ff}',
|
|
977
|
+
'.sb-ghost{background:transparent;color:var(--dsw-alias-label-secondary,#9aa3b2)}',
|
|
978
|
+
'.sb-danger{border-color:rgba(248,113,113,.45);background:rgba(248,113,113,.12);color:#fecaca}',
|
|
979
|
+
'.sb-installed{border-color:rgba(74,222,128,.4);background:rgba(74,222,128,.12);color:#4ade80}',
|
|
980
|
+
'.sb-skeleton{height:180px;border-radius:12px;border:1px solid var(--dsw-alias-border-l1,#262c37);background:linear-gradient(90deg,#161a21 25%,#1d222b 37%,#161a21 63%);background-size:400% 100%;animation:sb-shimmer 1.4s ease infinite}',
|
|
981
|
+
'@keyframes sb-shimmer{0%{background-position:100% 0}100%{background-position:-100% 0}}',
|
|
982
|
+
'.sb-empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;color:var(--dsw-alias-label-tertiary,#6b7484)}',
|
|
983
|
+
'.sb-empty-icon{font-size:32px;opacity:.6}',
|
|
984
|
+
'.sb-overlay{position:fixed;inset:0;z-index:80;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,.55);backdrop-filter:blur(2px);padding:20px}',
|
|
985
|
+
'.sb-modal{width:min(560px,94vw);max-height:86vh;overflow-y:auto;padding:20px 22px;border:1px solid var(--dsw-alias-border-l2,#333b49);border-radius:16px;background:var(--dsw-alias-bg-base,#0e1116);box-shadow:0 20px 60px rgba(0,0,0,.5)}',
|
|
986
|
+
'.sb-detail-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}',
|
|
987
|
+
'.sb-detail-head h2{margin:6px 0 2px;font-size:19px;font-weight:680}',
|
|
988
|
+
'.sb-sub{font-size:11.5px;color:var(--dsw-alias-label-tertiary,#6b7484);font-family:var(--dsw-font-family-mono,Consolas,monospace)}',
|
|
989
|
+
'.sb-detail-desc{margin-top:16px;padding:14px 16px;border:1px solid var(--dsw-alias-border-l1,#262c37);border-radius:11px;background:rgba(255,255,255,.02);font-size:13px;line-height:1.75;white-space:pre-wrap;word-break:break-word;color:var(--dsw-alias-label-primary,#cfd6e2)}',
|
|
990
|
+
'.sb-meta{display:flex;gap:7px;flex-wrap:wrap;margin-top:12px}',
|
|
991
|
+
'.sb-pill{font-size:11px;color:var(--dsw-alias-label-secondary,#9aa3b2);border:1px solid var(--dsw-alias-border-l1,#262c37);border-radius:6px;padding:3px 8px;background:rgba(255,255,255,.03);font-family:var(--dsw-font-family-mono,Consolas,monospace)}',
|
|
992
|
+
'.sb-actions{display:flex;align-items:center;gap:9px;margin-top:16px;flex-wrap:wrap}',
|
|
993
|
+
'.sb-actions .sb-btn{height:36px;font-size:13px}',
|
|
994
|
+
'.sb-hint{margin-top:12px;font-size:11.5px;line-height:1.6;color:var(--dsw-alias-label-tertiary,#6b7484)}',
|
|
995
|
+
'.sb-settings h3{margin:0 0 8px;font-size:13px;font-weight:600;color:var(--dsw-alias-label-secondary,#9aa3b2)}',
|
|
996
|
+
'.sb-source-list{display:flex;flex-direction:column;gap:8px;margin-top:14px}',
|
|
997
|
+
'.sb-source-row{display:flex;align-items:center;gap:10px;padding:10px 12px;border:1px solid var(--dsw-alias-border-l1,#262c37);border-radius:10px;background:rgba(255,255,255,.02)}',
|
|
998
|
+
'.sb-source-info{flex:1;min-width:0}',
|
|
999
|
+
'.sb-source-info strong{display:block;font-size:12.5px}',
|
|
1000
|
+
'.sb-source-info span{display:block;font-size:11px;color:var(--dsw-alias-label-tertiary,#6b7484);font-family:var(--dsw-font-family-mono,Consolas,monospace);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
|
|
1001
|
+
'.sb-source-ops{display:flex;gap:6px;flex:none}',
|
|
1002
|
+
'.sb-mini-btn{height:24px;padding:0 9px;font-size:11px;border-radius:6px;border:1px solid var(--dsw-alias-border-l1,#262c37);background:transparent;color:var(--dsw-alias-label-secondary,#9aa3b2);cursor:pointer}',
|
|
1003
|
+
'.sb-mini-btn:hover{color:var(--dsw-alias-label-primary,#e7eaf0)}',
|
|
1004
|
+
'.sb-mini-btn.sb-off{color:#fbbf24;border-color:rgba(251,191,36,.4)}',
|
|
1005
|
+
'.sb-mini-btn.sb-danger:hover{color:#f87171;border-color:rgba(248,113,113,.5)}',
|
|
1006
|
+
'.sb-divider{height:1px;background:var(--dsw-alias-border-l1,#262c37);margin:18px 0}',
|
|
1007
|
+
'.sb-form{display:flex;flex-direction:column;gap:9px}',
|
|
1008
|
+
'.sb-form label{display:flex;flex-direction:column;gap:4px;font-size:11.5px;color:var(--dsw-alias-label-tertiary,#6b7484)}',
|
|
1009
|
+
'.sb-form input,.sb-form select{height:32px;padding:0 9px;border:1px solid var(--dsw-alias-border-l2,#333b49);border-radius:7px;background:var(--dsw-specific-input-major,#11141a);color:inherit;font-size:12.5px;outline:none}',
|
|
1010
|
+
'.sb-form input:focus,.sb-form select:focus{border-color:var(--dsw-alias-state-business-primary,#7aa2ff)}',
|
|
1011
|
+
'.sb-form-msg{font-size:11.5px}',
|
|
1012
|
+
'.sb-form-msg.sb-ok{color:#4ade80}',
|
|
1013
|
+
'.sb-form-msg.sb-err{color:#f87171}',
|
|
1014
|
+
'.sb-toast{position:fixed;left:50%;bottom:26px;transform:translateX(-50%);z-index:95;max-width:min(540px,90vw);padding:10px 16px;border-radius:10px;border:1px solid var(--dsw-alias-border-l2,#333b49);background:#1b212b;color:var(--dsw-alias-label-primary,#e7eaf0);font-size:12.5px;box-shadow:0 16px 40px rgba(0,0,0,.4);word-break:break-all}',
|
|
1015
|
+
'.sb-toast.sb-toast-ok{border-color:rgba(74,222,128,.45);color:#bbf7d0}',
|
|
1016
|
+
'.sb-toast.sb-toast-err{border-color:rgba(248,113,113,.5);color:#fecaca}',
|
|
1017
|
+
'.sb-confirm{width:min(420px,92vw)}',
|
|
1018
|
+
'.sb-confirm h3{margin:0 0 8px;font-size:15px}',
|
|
1019
|
+
'.sb-confirm p{margin:0;color:var(--dsw-alias-label-secondary,#9aa3b2);font-size:12.5px;word-break:break-all}',
|
|
1020
|
+
'.sb-section-title{margin:0}',
|
|
1021
|
+
'.sb-target-picker{width:min(560px,94vw)}',
|
|
1022
|
+
'.sb-target-sub{font-size:12px;color:var(--dsw-alias-label-secondary,#9aa3b2);margin-top:4px;line-height:1.6}',
|
|
1023
|
+
'.sb-folder-row{display:flex;gap:8px;margin-top:14px}',
|
|
1024
|
+
'.sb-folder-input{flex:1;min-width:0;height:34px;padding:0 10px;border:1px solid var(--dsw-alias-border-l2,#333b49);border-radius:8px;background:var(--dsw-specific-input-major,#11141a);color:inherit;font-size:12.5px;outline:none}',
|
|
1025
|
+
'.sb-folder-input:focus{border-color:var(--dsw-alias-state-business-primary,#7aa2ff)}',
|
|
1026
|
+
'.sb-folder-quick{display:flex;gap:6px;margin-top:8px}',
|
|
1027
|
+
'.sb-target-preview{margin-top:12px;display:flex;align-items:center;gap:6px;flex-wrap:wrap;font-size:11.5px;color:var(--dsw-alias-label-secondary,#9aa3b2)}',
|
|
1028
|
+
'.sb-mode-row{display:flex;flex-direction:column;gap:8px;margin-top:14px}',
|
|
1029
|
+
'.sb-mode{display:flex;flex-direction:column;gap:3px;padding:10px 12px;border:1px solid var(--dsw-alias-border-l1,#262c37);border-radius:10px;background:rgba(255,255,255,.02);color:inherit;cursor:pointer;text-align:left}',
|
|
1030
|
+
'.sb-mode:hover{border-color:var(--dsw-alias-border-l2,#333b49)}',
|
|
1031
|
+
'.sb-mode.sb-mode-active{border-color:var(--dsw-alias-state-business-primary,#7aa2ff);background:rgba(122,162,255,.1)}',
|
|
1032
|
+
'.sb-mode strong{font-size:13px;font-weight:600}',
|
|
1033
|
+
'.sb-mode span{font-size:11px;color:var(--dsw-alias-label-tertiary,#6b7484);font-family:var(--dsw-font-family-mono,Consolas,monospace);word-break:break-all}',
|
|
1034
|
+
'.sb-mode em{font-size:11px;color:var(--dsw-alias-label-secondary,#9aa3b2);font-style:normal}',
|
|
1035
|
+
'.sb-target-warn{margin-top:8px;padding:8px 10px;border:1px solid rgba(251,191,36,.35);background:rgba(251,191,36,.1);border-radius:8px;font-size:11.5px;line-height:1.6;color:#fde68a}',
|
|
1036
|
+
'.sb-target-preview code{font-family:var(--dsw-font-family-mono,Consolas,monospace);font-size:11px;background:rgba(255,255,255,.05);border:1px solid var(--dsw-alias-border-l1,#262c37);border-radius:5px;padding:2px 6px;word-break:break-all}',
|
|
1037
|
+
'.sb-target-state{color:var(--dsw-alias-label-tertiary,#6b7484)}',
|
|
1038
|
+
'.sb-target-error{margin-top:8px;font-size:11.5px;color:#f87171;word-break:break-all}'
|
|
1039
|
+
].join('')
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
})
|
|
1043
|
+
});
|