pi-web-ui 0.109.0 → 0.110.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.
Files changed (59) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +21 -1
  3. package/README.zh-CN.md +21 -1
  4. package/README.zh-TW.md +201 -677
  5. package/dist/server/agent-service-daemon.js +2 -2
  6. package/dist/server/agent-service.js +20 -30
  7. package/dist/server/attachments.js +26 -6
  8. package/dist/server/dispatch-domain-handlers.js +2 -0
  9. package/dist/server/dispatch-plugin-handlers.js +1 -0
  10. package/dist/server/durable/durable-driver.js +1 -1
  11. package/dist/server/durable/durable-tools.js +4 -1
  12. package/dist/server/files-service.js +23 -4
  13. package/dist/server/goal-service.js +12 -3
  14. package/dist/server/index.js +39 -10
  15. package/dist/server/locales.js +33 -0
  16. package/dist/server/marker-service.js +7 -13
  17. package/dist/server/markers/builtins/action.js +5 -6
  18. package/dist/server/markers/builtins/notify.js +2 -2
  19. package/dist/server/markers/builtins/rename.js +2 -2
  20. package/dist/server/markers/registry.js +5 -1
  21. package/dist/server/message-window.js +190 -0
  22. package/dist/server/model-admin.js +0 -4
  23. package/dist/server/plugin-catalog-sync.js +10 -2
  24. package/dist/server/plugin-catalog.js +63 -10
  25. package/dist/server/plugins.js +47 -6
  26. package/dist/server/preset-share.js +2 -3
  27. package/dist/server/process-utils.js +58 -24
  28. package/dist/server/protocol-version.js +1 -1
  29. package/dist/server/settings-service.js +5 -0
  30. package/dist/server/slash-commands.js +16 -4
  31. package/dist/server/text-sniff.js +10 -7
  32. package/dist/server/themes.js +36 -1
  33. package/dist/server/universal/drivers/dsh-driver.js +1 -1
  34. package/dist/server/universal/universal-session.js +10 -3
  35. package/dist/server/worktree-service.js +1 -1
  36. package/package.json +7 -2
  37. package/plugin-sdk/index.d.ts +20 -0
  38. package/plugin-sdk/index.mjs +14 -0
  39. package/plugins/catalog.json +22 -2
  40. package/themes/aetheris.css +149 -118
  41. package/themes/bases/flow-base.css +1363 -0
  42. package/themes/bases/obsidian-base.css +679 -0
  43. package/themes/bases/zhujian-base.css +687 -0
  44. package/themes/bases/zhupi-base.css +659 -0
  45. package/themes/flow-light.css +2 -925
  46. package/themes/flow.css +1 -936
  47. package/themes/wallpaper-flow.css +71 -1031
  48. package/themes/wallpaper-obsidian.css +1 -673
  49. package/themes/zhujian-dark.css +1 -605
  50. package/themes/zhujian.css +1 -654
  51. package/themes/zhupi-dark.css +1 -576
  52. package/themes/zhupi.css +1 -626
  53. package/web/dist/assets/{TerminalPanel-BD3a9o-a.js → TerminalPanel-BHjM6pzY.js} +1 -1
  54. package/web/dist/assets/index-DwInT7-a.css +1 -0
  55. package/web/dist/assets/index-GfVFIgIL.js +693 -0
  56. package/web/dist/index.html +2 -2
  57. package/web/dist/sw.js +1 -1
  58. package/web/dist/assets/index-AccytlpP.css +0 -1
  59. package/web/dist/assets/index-B3dar1BK.js +0 -690
@@ -158,10 +158,9 @@ export function previewKind(name) {
158
158
  return "none";
159
159
  }
160
160
  /**
161
- * 扩展名是否为浏览器可直接播放的音频。与 previewKind 分开:PreviewKind 只有
162
- * image/video/text/none 四档(右栏图标、附件、预览弹窗都按它分支),把音频塞进去
163
- * 要动整条链路;而 /api/file 的媒体白名单与 present_files 的卡片只需要一个
164
- * 「能不能 inline 播」的布尔判断。
161
+ * 扩展名是否为浏览器可直接播放的音频。与 previewKind 分开:预览弹窗的媒体分支
162
+ * 只关心 image/video,音频得单独判一次;而 /api/file 的媒体白名单与
163
+ * present_files 的卡片只需要一个「能不能 inline 播」的布尔判断。
165
164
  */
