dsh-modpack-kit 0.2.3 → 0.3.0

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/docs/CODE-MAP.md CHANGED
@@ -7,9 +7,12 @@
7
7
  ## 0. 结构一句话
8
8
 
9
9
  ```
10
- index.js Host 侧:30 条路由 + 打包/安装/社区资源编排 + 任务队列
11
- client.js 客户端:打包 / 安装·导入 / 社区资源 / 设置与记录 + 悬浮进度窗
10
+ index.js Host 侧:44 条路由 + 打包/安装/社区资源/插件管理编排 + 任务队列
11
+ client.js 客户端:打包 / 安装·导入 / 社区资源 / 插件管理 / 设置与记录 + 插件树浮层 + 悬浮进度窗
12
12
  lib/*.mjs 纯逻辑(无 Cordis 依赖,可单独 node 跑)
13
+ community/ 附属小插件「社区资源」:自己的 manifest.json + index.mjs(9 条接口)
14
+ annotate/ 附属小插件「代码标注」:读全仓 @file 标注、跑自检(2 条接口)
15
+ plugin-tree/ 附属小插件「插件树」:插件树与兼容树(2 条接口)
13
16
  assets/install-stub.mjs 打进包里的独立安装器(裸 DSH 用)
14
17
  test/*.mjs 单元 / 宿主集成 / 联网 / 假 React 渲染
15
18
  dev/tools/*.mjs 一次性验证工具(基准、矩阵、沙箱、同步、校验、代码地图)
@@ -20,6 +23,8 @@ docs/DETAIL.md 插件详情页正文(locale 的 meta.detail 指向它)
20
23
 
21
24
  | 想改什么 | 先看 | 关键符号 | 常用 grep |
22
25
  | --- | --- | --- | --- |
26
+ | 测试模式(只走流程) | `lib/testmode.mjs` | `testModeOn`、`playTestJob`、`testStepsFor` | `grep -n "function playTestJob" lib/testmode.mjs` |
27
+ | 配色 / 主题 | `lib/theme.mjs` | `THEME_PRESETS`、`themeOf`、`themeVars` | `grep -n "function themeVars" lib/theme.mjs` |
23
28
  | 打包流程 / 三种策略 | `lib/pack.mjs` | `buildPack`、`strategy`、`embedded`、`tick` | `grep -n "function buildPack" lib/pack.mjs` |
24
29
  | 包格式 / 清单字段 | `lib/manifest.mjs` | `buildManifest`、`normalizeManifest`、`normalizePlugin`、`buildReadme` | `grep -n "normalizePlugin" lib/manifest.mjs` |
25
30
  | 安装(市场版优先 / 回退) | `lib/install.mjs` | `installPack`、`installSpec`、`preferMarketSpec`、`applyMarketGroups` | `grep -n "preferMarketSpec" lib/install.mjs` |
@@ -35,53 +40,99 @@ docs/DETAIL.md 插件详情页正文(locale 的 meta.detail 指向它)
35
40
  | 进度窗 / 任务队列 | `client.js` + `index.js` | `JobDock`、`clampDockPos`、`useJobs`;`createJob`、`pruneJobs`、`performPack` | `grep -n "function JobDock" client.js` |
36
41
  | 打包策略可用性判定 | `index.js` | `computePlan`、`versionOf` | `grep -n "function computePlan" index.js` |
37
42
  | 分组读写 / 重名避让 | `lib/groups.mjs` | `readMarketGroups`、`groupViews`、`applyMarketGroups` | `grep -n "applyMarketGroups" lib/groups.mjs` |
43
+ | 插件管理(列表 / 开关 / 更新 / 重装) | `lib/plugin-manager.mjs` + `client.js` | `listManaged`、`setPluginEnabled`、`reinstallPlugin`;`PluginManagerPanel` | `grep -n "function PluginManagerPanel" client.js` |
44
+ | 一键更新(跳过停用与按路径装) | `lib/plugin-manager.mjs` + `index.js` + `client.js` | `updatableItems`、`updatePlugins`;`/plugins/update-all`;`bulkReady`、`askBulk` | `grep -n "plugins/update-all" index.js` |
45
+ | 插件行首图标 / 放大预览 | `lib/plugin-manager.mjs` + `index.js` + `client.js` | `pluginIcon`、`ICON_FILES`;`/plugins/icon`;`icons`、`setZoomIcon` | `grep -n "function pluginIcon" lib/plugin-manager.mjs` |
46
+ | 附属小插件清单(谁属于谁) | `lib/subplugins.mjs` + `client.js` | `SUBPLUGINS`、`listSubplugins`、`subEnabled`;`SubpluginList`、`SubpluginCard` | `grep -n "SUBPLUGINS" lib/subplugins.mjs` |
47
+ | 附属小插件的接口表 | `community/`、`annotate/`、`plugin-tree/` | 各自的 `manifest.json` 与 `index.mjs`(导出 `*Routes()`) | `grep -n "routes" annotate/index.mjs` |
48
+ | 代码标注 / 自检 | `lib/annotate.mjs` | `parseAnnotation`、`collectAnnotations`、`checkAnnotations` | `grep -n "function checkAnnotations" lib/annotate.mjs` |
49
+ | 插件树 / 兼容树(勾哪个看哪个) | `lib/plugin-graph.mjs` + `plugin-tree/` + `client.js` | `listTreeCandidates`、`buildRelations`、`compatOf`、`versionVerdict`;`PluginTreeOverlay` | `grep -n "function buildRelations" lib/plugin-graph.mjs` |
50
+ | 一键上传(GitHub) | `lib/github.mjs` | `whoAmI`、`ensureRelease`、`uploadReleaseAsset`、`openPackPullRequest` | `grep -n "function openPackPullRequest" lib/github.mjs` |
38
51
  | 网络与主机白名单 | `lib/net.mjs` | `requestJson`、`requestBuffer`、`curlOnce` | `grep -n "function requestJson" lib/net.mjs` |
39
52
  | 设置项默认值 | `lib/store.mjs` | `DEFAULT_CONFIG`、`clampConfig`、`loadConfig` | `grep -n "DEFAULT_CONFIG" lib/store.mjs` |
40
53
 
41
- ## 2. 路由表(`index.js`,共 30 条)
54
+ ## 2. 路由表(`index.js`,共 44 条)
42
55
 
43
56
  | 路由 | 行 |
44
57
  | --- | --- |
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 |
58
+ | `status` | 432 |
59
+ | `settings` | 438 |
60
+ | `catalog` | 468 |
61
+ | `catalog/status` | 478 |
62
+ | `catalog/lookup` | 490 |
63
+ | `catalog/sync` | 501 |
64
+ | `catalog/search` | 512 |
65
+ | `market` | 547 |
66
+ | `market/search` | 565 |
67
+ | `market/sync` | 589 |
68
+ | `upload/status` | 603 |
69
+ | `upload/token` | 620 |
70
+ | `upload/preview` | 646 |
71
+ | `upload/submit` | 724 |
72
+ | `market/preview` | 974 |
73
+ | `market/download` | 1017 |
74
+ | `versions` | 1104 |
75
+ | `pack/plan` | 1414 |
76
+ | `plugin/install` | 1426 |
77
+ | `plugins` | 1474 |
78
+ | `plugins/toggle` | 1483 |
79
+ | `plugins/reveal` | 1505 |
80
+ | `plugins/icon` | 1517 |
81
+ | `plugins/update-all` | 1534 |
82
+ | `plugins/reinstall` | 1621 |
83
+ | `pack` | 1706 |
84
+ | `jobs/ack` | 1734 |
85
+ | `jobs/dismiss` | 1769 |
86
+ | `jobs/clear` | 1782 |
87
+ | `jobs/cancel` | 1801 |
88
+ | `jobs` | 1824 |
89
+ | `download` | 1831 |
90
+ | `save` | 1859 |
91
+ | `packs` | 1903 |
92
+ | `packs/open` | 1919 |
93
+ | `packs/remove` | 1934 |
94
+ | `pack/drop` | 1963 |
95
+ | `inspect` | 2028 |
96
+ | `install` | 2241 |
97
+ | `install/replace` | 2254 |
98
+ | `history` | 2280 |
99
+ | `history/clear` | 2286 |
100
+ | `history/remove` | 2292 |
101
+ | `plugin-summary` | 2300 |
75
102
 
76
103
  > 全部挂在 `/dsh-modpack-kit/api/` 下;路由体统一 `if (!needPost(req, res)) return` + `await readJsonBody(req)`,不要再写 `fenced()`。
77
104
 
105
+ ### 附属小插件声明的接口(14 条)
106
+
107
+ | 附属小插件 | 开关键 | 路由 |
108
+ | --- | --- | --- |
109
+ | `dsh-modpack-community` | `常开` | `market` |
110
+ | `dsh-modpack-community` | `常开` | `market/search` |
111
+ | `dsh-modpack-community` | `常开` | `market/sync` |
112
+ | `dsh-modpack-community` | `常开` | `market/download` |
113
+ | `dsh-modpack-community` | `常开` | `market/preview` |
114
+ | `dsh-modpack-community` | `常开` | `upload/status` |
115
+ | `dsh-modpack-community` | `常开` | `upload/token` |
116
+ | `dsh-modpack-community` | `常开` | `upload/preview` |
117
+ | `dsh-modpack-community` | `常开` | `upload/submit` |
118
+ | `dsh-modpack-annotate` | `showAnnotate` | `annotate/tree` |
119
+ | `dsh-modpack-annotate` | `showAnnotate` | `annotate/check` |
120
+ | `dsh-modpack-plugin-tree` | `showPluginTree` | `tree/plugins` |
121
+ | `dsh-modpack-plugin-tree` | `showPluginTree` | `tree/plugin` |
122
+ | `dsh-modpack-plugin-tree` | `showPluginTree` | `tree/compat` |
123
+
124
+ > 关掉某个附属小插件时,它这几条统一回 404(`subRoute` / `mountSubRoutes` 保证),主体照常。
125
+
126
+
78
127
  ## 3. 文件职责与符号
79
128
 
80
- ### `index.js`(1396 行)
129
+ ### `index.js`(2389 行)
81
130
 
82
131
  Host 侧:所有 HTTP 路由、打包/安装/市场编排、任务队列与进度
83
132
 
84
- ### `client.js`(3131 行)
133
+ - `runtimeFreshness` L60
134
+
135
+ ### `client.js`(5300 行)
85
136
 
86
137
  客户端:打包 / 安装·导入 / 社区资源 / 设置与记录 四块界面 + 悬浮进度窗
87
138
 
@@ -98,275 +149,420 @@ Host 侧:所有 HTTP 路由、打包/安装/市场编排、任务队列与进
98
149
  - `restoreGroups` L335
99
150
  - `restoreData` L399
100
151
 
101
- ### `lib/classify.mjs`(106 行)
152
+ ### `lib/annotate.mjs`(173 行)
153
+
154
+ 代码标注协议:解析每个源文件头部的 @file/@role/… 块,跑全仓自检
155
+
156
+ - `ANNOTATE_KEYS` L17(导出常量)
157
+ - `REQUIRED_KEYS` L20(导出常量)
158
+ - `splitList` L25
159
+ - `parseAnnotation` L36(导出)
160
+ - `readAnnotation` L84(导出)
161
+ - `walk` L96
162
+ - `runtimeFiles` L116(导出)
163
+ - `collectAnnotations` L128(导出)
164
+ - `checkAnnotations` L163(导出)
165
+
166
+ ### `lib/classify.mjs`(117 行)
102
167
 
103
168
  把插件名/描述映射到插件市场的 23 个分类(纯字符串匹配)
104
169
 
105
- - `CATEGORIES` L12(导出常量)
106
- - `hit` L51
107
- - `classifyPlugin` L67(导出)
108
- - `categoryLabel` L103(导出)
170
+ - `CATEGORIES` L23(导出常量)
171
+ - `hit` L62
172
+ - `classifyPlugin` L78(导出)
173
+ - `categoryLabel` L114(导出)
174
+
175
+ ### `lib/community.mjs`(78 行)
176
+
177
+ 附属小插件「社区资源」的登记与开关解析(内置清单 / 外部实现 / 是否启用)
178
+
179
+ - `COMMUNITY_ID` L23(导出常量)
180
+ - `COMMUNITY_API` L24(导出常量)
181
+ - `readBuiltinManifest` L28(导出)
182
+ - `readExternal` L36
183
+ - `resolveCommunity` L53(导出)
109
184
 
110
- ### `lib/compat.mjs`(114 行)
185
+ ### `lib/compat.mjs`(125 行)
111
186
 
112
187
  兼容性判定:peer 依赖、engines、license、版本差异;按打包策略给不同建议
113
188
 
114
- - `versionOf` L12
115
- - `checkCompatibility` L21(导出)
189
+ - `versionOf` L23
190
+ - `checkCompatibility` L32(导出)
191
+
192
+ ### `lib/github.mjs`(301 行)
193
+
194
+ GitHub 写接口:fork、Release 资产、改词条、开 PR(一键上传)
195
+
196
+ - `run` L25
197
+ - `gh` L41(导出)
198
+ - `whoAmI` L82(导出)
199
+ - `ensureFork` L88(导出)
200
+ - `openPackPullRequest` L114(导出)
201
+ - `entryFileName` L195(导出)
202
+ - `packFileName` L201(导出)
203
+ - `runRaw` L206
204
+ - `parseStatus` L219
205
+ - `ensureRelease` L230(导出)
206
+ - `uploadReleaseAsset` L252(导出)
116
207
 
117
- ### `lib/groups.mjs`(148 行)
208
+ ### `lib/groups.mjs`(160 行)
118
209
 
119
210
  读插件市场的分组(.dsh-market/state.json),装完后并入/重名避让
120
211
 
121
- - `marketStatePath` L16(导出)
122
- - `stringList` L20
123
- - `readMarketGroups` L34(导出)
124
- - `groupViews` L62(导出)
125
- - `hasMarket` L77(导出)
126
- - `applyMarketGroups` L94(导出)
212
+ - `marketStatePath` L28(导出)
213
+ - `stringList` L32
214
+ - `readMarketGroups` L46(导出)
215
+ - `groupViews` L74(导出)
216
+ - `hasMarket` L89(导出)
217
+ - `applyMarketGroups` L106(导出)
127
218
 
128
- ### `lib/http.mjs`(42 行)
219
+ ### `lib/http.mjs`(52 行)
129
220
 
130
221
  读请求体、发 JSON 响应、needPost 等方法判定
131
222
 
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(导出)
223
+ - `MAX_JSON_BODY` L17(导出常量)
224
+ - `MAX_DROP_BODY` L19(导出常量)
225
+ - `sendJson` L21(导出)
226
+ - `readBody` L42(导出常量)
227
+ - `readRawBody` L44(导出常量)
228
+ - `readJsonBody` L47(导出常量)
229
+ - `asJson` L49(导出)
139
230
 
140
- ### `lib/install.mjs`(701 行)
231
+ ### `lib/install.mjs`(713 行)
141
232
 
142
233
  读包 → 扫描 → 按策略装(市场版优先 / 包内副本回退)→ 回填配置与分组
143
234
 
144
- - `inspectPackBuffer` L53(导出)
145
- - `readPackFromUrl` L126(导出)
146
- - `pluginPayload` L134
147
- - `materializePayload` L143(导出)
148
- - `packDirOf` L166
149
- - `installPack` L179(导出)
235
+ - `inspectPackBuffer` L65(导出)
236
+ - `readPackFromUrl` L138(导出)
237
+ - `pluginPayload` L146
238
+ - `materializePayload` L155(导出)
239
+ - `packDirOf` L178
240
+ - `installPack` L191(导出)
150
241
 
151
- ### `lib/manifest.mjs`(226 行)
242
+ ### `lib/manifest.mjs`(238 行)
152
243
 
153
244
  dsh-modpack.json 的构造、归一化、校验与包内 README 生成
154
245
 
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(导出)
246
+ - `SCHEMA` L21(导出常量)
247
+ - `KIND` L22(导出常量)
248
+ - `MANIFEST_NAME` L23(导出常量)
249
+ - `sha256` L25(导出常量)
250
+ - `shortHash` L26(导出常量)
251
+ - `normalizePlugin` L32
252
+ - `normalizeManifest` L97(导出)
253
+ - `buildReadme` L160(导出)
163
254
 
164
- ### `lib/market-catalog.mjs`(424 行)
255
+ ### `lib/market-catalog.mjs`(436 行)
165
256
 
166
257
  插件市场目录(分类 + 分页搜索 + 已装优先),数据源是 npm 包 dsh-plugin-catalog
167
258
 
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 行)
259
+ - `CATEGORY_FALLBACK` L35(导出常量)
260
+ - `CATALOG_SOURCES` L62(导出常量)
261
+ - `PAGE_SIZE_DEFAULT` L67(导出常量)
262
+ - `catalogPaths` L72(导出)
263
+ - `categoriesOf` L80(导出)
264
+ - `normalizePlugin` L97
265
+ - `buildIndex` L133(导出)
266
+ - `readIndex` L153(导出)
267
+ - `writeIndex` L177(导出)
268
+ - `catalogSummary` L185(导出)
269
+ - `fetchSource` L214
270
+ - `syncCatalog` L229(导出)
271
+ - `relevance` L258
272
+ - `searchCatalog` L298(导出)
273
+ - `categoryMapFor` L404(导出)
274
+ - `lookupPlugins` L416(导出)
275
+
276
+ ### `lib/modpack-catalog.mjs`(394 行)
186
277
 
187
278
  社区资源目录(自建仓库 packs.json):同步、缓存、检索、取包
188
279
 
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 行)
280
+ - `MARKET_REPO` L42(导出常量)
281
+ - `MARKET_BRANCH` L43(导出常量)
282
+ - `MARKET_SOURCES` L45(导出常量)
283
+ - `CATEGORY_FALLBACK` L54(导出常量)
284
+ - `TIER_BANDS` L67(导出常量)
285
+ - `tierOf` L74(导出)
286
+ - `marketPaths` L80(导出)
287
+ - `readCache` L88
288
+ - `writeCache` L112
289
+ - `normalizeCatalog` L126
290
+ - `sourceBaseOf` L202
291
+ - `packFileUrl` L207(导出)
292
+ - `marketSummary` L219(导出)
293
+ - `syncMarket` L253(导出)
294
+ - `installedState` L289
295
+ - `relevance` L297
296
+ - `searchMarket` L321(导出)
297
+ - `fetchMarketPack` L374(导出)
298
+ - `findMarketPack` L387(导出)
299
+
300
+ ### `lib/net.mjs`(179 行)
210
301
 
211
302
  网络层:https 白名单、逐跳校验、体积上限、重试、curl 兜底
212
303
 
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(导出)
304
+ - `NET_DEFAULTS` L23(导出常量)
305
+ - `assertAllowedUrl` L34(导出)
306
+ - `netOptions` L50
307
+ - `parseCurlResponse` L60(导出)
308
+ - `curlOnce` L75
309
+ - `fetchOnce` L95
310
+ - `requestBuffer` L128(导出)
311
+ - `requestJson` L171(导出)
221
312
 
222
- ### `lib/pack.mjs`(665 行)
313
+ ### `lib/pack.mjs`(677 行)
223
314
 
224
315
  打包:收集插件 → 抓配置/数据 → 扫描 → 写清单与安装器 → 压 zip
225
316
 
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 行)
317
+ - `collectFiles` L51(导出)
318
+ - `readInstalledPlugin` L93(导出)
319
+ - `REDACTED` L126(导出常量)
320
+ - `normalizeConfigKey` L128(导出)
321
+ - `redactConfig` L135(导出)
322
+ - `captureConfigs` L161(导出)
323
+ - `dataDirsFor` L207
324
+ - `scrubText` L235
325
+ - `captureData` L246(导出)
326
+ - `licenseId` L294
327
+ - `authorOf` L301
328
+ - `buildPack` L314(导出)
329
+
330
+ ### `lib/plugin-graph.mjs`(462 行)
331
+
332
+ 插件树与兼容树:按勾选的插件,从 package.json 声明、manifest、路由表构筑相关性节点与边,并给出版本兼容判定
333
+
334
+ - `SUB_FILES` L18(导出常量)
335
+ - `readJson` L20
336
+ - `readDeclarations` L29(导出)
337
+ - `readInstalledPackages` L53
338
+ - `versionVerdict` L111
339
+ - `listTreeCandidates` L126(导出)
340
+ - `recordOf` L183
341
+ - `buildRelations` L203(导出)
342
+ - `compatOf` L438(导出)
343
+
344
+ ### `lib/plugin-manager.mjs`(558 行)
345
+
346
+ 插件管理:已装列表(含分组/新版)、启用停用、重装(可保留配置)
347
+
348
+ - `isValidPluginName` L51(导出)
349
+ - `isValidVersion` L56(导出)
350
+ - `patchEntries` L61
351
+ - `writeMarketDisabled` L77(导出)
352
+ - `listManaged` L106(导出)
353
+ - `setPluginEnabled` L195(导出)
354
+ - `resolveReinstallVersion` L243(导出)
355
+ - `dropPatchEntries` L256(导出)
356
+ - `cliTail` L291
357
+ - `reinstallPlugin` L313(导出)
358
+ - `revealPluginDir` L425(导出)
359
+ - `pluginIcon` L463(导出)
360
+ - `updatableItems` L489(导出)
361
+ - `updatePlugins` L498(导出)
362
+
363
+ ### `lib/profile.mjs`(344 行)
240
364
 
241
365
  读写 profile:已装列表、bundles、cordis.patch.yml、调官方 CLI
242
366
 
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 行)
367
+ - `readJson` L27(导出)
368
+ - `readProfilePackage` L35(导出)
369
+ - `listInstalled` L39(导出)
370
+ - `dshVersion` L151(导出)
371
+ - `readBundles` L159(导出)
372
+ - `backup` L164
373
+ - `ensureBundles` L173(导出)
374
+ - `setBundles` L195(导出)
375
+ - `patchPath` L210(导出)
376
+ - `readPatch` L214(导出)
377
+ - `writePatch` L223(导出)
378
+ - `cliPath` L232
379
+ - `cliEntry` L239
380
+ - `quoteArg` L251
381
+ - `safeArg` L257
382
+ - `normalizePluginArgs` L262
383
+ - `decodeOutput` L274
384
+ - `runDshPlugin` L288(导出)
385
+
386
+ ### `lib/registry.mjs`(254 行)
263
387
 
264
388
  从 npm 取版本清单与 tarball(三层退让 + curl 兜底)
265
389
 
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(导出)
390
+ - `fetchLimited` L29(导出常量)
391
+ - `fetchJson` L30(导出常量)
392
+ - `validatePackageName` L32(导出)
393
+ - `metadataLimit` L48(导出)
394
+ - `probeRegistry` L66(导出)
395
+ - `npmMetadata` L83(导出)
396
+ - `pickVersion` L137(导出)
397
+ - `relativeTime` L154(导出)
398
+ - `downloadPackage` L165(导出)
399
+ - `fetchCatalog` L208(导出)
400
+ - `npmSearchCatalog` L223(导出)
277
401
 
278
- ### `lib/scan.mjs`(347 行)
402
+ ### `lib/repack.mjs`(69 行)
403
+
404
+ 轻量重打包:只改清单里几个字段,其余字节原样保留
405
+
406
+ - `rewritePackManifest` L22(导出)
407
+
408
+ ### `lib/scan.mjs`(359 行)
279
409
 
280
410
  安全检测:敏感信息 + 恶意代码痕迹;按来源分组;同内容去重
281
411
 
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 行)
412
+ - `scanFileName` L78(导出)
413
+ - `maskSecret` L87
414
+ - `maskAll` L93
415
+ - `findingOf` L98
416
+ - `looksBinary` L110(导出)
417
+ - `extOf` L116
418
+ - `lineAt` L122
419
+ - `scanFile` L134(导出)
420
+ - `groupFindings` L205(导出)
421
+ - `severityRank` L247(导出)
422
+ - `scanEntries` L256(导出)
423
+ - `renderScanReport` L323(导出)
424
+
425
+ ### `lib/semver.mjs`(148 行)
296
426
 
297
427
  极小 semver 实现(判断兼容性用)
298
428
 
299
- - `parseVersion` L11(导出)
300
- - `compareVersions` L18(导出)
301
- - `bound` L33
302
- - `parseComparatorSet` L38
303
- - `testBounds` L103
304
- - `satisfies` L119(导出)
429
+ - `parseVersion` L21(导出)
430
+ - `compareVersions` L28(导出)
431
+ - `bound` L43
432
+ - `parseComparatorSet` L48
433
+ - `testBounds` L113
434
+ - `satisfies` L129(导出)
305
435
 
306
- ### `lib/store.mjs`(243 行)
436
+ ### `lib/store.mjs`(283 行)
307
437
 
308
438
  本地状态:settings.json / history.json / 目录路径 / 默认配置与 clamp
309
439
 
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 行)
440
+ - `dshHome` L25(导出)
441
+ - `pluginHome` L29(导出)
442
+ - `profileName` L38(导出)
443
+ - `profileDir` L44(导出)
444
+ - `HOSTS_VERSION` L48(导出常量)
445
+ - `NET_VERSION` L50(导出常量)
446
+ - `DEFAULT_CONFIG` L52(导出常量)
447
+ - `pathsFor` L129(导出)
448
+ - `clampConfig` L142(导出)
449
+ - `loadConfig` L192(导出)
450
+ - `writeJsonAtomic` L215(导出)
451
+ - `saveConfig` L222(导出)
452
+ - `readHistory` L228(导出)
453
+ - `appendHistory` L237(导出)
454
+ - `clearHistory` L245(导出)
455
+ - `removeHistory` L251(导出)
456
+ - `appendLog` L258(导出)
457
+ - `slugify` L268(导出)
458
+ - `ensureDir` L279(导出)
459
+
460
+ ### `lib/subplugins.mjs`(142 行)
461
+
462
+ 附属小插件登记表(社区资源 / 代码标注 / 插件树):id、目录、开关键、清单与启用判定
463
+
464
+ - `SUBPLUGINS` L18(导出常量)
465
+ - `readSubManifest` L48(导出)
466
+ - `readSubManifests` L85(导出)
467
+ - `findSubplugin` L89(导出)
468
+ - `subEnabled` L96(导出)
469
+ - `listSubplugins` L106(导出)
470
+
471
+ ### `lib/tar.mjs`(118 行)
331
472
 
332
473
  读 .tgz(npm 包)
333
474
 
334
- - `readString` L14
335
- - `readOctal` L20
336
- - `parsePax` L27
337
- - `readTarball` L48(导出)
338
- - `stripPackagePrefix` L98(导出)
339
- - `tarLimits` L107(导出常量)
340
-
341
- ### `lib/yamlish.mjs`(408 行)
475
+ - `readString` L24
476
+ - `readOctal` L30
477
+ - `parsePax` L37
478
+ - `readTarball` L58(导出)
479
+ - `stripPackagePrefix` L108(导出)
480
+ - `tarLimits` L117(导出常量)
481
+
482
+ ### `lib/testmode.mjs`(103 行)
483
+
484
+ 测试模式:开着时把打包/下载/安装/更新/重装/启停/上传都变成只走流程(进度与弹窗照常)
485
+
486
+ - `TEST_PREFIX` L13(导出常量)
487
+ - `testModeOn` L16(导出)
488
+ - `testNote` L21(导出)
489
+ - `stepDelay` L26
490
+ - `TEST_STEPS` L36(导出常量)
491
+ - `testStepsFor` L57(导出)
492
+ - `playTestJob` L69(导出)
493
+ - `testPayload` L100(导出)
494
+
495
+ ### `lib/theme.mjs`(187 行)
496
+
497
+ 配色:四套预设(雾蓝/墨绿/暮紫/跟宿主)与自定义主色+附属色,算成 --mp-* CSS 变量(只作用于本插件界面)
498
+
499
+ - `THEME_PRESETS` L26(导出常量)
500
+ - `THEME_IDS` L62(导出常量)
501
+ - `DEFAULT_THEME_ID` L63(导出常量)
502
+ - `isHexColor` L67(导出)
503
+ - `mix` L72
504
+ - `readableOn` L90(导出)
505
+ - `themeOf` L102(导出)
506
+ - `rgba` L117
507
+ - `themeVars` L130(导出)
508
+ - `themeActive` L164(导出)
509
+ - `themeCss` L168(导出)
510
+ - `themeOptions` L176(导出)
511
+
512
+ ### `lib/yamlish.mjs`(419 行)
342
513
 
343
514
  YAML 子集:只服务 cordis.patch.yml 的读写
344
515
 
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(导出)
516
+ - `stripComment` L26
517
+ - `parseDoubleQuoted` L40
518
+ - `parseSingleQuoted` L66
519
+ - `parseFlow` L71
520
+ - `parseScalar` L144
521
+ - `parseYaml` L274(导出)
522
+ - `emitScalar` L288(导出)
523
+ - `emitYaml` L299(导出)
524
+ - `splitTopLevelItems` L345(导出)
525
+ - `upsertPatchItem` L379(导出)
526
+ - `findPatchItem` L408(导出)
356
527
 
357
- ### `lib/zip.mjs`(255 行)
528
+ ### `lib/zip.mjs`(267 行)
358
529
 
359
530
  最小 ZIP 读写(node:zlib,无依赖)
360
531
 
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(导出常量)
532
+ - `dosTime` L40
533
+ - `dosToDate` L49
534
+ - `safeEntryName` L60(导出)
535
+ - `alreadyCompressed` L86(导出)
536
+ - `writeZip` L99(导出)
537
+ - `findEocd` L176
538
+ - `readZip` L194(导出)
539
+ - `readZipText` L261(导出)
540
+ - `zipLimits` L266(导出常量)
541
+
542
+ ### `community/index.mjs`(30 行)
543
+
544
+ 附属小插件「社区资源」的路由表(浏览 / 详情 / 下载 / 上传 / 封面)
545
+
546
+ - `COMMUNITY_ID` L28(导出常量)
547
+ - `COMMUNITY_API` L29(导出常量)
548
+
549
+ ### `annotate/index.mjs`(63 行)
550
+
551
+ 附属小插件「代码标注」的路由表(读全仓标注 / 跑自检)
552
+
553
+ - `ANNOTATE_ID` L16(导出常量)
554
+ - `ANNOTATE_API` L17(导出常量)
555
+ - `annotateRoutes` L23(导出)
556
+
557
+ ### `plugin-tree/index.mjs`(75 行)
558
+
559
+ 附属小插件「插件树」的路由表(插件树 / 兼容树,带 3 秒缓存)
560
+
561
+ - `TREE_ID` L17(导出常量)
562
+ - `TREE_API` L18(导出常量)
563
+ - `queryNames` L24
564
+ - `cacheKey` L34
565
+ - `treeRoutes` L50(导出)
370
566
 
371
567
  ## 4. 常见改动的连锁清单
372
568
 
@@ -374,8 +570,11 @@ YAML 子集:只服务 cordis.patch.yml 的读写
374
570
  - **加一条路由**:`index.js` 里 `route("/dsh-modpack-kit/api/…")` → 客户端 `api("/…")` → `dev/tools/verify.cjs` 的路由数 → `test/host-smoke.mjs` 补一条 HTTP 用例。旧宿主没有该路由时会回 404/405,`client.js` 的 `api()` 会提示「重启 DSH」。
375
571
  - **加一个社区资源字段**:`_market/modpack-catalog/scripts/build.mjs`(校验 + 输出)→ `lib/modpack-catalog.mjs` 的 `normalizeCatalog` → `client.js` 的 `renderRow` / 详情块 → `_market/modpack-catalog/README.md` 的条目格式表。
376
572
  - **加一种打包策略或改策略判定**:`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`(刷新本文件)。
573
+ - **改界面文案**:`client.js` 里的中文字面量;`locale/zh.json`、`locale/en.json` 的 `meta.title/description`;`README.md`;`docs/DETAIL.md`;注意测试里有硬断言(例如旧名「整合包市场」不许出现);市场介绍那段统一改 `docs/MARKET.txt`,再跑 `dev/tools/market-text.mjs` 同步。
574
+ - **加一个附属小插件**:`lib/subplugins.mjs` 的 `SUBPLUGINS` → 新目录的 `manifest.json`(id/apiVersion/configKey/routes)与 `index.mjs`(导出 `*Routes()`)→ `index.js` 的 `mountSubRoutes(...)` → `lib/store.mjs` 的 `DEFAULT_CONFIG` 加开关键 → `lib/plugin-graph.mjs` 的 `SUB_FILES` → `package.json` 的 `files` → `client.js` 的卡片与设置页。
575
+ - **给源文件加/改代码标注**:标注块在文件最上面的 `/** … */`(`@file` 必须等于相对路径,`@role/@risk/@touch` 必需),改完跑 `POST /api/annotate/check` 或 `lib/annotate.mjs` 的 `checkAnnotations()` 自检;新文件加进 `runtimeFiles` 的扫描范围即可。
576
+ - **看整套代码结构**:`docs/ANNOTATIONS.md`(`dev/tools/annotations.mjs` 生成,一页列出每个文件的职责 / 能力 / 改坏的后果),比翻源码快;它过期了 `test/run.mjs` 会红。
577
+ - **改完固定收尾**:`test/run.mjs`、`DSH_MODPACK_OFFLINE=1 test/host-smoke.mjs`、`dev/tools/sync.cjs`、`dev/tools/verify.cjs`、`dev/tools/map.mjs`(刷新本文件);界面改动可用 `dev/tools/ui-preview.mjs` 导出 HTML 截图核对。
379
578
 
380
579
  ## 5. 检索示例
381
580