dsh-pick 0.4.4 → 0.5.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/plugin/tools.js CHANGED
@@ -49,8 +49,10 @@ function line(r) {
49
49
  r.relevance != null ? `相关度 ${r.relevance}%` : '',
50
50
  ].filter(Boolean).join(' · ')
51
51
  const desc = r.description ? `\n ${String(r.description).slice(0, 160)}` : ''
52
+ const g = r.gh
53
+ const gh = g ? `\n GitHub ★${num(g.s)} · Fork ${num(g.f)} · 未关闭 issue/PR ${num(g.i)} · 最近提交 ${g.p || '—'}${g.a ? ' · 已归档' : ''}${g.l ? ` · ${g.l}` : ''}` : ''
52
54
  const notes = r.notes && r.notes.length ? `\n ⚠ ${r.notes.join(';')}` : ''
53
- return `- ${parts}\n ${nums}${desc}${notes}`
55
+ return `- ${parts}\n ${nums}${gh}${desc}${notes}`
54
56
  }
55
57
 
56
58
  /**
@@ -72,9 +74,10 @@ export function annotate(rows, cat, have) {
72
74
  if (inst && !inst.b) notes.push('没声明 dsh.bundle,DSH 不能把它当插件安装')
73
75
  if (inst && inst.p && inst.p !== 'web') notes.push(`这是 ${inst.p} 客户端插件,装进桌面版 / 网页版可能让 DSH 起不来`)
74
76
  if (inst && inst.r) notes.push(`声明需要 DSH ${inst.r}`)
77
+ if (rec.gh && rec.gh.a) notes.push('GitHub 仓库已归档,作者不再维护')
75
78
  const same = (installedByCat.get(rec.cat || r.category) || []).filter(n => n !== r.name)
76
79
  if (same.length && !have.has(r.name)) notes.push(`你已装了同类插件:${same.join('、')},功能可能重叠`)
77
- return { ...r, installed: have.has(r.name), notes }
80
+ return { ...r, gh: rec.gh || r.gh || null, installed: have.has(r.name), notes }
78
81
  })
79
82
  }
80
83
 
@@ -124,10 +127,10 @@ const cleanNames = (names, max) =>
124
127
  */
125
128
  export async function buildToolDefinitions(deps = {}) {
126
129
  const defineTool = await loadDefineTool()
127
- const installed = () => {
128
- try { return deps.installed ? deps.installed() : new Set() } catch { return new Set() }
130
+ const installed = async () => {
131
+ try { return deps.installed ? await deps.installed() : new Set() } catch { return new Set() }
129
132
  }
130
- const header = cat => `目录数据截止 ${cat.anchor || '未知'}(npm 统计约滞后 5 天),共 ${num(cat.total)} 个插件。`
133
+ const header = cat => `目录数据截止 ${cat.anchor || '未知'}(npm 最近有数据的一天;npm 每日下载只在一天结束后汇总,常晚几天),共 ${num(cat.total)} 个插件。`
131
134
  const CATS = allCategories()
132
135
 
133
136
  return [
@@ -156,7 +159,7 @@ export async function buildToolDefinitions(deps = {}) {
156
159
  limit: clampInt(args.limit, 1, 20, 8),
157
160
  category: CATS.includes(args.category) ? args.category : null,
158
161
  })
159
- return plain({ header: header(cat), need, candidates: annotate(candidates, cat, installed()) })
162
+ return plain({ header: header(cat), need, candidates: annotate(candidates, cat, await installed()) })
160
163
  },
161
164
  }),
162
165
 
@@ -181,7 +184,7 @@ export async function buildToolDefinitions(deps = {}) {
181
184
  const names = cleanNames(args.names, 8)
182
185
  if (!names.length) throw new Error('names 里没有合法的 npm 包名')
183
186
  const rows = (await stats(cat, names)).map(withCatalogFields(cat))
184
- return plain({ header: header(cat), rows: annotate(rows, cat, installed()) })
187
+ return plain({ header: header(cat), rows: annotate(rows, cat, await installed()) })
185
188
  },
186
189
  }),
187
190
 
@@ -231,33 +234,50 @@ export async function buildToolDefinitions(deps = {}) {
231
234
  return { label: m.label, winner: vals[0][0], value: m.fmt(vals[0][1]) }
232
235
  })
233
236
  rows.sort((a, b) => ((b.deep && b.deep.score) ?? -1) - ((a.deep && a.deep.score) ?? -1))
234
- return plain({ header: header(cat), best, rows: annotate(rows, cat, installed()), missing })
237
+ return plain({ header: header(cat), best, rows: annotate(rows, cat, await installed()), missing })
235
238
  },
236
239
  }),
237
240
 
