dsh-pick 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/README.md +13 -0
- package/lib/engine.js +13 -1
- package/lib/market-index.js +131 -0
- package/lib/market-source.js +68 -0
- package/package.json +6 -2
- package/plugin/client.js +26 -0
- package/plugin/index.js +30 -0
package/README.md
CHANGED
|
@@ -98,6 +98,17 @@ dsh plugin --profile web add dsh-pick
|
|
|
98
98
|
|
|
99
99
|
社区榜、商店榜每个指标只保留前 100 名。AI 工具 `pick_rank` 加 `board` 参数也能查这三个榜。
|
|
100
100
|
|
|
101
|
+
**DSH「插件 → 发现」的插件索引源**:dsh-pick 每天生成一份 DSH 官方格式(format 1)的插件索引:
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
https://cdn.jsdelivr.net/gh/AIcivilization/dsh-pick@catalog/index.json
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
- 在 DSH「插件」页打开实验功能「自定义插件索引」后,dsh-pick 启动时会自动把它加进「发现」的索引源,只加一次;你在「发现」里删掉后,不会再自动加回来。设置页有「添加到『发现』」按钮。
|
|
108
|
+
- 按官方规定,只收声明了 `dsh.bundle` 和顶层 `engines.dsh` 的插件(目前约 280 个,长尾插件大多没写 `engines.dsh`)。每条都先过官方校验器 `@deepseek-ai/dsh-plugin-market-index`,不合格的剔除,整份再校验一次。
|
|
109
|
+
- 带分类,以及「周下载 / 日常基线 / GitHub 星标 / 健康度」四个排序项。
|
|
110
|
+
- 插件作者想被收录:在 `package.json` 里写上 `"engines": { "dsh": "..." }`。
|
|
111
|
+
|
|
101
112
|
**数据每天自动更新**:GitHub Actions 每天重建一次目录,推到本仓库的 `catalog` 分支。插件启动时、之后每 6 小时检查一次,有新的就下载到 `~/.dsh/dsh-pick/`(先走 jsDelivr,再走 raw.githubusercontent.com)。取不到就用包里自带的那份,不影响使用;设置页会写明当前用的是哪份。
|
|
102
113
|
|
|
103
114
|
### 作为命令行 / 独立网页
|
|
@@ -143,6 +154,8 @@ dsh-pick/
|
|
|
143
154
|
│ ├── remote.js 每日更新的目录:检查、下载、校验、换上
|
|
144
155
|
│ ├── github.js 插件仓库的 GitHub 数据(构建时批量查、刷新时实时查)
|
|
145
156
|
│ ├── boards.js 官方榜、社区榜、商店榜的数据(构建时抓,只解析不执行)
|
|
157
|
+
│ ├── market-index.js 生成 DSH「发现」页用的插件索引(index.json)
|
|
158
|
+
│ ├── market-source.js 把插件索引加进 DSH「发现」的索引源
|
|
146
159
|
│ ├── classify.js 13 类 + 其他,关键词加权分类
|
|
147
160
|
│ ├── metrics.js 去噪指标:基线 / 增速 / 节奏 / 新鲜度 / 健康度
|
|
148
161
|
│ ├── words.js 需求 → 搜索词(同义词 + 中文二元切分),CLI 与面板共用
|
package/lib/engine.js
CHANGED
|
@@ -150,6 +150,8 @@ export async function buildCatalog({ deep = 200, max = 2250, pages = 9, deepOnly
|
|
|
150
150
|
w: (o.downloads && o.downloads.weekly) || 0,
|
|
151
151
|
m: (o.downloads && o.downloads.monthly) || 0,
|
|
152
152
|
pub: (pkg.date || '').slice(0, 10),
|
|
153
|
+
// 最新版的发布时间(完整的 ISO 时间):插件索引的 publishTimestamp 要它
|
|
154
|
+
t: /^\d{4}-\d{2}-\d{2}T/.test(pkg.date || '') ? pkg.date : undefined,
|
|
153
155
|
// search API 直接给 links,不额外花请求
|
|
154
156
|
home: (pkg.links && pkg.links.homepage) || '',
|
|
155
157
|
repo: (pkg.links && pkg.links.repository) || '',
|
|
@@ -423,6 +425,8 @@ export function slimRecord(rec) {
|
|
|
423
425
|
if (rec.inst) {
|
|
424
426
|
if (rec.inst.p == null) delete rec.inst.p
|
|
425
427
|
if (rec.inst.r == null) delete rec.inst.r
|
|
428
|
+
if (rec.inst.e == null) delete rec.inst.e
|
|
429
|
+
if (rec.inst.a == null) delete rec.inst.a
|
|
426
430
|
}
|
|
427
431
|
if (rec.gh) {
|
|
428
432
|
if (!rec.gh.a) delete rec.gh.a
|
|
@@ -446,7 +450,15 @@ export function installFacts(manifest = {}) {
|
|
|
446
450
|
if (/^@deepseek-ai\/dsh(-|$)/.test(name) && typeof range === 'string' && range.trim()) reqs.push(range.trim())
|
|
447
451
|
}
|
|
448
452
|
const platform = dsh.client && typeof dsh.client.platform === 'string' ? dsh.client.platform : null
|
|
449
|
-
|
|
453
|
+
// e:只认顶层 engines.dsh,原样保留——DSH 插件索引(index.json)只收声明了它的版本,而且要求一字不改
|
|
454
|
+
const e = manifest.engines && typeof manifest.engines.dsh === 'string' && manifest.engines.dsh.trim() ? manifest.engines.dsh : null
|
|
455
|
+
// a:作者名(npm 的 author 可以是对象,也可以是 "名字 <邮箱> (网址)" 这种简写),只留名字
|
|
456
|
+
const author = manifest.author
|
|
457
|
+
const name = typeof author === 'string' ? author.replace(/\s*[<(].*$/, '') : author && typeof author.name === 'string' ? author.name : ''
|
|
458
|
+
return {
|
|
459
|
+
b: Boolean(dsh.bundle), p: platform, r: reqs.length ? [...new Set(reqs)].join(' ∩ ') : null,
|
|
460
|
+
e, a: name.trim() || null,
|
|
461
|
+
}
|
|
450
462
|
}
|
|
451
463
|
|
|
452
464
|
/* ---------------------------------------------------------------- 查询 */
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// lib/market-index.js — 把目录变成 DSH「插件 → 发现」能读的插件索引(index.json,format 1)
|
|
2
|
+
//
|
|
3
|
+
// DSH 的「发现」页读用户添加的插件索引源,格式由官方定义(deepseek-harness 仓库
|
|
4
|
+
// .agents/notes/implemented/feature/2026-10-02-plugin-market-index-format.md),
|
|
5
|
+
// 官方校验器是 @deepseek-ai/dsh-plugin-market-index。要点:
|
|
6
|
+
// - 只收声明了 dsh.bundle 和顶层 engines.dsh 的插件,engines.dsh 原样照抄(官方的硬性要求)
|
|
7
|
+
// - 每个版本要有发布时间(秒)、来源(这里都是 npm);dist-tags 只能指向列出来的版本
|
|
8
|
+
// - 读取方遇到任何一处不合规就拒收整份索引——所以每条先单独过校验,不合格的剔除并记下原因
|
|
9
|
+
//
|
|
10
|
+
// 每日构建时生成,和目录一起推到 catalog 分支;插件启动时把 INDEX_URL 加进「发现」(plugin/index.js)。
|
|
11
|
+
|
|
12
|
+
import { parseRepo } from './github.js'
|
|
13
|
+
|
|
14
|
+
export const INDEX_URL = 'https://cdn.jsdelivr.net/gh/AIcivilization/dsh-pick@catalog/index.json'
|
|
15
|
+
|
|
16
|
+
/** 目录的分类 → 索引里的分类 id(索引要求 id 稳定,不能用会变的中文名) */
|
|
17
|
+
const CATEGORY_IDS = {
|
|
18
|
+
'界面与主题': ['ui', 'UI & themes'],
|
|
19
|
+
'记忆与上下文': ['memory', 'Memory & context'],
|
|
20
|
+
'模型与网关': ['models', 'Models & gateways'],
|
|
21
|
+
'搜索与检索': ['search', 'Search & retrieval'],
|
|
22
|
+
'用量与计费': ['usage', 'Usage & billing'],
|
|
23
|
+
'自动化与多智能体': ['automation', 'Automation & agents'],
|
|
24
|
+
'远程与部署': ['remote', 'Remote & deploy'],
|
|
25
|
+
'文档与办公': ['docs', 'Docs & office'],
|
|
26
|
+
'媒体与生成': ['media', 'Media & generation'],
|
|
27
|
+
'集成与连接': ['integrations', 'Integrations'],
|
|
28
|
+
'插件市场与工具链': ['tooling', 'Markets & tooling'],
|
|
29
|
+
'安全与权限': ['security', 'Security & permissions'],
|
|
30
|
+
'代码与开发': ['code', 'Code & development'],
|
|
31
|
+
'其他': ['other', 'Other'],
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const SORT_KEYS = {
|
|
35
|
+
downloads: { title: { en: 'Weekly downloads', zh: '周下载' }, order: 'desc' },
|
|
36
|
+
baseline: { title: { en: 'Daily baseline (denoised)', zh: '日常基线(去噪)' }, order: 'desc' },
|
|
37
|
+
stars: { title: { en: 'GitHub stars', zh: 'GitHub 星标' }, order: 'desc' },
|
|
38
|
+
health: { title: { en: 'Health score', zh: '健康度' }, order: 'desc' },
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const nonBlank = v => typeof v === 'string' && /\S/.test(v)
|
|
42
|
+
const finite = v => (Number.isFinite(v) ? v : undefined)
|
|
43
|
+
|
|
44
|
+
/** 索引的根:标题、说明、分类与排序项的声明 */
|
|
45
|
+
export function indexRoot() {
|
|
46
|
+
const categories = {}
|
|
47
|
+
for (const [zh, [id, en]] of Object.entries(CATEGORY_IDS)) categories[id] = { title: { en, zh } }
|
|
48
|
+
return {
|
|
49
|
+
format: 1,
|
|
50
|
+
title: { en: 'dsh-pick · DSH plugin picks', zh: 'dsh-pick 选插件' },
|
|
51
|
+
description: {
|
|
52
|
+
en: 'Every npm DSH plugin that declares engines.dsh and a bundle, sorted by weekly downloads, with denoised download metrics and GitHub stars. Rebuilt daily; a community index, not an official DeepSeek one.',
|
|
53
|
+
zh: '所有声明了 engines.dsh 和 bundle 的 npm DSH 插件,按周下载排,带去噪后的下载指标和 GitHub 星标。每天重建;社区索引,不是 DeepSeek 官方的。',
|
|
54
|
+
},
|
|
55
|
+
metadata: { categories, sortKeys: SORT_KEYS },
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 目录里的一个包 → 索引里的一个插件;不够格返回 { skip: 原因 }
|
|
61
|
+
* @param {object} rec 目录记录(归一化前后都行)
|
|
62
|
+
* @param {string} [publishedAt] 最新版的发布时间(ISO);不给就用 rec.t
|
|
63
|
+
*/
|
|
64
|
+
export function indexEntry(rec, publishedAt) {
|
|
65
|
+
const inst = rec.inst || {}
|
|
66
|
+
if (!inst.b) return { skip: '没声明 dsh.bundle' }
|
|
67
|
+
if (!nonBlank(inst.e)) return { skip: '没声明 engines.dsh' }
|
|
68
|
+
if (!nonBlank(rec.v)) return { skip: '没有版本号' }
|
|
69
|
+
const ms = Date.parse(publishedAt || rec.t || '')
|
|
70
|
+
if (!Number.isFinite(ms)) return { skip: '没有发布时间' }
|
|
71
|
+
|
|
72
|
+
const entry = { name: rec.n }
|
|
73
|
+
if (nonBlank(rec.d)) entry.description = rec.d.trim()
|
|
74
|
+
if (nonBlank(inst.a)) entry.author = inst.a.trim()
|
|
75
|
+
if (/^https?:\/\/[^\s?#]+$/.test(rec.home || '')) entry.homepage = rec.home
|
|
76
|
+
const repo = parseRepo(rec.repo) || parseRepo(rec.home)
|
|
77
|
+
if (repo) entry.repository = { url: `https://github.com/${repo}` }
|
|
78
|
+
|
|
79
|
+
const sortKeys = {}
|
|
80
|
+
const d = rec.deep
|
|
81
|
+
if (finite(rec.w) !== undefined) sortKeys.downloads = rec.w
|
|
82
|
+
if (d && finite(d.base ?? d.baseline) !== undefined) sortKeys.baseline = d.base ?? d.baseline
|
|
83
|
+
if (rec.gh && finite(rec.gh.s) !== undefined) sortKeys.stars = rec.gh.s
|
|
84
|
+
if (d && finite(d.s ?? d.score) !== undefined) sortKeys.health = d.s ?? d.score
|
|
85
|
+
entry.metadata = {
|
|
86
|
+
category: (CATEGORY_IDS[rec.cat] || CATEGORY_IDS['其他'])[0],
|
|
87
|
+
keywords: (rec.kw || []).filter(nonBlank),
|
|
88
|
+
sortKeys,
|
|
89
|
+
}
|
|
90
|
+
entry['dist-tags'] = { latest: rec.v }
|
|
91
|
+
entry.versions = [{
|
|
92
|
+
version: rec.v,
|
|
93
|
+
publishTimestamp: Math.floor(ms / 1000),
|
|
94
|
+
source: { type: 'npm' },
|
|
95
|
+
engines: { dsh: inst.e },
|
|
96
|
+
}]
|
|
97
|
+
return { entry }
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* 生成整份索引
|
|
102
|
+
* @param {object} catalog 目录
|
|
103
|
+
* @param {object} opt
|
|
104
|
+
* @param {(value: object, url: string) => unknown} opt.parse 官方校验器的 parseMarketIndex:不合规就抛错
|
|
105
|
+
* @param {Record<string, string>} [opt.times] 包名 → 最新版发布时间(目录里没有 t 的,构建脚本另外查)
|
|
106
|
+
* @returns {{ index: object, skipped: Record<string, number>, rejected: {name: string, reason: string}[] }}
|
|
107
|
+
*/
|
|
108
|
+
export function buildMarketIndex(catalog, { parse, times = {} }) {
|
|
109
|
+
const root = indexRoot()
|
|
110
|
+
const skipped = {}
|
|
111
|
+
const rejected = []
|
|
112
|
+
const plugins = []
|
|
113
|
+
const recs = Object.values(catalog.packages || {}).sort((a, b) => (b.w || 0) - (a.w || 0))
|
|
114
|
+
for (const rec of recs) {
|
|
115
|
+
const { entry, skip } = indexEntry(rec, times[rec.n])
|
|
116
|
+
if (skip) {
|
|
117
|
+
skipped[skip] = (skipped[skip] || 0) + 1
|
|
118
|
+
continue
|
|
119
|
+
}
|
|
120
|
+
// 读取方见到一处不合规就拒收整份:每条先单独校验,不合格的剔掉、记下原因
|
|
121
|
+
try {
|
|
122
|
+
parse({ ...root, plugins: [entry] }, INDEX_URL)
|
|
123
|
+
plugins.push(entry)
|
|
124
|
+
} catch (e) {
|
|
125
|
+
rejected.push({ name: rec.n, reason: `${e.path || ''} ${e.reason || e.message}`.trim() })
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const index = { ...root, plugins }
|
|
129
|
+
parse(index, INDEX_URL) // 整份再校验一次(比如重名),不过就让构建失败
|
|
130
|
+
return { index, skipped, rejected }
|
|
131
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// lib/market-source.js — 把 dsh-pick 的插件索引加进 DSH「插件 → 发现」的索引源
|
|
2
|
+
//
|
|
3
|
+
// 「发现」页由 DSH 的 pluginMarket 服务读用户配置的索引源(官方的实验功能「自定义插件索引」)。
|
|
4
|
+
// 它提供 listIndexes() 和 setIndexes(urls):setIndexes 用整份列表替换,所以要带上已有的再加我们的。
|
|
5
|
+
//
|
|
6
|
+
// 规矩:装上后自动加一次;用户之后在「发现」里删掉了,就尊重他,不再自动加回来
|
|
7
|
+
// (本机 ~/.dsh/dsh-pick/market.json 记着加过没有)。设置页的按钮是用户明确要加,不受这条限制。
|
|
8
|
+
|
|
9
|
+
import { readFile, writeFile, mkdir } from 'node:fs/promises'
|
|
10
|
+
import { join, dirname } from 'node:path'
|
|
11
|
+
import { dshHome } from './engine.js'
|
|
12
|
+
import { INDEX_URL } from './market-index.js'
|
|
13
|
+
|
|
14
|
+
const stateFile = env => join(dshHome(env), 'dsh-pick', 'market.json')
|
|
15
|
+
|
|
16
|
+
async function readState(env) {
|
|
17
|
+
try { return JSON.parse(await readFile(stateFile(env), 'utf8')) } catch { return {} }
|
|
18
|
+
}
|
|
19
|
+
async function writeState(env, state) {
|
|
20
|
+
await mkdir(dirname(stateFile(env)), { recursive: true })
|
|
21
|
+
await writeFile(stateFile(env), JSON.stringify(state))
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** listIndexes 的答复里的地址(每项可能是字符串,也可能是 { url, ... }) */
|
|
25
|
+
async function configured(market) {
|
|
26
|
+
const list = await market.listIndexes()
|
|
27
|
+
return (Array.isArray(list) ? list : []).map(x => (typeof x === 'string' ? x : x && x.url)).filter(Boolean)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const usable = market => Boolean(market && typeof market.listIndexes === 'function' && typeof market.setIndexes === 'function')
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 现在的状态(设置页显示用)
|
|
34
|
+
* @returns {Promise<{available: boolean, added: boolean, url: string}>}
|
|
35
|
+
*/
|
|
36
|
+
export async function marketStatus(market) {
|
|
37
|
+
if (!usable(market)) return { available: false, added: false, url: INDEX_URL }
|
|
38
|
+
try {
|
|
39
|
+
return { available: true, added: (await configured(market)).includes(INDEX_URL), url: INDEX_URL }
|
|
40
|
+
} catch {
|
|
41
|
+
return { available: false, added: false, url: INDEX_URL }
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 把索引源加进去
|
|
47
|
+
* @param {object} market DSH 的 pluginMarket 服务
|
|
48
|
+
* @param {object} [opt]
|
|
49
|
+
* @param {boolean} [opt.force] 用户在设置页点的:不管以前加过没有都加
|
|
50
|
+
* @returns {Promise<{status: 'added'|'present'|'skipped'|'unavailable'|'failed', message?: string}>}
|
|
51
|
+
*/
|
|
52
|
+
export async function ensureMarketSource(market, { force = false, env = process.env } = {}) {
|
|
53
|
+
if (!usable(market)) return { status: 'unavailable' }
|
|
54
|
+
try {
|
|
55
|
+
const urls = await configured(market)
|
|
56
|
+
if (urls.includes(INDEX_URL)) {
|
|
57
|
+
await writeState(env, { added: true, at: new Date().toISOString() })
|
|
58
|
+
return { status: 'present' }
|
|
59
|
+
}
|
|
60
|
+
// 自动加过、现在又不在了:是用户自己删的
|
|
61
|
+
if (!force && (await readState(env)).added) return { status: 'skipped' }
|
|
62
|
+
await market.setIndexes([...urls, INDEX_URL])
|
|
63
|
+
await writeState(env, { added: true, at: new Date().toISOString() })
|
|
64
|
+
return { status: 'added' }
|
|
65
|
+
} catch (e) {
|
|
66
|
+
return { status: 'failed', message: e && e.message ? e.message : String(e) }
|
|
67
|
+
}
|
|
68
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-pick",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "帮你在 DSH 生态里选对插件:说需求 → 找候选 → 多维比较 → 出结论。下载量是证据,AI 是推理。",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -58,6 +58,10 @@
|
|
|
58
58
|
],
|
|
59
59
|
"license": "MIT",
|
|
60
60
|
"engines": {
|
|
61
|
-
"node": ">=20"
|
|
61
|
+
"node": ">=20",
|
|
62
|
+
"dsh": ">=0.2.0-0"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@deepseek-ai/dsh-plugin-market-index": "0.2.1-alpha.4"
|
|
62
66
|
}
|
|
63
67
|
}
|
package/plugin/client.js
CHANGED
|
@@ -274,10 +274,13 @@ window.__ModuleLoader__.load({
|
|
|
274
274
|
function SettingsSection() {
|
|
275
275
|
const [meta, setMeta] = useState(null)
|
|
276
276
|
const [openMsg, setOpenMsg] = useState('')
|
|
277
|
+
const [market, setMarket] = useState(null) // { available, added, url }
|
|
278
|
+
const [marketMsg, setMarketMsg] = useState('')
|
|
277
279
|
|
|
278
280
|
useEffect(() => {
|
|
279
281
|
let alive = true
|
|
280
282
|
api('meta').then(j => { if (alive) setMeta(j) }).catch(() => {})
|
|
283
|
+
api('market').then(j => { if (alive) setMarket(j) }).catch(() => {})
|
|
281
284
|
return () => { alive = false }
|
|
282
285
|
}, [])
|
|
283
286
|
|
|
@@ -313,6 +316,29 @@ window.__ModuleLoader__.load({
|
|
|
313
316
|
: null,
|
|
314
317
|
),
|
|
315
318
|
|
|
319
|
+
h(Section, { title: L('插件索引源(DSH「插件 → 发现」)', 'Plugin index (DSH Plugins → Discover)') },
|
|
320
|
+
h('div', null, L(
|
|
321
|
+
'dsh-pick 每天生成一份 DSH 官方格式的插件索引。加进「发现」后,可以在 DSH 的插件页里直接浏览、安装其中的插件。只收声明了 engines.dsh 的插件(官方要求)。',
|
|
322
|
+
'dsh-pick publishes a daily plugin index in the official DSH format. Add it to Discover to browse and install its plugins on the DSH Plugins page. Only plugins that declare engines.dsh are listed (an official requirement).')),
|
|
323
|
+
!market ? null
|
|
324
|
+
: market.added
|
|
325
|
+
? h('div', { style: { marginTop: 8, color: C.text } }, L('✓ 已在「发现」的索引源里', '✓ Already in Discover'))
|
|
326
|
+
: h('div', { style: { display: 'flex', alignItems: 'center', gap: 8, marginTop: 8, flexWrap: 'wrap' } },
|
|
327
|
+
h(Btn, {
|
|
328
|
+
onClick: async () => {
|
|
329
|
+
setMarketMsg('')
|
|
330
|
+
try {
|
|
331
|
+
const j = await api('market', 'POST')
|
|
332
|
+
if (j.ok) setMarket({ ...market, available: true, added: true })
|
|
333
|
+
else setMarketMsg(j.message || L('没加上', 'Not added'))
|
|
334
|
+
} catch (e) { setMarketMsg(e.message) }
|
|
335
|
+
},
|
|
336
|
+
}, L('添加到「发现」', 'Add to Discover')),
|
|
337
|
+
!market.available ? h('span', { style: { fontSize: 12, color: C.faint } }, L('需要先在 DSH「插件」页打开实验功能「自定义插件索引」', 'Turn on the experimental "Custom plugin indexes" on the DSH Plugins page first')) : null,
|
|
338
|
+
marketMsg ? h('span', { style: { fontSize: 12, color: C.danger } }, marketMsg) : null),
|
|
339
|
+
market ? h(CommandLine, { command: market.url }) : null,
|
|
340
|
+
),
|
|
341
|
+
|
|
316
342
|
h(Section, { title: L('数据口径', 'About the data') },
|
|
317
343
|
h('div', null, catalog),
|
|
318
344
|
meta && meta.total ? h('div', { style: { marginTop: 4 } }, meta.source === 'remote'
|
package/plugin/index.js
CHANGED
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
// POST /api-dsh-pick/uninstall 从 DSH 卸载本插件
|
|
16
16
|
// GET /api-dsh-pick/installed DSH 里已装的插件名(面板的「已安装」标记)
|
|
17
17
|
// GET /api-dsh-pick/live?names=a,b 实时查 npm(「我的监控」的刷新,最多 30 个)
|
|
18
|
+
// GET /api-dsh-pick/market dsh-pick 的插件索引在不在 DSH「插件 → 发现」的索引源里
|
|
19
|
+
// POST /api-dsh-pick/market 把它加进去(设置页的按钮)
|
|
20
|
+
//
|
|
21
|
+
// 启动时还会自动把插件索引加进「发现」一次(lib/market-source.js),用户删掉后不再自动加。
|
|
18
22
|
// POST /api-dsh-pick/install 安装目录里的某个插件 { name }
|
|
19
23
|
//
|
|
20
24
|
// 另外注册 4 个 AI 工具(plugin/tools.js):对话里的 AI 能自己查目录、比较插件。
|
|
@@ -27,6 +31,7 @@ import { join } from 'node:path'
|
|
|
27
31
|
import { registerTools } from './tools.js'
|
|
28
32
|
import { loadCatalog, liveStats, parseWatchNames } from '../lib/engine.js'
|
|
29
33
|
import { refreshCatalog, remoteState, CHECK_EVERY_MS } from '../lib/remote.js'
|
|
34
|
+
import { ensureMarketSource, marketStatus } from '../lib/market-source.js'
|
|
30
35
|
|
|
31
36
|
/** 本包根目录:插件就是完整的 dsh-pick 包 */
|
|
32
37
|
const PKG_ROOT = fileURLToPath(new URL('..', import.meta.url))
|
|
@@ -254,6 +259,15 @@ export function apply(ctx) {
|
|
|
254
259
|
profile = ctx.get && ctx.get('profileContext') && ctx.get('profileContext').name
|
|
255
260
|
} catch { profile = undefined }
|
|
256
261
|
|
|
262
|
+
// DSH「插件 → 发现」的索引源(实验功能「自定义插件索引」打开时才有这个服务):自动加一次 dsh-pick 的插件索引
|
|
263
|
+
let pluginMarket
|
|
264
|
+
ctx.inject(['pluginMarket'], (mCtx) => {
|
|
265
|
+
pluginMarket = mCtx.pluginMarket || (mCtx.get && mCtx.get('pluginMarket'))
|
|
266
|
+
ensureMarketSource(pluginMarket)
|
|
267
|
+
.then(r => { if (r.status === 'added') console.info('[dsh-pick] 已把插件索引加进「插件 → 发现」') })
|
|
268
|
+
.catch(() => {})
|
|
269
|
+
})
|
|
270
|
+
|
|
257
271
|
// 每日更新的目录:启动时查一次,之后每 6 小时查一次(查不到就继续用手上的)
|
|
258
272
|
const refresh = () => refreshCatalog().catch(() => {})
|
|
259
273
|
const startTimer = setTimeout(refresh, 5000) // 别和 DSH 启动抢网络
|
|
@@ -406,6 +420,22 @@ export function apply(ctx) {
|
|
|
406
420
|
},
|
|
407
421
|
}))
|
|
408
422
|
|
|
423
|
+
// 「发现」的索引源:查状态 / 用户点按钮加进去
|
|
424
|
+
track(ws.register({
|
|
425
|
+
kind: 'exact',
|
|
426
|
+
path: '/api-dsh-pick/market',
|
|
427
|
+
handler: async (req, res) => {
|
|
428
|
+
if (req.method === 'GET') return sendJson(res, 200, await marketStatus(pluginMarket))
|
|
429
|
+
if (!isSafePost(req)) return sendJson(res, 403, { ok: false, message: '只接受本页面发出的请求' })
|
|
430
|
+
const r = await ensureMarketSource(pluginMarket, { force: true })
|
|
431
|
+
if (r.status === 'added' || r.status === 'present') return sendJson(res, 200, { ok: true, status: r.status })
|
|
432
|
+
if (r.status === 'unavailable') {
|
|
433
|
+
return sendJson(res, 200, { ok: false, message: '先在 DSH 的「插件」页打开实验功能「自定义插件索引」,「发现」页出来后再点' })
|
|
434
|
+
}
|
|
435
|
+
return sendJson(res, 200, { ok: false, message: `没加上:${r.message || r.status}` })
|
|
436
|
+
},
|
|
437
|
+
}))
|
|
438
|
+
|
|
409
439
|
// 已装的插件(面板卡片上的「已安装」)
|
|
410
440
|
track(ws.register({
|
|
411
441
|
kind: 'exact',
|