Skip to content

Commit fa1c2ee

Browse files
authored
docs(plugin-api): document API extension PR requirements (#191)
1 parent 5fa6f58 commit fa1c2ee

7 files changed

Lines changed: 312 additions & 29 deletions

File tree

‎AGENTS.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Core 开发入口
2+
3+
开始工作前阅读 [CONTRIBUTING.md](CONTRIBUTING.md)。插件契约、指南、参考与官方 SDK 的维护入口是 [shared/plugins/README.md](shared/plugins/README.md)。
4+
5+
新增或修改公共插件 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 可以后补。
6+
7+
契约规定的已有字段和运行时行为以 [contract/v1/README.md](shared/plugins/contract/v1/README.md) 为准;历史升版先例不能替代本次的版本判断。未修改契约或 SDK 实现的纯文档任务只运行相关文档校验。

‎shared/plugins/README.md‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
| 参考现成插件 | [示例插件](#示例插件) |
1818
| 查 API-01–44 现在能用什么、每种能力和协议的版本、Core 和 Lithe 桌面端支持哪些 | [插件参考](reference/README.md) |
1919
| 查字段的准确含义 | [插件契约](#插件契约) |
20+
| 为插件需要的公共 API 提 PR | [API PR 提交指南(中文)](guides/plugin-api-pr-guide.zh-CN.md) |
2021
| 修改契约、指南或 SDK,在本地验证 | [贡献与维护](#贡献与维护) |
2122

2223
### 插件是什么
@@ -56,12 +57,12 @@ Lithe 读取并校验 `plugin.json`,然后自己启动其中声明的外部进
5657
| --- | --- | --- |
5758
| `schemaVersion` | `0` | 清单的文件格式 |
5859
| `pluginAPIVersion` | `0` | 插件 API 版本,Lithe 据此判断能不能读你的清单 |
59-
| `requires` | 每个用到的能力写 `0` | 你的插件用了哪些能力;Lithe 只在支持这些能力时才提供安装 |
60+
| `requires` | 每个用到的能力取已有的最低可用版本 | 你的插件用了哪些能力;Lithe 只在支持这些能力时才提供安装 |
6061
| `version` | 你自己定 | 你的插件自己的版本 |
6162

6263
`requires` 必须**恰好**列出实际用到的能力:漏一个或多列一个,清单都会被拒绝。例如只用声明式构建系统时写 `"requires": { "buildSystems": 0 }`,不要多写。
6364

64-
能力以后可能出新版本。一次改动只给一个能力加一个新版本,没用到它的插件继续写 `0`,继续可以安装。每个能力的内容、Core 的支持表和 Lithe 桌面端是否声明它,见[能力与协议版本对照](reference/capabilities-and-versions.md#能力版本requires);Lithe 桌面端没有声明的能力,需要它的插件不会被提供安装。
65+
已有的能力版本继续保留,按实际用法选择最低可用版本;用到 `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 桌面端没有声明的能力,需要它的插件不会被提供安装。
6566

6667
### 在编辑器里校验 plugin.json
6768

@@ -193,6 +194,8 @@ fixture 放在 `fixtures/<功能>/` 下,文件按演示的能力命名,例
193194

194195
### 贡献与维护
195196

197+
为插件补充公共 API 前,先读 [API PR 提交指南](guides/plugin-api-pr-guide.zh-CN.md):包括领域复用、版本限制、兼容与发布顺序、统一日志定位及脱敏、错误码查重,以及四个官方 SDK 的同步交付;example 可以后补。
198+
196199
修改契约、指南、参考或 SDK 的 PR 提到 [Core 仓库](https://github.com/Lithe-IDEA/Lithe-core-rust),和对应的 Rust Core 改动放在同一个 PR 里。下面的命令都在 **Core 仓库的根目录**运行;CI 工作流是仓库根的 `.github/workflows/plugins-verify.yml`,每次涉及 `shared/plugins/` 或 `rust/` 的提交都会运行它们。
197200

198201
| 命令 | 作用 |
@@ -238,6 +241,7 @@ Writing, testing, and publishing a plugin all happen in **your own repository**.
238241
| Learn from existing plugins | [Example plugins](#example-plugins) |
239242
| 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) |
240243
| Look up the exact meaning of a field | [Plugin contract](#plugin-contract) |
244+
| Propose a public API extension for a plugin | [API PR guide (Chinese)](guides/plugin-api-pr-guide.zh-CN.md) |
241245
| Change the contract, guides, or SDKs and verify locally | [Contributing and maintenance](#contributing-and-maintenance) |
242246

243247
### What a plugin is
@@ -277,12 +281,12 @@ When you need run, test, or build tool integration, read the [build, run, and te
277281
| --- | --- | --- |
278282
| `schemaVersion` | `0` | The manifest file format |
279283
| `pluginAPIVersion` | `0` | The plugin API version; Lithe uses it to decide whether it can read your manifest |
280-
| `requires` | `0` for each capability you use | Which capabilities your plugin uses; Lithe offers the plugin for installation only where it supports them |
284+
| `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 |
281285
| `version` | Your choice | Your plugin's own version |
282286

283287
`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.
284288

285-
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.
289+
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.
286290

287291
### Validate plugin.json in your editor
288292

@@ -414,6 +418,8 @@ For questions or suggestions about the contract, [open an issue in the Core repo
414418

415419
### Contributing and maintenance
416420

421+
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.
422+
417423
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/`.
418424

419425
| Command | Purpose |

‎shared/plugins/contract/v1/README.md‎

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ symbolic links. A host treats an installed package as read-only.
190190

191191
Unknown fields are refused (`plugin.manifest.invalid`) so a host rejects a
192192
package instead of ignoring part of it. A new optional field in an existing
193-
section needs no new version; a change to what a section means gives the one
194-
capability that owns it version `1`, and only plugins that use that change
195-
declare it (see [Versioning](#versioning)).
193+
section needs no new version. A semantic change does not automatically justify
194+
a new capability version; it must satisfy [Versioning](#versioning). Existing
195+
versions and strict unknown-field rejection remain in force.
196196

197197
### Languages
198198

@@ -959,14 +959,15 @@ files sorted by path, or an empty list when no project marker is present.
959959

960960
## Versioning
961961

962-
Every version in this contract is `0`. A change adds a version to exactly one
963-
place, so a plugin states what it needs and a host states what it runs, each
964-
per capability.
962+
Version series start at `0`; several capabilities already support `1` or `2`.
963+
Use the [capability and protocol tables](../../reference/capabilities-and-versions.md)
964+
and the target host's actual declarations for existing support. A plugin states
965+
what it needs and a host states what it runs, each per capability.
965966

966967
1. **Capabilities start at `0`.** A manifest lists the capabilities it uses in
967-
`requires`, each with version `0`. A capability version names one manifest
968-
section and, when the capability owns one, the runtime protocol that goes
969-
with it.
968+
`requires`, each at the lowest existing version that covers its actual use.
969+
A capability version names one manifest section and, when the capability owns
970+
one, the runtime protocol that goes with it.
970971
2. **A runtime protocol has no version of its own.** Its version is the owning
971972
capability's, and a host offers exactly that version
972973
(`{"versions": [<that version>]}`; the process answers `{"version": <that
@@ -978,11 +979,27 @@ per capability.
978979
all the others are `0`.
979980
3. **A host declares a capability version when it can serve every form of
980981
it.** See [Host capabilities](#host-capabilities).
981-
4. **A future change gives one capability version `1`.** The manifest section
982-
and the protocol move together, a plugin that uses the change lists
983-
`"<capability>": 1`, and every other plugin keeps `0` and stays installable
984-
wherever it was. An additive optional field in an existing section or
985-
message needs no new version.
982+
4. **Reuse and compatible extension come first.** API-01–44 classify domains,
983+
not a closed method list. Add general methods, notifications, optional fields,
984+
or declarations within the appropriate domain when existing interfaces are
985+
insufficient. An additive optional field preserves its omission behavior
986+
and needs no new version; strict unknown-field validation still applies.
987+
5. **Specific requirements must not raise any system API version.** This covers
988+
plugin-, language-server-, and build-tool-specific needs, including base API,
989+
schema, individual capability, process protocol, and public document-format
990+
versions. Renaming a capability, protocol, or contract directory does not
991+
bypass the restriction. Keep tool-specific knowledge in plugins or upstream
992+
tools, with general typed declarations for data the host must understand.
993+
6. **Only a public, non-specific interface change may propose a new version,
994+
and only when compatible extension cannot safely express it.** The PR must
995+
explain the public use, why optional fields or discovery are insufficient,
996+
why old behavior cannot remain, affected consumers, and migration. Only the
997+
owner of that change may gain a version; unrelated versions stay unchanged.
998+
Security requirements or an old host rejecting unknown fields do not alone
999+
justify a new version. Existing `1`, `2`, and later versions remain valid.
1000+
The [API PR guide (Chinese)](../../guides/plugin-api-pr-guide.zh-CN.md)
1001+
describes compatibility, release order, diagnostics, error-code checks, and
1002+
support in all four official SDKs; new examples may follow later.
9861003

9871004
`pluginAPIVersion` versions only the base fields: `schemaVersion`, `id`,
9881005
`displayName`, `version`, `vendor`, `permissions`, `activationEvents`,
@@ -1014,7 +1031,7 @@ contract version: the plugin that exports the function owns it.
10141031
lowerCamelCase identifiers of at most 64 characters; versions are
10151032
non-negative integers.
10161033
- Core reads `requires` before it decodes any section. A capability this
1017-
contract does not define, or a version other than `0`, is
1034+
contract does not define, or a version absent from its support table, is
10181035
`plugin.api.unsupported` with `field: "requires.<capability>"`, even when the
10191036
manifest also holds a section Core does not know, so the user learns which
10201037
capability needs a newer Lithe instead of seeing an unknown field.
@@ -3810,9 +3827,10 @@ Two rules keep these directions from forming a loop:
38103827
`pluginAPIVersion` nor any `requires` version. Only a function that
38113828
another plugin may call, and a call to such a function, are declared, in
38123829
[`pluginFunctions`](#cross-plugin-calls).
3813-
- A new kind of domain implementation is a new version of the capability that
3814-
owns it, so only plugins that use it are filtered from hosts that cannot run
3815-
it.
3830+
- A new kind of domain implementation follows [Versioning](#versioning); it
3831+
does not automatically require a new capability version. Prefer compatible
3832+
typed declarations and discovery, and define how an unsupported host refuses
3833+
or degrades the new path.
38163834

38173835
### Negotiation
38183836

0 commit comments

Comments
 (0)