238
241
  defineTool({
239
242
  name: 'pick_rank',
240
243
  description:
241
- '插件排行榜:全部或某一类,可按周下载、日常基线、环比增速、健康度排。用户问「哪些插件最火 / 某类里谁最好」时用它。',
244
+ '插件排行榜:全部或某一类,可按周下载、日常基线、环比增速、健康度、GitHub 星标、GitHub 最近提交排。用户问「哪些插件最火 / 某类里谁最好 / 谁还在维护 / 官方有哪些插件 / 社区最近新上了什么」时用它。',
242
245
  parameters: {
243
- metric: { type: 'string', enum: ['weekly', 'baseline', 'growth', 'score'], description: '排序指标,默认 baseline(日常基线,最接近真实使用量)' },
246
+ metric: { type: 'string', enum: ['weekly', 'baseline', 'growth', 'score', 'stars', 'pushed', 'downloads', 'newest'], description: '排序指标,默认 baseline(日常基线,最接近真实使用量);stars = GitHub 星标,pushed = GitHub 最近提交' },
244
247
  category: { type: 'string', enum: CATS, description: '只看某一类(可省略)' },
245
248
  limit: { type: 'integer', description: '前几名,默认 10,最多 30' },
249
+ board: { type: 'string', enum: ['official', 'community', 'shop'], description: '看别的榜单(可省略,省略就是 npm / GitHub):official = DeepSeek 官方插件;community = awesome-dsh-plugin 社区目录;shop = dsh-plugin-shop 插件商店(第三方)。这时 metric 可填 stars / downloads / newest' },
246
250
  },
247
251
  output: {
248
252
  schema: ANY_JSON,
249
253
  render: (_a, v) => [{
250
254
  type: 'text',
251
- text: `${v.header}\n排行:${v.category || '全部'} · 按${v.metricLabel}\n${v.rows.map((r, i) => `${i + 1}.${line(r).slice(1)}`).join('\n')}\n\n${NOTE}`,
255
+ text: v.board ? `${v.header}\n${v.board}\n${v.rows.join('\n')}\n\n只引用这里的数字,不要自己推算。下载量含 CI、镜像流量,不等于用户数。` : `${v.header}\n排行:${v.category || '全部'} · 按${v.metricLabel}\n${v.rows.map((r, i) => `${i + 1}.${line(r).slice(1)}`).join('\n')}\n\n${NOTE}`,
252
256
  }],
253
257
  },
254
258
  async execute(args) {
255
259
  const cat = await loadCatalog()
256
- const LABELS = { weekly: '周下载', baseline: '日常基线', growth: '环比增速', score: '健康度' }
260
+ if (args.board) {
261
+ const limit = clampInt(args.limit, 1, 30, 10)
262
+ const board = cat.boards && cat.boards[args.board]
263
+ const TITLE = { official: 'DeepSeek 官方插件', community: 'awesome-dsh-plugin 社区目录', shop: 'dsh-plugin-shop 插件商店(第三方,非官方)' }
264
+ if (!board) return plain({ header: header(cat), board: `${TITLE[args.board]}:还没有这个榜单的数据`, rows: [] })
265
+ const key = args.board === 'official' ? 'w' : args.metric === 'downloads' ? 'dl' : args.metric === 'newest' ? 'added' : 's'
266
+ const rows = board.rows.filter(r => r[key] != null)
267
+ .sort((a, b) => (b[key] > a[key] ? 1 : b[key] < a[key] ? -1 : 0)).slice(0, limit)
268
+ return plain({
269
+ header: header(cat),
270
+ board: `${TITLE[args.board]}(共 ${num(board.total)} 个)`,
271
+ rows: rows.map((r, i) => `${i + 1}. ${r.n || r.name}` +
272
+ (r.s != null ? ` · ★${num(r.s)}` : '') + (r.dl != null ? ` · 30 天下载 ${num(r.dl)}` : '') + (r.w != null ? ` · 周下载 ${num(r.w)}` : '') +
273
+ (r.added ? ` · 收录 ${r.added}` : '') + (r.n ? '' : ` · 只在 GitHub(${r.repo})`) + (r.d ? `\n ${r.d}` : '')),
274
+ })
275
+ }
276
+ const LABELS = { weekly: '周下载', baseline: '日常基线', growth: '环比增速', score: '健康度', stars: 'GitHub 星标', pushed: 'GitHub 最近提交' }
257
277
  const metric = LABELS[args.metric] ? args.metric : 'baseline'
258
278
  const category = CATS.includes(args.category) ? args.category : null
259
279
  const rows = rank(cat, { metric, category, limit: clampInt(args.limit, 1, 30, 10) }).map(fromRec)
260
- return plain({ header: header(cat), metric, metricLabel: LABELS[metric], category, rows: annotate(rows, cat, installed()) })
280
+ return plain({ header: header(cat), metric, metricLabel: LABELS[metric], category, rows: annotate(rows, cat, await installed()) })
261
281
  },
262
282
  }),
