dsh-modpack-kit 0.2.4 → 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,61 +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`,共 38 条)
54
+ ## 2. 路由表(`index.js`,共 44 条)
42
55
 
43
56
  | 路由 | 行 |
44
57
  | --- | --- |
45
- | `status` | 315 |
46
- | `settings` | 321 |
47
- | `catalog` | 342 |
48
- | `catalog/status` | 352 |
49
- | `catalog/lookup` | 364 |
50
- | `catalog/sync` | 375 |
51
- | `catalog/search` | 386 |
52
- | `market` | 421 |
53
- | `market/search` | 439 |
54
- | `market/sync` | 463 |
55
- | `upload/status` | 477 |
56
- | `upload/token` | 494 |
57
- | `upload/preview` | 520 |
58
- | `upload/submit` | 598 |
59
- | `market/preview` | 847 |
60
- | `market/download` | 890 |
61
- | `versions` | 977 |
62
- | `pack/plan` | 1279 |
63
- | `plugin/install` | 1291 |
64
- | `pack` | 1333 |
65
- | `jobs/ack` | 1357 |
66
- | `jobs/dismiss` | 1392 |
67
- | `jobs/clear` | 1405 |
68
- | `jobs/cancel` | 1424 |
69
- | `jobs` | 1447 |
70
- | `download` | 1454 |
71
- | `save` | 1469 |
72
- | `packs` | 1508 |
73
- | `packs/open` | 1524 |
74
- | `packs/remove` | 1539 |
75
- | `pack/drop` | 1564 |
76
- | `inspect` | 1629 |
77
- | `install` | 1826 |
78
- | `install/replace` | 1839 |
79
- | `history` | 1865 |
80
- | `history/clear` | 1871 |
81
- | `history/remove` | 1877 |
82
- | `plugin-summary` | 1885 |
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 |
83
102
 
84
103
  > 全部挂在 `/dsh-modpack-kit/api/` 下;路由体统一 `if (!needPost(req, res)) return` + `await readJsonBody(req)`,不要再写 `fenced()`。
85
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
+
86
127
  ## 3. 文件职责与符号
87
128
 
88
- ### `index.js`(1974 行)
129
+ ### `index.js`(2389 行)
89
130
 
90
131
  Host 侧:所有 HTTP 路由、打包/安装/市场编排、任务队列与进度
91
132
 
92
- ### `client.js`(3873 行)
133
+ - `runtimeFreshness` L60
134
+
135
+ ### `client.js`(5300 行)
93
136
 
94
137
  客户端:打包 / 安装·导入 / 社区资源 / 设置与记录 四块界面 + 悬浮进度窗
95
138
 
@@ -106,307 +149,420 @@ Host 侧:所有 HTTP 路由、打包/安装/市场编排、任务队列与进
106
149
  - `restoreGroups` L335
107
150
  - `restoreData` L399
108
151
 
109
- ### `lib/classify.mjs`(106 行)
152
+ ### `lib/annotate.mjs`(173 行)
110
153
 
111
- 把插件名/描述映射到插件市场的 23 个分类(纯字符串匹配)
154
+ 代码标注协议:解析每个源文件头部的 @file/@role/… 块,跑全仓自检
112
155
 
113
- - `CATEGORIES` L12(导出常量)
114
- - `hit` L51
115
- - `classifyPlugin` L67(导出)
116
- - `categoryLabel` L103(导出)
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(导出)
117
165
 
118
- ### `lib/community.mjs`(67 行)
166
+ ### `lib/classify.mjs`(117 行)
119
167
 
168
+ 把插件名/描述映射到插件市场的 23 个分类(纯字符串匹配)
120
169
 
170
+ - `CATEGORIES` L23(导出常量)
171
+ - `hit` L62
172
+ - `classifyPlugin` L78(导出)
173
+ - `categoryLabel` L114(导出)
121
174
 
122
- - `COMMUNITY_ID` L12(导出常量)
123
- - `COMMUNITY_API` L13(导出常量)
124
- - `readBuiltinManifest` L17(导出)
125
- - `readExternal` L25
126
- - `resolveCommunity` L42(导出)
175
+ ### `lib/community.mjs`(78 行)
127
176
 
128
- ### `lib/compat.mjs`(114 行)
177
+ 附属小插件「社区资源」的登记与开关解析(内置清单 / 外部实现 / 是否启用)
129
178
 
130
- 兼容性判定:peer 依赖、engines、license、版本差异;按打包策略给不同建议
179
+ - `COMMUNITY_ID` L23(导出常量)
180
+ - `COMMUNITY_API` L24(导出常量)
181
+ - `readBuiltinManifest` L28(导出)
182
+ - `readExternal` L36
183
+ - `resolveCommunity` L53(导出)
131
184
 
132
- - `versionOf` L12
133
- - `checkCompatibility` L21(导出)
185
+ ### `lib/compat.mjs`(125 行)
134
186
 
135
- ### `lib/github.mjs`(290 行)
187
+ 兼容性判定:peer 依赖、engines、license、版本差异;按打包策略给不同建议
136
188
 
189
+ - `versionOf` L23
190
+ - `checkCompatibility` L32(导出)
137
191
 
192
+ ### `lib/github.mjs`(301 行)
138
193
 
139
- - `run` L14
140
- - `gh` L30(导出)
141
- - `whoAmI` L71(导出)
142
- - `ensureFork` L77(导出)
143
- - `openPackPullRequest` L103(导出)
144
- - `entryFileName` L184(导出)
145
- - `packFileName` L190(导出)
146
- - `runRaw` L195
147
- - `parseStatus` L208
148
- - `ensureRelease` L219(导出)
149
- - `uploadReleaseAsset` L241(导出)
194
+ GitHub 写接口:fork、Release 资产、改词条、开 PR(一键上传)
150
195
 
151
- ### `lib/groups.mjs`(148 行)
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(导出)
207
+
208
+ ### `lib/groups.mjs`(160 行)
152
209
 
153
210
  读插件市场的分组(.dsh-market/state.json),装完后并入/重名避让
154
211
 
155
- - `marketStatePath` L16(导出)
156
- - `stringList` L20
157
- - `readMarketGroups` L34(导出)
158
- - `groupViews` L62(导出)
159
- - `hasMarket` L77(导出)
160
- - `applyMarketGroups` L94(导出)
212
+ - `marketStatePath` L28(导出)
213
+ - `stringList` L32
214
+ - `readMarketGroups` L46(导出)
215
+ - `groupViews` L74(导出)
216
+ - `hasMarket` L89(导出)
217
+ - `applyMarketGroups` L106(导出)
161
218
 
162
- ### `lib/http.mjs`(42 行)
219
+ ### `lib/http.mjs`(52 行)
163
220
 
164
221
  读请求体、发 JSON 响应、needPost 等方法判定
165
222
 
166
- - `MAX_JSON_BODY` L7(导出常量)
167
- - `MAX_DROP_BODY` L9(导出常量)
168
- - `sendJson` L11(导出)
169
- - `readBody` L32(导出常量)
170
- - `readRawBody` L34(导出常量)
171
- - `readJsonBody` L37(导出常量)
172
- - `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(导出)
173
230
 
