dsh-skill-harbor 0.5.2 → 0.5.3
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/dsh.plugin.json +1 -1
- package/lib/audit/ruleset.js +104 -104
- package/lib/client/panel.js +29 -16
- package/lib/routes/index.js +516 -516
- package/package.json +1 -1
- package/src/client/panel.js +371 -358
package/src/client/panel.js
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 技能港湾面板(客户端半)。
|
|
3
|
-
*
|
|
4
|
-
* 无框架依赖:DSH 的 slots 只要求返回 DOM 节点。用原生 DOM 避免把 React
|
|
5
|
-
* 打进插件包,也避免跨 React 根复用组件的样式事故。
|
|
6
|
-
*/
|
|
7
|
-
import { api, dict } from './api.js'
|
|
8
|
-
import { FILE_STATE_LABEL } from './labels.js'
|
|
9
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 技能港湾面板(客户端半)。
|
|
3
|
+
*
|
|
4
|
+
* 无框架依赖:DSH 的 slots 只要求返回 DOM 节点。用原生 DOM 避免把 React
|
|
5
|
+
* 打进插件包,也避免跨 React 根复用组件的样式事故。
|
|
6
|
+
*/
|
|
7
|
+
import { api, dict } from './api.js'
|
|
8
|
+
import { FILE_STATE_LABEL } from './labels.js'
|
|
9
|
+
|
|
10
10
|
const CSS_ID = 'dsh-skill-harbor-style'
|
|
11
11
|
|
|
12
|
-
/* __STAR_INLINE_BEGIN__ — 手写内联 star 面板(v1→v2→v3 阶梯,_tools/star-row 计划)。
|
|
12
|
+
/* __STAR_INLINE_BEGIN__ — 手写内联 star 面板(v1→v2→v3→v4 阶梯,_tools/star-row 计划)。
|
|
13
13
|
* 本仓浏览器半边是手写 JS/无 TS 构建,插不进 star-row-copy.ts,故内联等价实现
|
|
14
14
|
* (沿用 dsh-preset-doctor 先例)。STAR_GEN / STAR_VERSION 由 _tools/star-row/ladder.mjs
|
|
15
|
-
* 每次发版改写:v1 = 话术+★CTA+×隐藏;v2 = 一行页脚点过即收;v3 =
|
|
15
|
+
* 每次发版改写:v1 = 话术+★CTA+×隐藏;v2 = 一行页脚点过即收;v3 = 两行页脚「我已支持」才收
|
|
16
|
+
* (冻结版见 gens/inline.star-panel.v3.js);v4 = 三动作描边胶囊 + v4.supported 键。
|
|
16
17
|
* 契约由本仓 tests/star-panel.test.* 锁定(★/💬 跳转语义、写键、旧键不迁值、10 语)。 */
|
|
17
18
|
(function () {
|
|
18
19
|
var REPO_URL = "https://github.com/drscrewdriver/dsh-skill-harbor";
|
|
19
20
|
var STAR_NS = "skill-harbor";
|
|
20
|
-
var STAR_GEN = "
|
|
21
|
-
var STAR_VERSION = "0.5.
|
|
21
|
+
var STAR_GEN = "v4"; /* ladder:gen */
|
|
22
|
+
var STAR_VERSION = "0.5.3"; /* ladder:ver */
|
|
22
23
|
var LANGS = ["zh", "en", "ja", "ko", "fr", "de", "it", "ru", "es", "pt"];
|
|
23
24
|
|
|
24
25
|
// 三代共享:GitHub 单色 mark(octicon 轮廓,fill 随 currentColor)。
|
|
@@ -62,6 +63,7 @@ const CSS_ID = 'dsh-skill-harbor-style'
|
|
|
62
63
|
var K_V1 = "dsh.star." + STAR_NS + ".dismissed";
|
|
63
64
|
var K_V2 = "dsh.star." + STAR_NS + ".v2.dismissed";
|
|
64
65
|
var K_V3 = "dsh.star." + STAR_NS + ".v3.supported";
|
|
66
|
+
var K_V4 = "dsh.star." + STAR_NS + ".v4.supported";
|
|
65
67
|
function lsGet(k) { try { return localStorage.getItem(k); } catch (e) { return null; } }
|
|
66
68
|
function lsSet(k) { try { localStorage.setItem(k, "1"); } catch (e) {} }
|
|
67
69
|
function lsRm(k) { try { if (localStorage.getItem(k) !== null) localStorage.removeItem(k); } catch (e) {} }
|
|
@@ -90,6 +92,12 @@ const CSS_ID = 'dsh-skill-harbor-style'
|
|
|
90
92
|
if (tag === "a" && href) { el.href = href; el.target = "_blank"; el.rel = "noopener noreferrer"; }
|
|
91
93
|
el.textContent = text; return el;
|
|
92
94
|
}
|
|
95
|
+
function footBtn(d, tag, text, href) {
|
|
96
|
+
var el = d.createElement(tag); el.className = "dsh-star-btn";
|
|
97
|
+
if (tag === "a" && href) { el.href = href; el.target = "_blank"; el.rel = "noopener noreferrer"; }
|
|
98
|
+
if (tag === "button") el.type = "button";
|
|
99
|
+
el.textContent = text; return el;
|
|
100
|
+
}
|
|
93
101
|
function dot(d) { var x = d.createElement("span"); x.className = "dsh-star-dot"; x.textContent = "·"; return x; }
|
|
94
102
|
|
|
95
103
|
function render(d) {
|
|
@@ -133,39 +141,43 @@ const CSS_ID = 'dsh-skill-harbor-style'
|
|
|
133
141
|
st2.addEventListener("click", collapse2); is2.addEventListener("click", collapse2);
|
|
134
142
|
return r2;
|
|
135
143
|
}
|
|
136
|
-
// v3
|
|
144
|
+
// v4(v3 结构 + 三动作描边胶囊;STAR_GEN 仍为 v3 的仓走本分支即升级为 v4 语义)
|
|
137
145
|
inject(d, "dsh-star-foot-style", FOOT +
|
|
138
|
-
".dsh-star-foot{display:flex;flex-direction:column;align-items:flex-start;gap:
|
|
139
|
-
".dsh-star-foot .dsh-star-
|
|
140
|
-
".dsh-star-
|
|
146
|
+
".dsh-star-foot{display:flex;flex-direction:column;align-items:flex-start;gap:6px;opacity:.85}.dsh-star-foot-line{display:flex;align-items:center;gap:6px;flex-wrap:wrap;min-width:0}" +
|
|
147
|
+
".dsh-star-foot .dsh-star-ask{opacity:.8}" +
|
|
148
|
+
".dsh-star-btn{display:inline-flex;align-items:center;gap:4px;flex:none;appearance:none;font:inherit;font-size:11px;line-height:1.5;padding:2px 10px;border-radius:999px;border:1px solid currentColor;background:transparent;color:inherit;cursor:pointer;text-decoration:none;opacity:.75}" +
|
|
149
|
+
".dsh-star-btn:hover{opacity:1;background:rgba(127,127,127,.12);text-decoration:none}" +
|
|
150
|
+
".dsh-star-foot-collapsed{display:flex;align-items:center;gap:8px;flex-wrap:wrap;font-size:12px;line-height:1.6;color:inherit;opacity:.72;margin-top:10px}" +
|
|
151
|
+
".dsh-star-foot-collapsed .dsh-star-row{display:inline-flex;align-items:center;gap:7px;color:inherit;text-decoration:none}" +
|
|
152
|
+
".dsh-star-foot-collapsed a{color:inherit;text-decoration:none}");
|
|
141
153
|
var n3 = neutralLink(d);
|
|
142
|
-
lsRm(K_V2); lsRm(K_V1); //
|
|
154
|
+
lsRm(K_V3); lsRm(K_V2); lsRm(K_V1); // v4 加载即清三旧键,不迁值
|
|
143
155
|
var iss = issuesUrl();
|
|
144
|
-
if (lsGet(
|
|
156
|
+
if (lsGet(K_V4) === "1") {
|
|
145
157
|
var box = d.createElement("div"); box.className = "dsh-star-foot-collapsed";
|
|
146
158
|
n3.className = "dsh-star-row"; box.appendChild(n3);
|
|
147
|
-
box.appendChild(
|
|
159
|
+
box.appendChild(footBtn(d, "a", "💬 " + (ISSUE_TXT[L] || ISSUE_TXT.en), iss));
|
|
148
160
|
return box;
|
|
149
161
|
}
|
|
150
162
|
var r3 = d.createElement("div"); r3.className = "dsh-star-foot";
|
|
151
163
|
var l1 = d.createElement("div"); l1.className = "dsh-star-foot-line";
|
|
152
164
|
var v3 = d.createElement("span"); v3.className = "dsh-star-ver"; v3.textContent = "v" + STAR_VERSION; l1.appendChild(v3);
|
|
153
165
|
l1.appendChild(dot(d)); l1.appendChild(footItem(d, "span", FASK[L] || FASK.en));
|
|
154
|
-
l1.appendChild(
|
|
166
|
+
l1.appendChild(footBtn(d, "a", "⭐ " + (STAR_TXT[L] || STAR_TXT.en), REPO_URL));
|
|
155
167
|
l1.appendChild(dot(d));
|
|
156
|
-
var sup = d.createElement("button"); sup.type = "button"; sup.className = "dsh-star-support"; sup.textContent = SUPPORT_TXT[L] || SUPPORT_TXT.en;
|
|
168
|
+
var sup = d.createElement("button"); sup.type = "button"; sup.className = "dsh-star-btn dsh-star-support"; sup.textContent = SUPPORT_TXT[L] || SUPPORT_TXT.en;
|
|
157
169
|
sup.addEventListener("click", function () {
|
|
158
|
-
lsSet(
|
|
170
|
+
lsSet(K_V4);
|
|
159
171
|
if (r3.parentNode) {
|
|
160
172
|
var b = d.createElement("div"); b.className = "dsh-star-foot-collapsed";
|
|
161
173
|
var nn = neutralLink(d); nn.className = "dsh-star-row"; b.appendChild(nn);
|
|
162
|
-
b.appendChild(
|
|
174
|
+
b.appendChild(footBtn(d, "a", "💬 " + (ISSUE_TXT[L] || ISSUE_TXT.en), iss));
|
|
163
175
|
r3.parentNode.replaceChild(b, r3);
|
|
164
176
|
}
|
|
165
177
|
});
|
|
166
178
|
l1.appendChild(sup);
|
|
167
179
|
var l2 = d.createElement("div"); l2.className = "dsh-star-foot-line";
|
|
168
|
-
l2.appendChild(
|
|
180
|
+
l2.appendChild(footBtn(d, "a", "💬 " + (ISSUE_TXT[L] || ISSUE_TXT.en), iss));
|
|
169
181
|
r3.appendChild(l1); r3.appendChild(l2);
|
|
170
182
|
return r3;
|
|
171
183
|
}
|
|
@@ -179,336 +191,337 @@ const CSS_ID = 'dsh-skill-harbor-style'
|
|
|
179
191
|
/* __STAR_INLINE_END__ */
|
|
180
192
|
|
|
181
193
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
if (document
|
|
186
|
-
|
|
187
|
-
style
|
|
188
|
-
style.
|
|
189
|
-
|
|
190
|
-
.dshh-
|
|
191
|
-
.dshh-
|
|
192
|
-
.dshh-tab
|
|
193
|
-
.dshh-
|
|
194
|
-
.dshh-
|
|
195
|
-
.dshh-
|
|
196
|
-
.dshh-table
|
|
197
|
-
.dshh-
|
|
198
|
-
.dshh-state
|
|
199
|
-
.dshh-state[data-state="
|
|
200
|
-
.dshh-state[data-state="
|
|
201
|
-
.dshh-
|
|
202
|
-
.dshh-
|
|
203
|
-
.dshh-
|
|
204
|
-
.dshh-btn
|
|
205
|
-
.dshh-
|
|
206
|
-
.dshh-
|
|
207
|
-
.dshh-verdict
|
|
208
|
-
.dshh-verdict[data-v="
|
|
209
|
-
.dshh-verdict[data-v="
|
|
210
|
-
.dshh-verdict[data-v="
|
|
211
|
-
.dshh-
|
|
212
|
-
.dshh-dup-
|
|
213
|
-
.dshh-dup-
|
|
214
|
-
.dshh-dup-group
|
|
215
|
-
.dshh-dup-
|
|
216
|
-
.dshh-dup-
|
|
217
|
-
.dshh-dup-
|
|
218
|
-
.dshh-dup-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
else if (key
|
|
229
|
-
else if (key === '
|
|
230
|
-
else node.
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
*
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
let
|
|
248
|
-
let
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
const
|
|
252
|
-
const
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
['
|
|
257
|
-
['
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
'
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
*
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
.
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
el('span', { text:
|
|
307
|
-
el('span', {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
const
|
|
330
|
-
|
|
331
|
-
el('td', { text:
|
|
332
|
-
el('td', { text:
|
|
333
|
-
el('td', {},
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
'
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
el('td', { text:
|
|
342
|
-
el('td', {},
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
:
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
el('th', { text: t.
|
|
357
|
-
el('th', { text: t.
|
|
358
|
-
el('th', { text: t.
|
|
359
|
-
el('th', { text: t.
|
|
360
|
-
el('th', { text: t.
|
|
361
|
-
el('th', { text: t.
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
await
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
await
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
el('td', {
|
|
411
|
-
el('td', {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
el('span', { text: `${t.
|
|
421
|
-
el('span', { text: `${t.
|
|
422
|
-
el('span', { text: `${t.
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
el('th', { text: t.
|
|
428
|
-
el('th', { text: t.
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
el('span', { text: `${t.
|
|
442
|
-
el('span', { text: `${t.
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
state.
|
|
469
|
-
state.
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
'project-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
'user-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
function injectStyles() {
|
|
197
|
+
if (typeof document === 'undefined') return
|
|
198
|
+
if (document.getElementById(CSS_ID) !== null) return
|
|
199
|
+
const style = document.createElement('style')
|
|
200
|
+
style.id = CSS_ID
|
|
201
|
+
style.textContent = `
|
|
202
|
+
.dshh-root { display: flex; flex-direction: column; gap: 12px; padding: 12px; font-size: 13px; }
|
|
203
|
+
.dshh-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--dsw-alias-border, #3334); }
|
|
204
|
+
.dshh-tab { padding: 6px 12px; cursor: pointer; border: none; background: transparent; color: inherit; border-radius: 4px 4px 0 0; }
|
|
205
|
+
.dshh-tab[data-active="true"] { background: var(--dsw-alias-surface, #ffffff10); font-weight: 600; }
|
|
206
|
+
.dshh-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; }
|
|
207
|
+
.dshh-spacer { flex: 1; }
|
|
208
|
+
.dshh-table { width: 100%; border-collapse: collapse; }
|
|
209
|
+
.dshh-table th, .dshh-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--dsw-alias-border, #3333); }
|
|
210
|
+
.dshh-state { padding: 1px 6px; border-radius: 3px; font-size: 11px; }
|
|
211
|
+
.dshh-state[data-state="editable"] { background: #2e7d3233; color: #4caf50; }
|
|
212
|
+
.dshh-state[data-state="provider-file"] { background: #ed6c0233; color: #ff9800; }
|
|
213
|
+
.dshh-state[data-state="virtual"] { background: #9e9e9e33; color: #9e9e9e; }
|
|
214
|
+
.dshh-shadowed { opacity: 0.55; }
|
|
215
|
+
.dshh-shadow-tag { font-size: 11px; color: #ff9800; }
|
|
216
|
+
.dshh-btn { padding: 3px 8px; border-radius: 3px; border: 1px solid var(--dsw-alias-border, #3336); background: transparent; color: inherit; cursor: pointer; }
|
|
217
|
+
.dshh-btn:disabled { opacity: 0.4; cursor: not-allowed; }
|
|
218
|
+
.dshh-empty { padding: 24px; text-align: center; opacity: 0.6; }
|
|
219
|
+
.dshh-verdict { padding: 1px 6px; border-radius: 3px; font-size: 11px; }
|
|
220
|
+
.dshh-verdict[data-v="ok"] { background: #2e7d3233; color: #4caf50; }
|
|
221
|
+
.dshh-verdict[data-v="warn"] { background: #ed6c0233; color: #ff9800; }
|
|
222
|
+
.dshh-verdict[data-v="fail"] { background: #c6282833; color: #f44336; }
|
|
223
|
+
.dshh-verdict[data-v="skipped"] { background: #9e9e9e33; color: #9e9e9e; }
|
|
224
|
+
.dshh-dup-panel { border: 1px solid var(--dsw-alias-border, #3334); border-radius: 6px; padding: 10px; margin-bottom: 12px; }
|
|
225
|
+
.dshh-dup-heading { font-weight: 600; margin-bottom: 8px; }
|
|
226
|
+
.dshh-dup-group { margin-bottom: 10px; }
|
|
227
|
+
.dshh-dup-group:last-child { margin-bottom: 0; }
|
|
228
|
+
.dshh-dup-title { font-size: 12px; opacity: 0.75; margin-bottom: 4px; }
|
|
229
|
+
.dshh-dup-row { display: flex; align-items: center; gap: 6px; padding: 3px 0; font-size: 12px; }
|
|
230
|
+
.dshh-dup-meta { opacity: 0.6; }
|
|
231
|
+
.dshh-dup-winner { color: #4caf50; font-weight: 600; }
|
|
232
|
+
`
|
|
233
|
+
document.head.appendChild(style)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function el(tag, props = {}, children = []) {
|
|
237
|
+
const node = document.createElement(tag)
|
|
238
|
+
for (const [key, value] of Object.entries(props)) {
|
|
239
|
+
if (key === 'className') node.className = value
|
|
240
|
+
else if (key.startsWith('data-')) node.setAttribute(key, value)
|
|
241
|
+
else if (key === 'text') node.textContent = value
|
|
242
|
+
else if (key === 'onClick') node.addEventListener('click', value)
|
|
243
|
+
else node.setAttribute(key, value)
|
|
244
|
+
}
|
|
245
|
+
for (const child of children) node.append(child)
|
|
246
|
+
return node
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* 创建面板。返回 { node, destroy }。
|
|
251
|
+
* @param {{ lang?: string }} options
|
|
252
|
+
*/
|
|
253
|
+
export function createPanel(options = {}) {
|
|
254
|
+
const lang = options.lang ?? 'zh'
|
|
255
|
+
const t = dict(lang)
|
|
256
|
+
|
|
257
|
+
injectStyles()
|
|
258
|
+
|
|
259
|
+
let tab = 'overview'
|
|
260
|
+
let state = { skills: [], duplicates: [], totals: {}, audit: null, budget: null, error: null }
|
|
261
|
+
let destroyed = false
|
|
262
|
+
|
|
263
|
+
const root = el('div', { className: 'dshh-root' })
|
|
264
|
+
const tabsBar = el('div', { className: 'dshh-tabs' })
|
|
265
|
+
const body = el('div', {})
|
|
266
|
+
|
|
267
|
+
const tabs = [
|
|
268
|
+
['overview', t.tabOverview],
|
|
269
|
+
['audit', t.tabAudit],
|
|
270
|
+
['budget', t.tabBudget],
|
|
271
|
+
]
|
|
272
|
+
|
|
273
|
+
function renderTabs() {
|
|
274
|
+
tabsBar.replaceChildren(
|
|
275
|
+
...tabs.map(([id, label]) =>
|
|
276
|
+
el('button', {
|
|
277
|
+
className: 'dshh-tab',
|
|
278
|
+
'data-active': String(tab === id),
|
|
279
|
+
text: label,
|
|
280
|
+
onClick: () => {
|
|
281
|
+
tab = id
|
|
282
|
+
void refresh()
|
|
283
|
+
},
|
|
284
|
+
}),
|
|
285
|
+
),
|
|
286
|
+
)
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function renderOverview() {
|
|
290
|
+
if (state.skills.length === 0) {
|
|
291
|
+
return el('div', { className: 'dshh-empty', text: t.noSkills })
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return el('div', {}, [
|
|
295
|
+
// 同名冲突先给树状视图:谁的 rank 高、谁被压住
|
|
296
|
+
state.duplicates.length > 0 ? renderDuplicates() : el('span', {}),
|
|
297
|
+
renderTable(),
|
|
298
|
+
])
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* 遮蔽关系树:一组同名技能按 rank 升序竖排,
|
|
303
|
+
* 胜者标「胜出」,其余标注被谁压住。
|
|
304
|
+
*/
|
|
305
|
+
function renderDuplicates() {
|
|
306
|
+
const groups = state.duplicates.map(group => {
|
|
307
|
+
// 从 skills 里捞出该组的全部条目(list 已按 rank 排序)
|
|
308
|
+
const entries = state.skills
|
|
309
|
+
.filter(skill => skill.name.toLowerCase() === group.name.toLowerCase())
|
|
310
|
+
.sort((a, b) => a.rank - b.rank)
|
|
311
|
+
|
|
312
|
+
const rows = entries.map((skill, index) => {
|
|
313
|
+
const isWinner = index === 0
|
|
314
|
+
return el('div', {
|
|
315
|
+
className: isWinner ? 'dshh-dup-row' : 'dshh-dup-row dshh-shadowed',
|
|
316
|
+
style: `padding-left:${index * 16}px`,
|
|
317
|
+
}, [
|
|
318
|
+
el('span', { text: isWinner ? '▼ ' : ' └ ' }),
|
|
319
|
+
el('span', { text: `${skill.name} ` }),
|
|
320
|
+
el('span', { className: 'dshh-dup-meta', text: `${sourceLabel(t, skill.source)} (rank ${skill.rank})` }),
|
|
321
|
+
isWinner
|
|
322
|
+
? el('span', { className: 'dshh-dup-winner', text: ` — ${t.winner}` })
|
|
323
|
+
: el('span', { className: 'dshh-shadow-tag', text: ` — ${t.shadowedBy}` }),
|
|
324
|
+
])
|
|
325
|
+
})
|
|
326
|
+
|
|
327
|
+
return el('div', { className: 'dshh-dup-group' }, [
|
|
328
|
+
el('div', { className: 'dshh-dup-title', text: `${t.duplicateGroup}: ${group.name}` }),
|
|
329
|
+
...rows,
|
|
330
|
+
])
|
|
331
|
+
})
|
|
332
|
+
|
|
333
|
+
return el('div', { className: 'dshh-dup-panel' }, [
|
|
334
|
+
el('div', { className: 'dshh-dup-heading', text: t.duplicateGroup }),
|
|
335
|
+
...groups,
|
|
336
|
+
])
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function renderTable() {
|
|
340
|
+
const rows = state.skills.map(skill => {
|
|
341
|
+
const shadowed = skill.shadowedBy !== null
|
|
342
|
+
const cells = [
|
|
343
|
+
el('td', { text: skill.name }),
|
|
344
|
+
el('td', { text: sourceLabel(t, skill.source) }),
|
|
345
|
+
el('td', { text: String(skill.rank) }),
|
|
346
|
+
el('td', {}, [
|
|
347
|
+
el('span', {
|
|
348
|
+
className: 'dshh-state',
|
|
349
|
+
'data-state': skill.fileState,
|
|
350
|
+
text: FILE_STATE_LABEL[skill.fileState] ?? skill.fileState,
|
|
351
|
+
}),
|
|
352
|
+
]),
|
|
353
|
+
el('td', { text: skill.modelInvocable ? '✓' : '—' }),
|
|
354
|
+
el('td', { text: String(skill.announcementChars) }),
|
|
355
|
+
el('td', {}, [
|
|
356
|
+
shadowed
|
|
357
|
+
? el('span', { className: 'dshh-shadow-tag', text: `${t.shadowedBy}: ${skill.shadowedBy.source}` })
|
|
358
|
+
: buildActions(skill),
|
|
359
|
+
]),
|
|
360
|
+
]
|
|
361
|
+
return el('tr', { className: shadowed ? 'dshh-shadowed' : '' }, cells)
|
|
362
|
+
})
|
|
363
|
+
|
|
364
|
+
return el('div', {}, [
|
|
365
|
+
el('table', { className: 'dshh-table' }, [
|
|
366
|
+
el('thead', {}, [
|
|
367
|
+
el('tr', {}, [
|
|
368
|
+
el('th', { text: t.colName }),
|
|
369
|
+
el('th', { text: t.colSource }),
|
|
370
|
+
el('th', { text: t.colRank }),
|
|
371
|
+
el('th', { text: t.colState }),
|
|
372
|
+
el('th', { text: t.colModel }),
|
|
373
|
+
el('th', { text: t.colChars }),
|
|
374
|
+
el('th', { text: t.colActions }),
|
|
375
|
+
]),
|
|
376
|
+
]),
|
|
377
|
+
el('tbody', {}, rows),
|
|
378
|
+
]),
|
|
379
|
+
])
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
function buildActions(skill) {
|
|
383
|
+
// provider-file / virtual 一律不渲染写控件
|
|
384
|
+
if (!skill.writable) return el('span', {})
|
|
385
|
+
|
|
386
|
+
const toggle = el('button', {
|
|
387
|
+
className: 'dshh-btn',
|
|
388
|
+
text: skill.modelInvocable ? t.actionDisable : t.actionEnable,
|
|
389
|
+
onClick: async () => {
|
|
390
|
+
try {
|
|
391
|
+
await api.setEnabled(skill.path, !skill.modelInvocable)
|
|
392
|
+
await refresh()
|
|
393
|
+
} catch (error) {
|
|
394
|
+
state.error = error.message
|
|
395
|
+
render()
|
|
396
|
+
}
|
|
397
|
+
},
|
|
398
|
+
})
|
|
399
|
+
|
|
400
|
+
const remove = el('button', {
|
|
401
|
+
className: 'dshh-btn',
|
|
402
|
+
text: t.actionDelete,
|
|
403
|
+
onClick: async () => {
|
|
404
|
+
if (!window.confirm(t.deleteConfirm)) return
|
|
405
|
+
try {
|
|
406
|
+
await api.remove(skill.path)
|
|
407
|
+
await refresh()
|
|
408
|
+
} catch (error) {
|
|
409
|
+
state.error = error.message
|
|
410
|
+
render()
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
})
|
|
414
|
+
|
|
415
|
+
return el('span', {}, [toggle, document.createTextNode(' '), remove])
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
function renderAudit() {
|
|
419
|
+
if (state.audit === null) return el('div', { className: 'dshh-empty', text: t.loading })
|
|
420
|
+
const rows = state.audit.results.map(result =>
|
|
421
|
+
el('tr', {}, [
|
|
422
|
+
el('td', { text: result.name }),
|
|
423
|
+
el('td', {}, [el('span', { className: 'dshh-verdict', 'data-v': result.verdict, text: verdictLabel(t, result.verdict) })]),
|
|
424
|
+
el('td', {
|
|
425
|
+
text: result.findings.map(f => `${f.rule} ${f.message}`).join('; ') || result.reason || '',
|
|
426
|
+
}),
|
|
427
|
+
]),
|
|
428
|
+
)
|
|
429
|
+
const totals = state.audit.totals
|
|
430
|
+
return el('div', {}, [
|
|
431
|
+
el('div', { className: 'dshh-toolbar' }, [
|
|
432
|
+
el('span', { text: `${t.auditOk}: ${totals.ok}` }),
|
|
433
|
+
el('span', { text: `${t.auditWarn}: ${totals.warn}` }),
|
|
434
|
+
el('span', { text: `${t.auditFail}: ${totals.fail}` }),
|
|
435
|
+
el('span', { text: `${t.auditSkipped}: ${totals.skipped}` }),
|
|
436
|
+
]),
|
|
437
|
+
el('table', { className: 'dshh-table' }, [
|
|
438
|
+
el('thead', {}, [el('tr', {}, [
|
|
439
|
+
el('th', { text: t.colName }),
|
|
440
|
+
el('th', { text: t.tabAudit }),
|
|
441
|
+
el('th', { text: t.colActions }),
|
|
442
|
+
])]),
|
|
443
|
+
el('tbody', {}, rows),
|
|
444
|
+
]),
|
|
445
|
+
])
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
function renderBudget() {
|
|
449
|
+
if (state.budget === null) return el('div', { className: 'dshh-empty', text: t.loading })
|
|
450
|
+
const budget = state.budget
|
|
451
|
+
return el('div', {}, [
|
|
452
|
+
el('div', { className: 'dshh-toolbar' }, [
|
|
453
|
+
el('span', { text: `${t.budgetTotal}: ${budget.total} chars` }),
|
|
454
|
+
el('span', { text: `${t.budgetAnnounced}: ${budget.announcedTotal} chars (${budget.announcedCount})` }),
|
|
455
|
+
el('span', { text: `${t.budgetSkipped}: ${budget.skippedTotal} chars (${budget.skippedCount})` }),
|
|
456
|
+
]),
|
|
457
|
+
budget.overLimit.length > 0
|
|
458
|
+
? el('ul', {}, budget.overLimit.map(row =>
|
|
459
|
+
el('li', { text: `${row.name}: ${row.chars} > ${budget.perSkillLimit} (${t.budgetOverLimit})` }),
|
|
460
|
+
))
|
|
461
|
+
: el('span', {}),
|
|
462
|
+
])
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
function render() {
|
|
466
|
+
if (destroyed) return
|
|
467
|
+
renderTabs()
|
|
468
|
+
body.replaceChildren(
|
|
469
|
+
state.error !== null ? el('div', { className: 'dshh-empty', text: state.error }) : el('span', {}),
|
|
470
|
+
tab === 'overview' ? renderOverview() : tab === 'audit' ? renderAudit() : renderBudget(),
|
|
471
|
+
)
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
async function refresh() {
|
|
475
|
+
state.error = null
|
|
476
|
+
render()
|
|
477
|
+
try {
|
|
478
|
+
if (tab === 'overview') {
|
|
479
|
+
const data = await api.list()
|
|
480
|
+
state.skills = data.skills
|
|
481
|
+
state.duplicates = data.duplicates
|
|
482
|
+
state.totals = data.totals
|
|
483
|
+
} else if (tab === 'audit') {
|
|
484
|
+
state.audit = await api.audit()
|
|
485
|
+
} else {
|
|
486
|
+
state.budget = await api.budget()
|
|
487
|
+
}
|
|
488
|
+
} catch (error) {
|
|
489
|
+
state.error = error.message
|
|
490
|
+
}
|
|
491
|
+
render()
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
root.append(tabsBar, body)
|
|
495
|
+
// star 快车道行(内联手写,_tools/star-row 阶梯;改本段无效,回 gens/inline.star-panel.js 真源)
|
|
496
|
+
try {
|
|
497
|
+
const starApi = (typeof window !== "undefined" && window.__StarPanel) || (typeof globalThis !== "undefined" && globalThis.__StarPanel)
|
|
498
|
+
if (starApi) { const n = starApi.mount(); if (n) root.append(n) }
|
|
499
|
+
} catch (e) { /* 面板挂载失败不影响主功能 */ }
|
|
500
|
+
void refresh()
|
|
501
|
+
|
|
502
|
+
return {
|
|
503
|
+
node: root,
|
|
504
|
+
destroy() {
|
|
505
|
+
destroyed = true
|
|
506
|
+
root.remove()
|
|
507
|
+
},
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
function sourceLabel(t, source) {
|
|
512
|
+
const map = {
|
|
513
|
+
'project-dsh': t.sourceProjectDsh,
|
|
514
|
+
'project-agents': t.sourceProjectAgents,
|
|
515
|
+
runtime: t.sourceRuntime,
|
|
516
|
+
custom: t.sourceCustom,
|
|
517
|
+
'user-dsh': t.sourceUserDsh,
|
|
518
|
+
'user-agents': t.sourceUserAgents,
|
|
519
|
+
bundled: t.sourceBundled,
|
|
520
|
+
}
|
|
521
|
+
return map[source] ?? source
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
function verdictLabel(t, verdict) {
|
|
525
|
+
const map = { ok: t.auditOk, warn: t.auditWarn, fail: t.auditFail, skipped: t.auditSkipped }
|
|
526
|
+
return map[verdict] ?? verdict
|
|
527
|
+
}
|