166
165
  export function isAudioFile(name) {
167
166
  const dot = name.lastIndexOf(".");
@@ -183,7 +182,7 @@ export function looksLikeText(buf) {
183
182
  let control = 0;
184
183
  for (const ch of text) {
185
184
  const c = ch.charCodeAt(0);
186
- // Keep \t \n \r \f (and \b); everything else < 0x20 is binary-ish.
185
+ // Keep \t \n \f \r; everything else < 0x20 (including \b and \v) is binary-ish.
187
186
  if (c < 0x20 && c !== 9 && c !== 10 && c !== 12 && c !== 13)
188
187
  control++;
189
188
  }
@@ -195,8 +194,12 @@ export function looksLikeText(buf) {
195
194
  * previews and inline attachments never show mojibake for GBK/GB2312 files
196
195
  * nor for truncated UTF-8 files (issue #392). */
197
196
  export function decodeText(buf) {
198
- for (let cut = 0; cut < 4; cut++) {
199
- const slice = cut === 0 ? buf : buf.subarray(0, Math.max(0, buf.length - cut));
197
+ // `cut < buf.length` keeps the truncated-tail retry from eating the whole
198
+ // buffer: a 1–3 byte buffer of legacy bytes (GBK "中" = D6 D0) would
199
+ // otherwise trim down to an empty slice, decode "successfully" as UTF-8 and
200
+ // return "" — silently blanking every tiny non-UTF-8 preview.
201
+ for (let cut = 0; cut < 4 && cut < buf.length; cut++) {
202
+ const slice = cut === 0 ? buf : buf.subarray(0, buf.length - cut);
200
203
  try {
201
204
  return new TextDecoder("utf-8", { fatal: true }).decode(slice);
202
205
  }
@@ -11,7 +11,7 @@
11
11
  * - user : <dataDir>/themes/*.css (drop a css file here to add a theme)
12
12
  */
13
13
  import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
14
- import { join } from "node:path";
14
+ import { dirname, join, resolve } from "node:path";
15
15
  /** Only simple file ids — no path traversal. */
16
16
  const ID_RE = /^[A-Za-z0-9_-]+$/;
17
17
  /** Display-name marker inside a theme css file (first lines):
@@ -111,3 +111,38 @@ export function resolveThemeFile(builtinDir, userDir, id) {
111
111
  }
112
112
  return null;
113
113
  }
114
+ /**
115
+ * 读取主题 CSS,并安全展开其中的 `@import "./..."` 相对导入。
116
+ * - 仅允许相对当前主题文件所在目录的子路径(或同级);
117
+ * - 限制递归深度(默认 3 层)防循环引用;
118
+ * - 仅允许引入 .css 文件;
119
+ * - 确保生产/开发模式下均能无缝组合共享形态基底(如 bases/flow-base.css),免去客户端多次瀑布流请求。
120
+ *
121
+ * 返回的整份样式表会被包进 `@layer theme { ... }`(与 `web/src/styles.css` 的
122
+ * `@layer guard, base, theme;` 声明配套:主题层永远压在 base 之上,主题之间不再靠
123
+ * `!important` 抢权重)。只包**最外层一次**——递归内联的子文件必须原样返回,
124
+ * 否则会形成嵌套层(嵌套层无法与顶层 base/theme 正确比较顺序)。
125
+ * 调用方(`server/index.ts` 的 `/themes/:id.css`)行为不变:仍直接写回响应。
126
+ */
127
+ export function readThemeCss(filePath, visited = new Set(), depth = 0) {
128
+ const css = inlineThemeImports(filePath, visited, depth);
129
+ if (depth > 0 || !css.trim())
130
+ return css;
131
+ return `@layer theme {\n${css.trimEnd()}\n}\n`;
132
+ }
133
+ /** `readThemeCss` 的内联主体:递归调用自身(不包层,见上文)。 */
134
+ function inlineThemeImports(filePath, visited, depth) {
135
+ if (depth > 3 || visited.has(filePath))
136
+ return "";
137
+ visited.add(filePath);
138
+ if (!existsSync(filePath) || !statSync(filePath).isFile())
139
+ return "";
140
+ const content = readFileSync(filePath, "utf8");
141
+ const dir = dirname(filePath);
142
+ return content.replace(/@import\s+["'](\.[^"']+\.css)["'];?\r?\n?/g, (_match, relPath) => {
143
+ const targetPath = resolve(dir, relPath);
144
+ if (!existsSync(targetPath) || !statSync(targetPath).isFile())
145
+ return "";
146
+ return inlineThemeImports(targetPath, visited, depth + 1) + "\n";
147
+ });
148
+ }
@@ -18,7 +18,7 @@ import { join } from "node:path";
18
18
  import { BaseAgentDriver } from "../driver-base.js";
19
19
  import { DshRuntime } from "../../dsh/dsh-client.js";
20
20
  import { normalizeDshUsage } from "../../dsh/dsh-usage.js";
21
- import { listCustomModelsFromConfig, resolveProviderCredential } from "../../model-resolver.js";
21
+ import { listCustomModelsFromConfig } from "../../model-resolver.js";
22
22
  import { discoverDiskSkills } from "../../skill-discovery.js";
23
23
  const DEFAULT_MODEL = "deepseek-v4-flash";
24
24
  const DSH_OFFICIAL_MODELS = [
@@ -12,7 +12,7 @@ import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
12
12
  import { homedir } from "node:os";
13
13
  import { join } from "node:path";
14
14
  import { FilesService } from "../files-service.js";
15
- import { TerminalManager, makePersistentTerminalTools, TERMINAL_TOOLS_GUIDANCE } from "../terminals.js";
15
+ import { TerminalManager, makePersistentTerminalTools } from "../terminals.js";
16
16
  import { TERMINAL_TOOL_NAMES } from "../tool-manager.js";
17
17
  import { BgServerTracker } from "../bg-servers.js";
18
18
  import { ModelAdminService } from "../model-admin.js";
@@ -1075,8 +1075,15 @@ export class UniversalSession {
1075
1075
  this.flushSnapshot();
1076
1076
  return;
1077
1077
  }
1078
- // 截断到编辑点之前的所有历史消息,fork 一个新的 UniversalConversation
1079
- const headMessages = structuredClone(conv.messages.slice(0, idx));
1078
+ // 截断到编辑点之前的所有历史消息(跳过属于本轮提问的前置附件卡片,避免 prompt 重新注入后附件重复),
1079
+ // fork 一个新的 UniversalConversation
1080
+ let cutIdx = idx;
1081
+ while (cutIdx > 0 &&
1082
+ conv.messages[cutIdx - 1]?.role === "custom" &&
1083
+ conv.messages[cutIdx - 1]?.customType === "file") {
1084
+ cutIdx--;
1085
+ }
1086
+ const headMessages = structuredClone(conv.messages.slice(0, cutIdx));
1080
1087
  const forkedConv = this.createEmptyConversation(conv.title, Boolean(conv.isEphemeral));
1081
1088
  forkedConv.messages = headMessages;
1082
1089
  if (headMessages.length > 0) {
@@ -10,7 +10,7 @@
10
10
  * 4. 组装 `WorktreeInfo` 上下文供 UI 横幅与 AI 工具消费。
11
11
  */
12
12
  import { execFile } from "node:child_process";
13
- import { resolve, relative, normalize } from "node:path";
13
+ import { resolve, normalize } from "node:path";
14
14
  import { promisify } from "node:util";
15
15
  import { existsSync } from "node:fs";
16
16
  import { pick } from "./i18n.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-web-ui",
3
- "version": "0.109.0",
3
+ "version": "0.110.0",
4
4
  "description": "Just open your browser to get all your work done — browser cockpit for AI coding agents (chat, code, files, terminal, Git in one tab)",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -76,9 +76,12 @@
76
76
  "check:protocol": "node scripts/check-protocol-sync.mjs",
77
77
  "i18n:diff": "node scripts/i18n-diff.mjs",
78
78
  "i18n:check": "node scripts/i18n-diff.mjs --check-packs",
79
+ "i18n:sync": "node scripts/sync-locales.mjs",
79
80
  "release:notes": "node scripts/release-notes.mjs",
80
81
  "changelog:i18n": "node scripts/release-notes.mjs --unreleased",
81
82
  "test:freeze": "node tests/freeze-test.mjs",
83
+ "plugins:link": "node scripts/link-plugins.mjs",
84
+ "plugins:unlink": "node scripts/link-plugins.mjs --unlink",
82
85
  "start": "node --import ./dist/server/resolve-global-sdk.js dist/server/index.js",
83
86
  "build:desktop": "tsc -p desktop/tsconfig.json",
84
87
  "desktop:dev": "npm run build:desktop && electron dist/desktop/main.js",
@@ -88,7 +91,9 @@
88
91
  "format": "prettier --write server/ web/src/ extensions/ scripts/ bin/ desktop/ tests/*.mjs tests/unit/ *.mjs",
89
92
  "format:check": "prettier --check server/ web/src/ extensions/ scripts/ bin/ desktop/ tests/*.mjs tests/unit/ *.mjs",
90
93
  "lint": "oxlint server/ web/src/ extensions/ scripts/ bin/ desktop/",
91
- "lint:fix": "oxlint --fix server/ web/src/ extensions/ scripts/ bin/ desktop/"
94
+ "lint:fix": "oxlint --fix server/ web/src/ extensions/ scripts/ bin/ desktop/",
95
+ "audit:themes": "node scripts/theme-audit.mjs --out .theme-audit/current",
96
+ "audit:diff": "node scripts/theme-diff.mjs .theme-audit/baseline .theme-audit/current"
92
97
  },
93
98
  "dependencies": {
94
99
  "@deepseek-ai/dsh-sdk-jsonrpc-server": "^0.1.5-rc.3",
@@ -206,6 +206,26 @@ export interface PluginHost {
206
206
  readonly cwd: string;
207
207
  onCwdChange(handler: (cwd: string) => void): () => void;
208
208
  registerCommand(cmd: PluginCommandDef): () => void;
209
+ /** 执行已注册的插件斜杠命令(如 /todo, /note 等);返回结果或错误。 */
210
+ execCommand?(
211
+ name: string,
212
+ args: string,
213
+ context?: { clientId?: string },
214
+ ): Promise<{ ok: boolean; result?: string; error?: string }>;
215
+ /** 获取当前系统注册的全部插件命令列表。 */
216
+ getPluginCommands?(): PluginCommandDef[];
217
+ /** 获取最近项目路径列表。 */
218
+ listProjects?(): string[];
219
+ /** 调起系统级目录浏览器弹窗选择文件夹。 */
220
+ pickDirectory?(opts?: {
221
+ initialPath?: string;
222
+ title?: string;
223
+ }): Promise<{ ok: boolean; path?: string; canceled?: boolean; error?: string }>;
224
+ /** 调起系统级模型选择器弹窗选择模型。 */
225
+ pickModel?(opts?: {
226
+ currentModelId?: string | null;
227
+ title?: string;
228
+ }): Promise<{ ok: boolean; modelId?: string; name?: string; provider?: string; canceled?: boolean; error?: string }>;
209
229
  /** 挂载 HTTP 路由(实际暴露为 /plugins-api/<id><path>;要 "http" 能力;返回注销函数)。 */
210
230
  route(
211
231
  method: "GET" | "POST" | "PUT" | "DELETE",
@@ -316,6 +316,20 @@ export function createMockHost(overrides) {
316
316
  cwd: typeof overrides.cwd === "string" ? overrides.cwd : "/mock-workspace",
317
317
  onCwdChange: sub("onCwdChange"),
318
318
  registerCommand: (cmd) => remember(commandStore, cmd),
319
+ execCommand: async (name, args, context) => {
320
+ const cmd = [...commandStore.values()].find((c) => c.name === name);
321
+ if (!cmd) return { ok: false, error: `Command /${name} not found` };
322
+ try {
323
+ const res = await cmd.run(args, context);
324
+ return { ok: true, result: typeof res === "string" ? res : "" };
325
+ } catch (err) {
326
+ return { ok: false, error: err?.message ?? String(err) };
327
+ }
328
+ },
329
+ getPluginCommands: () => [...commandStore.values()],
330
+ listProjects: () => ["/mock-workspace", "/mock-project-2"],
331
+ pickDirectory: async (opts) => ({ ok: true, path: opts?.initialPath || "/mock-workspace" }),
332
+ pickModel: async (opts) => ({ ok: true, modelId: opts?.currentModelId || "mock/test-model" }),
319
333
  ui: {
320
334
  // 内存注册表(同 id 覆盖、上限 32 条,与宿主合并语义同口径的精简版):
321
335
  // list() 真反映 register/update/remove,off() 只摘除本次注册的 id。
@@ -24,8 +24,8 @@
24
24
  "name": "vscode-editor",
25
25
  "icon": "📝",
26
26
  "iconSvg": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"m16 18 6-6-6-6\"/><path d=\"m8 6-6 6 6 6\"/></svg>",
27
- "description": "类 VSCode 工作台:多根文件树 + CodeMirror 编辑器 + 底部终端 + Remote-SSH + SFTP 同步;向 AI 注册 SFTP/SSH/远端文件工具,可自主传代码。",
28
- "descriptionEn": "VSCode-like workbench: multi-root file tree, CodeMirror editor, integrated terminal, Remote-SSH and SFTP sync; registers SFTP/SSH/remote-file tools so the AI can deploy code itself.",
27
+ "description": "类 VSCode 工作台:多根文件树 + CodeMirror 编辑器 + 底部终端 + Remote-SSH 远程文件浏览与编辑。",
28
+ "descriptionEn": "VSCode-like workbench: multi-root file tree, CodeMirror editor, integrated terminal, and Remote-SSH remote file browsing/editing.",
29
29
  "source": "xing-shuyin/pi-web-ui/plugins/vscode-editor",
30
30
  "homepage": "https://github.com/xing-shuyin/pi-web-ui/tree/main/plugins/vscode-editor"
31
31
  },
@@ -371,5 +371,25 @@
371
371
  "descriptionEn": "Multi-engine TTS plugin aggregating Doubao and DeepSeek official voices, supporting one-click browser credential sync, message narration, and real-time streaming speech playback.",
372
372
  "source": "xing-shuyin/pi-web-ui/plugins/tts",
373
373
  "homepage": "https://github.com/xing-shuyin/pi-web-ui/tree/main/plugins/tts"
374
+ },
375
+ {
376
+ "id": "tunnel",
377
+ "name": "网络隧道",
378
+ "icon": "🔗",
379
+ "iconSvg": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71\"/><path d=\"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71\"/></svg>",
380
+ "description": "反向隧道:主人设备 CLI 主动连入(零公网暴露,穿 NAT),pi 经本机 SOCKS5 以主人所在网络为出口做巡检与访问(DNS 在主人侧解析)。面板展示隧道在线状态/连接数/令牌管理;注册 tunnel_fetch 工具供 AI 直接探测主人网络。",
381
+ "descriptionEn": "Reverse tunnel: the owner's device dials in (no public exposure, NAT-friendly); pi reaches the owner's network via local SOCKS5 with DNS resolved owner-side. Panel shows tunnel status/connections/token; tunnel_fetch tool for AI probes.",
382
+ "source": "xing-shuyin/pi-web-ui/plugins/tunnel",
383
+ "homepage": "https://github.com/xing-shuyin/pi-web-ui/tree/main/plugins/tunnel"
384
+ },
385
+ {
386
+ "id": "approval-gate",
387
+ "name": "拍板",
388
+ "icon": "🪧",
389
+ "iconSvg": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M22 5H2v11h20z\"/><path d=\"M12 16v4\"/><path d=\"M8 20h8\"/><path d=\"M7 9l3 3 5-5\"/></svg>",
390
+ "description": "定时任务拍板中心:待拍板项集中列表,点击跳转对应会话完成拍板;通用 CLI 供任意定时任务登记;顶栏拍板 tab 红点显示待拍板数。",
391
+ "descriptionEn": "Approval gate: centralized pending-decision list from scheduled tasks; click an item to jump into its conversation; red-dot badge on the tab shows pending count. A generic CLI lets any cron job register items.",
392
+ "source": "xing-shuyin/pi-web-ui/plugins/approval-gate",
393
+ "homepage": "https://github.com/xing-shuyin/pi-web-ui/tree/main/plugins/approval-gate"
374
394
  }
375
395
  ]