174
- ### `lib/install.mjs`(701 行)
231
+ ### `lib/install.mjs`(713 行)
175
232
 
176
233
  读包 → 扫描 → 按策略装(市场版优先 / 包内副本回退)→ 回填配置与分组
177
234
 
178
- - `inspectPackBuffer` L53(导出)
179
- - `readPackFromUrl` L126(导出)
180
- - `pluginPayload` L134
181
- - `materializePayload` L143(导出)
182
- - `packDirOf` L166
183
- - `installPack` L179(导出)
235
+ - `inspectPackBuffer` L65(导出)
236
+ - `readPackFromUrl` L138(导出)
237
+ - `pluginPayload` L146
238
+ - `materializePayload` L155(导出)
239
+ - `packDirOf` L178
240
+ - `installPack` L191(导出)
184
241
 
185
- ### `lib/manifest.mjs`(226 行)
242
+ ### `lib/manifest.mjs`(238 行)
186
243
 
187
244
  dsh-modpack.json 的构造、归一化、校验与包内 README 生成
188
245
 
189
- - `SCHEMA` L9(导出常量)
190
- - `KIND` L10(导出常量)
191
- - `MANIFEST_NAME` L11(导出常量)
192
- - `sha256` L13(导出常量)
193
- - `shortHash` L14(导出常量)
194
- - `normalizePlugin` L20
195
- - `normalizeManifest` L85(导出)
196
- - `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(导出)
197
254
 
198
- ### `lib/market-catalog.mjs`(424 行)
255
+ ### `lib/market-catalog.mjs`(436 行)
199
256
 
200
257
  插件市场目录(分类 + 分页搜索 + 已装优先),数据源是 npm 包 dsh-plugin-catalog
201
258
 
202
- - `CATEGORY_FALLBACK` L23(导出常量)
203
- - `CATALOG_SOURCES` L50(导出常量)
204
- - `PAGE_SIZE_DEFAULT` L55(导出常量)
205
- - `catalogPaths` L60(导出)
206
- - `categoriesOf` L68(导出)
207
- - `normalizePlugin` L85
208
- - `buildIndex` L121(导出)
209
- - `readIndex` L141(导出)
210
- - `writeIndex` L165(导出)
211
- - `catalogSummary` L173(导出)
212
- - `fetchSource` L202
213
- - `syncCatalog` L217(导出)
214
- - `relevance` L246
215
- - `searchCatalog` L286(导出)
216
- - `categoryMapFor` L392(导出)
217
- - `lookupPlugins` L404(导出)
218
-
219
- ### `lib/modpack-catalog.mjs`(383 行)
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 行)
220
277
 
221
278
  社区资源目录(自建仓库 packs.json):同步、缓存、检索、取包
222
279
 
223
- - `MARKET_REPO` L31(导出常量)
224
- - `MARKET_BRANCH` L32(导出常量)
225
- - `MARKET_SOURCES` L34(导出常量)
226
- - `CATEGORY_FALLBACK` L43(导出常量)
227
- - `TIER_BANDS` L56(导出常量)
228
- - `tierOf` L63(导出)
229
- - `marketPaths` L69(导出)
230
- - `readCache` L77
231
- - `writeCache` L101
232
- - `normalizeCatalog` L115
233
- - `sourceBaseOf` L191
234
- - `packFileUrl` L196(导出)
235
- - `marketSummary` L208(导出)
236
- - `syncMarket` L242(导出)
237
- - `installedState` L278
238
- - `relevance` L286
239
- - `searchMarket` L310(导出)
240
- - `fetchMarketPack` L363(导出)
241
- - `findMarketPack` L376(导出)
242
-
243
- ### `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 行)
244
301
 
245
302
  网络层:https 白名单、逐跳校验、体积上限、重试、curl 兜底
246
303
 
247
- - `NET_DEFAULTS` L12(导出常量)
248
- - `assertAllowedUrl` L23(导出)
249
- - `netOptions` L39
250
- - `parseCurlResponse` L49(导出)
251
- - `curlOnce` L64
252
- - `fetchOnce` L84
253
- - `requestBuffer` L117(导出)
254
- - `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(导出)
255
312
 
256
- ### `lib/pack.mjs`(665 行)
313
+ ### `lib/pack.mjs`(677 行)
257
314
 
258
315
  打包:收集插件 → 抓配置/数据 → 扫描 → 写清单与安装器 → 压 zip
259
316
 
260
- - `collectFiles` L39(导出)
261
- - `readInstalledPlugin` L81(导出)
262
- - `REDACTED` L114(导出常量)
263
- - `normalizeConfigKey` L116(导出)
264
- - `redactConfig` L123(导出)
265
- - `captureConfigs` L149(导出)
266
- - `dataDirsFor` L195
267
- - `scrubText` L223
268
- - `captureData` L234(导出)
269
- - `licenseId` L282
270
- - `authorOf` L289
271
- - `buildPack` L302(导出)
272
-
273
- ### `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 行)
274
364
 
