pi-web-ui 0.58.0 → 0.59.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/README.md CHANGED
@@ -96,6 +96,17 @@ theme switching, and a full settings panel — tuned for daily development.
96
96
  - Goal wizard (**AI Refine**) — turns a raw request into a concrete goal through a guided questionnaire.
97
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
98
 
99
+ ### 🤖 DeepSeek Harness engine
100
+
101
+ - **Switchable engine** — `PI_WEB_ENGINE=pi|dsh` (default `pi`). The pi engine runs the agent in-process via the pi SDK; the **DSH engine** runs the official [`@deepseek-ai/dsh`](https://github.com/deepseek-ai/dsh) (DeepSeek Harness) runtime as a subprocess. `/api/health` reports `engine`; the footer shows a DSH badge.
102
+ - **Same wire protocol** — the DSH engine implements the same WebSocket protocol, so goal mode, SCM, background tasks, settings, plugins, terminals, message-delta & snapshots all work identically.
103
+ - **Native goal machinery** — DSH's own goal state machine + round-driver auto-continues rounds; the model judges completion/blocked (no separate review session). The goal wizard drives it via the model's `ask_user_question`.
104
+ - **Real image blocks** — photos are sent as true image content to vision-capable DeepSeek models (e.g. `deepseek-v4-flash-vision-exp`); text-only models get a text-transcription bridge instead.
105
+ - **Question dialog** — the model's `ask_user_question` surfaces as a browser dialog (single/multi-select + free text) with queueing and a countdown.
106
+ - **Tools & MCP bridge** — plugin AI tools and external MCP servers (`mcp.json`) are bridged into the DSH runtime, so the DSH model can call them (executed server-side).
107
+ - **Skill enable/disable** — the DSH skill catalog is exposed in Settings; disabling a skill filters it out of the model's view at runtime.
108
+ - **DSH user patches** — drop `.yml` Cordis patches into `<dataDir>/dsh-patches/` to extend the runtime and reload from Settings.
109
+
99
110
  ### ⚙️ Background tasks
100
111
 
101
112
  - Background-task panel — servers launched by the agent are detected via port snapshots and listed (port/pid/name); stop one or kill all.
@@ -219,20 +230,20 @@ up in the UI.
219
230
 
220
231
  ### Plugin catalog
221
232
 
222
- These plugins ship in this repository (`dev/plugins/<id>/`) and can be installed
233
+ These plugins ship in this repository (`plugins/<id>/`) and can be installed
223
234
  straight from GitHub:
224
235
 
225
236
  | Plugin | What it does |
226
237
  | --- | --- |
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. |
238
+ | 📬 [webmail](https://github.com/xing-shuyin/pi-web-ui/tree/main/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. |
239
+ | 🗄️ [db-client](https://github.com/xing-shuyin/pi-web-ui/tree/main/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. |
240
+ | 📝 [vscode-editor](https://github.com/xing-shuyin/pi-web-ui/tree/main/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`. |
241
+ | 📬 [demo-mailbox](https://github.com/xing-shuyin/pi-web-ui/tree/main/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
242
 
232
243
  Example — install the webmail plugin:
233
244
 
234
245
  ```bash
235
- pi-web-ui install https://github.com/xing-shuyin/pi-web-ui/tree/main/dev/plugins/webmail
246
+ pi-web-ui install https://github.com/xing-shuyin/pi-web-ui/tree/main/plugins/webmail
236
247
  ```
237
248
 
238
249
  Each plugin's directory in the repo has its own `README.md` with full feature
@@ -271,7 +282,7 @@ Re-run `install` against the same source with `--force`:
271
282
 
272
283
  ```bash
273
284
  # 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
285
+ pi-web-ui install https://github.com/xing-shuyin/pi-web-ui/tree/main/plugins/webmail --force
275
286
  ```
276
287
 
277
288
  - The upgrade preserves the plugin's local `config.json` automatically.
@@ -435,7 +446,7 @@ pi-web-ui is a small open-source project — **your contributions are what make
435
446
 
436
447
  | Way to contribute | How to get started |
437
448
  | --- | --- |
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). |
449
+ | 🧩 **Write a plugin** | Build your own UI tab + agent tools. Copy `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/plugins). |
439
450
  | 🎨 **Contribute a theme** | Copy `themes/white.css` (light) or `themes/cyberpunk.css` (dark) as a pure-palette 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
451
  | 💻 **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
452
  | 📖 **Docs & translations** | Improve the READMEs, write plugin docs, fix typos, or help translate the UI / docs into more languages. |
package/README.zh-CN.md CHANGED
@@ -62,6 +62,17 @@
62
62
  - 目标调研向导(「AI 提炼」)—— 通过引导式问卷把原始需求收敛成明确目标。
63
63
  - 自动审查循环 —— 每轮结束后用独立审查会话核对「目标 + 最终文本 + git diff HEAD」;不达标就把审查意见作为 steer 注入重改,直到通过或达到轮数上限。
64
64
 
65
+ **DeepSeek Harness(DSH)引擎**
66
+
67
+ - **引擎可切换** —— `PI_WEB_ENGINE=pi|dsh`(默认 `pi`)。pi 引擎在进程内跑 pi SDK;**DSH 引擎**把官方 [`@deepseek-ai/dsh`](https://github.com/deepseek-ai/dsh)(DeepSeek Harness)运行时作为子进程拉起。`/api/health` 返回 `engine`;底栏显示 DSH 徽标。
68
+ - **同一套 wire 协议** —— DSH 引擎实现与 pi 相同的 WebSocket 协议,目标/审查、SCM、后台任务、设置、插件、终端、message_delta 与快照全部一致。
69
+ - **原生目标机制** —— DSH 自己的目标状态机 + round-driver 自动续轮;完成/受阻由模型自判定(无独立审查会话)。目标向导经模型 `ask_user_question` 驱动。
70
+ - **真图片块** —— 图片作为真正的 image 内容发给支持视觉的 DeepSeek 模型(如 `deepseek-v4-flash-vision-exp`);纯文本模型走文字转写桥。
71
+ - **提问对话框** —— 模型 `ask_user_question` 弹出浏览器对话框(单选/多选 + 自由文本),支持排队与倒计时。
72
+ - **工具 & MCP 桥** —— 插件 AI 工具与外部 MCP 服务器(`mcp.json`)都桥进 DSH 运行时,DSH 模型可直接调用(服务端执行)。
73
+ - **技能启停** —— 设置面板暴露 DSH 技能目录;禁用即运行时过滤该技能,模型不可见。
74
+ - **DSH 用户补丁** —— 在 `<dataDir>/dsh-patches/` 放 `.yml` Cordis 补丁扩展运行时,设置面板一键重扫生效。
75
+
65
76
  **后台任务**
66
77
 
67
78
  - 后台任务面板 —— 通过端口快照检测 agent 启动的服务(端口/pid/名称),可单独停止或全部关闭。
@@ -168,19 +179,19 @@ pi-web-ui server unquiesce # 解除排空,恢复接收新工
168
179
 
169
180
  ### 插件目录
170
181
 
171
- 以下插件随本仓库发布(`dev/plugins/<id>/`),可直接从 GitHub 安装:
182
+ 以下插件随本仓库发布(`plugins/<id>/`),可直接从 GitHub 安装:
172
183
 
173
184
  | 插件 | 功能 |
174
185
  | --- | --- |
175
- | 📬 [网页邮箱 webmail](https://github.com/xing-shuyin/pi-web-ui/tree/main/dev/plugins/webmail) | IMAP 收件箱浏览/搜索/阅读/标记/删除 + SMTP 发信、新邮件通知,可选「允许 AI 管理邮箱」(六个 `mail_*` AI 工具)。首次激活自动补装 npm 依赖。 |
176
- | 🗄️ [数据库 db-client](https://github.com/xing-shuyin/pi-web-ui/tree/main/dev/plugins/db-client) | 数据库工作台:MySQL / PostgreSQL / SQLite / SQL Server / MongoDB / Redis 连接管理 + 库表树 —— 表结构、分页排序、SQL 编辑器、行编辑。驱动首次使用自动安装。 |
177
- | 📝 [编辑器 + SSH vscode-editor](https://github.com/xing-shuyin/pi-web-ui/tree/main/dev/plugins/vscode-editor) | 类 VSCode 工作台:多根文件树(本地 + SSH 主机)、CodeMirror 多标签编辑器、Remote-SSH 远程文件浏览/编辑、可拖拽多终端面板(xterm.js)、SFTP 同步与下载到电脑。自动安装 `ssh2`。 |
178
- | 📬 [示例邮箱 demo-mailbox](https://github.com/xing-shuyin/pi-web-ui/tree/main/dev/plugins/demo-mailbox) | 最小示例插件:演示服务端入口 + 客户端视图 + 双向消息协议,兼作测试夹具——想自己写插件从这里入手。 |
186
+ | 📬 [网页邮箱 webmail](https://github.com/xing-shuyin/pi-web-ui/tree/main/plugins/webmail) | IMAP 收件箱浏览/搜索/阅读/标记/删除 + SMTP 发信、新邮件通知,可选「允许 AI 管理邮箱」(六个 `mail_*` AI 工具)。首次激活自动补装 npm 依赖。 |
187
+ | 🗄️ [数据库 db-client](https://github.com/xing-shuyin/pi-web-ui/tree/main/plugins/db-client) | 数据库工作台:MySQL / PostgreSQL / SQLite / SQL Server / MongoDB / Redis 连接管理 + 库表树 —— 表结构、分页排序、SQL 编辑器、行编辑。驱动首次使用自动安装。 |
188
+ | 📝 [编辑器 + SSH vscode-editor](https://github.com/xing-shuyin/pi-web-ui/tree/main/plugins/vscode-editor) | 类 VSCode 工作台:多根文件树(本地 + SSH 主机)、CodeMirror 多标签编辑器、Remote-SSH 远程文件浏览/编辑、可拖拽多终端面板(xterm.js)、SFTP 同步与下载到电脑。自动安装 `ssh2`。 |
189
+ | 📬 [示例邮箱 demo-mailbox](https://github.com/xing-shuyin/pi-web-ui/tree/main/plugins/demo-mailbox) | 最小示例插件:演示服务端入口 + 客户端视图 + 双向消息协议,兼作测试夹具——想自己写插件从这里入手。 |
179
190
 
180
191
  安装示例(网页邮箱):
181
192
 
182
193
  ```bash
183
- pi-web-ui install https://github.com/xing-shuyin/pi-web-ui/tree/main/dev/plugins/webmail
194
+ pi-web-ui install https://github.com/xing-shuyin/pi-web-ui/tree/main/plugins/webmail
184
195
  ```
185
196
 
186
197
  每个插件在仓库里的目录都带独立 `README.md`,含完整功能清单、配置说明与注意事项。
@@ -214,7 +225,7 @@ CLI 会浅克隆仓库(无 git 时回退 tarball 下载),定位其中的 `
214
225
 
215
226
  ```bash
216
227
  # 例:把网页邮箱插件更新到仓库里的最新版
217
- pi-web-ui install https://github.com/xing-shuyin/pi-web-ui/tree/main/dev/plugins/webmail --force
228
+ pi-web-ui install https://github.com/xing-shuyin/pi-web-ui/tree/main/plugins/webmail --force
218
229
  ```
219
230
 
220
231
  - 升级时会自动保留插件目录里的 `config.json`(账号凭据等)。
@@ -360,7 +371,7 @@ pi-web-ui 是一个小型开源项目 —— **你的贡献就是它成长的力
360
371
 
361
372
  | 贡献方式 | 如何开始 |
362
373
  | --- | --- |
363
- | 🧩 **写插件** | 打造你自己的界面 tab + AI 工具。以 `dev/plugins/demo-mailbox` 为最小模板(它兼作测试夹具),本地开发后既可开 PR 收录进[插件目录](#插件目录),也可独立发布。 |
374
+ | 🧩 **写插件** | 打造你自己的界面 tab + AI 工具。以 `plugins/demo-mailbox` 为最小模板(它兼作测试夹具),本地开发后既可开 PR 收录进[插件目录](#插件目录),也可独立发布。 |
364
375
  | 🎨 **贡献主题** | 以 `themes/white.css`(浅色)或 `themes/cyberpunk.css`(深色)为纯调色板模板,调整 `:root` 配色 + `--term-*` + `.hljs`,用 `npm run dev` 验证后开 PR —— 完整步骤见[向仓库贡献主题](#向仓库贡献主题github)。 |
365
376
  | 💻 **修 bug / 加功能** | 在 [Issues](https://github.com/xing-shuyin/pi-web-ui/issues) 里挑一个,或提出新想法。Fork → 分支 → PR。代码约定见 `AGENTS.md`(Tab 缩进、i18n 双语 key、协议改动只动 `server/protocol.ts`)。 |
366
377
  | 📖 **文档与翻译** | 完善 README、补插件文档、改错别字,或帮忙把界面/文档翻译成更多语言。 |
@@ -91,6 +91,11 @@ const WINDOWS_PERSONA = `You are a coding agent running on Windows. The bash too
91
91
  - In the interactive terminal (TTY) — which is Git Bash too, not PowerShell — NEVER use heredocs (<<'EOF' ... EOF) or here-strings, and NEVER start interactive programs (vi, less, python -, node -, npm init): they wait for keyboard input that never arrives and hang the terminal forever. Prefer writing a temp script file (e.g. .pi-tmp.sh) and running it non-interactively. ALWAYS pass a timeout to long-running commands (e.g. \`timeout 120 npm run dev\`).
92
92
 
93
93
  Many legacy Chinese text files (.html/.txt/.md/.log, exported documents) are GBK/GB2312 encoded: the read tool decodes UTF-8 only and will show mojibake (乱码) for them. If a file's content looks garbled, read it through the terminal instead: in Git Bash use \`cat file | iconv -f GBK -t UTF-8\` (or \`iconv -f GBK -t UTF-8 file\`); in cmd use \`chcp 65001 && type file\`; in PowerShell use \`Get-Content -Encoding Default file\`. Never paste mojibake into your reasoning or answer — describe the decoded content instead.`;
94
+ /** bash 工具输出限制/过滤管道引导:模型习惯套 `| tail/-n`、`| head`、`| grep`、`| less`
95
+ * 等限输出。这些管道在持久终端里会①缓冲(可见终端全程哑火、看不到实时进度)②把退出码
96
+ * 错报成管道末尾命令(tail 恒 0、grep 无命中恒 1,灾难性掩盖真实失败)③长驻/出错命令会挂到超时。
97
+ * 让模型改用 bash 的 `tail` 参数限输出;长驻/交互任务改走持久终端工具。 */
98
+ const PIPELESS_BASH_GUIDANCE = `Bash tool output-limiting/filtering: do NOT chain shell pipes to trim or filter output. Avoid \`| tail\`, \`| head\`, \`| grep\`, \`| less\`, \`| more\`, \`| cat\`, \`| sort\`, \`| awk\`, \`| sed\`. They buffer output (so the visible terminal shows nothing live), turn the real exit code into the last pipe command's (tail always 0, grep 1 when no match — hiding the actual failure), and can hang a long-running or failing command until timeout. Instead:\n- To limit returned output use the bash \`tail\` parameter (e.g. \`bash(command=..., tail=20)\`) — the underlying command still streams live to the visible terminal.\n- For a long-running server / watcher / interactive program, use the persistent terminal tools (terminal_create then terminal_read / terminal_input / terminal_key / terminal_wait) instead of piping through bash.\nThe bash tool auto-detects a trailing \`| tail\`/\`| grep\` etc. and runs the underlying command directly so it never hides a failure — but you should still prefer the \`tail\` parameter.`;
94
99
  /**
95
100
  * Killable bash tool: wraps the SDK bash tool with operations that register
96
101
  * their own AbortController into a client-level set. abortBash() aborts only
@@ -434,14 +439,14 @@ export class ClientSession {
434
439
  const mgr = new TerminalManager((msg) => this.emitTerminal(conversationId, msg), cwd);
435
440
  // 终端活力检测:AI 触碰过的终端静默 ≥ 阈值(PI_WEB_TERMINAL_IDLE_MS,
436
441
  // 默认 15s)且该对话正在运行时,注入一条 steer 消息唤醒 AI 去检查。
437
- mgr.onAgentIdle = (terminalId, idleMs, title) => this.notifyTerminalIdle(conversationId, terminalId, idleMs, title);
442
+ mgr.onAgentIdle = (terminalId, idleMs, title, lastLines) => this.notifyTerminalIdle(conversationId, terminalId, idleMs, title, lastLines);
438
443
  return mgr;
439
444
  }
440
445
  /** 终端活力提醒:仅在该对话正在流式运行时注入(sendUserMessage 在流式中
441
446
  * 即 steer 语义——当前回合结算后送达,agent 立即响应);空闲时不打扰。
442
447
  * 一次性语义由 TerminalManager 保证(触发后解除武装,agent 再次触碰才
443
448
  * 重新计时),不会反复刷屏。 */
444
- notifyTerminalIdle(conversationId, terminalId, idleMs, title) {
449
+ notifyTerminalIdle(conversationId, terminalId, idleMs, title, lastLines = "") {
445
450
  const conv = this.convs.get(conversationId);
446
451
  if (!conv || this.disposed)
447
452
  return;
@@ -449,8 +454,9 @@ export class ClientSession {
449
454
  return;
450
455
  const seconds = Math.max(1, Math.round(idleMs / 1000));
451
456
  void conv.runtime.session
452
- .sendUserMessage(`(系统自动提醒:你启动的终端「${title}」已连续 ${seconds} 秒没有任何新输出。` +
453
- `进程可能在等待输入、卡住或已挂起。请用 terminal_read 查看它的当前状态;` +
457
+ .sendUserMessage(`(系统自动提醒:你启动的终端「${title}」(id=${terminalId})已连续 ${seconds} 秒没有任何新输出。` +
458
+ `进程可能在等待输入、卡住或已挂起。\n最近输出:\n${lastLines || "(无输出)"}\n` +
459
+ `请用 terminal_read(terminalId="${terminalId}") 查看/搜索它的当前状态;` +
454
460
  `若在等交互就用 terminal_input / terminal_key 回应;确认不再需要就 terminal_close 关掉它。)`)
455
461
  .catch(() => {
456
462
  // best effort —— 注入失败不影响终端本身
@@ -742,6 +748,11 @@ export class ClientSession {
742
748
  // 而不是一次性 bash——没有这段模型几乎从不主动选终端工具。
743
749
  out.push(TERMINAL_TOOLS_GUIDANCE);
744
750
  }
751
+ // bash 工具输出限制/过滤管道引导:模型习惯套 `| tail/-n`、`| head`、
752
+ // `| grep` 等限输出。这些管道会缓冲(终端全程哑火)、把退出码错报成
753
+ // 管道末尾命令(tail 恒 0、grep 无命中 1)、长驻/出错命令挂到超时。
754
+ // 让模型改用 bash 的 tail 参数,长驻/交互改走持久终端。
755
+ out.push(PIPELESS_BASH_GUIDANCE);
745
756
  return out;
746
757
  },
747
758
  // 技能开关:禁用的技能从系统提示词和 /skill: 目录中剔除。