pi-web-ui 0.64.2 → 0.64.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/bin/pi-web-ui.mjs +72 -5
- package/package.json +1 -1
package/bin/pi-web-ui.mjs
CHANGED
|
@@ -62,7 +62,21 @@ try {
|
|
|
62
62
|
// version is best-effort — the server itself doesn't need it
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
/** Detect if the user prefers Chinese locale: POSIX env vars win, then Intl API fallback. */
|
|
66
|
+
function isZhLang() {
|
|
67
|
+
const env = process.env.LC_ALL || process.env.LC_MESSAGES || process.env.LANG || "";
|
|
68
|
+
if (env.startsWith("zh")) return true;
|
|
69
|
+
if (!env) {
|
|
70
|
+
try {
|
|
71
|
+
return Intl.DateTimeFormat().resolvedOptions().locale.startsWith("zh");
|
|
72
|
+
} catch {
|
|
73
|
+
/* ignore */
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const HELP_ZH = `pi-web-ui v${pkg.version} — web chat for the pi coding agent
|
|
66
80
|
|
|
67
81
|
用法:
|
|
68
82
|
pi-web-ui 启动服务器(前台,Ctrl+C 停止,自动打开浏览器)
|
|
@@ -109,6 +123,55 @@ server 选项:
|
|
|
109
123
|
鉴权口令 PI_WEB_TOKEN:仅环境变量(不走命令行,避免被 ps 看到),需要时手动加入服务配置。
|
|
110
124
|
`;
|
|
111
125
|
|
|
126
|
+
const HELP_EN = `pi-web-ui v${pkg.version} — web chat for the pi coding agent
|
|
127
|
+
|
|
128
|
+
Usage:
|
|
129
|
+
pi-web-ui Start server (foreground, Ctrl+C to stop, auto-opens browser)
|
|
130
|
+
pi-web-ui --engine dsh --port 9000 --cwd /path Start with engine/port/cwd/data-dir overrides
|
|
131
|
+
pi-web-ui --no-browser Start without auto-opening browser
|
|
132
|
+
pi-web-ui server install [options] Install system service (autostart on boot) and launch it
|
|
133
|
+
pi-web-ui server shortcut [options] Create desktop "one-click start" icon
|
|
134
|
+
pi-web-ui server uninstall [options] Uninstall system service (also removes desktop icon)
|
|
135
|
+
pi-web-ui server start|stop|restart|status [options]
|
|
136
|
+
pi-web-ui server quiesce [options] Drain mode: reject new chats/messages/edits; let current runs finish
|
|
137
|
+
pi-web-ui server unquiesce [options] Exit drain mode, resume accepting new work
|
|
138
|
+
pi-web-ui --version / --help
|
|
139
|
+
|
|
140
|
+
Server options:
|
|
141
|
+
--port <n> Port (default 8787, or $PI_WEB_PORT)
|
|
142
|
+
--cwd <dir> Working directory (default $PI_WEB_CWD or home dir; foreground uses current dir)
|
|
143
|
+
--data-dir <dir> Session data directory (default <cwd>/.pi-web)
|
|
144
|
+
--engine <pi|dsh> Agent engine (default $PI_WEB_ENGINE or pi)
|
|
145
|
+
--host <addr> Listen address (default $PI_WEB_HOST or 127.0.0.1; 0.0.0.0 for LAN/containers)
|
|
146
|
+
--agent-dir <dir> pi config directory (default $PI_CODING_AGENT_DIR or ~/.pi/agent)
|
|
147
|
+
--name <name> Service name (default pi-web-ui; macOS launchd label is
|
|
148
|
+
com.xingshuyin.pi-web-ui, or com.<name>.server for custom names)
|
|
149
|
+
--print Only print generated config files (no actual install)
|
|
150
|
+
|
|
151
|
+
Platforms: macOS → launchd user agent · Linux → systemd · Windows → Logon Run key
|
|
152
|
+
(HKCU, no admin needed; wscript hidden launch, no black window)
|
|
153
|
+
Shortcuts: Windows → desktop .lnk · macOS → desktop .command · Linux → desktop .desktop
|
|
154
|
+
|
|
155
|
+
UI plugins (installed into <data-dir>/plugins/; refresh browser to activate while running):
|
|
156
|
+
pi-web-ui install <source> Install a UI plugin from GitHub
|
|
157
|
+
pi-web-ui uninstall <id> Uninstall a UI plugin
|
|
158
|
+
pi-web-ui plugins List installed UI plugins
|
|
159
|
+
|
|
160
|
+
Source formats: owner/repo · https://github.com/owner/repo · local directory path
|
|
161
|
+
URL with /tree/<branch>/<subdir> to specify branch and sub-directory;
|
|
162
|
+
append #<branch-or-tag> to any source to pin a branch (e.g. owner/repo#v1.2)
|
|
163
|
+
install options: --name <id> Custom plugin directory name (default: repo name)
|
|
164
|
+
--data-dir <dir> Data directory (default: ~/.pi-web)
|
|
165
|
+
--force Overwrite if target already exists
|
|
166
|
+
|
|
167
|
+
Environment variables (flag takes precedence, env var as fallback):
|
|
168
|
+
PI_WEB_PORT / PI_WEB_CWD / PI_WEB_DATA_DIR / PI_WEB_ENGINE / PI_WEB_HOST /
|
|
169
|
+
PI_CODING_AGENT_DIR
|
|
170
|
+
Auth token PI_WEB_TOKEN: env var only (not on command line, to avoid ps exposure)
|
|
171
|
+
`;
|
|
172
|
+
|
|
173
|
+
const HELP = isZhLang() ? HELP_ZH : HELP_EN;
|
|
174
|
+
|
|
112
175
|
/** Minimum Node required by the pi SDK (its dist uses `import … with { type: "json" }`). */
|
|
113
176
|
const NODE_MIN = [22, 19, 0];
|
|
114
177
|
function checkNodeVersion() {
|
|
@@ -118,11 +181,15 @@ function checkNodeVersion() {
|
|
|
118
181
|
(v[0] === NODE_MIN[0] && v[1] < NODE_MIN[1]) ||
|
|
119
182
|
(v[0] === NODE_MIN[0] && v[1] === NODE_MIN[1] && v[2] < NODE_MIN[2]);
|
|
120
183
|
if (tooOld) {
|
|
121
|
-
|
|
184
|
+
const zh =
|
|
122
185
|
`✖ pi-web-ui 需要 Node.js >= ${NODE_MIN.join(".")}(当前 ${process.versions.node})。\n` +
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
186
|
+
` pi SDK 的代码使用了 import attributes(with)语法,旧版 Node 无法解析。\n` +
|
|
187
|
+
` 请升级 Node:https://nodejs.org(或 nvm-windows / fnm)后重装:npm i -g pi-web-ui`;
|
|
188
|
+
const en =
|
|
189
|
+
`✖ pi-web-ui requires Node.js >= ${NODE_MIN.join(".")} (current: ${process.versions.node}).\n` +
|
|
190
|
+
` The pi SDK uses import attributes (\`with\` syntax) which older Node versions can't parse.\n` +
|
|
191
|
+
` Upgrade Node: https://nodejs.org then reinstall: npm i -g pi-web-ui`;
|
|
192
|
+
console.error(isZhLang() ? zh : en);
|
|
126
193
|
process.exit(1);
|
|
127
194
|
}
|
|
128
195
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-web-ui",
|
|
3
|
-
"version": "0.64.
|
|
3
|
+
"version": "0.64.3",
|
|
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
|
"author": {
|