dshmarket 1.29.1 → 1.29.2

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/dsh-cli.js CHANGED
@@ -406,15 +406,41 @@ export function cancelActive() {
406
406
  }
407
407
  /** Whether `pnpm` resolves on PATH; success is cached, absence is re-probed. */
408
408
  let pnpmReady = false;
409
+ /**
410
+ * Why the last probe said no.
411
+ *
412
+ * `missing` and `failed` are different problems with different fixes, and
413
+ * collapsing both into `false` made the market give one answer to both: it
414
+ * told a user whose pnpm ran perfectly from their shell to go set PNPM_HOME
415
+ * (#228). A binary that IS on the path and exits non-zero — a corepack shim
416
+ * that cannot reach the network to fetch pnpm itself is the common one —
417
+ * needs its own output shown, not a path to fix that is already right.
418
+ */
419
+ let pnpmProbeFailure = null;
420
+ /** Why `pnpm --version` last failed, or null when it has not failed. */
421
+ export function lastPnpmProbeFailure() {
422
+ return pnpmProbeFailure;
423
+ }
409
424
  /** Probe `pnpm --version` on PATH. */
410
425
  export function probePnpm() {
411
426
  if (pnpmReady)
412
427
  return Promise.resolve(true);
413
428
  return new Promise((resolvePromise) => {
414
- const child = spawnShim('pnpm', ['--version'], { stdio: 'ignore', viaShell: winCmdShim, env: spawnEnv() });
415
- child.on('error', () => resolvePromise(false));
429
+ // Piped, not ignored: the output of a pnpm that exists but will not run
430
+ // IS the explanation, and throwing it away is what left #228 with a
431
+ // failure nobody could act on.
432
+ const child = spawnShim('pnpm', ['--version'], { stdio: ['ignore', 'pipe', 'pipe'], viaShell: winCmdShim, env: spawnEnv() });
433
+ let output = '';
434
+ const collect = (chunk) => { output = (output + chunk.toString()).slice(-2000); };
435
+ child.stdout?.on('data', collect);
436
+ child.stderr?.on('data', collect);
437
+ child.on('error', (error) => {
438
+ pnpmProbeFailure = { kind: 'missing', output: error.message };
439
+ resolvePromise(false);
440
+ });
416
441
  child.on('close', (code) => {
417
442
  pnpmReady = code === 0;
443
+ pnpmProbeFailure = pnpmReady ? null : { kind: 'failed', output: output.trim() };
418
444
  resolvePromise(pnpmReady);
419
445
  });
420
446
  });
@@ -468,7 +494,7 @@ export async function provisionPnpm() {
468
494
  const npmFound = toolOnPath('npm');
469
495
  if (!npmFound)
470
496
  logEvent('warn', 'setup-pnpm', `npm is not on any searched path (node lives in ${nodeBinDir})`);
471
- return { ok: false, hint: provisionHint(corepack.output, npm.output, npmFound) };
497
+ return { ok: false, hint: provisionHint(corepack.output, npm.output, npmFound, lastPnpmProbeFailure()) };
472
498
  }
473
499
  /** Executable suffixes a bare command name can carry on this platform. */
474
500
  const EXECUTABLE_SUFFIXES = process.platform === 'win32'
@@ -508,7 +534,7 @@ export function toolOnPath(name) {
508
534
  * a GUI launch with no Node on PATH at all).
509
535
  * @returns a bilingual, actionable hint, or undefined when unrecognized.
510
536
  */
511
- export function provisionHint(corepackOutput, npmOutput, npmFound = true) {
537
+ export function provisionHint(corepackOutput, npmOutput, npmFound = true, probeFailure = null) {
512
538
  // Node itself unreachable: pointing the user back at this same button
513
539
  // would be a dead end (#32). `npmFound` answers this from disk, so it
514
540
  // holds on a Windows console that reports the same thing in a codepage we
@@ -543,6 +569,13 @@ export function provisionHint(corepackOutput, npmOutput, npmFound = true) {
543
569
  // they can see succeeded, and their complaint was exactly that — "又不告诉
544
570
  // 我怎么手动配置". Whatever the cause, the actionable question is the same
545
571
  // one, so ask it: where is pnpm, and is that anywhere this process looks?
572
+ // pnpm IS on the path and exits non-zero. Telling this user to fix PNPM_HOME
573
+ // would be advice for the opposite problem — theirs runs fine from a shell,
574
+ // which is exactly what #228 reported. Its own output is the explanation.
575
+ if (probeFailure?.kind === 'failed') {
576
+ const detail = probeFailure.output === '' ? '' : `\n\n${probeFailure.output}`;
577
+ return `找到 pnpm 了,但运行 \`pnpm --version\` 失败——所以问题不在路径上,设 PNPM_HOME 没有用。最常见的原因是 corepack 的 shim 需要联网下载 pnpm 本体,而这台机器下不到。请在终端执行一次 \`pnpm --version\`:如果同样失败,按它的提示修(受限网络可用 \`brew install pnpm\` 或 \`npm i -g pnpm --registry <你的镜像>\` 装一个完整的 pnpm,绕开 shim);如果在终端里正常,说明 dsh 进程的环境和你的终端不同,请从该终端启动 dsh。pnpm 的原始输出:${detail} / pnpm was found, but \`pnpm --version\` fails — so this is not a path problem and PNPM_HOME will not help. The usual cause is a corepack shim that has to download pnpm itself and cannot reach the network. Run \`pnpm --version\` in a terminal: if it fails the same way, follow what it says (on a restricted network install a real pnpm with \`brew install pnpm\` or \`npm i -g pnpm --registry <your mirror>\` to bypass the shim); if it works there, the dsh process has a different environment than your shell — start dsh from that terminal. pnpm's own output:${detail}`;
578
+ }
546
579
  const searched = toolSearchDirs().join(process.platform === 'win32' ? ' ; ' : ' : ');
547
580
  const locate = process.platform === 'win32' ? 'where pnpm' : 'which pnpm';
548
581
  return `pnpm 装好了,但这个 dsh 进程仍然启动不了它——安装步骤都成功,只是装到的位置不在它搜索的范围内。已找过:${searched}。请在终端执行 \`${locate}\` 看 pnpm 实际在哪:如果它不在上面这些目录里,把该目录设为 PNPM_HOME 后重启 dsh(\`export PNPM_HOME=<那个目录>\`),或者干脆从一个能直接运行 pnpm 的终端里启动 dsh。注意必须重启——正在运行的进程读不到新设的环境变量 / pnpm is installed but this dsh process still cannot start it: every step succeeded, the binary just landed somewhere this process does not look. Searched: ${searched}. Run \`${locate}\` in a terminal to see where pnpm actually is; if that directory is not in the list above, set PNPM_HOME to it and restart dsh (\`export PNPM_HOME=<that directory>\`), or simply start dsh from a terminal where \`pnpm\` already runs. The restart matters — a running process cannot see a newly set variable`;
@@ -219,6 +219,11 @@ export declare function killChild(child: ChildProcess): void;
219
219
  * @returns true when there was one to cancel.
220
220
  */
221
221
  export declare function cancelActive(): boolean;
222
+ /** Why `pnpm --version` last failed, or null when it has not failed. */
223
+ export declare function lastPnpmProbeFailure(): {
224
+ kind: 'missing' | 'failed';
225
+ output: string;
226
+ } | null;
222
227
  /** Probe `pnpm --version` on PATH. */
223
228
  export declare function probePnpm(): Promise<boolean>;
224
229
  /**
@@ -253,7 +258,10 @@ export declare function toolOnPath(name: string): boolean;
253
258
  * a GUI launch with no Node on PATH at all).
254
259
  * @returns a bilingual, actionable hint, or undefined when unrecognized.
255
260
  */
256
- export declare function provisionHint(corepackOutput: string, npmOutput: string, npmFound?: boolean): string | undefined;
261
+ export declare function provisionHint(corepackOutput: string, npmOutput: string, npmFound?: boolean, probeFailure?: {
262
+ kind: 'missing' | 'failed';
263
+ output: string;
264
+ } | null): string | undefined;
257
265
  /** Live progress of the running plugin command, for the status route. */
258
266
  export interface InstallProgress {
259
267
  active: boolean;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dshmarket",
3
3
  "description": "Visual plugin market inside DeepSeek Harness — browse, search, and one-click install community plugins. · DSH 可视化插件市场:逛一逛,点一下,装好。",
4
- "version": "1.29.1",
4
+ "version": "1.29.2",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/types/index.d.ts",
package/src/dsh-cli.ts CHANGED
@@ -526,14 +526,42 @@ export function cancelActive(): boolean {
526
526
  /** Whether `pnpm` resolves on PATH; success is cached, absence is re-probed. */
527
527
  let pnpmReady = false
528
528
 
529
+ /**
530
+ * Why the last probe said no.
531
+ *
532
+ * `missing` and `failed` are different problems with different fixes, and
533
+ * collapsing both into `false` made the market give one answer to both: it
534
+ * told a user whose pnpm ran perfectly from their shell to go set PNPM_HOME
535
+ * (#228). A binary that IS on the path and exits non-zero — a corepack shim
536
+ * that cannot reach the network to fetch pnpm itself is the common one —
537
+ * needs its own output shown, not a path to fix that is already right.
538
+ */
539
+ let pnpmProbeFailure: { kind: 'missing' | 'failed'; output: string } | null = null
540
+
541
+ /** Why `pnpm --version` last failed, or null when it has not failed. */
542
+ export function lastPnpmProbeFailure(): { kind: 'missing' | 'failed'; output: string } | null {
543
+ return pnpmProbeFailure
544
+ }
545
+
529
546
  /** Probe `pnpm --version` on PATH. */
530
547
  export function probePnpm(): Promise<boolean> {
531
548
  if (pnpmReady) return Promise.resolve(true)
532
549
  return new Promise((resolvePromise) => {
533
- const child = spawnShim('pnpm', ['--version'], { stdio: 'ignore', viaShell: winCmdShim, env: spawnEnv() })
534
- child.on('error', () => resolvePromise(false))
550
+ // Piped, not ignored: the output of a pnpm that exists but will not run
551
+ // IS the explanation, and throwing it away is what left #228 with a
552
+ // failure nobody could act on.
553
+ const child = spawnShim('pnpm', ['--version'], { stdio: ['ignore', 'pipe', 'pipe'], viaShell: winCmdShim, env: spawnEnv() })
554
+ let output = ''
555
+ const collect = (chunk: Buffer): void => { output = (output + chunk.toString()).slice(-2000) }
556
+ child.stdout?.on('data', collect)
557
+ child.stderr?.on('data', collect)
558
+ child.on('error', (error) => {
559
+ pnpmProbeFailure = { kind: 'missing', output: error.message }
560
+ resolvePromise(false)
561
+ })
535
562
  child.on('close', (code) => {
536
563
  pnpmReady = code === 0
564
+ pnpmProbeFailure = pnpmReady ? null : { kind: 'failed', output: output.trim() }
537
565
  resolvePromise(pnpmReady)
538
566
  })
539
567
  })
@@ -585,7 +613,7 @@ export async function provisionPnpm(): Promise<{ ok: boolean; hint?: string }> {
585
613
  }
586
614
  const npmFound = toolOnPath('npm')
587
615
  if (!npmFound) logEvent('warn', 'setup-pnpm', `npm is not on any searched path (node lives in ${nodeBinDir})`)
588
- return { ok: false, hint: provisionHint(corepack.output, npm.output, npmFound) }
616
+ return { ok: false, hint: provisionHint(corepack.output, npm.output, npmFound, lastPnpmProbeFailure()) }
589
617
  }
590
618
 
591
619
  /** Executable suffixes a bare command name can carry on this platform. */
@@ -626,7 +654,12 @@ export function toolOnPath(name: string): boolean {
626
654
  * a GUI launch with no Node on PATH at all).
627
655
  * @returns a bilingual, actionable hint, or undefined when unrecognized.
628
656
  */
629
- export function provisionHint(corepackOutput: string, npmOutput: string, npmFound = true): string | undefined {
657
+ export function provisionHint(
658
+ corepackOutput: string,
659
+ npmOutput: string,
660
+ npmFound = true,
661
+ probeFailure: { kind: 'missing' | 'failed'; output: string } | null = null,
662
+ ): string | undefined {
630
663
  // Node itself unreachable: pointing the user back at this same button
631
664
  // would be a dead end (#32). `npmFound` answers this from disk, so it
632
665
  // holds on a Windows console that reports the same thing in a codepage we
@@ -661,6 +694,13 @@ export function provisionHint(corepackOutput: string, npmOutput: string, npmFoun
661
694
  // they can see succeeded, and their complaint was exactly that — "又不告诉
662
695
  // 我怎么手动配置". Whatever the cause, the actionable question is the same
663
696
  // one, so ask it: where is pnpm, and is that anywhere this process looks?
697
+ // pnpm IS on the path and exits non-zero. Telling this user to fix PNPM_HOME
698
+ // would be advice for the opposite problem — theirs runs fine from a shell,
699
+ // which is exactly what #228 reported. Its own output is the explanation.
700
+ if (probeFailure?.kind === 'failed') {
701
+ const detail = probeFailure.output === '' ? '' : `\n\n${probeFailure.output}`
702
+ return `找到 pnpm 了,但运行 \`pnpm --version\` 失败——所以问题不在路径上,设 PNPM_HOME 没有用。最常见的原因是 corepack 的 shim 需要联网下载 pnpm 本体,而这台机器下不到。请在终端执行一次 \`pnpm --version\`:如果同样失败,按它的提示修(受限网络可用 \`brew install pnpm\` 或 \`npm i -g pnpm --registry <你的镜像>\` 装一个完整的 pnpm,绕开 shim);如果在终端里正常,说明 dsh 进程的环境和你的终端不同,请从该终端启动 dsh。pnpm 的原始输出:${detail} / pnpm was found, but \`pnpm --version\` fails — so this is not a path problem and PNPM_HOME will not help. The usual cause is a corepack shim that has to download pnpm itself and cannot reach the network. Run \`pnpm --version\` in a terminal: if it fails the same way, follow what it says (on a restricted network install a real pnpm with \`brew install pnpm\` or \`npm i -g pnpm --registry <your mirror>\` to bypass the shim); if it works there, the dsh process has a different environment than your shell — start dsh from that terminal. pnpm's own output:${detail}`
703
+ }
664
704
  const searched = toolSearchDirs().join(process.platform === 'win32' ? ' ; ' : ' : ')
665
705
  const locate = process.platform === 'win32' ? 'where pnpm' : 'which pnpm'
666
706
  return `pnpm 装好了,但这个 dsh 进程仍然启动不了它——安装步骤都成功,只是装到的位置不在它搜索的范围内。已找过:${searched}。请在终端执行 \`${locate}\` 看 pnpm 实际在哪:如果它不在上面这些目录里,把该目录设为 PNPM_HOME 后重启 dsh(\`export PNPM_HOME=<那个目录>\`),或者干脆从一个能直接运行 pnpm 的终端里启动 dsh。注意必须重启——正在运行的进程读不到新设的环境变量 / pnpm is installed but this dsh process still cannot start it: every step succeeded, the binary just landed somewhere this process does not look. Searched: ${searched}. Run \`${locate}\` in a terminal to see where pnpm actually is; if that directory is not in the list above, set PNPM_HOME to it and restart dsh (\`export PNPM_HOME=<that directory>\`), or simply start dsh from a terminal where \`pnpm\` already runs. The restart matters — a running process cannot see a newly set variable`