@firstpick/pi-package-webui 0.1.0 → 0.1.2

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
@@ -1,95 +1,193 @@
1
1
  # @firstpick/pi-package-webui
2
2
 
3
- Pi Web UI companion package for [Pi coding agent](https://www.npmjs.com/package/@earendil-works/pi-coding-agent).
3
+ Local browser companion for [Pi coding agent](https://www.npmjs.com/package/@earendil-works/pi-coding-agent).
4
4
 
5
- Category: **Pi package / companion app**. It bundles both:
5
+ This package provides:
6
6
 
7
- - a CLI server, `pi-webui`, that starts `pi --mode rpc`, serves a small no-build web app, and proxies prompts/events over HTTP + Server-Sent Events
8
- - a Pi extension command, `/start-webui`, that launches the local server from terminal Pi and opens the browser
7
+ - `pi-webui`: a local HTTP/SSE server that starts `pi --mode rpc`, serves the static browser UI, and proxies browser actions to Pi RPC commands.
8
+ - `/webui-start`: a Pi slash command that launches `pi-webui` for the current Pi working directory and opens the browser.
9
+ - `/webui-status`: a Pi slash command that reports the Web UI URL, online state, network exposure, and optional detailed runtime info.
10
+ - A no-build web app in `public/` with no runtime frontend dependencies.
9
11
 
10
- ## Features
12
+ > **Security:** Pi Web UI has no authentication. It can control the spawned Pi session, including any tools Pi is allowed to run. It binds to `127.0.0.1` by default; do not expose it on untrusted networks.
11
13
 
12
- - Chat with Pi from a browser
13
- - Live assistant text streaming
14
- - Tool start/finish event log
15
- - Prompt, steer, follow-up, abort, new session
16
- - Model and thinking-level controls
17
- - Guided git workflow: `git add .`, `/git-staged-msg`, preview generated messages, short/long commit, and `git push`
18
- - Pi slash command `/start-webui` to launch the local server from terminal Pi and open the browser
19
- - ChatGPT-style collapsible session/queue/commands/events side panel with in-panel control
20
- - Pi-style footer between transcript and input with token, cost, context, model, cwd, and git summary
21
- - Slash-command autocomplete while typing `/...` in the prompt box
22
- - Enter sends, Shift+Enter inserts a new line
23
- - Cyberpunk Catppuccin-inspired visual theme
24
- - Basic rendering for user/assistant/tool/bash messages
25
- - Basic RPC extension UI support: `select`, `confirm`, `input`, `editor`, notifications, status, widgets
26
- - No frontend build step and no runtime web dependencies
27
-
28
- ## Usage
14
+ ## Requirements
15
+
16
+ - Node.js `>=22.19.0`
17
+ - Pi available through this package dependency or as `pi` on `PATH`
18
+ - A modern browser with Server-Sent Events support
19
+
20
+ ## Quick start
21
+
22
+ Install the package from npm into Pi, then restart Pi so `/webui-start` and `/webui-status` are loaded:
23
+
24
+ ```bash
25
+ pi install npm:@firstpick/pi-package-webui
26
+ ```
27
+
28
+ From inside terminal Pi:
29
+
30
+ ```text
31
+ /webui-start
32
+ ```
33
+
34
+ Open the printed URL, usually <http://127.0.0.1:31415/>. The command opens it automatically unless `--no-open` is passed. Check a running instance with `/webui-status` or `/webui-status detailed`.
35
+
36
+ For direct development from this package directory:
29
37
 
30
38
  ```bash
31
- # from this package directory during development
32
39
  node bin/pi-webui.mjs --cwd /path/to/project
40
+ ```
41
+
42
+ After a global npm install:
33
43
 
34
- # after global install
44
+ ```bash
45
+ npm install -g @firstpick/pi-package-webui
35
46
  pi-webui --cwd /path/to/project
47
+ ```
36
48
 
37
- # pass Pi CLI args after --
38
- pi-webui --port 3000 -- --model anthropic/claude-sonnet-4-5:high
49
+ ## Features
50
+
51
+ - Browser chat with Pi over RPC
52
+ - Isolated terminal tabs: each Web UI tab starts its own separate `pi --mode rpc` subprocess, event stream, session state, and prompt draft
53
+ - Live assistant text streaming, including streamed thinking blocks when exposed by the provider
54
+ - Prompt, steer, follow-up, abort, new session, and manual compact controls
55
+ - Busy-session behavior selector for follow-up vs steer
56
+ - Model and thinking-level controls
57
+ - Slash-command autocomplete while typing `/...`
58
+ - Tool, process, compaction, queue, and extension event log
59
+ - Collapsible side panel with session state, queue, available commands, events, and local-network exposure status/control
60
+ - Pi-style footer with token, cache, estimated Pi-context tokens, speed, cost, context usage, clickable per-tab cwd picker with server-persisted fast picks, git branch, changes, runtime, model, and thinking level
61
+ - Guided Git workflow: `git add .`, ask Pi to run `/git-staged-msg`, preview short/long messages, commit with the selected message, and `git push`
62
+ - Basic rendering for user, assistant, tool result, bash execution, and thinking messages
63
+ - Basic extension UI bridge for `notify`, `setStatus`, `setWidget`, `setTitle`, `set_editor_text`, `select`, `confirm`, `input`, and `editor`
64
+ - Cyberpunk/Catppuccin-inspired theme
65
+ - PWA metadata, icons, and service worker for install-to-home-screen support when served from a secure context
66
+ - Static frontend: no bundler, no frontend install step
67
+
68
+ ## Mobile/PWA notes
69
+
70
+ - The mobile composer starts as a one-line `Ask Pi…` input, grows with user-entered lines, and scrolls the transcript to the latest output when focused.
71
+ - When Pi is idle, `Steer` and `Follow-up` live inside `Actions`; while a run is active, they move back into the main composer row for quick steering/follow-up.
72
+ - PWA install support requires browser service-worker support and usually HTTPS or `localhost`. Plain `http://<LAN-IP>` may show the app but may not offer install on Chrome/Safari.
73
+
74
+ ## Pi slash commands
75
+
76
+ ```text
77
+ /webui-start [port] [options] [-- <pi args...>]
39
78
  ```
40
79
 
41
- Open the printed URL, usually <http://127.0.0.1:31415/>.
80
+ Options:
42
81
 
43
- ## Pi slash command
82
+ ```text
83
+ [port] Positional port shortcut
84
+ --host <host> HTTP bind host (default: 127.0.0.1)
85
+ --port <port> HTTP port (default: 31415)
86
+ --no-open Do not open the browser automatically
87
+ --no-session Start Pi RPC with --no-session
88
+ --name <name> Initial Pi session name
89
+ -- <pi args...> Extra arguments forwarded to Pi RPC
90
+ ```
44
91
 
45
- Install this package as a Pi package, then reload Pi:
92
+ Examples:
46
93
 
47
- ```bash
48
- pi install ./pi-package-webui
94
+ ```text
95
+ /webui-start
96
+ /webui-start 31500
97
+ /webui-start --port 31500 --no-open
98
+ /webui-start --name browser -- --model anthropic/claude-sonnet-4-5:high
49
99
  ```
50
100
 
51
- From terminal Pi, run:
101
+ If a compatible Web UI is already running on the target URL, `/webui-start` stops that instance first, then starts a fresh server for the current cwd and opens it.
102
+
103
+ Status commands:
52
104
 
53
105
  ```text
54
- /start-webui
55
- /start-webui --port 31500
56
- /start-webui --no-open
106
+ /webui-status
107
+ /webui-status detailed
108
+ /webui-status detailed --port 31500
57
109
  ```
58
110
 
59
- The command starts `pi-webui` for the current Pi cwd, shows the localhost URL, and opens it in the default browser unless `--no-open` is passed.
111
+ `/webui-status` reports the page URL, whether the server is online, and whether it is open to the local network. `detailed` adds Web UI/Pi PIDs, bind info, tabs, current session/model/thinking state, available providers, per-tab workspace/stats summaries, and recent backend events.
60
112
 
61
113
  ## CLI
62
114
 
63
115
  ```text
64
116
  pi-webui [options] [-- <pi args...>]
117
+ ```
65
118
 
66
119
  Options:
120
+
121
+ ```text
67
122
  --host <host> HTTP bind host (default: 127.0.0.1)
68
123
  --port <port> HTTP port (default: 31415)
69
- --cwd <path> Working directory for the Pi session (default: current dir)
124
+ --cwd <path> Default working directory for Pi tabs (default: current dir)
70
125
  --pi <command> Pi executable to spawn (default: bundled dependency, then "pi")
71
126
  --no-session Start Pi RPC with --no-session
72
127
  --name <name> Initial Pi session name
128
+ -h, --help Show help
129
+ -v, --version Print version
73
130
  ```
74
131
 
75
- Environment:
132
+ Examples:
133
+
134
+ ```bash
135
+ pi-webui --cwd ~/src/my-project
136
+ pi-webui --port 3000 -- --model anthropic/claude-sonnet-4-5:high
137
+ PI_WEBUI_PI_BIN=/path/to/pi pi-webui --no-session
138
+ ```
139
+
140
+ Environment variables:
76
141
 
77
142
  - `PI_WEBUI_HOST`
78
143
  - `PI_WEBUI_PORT`
79
- - `PI_WEBUI_PI_BIN` (overrides bundled Pi resolution)
144
+ - `PI_WEBUI_PI_BIN` (same purpose as `--pi`)
80
145
 
81
- ## Security
146
+ ## Guided Git workflow
82
147
 
83
- This UI has **no authentication**. It can control Pi, including tools such as shell commands and file edits if enabled in the spawned Pi session.
148
+ The browser button runs a native local workflow in the Web UI server process:
84
149
 
85
- Default binding is `127.0.0.1`. Do not use `--host 0.0.0.0` unless you are on a trusted network and understand the risk.
150
+ 1. `git add .` in the active Pi working directory.
151
+ 2. Send `/git-staged-msg` to Pi.
152
+ 3. Read `dev/COMMIT/staged-commit-short.txt` and `dev/COMMIT/staged-commit-long.txt` from the git root.
153
+ 4. Commit with either the short message (`git commit -m ...`) or the long message (`git commit -F ...`).
154
+ 5. Run `git push`.
155
+
156
+ This workflow assumes `/git-staged-msg` is available in the Pi session and writes the two `dev/COMMIT/` files above. It can be cancelled between steps; active native git commands are terminated on cancel where possible.
86
157
 
87
158
  ## How it works
88
159
 
89
- The server spawns Pi in RPC mode:
160
+ `pi-webui` starts a Pi RPC subprocess for the initial browser terminal tab, and each additional Web UI tab starts another isolated subprocess:
90
161
 
91
162
  ```bash
92
163
  pi --mode rpc
93
164
  ```
94
165
 
95
- Browser actions call local HTTP endpoints. Agent events from Pi stdout are broadcast to the browser through Server-Sent Events. The JSONL reader follows Pi RPC framing rules and splits records only on `\n`.
166
+ With options, each spawned command becomes:
167
+
168
+ ```bash
169
+ pi --mode rpc [--no-session] [--name <name>] [...extra Pi args]
170
+ ```
171
+
172
+ The local server exposes:
173
+
174
+ - static files from `public/`
175
+ - `GET /api/tabs`, `POST /api/tabs`, `PATCH /api/tabs/:id`, and `DELETE /api/tabs/:id` for isolated Web UI terminal tabs and per-tab cwd changes
176
+ - `GET /api/directories?tab=<tabId>&path=<path>` for the browser cwd picker
177
+ - `GET /api/path-fast-picks` and `POST /api/path-fast-picks` for cwd picker fast picks persisted across browser tabs, Pi terminal tabs, and Web UI server restarts
178
+ - `GET /api/network` and localhost-only `POST /api/network/open` for local-network exposure status/control
179
+ - `GET /api/webui-status?detailed=1` for slash-command status reporting
180
+ - `POST /api/shutdown` for localhost-only graceful restarts from `/webui-start`
181
+ - HTTP endpoints for prompt/session/model/thinking/compact/git actions; tab-scoped calls use `?tab=<tabId>`
182
+ - `/api/events?tab=<tabId>` as a per-tab Server-Sent Events stream for Pi RPC events
183
+ - `/api/extension-ui-response?tab=<tabId>` for browser responses to extension UI prompts
184
+
185
+ Pi stdout is read as JSONL and split only on `\n`, matching Pi RPC framing.
186
+
187
+ ## Network and safety notes
188
+
189
+ - Default bind is localhost-only: `127.0.0.1:31415`.
190
+ - The side-panel "Open to network" button rebinds the current server to `0.0.0.0` and shows LAN URLs when available.
191
+ - `--host 0.0.0.0` also makes the UI reachable from the network and is unsafe unless the network is trusted.
192
+ - The UI is intended as a local companion, not a hardened multi-user web service.
193
+ - Browser actions can trigger Pi tools, shell commands, file edits, and git operations according to the spawned Pi session's permissions.