Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -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 实现的纯文档任务只运行相关文档校验。
14 changes: 10 additions & 4 deletions shared/plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,在本地验证 | [贡献与维护](#贡献与维护) |

### 插件是什么
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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/` 的提交都会运行它们。

| 命令 | 作用 |
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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 |
Expand Down
54 changes: 36 additions & 18 deletions shared/plugins/contract/v1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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": [<that version>]}`; the process answers `{"version": <that
Expand All @@ -978,11 +979,27 @@ per capability.
all the others are `0`.
3. **A host declares a capability version when it can serve every form of
it.** See [Host capabilities](#host-capabilities).
4. **A future change gives one capability version `1`.** The manifest section
and the protocol move together, a plugin that uses the change lists
`"<capability>": 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`,
Expand Down Expand Up @@ -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.<capability>"`, 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.
Expand Down Expand Up @@ -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

Expand Down
Loading
Loading