From 3075badabadfc433152751a6371dff3c4775e326 Mon Sep 17 00:00:00 2001 From: Yao Jingxi <23722032@bjtu.edu.cn> Date: Tue, 24 Nov 2026 04:58:03 +0800 Subject: [PATCH] docs(plugin-api): document API extension PR requirements --- AGENTS.md | 7 + shared/plugins/README.md | 14 +- shared/plugins/contract/v1/README.md | 54 ++-- .../guides/plugin-api-pr-guide.zh-CN.md | 247 ++++++++++++++++++ shared/plugins/reference/README.md | 2 + .../reference/capabilities-and-versions.md | 14 +- .../plugins/reference/protocol-changelog.md | 3 +- 7 files changed, 312 insertions(+), 29 deletions(-) create mode 100644 AGENTS.md create mode 100644 shared/plugins/guides/plugin-api-pr-guide.zh-CN.md diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 00000000..853759ae --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,7 @@ +# Core 开发入口 + +开始工作前阅读 [CONTRIBUTING.md](CONTRIBUTING.md)。插件契约、指南、参考与官方 SDK 的维护入口是 [shared/plugins/README.md](shared/plugins/README.md)。 + +新增或修改公共插件 API、决定是否引入版本前,必须阅读 [插件 API PR 提交指南](shared/plugins/guides/plugin-api-pr-guide.zh-CN.md),尤其是第 2–5、8、11 节。AI 同样必须遵守其中的领域复用与升版限制、可定位且脱敏的统一日志、错误码全契约查重,以及 Rust、Go、Node、Java 四个 SDK 同 PR 支持要求;example 可以后补。 + +契约规定的已有字段和运行时行为以 [contract/v1/README.md](shared/plugins/contract/v1/README.md) 为准;历史升版先例不能替代本次的版本判断。未修改契约或 SDK 实现的纯文档任务只运行相关文档校验。 diff --git a/shared/plugins/README.md b/shared/plugins/README.md index f9232b95..2a30dacb 100644 --- a/shared/plugins/README.md +++ b/shared/plugins/README.md @@ -17,6 +17,7 @@ | 参考现成插件 | [示例插件](#示例插件) | | 查 API-01–44 现在能用什么、每种能力和协议的版本、Core 和 Lithe 桌面端支持哪些 | [插件参考](reference/README.md) | | 查字段的准确含义 | [插件契约](#插件契约) | +| 为插件需要的公共 API 提 PR | [API PR 提交指南(中文)](guides/plugin-api-pr-guide.zh-CN.md) | | 修改契约、指南或 SDK,在本地验证 | [贡献与维护](#贡献与维护) | ### 插件是什么 @@ -56,12 +57,12 @@ Lithe 读取并校验 `plugin.json`,然后自己启动其中声明的外部进 | --- | --- | --- | | `schemaVersion` | `0` | 清单的文件格式 | | `pluginAPIVersion` | `0` | 插件 API 版本,Lithe 据此判断能不能读你的清单 | -| `requires` | 每个用到的能力写 `0` | 你的插件用了哪些能力;Lithe 只在支持这些能力时才提供安装 | +| `requires` | 每个用到的能力取已有的最低可用版本 | 你的插件用了哪些能力;Lithe 只在支持这些能力时才提供安装 | | `version` | 你自己定 | 你的插件自己的版本 | `requires` 必须**恰好**列出实际用到的能力:漏一个或多列一个,清单都会被拒绝。例如只用声明式构建系统时写 `"requires": { "buildSystems": 0 }`,不要多写。 -能力以后可能出新版本。一次改动只给一个能力加一个新版本,没用到它的插件继续写 `0`,继续可以安装。每个能力的内容、Core 的支持表和 Lithe 桌面端是否声明它,见[能力与协议版本对照](reference/capabilities-and-versions.md#能力版本requires);Lithe 桌面端没有声明的能力,需要它的插件不会被提供安装。 +已有的能力版本继续保留,按实际用法选择最低可用版本;用到 `1`、`2` 才有的行为时如实声明,不强制填 `0`。新增能力先复用 API-01–44,在所属领域兼容扩展;工具特有需求不得提升任何系统 API 版本,公共变化也要先证明兼容扩展不足,详见 [API PR 提交指南](guides/plugin-api-pr-guide.zh-CN.md)。每个能力的内容、Core 的支持表和 Lithe 桌面端是否声明它,见[能力与协议版本对照](reference/capabilities-and-versions.md#能力版本requires);Lithe 桌面端没有声明的能力,需要它的插件不会被提供安装。 ### 在编辑器里校验 plugin.json @@ -193,6 +194,8 @@ fixture 放在 `fixtures/<功能>/` 下,文件按演示的能力命名,例 ### 贡献与维护 +为插件补充公共 API 前,先读 [API PR 提交指南](guides/plugin-api-pr-guide.zh-CN.md):包括领域复用、版本限制、兼容与发布顺序、统一日志定位及脱敏、错误码查重,以及四个官方 SDK 的同步交付;example 可以后补。 + 修改契约、指南、参考或 SDK 的 PR 提到 [Core 仓库](https://github.com/Lithe-IDEA/Lithe-core-rust),和对应的 Rust Core 改动放在同一个 PR 里。下面的命令都在 **Core 仓库的根目录**运行;CI 工作流是仓库根的 `.github/workflows/plugins-verify.yml`,每次涉及 `shared/plugins/` 或 `rust/` 的提交都会运行它们。 | 命令 | 作用 | @@ -238,6 +241,7 @@ Writing, testing, and publishing a plugin all happen in **your own repository**. | Learn from existing plugins | [Example plugins](#example-plugins) | | See what API-01–44 offer today, the version of each capability and protocol, and what Core and the Lithe desktop client support | [Plugin reference](reference/README.md) | | Look up the exact meaning of a field | [Plugin contract](#plugin-contract) | +| Propose a public API extension for a plugin | [API PR guide (Chinese)](guides/plugin-api-pr-guide.zh-CN.md) | | Change the contract, guides, or SDKs and verify locally | [Contributing and maintenance](#contributing-and-maintenance) | ### What a plugin is @@ -277,12 +281,12 @@ When you need run, test, or build tool integration, read the [build, run, and te | --- | --- | --- | | `schemaVersion` | `0` | The manifest file format | | `pluginAPIVersion` | `0` | The plugin API version; Lithe uses it to decide whether it can read your manifest | -| `requires` | `0` for each capability you use | Which capabilities your plugin uses; Lithe offers the plugin for installation only where it supports them | +| `requires` | The lowest existing version that covers each capability you use | Which capabilities your plugin uses; Lithe offers the plugin for installation only where it supports them | | `version` | Your choice | Your plugin's own version | `requires` must list **exactly** the capabilities you use: leaving one out or listing one extra gets the manifest rejected. For example, a plugin that only uses declarative build systems writes `"requires": { "buildSystems": 0 }` and nothing more. -A capability may get a new version later. One change adds a new version to exactly one capability, and a plugin that does not use it keeps writing `0` and stays installable. For what each capability covers, Core's support table, and whether the Lithe desktop client declares it, see [Capability and protocol versions](reference/capabilities-and-versions.md#capability-versions-requires); a plugin that needs a capability the Lithe desktop client does not declare is not offered for installation there. +Keep existing capability versions and select the lowest that covers the actual use; declare `1` or `2` when its behavior is needed rather than forcing every value to `0`. Reuse API-01–44 and extend the appropriate domain compatibly. Tool-specific requirements must not raise any system API version; even a public change must first show why a compatible extension is insufficient. See the [API PR guide (Chinese)](guides/plugin-api-pr-guide.zh-CN.md). For what each capability covers, Core's support table, and whether the Lithe desktop client declares it, see [Capability and protocol versions](reference/capabilities-and-versions.md#capability-versions-requires); a plugin that needs a capability the Lithe desktop client does not declare is not offered for installation there. ### Validate plugin.json in your editor @@ -414,6 +418,8 @@ For questions or suggestions about the contract, [open an issue in the Core repo ### Contributing and maintenance +Before extending a public plugin API, read the [API PR guide (Chinese)](guides/plugin-api-pr-guide.zh-CN.md): domain reuse, version restrictions, compatibility and release order, useful unified logs with redaction, error-code uniqueness, and support in all four official SDKs in the same PR. New examples may follow later. + A PR that changes the contract, guides, reference, or SDKs goes to the [Core repository](https://github.com/Lithe-IDEA/Lithe-core-rust), in the same PR as the matching Rust Core change. Run the commands below at the **root of the Core repository**; CI runs them from `.github/workflows/plugins-verify.yml` at the repository root on every change that touches `shared/plugins/` or `rust/`. | Command | Purpose | diff --git a/shared/plugins/contract/v1/README.md b/shared/plugins/contract/v1/README.md index d790e48a..cd44c5b5 100644 --- a/shared/plugins/contract/v1/README.md +++ b/shared/plugins/contract/v1/README.md @@ -190,9 +190,9 @@ symbolic links. A host treats an installed package as read-only. Unknown fields are refused (`plugin.manifest.invalid`) so a host rejects a package instead of ignoring part of it. A new optional field in an existing -section needs no new version; a change to what a section means gives the one -capability that owns it version `1`, and only plugins that use that change -declare it (see [Versioning](#versioning)). +section needs no new version. A semantic change does not automatically justify +a new capability version; it must satisfy [Versioning](#versioning). Existing +versions and strict unknown-field rejection remain in force. ### Languages @@ -959,14 +959,15 @@ files sorted by path, or an empty list when no project marker is present. ## Versioning -Every version in this contract is `0`. A change adds a version to exactly one -place, so a plugin states what it needs and a host states what it runs, each -per capability. +Version series start at `0`; several capabilities already support `1` or `2`. +Use the [capability and protocol tables](../../reference/capabilities-and-versions.md) +and the target host's actual declarations for existing support. A plugin states +what it needs and a host states what it runs, each per capability. 1. **Capabilities start at `0`.** A manifest lists the capabilities it uses in - `requires`, each with version `0`. A capability version names one manifest - section and, when the capability owns one, the runtime protocol that goes - with it. + `requires`, each at the lowest existing version that covers its actual use. + A capability version names one manifest section and, when the capability owns + one, the runtime protocol that goes with it. 2. **A runtime protocol has no version of its own.** Its version is the owning capability's, and a host offers exactly that version (`{"versions": []}`; the process answers `{"version": ": 1`, and every other plugin keeps `0` and stays installable - wherever it was. An additive optional field in an existing section or - message needs no new version. +4. **Reuse and compatible extension come first.** API-01–44 classify domains, + not a closed method list. Add general methods, notifications, optional fields, + or declarations within the appropriate domain when existing interfaces are + insufficient. An additive optional field preserves its omission behavior + and needs no new version; strict unknown-field validation still applies. +5. **Specific requirements must not raise any system API version.** This covers + plugin-, language-server-, and build-tool-specific needs, including base API, + schema, individual capability, process protocol, and public document-format + versions. Renaming a capability, protocol, or contract directory does not + bypass the restriction. Keep tool-specific knowledge in plugins or upstream + tools, with general typed declarations for data the host must understand. +6. **Only a public, non-specific interface change may propose a new version, + and only when compatible extension cannot safely express it.** The PR must + explain the public use, why optional fields or discovery are insufficient, + why old behavior cannot remain, affected consumers, and migration. Only the + owner of that change may gain a version; unrelated versions stay unchanged. + Security requirements or an old host rejecting unknown fields do not alone + justify a new version. Existing `1`, `2`, and later versions remain valid. + The [API PR guide (Chinese)](../../guides/plugin-api-pr-guide.zh-CN.md) + describes compatibility, release order, diagnostics, error-code checks, and + support in all four official SDKs; new examples may follow later. `pluginAPIVersion` versions only the base fields: `schemaVersion`, `id`, `displayName`, `version`, `vendor`, `permissions`, `activationEvents`, @@ -1014,7 +1031,7 @@ contract version: the plugin that exports the function owns it. lowerCamelCase identifiers of at most 64 characters; versions are non-negative integers. - Core reads `requires` before it decodes any section. A capability this - contract does not define, or a version other than `0`, is + contract does not define, or a version absent from its support table, is `plugin.api.unsupported` with `field: "requires."`, even when the manifest also holds a section Core does not know, so the user learns which capability needs a newer Lithe instead of seeing an unknown field. @@ -3810,9 +3827,10 @@ Two rules keep these directions from forming a loop: `pluginAPIVersion` nor any `requires` version. Only a function that another plugin may call, and a call to such a function, are declared, in [`pluginFunctions`](#cross-plugin-calls). -- A new kind of domain implementation is a new version of the capability that - owns it, so only plugins that use it are filtered from hosts that cannot run - it. +- A new kind of domain implementation follows [Versioning](#versioning); it + does not automatically require a new capability version. Prefer compatible + typed declarations and discovery, and define how an unsupported host refuses + or degrades the new path. ### Negotiation diff --git a/shared/plugins/guides/plugin-api-pr-guide.zh-CN.md b/shared/plugins/guides/plugin-api-pr-guide.zh-CN.md new file mode 100644 index 00000000..15159289 --- /dev/null +++ b/shared/plugins/guides/plugin-api-pr-guide.zh-CN.md @@ -0,0 +1,247 @@ +# 为插件扩展公共 API:PR 提交指南 + +当新插件需要的能力在现有接口中找不到时,先调查已有 API,再提出最小的公共扩展。**API-01–44 划分领域,允许在领域内持续增加方法、通知、可选字段和声明;它们不是封闭的方法清单。先复用已有能力,缺什么就补到合适的领域中。** + +**允许扩展不等于允许升版。** 插件、语言服务器、构建工具等特有需求,不得提升任何系统 API 版本。只有公共、非特有的接口发生变化,才具备讨论升版的条件;能兼容扩展的仍不升版。 + +**日志、错误码和四语 SDK 也是 API 的交付内容。** 日志要能迅速定位到具体操作、阶段和真实原因;错误码语义清晰、分配不重复;Rust、Go、Node、Java 四个官方 SDK 同步补齐。新增 example 可以后补,SDK 支持不能推迟。 + +本文约束新增 API 的贡献方式,不修改已存在版本的含义。接口事实核对自 [Core 提交 `5fa6f58`](https://github.com/Lithe-IDEA/Lithe-core-rust/tree/5fa6f5875ee8a1fe5140a44e84d29dae2ce6d6fb/shared/plugins);实际开发前仍须读取目标分支的当前契约。 + +## 1. 开始前,先查这些资料 + +插件开发者只需查看 [Core 的 `shared/plugins/`](https://github.com/Lithe-IDEA/Lithe-core-rust/tree/main/shared/plugins),无需为了查契约克隆桌面端仓库。 + +| 资料 | 用途 | +| --- | --- | +| [API 总表](https://github.com/Lithe-IDEA/Lithe-core-rust/blob/main/shared/plugins/reference/api-catalog.md) | 查已有分类、方法、权限、协议,以及仍在计划中的能力 | +| [正式契约](https://github.com/Lithe-IDEA/Lithe-core-rust/blob/main/shared/plugins/contract/v1/README.md) | 查参数、结果、错误码、权限、生命周期及兼容行为 | +| [能力与版本对照](https://github.com/Lithe-IDEA/Lithe-core-rust/blob/main/shared/plugins/reference/capabilities-and-versions.md) | 确认 Core、目标宿主和进程协议分别支持哪些已有版本 | +| [协议更新记录](https://github.com/Lithe-IDEA/Lithe-core-rust/blob/main/shared/plugins/reference/protocol-changelog.md) | 查扩展首次出现的 PR、Core 修订与版本历史 | +| [专题指南](https://github.com/Lithe-IDEA/Lithe-core-rust/tree/main/shared/plugins/guides)、[官方 SDK](https://github.com/Lithe-IDEA/Lithe-core-rust/tree/main/shared/plugins/sdk) | 查当前推荐用法及 SDK 的实际支持范围 | +| [日志目录与脱敏规则](https://github.com/Lithe-IDEA/Lithe-core-rust/blob/main/rust/logging/README.md)、[插件日志协议](https://github.com/Lithe-IDEA/Lithe-core-rust/blob/main/shared/plugins/contract/v1/README.md#structured-plugin-diagnostics) | 查统一日志接入、字段语义、记录责任和敏感信息处理 | + +API-01–44 是 **44 类规划能力**,既不是 44 个方法,也不是 44 个已经全部实现的 API。一个分类可以逐步增加多个方法,当前总表未列出的方法也可以通过 PR 补充;不要因为它尚未列出就判定“不允许”。历史实施计划中的版本和完成状态不能代替当前契约与运行时能力发现。 + +## 2. 先复用,缺口在所属领域扩展 + +按以下顺序调查,并把结论放进 PR: + +1. **已有 API 能直接完成吗?** 查现有方法、清单声明、设置、编辑器扩展点,以及上游语言服务器或构建工具的公开能力。不要为同一个功能再造一个入口。 +2. **能组合现有能力吗?** 复用现有文档、动作、函数调用和领域工作流。底层请求、超时、取消和进程管理继续使用现有机制。 +3. **缺口是否只是工具自己的知识?** 工具配置格式、框架参数、版本别名和私有协议由插件或上游处理。宿主只理解必要的公共数据。 +4. **能在所属 API 中兼容扩展吗?** 可以增加通用方法、通知、可选字段和声明;优先使用明确的缺省行为、能力发现及已有生命周期。复用要求不限制接口只能调用今天已经存在的方法,也不要求把缺口勉强塞进现有方法。不要先改版本号,再设计接口。 +5. **公共接口确有缺口时,再提最小扩展。** 说明第二个语义不同的工具如何使用同一接口。接入第二个工具还要给宿主加工具名分支,说明设计仍然特有,需先调整。 + +复用必须符合语义。例如语言服务器接入归 API-25,构建、测试和运行准备归 API-29,调试适配器归 API-30;HTTP 文档旁绑定插件函数的按钮属于 API-27 编辑器动作。按下“运行”图标本身,不要求插件成为构建提供者。 + +新方法归入现有 API-01–44 中合适的一类;确实不属于任何编号时标 `—` 并解释原因,**不得自行编出 API-45**。先查 [Core Issues](https://github.com/Lithe-IDEA/Lithe-core-rust/issues) 和 [现有 PR](https://github.com/Lithe-IDEA/Lithe-core-rust/pulls),避免重复实现。 + +## 3. API 版本怎么处理 + +### 特有需求不允许升任何系统版本 + +此限制同时覆盖基础 `pluginAPIVersion`、清单 `schemaVersion`、`requires.<能力>`、进程协议,以及公共数据文档的格式版本。**只给 `languageServers` 或 `buildProviders` 升版,同样受限制。** 不得换一个能力名、协议名或契约目录绕过。 + +| 变化 | 处理方式 | +| --- | --- | +| 某个服务器或构建工具新增自己的选项、配置或私有函数 | 在插件或上游实现;确需宿主理解的数据,提炼成通用可选声明,不升系统版本 | +| 所属 API 新增有明确缺省行为的可选字段 | 同步类型、校验、文档和消费者,保持已有版本 | +| 所属领域新增宿主方法或通知 | 在现有协议内扩展,按契约提供能力发现,声明权限与支持限制,登记每个方法或通知 | +| 公共、非特有的接口发生变化 | 先证明兼容扩展是否足够;足够就保持版本,确实不足才提出升版方案 | +| 插件改用一个已经存在的较高能力版本 | 仅在实际使用其功能且目标宿主支持时声明;这是选择已有版本,不是创造新版本 | + +公共、非特有是升版的必要条件,**不是自动升版的理由**。确需提出升版方案时,在 PR 中写清公共用途、已有可选扩展为什么无法安全表达、旧行为为什么不能保留、哪些消费者受影响及如何迁移;只涉及拥有变化的版本,不连带提升整套基础契约或其他能力。安全要求、旧宿主拒绝未知字段或“以后可能需要”,本身都不足以证明必须升版。 + +### 已经存在的 1、2 怎么办 + +已有版本继续保留。核对提交时,`buildProviders` 已有 0、1,`languageServers` 已有 0、1,`buildSystems` 已有 0、1、2;基础 `pluginAPIVersion` 和清单 `schemaVersion` 仍是 0。完整取值以当前支持表和目标宿主声明为准,不在这里维护第二张版本全集。 + +插件为每项实际使用的能力选择**已有的最低可用版本**。用到版本 1 才提供的行为时,如实声明 1;没有使用时继续沿用较低版本。不要将本规则理解为“全部填 0”,也不要修改、回退或删除已有的较高版本。 + +SDK 包版本、插件自己的发布版本、宿主应用版本与系统 API 版本分别管理;升级 SDK 不会自动证明宿主具备某个方法,也不构成提升 API 版本的理由。 + +## 4. 可选字段要怎样设计才成立 + +PR 必须逐项回答: + +- **不写时做什么?** 省略字段保持原有行为;不能把原字段偷偷改成必填,或更改原默认值。 +- **谁解释这个值?** 插件解释工具自己的配置;Core 只做通用规则、类型校验和生命周期管理;平台层执行原生 I/O 和呈现。 +- **边界是什么?** 定义类型、长度、数量、允许值、权限、资源所有权、取消、超时与清理,以及本机或远程等平台限制。 +- **老的一侧会怎样?** 分清清单字段、请求参数、返回值和通知,逐种核对未知字段规则。JSON 能解析不等于契约允许忽略。 + +已经合入的真实例子: + +| 例子 | 为什么不需要新版本 | 兼容限制 | +| --- | --- | --- | +| [Core #68](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/68):`languageServers[].indexingExclusions` | 在 `languageServers` 0 中增加可选声明,用 `section`、`entry` 等描述服务器配置;无声明时配置保持原样,不按服务器名特判 | 老 Core 严格拒绝未知清单字段;插件须等支持此声明的宿主发布后再使用 | +| [Core #128](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/128):`run/start.process.outputEncoding`、`lithe/build/prepareRun` 的 `outputEncoding` | 在 API-23、API-29 的已有接口中可选声明进程输出编码,省略时沿用原处理,不新增系统或能力版本 | 宿主请求的严格参数校验,与提供者返回值的扩展规则需分别检查 | +| [Core #175](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/175):工具行的 `choose` | 把可选字段保留在 `ui` 0;撤回尚未随宿主发布的 `ui` 1 | 老 Core 仍可能拒绝未知视图字段,不能因此宣称所有旧宿主可用 | + +这些例子说明:可选扩展与“新插件在旧宿主上可用”是两个需要分别证明的问题。 + +## 5. 不升版时,如何处理旧宿主 + +### 宿主方法、请求选项与结果 + +后端先读取 `lithe/host/getCapabilities` 的 `services`,确认方法可用,调用时继续遵守权限与上下文要求。不能用 SDK 版本、应用版本字符串或某个 API 已写进文档来替代发现。 + +按 [宿主服务扩展规则](https://github.com/Lithe-IDEA/Lithe-core-rust/blob/main/shared/plugins/contract/v1/README.md#extending-the-host-services): + +- 未支持的方法返回 `plugin.host.unavailable`(JSON-RPC `-32601`)。 +- 方法不支持的请求选项返回 `plugin.host.unsupportedOption`(`-32018`),`details.option` 指明字段。Core 类型化的请求会在交给宿主前拒绝该字段;未由 Core 定义参数类型的服务由服务自身执行同样检查。 +- 只有去掉该选项仍能正确完成操作、且已确认失败发生在副作用之前时,才按契约降级重试。超时或执行结果不明时,不能盲目重试写入、启动等操作。 +- 按契约忽略不认识的结果字段、通知及扩展信息;其他协议和文档的规则逐项检查,不能据此放宽全部 JSON 的校验。 + +### 清单、权限与发布顺序 + +旧 Core 会以 `plugin.manifest.invalid` 拒绝未知清单字段,不认识的新权限会以 `plugin.permission.unknown` 拒绝安装。**不允许为了“兼容”放宽严格解码或 schema,也不因旧宿主拒绝就机械地新增能力版本。** + +在 PR 和插件发布说明中写清首次支持该扩展的 Core commit、宿主 PR 和实际发布版本。先发布支持它的宿主,再发布使用它的插件;宿主尚未稳定发布时,插件仅发预发布版本,不进入插件市场。保留之前的插件发布包,明确旧宿主上的可用旧版本或拒绝方式;不要虚构契约中不存在的最低宿主版本字段。 + +至少验证这些组合,并在 PR 中记录真实结果: + +| 组合 | 要证明什么 | +| --- | --- | +| 旧插件 + 新宿主 | 已有行为与默认值保持可用 | +| 新插件省略扩展 + 新宿主 | 可选字段确实可省略 | +| 新插件使用扩展 + 支持该扩展的宿主 | 新行为、权限和生命周期按契约执行 | +| 新插件 + 不支持该扩展的旧宿主 | 按设计降级或明确拒绝;不能静默执行错误行为 | + +## 6. 改哪些仓库、放哪些文件 + +| 位置 | 本次应包含的内容 | +| --- | --- | +| **Core PR** | 公共模型、校验、协议执行代码、需要的日志目录更新,与 `shared/plugins/` 中的契约、schema、fixture、指南、参考和四个官方 SDK 同一个 PR 修改 | +| **桌面端 PR** | 原生 I/O、呈现、宿主能力声明及 Core 桥接;Core 合入后将 `PINNED_CORE_REVISION` 固定到包含变化的 commit | +| **插件 PR** | 工具特有的实现、清单与打包资源,以及插件自己的测试、功能矩阵和翻译 | + +契约、SDK 和插件开发指南只在 Core 维护,不复制到桌面端仓库或 Lithe Store。真实插件的端到端测试只在插件仓库;Core 和宿主验证通用扩展点使用自己的契约 fixture 或合成输入,不依赖具体插件包、本机插件检出或真实插件 ID。 + +## 7. Core PR 的公开资料必须同步 + +即使没有升版,也要完成以下事项: + +1. 在契约 README 写清参数、结果、错误码、权限、生命周期、缺省行为及平台限制;schema、fixture 和执行代码一致。 +2. 在对应 `guides/` 或 `reference/` 专题页补充用法,并从已有入口链接到新页面。仅写在 PR、实施计划、宿主源码或 Agent Note 中,不算公开契约。 +3. 更新 [协议更新记录](https://github.com/Lithe-IDEA/Lithe-core-rust/blob/main/shared/plugins/reference/protocol-changelog.md):修改协议或 API、PR、修改人(PR 作者)及合入日期。未合入就如实写“待合入”,合入时回填真实日期;没有新版本也要登记。确有新版本时,另更新“按协议查首次出现”。 +4. 新增或修改宿主方法、通知时,PR 正文逐个列出下表。Core 的 [API 总表](https://github.com/Lithe-IDEA/Lithe-core-rust/blob/main/shared/plugins/reference/api-catalog.md)中英方法或通知表,以及更新记录的“宿主方法(按 API 编号)”索引同步逐项登记;同类方法分几次 PR 加入时,分别记自己的 PR。 +5. 搜索并检查所有受影响消费者;新增或修改的公共插件 API 在 Rust、Go、Node、Java 四个官方 SDK 中同步补齐,更新对应类型、专题说明和能力支持表。不能只补提出需求的插件所用语言。 + +新增或修改方法、通知的表格格式如下;把每一项单独填一行: + +```markdown +| 原计划编号 | 方法 | 用途 | +| --- | --- | --- | +``` + +编号使用 API-01–44;没有对应项写 `—`。方法名写真实协议名,通知也要列出,不能只写“补了构建 API”作为整组概括。 + +## 8. 日志、错误码和四语 SDK 的交付要求 + +### 日志必须接入,而且能迅速定位问题 + +API 的关键终态、失败、降级、恢复和异常清理进入现有统一日志系统。PR 要说明记录由 Core、宿主还是 SDK 负责;新增日志回调必须在每个生产构造处注入真实实现,不能只定义接口却不接线。复用已有事件和写入器,确实需要新目录事件时在 Core 中声明,不能自建日志文件、自由文本通道或旁路输出。 + +验收时,维护者应能从该操作及同一操作的关联记录中快速回答: + +- **什么操作出错?** 具体 API 或协议方法,以及经过校验的插件、提供者或组件身份。 +- **在哪个阶段出错?** 例如能力校验、工具解析、启动、握手、执行、结果解码或清理。 +- **已知原因是什么?** 保留稳定错误类别和允许的结构化细节;已有具体原因时,不得只剩“操作失败”“内部错误”或“未知异常”。尚未确定根因时,如实记录已观测到的失败,不猜原因。 +- **造成什么结果?** 明确拒绝、最终失败、降级或恢复;记录必要的耗时、尝试次数,并用同一操作 ID 串起上下游证据。 + +例如,已有 `plugin.host.toolUnresolved` 能区分工具未找到和选中的入口不可用,契约允许的 `details` 带 `tool`、`reason`。应复用并保留这种语义,避免在传递和记录时统一抹成“启动失败”。这些信息通过现有目录字段及关联轨迹表达,**不要求给每条日志重复塞入全部字段**。插件 `lithe/log` 仍只用契约允许的操作、稳定码等字段,不擅自添加 `message`、`stage` 或任意 `details`。 + +**含敏感上下文时,使用现有共享脱敏机制,并检查脱敏后仍可定位。** 宿主按日志目录的类型传入路径、错误等允许字段,由 Core 集中脱敏、限长、校验后落盘;保留安全的 API 名、阶段、稳定码、关联 ID、计数和耗时。不能因错误中含路径就删掉整个原因,也不能直接转储原始异常或协议载荷。源码、凭据、文件内容等禁止记录的内容,不能以“会脱敏”为由写入。 + +复用 SDK 已自动记录的终态,不重复上报同一错误;用户取消按契约处理,高频读取不逐条记成功 INFO。触发真实失败和可触发的降级、恢复路径,检查日志窗口及落盘记录的语义、关联、级别与脱敏结果。仅确认“窗口有输出”不算完成。 + +### 错误码语义单一,新增分配不冲突 + +先查整个公共插件契约和 Core、四个 SDK 的错误映射,再决定是否新增。**同一错误语义复用原码,不同语义不得共用一个自定义码,也不要为同一原因重复造码。** 分配新的业务 JSON-RPC 编号时,检查宿主服务、插件函数、工具链等所有公共插件协议的已占用编号和保留区,不能只查当前 API 或某一个 SDK。标准 JSON-RPC 错误按标准语义使用,不将其占作新的业务编号。 + +每个错误在契约中写清稳定字符串、JSON-RPC 编号(如适用)、所属 API、触发条件、允许的 `details`、是否已发生副作用和可否重试。参数无效、权限不足、版本冲突、超时、取消和执行失败要有可区分的含义;不能把可识别的失败全部变成通用内部错误。已发布的编号不得改成另一种含义,SDK 不靠本地化错误消息文本分支。 + +在 PR 中列出新增或复用的码,以及全契约查重结果。代码、fixture、文档和四个 SDK 的映射保持一致,相关验证覆盖新增分配无冲突、错误分类和传播;不需要为无关模块扩大全量测试。 + +### 四个官方 SDK 必须同步,example 可以后补 + +新增或修改的公共插件 API,**Rust、Go、Node、Java 四个官方 SDK 都必须在同一个 Core PR 中补齐**,按各语言现有形态提供对应支持: + +| 范围 | 必须同步的内容 | +| --- | --- | +| 请求与提供者接口 | 对应调用封装或处理接口、参数与结果,以及可选字段的省略行为 | +| 通知 | 订阅或处理入口、通知数据及生命周期 | +| 错误 | 稳定码、数字码、结构化详情和一致的错误传播 | +| 日志与操作上下文 | 复用现有日志入口及自动终态记录,保留取消和操作关联 | +| 验证 | 相关类型检查、单元或协议用例,以及既有四语 SDK 端到端检查 | + +某个 SDK 当前覆盖的提供者较少,不构成新增公共 API 只实现另一种语言的理由;补齐本次 API 所需的支持范围。已有通用原始请求入口,也不能代替应有的调用、类型和错误支持。纯清单声明没有新的进程调用时,不凭空创造 RPC 接口,但仍核对四个 SDK 对该声明所涉参数、结果和错误的支持。 + +**本 PR 不要求立刻新增或扩充 example。** 可以后补演示代码;这不免除 SDK 实现和相关验证。既有示例用于端到端回归时照常运行,示例没有演示新 API 也不能代替该 API 的相关验证。 + +## 9. 提交 PR 的实际步骤 + +1. 写清具体用户操作、现有接口为何不足,以及本次扩展的公共用途;查重后关联已有 Issue,尚无 Issue 时按目标仓库模板建立。避免只写“某插件需要”。 +2. 从目标仓库最新 `main` 切出分支。优先复用空闲的已有检出;不要仅为文档或小改动另开工作树。按第 6 节拆分 Core、桌面端和插件改动,互相链接依赖。 +3. 完成实现、第 7 节资料更新和第 8 节日志、错误码与四语 SDK 交付,再做下面的相关验证。只改指南时做文档校验,不需要构建全部平台;改协议时不能用文档检查代替协议验证。 +4. 读取**目标仓库当前的 PR 模板**,以它为骨架,关联 Issue 放最前面,再选择 feat、fix 或 docs 等适用类型。桌面端必须使用其 [PR 模板](https://github.com/1lck/Lithe-IDEA/blob/main/.github/pull_request_template.md);Core 如未设置模板,也保留问题、改动、兼容、依赖和验证内容。下节的填写提纲用于补充,不替代已有模板。 +5. 将正文写入 UTF-8 文件,通过 `gh pr create --draft --body-file <正文文件>` 创建 Draft PR。`--body-file` 不会自动应用仓库模板,必须事先填好。 +6. 按实际改动填写功能矩阵、日志、权限、i18n、平台及资源检查项;不适用的写原因。只实现一端的桌面端 feat 为另一端提交跟进 Issue。可评审且本地相关验证通过后再 `gh pr ready`;后续修改攒好后再推送,避免反复触发完整 CI。 + +Core 仓库根目录的相关验证: + +```bash +node shared/plugins/scripts/verify-docs.mjs +``` + +改公共插件协议、字段或消费者时,运行受影响 crate 的测试;四个官方 SDK 按改动补充相关类型或单元检查,并运行既有示例后端的端到端验证。无需为了交付本次 API 再创建一个 example: + +```bash +node shared/plugins/scripts/sdk-e2e.mjs +``` + +桌面端运行受影响的桥接、宿主消费者和平台验证;真实工具流程在插件仓库验证。报告真实命令、Core/宿主/SDK 修订和结果,未执行的项目写明原因,不把 CI 预期结果写成已通过。 + +## 10. 可直接填入 PR 的说明提纲 + +以下项目按目标模板放入背景、改动、插件契约和验证等栏目: + +```markdown +关联 Issue: +PR 类型: + +用户流程与缺口: +已调查的 API-01–44 分类、现有方法/声明、上游能力,以及无法复用的原因: +公共接口如何供第二个语义不同的工具使用: +工具特有知识留在哪个插件或上游: + +新增或修改的字段/方法/通知、权限与生命周期: +省略字段时的原有行为: +基础 API、能力、进程协议、公共文档格式各自的版本变化: +升版理由(通常填“无,沿用已有版本”;提议升版时附公共用途及不可兼容证据): + +新旧插件/宿主的兼容组合与结果: +首次支持的 Core commit、宿主 PR/发布版本及插件发布顺序: +关联 Core / 桌面端 / 插件 PR: +契约、schema、fixture、API 总表、更新记录、SDK 与消费者的同步情况: +统一日志的记录方与生产接线、API/阶段/原因/处理结果的定位线索: +敏感字段如何脱敏,脱敏后仍可定位的验证结果: +新增或复用的稳定错误码、JSON-RPC 编号、触发条件及全契约查重结果: +Rust / Go / Node / Java 四个 SDK 各自的实现路径和相关验证: +example 的情况(不要求本次新增,不代替 SDK 实现): + +| 原计划编号 | 方法 | 用途 | +| --- | --- | --- | + +实际执行的验证、所用修订和结果: +未执行的检查及原因: +``` + +## 11. 交给 AI 开发时,必须附上的约束 + +> API-01–44 划分领域,允许在领域内持续扩展,不是封闭的方法清单。先调查并复用现有接口、对应契约和成熟上游;有公共缺口时在所属领域增加方法、通知、可选字段或声明。插件、语言服务器、构建工具等特有需求不得提升任何系统 API 版本,包括单个能力或进程协议,也不得换名绕过。只有公共、非特有的接口变化且无法兼容表达时,才可提出升版方案;可选字段、能力发现等足够时保持现有版本。保留已有 1、2 等版本,按实际用法选择已有最低版本,不强制填 0。不升版也要同步契约、校验、schema、fixture、消费者、SDK、API 登记及相关验证,并说明旧宿主的降级或拒绝行为。 + +> 新增 API 必须接入统一日志系统,真实失败能从具体 API、阶段、稳定原因、处理结果及操作 ID 定位,不能只记模糊错误;敏感上下文走共享脱敏并保留允许的定位线索。错误码语义清晰,新增自定义码和业务编号经全插件契约查重,不冲突、不改旧含义。Rust、Go、Node、Java 四个官方 SDK 在同一 Core PR 中补齐接口、数据、通知、错误和日志支持及相关验证;example 可以后补,SDK 支持不能推迟。 + +AI 开始前必须读取目标仓库的 `AGENTS.md`。Core 的入口指向本指南;在桌面端仓库工作时,还须加载其入口指定的 `develop-lithe` Skill,读取“API 复用与版本演进”,创建插件时再读取 `create-lithe-plugin`。插件开发者只查 Core 的公共资料即可,无需为此克隆桌面端仓库。不能仅凭旧 PR、历史版本表或已有插件的写法决定本次该如何扩展。 diff --git a/shared/plugins/reference/README.md b/shared/plugins/reference/README.md index 2e1ceb44..cd74a8a3 100644 --- a/shared/plugins/reference/README.md +++ b/shared/plugins/reference/README.md @@ -15,6 +15,7 @@ | 每个协议、能力和 API 是哪天、哪个 PR 改的 | [插件协议更新记录](protocol-changelog.md)(只有中文) | | 某个功能的字段、宿主现状、契约章节和示例 | 下方的功能页 | | 一步步做出一个插件 | [开发指南](../guides/) | +| 为插件扩展 API 并提交 PR | [API PR 提交指南](../guides/plugin-api-pr-guide.zh-CN.md) | ### 功能页 @@ -61,6 +62,7 @@ This directory organizes the plugin contract by feature: what each numbered API | When, and in which PR, each protocol, capability, and API changed | [Plugin protocol changelog](protocol-changelog.md) (Chinese only) | | A feature's fields, host status, contract sections, and examples | The feature pages below | | Building a plugin step by step | [Guides](../guides/) | +| Extending an API for a plugin and submitting a PR | [API PR guide (Chinese)](../guides/plugin-api-pr-guide.zh-CN.md) | ### Feature pages diff --git a/shared/plugins/reference/capabilities-and-versions.md b/shared/plugins/reference/capabilities-and-versions.md index 30cbbeec..33e85b3d 100644 --- a/shared/plugins/reference/capabilities-and-versions.md +++ b/shared/plugins/reference/capabilities-and-versions.md @@ -4,7 +4,7 @@ ## 中文 -本页把插件会碰到的所有版本号放在一起:`pluginAPIVersion`、清单格式、各项能力、进程协议和文档格式。**它们都从 `0` 开始(仅下表显式列出 `1` 的能力已有新版本)。** 规范以 [`contract/v1/README.md`](../contract/v1/README.md) 的 [Versioning](../contract/v1/README.md#versioning)、[Capabilities](../contract/v1/README.md#capabilities)、[Host capabilities](../contract/v1/README.md#host-capabilities) 和 [Publishing](../contract/v1/README.md#publishing) 为准;本页与契约不一致时以契约为准,并请到 [Lithe-core-rust 的 Issues](https://github.com/Lithe-IDEA/Lithe-core-rust/issues) 反馈。 +本页把插件会碰到的所有版本号放在一起:`pluginAPIVersion`、清单格式、各项能力、进程协议和文档格式。**各系列从 `0` 开始,已有 `1`、`2` 等版本按下表和目标宿主的实际支持选择;不要一律填 `0`。** 规范以 [`contract/v1/README.md`](../contract/v1/README.md) 的 [Versioning](../contract/v1/README.md#versioning)、[Capabilities](../contract/v1/README.md#capabilities)、[Host capabilities](../contract/v1/README.md#host-capabilities) 和 [Publishing](../contract/v1/README.md#publishing) 为准;本页与契约不一致时以契约为准,并请到 [Lithe-core-rust 的 Issues](https://github.com/Lithe-IDEA/Lithe-core-rust/issues) 反馈。 Core 列以本仓库 `main` 上的 Core 源码为准([`capabilities.rs`](https://github.com/Lithe-IDEA/Lithe-core-rust/blob/main/rust/crates/plugin-model/src/capabilities.rs) 的 `SUPPORTED_CAPABILITIES`,[`plugin-manifest/src/lib.rs`](https://github.com/Lithe-IDEA/Lithe-core-rust/blob/main/rust/crates/plugin-manifest/src/lib.rs) 的 `SUPPORTED_PLUGIN_API_VERSIONS`);Lithe 桌面端列以桌面端的[声明与说明](https://github.com/1lck/Lithe-IDEA/blob/main/desktop/internal/pluginhost/pluginhost.go)为准。Core 能校验不等于宿主能运行:宿主未声明的能力不会提供给插件,市场按实际声明筛选版本。 @@ -21,7 +21,8 @@ Core 列以本仓库 `main` 上的 Core 源码为准([`capabilities.rs`](https 以后的变化遵循契约的规则: -- 一次改动只给**一个**能力加一个新版本(`1`),清单段和协议一起变;没用到这次改动的插件继续写 `0`,在原来的宿主上继续可装。 +- 先在 API-01–44 所属领域复用和兼容扩展。插件、语言服务器、构建工具等特有需求不得提升任何系统 API 版本;公共、非特有的变化也只有在兼容扩展无法安全表达时才可提出升版,见 [API PR 提交指南](../guides/plugin-api-pr-guide.zh-CN.md#3-api-版本怎么处理)。 +- 确需引入新版本时,只涉及拥有公共变化的版本,清单段与所属协议保持一致;其他插件继续选择原来所需的已有版本,不回退或删除已有的 `1`、`2` 等版本。 - 已发布的能力版本不改变含义,宿主一直支持它。 - 插件只声明自己用到的能力,每个能力取能覆盖它用法的**最低**版本。没用到新内容就提高版本,只会让旧宿主装不上。 - 把插件改到新的能力版本必须发新的插件版本;市场索引保留上一个旧要求的版本,旧宿主仍有版本可装。 @@ -36,7 +37,7 @@ Core 列以本仓库 `main` 上的 Core 源码为准([`capabilities.rs`](https ### 能力版本(`requires`) -每一行是一个能力。`requires` 必须**恰好**列出清单用到的能力:漏一个或多列一个都是 `plugin.manifest.invalid`;每个能力的值是能覆盖插件用法的最低版本,没有用到 `1` 的新内容就写 `0`。启动进程([Process start](../contract/v1/README.md#process-start))和可执行文件解析([Executable resolution](../contract/v1/README.md#executable-resolution))属于基础契约,不是能力;写 `requires.serverProcess` 会像未知能力一样被拒绝。 +每一行是一个能力。`requires` 必须**恰好**列出清单用到的能力:漏一个或多列一个都是 `plugin.manifest.invalid`;每个能力的值是能覆盖插件实际用法的已有最低版本,按下表选择 `0`、`1`、`2` 等取值。启动进程([Process start](../contract/v1/README.md#process-start))和可执行文件解析([Executable resolution](../contract/v1/README.md#executable-resolution))属于基础契约,不是能力;写 `requires.serverProcess` 会像未知能力一样被拒绝。 | 版本 | 内容 | Core | Lithe 桌面端 | 详见 | | --- | --- | --- | --- | --- | @@ -123,7 +124,7 @@ Node.js SDK 0.5.0、Java SDK 0.5.0、Rust SDK 0.4.0 和还没发布的 Go SDK ## English -This page puts every version number a plugin meets in one place: `pluginAPIVersion`, the manifest format, the capabilities, the process protocols, and the document formats. **Every version starts at `0` (only capabilities explicitly listed at `1` below have a newer version).** The normative text is [Versioning](../contract/v1/README.md#versioning), [Capabilities](../contract/v1/README.md#capabilities), [Host capabilities](../contract/v1/README.md#host-capabilities), and [Publishing](../contract/v1/README.md#publishing) in [`contract/v1/README.md`](../contract/v1/README.md). Where this page disagrees with the contract, the contract wins; please report it in the [Lithe-core-rust issues](https://github.com/Lithe-IDEA/Lithe-core-rust/issues). +This page puts every version number a plugin meets in one place: `pluginAPIVersion`, the manifest format, the capabilities, the process protocols, and the document formats. **Each series starts at `0`; choose existing `1`, `2`, or later entries from the table and the target host's actual support rather than forcing every value to `0`.** The normative text is [Versioning](../contract/v1/README.md#versioning), [Capabilities](../contract/v1/README.md#capabilities), [Host capabilities](../contract/v1/README.md#host-capabilities), and [Publishing](../contract/v1/README.md#publishing) in [`contract/v1/README.md`](../contract/v1/README.md). Where this page disagrees with the contract, the contract wins; please report it in the [Lithe-core-rust issues](https://github.com/Lithe-IDEA/Lithe-core-rust/issues). The Core column follows the Core source on this repository's `main` (`SUPPORTED_CAPABILITIES` in [`capabilities.rs`](https://github.com/Lithe-IDEA/Lithe-core-rust/blob/main/rust/crates/plugin-model/src/capabilities.rs), `SUPPORTED_PLUGIN_API_VERSIONS` in [`plugin-manifest/src/lib.rs`](https://github.com/Lithe-IDEA/Lithe-core-rust/blob/main/rust/crates/plugin-manifest/src/lib.rs)); the Lithe desktop column follows the desktop client's [declarations and notes](https://github.com/1lck/Lithe-IDEA/blob/main/desktop/internal/pluginhost/pluginhost.go). Validating a capability is not running it: the marketplace offers only versions whose requirements the host declares. @@ -140,7 +141,8 @@ A capability version decides **whether a plugin installs**; a protocol version d Future changes follow the contract's rules: -- A change adds one new version (`1`) to exactly **one** capability, and the manifest section and the protocol move together. A plugin that does not use the change keeps `0` and stays installable wherever it was. +- Reuse and compatibly extend the appropriate API-01–44 domain first. A requirement specific to a plugin, language server, or build tool must not raise any system API version. Even a public, non-specific change may propose a new version only when compatible extensions cannot express it safely; see the [API PR guide (Chinese)](../guides/plugin-api-pr-guide.zh-CN.md#3-api-版本怎么处理). +- A necessary new version affects only the owner of that public change, with its manifest section and protocol kept together. Other plugins retain the existing versions they need; existing `1`, `2`, or later versions are not reset or removed. - A released capability version never changes meaning, and hosts keep supporting it. - A plugin declares only the capabilities it uses, each at the **lowest** version that covers its use. Raising one without using what it adds only cuts off older hosts. - Moving a plugin to a new capability version needs a new plugin version; the index keeps the last version with the previous requirements so older hosts still have one to install. @@ -155,7 +157,7 @@ Future changes follow the contract's rules: ### Capability versions (`requires`) -Each row is one capability. `requires` lists **exactly** the capabilities a manifest uses: leaving one out or listing an unused one is `plugin.manifest.invalid`; each value is the lowest version that covers the plugin's use, so `0` unless the plugin uses something a version `1` added. [Process start](../contract/v1/README.md#process-start) and [Executable resolution](../contract/v1/README.md#executable-resolution) belong to the base contract and are not capabilities; `requires.serverProcess` is refused like any unknown capability. +Each row is one capability. `requires` lists **exactly** the capabilities a manifest uses: leaving one out or listing an unused one is `plugin.manifest.invalid`; each value is the lowest existing version that covers the plugin's actual use, selected from the `0`, `1`, `2`, or later entries below. [Process start](../contract/v1/README.md#process-start) and [Executable resolution](../contract/v1/README.md#executable-resolution) belong to the base contract and are not capabilities; `requires.serverProcess` is refused like any unknown capability. | Version | Content | Core | Lithe desktop | See | | --- | --- | --- | --- | --- | diff --git a/shared/plugins/reference/protocol-changelog.md b/shared/plugins/reference/protocol-changelog.md index 01cb9a1a..8bb978a3 100644 --- a/shared/plugins/reference/protocol-changelog.md +++ b/shared/plugins/reference/protocol-changelog.md @@ -14,6 +14,7 @@ ## 待合入 +- 本 PR(创建后补齐链接),[@xiaoyumuxi](https://github.com/xiaoyumuxi)(—,贡献规则与版本说明):新增插件 API PR 提交指南,明确 API-01–44 是可扩展领域、特有需求不得提升任何系统 API 版本,公共变化也须先证明兼容扩展不足;保留已有 1、2 等版本并按实际用法选最低值。要求统一日志具备可定位语义并集中脱敏、错误码全契约查重、Rust/Go/Node/Java 四个 SDK 在同一 PR 补齐,example 可后补。Core AI 入口及中英导航、契约和版本页同步纠正机械升版与全部填 0 的旧表述。没有新增运行时字段、方法、通知、错误码或版本;合入日期在合并时补齐。 - [#190](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/190),[@xiaoyumuxi](https://github.com/xiaoyumuxi)(API-07/08,`pluginAPIVersion` 0 内补充):Core 新增 `workspace.watchPlan`、`workspace.watchEvents`、`workspace.findFiles`、`workspace.findText`,宿主方法保持原名和权限。路由前严格校验监听与搜索参数,复用文件匹配、编码和隐藏/索引规则,以 no-follow 句柄处理实时磁盘;搜索分页有查询绑定游标、200 条总上限、取消和 30 秒预算,监听投影有排序去重、隐藏过滤和溢出重扫。桌面使用 Viva 原生事件,订阅受插件/会话/上下文约束,注册后先发重扫,释放前停止通知;无空闲轮询。macOS 原生事件与资源释放已验证,Windows 原生验证本轮未执行。没有新增协议版本、宿主方法或通知;合入日期在合并时补齐。 - [#190](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/190),[@xiaoyumuxi](https://github.com/xiaoyumuxi)(API-06,`pluginAPIVersion` 0 内补充):Core 新增 `workspace.readDirectory`、`workspace.stat`、`workspace.readFile` 三个执行命令;宿主方法保持原名和权限。路由前严格校验上下文、资源、未知字段与分页/读取上限。补齐 no-follow、Windows reparse point、稳定有界分页、磁盘 UTF-8/base64 和截断前缀 identity 的公开行为及共享 fixture;Node SDK 同步明确前缀 identity 类型与可空修改时间;其他 SDK 保留通用 JSON 返回值。没有新增协议版本、方法或通知。合入日期在合并时补齐。 @@ -289,7 +290,7 @@ 修改 `shared/plugins/contract/v1/`、`rust/crates/plugin-model/src/capabilities.rs` 或 `rust/crates/plugin-rpc/src/` 的 Core PR,在**同一个 PR** 里更新本页: -1. 把这个 PR 补到时间线最上面(按合入日期分组):PR、修改人、API 编号、协议 / 能力、改了什么。新增的版本号要加粗,并写进“按协议查首次出现”里对应的表:例如给 `buildProviders` 加版本 `1`,就在能力表里为它加一行,并在进程协议表里同步 `litheBuild`。一个 PR 只给一个能力加一个版本。 +1. 把这个 PR 补到时间线最上面(按合入日期分组):PR、修改人、API 编号、协议 / 能力、改了什么。不升版的兼容扩展同样登记;是否允许引入新版本,先按契约 [Versioning](../contract/v1/README.md#versioning) 和 [API PR 提交指南](../guides/plugin-api-pr-guide.zh-CN.md#3-api-版本怎么处理) 判断,不能照搬历史升版先例。确有新版本时才加粗,并写进“按协议查首次出现”里的对应表;所属能力与进程协议保持一致。 2. “API 编号”填这个 PR 涉及的全部 API-01–44 编号,取自 PR 描述里的“原计划编号”。PR 没写时按 [API 实施计划](https://github.com/1lck/Lithe-IDEA/blob/main/docs/development/macos-plugin-api-plan.md) 判断,不要自编新号;不属于任何编号的写 —。 3. PR 新增或修改了宿主方法或通知时,每个方法在“宿主方法(按 API 编号)”表里加一行,写明 API 编号、协议、日期和 PR;同时在 [API 总表](api-catalog.md#已公开的宿主方法)的中英两张方法表里各加一行,写明用途、权限和协议。同一个 API 下的方法分几个 PR 加入时,各自登记自己的 PR。 4. “修改人”填 PR 作者的 GitHub 账号,写成 `[@账号](https://github.com/账号)`。账号可以这样查: