dsh-modpack-kit 0.1.3 → 0.1.5
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 +104 -24
- package/assets/install-stub.mjs +78 -3
- package/client.js +408 -45
- package/docs/DETAIL.md +57 -12
- package/index.js +341 -66
- package/lib/install.mjs +196 -44
- package/lib/manifest.mjs +24 -2
- package/lib/pack.mjs +114 -7
- package/lib/scan.mjs +21 -0
- package/lib/store.mjs +7 -0
- package/lib/yamlish.mjs +19 -9
- package/lib/zip.mjs +22 -2
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +2 -2
package/lib/yamlish.mjs
CHANGED
|
@@ -103,10 +103,19 @@ function parseFlow(text) {
|
|
|
103
103
|
if (text[i] === '}') { i += 1; return out }
|
|
104
104
|
for (;;) {
|
|
105
105
|
ws()
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
106
|
+
let key
|
|
107
|
+
if (text[i] === '"' || text[i] === "'") {
|
|
108
|
+
// 用 JSON 写出来的 flow 映射键是带引号的,这里必须去引号,否则读回来会多出一层引号。
|
|
109
|
+
key = scalar()
|
|
110
|
+
ws()
|
|
111
|
+
if (text[i] !== ':') throw new YamlError('flow 映射缺少冒号:' + text)
|
|
112
|
+
i += 1
|
|
113
|
+
} else {
|
|
114
|
+
const keyStart = i
|
|
115
|
+
while (i < text.length && text[i] !== ':') i += 1
|
|
116
|
+
key = text.slice(keyStart, i).trim()
|
|
117
|
+
i += 1
|
|
118
|
+
}
|
|
110
119
|
out[key] = scalar()
|
|
111
120
|
ws()
|
|
112
121
|
if (text[i] === ',') { i += 1; continue }
|
|
@@ -300,12 +309,13 @@ export function emitYaml(value, indent = 0) {
|
|
|
300
309
|
for (const key of keys) {
|
|
301
310
|
const v = value[key]
|
|
302
311
|
if (v !== null && typeof v === 'object') {
|
|
303
|
-
const
|
|
304
|
-
if (
|
|
305
|
-
|
|
306
|
-
lines.push(...nested)
|
|
307
|
-
} else {
|
|
312
|
+
const isEmpty = Array.isArray(v) ? v.length === 0 : Object.keys(v).length === 0
|
|
313
|
+
if (isEmpty) {
|
|
314
|
+
// 空数组/空对象必须写在同一行:写成「key:」再另起一行「[]」是非法 YAML。
|
|
308
315
|
lines.push(pad + emitScalar(key) + ': ' + (Array.isArray(v) ? '[]' : '{}'))
|
|
316
|
+
} else {
|
|
317
|
+
lines.push(pad + emitScalar(key) + ':')
|
|
318
|
+
lines.push(...emitYaml(v, indent + 2).split('\n'))
|
|
309
319
|
}
|
|
310
320
|
} else {
|
|
311
321
|
lines.push(pad + emitScalar(key) + ': ' + emitScalar(v))
|
package/lib/zip.mjs
CHANGED
|
@@ -60,6 +60,24 @@ export function safeEntryName(raw) {
|
|
|
60
60
|
return parts.join('/')
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
/**
|
|
64
|
+
* 已经是压缩格式的文件再 deflate 一遍收益几乎是零,纯白烧 CPU。
|
|
65
|
+
* 按扩展名跳过(图片/音视频/归档/字体),其余照常压。
|
|
66
|
+
*/
|
|
67
|
+
const PRECOMPRESSED_EXT = new Set([
|
|
68
|
+
'.png', '.jpg', '.jpeg', '.gif', '.webp', '.ico', '.avif', '.bmp',
|
|
69
|
+
'.mp3', '.mp4', '.m4a', '.webm', '.ogg', '.opus', '.flac', '.wav',
|
|
70
|
+
'.zip', '.gz', '.tgz', '.bz2', '.xz', '.7z', '.rar', '.br', '.zst',
|
|
71
|
+
'.woff', '.woff2', '.ttf', '.otf', '.pdf', '.jar', '.class', '.node',
|
|
72
|
+
])
|
|
73
|
+
|
|
74
|
+
export function alreadyCompressed(name) {
|
|
75
|
+
const lower = String(name || '').toLowerCase()
|
|
76
|
+
const dot = lower.lastIndexOf('.')
|
|
77
|
+
if (dot < 0) return false
|
|
78
|
+
return PRECOMPRESSED_EXT.has(lower.slice(dot))
|
|
79
|
+
}
|
|
80
|
+
|
|
63
81
|
/**
|
|
64
82
|
* 写 zip。
|
|
65
83
|
* @param {{name: string, data: Buffer|string, compress?: boolean}[]} entries
|
|
@@ -81,8 +99,10 @@ export function writeZip(entries, options = {}) {
|
|
|
81
99
|
const crc = crc32(data) >>> 0
|
|
82
100
|
let method = 0
|
|
83
101
|
let body = data
|
|
84
|
-
if (entry.compress !== false && data.length > 128) {
|
|
85
|
-
|
|
102
|
+
if (entry.compress !== false && data.length > 128 && !alreadyCompressed(name)) {
|
|
103
|
+
// 大文件降到 6 级:9 级省下的那点体积不值那几倍 CPU,包越大差得越明显。
|
|
104
|
+
const level = data.length > 2 * 1024 * 1024 ? 6 : 9
|
|
105
|
+
const deflated = deflateRawSync(data, { level })
|
|
86
106
|
if (deflated.length < data.length) {
|
|
87
107
|
method = 8
|
|
88
108
|
body = deflated
|
package/locale/en.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "Modpack",
|
|
4
|
-
"description": "
|
|
4
|
+
"description": "Provides HMCL/PCL-style modpack packaging and installation for DeepSeek Harness: bundle several plugins with their configuration and data into one .dshpack and install it in a single pass. Two forms: a self-contained full pack that a machine with only DSH installed can install, and a lite pack that records names and versions and fetches them on install. Each plugin can be packed from its upstream release with default configuration or from a local copy (code, config entries, data snapshot); configuration is re-applied by entry, data is restored under ~/.dsh without overwriting existing files, and suspected credentials become ${REDACTED}. Categories, search, paging and entries come from the plugin-market catalog, and market versions are preferred when online. Packing always runs an in-memory scan for secrets and risky code (masked, never written to disk); high-risk hits pause the job until confirmed, then it resumes from the checkpoint without rescanning. Installation re-checks sha256 integrity, compatibility and licences, and can finish without enabling or enable right away. The UI can live in settings, the sidebar or the plugins tab, each switchable. Installing the plugin market (dshmarket) first is recommended, not required.",
|
|
5
5
|
"detail": "docs/DETAIL.md"
|
|
6
6
|
}
|
|
7
7
|
}
|
package/locale/zh.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "整合包",
|
|
4
|
-
"description": "
|
|
4
|
+
"description": "为 DeepSeek Harness 提供类似 HMCL / PCL 的整合包打包与安装:把多个插件连同各自的配置与数据打成一个 .dshpack 一次装好。支持懒人包(完整包,自带插件本体,目标机器只装 DSH 本体即可安装)与轻量包(只记录插件名与版本,安装时按记录取包);支持按插件逐个定制打包内容(基础配置或本地改动),配置按原结构回填、数据写回 ~/.dsh 且默认不覆盖已有文件,疑似凭据替换为 ${REDACTED};分类、搜索、分页与条目与插件市场目录同源,联网时可优先按市场版本安装。打包前强制做敏感信息与风险代码静态检测(命中只留掩码、原文不落盘),高风险停在「等决定」,确认后从检测点续跑、不重复扫描;安装前校验 sha256 完整性、兼容性与许可证,装完可选先不启用或直接启用;设置页、侧边栏、插件页三处入口各自独立开关。建议先安装插件市场(dshmarket),但不是必须。",
|
|
5
5
|
"detail": "docs/DETAIL.md"
|
|
6
6
|
}
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-modpack-kit",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.5",
|
|
4
|
+
"description": "Provides HMCL/PCL-style modpack packaging and installation for DeepSeek Harness: bundle several plugins with their configuration and data into one .dshpack and install it in a single pass. Two forms: a self-contained full pack that a machine with only DSH installed can install, and a lite pack that records names and versions and fetches them on install. Each plugin can be packed from its upstream release with default configuration or from a local copy (code, config entries, data snapshot); configuration is re-applied by entry, data is restored under ~/.dsh without overwriting existing files, and suspected credentials become ${REDACTED}. Categories, search, paging and entries come from the plugin-market catalog, and market versions are preferred when online. Packing always runs an in-memory scan for secrets and risky code (masked, never written to disk); high-risk hits pause the job until confirmed, then it resumes from the checkpoint without rescanning. Installation re-checks sha256 integrity, compatibility and licences, and can finish without enabling or enable right away. The UI can live in settings, the sidebar or the plugins tab, each switchable. Installing the plugin market (dshmarket) first is recommended, not required.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"exports": {
|