pi-web-ui 0.11.4 → 0.11.5
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/bin/pi-web-ui.mjs +45 -3
- package/package.json +1 -1
package/bin/pi-web-ui.mjs
CHANGED
|
@@ -319,6 +319,14 @@ function winPowershell() {
|
|
|
319
319
|
);
|
|
320
320
|
}
|
|
321
321
|
|
|
322
|
+
|
|
323
|
+
/** Full path to wscript.exe — a console-free host (no conhost window, so no black
|
|
324
|
+
* console box ever appears in the taskbar on double-click). Used as the .lnk target;
|
|
325
|
+
* it launches the .ps1 hidden via a thin VBS launcher. */
|
|
326
|
+
function winWscript() {
|
|
327
|
+
return join(process.env.SystemRoot ?? "C:\\Windows", "System32", "wscript.exe");
|
|
328
|
+
}
|
|
329
|
+
|
|
322
330
|
/**
|
|
323
331
|
* Resolve the real node binary. fnm/volta/nvm shims (e.g. fnm_multishells)
|
|
324
332
|
* point into temp dirs that vanish when the installing shell exits — the
|
|
@@ -337,6 +345,12 @@ function winShortcutPs1Path(name) {
|
|
|
337
345
|
return join(winServiceDir(), `${name}-shortcut.ps1`);
|
|
338
346
|
}
|
|
339
347
|
|
|
348
|
+
|
|
349
|
+
/** Windows: launcher vbs the desktop .lnk actually runs (wscript.exe, console-free). */
|
|
350
|
+
function winShortcutVbsPath(name) {
|
|
351
|
+
return join(winServiceDir(), `${name}-shortcut.vbs`);
|
|
352
|
+
}
|
|
353
|
+
|
|
340
354
|
/** Windows: PID file of a shortcut-started (no scheduled task) instance. */
|
|
341
355
|
function winPidFilePath(name) {
|
|
342
356
|
return join(winServiceDir(), `${name}.pid`);
|
|
@@ -430,6 +444,31 @@ function buildWinShortcutPs1(env, cwd, taskName, url, logPath, pidPath) {
|
|
|
430
444
|
].join("\r\n");
|
|
431
445
|
}
|
|
432
446
|
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Build the tiny VBS launcher the desktop .lnk invokes. Its purpose is purely to
|
|
450
|
+
* start the .ps1 *without* creating any console host: wscript.exe has no console,
|
|
451
|
+
* and WScript.Shell.Run(…, 0, False) launches the child hidden and returns at once
|
|
452
|
+
* (0 = hidden window, False = don't wait). Result: double-clicking the icon never
|
|
453
|
+
* flashes a black box and no leftover console appears in the taskbar.
|
|
454
|
+
*/
|
|
455
|
+
function buildWinShortcutVbs(ps1Path) {
|
|
456
|
+
const cmd = `${winPowershell()} -NoProfile -NonInteractive -ExecutionPolicy Bypass -WindowStyle Hidden -File "${ps1Path}"`;
|
|
457
|
+
// VBScript 字符串没有 \" 转义(也没有 \uXXXX),内嵌引号必须写成 "";
|
|
458
|
+
// 不能用 JSON.stringify —— 它输出 \" 会在 VBScript 里提前结束字符串(语句未结束 800A0401),
|
|
459
|
+
// 且会把非 ASCII 路径转成 \uXXXX 字面量(wscript 不识别,中文用户名直接变成乱码路径)。
|
|
460
|
+
const vbsCmd = cmd.replace(/"/g, '""');
|
|
461
|
+
return [
|
|
462
|
+
"Option Explicit",
|
|
463
|
+
"Dim sh, cmd",
|
|
464
|
+
"Set sh = CreateObject(\"WScript.Shell\")",
|
|
465
|
+
`cmd = "${vbsCmd}"`,
|
|
466
|
+
"sh.Run cmd, 0, False",
|
|
467
|
+
"Set sh = Nothing",
|
|
468
|
+
"",
|
|
469
|
+
].join("\r\n");
|
|
470
|
+
}
|
|
471
|
+
|
|
433
472
|
/**
|
|
434
473
|
* Create the Windows desktop .lnk via WScript.Shell COM (correct Desktop path
|
|
435
474
|
* even with OneDrive redirection). Target is powershell.exe with
|
|
@@ -454,6 +493,9 @@ function installWinShortcut(opts) {
|
|
|
454
493
|
}
|
|
455
494
|
mkdirSync(dirname(ps1Path), { recursive: true });
|
|
456
495
|
writeFileSync(ps1Path, "\uFEFF" + ps1, "utf8"); // PS 5.1 需要 BOM
|
|
496
|
+
// wscript host + VBS launcher: no console window / taskbar black box on double-click.
|
|
497
|
+
const vbsPath = winShortcutVbsPath(name);
|
|
498
|
+
writeFileSync(vbsPath, "\uFEFF" + buildWinShortcutVbs(ps1Path), "utf16le"); // wscript 只认 UTF-16/ANSI,UTF-8 BOM 会报“无效字符”,中文路径用 utf16le + BOM
|
|
457
499
|
// 把品牌图标准备好:复制到用户目录(.lnk 图标指向稳定路径)
|
|
458
500
|
if (existsSync(APP_ICO_SOURCE)) {
|
|
459
501
|
copyFileSync(APP_ICO_SOURCE, winIcoPath());
|
|
@@ -466,8 +508,8 @@ function installWinShortcut(opts) {
|
|
|
466
508
|
"$ws = New-Object -ComObject WScript.Shell",
|
|
467
509
|
"$desktop = [Environment]::GetFolderPath('Desktop')",
|
|
468
510
|
`$lnk = $ws.CreateShortcut((Join-Path $desktop ${psQuote(SHORTCUT_LNK_NAME)}))`,
|
|
469
|
-
`$lnk.TargetPath = ${psQuote(
|
|
470
|
-
`$lnk.Arguments =
|
|
511
|
+
`$lnk.TargetPath = ${psQuote(winWscript())}`,
|
|
512
|
+
`$lnk.Arguments = ${psQuote(vbsPath)}`,
|
|
471
513
|
`$lnk.WorkingDirectory = ${psQuote(cwd)}`,
|
|
472
514
|
"$lnk.Description = 'pi-web-ui — 双击启动服务并打开浏览器'",
|
|
473
515
|
`$lnk.IconLocation = ${psQuote(winIcoPath())} + ',0'`,
|
|
@@ -642,7 +684,7 @@ Categories=Network;WebBrowser;
|
|
|
642
684
|
/** Remove desktop shortcut artifacts created by `server shortcut`. */
|
|
643
685
|
function removeShortcut(name) {
|
|
644
686
|
if (isWin) {
|
|
645
|
-
for (const f of [winShortcutPs1Path(name), winPidFilePath(name), winIcoPath()]) {
|
|
687
|
+
for (const f of [winShortcutPs1Path(name), winShortcutVbsPath(name), winPidFilePath(name), winIcoPath()]) {
|
|
646
688
|
if (existsSync(f)) rmSync(f);
|
|
647
689
|
}
|
|
648
690
|
spawnSync(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-web-ui",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.5",
|
|
4
4
|
"description": "Web chat interface for the pi coding agent, powered by the pi SDK (@earendil-works/pi-coding-agent) — one-command run, Docker/systemd/launchd deployable",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|