dsh-modpack-kit 0.2.2 → 0.2.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.
@@ -0,0 +1,391 @@
1
+ # 代码地图(CODE-MAP)
2
+
3
+ > 给改代码的人:**先在这里定位,再用函数名 grep**。行号会随改动漂移,只信符号名;行号列仅供大致范围参考。
4
+ >
5
+ > 生成方式:`node dev/tools/map.mjs`(本仓库用 `ELECTRON_RUN_AS_NODE=1 "<DeepSeek Harness.exe>" dev/tools/map.mjs`)。加了大段代码后重跑一次即可刷新符号表。
6
+
7
+ ## 0. 结构一句话
8
+
9
+ ```
10
+ index.js Host 侧:30 条路由 + 打包/安装/社区资源编排 + 任务队列
11
+ client.js 客户端:打包 / 安装·导入 / 社区资源 / 设置与记录 + 悬浮进度窗
12
+ lib/*.mjs 纯逻辑(无 Cordis 依赖,可单独 node 跑)
13
+ assets/install-stub.mjs 打进包里的独立安装器(裸 DSH 用)
14
+ test/*.mjs 单元 / 宿主集成 / 联网 / 假 React 渲染
15
+ dev/tools/*.mjs 一次性验证工具(基准、矩阵、沙箱、同步、校验、代码地图)
16
+ docs/DETAIL.md 插件详情页正文(locale 的 meta.detail 指向它)
17
+ ```
18
+
19
+ ## 1. 功能 → 去哪找
20
+
21
+ | 想改什么 | 先看 | 关键符号 | 常用 grep |
22
+ | --- | --- | --- | --- |
23
+ | 打包流程 / 三种策略 | `lib/pack.mjs` | `buildPack`、`strategy`、`embedded`、`tick` | `grep -n "function buildPack" lib/pack.mjs` |
24
+ | 包格式 / 清单字段 | `lib/manifest.mjs` | `buildManifest`、`normalizeManifest`、`normalizePlugin`、`buildReadme` | `grep -n "normalizePlugin" lib/manifest.mjs` |
25
+ | 安装(市场版优先 / 回退) | `lib/install.mjs` | `installPack`、`installSpec`、`preferMarketSpec`、`applyMarketGroups` | `grep -n "preferMarketSpec" lib/install.mjs` |
26
+ | 独立安装器(裸 DSH) | `assets/install-stub.mjs` | `resolveCli`、`vendorRoot`、`restoreConfigs`、`restoreGroups` | `grep -n "function vendorRoot" assets/install-stub.mjs` |
27
+ | 安全检测 / 风险分组 | `lib/scan.mjs` | `scanEntries`、`groupFindings`、`SECRET_PATTERNS` | `grep -n "function groupFindings" lib/scan.mjs` |
28
+ | 兼容性建议 | `lib/compat.mjs` | `checkCompatibility`、`canCarry` | `grep -n "canCarry" lib/compat.mjs` |
29
+ | 插件市场目录(分类/搜索) | `lib/market-catalog.mjs` | `syncCatalog`、`searchCatalog`、`catalogSummary` | `grep -n "function searchCatalog" lib/market-catalog.mjs` |
30
+ | 社区资源目录(自建仓库) | `lib/modpack-catalog.mjs` | `syncMarket`、`searchMarket`、`fetchMarketPack` | `grep -n "function searchMarket" lib/modpack-catalog.mjs` |
31
+ | 社区资源界面 | `client.js` | `MarketPanel`、`renderRow`、`requestInstall` | `grep -n "function MarketPanel" client.js` |
32
+ | 打包界面 / 策略卡片 | `client.js` | `PackPanel`、`computePlan` 的前端消费、`STRATEGY_INFO` | `grep -n "function PackPanel" client.js` |
33
+ | 安装界面 / 预览 | `client.js` | `InstallPanel`、`subscribeInstallRequest` | `grep -n "function InstallPanel" client.js` |
34
+ | 设置与记录 | `client.js` + `lib/store.mjs` | `SettingsPanel`、`DEFAULT_CONFIG`、`clampConfig`、`clearHistory` | `grep -n "function SettingsPanel" client.js` |
35
+ | 进度窗 / 任务队列 | `client.js` + `index.js` | `JobDock`、`clampDockPos`、`useJobs`;`createJob`、`pruneJobs`、`performPack` | `grep -n "function JobDock" client.js` |
36
+ | 打包策略可用性判定 | `index.js` | `computePlan`、`versionOf` | `grep -n "function computePlan" index.js` |
37
+ | 分组读写 / 重名避让 | `lib/groups.mjs` | `readMarketGroups`、`groupViews`、`applyMarketGroups` | `grep -n "applyMarketGroups" lib/groups.mjs` |
38
+ | 网络与主机白名单 | `lib/net.mjs` | `requestJson`、`requestBuffer`、`curlOnce` | `grep -n "function requestJson" lib/net.mjs` |
39
+ | 设置项默认值 | `lib/store.mjs` | `DEFAULT_CONFIG`、`clampConfig`、`loadConfig` | `grep -n "DEFAULT_CONFIG" lib/store.mjs` |
40
+
41
+ ## 2. 路由表(`index.js`,共 30 条)
42
+
43
+ | 路由 | 行 |
44
+ | --- | --- |
45
+ | `status` | 299 |
46
+ | `settings` | 305 |
47
+ | `catalog` | 326 |
48
+ | `catalog/status` | 336 |
49
+ | `catalog/lookup` | 348 |
50
+ | `catalog/sync` | 359 |
51
+ | `catalog/search` | 370 |
52
+ | `market` | 405 |
53
+ | `market/search` | 423 |
54
+ | `market/sync` | 447 |
55
+ | `market/download` | 463 |
56
+ | `versions` | 512 |
57
+ | `pack/plan` | 814 |
58
+ | `pack` | 824 |
59
+ | `jobs/ack` | 848 |
60
+ | `jobs/dismiss` | 883 |
61
+ | `jobs/clear` | 896 |
62
+ | `jobs/cancel` | 915 |
63
+ | `jobs` | 938 |
64
+ | `download` | 945 |
65
+ | `save` | 960 |
66
+ | `packs` | 999 |
67
+ | `pack/drop` | 1015 |
68
+ | `inspect` | 1080 |
69
+ | `install` | 1265 |
70
+ | `install/replace` | 1278 |
71
+ | `history` | 1304 |
72
+ | `history/clear` | 1310 |
73
+ | `history/remove` | 1316 |
74
+ | `plugin-summary` | 1324 |
75
+
76
+ > 全部挂在 `/dsh-modpack-kit/api/` 下;路由体统一 `if (!needPost(req, res)) return` + `await readJsonBody(req)`,不要再写 `fenced()`。
77
+
78
+ ## 3. 文件职责与符号
79
+
80
+ ### `index.js`(1396 行)
81
+
82
+ Host 侧:所有 HTTP 路由、打包/安装/市场编排、任务队列与进度
83
+
84
+ ### `client.js`(3131 行)
85
+
86
+ 客户端:打包 / 安装·导入 / 社区资源 / 设置与记录 四块界面 + 悬浮进度窗
87
+
88
+ ### `assets/install-stub.mjs`(438 行)
89
+
90
+ 打进包里 install/install.mjs 的独立安装器(裸 DSH 也能装)
91
+
92
+ - `resolveCli` L87
93
+ - `vendorRoot` L134
94
+ - `copyTree` L146
95
+ - `readDependencies` L162
96
+ - `restoreConfigs` L252
97
+ - `stripBundles` L291
98
+ - `restoreGroups` L335
99
+ - `restoreData` L399
100
+
101
+ ### `lib/classify.mjs`(106 行)
102
+
103
+ 把插件名/描述映射到插件市场的 23 个分类(纯字符串匹配)
104
+
105
+ - `CATEGORIES` L12(导出常量)
106
+ - `hit` L51
107
+ - `classifyPlugin` L67(导出)
108
+ - `categoryLabel` L103(导出)
109
+
110
+ ### `lib/compat.mjs`(114 行)
111
+
112
+ 兼容性判定:peer 依赖、engines、license、版本差异;按打包策略给不同建议
113
+
114
+ - `versionOf` L12
115
+ - `checkCompatibility` L21(导出)
116
+
117
+ ### `lib/groups.mjs`(148 行)
118
+
119
+ 读插件市场的分组(.dsh-market/state.json),装完后并入/重名避让
120
+
121
+ - `marketStatePath` L16(导出)
122
+ - `stringList` L20
123
+ - `readMarketGroups` L34(导出)
124
+ - `groupViews` L62(导出)
125
+ - `hasMarket` L77(导出)
126
+ - `applyMarketGroups` L94(导出)
127
+
128
+ ### `lib/http.mjs`(42 行)
129
+
130
+ 读请求体、发 JSON 响应、needPost 等方法判定
131
+
132
+ - `MAX_JSON_BODY` L7(导出常量)
133
+ - `MAX_DROP_BODY` L9(导出常量)
134
+ - `sendJson` L11(导出)
135
+ - `readBody` L32(导出常量)
136
+ - `readRawBody` L34(导出常量)
137
+ - `readJsonBody` L37(导出常量)
138
+ - `asJson` L39(导出)
139
+
140
+ ### `lib/install.mjs`(701 行)
141
+
142
+ 读包 → 扫描 → 按策略装(市场版优先 / 包内副本回退)→ 回填配置与分组
143
+
144
+ - `inspectPackBuffer` L53(导出)
145
+ - `readPackFromUrl` L126(导出)
146
+ - `pluginPayload` L134
147
+ - `materializePayload` L143(导出)
148
+ - `packDirOf` L166
149
+ - `installPack` L179(导出)
150
+
151
+ ### `lib/manifest.mjs`(226 行)
152
+
153
+ dsh-modpack.json 的构造、归一化、校验与包内 README 生成
154
+
155
+ - `SCHEMA` L9(导出常量)
156
+ - `KIND` L10(导出常量)
157
+ - `MANIFEST_NAME` L11(导出常量)
158
+ - `sha256` L13(导出常量)
159
+ - `shortHash` L14(导出常量)
160
+ - `normalizePlugin` L20
161
+ - `normalizeManifest` L85(导出)
162
+ - `buildReadme` L148(导出)
163
+
164
+ ### `lib/market-catalog.mjs`(424 行)
165
+
166
+ 插件市场目录(分类 + 分页搜索 + 已装优先),数据源是 npm 包 dsh-plugin-catalog
167
+
168
+ - `CATEGORY_FALLBACK` L23(导出常量)
169
+ - `CATALOG_SOURCES` L50(导出常量)
170
+ - `PAGE_SIZE_DEFAULT` L55(导出常量)
171
+ - `catalogPaths` L60(导出)
172
+ - `categoriesOf` L68(导出)
173
+ - `normalizePlugin` L85
174
+ - `buildIndex` L121(导出)
175
+ - `readIndex` L141(导出)
176
+ - `writeIndex` L165(导出)
177
+ - `catalogSummary` L173(导出)
178
+ - `fetchSource` L202
179
+ - `syncCatalog` L217(导出)
180
+ - `relevance` L246
181
+ - `searchCatalog` L286(导出)
182
+ - `categoryMapFor` L392(导出)
183
+ - `lookupPlugins` L404(导出)
184
+
185
+ ### `lib/modpack-catalog.mjs`(356 行)
186
+
187
+ 社区资源目录(自建仓库 packs.json):同步、缓存、检索、取包
188
+
189
+ - `MARKET_REPO` L31(导出常量)
190
+ - `MARKET_BRANCH` L32(导出常量)
191
+ - `MARKET_SOURCES` L34(导出常量)
192
+ - `CATEGORY_FALLBACK` L43(导出常量)
193
+ - `TIER_BANDS` L56(导出常量)
194
+ - `tierOf` L63(导出)
195
+ - `marketPaths` L69(导出)
196
+ - `readCache` L77
197
+ - `writeCache` L101
198
+ - `normalizeCatalog` L115
199
+ - `sourceBaseOf` L171
200
+ - `packFileUrl` L176(导出)
201
+ - `marketSummary` L181(导出)
202
+ - `syncMarket` L215(导出)
203
+ - `installedState` L251
204
+ - `relevance` L259
205
+ - `searchMarket` L283(导出)
206
+ - `fetchMarketPack` L336(导出)
207
+ - `findMarketPack` L349(导出)
208
+
209
+ ### `lib/net.mjs`(168 行)
210
+
211
+ 网络层:https 白名单、逐跳校验、体积上限、重试、curl 兜底
212
+
213
+ - `NET_DEFAULTS` L12(导出常量)
214
+ - `assertAllowedUrl` L23(导出)
215
+ - `netOptions` L39
216
+ - `parseCurlResponse` L49(导出)
217
+ - `curlOnce` L64
218
+ - `fetchOnce` L84
219
+ - `requestBuffer` L117(导出)
220
+ - `requestJson` L160(导出)
221
+
222
+ ### `lib/pack.mjs`(665 行)
223
+
224
+ 打包:收集插件 → 抓配置/数据 → 扫描 → 写清单与安装器 → 压 zip
225
+
226
+ - `collectFiles` L39(导出)
227
+ - `readInstalledPlugin` L81(导出)
228
+ - `REDACTED` L114(导出常量)
229
+ - `normalizeConfigKey` L116(导出)
230
+ - `redactConfig` L123(导出)
231
+ - `captureConfigs` L149(导出)
232
+ - `dataDirsFor` L195
233
+ - `scrubText` L223
234
+ - `captureData` L234(导出)
235
+ - `licenseId` L282
236
+ - `authorOf` L289
237
+ - `buildPack` L302(导出)
238
+
239
+ ### `lib/profile.mjs`(332 行)
240
+
241
+ 读写 profile:已装列表、bundles、cordis.patch.yml、调官方 CLI
242
+
243
+ - `readJson` L15(导出)
244
+ - `readProfilePackage` L23(导出)
245
+ - `listInstalled` L27(导出)
246
+ - `dshVersion` L139(导出)
247
+ - `readBundles` L147(导出)
248
+ - `backup` L152
249
+ - `ensureBundles` L161(导出)
250
+ - `setBundles` L183(导出)
251
+ - `patchPath` L198(导出)
252
+ - `readPatch` L202(导出)
253
+ - `writePatch` L211(导出)
254
+ - `cliPath` L220
255
+ - `cliEntry` L227
256
+ - `quoteArg` L239
257
+ - `safeArg` L245
258
+ - `normalizePluginArgs` L250
259
+ - `decodeOutput` L262
260
+ - `runDshPlugin` L276(导出)
261
+
262
+ ### `lib/registry.mjs`(242 行)
263
+
264
+ 从 npm 取版本清单与 tarball(三层退让 + curl 兜底)
265
+
266
+ - `fetchLimited` L17(导出常量)
267
+ - `fetchJson` L18(导出常量)
268
+ - `validatePackageName` L20(导出)
269
+ - `metadataLimit` L36(导出)
270
+ - `probeRegistry` L54(导出)
271
+ - `npmMetadata` L71(导出)
272
+ - `pickVersion` L125(导出)
273
+ - `relativeTime` L142(导出)
274
+ - `downloadPackage` L153(导出)
275
+ - `fetchCatalog` L196(导出)
276
+ - `npmSearchCatalog` L211(导出)
277
+
278
+ ### `lib/scan.mjs`(347 行)
279
+
280
+ 安全检测:敏感信息 + 恶意代码痕迹;按来源分组;同内容去重
281
+
282
+ - `scanFileName` L66(导出)
283
+ - `maskSecret` L75
284
+ - `maskAll` L81
285
+ - `findingOf` L86
286
+ - `looksBinary` L98(导出)
287
+ - `extOf` L104
288
+ - `lineAt` L110
289
+ - `scanFile` L122(导出)
290
+ - `groupFindings` L193(导出)
291
+ - `severityRank` L235(导出)
292
+ - `scanEntries` L244(导出)
293
+ - `renderScanReport` L311(导出)
294
+
295
+ ### `lib/semver.mjs`(138 行)
296
+
297
+ 极小 semver 实现(判断兼容性用)
298
+
299
+ - `parseVersion` L11(导出)
300
+ - `compareVersions` L18(导出)
301
+ - `bound` L33
302
+ - `parseComparatorSet` L38
303
+ - `testBounds` L103
304
+ - `satisfies` L119(导出)
305
+
306
+ ### `lib/store.mjs`(243 行)
307
+
308
+ 本地状态:settings.json / history.json / 目录路径 / 默认配置与 clamp
309
+
310
+ - `dshHome` L13(导出)
311
+ - `pluginHome` L17(导出)
312
+ - `profileName` L21(导出)
313
+ - `profileDir` L27(导出)
314
+ - `HOSTS_VERSION` L31(导出常量)
315
+ - `NET_VERSION` L33(导出常量)
316
+ - `DEFAULT_CONFIG` L35(导出常量)
317
+ - `pathsFor` L96(导出)
318
+ - `clampConfig` L109(导出)
319
+ - `loadConfig` L152(导出)
320
+ - `writeJsonAtomic` L175(导出)
321
+ - `saveConfig` L182(导出)
322
+ - `readHistory` L188(导出)
323
+ - `appendHistory` L197(导出)
324
+ - `clearHistory` L205(导出)
325
+ - `removeHistory` L211(导出)
326
+ - `appendLog` L218(导出)
327
+ - `slugify` L228(导出)
328
+ - `ensureDir` L239(导出)
329
+
330
+ ### `lib/tar.mjs`(108 行)
331
+
332
+ 读 .tgz(npm 包)
333
+
334
+ - `readString` L14
335
+ - `readOctal` L20
336
+ - `parsePax` L27
337
+ - `readTarball` L48(导出)
338
+ - `stripPackagePrefix` L98(导出)
339
+ - `tarLimits` L107(导出常量)
340
+
341
+ ### `lib/yamlish.mjs`(408 行)
342
+
343
+ YAML 子集:只服务 cordis.patch.yml 的读写
344
+
345
+ - `stripComment` L15
346
+ - `parseDoubleQuoted` L29
347
+ - `parseSingleQuoted` L55
348
+ - `parseFlow` L60
349
+ - `parseScalar` L133
350
+ - `parseYaml` L263(导出)
351
+ - `emitScalar` L277(导出)
352
+ - `emitYaml` L288(导出)
353
+ - `splitTopLevelItems` L334(导出)
354
+ - `upsertPatchItem` L368(导出)
355
+ - `findPatchItem` L397(导出)
356
+
357
+ ### `lib/zip.mjs`(255 行)
358
+
359
+ 最小 ZIP 读写(node:zlib,无依赖)
360
+
361
+ - `dosTime` L28
362
+ - `dosToDate` L37
363
+ - `safeEntryName` L48(导出)
364
+ - `alreadyCompressed` L74(导出)
365
+ - `writeZip` L87(导出)
366
+ - `findEocd` L164
367
+ - `readZip` L182(导出)
368
+ - `readZipText` L249(导出)
369
+ - `zipLimits` L254(导出常量)
370
+
371
+ ## 4. 常见改动的连锁清单
372
+
373
+ - **加一个设置项**:`lib/store.mjs` 的 `DEFAULT_CONFIG` + `clampConfig` → `client.js` 的 `SettingsPanel`(控件 + `patch({...})`)→ README「能做什么 / 与插件市场」→ `docs/DETAIL.md` → `test/run.mjs` 断言默认值。
374
+ - **加一条路由**:`index.js` 里 `route("/dsh-modpack-kit/api/…")` → 客户端 `api("/…")` → `dev/tools/verify.cjs` 的路由数 → `test/host-smoke.mjs` 补一条 HTTP 用例。旧宿主没有该路由时会回 404/405,`client.js` 的 `api()` 会提示「重启 DSH」。
375
+ - **加一个社区资源字段**:`_market/modpack-catalog/scripts/build.mjs`(校验 + 输出)→ `lib/modpack-catalog.mjs` 的 `normalizeCatalog` → `client.js` 的 `renderRow` / 详情块 → `_market/modpack-catalog/README.md` 的条目格式表。
376
+ - **加一种打包策略或改策略判定**:`lib/pack.mjs`(`strategy` / `embedded`)→ `lib/manifest.mjs`(`format` 归一化)→ `index.js` 的 `computePlan` 与 `/pack/plan` → `client.js` 的 `STRATEGY_INFO` 与卡片 → `lib/install.mjs`(按 `embedded` 决定走市场版还是包内副本)→ 测试。
377
+ - **改界面文案**:`client.js` 里的中文字面量;`locale/zh.json`、`locale/en.json` 的 `meta.title/description`;`README.md`;`docs/DETAIL.md`;注意测试里有硬断言(例如旧名「整合包市场」不许出现)。
378
+ - **改完固定收尾**:`test/run.mjs`、`DSH_MODPACK_OFFLINE=1 test/host-smoke.mjs`、`dev/tools/sync.cjs`、`dev/tools/verify.cjs`、`dev/tools/map.mjs`(刷新本文件)。
379
+
380
+ ## 5. 检索示例
381
+
382
+ ```bash
383
+ # 找某个函数在哪
384
+ grep -n "function MarketPanel" client.js
385
+ # 找某个路由
386
+ grep -n "/api/market" index.js
387
+ # 找某个设置键
388
+ grep -rn "showModpackMarket" --include=*.mjs --include=*.js .
389
+ # 找某段文案出现在哪些地方(改文案前必做)
390
+ grep -rn "进度在悬浮窗" --include=*.js --include=*.mjs --include=*.md .
391
+ ```
package/docs/DETAIL.md CHANGED
@@ -8,13 +8,13 @@
8
8
 
