@rainmanhhh/pi-web 0.8.7
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 +22 -0
- package/README.md +147 -0
- package/README.zh-CN.md +145 -0
- package/dist/server.mjs +403 -0
- package/dist/static/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/static/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/static/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/static/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/static/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/static/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/static/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/static/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/static/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/static/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/static/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/static/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/static/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/static/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/static/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/static/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/static/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/static/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/static/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/static/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/static/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/static/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/static/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/static/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/static/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/static/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/static/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/static/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/static/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/static/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/static/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/static/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/static/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/static/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/static/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/static/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/static/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/static/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/static/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/static/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/static/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/static/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/static/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/static/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/static/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/static/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/static/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/static/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/static/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/static/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/static/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/static/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/static/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/static/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/static/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/static/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/static/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/static/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/static/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/static/assets/_baseFor-D6HAxaEF.js +1 -0
- package/dist/static/assets/arc-Cev3HYkO.js +1 -0
- package/dist/static/assets/architecture-YZFGNWBL-DSVeA3Mc.js +1 -0
- package/dist/static/assets/architectureDiagram-Q4EWVU46-BUaFXLue.js +36 -0
- package/dist/static/assets/array-BifhSqXX.js +1 -0
- package/dist/static/assets/blockDiagram-DXYQGD6D-BD7crHZn.js +132 -0
- package/dist/static/assets/c4Diagram-AHTNJAMY-BTvR1Qix.js +10 -0
- package/dist/static/assets/channel-DSbgxqFl.js +1 -0
- package/dist/static/assets/chunk-4BX2VUAB-C9I87hfN.js +1 -0
- package/dist/static/assets/chunk-4TB4RGXK-CYXNKQNe.js +206 -0
- package/dist/static/assets/chunk-55IACEB6-DAYR8bYh.js +1 -0
- package/dist/static/assets/chunk-5FUZZQ4R-BghvyuR7.js +62 -0
- package/dist/static/assets/chunk-5PVQY5BW-CZT35iHI.js +2 -0
- package/dist/static/assets/chunk-BSJP7CBP-BclwT518.js +1 -0
- package/dist/static/assets/chunk-EDXVE4YY-C4TkNvln.js +1 -0
- package/dist/static/assets/chunk-ENJZ2VHE-BNRddB0h.js +10 -0
- package/dist/static/assets/chunk-FMBD7UC4-4iiTC4rp.js +15 -0
- package/dist/static/assets/chunk-ICPOFSXX-BIhiNjvk.js +122 -0
- package/dist/static/assets/chunk-K5T4RW27-FpH_VPgE.js +94 -0
- package/dist/static/assets/chunk-OYMX7WX6-Dg0dFe8H.js +231 -0
- package/dist/static/assets/chunk-QZHKN3VN-DnoLcr4T.js +1 -0
- package/dist/static/assets/chunk-U2HBQHQK-CJqSKuXA.js +70 -0
- package/dist/static/assets/chunk-X2U36JSP-DVXuKdYc.js +1 -0
- package/dist/static/assets/chunk-YZCP3GAM-D4t97aMk.js +1 -0
- package/dist/static/assets/chunk-ZZ45TVLE-D3ALxVxH.js +1 -0
- package/dist/static/assets/classDiagram-6PBFFD2Q-3fKgRhOi.js +1 -0
- package/dist/static/assets/classDiagram-v2-HSJHXN6E-3fKgRhOi.js +1 -0
- package/dist/static/assets/clone-Dgktwry5.js +1 -0
- package/dist/static/assets/cose-bilkent-S5V4N54A-CVHW-V1c.js +1 -0
- package/dist/static/assets/cytoscape.esm-KkXhEuBu.js +321 -0
- package/dist/static/assets/dagre-DANBRJgS.js +1 -0
- package/dist/static/assets/dagre-KV5264BT-RX495Ogs.js +4 -0
- package/dist/static/assets/defaultLocale-BFoDCU3G.js +1 -0
- package/dist/static/assets/diagram-5BDNPKRD-B3TQrwLp.js +10 -0
- package/dist/static/assets/diagram-G4DWMVQ6-DMTfV1fq.js +24 -0
- package/dist/static/assets/diagram-MMDJMWI5-BA8Bf6LU.js +43 -0
- package/dist/static/assets/diagram-TYMM5635-DZgWIMF2.js +24 -0
- package/dist/static/assets/dist-C_yfW-4f.js +1 -0
- package/dist/static/assets/erDiagram-SMLLAGMA-BPjiJgpM.js +85 -0
- package/dist/static/assets/flatten-DYA82rhy.js +1 -0
- package/dist/static/assets/flowDiagram-DWJPFMVM-C8itnDyk.js +162 -0
- package/dist/static/assets/ganttDiagram-T4ZO3ILL-QijQZ_7A.js +292 -0
- package/dist/static/assets/gitGraph-7Q5UKJZL-DUTBJasc.js +1 -0
- package/dist/static/assets/gitGraphDiagram-UUTBAWPF-B4SbXUo2.js +106 -0
- package/dist/static/assets/graphlib-CAZZWEle.js +1 -0
- package/dist/static/assets/highlighted-body-OFNGDK62-B6SZt-Xj.js +1 -0
- package/dist/static/assets/index-BSAN2ZmA.css +1 -0
- package/dist/static/assets/index-CtaBtFPm.js +492 -0
- package/dist/static/assets/info-OMHHGYJF-y8VVrvpT.js +1 -0
- package/dist/static/assets/infoDiagram-42DDH7IO-SEL8m7Hn.js +2 -0
- package/dist/static/assets/init-C-OQMol4.js +1 -0
- package/dist/static/assets/ishikawaDiagram-UXIWVN3A-BiGygTnl.js +70 -0
- package/dist/static/assets/journeyDiagram-VCZTEJTY-x16DmnC7.js +139 -0
- package/dist/static/assets/kanban-definition-6JOO6SKY-B_Vmy_se.js +89 -0
- package/dist/static/assets/katex-9tSoZCUs.js +257 -0
- package/dist/static/assets/line-BXZmYadU.js +1 -0
- package/dist/static/assets/linear-BDsPwGxk.js +1 -0
- package/dist/static/assets/mermaid-GHXKKRXX-CZfowopI.js +1 -0
- package/dist/static/assets/mermaid-parser.core-BdiNtuYK.js +4 -0
- package/dist/static/assets/mermaid.core-Cy3kC-2x.js +42 -0
- package/dist/static/assets/mindmap-definition-QFDTVHPH-DibAS34Z.js +96 -0
- package/dist/static/assets/ordinal-DtR4qwUh.js +1 -0
- package/dist/static/assets/packet-4T2RLAQJ-QWjI5ifX.js +1 -0
- package/dist/static/assets/path-fybaL0A-.js +1 -0
- package/dist/static/assets/pie-ZZUOXDRM-CCpZfmHW.js +1 -0
- package/dist/static/assets/pieDiagram-DEJITSTG-DE3IRdo2.js +30 -0
- package/dist/static/assets/quadrantDiagram-34T5L4WZ-BnFzq8uS.js +7 -0
- package/dist/static/assets/radar-PYXPWWZC-DJRfpCAG.js +1 -0
- package/dist/static/assets/reduce-D9Ymtwj-.js +1 -0
- package/dist/static/assets/requirementDiagram-MS252O5E-4JH5mfMt.js +84 -0
- package/dist/static/assets/rolldown-runtime-C_s2cVnS.js +1 -0
- package/dist/static/assets/rough.esm-Dy-Kn_BL.js +1 -0
- package/dist/static/assets/sankeyDiagram-XADWPNL6-BBM3bCVp.js +10 -0
- package/dist/static/assets/sequenceDiagram-FGHM5R23-Ngkhph4n.js +157 -0
- package/dist/static/assets/src-D3QavEJ4.js +1 -0
- package/dist/static/assets/stateDiagram-FHFEXIEX-B8QHUbFP.js +1 -0
- package/dist/static/assets/stateDiagram-v2-QKLJ7IA2-8s677m33.js +1 -0
- package/dist/static/assets/timeline-definition-GMOUNBTQ-Cj_jCa6v.js +120 -0
- package/dist/static/assets/treeView-SZITEDCU-BYIf12Kb.js +1 -0
- package/dist/static/assets/treemap-W4RFUUIX-ChTAE-ps.js +1 -0
- package/dist/static/assets/vennDiagram-DHZGUBPP-Nv73eNL-.js +34 -0
- package/dist/static/assets/wardley-RL74JXVD-D4JZq5aY.js +1 -0
- package/dist/static/assets/wardleyDiagram-NUSXRM2D-D4_-w6kd.js +20 -0
- package/dist/static/assets/xychartDiagram-5P7HB3ND-BWrW2XAn.js +7 -0
- package/dist/static/icons/apple-touch-icon.png +0 -0
- package/dist/static/icons/icon-192.png +0 -0
- package/dist/static/icons/icon-512.png +0 -0
- package/dist/static/index.html +46 -0
- package/dist/static/manifest.webmanifest +28 -0
- package/dist/static/offline.html +83 -0
- package/dist/static/sw.js +75 -0
- package/package.json +107 -0
- package/public/icons/apple-touch-icon.png +0 -0
- package/public/icons/icon-192.png +0 -0
- package/public/icons/icon-512.png +0 -0
- package/public/manifest.webmanifest +28 -0
- package/public/offline.html +83 -0
- package/public/sw.js +75 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 agegr
|
|
4
|
+
Copyright (c) 2026 rainmanhhh
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# Pi Web
|
|
2
|
+
|
|
3
|
+
[中文文档](./README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
Local web UI for the [pi coding agent](https://github.com/earendil-works/pi) (core npm package [`@earendil-works/pi-ai`](https://www.npmjs.com/package/@earendil-works/pi-ai)). Pi Web reads your local pi session files and gives you a browser workspace for session browsing, real-time chat, model configuration, skill management, and project file preview.
|
|
6
|
+
|
|
7
|
+
This project is a fork of [@agegr/pi-web](https://github.com/agegr/pi-web).
|
|
8
|
+
|
|
9
|
+
The same pi session in CLI and Pi Web: structured tool calls, readable Markdown, session browsing, and cleaner results.
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
Pi Web requires Node.js 22.19.0 or newer. Check your version with `node --version`.
|
|
14
|
+
|
|
15
|
+
**Run without installing:**
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx @rainmanhhh/pi-web@latest
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Or install globally:**
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install -g @rainmanhhh/pi-web # 或 bun add -g @rainmanhhh/pi-web
|
|
25
|
+
pi-web
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The packaged server listens on `http://127.0.0.1:3142` by default and binds `127.0.0.1`. It serves the API and the built frontend from one process; add `--open` to open the browser automatically once it is ready.
|
|
29
|
+
|
|
30
|
+
**Options:**
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pi-web --port 8080 # custom port
|
|
34
|
+
pi-web --hostname 0.0.0.0 # expose on a trusted network
|
|
35
|
+
pi-web -p 8080 -H 0.0.0.0 # combine options
|
|
36
|
+
pi-web --open # open the browser when the server is ready
|
|
37
|
+
pi-web --agent-dir ~/.pi/agent # point at another pi agent directory
|
|
38
|
+
|
|
39
|
+
PORT=8080 pi-web # environment variable is also supported
|
|
40
|
+
HOST=0.0.0.0 pi-web # explicit network exposure
|
|
41
|
+
PI_WEB_ALLOWED_HOSTS=pi-web.internal pi-web # allow an exact proxy/custom hostname
|
|
42
|
+
PI_WEB_PASSWORD='a-long-random-password' pi-web # require Basic Auth (username: pi)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Set `PI_WEB_PASSWORD` to protect the web interface and every API endpoint with HTTP Basic Auth. The username is always `pi`. Leaving the variable unset or empty disables authentication.
|
|
46
|
+
|
|
47
|
+
Pi Web can invoke a high-privilege agent. Basic Auth does not encrypt the password in transit, so do not expose plain HTTP to the internet. Use HTTPS through a trusted reverse proxy or a trusted VPN for remote access.
|
|
48
|
+
API requests accept loopback names, IP literals, and exact comma-separated names in `PI_WEB_ALLOWED_HOSTS`. Configure that variable when a trusted reverse proxy uses a different external hostname. `PI_WEB_HOSTNAME` is a legacy alias for the same allow-list — it does **not** control the bind address (use `HOST` for that).
|
|
49
|
+
|
|
50
|
+
## HTTP Proxy
|
|
51
|
+
|
|
52
|
+
Pi Web reads the standard `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY` environment variables for server-side model and API requests.
|
|
53
|
+
|
|
54
|
+
On macOS or Linux:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
HTTP_PROXY=http://127.0.0.1:7890 \
|
|
58
|
+
HTTPS_PROXY=http://127.0.0.1:7890 \
|
|
59
|
+
NO_PROXY=localhost,127.0.0.1 \
|
|
60
|
+
npx @rainmanhhh/pi-web@latest
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
On Windows PowerShell:
|
|
64
|
+
|
|
65
|
+
```powershell
|
|
66
|
+
$env:HTTP_PROXY = "http://127.0.0.1:7890"
|
|
67
|
+
$env:HTTPS_PROXY = "http://127.0.0.1:7890"
|
|
68
|
+
$env:NO_PROXY = "localhost,127.0.0.1"
|
|
69
|
+
npx @rainmanhhh/pi-web@latest
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Features
|
|
73
|
+
|
|
74
|
+
- **Pick work back up**: browse previous pi conversations by project without digging through terminal history or session paths.
|
|
75
|
+
- **Try different directions safely**: continue from an earlier message or fork a session into a separate route.
|
|
76
|
+
- **Work across branches**: switch Git worktrees from the sidebar so new sessions and the Explorer follow the checkout you choose.
|
|
77
|
+
- **Chat beside the project**: browse files on the left and preview source, docs, images, audio, and PDFs on the right while the agent works.
|
|
78
|
+
- **See session state clearly**: context usage, cost, compaction state, and system prompt details are visible from the top bar.
|
|
79
|
+
- **Configure less from the terminal**: manage models, login/API keys, model tests, and skill switches from the web UI.
|
|
80
|
+
- **Use the interface in your language**: switch between the supported UI languages from the top bar.
|
|
81
|
+
|
|
82
|
+
## Notes
|
|
83
|
+
|
|
84
|
+
- **Data directory**: Pi Web reads `~/.pi/agent/sessions` by default. Set `PI_CODING_AGENT_DIR` to point at another pi agent directory.
|
|
85
|
+
- **Session files**: files are stored as `~/.pi/agent/sessions/<encoded-cwd>/<timestamp>_<uuid>.jsonl`.
|
|
86
|
+
- **Model config**: the Models panel reads and writes `models.json` in the pi agent directory. Model lists and defaults come from pi's config.
|
|
87
|
+
- **Preferences**: UI preferences (scroll step, auto-reload, long-block collapse, …) live in `pi-web-preferences.json` in the pi agent directory (default `~/.pi/agent/pi-web-preferences.json`). The browser's `localStorage` holds a front-end copy; the server file is the source of truth for other clients.
|
|
88
|
+
- **File access**: file browsing and preview are scoped to the selected project directory and working directories that appear in sessions.
|
|
89
|
+
- **Git worktrees**: see [Worktrees in Pi Web](./docs/worktrees.md) for when the switcher appears, how new worktrees are created, and what removal does.
|
|
90
|
+
- **Forks vs in-session branches**: Fork creates a new `.jsonl` file. "Edit from here" creates another branch inside the same session file.
|
|
91
|
+
- **Internationalization**: see [Internationalization](./docs/i18n.md) for using translations and adding languages or UI text.
|
|
92
|
+
|
|
93
|
+
## Development
|
|
94
|
+
|
|
95
|
+
Requires [Bun](https://bun.sh) and Node.js 22.19.0+.
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
bun install
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Run the API server and the Vite dev server in two terminals:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
bun run api # Hono API server on http://127.0.0.1:30002
|
|
105
|
+
bun run dev # Vite dev server on http://127.0.0.1:30001 (proxies /api → :30002)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Open [http://127.0.0.1:30001](http://127.0.0.1:30001). The dev proxy target defaults to `30002`; override it with `VITE_API_PORT` if your API server runs elsewhere.
|
|
109
|
+
|
|
110
|
+
Common checks:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
bun run check # tsc --noEmit
|
|
114
|
+
bun run lint
|
|
115
|
+
bun run test:unit
|
|
116
|
+
bun run test:e2e # Playwright; e2e uses isolated ports (E2E_API_PORT etc.)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Avoid running `bun run build` during local development. It writes to `dist/` and can interfere with the dev server; leave builds for release work.
|
|
120
|
+
|
|
121
|
+
Other scripts: `bun run check` (tsc --noEmit), `bun run format` (biome), `bun run build:server` (bundle the API for Node), `bun run api:node` (run the bundled server), `bun run e2e:stop` (kill leftover e2e processes). Publish with `pnpm publish` (use `pnpm publish --dry-run` to preview the pack) — `prepublishOnly` runs check + builds both the frontend and the server bundle first, and `publishConfig.access` makes the scoped package public.
|
|
122
|
+
|
|
123
|
+
Known issue: `bun publish` does not read the `//registry.npmjs.org/:_authToken` from `.npmrc`/`~/.npmrc` (loginless publish config) and fails with `error: missing authentication (run bunx npm login)` — use `pnpm publish` instead, which reads the token.
|
|
124
|
+
|
|
125
|
+
## Project Structure
|
|
126
|
+
|
|
127
|
+
```text
|
|
128
|
+
src/
|
|
129
|
+
components/ # React UI: AppShell, SessionSidebar, ChatWindow, ChatInput,
|
|
130
|
+
# MessageView, ModelsConfig, SkillsConfig, FileExplorer, FileViewer, …
|
|
131
|
+
hooks/ # useAgentSession (SSE state machine), useTheme, useDragDrop, …
|
|
132
|
+
lib/ # session .jsonl parsing, RPC manager, file-access safety,
|
|
133
|
+
# request security, i18n, markdown setup
|
|
134
|
+
main.tsx # frontend entry
|
|
135
|
+
server/
|
|
136
|
+
main.ts # API entry + pi-web CLI (Bun or Node, honors PORT/HOST,
|
|
137
|
+
# --port/--hostname/--open/--agent-dir)
|
|
138
|
+
index.ts # Hono app wiring
|
|
139
|
+
routes/ # API handlers: agent, auth, cwd, files, git, models,
|
|
140
|
+
# sessions, skills, worktrees, preferences, project-trust, …
|
|
141
|
+
static.ts # serves dist/static in production (single-process mode)
|
|
142
|
+
mount.ts # Next-style route-module adapter for Hono
|
|
143
|
+
scripts/ # e2e-stop, cdp-capture helpers
|
|
144
|
+
tests/e2e/ # Playwright specs and fixtures
|
|
145
|
+
vite.config.ts # dev server (:30001), /api proxy → :30002, build outDir
|
|
146
|
+
playwright.config.ts # e2e webServers (API + Vite) on isolated ports
|
|
147
|
+
```
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# Pi Web
|
|
2
|
+
|
|
3
|
+
[English](./README.md)
|
|
4
|
+
|
|
5
|
+
[pi 编程智能体](https://github.com/earendil-works/pi)(核心 npm 包 [`@earendil-works/pi-ai`](https://www.npmjs.com/package/@earendil-works/pi-ai))的本地网页界面。它会读取本机的 pi 会话文件,在浏览器里提供会话管理、实时对话、模型配置、技能管理和项目文件预览。
|
|
6
|
+
|
|
7
|
+
本项目是 [@agegr/pi-web](https://github.com/agegr/pi-web) 的 fork。
|
|
8
|
+
|
|
9
|
+
## 快速开始
|
|
10
|
+
|
|
11
|
+
Pi Web 要求 Node.js 22.19.0 或更高版本。可通过 `node --version` 检查当前版本。
|
|
12
|
+
|
|
13
|
+
**无需安装,直接运行:**
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx @rainmanhhh/pi-web@latest
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**或全局安装后使用:**
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install -g @rainmanhhh/pi-web
|
|
23
|
+
pi-web
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
发布版服务默认监听 `http://127.0.0.1:3142` 并绑定 `127.0.0.1`,单进程同时提供 API 和构建后的前端;加 `--open` 可在服务就绪后自动打开浏览器。
|
|
27
|
+
|
|
28
|
+
**可选参数:**
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pi-web --port 8080 # 自定义端口
|
|
32
|
+
pi-web --hostname 0.0.0.0 # 在可信网络中开放访问
|
|
33
|
+
pi-web -p 8080 -H 0.0.0.0 # 组合使用
|
|
34
|
+
pi-web --open # 服务就绪后自动打开浏览器
|
|
35
|
+
pi-web --agent-dir ~/.pi/agent # 指定其他 pi agent 目录
|
|
36
|
+
|
|
37
|
+
PORT=8080 pi-web # 也支持环境变量
|
|
38
|
+
HOST=0.0.0.0 pi-web # 显式开放网络访问
|
|
39
|
+
PI_WEB_ALLOWED_HOSTS=pi-web.internal pi-web # 允许指定的代理或自定义主机名
|
|
40
|
+
PI_WEB_PASSWORD='足够长的随机密码' pi-web # 启用 Basic Auth(用户名固定为 pi)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
设置 `PI_WEB_PASSWORD` 后,网页和所有 API 端点都会启用 HTTP Basic Auth,用户名固定为 `pi`。未设置或设置为空值时不启用认证。
|
|
44
|
+
|
|
45
|
+
Pi Web 可以调用高权限智能体。Basic Auth 不会加密传输中的密码,因此不要把明文 HTTP 暴露到互联网。远程访问时应使用可信反向代理提供 HTTPS,或通过可信 VPN 访问。
|
|
46
|
+
API 请求仅接受 loopback 名称、IP 字面量,以及 `PI_WEB_ALLOWED_HOSTS` 中以逗号分隔的精确主机名。可信反向代理使用不同的外部主机名时,请配置该变量。`PI_WEB_HOSTNAME` 是该白名单的旧别名,**不**控制监听地址(绑定地址请用 `HOST`)。
|
|
47
|
+
|
|
48
|
+
## HTTP 代理
|
|
49
|
+
|
|
50
|
+
Pi Web 的服务端模型请求和 API 请求会读取标准的 `HTTP_PROXY`、`HTTPS_PROXY` 和 `NO_PROXY` 环境变量。
|
|
51
|
+
|
|
52
|
+
macOS 或 Linux:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
HTTP_PROXY=http://127.0.0.1:7890 \
|
|
56
|
+
HTTPS_PROXY=http://127.0.0.1:7890 \
|
|
57
|
+
NO_PROXY=localhost,127.0.0.1 \
|
|
58
|
+
npx @rainmanhhh/pi-web@latest
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Windows PowerShell:
|
|
62
|
+
|
|
63
|
+
```powershell
|
|
64
|
+
$env:HTTP_PROXY = "http://127.0.0.1:7890"
|
|
65
|
+
$env:HTTPS_PROXY = "http://127.0.0.1:7890"
|
|
66
|
+
$env:NO_PROXY = "localhost,127.0.0.1"
|
|
67
|
+
npx @rainmanhhh/pi-web@latest
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## 功能介绍
|
|
71
|
+
|
|
72
|
+
- **把历史工作接回来**:打开网页就能按项目找到以前的 pi 对话,不必在终端里翻文件或记住会话路径。
|
|
73
|
+
- **放心试不同方向**:可以从某条历史消息重新开始,也可以复制出一条独立的新路线,探索方案时不怕弄乱原来的对话。
|
|
74
|
+
- **跨分支工作**:在侧边栏切换 Git worktree,让新会话和 Explorer 跟随你选择的 checkout。
|
|
75
|
+
- **边聊边看项目文件**:左侧浏览项目文件,右侧打开源码、文档、图片、音频和 PDF;文件变化会自动刷新,适合边让 agent 改边检查结果。
|
|
76
|
+
- **随时掌握会话状态**:在顶部就能看到上下文占用、花费、压缩结果和系统提示,长会话不再像黑箱。
|
|
77
|
+
- **少离开当前界面**:模型、登录/API key、模型测试和技能开关都能在网页里处理,配置 agent 时不用在多个工具之间来回切换。
|
|
78
|
+
- **界面语言可选**:在顶部栏切换界面支持的 UI 语言。
|
|
79
|
+
|
|
80
|
+
## 注意事项
|
|
81
|
+
|
|
82
|
+
- **数据目录**:默认读取 `~/.pi/agent/sessions` 下的会话文件。可通过环境变量 `PI_CODING_AGENT_DIR` 指定其他 pi agent 目录。
|
|
83
|
+
- **会话文件**:路径形如 `~/.pi/agent/sessions/<编码后的工作目录>/<时间戳>_<uuid>.jsonl`。
|
|
84
|
+
- **模型配置**:Models 面板读写 pi agent 目录下的 `models.json`,模型列表和默认模型由 pi 的配置解析得到。
|
|
85
|
+
- **偏好配置**:UI 偏好(滚动步长、自动刷新、长块折叠等)保存在 pi agent 目录下的 `pi-web-preferences.json`(默认 `~/.pi/agent/pi-web-preferences.json`)。浏览器 `localStorage` 是前端副本,服务端文件是其他客户端读取的权威来源。
|
|
86
|
+
- **文件访问**:文件浏览和预览面向当前选择的项目目录,以及会话中已出现过的工作目录。
|
|
87
|
+
- **Git worktree**:什么时候显示切换器、新建目录在哪里、删除会影响什么,见 [Pi Web 里的 Worktree](./docs/worktrees.zh-CN.md)。
|
|
88
|
+
- **Fork 与会话内分支不同**:Fork 会创建新的 `.jsonl` 文件;“Edit from here” 是同一会话文件里的分支。
|
|
89
|
+
- **国际化**:翻译使用与新增语言/UI 文案的方法见 [Internationalization](./docs/i18n.md)。
|
|
90
|
+
|
|
91
|
+
## 开发
|
|
92
|
+
|
|
93
|
+
需要 [Bun](https://bun.sh) 和 Node.js 22.19.0+。
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
bun install
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
两个终端分别跑 API 服务和 Vite dev server:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
bun run api # Hono API 服务,http://127.0.0.1:30002
|
|
103
|
+
bun run dev # Vite dev server,http://127.0.0.1:30001(/api 代理到 :30002)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
打开 [http://127.0.0.1:30001](http://127.0.0.1:30001)。dev 代理目标默认 `30002`,API 跑在其他端口时用 `VITE_API_PORT` 覆盖。
|
|
107
|
+
|
|
108
|
+
常用检查:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
node_modules/.bin/tsc --noEmit
|
|
112
|
+
bun run lint
|
|
113
|
+
bun run test:unit
|
|
114
|
+
bun run test:e2e # Playwright;e2e 使用隔离端口(E2E_API_PORT 等)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
开发时不要运行 `bun run build`,它会写入 `dist/`,容易影响正在运行的 dev server。发布流程再执行构建。
|
|
118
|
+
|
|
119
|
+
其他脚本:`bun run check`(tsc --noEmit)、`bun run format`(biome)、`bun run build:server`(打包 API 供 Node 运行)、`bun run api:node`(运行打包后的服务)、`bun run e2e:stop`(清理残留 e2e 进程)。发布用 `pnpm publish`(可用 `pnpm publish --dry-run` 预览打包内容)— `prepublishOnly` 会先执行 check 并构建前端和服务端 bundle,`publishConfig.access` 保证 scoped 包公开。
|
|
120
|
+
|
|
121
|
+
已知问题:`bun publish` 不读取 `.npmrc`/`~/.npmrc` 里的 `//registry.npmjs.org/:_authToken`(无登录发布配置),会报 `error: missing authentication (run bunx npm login)` — 请改用会读取该 token 的 `pnpm publish`。
|
|
122
|
+
|
|
123
|
+
## 项目结构
|
|
124
|
+
|
|
125
|
+
```text
|
|
126
|
+
src/
|
|
127
|
+
components/ # React UI:AppShell、SessionSidebar、ChatWindow、ChatInput、
|
|
128
|
+
# MessageView、ModelsConfig、SkillsConfig、FileExplorer、FileViewer 等
|
|
129
|
+
hooks/ # useAgentSession(SSE 状态机)、useTheme、useDragDrop 等
|
|
130
|
+
lib/ # 会话 .jsonl 解析、RPC manager、文件访问安全边界、
|
|
131
|
+
# 请求安全、i18n、markdown 配置
|
|
132
|
+
main.tsx # 前端入口
|
|
133
|
+
server/
|
|
134
|
+
main.ts # API 入口 + pi-web CLI(Bun 或 Node,支持 PORT/HOST、
|
|
135
|
+
# --port/--hostname/--open/--agent-dir)
|
|
136
|
+
index.ts # Hono app 装配
|
|
137
|
+
routes/ # API 处理器:agent、auth、cwd、files、git、models、
|
|
138
|
+
# sessions、skills、worktrees、preferences、project-trust 等
|
|
139
|
+
static.ts # 生产环境提供 dist/static(单进程模式)
|
|
140
|
+
mount.ts # Next 风格路由模块到 Hono 的适配
|
|
141
|
+
scripts/ # e2e-stop、cdp-capture 辅助脚本
|
|
142
|
+
tests/e2e/ # Playwright 测试与 fixtures
|
|
143
|
+
vite.config.ts # dev server(:30001)、/api 代理 → :30002、build outDir
|
|
144
|
+
playwright.config.ts # e2e webServer(API + Vite)隔离端口
|
|
145
|
+
```
|