Skip to content

docs: 同步插件契约到 #1595 并新增插件后端工作区指南 - #6

Merged
xiaoyumuxi merged 1 commit into
mainfrom
sync/1548-plugin-host-api
Oct 30, 2026
Merged

xiaoyumuxi merged 1 commit into
mainfrom
sync/1548-plugin-host-api

Conversation

@xiaoyumuxi

Copy link
Copy Markdown
Contributor

配合 1lck/Lithe-IDEA#1595(插件后端工作区上下文与宿主服务)同步契约,并补开发者指南。

1. 契约同步(contract/v1、contract.lock.json)

  • 用 node scripts/contract.mjs sync --revision f20601ee6194f32d597031556ea628de586ac2e2 同步,固定到 #1595 的当前 head。原来固定的是 32021a86f。
  • #1595 带来的变化:
    • requires.backend: 2:可以不经页面启动,启动方式有 onWorkspaceOpen、onCommand、网页工具窗口;新增 workspace.metadata 权限。
    • 插件函数协议 3:getCapabilities、subscriptions/dispose、workspace/listContexts|getContext|getFolders,函数调用的 params.context。
    • 宿主通知:didChangeContexts、commands/didRun、subscriptions/notify。
    • 带类型的宿主失败码 -32010~-32021 和 details。
    • “协议 3 内只增不改”规则:不认识的字段回 -32018 plugin.host.unsupportedOption,details.option 指明是哪个字段。
  • preview 上自 32021a86f 以来已合入的契约变化也一并进来:构建提供者的执行、测试、运行与调试准备、只读模型输入,以及调试适配器的补充用例和多个新 fixture。

合并前要重新同步。 按主仓库规则,契约副本应固定到合并后的 preview 提交。#1595 合并后要运行
node scripts/contract.mjs sync --revision <合并后的 preview commit> 并把结果推到本分支,然后才能把这个 PR 标为 ready。
现在固定在 PR head,是为了让评审能提前看到契约差异,并让 CI 对着这个提交跑 SDK E2E。

2. 新指南 guides/plugin-backend-workspace.md

  • 三个版本号各管什么:requires.backend、litheFunctions.version、getCapabilities.services。
  • 最小清单和启动时机。
  • 怎么协商协议 3,以及 getCapabilities 的应答示例(取自契约 fixture)。
  • 工作区上下文各字段的用法,以及 contextExpired 之后怎么重试。
  • 三种宿主通知。
  • 失败码表,每个码附后端通常的处理方式。
  • 协议 3 只增不改时后端要遵守的四条规则:
    • 只调用 services 列出的方法;
    • 忽略不认识的字段和通知;
    • 遇到 unsupportedOption,去掉那个选项后重试;
    • 不认识的号码按一般失败处理。
  • 指南标注了“开发中”:backend 2 和协议 3 还没进稳定版。

README 的教程表新增了这篇指南的链接。

3. 没有改的

  • SDK 没改。 三个 SDK 都还停在协议 1 或 2,宿主提供 [1, 2, 3] 时会选自己支持的最高版本,不受影响。Rust SDK 的宿主错误本来就保留 data.code 和 JSON-RPC 号码,未知号码按一般失败处理,已经符合协议 3 对后端的要求。给 SDK 加协议 3(getCapabilities、工作区上下文、通知回调)等宿主进稳定版后单独做,避免 SDK 提前发布宿主还没提供的能力。

验证(本地)

  • node --test scripts/*.test.mjs:0 失败。
  • node scripts/contract.mjs verify --upstream:56 个文件与 f20601ee6 一致。
  • node scripts/contract.mjs drift --ref codex/1548-plugin-host-api:无漂移。
  • node scripts/sdk-e2e.mjs --source https://github.com/1lck/Lithe-IDEA.git --ref codex/1548-plugin-host-api:Node、Java、Rust 三个场景全部通过。
  • SDK 单测:
    • node --test sdk/node/test/*.test.mjs:57 个通过。
    • cargo test --locked --manifest-path sdk/rust/Cargo.toml:全部通过。
    • mvn -f sdk/java/pom.xml verify:通过。

…ce guide

- Sync contract/v1 to 1lck/Lithe-IDEA@f20601ee6 (PR #1595 head): backend 2
  workspace contexts, plugin-function protocol 3 (getCapabilities, workspace
  service, host notifications, typed host failures, unsupportedOption with
  details.option, the "extend version 3 additively" rule), plus the build
  provider and debug adapter contract changes merged into preview since
  32021a86f.
- Add guides/plugin-backend-workspace.md: manifest, start triggers,
  negotiating version 3, capability discovery, contexts, notifications,
  failure codes, and the four rules a version 3 backend follows.
- List the guide in the README tutorials.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant