@hyzyn/dsh-safe 0.10.0 → 0.11.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/README.en.md CHANGED
@@ -48,7 +48,7 @@ Error: dsh: plugin tree failed to load: failed to apply loader entry smoke-broke
48
48
  | `dsh-safe doctor` | environment check: versions, DSH_HOME, profiles, ledger, patch health |
49
49
  | `dsh-safe restore [--profile <name>] (--id <id> \| --all) [--dry-run]` | re-enable auto-disabled plugins (omit `--profile` to cover every profile in the ledger) |
50
50
  | `dsh-safe explain [id] [--profile <name> \| --file <path>]` | interpret failure info with AI: an `id` interprets that quarantine record (with repair advice); defaults to the last failure log, falling back to the ledger; `--file`/stdin read any log (needs `DSH_SAFE_AI_KEY`) |
51
- | `dsh-safe repair [id] [--profile <name>] [--to <version>] [-y] [--dry-run]` | reinstall/upgrade a quarantined plugin and auto-restore it (module-resolution failures only; installs via `dsh plugin`'s pnpm channel) |
51
+ | `dsh-safe repair [id] [--profile <name>] [--to <version>] [-y] [--dry-run]` | reinstall/upgrade a quarantined plugin and auto-restore it (failures a reinstall/upgrade may fix: package resolution, export mismatches; installs via `dsh plugin`'s pnpm channel) |
52
52
  | `dsh-safe help` (`-h` / `--help`) | show help |
53
53
  | `dsh-safe --version` (`-V`) | show version |
54
54
 
package/README.md CHANGED
@@ -48,7 +48,7 @@ Error: dsh: plugin tree failed to load: failed to apply loader entry smoke-broke
48
48
  | `dsh-safe doctor` | 环境体检:版本、DSH_HOME、profiles、台账、各 patch 健康度 |
49
49
  | `dsh-safe restore [--profile <名>] (--id <id> \| --all) [--dry-run]` | 恢复被自动禁用的插件(省略 `--profile` 时遍历台账全部 profile) |
50
50
  | `dsh-safe explain [id] [--profile <名> \| --file <路径>]` | 用 AI 解读失败信息:指定 `id` 解读该条隔离记录(给 repair 建议);默认解读最近一次失败日志,无日志则解读隔离台账;`--file`/stdin 读任意日志(需 `DSH_SAFE_AI_KEY`) |
51
- | `dsh-safe repair [id] [--profile <名>] [--to <版本>] [-y] [--dry-run]` | 重装/升级被隔离的插件并自动恢复(限模块解析失败类;经 `dsh plugin` 的 pnpm 通道安装) |
51
+ | `dsh-safe repair [id] [--profile <名>] [--to <版本>] [-y] [--dry-run]` | 重装/升级被隔离的插件并自动恢复(限重装/升级可能修复的失败:包解析失败、导出版本不匹配等;经 `dsh plugin` 的 pnpm 通道安装) |
52
52
  | `dsh-safe help`(`-h` / `--help`) | 显示帮助 |
53
53
  | `dsh-safe --version`(`-V`) | 显示版本 |
54
54
 
package/lib/i18n.js CHANGED
@@ -26,7 +26,7 @@ const ZH = {
26
26
  升级 dsh 与 dsh-safe 自身,并自动恢复被隔离的插件
27
27
  dsh-safe explain [id] [--profile <名> | --file <路径>] 用 AI 解读:最近失败日志 / 隔离台账 / 任意日志
28
28
  dsh-safe repair [id] [--profile <名>] [--to <版本>] [-y] [--dry-run]
29
- 重装/升级被隔离的插件并自动恢复(限模块解析失败类;省略 id 时只有一条记录则直接修)
29
+ 重装/升级被隔离的插件并自动恢复(限包解析/导出不匹配类;省略 id 时只有一条记录则直接修)
30
30
  dsh-safe help 显示本帮助
31
31
  dsh-safe --version 显示版本
32
32
 
@@ -133,7 +133,7 @@ const ZH = {
133
133
  repairNotSupportedTag: '(不支持自动修复)',
134
134
  repairEntryMissing: '[dsh-safe] 台账里没有找到 {id} 对应的隔离记录。',
135
135
  repairAmbiguous: '[dsh-safe] {id} 在多个 profile 中都有隔离记录({profiles}),请用 --profile <名> 指定。',
136
- repairUnsupported: '[dsh-safe] 该失败类型不支持自动修复(仅限模块解析失败类)。原因: {reason}\n 可用 dsh-safe explain 查看解读。',
136
+ repairUnsupported: '[dsh-safe] 该失败类型不支持自动修复(可修复范围:包解析失败、导出版本不匹配等重装/升级可能修复的问题)。原因: {reason}\n 可用 dsh-safe explain 查看解读。',
137
137
  repairPlan: '[dsh-safe] 将在 profile {profile} 中修复 {name}:执行 {command},成功后自动摘除隔离行',
138
138
  repairInstallFailed: '[dsh-safe] 插件安装失败(退出码 {code}),隔离状态保持不变。',
139
139
  repairDone: '[dsh-safe] 修复完成:跑 dsh-safe <启动命令> 验证;若仍失败会被自动重新隔离。',
@@ -160,7 +160,7 @@ Usage:
160
160
  upgrade dsh and dsh-safe itself, auto-restore quarantined plugins
161
161
  dsh-safe explain [id] [--profile <name> | --file <path>] interpret with AI: last failure log / ledger / any log
162
162
  dsh-safe repair [id] [--profile <name>] [--to <ver>] [-y] [--dry-run]
163
- reinstall/upgrade a quarantined plugin and auto-restore it (module-resolution failures only; omit id when there is exactly one record)
163
+ reinstall/upgrade a quarantined plugin and auto-restore it (resolution/export-mismatch failures; omit id when there is exactly one record)
164
164
  dsh-safe help show this help
165
165
  dsh-safe --version show version
166
166
 
@@ -270,7 +270,7 @@ Notes:
270
270
  repairNotSupportedTag: ' (not auto-repairable)',
271
271
  repairEntryMissing: '[dsh-safe] no quarantine record found for {id}.',
272
272
  repairAmbiguous: '[dsh-safe] {id} is quarantined in multiple profiles ({profiles}); specify one with --profile <name>.',
273
- repairUnsupported: '[dsh-safe] this failure type cannot be auto-repaired (module-resolution failures only). Reason: {reason}\n try dsh-safe explain for an interpretation.',
273
+ repairUnsupported: '[dsh-safe] this failure type cannot be auto-repaired (repairable: package-resolution failures, export mismatches — problems a reinstall/upgrade may fix). Reason: {reason}\n try dsh-safe explain for an interpretation.',
274
274
  repairPlan: '[dsh-safe] repairing {name} in profile {profile}: running {command}, then the quarantine row is removed automatically',
275
275
  repairInstallFailed: '[dsh-safe] plugin install failed (exit code {code}); quarantine state left unchanged.',
276
276
  repairDone: '[dsh-safe] repair finished: run dsh-safe <boot command> to verify; a still-broken plugin will be auto-quarantined again.',
package/lib/repair.js CHANGED
@@ -20,8 +20,16 @@ import { t } from './i18n.js'
20
20
  const err = (line) => process.stderr.write(`${line}\n`)
21
21
  const out = (line) => process.stdout.write(`${line}\n`)
22
22
 
23
- /** 台账 reason 里判定"模块解析失败"的特征。 */
24
- const RESOLVE_FAIL_RE = /Cannot find package|could not be resolved|ERR_MODULE_NOT_FOUND/i
23
+ /**
24
+ * repair 可修复的失败特征:问题出在"包的安装状态或版本适配"上,重装/升级
25
+ * 插件包可能修复——
26
+ * - 模块解析失败:包缺失/损坏/未安装 → 重装即愈;
27
+ * - ESM 导出不匹配(does not provide an export/import binding):插件与
28
+ * 当前 dsh API 版本不兼容,升级插件到适配版本可能修复(真实案例:
29
+ * describe-image 隔离于 dsh-settings 导出变更)。修复失败不恢复、无损。
30
+ */
31
+ const REPAIRABLE_RE =
32
+ /Cannot find package|could not be resolved|ERR_MODULE_NOT_FOUND|does not provide an (?:export|import binding)/i
25
33
 
26
34
  function parseRepairArgs(args) {
27
35
  const opts = { id: undefined, profile: undefined, to: undefined, yes: false, dryRun: false }
@@ -85,7 +93,7 @@ export async function cmdRepair(args, { spawn = spawnSync, log = err, write = ou
85
93
  if (matches.length > 1) {
86
94
  log(t('repairPickOne', { count: matches.length }))
87
95
  for (const m of matches) {
88
- const repairable = RESOLVE_FAIL_RE.test(m.entry.reason ?? '')
96
+ const repairable = REPAIRABLE_RE.test(m.entry.reason ?? '')
89
97
  log(` - ${m.entry.id}(${m.entry.name ?? '-'})${repairable ? '' : t('repairNotSupportedTag')}`)
90
98
  }
91
99
  return 0
@@ -104,7 +112,7 @@ export async function cmdRepair(args, { spawn = spawnSync, log = err, write = ou
104
112
  const name = entry.name ?? entry.id
105
113
 
106
114
  // 类别门禁:只修"模块解析失败"类
107
- if (!RESOLVE_FAIL_RE.test(entry.reason ?? '')) {
115
+ if (!REPAIRABLE_RE.test(entry.reason ?? '')) {
108
116
  log(t('repairUnsupported', { reason: summarizeLine(entry.reason) }))
109
117
  return 1
110
118
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyzyn/dsh-safe",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "dsh 启动保险丝:社区插件不兼容导致 dsh 启动失败时,自动禁用坏插件并重试",
5
5
  "type": "module",
6
6
  "license": "MIT",