Repository navigation
feat(plugins): 命令安装器支持下载固定地址的压缩包 - #2241
Merged
Merged
Conversation
插件可以在 commandInstallers 里声明下载安装器(commandInstallers 1, Lithe-core-rust#133):为每个平台固定压缩包地址、镜像和 SHA-256。 命令缺失时,用户在对话框里看到地址和校验值,确认后宿主下载、校验、 解压到插件的受管命令目录并记录,之后的 systemCommand 启动能找到命令。 - 下载、镜像选择、校验和安全解压复用 pluginruntime.Manager.Prepare, 发布前检查命令是否在压缩包的命令目录里 - 下载失败、校验值不符、压缩包无效、命令不在压缩包里、超时分别报告, 取消不写失败日志 - 记录新缓存键后删除同一安装器的旧版本目录 - 对话框显示下载地址、镜像、SHA-256 和下载进度 - 宿主声明 commandInstallers [0, 1],Core 固定到 f9af83e
-race 下压缩和解压约 250 MB 的测试二进制超过了 20 秒期限,main 上同样失败。
xiaoyumuxi
marked this pull request as ready for review
November 20, 2026 14:34
15 of 18 tasks
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.
关联 Issue / Linked issue
PR 类型 / Type
改动说明 / What changes
背景 / Why
插件声明的
systemCommand缺命令时,现有命令安装器(API-23,commandInstallers 0)只能调用插件指定的工具来安装,例如go install。有些调试适配器没有包管理器可用,上游只发布按平台打好的压缩包。CodeLLDB 就是这样,每个平台一个
.vsix。这类命令过去只能把压缩包打进插件,会让插件变大,而且每个平台都要单独打包。
Core #133 给 commandInstallers 加了能力版本 1:插件可以为每个平台固定一个压缩包,写明地址、可选镜像、SHA-256、格式(zip / tar.gz)、要去掉的前缀,以及命令在包里的目录。
本 PR 是桌面端的实现。用户在插件能力卡片上点“安装”,确认对话框里列出版本、地址、镜像和摘要,确认后宿主下载、校验、解压到插件自己的托管目录,之后的
systemCommand启动就能找到命令。下载、镜像测速与回退、SHA-256 校验和安全解压,全部复用 managedRuntimes 已有的
pluginruntime.Manager,没有新写下载器。改动 / Changes
Core 客户端(
desktop/internal/core/command_installers.go)CommandInstallerRequirements和PlanCommandInstaller新增platform参数,Core 据此为当前平台选压缩包;没有当前平台压缩包的下载安装器不会出现在需求里。CommandInstaller.Tool改为可空;新增Download(固定版本)。CommandInstallPlan新增Download,内容包括地址、镜像、SHA-256、格式、去前缀、缓存键和命令目录。consistent()校验:下载计划只能是 managed 目标,不能带工具、参数、环境变量或目录探测;工具计划仍然要求“托管安装才有命令目录”。不一致的结果作为解析错误拒绝。插件宿主(
desktop/internal/pluginhost/)commandInstallers支持[0, 1]。plugin.commandInstaller.downloadFailed(所有地址都没下到)、checksumMismatch(SHA-256 不符)、archiveInvalid(不是 zip/tar.gz,或条目不能安全解压)。CommandInstallError增加Err和Unwrap,诊断里带上底层原因。commands/<安装器 ID>/的布局注释补上下载安装器的<缓存键>/子目录。托管运行时(
desktop/internal/pluginruntime/、desktop/internal/pluginservice/)pluginruntime.ErrDownload:所有候选地址都失败时,用它包住最后一个地址的错误。调用方由此能区分“没下到”和“下到了但摘要不符”。原先直接返回最后一个错误;相应测试改为同时断言两者。pluginservice.ArchivePlatform(),managedRuntimes 和命令安装器共用同一个平台值。工作台(
desktop/internal/workbench/command_installers.go)Offer:下载安装器不解析工具,只返回版本、地址、镜像、摘要,目标只有 managed,没有命令行。这一步不发起任何网络请求(有测试覆盖)。Install→download():用pluginruntime.Manager{Root: 安装器托管目录}.Prepare下载、校验和解压。校验器检查每个命令都在计划的命令目录里;检查通过后写入commands.json,再删掉同一安装器其他缓存键的旧解压目录。downloadFailure把失败映射到上面三个错误码,并与已有的超时、取消区分开:用户取消不记录;传输卡住时,以安装自己的期限判定为超时。Missing:下载安装器没有工具名,卡片上显示为下载安装。StartPluginAttempt/EndAttempt)和recordFailure,下载失败按阶段记一条终态,没有新增事件。设置窗口(
desktop/internal/settingswindow/)CommandInstaller.Install接口新增progress回调,可从任意 goroutine 调用。界面文案
shared/i18n/features/command-installer-downloads.json,含 8 条中英词条:commandInstallDownloadPrompt、DownloadNetwork、Source、Mirror、Digest、DownloadFailed、ChecksumMismatch、ArchiveInvalid。生成结果已提交。文档、Note 与矩阵
2026-11-15-plugin-command-installers.md写入下载安装器的结论、做法、被否方案 6–9,以及后果和验证。被否方案 8 说明:命令下载会删旧缓存键,managedRuntimes 却保留旧目录,这是两边有意不同的取舍。docs/ci-builds.md写明<插件根>/.state/<插件 ID>/commands/<安装器 ID>/<缓存键>/的归属、生命周期,以及不能跨工作树复制的原因。docs/development/macos-plugin-api-plan.md的 API-23 行补充 commandInstallers 1。plugin-command-installers.json更新能力、两端证据和验证动作。验证动作用通用的测试插件描述,不引用具体插件。Core 固定版本
PINNED_CORE_REVISION升到 Core main72036de(功能建议:设置支持日志相关操作 #133 squash 合入)。它与此前在分支上验证的f9af83e代码树完全相同(git diff为空)。顺带修复:既有测试在 -race 下超时(main 上同样失败)
pluginservice/runtime_trust_test.go的TestManagedToolchainFactsFeedToolchainResolutionWithoutStartingBackend把约 250 MB 的测试二进制用 Deflate 压进 zip 当运行时。-race 会给标准库 flate 也插桩,压缩加解压超过了 20 秒期限,表现为managed runtime archive is not safe to extract: context deadline exceeded。zip.Store后,-race 下从超过 20 秒降到 4.55 秒;不开 -race 时 1.6 秒。测试断言没有改。不在本 PR 范围内 / Out of scope
pending。类型专属:feat
多平台对齐
范围检查 / Scope checks
功能矩阵 / Feature matrix
shared/platform-feature-matrix/features/plugin-command-installers.json:能力、两端证据和验证动作已更新;没有运行的真机验证保持pending./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh(218 validated)和./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEAD(passed).artifacts/下生成的矩阵视图插件归属 / Plugin ownership
develop-lithe第三节的自查命令,结果为空dev.lithe.test.*)和本地生成的压缩包,没有真实插件 ID,没有“缺少插件时跳过”的测试shared/i18n/;插件的构建步骤和资源路径没有写进docs/ci-builds.md、Note 或 SkillLithe-IDEA/lithe-plugin-gomain 241c26c)用已发布的go-support-1.3.1-darwin.zip,执行node scripts/e2e-host.mjs --source <本仓库> --ref feat/command-installer-downloads,projectgen 5 项和 workbench 4 项(含 Delve 调试)全部通过UI 验证 / UI evidence
LITHE_VISUAL_OUTPUT_DIR=… scripts/desktop/desktop-go.sh test -tags 'vivahead lithevisual' ./internal/settingswindow/ -run TestVisualCommandInstall -count=1。暗色为中文、亮色为英文,覆盖“确认下载”和“下载中”两个状态docs/assets/command-installer-downloads/并嵌入下方统一日志系统 / Structured logging
core.StartPluginAttempt/EndAttempt)和recordFailure("plugin_command_install", …),没有新增事件,也没有print或直接写 stderr界面文案 / i18n
shared/i18n/features/command-installer-downloads.json(8 条中英词条),已运行生成脚本并提交shared.generated.goshared/i18n/node scripts/i18n/verify-app-language-localization.mjs和node scripts/i18n/generate-i18n.mjs --check,都通过逻辑归属 / Logic placement
性能与内存 / Performance and memory
设置 / Settings
插件契约 / Plugin contract
shared/plugins/reference/protocol-changelog.md、api-catalog.md和capabilities-and-versions.md:feat(plugins): 命令安装器支持固定 URL 归档下载(commandInstallers 1) Lithe-IDEA/Lithe-core-rust#133PINNED_CORE_REVISION已升到包含该契约的 Core main72036delithe/host/*宿主方法或宿主通知;API-23 的变化在清单和 Core API 请求参数上:commandInstallers[].download是清单字段;Core APIplugins.commandInstallers.requirements/plan新增platform参数,由宿主内部调用,不对插件开放发行包与资源 / Bundle and resources
<插件根>/.state/<插件 ID>/commands/<安装器 ID>/<缓存键>/,即平台存储里的插件状态目录,不写 app bundle 或安装目录;已运行./scripts/desktop/verify/verify-runtime-bundle-immutability.sh,通过docs/ci-builds.md“独立工作树的本地编译”一节写明路径、归属、生命周期,以及不能跨工作树复制的原因无用代码与重构 / Dead code and refactoring
验证 / Verification
scripts/desktop/desktop-go.sh test ./...(固定到 f9af83e 时)desktop-go.sh test -count=1 ./internal/core/ ./internal/pluginhost/ ./internal/pluginruntime/ ./internal/pluginservice/ ./internal/settingswindow/,以及./internal/workbench/ -run 'Command(Download|Install)'desktop-go.sh test -race -count=1core / pluginruntime / pluginhost / pluginservice / settingswindow / workbench.agents/skills/write-stable-tests/scripts/test-stability-macos.sh --package ./internal/pluginservice -- --filter TestManagedToolchainFacts….agents/skills/write-stable-tests/scripts/verify-test-stability.shgofmt -l/desktop-go.sh vetTestVisualCommandInstall(vivahead lithevisual)node scripts/i18n/generate-i18n.mjs --check、node scripts/i18n/verify-app-language-localization.mjs./scripts/desktop/verify/verify-runtime-bundle-immutability.sh./scripts/agent-notes/verify-agent-notes.shverify-platform-feature-matrix.sh/verify-platform-feature-matrix-change.sh origin/main HEADdevelop-lithe第三节插件归属自查--ref feat/command-installer-downloads)codelldb-darwin-arm64.vsix,用 zipinfo 检查extension/adapter/codelldb为 0755,解压会保留可执行位未能执行的检查和原因:
pending。pending。提交前确认 / Final checks
main创建,期间合入过一次 origin/main(9cd03eb);目标分支main