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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

状态:已实现

归档日期:2026-11-11

> 已被[插件契约从统一基线 0 开始](../../implemented/architecture/2026-11-11-plugin-contract-single-baseline.md)取代。

> Viva 迁移状态:能力版本规则存在于固定修订的 Rust Core 和共享插件契约;当前桌面端已有市场索引校验与后端桥接,尚未完成插件安装和各能力的产品接入。下文的旧客户端验收不代表 Viva 已支持所有列出的能力;历史验证入口见[迁移前笔记](https://github.com/1lck/Lithe-IDEA/blob/5a54c41aa37a4e6e6b68918a4b05765b9dd07a36/.agents/notes/implemented/architecture/2026-10-17-plugin-capability-versions.md)。

## 先说结论
Expand Down Expand Up @@ -162,7 +166,7 @@ backend 模块,不增加第二个开关。正确做法是让纯定义插件通
- Lithe-core-rust 锁定修订:[rust/lithe-core/src/plugins/capabilities.rs](https://github.com/Lithe-IDEA/Lithe-core-rust/blob/0ffd327b4329261e393b08ed76fbd134b4dd17e9/rust/lithe-core/src/plugins/capabilities.rs)
- Lithe-core-rust 锁定修订:[rust/lithe-core/src/plugins/declarative.rs](https://github.com/Lithe-IDEA/Lithe-core-rust/blob/0ffd327b4329261e393b08ed76fbd134b4dd17e9/rust/lithe-core/src/plugins/declarative.rs)
- Lithe-core-rust 锁定修订:[rust/lithe-core/src/plugins/marketplace.rs](https://github.com/Lithe-IDEA/Lithe-core-rust/blob/0ffd327b4329261e393b08ed76fbd134b4dd17e9/rust/lithe-core/src/plugins/marketplace.rs)
- `shared/contracts/plugins/v1/`
- `https://github.com/Lithe-IDEA/Lithe-core-rust/blob/main/shared/plugins/contract/v1/`
- `shared/contracts/rust-core-api.md`
- `desktop/internal/core/plugin_session.go`
- `desktop/internal/marketplace/`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

状态:已实现

归档日期:2026-11-11

> 已被[插件契约与开发资料只在 Rust Core](../../implemented/architecture/2026-11-11-plugin-contract-single-source-in-core.md)取代:Rust Core 拆成独立仓库后,契约、开发资料和 SDK 都并入 Core 的 `shared/plugins/`,lithe-plugin-docs 停止维护。

## 先说结论

插件契约(`shared/contracts/plugins/v1/`,规定 `plugin.json` 每个字段的含义、错误码和标准答案用例)仍然在主仓库定义,由 Rust Core 执行。公开仓库 `Lithe-IDEA/lithe-plugin-docs` 的 `contract/v1/` 保存这个目录的**完整逐字节副本**,另外放开发指南、从 Lithe Store 搬过来的两篇教程、两个官方 SDK(源码、发版和端到端测试)和示例插件列表。插件开发者只看 lithe-plugin-docs 就能开发,写插件、发布插件都不需要克隆主仓库,也不需要给主仓库提 PR。
插件契约(`Lithe-core-rust/shared/plugins/contract/v1/`,规定 `plugin.json` 每个字段的含义、错误码和标准答案用例)仍然在主仓库定义,由 Rust Core 执行。公开仓库 `Lithe-IDEA/lithe-plugin-docs` 的 `contract/v1/` 保存这个目录的**完整逐字节副本**,另外放开发指南、从 Lithe Store 搬过来的两篇教程、两个官方 SDK(源码、发版和端到端测试)和示例插件列表。插件开发者只看 lithe-plugin-docs 就能开发,写插件、发布插件都不需要克隆主仓库,也不需要给主仓库提 PR。

日常开发要记住四件事:

Expand Down Expand Up @@ -38,7 +42,7 @@

- `README.md`:中文开发指南,讲插件结构、API 等级怎么选、编辑器校验、后端 SDK 和示例插件。
- `guides/`:从 Lithe Store 搬来的《LSP 插件完整生命周期》和《构建、运行与测试接入》。契约链接改为本仓库的 `contract/v1/`,发布相关链接指向 Store。
- `contract/v1/`:主仓库 `shared/contracts/plugins/v1/` 整个目录的逐字节副本,包括 README、两份 schema 和全部 fixture。
- `contract/v1/`:主仓库 `Lithe-core-rust/shared/plugins/contract/v1/` 整个目录的逐字节副本,包括 README、两份 schema 和全部 fixture。
- `contract.lock.json`:记录来源仓库、来源目录、commit 和每个文件的 SHA-256,格式与 Cargo 插件的 `sdk.lock.json` 相同。
- `sdk/node`、`sdk/java`:两个官方 SDK 和各自的示例插件;`sdk/e2e`:两个示例共用的端到端场景(Rust 测试文件)。
- `scripts/contract.mjs` 提供四个命令:
Expand All @@ -61,7 +65,7 @@ Store 的 `validate-index.mjs` 仍然实现索引规则。它的 CI 原来比较
### Schema 地址固定为 docs 仓库的 raw 地址

契约目录里每份 schema(包括子目录里的)的 `$id` 是它在 docs 仓库里的地址:
`https://raw.githubusercontent.com/Lithe-IDEA/lithe-plugin-docs/main/contract/v1/<目录内路径>`。
`https://raw.githubusercontent.com/Lithe-IDEA/Lithe-core-rust/main/shared/plugins/contract/v1/<目录内路径>`。

两边都对这个地址做严格检查:

Expand Down Expand Up @@ -100,7 +104,7 @@ Core 解析清单时拒绝未知字段(serde `deny_unknown_fields`),schema

### fixture 按能力命名

`shared/contracts/plugins/v1/fixtures/` 中的 fixture 改为按演示的能力命名,ID 同步改成 `dev.lithe.fixture.<新名字>`:
`Lithe-core-rust/shared/plugins/contract/v1/fixtures/` 中的 fixture 改为按演示的能力命名,ID 同步改成 `dev.lithe.fixture.<新名字>`:

| 原名 | 新名 | 演示什么 |
| --- | --- | --- |
Expand All @@ -116,13 +120,13 @@ Core 解析清单时拒绝未知字段(serde `deny_unknown_fields`),schema

fixture 的内容仍然用 Cargo、Go、Gradle、Maven 作为真实输入,契约 README 写明“它们不是这些插件”。macOS 测试中同 ID 的展示用副本(`macos/Tests/LitheTests/Fixtures/BuildSystems/`)一起改名。

`shared/fixtures/plugins/language-support-v1.json` 保留旧 ID `dev.lithe.fixture.go-support`。它是已退役的 schema 1 格式,只被 `rust/lithe-core/src/tests/plugins.rs` 的旧格式测试读取,与声明式契约无关。
`shared/fixtures/plugins/` 不再保存旧格式的插件清单 fixture。声明式插件的清单 fixture 只有 `Lithe-core-rust/shared/plugins/contract/v1/fixtures/` 这一套。

### SDK 整体移到 lithe-plugin-docs

SDK 是给插件开发者用的库,不是契约。开发者要读它的 README、看示例、提问题、下载发布包,这些都应该在 lithe-plugin-docs 完成,所以 `sdk/`、SDK 端到端测试和两个发版工作流都从主仓库移走,主仓库只保留契约。

- **发版**:lithe-plugin-docs 打 `sdk-node-v<版本>` 或 `sdk-java-v<版本>` 标签,`release-node-sdk.yml`、`release-java-sdk.yml` 发布包和 `.sha256`。具体规则见 [官方插件后端 SDK](2026-10-20-plugin-backend-sdk.md)。Java SDK 0.1.0 是迁移前从主仓库发布的,那个 Release 保留,Maven 插件锁定的下载地址不变。
- **发版**:lithe-plugin-docs 打 `sdk-node-v<版本>` 或 `sdk-java-v<版本>` 标签,`release-node-sdk.yml`、`release-java-sdk.yml` 发布包和 `.sha256`。具体规则见 [官方插件后端 SDK](../../implemented/architecture/2026-10-20-plugin-backend-sdk.md)。Java SDK 0.1.0 是迁移前从主仓库发布的,那个 Release 保留,Maven 插件锁定的下载地址不变。
- **单元测试**:SDK 自己的测试读 `contract/v1/fixtures/backend/function-protocol.json`,也就是契约副本,不再读主仓库。
- **端到端测试**:场景仍是 Rust 测试,要链接 Rust Core。`sdk-e2e.mjs` 把锁文件记录的主仓库 commit 稀疏检出到 `.artifacts/lithe`(只取 `rust/` 和 `shared/`),把 `sdk/e2e` 复制进它的 `rust/lithe-core/tests/`,再用 `cargo test --locked` 运行。`LITHE_PLUGIN_SDK_ROOT` 告诉测试示例插件在哪里。这和 Cargo 插件测 Core 的方式相同。
- **两个版本的 Core**:每次提交测契约副本锁定的那个 commit,保证 SDK、契约副本和 Core 是同一个版本;每周再用 `--ref preview` 测主仓库 `preview` 分支的最新 Core,提前发现 Core 的改动破坏了 SDK。
Expand All @@ -131,7 +135,7 @@ SDK 是给插件开发者用的库,不是契约。开发者要读它的 README

### 正确做法

- 修改契约:在同一个 PR 里改 `shared/contracts/plugins/v1/`、Core 和测试。合并后,在 lithe-plugin-docs 运行 `node scripts/contract.mjs sync --revision <合并后的 preview commit>`,然后提交。
- 修改契约:在同一个 PR 里改 `Lithe-core-rust/shared/plugins/contract/v1/`、Core 和测试。合并后,在 lithe-plugin-docs 运行 `node scripts/contract.mjs sync --revision <合并后的 preview commit>`,然后提交。
- 改了 `plugin-index.schema.json`:同步 docs 仓库之后,Lithe Store 的 CI 会失败,按 Store 的 `docs/maintainers.md` 更新索引校验和记录的哈希。
- 在契约 README 里引用目录外的文件:写 `https://github.com/1lck/Lithe-IDEA/blob/preview/<路径>`。
- 新增 fixture:按演示的能力命名,例如 `build-command-stdout.plugin.json`,ID 使用 `dev.lithe.fixture.` 前缀。
Expand Down Expand Up @@ -209,7 +213,7 @@ npm 是 Node 开发者最熟悉的方式。但插件包安装后没有 `npm inst
## 适用范围

- `AGENTS.md`
- `shared/contracts/plugins/v1/`
- `https://github.com/Lithe-IDEA/Lithe-core-rust/blob/main/shared/plugins/contract/v1/`
- ~~scripts/architecture/verify-shared-contracts.sh~~(脚本已随旧客户端移除)
- ~~`scripts/plugins/plugin-settings-schema.test.mjs`~~(已随 #1794 移除)
- ~~`scripts/rust-core/verify-rust-core-crates.sh`~~(已随 #1794 移除)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ LSP 控制中心和语言工具发现沿用现有 Rust Core LSP 会话。组合

### 6. 跨平台实现保持相同边界

macOS 使用声明式插件包和 publisher Ed25519 包签名;Windows 使用自己的 Tauri 插件包和平台签名、缓存适配器,接入共享契约 `shared/contracts/plugins/v1/` 时复用同一份声明语义。Windows 不得因为跨平台而把 macOS 的目录或构建脚本复制到 Windows。两端都必须满足:插件自有资源、构建时校验、运行时只读安装目录、禁用和卸载可清理自有资源。
macOS 使用声明式插件包和 publisher Ed25519 包签名;Windows 使用自己的 Tauri 插件包和平台签名、缓存适配器,接入共享契约 `Lithe-core-rust/shared/plugins/contract/v1/` 时复用同一份声明语义。Windows 不得因为跨平台而把 macOS 的目录或构建脚本复制到 Windows。两端都必须满足:插件自有资源、构建时校验、运行时只读安装目录、禁用和卸载可清理自有资源。

## 考虑过的备选方案

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

官方语言插件(Go、PHP)不再是"在 Lithe 进程里加载的 Swift Bundle",而是声明式插件包:包里只有 `plugin.json` 和它声明的资源(例如打包好的 Intelephense)。Lithe 读取声明,由 Rust Core 校验并展开运行/测试命令,再由宿主自己启动语言服务器和运行进程。插件不在宿主进程内执行任何代码,所以插件包不再依赖宿主二进制,Lithe 每次发版也不用重新编译插件,之后可以把插件拆到独立仓库维护。Go 和 PHP 后来确实拆成了 Lithe Store 社区插件,见 [Go 与 PHP 改为 Lithe Store 社区插件](2026-10-20-go-php-community-plugins.md)。

对日常开发的直接影响:新增语言插件时写 `plugin.json`,不要写 Swift 入口类;声明格式和语义以 `shared/contracts/plugins/v1/` 为准,校验与命令模板展开只在 `rust/lithe-core/src/plugins/declarative.rs` 实现一次。
对日常开发的直接影响:新增语言插件时写 `plugin.json`,不要写 Swift 入口类;声明格式和语义以 `Lithe-core-rust/shared/plugins/contract/v1/` 为准,校验与命令模板展开只在 `rust/lithe-core/src/plugins/declarative.rs` 实现一次。

通用工作台 UI 已通过 API level 2 扩展,见 [宿主管理的工作台 UI 贡献](2026-10-12-workbench-ui-contributions.md)。语言插件的 API level 1 和进程归属保持兼容。

Expand All @@ -24,8 +24,8 @@

### 1. 契约放在 shared,执行放在 Rust Core

- `shared/contracts/plugins/v1/` 定义 `plugin.json`(`schemaVersion: 2`)的字段、权限、激活事件、命令模板变量、错误码和状态语义,并提供合法样例、非法样例(附期望错误码)和命令展开的标准答案。schema 1 是已退役的 macOS 原生清单。
- 兼容性只看 `pluginAPIVersion`(声明式插件 API 级别),不再用写死的 `BuiltInPluginCatalog.hostVersion = 0.3.0` 冒充宿主版本。级别 3 起清单还按能力分版本,见[声明式插件按能力分版本](2026-10-17-plugin-capability-versions.md)。
- `Lithe-core-rust/shared/plugins/contract/v1/` 定义 `plugin.json`(`schemaVersion: 2`)的字段、权限、激活事件、命令模板变量、错误码和状态语义,并提供合法样例、非法样例(附期望错误码)和命令展开的标准答案。schema 1 是已退役的 macOS 原生清单。
- 兼容性只看 `pluginAPIVersion`(声明式插件 API 级别),不再用写死的 `BuiltInPluginCatalog.hostVersion = 0.3.0` 冒充宿主版本。级别 3 起清单还按能力分版本,见[插件契约从统一基线 0 开始](2026-11-11-plugin-contract-single-baseline.md)。
- 校验和模板展开是两端共享的确定性逻辑,按仓库规则放进 Rust Core,通过 `plugins.declarative.validate`、`runPlan`、`discoverTests`、`testPlan` 四个命令暴露。命令是纯函数:宿主每次把清单和请求传进去,Core 不读包、不读工作区。清单内容问题以 `{status: "rejected", error: {code}}` 返回稳定的 `plugin.*` 错误码;只有请求格式错误才是 Core 失败。
- Windows 现有扩展清单暂未改造,契约 README 给出字段对照;Windows 接入时必须通过同一组 fixture。

Expand Down Expand Up @@ -108,7 +108,7 @@ gopls 把 `fmt.Println` 的定义指向 `GOROOT/src/fmt/print.go`,Intelephense

## 适用范围

- `shared/contracts/plugins/v1/`
- `https://github.com/Lithe-IDEA/Lithe-core-rust/blob/main/shared/plugins/contract/v1/`
- Lithe-core-rust 锁定修订:[rust/lithe-core/src/plugins/declarative.rs](https://github.com/Lithe-IDEA/Lithe-core-rust/blob/0ffd327b4329261e393b08ed76fbd134b4dd17e9/rust/lithe-core/src/plugins/declarative.rs)
- ~~`macos/Sources/Lithe/Core/Rust/RustDeclarativePluginOperations.swift`~~(已随 #1794 移除)
- ~~`macos/Sources/LitheCoreContracts/Plugins/DeclarativePluginContracts.swift`~~(已随 #1794 移除)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ Agent 的配置入口由同一个目录补齐,移动到任何已有停靠区
- ~~`macos/Sources/LitheCoreContracts/Plugins/DeclarativePluginContracts.swift`~~(已随 #1794 移除)
- ~~`macos/Sources/Lithe/Views/Workbench/`~~(已随 #1794 移除)
- ~~`macos/Sources/Lithe/Application/Features/WorkbenchFeatureModel.swift`~~(已随 #1794 移除)
- `shared/contracts/plugins/v1/`
- `https://github.com/Lithe-IDEA/Lithe-core-rust/blob/main/shared/plugins/contract/v1/`
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Java 的语言服务器 JDT LS(Eclipse 的 Java 语言服务器,提供补全
| 插件资源 | 集成要读的文件 | `hostIntegration.resources`,由插件声明包内路径 |
| 宿主能力 | 仍由宿主内置实现提供的运行、测试、调试 | `hostIntegration.capabilities`,由插件逐项声明 |

字段语义以 `shared/contracts/plugins/v1/README.md` 为准,校验和模板展开只在 `rust/lithe-core/src/plugins/declarative.rs` 实现一次。
字段语义以 `Lithe-core-rust/shared/plugins/contract/v1/README.md` 为准,校验和模板展开只在 `rust/lithe-core/src/plugins/declarative.rs` 实现一次。

### 2. 契约 API 2 增加的内容

Expand Down Expand Up @@ -219,7 +219,7 @@ dev.lithe.plugin.java-support/

## 适用范围

- `shared/contracts/plugins/v1/`
- `https://github.com/Lithe-IDEA/Lithe-core-rust/blob/main/shared/plugins/contract/v1/`
- Lithe-core-rust 锁定修订:[rust/lithe-core/src/plugins/declarative.rs](https://github.com/Lithe-IDEA/Lithe-core-rust/blob/0ffd327b4329261e393b08ed76fbd134b4dd17e9/rust/lithe-core/src/plugins/declarative.rs)
- 已迁出:原 `Plugins/mac/Official/JavaSupport/`。官方插件的源码、组装与发布已移出本仓库(#1495),改由各插件仓库自行构建发布([lithe-plugin-java](https://github.com/Lithe-IDEA/lithe-plugin-java)、[lithe-plugin-maven](https://github.com/Lithe-IDEA/lithe-plugin-maven)、[lithe-plugin-gradle](https://github.com/Lithe-IDEA/lithe-plugin-gradle)),Store 索引由 Lithe Store 维护。
- 已迁出:原 `scripts/plugins/build-official-plugins.sh`。官方插件的源码、组装与发布已移出本仓库(#1495),改由各插件仓库自行构建发布([lithe-plugin-java](https://github.com/Lithe-IDEA/lithe-plugin-java)、[lithe-plugin-maven](https://github.com/Lithe-IDEA/lithe-plugin-maven)、[lithe-plugin-gradle](https://github.com/Lithe-IDEA/lithe-plugin-gradle)),Store 索引由 Lithe Store 维护。
Expand Down
Loading
Loading