pi-web-ui 0.44.2 → 0.46.0
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/LICENSE +21 -21
- package/README.md +458 -388
- package/README.zh-CN.md +380 -359
- package/bin/pi-web-ui.mjs +1818 -1818
- package/deploy/com.xingshuyin.pi-web-ui.plist +48 -48
- package/deploy/nginx-subpath.conf +88 -88
- package/deploy/pi-web-ui-task.xml +71 -71
- package/deploy/pi-web-ui.service +31 -31
- package/dist/server/agent-service.js +184 -36
- package/dist/server/attachments.js +3 -3
- package/dist/server/client-state.js +2 -0
- package/dist/server/index.js +6 -0
- package/dist/server/protocol-version.js +1 -1
- package/dist/server/settings-service.js +105 -11
- package/dist/server/terminals.js +5 -5
- package/electron/main.mjs +427 -0
- package/extensions/webui.ts +192 -192
- package/package.json +19 -5
- package/themes/md-preview.css +7328 -7253
- package/themes/white.css +7389 -7314
- package/web/dist/assets/{TerminalPanel-BuG4RDBE.js → TerminalPanel-BoLQmU5b.js} +1 -1
- package/web/dist/assets/index-B71Da7xx.js +19 -0
- package/web/dist/assets/index-CoufKLTQ.css +10 -0
- package/web/dist/favicon.svg +8 -8
- package/web/dist/index.html +15 -15
- package/web/public/favicon.svg +8 -8
- package/web/dist/assets/index-B0NAJgJX.js +0 -19
- package/web/dist/assets/index-BByVm30o.css +0 -10
package/README.md
CHANGED
|
@@ -1,388 +1,458 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
[
|
|
6
|
-
|
|
7
|
-
[
|
|
8
|
-
|
|
9
|
-
>
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
>
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
-
|
|
55
|
-
-
|
|
56
|
-
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
-
|
|
63
|
-
-
|
|
64
|
-
-
|
|
65
|
-
|
|
66
|
-
**
|
|
67
|
-
|
|
68
|
-
-
|
|
69
|
-
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
-
|
|
75
|
-
-
|
|
76
|
-
-
|
|
77
|
-
-
|
|
78
|
-
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
-
|
|
83
|
-
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
**
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
##
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
pi-web-ui
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
pi-web-ui
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
pi-web-ui
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
pi-web-ui
|
|
250
|
-
pi-web-ui
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# 💬 pi-web-ui
|
|
4
|
+
|
|
5
|
+
**English** | [Chinese (Simplified)](https://github.com/xing-shuyin/pi-web-ui/blob/main/README.zh-CN.md)
|
|
6
|
+
|
|
7
|
+
*The polished browser cockpit for the [pi coding agent](https://pi.dev).*
|
|
8
|
+
|
|
9
|
+
<p>
|
|
10
|
+
<a href="https://www.npmjs.com/package/pi-web-ui"><img src="https://img.shields.io/npm/v/pi-web-ui?color=cb3837&logo=npm&label=pi-web-ui" alt="npm version"></a>
|
|
11
|
+
<a href="https://nodejs.org/"><img src="https://img.shields.io/node/v/pi-web-ui?logo=node.js&logoColor=white" alt="Node.js"></a>
|
|
12
|
+
<a href="LICENSE"><img src="https://img.shields.io/github/license/xing-shuyin/pi-web-ui" alt="License"></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/pi-web-ui"><img src="https://img.shields.io/npm/dm/pi-web-ui?label=downloads" alt="npm downloads"></a>
|
|
14
|
+
<a href="https://github.com/xing-shuyin/pi-web-ui/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/xing-shuyin/pi-web-ui/ci.yml?branch=main&label=CI" alt="CI status"></a>
|
|
15
|
+
<a href="https://github.com/xing-shuyin/pi-web-ui/stargazers"><img src="https://img.shields.io/github/stars/xing-shuyin/pi-web-ui?style=social" alt="GitHub stars"></a>
|
|
16
|
+
<a href="https://github.com/xing-shuyin/pi-web-ui/fork"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen?style=flat" alt="PRs welcome"></a>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
Stream conversations, inspect tool calls, manage files, and run your workspace — all from one place.
|
|
20
|
+
|
|
21
|
+

|
|
22
|
+
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
A web chat interface for the [pi coding agent](https://pi.dev). The agent runs
|
|
26
|
+
**in-process** via the pi SDK and streams events to the browser over WebSocket:
|
|
27
|
+
thinking blocks, tool calls, file trees, a built-in terminal, model management,
|
|
28
|
+
theme switching, and a full settings panel — tuned for daily development.
|
|
29
|
+
|
|
30
|
+
> **Requirements** — Node.js ≥ 22.19 and a configured pi install.
|
|
31
|
+
|
|
32
|
+
## More from the author
|
|
33
|
+
|
|
34
|
+
> **Building with DSH?**
|
|
35
|
+
>
|
|
36
|
+
> [**dsh-ui-tools**](https://github.com/xing-shuyin/dsh-ui-tools) is the author's companion project for building and extending UI tools in the DSH ecosystem.
|
|
37
|
+
|
|
38
|
+
## ✨ Highlights
|
|
39
|
+
|
|
40
|
+
| 💬 **Chat that works like you do** | 🖼️ **Files & images** | 🧩 **Extensible by design** | 🔒 **Private by default** |
|
|
41
|
+
| --- | --- | --- | --- |
|
|
42
|
+
| Streaming replies, steer & follow-up queueing, slash commands, multiple conversations per project, edit-&-re-ask. | Attach files, paste images, ask about pictures (vision bridge), preview anything with GBK fallback. | Drop-in UI **plugins** (extra top-bar tabs + agent tools) and standalone **themes** — no rebuild, no restart. | Loopback-only, credential-safe: provider keys & headers never reach the browser. |
|
|
43
|
+
|
|
44
|
+
## 📚 Table of Contents
|
|
45
|
+
|
|
46
|
+
- 🚀 [Features](#features)
|
|
47
|
+
- 🖼️ [Screenshots](#screenshots)
|
|
48
|
+
- 📦 [Install](#install)
|
|
49
|
+
- ⚡ [Quick start](#quick-start)
|
|
50
|
+
- 🖥️ [System service](#system-service)
|
|
51
|
+
- 🧩 [Plugins](#plugins)
|
|
52
|
+
- 🎨 [Themes](#themes)
|
|
53
|
+
- 🔒 [Security](#security)
|
|
54
|
+
- 🌐 [Reverse proxy (nginx)](#reverse-proxy-nginx)
|
|
55
|
+
- 🤝 [Contribute](#contribute)
|
|
56
|
+
- 📄 [License](#license)
|
|
57
|
+
|
|
58
|
+
## Features
|
|
59
|
+
|
|
60
|
+
### 💬 Chat
|
|
61
|
+
|
|
62
|
+
- **Streaming agent chat over WebSocket** — the pi SDK runs in-process; events are pushed as snapshots (60 ms throttled) and the browser renders them.
|
|
63
|
+
- Thinking blocks, tool-call cards and bash outputs with live status (running → finished · waiting for the model · duration).
|
|
64
|
+
- **Steer (follow-up queueing)** — send a follow-up while the agent is replying; it is queued and injected as soon as the current turn's tool calls settle (the "Interrupt" equivalent of the pi CLI).
|
|
65
|
+
- **Slash commands** — `/` opens a command picker (built-in / extension / template / skill); built-ins include `/new /model /compact /cwd /thinking /resume`, plus `/help` (command list) and `/copy` (copy last reply).
|
|
66
|
+
- **Multiple conversations per project** — each conversation gets its own agent runtime and keeps running in the background after you switch away; the "Running conversations" list shows stream progress and lets you switch back.
|
|
67
|
+
- **Edit & re-ask** — fork any past question into a new branch and re-prompt; the original conversation stays untouched.
|
|
68
|
+
- Long threads auto-collapse messages older than 30 into lazy summary rows (click to expand).
|
|
69
|
+
- Question navigation — a floating rail plus per-question tags to jump between questions.
|
|
70
|
+
|
|
71
|
+
### 🖼️ Files, images & attachments
|
|
72
|
+
|
|
73
|
+
- Three attachment modes: `inline` (≤12 KB), `reference` (path only), `lines` (selected ranges) — over-limit ones degrade automatically.
|
|
74
|
+
- Paste / drag-drop / upload images — resized client-side and sent as image content when the model supports vision (warning otherwise).
|
|
75
|
+
- **Vision bridge** — when the current model is text-only, images are transcribed into text evidence by an auto-discovered vision model (cached per batch; model & on/off configurable in Settings).
|
|
76
|
+
- Attach arbitrary files without a workspace path — stored in a global uploads dir, inlined when small, referenced by absolute path otherwise.
|
|
77
|
+
- File preview — line numbers, click/drag/Shift selection (add to chat as `lines`), GBK fallback decoding, binary hex view, media preview over HTTP with Range support, and a download button.
|
|
78
|
+
- Live file tree — the server watches the listed directory (`fs.watch`) and re-lists on change; oversized directories show a truncation warning.
|
|
79
|
+
|
|
80
|
+
### 🖥️ Terminal & Git
|
|
81
|
+
|
|
82
|
+
- Built-in terminal (xterm.js + node-pty) with per-client PTY management; Windows auto-selects Git Bash (busybox fallback).
|
|
83
|
+
- **Source control (Git) panel** — status / branch / diff / untracked files via a hidden query terminal; commit, switch branch, push and pull run in the visible terminal and auto-switch to the terminal view.
|
|
84
|
+
|
|
85
|
+
### 🎛️ Models & settings
|
|
86
|
+
|
|
87
|
+
- Theme switching — pick a theme in the top bar; each theme is a full standalone stylesheet (default dark + a bundled light). See [Themes](#themes) for how to add your own or contribute one.
|
|
88
|
+
- Model management — edit `models.json` in the UI and set per-provider API keys (keys/headers never leave the server).
|
|
89
|
+
- Thinking level per model (only the levels the model actually supports are shown).
|
|
90
|
+
- First-run setup wizard.
|
|
91
|
+
- Settings panel — system prompt (append or replace), toggle skills/extensions on/off with immediate effect, save/apply/delete settings presets, and vision-bridge model & switch.
|
|
92
|
+
|
|
93
|
+
### 🎯 Goal mode
|
|
94
|
+
|
|
95
|
+
- Goal bar — set a target with a review model, max rounds and a lock switch.
|
|
96
|
+
- Goal wizard (**AI Refine**) — turns a raw request into a concrete goal through a guided questionnaire.
|
|
97
|
+
- Automatic review loop — after each turn an independent review session checks the goal against the final text and `git diff HEAD`; on fail the feedback is injected as steer until it passes (or the round cap is hit).
|
|
98
|
+
|
|
99
|
+
### ⚙️ Background tasks
|
|
100
|
+
|
|
101
|
+
- Background-task panel — servers launched by the agent are detected via port snapshots and listed (port/pid/name); stop one or kill all.
|
|
102
|
+
- Tool watchdog — a tool call running over 20 minutes is aborted automatically.
|
|
103
|
+
- **Stop bash command only** — abort a running bash tool without killing the conversation.
|
|
104
|
+
|
|
105
|
+
### 🛡️ Safety & operations
|
|
106
|
+
|
|
107
|
+
- Loopback-only by default; set `PI_WEB_HOST=0.0.0.0` for LAN / containers.
|
|
108
|
+
- WebSocket Origin/Host same-authority check — cross-origin pages are rejected (403); `PI_WEB_ALLOW_ORIGINS` whitelist for reverse proxies.
|
|
109
|
+
- Quiesce drain mode via a local control socket (`server status|quiesce|unquiesce`).
|
|
110
|
+
- Credentials stay server-side — provider headers are never sent to the browser.
|
|
111
|
+
- Sound alerts, Chinese/English UI, and a recent-projects list (click to switch workspace).
|
|
112
|
+
|
|
113
|
+
### 🚢 Deploy & update
|
|
114
|
+
|
|
115
|
+
- Foreground, global npm install, Docker (docker-compose), macOS launchd, Linux systemd, Windows Task Scheduler, and a desktop shortcut (`server shortcut`).
|
|
116
|
+
- In-app self-update — checks the npm registry, installs and auto-restarts the service.
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
## Screenshots
|
|
120
|
+
|
|
121
|
+
<table>
|
|
122
|
+
<tr>
|
|
123
|
+
<td align="center"><img src="https://raw.githubusercontent.com/xing-shuyin/pi-web-ui/main/assets/shot1.png" alt="Settings panel"><br><sub>Settings panel</sub></td>
|
|
124
|
+
<td align="center"><img src="https://raw.githubusercontent.com/xing-shuyin/pi-web-ui/main/assets/shot2.jpeg" alt="Built-in terminal"><br><sub>Built-in terminal</sub></td>
|
|
125
|
+
</tr>
|
|
126
|
+
<tr>
|
|
127
|
+
<td align="center"><img src="https://raw.githubusercontent.com/xing-shuyin/pi-web-ui/main/assets/shot3.jpeg" alt="Chat interface"><br><sub>Chat interface</sub></td>
|
|
128
|
+
<td align="center"><img src="https://raw.githubusercontent.com/xing-shuyin/pi-web-ui/main/assets/shot4.jpeg" alt="Git source control panel"><br><sub>Git source control panel</sub></td>
|
|
129
|
+
</tr>
|
|
130
|
+
</table>
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
## Install
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
npm i -g pi-web-ui # global install (recommended)
|
|
137
|
+
npx pi-web-ui # or run without installing (latest, starts on :8787)
|
|
138
|
+
npm i -g . # or install the local checkout
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**npm ≥ 12?** npm 12+ blocks dependency install scripts by default (you'll see
|
|
142
|
+
`npm warn install-scripts … blocked`). node-pty is a native module, so allow its
|
|
143
|
+
script (the other two packages it lists are harmless no-ops — allowing them just
|
|
144
|
+
silences the warning):
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
npm i -g --allow-scripts=node-pty,@google/genai,protobufjs pi-web-ui@latest
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
## Quick start
|
|
152
|
+
|
|
153
|
+
**Start**
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
pi-web-ui # foreground, http://localhost:8787
|
|
157
|
+
PORT=9000 PI_WEB_CWD=/path/to/project pi-web-ui # custom port / workspace
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**Stop**
|
|
161
|
+
|
|
162
|
+
- **Foreground**: press `Ctrl+C` in the terminal running it.
|
|
163
|
+
- **As a service**: `pi-web-ui server stop` (stops the instance; auto-start stays until `server uninstall`).
|
|
164
|
+
|
|
165
|
+
**Update**
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
npm i -g pi-web-ui@latest # upgrade to the latest published version
|
|
169
|
+
pi-web-ui server restart # restart the service to apply it (foreground: restart manually)
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**Uninstall**
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
npm uninstall -g pi-web-ui
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Uninstalling does **not** delete your chats — session data lives in
|
|
179
|
+
`<cwd>/.pi-web` (or `PI_WEB_DATA_DIR`) and survives uninstall/upgrade.
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
## System service
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
pi-web-ui server install --port 9000 --cwd /path/to/project # install + start
|
|
186
|
+
pi-web-ui server status # running? auto-start?
|
|
187
|
+
pi-web-ui server restart # restart (applies config/version changes)
|
|
188
|
+
pi-web-ui server stop # stop (auto-start stays)
|
|
189
|
+
pi-web-ui server start # start again
|
|
190
|
+
pi-web-ui server uninstall # remove the service entirely
|
|
191
|
+
pi-web-ui server shortcut # desktop one-click launch icon
|
|
192
|
+
pi-web-ui server quiesce # drain: refuse NEW chats/messages, let running ones finish
|
|
193
|
+
pi-web-ui server unquiesce # reopen admission
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
`server status` also shows live stats via a local control socket (version,
|
|
197
|
+
PID, quiesce state, connected browsers, running conversations) — the same
|
|
198
|
+
socket drives `quiesce`/`unquiesce`.
|
|
199
|
+
|
|
200
|
+
- **macOS** → launchd agent (no sudo), logs to `/tmp/pi-web-ui.log` / `.err`
|
|
201
|
+
- **Linux** → systemd unit (`systemctl enable --now`), logs via `journalctl -u pi-web-ui -f`
|
|
202
|
+
- **Windows** → Task Scheduler logon task (hidden PowerShell window, no black console)
|
|
203
|
+
|
|
204
|
+
Options: `--port` (default 8787), `--cwd` (workspace), `--data-dir` (sessions),
|
|
205
|
+
`--name` (custom service name). Rerunning `server install` with new options
|
|
206
|
+
regenerates the config and restarts the service — that's how you change its
|
|
207
|
+
port/cwd.
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
## Plugins
|
|
211
|
+
|
|
212
|
+
Plugins are optional UI components (extra top-bar tabs backed by their own
|
|
213
|
+
client view, optionally with a server-side entry and agent tools). They live in
|
|
214
|
+
your **data-dir plugins folder** (`<dataDir>/plugins/<id>/`, default
|
|
215
|
+
`~/.pi-web/plugins/`) — a plugin is simply a directory containing
|
|
216
|
+
`manifest.json`, an optional server entry (`index.mjs`) and an optional view
|
|
217
|
+
entry (`client/entry.mjs`). No plugin directories = no plugins, nothing shows
|
|
218
|
+
up in the UI.
|
|
219
|
+
|
|
220
|
+
### Plugin catalog
|
|
221
|
+
|
|
222
|
+
These plugins ship in this repository (`dev/plugins/<id>/`) and can be installed
|
|
223
|
+
straight from GitHub:
|
|
224
|
+
|
|
225
|
+
| Plugin | What it does |
|
|
226
|
+
| --- | --- |
|
|
227
|
+
| 📬 [webmail](https://github.com/xing-shuyin/pi-web-ui/tree/main/dev/plugins/webmail) | IMAP inbox browsing / search / read / mark / delete + SMTP sending, new-mail notifications, and an optional "allow AI to manage my mailbox" switch (six `mail_*` agent tools). Auto-installs its npm deps on first activation. |
|
|
228
|
+
| 🗄️ [db-client](https://github.com/xing-shuyin/pi-web-ui/tree/main/dev/plugins/db-client) | Database workbench: connection manager + schema tree for MySQL / PostgreSQL / SQLite / SQL Server / MongoDB / Redis — table structure, paginated data with sorting, SQL editor, and row editing. Drivers auto-install on first use. |
|
|
229
|
+
| 📝 [vscode-editor](https://github.com/xing-shuyin/pi-web-ui/tree/main/dev/plugins/vscode-editor) | VS Code-like workbench: multi-root file tree (local + SSH hosts), CodeMirror multi-tab editor, Remote-SSH remote file browsing/editing, draggable multi-terminal panel (xterm.js), SFTP sync & upload/download to your computer. Auto-installs `ssh2`. |
|
|
230
|
+
| 📬 [demo-mailbox](https://github.com/xing-shuyin/pi-web-ui/tree/main/dev/plugins/demo-mailbox) | Minimal example plugin demonstrating the server entry + client view + two-way message protocol. Doubles as the plugin test fixture — start here if you want to write your own. |
|
|
231
|
+
|
|
232
|
+
Example — install the webmail plugin:
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
pi-web-ui install https://github.com/xing-shuyin/pi-web-ui/tree/main/dev/plugins/webmail
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
Each plugin's directory in the repo has its own `README.md` with full feature
|
|
239
|
+
lists, configuration and per-plugin caveats.
|
|
240
|
+
|
|
241
|
+
### Installing
|
|
242
|
+
|
|
243
|
+
From GitHub (any of these source forms):
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
pi-web-ui install owner/repo # shorthand
|
|
247
|
+
pi-web-ui install https://github.com/owner/repo # full URL (.git optional)
|
|
248
|
+
pi-web-ui install https://github.com/o/r/tree/dev/sub/dir # branch + subdirectory inside the repo
|
|
249
|
+
pi-web-ui install owner/repo#v1.2 # pin a branch/tag (#suffix works on any form above)
|
|
250
|
+
pi-web-ui install /path/to/plugin-dir # local directory (for development)
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Useful options:
|
|
254
|
+
|
|
255
|
+
- `--name <id>` — custom plugin id / directory name (defaults to the repo or
|
|
256
|
+
subdirectory name; letters/digits/`-`/`_` only).
|
|
257
|
+
- `--force` — overwrite an existing installation. Your plugin's local
|
|
258
|
+
`config.json` (credentials etc.) is preserved across upgrades.
|
|
259
|
+
- `--data-dir <dir>` — override the data dir (default `~/.pi-web`).
|
|
260
|
+
|
|
261
|
+
The CLI clones the repo (shallow; falls back to a tarball download without
|
|
262
|
+
git), locates the `manifest.json` (including inside subdirectories) and copies
|
|
263
|
+
the plugin into `<dataDir>/plugins/<id>/`.
|
|
264
|
+
|
|
265
|
+
**No git? No network?** You can also just copy a plugin directory into
|
|
266
|
+
`~/.pi-web/plugins/` by hand — same result.
|
|
267
|
+
|
|
268
|
+
### Updating
|
|
269
|
+
|
|
270
|
+
Re-run `install` against the same source with `--force`:
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
# example: update the webmail plugin to the latest version in the repo
|
|
274
|
+
pi-web-ui install https://github.com/xing-shuyin/pi-web-ui/tree/main/dev/plugins/webmail --force
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
- The upgrade preserves the plugin's local `config.json` automatically.
|
|
278
|
+
- Plugins that store other local state inside their directory (e.g. db-client's
|
|
279
|
+
`db-connections.json`, vscode-editor's `ssh-hosts.json`) are **not** covered
|
|
280
|
+
by that preservation — back those up before a forced reinstall.
|
|
281
|
+
- Refresh the browser afterwards; no server restart needed.
|
|
282
|
+
|
|
283
|
+
### Activating
|
|
284
|
+
|
|
285
|
+
If the server is running, just **refresh the browser** — new plugins are picked
|
|
286
|
+
up on attach without a restart. If it isn't, they load on next start. Each
|
|
287
|
+
plugin appears as a tab (🧩 or its own icon) in the top bar.
|
|
288
|
+
|
|
289
|
+
### Listing / disabling / uninstalling
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
pi-web-ui plugins # list installed plugins (id / name / version / description)
|
|
293
|
+
pi-web-ui uninstall <id> # remove a plugin
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
- To temporarily hide a plugin without uninstalling, use the **Settings panel
|
|
297
|
+
(⚙) → UI plugins** switches — stored per client, purely visual, no restart
|
|
298
|
+
needed. Re-enable any time.
|
|
299
|
+
- `uninstall` deletes the plugin directory; refresh the browser and its tab
|
|
300
|
+
disappears. Plugin configuration written inside the plugin dir is removed
|
|
301
|
+
too — back up `<dataDir>/plugins/<id>/config.json` first if you need it.
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
## Themes
|
|
305
|
+
|
|
306
|
+
Each theme is a **complete standalone stylesheet** — a full copy of the bundled dark `web/src/styles.css` with a different palette (no CSS-variable extraction, no base file to include). Picking a theme swaps the whole file, so any theme works with every build.
|
|
307
|
+
|
|
308
|
+
Built-in themes ship in the npm package (`themes/`, e.g. the bundled light theme). The theme picker lives in the top bar (🌞 icon); the current choice is stored per browser in `localStorage`.
|
|
309
|
+
|
|
310
|
+
### Using a theme
|
|
311
|
+
|
|
312
|
+
Just pick it in the top bar — built-in and user themes are merged in the same menu. User themes win over built-ins on the same id.
|
|
313
|
+
|
|
314
|
+
### Providing a theme locally (no GitHub needed)
|
|
315
|
+
|
|
316
|
+
Any CSS file dropped into your **data-dir themes folder** shows up in the theme menu automatically — no restart, no rebuild:
|
|
317
|
+
|
|
318
|
+
1. Find your data dir (default `~/.pi-web`, override with `PI_WEB_DATA_DIR`).
|
|
319
|
+
2. Create `<dataDir>/themes/` and drop your stylesheet in: e.g. `~/.pi-web/themes/my-theme.css`.
|
|
320
|
+
3. Reload the page and pick it in the top bar. The **file name (without `.css`)** is the theme id shown in the menu.
|
|
321
|
+
|
|
322
|
+
```
|
|
323
|
+
~/.pi-web/
|
|
324
|
+
└── themes/
|
|
325
|
+
└── my-theme.css # appears in the menu as "my-theme"
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
Easiest way to write one: copy `themes/light.css` (or the bundled dark `web/src/styles.css` from the source repo) and change the `:root` colors plus any hardcoded values — the file must be **self-contained**. Notes:
|
|
329
|
+
|
|
330
|
+
- The **terminal follows the theme** — set the `--term-*` variables (terminal ANSI palette + `--term-bg`) in your `:root` and both the xterm canvas and its padded container adapt automatically (see the defaults in `styles.css` and the light values in `themes/light.css`).
|
|
331
|
+
- Syntax-highlight colors (`highlight.js`'s `github-dark.css` is bundled) must be overridden in your theme file or code will be unreadable — see the `.hljs` overrides at the bottom of `themes/light.css` for the pattern.
|
|
332
|
+
- Theme ids must match `^[A-Za-z0-9_-]+$` (no dots/slashes — path-traversal guard on the server).
|
|
333
|
+
|
|
334
|
+
### Contributing a theme to the repository (GitHub)
|
|
335
|
+
|
|
336
|
+
Want your theme shipped to everyone? Open a pull request at [github.com/xing-shuyin/pi-web-ui](https://github.com/xing-shuyin/pi-web-ui):
|
|
337
|
+
|
|
338
|
+
1. Fork the repo and clone it.
|
|
339
|
+
2. Create your theme as `themes/<id>.css` — a **self-contained** stylesheet. Copy `themes/light.css` as the starting template (it's the generator output for a full standalone theme).
|
|
340
|
+
3. Verify locally: run `npm run dev`, then use the top bar theme picker — your theme must be listed and render correctly (chat cards, code blocks, tool-call cards, git/terminal panels).
|
|
341
|
+
4. If you only changed colors in `styles.css` and want the bundled light theme updated too, regenerate it with `node make-light-theme.mjs`.
|
|
342
|
+
5. Commit (`git add themes/<id>.css`) and open the PR. The `themes/` folder is already in the npm package `files` whitelist, so once merged and released, `npm i -g pi-web-ui` will ship your theme to everyone.
|
|
343
|
+
|
|
344
|
+
Rules for merged themes: the file must be a single self-contained CSS file, be a full standalone theme (no imports of the base `styles.css`), set the `--term-*` variables for a readable terminal, and override `.hljs` syntax colors for readable code.
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
## Security
|
|
348
|
+
|
|
349
|
+
- **Loopback-only by default** — the server binds `127.0.0.1` and is not
|
|
350
|
+
reachable from the network unless you explicitly set `PI_WEB_HOST=0.0.0.0`
|
|
351
|
+
(e.g. LAN access, Docker port mapping — the compose file sets it for you).
|
|
352
|
+
- **WebSocket origin check** — browser pages connecting to `/ws` must present
|
|
353
|
+
an `Origin` whose hostname **and port** match the request `Host`;
|
|
354
|
+
cross-origin pages are rejected with 403. Non-browser clients (no `Origin`)
|
|
355
|
+
are unaffected. Add `PI_WEB_ALLOW_ORIGINS=http://your-host:port` for
|
|
356
|
+
reverse-proxy setups.
|
|
357
|
+
- **Quiesce** — `server quiesce` refuses new prompts/forks/session resumes
|
|
358
|
+
until you `server unquiesce`; in-flight runs finish cleanly (useful before
|
|
359
|
+
upgrades/backups).
|
|
360
|
+
- **Credentials stay server-side** — provider `headers` (which may carry
|
|
361
|
+
`Authorization` / API keys) are never sent to the browser; the model
|
|
362
|
+
management UI edits everything else and the server preserves the headers.
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
## Reverse proxy (nginx)
|
|
366
|
+
|
|
367
|
+
Serve pi-web-ui behind nginx on the same host (it binds loopback only, so a
|
|
368
|
+
same-machine reverse proxy is the supported remote-access path — no
|
|
369
|
+
`PI_WEB_HOST=0.0.0.0` needed):
|
|
370
|
+
|
|
371
|
+
```nginx
|
|
372
|
+
# pi-web-ui on 127.0.0.1:8787, exposed as https://your-host/pi/
|
|
373
|
+
server {
|
|
374
|
+
listen 443 ssl;
|
|
375
|
+
server_name your-host;
|
|
376
|
+
# ssl_certificate ... / ssl_certificate_key ...
|
|
377
|
+
|
|
378
|
+
# App entry at a sub-path (strips the /pi/ prefix)
|
|
379
|
+
location /pi/ {
|
|
380
|
+
proxy_pass http://127.0.0.1:8787/;
|
|
381
|
+
proxy_http_version 1.1;
|
|
382
|
+
# $http_host keeps the port — the server's origin check compares the
|
|
383
|
+
# full authority (hostname AND port). $host would drop it and get 403.
|
|
384
|
+
proxy_set_header Host $http_host;
|
|
385
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
386
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
387
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
# WebSocket — MUST forward Host identically or the upgrade is 403'd
|
|
391
|
+
# (page loads, but chat/terminal keep reconnecting)
|
|
392
|
+
location /ws {
|
|
393
|
+
proxy_pass http://127.0.0.1:8787;
|
|
394
|
+
proxy_http_version 1.1;
|
|
395
|
+
proxy_set_header Host $http_host;
|
|
396
|
+
proxy_set_header Upgrade $http_upgrade;
|
|
397
|
+
proxy_set_header Connection "upgrade";
|
|
398
|
+
proxy_read_timeout 3600s;
|
|
399
|
+
proxy_send_timeout 3600s;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
# Absolute-path assets/API the built frontend requests (root, not /pi/)
|
|
403
|
+
location /assets/ { proxy_pass http://127.0.0.1:8787; }
|
|
404
|
+
location = /favicon.svg { proxy_pass http://127.0.0.1:8787; }
|
|
405
|
+
location = /favicon-streaming.svg { proxy_pass http://127.0.0.1:8787; }
|
|
406
|
+
location = /api/file { proxy_pass http://127.0.0.1:8787; }
|
|
407
|
+
location = /api/health { proxy_pass http://127.0.0.1:8787; }
|
|
408
|
+
}
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
Key points:
|
|
412
|
+
|
|
413
|
+
- **`Host` must be `$http_host`** (keeps the port) on both `/pi/` and `/ws` —
|
|
414
|
+
the origin check compares hostname **and** port. `proxy_set_header Host $host`
|
|
415
|
+
or leaving it unset (defaults to the upstream `127.0.0.1:8787`) both fail with 403.
|
|
416
|
+
- **Same-origin works automatically**: as long as the browser's `Origin` equals
|
|
417
|
+
the forwarded `Host` (it does through a plain proxy), no
|
|
418
|
+
`PI_WEB_ALLOW_ORIGINS` is needed. Only set it when the browser origin differs
|
|
419
|
+
from the Host the server sees (e.g. a TLS-terminating proxy that changes the
|
|
420
|
+
port).
|
|
421
|
+
- **No `proxy_protocol` unless you really need real client IPs**: it makes
|
|
422
|
+
nginx reject every connection that does not send a PROXY header, which
|
|
423
|
+
breaks direct LAN access and any non-frp clients. With frp, drop
|
|
424
|
+
`transport.proxyProtocolVersion` from the proxy config unless nginx listens
|
|
425
|
+
with `proxy_protocol` too.
|
|
426
|
+
- **LAN access without a proxy**: just set `PI_WEB_HOST=0.0.0.0` (and a
|
|
427
|
+
firewall rule) — or put the whole server block above on port 80/443.
|
|
428
|
+
|
|
429
|
+
Full working example (with an frp tunnel): `deploy/nginx-subpath.conf`.
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
## Contribute
|
|
433
|
+
|
|
434
|
+
pi-web-ui is a small open-source project — **your contributions are what make it grow**. Code, plugins, themes, docs, translations, ideas: everything is welcome, and every merged PR ships to all users with the next `npm publish`. ❤️
|
|
435
|
+
|
|
436
|
+
| Way to contribute | How to get started |
|
|
437
|
+
| --- | --- |
|
|
438
|
+
| 🧩 **Write a plugin** | Build your own UI tab + agent tools. Copy `dev/plugins/demo-mailbox` as the minimal template (it doubles as the test fixture), develop locally, then either open a PR to ship it in the [catalog](#plugin-catalog) or [publish it standalone](https://github.com/xing-shuyin/pi-web-ui/tree/main/dev/plugins). |
|
|
439
|
+
| 🎨 **Contribute a theme** | Copy `themes/light.css` as a self-contained template, tweak the `:root` palette + `--term-*` + `.hljs`, verify with `npm run dev`, then open a PR — full walkthrough in [Contributing a theme](#contributing-a-theme-to-the-repository-github). |
|
|
440
|
+
| 💻 **Fix a bug / add a feature** | Look for [open issues](https://github.com/xing-shuyin/pi-web-ui/issues) or propose something new. Fork → branch → PR. Keep the code conventions in `AGENTS.md` (tabs, i18n keys in both languages, protocol changes in `server/protocol.ts`). |
|
|
441
|
+
| 📖 **Docs & translations** | Improve the READMEs, write plugin docs, fix typos, or help translate the UI / docs into more languages. |
|
|
442
|
+
| 💡 **Ideas & feedback** | Open an [issue](https://github.com/xing-shuyin/pi-web-ui/issues) or start a [discussion](https://github.com/xing-shuyin/pi-web-ui/discussions) — feature requests, bug reports, UI polish ideas, deployment experience reports. |
|
|
443
|
+
|
|
444
|
+
**Before opening a PR**, a quick sanity pass keeps reviewers happy:
|
|
445
|
+
|
|
446
|
+
- `npm run check:protocol` + `npm test` — protocol sync and unit tests.
|
|
447
|
+
- `npm run typecheck` — no type errors.
|
|
448
|
+
- `npm run build` — both frontend and backend compile.
|
|
449
|
+
- For protocol changes: add branches in both `server/index.ts` and `web/src/use-chat.ts` (see the "Protocol single source" note in `AGENTS.md`).
|
|
450
|
+
|
|
451
|
+
> Enjoying pi-web-ui? Give the repo a ⭐ — it helps others find it. And if you
|
|
452
|
+
> built something cool on top (plugin, theme, deployment recipe), tell us — we
|
|
453
|
+
> love showcasing community work.
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
## License
|
|
457
|
+
|
|
458
|
+
[MIT](LICENSE)
|