Repository navigation
feat(plugins): commandInstallers 让宿主安装 systemCommand 启动缺的命令 - #53
Merged
Merged
Conversation
插件清单新增顶层 commandInstallers[](能力 commandInstallers 0、权限
commands.install),声明怎样用插件已依赖的工具安装 systemCommand 启动用到的
裸命令,例如用 go install 装 dlv。目标有两个:managed 装进宿主为插件管理的
目录(唯一模板变量 ${installDirectory}),toolDefault 装到工具默认位置,并
用探针读出目录。
新增宿主命令 plugins.commandInstallers.requirements、plan、defaultDirectory,
Core 错误码 plugin.commandInstaller.unknown、targetUndeclared、
directoryInvalid、probeOutputsInvalid;安装声明进入安装审查。
lithe-platform 增加 path_list_separator、is_absolute_path、join_native;
is_environment_name 收到 plugin-model::names 一处。
契约 README、schema、fixture、rust-core-api.md、协议更新记录、能力版本、
API 总表和工具链领域页同步更新。
xiaoyumuxi
marked this pull request as ready for review
November 15, 2026 07:11
14 of 20 tasks
宿主每次执行用户确认的安装,用 diagnostics.recordPluginOperation 记一条 commandInstaller/install(命令执行生命周期):计划、找工具、启动、超时、 非零退出各有阶段,正常退出但命令不在目录里记 decode。用户取消不记录。 CONTRIBUTIONS 加一行,契约 README、rust-core-api.md、日志 README 的贡献表 和协议更新记录同步更新;不新增事件、通道或错误码。
This was referenced Nov 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
Go 插件的 Delve 调试适配器和 gopls 语言服务器都是
systemCommand启动,只写裸命令名dlv、gopls。机器上没装时,插件管理的能力卡片只报none of the plan's commands is available,用户得自己开终端跑go install,还要保证$(go env GOPATH)/bin在PATH里。这个 PR 给契约加上「安装缺失的命令」:插件声明怎样用它已经依赖的工具(
requiresTools)安装这些命令,宿主在卡片上显示「未找到」和安装按钮,用户确认命令行、是否联网和安装位置后才运行。安装位置由用户选:装进 Lithe 管理的目录(managed),或者装到工具默认位置(toolDefault)。归入 API-23(工具链)。改动
清单与校验(
rust/crates/plugin-manifest/src/command_installers.rs,新文件)commandInstallers[](最多 16 个),字段id、commands(1–8 个裸命令)、tool、minimumVersion?、字面量arguments、mayUseNetwork(必填)、timeoutSeconds?(1–3600,默认 600)、targets。targets.managed:arguments?(替换安装的参数)和environment可以用唯一的模板变量${installDirectory},而且两者加起来至少要用一次;commandDirectory?是安装目录下命令所在的相对路径。targets.toolDefault:值全是字面量;directory最多 4 个探针,每个有非空arguments,可选pathList(取路径列表第一项)和append(拼接相对路径)。systemCommand启动里(语言服务器、构建提供者、VCS 提供者、调试适配器、后端)。tool必须在requiresTools里,否则返回plugin.runtime.undeclared。_。commandInstallers0 写进plugin-model/src/capabilities.rs,并接入used_capabilities:用了要声明,没用不能声明。commands.install:有安装就必须声明这个权限;没有安装时声明它会被拒绝。kind: "commandInstaller"),改了要运行的内容需要重新批准。宿主命令(
core/src/protocol/command.rs、runtime/dispatcher/plugins.rs)plugins.commandInstallers.requirements{ manifest }systemCommand启动(kind、id)的命令以及提供它的安装(没有时为null);所有安装的摘要plugins.commandInstallers.plan{ manifest, installerID, target, installDirectory? }tool、arguments、environment、timeoutMilliseconds、commandDirectory、directoryProbesplugins.commandInstallers.defaultDirectory{ manifest, installerID, outputs }nullmanaged要求installDirectory是本平台的绝对路径,commandDirectory用本平台的分隔符拼接;探针输出先去掉首尾空白,pathList按本平台的路径列表分隔符切分。plugin.commandInstaller.unknownplugin.commandInstaller.targetUndeclaredplugin.commandInstaller.directoryInvalidplugin.commandInstaller.probeOutputsInvalidplugin.command.missingplugin.commandInstaller.failedplugin.commandInstaller.timedOutplugin.commandInstaller.commandsMissingtarget不是两个目标之一、缺outputs)时,命令直接失败,不返回拒绝。平台与重构
lithe-platform的paths.rs新增三个函数,判断 Windows 绝对路径时不把C:、C:go和\go算作绝对路径:path_list_separatoris_absolute_path:只看文本判断是否绝对路径,Windows 认盘符加分隔符和 UNC 路径。join_nativeis_environment_name,现在收到plugin-model::names一处。行为不变。契约与文档
contract/v1/README.md:## Command installers一节,包括示例(Go 安装 dlv)、字段表、两个目标、限额、宿主的五步流程和不覆盖的范围(invocation.executables)。commands.install权限和错误码表的对应行。plugin-manifest.schema.json:commandInstallers属性和requires.commandInstallers。commands.install。commandInstallers时必须声明这个能力和权限。$defs/commandInstaller、commandInstallerArguments、commandInstallerEnvironment、commandInstallerRelativePath。fixtures/command-installers/command-installer.plugin.json,含两个安装:sample-ls两种目标都有、用环境变量传目录;sample-dap只有managed、替换参数并指定bin。command-installer-plans.json,共 16 个期望结果,与平台有关的用例分别给出unix和windows的结果。invalid-manifests.json增加 20 个拒绝用例。rust/contracts/rust-core-api.md:命令表加三行,Declarative plugins 一节加一段说明。reference/protocol-changelog.md:首次出现表加一行commandInstallers0,2026-11-15 时间线加一行。reference/capabilities-and-versions.md:中英表格各加一行,桌面端标为「未声明」。reference/api-catalog.md:API-23 中英两行补上commandInstallers,并写明桌面端尚未声明。reference/domains/toolchains.md:中英文各新增「安装缺失的命令」一节,并补上桌面端状态、契约章节和示例行。模块注释引用的 Agent Note
.agents/notes/implemented/architecture/2026-11-15-plugin-command-installers.md写在 Lithe-IDEA 主仓库,随桌面端 PR 提交。这和其他 Core 模块引用 Note 的方式一致。不新增
lithe/host/*方法或宿主通知,所以 API 总表和更新记录里没有宿主方法行。commandInstallers;宿主命令plugins.commandInstallers.requirements/plan/defaultDirectory,不是插件可调用的宿主方法验证
cargo test -p lithe-core -p lithe-plugin-manifest -p lithe-platform -p lithe-build -p lithe-project-generators -p lithe-plugin-model -p lithe-plugin-marketplace -p lithe-protocollithe-plugin-manifest的command_installers单元测试lithe-core的declarative_pluginscargo clippy(同上 8 个 crate)--all-targets -- -D warningscargo fmt --all -- --checknode shared/plugins/scripts/verify-docs.mjs没做的验证:
lithe-core测试(本机平台那一组)没有在 Windows 上跑,等 CI 跑。不过 Windows 路径规则已经在lithe-plugin-manifest里按两个平台测过。合入后
PINNED_CORE_REVISION升到合入提交,并声明commandInstallers: [0]。dlv和gopls声明go install安装。