From a8b1b86ae68292a882f4182a2b2b9eeaedcf7d51 Mon Sep 17 00:00:00 2001 From: Yao Jingxi <23722032@bjtu.edu.cn> Date: Mon, 16 Nov 2026 19:02:38 +0800 Subject: [PATCH] =?UTF-8?q?refactor(build):=20=E5=88=A0=E9=99=A4=20KNOWN?= =?UTF-8?q?=5FRUNTIME=5FTOOLS=EF=BC=8Cgo=E3=80=81node=20=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E6=97=B6=E4=BE=9D=E8=B5=96=E6=8C=89=E5=B7=A5=E5=85=B7=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 构建系统的 runtimeDependencies 原来把 go、node 当作宿主管理的运行时: 计划返回 { kind: runtime } 候选和 Core 自带的版本参数(go version、 node --version),checkToolVersion 用 reported_version 读版本,清单里 不许给它们写 executables。这是 Core 认识具体工具的写死逻辑。 现在 Core 不认识任何具体运行时:没有 executables 的运行时一律是同 ID 工具定义的隐式引用,计划返回 toolchain 候选、version 为 null,版本由 工具定义检查;写了 executables 的按普通运行时校验。 - build:删除 KNOWN_RUNTIME_TOOLS、is_host_managed、宿主运行时校验分支、 host_runtime_version_arguments 和计划里的 hostManaged 字段 - plugin-model:删除只服务于它的 reported_version - 测试:go、node、vm 走同一条路径;自己描述的运行时按自己的 pattern 读版本 - 契约:README、build-plans 与 invalid-manifests fixture、build-systems 参考页和协议更新记录;三处 runtime_tools 注释改成准确描述 Refs 1lck/Lithe-IDEA#1856 --- rust/crates/build/src/invocation.rs | 43 +---- rust/crates/build/src/manifest.rs | 2 +- rust/crates/build/src/manifest/invocation.rs | 74 ++------ .../core/src/tests/build_runtime_versions.rs | 158 +++++++----------- rust/crates/debug/src/adapters.rs | 2 +- rust/crates/plugin-model/src/lib.rs | 2 +- rust/crates/plugin-model/src/version.rs | 21 --- rust/crates/vcs/src/manifest.rs | 2 +- shared/plugins/contract/v1/README.md | 10 +- .../fixtures/build-systems/build-plans.json | 43 ++--- .../fixtures/manifest/invalid-manifests.json | 2 +- .../reference/domains/build-systems.md | 4 +- .../plugins/reference/protocol-changelog.md | 1 + 13 files changed, 111 insertions(+), 253 deletions(-) diff --git a/rust/crates/build/src/invocation.rs b/rust/crates/build/src/invocation.rs index f17814d2..54b044e7 100644 --- a/rust/crates/build/src/invocation.rs +++ b/rust/crates/build/src/invocation.rs @@ -14,7 +14,7 @@ use super::manifest::{ use super::BuildManifest; use lithe_plugin_model::executables::ordered_indices; use lithe_plugin_model::{ - reported_version, validate_minimum_version, version_components, PluginRejection, Validation, + validate_minimum_version, version_components, PluginRejection, Validation, }; use serde::Deserialize; use serde_json::{json, Value}; @@ -67,19 +67,6 @@ fn candidates( }).collect() } -/// Arguments that make a host-managed runtime print its version and exit. -/// Core owns them so hosts use the same probe, for build runtimes and for -/// plugin launch runtimes alike. Hosts capture stderr together with stdout -/// before checking the declared minimum. A tool definition probes the -/// runtimes it resolves itself, so other IDs have none. -pub(crate) fn host_runtime_version_arguments(id: &str) -> Option<&'static [&'static str]> { - match id { - "go" => Some(&["version"]), - "node" => Some(&["--version"]), - _ => None, - } -} - fn runtime( runtime: &RuntimeDependency, root: &str, @@ -87,28 +74,20 @@ fn runtime( manifest: &impl BuildManifest, settings: &BTreeMap, ) -> Validation { - let version = if runtime.is_host_managed() { - host_runtime_version_arguments(&runtime.id) - .map(|arguments| json!({ "arguments": arguments })) - } else { - runtime - .version - .as_ref() - .map(|probe| json!({ "arguments": probe.arguments })) - }; + let version = runtime + .version + .as_ref() + .map(|probe| json!({ "arguments": probe.arguments })); // An implicit reference is the toolchain candidate of the tool // definition with the same ID; resolving it checks `minimumVersion`. let executables = if runtime.names_tool_definition() { vec![json!({ "kind": "toolchain", "toolchainID": runtime.id, "root": root })] - } else if runtime.is_host_managed() { - vec![json!({"kind":"runtime","runtime":runtime.id})] } else { candidates(&runtime.executables, root, platform, manifest, settings)? }; Ok(json!({ "id": runtime.id, "displayName": runtime.display_name, - "hostManaged": runtime.is_host_managed(), "pathVariable":format!("LITHE_{}_PATH",runtime.id.to_ascii_uppercase().replace('-',"_")), "minimumVersion": runtime.minimum_version, "executables": executables, @@ -202,14 +181,10 @@ pub(crate) fn check_version( ), )); } - let found = if dependency.is_host_managed() { - reported_version(&request.output) - } else { - dependency - .version - .as_ref() - .and_then(|probe: &VersionProbe| probe.version(&request.output)) - }; + let found = dependency + .version + .as_ref() + .and_then(|probe: &VersionProbe| probe.version(&request.output)); (found, dependency.minimum_version.as_deref()) } }; diff --git a/rust/crates/build/src/manifest.rs b/rust/crates/build/src/manifest.rs index b676d8ba..cb19b03e 100644 --- a/rust/crates/build/src/manifest.rs +++ b/rust/crates/build/src/manifest.rs @@ -142,7 +142,7 @@ pub struct DeclarationContext<'a> { pub declared_settings: &'a lithe_plugin_model::settings::DeclaredSettings, /// Language IDs the plugin declares a language server for. pub language_servers: &'a BTreeSet, - /// Whether tool names are host runtimes or tool-definition IDs. + /// The tool-definition IDs in `requiresTools` that a process may name. pub runtime_tools: lithe_plugin_model::process::RuntimeTools<'a>, } diff --git a/rust/crates/build/src/manifest/invocation.rs b/rust/crates/build/src/manifest/invocation.rs index 64066265..e8701d45 100644 --- a/rust/crates/build/src/manifest/invocation.rs +++ b/rust/crates/build/src/manifest/invocation.rs @@ -21,20 +21,12 @@ pub(crate) struct Invocation { pub(crate) minimum_version: Option, } -/// Runtime tools the host discovers and manages itself for build-system -/// runtime dependencies: it exports each as `LITHE__PATH` and puts its -/// directory on the process's `PATH`. Server processes never use this list; -/// they name tool definitions from `requiresTools`. -pub(crate) const KNOWN_RUNTIME_TOOLS: &[&str] = &["go", "node"]; - pub(crate) use lithe_plugin_model::executables::{ExecutableCandidate, ExecutableSource, Platform}; -/// A runtime the tool needs. Runtimes the host already manages (`node`, -/// `go`) take only an ID and an optional minimum version and follow the -/// user's runtime settings. Any other runtime either describes how to find -/// and probe it, or lists no executables and names the tool definition with -/// its ID, which finds the executable and checks `minimumVersion`. A -/// plugin is never limited to a host list. +/// A runtime the tool needs. It either describes how to find and probe the +/// executable, or lists no executables and names the tool definition with +/// its ID, which finds the executable and checks `minimumVersion`. Core +/// knows no runtime by name; every runtime comes from a manifest. #[derive(Debug, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub(crate) struct RuntimeDependency { @@ -50,31 +42,24 @@ pub(crate) struct RuntimeDependency { } impl RuntimeDependency { - /// True when the host discovers this runtime with its own settings. - pub(crate) fn is_host_managed(&self) -> bool { - KNOWN_RUNTIME_TOOLS.contains(&self.id.as_str()) - } - /// True when the runtime is the tool definition with the same ID: it - /// lists no executables and the host does not manage it. Plans give it - /// a single toolchain candidate for that ID. + /// lists no executables. Plans give it a single toolchain candidate for + /// that ID. pub(crate) fn names_tool_definition(&self) -> bool { - self.executables.is_empty() && !self.is_host_managed() + self.executables.is_empty() } /// True when the tool definition the runtime resolves through checks - /// `minimumVersion`, so the manifest needs no version probe: a runtime - /// the host does not manage that is an implicit reference or has exactly - /// one toolchain candidate. + /// `minimumVersion`, so the manifest needs no version probe: the runtime + /// is an implicit reference or has exactly one toolchain candidate. pub(crate) fn checked_by_tool_definition(&self) -> bool { - !self.is_host_managed() - && matches!( - self.executables.as_slice(), - [] | [ExecutableCandidate { - source: ExecutableSource::Toolchain { .. }, - .. - }] - ) + matches!( + self.executables.as_slice(), + [] | [ExecutableCandidate { + source: ExecutableSource::Toolchain { .. }, + .. + }] + ) } } @@ -137,33 +122,6 @@ impl BuildSystemDeclaration { if let Some(minimum) = &runtime.minimum_version { validate_minimum_version(minimum, &format!("{field}.minimumVersion"))?; } - if runtime.is_host_managed() { - // The host finds these with the user's own runtime settings; - // a plugin must not route around that choice. - let toolchain = runtime.executables.len() == 1 - && matches!( - runtime.executables[0].source, - ExecutableSource::Toolchain { .. } - ); - if (!runtime.executables.is_empty() && !toolchain) || runtime.version.is_some() { - return Err(invalid( - field, - format!( - "{} is discovered by the host; declare only its minimumVersion.", - runtime.id - ), - )); - } - if toolchain { - check_candidate( - &mut runtime.executables[0], - &format!("{field}.executables[0]"), - &invocation.environment_inputs, - &BTreeSet::new(), - )?; - } - continue; - } if runtime.names_tool_definition() { // The tool definition finds the executable and checks // `minimumVersion`; a probe here would have nothing to run. diff --git a/rust/crates/core/src/tests/build_runtime_versions.rs b/rust/crates/core/src/tests/build_runtime_versions.rs index 42f2953f..812dc347 100644 --- a/rust/crates/core/src/tests/build_runtime_versions.rs +++ b/rust/crates/core/src/tests/build_runtime_versions.rs @@ -1,5 +1,6 @@ -//! Host runtimes keep Core's version probe; any other runtime names the tool -//! definition with the same ID, which checks the version itself. +//! A runtime without executables names the tool definition with the same ID, +//! which finds the executable and checks the version itself. Core knows no +//! runtime by name: `go` and `node` follow the same rules as any other ID. use crate::build::{build_check_tool_version_command, build_invocation_plan_command}; use lithe_plugin_manifest::DeclarativePluginManifest as Manifest; @@ -31,126 +32,93 @@ fn check(manifest: Value, runtime: &str, output: &str) -> Value { .expect("version request is valid") } +/// A published manifest that names a runtime without executables keeps +/// validating; the plan resolves it through the tool definition with that +/// ID. `go` and `node` get no host candidate and no Core probe. #[test] -fn host_runtime_probe_arguments_are_portable_across_platforms() { +fn runtime_without_executables_becomes_a_toolchain_candidate() { for platform in ["macos", "linux", "windows"] { - let mut manifest = manifest(); - manifest["buildSystems"][0]["invocation"]["runtimeDependencies"] = json!([ - { "id": "node", "minimumVersion": "20" }, - { "id": "go", "minimumVersion": "1.22" } - ]); - let result = plan(manifest, platform); - assert_eq!(result["status"], "ok", "{platform}: {result}"); - let runtimes = &result["invocation"]["runtimeDependencies"]; - for (index, arguments) in [json!(["--version"]), json!(["version"])] - .into_iter() - .enumerate() - { - assert_eq!(runtimes[index]["hostManaged"], true, "{platform}"); - let id = if index == 0 { "node" } else { "go" }; - assert_eq!( - runtimes[index]["executables"], - json!([{"kind":"runtime","runtime":id}]), - "{platform}" - ); + for (id, minimum, path_variable) in [ + ("vm", "8", "LITHE_VM_PATH"), + ("go", "1.22", "LITHE_GO_PATH"), + ("node", "20", "LITHE_NODE_PATH"), + ] { + let mut manifest = manifest(); + manifest["buildSystems"][0]["invocation"]["runtimeDependencies"] = + json!([{ "id": id, "minimumVersion": minimum }]); + let result = plan(manifest, platform); + assert_eq!(result["status"], "ok", "{platform} {id}: {result}"); assert_eq!( - runtimes[index]["pathVariable"], - format!("LITHE_{}_PATH", id.to_ascii_uppercase()) + result["invocation"]["runtimeDependencies"][0], + json!({ + "id": id, + "displayName": null, + "pathVariable": path_variable, + "executables": [ + { "kind": "toolchain", "toolchainID": id, "root": "." } + ], + "version": null, + "minimumVersion": minimum + }), + "{platform} {id}" ); + // The build tool's own probe stays independent of its runtimes. assert_eq!( - runtimes[index]["version"]["arguments"], arguments, - "{platform}" + result["invocation"]["version"]["arguments"], + json!(["--version"]) ); } - // The build tool's own probe stays independent of its runtimes. - assert_eq!( - result["invocation"]["version"]["arguments"], - json!(["--version"]) - ); } } -/// A published manifest that names `vm` without executables keeps -/// validating; the plan resolves it through the tool definition `vm`. #[test] -fn runtime_without_executables_becomes_a_toolchain_candidate() { - for platform in ["macos", "linux", "windows"] { +fn runtime_named_by_tool_definition_has_no_core_probe() { + for (id, output) in [ + ("vm", "21.0.4\n"), + ("go", "go version go1.22.3 darwin/arm64\n"), + ("node", "v20.11.0\n"), + ] { let mut manifest = manifest(); manifest["buildSystems"][0]["invocation"]["runtimeDependencies"] = - json!([{ "id": "vm", "minimumVersion": "8" }]); - let result = plan(manifest, platform); - assert_eq!(result["status"], "ok", "{platform}: {result}"); + json!([{ "id": id, "minimumVersion": "8" }]); + let result = check(manifest, id, output); assert_eq!( - result["invocation"]["runtimeDependencies"][0], + result, json!({ - "id": "vm", - "displayName": null, - "hostManaged": false, - "pathVariable":"LITHE_VM_PATH", - "executables": [ - { "kind": "toolchain", "toolchainID": "vm", "root": "." } - ], - "version": null, - "minimumVersion": "8" + "status": "rejected", + "error": { + "code": "plugin.build.unavailable", + "message": format!( + "Cargo declares no version probe for {id}; its tool definition checks the version." + ) + } }), - "{platform}" + "{id}" ); } } +/// A runtime the plugin describes itself reads its version with its own +/// pattern, whatever its ID. #[test] -fn runtime_named_by_tool_definition_has_no_core_probe() { - let mut manifest = manifest(); - manifest["buildSystems"][0]["invocation"]["runtimeDependencies"] = - json!([{ "id": "vm", "minimumVersion": "8" }]); - let result = check(manifest, "vm", "21.0.4\n"); - assert_eq!( - result, - json!({ - "status": "rejected", - "error": { - "code": "plugin.build.unavailable", - "message": "Cargo declares no version probe for vm; its tool definition checks the version." - } - }) - ); -} - -#[test] -fn host_runtime_output_reads_the_first_dotted_number() { - for (runtime, minimum, output, satisfied, version) in [ - ("node", "20", "v20.11.0\n", true, "20.11.0"), - ( - "node", - "20", - "warning: custom build\nv18.20.4\n", - false, - "18.20.4", - ), - ( - "go", - "1.22", - "go version go1.22.3 darwin/arm64\n", - true, - "1.22.3", - ), - ( - "go", - "1.22", - "go version go1.21.9 linux/amd64\n", - false, - "1.21.9", - ), +fn described_runtime_reads_its_own_probe() { + for (output, satisfied, version) in [ + ("go version go1.22.3 darwin/arm64\n", true, "1.22.3"), + ("go version go1.21.9 linux/amd64\n", false, "1.21.9"), ] { let mut manifest = manifest(); - manifest["buildSystems"][0]["invocation"]["runtimeDependencies"] = - json!([{ "id": runtime, "minimumVersion": minimum }]); - let result = check(manifest, runtime, output); + manifest["buildSystems"][0]["invocation"]["runtimeDependencies"] = json!([{ + "id": "go", + "minimumVersion": "1.22", + "executables": [{ "kind": "command", "command": "go" }], + "version": { "arguments": ["version"], "pattern": "go(\\d+\\.\\d+(?:\\.\\d+)?)" } + }]); + let result = check(manifest, "go", output); assert_eq!(result["status"], "ok", "{result}"); assert_eq!( result["version"], json!({ "satisfied": satisfied, "version": version }), - "{runtime} {output}" + "{output}" ); } } diff --git a/rust/crates/debug/src/adapters.rs b/rust/crates/debug/src/adapters.rs index 5e385513..8ac2cd10 100644 --- a/rust/crates/debug/src/adapters.rs +++ b/rust/crates/debug/src/adapters.rs @@ -204,7 +204,7 @@ pub struct DeclarationContext<'a> { pub declared_settings: &'a DeclaredSettings, /// Language IDs of the plugin's `languageServers[]`. pub language_servers: &'a BTreeSet, - /// Whether tool names are host runtimes or tool-definition IDs. + /// The tool-definition IDs in `requiresTools` that a process may name. pub runtime_tools: lithe_plugin_model::process::RuntimeTools<'a>, } diff --git a/rust/crates/plugin-model/src/lib.rs b/rust/crates/plugin-model/src/lib.rs index 635259e2..d53ee0e7 100644 --- a/rust/crates/plugin-model/src/lib.rs +++ b/rust/crates/plugin-model/src/lib.rs @@ -37,4 +37,4 @@ pub use rejection::{ decode_payload, invalid, invalid_template, outcome, PluginRejection, Validation, }; pub use template::{parse_template_with, regex_literal, TemplatePart}; -pub use version::{reported_version, validate_minimum_version, version_components, PluginVersion}; +pub use version::{validate_minimum_version, version_components, PluginVersion}; diff --git a/rust/crates/plugin-model/src/version.rs b/rust/crates/plugin-model/src/version.rs index 9c7e2c5c..d467d016 100644 --- a/rust/crates/plugin-model/src/version.rs +++ b/rust/crates/plugin-model/src/version.rs @@ -29,27 +29,6 @@ pub fn version_components(value: &str) -> Vec { .collect() } -/// First dotted number in a version probe's output, at most three -/// components: `20.11.0` from `v20.11.0`, `1.22.4` from -/// `go version go1.22.4 darwin/arm64`. A tool whose output needs more than -/// this is checked through its tool definition instead. -pub fn reported_version(output: &str) -> Option> { - let line = output - .lines() - .find(|line| line.contains(|character: char| character.is_ascii_digit()))?; - let start = line.find(|character: char| character.is_ascii_digit())?; - let text: String = line[start..] - .chars() - .take_while(|character| character.is_ascii_digit() || *character == '.') - .collect(); - // A sentence-ending period is not a component. - text.split('.') - .take_while(|part| !part.is_empty()) - .take(3) - .map(|part| part.parse().ok()) - .collect() -} - #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] /// Strict three-component semantic version used for compatibility comparisons. pub struct PluginVersion { diff --git a/rust/crates/vcs/src/manifest.rs b/rust/crates/vcs/src/manifest.rs index 412bcb9b..4fffda7f 100644 --- a/rust/crates/vcs/src/manifest.rs +++ b/rust/crates/vcs/src/manifest.rs @@ -120,7 +120,7 @@ fn is_marker_name(value: &str) -> bool { pub struct DeclarationContext<'a> { /// The manifest's validated settings, which launch templates may reference. pub declared_settings: &'a DeclaredSettings, - /// Whether tool names are host runtimes or tool-definition IDs. + /// The tool-definition IDs in `requiresTools` that a process may name. pub runtime_tools: lithe_plugin_model::process::RuntimeTools<'a>, } diff --git a/shared/plugins/contract/v1/README.md b/shared/plugins/contract/v1/README.md index d5916cb3..e1e90788 100644 --- a/shared/plugins/contract/v1/README.md +++ b/shared/plugins/contract/v1/README.md @@ -1227,10 +1227,10 @@ normalized instance `root`. The host adapter resolves installed definitions against fresh native evidence and directory pins. Unavailable selections are terminal, including when a prerequisite runtime fails first; they cannot silently fall back to Provider discovery. -A host-managed `node` or `go` dependency may select one such candidate, -while retaining Core's version probe. Any other dependency that declares no -`executables` is already this candidate for the definition with its own ID, and -that definition checks `minimumVersion`. A tool that needs another tool as a +A runtime dependency that declares no `executables` is already this candidate +for the definition with its own ID, and that definition checks +`minimumVersion`. Core knows no runtime by name: `node` and `go` are tool +definitions like any other. A tool that needs another tool as a prerequisite names that tool's definition; Core adds no registry entry for any particular tool. Passive import performs no version or runtime probes; a definition that requires @@ -1643,7 +1643,7 @@ declaration are relative, use `/`, and stay inside their base directory | --- | --- | | `detection` | `markers` are file names; a directory holding one is a candidate root. Core searches at most 6 levels below the workspace root and skips known caches and build outputs, plus directories Git ignores: the rules come from the `.gitignore` files inside the workspace and the `info/exclude` of each repository whose root lies in it, not from directories above the workspace root, `core.excludesFile` or the index, so a tracked manifest below an ignored directory is not a candidate. Detection also skips the workspace's ignored paths, a Build option the user edits (`.gitignore` patterns stored in the team or machine-local Build options): by default every directory whose name starts with a dot, such as `.claude/worktrees`, and the user can list more or bring one back with `!`. `nesting: "outermost"` folds deeper candidates into the outer instance (Gradle builds, Maven reactors); `"separate"` (default) keeps each (Cargo packages). `priority` (0–100, default 50) decides between plugins declaring the same ID; ties go to the smaller plugin ID. | | `invocation` | `executables` in preference order: `projectFile` (a wrapper inside the root, with `requires` files; always runs project code), `environment` (a path below a variable listed in `environmentInputs`), `command` (a bare name found on `PATH`), `runtime` (a declared runtime dependency itself). `platforms` limits a candidate. `globalArguments` precede every command. `version` probes the executable with literal `arguments` and a `pattern` whose first group is the version; `minimumVersion` needs a probe. | -| `runtimeDependencies` | `node` and `go` are host-managed: only `id` and `minimumVersion`, discovered with the user's runtime settings; `build.invocationPlan` returns the probe arguments Core reads their version with, so hosts keep no per-runtime probe. Any other runtime without `executables` names the [tool definition](toolchains/README.md) with the same ID, so its `id` must be a valid tool-definition ID and it declares only `minimumVersion`: `build.invocationPlan` returns it with `hostManaged: false`, `version: null`, and the single candidate `{ "kind": "toolchain", "toolchainID": , "root": }`, whose resolution checks `minimumVersion`, and `build.checkToolVersion` for it is `plugin.build.unavailable` because Core reads no version. Any other runtime describes its own `executables` and `version` probe, so the runtime list is open; a runtime whose only candidate is a `toolchain` candidate may omit the probe, since the definition checks the version. | +| `runtimeDependencies` | Core knows no runtime by name; `node` and `go` follow the same rules as any other ID. A runtime without `executables` names the [tool definition](toolchains/README.md) with the same ID, so its `id` must be a valid tool-definition ID and it declares only `minimumVersion`: `build.invocationPlan` returns it with `version: null` and the single candidate `{ "kind": "toolchain", "toolchainID": , "root": }`, whose resolution checks `minimumVersion`, and `build.checkToolVersion` for it is `plugin.build.unavailable` because Core reads no version. Any other runtime describes its own `executables` and `version` probe, so the runtime list is open; a runtime whose only candidate is a `toolchain` candidate may omit the probe, since the definition checks the version. | | `options` | Build dimensions the user chooses: `boolean`, `singleSelect`, `multiSelect`, `text`, `file`, `directory`. Each contributes `arguments` and `environment` (with `${value}`) when it has a value. Choices are declared, come from the model (`choicesFromModel`), or are free (`allowCustom`). | | `provider` | The process that answers model and dependency requests when no command prints them; see [Build providers](#build-providers). | | `model` | `static` (a `toml` file read during detection, no process), `command` (a command whose output Core decodes; it states `executesProjectCode` and `mayUseNetwork`), or `provider`. | diff --git a/shared/plugins/contract/v1/fixtures/build-systems/build-plans.json b/shared/plugins/contract/v1/fixtures/build-systems/build-plans.json index 5a39ff65..e18835c9 100644 --- a/shared/plugins/contract/v1/fixtures/build-systems/build-plans.json +++ b/shared/plugins/contract/v1/fixtures/build-systems/build-plans.json @@ -462,7 +462,7 @@ } }, { - "name": "go runs through the host-managed runtime", + "name": "go runs through the go tool definition", "plugin": "build-command-stdout.plugin.json", "buildSystemID": "go", "operation": "invocationPlan", @@ -486,19 +486,15 @@ { "id": "go", "displayName": null, - "hostManaged": true, "minimumVersion": "1.21", "executables": [ { - "kind": "runtime", - "runtime": "go" + "kind": "toolchain", + "toolchainID": "go", + "root": "." } ], - "version": { - "arguments": [ - "version" - ] - }, + "version": null, "pathVariable": "LITHE_GO_PATH" } ], @@ -508,7 +504,7 @@ } }, { - "name": "go runtime version", + "name": "go runtime version is checked by its tool definition", "plugin": "build-command-stdout.plugin.json", "buildSystemID": "go", "operation": "checkToolVersion", @@ -517,27 +513,10 @@ "output": "go version go1.22.3 darwin/arm64\n" }, "expected": { - "status": "ok", - "version": { - "satisfied": true, - "version": "1.22.3" - } - } - }, - { - "name": "go runtime below the minimum", - "plugin": "build-command-stdout.plugin.json", - "buildSystemID": "go", - "operation": "checkToolVersion", - "request": { - "runtime": "go", - "output": "go version go1.20.14 linux/amd64\n" - }, - "expected": { - "status": "ok", - "version": { - "satisfied": false, - "version": "1.20.14" + "status": "rejected", + "error": { + "code": "plugin.build.unavailable", + "message": "Go Modules declares no version probe for go; its tool definition checks the version." } } }, @@ -859,7 +838,6 @@ { "id": "java", "displayName": null, - "hostManaged": false, "minimumVersion": "17", "executables": [ { @@ -921,7 +899,6 @@ { "id": "java", "displayName": null, - "hostManaged": false, "minimumVersion": "17", "executables": [ { diff --git a/shared/plugins/contract/v1/fixtures/manifest/invalid-manifests.json b/shared/plugins/contract/v1/fixtures/manifest/invalid-manifests.json index de08480f..b493f6aa 100644 --- a/shared/plugins/contract/v1/fixtures/manifest/invalid-manifests.json +++ b/shared/plugins/contract/v1/fixtures/manifest/invalid-manifests.json @@ -435,7 +435,7 @@ "expectedCode": "plugin.manifest.invalid" }, { - "name": "host-managed runtime with its own executables", + "name": "runtime minimum version with a command candidate but no probe", "base": "build-command-stdout.plugin.json", "edits": [{ "op": "set", "path": "/buildSystems/0/invocation/runtimeDependencies/0/executables", "value": [{ "kind": "command", "command": "go" }] }], "expectedCode": "plugin.manifest.invalid" diff --git a/shared/plugins/reference/domains/build-systems.md b/shared/plugins/reference/domains/build-systems.md index 683cd4fc..461743c4 100644 --- a/shared/plugins/reference/domains/build-systems.md +++ b/shared/plugins/reference/domains/build-systems.md @@ -29,7 +29,7 @@ | --- | --- | | `detection` | 用 `markers` 里的文件名识别候选根目录。Core 最多向下找 6 层,跳过已知的缓存和构建输出目录,以及被 Git 忽略的目录(规则来自工作区内途经的 `.gitignore`,以及根目录在工作区内的仓库的 `info/exclude`;不读工作区根以上的目录、`core.excludesFile` 和索引,所以被忽略目录下即使有已跟踪的清单文件也不算候选)。检测还会跳过工作区的忽略路径:这是用户在构建选项里编辑的 `.gitignore` 规则,存放在团队或本机的构建选项中,默认是所有名字以 `.` 开头的目录(如 `.claude/worktrees`),用户可以再添加,也可以用 `!` 放回某个目录;`nesting` 决定深层候选并入外层实例(`outermost`,如 Gradle、Maven)还是各自独立(`separate`,默认,如 Cargo);`priority` 决定多个插件声明同一个 ID 时谁优先 | | `invocation` | 可执行文件候选(`executables`,按偏好排序)、`globalArguments`、版本探测和 `minimumVersion` | -| `runtimeDependencies` | 构建工具依赖的运行时。`node`、`go` 由宿主管理;其他运行时要么命名同 ID 的[工具定义](toolchains.md),要么自己声明 `executables` 和版本探测 | +| `runtimeDependencies` | 构建工具依赖的运行时。每个运行时要么命名同 ID 的[工具定义](toolchains.md)(不写 `executables`,由工具定义查找可执行文件并检查 `minimumVersion`),要么自己声明 `executables` 和版本探测。Core 不认识任何具体运行时,`node`、`go` 也一样:用它们的插件要提供或依赖同名工具定义 | | `options` | 用户选择的构建维度:`boolean`、`singleSelect`、`multiSelect`、`text`、`file`、`directory`;每个选项在有值时贡献 `arguments` 和 `environment` | | `model` | 怎么得到项目模型,见下表 | | `provider` | 没有命令能打印模型时,由[构建提供者](build-providers.md)回答模型和依赖请求 | @@ -126,7 +126,7 @@ IDs of build systems, tasks, and run entries start with a lowercase letter and u | --- | --- | | `detection` | Candidate roots are directories holding one of the `markers` file names. Core searches at most 6 levels down and skips known caches and build outputs, plus directories Git ignores (rules from the `.gitignore` files inside the workspace and the `info/exclude` of each repository rooted there; directories above the workspace root, `core.excludesFile` and the index are not read, so a tracked manifest below an ignored directory is no candidate). Detection also skips the workspace's ignored paths, `.gitignore` patterns the user edits in the team or machine-local Build options: by default every directory whose name starts with a dot, such as `.claude/worktrees`, and the user can add more or bring one back with `!`; `nesting` folds deeper candidates into the outer instance (`outermost`, such as Gradle and Maven) or keeps each one (`separate`, the default, such as Cargo); `priority` decides between plugins declaring the same ID | | `invocation` | Executable candidates (`executables`, in preference order), `globalArguments`, the version probe, and `minimumVersion` | -| `runtimeDependencies` | Runtimes the build tool needs. `node` and `go` are host-managed; any other runtime either names the [tool definition](toolchains.md) with the same ID or declares its own `executables` and version probe | +| `runtimeDependencies` | Runtimes the build tool needs. Each runtime either names the [tool definition](toolchains.md) with the same ID (no `executables`; the definition finds the executable and checks `minimumVersion`) or declares its own `executables` and version probe. Core knows no runtime by name, `node` and `go` included: a plugin that uses them provides or requires the tool definition with that ID | | `options` | Build dimensions the user chooses: `boolean`, `singleSelect`, `multiSelect`, `text`, `file`, `directory`; each contributes `arguments` and `environment` when it has a value | | `model` | How the project model is obtained; see the table below | | `provider` | The [build provider](build-providers.md) that answers model and dependency requests when no command prints them | diff --git a/shared/plugins/reference/protocol-changelog.md b/shared/plugins/reference/protocol-changelog.md index 53d72397..81dce707 100644 --- a/shared/plugins/reference/protocol-changelog.md +++ b/shared/plugins/reference/protocol-changelog.md @@ -137,6 +137,7 @@ | PR | 修改人 | API 编号 | 协议 / 能力 | 改了什么 | | --- | --- | --- | --- | --- | +| [#69](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/69) | [@xiaoyumuxi](https://github.com/xiaoyumuxi) | API-23 | `buildSystems` 0 内的修正 | Core 不再把 `go`、`node` 当作宿主管理的运行时([1lck/Lithe-IDEA#1856](https://github.com/1lck/Lithe-IDEA/issues/1856) 第 3 项):`runtimeDependencies` 里没有 `executables` 的运行时一律按同 ID 的工具定义解析,`go`、`node` 也不例外。`build.invocationPlan` 对它们返回 `{ "kind": "toolchain", "toolchainID": , "root": }` 和 `version: null`,不再返回 `{ "kind": "runtime" }` 候选和 Core 自带的版本参数(`["version"]`、`["--version"]`);`build.checkToolVersion` 对它们以 `plugin.build.unavailable` 拒绝,版本由工具定义检查。运行时计划删掉 `hostManaged` 字段。`go`、`node` 写了自己的 `executables` 时按普通运行时校验,不再报“由宿主发现”。已发布的清单不用改:Go 插件本来就提供 `go` 工具定义。没有新增方法、字段或能力版本。 | | [#61](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/61) | [@xiaoyumuxi](https://github.com/xiaoyumuxi) | — | `languageServers` 0 内的补充 | LSP 引擎在一次会话里保留语言服务器的悬浮提示答案([1lck/Lithe-IDEA#1995](https://github.com/1lck/Lithe-IDEA/issues/1995)):同一文档版本的同一位置,或答案 `range` 在同一行内覆盖的位置,直接用保留的答案完成请求,不再发 `textDocument/hover`。每个会话最多 32 个,先丢最久没用的;空答案、错误、文本超过 64 KiB 的答案和清空之后才到达的答案照常交付但不保留。文档打开、修改、保存、关闭,工作区文件变化,设置或索引排除项变化,运行命令,后端的 `languageServer/request`、`languageServer/notify` 和宿主通知,服务器发来的任何请求和 `$/progress` 结束,以及会话停止时全部清空。`requestCompleted` 的结果形状不变,没有新增方法、字段或能力版本。 | ### 2026-11-15