@gluztm/dsh-guard 0.0.0-stage → 2.4.1

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.
@@ -0,0 +1,571 @@
1
+ import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs'
2
+ import { execFileSync, spawn } from 'node:child_process'
3
+ import { homedir } from 'node:os'
4
+ import { basename, join, resolve } from 'node:path'
5
+
6
+ export const PACKAGE_VERSION = '2.4.1'
7
+ export const REPO_URL = 'https://github.com/gluztm/DSHGuard'
8
+ export const RELEASE_URL = 'https://github.com/gluztm/DSHGuard/releases/latest'
9
+ export const INSTALLER_URL = 'https://github.com/gluztm/DSHGuard/releases/download/2.4.1/DSHGuard-Setup-2.4.1.exe'
10
+
11
+ const REG_POINTER_KEY = 'HKCU\\Software\\DSHGuard'
12
+ const REG_UNINSTALL_KEY = 'HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{9E1F7C34-5B2A-4D18-9C77-6A0E5D3B21F4}_is1'
13
+
14
+ export function resolveDshHome(overrideHome) {
15
+ if (overrideHome && String(overrideHome).trim()) {
16
+ return resolve(String(overrideHome).trim())
17
+ }
18
+ if (process.env.DSH_HOME && process.env.DSH_HOME.trim()) {
19
+ return resolve(process.env.DSH_HOME.trim())
20
+ }
21
+ return join(homedir(), '.dsh')
22
+ }
23
+
24
+ function queryRegInstallLocation(keyPath, valueName) {
25
+ if (process.platform !== 'win32') return null
26
+ try {
27
+ const out = execFileSync('reg.exe', ['query', keyPath, '/v', valueName], {
28
+ encoding: 'utf8',
29
+ timeout: 2000,
30
+ windowsHide: true,
31
+ stdio: ['ignore', 'pipe', 'ignore'],
32
+ })
33
+ for (const rawLine of out.split(/\r?\n/)) {
34
+ const m = rawLine.trim().match(new RegExp(`^${valueName}\\s+REG_\\w+\\s+(.+)$`, 'i'))
35
+ if (m && m[1]) return m[1].trim()
36
+ }
37
+ } catch {
38
+ return null
39
+ }
40
+ return null
41
+ }
42
+
43
+ /**
44
+ * Locate local DSHGuard out-of-band installation (strictly read-only).
45
+ */
46
+ export function locateGuardInstallation(options = {}) {
47
+ const candidates = []
48
+ if (options.guardHome && String(options.guardHome).trim()) {
49
+ candidates.push(resolve(String(options.guardHome).trim()))
50
+ } else {
51
+ if (process.env.DSHGUARD_HOME && process.env.DSHGUARD_HOME.trim()) {
52
+ candidates.push(resolve(process.env.DSHGUARD_HOME.trim()))
53
+ }
54
+ const ptrDir = queryRegInstallLocation(REG_POINTER_KEY, 'InstallLocation')
55
+ || queryRegInstallLocation(REG_POINTER_KEY, 'InstallDir')
56
+ if (ptrDir) candidates.push(resolve(ptrDir))
57
+
58
+ const uninstDir = queryRegInstallLocation(REG_UNINSTALL_KEY, 'InstallLocation')
59
+ if (uninstDir) candidates.push(resolve(uninstDir))
60
+
61
+ const localAppData = process.env.LOCALAPPDATA
62
+ if (localAppData) {
63
+ candidates.push(join(localAppData, 'Programs', 'DSHGuard'))
64
+ }
65
+ }
66
+
67
+ let matchedHome = null
68
+ let matchedExe = null
69
+ let matchedSnapshots = null
70
+
71
+ for (const dir of candidates) {
72
+ if (!dir || !existsSync(dir)) continue
73
+ const exeCandidate = join(dir, 'DSHGuard.exe')
74
+ const snapCandidate = options.snapshotsDir ? resolve(String(options.snapshotsDir)) : join(dir, 'Snapshots')
75
+ if (existsSync(exeCandidate) || existsSync(snapCandidate)) {
76
+ matchedHome = dir
77
+ if (existsSync(exeCandidate)) matchedExe = exeCandidate
78
+ if (existsSync(snapCandidate)) matchedSnapshots = snapCandidate
79
+ break
80
+ }
81
+ }
82
+
83
+ if (!matchedSnapshots && options.snapshotsDir && existsSync(resolve(String(options.snapshotsDir)))) {
84
+ matchedSnapshots = resolve(String(options.snapshotsDir))
85
+ }
86
+
87
+ return {
88
+ installed: Boolean(matchedExe),
89
+ guardHome: matchedHome,
90
+ exePath: matchedExe,
91
+ snapshotsDir: matchedSnapshots,
92
+ releaseUrl: RELEASE_URL,
93
+ installerUrl: INSTALLER_URL,
94
+ repoUrl: REPO_URL,
95
+ }
96
+ }
97
+
98
+ function readJsonSafe(filePath) {
99
+ try {
100
+ const raw = readFileSync(filePath, 'utf8')
101
+ return { ok: true, data: JSON.parse(raw), error: null }
102
+ } catch (err) {
103
+ return { ok: false, data: null, error: err && err.message ? err.message : String(err) }
104
+ }
105
+ }
106
+
107
+ function extractBundleIds(bundlesField) {
108
+ if (Array.isArray(bundlesField)) {
109
+ return bundlesField.map((item) => String(item || '').trim()).filter(Boolean)
110
+ }
111
+ if (bundlesField && typeof bundlesField === 'object') {
112
+ return Object.keys(bundlesField).map((k) => k.trim()).filter(Boolean)
113
+ }
114
+ return []
115
+ }
116
+
117
+ function scanCordisPatch(patchPath) {
118
+ if (!existsSync(patchPath)) {
119
+ return {
120
+ exists: false,
121
+ readable: false,
122
+ syntaxOk: true,
123
+ hasTabIndent: false,
124
+ disabledCount: 0,
125
+ apiKeyEnvKeys: [],
126
+ mcpEntriesCount: 0,
127
+ error: null,
128
+ }
129
+ }
130
+ try {
131
+ const raw = readFileSync(patchPath, 'utf8')
132
+ const lines = raw.split(/\r?\n/)
133
+ let hasTabIndent = false
134
+ let disabledCount = 0
135
+ let mcpEntriesCount = 0
136
+ const envSet = new Set()
137
+ let hasStructuredToken = false
138
+
139
+ for (const line of lines) {
140
+ if (/^\t+/.test(line)) hasTabIndent = true
141
+ const trimmed = line.trim()
142
+ if (!trimmed || trimmed.startsWith('#')) continue
143
+ if (trimmed.startsWith('- ') || /^[A-Za-z0-9_.-]+\s*:/.test(trimmed)) {
144
+ hasStructuredToken = true
145
+ }
146
+ if (/^enabled\s*:\s*false\b/i.test(trimmed)) {
147
+ disabledCount += 1
148
+ }
149
+ const envMatch = trimmed.match(/^apiKeyEnv\s*:\s*['"]?([A-Za-z0-9_]+)['"]?/i)
150
+ if (envMatch && envMatch[1]) {
151
+ envSet.add(envMatch[1])
152
+ }
153
+ if (/\bmcpServers\b|id\s*:\s*['"]?mcp\b/i.test(trimmed)) {
154
+ mcpEntriesCount += 1
155
+ }
156
+ }
157
+
158
+ const nonEmpty = lines.some((l) => l.trim() && !l.trim().startsWith('#'))
159
+ const syntaxOk = !hasTabIndent && (!nonEmpty || hasStructuredToken)
160
+
161
+ return {
162
+ exists: true,
163
+ readable: true,
164
+ syntaxOk,
165
+ hasTabIndent,
166
+ disabledCount,
167
+ apiKeyEnvKeys: Array.from(envSet).sort(),
168
+ mcpEntriesCount,
169
+ error: syntaxOk ? null : (hasTabIndent ? 'Tab indentation detected in YAML' : 'Unrecognized YAML structure'),
170
+ }
171
+ } catch (err) {
172
+ return {
173
+ exists: true,
174
+ readable: false,
175
+ syntaxOk: false,
176
+ hasTabIndent: false,
177
+ disabledCount: 0,
178
+ apiKeyEnvKeys: [],
179
+ mcpEntriesCount: 0,
180
+ error: err && err.message ? err.message : String(err),
181
+ }
182
+ }
183
+ }
184
+
185
+ /**
186
+ * Read-only health inspection of a single DSH profile ('web' or 'desktop').
187
+ */
188
+ export function inspectProfile(profileDir, targetName) {
189
+ const exists = existsSync(profileDir)
190
+ const pkgPath = join(profileDir, 'package.json')
191
+ const patchPath = join(profileDir, 'cordis.patch.yml')
192
+
193
+ if (!exists) {
194
+ return {
195
+ target: targetName,
196
+ profileDir,
197
+ exists: false,
198
+ packageJsonOk: false,
199
+ dependenciesCount: 0,
200
+ bundlesCount: 0,
201
+ missingInDeps: [],
202
+ unregisteredDeps: [],
203
+ patch: scanCordisPatch(patchPath),
204
+ issues: [],
205
+ }
206
+ }
207
+
208
+ const pkgRes = existsSync(pkgPath)
209
+ ? readJsonSafe(pkgPath)
210
+ : { ok: false, data: null, error: 'package.json not found' }
211
+
212
+ const depsObj = pkgRes.ok && pkgRes.data && typeof pkgRes.data.dependencies === 'object' && pkgRes.data.dependencies
213
+ ? pkgRes.data.dependencies
214
+ : {}
215
+ const depNames = Object.keys(depsObj)
216
+ const depSet = new Set(depNames)
217
+
218
+ const bundles = pkgRes.ok && pkgRes.data && pkgRes.data.dsh
219
+ ? extractBundleIds(pkgRes.data.dsh.bundles ?? (pkgRes.data.dsh.profile && pkgRes.data.dsh.profile.bundles))
220
+ : []
221
+ const bundleSet = new Set(bundles)
222
+
223
+ const missingInDeps = bundles.filter((b) => !depSet.has(b))
224
+ const unregisteredDeps = depNames.filter((d) => {
225
+ if (bundleSet.has(d)) return false
226
+ return d.startsWith('dsh-') || d.includes('/dsh-')
227
+ })
228
+
229
+ const patch = scanCordisPatch(patchPath)
230
+ const issues = []
231
+ if (!pkgRes.ok) {
232
+ issues.push(`${targetName} package.json error: ${pkgRes.error}`)
233
+ }
234
+ if (missingInDeps.length > 0) {
235
+ issues.push(`${targetName} manifest drift: ${missingInDeps.length} bundle(s) missing in dependencies (${missingInDeps.join(', ')})`)
236
+ }
237
+ if (unregisteredDeps.length > 0) {
238
+ issues.push(`${targetName} manifest drift: ${unregisteredDeps.length} plugin dep(s) not listed in bundles (${unregisteredDeps.join(', ')})`)
239
+ }
240
+ if (patch.exists && !patch.syntaxOk) {
241
+ issues.push(`${targetName} cordis.patch.yml warning: ${patch.error}`)
242
+ }
243
+
244
+ return {
245
+ target: targetName,
246
+ profileDir,
247
+ exists: true,
248
+ packageJsonOk: pkgRes.ok,
249
+ dependenciesCount: depNames.length,
250
+ bundlesCount: bundles.length,
251
+ missingInDeps,
252
+ unregisteredDeps,
253
+ patch,
254
+ issues,
255
+ }
256
+ }
257
+
258
+ /**
259
+ * Strictly masked credential readiness check: NEVER reads, slices, or returns secret values.
260
+ */
261
+ export function inspectCredentialKeysMasked(dshHome, referencedEnvKeys = []) {
262
+ const credPath = join(dshHome, '.credentials.yaml')
263
+ const nonEmptyKeys = new Set()
264
+ let totalKeysCount = 0
265
+ let fileExists = false
266
+
267
+ if (existsSync(credPath)) {
268
+ fileExists = true
269
+ try {
270
+ const raw = readFileSync(credPath, 'utf8')
271
+ for (const rawLine of raw.split(/\r?\n/)) {
272
+ const line = rawLine.trimEnd()
273
+ if (!line || line.trim().startsWith('#') || /^\s/.test(line)) continue
274
+ const m = line.match(/^([A-Za-z0-9_.-]+)\s*:\s*(.*)$/)
275
+ if (!m) continue
276
+ totalKeysCount += 1
277
+ const keyName = m[1].trim()
278
+ const rawVal = m[2].trim()
279
+ const stripped = rawVal.replace(/^(['"])(.*)\1$/, '$2').trim()
280
+ const isEmpty = !stripped || stripped === '~' || stripped.toLowerCase() === 'null'
281
+ if (!isEmpty) {
282
+ nonEmptyKeys.add(keyName)
283
+ }
284
+ }
285
+ } catch {
286
+ // Unreadable file stays nonEmptyKeys empty; never leak raw error internals with secrets.
287
+ }
288
+ }
289
+
290
+ const uniqueRefs = Array.from(new Set(referencedEnvKeys.filter(Boolean))).sort()
291
+ const referencedKeys = uniqueRefs.map((key) => ({
292
+ key,
293
+ ready: nonEmptyKeys.has(key),
294
+ }))
295
+ const missingReferencedKeys = referencedKeys.filter((item) => !item.ready).map((item) => item.key)
296
+
297
+ return {
298
+ fileExists,
299
+ totalKeysCount,
300
+ nonEmptyKeysCount: nonEmptyKeys.size,
301
+ referencedKeys,
302
+ missingReferencedKeys,
303
+ }
304
+ }
305
+
306
+ /**
307
+ * Full read-only health report across Web & Desktop profiles, masked credentials, and DSHGuard.
308
+ */
309
+ export function inspectHealth(options = {}) {
310
+ const dshHome = resolveDshHome(options.dshHome)
311
+ const target = options.target && ['all', 'web', 'desktop'].includes(options.target)
312
+ ? options.target
313
+ : 'all'
314
+
315
+ const profiles = []
316
+ if (target === 'all' || target === 'web') {
317
+ profiles.push(inspectProfile(join(dshHome, 'profiles', 'web'), 'web'))
318
+ }
319
+ if (target === 'all' || target === 'desktop') {
320
+ profiles.push(inspectProfile(join(dshHome, 'profiles', 'desktop'), 'desktop'))
321
+ }
322
+
323
+ const referencedEnvKeys = profiles.flatMap((p) => (p.patch ? p.patch.apiKeyEnvKeys : []))
324
+ const credentials = inspectCredentialKeysMasked(dshHome, referencedEnvKeys)
325
+ const guard = locateGuardInstallation(options)
326
+
327
+ const issues = profiles.flatMap((p) => p.issues)
328
+ if (credentials.missingReferencedKeys.length > 0) {
329
+ issues.push(`Missing credential key(s) in .credentials.yaml: ${credentials.missingReferencedKeys.join(', ')}`)
330
+ }
331
+
332
+ const healthy = issues.length === 0
333
+
334
+ return {
335
+ platform: process.platform,
336
+ dshHome,
337
+ target,
338
+ healthy,
339
+ issuesCount: issues.length,
340
+ issues,
341
+ profiles,
342
+ credentials,
343
+ guard,
344
+ }
345
+ }
346
+
347
+ function classifySnapshotEntry(dirPath, name) {
348
+ let target = 'web'
349
+ let reason = ''
350
+ let itemCount = 0
351
+ let createdAt = ''
352
+
353
+ const manifestPath = join(dirPath, 'manifest.json')
354
+ if (existsSync(manifestPath)) {
355
+ const res = readJsonSafe(manifestPath)
356
+ if (res.ok && res.data) {
357
+ if (typeof res.data.target === 'string' && res.data.target.toLowerCase().includes('desktop')) {
358
+ target = 'desktop'
359
+ } else if (typeof res.data.scope === 'string' && res.data.scope.toLowerCase().includes('desktop')) {
360
+ target = 'desktop'
361
+ }
362
+ if (typeof res.data.reason === 'string') reason = res.data.reason
363
+ if (typeof res.data.createdAt === 'string') createdAt = res.data.createdAt
364
+ if (Array.isArray(res.data.files)) itemCount = res.data.files.length
365
+ }
366
+ }
367
+
368
+ if (target === 'web' && /desktop/i.test(name)) {
369
+ target = 'desktop'
370
+ }
371
+
372
+ try {
373
+ const entries = readdirSync(dirPath)
374
+ if (itemCount === 0) {
375
+ itemCount = entries.filter((e) => e !== 'manifest.json').length
376
+ }
377
+ if (!createdAt) {
378
+ createdAt = new Date(statSync(dirPath).mtimeMs).toISOString()
379
+ }
380
+ } catch {
381
+ // Ignore stat errors on individual directories
382
+ }
383
+
384
+ return {
385
+ id: name,
386
+ target,
387
+ reason,
388
+ itemCount,
389
+ createdAt,
390
+ }
391
+ }
392
+
393
+ /**
394
+ * List saved DSHGuard snapshots (strictly read-only).
395
+ */
396
+ export function inspectSnapshots(options = {}) {
397
+ const guard = locateGuardInstallation(options)
398
+ const limit = Math.max(1, Math.min(50, Number(options.limit) || 20))
399
+ const targetFilter = options.target && ['all', 'web', 'desktop'].includes(options.target)
400
+ ? options.target
401
+ : 'all'
402
+
403
+ if (!guard.snapshotsDir || !existsSync(guard.snapshotsDir)) {
404
+ return {
405
+ snapshotsDir: guard.snapshotsDir,
406
+ guardInstalled: guard.installed,
407
+ total: 0,
408
+ snapshots: [],
409
+ releaseUrl: RELEASE_URL,
410
+ installerUrl: INSTALLER_URL,
411
+ repoUrl: REPO_URL,
412
+ }
413
+ }
414
+
415
+ let items = []
416
+ try {
417
+ const entries = readdirSync(guard.snapshotsDir, { withFileTypes: true })
418
+ for (const ent of entries) {
419
+ if (!ent.isDirectory()) continue
420
+ const full = join(guard.snapshotsDir, ent.name)
421
+ const parsed = classifySnapshotEntry(full, ent.name)
422
+ if (targetFilter === 'all' || parsed.target === targetFilter) {
423
+ items.push(parsed)
424
+ }
425
+ }
426
+ } catch {
427
+ items = []
428
+ }
429
+
430
+ items.sort((a, b) => String(b.createdAt).localeCompare(String(a.createdAt)))
431
+
432
+ return {
433
+ snapshotsDir: guard.snapshotsDir,
434
+ guardInstalled: guard.installed,
435
+ total: items.length,
436
+ snapshots: items.slice(0, limit),
437
+ releaseUrl: RELEASE_URL,
438
+ installerUrl: INSTALLER_URL,
439
+ repoUrl: REPO_URL,
440
+ }
441
+ }
442
+
443
+ /**
444
+ * Locate or optionally launch the local Windows DSHGuard desktop supervisor.
445
+ */
446
+ export function openGuard(options = {}) {
447
+ const guard = locateGuardInstallation(options)
448
+ if (!guard.installed || !guard.exePath) {
449
+ return {
450
+ installed: false,
451
+ launched: false,
452
+ exePath: null,
453
+ guardHome: guard.guardHome,
454
+ releaseUrl: RELEASE_URL,
455
+ installerUrl: INSTALLER_URL,
456
+ repoUrl: REPO_URL,
457
+ message: '未检测到本地 DSHGuard 桌面控制台。安装 Windows 完整版(免管理员)即可获得:四协议模型可视化配置与测速、CC Switch 多源凭据导入、进程外崩溃救援与快照回滚。',
458
+ }
459
+ }
460
+
461
+ if (options.launch === true) {
462
+ if (process.platform !== 'win32') {
463
+ return {
464
+ installed: true,
465
+ launched: false,
466
+ exePath: guard.exePath,
467
+ guardHome: guard.guardHome,
468
+ releaseUrl: RELEASE_URL,
469
+ installerUrl: INSTALLER_URL,
470
+ repoUrl: REPO_URL,
471
+ message: '当前非 Windows 环境,无法直接拉起桌面端 DSHGuard.exe。',
472
+ }
473
+ }
474
+ try {
475
+ const child = spawn(guard.exePath, [], {
476
+ detached: true,
477
+ stdio: 'ignore',
478
+ windowsHide: false,
479
+ })
480
+ if (typeof child.on === 'function') {
481
+ child.on('error', () => {})
482
+ }
483
+ child.unref()
484
+ return {
485
+ installed: true,
486
+ launched: true,
487
+ exePath: guard.exePath,
488
+ guardHome: guard.guardHome,
489
+ releaseUrl: RELEASE_URL,
490
+ installerUrl: INSTALLER_URL,
491
+ repoUrl: REPO_URL,
492
+ message: `已在桌面拉起 DSHGuard 守护壳(${basename(guard.exePath)})。`,
493
+ }
494
+ } catch (err) {
495
+ return {
496
+ installed: true,
497
+ launched: false,
498
+ exePath: guard.exePath,
499
+ guardHome: guard.guardHome,
500
+ releaseUrl: RELEASE_URL,
501
+ installerUrl: INSTALLER_URL,
502
+ repoUrl: REPO_URL,
503
+ message: `拉起 DSHGuard 守护壳失败:${err && err.message ? err.message : String(err)}`,
504
+ }
505
+ }
506
+ }
507
+
508
+ return {
509
+ installed: true,
510
+ launched: false,
511
+ exePath: guard.exePath,
512
+ guardHome: guard.guardHome,
513
+ releaseUrl: RELEASE_URL,
514
+ installerUrl: INSTALLER_URL,
515
+ repoUrl: REPO_URL,
516
+ message: `已定位本机 DSHGuard 守护壳:${guard.exePath}`,
517
+ }
518
+ }
519
+
520
+ export function formatHealthText(report) {
521
+ const lines = []
522
+ lines.push(`DSH 守护壳伴生体检(状态:${report.healthy ? '正常' : `发现 ${report.issuesCount} 项异常`})`)
523
+ for (const p of report.profiles) {
524
+ if (!p.exists) {
525
+ lines.push(`- [${p.target}] 未检测到配置目录`)
526
+ continue
527
+ }
528
+ const patchNote = p.patch.exists
529
+ ? (p.patch.syntaxOk ? `patch 正常(禁用 ${p.patch.disabledCount} 项)` : `patch 异常(${p.patch.error})`)
530
+ : '无 cordis.patch.yml'
531
+ lines.push(
532
+ `- [${p.target}] bundles=${p.bundlesCount} / deps=${p.dependenciesCount} | ${patchNote}`
533
+ + (p.missingInDeps.length ? ` | 缺依赖: ${p.missingInDeps.join(', ')}` : '')
534
+ + (p.unregisteredDeps.length ? ` | 未登记: ${p.unregisteredDeps.join(', ')}` : '')
535
+ )
536
+ }
537
+ const cred = report.credentials
538
+ const refTotal = cred.referencedKeys.length
539
+ const refReady = cred.referencedKeys.filter((r) => r.ready).length
540
+ lines.push(
541
+ `- [凭据脱敏对账] .credentials.yaml ${cred.fileExists ? `已存在(非空键 ${cred.nonEmptyKeysCount}/${cred.totalKeysCount})` : '未创建'}`
542
+ + (refTotal > 0 ? ` | patch 引用键就绪 ${refReady}/${refTotal}` : '')
543
+ + (cred.missingReferencedKeys.length ? ` | 缺失: ${cred.missingReferencedKeys.join(', ')}` : '')
544
+ )
545
+ lines.push(
546
+ report.guard.installed
547
+ ? `- [本机 DSHGuard] 已安装(${report.guard.exePath})`
548
+ : `- [本机 DSHGuard] 未安装;安装 Windows 桌面控制台可解锁四协议模型配置与测速、CC Switch 多源凭据导入、进程外崩溃救援与快照回滚:\n 安装包直链:${report.guard.installerUrl || INSTALLER_URL}\n 发布页:${report.guard.releaseUrl}`
549
+ )
550
+ if (report.issues.length > 0) {
551
+ lines.push('诊断建议:')
552
+ for (const issue of report.issues) {
553
+ lines.push(` ! ${issue}`)
554
+ }
555
+ }
556
+ return lines.join('\n')
557
+ }
558
+
559
+ export function formatSnapshotsText(report) {
560
+ if (!report.snapshotsDir || report.total === 0) {
561
+ return report.guardInstalled
562
+ ? '本机 DSHGuard 尚无快照存档(Snapshots 目录为空或不存在)。'
563
+ : `未定位到本机 DSHGuard 快照目录;安装 Windows 桌面控制台可自动存档并于崩溃时回滚(支持四协议模型配置与 CC Switch 导入):\n安装包直链:${report.installerUrl || INSTALLER_URL}\n发布页:${report.releaseUrl}`
564
+ }
565
+ const lines = [`已找到 ${report.total} 份守护壳快照(展示最近 ${report.snapshots.length} 份):`]
566
+ for (const snap of report.snapshots) {
567
+ const meta = [snap.target, `${snap.itemCount} 项`, snap.createdAt].filter(Boolean).join(' · ')
568
+ lines.push(`- ${snap.id}(${meta})${snap.reason ? ` — ${snap.reason}` : ''}`)
569
+ }
570
+ return lines.join('\n')
571
+ }
package/package.json CHANGED
@@ -1,6 +1,90 @@
1
1
  {
2
2
  "name": "@gluztm/dsh-guard",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "2.4.1",
4
+ "description": "Cross-platform read-only companion plugin & Web UI sidebar inspector for DSHGuard: inspects Web/Desktop bundle drift, cordis.patch.yml structure, masked .credentials.yaml key readiness, pre-change snapshots, and opens DSHGuard.exe on Windows (3 dsh_guard_* tools + /guard command + Web UI panel).",
5
+ "icon": "./assets/icon.png",
6
+ "license": "GPL-3.0-only",
7
+ "type": "module",
8
+ "main": "./lib/index.mjs",
9
+ "exports": {
10
+ ".": "./lib/index.mjs",
11
+ "./client": "./lib/client.js",
12
+ "./inspector": "./lib/inspector.mjs",
13
+ "./cordis.patch.yml": "./cordis.patch.yml",
14
+ "./package.json": "./package.json",
15
+ "./icon": "./assets/icon.png"
16
+ },
17
+ "bin": {
18
+ "dsh-guard": "./bin/dsh-guard.mjs"
19
+ },
20
+ "files": [
21
+ "assets",
22
+ "bin",
23
+ "lib",
24
+ "cordis.patch.yml",
25
+ "screenshots.json",
26
+ "README.md",
27
+ "README.en.md",
28
+ "LICENSE"
29
+ ],
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/gluztm/DSHGuard.git",
33
+ "directory": "packages/dsh-guard"
34
+ },
35
+ "homepage": "https://github.com/gluztm/DSHGuard#readme",
36
+ "bugs": {
37
+ "url": "https://github.com/gluztm/DSHGuard/issues"
38
+ },
39
+ "dsh": {
40
+ "bundle": {
41
+ "patch": "./cordis.patch.yml"
42
+ },
43
+ "client": {
44
+ "platform": "web",
45
+ "immediately": true,
46
+ "inject": []
47
+ },
48
+ "compatibility": {
49
+ "dsh": ">=0.1.5-rc.1 <0.3.0-0"
50
+ }
51
+ },
52
+ "peerDependencies": {
53
+ "@deepseek-ai/cordis": "^4.0.1",
54
+ "@deepseek-ai/dsh": ">=0.1.5-rc.1",
55
+ "@deepseek-ai/dsh-tools": ">=0.1.0-rc.6 <0.3.0"
56
+ },
57
+ "peerDependenciesMeta": {
58
+ "@deepseek-ai/cordis": {
59
+ "optional": true
60
+ },
61
+ "@deepseek-ai/dsh": {
62
+ "optional": true
63
+ },
64
+ "@deepseek-ai/dsh-tools": {
65
+ "optional": true
66
+ }
67
+ },
68
+ "keywords": [
69
+ "deepseek-harness",
70
+ "dsh-plugin",
71
+ "dsh",
72
+ "dshguard",
73
+ "client-plugin",
74
+ "health-check",
75
+ "snapshot",
76
+ "rollback",
77
+ "credentials",
78
+ "cc-switch",
79
+ "sidebar",
80
+ "cross-platform"
81
+ ],
82
+ "os": [
83
+ "darwin",
84
+ "linux",
85
+ "win32"
86
+ ],
87
+ "engines": {
88
+ "node": ">=18.0.0"
89
+ }
90
+ }
@@ -0,0 +1,7 @@
1
+ [
2
+ "https://raw.githubusercontent.com/gluztm/DSHGuard/main/docs/screenshots/241-companion-sidebar.png",
3
+ "https://raw.githubusercontent.com/gluztm/DSHGuard/main/docs/screenshots/240-showcase.gif",
4
+ "https://raw.githubusercontent.com/gluztm/DSHGuard/main/docs/screenshots/240-vault-dark.png",
5
+ "https://raw.githubusercontent.com/gluztm/DSHGuard/main/docs/screenshots/240-ccswitch-import-dark.png",
6
+ "https://raw.githubusercontent.com/gluztm/DSHGuard/main/docs/screenshots/240-status-running-dark.png"
7
+ ]