Skip to content

feat(plugins): 命令安装器支持固定 URL 归档下载(commandInstallers 1) - #133

Merged
xiaoyumuxi merged 1 commit into
mainfrom
feat/command-installer-archives
Nov 20, 2026
Merged

xiaoyumuxi merged 1 commit into
mainfrom
feat/command-installer-archives

Conversation

@xiaoyumuxi

Copy link
Copy Markdown
Contributor

关联 Issue

无独立 Issue。用于 Rust Support 插件(API-23)按需下载 CodeLLDB:调试器不打进插件包,第一次调试缺命令时由宿主提示安装,体验与 Go 插件安装 dlv 一致。

类型

  • feat:commandInstallers 能力版本 1,新增固定 URL 归档下载安装

改动说明

清单与校验(plugin-manifest)

  • 新增 archives.rs:managedRuntimes 依赖和命令下载共用的归档声明校验(HTTPS 无凭据/片段的 URL、最多 8 个唯一镜像、完整 SHA-256 并转小写、zip/tar.gz、stripPrefix 布局路径、平台 os/arch)。managed_runtimes.rs 改为调用这套共用逻辑,行为不变。
  • commandInstallers[].download:version 加 1–6 个平台归档(每个平台最多一个),与 tool、minimumVersion、arguments 互斥;只能用 managed 目标,不带 arguments、environment,commandDirectory 相对解压根目录;mayUseNetwork 必须为 true;清单 requires.commandInstallers 必须 ≥ 1。
  • capabilities.rs:commandInstallers 支持 [0, 1]。

Core API(plugins.commandInstallers.requirements / plan)

  • 两个请求新增可选 platform: {os, arch};不支持的平台返回 plugin.commandInstaller.platformInvalid。
  • requirements:安装条目新增 download: null | {version};带 platform 时没有该平台归档的下载安装不列出。
  • plan:下载安装必须带 platform、不接受 installDirectory;没有该平台归档返回 plugin.commandInstaller.unavailable。计划的 arguments、environment、directoryProbes 为空、commandDirectory 为 null,新增 download:选中归档的 installer、version、os、arch、url、sha256、archive、stripPrefix、mirrors、cacheKey、commandDirectory。cacheKey 是规范 JSON(不含镜像)的 SHA-256,改地址、摘要、格式、版本或布局都会换新目录。工具安装的计划 download 为 null。
  • 审查程序(approval program)对下载安装列出全部归档,改地址、镜像、摘要或版本都需要重新批准。

契约与文档

  • plugin-manifest.schema.json:commandInstallers 条目改为 tool / download 二选一,新增归档 $defs。
  • 契约 README:命令安装一节重写,新增“Download installers”“Installation steps”,补错误码表(Core:platformInvalid、unavailable;宿主:downloadFailed、checksumMismatch、archiveInvalid,failed 只指工具安装失败)。
  • fixture:新增 command-installer-download.plugin.json;command-installer-plans.json 共 28 个用例;invalid-manifests.json 新增 22 个非法清单。
  • 能力版本表、工具链领域页(中英)、API 总表 API-23 行、rust-core-api.md、协议更新记录(commandInstallers 1 条目和首次出现表)。

本 PR 不新增或修改插件宿主方法(lithe/host/*)、宿主通知或 SDK 版本,所以没有“原计划编号 | 方法 | 用途”表;改动属于 API-23 的清单声明和 Core API 请求参数。桌面端实现下载、校验、解压和界面在 Lithe-IDEA 的后续 Draft PR。

验证

  • cargo test --workspace(rust/):19 组全部通过(含 lithe-core 876 项)。
  • cargo test -p lithe-plugin-manifest、lithe-core 的 declarative_plugins 定向测试通过。
  • cargo fmt --all --check、cargo clippy --workspace --all-targets -- -D warnings 通过。
  • node shared/plugins/scripts/verify-docs.mjs 通过;新 fixture 用 ajv 对 schema 校验通过。
  • 用 CodeLLDB v1.12.3 五个平台的真实 vsix 核对了 SHA-256 和压缩包布局(extension/adapter/codelldb,zip 保留可执行位)。
  • 没改插件后端协议,未运行 sdk-e2e.mjs。

范围检查

  • 通用的声明校验、平台选择和计划在 Core,下载、校验、解压由宿主做。
  • 不依赖具体插件,fixture 用示例插件。
  • 没有新增宿主方法、SDK、日志旁路或运行时资源写入。
  • Draft 提交,不触发合并。

API-23 的 commandInstallers 升到能力版本 1,新增 download 安装方式:
插件按平台声明固定 HTTPS URL、可选镜像、完整 SHA-256、zip/tar.gz 格式和
stripPrefix,宿主下载、校验、解压后在 managed 目标的 commandDirectory 下查找命令。

- 新增 archives.rs,managedRuntimes 与 commandInstallers 共用归档声明校验。
- requirements/plan 接受宿主平台;下载计划给出所选归档、cacheKey 和命令目录。
- 更新 manifest schema、契约 README、fixture、能力版本表与协议更新记录。
@xiaoyumuxi
xiaoyumuxi marked this pull request as ready for review November 20, 2026 14:18
@xiaoyumuxi
xiaoyumuxi merged commit 72036de into main Nov 20, 2026
10 checks passed
xiaoyumuxi added a commit that referenced this pull request Nov 20, 2026
* fix(toolchain): 外部安装的多入口链接保留布局里的文件名

rustup 把 ~/.cargo/bin/cargo、rust-analyzer 链接到自身,按启动时的名字决定运行哪个工具。
Core 校验外部安装后返回规范路径,把 cargo 解析成 rustup,版本探针运行的是 rustup,
cargo 因此永远找不到。

布局文件链接到另一个文件名时,返回规范主目录下的布局路径;链接目标的类型、可执行位和
不越出主目录、不进入工作区的检查不变。同名链接(版本管理器别名等)仍返回规范路径。

顺带把已合入的 #112、#127、#128、#130、#133 从协议更新记录的“待合入”移到时间线。

* docs(plugins): 协议更新记录登记 #135
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