From 2cadd2612b031d5323361c157871f186219ab134 Mon Sep 17 00:00:00 2001 From: Yao Jingxi <23722032@bjtu.edu.cn> Date: Mon, 23 Nov 2026 08:28:54 +0800 Subject: [PATCH 1/2] =?UTF-8?q?docs(plugins):=20=E5=86=99=E6=98=8E?= =?UTF-8?q?=E5=90=8E=E7=AB=AF=E5=86=B3=E5=AE=9A=E5=90=AF=E5=8A=A8=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=E7=9A=84=E8=AF=AD=E8=A8=80=E6=9C=8D=E5=8A=A1=E5=99=A8?= =?UTF-8?q?=E5=9C=A8=E7=AB=8B=E5=8D=B3=E7=94=9F=E6=95=88=E7=9A=84=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E5=8F=98=E5=8C=96=E6=97=B6=E9=87=8D=E6=96=B0=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E5=90=AF=E5=8A=A8=E5=87=BD=E6=95=B0=E5=8F=96=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shared/plugins/contract/v1/README.md | 16 +++++++++++++++- shared/plugins/reference/domains/languages.md | 6 ++++-- shared/plugins/reference/domains/settings.md | 4 ++-- shared/plugins/reference/protocol-changelog.md | 1 + 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/shared/plugins/contract/v1/README.md b/shared/plugins/contract/v1/README.md index 834aa09d..d260eede 100644 --- a/shared/plugins/contract/v1/README.md +++ b/shared/plugins/contract/v1/README.md @@ -406,7 +406,11 @@ Core expands it with the merged settings requests by section path from it, and sends `workspace/didChangeConfiguration` after `initialized`. Hosts send a new value with `lsp.updateWorkspaceConfiguration` when an `immediate` setting -changes; the running server receives it without a restart. +changes; the running server receives it without a restart. The value +replaces the whole configuration. For a server whose +[backend-resolved launch](#backend-resolved-launch) answer carried its own +`workspaceConfiguration`, the new value comes from the launch function +again, not from the declaration. #### Indexing exclusions @@ -1282,6 +1286,16 @@ declaring one: starts it like any other. A server that is not launched by the backend is `plugin.launch.notBackend`, so a host never runs an answer it did not ask for. +- When an `immediate` setting changes while the server runs and its answer + carried `workspaceConfiguration`, the host calls `function` again with the + running start's directories, the workspace `context` and the new + `settings`, decodes the answer the same way, and sends only the plan's + `workspaceConfiguration` with `lsp.updateWorkspaceConfiguration`. The rest + of the answer waits for the next start. A function whose answer carries + `workspaceConfiguration` is therefore called more than once per start; one + that installs or downloads does so only when something is missing. When the + answer has no `workspaceConfiguration`, the host sends the declaration's + expansion and does not call the function again. `resolveParams`: diff --git a/shared/plugins/reference/domains/languages.md b/shared/plugins/reference/domains/languages.md index c0baac61..89adcdd9 100644 --- a/shared/plugins/reference/domains/languages.md +++ b/shared/plugins/reference/domains/languages.md @@ -89,7 +89,7 @@ #### 工作区配置(`workspaceConfiguration`) -语言服务器可以声明 `workspaceConfiguration`:一个对象,其中的字符串叶子可以是 `${setting:}`。Core 用合并后的设置展开它,按节路径回答服务器的 `workspace/configuration` 请求,并在 `initialized` 之后发送 `workspace/didChangeConfiguration`。`immediate` 设置变化时,宿主通过 `lsp.updateWorkspaceConfiguration` 推送新值,运行中的服务器无需重启即可收到。 +语言服务器可以声明 `workspaceConfiguration`:一个对象,其中的字符串叶子可以是 `${setting:}`。Core 用合并后的设置展开它,按节路径回答服务器的 `workspace/configuration` 请求,并在 `initialized` 之后发送 `workspace/didChangeConfiguration`。`immediate` 设置变化时,宿主通过 `lsp.updateWorkspaceConfiguration` 推送新值,运行中的服务器无需重启即可收到。新值整体替换原来的配置;[由后端决定启动方式](#后端决定启动方式launchkind-backend)、且应答自带 `workspaceConfiguration` 的服务器,新值由启动函数重新给出,不用声明的展开。 #### 索引排除(`indexingExclusions`) @@ -126,6 +126,7 @@ | 调用 | 宿主建好四个目录,必要时启动插件后端,用 `lithe/function/invoke` 调用 `function`,参数是 `resolveParams`(`serverID`、`platform`、四个目录、`settings`)和工作区 `context`。调用失败、超时,或工作区代次已变,这次启动就不产生进程 | | 应答 | `executable`(`{kind: "packaged", path}` 是包内只读文件;`{kind: "tool", tool}` 是插件自己定义的工具,由宿主按工具解析)、`arguments`、`environment`、`initializationOptions`、`workspaceConfiguration`、`gates`(最多 8 个)、`writablePaths`(最多 32 个,都在四个目录之内);不认识的字段会被拒绝 | | 解码 | 宿主把 `{manifest, languageID, request, result}` 交给 `plugins.languageServers.decodeLaunch`,得到普通的启动计划(`launch` 为 `packaged` 或 `tool`),`sessionPolicy` 另带应答的 `gates` | +| 设置立即生效 | 服务器运行中 `immediate` 设置变化、且应答自带 `workspaceConfiguration` 时,宿主用这次启动的四个目录、工作区 `context` 和新的 `settings` 再调用一次 `function`,同样解码,只把计划里的 `workspaceConfiguration` 通过 `lsp.updateWorkspaceConfiguration` 发出;应答的其余部分等下次启动才生效。所以这类函数每次启动可能被调用多次,安装或下载只应在缺少时进行。应答不带 `workspaceConfiguration` 时,宿主发送声明的展开,不再调用函数 | | 拒绝码 | `plugin.launch.invalidResult`、`plugin.launch.outsidePackage`、`plugin.launch.undeclaredTool`、`plugin.launch.unwritablePath`、`plugin.launch.invalidRequest`、`plugin.launch.unavailable`、`plugin.launch.notBackend`、`plugin.launch.untrustedWorkspace`(工作区未信任;用户在两步之间撤销信任时,第二步同样拒绝) | ### 插件自有会话(`languageServers` 的会话字段) @@ -372,7 +373,7 @@ A plugin that declares a language owns its process-backed features: the host sto #### Workspace configuration -A language server may declare `workspaceConfiguration`, an object whose string leaves may be `${setting:}` templates. Core expands it with the merged settings, answers the server's `workspace/configuration` requests by section path, and sends `workspace/didChangeConfiguration` after `initialized`. When an `immediate` setting changes, the host sends the new value with `lsp.updateWorkspaceConfiguration`, and the running server receives it without a restart. +A language server may declare `workspaceConfiguration`, an object whose string leaves may be `${setting:}` templates. Core expands it with the merged settings, answers the server's `workspace/configuration` requests by section path, and sends `workspace/didChangeConfiguration` after `initialized`. When an `immediate` setting changes, the host sends the new value with `lsp.updateWorkspaceConfiguration`, and the running server receives it without a restart. The value replaces the whole configuration. For a [backend-resolved launch](#backend-resolved-launch-launchkind-backend) whose answer carried its own `workspaceConfiguration`, the launch function gives the new value again, not the declaration. #### Indexing exclusions (`indexingExclusions`) @@ -409,6 +410,7 @@ When a server's command line depends on what is known only at start (a version i | Call | The host creates the four directories, starts the plugin backend if needed, and calls `function` through `lithe/function/invoke` with `resolveParams` (`serverID`, `platform`, the four directories, `settings`) and the workspace `context`. A failed or timed-out call, or a changed workspace generation, ends the start without a process | | Answer | `executable` (`{kind: "packaged", path}` is a read-only file in the package; `{kind: "tool", tool}` names a tool definition of the plugin, which the host resolves), `arguments`, `environment`, `initializationOptions`, `workspaceConfiguration`, `gates` (at most 8), and `writablePaths` (at most 32, all inside the four directories). An unknown field is refused | | Decoding | The host passes `{manifest, languageID, request, result}` to `plugins.languageServers.decodeLaunch`, which returns an ordinary launch plan (`launch` is `packaged` or `tool`); its `sessionPolicy` also carries the answer's `gates` | +| Immediate settings | When an `immediate` setting changes while the server runs and its answer carried `workspaceConfiguration`, the host calls `function` again with the running start's four directories, the workspace `context` and the new `settings`, decodes the answer the same way, and sends only the plan's `workspaceConfiguration` with `lsp.updateWorkspaceConfiguration`; the rest of the answer waits for the next start. Such a function may therefore be called more than once per start, and should install or download only what is missing. When the answer has no `workspaceConfiguration`, the host sends the declaration's expansion and does not call the function again | | Rejections | `plugin.launch.invalidResult`, `plugin.launch.outsidePackage`, `plugin.launch.undeclaredTool`, `plugin.launch.unwritablePath`, `plugin.launch.invalidRequest`, `plugin.launch.unavailable`, `plugin.launch.notBackend`, `plugin.launch.untrustedWorkspace` (the workspace is not trusted; the second step refuses too when the user revoked trust between the steps) | ### Plugin-owned sessions diff --git a/shared/plugins/reference/domains/settings.md b/shared/plugins/reference/domains/settings.md index 0c745b6f..198e744d 100644 --- a/shared/plugins/reference/domains/settings.md +++ b/shared/plugins/reference/domains/settings.md @@ -69,7 +69,7 @@ 由 Core 在校验时检查的放置和使用规则: -- `immediate` 设置只能出现在语言服务器的 `workspaceConfiguration` 里,它从不进入命令行或 `initializationOptions`,所以修改它从不需要新进程。 +- `immediate` 设置只能出现在语言服务器的 `workspaceConfiguration` 里,它从不进入命令行或 `initializationOptions`,所以修改它从不需要新进程。[后端决定启动方式](languages.md#后端决定启动方式launchkind-backend)的服务器,启动函数也会收到 `immediate` 设置;设置变化时,只有函数重新给出的 `workspaceConfiguration` 立即生效。 - `text`、`file`、`directory` 设置只能是一个完整的模板值,或某个 `name=` 参数的值,不能是较长参数的一部分。 ### 设置区域 @@ -222,7 +222,7 @@ A setting may also say where it is shown and when a change takes effect. The hos Placement and use rules that Core checks at validation: -- An `immediate` setting may appear only in a language server's `workspaceConfiguration`. It never reaches a command line or `initializationOptions`, so a change never needs a new process. +- An `immediate` setting may appear only in a language server's `workspaceConfiguration`. It never reaches a command line or `initializationOptions`, so a change never needs a new process. A [backend-resolved launch](languages.md#backend-resolved-launch-launchkind-backend) function receives `immediate` settings too; when one changes, only the `workspaceConfiguration` the function gives again takes effect at once. - A `text`, `file`, or `directory` setting is a whole template value, or the value of one `name=` argument; it is never part of a longer argument. ### Settings regions diff --git a/shared/plugins/reference/protocol-changelog.md b/shared/plugins/reference/protocol-changelog.md index 54629d88..5db54ef9 100644 --- a/shared/plugins/reference/protocol-changelog.md +++ b/shared/plugins/reference/protocol-changelog.md @@ -14,6 +14,7 @@ ## 待合入 +- [#PRNUM](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/PRNUM),[@xiaoyumuxi](https://github.com/xiaoyumuxi),`languageServers` 0 内的说明补充(—):写明后端决定启动方式的语言服务器在 `immediate` 设置变化时的行为。启动应答自带 `workspaceConfiguration` 时,宿主用这次启动的四个目录、工作区 `context` 和新的 `settings` 再调用一次启动函数,同样交给 `plugins.languageServers.decodeLaunch` 解码,只把计划里的 `workspaceConfiguration` 通过 `lsp.updateWorkspaceConfiguration` 发出(整体替换原配置),应答的其余部分等下次启动;应答不带时发送声明的展开,不再调用函数。所以这类启动函数每次启动可能被调用多次,安装或下载只应在缺少时进行。契约 README 的 Workspace configuration 和 Backend-resolved launch 两节、`reference/domains/languages.md` 与 `settings.md` 的中英文随之补充。桌面端实现见 1lck/Lithe-IDEA#2319。Core 代码、能力版本、宿主方法、通知和协议字段都不变。 - [#175](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/175),[@xiaoyumuxi](https://github.com/xiaoyumuxi),`ui` 0 内的补充(API-13、API-23):撤回 #174 新增的 `ui` 1,设置区域 `tool` 行的可选布尔字段 `choose` 改为 `ui` 0 内的补充,清单写 `requires.ui: 0` 即可使用。`capabilities.rs` 和清单 schema 的 `requires.ui` 回到只有 0,能力对照表删去 `ui` 1 一行。`choose` 不是布尔值时 Core 以 `plugin.ui.invalidView` 拒绝整个结果,位置指向 `choose`;旧宿主的 Core 不认识这个字段,同样会拒绝带它的视图,所以插件要等包含本改动的桌面端发布后再写。fixture `ui/view-results.json` 改为两个用例(接受选择器、`choose` 不是布尔值时拒绝),替换原来“`requires.ui` 为 0 时拒绝”的用例。`ui` 1 没有随任何宿主发布过。没有新增能力版本、宿主方法、通知或进程协议字段。 - [#174](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/174),[@xiaoyumuxi](https://github.com/xiaoyumuxi),**`ui` 1**(API-13、API-23):设置区域视图的 `tool` 行新增可选的布尔字段 `choose`,带上后这一行同时是该工具的选择器,像解释器下拉框一样列出自动选择、已发现和已添加的安装(带版本和来源)、添加目录和打开工具链页的入口;选择只改设置窗口的草稿,“应用”提交、“取消”丢弃,行上显示待提交的选择,应用后启动和运行拿到选中的安装。清单 `requires.ui` 为 0 时 Core 以 `plugin.ui.invalidView` 拒绝整个结果,位置指向 `choose`。契约 README 的插件视图一节补充:为某个工作区显示的视图(项目窗口里的工具窗口,或从项目窗口打开的设置页)调用时,带上该窗口的工作区上下文作为 invoke 的 `params.context`,后端可以在 `click` 里用它调用 `run/start` 等需要上下文的宿主方法;没有工作区时不带。fixture `ui/view-results.json` 新增一个用例,Node SDK 的视图节点类型加上 `choose`,Rust 和 Go SDK 的工作区上下文说明随之修正。没有新增宿主方法、通知或进程协议字段。(`ui` 1 已由 #175 撤回,`choose` 改为 `ui` 0 内的补充。) - [#173](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/173),[@xiaoyumuxi](https://github.com/xiaoyumuxi),市场索引 `schemaVersion` 0 内的补充(—):`plugins.marketplace.resolveSource` 的结果新增 `revision: { repository: { owner, name }, ref }`(托管在 GitHub 且不带查询参数的索引才有,否则为 null),输入新增可选的 `commit`,带上后结果多出 `pinned: { commit, indexURL, recommendationsURL }`,即同一批文件在该提交上的地址;`commit` 不是完整的 SHA-1 或 SHA-256 时返回新的拒绝码 `plugin.source.commitInvalid`。`indexURL` 仍是来源身份。宿主借此绕过 raw.githubusercontent.com 对分支地址约 5 分钟的缓存,查询或固定下载失败时退回原地址。fixture `marketplace/source-urls.json` 从 11 个用例增加到 17 个。索引格式、插件清单、宿主方法和能力版本都不变。 From 1adc625e98596a964b05102934de31718515dde8 Mon Sep 17 00:00:00 2001 From: Yao Jingxi <23722032@bjtu.edu.cn> Date: Mon, 23 Nov 2026 08:29:18 +0800 Subject: [PATCH 2/2] =?UTF-8?q?docs(plugins):=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E5=A1=AB=E4=B8=8A=20PR=20=E7=BC=96=E5=8F=B7?= =?UTF-8?q?=20#176?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shared/plugins/reference/protocol-changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/plugins/reference/protocol-changelog.md b/shared/plugins/reference/protocol-changelog.md index 5db54ef9..c9ab575c 100644 --- a/shared/plugins/reference/protocol-changelog.md +++ b/shared/plugins/reference/protocol-changelog.md @@ -14,7 +14,7 @@ ## 待合入 -- [#PRNUM](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/PRNUM),[@xiaoyumuxi](https://github.com/xiaoyumuxi),`languageServers` 0 内的说明补充(—):写明后端决定启动方式的语言服务器在 `immediate` 设置变化时的行为。启动应答自带 `workspaceConfiguration` 时,宿主用这次启动的四个目录、工作区 `context` 和新的 `settings` 再调用一次启动函数,同样交给 `plugins.languageServers.decodeLaunch` 解码,只把计划里的 `workspaceConfiguration` 通过 `lsp.updateWorkspaceConfiguration` 发出(整体替换原配置),应答的其余部分等下次启动;应答不带时发送声明的展开,不再调用函数。所以这类启动函数每次启动可能被调用多次,安装或下载只应在缺少时进行。契约 README 的 Workspace configuration 和 Backend-resolved launch 两节、`reference/domains/languages.md` 与 `settings.md` 的中英文随之补充。桌面端实现见 1lck/Lithe-IDEA#2319。Core 代码、能力版本、宿主方法、通知和协议字段都不变。 +- [#176](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/176),[@xiaoyumuxi](https://github.com/xiaoyumuxi),`languageServers` 0 内的说明补充(—):写明后端决定启动方式的语言服务器在 `immediate` 设置变化时的行为。启动应答自带 `workspaceConfiguration` 时,宿主用这次启动的四个目录、工作区 `context` 和新的 `settings` 再调用一次启动函数,同样交给 `plugins.languageServers.decodeLaunch` 解码,只把计划里的 `workspaceConfiguration` 通过 `lsp.updateWorkspaceConfiguration` 发出(整体替换原配置),应答的其余部分等下次启动;应答不带时发送声明的展开,不再调用函数。所以这类启动函数每次启动可能被调用多次,安装或下载只应在缺少时进行。契约 README 的 Workspace configuration 和 Backend-resolved launch 两节、`reference/domains/languages.md` 与 `settings.md` 的中英文随之补充。桌面端实现见 1lck/Lithe-IDEA#2319。Core 代码、能力版本、宿主方法、通知和协议字段都不变。 - [#175](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/175),[@xiaoyumuxi](https://github.com/xiaoyumuxi),`ui` 0 内的补充(API-13、API-23):撤回 #174 新增的 `ui` 1,设置区域 `tool` 行的可选布尔字段 `choose` 改为 `ui` 0 内的补充,清单写 `requires.ui: 0` 即可使用。`capabilities.rs` 和清单 schema 的 `requires.ui` 回到只有 0,能力对照表删去 `ui` 1 一行。`choose` 不是布尔值时 Core 以 `plugin.ui.invalidView` 拒绝整个结果,位置指向 `choose`;旧宿主的 Core 不认识这个字段,同样会拒绝带它的视图,所以插件要等包含本改动的桌面端发布后再写。fixture `ui/view-results.json` 改为两个用例(接受选择器、`choose` 不是布尔值时拒绝),替换原来“`requires.ui` 为 0 时拒绝”的用例。`ui` 1 没有随任何宿主发布过。没有新增能力版本、宿主方法、通知或进程协议字段。 - [#174](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/174),[@xiaoyumuxi](https://github.com/xiaoyumuxi),**`ui` 1**(API-13、API-23):设置区域视图的 `tool` 行新增可选的布尔字段 `choose`,带上后这一行同时是该工具的选择器,像解释器下拉框一样列出自动选择、已发现和已添加的安装(带版本和来源)、添加目录和打开工具链页的入口;选择只改设置窗口的草稿,“应用”提交、“取消”丢弃,行上显示待提交的选择,应用后启动和运行拿到选中的安装。清单 `requires.ui` 为 0 时 Core 以 `plugin.ui.invalidView` 拒绝整个结果,位置指向 `choose`。契约 README 的插件视图一节补充:为某个工作区显示的视图(项目窗口里的工具窗口,或从项目窗口打开的设置页)调用时,带上该窗口的工作区上下文作为 invoke 的 `params.context`,后端可以在 `click` 里用它调用 `run/start` 等需要上下文的宿主方法;没有工作区时不带。fixture `ui/view-results.json` 新增一个用例,Node SDK 的视图节点类型加上 `choose`,Rust 和 Go SDK 的工作区上下文说明随之修正。没有新增宿主方法、通知或进程协议字段。(`ui` 1 已由 #175 撤回,`choose` 改为 `ui` 0 内的补充。) - [#173](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/173),[@xiaoyumuxi](https://github.com/xiaoyumuxi),市场索引 `schemaVersion` 0 内的补充(—):`plugins.marketplace.resolveSource` 的结果新增 `revision: { repository: { owner, name }, ref }`(托管在 GitHub 且不带查询参数的索引才有,否则为 null),输入新增可选的 `commit`,带上后结果多出 `pinned: { commit, indexURL, recommendationsURL }`,即同一批文件在该提交上的地址;`commit` 不是完整的 SHA-1 或 SHA-256 时返回新的拒绝码 `plugin.source.commitInvalid`。`indexURL` 仍是来源身份。宿主借此绕过 raw.githubusercontent.com 对分支地址约 5 分钟的缓存,查询或固定下载失败时退回原地址。fixture `marketplace/source-urls.json` 从 11 个用例增加到 17 个。索引格式、插件清单、宿主方法和能力版本都不变。