275
365
  读写 profile:已装列表、bundles、cordis.patch.yml、调官方 CLI
276
366
 
277
- - `readJson` L15(导出)
278
- - `readProfilePackage` L23(导出)
279
- - `listInstalled` L27(导出)
280
- - `dshVersion` L139(导出)
281
- - `readBundles` L147(导出)
282
- - `backup` L152
283
- - `ensureBundles` L161(导出)
284
- - `setBundles` L183(导出)
285
- - `patchPath` L198(导出)
286
- - `readPatch` L202(导出)
287
- - `writePatch` L211(导出)
288
- - `cliPath` L220
289
- - `cliEntry` L227
290
- - `quoteArg` L239
291
- - `safeArg` L245
292
- - `normalizePluginArgs` L250
293
- - `decodeOutput` L262
294
- - `runDshPlugin` L276(导出)
295
-
296
- ### `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 行)
297
387
 
298
388
  从 npm 取版本清单与 tarball(三层退让 + curl 兜底)
299
389
 
300
- - `fetchLimited` L17(导出常量)
301
- - `fetchJson` L18(导出常量)
302
- - `validatePackageName` L20(导出)
303
- - `metadataLimit` L36(导出)
304
- - `probeRegistry` L54(导出)
305
- - `npmMetadata` L71(导出)
306
- - `pickVersion` L125(导出)
307
- - `relativeTime` L142(导出)
308
- - `downloadPackage` L153(导出)
309
- - `fetchCatalog` L196(导出)
310
- - `npmSearchCatalog` L211(导出)
311
-
312
- ### `lib/repack.mjs`(58 行)
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(导出)
313
401
 
402
+ ### `lib/repack.mjs`(69 行)
314
403
 
404
+ 轻量重打包:只改清单里几个字段,其余字节原样保留
315
405
 
316
- - `rewritePackManifest` L11(导出)
406
+ - `rewritePackManifest` L22(导出)
317
407
 
318
- ### `lib/scan.mjs`(347 行)
408
+ ### `lib/scan.mjs`(359 行)
319
409
 
320
410
  安全检测:敏感信息 + 恶意代码痕迹;按来源分组;同内容去重
321
411
 
322
- - `scanFileName` L66(导出)
323
- - `maskSecret` L75
324
- - `maskAll` L81
325
- - `findingOf` L86
326
- - `looksBinary` L98(导出)
327
- - `extOf` L104
328
- - `lineAt` L110
329
- - `scanFile` L122(导出)
330
- - `groupFindings` L193(导出)
331
- - `severityRank` L235(导出)
332
- - `scanEntries` L244(导出)
333
- - `renderScanReport` L311(导出)
334
-
335
- ### `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 行)
336
426
 
337
427
  极小 semver 实现(判断兼容性用)
338
428
 
339
- - `parseVersion` L11(导出)
340
- - `compareVersions` L18(导出)
341
- - `bound` L33
342
- - `parseComparatorSet` L38
343
- - `testBounds` L103
344
- - `satisfies` L119(导出)
429
+ - `parseVersion` L21(导出)
430
+ - `compareVersions` L28(导出)
431
+ - `bound` L43
432
+ - `parseComparatorSet` L48
433
+ - `testBounds` L113
434
+ - `satisfies` L129(导出)
345
435
 
