@hyzyn/dsh-safe 0.6.0 → 0.7.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 +1 -1
- package/README.md +1 -1
- package/lib/i18n.js +8 -6
- package/lib/repair.js +20 -4
- package/package.json +1 -1
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 [--file <path>]` | interpret a failed-boot stderr with AI (read-only, needs `DSH_SAFE_AI_KEY`) |
|
|
51
|
-
| `dsh-safe repair
|
|
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) |
|
|
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 [--file <路径>]` | 用 AI 解读一段启动失败 stderr(纯只读,需 `DSH_SAFE_AI_KEY`) |
|
|
51
|
-
| `dsh-safe repair
|
|
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
|
@@ -25,8 +25,8 @@ const ZH = {
|
|
|
25
25
|
dsh-safe update [-y] [--to <版本>] [--self] [--no-restore] [--no-verify] [--pm npm|pnpm]
|
|
26
26
|
升级 dsh 与 dsh-safe 自身,并自动恢复被隔离的插件
|
|
27
27
|
dsh-safe explain [--file <路径>] 用 AI 解读一段启动失败的 stderr(需 DSH_SAFE_AI_KEY)
|
|
28
|
-
dsh-safe repair
|
|
29
|
-
|
|
28
|
+
dsh-safe repair [id] [--profile <名>] [--to <版本>] [-y] [--dry-run]
|
|
29
|
+
重装/升级被隔离的插件并自动恢复(限模块解析失败类;省略 id 时只有一条记录则直接修)
|
|
30
30
|
dsh-safe help 显示本帮助
|
|
31
31
|
dsh-safe --version 显示版本
|
|
32
32
|
|
|
@@ -124,7 +124,8 @@ const ZH = {
|
|
|
124
124
|
doctorAIOff: 'AI 未启用(DSH_SAFE_AI_KEY 未设置)',
|
|
125
125
|
doctorCheckLast: '更新检查 上次 {time}',
|
|
126
126
|
doctorCheckNever: '更新检查 从未执行',
|
|
127
|
-
|
|
127
|
+
repairPickOne: '[dsh-safe] 共 {count} 条隔离记录,指定要修复的 id(dsh-safe repair <id>):',
|
|
128
|
+
repairNotSupportedTag: '(不支持自动修复)',
|
|
128
129
|
repairEntryMissing: '[dsh-safe] 台账里没有找到 {id} 对应的隔离记录。',
|
|
129
130
|
repairAmbiguous: '[dsh-safe] {id} 在多个 profile 中都有隔离记录({profiles}),请用 --profile <名> 指定。',
|
|
130
131
|
repairUnsupported: '[dsh-safe] 该失败类型不支持自动修复(仅限模块解析失败类)。原因: {reason}\n 可用 dsh-safe explain 查看解读。',
|
|
@@ -153,8 +154,8 @@ Usage:
|
|
|
153
154
|
dsh-safe update [-y] [--to <ver>] [--self] [--no-restore] [--no-verify] [--pm npm|pnpm]
|
|
154
155
|
upgrade dsh and dsh-safe itself, auto-restore quarantined plugins
|
|
155
156
|
dsh-safe explain [--file <path>] interpret a failed-boot stderr with AI (needs DSH_SAFE_AI_KEY)
|
|
156
|
-
dsh-safe repair
|
|
157
|
-
reinstall/upgrade a quarantined plugin and auto-restore it (module-resolution failures only)
|
|
157
|
+
dsh-safe repair [id] [--profile <name>] [--to <ver>] [-y] [--dry-run]
|
|
158
|
+
reinstall/upgrade a quarantined plugin and auto-restore it (module-resolution failures only; omit id when there is exactly one record)
|
|
158
159
|
dsh-safe help show this help
|
|
159
160
|
dsh-safe --version show version
|
|
160
161
|
|
|
@@ -255,7 +256,8 @@ Notes:
|
|
|
255
256
|
doctorAIOff: 'AI disabled (DSH_SAFE_AI_KEY not set)',
|
|
256
257
|
doctorCheckLast: 'update-check last ran at {time}',
|
|
257
258
|
doctorCheckNever: 'update-check never ran',
|
|
258
|
-
|
|
259
|
+
repairPickOne: '[dsh-safe] {count} quarantined record(s); specify the id to repair (dsh-safe repair <id>):',
|
|
260
|
+
repairNotSupportedTag: ' (not auto-repairable)',
|
|
259
261
|
repairEntryMissing: '[dsh-safe] no quarantine record found for {id}.',
|
|
260
262
|
repairAmbiguous: '[dsh-safe] {id} is quarantined in multiple profiles ({profiles}); specify one with --profile <name>.',
|
|
261
263
|
repairUnsupported: '[dsh-safe] this failure type cannot be auto-repaired (module-resolution failures only). Reason: {reason}\n try dsh-safe explain for an interpretation.',
|
package/lib/repair.js
CHANGED
|
@@ -42,7 +42,6 @@ function parseRepairArgs(args) {
|
|
|
42
42
|
else if (!a.startsWith('-') && opts.id === undefined) opts.id = a
|
|
43
43
|
else return { error: { key: 'updateUnknownFlag', params: { arg: a } } }
|
|
44
44
|
}
|
|
45
|
-
if (opts.id === undefined) return { error: { key: 'repairIdRequired' } }
|
|
46
45
|
if (opts.to !== undefined && !/^[\w.+-]+$/.test(opts.to)) return { error: { key: 'updateToInvalid' } }
|
|
47
46
|
return { opts }
|
|
48
47
|
}
|
|
@@ -67,15 +66,32 @@ export async function cmdRepair(args, { spawn = spawnSync, log = err, write = ou
|
|
|
67
66
|
return 2
|
|
68
67
|
}
|
|
69
68
|
|
|
70
|
-
// 台账定位:省略 --profile 时跨 profile
|
|
69
|
+
// 台账定位:省略 --profile 时跨 profile 搜索;省略 id 时——
|
|
70
|
+
// 恰好一条隔离记录 → 直接修它(最常见情况);
|
|
71
|
+
// 多条 → 列出清单让用户挑(标记哪些可自动修复)。
|
|
71
72
|
const ledger = loadLedger()
|
|
72
|
-
|
|
73
|
+
let matches = []
|
|
73
74
|
for (const [profile, entries] of Object.entries(ledger.profiles)) {
|
|
74
75
|
if (opts.profile && profile !== opts.profile) continue
|
|
75
76
|
for (const entry of entries ?? []) {
|
|
76
|
-
if (entry.id === opts.id) matches.push({ profile, entry })
|
|
77
|
+
if (opts.id === undefined || entry.id === opts.id) matches.push({ profile, entry })
|
|
77
78
|
}
|
|
78
79
|
}
|
|
80
|
+
if (opts.id === undefined) {
|
|
81
|
+
if (!matches.length) {
|
|
82
|
+
log(t('noRecords'))
|
|
83
|
+
return 0
|
|
84
|
+
}
|
|
85
|
+
if (matches.length > 1) {
|
|
86
|
+
log(t('repairPickOne', { count: matches.length }))
|
|
87
|
+
for (const m of matches) {
|
|
88
|
+
const repairable = RESOLVE_FAIL_RE.test(m.entry.reason ?? '')
|
|
89
|
+
log(` - ${m.entry.id}(${m.entry.name ?? '-'})${repairable ? '' : t('repairNotSupportedTag')}`)
|
|
90
|
+
}
|
|
91
|
+
return 0
|
|
92
|
+
}
|
|
93
|
+
opts.id = matches[0].entry.id
|
|
94
|
+
}
|
|
79
95
|
if (!matches.length) {
|
|
80
96
|
log(t('repairEntryMissing', { id: opts.id }))
|
|
81
97
|
return 1
|