9
9
  ## 能做什么
10
10
 
11
- * **三种打包策略**:懒人包(带本体,离线可装)、仅下载码(只记安装码,体积最小)、混合(按插件配置类型选择打包策略)。
11
+ * **三种打包策略**:懒人包(带本体,离线可装)、轻量包(只记安装码,体积最小)、混合(按插件配置类型选择打包策略)。
12
12
  * **逐插件定制**:「插件预设」或「自定义配置」,按条目回填、默认不覆盖本机文件,疑似凭据替换为 `${REDACTED}`。
13
13
  * **强制检测**:打包前扫描风险与敏感信息(只留掩码),高风险停下等确认;安装前校验 sha256、兼容性与许可证。
14
14
  * **和市场同源**:分类、搜索、分页、分组、版本与插件市场目录同步;没装市场也能打包与安装。
15
15
  * **备份与取包**:平时可以把整合包当作插件组合的备份——迁移、备份或分享配置;取包支持文件/文件夹选择器、任意目录、已导入列表与链接,支持市场新版 AI 搜索。
16
16
 
17
- 想整整合包市场奈何技术力不足,不定时更新咕咕咕。
17
+ 想整社区资源奈何技术力不足,不定时更新咕咕咕。
18
18
 
19
19
  ## 安装码
20
20
 
