pi-web-ui 0.108.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 (83) hide show
  1. package/CHANGELOG.md +54 -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 +47 -36
  7. package/dist/server/attachments.js +26 -6
  8. package/dist/server/client-state.js +4 -3
  9. package/dist/server/dispatch-domain-handlers.js +2 -0
  10. package/dist/server/dispatch-plugin-handlers.js +1 -0
  11. package/dist/server/dsh/dsh-agent-service.js +2 -2
  12. package/dist/server/durable/durable-driver.js +1 -1
  13. package/dist/server/durable/durable-tools.js +4 -1
  14. package/dist/server/files-service.js +23 -4
  15. package/dist/server/goal-service.js +12 -3
  16. package/dist/server/index.js +39 -10
  17. package/dist/server/locales.js +33 -0
  18. package/dist/server/marker-service.js +7 -13
  19. package/dist/server/markers/builtins/action.js +5 -6
  20. package/dist/server/markers/builtins/notify.js +2 -2
  21. package/dist/server/markers/builtins/rename.js +2 -2
  22. package/dist/server/markers/registry.js +5 -1
  23. package/dist/server/message-window.js +190 -0
  24. package/dist/server/model-admin.js +0 -4
  25. package/dist/server/plugin-catalog-sync.js +10 -2
  26. package/dist/server/plugin-catalog.js +63 -10
  27. package/dist/server/plugins.js +47 -6
  28. package/dist/server/preset-share.js +2 -3
  29. package/dist/server/process-utils.js +58 -24
  30. package/dist/server/protocol-version.js +1 -1
  31. package/dist/server/settings-service.js +8 -3
  32. package/dist/server/slash-commands.js +16 -4
  33. package/dist/server/text-sniff.js +10 -7
  34. package/dist/server/themes.js +36 -1
  35. package/dist/server/universal/drivers/dsh-driver.js +1 -1
  36. package/dist/server/universal/universal-session.js +12 -4
  37. package/dist/server/worktree-service.js +1 -1
  38. package/package.json +7 -2
  39. package/plugin-sdk/index.d.ts +20 -0
  40. package/plugin-sdk/index.mjs +14 -0
  41. package/plugins/catalog.json +22 -2
  42. package/themes/aetheris.css +155 -121
  43. package/themes/ayu-light.css +19 -15
  44. package/themes/bases/flow-base.css +1363 -0
  45. package/themes/bases/obsidian-base.css +679 -0
  46. package/themes/bases/zhujian-base.css +687 -0
  47. package/themes/bases/zhupi-base.css +659 -0
  48. package/themes/catppuccin-latte.css +17 -15
  49. package/themes/catppuccin.css +5 -2
  50. package/themes/claude-code-dark.css +2 -0
  51. package/themes/codex.css +16 -14
  52. package/themes/cyberpunk.css +4 -1
  53. package/themes/dark-teal.css +4 -1
  54. package/themes/dazzle.css +3 -0
  55. package/themes/everforest-light.css +17 -15
  56. package/themes/flow-light.css +10 -931
  57. package/themes/flow.css +13 -946
  58. package/themes/geist.css +16 -14
  59. package/themes/gruvbox-light.css +13 -11
  60. package/themes/kanagawa-lotus.css +16 -14
  61. package/themes/mist.css +18 -16
  62. package/themes/nord.css +16 -12
  63. package/themes/one-dark.css +9 -5
  64. package/themes/paper.css +9 -7
  65. package/themes/rose-pine-dawn.css +14 -12
  66. package/themes/sakura.css +15 -13
  67. package/themes/solarized-light.css +19 -17
  68. package/themes/tokyo-night.css +4 -2
  69. package/themes/vs-code-dark.css +4 -3
  70. package/themes/wallpaper-flow.css +73 -1031
  71. package/themes/wallpaper-obsidian.css +4 -673
  72. package/themes/white.css +8 -6
  73. package/themes/zhujian-dark.css +6 -608
  74. package/themes/zhujian.css +6 -657
  75. package/themes/zhupi-dark.css +6 -579
  76. package/themes/zhupi.css +6 -629
  77. package/web/dist/assets/{TerminalPanel-CslRhcS7.js → TerminalPanel-BHjM6pzY.js} +1 -1
  78. package/web/dist/assets/index-DwInT7-a.css +1 -0
  79. package/web/dist/assets/index-GfVFIgIL.js +693 -0
  80. package/web/dist/index.html +2 -2
  81. package/web/dist/sw.js +1 -1
  82. package/web/dist/assets/index-C_2Fl6f6.js +0 -690
  83. package/web/dist/assets/index-D0BtO5dn.css +0 -1
