@kira905/dsh-butler-install 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.
@@ -92,6 +92,17 @@ export async function runEntry({
92
92
  out.write(`端口 ${port} 上没有我们自己的向导页(${found.reason})⇒ 现在起一个。\n`);
93
93
  }
94
94
 
95
+ // 桌面版探测**在这里做一次**(允许探进程),结果挂到 options 上给每个请求复用:
96
+ // · 向导要求"每请求零 spawn" ⇒ 不能每次请求都去探进程;
97
+ // · 而要知道"桌面版正开着",又必须探进程(source === 'process')——
98
+ // 不然同机装了 CLI + 桌面版的人会默认落回 web,装完桌面版界面一个插件都看不到(2026-11-07 实测)。
99
+ if (options.ui && !options.desktopPre) {
100
+ try {
101
+ const { detectDesktop } = await import('../lib/desktop.mjs');
102
+ options.desktopPre = await detectDesktop({ home: options.home, allowProcessProbe: true });
103
+ } catch { /* 探测失败就当没桌面版:退回原来的默认 web */ }
104
+ }
105
+
95
106
  const started = await startServer({ options, port: options.uiPort });
96
107
  if (!started.ok) {
97
108
  for (const line of started.log) out.write(`${line}\n`);
package/lib/plan.mjs CHANGED
@@ -208,6 +208,8 @@ export function resetDesktopDetectCache() {
208
208
  }
209
209
 
210
210
  async function desktopFor(home, options) {
211
+ // 启动时已解析过的(--ui 用它保证每请求零 spawn,同时也才有资格做进程探测)
212
+ if (options.desktopPre) return options.desktopPre;
211
213
  const env = options.env || process.env;
212
214
  const key = `${home}|${env.DSH_DESKTOP_DIR || ''}|${env.DSH_DESKTOP_CLI || ''}`;
213
215
  if (desktopDetectCache.has(key)) return desktopDetectCache.get(key);
@@ -247,6 +249,13 @@ export function decideProfile({ options, home, desktop }) {
247
249
  return { profile: requested, changed: false, source: 'explicit', notices };
248
250
  }
249
251
  if (!options.profileExplicit) {
252
+ // ① 桌面版**正在运行** ⇒ 用户此刻就在用它,默认就该装 desktop。
253
+ // 为什么要这条:下面 ② 只处理"只有 desktop、没有 web"的机器;而同时装了 CLI 与桌面版的人
254
+ // 两个 profile 都在,② 不命中 ⇒ 会落回 web ⇒ 装完桌面版界面上一个插件都看不到(2026-11-07 实测)。
255
+ if (desktop.source === 'process' && desktop.cliCmd) {
256
+ notices.push('检测到桌面版(Electron)正在运行,已默认改成 --profile desktop —— 装进 web 的那套界面,桌面版永远不加载');
257
+ return { profile: 'desktop', changed: true, source: 'auto-desktop-running', notices };
258
+ }
250
259
  const webExists = readProfile(home, 'web').exists;
251
260
  if (desktop.desktopProfileExists && desktop.cliCmd && !webExists) {
252
261
  notices.push('这台机器的数据根里只有桌面版自建的 desktop profile(没有 web),已改成 --profile desktop —— 装进 web 的那套界面桌面版永远不加载');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kira905/dsh-butler-install",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "description": "Thin installer for the DSH butler suite: one command installs the plugin + CLI bundle through the host's own commands, then tells you whether it actually took effect, and can roll the whole batch back. Also ships a local wizard page (--ui) that lives outside DSH and can install from the browser: nothing runs until you press confirm; loopback only, per-process token + same-origin check, four POST entry points (preview/start/cancel/rollback), two honest rollbacks. It does not isolate you from other programs running as the same local user.",
5
5
  "type": "module",
6
6
  "license": "MIT",