pi-web-ui 0.111.0 → 0.113.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 (88) hide show
  1. package/CHANGELOG.md +92 -2
  2. package/bin/frp-manager.mjs +9 -2
  3. package/bin/pi-web-ui.mjs +325 -45
  4. package/dist/server/agent-service-daemon.js +29 -4
  5. package/dist/server/agent-service.js +1527 -510
  6. package/dist/server/approval-audit.js +119 -0
  7. package/dist/server/approval-default-rules.js +4 -4
  8. package/dist/server/approval-rules.js +42 -17
  9. package/dist/server/attachment-store.js +8 -8
  10. package/dist/server/canvas/canvas-agent-tool.js +8 -0
  11. package/dist/server/canvas/canvas-orchestrator.js +128 -22
  12. package/dist/server/canvas/pstack-skills-data.js +498 -0
  13. package/dist/server/client-state.js +28 -0
  14. package/dist/server/delegate-mode.js +6 -3
  15. package/dist/server/delegate-task.js +18 -3
  16. package/dist/server/dispatch-domain-handlers.js +39 -11
  17. package/dist/server/dsh/dsh-agent-service.js +294 -15
  18. package/dist/server/dsh/dsh-serialize.js +1 -1
  19. package/dist/server/durable/durable-driver.js +112 -107
  20. package/dist/server/durable/durable-event-projector.js +253 -0
  21. package/dist/server/durable/durable-loader.js +1 -14
  22. package/dist/server/durable/durable-models.js +107 -0
  23. package/dist/server/durable/index.js +0 -4
  24. package/dist/server/engine-probe.js +111 -48
  25. package/dist/server/eval-tool.js +28 -3
  26. package/dist/server/goal-service.js +7 -0
  27. package/dist/server/index.js +371 -57
  28. package/dist/server/json-utils.js +57 -0
  29. package/dist/server/marker-service.js +8 -0
  30. package/dist/server/message-window.js +43 -10
  31. package/dist/server/model-admin.js +247 -163
  32. package/dist/server/model-resolver.js +66 -44
  33. package/dist/server/plan-manager.js +3 -6
  34. package/dist/server/plugin-api-catalog.js +1 -0
  35. package/dist/server/plugin-assets.js +238 -0
  36. package/dist/server/plugin-facilities.js +22 -0
  37. package/dist/server/plugin-ui-slots.js +1 -0
  38. package/dist/server/plugins.js +209 -11
  39. package/dist/server/preset-fields.js +25 -1
  40. package/dist/server/preset-share.js +5 -2
  41. package/dist/server/prompt-assembler.js +2 -1
  42. package/dist/server/prompt-composer.js +18 -8
  43. package/dist/server/protocol-version.js +1 -1
  44. package/dist/server/queue-utils.js +156 -0
  45. package/dist/server/remote-ssh-service.js +110 -12
  46. package/dist/server/sdk-builtin-extensions.js +85 -0
  47. package/dist/server/serialize.js +1 -1
  48. package/dist/server/server-config.js +66 -0
  49. package/dist/server/session-parser.js +49 -13
  50. package/dist/server/session-search.js +4 -3
  51. package/dist/server/settings-service.js +74 -53
  52. package/dist/server/setup-page.js +632 -0
  53. package/dist/server/skill-discovery.js +361 -59
  54. package/dist/server/skill-maintenance.js +231 -0
  55. package/dist/server/skill-tool.js +32 -3
  56. package/dist/server/soft-cap.js +30 -6
  57. package/dist/server/subagent-helpers.js +22 -1
  58. package/dist/server/subagent-notify.js +93 -0
  59. package/dist/server/subagent-security-gate.js +282 -0
  60. package/dist/server/subagent-templates.js +8 -0
  61. package/dist/server/subagents.js +390 -48
  62. package/dist/server/terminals.js +196 -8
  63. package/dist/server/text-quote.js +61 -0
  64. package/dist/server/tool-approval.js +63 -4
  65. package/dist/server/tool-guards.js +208 -0
  66. package/dist/server/tool-host-factories.js +48 -10
  67. package/dist/server/tool-manager.js +106 -28
  68. package/dist/server/tool-overrides.js +21 -11
  69. package/dist/server/universal/driver-base.js +8 -0
  70. package/dist/server/universal/drivers/claude-code.js +116 -7
  71. package/dist/server/universal/drivers/dsh-driver.js +3 -0
  72. package/dist/server/universal/index.js +0 -1
  73. package/dist/server/universal/universal-session.js +106 -10
  74. package/dist/server/worktree-service.js +189 -1
  75. package/docs/dsh-engine.md +1 -5
  76. package/package.json +1 -1
  77. package/plugin-sdk/client-utils.mjs +192 -5
  78. package/plugin-sdk/index.d.ts +63 -1
  79. package/plugin-sdk/index.mjs +94 -0
  80. package/plugin-sdk/package.json +5 -1
  81. package/plugins/catalog.json +21 -0
  82. package/web/dist/assets/{TerminalPanel-BiUNySMA.js → TerminalPanel-3wojLfLk.js} +2 -2
  83. package/web/dist/assets/index-A8YXwnpZ.js +2008 -0
  84. package/web/dist/assets/index-BwL7qBh6.css +1 -0
  85. package/web/dist/index.html +11 -2
  86. package/web/dist/sw.js +1 -1
  87. package/web/dist/assets/index-B0ajS__T.js +0 -697
  88. package/web/dist/assets/index-BHik5WGG.css +0 -1
package/CHANGELOG.md CHANGED
@@ -8,12 +8,99 @@
8
8
  每个版本的内容按"实际合入该版本发布的提交"归档(以 `package.json` 的 version 变更提交为准),
9
9
  而不是按提交日期聚类——连续快速发布的 patch 版本以此为准最准确。
10
10
 