@@ -4,6 +4,61 @@ import { resolve } from "node:path";
4
4
  * 后台任务面板(bgServers)用它们检测/停止 agent 在后台拉起的服务。
5
5
  * 从 agent-service.ts 抽出,行为保持不变。全平台 best-effort:失败静默。
6
6
  */
7
+ /**
8
+ * 解析 Windows `netstat -ano -p tcp` 输出 → 端口→pid。纯函数,单测覆盖。
9
+ * 行形状:`TCP 0.0.0.0:5173 0.0.0.0:0 LISTENING 12345`。
10
+ */
11
+ export function parseNetstatListening(stdout) {
12
+ const m = new Map();
13
+ for (const line of stdout.split(/\r?\n/)) {
14
+ const p = line.trim().split(/\s+/);
15
+ if (p.length >= 5 && p[0] === "TCP" && p[3] === "LISTENING") {
16
+ // 本地地址可能是 0.0.0.0:5173 / [::1]:5173 —— 取最后一段就是端口。
17
+ const port = Number(p[1].split(":").pop());
18
+ const pid = Number(p[4]);
19
+ if (Number.isFinite(port) && Number.isFinite(pid))
20
+ m.set(port, pid);
21
+ }
22
+ }
23
+ return m;
24
+ }
25
+ /**
26
+ * 解析 POSIX `lsof -iTCP -sTCP:LISTEN -P -n` 输出 → 端口→pid。纯函数,单测覆盖。
27
+ *
28
+ * NAME 列形如 `*:5173` / `127.0.0.1:5173` / `[::1]:5173`。监听态 `(LISTEN)`
29
+ * 在不同发行版上**要么贴在 NAME 里、要么自成最后一列**,所以“取最后一列”的
30
+ * 写法(旧实现)在后者上拿到的是 `(LISTEN)` 而不是地址 —— 整条 posix 端口探测
31
+ * 静默失效(后台任务面板就看不到 AI 拉起的服务)。这里改成扫列:第一个
32
+ * “以冒号+数字收尾”的列就是地址(FD/TYPE/DEVICE/SIZE-OFF/NODE 都不带这种形状)。
33
+ */
34
+ export function parseLsofListening(stdout) {
35
+ const m = new Map();
36
+ for (const line of stdout.split(/\r?\n/)) {
37
+ const p = line.trim().split(/\s+/);
38
+ if (p.length < 5)
39
+ continue;
40
+ const pid = Number(p[1]);
41
+ if (!Number.isFinite(pid) || pid <= 0)
42
+ continue; // 表头 / 脏行
43
+ const port = findListenPort(p.slice(3));
44
+ if (port === null)
45
+ continue;
46
+ m.set(port, pid);
47
+ }
48
+ return m;
49
+ }
50
+ /** 从 lsof 行尾列里找出监听端口(第一个 `:数字` 收尾的列)。 */
51
+ function findListenPort(cols) {
52
+ for (const col of cols) {
53
+ const mm = col.match(/:(\d{1,5})$/);
54
+ if (!mm)
55
+ continue;
56
+ const port = Number(mm[1]);
57
+ if (port > 0 && port <= 65535)
58
+ return port;
59
+ }
60
+ return null;
61
+ }
7
62
  /**
8
63
  * Snapshot currently LISTENING TCP ports → owning pid. Windows: netstat;
9
64
  * POSIX: lsof. Used to detect servers the agent started in the background
@@ -15,31 +70,10 @@ export async function snapshotListeningPorts() {
15
70
  const { execFile } = await import("node:child_process");
16
71
  if (process.platform === "win32") {
17
72
  const out = await new Promise((resolve, reject) => execFile("netstat", ["-ano", "-p", "tcp"], { windowsHide: true, timeout: 8000 }, (err, stdout) => err ? reject(err) : resolve(stdout)));
18
- for (const line of out.split(/\r?\n/)) {
19
- const p = line.trim().split(/\s+/);
20
- // TCP 0.0.0.0:5173 0.0.0.0:0 LISTENING 12345
21
- if (p.length >= 5 && p[0] === "TCP" && p[3] === "LISTENING") {
22
- const port = Number(p[1].split(":").pop());
23
- const pid = Number(p[4]);
24
- if (Number.isFinite(port) && Number.isFinite(pid))
25
- m.set(port, pid);
26
- }
27
- }
28
- }
29
- else {
30
- const out = await new Promise((resolve, reject) => execFile("lsof", ["-iTCP", "-sTCP:LISTEN", "-P", "-n"], { timeout: 8000 }, (err, stdout) => err ? reject(err) : resolve(stdout)));
31
- for (const line of out.split(/\r?\n/).slice(1)) {
32
- const p = line.trim().split(/\s+/);
33
- if (p.length >= 9) {
34
- // NAME column tail: "*:5173 (LISTEN)" or "[::1]:5173 (LISTEN)"
35
- const mm = (p[p.length - 1] ?? "").match(/(\d+)\)?\s*$/);
36
- const port = mm ? Number(mm[1]) : NaN;
37
- const pid = Number(p[1]);
38
- if (Number.isFinite(port) && Number.isFinite(pid))
39
- m.set(port, pid);
40
- }
41
- }
73
+ return parseNetstatListening(out);
42
74
  }
75
+ const out = await new Promise((resolve, reject) => execFile("lsof", ["-iTCP", "-sTCP:LISTEN", "-P", "-n"], { timeout: 8000 }, (err, stdout) => err ? reject(err) : resolve(stdout)));
76
+ return parseLsofListening(out);
43
77
  }
44
78
  catch {
45
79
  // best effort — snapshot failure just means no tracking this round
@@ -8,4 +8,4 @@
8
8
  * its own copy in web/src/protocol-version.ts; scripts/check-protocol-sync.mjs
9
9
  * verifies the two never drift.
10
10
  */
