Repository navigation
feat(toolchain): 工具定义的版本探针可以用子命令开头 - #52
Merged
Merged
Conversation
Go 只能用 go version 打印版本,原来的校验要求每个探针参数都是选项, 工具定义写不出 Go。现在第一个参数可以是子命令,之后的参数仍然只能是选项, 探针仍然不能把脚本或文件交给工具。
xiaoyumuxi
marked this pull request as ready for review
November 15, 2026 06:10
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 插件要在「新建项目」里加一个像 GoLand 那样的 GOROOT 下拉框:列出本机装的 Go,
go.mod的go版本默认取选中的那个 Go。这要靠项目生成器的tool字段,而tool字段的候选来自插件的toolDefinitions。工具定义的版本探针
version.arguments原来要求每个参数都是选项(-x、--x)。Go 只能用go version打印版本,go -version、go --version、go -v都会失败,所以 Go 插件写不出工具定义。Zig(zig version)等工具也是这样。Core 给宿主托管的go运行时用的探针本来就是["version"](build::invocation::host_runtime_version_arguments),只是工具定义这边不允许。改动
rust/crates/toolchain/src/definitions.rs:version.arguments的第一个参数可以是选项,也可以是子命令;从第二个参数起只能是选项,否则以plugin.manifest.invalid(字段version.arguments)拒绝。单词规则不变:ASCII 字母开头,只含字母、数字和-,不带=值,最长 64 字节,1 到 8 个且不重复。原来就拒绝的["-c", "script"]现在照样拒绝,因为script不在第一个位置。抽出probe_word、probe_flag两个函数。plugin-manifest.schema.json(toolchainVersion.arguments):用prefixItems让第一项允许子命令,其余项仍是选项的正则;补上uniqueItems和说明。contract/v1/toolchains/README.md:写明version的形状和参数规则,以及为什么第一个之后不允许裸词。reference/domains/toolchains.md:中英两节各补一段同样的说明。reference/protocol-changelog.md:时间线加一行(toolDefinitions0 内的补充,不加能力版本)。rust/crates/core/src/tests/toolchain_definitions.rs,新增a_version_probe_may_lead_with_a_subcommand_followed_only_by_flags:["version"]、["version", "--json"]、["-version"]、["--version", "-v"];["version", "script"]、["--version", "run"]、["-c", "script"]、["./version"]、["version=1"];validate_declarations和整份清单校验validate_manifest_value两条路径都覆盖。不涉及宿主方法;桌面端宿主的探针原样传参数(
desktop/internal/toolchain/scan.go、probe.go),不用改。version.arguments校验放宽,不新增方法验证
cargo test -p lithe-core toolchain_definitionscargo test -p lithe-toolchaincargo clippy -p lithe-toolchain -p lithe-core --all-targets -- -D warningscargo fmt --all -- --checknode shared/plugins/scripts/verify-docs.mjs没做的验证: 本机没有 JSON Schema 校验器,schema 里
prefixItems加items的写法(2020-12 语义:items只约束prefixItems之后的项)是人工核对的,没有用校验器跑过。合入后
scripts/desktop/build-desktop-core.sh的PINNED_CORE_REVISION升到合入提交。go工具定义和 GOROOT 字段。