263
283
  ]
package/web/panel.html CHANGED
@@ -107,6 +107,14 @@ h1{margin:0;font-size:19px;font-weight:650;letter-spacing:-.2px}
107
107
  .ai:hover{border-color:color-mix(in srgb,var(--ai) 62%,transparent);
108
108
  background:linear-gradient(135deg,color-mix(in srgb,var(--accent) 22%,transparent),color-mix(in srgb,var(--ai) 28%,transparent))}
109
109
  .section h2 .ai{margin-left:auto;font-weight:650}
110
+ /* 排行榜:npm 榜 / GitHub 榜 */
111
+ .board{display:flex;flex-wrap:wrap;width:fit-content;max-width:100%;gap:2px;background:var(--soft);border-radius:9px;padding:3px;margin:8px 0 6px}
112
+ .board button{appearance:none;border:none;background:transparent;font-family:inherit;font-size:12.5px;font-weight:600;
113
+ color:var(--t3);padding:6px 14px;border-radius:6px;cursor:pointer}
114
+ .board button.on{background:var(--panel);color:var(--text);box-shadow:0 1px 2px var(--shadow)}
115
+ table.rank td.nm .sub{font-size:10.5px;color:var(--t3);font-weight:400;margin-top:2px}
116
+ table.rank td.nm .desc{min-width:150px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
117
+ table.rank td .arch{font-size:10.5px;color:var(--t3);background:var(--soft);border-radius:5px;padding:1px 6px}
110
118
  .section h2 .h2-acts{margin-left:auto;display:inline-flex;gap:8px;align-items:center}
111
119
  .section h2 .h2-acts .ai{margin-left:0}
112
120
  .btn.sm{font-size:11.5px;padding:0 10px;height:24px;border-radius:7px}
@@ -205,7 +213,14 @@ table.rank td.mt{line-height:1.35}
205
213
  table.rank td.mt .sub{font-size:10.5px;color:var(--t3)}
206
214
  table.rank td.mt .stale{color:var(--warn-text);font-weight:600}
207
215
  /* 只有图标的外链(排行榜) */
208
- table.rank td.lks{white-space:nowrap;width:1%}
216
+ table.rank td.lks{white-space:nowrap;width:1%;position:sticky;right:0;background:var(--panel);box-shadow:-6px 0 6px -6px var(--shadow)}
217
+ table.rank tbody tr:hover td.lks{background:var(--panel)}
218
+ /* 彩色 + 号:一键加入我的监控;已加入显示 ✓,再点取消 */
219
+ .wadd{appearance:none;display:inline-flex;align-items:center;justify-content:center;width:24px;height:22px;padding:0;margin-right:4px;
220
+ border:none;border-radius:6px;cursor:pointer;font-family:inherit;font-size:15px;font-weight:700;line-height:1;color:#fff;vertical-align:top;
221
+ background:linear-gradient(135deg,#ff7a45,#f5317f 55%,#7c4dff)}
222
+ .wadd:hover{filter:brightness(1.1)}
223
+ .wadd.on{background:var(--ok-bg);color:var(--ok-text);font-size:12px}
209
224
  .lk.ic{padding:0;width:24px;height:22px;justify-content:center;gap:0}
210
225
  .lk.ic + .lk.ic{margin-left:4px}
211
226
  td.up{color:var(--ok);font-weight:600}
@@ -213,13 +228,19 @@ td.down{color:var(--bad);font-weight:600}
213
228
  .catpill{font-size:10.5px;background:var(--soft);color:var(--t2);border-radius:20px;padding:2px 8px;white-space:nowrap}
214
229
 
215
230
  /* ---------- 监控 ---------- */
216
- .mon{display:flex;align-items:center;gap:12px;padding:11px 0;border-bottom:1px solid var(--soft);flex-wrap:wrap}
231
+ .mon{border-bottom:1px solid var(--soft)}
217
232
  .mon:last-child{border-bottom:none}
218
- .mon .nm{font-size:13px;font-weight:650;flex:1;min-width:150px}
233
+ .mon .mhead{display:flex;align-items:center;gap:6px;padding:8px 0;cursor:pointer}
234
+ .mon .mhead:hover .nm{color:var(--accent)}
235
+ .mon .mtoggle{appearance:none;border:none;background:none;color:var(--t3);cursor:pointer;font-size:11px;width:16px;padding:0;flex:none}
236
+ .mon .nm{font-size:13px;font-weight:650;flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
237
+ .mon .ver{color:var(--t3);font-weight:400;font-size:11px}
238
+ .mon .mdetail{display:flex;flex-wrap:wrap;align-items:center;gap:5px 12px;padding:0 0 10px 22px;font-size:12px;color:var(--t2)}
239
+ .mon .mdetail b{color:var(--text)}
219
240
  .mon .mrank{font-size:10.5px;color:var(--t3);font-variant-numeric:tabular-nums}
220
241
  .mon .mrank b{color:var(--t2);font-weight:700}
221
- .mon .mlinks{display:flex;gap:5px}
222
- .mon .x{appearance:none;border:none;background:none;color:var(--t3);cursor:pointer;font-size:16px;padding:0 4px}
242
+ .mon .mlinks{display:flex;flex:none}
243
+ .mon .x{appearance:none;border:none;background:none;color:var(--t3);cursor:pointer;font-size:16px;line-height:1;padding:0 2px 0 4px;flex:none}
223
244
  .mon .x:hover{color:var(--bad)}
224
245
 
225
246
  .foot{font-size:11.5px;color:var(--t3);line-height:1.9;margin-top:6px}
@@ -353,21 +374,33 @@ td.down{color:var(--bad);font-weight:600}
353
374
  <div id="tab-rank" class="hidden">
354
375
  <div class="section">
355
376
  <h2>排行榜</h2>
356
- <p class="cap">换一种方式发现:按去噪后的指标看整个生态。</p>
377
+ <div class="board" id="rankBoard">
378
+ <button data-b="npm" class="on">npm 榜</button>
379
+ <button data-b="gh">GitHub 榜</button>
380
+ <button data-b="official">官方榜</button>
381
+ <button data-b="community">社区榜</button>
382
+ <button data-b="shop">商店榜</button>
383
+ </div>
384
+ <p class="cap" id="rankCap"></p>
357
385
  <div class="filters" id="rankFilters">
358
- <button class="chip on" data-m="base">日常基线</button>
359
- <button class="chip" data-m="w">周下载</button>
360
- <button class="chip" data-m="growth">增速最快</button>
361
- <button class="chip" data-m="s">健康度</button>
386
+ <button class="chip on" data-board="npm" data-m="base">日常基线</button>
387
+ <button class="chip" data-board="npm" data-m="w">周下载</button>
388
+ <button class="chip" data-board="npm" data-m="growth">增速最快</button>
389
+ <button class="chip" data-board="npm" data-m="s">健康度</button>
390
+ <button class="chip on hidden" data-board="gh" data-m="gs">星标</button>
391
+ <button class="chip hidden" data-board="gh" data-m="gp">最近提交</button>
392
+ <button class="chip hidden" data-board="gh" data-m="gf">Fork</button>
393
+ <button class="chip hidden" data-board="gh" data-m="gi">讨论最多</button>
394
+ <button class="chip on hidden" data-board="community" data-m="s">星标</button>
395
+ <button class="chip hidden" data-board="community" data-m="dl">下载</button>
396
+ <button class="chip hidden" data-board="community" data-m="added">新上架</button>
397
+ <button class="chip on hidden" data-board="shop" data-m="s">星标</button>
398
+ <button class="chip hidden" data-board="shop" data-m="added">新上架</button>
362
399
  <select id="rankCat"></select>
363
400
  </div>
364
401
  <div class="tblwrap">
365
402
  <table class="rank">
366
- <thead><tr>
367
- <th style="width:44px">#</th><th>插件</th><th>分类</th>
368
- <th class="r">基线</th><th class="r">周下载</th><th class="r">环比</th>
369
- <th class="r" title="最近一次发版 · 平均几天发一个版本">更新</th><th></th>
370
- </tr></thead>
403
+ <thead id="rankHead"></thead>
371
404
  <tbody id="rankBody"></tbody>
372
405
  </table>
373
406
  </div>
@@ -378,7 +411,7 @@ td.down{color:var(--bad);font-weight:600}
378
411
  <div id="tab-watch" class="hidden">
379
412
  <div class="section">
380
413
  <h2>我的监控<span class="h2-acts"><button class="btn ghost sm" id="btnWatchRefresh" title="去 npm 实时查这些插件的最新数据">↻ 刷新</button><button class="ai hidden" id="aiWatch" title="把监控列表发到对话里,让 AI 看看谁在涨、谁停更了">+AI 看看近况</button></span></h2>
381
- <p class="cap"><span id="watchAsOf"></span>监控列表存在浏览器本地,不上传。点「刷新」去 npm 查最新:版本号、发版时间是即时的;下载量 npm 大约一天更新一次,日常基线和环比按 npm 下载统计算(滞后约 5 天)。</p>
414
+ <p class="cap"><span id="watchAsOf"></span>监控列表存在浏览器本地,不上传。点「刷新」去 npm 和 GitHub 查最新:版本号、发版时间、GitHub 数据是即时的;周下载 npm 大约一天更新一次;日常基线和环比按 npm 已经出数据的最近 30 天算(npm 只在一天结束后才汇总,最近还常晚几天)。</p>
382
415
  <div id="watchList"></div>
383
416
  </div>
384
417
  <div class="section">