@@ -35,10 +35,12 @@ dsh plugin --profile desktop add github:Vesna-Strivozha-cn/dsh-modpack-kit
35
35
  |策略|包里有什么|要联网|适合|
36
36
  |-|-|-|-|
37
37
  |懒人包 `full`|清单 + 插件本体 + 配置 + 数据 + 检测报告|可以不用|换机器、离线装、没装本插件的机器|
38
- |仅下载码 `lite`|清单 + 版本号|要|分享给别人、自己已有插件|
38
+ |轻量包 `lite`|清单 + 版本号|要|分享给别人、自己已有插件|
39
39
  |混合 `hybrid`|能按版本装的只记版本,其余连本体|部分|体积和可装性兼顾|
40
40
 
41
- 打包界面就是三张卡片,按所选插件实时判定:不可选的灰显,点一下说明原因;版本号由清单决定,不能手改。
41
+ 打包界面就是三张卡片,按所选插件实时判定:不可选的灰显,点一下说明原因。版本号不打时候不鉴别:轻量包与混合包里「只记版本」的插件,直接记你本机(或市场目录里)那一版,打包过程不联网、不向 registry 校验;「市场版」这个身份要等安装时联网取包才确认。只有完整包(离线包)会真的下载并核对代码。
42
+
43
+ 轻量包与混合包里「只记版本」的插件不写死版本号(`latest: true`):安装时按名字从市场取最新一版,所以打包页看到的「市场最新」和装出来的是一版;只有完整包(和混合包里嵌了本体的那几个)才记具体版本。
42
44
 
