# market —— 插件市场索引(format 1) DSH **没有官方市场**。`@deepseek-ai/dsh-experimental-plugin-market-bundle` 的 README 原话: > There is no official market; Discover lists only the index sources the user adds. 所以「被市场收录」只有一条路:把一份符合 **format 1** 的索引 JSON 挂在一个 http(s) 地址上, 用户在 **Plugins → Discover** 里把它加为索引源。本目录就是那份索引。 | 文件 | 作用 | |---|---| | `plugin.json` | 手写的条目元数据(标题、简介、发布时间、category、labels、source)。改这个。 | | `index.json` | 由 `npm run build:index` 生成,**不要手改**;`npm run check:index` 在 CI 里校验一致性。 | ## 收录的硬规则(来自校验器源码,不是转述) `@deepseek-ai/dsh-plugin-market-index/lib/index.js` 的 `parseMarketIndex(value, indexUrl)`: - `$.format` 必须**严格等于 `1`**; - `$.title` 必填;`LocalizedText` 用对象形式时必须含 `en` 键; - `$.plugins[]` 的 `name` 必须是合法 npm 包名且不重复; - 每个 plugin 的 `versions` 非空,`version` 是精确 SemVer,`publishTimestamp` 是**整数秒** (`[0, 1e11)`); - `source.type` 只能是 `npm`(可选 `registry`)或 `git`(`url` 必须 https 且规范化、 `commit` 是 **40 位小写 hex**,包不在仓库根时加 `path`); - **`metadata.category` 和 `metadata.labels[]` 里的每个 id,都必须先在索引自己的 `$.metadata.categories` / `$.metadata.labels` 里声明过**,否则报 `references undeclared id`。⚠️ 这就是「被收录除了发 npm 还有额外 tag 要求」的真身: tag 不是 npm 上的东西,而是**索引文档自己声明的分类/标签**;写一个索引里没声明过的 category,条目会被整个索引校验直接拒掉。 可选项:`icon`(相对索引 URL 解析,必须同源或 https;也接受 ≤32 KiB 的 base64 data URL)、 `author`、`homepage`、`repository{url,directory?}`、`metadata.keywords[]`、`sortKeys`。 ## 怎么让它被收录 ```powershell # 1) 生成索引(版本号、engines 从 package.json 取,永远同步) npm run build:index # 2) 推到 GitHub(索引在同源 https 上才能被读到) git add market/index.json market/plugin.json git commit -m "chore(market): refresh index" git push # 3) 在 DSH 里:Plugins → 更多 → 打开「自定义插件市场」→ Discover → 添加索引源: # https://raw.githubusercontent.com/Astepluver/dsh-interaction-habits/main/market/index.json ``` 想被别人收录进**他人维护的索引**时,把 `plugin.json` 里的 `category` / `labels` 换成 那个索引 `metadata` 里声明过的 id 再提交 PR——这是唯一会被校验卡住的地方。 ## 本地校验 ```powershell npm run check:index # 索引与 package.json / plugin.json 是否一致 npm test # 插件单测 ``` DSH 自己的校验器跑不起来:它在 `app.asar` 里,Node 无法从 asar 路径 `import`。 因此本目录的规则是按源码逐条实现的,并在 README 的「已验证 / 未验证」里如实标注。 真正的端到端验证只有一条:在 Discover 里加上索引 URL,看它能不能列出来 (失败会报 `plugin-market/invalid-index` 并给出 JSON 路径)。