@mrrisega/dsh-remote 0.3.8 → 0.3.9

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 +46 -38
  2. package/package.json +1 -1
package/dsh-setup.mjs CHANGED
@@ -469,22 +469,23 @@ async function setup(argv) {
469
469
  // ---------- plugin:安装/卸载 dsh web 远程控制插件 ----------
470
470
  const PLUGIN_MARKER_START = "# >>> dsh-remote-ui (managed by dsh-remote plugin; do not edit)";
471
471
  const PLUGIN_MARKER_END = "# <<< dsh-remote-ui";
472
- /** 插件在 profile 内的固定本地目录(安装时整目录拷贝;include 直接指向其入口文件)。 */
472
+ /** 插件在 profile 内的固定本地目录(安装时整目录拷贝)。 */
473
473
  const PLUGIN_LOCAL_DIR = "dsh-remote-ui-plugin";
474
- /** 插件 node 半入口(相对 profile 目录;加载器按 '.' 开头在配置文件旁解析)。 */
475
- const PLUGIN_ENTRY_REL = `./${PLUGIN_LOCAL_DIR}/lib/index.js`;
476
474
 
477
475
  /**
478
- * include 块。v0.3.7 起 name 直接用「相对文件路径」指向已拷贝的插件入口:
479
- * dsh 加载器对 '.' 开头的 name 会在配置文件(profile)目录旁解析并 import 该文件,
480
- * 完全不经过 pnpm/npm/node_modules —— 任何机器装完即用,包管理器成不成功都不影响。
481
- * (已用隔离 HOME + 独立端口真实启动 dsh web 验证:/dsh-remote/* 路由正常注册。)
476
+ * include 块。name 必须是【裸包名】'dsh-remote-ui':
477
+ * - 加载器据此 import 节点半(dsh-remote-ui node_modules 链接解析);
478
+ * - dsh 客户端模块系统(@deepseek-ai/dsh-client-modules)用 require.resolve(
479
+ * '<name>/package.json') profile 解析该包并读取 package.json
480
+ * dsh.client 声明 → 注入浏览器半(设置面板 UI)。相对文件路径入口只会加载
481
+ * 节点半、不会注入 UI —— 0.3.7/0.3.8 曾因此丢设置页。
482
+ * 链接由安装器自建(node_modules/dsh-remote-ui → 拷贝出的目录),不依赖 pnpm/npm。
482
483
  */
483
484
  function pluginBlock(relayDir) {
484
485
  return `${PLUGIN_MARKER_START}
485
486
  - insert:
486
487
  - id: dsh-remote-ui
487
- name: '${PLUGIN_ENTRY_REL}'
488
+ name: 'dsh-remote-ui'
488
489
  config:
489
490
  relayDir: '${relayDir}'
490
491
  ${PLUGIN_MARKER_END}`;
@@ -559,27 +560,29 @@ function copyPluginIntoProfile(profileDir, pluginDir) {
559
560
  return dest;
560
561
  }
561
562
 
562
- /**
563
- * 清理 v0.3.0~0.3.6 旧机制的残留(避免与新 include 并存造成困惑/冲突):
564
- * - package.json 里 link:/file: 的 dsh-remote-ui 依赖;
565
- * - node_modules 里的 dsh-remote-ui 链接/目录。
566
- */
567
- function cleanupLegacyPluginState(profileDir, pkgFile) {
568
- let changed = false;
563
+ /** 把插件挂到 <profile>/node_modules/dsh-remote-ui(裸包名解析需要),指向拷贝目录;缺失/指错时重建。 */
564
+ function ensurePluginLinked(profileDir, pluginLocalDir) {
565
+ const nmDir = path.join(profileDir, "node_modules");
566
+ const nmPlugin = path.join(nmDir, "dsh-remote-ui");
567
+ fs.mkdirSync(nmDir, { recursive: true });
569
568
  try {
570
- const pkg = JSON.parse(fs.readFileSync(pkgFile, "utf8"));
571
- if (pkg.dependencies && pkg.dependencies["dsh-remote-ui"]) {
572
- delete pkg.dependencies["dsh-remote-ui"];
573
- fs.writeFileSync(pkgFile, JSON.stringify(pkg, null, 2) + "\n");
574
- changed = true;
575
- }
576
- } catch { /* 无 package.json 或损坏则跳过 */ }
569
+ if (fs.realpathSync(nmPlugin) === pluginLocalDir) return false;
570
+ } catch { /* 缺失/悬空 → 重建 */ }
571
+ try { fs.rmSync(nmPlugin, { recursive: true, force: true }); } catch { /* ignore */ }
577
572
  try {
578
- const legacy = path.join(profileDir, "node_modules", "dsh-remote-ui");
579
- fs.rmSync(legacy, { recursive: true, force: true });
580
- // 顺手清理可能因旧依赖产生的空 node_modules 不影响 dsh
581
- } catch { /* ignore */ }
582
- return changed;
573
+ fs.symlinkSync(pluginLocalDir, nmPlugin, "dir");
574
+ } catch {
575
+ fs.cpSync(pluginLocalDir, nmPlugin, { recursive: true });
576
+ }
577
+ try { return fs.realpathSync(nmPlugin) === pluginLocalDir; } catch { return false; }
578
+ }
579
+
580
+ /** package.json 写入 file: 依赖(让后续任何 pnpm/npm install 也认可该插件,不会删链接)。 */
581
+ function declarePluginDep(pkgFile) {
582
+ const pkg = JSON.parse(fs.readFileSync(pkgFile, "utf8"));
583
+ pkg.dependencies = pkg.dependencies || {};
584
+ pkg.dependencies["dsh-remote-ui"] = `file:./${PLUGIN_LOCAL_DIR}`;
585
+ fs.writeFileSync(pkgFile, JSON.stringify(pkg, null, 2) + "\n");
583
586
  }
584
587
 
585
588
  async function pluginCmd(argv) {
@@ -614,21 +617,25 @@ async function pluginCmd(argv) {
614
617
  console.log("ℹ patch 中未发现 dsh-remote-ui 条目。");
615
618
  }
616
619
  fs.rmSync(path.join(profileDir, PLUGIN_LOCAL_DIR), { recursive: true, force: true });
617
- console.log(`✅ 已删除本地插件目录 ${path.join(profileDir, PLUGIN_LOCAL_DIR)}`);
618
- cleanupLegacyPluginState(profileDir, pkgFile);
620
+ fs.rmSync(path.join(profileDir, "node_modules", "dsh-remote-ui"), { recursive: true, force: true });
621
+ try {
622
+ const pkg = JSON.parse(fs.readFileSync(pkgFile, "utf8"));
623
+ if (pkg.dependencies) delete pkg.dependencies["dsh-remote-ui"];
624
+ fs.writeFileSync(pkgFile, JSON.stringify(pkg, null, 2) + "\n");
625
+ } catch { /* ignore */ }
619
626
  console.log("✅ 卸载完成。重启 dsh web 生效。");
620
627
  return;
621
628
  }
622
629
 
623
- // 安装:整目录拷贝插件 + 写相对路径 include。不写 package.json 依赖、不跑 pnpm/npm,
624
- // 不依赖 node_modules —— dsh 加载器按 name 的 './' 相对路径直接 import 入口文件。
630
+ // 安装 = 拷贝完整插件目录 + 写裸名 include + 自建 node_modules 链接 + 声明 file: 依赖。
631
+ // 全程不跑 pnpm/npm;但链接与依赖双保险,任何包管理器之后 install 也不会破坏它。
625
632
  const pluginLocalDir = copyPluginIntoProfile(profileDir, pluginDir);
626
633
  const entryFile = path.join(pluginLocalDir, "lib", "index.js");
627
634
  if (!fs.existsSync(entryFile)) {
628
- console.error(`❌ 插件入口缺失:${entryFile}(本包不完整?)`);
635
+ console.error(`❌ 插件入口缺失:${entryFile}(本包不完整?请用官方源重装:npx --registry=https://registry.npmjs.org @mrrisega/dsh-remote@latest)`);
629
636
  process.exit(1);
630
637
  }
631
- console.log(`✅ 插件已拷贝到 ${pluginLocalDir}(include 直接指向其入口,无需 pnpm/npm)`);
638
+ console.log(`✅ 插件已拷贝到 ${pluginLocalDir}`);
632
639
 
633
640
  // 先清掉旧条目(含旧版无标记条目),再写入带标记的新块,保证不重复。
634
641
  // 关键:先清除默认的 [] 空文档占位行,否则拼接出的 YAML 非法,dsh web 启动即崩。
@@ -636,12 +643,13 @@ async function pluginCmd(argv) {
636
643
  const base = normalizePatchBase(stripped);
637
644
  const block = pluginBlock(CONFIG_DIR);
638
645
  fs.writeFileSync(patchFile, (base ? base + "\n" : "") + block + "\n");
639
- console.log(`✅ 已写入 ${patchFile}(name: ${PLUGIN_ENTRY_REL})`);
646
+ console.log(`✅ 已写入 ${patchFile}(裸名 include:dsh-remote-ui → 节点半 + 浏览器半均生效)`);
640
647
 
641
- // 清理 v0.3.0~0.3.6 旧机制的残留(file:/link: 依赖与 node_modules 链接)
642
- if (cleanupLegacyPluginState(profileDir, pkgFile)) {
643
- console.log("✅ 已清理旧版写入 package.json 的 dsh-remote-ui 依赖与 node_modules 链接");
644
- }
648
+ declarePluginDep(pkgFile); // package.json 声明 file: 依赖(后端各类 install 不误删)
649
+ const linked = ensurePluginLinked(profileDir, pluginLocalDir); // 自建 node_modules 链接
650
+ console.log(linked
651
+ ? `✅ 已建立 node_modules/dsh-remote-ui → ${pluginLocalDir}(免包管理器即可解析)`
652
+ : "✅ node_modules/dsh-remote-ui 已就绪");
645
653
 
646
654
  console.log(`✅ 插件安装完成。配置目录: ${CONFIG_DIR}`);
647
655
  console.log(" 重启 dsh web(或重开 profile)后,在「设置 → 远程控制」查看面板。");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrrisega/dsh-remote",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
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",