43
45
  ## 功能简述
44
46
 
@@ -60,6 +62,31 @@ dsh plugin --profile desktop add github:Vesna-Strivozha-cn/dsh-modpack-kit
60
62
  * **在插件里导入**:可逐插件勾选,缺依赖 / 引擎不符的置顶显示,每个带配置的插件可选「包内配置 / 保持本机」,装后整体启用,装后同步市场分组。
61
63
  * 已装的默认跳过,可选换成包内版本。
62
64
 
65
+ ## 社区资源
66
+
67
+ 界面不带语言切换,只提供中文。
68
+
69
+ - 体量词条:按插件总数自动判定(0-3 轻量 / 4-8 中型 / 9-12 大型 / 13+ 大宗),目录条目里存成 `tier`,客户端只用不猜。
70
+ - 水槽:构建时把包里每个插件映射到插件市场分类,跨 ≥3 类就强制 `category = 水槽`,避免「什么都有」的包被塞进单一场景。
71
+ - 条目字段:id / name / author / category / version / strategy(只收 lite)/ file / sha256 / size / createdAt / updatedAt / description{zh,en} / plugins[{name,version,description}] / downloads。
72
+ - downloads 指这个 .dshpack 安装文件本身被下载的次数;目录只存元数据、不搬文件。Git 仓库里的文件没有逐文件计数,作者不写这个字段时客户端显示「下载量未统计」,绝不用包里插件的 npm 下载量顶替;托管到 GitHub Release 并写 download_count 就会原样显示。
73
+ - 上传时条目只写定位字段(id/类型/文件名/sha256/日期);介绍、名称、作者、插件清单全部取自包内 `dsh-modpack.json`,也就是打包那一刻填的内容——目录里显示什么,取决于打包时写了什么。
74
+ - 插件数只算清单里的顶层插件;壁纸引擎那类由插件自己带的组件不计入。
75
+ - 检索:目录 JSON 按文件的 mtime+size 做内存缓存,每条预算一份小写 searchText;命中查询时先做包含过滤再打分,服务端对同一组条件再缓存 20 秒。
76
+ - 分组写入:.dsh-market/state.json 里新增 groupOrigins(组名 → 创建它的包);同名组属于别的包时依次试「名字 2」「名字 3」,安装日志会写明避让结果。
77
+
78
+ 目录仓库 `Vesna-Strivozha-cn/dsh-modpack-catalog`(GitHub Actions `17 3 * * *` 一天一轮询)。
79
+
80
+ * 数据:`packs.json`(`schema: 1`、`builtAt`、`count`、`categories[{id,label,count}]`、`packs[]`)。jsDelivr `gh/<repo>@main/packs.json` 与 raw.githubusercontent 两个源都取一遍,按 `builtAt` 用更新的那份(jsDelivr 对 gh 的缓存可能落后一整天);本地缓存在 `<home>/dsh-modpack/modpack-market/packs.cache.json`(连 `sourceBase` 一起存),TTL 按 `modpackRefreshHours`(默认 24 小时)。
81
+ * 条目:`id`、`name`、`author`、`category`、`version`、`strategy`(当前只收 `lite`)、`file`、`sha256`、`size`、`createdAt`、`description{zh,en}`、`plugins[{name,version,description}]`、`downloads`。
82
+ * 插件端路由:`GET /api/market`(摘要 + 首页 + 已装标记)、`POST /api/market/search`、`POST /api/market/sync`、`POST /api/market/download`。下载只认目录里的 id,取回字节后先对体积与 `sha256`,再 `inspectPackBuffer`、`rememberPending`,返回的 `token` 交安装页读取——与手动导入走同一条。
83
+ * 客户端:`MarketPanel`(列表 / 详情 / 规则三视图),下载后 `requestInstall()` 一次交接给 `InstallPanel`,后者照旧 `POST /api/inspect`;进度仍在左下角悬浮窗。
84
+ * 开关:`showModpackMarket`(默认 true)、`modpackRefreshHours`(1~168)。
85
+
86
+
87
+
88
+ 上传流程:轻量包 → sha256/字节数 → fork 目录仓库 → `packs/` + `data/packs/<id>.json`(定位字段)→ 本地 `scripts/build.mjs` → PR;合并后每日 03:17 UTC 重建或 Actions 手动 dispatch。构建会打开包读 `dsh-modpack.json`:名称、作者、介绍、插件清单都以它为准,包里插件可写 `{ "name": "x", "latest": true }`(安装取市场最新)。
89
+
63
90
  ## 与插件市场的兼容
64
91
 
65
92
  ||装了插件市场|没装|
@@ -87,6 +114,10 @@ AI 搜索花的 token 记在插件市场那边(它用你在「设置 → 模
87
114
  * **进度窗丢失/忘了在哪**:页面标签行右边有「召回进度窗」点击。
88
115
  * **想先装上但是不启用插件**:打包/安装时关掉「装后整体启用」,或在安装器加 `--no-bundles`。
89
116
 
117
+ ## 代码地图
118
+
119
+ `docs/CODE-MAP.md` 是给改代码的人的索引:功能 → 文件 → 符号 → grep 示例,路由表自动生成。`dev/tools/map.mjs` 重跑即可刷新。
120
+
90
121
  ## 实现要点(给改代码的人)
91
122
 
92
123
  * 宿主侧:`index.js` 只做路由与任务队列,打包/安装的纯逻辑在 `lib/`(`pack` / `install` / `scan` / `manifest` / `market-catalog` / `registry` / `net` / `groups` / `zip` / `tar` / `semver` / `store` / `http`),前端全部在单文件 `client.js`。