From d0e02c6f694de380cb797947634f656139a402fe Mon Sep 17 00:00:00 2001 From: lick <2188718831@qq.com> Date: Thu, 19 Nov 2026 04:27:13 -0800 Subject: [PATCH 1/2] feat(build): report the implicit value of unset path options and option descriptions A model's optionDefaults may now name a text, file or directory option: the value the tool uses while the option is unset (Maven's user settings file and local repository). build.resolveOptions returns it as implicitValue, display only, so hosts can show the effective path as IDEA's PathOverrider does. Options may declare a description for the host's info icon. Refs 1lck/Lithe-IDEA#2152, 1lck/Lithe-IDEA#2204 Co-Authored-By: Claude Opus 5.5 --- rust/crates/build/src/manifest/model.rs | 23 +++- rust/crates/build/src/manifest/options.rs | 15 +++ rust/crates/build/src/model.rs | 31 ++++-- rust/crates/build/src/options.rs | 16 +++ rust/crates/core/src/tests/build_systems.rs | 104 ++++++++++++++++++ shared/plugins/contract/v1/README.md | 11 +- .../contract/v1/plugin-manifest.schema.json | 7 ++ .../reference/domains/build-systems.md | 4 +- 8 files changed, 194 insertions(+), 17 deletions(-) diff --git a/rust/crates/build/src/manifest/model.rs b/rust/crates/build/src/manifest/model.rs index 471efe79..8c0a82b1 100644 --- a/rust/crates/build/src/manifest/model.rs +++ b/rust/crates/build/src/manifest/model.rs @@ -212,6 +212,14 @@ impl BuildSystemDeclaration { .filter(|option| option.choices_from_model) .map(|option| option.id.clone()) .collect(); + // `optionDefaults` also reports the value a text, file or directory + // option has when the user leaves it unset. + let default_options: BTreeSet = self + .options + .iter() + .filter(|option| option.choices_from_model || option.is_text_like()) + .map(|option| option.id.clone()) + .collect(); match &self.model { None => { if !model_options.is_empty() { @@ -227,7 +235,7 @@ impl BuildSystemDeclaration { "The model file must be relative to the build-system root.", )); } - map.validate(&format!("{field}.map"), &model_options) + map.validate(&format!("{field}.map"), &model_options, &default_options) } Some(ModelSource::Command { arguments, @@ -258,7 +266,7 @@ impl BuildSystemDeclaration { format!("{field}.map"), "A model command with a generic format needs a map.", )), - (_, Some(map)) => map.validate(&format!("{field}.map"), &model_options), + (_, Some(map)) => map.validate(&format!("{field}.map"), &model_options, &default_options), } } Some(ModelSource::Provider) => Ok(()), @@ -286,7 +294,12 @@ pub(crate) fn check_output_channel( } impl ModelMap { - fn validate(&self, field: &str, model_options: &BTreeSet) -> Validation<()> { + fn validate( + &self, + field: &str, + model_options: &BTreeSet, + default_options: &BTreeSet, + ) -> Validation<()> { if self.projects.is_empty() { return Err(invalid( format!("{field}.projects"), @@ -327,10 +340,10 @@ impl ModelMap { } for (id, rule) in &self.option_defaults { let field = format!("{field}.optionDefaults.{id}"); - if !model_options.contains(id) { + if !default_options.contains(id) { return Err(invalid( field, - "optionDefaults may only fill options declared with choicesFromModel.", + "optionDefaults may only fill choicesFromModel, text, file and directory options.", )); } select::validate(&rule.each, &format!("{field}.each"), false)?; diff --git a/rust/crates/build/src/manifest/options.rs b/rust/crates/build/src/manifest/options.rs index 06ada0c0..4638b431 100644 --- a/rust/crates/build/src/manifest/options.rs +++ b/rust/crates/build/src/manifest/options.rs @@ -8,6 +8,9 @@ use super::*; pub(crate) struct OptionDeclaration { pub(crate) id: String, pub(crate) display_name: String, + /// What the option does, for the host's ⓘ next to it; display only. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub(crate) description: Option, pub(crate) kind: OptionKind, /// Instance values belong to one detected root, never to its siblings. #[serde(default, skip_serializing_if = "OptionScope::is_workspace")] @@ -73,6 +76,15 @@ impl OptionDeclaration { self.separator.as_deref().unwrap_or(DEFAULT_SEPARATOR) } + /// Whether the option holds one free value (`text`, `file`, `directory`), + /// whose unset value the model may report as the tool's own. + pub(crate) fn is_text_like(&self) -> bool { + matches!( + self.kind, + OptionKind::Text | OptionKind::File | OptionKind::Directory + ) + } + pub(crate) fn is_select(&self) -> bool { matches!( self.kind, @@ -272,6 +284,9 @@ impl OptionDeclaration { &format!("{field}.displayName"), "display name", )?; + if let Some(description) = &self.description { + super::run_types::check_description(description, &format!("{field}.description"))?; + } let select = self.is_select(); if !select && (!self.choices.is_empty() || self.choices_from_model || self.allow_custom) { return Err(invalid( diff --git a/rust/crates/build/src/model.rs b/rust/crates/build/src/model.rs index 4cf57021..64040d17 100644 --- a/rust/crates/build/src/model.rs +++ b/rust/crates/build/src/model.rs @@ -38,7 +38,9 @@ pub(crate) struct BuildModel { pub(crate) content_roots: Vec, /// Values the model offers for `choicesFromModel` options. pub(crate) option_values: BTreeMap>, - /// Subset of `option_values` the build tool activates when the option is unset. + /// What the build tool uses when an option is unset: the subset of + /// `option_values` it activates, or the one value of a text, file or + /// directory option. #[serde(skip_serializing_if = "BTreeMap::is_empty")] pub(crate) option_defaults: BTreeMap>, /// Per-option prefix a `litheBuildModel` script supplies to turn a default choice off. @@ -346,17 +348,25 @@ impl<'a> ModelBuilder<'a> { } } + /// Records a value the tool uses while `option` is unset: a choice it + /// activates, or the one value of a text, file or directory option (the + /// first reported wins, as the tool has only one). fn add_option_default(&mut self, option: &str, value: &str) { - let accepted = self - .build_system - .option(option) - .is_some_and(|declaration| declaration.choices_from_model) - && super::manifest::is_option_value(value); - if accepted { + let Some(declaration) = self.build_system.option(option) else { + return; + }; + if !super::manifest::is_option_value(value) { + return; + } + if declaration.choices_from_model { let values = self.option_defaults.entry(option.to_string()).or_default(); if values.len() < MAX_ITEMS { values.insert(value.to_string()); } + } else if declaration.is_text_like() { + self.option_defaults + .entry(option.to_string()) + .or_insert_with(|| BTreeSet::from([value.to_string()])); } } @@ -477,6 +487,13 @@ impl<'a> ModelBuilder<'a> { .option_defaults .into_iter() .filter_map(|(id, defaults)| { + if self + .build_system + .option(&id) + .is_some_and(|option| option.is_text_like()) + { + return Some((id, defaults.into_iter().collect())); + } let known = model.option_values.get(&id)?; let kept: Vec = defaults .into_iter() diff --git a/rust/crates/build/src/options.rs b/rust/crates/build/src/options.rs index b5ebb268..fc2c3fa3 100644 --- a/rust/crates/build/src/options.rs +++ b/rust/crates/build/src/options.rs @@ -543,6 +543,22 @@ pub(crate) fn describe_with_facts( if option.scope == super::manifest::OptionScope::Instance { entry["scope"] = json!("instance"); } + if let Some(description) = &option.description { + entry["description"] = json!(description); + } + if source == "unset" && option.is_text_like() { + // What the tool uses while the option is unset, as the model + // reported it (Maven's user settings file, its local + // repository). Display only: it contributes no argument, so + // the tool keeps deciding when its own configuration changes. + if let Some(value) = facts + .defaults + .and_then(|map| map.get(&option.id)) + .and_then(|values| values.first()) + { + entry["implicitValue"] = json!(value); + } + } entry }) .collect(); diff --git a/rust/crates/core/src/tests/build_systems.rs b/rust/crates/core/src/tests/build_systems.rs index a76b6cfa..f17297d9 100644 --- a/rust/crates/core/src/tests/build_systems.rs +++ b/rust/crates/core/src/tests/build_systems.rs @@ -3447,6 +3447,110 @@ fn model_option_defaults_and_exclusions_round_trip_through_storage_and_plans() { assert_eq!(after_restore["source"], "default"); } +/// A model reports what the tool uses for a text, file or directory option +/// the user left unset (Maven's user settings file and local repository), as +/// IDEA shows the effective path greyed out until the user overrides it. The +/// value is display only: it contributes no argument, and a user value or a +/// declared default replaces it. +#[test] +fn model_reports_the_implicit_value_of_unset_path_options() { + let workspace = TemporaryWorkspace::new("model-implicit-values"); + let mut manifest = option_edit_fixture()["manifest"].clone(); + manifest["buildSystems"][0]["options"] + .as_array_mut() + .unwrap() + .extend([ + json!({"id": "settingsFile", "displayName": "User settings file", "kind": "file", + "description": "The settings.xml passed with -s.", + "arguments": ["-s", "${value}"]}), + json!({"id": "localRepository", "displayName": "Local repository", "kind": "directory", + "arguments": ["-Dmaven.repo.local=${value}"]}), + json!({"id": "threads", "displayName": "Threads", "kind": "text", "default": "1", + "arguments": ["-T", "${value}"]}), + json!({"id": "offline", "displayName": "Offline", "kind": "boolean", + "arguments": ["-o"]}), + ]); + let canonical = json!({ + "format": "litheBuildModel", + "version": 0, + "projects": [{"path": ".", "name": "demo"}], + "optionValues": {"profiles": ["dev"]}, + "optionDefaults": { + "settingsFile": ["/home/me/.m2/settings.xml", "/ignored/second.xml"], + "localRepository": ["/home/me/.m2/repository"], + "threads": ["4"], + "offline": ["true"] + } + }); + let decoded = build_decode_model_command::(json!({ + "manifest": manifest, + "buildSystemID": "fixture", + "request": {"workspaceRoot": workspace.root(), "root": ".", "output": canonical.to_string()} + })) + .unwrap(); + assert_eq!(decoded["status"], "ok", "{decoded}"); + let defaults = &decoded["model"]["optionDefaults"]; + // The tool has one value: the first reported is kept. A boolean option has + // no implicit value to report. + assert_eq!(defaults["settingsFile"], json!(["/home/me/.m2/settings.xml"]), "{defaults}"); + assert_eq!(defaults["localRepository"], json!(["/home/me/.m2/repository"])); + assert!(defaults.get("offline").is_none(), "{defaults}"); + + let resolve = |options: Value| { + let resolved = build_resolve_options_command::(json!({ + "manifest": manifest, + "buildSystemID": "fixture", + "request": {"options": options, "modelValues": decoded["model"]["optionValues"], + "modelDefaults": defaults} + })) + .unwrap(); + resolved["options"]["options"].as_array().unwrap().clone() + }; + let by_id = |options: &[Value], id: &str| { + options.iter().find(|option| option["id"] == id).unwrap().clone() + }; + let unset = resolve(json!({})); + let settings = by_id(&unset, "settingsFile"); + assert_eq!(settings["source"], "unset", "{settings}"); + assert_eq!(settings["value"], Value::Null); + assert_eq!(settings["implicitValue"], "/home/me/.m2/settings.xml"); + assert_eq!(settings["description"], "The settings.xml passed with -s."); + assert_eq!(by_id(&unset, "localRepository")["implicitValue"], "/home/me/.m2/repository"); + // A declared default is the effective value, so the model's is not shown. + let threads = by_id(&unset, "threads"); + assert_eq!(threads["source"], "default"); + assert!(threads.get("implicitValue").is_none(), "{threads}"); + assert!(by_id(&unset, "offline").get("implicitValue").is_none()); + + let overridden = resolve(json!({"settingsFile": "/work/settings.xml"})); + let settings = by_id(&overridden, "settingsFile"); + assert_eq!(settings["source"], "user"); + assert_eq!(settings["value"], "/work/settings.xml"); + assert!(settings.get("implicitValue").is_none(), "{settings}"); +} + +/// A model map may fill `optionDefaults` for choicesFromModel, text, file and +/// directory options only: a boolean or a declared select has no value the +/// tool picks on its own. +#[test] +fn model_map_option_defaults_name_choice_or_text_options() { + let mut manifest = fixture("build-static-file.plugin.json"); + let system = &mut manifest["buildSystems"][0]; + system["options"].as_array_mut().unwrap().extend([ + json!({"id": "settingsFile", "displayName": "Settings", "kind": "file", "arguments": ["-s", "${value}"]}), + json!({"id": "goOffline", "displayName": "Offline", "kind": "boolean", "arguments": ["-o"]}), + ]); + system["model"]["map"]["optionDefaults"] = + json!({"settingsFile": {"each": "/package", "value": "/settings"}}); + let accepted = validate(manifest.clone()); + assert_eq!(accepted["status"], "ok", "{accepted}"); + + manifest["buildSystems"][0]["model"]["map"]["optionDefaults"] = + json!({"goOffline": {"each": "/package", "value": "/offline"}}); + let refused = validate(manifest); + assert_eq!(refused["status"], "rejected", "{refused}"); +} + fn option_edit_fixture() -> Value { serde_json::from_str(include_str!( "../../../../fixtures/build/option-edit-v1.json" diff --git a/shared/plugins/contract/v1/README.md b/shared/plugins/contract/v1/README.md index c62ef542..b5cff411 100644 --- a/shared/plugins/contract/v1/README.md +++ b/shared/plugins/contract/v1/README.md @@ -1938,7 +1938,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 the folders hidden by default (Core's own and the names enabled plugins declare, see `layout`), 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` | 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`, with optional `optionDefaults` for choices the tool activates when unset), or are free (`allowCustom`); a `multiSelect` option may set `excludePrefix` (or report `optionExcludePrefixes` in `litheBuildModel`) so unchecking a default choice passes ``. | +| `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`, with optional `optionDefaults` for choices the tool activates when unset), or are free (`allowCustom`). A `text`, `file` or `directory` option may also get the value the tool uses while it is unset from the model's `optionDefaults` (Maven's user settings file, its local repository); `build.resolveOptions` returns it as `implicitValue` for display only, and it contributes no argument. `description` (1-512 characters) says what the option does, for the host's info icon; a `multiSelect` option may set `excludePrefix` (or report `optionExcludePrefixes` in `litheBuildModel`) so unchecking a default choice passes ``. | | `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`. | | `tasks` | The task catalog. `scopes` say what a task runs on (`workspace`, `project`, `target`); `targetTags` restrict targets; `requiresUserArguments` makes the host ask for arguments. A `fromModel` task is the template for tasks the model lists. | @@ -2116,7 +2116,10 @@ for this invocation, including values activated outside the IDE's saved options. Use an empty array if the tool reports that none are active. Omit the entry when the tool cannot observe the active set. Report baseline defaults in `optionDefaults`; Core restricts both sets to the available `optionValues` and -ties the observed set to the option fingerprint of the model load. +ties the observed set to the option fingerprint of the model load. For a +`text`, `file` or `directory` option, `optionDefaults: { : [value] }` +is the value the tool uses while the option is unset; Core keeps the first +value and passes nothing for it. Unknown fields in canonical documents are ignored, so a script may add fields without a new version. Output that does not fit its decoder is `plugin.build.invalidOutput`. @@ -2984,7 +2987,9 @@ manifest, the build-system ID, and a request, and revalidate the manifest every time. `build.detect` walks the workspace once for all enabled plugins and returns instances, with the model of `static` sources. `build.invocationPlan` and `build.checkToolVersion` resolve the executable; `build.resolveOptions` checks stored option values and returns -the configuration fingerprint; `build.modelPlan`, `build.taskPlan`, +each option's value, `source` (`user`, `default` or `unset`), choices, +`description`, and, for an unset `text`, `file` or `directory` option, the +`implicitValue` the loaded model reported, with the configuration fingerprint; `build.modelPlan`, `build.taskPlan`, `build.testPlan`, and `build.dependencyPlan` return argv plans, or provider requests for a provider source; `build.decodeModel`, `build.decodeTestResults`, `build.decodeDiagnostics`, diff --git a/shared/plugins/contract/v1/plugin-manifest.schema.json b/shared/plugins/contract/v1/plugin-manifest.schema.json index 1b1596ce..6d85e865 100644 --- a/shared/plugins/contract/v1/plugin-manifest.schema.json +++ b/shared/plugins/contract/v1/plugin-manifest.schema.json @@ -2750,6 +2750,7 @@ } }, "optionDefaults": { + "description": "What the tool uses while an option is unset: choices of a choicesFromModel option it activates, or the one value of a text, file or directory option (the first reported wins). The latter is display only and contributes no argument.", "type": "object", "additionalProperties": { "type": "object", @@ -3070,6 +3071,12 @@ "minLength": 1, "maxLength": 120 }, + "description": { + "description": "What the option does, shown by the host next to it (an info icon); display only.", + "type": "string", + "minLength": 1, + "maxLength": 512 + }, "kind": { "enum": [ "boolean", diff --git a/shared/plugins/reference/domains/build-systems.md b/shared/plugins/reference/domains/build-systems.md index 27299fa1..8ab5ee5c 100644 --- a/shared/plugins/reference/domains/build-systems.md +++ b/shared/plugins/reference/domains/build-systems.md @@ -57,7 +57,7 @@ - **选项范围。** 选项可以声明 `scope: "instance"`,按检测到的每个根目录分别保存:改动或重置 `a` 不会影响 `b`。省略范围(或 `"workspace"`)使用工作区和构建系统存储。显式的 `false`、`""`、`[]` 仍然是用户保存的值。实例值不能覆盖工作区选项,工作区值也不能悄悄覆盖实例选项。示例:`build-instance-options`。 - **可执行文件解析。** `invocation.executables` 按偏好顺序列出来源:`projectFile`(项目里的包装脚本,总是运行项目代码)、`environment`、`command`(`PATH` 上的命令名)、`runtime`、`setting`(引用声明为 `file` 的全局设置)和 `toolchain`(工具定义 ID)。可以用 `id`、`priority`、`insertBefore`、`insertAfter` 调整同一个候选集内的顺序。用户配置的路径失败是终止性的,不会回退到后面的候选或提供者自己的查找。示例:`build-tool-path`(`setting`)、`build-toolchains`(`toolchain`)。规则见[可执行文件解析](../../contract/v1/README.md#executable-resolution)。 -- **展示。** 每个启用的构建系统有自己的工具窗口,由宿主按模型绘制;`options[].presentation` 把布尔选项放到工具栏(`toolbar`,需要 `icon`)或把多选选项放成树顶部的清单(`tree`),`tasks[].category` 给任务归类。模型可以通过 `optionDefaults` 给出未设置时默认激活的多选候选,并通过 `options[].excludePrefix` 或 `litheBuildModel` 的 `optionExcludePrefixes` 声明取消默认激活项的前缀(如 `"-"`),Core 负责把勾选集合编码成存储值并在树顶生成 `option` 与 `optionChoice` 节点。树由 Core 统一排布:项目按 `parentID` 嵌套,每个项目下依次是它的任务文件夹、依赖、目标和子项目;只作用于整个工作区的任务、依赖和测试在根项目旁边只出现一次;只有一个根项目时,它的内容直接作为构建系统的内容,任务仍在根项目上运行。 +- **展示。** 每个启用的构建系统有自己的工具窗口,由宿主按模型绘制;`options[].presentation` 把布尔选项放到工具栏(`toolbar`,需要 `icon`)或把多选选项放成树顶部的清单(`tree`),`tasks[].category` 给任务归类。模型可以通过 `optionDefaults` 给出未设置时默认激活的多选候选,并通过 `options[].excludePrefix` 或 `litheBuildModel` 的 `optionExcludePrefixes` 声明取消默认激活项的前缀(如 `"-"`),Core 负责把勾选集合编码成存储值并在树顶生成 `option` 与 `optionChoice` 节点。`text`、`file`、`directory` 选项也可以由模型在 `optionDefaults` 里报告未设置时工具实际使用的值(如 Maven 的用户设置文件和本地仓库),`build.resolveOptions` 以 `implicitValue` 返回,宿主只用来显示“实际生效值”,不会据此传参数;选项的 `description` 是宿主 ⓘ 里的说明。树由 Core 统一排布:项目按 `parentID` 嵌套,每个项目下依次是它的任务文件夹、依赖、目标和子项目;只作用于整个工作区的任务、依赖和测试在根项目旁边只出现一次;只有一个根项目时,它的内容直接作为构建系统的内容,任务仍在根项目上运行。 - **项目准备任务。** 项目任务可以声明 `preparation: { purpose, sourceRoles }`,按用途(如 `run`)和内容根角色绑定运行前要执行的任务;宿主从当前模型选出最深的所属项目和内容根,要求恰好一个匹配的声明,不猜任务名,也不回退到约定的任务 ID。示例:`build-providers/build-provider-preparation`。 - **只读模型输入。** 生产者用 `modelSharing: { options: [...] }` 公开规范化的项目、目标和内容根(以及明确列出的普通选项的有效值),消费者用 `modelInputs: [{ pluginID, buildSystemID }]` 读取,最多 8 个槽位。缺失、被禁用或不公开的生产者只会让该槽位 `unavailable`,从不被自动安装或激活;一个生产者不能同时是消费者。示例:`build-model-producer`、`build-model-consumer`。 @@ -159,7 +159,7 @@ A build system's `hostIntegration` and a language server's `hostIntegration` are - **Option scope.** An option may declare `scope: "instance"`, stored separately per detected root: changing or resetting `a` cannot change `b`. Omitting the scope (or `"workspace"`) uses the workspace and build-system storage. Explicit `false`, `""`, and `[]` remain stored user values. Instance values cannot override workspace options, and workspace values cannot silently override an instance option. Example: `build-instance-options`. - **Executable resolution.** `invocation.executables` lists sources in preference order: `projectFile` (a wrapper inside the project; always runs project code), `environment`, `command` (a bare name on `PATH`), `runtime`, `setting` (references a declared global `file` setting), and `toolchain` (a tool-definition ID). `id`, `priority`, `insertBefore`, and `insertAfter` reorder candidates within one candidate set. A configured path that fails is terminal and never falls back to later candidates or to the provider's own lookup. Examples: `build-tool-path` (`setting`) and `build-toolchains` (`toolchain`). The rules are in [Executable resolution](../../contract/v1/README.md#executable-resolution). -- **Presentation.** Every enabled build system gets a tool window of its own, drawn by the host from the model; `options[].presentation` puts a boolean option on the toolbar (`toolbar`, needs an `icon`) or a multiSelect option as a checklist at the top of the tree (`tree`), and `tasks[].category` files a task under headings. A model may also report choices active when the option is unset (`optionDefaults`) and a prefix that turns a default choice off (`options[].excludePrefix` or `optionExcludePrefixes` in `litheBuildModel`, such as `"-"`), so Core encodes the checked set and places `option` and `optionChoice` nodes at the top of the tree. Core lays out the tree the same way for every tool: projects nest by `parentID`, and each project lists its task folders, its dependencies, its targets and then its child projects; tasks, dependencies and tests that act on the whole workspace appear once, beside the root projects. With a single root project, its contents become the build system's own, and its tasks still run on the root project. +- **Presentation.** Every enabled build system gets a tool window of its own, drawn by the host from the model; `options[].presentation` puts a boolean option on the toolbar (`toolbar`, needs an `icon`) or a multiSelect option as a checklist at the top of the tree (`tree`), and `tasks[].category` files a task under headings. A model may also report choices active when the option is unset (`optionDefaults`) and a prefix that turns a default choice off (`options[].excludePrefix` or `optionExcludePrefixes` in `litheBuildModel`, such as `"-"`), so Core encodes the checked set and places `option` and `optionChoice` nodes at the top of the tree. A `text`, `file` or `directory` option may also have the value the tool uses while it is unset reported in `optionDefaults` (Maven's user settings file and local repository); `build.resolveOptions` returns it as `implicitValue`, which the host shows as the effective value and never passes as an argument. An option's `description` is the text of the host's info icon. Core lays out the tree the same way for every tool: projects nest by `parentID`, and each project lists its task folders, its dependencies, its targets and then its child projects; tasks, dependencies and tests that act on the whole workspace appear once, beside the root projects. With a single root project, its contents become the build system's own, and its tasks still run on the root project. - **Project preparation tasks.** A project task may declare `preparation: { purpose, sourceRoles }`, binding the task to run first by purpose (such as `run`) and content-root role. The host selects the deepest owning project and content root from the current model, requires exactly one matching declaration, never guesses a task name, and never falls back to a conventional task ID. Example: `build-providers/build-provider-preparation`. - **Read-only model inputs.** A producer publishes normalized projects, targets, and content roots (and the effective values of explicitly listed ordinary options) with `modelSharing: { options: [...] }`; a consumer reads them with `modelInputs: [{ pluginID, buildSystemID }]`, up to 8 slots. A missing, disabled, or non-public producer only makes that slot `unavailable` and is never installed or activated automatically; a producer cannot also be a consumer. Examples: `build-model-producer` and `build-model-consumer`. From 53c9cf9f94d5c78ee5ba5783657794a7351d3f1b Mon Sep 17 00:00:00 2001 From: lick <2188718831@qq.com> Date: Thu, 19 Nov 2026 04:28:17 -0800 Subject: [PATCH 2/2] docs(plugins): record #120 in the protocol changelog Co-Authored-By: Claude Opus 5.5 --- rust/crates/build/src/manifest/model.rs | 4 +++- rust/crates/core/src/tests/build_systems.rs | 22 +++++++++++++++---- .../plugins/reference/protocol-changelog.md | 1 + 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/rust/crates/build/src/manifest/model.rs b/rust/crates/build/src/manifest/model.rs index 8c0a82b1..0eb7b65b 100644 --- a/rust/crates/build/src/manifest/model.rs +++ b/rust/crates/build/src/manifest/model.rs @@ -266,7 +266,9 @@ impl BuildSystemDeclaration { format!("{field}.map"), "A model command with a generic format needs a map.", )), - (_, Some(map)) => map.validate(&format!("{field}.map"), &model_options, &default_options), + (_, Some(map)) => { + map.validate(&format!("{field}.map"), &model_options, &default_options) + } } } Some(ModelSource::Provider) => Ok(()), diff --git a/rust/crates/core/src/tests/build_systems.rs b/rust/crates/core/src/tests/build_systems.rs index f17297d9..881ad865 100644 --- a/rust/crates/core/src/tests/build_systems.rs +++ b/rust/crates/core/src/tests/build_systems.rs @@ -3492,8 +3492,15 @@ fn model_reports_the_implicit_value_of_unset_path_options() { let defaults = &decoded["model"]["optionDefaults"]; // The tool has one value: the first reported is kept. A boolean option has // no implicit value to report. - assert_eq!(defaults["settingsFile"], json!(["/home/me/.m2/settings.xml"]), "{defaults}"); - assert_eq!(defaults["localRepository"], json!(["/home/me/.m2/repository"])); + assert_eq!( + defaults["settingsFile"], + json!(["/home/me/.m2/settings.xml"]), + "{defaults}" + ); + assert_eq!( + defaults["localRepository"], + json!(["/home/me/.m2/repository"]) + ); assert!(defaults.get("offline").is_none(), "{defaults}"); let resolve = |options: Value| { @@ -3507,7 +3514,11 @@ fn model_reports_the_implicit_value_of_unset_path_options() { resolved["options"]["options"].as_array().unwrap().clone() }; let by_id = |options: &[Value], id: &str| { - options.iter().find(|option| option["id"] == id).unwrap().clone() + options + .iter() + .find(|option| option["id"] == id) + .unwrap() + .clone() }; let unset = resolve(json!({})); let settings = by_id(&unset, "settingsFile"); @@ -3515,7 +3526,10 @@ fn model_reports_the_implicit_value_of_unset_path_options() { assert_eq!(settings["value"], Value::Null); assert_eq!(settings["implicitValue"], "/home/me/.m2/settings.xml"); assert_eq!(settings["description"], "The settings.xml passed with -s."); - assert_eq!(by_id(&unset, "localRepository")["implicitValue"], "/home/me/.m2/repository"); + assert_eq!( + by_id(&unset, "localRepository")["implicitValue"], + "/home/me/.m2/repository" + ); // A declared default is the effective value, so the model's is not shown. let threads = by_id(&unset, "threads"); assert_eq!(threads["source"], "default"); diff --git a/shared/plugins/reference/protocol-changelog.md b/shared/plugins/reference/protocol-changelog.md index d4c93d3e..32b04669 100644 --- a/shared/plugins/reference/protocol-changelog.md +++ b/shared/plugins/reference/protocol-changelog.md @@ -150,6 +150,7 @@ | PR | 修改人 | API 编号 | 协议 / 能力 | 改了什么 | | --- | --- | --- | --- | --- | +| [#120](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/120) | [@1lck](https://github.com/1lck) | API-29 | `buildSystems` 0 内的补充 | 清单的 `options[]` 新增 `description`(1–512 字符),作为宿主 ⓘ 中的说明,只用于显示。`litheBuildModel` 和 `model.map` 的 `optionDefaults` 除 `choicesFromModel` 选项外,也可以填 `text`、`file`、`directory` 选项,值是选项未设置时工具实际使用的那一个(如 Maven 的用户设置文件和本地仓库),Core 只保留第一个值。`build.resolveOptions` 对未设置的这类选项返回 `implicitValue`,并返回 `description`。`implicitValue` 只用于显示,不生成参数,也不进入选项指纹。旧 Core 会拒绝声明了 `description` 或给路径选项填 `optionDefaults` 的清单。没有新增版本号、宿主方法、通知或 SDK 版本。见 [1lck/Lithe-IDEA#2152](https://github.com/1lck/Lithe-IDEA/issues/2152)、[#2204](https://github.com/1lck/Lithe-IDEA/issues/2204)。 | | [#118](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/118) | [@1lck](https://github.com/1lck) | — | `buildSystems` 0 内的行为补充 | 契约新增 [Workspace trust](../contract/v1/README.md#workspace-trust) 一节,取代“Lithe 没有工作区信任状态”的说法。构建计划请求新增 `projectCodeAllowed`;工作区未受信任时,Core 以新错误码 `plugin.build.untrustedWorkspace` 拒绝所有任务、测试、运行、调试准备,以及声明了 `executesProjectCode: true` 的模型、依赖命令和构建提供者请求。声明 `false` 的模型和依赖命令在安全模式下照常加载。插件清单和后端协议都不变;宿主必须在计划请求里传入信任,否则会运行项目代码的计划都会被拒绝。没有新增版本号、宿主方法、通知或 SDK 版本。见 [1lck/Lithe-IDEA#2201](https://github.com/1lck/Lithe-IDEA/issues/2201)。 | | [#111](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/111) | [@Mucheen](https://github.com/Mucheen) | API-23 | `toolchainProviders` 0 内的修正 | 无项目时,`toolchains.resolve` 可使用同一代次的全局提供者回包。解析目录为 `.`,查询的 `workspace` 和 `context` 显式为 `null`,解析上下文也为空。工作区查询继续校验根目录和相对目录,两种查询都核对文件系统快照及排除根。 | | [#113](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/113) | [@xiaoyumuxi](https://github.com/xiaoyumuxi) | — | `pluginAPIVersion` 0 内的说明补充(官方 SDK 新增 Go) | Go 插件后端 SDK 放在 `shared/plugins/sdk/go`,模块路径 `github.com/Lithe-IDEA/Lithe-core-rust/shared/plugins/sdk/go`,需要 Go 1.22 或更高版本,只用标准库,按模块标签 `shared/plugins/sdk/go/v<版本>` 发布(还没有推送标签)。它实现函数协议和宿主服务(凭据、工作区、文档与编辑器、预览、浏览器、窗口消息、`functions/providers` 与 `functions/invoke`、原生终端、订阅)、插件视图 `View(id, handler)` 和 `litheKeymapImport` 0,不实现构建和 VCS 提供者。契约 README 的 Official backend SDK 加上 `sdk/go` 一段:在 Unix 上把协议移到 stdout 的副本、stdout 指向 stderr,处理函数 panic 只结束这一次调用。Go 示例后端和 Rust 示例后端跑同一个插件后端场景,`sdk-e2e.mjs` 新增 `plugin_sdk_go`。插件总览、日志指南和各参考页列出 Go SDK,并推荐新插件优先用 Rust 或 Go SDK(构建后端照旧用 Node.js 或 Java SDK,VCS 后端用 Node.js SDK)。没有新增版本号、宿主方法、通知或协议字段。 |