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/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
- const keyStart = i
107
- while (i < text.length && text[i] !== ':') i += 1
108
- const key = text.slice(keyStart, i).trim()
109
- i += 1
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 nested = emitYaml(v, indent + 2).split('\n')
304
- if (Array.isArray(v) || Object.keys(v).length > 0) {
305
- lines.push(pad + emitScalar(key) + ':')
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
- const deflated = deflateRawSync(data, { level: 9 })
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": "Bundle several plugins into one .dshpack and install them in a single pass: full packs carry the payloads, lite packs record names and versions and fetch them from the registry, and both ship a standalone installer so a machine with nothing but a bare DSH can still install. Each plugin can be packed as upstream-basic or as your local copy. Packing always runs an in-memory scan for secrets and risky code (masked, never written to disk); high-risk hits pause the job until you confirm, and the confirmation is recorded in the manifest. Installing re-checks integrity, compatibility and licences, then re-applies the packed config, with options to install without enabling or to enable right away. Categories, search, sorting and entries come from the same plugin-market catalog (first screen lists only what you have, paged on the server), and the UI can be shown in settings, the sidebar or the plugins tab, each switchable. Installing the plugin market (dshmarket) first is recommended but not required.",
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": "把多个插件打成一个 .dshpack,一次装好:完整版自带插件本体,轻量版只记名字与版本、安装时按记录取包;两种包都附独立安装器,对方只剩一个 DSH 本体也能装。每个插件可单独选「基础配置」或「本地改动」。打包前强制做敏感信息与风险代码检测(命中只留掩码、原文不落盘),检出高危会先停下来,确认后才继续,确认状态写进清单;安装前再查完整性、兼容性与许可证,装完按条目回填配置,也可选先不启用或装完直接启用。分类、搜索、排序与条目都跟插件市场同源(首屏只列已装、服务端分页),三处入口(设置 / 侧边栏 / 插件页)可各自开关。建议先装插件市场(dshmarket)再一起用——不装也能打包、装包与检测,只是少了它的界面与市场版对照。",
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.3",
4
- "description": "Bundle several plugins into one .dshpack and install them in a single pass: full packs carry the payloads, lite packs record names and versions and fetch them from the registry, and both ship a standalone installer so a machine with nothing but a bare DSH can still install. Each plugin can be packed as upstream-basic or as your local copy. Packing always runs an in-memory scan for secrets and risky code (masked, never written to disk); high-risk hits pause the job until you confirm, and the confirmation is recorded in the manifest. Installing re-checks integrity, compatibility and licences, then re-applies the packed config, with options to install without enabling or to enable right away. Categories, search, sorting and entries come from the same plugin-market catalog (first screen lists only what you have, paged on the server), and the UI can be shown in settings, the sidebar or the plugins tab, each switchable. Installing the plugin market (dshmarket) first is recommended but not required.",
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": {