@mrrisega/dsh-remote 0.3.5 → 0.3.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.
Files changed (2) hide show
  1. package/dsh-setup.mjs +17 -14
  2. package/package.json +1 -1
package/dsh-setup.mjs CHANGED
@@ -557,26 +557,29 @@ function copyPluginIntoProfile(profileDir, pluginDir) {
557
557
  }
558
558
 
559
559
  /**
560
- * 兜底:确保 dsh 能从 profile 的 node_modules 解析到 dsh-remote-ui
561
- * 部分机器上 pnpm/npm 可能因网络、锁文件或旧 node_modules 布局没真正放下链接,
562
- * 导致 dsh web 启动报 "Cannot find package 'dsh-remote-ui'"。这里直接自建链接/拷贝,
563
- * 保证“装完就能用”,不依赖包管理器的成败。返回 true 表示本次补建了链接。
560
+ * 兜底:确保 dsh 能从 profile 的 node_modules 解析到 dsh-remote-ui,且指向本次拷贝的插件目录。
561
+ * 常见坑:
562
+ * - 残留的旧软链指向旧 npx 缓存(可能悬空/已清理),existsSync 判“存在”会误跳过 必须校验真实目标;
563
+ * - pnpm 布局的 profile 里跑 npm install 会崩(npm 读 .pnpm 报错),不能依赖包管理器。
564
+ * 因此这里:解析现有链接的真实目标,只要不等于本次拷贝目录就强制重建为绝对路径链接/拷贝。
565
+ * 返回 true 表示本次重建了链接。
564
566
  */
565
567
  function ensurePluginLinked(profileDir, pluginLocalDir) {
566
- const nmPlugin = path.join(profileDir, "node_modules", "dsh-remote-ui");
567
- if (fs.existsSync(nmPlugin)) return false; // 已可解析(含目标仍有效的软链)
568
+ const nmDir = path.join(profileDir, "node_modules");
569
+ const nmPlugin = path.join(nmDir, "dsh-remote-ui");
570
+ fs.mkdirSync(nmDir, { recursive: true });
571
+ // 已正确指向本次拷贝目录 → 无需处理
572
+ try {
573
+ if (fs.realpathSync(nmPlugin) === pluginLocalDir) return false;
574
+ } catch { /* 悬空或不存在 → 需要重建 */ }
575
+ try { fs.rmSync(nmPlugin, { recursive: true, force: true }); } catch { /* ignore */ }
568
576
  try {
569
- fs.mkdirSync(path.join(profileDir, "node_modules"), { recursive: true });
570
577
  fs.symlinkSync(pluginLocalDir, nmPlugin, "dir");
571
- return true;
572
578
  } catch {
573
- try {
574
- fs.cpSync(pluginLocalDir, nmPlugin, { recursive: true });
575
- return true;
576
- } catch {
577
- return false;
578
- }
579
+ fs.cpSync(pluginLocalDir, nmPlugin, { recursive: true });
579
580
  }
581
+ // 复核
582
+ try { return fs.realpathSync(nmPlugin) === pluginLocalDir; } catch { return false; }
580
583
  }
581
584
 
582
585
  async function pluginCmd(argv) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrrisega/dsh-remote",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "手机远程控制 DeepSeek Harness · Remote control DeepSeek Harness (dsh web) from any phone browser — 100% 全功能 App 级体验:发消息、看工具执行、审批权限、改设置、管凭据,含特权操作,免内网穿透。一条命令安装 npx @mrrisega/dsh-remote。Mobile remote control for DSH, self-host or SaaS, no server needed on LAN.",
5
5
  "keywords": [
6
6
  "deepseek-harness",