@bruc3van/dsh-doctor 0.1.5 → 0.1.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bruc3van/dsh-doctor",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Diagnose DSH plugins broken by upgrades, startup blockers, and profile issues with explicit, confirmed repairs",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/cli.mjs CHANGED
@@ -50,15 +50,28 @@ function valueAfter(args, index, name) {
50
50
  return value
51
51
  }
52
52
 
53
+ function optionValue(arg, name) {
54
+ const prefix = `${name}=`
55
+ if (!arg.startsWith(prefix)) return undefined
56
+ const value = arg.slice(prefix.length)
57
+ if (value === '') throw new Error(`${name} needs a value`)
58
+ return value
59
+ }
60
+
53
61
  function parse(args) {
54
62
  const options = {}
55
63
  for (let index = 0; index < args.length; index += 1) {
56
64
  const arg = args[index]
57
65
  if (arg === '--profile') options.profile = valueAfter(args, index++, arg)
66
+ else if (arg.startsWith('--profile=')) options.profile = optionValue(arg, '--profile')
58
67
  else if (arg === '--home') options.home = valueAfter(args, index++, arg)
68
+ else if (arg.startsWith('--home=')) options.home = optionValue(arg, '--home')
59
69
  else if (arg === '--harness-root') options.harnessRoot = valueAfter(args, index++, arg)
70
+ else if (arg.startsWith('--harness-root=')) options.harnessRoot = optionValue(arg, '--harness-root')
60
71
  else if (arg === '--dsh-command') options.dshCommand = valueAfter(args, index++, arg)
72
+ else if (arg.startsWith('--dsh-command=')) options.dshCommand = optionValue(arg, '--dsh-command')
61
73
  else if (arg === '--lang') options.lang = valueAfter(args, index++, arg)
74
+ else if (arg.startsWith('--lang=')) options.lang = optionValue(arg, '--lang')
62
75
  else if (arg === '--json') options.json = true
63
76
  else if (arg === '--fix' || arg === '--repair') options.fix = true
64
77
  else if (arg === '--yes') options.yes = true
package/src/doctor.mjs CHANGED
@@ -7,6 +7,9 @@ import semver from 'semver'
7
7
  import { parseDocument } from 'yaml'
8
8
  import { languageName, localizedFinding } from './i18n.mjs'
9
9
 
10
+ // Mirrors packages/client/web/src/platform.ts in DeepSeek Harness. Installed
11
+ // DSH packages do not expose this source list, so update this baseline when
12
+ // Harness changes PLATFORM_MODULES.
10
13
  export const PLATFORM_MODULES = new Set([
11
14
  'react',
12
15
  'react/jsx-runtime',
@@ -168,11 +171,12 @@ function manifestBin(packageDir) {
168
171
  }
169
172
  }
170
173
 
171
- function localDshPackage(start) {
174
+ function localDshBin(start) {
172
175
  let current = resolve(start)
173
176
  while (true) {
174
177
  const packageDir = join(current, 'node_modules', '@deepseek-ai', 'dsh')
175
- if (manifestBin(packageDir) !== undefined) return packageDir
178
+ const bin = manifestBin(packageDir)
179
+ if (bin !== undefined) return bin
176
180
  const parent = dirname(current)
177
181
  if (parent === current) return undefined
178
182
  current = parent
@@ -218,10 +222,9 @@ function resolveDshCli(options, harness, home) {
218
222
  if (bin !== undefined) return { command: [process.execPath, bin.bin], path: bin.bin, source: 'profile', version: bin.version }
219
223
  }
220
224
 
221
- const localPackage = localDshPackage(cwd)
222
- if (localPackage !== undefined) {
223
- const bin = manifestBin(localPackage)
224
- return { command: [process.execPath, bin.bin], path: bin.bin, source: 'project', version: bin.version }
225
+ const localBin = localDshBin(cwd)
226
+ if (localBin !== undefined) {
227
+ return { command: [process.execPath, localBin.bin], path: localBin.bin, source: 'project', version: localBin.version }
225
228
  }
226
229
 
227
230
  const pathCommand = executableOnPath('dsh', env)
@@ -422,6 +425,7 @@ function codePositions(source) {
422
425
  const code = new Uint8Array(source.length)
423
426
  let state = 'code'
424
427
  let regexClass = false
428
+ const templateExpressions = []
425
429
  for (let index = 0; index < source.length; index += 1) {
426
430
  const char = source[index]
427
431
  const next = source[index + 1]
@@ -432,11 +436,25 @@ function codePositions(source) {
432
436
  } else if (char === '/' && next === '*') {
433
437
  state = 'block-comment'
434
438
  index += 1
435
- } else if (char === "'" || char === '"' || char === '`') {
439
+ } else if (char === "'" || char === '"') {
436
440
  state = char
441
+ } else if (char === '`') {
442
+ state = 'template'
437
443
  } else if (char === '/' && regexCanStart(source, index)) {
438
444
  state = 'regex'
439
445
  regexClass = false
446
+ } else if (templateExpressions.length > 0 && char === '{') {
447
+ templateExpressions[templateExpressions.length - 1] += 1
448
+ code[index] = 1
449
+ } else if (templateExpressions.length > 0 && char === '}') {
450
+ const last = templateExpressions.length - 1
451
+ templateExpressions[last] -= 1
452
+ if (templateExpressions[last] === 0) {
453
+ templateExpressions.pop()
454
+ state = 'template'
455
+ } else {
456
+ code[index] = 1
457
+ }
440
458
  } else {
441
459
  code[index] = 1
442
460
  }
@@ -456,6 +474,14 @@ function codePositions(source) {
456
474
  else if (char === ']') regexClass = false
457
475
  else if (char === '/' && !regexClass) state = 'code'
458
476
  else if (char === '\n' || char === '\r') state = 'code'
477
+ } else if (state === 'template') {
478
+ if (char === '\\') index += 1
479
+ else if (char === '`') state = 'code'
480
+ else if (char === '$' && next === '{') {
481
+ templateExpressions.push(1)
482
+ state = 'code'
483
+ index += 1
484
+ }
459
485
  } else if (char === '\\') {
460
486
  index += 1
461
487
  } else if (char === state) {
@@ -1425,7 +1451,7 @@ export function formatReport(report, options = {}) {
1425
1451
  : zh ? '未找到(命令型修复已禁用)' : 'not found (command-based repairs disabled)'
1426
1452
  const lines = [
1427
1453
  'DSH Doctor',
1428
- `${zh ? 'Profile' : 'Profile'}: ${report.context.profile}`,
1454
+ `Profile: ${report.context.profile}`,
1429
1455
  `${zh ? 'DSH 主目录' : 'Home'}: ${report.context.home}`,
1430
1456
  `${zh ? '当前使用的 DSH' : 'Active DSH'}: ${report.context.harness.version ?? 'unknown'}${report.context.harness.root ? ` (${report.context.harness.root})` : ''}`,
1431
1457
  `${zh ? 'DSH CLI' : 'DSH CLI'}: ${cliText}`,