11
+ ## [Unreleased]
12
+
13
+ ## [0.113.0] — 2026-10-28
14
+
15
+ ### Added
16
+
17
+ - **QQ 通道富媒体双向(图片/语音/视频/文件)**:入站附件(`attachments`,腾讯 CDN)下载到工作区 `.pi-qq-media/` 并给 agent 本地路径(语音优先 `voice_wav_url` + 官方 ASR 文本),单件 25MB 上限、失败降级占位;出站给 `qq` 工具补 `image`/`file` 与 `user_openid`/`group_openid`,本地文件自动上传(≤5MB 走 base64 `file_data`,更大走 `upload_prepare` → 分片 PUT → `upload_part_finish` → 合并拿 `file_info`,再 `msg_type=7` 发送),超软限制降级为文件卡片;工作台新增媒体发送与「接收图片/文件落地」开关。频道(子频道)受官方限制只收公网 URL,本地文件明确报错。
18
+ - **通道插件运行归属根治(`host.chat` 回执新增稳定 `runId`)**:微信/钉钉/QQ/Discord/飞书此前靠 `clientId + conversationId` 认领回包,而「过户」会把两者同时改掉(`clientId` 换成浏览器标签页、撞 id 时对话就地改名),导致整轮事件无人认领、只剩「还在执行」后再无下文。现在运行轨迹事件携带不随过户/改名变化的 `runId`,`chatWait` 亦按它唤醒;钉钉/Discord 顺带修复「忽略 `host.chat` 回执、用本地编造会话 id 当键」导致正文从来发不出去的老问题。
19
+ - **画布工作室与技能/工具工作台升级**:P-Stack 技能包、节点抽屉与模板、审查卡点续跑;工具检查器(Tool Inspector)重构与文件差异可视化(统一/分屏/原始三视图、全屏、复制 patch);设置面板重排与 MCP / 技能市场(分类、复制链接、空态引导)。
20
+ - **远程工作台插件(remote-workbench)**:SSH 远程会话、xterm 终端、紧凑视图与工作区 URI,配套 sftp 插件增强。
21
+ - **技能发现与维护**:`skill-discovery` 重写 + `universal-skill-scanner`(`.pi/skills`、`.claude/skills` 目录型/单文件型统一扫描)+ `skill-maintenance` 清理能力。
22
+ - **用户终端持久化**:用户直接创建的交互式终端按客户端/工作区存活,不受单个对话切换与生命周期影响(快照、回放、退出广播都独立登记)。
23
+ - **`subagent(action="dismiss")`**:批量/单个回收已结束的子代理(含 `finished_all`、worktree 脏检查、持久化子代理保护),并同步 UI 列表(#767, #768)。
24
+ - **模型级 `thinkingLevelMap` 推导与保留**:候选采纳器默认勾选现有模型,切换/采纳后不丢思考强度映射(#771, #772)。
25
+
26
+ ### Changed
27
+
28
+ - **工具门控改为声明式「管辖权分界」(Authority Boundary)**:`tool-manager` 重构门控合成,恢复会话与重放时保留扩展主动禁用的工具状态,避免重连后被悄悄打开(#777, #779)。
29
+ - **Durable 引擎工具卡改由 `watchEvents` 事件流投影**:新增 `durable-event-projector`,工具卡入参与结果不再读 `pi.live` 私有槽位(原来为空并污染落盘会话),正文与工具卡按提交时间对齐(#774, #775)。
30
+ - **官方插件体系**:browser-use 探测脚本与文档更新;QQ / 微信 / 钉钉 / Discord / 飞书 / sftp 版本号递增(随包热同步生效)。
31
+
32
+ ### Fixed
33
+
34
+ - **微信通道连发丢答**:`bindActive`(投递到网页活跃会话)模式下第二条消息会把同一会话里**还在跑那一轮已产出的正文**一起清掉,最终只回「任务完成(无文本输出)」;改为只清没有在跑登记的残留文本(#770)。
35
+ - **Claude Code 引擎 macOS 定位**:自动解析 CLI 可执行路径并完善全局检测与 PATH 扫描(含 nvm/homebrew 场景)。
36
+ - **界面细节**:设置面板格式化、composer 高度自适应与拖拽手柄文案、文件差异卡在流式期间的渲染稳定性。
37
+
38
+ <!-- auto-i18n:start -->
39
+ ### i18n
40
+
41
+ - 前端新增 key(36):`composerResizeFixed`、`mcpMarketVisit`、`mcpMarketCopyLink`、`mcpMarketCopied`、`mcpMarketEmpty`、`mcpMarketEmptyClear`、`mcpCatAll`、`mcpCatCn`、`mcpCatMarketplace`、`mcpCatCommunity`、`mcpCatOfficial`、`skillMarketNoticeTitle`、`skillMarketNoticeDesc`、`skillMarketVisit`、`skillMarketCopyLink`、`skillMarketCopied`、`skillMarketEmpty`、`skillMarketEmptyClear`、`skillCatOfficial`、`skillCatMarketplace`、`skillCatCommunity`、`skillCatDirectory`、`diffViewUnified`、`diffViewSplit`、`diffViewRaw`、`diffNewFile`、`diffOpenFile`、`diffCopyContent`、`diffCopyPatch`、`diffStreaming`、`diffEmptyHunks`、`diffFullscreen`、`diffRestoreScreen`、`skillClickToInspect`、`copySkillContent`、`copiedSkillContent`
42
+ - 前端删除 key(34):`mcpBadgeOfficial`、`mcpConfigured`、`mcpAddGlobal`、`mcpAddProject`、`mcpAddGlobalHint`、`mcpAddProjectHint`、`skillCatQuality`、`skillCatWorkflow`、`skillCatArchitecture`、`skillCatDevops`、`skillCatStack`、`skillInspectPrompt`、`skillInstalled`、`skillInstallGlobal`、`skillInstallProject`、`skillInstallGlobalHint`、`skillInstallProjectHint`、`mcpSourceSelectLabel`、`mcpSourceSmithery`、`mcpSourceGithub`、`mcpSourceCustom`、`mcpSourceCustomPlaceholder`、`mcpMarketLoading`、`mcpMarketRetry`、`skillRepoSelect`、`skillRepoDefault`、`skillRepoCustom`、`skillRepoCustomPlaceholder`、`skillMarketLoading`、`skillMarketRetry`、`toolInspectorOutput`、`toolInspectorError`、`toolInspectorToggleRaw`、`toolInspectorTogglePreview`
43
+ - 前端中文变更(8):`composerResize`、`mcpMarketSearchPlaceholder`、`skillEmptyDesc`、`skillMarketSearchPlaceholder`、`skillCatAll`、`skillFullTextShort`、`skillInspectModalTitle`、`skillContentLoading`
44
+ - 前端英文变更(7):`composerResize`、`mcpMarketSearchPlaceholder`、`skillEmptyDesc`、`skillMarketSearchPlaceholder`、`skillCatAll`、`skillFullTextShort`、`skillContentLoading`
45
+ - 服务端新增 key(14):`subagents.dismiss.unsupported`、`subagents.dismiss.missing.target`、`subagents.dismiss.finished_all.empty`、`subagents.dismiss.not_found`、`subagents.dismiss.self`、`subagents.dismiss.active`、`subagents.dismiss.not_descendant`、`subagents.dismiss.persisted`、`subagents.dismiss.running`、`subagents.dismiss.worktree.dirty`、`subagents.dismiss.failed`、`subagents.dismiss.success.single`、`subagents.dismiss.none`、`subagents.dismiss.success.batch`
46
+ - 服务端文案变更(2):`subagents.action.missing`、`subagents.action.unknown`
47
+ <!-- auto-i18n:end -->
48
+
49
+ ## [0.112.0] — 2026-10-26
50
+
51
+ ### Added
52
+
53
+ - **消息滚动与逃逸生命周期管理器(useChatScroll)与平滑无感向上预加载**:彻底解耦手势感知、程序吸底保护窗(grace window)及用户逃逸阅读状态,解决会话切换 key 突变引发的重挂载掉帧与误吸底;逆向分页升级为水库双缓冲预加载模型,到达预警水位线静默拉取并基于锚点无缝前插,移除突兀的手动加载条幅(#764)。
54
+ - **会话级隔离审批与 0.0.0.0 零信任自愈口令**:高危工具审批状态由全局下沉至 Conversation 隔离,彻底消除多会话并发审批串台与幽灵弹窗;监听 0.0.0.0 且未配置 token 时自动生成高熵随机自愈口令并在终端显式提示,杜绝未授权暴露(#762)。
55
+ - **子代理 Worktree 隔离模式、依赖桥接与自动清理**:`subagent(action="spawn")` 支持 `isolation: "worktree"`,为任务创建独立临时工作树与 Git 分支,跨树桥接 node_modules 等依赖,任务结束后自动安全清理或保留(#728, #761)。
56
+ - **确认对话框三段式视窗架构、命令专用审计盒与拒绝附言反馈闭环**:确认对话框重构为三段式视窗,自适应吸收长标题;新增高危命令专用审计盒与多行语法高亮;拒绝授权时支持输入附言并直接注入智能体上下文,实现拒绝反馈闭环(#747, #759)。
57
+ - **宿主重资产流水线规范、国内镜像自动回退与 SHA-256 验签**:官方插件外部大资产统一流水线下载与验签;office 等重量级插件增加空闲自动休眠与按需唤醒(#760)。
58
+ - **子代理递归深度与连续唤醒保护**:新增 `subagentMaxDepth`(最大嵌套层数)与 `subagentAutoWakeMaxTurns`(连续自动唤醒上限轮数)设置项;智能熔断防误拦、挂起通知零丢失(#712, #726, #754)。
59
+ - **Favicon 状态指示与自定义颜色设置**:支持根据智能体运行态展示 Favicon 动态徽标,设置面板提供自定义颜色配置(#763)。
60
+ - **工具卡片与检查器技能标识**:工具调用卡片与 Tool Inspector 抽屉支持显示关联的 skill 技能名称(#734, #743)。
61
+ - **Durable 引擎思考强度自适应与 Llama 模型支持**:完善各主流服务商(DeepSeek, Claude, GPT, Llama 等)思考强度的跨模型自适应映射与诊断提示。
62
+
63
+ ### Changed
64
+
65
+ - **共享公共工具函数收敛与规范守卫**:收敛 `stripJsonComments`、`writeAtomicSync`、`markdown-chunks` 至 `plugin-sdk/client-utils.mjs` 与服务端共享模块,建立防回潮守卫(#730)。
66
+ - **官方插件体系同步升级**:清理废弃的 feature-board 插件及 univer-service 陈旧代码;14 个官方内置插件同步更新并递增版本号。
67
+
68
+ ### Fixed
69
+
70
+ - **安全加固**:网络隧道(Tunnel)令牌脱敏、Mesh 未授权注入防护与生命周期泄漏修复(#724, #765);审批归属门禁与部署姿态告警(#723, #752);常驻终端补异步审批与跨调用行缓冲防拆行绕过(#721, #736);统一审批流水线与命令防逃逸(#722);patch 工具补权限预设与审批规则包装(#720)。
71
+ - **跨平台与执行管道**:修复 Windows 环境下 Python eval 管道编码导致非 ASCII 字符传输中断(#757, #758);bash 工具纳入 tool-overrides 覆盖管线,与第三方扩展同名 bash 叠加共存(#750)。
72
+ - **界面与交互**:修复引擎切换死键、滚轮翻页闭包、问卷串台、断线过渡遮罩与 TTS 卡顿(#740, #744);历史按需加载不可变锚点翻页与过渡期沙箱隔离(#719, #735);工具文案覆盖 snippet 预览与实发对齐;会话目录兼收专属子目录与扁平旧会话(#711)。
73
+
74
+ <!-- auto-i18n:start -->
75
+ ### i18n
76
+
77
+ - 前端新增 key(27):`dismissTerminalsConfirm`、`toolApprovalDshNotice`、`cmdInspectorTitle`、`cmdInspectorLines`、`cmdInspectorExpand`、`cmdInspectorCollapse`、`cmdInspectorRisk`、`cmdCopied`、`rejectWithNote`、`rejectWithNoteSubmit`、`rejectNotePlaceholder`、`rejectFeedbackPrefix`、`promptToggleEnabled`、`instanceName`、`instanceNameDesc`、`instanceNamePh`、`faviconColor`、`faviconColorDesc`、`faviconColorAuto`、`customColor`、`uiLayoutToolCardFooter`、`subagentMaxDepth`、`subagentMaxDepthDesc`、`subagentMaxDepthUnlimited`、`subagentAutoWakeMaxTurns`、`subagentAutoWakeMaxTurnsDesc`、`subagentAutoWakeMaxTurnsUnlimited`
78
+ - 前端删除 key(3):`earlierMessagesInfo`、`loadEarlier`、`loadAllEarlier`
79
+ - 前端中文变更(3):`promptTok_tools_desc`、`promptTok_guidelines_desc`、`reversePaginationDesc`
80
+ - 前端英文变更(3):`promptTok_tools_desc`、`promptTok_guidelines_desc`、`reversePaginationDesc`
81
+ - 服务端新增 key(25):`agent.subagent.worktree.remote_unsupported`、`agent.subagent.model.failed`、`agent.subagent.model.not.found`、`canvas.edge.self`、`canvas.edge.duplicate`、`subagents.notify.fallback`、`subagents.notify.header`、`subagents.notify.status.failed`、`subagents.notify.status.canceled`、`subagents.notify.status.done`、`subagents.notify.goal`、`subagents.notify.worktree`、`subagents.notify.worktree.cleaned`、`subagents.notify.worktree.preserved`、`subagents.notify.worktree.path`、`subagents.notify.summary`、`subagents.notify.footer`、`subagents.spawn.thinking.invalid`、`subagents.spawn.isolation.invalid`、`subagents.get.worktree.cleaned`、`subagents.get.worktree.preserved`、`terminals.operation.denied`、`terminals.input.edited_sent`、`terminals.key.edited_sent`、`worktree.isolation.not_git`
82
+ - 服务端文案变更(5):`delegate.started`、`subagents.spawn.started`、`subagents.get.running`、`subagents.get.done`、`terminals.command.blocked`
83
+ - 服务端删除 key(2):`prompt.guidelines.be.concise`、`prompt.guidelines.show.paths`
84
+ <!-- auto-i18n:end -->
85
+
86
+ ## [0.111.0] — 2026-10-24
87
+
88
+ ### Added
89
+
90
+ - **画布工作室升级(Canvas Studio)**:新增汇聚门(join gate)、节点认领状态同步、可复用自定义卡片与审查熔断器,编排运行更稳、 review 卡点更清晰。
91
+ - **语音输入插件增强**:补齐连续语音输入能力与配置项。
92
+
93
+ ### Fixed
94
+
95
+ - **安全加固合集**:画布 id 白名单化(路径穿越与 git 参数注入)、供应链加固(frp 镜像源移除 + SHA256 校验)、TTS 输出路径边界、Live2D 模型名存储型 XSS、壁纸包路径越界、image-toolkit 探测密钥外呼、插件路径穿越/zip 炸弹/CORS 常驻浏览器泄漏、隧道鉴权端点。
96
+ - **稳定性修复**:多会话历史消息串台、子代理换模型后软上限重算、便携包 Node 陈旧与静默降级、空闲态图片附件未注入上下文。
97
+
11
98
  ## [0.110.0] — 2026-10-21
12
99
 
13
100
  ### Added
14
101
 
15
102
  - **网络隧道 (Tunnel) 插件**:内置开箱即用的公网穿透隧道支持,支持客户端一键连接、心跳自愈与断线重连、CLI 自动更新回路、四重探针健康探测,让私有部署轻松安全共享公网访问。
16
- - **拍板中心 (Approval Gate) 插件**:可视化集中审计与规则门禁,针对智能体敏感工具(如 bash、写操作等)提供对话内审批放行、白名单记忆管理及决策流日志。
103
+ - **定时任务拍板中心 (Approval Gate) 插件**:面向定时任务与外部调用的异步待办拍板台账,提供通用 CLI、集中待办列表与顶栏红点提示,支持点击跳转对应会话完成拍板并自动清账(注:智能体高危工具调用的实时弹窗与规则门禁属于服务端内建安全能力,独立于该插件)。
17
104
  - **插件市场三层目录合并与生态检索**:插件管理面板重构支持「官方内置 / 社区扩展 / 本地自定义」三层目录无缝合并展示;新增「全部 / 内置 / 社区 / 自定义」分类标签与关键词实时检索;提供第三方社区插件提交向导与官方生态链接。
18
105
  - **工具详情抽屉面板 (Tool Inspector)**:对话流内工具调用卡片支持打开专有抽屉详情面板,结构化查看输入参数、执行输出、思考过程 (thinking)、报错详情与统计信息,支持一键复制入参和完整输出。
19
106
  - **极简行文字级输入流**:流式输出与输入行视觉优化,支持高响应度文字级输入流呈现。
@@ -1908,7 +1995,10 @@ when?, children?}`,也收 `topbar` / `settings` 这类简写别名);宿主
1908
1995
  - 0.35.1(2026-08-27):编辑重问保留附件(#18)+ 全窗口拖放(#19)。
1909
1996
  - 0.29.0(2026-08-23):全局搜索弹窗(Ctrl+K)+ 消息列表惰性窗口化。
1910
1997
 
1911
- [Unreleased]: https://github.com/xing-shuyin/pi-web-ui/compare/v0.108.0...main
1998
+ [Unreleased]: https://github.com/xing-shuyin/pi-web-ui/compare/v0.113.0...main
1999
+ [0.113.0]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.113.0
2000
+ [0.112.0]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.112.0
2001
+ [0.111.0]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.111.0
1912
2002
  [0.108.0]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.108.0
1913
2003
  [0.109.0]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.109.0
1914
2004
  [0.103.3]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.103.3
@@ -259,10 +259,17 @@ if [ -s "$TMP_DIR/checksums.txt" ]; then
259
259
  fi
260
260
  echo "✅ SHA256 校验通过"
261
261
  else
262
- echo "⚠ 未在官方 checksums 中找到 \${TAR_NAME},跳过校验"
262
+ # fail-closed:这是 root 权限安装到 /usr/local/bin 的脚本——「找不到条目」
263
+ # 同样可能是 checksums 被污染/降级,与本地 frpc 安装路径同口径直接中止,
264
+ # 不给「阻断 checksums 请求即降级为无校验 root 安装」留面。
265
+ echo "❌ 未在官方 checksums 中找到 \${TAR_NAME},无法校验,已中止安装" >&2
266
+ rm -rf "$TMP_DIR"
267
+ exit 1
263
268
  fi
264
269
  else
265
- echo "⚠ 未获取到官方 checksums 文件,跳过校验"
270
+ echo "❌ 未获取到官方 checksums 文件,无法校验,已中止安装(请检查网络后重试)" >&2
271
+ rm -rf "$TMP_DIR"
272
+ exit 1
266
273
  fi
267
274
 
268
275
  echo "📂 解压并安装到 /usr/local/bin/frps..."
package/bin/pi-web-ui.mjs CHANGED
@@ -34,6 +34,7 @@ import {
34
34
  restoreBackup as restorePluginBackup,
35
35
  checkPluginUpdates,
36
36
  resolveRemoteSha,
37
+ compareVersions,
37
38
  } from "../dist/server/plugin-updater.js";
38
39
  import {
39
40
  chmodSync,
@@ -279,6 +280,7 @@ function parseFlags(argv) {
279
280
  dir: undefined,
280
281
  template: undefined,
281
282
  withTest: false,
283
+ remote: false,
282
284
  help: false,
283
285
  };
284
286
  const positionals = [];
@@ -353,6 +355,9 @@ function parseFlags(argv) {
353
355
  case "--with-test":
354
356
  opts.withTest = true;
355
357
  break;
358
+ case "--remote":
359
+ opts.remote = true;
360
+ break;
356
361
  case "--help":
357
362
  case "-h":
358
363
  opts.help = true;
@@ -1291,7 +1296,18 @@ function serviceEnv(port, cwd, dataDir, engine, host, agentDir, service = {}) {
1291
1296
  }
1292
1297
  // Interactive Windows tasks inherit the user's PATH; only systemd/launchd
1293
1298
  // run with a minimal environment that needs an explicit PATH.
1294
- if (!isWin) env.PATH = process.env.PATH ?? "/usr/local/bin:/usr/bin:/bin";
1299
+ if (!isWin) {
1300
+ const defaultPath =
1301
+ process.platform === "darwin"
1302
+ ? "/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
1303
+ : "/usr/local/bin:/usr/bin:/bin";
1304
+ const currentPath = process.env.PATH ?? defaultPath;
1305
+ if (process.platform === "darwin" && !currentPath.includes("/opt/homebrew/bin")) {
1306
+ env.PATH = `/opt/homebrew/bin:/usr/local/bin:${currentPath}`;
1307
+ } else {
1308
+ env.PATH = currentPath;
1309
+ }
1310
+ }
1295
1311
  // Same for the locale: launchd/systemd drop LANG/LC_ALL, and a C-locale
1296
1312
  // shell garbles multibyte input in the terminal (UTF-8 continuation
1297
1313
  // bytes 0x80–0x9F rendered as C1 control chars). Bake the installing
@@ -1877,6 +1893,7 @@ const PLUGIN_HELP = ZH
1877
1893
  --name <id> 插件目录名/id(默认取仓库名或 manifest.id,仅限字母数字-_)
1878
1894
  --data-dir <dir> 数据目录(默认 ~/.pi-web 或 $PI_WEB_DATA_DIR)
1879
1895
  --force 目标目录已存在时覆盖(覆盖前自动备份旧版本)
1896
+ --remote 强制从远端拉取最新代码(跳过本地随包内置插件快速路径)
1880
1897
  --build 强制源码构建:在隔离临时目录里按插件声明安装构建依赖并编译
1881
1898
  (manifest.build 或 package.json 的 scripts.build),
1882
1899
  成功且产物齐全后才替换目标目录,失败不留半装状态
@@ -1921,6 +1938,7 @@ Source formats (choose one):
1921
1938
  --name <id> plugin directory name/id (default: repo name or manifest.id; alphanumeric -_ only)
1922
1939
  --data-dir <dir> data directory (default ~/.pi-web or $PI_WEB_DATA_DIR)
1923
1940
  --force overwrite if target directory exists (auto-backup before overwrite)
1941
+ --remote force pulling from remote (skip local bundled builtin fast path)
1924
1942
  --build force source build: install build deps and compile in an isolated temp directory
1925
1943
  (manifest.build or package.json scripts.build),
1926
1944
  replaces target only on success with complete artifacts; no partial state on failure
@@ -1971,10 +1989,34 @@ function parsePluginSource(rawSpec) {
1971
1989
  if (url) [, spec] = url;
1972
1990
  }
1973
1991
  const segs = spec.split("/").filter(Boolean);
1974
- if (segs.length < 2)
1992
+ if (segs.length < 2) {
1993
+ // 单段名称(如 browser-use):若本地随包官方插件或 catalog 存在该 id,自动补齐为官方插件源
1994
+ if (segs.length === 1 && PLUGIN_ID_RE.test(segs[0])) {
1995
+ const id = segs[0];
1996
+ const pkgRoot = resolve(BIN_DIR, "..");
1997
+ const catalogPath = join(pkgRoot, "plugins", "catalog.json");
1998
+ const pluginDir = join(pkgRoot, "plugins", id);
1999
+ let isOfficial = existsSync(join(pluginDir, "manifest.json"));
2000
+ if (!isOfficial && existsSync(catalogPath)) {
2001
+ try {
2002
+ const cat = JSON.parse(readFileSync(catalogPath, "utf8"));
2003
+ if (Array.isArray(cat) && cat.some((e) => e?.id === id)) isOfficial = true;
2004
+ } catch {}
2005
+ }
2006
+ if (isOfficial) {
2007
+ return {
2008
+ owner: "xing-shuyin",
2009
+ repo: "pi-web-ui",
2010
+ ref,
2011
+ subpath: `plugins/${id}`,
2012
+ cloneUrl: "https://github.com/xing-shuyin/pi-web-ui.git",
2013
+ };
2014
+ }
2015
+ }
1975
2016
  fail(
1976
2017
  ZH ? `无法识别的插件源 "${rawSpec}"\n${PLUGIN_HELP}` : `Unrecognized plugin source "${rawSpec}"\n${PLUGIN_HELP}`,
1977
2018
  );
2019
+ }
1978
2020
  for (const s of segs) {
1979
2021
  if (s === "." || s === "..")
1980
2022
  fail(
@@ -2014,28 +2056,172 @@ function cleanStalePluginTmpDirs() {
2014
2056
  } catch {}
2015
2057
  }
2016
2058
 
2017
- /** 把仓库拉到 tmpDir 并返回检出根目录。优先 git clone --depth 1,失败回退 codeload tarball + 系统 tar。 */
2018
- async function acquireRepo(src, tmpDir) {
2059
+ /**
2060
+ * 尝试定位随包自带的内置官方插件目录。
2061
+ * 命中条件:
2062
+ * 1. 未开启强制远端拉取标志(opts.remote / PI_WEB_PLUGIN_FORCE_REMOTE);
2063
+ * 2. 未显式指定非主干 git ref(除 main/master/HEAD 之外的 ref 说明用户想试特定提交);
2064
+ * 3. 属于官方仓库(xing-shuyin/pi-web-ui)的 plugins/<id> 子路径,且随包目录存在合法 manifest.json。
2065
+ */
2066
+ function resolveLocalBuiltinPluginDir(rawSpec, src, opts = {}) {
2067
+ if (opts.remote === true || process.env.PI_WEB_PLUGIN_FORCE_REMOTE === "1") return null;
2068
+ if (src?.ref && src.ref !== "main" && src.ref !== "master" && src.ref !== "HEAD") return null;
2069
+
2070
+ const pkgRoot = resolve(BIN_DIR, "..");
2071
+ let pluginSubdir = null;
2072
+
2073
+ if (src?.owner === "xing-shuyin" && src?.repo === "pi-web-ui" && src?.subpath) {
2074
+ pluginSubdir = src.subpath.startsWith("plugins/") ? src.subpath.slice("plugins/".length) : src.subpath;
2075
+ } else if (!src && typeof rawSpec === "string" && !rawSpec.includes("/") && PLUGIN_ID_RE.test(rawSpec.trim())) {
2076
+ pluginSubdir = rawSpec.trim();
2077
+ }
2078
+
2079
+ if (!pluginSubdir) return null;
2080
+ const localDir = join(pkgRoot, "plugins", pluginSubdir);
2081
+ if (existsSync(join(localDir, "manifest.json"))) {
2082
+ return localDir;
2083
+ }
2084
+ return null;
2085
+ }
2086
+
2087
+ /**
2088
+ * 把仓库拉到 tmpDir 并返回检出根目录。
2089
+ * 优化策略:
2090
+ * 1. 共享缓存复用:同一批量操作/同源仓库共享检出,增量 sparse-checkout add,杜绝反复 clone;
2091
+ * 2. 稀疏拉取(Sparse Checkout + Blobless filter):只拉取元数据与目标子目录,免除全量下载数十兆整仓;
2092
+ * 3. 健壮降级:稀疏失败平滑降级常规 shallow clone,再失败回退 tarball 直连。
2093
+ */
2094
+ async function acquireRepo(src, tmpDir, opts = {}) {
2095
+ const sharedCache = opts.sharedCache;
2096
+ const cacheKey = sharedCache ? `${src.cloneUrl}#${src.ref || "HEAD"}` : null;
2097
+ const normalizedSubpath = src.subpath ? src.subpath.split(/[\\/]/).filter(Boolean).join("/") : null;
2098
+
2099
+ // 1. 尝试从共享缓存中复用已有检出
2100
+ if (sharedCache && cacheKey && sharedCache.has(cacheKey)) {
2101
+ const cached = sharedCache.get(cacheKey);
2102
+ if (existsSync(cached.dir)) {
2103
+ if (!normalizedSubpath || (cached.subpaths && cached.subpaths.has(normalizedSubpath))) {
2104
+ console.log(
2105
+ ZH
2106
+ ? `· 复用已拉取仓库 ${src.cloneUrl}${normalizedSubpath ? ` (${normalizedSubpath})` : ""}`
2107
+ : `· Reusing cached repo ${src.cloneUrl}${normalizedSubpath ? ` (${normalizedSubpath})` : ""}`,
2108
+ );
2109
+ return cached.dir;
2110
+ }
2111
+ if (cached.isSparse && normalizedSubpath) {
2112
+ console.log(
2113
+ ZH
2114
+ ? `· 复用已拉取仓库,增量检出 ${normalizedSubpath}…`
2115
+ : `· Reusing cached repo, incrementally checking out ${normalizedSubpath}…`,
2116
+ );
2117
+ const addRes = spawnSync("git", ["sparse-checkout", "add", normalizedSubpath], {
2118
+ cwd: cached.dir,
2119
+ stdio: "inherit",
2120
+ env: { ...process.env, GIT_TERMINAL_PROMPT: "0", GCM_INTERACTIVE: "never" },
2121
+ timeout: Number(process.env.PI_WEB_GIT_TIMEOUT_MS) || 45_000,
2122
+ });
2123
+ if (addRes.status === 0) {
2124
+ cached.subpaths.add(normalizedSubpath);
2125
+ return cached.dir;
2126
+ }
2127
+ }
2128
+ }
2129
+ }
2130
+
2019
2131
  const dst = join(tmpDir, "src");
2020
2132
  const hasGit = spawnSync("git", ["--version"], { stdio: "ignore", timeout: 10_000 }).status === 0;
2021
2133
  if (hasGit) {
2022
2134
  const gitTimeout = Number(process.env.PI_WEB_GIT_TIMEOUT_MS) || 45_000;
2135
+ const gitEnv = { ...process.env, GIT_TERMINAL_PROMPT: "0", GCM_INTERACTIVE: "never" };
2136
+
2137
+ // 2. 稀疏拉取:当指定了 subpath 时,优先尝试 --filter=blob:none --sparse
2138
+ if (normalizedSubpath) {
2139
+ const sparseArgs = [
2140
+ "-c",
2141
+ "connect.timeout=15",
2142
+ "clone",
2143
+ "--depth",
2144
+ "1",
2145
+ "--filter=blob:none",
2146
+ "--sparse",
2147
+ "--no-checkout",
2148
+ ];
2149
+ if (src.ref) sparseArgs.push("--branch", src.ref);
2150
+ sparseArgs.push(src.cloneUrl, dst);
2151
+ console.log(
2152
+ `· git clone --depth 1 --filter=blob:none --sparse ${src.cloneUrl}${src.ref ? ` (${src.ref})` : ""} [${normalizedSubpath}]`,
2153
+ );
2154
+ const cloneRes = spawnSync("git", sparseArgs, {
2155
+ stdio: "inherit",
2156
+ env: gitEnv,
2157
+ timeout: gitTimeout,
2158
+ });
2159
+ if (cloneRes.status === 0 && existsSync(dst)) {
2160
+ const setRes = spawnSync("git", ["sparse-checkout", "set", normalizedSubpath], {
2161
+ cwd: dst,
2162
+ stdio: "inherit",
2163
+ env: gitEnv,
2164
+ timeout: gitTimeout,
2165
+ });
2166
+ if (setRes.status === 0) {
2167
+ const coRes = spawnSync("git", ["checkout"], {
2168
+ cwd: dst,
2169
+ stdio: "inherit",
2170
+ env: gitEnv,
2171
+ timeout: gitTimeout,
2172
+ });
2173
+ if (coRes.status === 0 && existsSync(dst)) {
2174
+ if (sharedCache && cacheKey) {
2175
+ sharedCache.set(cacheKey, {
2176
+ dir: dst,
2177
+ tmpDir,
2178
+ isSparse: true,
2179
+ subpaths: new Set([normalizedSubpath]),
2180
+ });
2181
+ }
2182
+ return dst;
2183
+ }
2184
+ }
2185
+ }
2186
+ // 稀疏拉取失败,清理已产生的残骸,准备降级
2187
+ if (existsSync(dst)) {
2188
+ try {
2189
+ rmSync(dst, { recursive: true, force: true });
2190
+ } catch {}
2191
+ }
2192
+ console.log(
2193
+ ZH ? "· 稀疏拉取不可用,降级为常规 git clone…" : "· Sparse checkout failed, falling back to regular git clone…",
2194
+ );
2195
+ }
2196
+
2197
+ // 3. 常规 shallow clone(未指定 subpath 或稀疏拉取失败时的降级通路)
2023
2198
  const args = ["-c", "connect.timeout=15", "clone", "--depth", "1", "--single-branch"];
2024
2199
  if (src.ref) args.push("--branch", src.ref);
2025
2200
  args.push(src.cloneUrl, dst);
2026
2201
  console.log(`· git clone --depth 1 ${src.cloneUrl}${src.ref ? ` (${src.ref})` : ""}`);
2027
2202
  const res = spawnSync("git", args, {
2028
2203
  stdio: "inherit",
2029
- env: { ...process.env, GIT_TERMINAL_PROMPT: "0", GCM_INTERACTIVE: "never" },
2204
+ env: gitEnv,
2030
2205
  timeout: gitTimeout,
2031
2206
  });
2032
- if (res.status === 0 && existsSync(dst)) return dst;
2207
+ if (res.status === 0 && existsSync(dst)) {
2208
+ if (sharedCache && cacheKey) {
2209
+ sharedCache.set(cacheKey, {
2210
+ dir: dst,
2211
+ tmpDir,
2212
+ isSparse: false,
2213
+ subpaths: normalizedSubpath ? new Set([normalizedSubpath]) : new Set(),
2214
+ });
2215
+ }
2216
+ return dst;
2217
+ }
2033
2218
  console.log(
2034
2219
  ZH
2035
2220
  ? "· git clone 失败,回退到 tarball 直连下载…"
2036
2221
  : "· git clone failed, falling back to direct tarball download…",
2037
2222
  );
2038
2223
  }
2224
+
2039
2225
  const url = `https://codeload.github.com/${src.owner}/${src.repo}/tar.gz/${src.ref || "HEAD"}`;
2040
2226
  console.log(ZH ? `· 下载 ${url}` : `· Downloading ${url}`);
2041
2227
  // 注意:这里不用 fail()/process.exit —— async 上下文里还有未关闭的 socket 时
@@ -2108,9 +2294,9 @@ function findManifestDirs(root) {
2108
2294
  function locatePluginRoot(checkout, subpath, repoLabel) {
2109
2295
  if (subpath) {
2110
2296
  const dir = join(checkout, ...subpath.split("/"));
2111
- if (!existsSync(join(dir, "manifest.json")))
2112
- fail(ZH ? `子目录 "${subpath}" 里没有 manifest.json` : `Subdirectory "${subpath}" has no manifest.json`);
2113
- return dir;
2297
+ if (existsSync(join(dir, "manifest.json"))) return dir;
2298
+ if (existsSync(join(checkout, "manifest.json"))) return checkout;
2299
+ fail(ZH ? `子目录 "${subpath}" 里没有 manifest.json` : `Subdirectory "${subpath}" has no manifest.json`);
2114
2300
  }
2115
2301
  if (existsSync(join(checkout, "manifest.json"))) return checkout;
2116
2302
  const hits = findManifestDirs(checkout);
@@ -2282,19 +2468,86 @@ async function confirmSourceBuild(plan) {
2282
2468
  * 覆盖(备份+保留 config.json)→ 落盘 → 记录来源/sha。
2283
2469
  * 失败抛 Error(目录模式逐条 try/catch 继续下一条,单源模式由调用方转 fail)。
2284
2470
  */
2285
- async function installOnePlugin({ rawSpec, name, force, build, noBuild, dataDir, isCatalog = false }) {
2471
+ async function installOnePlugin({
2472
+ rawSpec,
2473
+ name,
2474
+ force,
2475
+ build,
2476
+ noBuild,
2477
+ dataDir,
2478
+ isCatalog = false,
2479
+ sharedCache = null,
2480
+ remote = false,
2481
+ }) {
2286
2482
  cleanStalePluginTmpDirs();
2287
2483
  const pluginsDir = join(dataDir, "plugins");
2288
- const localCandidate = resolve(rawSpec.replace(/^file:\/\//, ""));
2484
+ let localCandidate = rawSpec;
2485
+ if (/^file:\/\//i.test(rawSpec)) {
2486
+ try {
2487
+ localCandidate = fileURLToPath(rawSpec);
2488
+ } catch {
2489
+ localCandidate = rawSpec.replace(/^file:\/\//i, "");
2490
+ }
2491
+ }
2492
+ localCandidate = resolve(localCandidate);
2289
2493
  const isLocal = existsSync(localCandidate);
2290
2494
  const src = isLocal ? null : parsePluginSource(rawSpec);
2495
+
2496
+ // 随包内置插件快速路径:若随包已自带官方插件且满足版本条件,优先走本地快速通路
2497
+ const localBuiltinDir = isLocal ? null : resolveLocalBuiltinPluginDir(rawSpec, src, { remote });
2498
+ let fastPathCandidate = null;
2499
+ if (localBuiltinDir) {
2500
+ const sourceName = src?.subpath ? src.subpath.split("/").pop() : src?.repo;
2501
+ const fallbackId =
2502
+ String(name ?? sourceName)
2503
+ .replace(/[^A-Za-z0-9_-]/g, "-")
2504
+ .replace(/^-+|-+$/g, "") || "plugin";
2505
+ const id = name ?? fallbackId;
2506
+ const target = join(pluginsDir, id);
2507
+ if (!existsSync(target)) {
2508
+ // 未安装:全新安装直接采用本地随包
2509
+ fastPathCandidate = localBuiltinDir;
2510
+ } else if (force) {
2511
+ // 覆盖更新:对比随包版本与已装版本
2512
+ try {
2513
+ const tgtM = JSON.parse(readFileSync(join(target, "manifest.json"), "utf8"));
2514
+ const srcM = JSON.parse(readFileSync(join(localBuiltinDir, "manifest.json"), "utf8"));
2515
+ if (srcM?.version && tgtM?.version && compareVersions(srcM.version, tgtM.version) > 0) {
2516
+ // 随包版本比已装版本更新(刚升级了主程序),优先直接使用本地随包
2517
+ fastPathCandidate = localBuiltinDir;
2518
+ }
2519
+ } catch {}
2520
+ }
2521
+ }
2522
+
2291
2523
  const tmp = mkdtempSync(join(tmpdir(), "pi-web-ui-plugin-"));
2292
2524
  try {
2293
2525
  let checkout;
2294
- try {
2295
- checkout = isLocal ? localCandidate : await acquireRepo(src, tmp);
2296
- } catch (err) {
2297
- throw new Error(`${err?.message ?? err}`);
2526
+ if (isLocal) {
2527
+ checkout = localCandidate;
2528
+ } else if (fastPathCandidate) {
2529
+ checkout = fastPathCandidate;
2530
+ console.log(
2531
+ ZH
2532
+ ? `· 优先使用本地随包内置插件: ${relative(resolve(BIN_DIR, ".."), checkout).replace(/\\/g, "/")}`
2533
+ : `· Using local bundled plugin: ${relative(resolve(BIN_DIR, ".."), checkout).replace(/\\/g, "/")}`,
2534
+ );
2535
+ } else {
2536
+ try {
2537
+ checkout = await acquireRepo(src, tmp, { sharedCache });
2538
+ } catch (err) {
2539
+ // 若远端拉取失败,且属于官方插件,优雅回退到本地随包(离线与断网容错保护)
2540
+ if (localBuiltinDir && existsSync(join(localBuiltinDir, "manifest.json"))) {
2541
+ console.warn(
2542
+ ZH
2543
+ ? `⚠ 远端拉取失败(${err?.message ?? err}),回退到本地随包内置插件…`
2544
+ : `⚠ Remote fetch failed (${err?.message ?? err}), falling back to bundled local plugin…`,
2545
+ );
2546
+ checkout = localBuiltinDir;
2547
+ } else {
2548
+ throw new Error(`${err?.message ?? err}`);
2549
+ }
2550
+ }
2298
2551
  }
2299
2552
  const repoLabel = isLocal ? localCandidate : `${src.owner}/${src.repo}`;
2300
2553
  const pluginRoot = locatePluginRoot(checkout, src?.subpath, repoLabel);
@@ -2445,10 +2698,22 @@ async function installOnePlugin({ rawSpec, name, force, build, noBuild, dataDir,
2445
2698
  }
2446
2699
  return { id, target, manifest, buildMode: decision.mode };
2447
2700
  } finally {
2448
- try {
2449
- rmSync(tmp, { recursive: true, force: true });
2450
- } catch {
2451
- /* Windows 等平台杀毒/进程占用可能抛 EBUSY,不应翻转已成功的安装 */
2701
+ // 若当前 tmp 正在被 sharedCache 共享复用,不在此清理,留给批量操作统一释放
2702
+ let isCached = false;
2703
+ if (sharedCache) {
2704
+ for (const c of sharedCache.values()) {
2705
+ if (c.tmpDir === tmp) {
2706
+ isCached = true;
2707
+ break;
2708
+ }
2709
+ }
2710
+ }
2711
+ if (!isCached) {
2712
+ try {
2713
+ rmSync(tmp, { recursive: true, force: true });
2714
+ } catch {
2715
+ /* Windows 等平台杀毒/进程占用可能抛 EBUSY,不应翻转已成功的安装 */
2716
+ }
2452
2717
  }
2453
2718
  }
2454
2719
  }
@@ -2637,33 +2902,47 @@ async function installCatalogCmd(opts) {
2637
2902
  let okCount = 0;
2638
2903
  let failCount = 0;
2639
2904
  let skipCount = 0;
2640
- for (const e of entries) {
2641
- if (existsSync(join(pluginsDir, e.id)) && !opts.force) {
2642
- console.log(
2643
- ZH
2644
- ? `· 跳过 ${e.id}(已安装,加 --force 更新)`
2645
- : `· Skipping ${e.id} (already installed, use --force to update)`,
2646
- );
2647
- skipCount++;
2648
- continue;
2905
+ const sharedCache = new Map();
2906
+ try {
2907
+ for (const e of entries) {
2908
+ if (existsSync(join(pluginsDir, e.id)) && !opts.force) {
2909
+ console.log(
2910
+ ZH
2911
+ ? `· 跳过 ${e.id}(已安装,加 --force 更新)`
2912
+ : `· Skipping ${e.id} (already installed, use --force to update)`,
2913
+ );
2914
+ skipCount++;
2915
+ continue;
2916
+ }
2917
+ try {
2918
+ await installOnePlugin({
2919
+ rawSpec: e.source,
2920
+ name: e.id,
2921
+ force: true,
2922
+ build: opts.build === true,
2923
+ noBuild: opts.noBuild === true,
2924
+ dataDir,
2925
+ isCatalog: true,
2926
+ sharedCache,
2927
+ remote: opts.remote === true,
2928
+ });
2929
+ console.log(ZH ? `✔ ${e.id} 安装成功` : `✔ ${e.id} installed`);
2930
+ okCount++;
2931
+ } catch (err) {
2932
+ console.error(
2933
+ ZH ? `✖ ${e.id} 安装失败:${err?.message ?? err}` : `✖ ${e.id} failed to install: ${err?.message ?? err}`,
2934
+ );
2935
+ failCount++;
2936
+ }
2649
2937
  }
2650
- try {
2651
- await installOnePlugin({
2652
- rawSpec: e.source,
2653
- name: e.id,
2654
- force: true,
2655
- build: opts.build === true,
2656
- noBuild: opts.noBuild === true,
2657
- dataDir,
2658
- isCatalog: true,
2659
- });
2660
- console.log(ZH ? `✔ ${e.id} 安装成功` : `✔ ${e.id} installed`);
2661
- okCount++;
2662
- } catch (err) {
2663
- console.error(
2664
- ZH ? `✖ ${e.id} 安装失败:${err?.message ?? err}` : `✖ ${e.id} failed to install: ${err?.message ?? err}`,
2665
- );
2666
- failCount++;
2938
+ } finally {
2939
+ // 统一清理同批任务复用的共享缓存检出目录
2940
+ for (const entry of sharedCache.values()) {
2941
+ if (entry.tmpDir) {
2942
+ try {
2943
+ rmSync(entry.tmpDir, { recursive: true, force: true });
2944
+ } catch {}
2945
+ }
2667
2946
  }
2668
2947
  }
2669
2948
  console.log(
@@ -3346,6 +3625,7 @@ async function pluginInstallCmd(argv) {
3346
3625
  build: opts.build === true,
3347
3626
  noBuild: opts.noBuild === true,
3348
3627
  dataDir: pluginDataDir(opts),
3628
+ remote: opts.remote === true,
3349
3629
  });
3350
3630
  console.log(
3351
3631
  ZH