Repository navigation
docs(plugins): align plugin API doc with host runtime - #2021
Conversation
The error model presented its code list as a closed union, so plugin authors could switch exhaustively on it, while the desktop host also throws INVALID_PARAMS, UNAVAILABLE, PLUGIN_UNLOADED and other codes and falls back to PLUGIN_API_FAILED. The workspace.get signature also omitted the remote field the host returns for SSH projects, and the event list left out the net.websocket frames. Describe the open code set, add the remote field, and list the websocket events in both the English and zh-CN documents. Related to vastsa#2000
vastsa
left a comment
There was a problem hiding this comment.
已独立对照 PluginWorkspaceInfo、pluginCallErrorCode、plugin-host-process 错误传递及 deliverSocketEvent。remote 字段、开放的错误码集合与 PLUGIN_API_FAILED 回退、四种定向 websocket 事件均与实现相符,中英文一致,未发现阻塞问题。
最新 main:9eb371e276eb36b06b4ff169013c70156e96dda1;已验证的 GitHub 合并候选:ad9151e5156d402a5a9b73af8062f948f742e03d。diff --check、base ancestry、86 组中英配对、599 个文档页面、agent-policy sync、VitePress 生产构建及 GitHub Docs checks / Head contains latest base 全部通过。仅文档改动,应用 E2E 不适用。
|
Merged. Thanks! Paired English/Chinese changes, every claim anchored to a code location, and the SDK-type discrepancy split into #2022 rather than papered over — exactly the standard #2000 set. Noting that you left the large missing-Chinese blocks (theme variables, |
Related to #2000
P1 第 2 项:
03-plugin-api.md对照PluginHostApi。只改文档,中英文成对。检查的文档
docs/spec/07-plugins/03-plugin-api.mddocs/zh-CN/spec/07-plugins/03-plugin-api.md对照的代码
PluginHostApi(issue 里写的PluginApi实际名为PluginHostApi)apps/desktop/electron/main/plugin-runtime.ts、plugin-host-process.mjs、plugin-websocket.tsplugin-runtime.tsbroadcastEvent、services/plugin-services.ts、bootstrap/app-lifecycle.ts、runtime/sidecar.ts、ipc/session-ipc.ts、index.tspackages/shared/src/types/plugins.tsPluginWorkspaceInfo方法
用 TypeScript 编译器 API 从
PluginHostApi抽出全部 104 个方法,与英文文档中出现的pi.<ns>.<method>逐一比对:两边完全一致,没有文档缺失或多余的方法。随后逐个比对签名代码块,并核对 §4 错误模型、§5 事件列表。发现与修改
PluginApiError.code写成 9 个值的封闭 unionapiError(code: string, …)接受任意字符串;返回插件前用pluginCallErrorCode原样转发,无 code 时为PLUGIN_API_FAILED;实际还会抛INVALID_PARAMS(如 session.import、usage)、UNAVAILABLE(browser)、PLUGIN_UNLOADED(L2260)、CONFLICT(speech)、PROVIDER_ERROR(L1403)、WORKSPACE_CHANGED(L5009)、OPEN_FAILED/REVEAL_FAILED(L5933、L6030)、CONNECT_FAILED(plugin-websocket.ts)pi.workspace.get()签名缺remotePluginWorkspaceInfo有remote?: { path: string; readOnly: true },同一节正文也在描述它net:websocket:${type},类型见 plugin-websocket.ts;§3 net 一节有描述,§5 清单漏了其余已核对、与代码一致:104 个方法名;除上面第 2 条外的签名;§5 中
bus.message、workspace:changed、plugin:settingsChanged、appearance:changed、session:modelChanged、session:turnEnded、session:activated均有对应发送方;未在白名单的 API 抛UNSUPPORTED,与 §8 一致。发现但未在本 PR 处理
pi.projects.list()签名块,属于 P0“中文缺失章节”,不在本 PR 范围。workspace.get类型 只有path/name/remote,缺运行时实际返回的projectId/roots(PluginWorkspaceInfo)。这是 SDK 类型问题,不在文档范围,会单独开 issue。验证
git diff --check通过net” 引用指向现有章节upstream/mainc85251b