From 699bd8b1bcc6ab09d43ab2a97498ecd8834fe86f Mon Sep 17 00:00:00 2001 From: Yao Jingxi <23722032@bjtu.edu.cn> Date: Thu, 19 Nov 2026 15:27:49 +0800 Subject: [PATCH] =?UTF-8?q?docs(plugins):=20=E7=AE=A1=E7=90=86=20JVM=20?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E7=9A=84=E6=8F=92=E4=BB=B6=E4=B9=9F=E4=BC=98?= =?UTF-8?q?=E5=85=88=E7=94=A8=20Rust=20=E6=88=96=20Go=20SDK=EF=BC=9B#113?= =?UTF-8?q?=20=E7=A7=BB=E8=BF=9B=E6=9B=B4=E6=96=B0=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 插件总览的推荐段原来写“插件围绕 JVM 工具(Maven、Gradle、Tomcat)时用 Java SDK”。 改为:管理这些工具的插件同样优先用 Rust 或 Go,后端以进程方式启动它们;只有后端必须在 JVM 里直接调用 Java 库时才用 Java SDK。中英文同步。 - 协议更新记录:已合入的 #113(官方 SDK 新增 Go)从“待合入”移到 2026-11-19 时间线。 --- shared/plugins/README.md | 4 ++-- shared/plugins/reference/protocol-changelog.md | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/shared/plugins/README.md b/shared/plugins/README.md index e2ea50d1..cf1c5821 100644 --- a/shared/plugins/README.md +++ b/shared/plugins/README.md @@ -104,7 +104,7 @@ Schema 只检查 JSON 结构。ID 引用、权限、激活事件、模板变量 只用语言服务器、运行和测试的插件不需要后端。需要构建后端(`buildProviders`)、插件函数,或给插件自己的网页配一个后端进程(`backend`)时,用官方 SDK 写:协议、取消、进程清理和错误处理由 SDK 负责,你只写处理函数。 -**新插件优先用 Rust 或 Go SDK。** 两者把后端编译成每个平台各一份的原生可执行文件,用户机器上不需要 Node.js 或 Java 运行时。插件本来就围绕 JVM 工具(例如 Maven、Gradle、Tomcat)时用 Java SDK。构建后端(`buildProviders`)目前只有 Node.js 和 Java SDK 支持,VCS 后端只有 Node.js SDK 支持,这两类后端照旧用它们。 +**新插件优先用 Rust 或 Go SDK。** 两者把后端编译成每个平台各一份的原生可执行文件,用户机器上不需要 Node.js 或 Java 运行时,常驻的后端也不会多占一份 JVM 的内存和启动时间。插件管理的是 JVM 工具(例如 Maven、Gradle、Tomcat)时也一样:后端用 Rust 或 Go 启动这些工具的进程即可。只有后端必须在 JVM 里直接调用 Java 库时,才用 Java SDK。构建后端(`buildProviders`)目前只有 Node.js 和 Java SDK 支持,VCS 后端只有 Node.js SDK 支持,这两类后端照旧用它们。 | SDK | 版本 | 运行时 | Release | 怎么放进插件 | | --- | --- | --- | --- | --- | @@ -324,7 +324,7 @@ A schema checks only JSON structure. Rules such as ID references, permissions, a A plugin that uses only language servers, run, and test needs no backend. When you need a build backend (`buildProviders`), plugin functions, or a backend process for the plugin's own web page (`backend`), write it with an official SDK: the SDK handles the protocol, cancellation, process cleanup, and errors, and you write only the handlers. -**New plugins should prefer the Rust or Go SDK.** Both compile the backend to one native executable per platform, so users need no Node.js or Java runtime. Use the Java SDK when the plugin is built around JVM tools anyway, such as Maven, Gradle, or Tomcat. Build backends (`buildProviders`) are supported only by the Node.js and Java SDKs today, and VCS backends only by the Node.js SDK, so keep using those for them. +**New plugins should prefer the Rust or Go SDK.** Both compile the backend to one native executable per platform, so users need no Node.js or Java runtime, and a long-running backend does not cost an extra JVM heap and startup. The same holds when the plugin manages JVM tools such as Maven, Gradle, or Tomcat: a Rust or Go backend starts those tools as processes. Use the Java SDK only when the backend must call Java libraries inside the JVM. Build backends (`buildProviders`) are supported only by the Node.js and Java SDKs today, and VCS backends only by the Node.js SDK, so keep using those for them. | SDK | Version | Runtime | Release | How it goes into the plugin | | --- | --- | --- | --- | --- | diff --git a/shared/plugins/reference/protocol-changelog.md b/shared/plugins/reference/protocol-changelog.md index 442ab0e1..c6548410 100644 --- a/shared/plugins/reference/protocol-changelog.md +++ b/shared/plugins/reference/protocol-changelog.md @@ -14,7 +14,7 @@ ## 待合入 -- 官方 SDK 新增 Go(—):Go 插件后端 SDK 放在 `shared/plugins/sdk/go`,模块路径 `github.com/Lithe-IDEA/Lithe-core-rust/shared/plugins/sdk/go`,需要 Go 1.22 或更高版本,只用标准库,按模块标签 `shared/plugins/sdk/go/v<版本>` 发布(还没有推送标签)。它实现函数协议和宿主服务(凭据、工作区、文档与编辑器、预览、浏览器、窗口消息、`functions/providers` 与 `functions/invoke`、原生终端、订阅)、插件视图 `View(id, handler)` 和 `litheKeymapImport` 0,不实现构建和 VCS 提供者。契约 README 的 Official backend SDK 加上 `sdk/go` 一段:在 Unix 上把协议移到 stdout 的副本、stdout 指向 stderr,处理函数 panic 只结束这一次调用。Go 示例后端和 Rust 示例后端跑同一个插件后端场景,`sdk-e2e.mjs` 新增 `plugin_sdk_go`。插件总览、日志指南和各参考页列出 Go SDK,并推荐新插件优先用 Rust 或 Go SDK(构建后端照旧用 Node.js 或 Java SDK,VCS 后端用 Node.js SDK)。没有新增版本号、宿主方法、通知或协议字段。 +目前没有。 ## 按协议查首次出现 @@ -149,6 +149,7 @@ | PR | 修改人 | API 编号 | 协议 / 能力 | 改了什么 | | --- | --- | --- | --- | --- | +| [#113](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/113) | [@xiaoyumuxi](https://github.com/xiaoyumuxi) | — | `pluginAPIVersion` 0 内的说明补充(官方 SDK 新增 Go) | Go 插件后端 SDK 放在 `shared/plugins/sdk/go`,模块路径 `github.com/Lithe-IDEA/Lithe-core-rust/shared/plugins/sdk/go`,需要 Go 1.22 或更高版本,只用标准库,按模块标签 `shared/plugins/sdk/go/v<版本>` 发布(还没有推送标签)。它实现函数协议和宿主服务(凭据、工作区、文档与编辑器、预览、浏览器、窗口消息、`functions/providers` 与 `functions/invoke`、原生终端、订阅)、插件视图 `View(id, handler)` 和 `litheKeymapImport` 0,不实现构建和 VCS 提供者。契约 README 的 Official backend SDK 加上 `sdk/go` 一段:在 Unix 上把协议移到 stdout 的副本、stdout 指向 stderr,处理函数 panic 只结束这一次调用。Go 示例后端和 Rust 示例后端跑同一个插件后端场景,`sdk-e2e.mjs` 新增 `plugin_sdk_go`。插件总览、日志指南和各参考页列出 Go SDK,并推荐新插件优先用 Rust 或 Go SDK(构建后端照旧用 Node.js 或 Java SDK,VCS 后端用 Node.js SDK)。没有新增版本号、宿主方法、通知或协议字段。 | | [#109](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/109) | [@xiaoyumuxi](https://github.com/xiaoyumuxi) | API-13 | `ui` 0 内的补充(API-13) | 视图事件新增 `width` 和 `resize`,画布可以跟随窗口宽度重新排版。会报告宽度的宿主在每个视图事件里带 `width`(排版视图节点用的宽度,单位为点,至少为 1 的整数,也是顶层画布的宽度),并且量到宽度之后才发 `open`;画布的 `on` 除 `viewport` 外可以写 `resize`,视图里有这样的画布时,宽度停止变化 400 ms 后宿主发 `resize` 和新的 `width`,等待中的 `resize` 可以合并成最新的一个。插件只有在收到带 `width` 的事件后才写 `resize`:不报告宽度的宿主不发 `resize`,它的 Core 也会拒绝写了 `resize` 的画布。契约 README 同时写明画布在缩放 1 时怎样放 `viewBox`:不写 `pan` 时显示整个 `viewBox`,按视图宽度缩放但不超过 `height`,从区域左上角开始;写了 `pan` 时宽度占满视图、上边对齐区域顶部,缩小到比区域窄时水平居中。以前的说明只有“按视图宽度缩放、`height` 点高”,在更宽的窗口里会裁掉场景下半部分。Core 的画布校验接受 `on: ["viewport", "resize"]`,`plugin-ui.schema.json` 的 canvas 说明和 `on` 同步;Rust SDK 新增 `ViewEventKind::Resize` 和 `ViewEvent::width`,Java SDK 新增 `Kind.RESIZE` 和 `width()`,Node SDK 的 `ViewEventKind` 加上 `resize`、`ViewEvent` 加上 `width`、画布 `on` 的类型放宽,三个 SDK 的 README 补充用法;`domains/settings.md` 中英两段说明区域画布怎样按 `width` 排版,以及旧宿主下的固定宽度(语言页约 610 点、构建系统页和编译器页右侧详情约 340 点)([1lck/Lithe-IDEA#2181](https://github.com/1lck/Lithe-IDEA/issues/2181))。没有新增能力版本、宿主方法、通知或 SDK 版本,取代 [#107](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/107)。 | | [#108](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/108) | [@1lck](https://github.com/1lck) | API-23 | **`managedRuntimes` 1** | 受管运行时的每个平台归档可以写 `mirrors`:最多 8 个备用 HTTPS 地址,提供与 `url` 同一个 SHA-256 固定的归档,不改变 `cacheKey`。Core 要求镜像地址不带凭据和片段、彼此不同且不同于 `url`;写了 `mirrors` 却没有声明 `managedRuntimes: 1` 的清单被拒绝,其他插件继续写 0。清单 schema 的 `requires.managedRuntimes` 加上版本 1、平台归档加上 `mirrors`;[能力与协议版本对照](capabilities-and-versions.md)把 `managedRuntimes` 0 的桌面端一列改为 ✅,新增版本 1 一行。没有新增宿主方法、通知或 SDK 版本。宿主须先声明 `managedRuntimes` 1,插件才可要求它。 | | [#105](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/105) | [@xiaoyumuxi](https://github.com/xiaoyumuxi) | API-13、API-19 | `ui` 0、`settings` 0 内的说明补充(API-13、API-19) | 契约 README 写明画布 `image` 节点怎样读取:路径留在插件包内、经过真实目录、指向普通 PNG 文件,单个文件最多 256 KiB、每边最多 1024 像素(预算表新增一行);宿主在场景第一次画到它时于窗口线程外读取,保留到视图关闭,读到之前或读取失败时场景不画它,失败只记一次日志。`image` 节点的字段表补上 `opacity`。文字是一行,基线在 `y`,`align` 把行首(默认)、中点或行尾放在 `x`;渐变 `angle` 与 CSS `linear-gradient` 一致(0 向上、90 向右、默认 180 向下),渐变线穿过形状中心;分组的 `x`、`y` 放置原点,`scale` 缩放内部,`children`、`w`、`h`、`radius` 都在分组自己的坐标里;捏合缩放只在宿主能上报捏合时可用。fixture `fixtures/ui/view-results.json` 的文字基线移到卡片中间。[能力与协议版本对照](capabilities-and-versions.md)删掉“插件视图尚未在桌面端绘制”的脚注,`domains/ui.md`、`domains/settings.md` 的桌面端一行改为已呈现插件视图、设置区域和包内翻译 `l10n/`([1lck/Lithe-IDEA#2181](https://github.com/1lck/Lithe-IDEA/issues/2181))。没有新增版本号、宿主方法、通知或 SDK 版本。 |