Skip to content

feat: 缺少 gopls、dlv 时可以在插件详情里安装(commandInstallers) - #8

Merged
xiaoyumuxi merged 2 commits into
mainfrom
feat/command-installers
Nov 15, 2026
Merged

xiaoyumuxi merged 2 commits into
mainfrom
feat/command-installers

Conversation

@xiaoyumuxi

Copy link
Copy Markdown
Contributor

背景

试装 Go 插件时,电脑上没有 gopls 或 dlv 的话,插件详情里只显示英文原始错误(“plugin package path is not usable: none of the plan's commands is available”),不知道缺什么、怎么装。

Lithe-IDEA/Lithe-core-rust#53(main c550c2b)加入了通用的 commandInstallers 契约(API-23):插件声明“用哪个已注入的工具、什么参数安装哪些命令”,Core 校验并展开。1lck/Lithe-IDEA#1971(Draft)让宿主在能力卡片上显示“未找到 xxx”和安装按钮,用户选安装位置、看清要运行的命令后确认。宿主和 Core 里没有任何 Go 专属代码,本 PR 只在插件清单里声明 gopls 和 dlv 怎么装。

改动

  • plugin.json(版本仍是 0.1.0:0.1.0 还没发布,这些内容并进 0.1.0)
    • requires 加入 commandInstallers: 0。

    • 新增 requiresTools: ["go"]:安装器用的 go 工具来自插件自己的 toolDefinitions[go]。

    • permissions 加入 commands.install:安装对话框里显示为“安装插件所需的命令行工具(每次安装前都会征得你的同意)”。

    • 新增 commandInstallers,两项结构相同:

      id 命令 参数
      gopls gopls install golang.org/x/tools/gopls@latest
      dlv dlv install github.com/go-delve/delve/cmd/dlv@latest
      • tool: go,minimumVersion: 1.21(Go 1.21 起有 GOTOOLCHAIN,go install 能取命令模块要求的更新 Go),mayUseNetwork: true,超时用默认的 10 分钟。
      • targets.managed:环境变量 GOBIN=${installDirectory},装进 Lithe 管理的目录(插件状态目录下,卸载插件时删除),不动 Go 的默认目录。
      • targets.toolDefault:不设 GOBIN;用 go env GOBIN 找目录,为空时用 go env GOPATH 的第一项加 bin。卸载插件时不删这些文件。
  • README.md
  • docs/releases/v0.1.0.md:功能里加上安装 gopls 和 dlv;权限加 commands.install;依赖的程序改写;兼容性改为需要 Core c550c2b 或更新版本的桌面端,并说明更早的桌面端为什么会拒绝安装。
  • docs/feature-matrix.md
    • go-support-plugin:能力、证据、依赖的宿主能力加上 commandInstallers;验证方法第 4 步写明 gopls 也可能来自安装目录,第 7 步改为语言服务器卡片显示“未找到 gopls”和安装按钮、两种位置各装一次后的检查;最近验证注明安装没有被覆盖。
    • go-debug-delve:能力、证据、依赖的宿主能力同样更新;验证方法第 6 步改为调试器卡片显示“未找到 dlv”和安装按钮、安装后能停在断点。
  • e2e/host/lithe-host.json:宿主固定到 a9bddd922(feat(desktop): 插件缺少的命令可在能力卡片上一键安装(API-23 commandInstallers) 1lck/Lithe-IDEA#1971 的分支头提交:preview 4caa57a33 加上 Core c550c2b 和命令安装)。原来的 b03dbf0c0 不认识 commandInstallers,装这个清单会被拒绝。

验证

检查 结果
用宿主 #1971 的 Core c550c2b 校验清单(临时测试,没有提交):pluginhost.Validate + Declared(),再调 plugins.commandInstallers.requirements、plan(managed、toolDefault)、defaultDirectory 通过:requirements 列出语言服务器 go → gopls、调试适配器 delve → dlv;managed 展开为 go install …@latest 加 GOBIN=<目录>;toolDefault 没有额外环境,两个探测命令;GOBIN 为空、GOPATH=/Users/x/go 时默认目录是 /Users/x/go/bin
node scripts/package.mjs 通过
Lithe Store 规则 读过 Lithe-store/scripts/validate-index.mjs 的 checkManifest:只检查 schemaVersion、pluginAPIVersion、requires 格式、版本一致和 signatureRequirement,没有权限白名单,新字段不影响;CI 会实际跑一遍
e2e 测试文件在新宿主上编译:把 e2e/host/desktop/** 拷进 #1971 的检出跑 go vet ./internal/workbench/ ./internal/projectgen/,跑完删掉 通过
node scripts/e2e-host.mjs(宿主端到端测试) 没有跑:测试很重,要先征得同意
真实宿主里点安装按钮 没有做,待试装

合入前

清单声明 commandInstallers(API-23):gopls 和 dlv 用注入的 go 工具运行
go install <包>@latest 安装,可以装进 Lithe 管理的目录(设置 GOBIN),也可以
装进 Go 的默认位置(go env GOBIN,为空时 GOPATH 第一项加 bin)。
requires 加 commandInstallers 0,requiresTools 为 go,权限加 commands.install。

README 改写依赖的程序一节,功能矩阵更新 gopls、dlv 缺失时的验证步骤,
宿主端到端测试的固定提交升到 1lck/Lithe-IDEA#1971 的 a9bddd922。
@xiaoyumuxi
xiaoyumuxi marked this pull request as ready for review November 15, 2026 08:58
@xiaoyumuxi
xiaoyumuxi merged commit 4eaee42 into main Nov 15, 2026
1 check passed
@xiaoyumuxi
xiaoyumuxi deleted the feat/command-installers branch November 15, 2026 10:53
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