11
- export const PROTOCOL_VERSION = 32;
11
+ export const PROTOCOL_VERSION = 34;
@@ -307,7 +307,7 @@ export class SettingsService {
307
307
  toolWatchdogTimeoutMs: this.settings.toolWatchdogTimeoutMs,
308
308
  readDirEnabled: this.settings.readDirEnabled !== false,
309
309
  bgAutoCleanupMin: normalizeBgCleanupMinutes(this.settings.bgAutoCleanupMin),
310
- toolLazyLoading: this.settings.toolLazyLoading !== false,
310
+ toolLazyLoading: this.settings.toolLazyLoading === true,
311
311
  codemodeMode: this.settings.codemodeMode ?? "on",
312
312
  codemodeInlineBudget: this.settings.codemodeInlineBudget ?? 3000,
313
313
  toolApprovalEnabled: this.settings.toolApprovalEnabled !== false,
@@ -323,6 +323,7 @@ export class SettingsService {
323
323
  toolsWrap: this.settings.toolsWrap,
324
324
  toolImagesEnabled: this.settings.toolImagesEnabled ?? true,
325
325
  keepRecentMessages: normalizeKeepRecentMessages(this.settings.keepRecentMessages),
326
+ reversePagination: this.settings.reversePagination ?? false,
326
327
  showForkedParentSessions: this.settings.showForkedParentSessions ?? false,
327
328
  retainFinishedConversations: this.settings.retainFinishedConversations ?? false,
328
329
  openRecentSessionOnProjectSwitch: this.settings.openRecentSessionOnProjectSwitch ?? true,
@@ -524,11 +525,11 @@ export class SettingsService {
524
525
  if (partial.bgAutoCleanupMin !== undefined) {
525
526
  this.settings.bgAutoCleanupMin = normalizeBgCleanupMinutes(partial.bgAutoCleanupMin);
526
527
  }
527
- // 工具延迟加载开关(默认开):门控每次实时读取,改动经 applyToolGating 重放生效
528
+ // 工具延迟加载开关(默认关,设置页可开):门控每次实时读取,改动经 applyToolGating 重放生效
528
529
  // (见 toolGatingChanged)——**只影响新会话与之后的门控重放**,已有对话的已加载
529
530
  // 集合不会被反向清空(不想让在跑的对话凭空丢掉工具)。
530
531
  if (partial.toolLazyLoading !== undefined) {
531
- this.settings.toolLazyLoading = partial.toolLazyLoading !== false;
532
+ this.settings.toolLazyLoading = partial.toolLazyLoading === true;
532
533
  }
533
534
  let codemodeChanged = false;
534
535
  if (partial.codemodeMode !== undefined && partial.codemodeMode !== this.settings.codemodeMode) {
@@ -577,6 +578,10 @@ export class SettingsService {
577
578
  if (partial.keepRecentMessages !== undefined) {
578
579
  this.settings.keepRecentMessages = normalizeKeepRecentMessages(partial.keepRecentMessages);
579
580
  }
581
+ // 向上分页加载:前端 MessageList 实时读它(纯渲染策略),无需 reload runtime。
582
+ if (partial.reversePagination !== undefined) {
583
+ this.settings.reversePagination = Boolean(partial.reversePagination);
584
+ }
580
585
  if (partial.retainFinishedConversations !== undefined) {
581
586
  this.settings.retainFinishedConversations = Boolean(partial.retainFinishedConversations);
582
587
  }
@@ -63,10 +63,10 @@ export function parseSlash(text) {
63
63
  const trimmed = text.trim();
64
64
  if (!trimmed.startsWith("/"))
65
65
  return null;
66
- const m = trimmed.match(/^\/([^\s]+)\s*([\s\S]*)$/);
67
- if (!m || !m[1])
66
+ const m = trimmed.match(/^\/([^\s]*)\s*([\s\S]*)$/);
67
+ if (!m)
68
68
  return null;
69
- return { name: m[1], args: m[2].trim() };
69
+ return { name: m[1] ?? "", args: (m[2] ?? "").trim() };
70
70
  }
71
71
  export class SlashCommandsService {
72
72
  host;
@@ -418,7 +418,19 @@ export class SlashCommandsService {
418
418
  }, 300);
419
419
  return true;
420
420
  }
421
- case "help":
421
+ case "":
422
+ case "?":
423
+ case "help": {
424
+ void this.push();
425
+ const cmdList = NATIVE_COMMANDS.map((c) => `/${c.name} : ${c.description}`).join("\n");
426
+ this.host.emit({
427
+ type: "notice",
428
+ level: "info",
429
+ text: `可用斜杠指令:\n${cmdList}`,
430
+ textEn: `Available slash commands:\n${cmdList}`,
431
+ });
432
+ return true;
433
+ }
422
434
  case "copy":
423
435
  // Client-side UI actions — the client handles them before sending;
424
436
  // swallow here so the SDK never sees them as plain prompt text.
@@ -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) {
@@ -1785,7 +1792,8 @@ export class UniversalSession {
1785
1792
  toolWatchdogTimeoutMs: s?.toolWatchdogTimeoutMs ?? 1200000,
1786
1793
  readDirEnabled: true,
1787
1794
  bgAutoCleanupMin: s?.bgAutoCleanupMin ?? 0,
1788
- toolLazyLoading: true,
1795
+ // 同一字段的含义在本引擎不适用(无 pi 工具注册面):恒为 false 占位,保协议完整。
1796
+ toolLazyLoading: false,
1789
1797
  codemodeMode: "on",
1790
1798
  codemodeInlineBudget: 3000,
1791
1799
  editSoftEnabled: false,
@@ -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.108.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
  ]