pi-webapp 0.1.50-alpha.1 → 0.1.50-alpha.3

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/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  Conversations, project files, terminals, and Git—side by side. Use the same workbench in your browser or on desktop, while keeping Pi's tools, skills, extensions, and terminal workflow.
6
6
 
7
- [简体中文](README.zh-CN.md) · [Get started](#get-started) · [Download desktop](#desktop-downloads) · [Architecture](#architecture-highlights) · [User guide](docs/en/getting-started.md) · [npm](https://www.npmjs.com/package/pi-webapp)
7
+ [简体中文](README.zh-CN.md) · [Get started](#get-started) · [Download desktop](#desktop-downloads) · [Architecture](#architecture-highlights) · [User guide](docs/en/introduction.md) · [npm](https://www.npmjs.com/package/pi-webapp)
8
8
 
9
9
  **Desktop test build 14:** [macOS Apple Silicon DMG](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b14/pi-0.1.39-desktop.14-mac-arm64.dmg) · [Intel, Windows & Linux downloads](#desktop-downloads) · [SHA-256 checksums](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b14/SHA256SUMS). These are unsigned/unnotarized test packages. See [safe installation](docs/desktop-testing.md).
10
10
 
@@ -48,7 +48,7 @@ npx pi-webapp
48
48
  - **Make it yours:** move shapes, edit labels, adjust layout, and use native undo/redo.
49
49
  - **Keep the result:** save editable `.excalidraw` source to the workspace or export a PNG from the editor.
50
50
 
51
- **Optional plugin:** explicitly install and enable `@chengzhiyi/pi-excalidraw` in **Plugins → Hosted plugins**, using an available compatible release. It is not bundled or auto-installed, and needs no drawing-service account. [Setup, saving & recovery](docs/diagrams.md).
51
+ **Optional plugin:** explicitly install and enable `@chengzhiyi/pi-excalidraw` in **Plugins → Official plugins**, using an available compatible release. It is not bundled or auto-installed, and needs no drawing-service account. [Setup, saving & recovery](docs/diagrams.md).
52
52
 
53
53
  ## Core features
54
54
 
@@ -160,9 +160,12 @@ Read the [architecture and ownership guide](docs/architecture.md) or [Web plugin
160
160
 
161
161
  ## Guides & development
162
162
 
163
- - **New users:** [First conversation](docs/en/getting-started.md) · [Sessions](docs/en/sessions.md) · [Workspace tools](docs/en/workspace-tools.md)
164
- - **Configuration:** [Models, packages, and skills](docs/en/configuration.md) · [Updates](docs/en/updates.md) · [Troubleshooting](docs/en/troubleshooting.md)
165
- - **Contributors:** [Architecture](docs/architecture.md) · [Web plugins](docs/web-plugins.md) · [Desktop builds](docs/desktop.md)
163
+ - **New users:** [Quick start](docs/en/getting-started.md) · [Conversations](docs/en/conversation.md) · [Sessions and workspaces](docs/en/sessions.md) · [Files, terminal and Git](docs/en/workspace-tools.md) · [Diagrams](docs/en/diagrams.md)
164
+ - **Configuration:** [Overview](docs/en/configuration.md) · [Models and providers](docs/en/models.md) · [Packages, skills and plugins](docs/en/extensions.md) · [Updates](docs/en/updates.md) · [Security and privacy](docs/en/security.md)
165
+ - **Help and reference:** [Troubleshooting](docs/en/troubleshooting.md) · [FAQ](docs/en/faq.md) · [Command line](docs/en/reference/cli.md) · [Environment variables](docs/en/reference/environment.md)
166
+ - **Contributors:** [Architecture](docs/architecture.md) · [Web plugins](docs/web-plugins.md) · [Desktop builds](docs/desktop.md) · [Developers](docs/en/developers.md)
167
+
168
+ The guides are also built as a searchable site with `npm run docs:build` (preview it with `npm run docs:dev`, after `npm --prefix docs ci`). They are written as VitePress pages under `docs/en/`; once the site has a public address, these links should point to it.
166
169
 
167
170
  The guides follow the source tree; installed versions may differ. For desktop availability, use the verified release links above and their release notes.
168
171
 
package/bin/pi-webapp.mjs CHANGED
@@ -193,12 +193,14 @@ async function serve(pi, args) {
193
193
  void readFile(stopPath, "utf8").then(value => value.trim() === nonce ? unlink(stopPath) : undefined)
194
194
  .catch(() => {}).finally(() => { stopping = false; });
195
195
  };
196
- const shutdown = (reason) => {
196
+ const shutdown = (reason, force = false) => {
197
197
  if (stopping) return;
198
198
  stopping = true;
199
199
  stopEpoch++;
200
200
  stopReason = reason;
201
201
  lifecycle("launcher_stop_requested", { reason });
202
+ // An explicit operator override: skip the save/drain preflight that an unresponsive view can block.
203
+ if (force) { lifecycle("launcher_stop_forced", { reason }); finishShutdown(reason); return; }
202
204
  // RPC EOF can exit even when an extension's shutdown handler fails. Drain
203
205
  // while the transport is alive and require an explicit successful response.
204
206
  if (ready && stopCommand) {
@@ -225,6 +227,7 @@ async function serve(pi, args) {
225
227
  const request = (await readFile(stopPath, "utf8")).trim();
226
228
  if (epoch !== stopEpoch || stopping) return;
227
229
  if (request === nonce) shutdown("stop_request");
230
+ else if (request === `${nonce} force`) shutdown("stop_request", true);
228
231
  } catch { /* No stop request. */ }
229
232
  if (stopping || epoch !== stopEpoch) return;
230
233
  if (runtimeKind === "desktop") {
@@ -505,16 +508,36 @@ async function openPageIfLocal(url) {
505
508
  }
506
509
  }
507
510
 
508
- async function stop() {
511
+ // Last resort for `stop --force`: a supervisor that predates the force marker (or is wedged)
512
+ // never answers it, so end the whole process tree. Hosted ownership recovers from SIGKILL.
513
+ async function killTree(pid) {
514
+ if (process.platform === "win32") { spawn.sync("taskkill", ["/pid", String(pid), "/T", "/F"], { windowsHide: true }); return; }
515
+ const listed = spawn.sync("pgrep", ["-P", String(pid)], { encoding: "utf8" });
516
+ for (const child of String(listed.stdout ?? "").split("\n").map(Number).filter(Number.isInteger)) if (child > 0) await killTree(child);
517
+ try { process.kill(pid, "SIGKILL"); } catch { /* already gone */ }
518
+ }
519
+
520
+ async function stop(force = false) {
509
521
  const state = await activeState();
510
522
  if (!state) { console.log("pi-webapp 未运行"); return; }
511
523
  if (!state.nonce) throw new Error("pi-webapp 正在启动,请稍后再停止");
512
- await writeFile(stopPath, state.nonce, { mode: 0o600 });
524
+ if (force) console.error("pi-webapp: 强制停止将跳过插件视图的保存确认,未保存的编辑可能丢失。");
525
+ await writeFile(stopPath, force ? `${state.nonce} force` : state.nonce, { mode: 0o600 });
513
526
  for (let attempt = 0; attempt < 400; attempt++) {
514
527
  await new Promise((resolveWait) => setTimeout(resolveWait, 100));
515
528
  const outcome = await observeStopOutcome(activeState, stopPath, state.nonce);
516
529
  if (outcome === "stopped") { console.log("pi-webapp 已停止"); return; }
517
- if (outcome === "refused") throw new Error("停止已取消:插件保存或释放未完成,服务及数据已保留。请处理插件诊断后重试。");
530
+ if (force && outcome === "pending" && attempt === 49) {
531
+ console.error("pi-webapp: 服务 5 秒内没有响应强制停止,正在直接结束后台进程及其子进程。");
532
+ await killTree(state.pid);
533
+ await unlink(stopPath).catch(() => {});
534
+ for (let wait = 0; wait < 50 && alive(state.pid); wait++) await new Promise((resolveWait) => setTimeout(resolveWait, 100));
535
+ if (alive(state.pid)) throw new Error(`无法结束后台进程 PID:${state.pid}`);
536
+ await activeState();
537
+ console.log("pi-webapp 已强制停止");
538
+ return;
539
+ }
540
+ if (outcome === "refused") throw new Error("停止已取消:插件保存或释放未完成,服务及数据已保留。请先保存并关闭所有 pi-webapp 浏览器标签页,或在插件页处理未确认的视图后重试;开发时可运行 pi-webapp stop --force 强制停止(可能丢失未保存的编辑)。");
518
541
  }
519
542
  throw new Error(`停止超时。后台进程 PID:${state.pid};日志:${logPath}`);
520
543
  }
@@ -523,15 +546,16 @@ async function main() {
523
546
  const [argument, ...rest] = process.argv.slice(2);
524
547
  if (argument === "__serve") { await serve(rest[0], rest.slice(1)); return; }
525
548
  if (argument === "stop" || argument === "status") {
526
- if (rest.length) throw new Error(`用法:pi-webapp ${argument}`);
527
- if (argument === "stop") await stop();
549
+ const force = argument === "stop" && rest.length === 1 && rest[0] === "--force";
550
+ if (rest.length && !force) throw new Error(`用法:pi-webapp ${argument}${argument === "stop" ? " [--force]" : ""}`);
551
+ if (argument === "stop") await stop(force);
528
552
  else {
529
553
  const state = await activeState();
530
554
  console.log(state ? `pi-webapp ${state.url ? `正在运行:${state.url}` : "正在启动"}` : "pi-webapp 未运行");
531
555
  }
532
556
  return;
533
557
  }
534
- if (argument === "--help" || argument === "-h") { console.log("用法:pi-webapp [start|status|stop] [Pi 参数]"); return; }
558
+ if (argument === "--help" || argument === "-h") { console.log("用法:pi-webapp [start|status|stop [--force]] [Pi 参数]"); return; }
535
559
  if (argument && argument !== "start" && !argument.startsWith("-")) throw new Error("用法:pi-webapp [start|status|stop] [Pi 参数]");
536
560
  await start(argument === "start" || !argument ? rest : [argument, ...rest]);
537
561
  }