346
- ### `lib/store.mjs`(245 行)
436
+ ### `lib/store.mjs`(283 行)
347
437
 
348
438
  本地状态:settings.json / history.json / 目录路径 / 默认配置与 clamp
349
439
 
350
- - `dshHome` L13(导出)
351
- - `pluginHome` L17(导出)
352
- - `profileName` L21(导出)
353
- - `profileDir` L27(导出)
354
- - `HOSTS_VERSION` L31(导出常量)
355
- - `NET_VERSION` L33(导出常量)
356
- - `DEFAULT_CONFIG` L35(导出常量)
357
- - `pathsFor` L98(导出)
358
- - `clampConfig` L111(导出)
359
- - `loadConfig` L154(导出)
360
- - `writeJsonAtomic` L177(导出)
361
- - `saveConfig` L184(导出)
362
- - `readHistory` L190(导出)
363
- - `appendHistory` L199(导出)
364
- - `clearHistory` L207(导出)
365
- - `removeHistory` L213(导出)
366
- - `appendLog` L220(导出)
367
- - `slugify` L230(导出)
368
- - `ensureDir` L241(导出)
369
-
370
- ### `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 行)
371
472
 
372
473
  读 .tgz(npm 包)
373
474
 
374
- - `readString` L14
375
- - `readOctal` L20
376
- - `parsePax` L27
377
- - `readTarball` L48(导出)
378
- - `stripPackagePrefix` L98(导出)
379
- - `tarLimits` L107(导出常量)
380
-
381
- ### `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 行)
382
513
 
383
514
  YAML 子集:只服务 cordis.patch.yml 的读写
384
515
 
385
- - `stripComment` L15
386
- - `parseDoubleQuoted` L29
387
- - `parseSingleQuoted` L55
388
- - `parseFlow` L60
389
- - `parseScalar` L133
390
- - `parseYaml` L263(导出)
391
- - `emitScalar` L277(导出)
392
- - `emitYaml` L288(导出)
393
- - `splitTopLevelItems` L334(导出)
394
- - `upsertPatchItem` L368(导出)
395
- - `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(导出)
396
527
 
397
- ### `lib/zip.mjs`(255 行)
528
+ ### `lib/zip.mjs`(267 行)
398
529
 
399
530
  最小 ZIP 读写(node:zlib,无依赖)
400
531
 
401
- - `dosTime` L28
402
- - `dosToDate` L37
403
- - `safeEntryName` L48(导出)
404
- - `alreadyCompressed` L74(导出)
405
- - `writeZip` L87(导出)
406
- - `findEocd` L164
407
- - `readZip` L182(导出)
408
- - `readZipText` L249(导出)
409
- - `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(导出)
410
566
 
411
567
  ## 4. 常见改动的连锁清单
412
568
 
@@ -415,7 +571,10 @@ YAML 子集:只服务 cordis.patch.yml 的读写
415
571
  - **加一个社区资源字段**:`_market/modpack-catalog/scripts/build.mjs`(校验 + 输出)→ `lib/modpack-catalog.mjs` 的 `normalizeCatalog` → `client.js` 的 `renderRow` / 详情块 → `_market/modpack-catalog/README.md` 的条目格式表。
416
572
  - **加一种打包策略或改策略判定**:`lib/pack.mjs`(`strategy` / `embedded`)→ `lib/manifest.mjs`(`format` 归一化)→ `index.js` 的 `computePlan` 与 `/pack/plan` → `client.js` 的 `STRATEGY_INFO` 与卡片 → `lib/install.mjs`(按 `embedded` 决定走市场版还是包内副本)→ 测试。
417
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` 同步。
418
- - **改完固定收尾**:`test/run.mjs`、`DSH_MODPACK_OFFLINE=1 test/host-smoke.mjs`、`dev/tools/sync.cjs`、`dev/tools/verify.cjs`、`dev/tools/map.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 截图核对。
419
578
 
420
579
  ## 5. 检索示例
421
580