From 8645fb97a90145040945081e86944608939c4564 Mon Sep 17 00:00:00 2001 From: lick <2188718831@qq.com> Date: Mon, 16 Nov 2026 22:12:28 -0800 Subject: [PATCH 1/2] =?UTF-8?q?feat(plugin-model):=20sourceSettings=201=20?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=A8=A1=E5=9D=97=E5=88=97=E8=A1=A8=E3=80=81?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=E9=A1=B5=E5=92=8C=E7=B1=BB=E5=9E=8B=E5=8C=96?= =?UTF-8?q?=E6=9D=A1=E7=9B=AE=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 分组布局 sidebar:来源显示为左侧导航列表,可用 parent 嵌套(最多 8 层) - 字段 section:sidebar 中为标签页,form 中为小标题,表格不接受 - 字段类型 entryList:entryKinds(file/directory/choice)、至多 4 个按条目属性列; 条目的 title/detail 只用于显示,比较和写回时忽略;新增的 choice 条目必须来自 当前可选项或原值 - SourceInput 新增 entries 草稿;effectiveDisplays 对 entryList 给出数量 - 能力表 sourceSettings 支持 [0, 1];新增 fixture settings-sources-modules.json - 契约 README、schema、能力版本表、设置指南和应用边界文档同步 Refs 1lck/Lithe-IDEA#2086 Co-Authored-By: Claude Opus 5.5 --- rust/contracts/application-boundary.md | 3 +- .../core/src/tests/plugin_source_settings.rs | 46 +++ rust/crates/plugin-model/src/capabilities.rs | 2 +- .../plugin-model/src/settings/sources.rs | 293 +++++++++++++++-- .../src/settings/sources/tests.rs | 190 +++++++++++ .../plugins/settings-sources-modules.json | 296 ++++++++++++++++++ shared/plugins/contract/v1/README.md | 35 ++- .../contract/v1/plugin-manifest.schema.json | 4 +- .../reference/capabilities-and-versions.md | 2 + shared/plugins/reference/domains/settings.md | 29 ++ 10 files changed, 868 insertions(+), 32 deletions(-) create mode 100644 rust/fixtures/plugins/settings-sources-modules.json diff --git a/rust/contracts/application-boundary.md b/rust/contracts/application-boundary.md index 3f880784..319cf97b 100644 --- a/rust/contracts/application-boundary.md +++ b/rust/contracts/application-boundary.md @@ -20,7 +20,8 @@ verification scripts are the executable source of boundary checks. ## Source-backed plugin settings -Source-backed plugin settings use `sourceSettings: 0` and the three +Source-backed plugin settings use `sourceSettings: 0` (version 1 adds module +sidebars, field sections and typed entry lists) and the three `plugins.settings.source*` commands. Plugins supply only allowlisted non-sensitive fields from their upstream configuration; Core validates and projects the form, inheritance and confirmed edits. Native adapters capture workspace identity, diff --git a/rust/crates/core/src/tests/plugin_source_settings.rs b/rust/crates/core/src/tests/plugin_source_settings.rs index e6a026aa..80a804eb 100644 --- a/rust/crates/core/src/tests/plugin_source_settings.rs +++ b/rust/crates/core/src/tests/plugin_source_settings.rs @@ -55,3 +55,49 @@ fn source_editor_actions_require_explicit_host_capability_and_keep_their_binding assert_eq!(plan["data"]["plan"]["function"], "compiler.settings"); assert_eq!(plan["data"]["plan"]["params"], json!({})); } + +#[test] +fn module_structure_editors_need_source_settings_version_one() { + let fixture: Value = serde_json::from_str(include_str!(concat!( + env!("CARGO_MANIFEST_DIR"), + "/../../fixtures/plugins/settings-sources-modules.json" + ))) + .unwrap(); + let run = |command: &str, payload: Value| -> Value { + serde_json::from_str(&crate::execute_json( + &json!({"command":command,"payload":payload}).to_string(), + )) + .unwrap() + }; + let state = run( + "plugins.settings.sourceState", + json!({"result":fixture["snapshot"]}), + ); + assert_eq!(state["data"]["status"], "ok", "{state}"); + assert_eq!( + state["data"]["state"]["inputs"]["app"]["roots"]["entries"][1]["attributes"]["test"], + true + ); + // A plugin that projects sidebars, sections or entry lists requires + // version 1; a host that only offers version 0 refuses to install it. + let mut manifest: Value = serde_json::from_str(include_str!(concat!( + env!("CARGO_MANIFEST_DIR"), + "/../../../shared/plugins/contract/v1/fixtures/settings/source-editor.plugin.json" + ))) + .unwrap(); + manifest["requires"]["sourceSettings"] = json!(1); + let host = |versions: Value| json!({"backend":[0],"languages":[0],"settings":[0],"sourceSettings":versions}); + let refused = run( + "plugins.declarative.validate", + json!({"manifest":manifest,"hostCapabilities":host(json!([0]))}), + ); + assert_eq!( + refused["data"]["error"]["code"], "plugin.api.unsupported", + "{refused}" + ); + let accepted = run( + "plugins.declarative.validate", + json!({"manifest":manifest,"hostCapabilities":host(json!([0, 1]))}), + ); + assert_eq!(accepted["data"]["status"], "ok", "{accepted}"); +} diff --git a/rust/crates/plugin-model/src/capabilities.rs b/rust/crates/plugin-model/src/capabilities.rs index e3a428db..386a575b 100644 --- a/rust/crates/plugin-model/src/capabilities.rs +++ b/rust/crates/plugin-model/src/capabilities.rs @@ -124,7 +124,7 @@ pub const SUPPORTED_CAPABILITIES: &[(&str, &[u32])] = &[ (PLUGIN_FUNCTIONS, &[0]), (PROJECT_GENERATORS, &[0]), (SETTINGS, &[0]), - (SOURCE_SETTINGS, &[0]), + (SOURCE_SETTINGS, &[0, 1]), (TOOL_DEFINITIONS, &[0]), (TOOLCHAIN_PROVIDERS, &[0]), (UI, &[0]), diff --git a/rust/crates/plugin-model/src/settings/sources.rs b/rust/crates/plugin-model/src/settings/sources.rs index 2e5be805..045ebaf4 100644 --- a/rust/crates/plugin-model/src/settings/sources.rs +++ b/rust/crates/plugin-model/src/settings/sources.rs @@ -12,6 +12,10 @@ const MAX_SOURCES: usize = 1024; const MAX_FIELDS: usize = 32; const MAX_TEXT: usize = 8192; const MAX_BYTES: usize = 2 * 1024 * 1024; +/// Entries of one `entryList` value, matching the list bound of `fileList`. +const MAX_ENTRIES: usize = 256; +/// Nesting bound of `sidebar` sources; deeper trees are not a presentation the host supports. +const MAX_DEPTH: usize = 8; #[cfg(test)] mod tests; @@ -40,7 +44,8 @@ pub struct SourceGroup { pub id: String, /// Plugin-localized section heading. pub title: String, - /// `form` presents labeled controls; `table` presents source labels as rows. + /// `form` presents labeled controls; `table` presents source labels as rows; + /// `sidebar` lists the sources for navigation and shows one selected source. pub layout: String, /// Localized heading of the first table column; empty uses the host default. #[serde(default, skip_serializing_if = "String::is_empty")] @@ -65,6 +70,10 @@ pub struct SettingsSource { pub writable: bool, /// Allowlisted non-sensitive fields; unrelated source content stays private. pub fields: Vec, + /// Earlier source of the same `sidebar` group under which the host nests + /// this one; empty for a top-level source. + #[serde(default, skip_serializing_if = "String::is_empty")] + pub parent: String, } /// One explicitly non-sensitive raw value and its upstream effective value. @@ -78,8 +87,12 @@ pub struct SourceField { /// Explanation displayed by the host's information control. #[serde(default)] pub description: String, - /// `text`, `enum`, `boolean`, `stringList`, or `fileList`. + /// `text`, `enum`, `boolean`, `stringList`, `fileList`, or `entryList`. pub kind: String, + /// Localized tab (`sidebar` group) or subheading (`form` group) holding the + /// field; empty places it before any section. Table columns have none. + #[serde(default, skip_serializing_if = "String::is_empty")] + pub section: String, /// Null means the source has no explicit override. pub value: Value, /// Current value selected by the upstream tool, including inheritance. @@ -92,6 +105,92 @@ pub struct SourceField { /// Upstream-supported choices; empty for non-enumeration controls. #[serde(default)] pub options: Vec, + /// Kinds of entry an `entryList` holds, in the order of the host's add menu. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub entry_kinds: Vec, + /// Per-entry columns of an `entryList`, such as whether an entry is exported. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub attributes: Vec, +} + +/// One kind of `entryList` entry and how the host lets the user add it. +#[derive(Debug, Clone, Deserialize, Serialize)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub struct EntryKind { + /// Opaque kind identity stored in each entry. + pub id: String, + /// Localized add-menu item, such as "JAR files". + pub title: String, + /// `file` and `directory` open the host's native picker, whose absolute + /// native paths the plugin turns into its own spelling on write; `choice` + /// offers `choices`. + pub input: String, + /// File-name extensions a `file` picker offers, without dots; empty allows any file. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub extensions: Vec, + /// Values a `choice` kind may add; empty when nothing can be added now. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub choices: Vec, +} + +/// A value the user may add as a `choice` entry, such as a library or module. +#[derive(Debug, Clone, Deserialize, Serialize)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub struct EntryChoice { + /// Opaque native value written only after confirmation. + pub value: String, + /// Localized label. + pub title: String, + /// Localized secondary text, such as a location or a count. + #[serde(default, skip_serializing_if = "String::is_empty")] + pub detail: String, +} + +/// A per-entry column; absent values mean the plugin's default for the entry. +#[derive(Debug, Clone, Deserialize, Serialize)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub struct EntryAttribute { + /// Opaque attribute identity, a key of each entry's `attributes`. + pub id: String, + /// Localized column heading. + pub title: String, + /// `boolean` or `enum`. + pub kind: String, + /// Choices of an `enum` attribute; empty for `boolean`. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub options: Vec, +} + +/// One ordered item of an `entryList` value. Only `kind`, `value` and +/// `attributes` are native data; `title` and `detail` are display text that +/// edits and comparisons ignore. +#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub struct SourceEntry { + /// Identity of one of the field's `entryKinds`. + pub kind: String, + /// Opaque native value: a path as the plugin spells it, or a choice value. + pub value: String, + /// Localized label; empty shows `value`. + #[serde(default, skip_serializing_if = "String::is_empty")] + pub title: String, + /// Localized secondary text. + #[serde(default, skip_serializing_if = "String::is_empty")] + pub detail: String, + /// Declared attribute values; an absent key keeps the plugin's default. + #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] + pub attributes: BTreeMap, +} + +impl SourceEntry { + /// The native part of an entry, as edits carry it to the plugin. + fn native(&self) -> Value { + let mut value = json!({"kind":self.kind,"value":self.value}); + if !self.attributes.is_empty() { + value["attributes"] = json!(self.attributes); + } + value + } } /// An upstream-supported choice; its opaque value never becomes a command line. @@ -120,6 +219,9 @@ pub struct SourceInput { /// Explicitly retain or restore absence of a native override. #[serde(default)] pub inherit: bool, + /// Ordered `entryList` draft, ignored by other control kinds. + #[serde(default)] + pub entries: Vec, } /// A source-bound collection of changed controls, not a source document. @@ -203,10 +305,96 @@ fn value_valid(field: &SourceField, value: &Value) -> bool { .iter() .all(|item| item.as_str().is_some_and(|item| text(item, 4096, false))) }), + "entryList" => value.as_array().is_some_and(|items| { + let mut seen = BTreeSet::new(); + items.len() <= MAX_ENTRIES + && items.iter().all(|item| { + entry(item).is_some_and(|item| { + entry_valid(field, &item) && seen.insert((item.kind, item.value)) + }) + }) + }), _ => false, } } +fn entry(value: &Value) -> Option { + serde_json::from_value(value.clone()).ok() +} + +fn entry_valid(field: &SourceField, entry: &SourceEntry) -> bool { + field.entry_kinds.iter().any(|kind| kind.id == entry.kind) + && text(&entry.value, 4096, false) + && text(&entry.title, 256, true) + && text(&entry.detail, 1024, true) + && entry.attributes.iter().all(|(id, value)| { + field + .attributes + .iter() + .find(|attribute| &attribute.id == id) + .is_some_and(|attribute| match attribute.kind.as_str() { + "boolean" => value.is_boolean(), + _ => value.as_str().is_some_and(|value| { + attribute.options.iter().any(|option| option.value == value) + }), + }) + }) +} + +fn options_valid(options: &[SourceOption]) -> bool { + let mut choices = BTreeSet::new(); + !options.is_empty() + && options.len() <= 64 + && options.iter().all(|option| { + text(&option.value, 128, false) + && choices.insert(&option.value) + && text(&option.title, 256, false) + }) +} + +/// Validates the add menu and columns of an `entryList`, or their absence elsewhere. +fn entry_declarations_valid(field: &SourceField) -> bool { + if field.kind != "entryList" { + return field.entry_kinds.is_empty() && field.attributes.is_empty(); + } + let mut kinds = BTreeSet::new(); + let mut attributes = BTreeSet::new(); + (1..=16).contains(&field.entry_kinds.len()) + && field.entry_kinds.iter().all(|kind| { + let mut choices = BTreeSet::new(); + identifier(&kind.id) + && kinds.insert(&kind.id) + && text(&kind.title, 256, false) + && matches!(kind.input.as_str(), "file" | "directory" | "choice") + && (kind.input == "file" || kind.extensions.is_empty()) + && kind.extensions.len() <= 16 + && kind.extensions.iter().all(|extension| { + !extension.is_empty() + && extension.len() <= 32 + && extension.bytes().all(|byte| byte.is_ascii_alphanumeric()) + }) + && (kind.input == "choice" || kind.choices.is_empty()) + && kind.choices.len() <= 1024 + && kind.choices.iter().all(|choice| { + text(&choice.value, 4096, false) + && choices.insert(&choice.value) + && text(&choice.title, 256, false) + && text(&choice.detail, 1024, true) + }) + }) + && field.attributes.len() <= 4 + && field.attributes.iter().all(|attribute| { + identifier(&attribute.id) + && attributes.insert(&attribute.id) + && text(&attribute.title, 256, false) + && match attribute.kind.as_str() { + "boolean" => attribute.options.is_empty(), + "enum" => options_valid(&attribute.options), + _ => false, + } + }) +} + impl SourceSettings { /// Rejects malformed files, aliases, controls, values and section references. pub fn validate(&self) -> Validation<()> { @@ -222,12 +410,12 @@ impl SourceSettings { { return Err(rejected("snapshot")); } - let mut groups = BTreeSet::new(); + let mut groups = BTreeMap::new(); for group in &self.groups { if !identifier(&group.id) - || !groups.insert(&group.id) + || groups.insert(&group.id, group.layout.as_str()).is_some() || !text(&group.title, 256, false) - || !matches!(group.layout.as_str(), "form" | "table") + || !matches!(group.layout.as_str(), "form" | "table" | "sidebar") || !text(&group.row_title, 256, true) { return Err(rejected("groups")); @@ -235,11 +423,33 @@ impl SourceSettings { } let mut ids = BTreeSet::new(); let mut paths = BTreeSet::new(); + // Depth of each `sidebar` source; a parent must precede its children, + // which also rules out cycles. + let mut depths: BTreeMap<&str, (&str, usize)> = BTreeMap::new(); for source in &self.sources { + let Some(&layout) = groups.get(&source.group) else { + return Err(rejected("sources")); + }; + if layout == "sidebar" { + let depth = if source.parent.is_empty() { + 0 + } else { + match depths.get(source.parent.as_str()) { + Some((group, depth)) + if *group == source.group && *depth + 1 < MAX_DEPTH => + { + depth + 1 + } + _ => return Err(rejected("parent")), + } + }; + depths.insert(&source.id, (&source.group, depth)); + } else if !source.parent.is_empty() { + return Err(rejected("parent")); + } if !identifier(&source.id) || !ids.insert(&source.id) || !paths.insert(&source.path) - || !groups.contains(&source.group) || !text(&source.title, 256, false) || !relative_path(&source.path) || !valid_source_revision(&source.revision) @@ -257,8 +467,11 @@ impl SourceSettings { || !text(&field.effective_source, 1024, true) || !matches!( field.kind.as_str(), - "text" | "enum" | "boolean" | "stringList" | "fileList" + "text" | "enum" | "boolean" | "stringList" | "fileList" | "entryList" ) + || !text(&field.section, 64, true) + || layout == "table" && (!field.section.is_empty() || field.kind == "entryList") + || !entry_declarations_valid(field) || !value_valid(field, &field.value) || !value_valid(field, &field.effective_value) || !value_valid(field, &field.inherited_value) @@ -266,18 +479,9 @@ impl SourceSettings { return Err(rejected("fields")); } if field.kind == "enum" { - let mut choices = BTreeSet::new(); - if field.options.is_empty() || field.options.len() > 64 { + if !options_valid(&field.options) { return Err(rejected("options")); } - for option in &field.options { - if !text(&option.value, 128, false) - || !choices.insert(&option.value) - || !text(&option.title, 256, false) - { - return Err(rejected("options")); - } - } } else if !field.options.is_empty() { return Err(rejected("options")); } @@ -302,6 +506,14 @@ impl SourceField { match self.kind.as_str() { "enum" => input.choice = value.as_str().unwrap_or_default().to_owned(), "boolean" => input.on = value.as_bool().unwrap_or_default(), + "entryList" => { + input.entries = value + .as_array() + .into_iter() + .flatten() + .filter_map(entry) + .collect(); + } "stringList" | "fileList" => { input.text = value .as_array() @@ -334,12 +546,50 @@ impl SourceField { .filter(|line| !line.trim().is_empty()) .collect::>()) } + "entryList" => { + // A new choice entry must be one the plugin offers now or one + // the source already holds; the host cannot invent containers. + let known = |added: &SourceEntry| { + [&self.value, &self.effective_value] + .into_iter() + .filter_map(Value::as_array) + .flatten() + .filter_map(entry) + .any(|known| known.kind == added.kind && known.value == added.value) + }; + for entry in &input.entries { + let offered = self.entry_kinds.iter().any(|kind| { + kind.id == entry.kind + && (kind.input != "choice" + || kind + .choices + .iter() + .any(|choice| choice.value == entry.value)) + }); + if !offered && !known(entry) { + return Err(rejected("input")); + } + } + json!(input.entries) + } _ => return Err(rejected("input")), }; if !value_valid(self, &value) { return Err(rejected("input")); } - Ok(value) + Ok(self.native(&value)) + } + + /// Drops the display text of `entryList` entries, which never reaches a + /// write and never makes two values differ. + fn native(&self, value: &Value) -> Value { + match (self.kind.as_str(), value.as_array()) { + ("entryList", Some(items)) => items + .iter() + .map(|item| entry(item).map_or_else(|| item.clone(), |item| item.native())) + .collect(), + _ => value.clone(), + } } } @@ -402,7 +652,8 @@ pub fn state_command(payload: Value) -> Result { .map(|source| { let displays = source.fields.iter().filter(|field| { (field.value.is_null() && field.kind != "enum") - || (!field.value.is_null() && field.value != field.effective_value) + || (!field.value.is_null() + && field.native(&field.value) != field.native(&field.effective_value)) }).map(|field| { let value = &field.effective_value; let mut display = if value.is_null() { @@ -415,7 +666,7 @@ pub fn state_command(payload: Value) -> Result { json!({"kind":"text","text":title}) } "boolean" => json!({"kind":"boolean","on":value.as_bool().unwrap_or_default()}), - "fileList" | "stringList" => json!({"kind":"list","count":value.as_array().map_or(0, Vec::len)}), + "fileList" | "stringList" | "entryList" => json!({"kind":"list","count":value.as_array().map_or(0, Vec::len)}), _ => json!({"kind":"text","text":value.as_str().unwrap_or_default()}), } }; @@ -483,7 +734,7 @@ pub fn edit_command(payload: Value) -> Result { .find(|field| field.id == id) .ok_or_else(|| rejected("fieldID"))?; let value = field.edited_value(&input)?; - if value != field.value { + if value != field.native(&field.value) { values.insert(id, value); } } diff --git a/rust/crates/plugin-model/src/settings/sources/tests.rs b/rust/crates/plugin-model/src/settings/sources/tests.rs index b4917fc5..8e23b772 100644 --- a/rust/crates/plugin-model/src/settings/sources/tests.rs +++ b/rust/crates/plugin-model/src/settings/sources/tests.rs @@ -174,3 +174,193 @@ fn source_editor_bindings_follow_the_public_id_field_spelling() { assert_eq!(declaration.language_id.as_deref(), Some("fictional")); assert_eq!(serde_json::to_value(declaration).unwrap(), value); } + +fn modules() -> Value { + let fixture: Value = serde_json::from_str(include_str!(concat!( + env!("CARGO_MANIFEST_DIR"), + "/../../fixtures/plugins/settings-sources-modules.json" + ))) + .unwrap(); + fixture["snapshot"].clone() +} + +fn module_edit(values: Value) -> Value { + edit_command(json!({"snapshot":modules(),"confirmed":true,"edits":[ + {"sourceID":"app","values":values} + ]})) + .unwrap() +} + +fn dependency_entries() -> Value { + state_command(json!({"result":modules()})).unwrap()["state"]["inputs"]["app"]["dependencies"] + ["entries"] + .clone() +} + +#[test] +fn sidebar_modules_keep_their_nesting_sections_and_ordered_entries() { + let state = state_command(json!({"result":modules()})).unwrap(); + assert_eq!(state["status"], "ok", "{state}"); + let state = &state["state"]; + assert_eq!(state["snapshot"]["sources"][1]["parent"], "root"); + assert_eq!( + state["snapshot"]["sources"][1]["fields"][0]["section"], + "Sources" + ); + let entries = &state["inputs"]["app"]["dependencies"]["entries"]; + assert_eq!(entries[0]["value"], "lib/one.zip"); + assert_eq!(entries[1]["title"], "Legacy library"); + assert_eq!(entries[1]["attributes"]["exported"], true); + // An inherited, read-only list is shown by count, like a file list. + assert_eq!( + state["effectiveDisplays"]["core"]["dependencies"], + json!({"kind":"list","count":1,"inherited":true}) + ); + assert_eq!( + state["layout"], + json!([{"group":0,"sources":[0,1,2]},{"group":1,"sources":[3]}]) + ); +} + +#[test] +fn unchanged_entries_with_display_text_produce_no_write() { + let entries = dependency_entries(); + let result = module_edit(json!({"dependencies":{"entries":entries}})); + assert_eq!(result["writes"], json!([]), "{result}"); +} + +#[test] +fn added_reordered_and_flagged_entries_reach_the_plugin_without_display_text() { + let mut entries = dependency_entries().as_array().unwrap().clone(); + entries.swap(0, 1); + entries[1]["attributes"] = json!({"exported":true,"scope":"test"}); + entries.push(json!({"kind":"library","value":"lib:shared","title":"Shared library"})); + entries.push(json!({"kind":"module","value":"core"})); + entries.push(json!({"kind":"archive","value":"C:\\Example Files\\two.jar"})); + let result = module_edit(json!({"dependencies":{"entries":entries}})); + assert_eq!(result["status"], "ok", "{result}"); + assert_eq!( + result["writes"][0]["values"]["dependencies"], + json!([ + {"kind":"library","value":"lib:legacy","attributes":{"exported":true}}, + {"kind":"archive","value":"lib/one.zip","attributes":{"exported":true,"scope":"test"}}, + {"kind":"library","value":"lib:shared"}, + {"kind":"module","value":"core"}, + {"kind":"archive","value":"C:\\Example Files\\two.jar"} + ]) + ); +} + +#[test] +fn removing_every_entry_writes_an_empty_list_not_an_absent_override() { + let result = module_edit(json!({"dependencies":{"entries":[]}})); + assert_eq!(result["writes"][0]["values"], json!({"dependencies":[]})); +} + +#[test] +fn entries_the_plugin_neither_offers_nor_holds_are_rejected() { + for added in [ + json!({"kind":"library","value":"lib:invented"}), + json!({"kind":"module","value":"app"}), + json!({"kind":"unknown","value":"lib/one.zip"}), + json!({"kind":"archive","value":"lib/x.zip","attributes":{"unknown":true}}), + json!({"kind":"archive","value":"lib/x.zip","attributes":{"exported":"yes"}}), + json!({"kind":"archive","value":"lib/x.zip","attributes":{"scope":"runtime"}}), + json!({"kind":"archive","value":"lib/one.zip"}), + json!({"kind":"archive","value":" "}), + ] { + let mut entries = dependency_entries().as_array().unwrap().clone(); + entries.push(added.clone()); + let result = module_edit(json!({"dependencies":{"entries":entries}})); + assert_eq!(result["status"], "rejected", "{added}: {result}"); + } +} + +#[test] +fn read_only_modules_reject_entry_edits() { + let result = edit_command(json!({"snapshot":modules(),"confirmed":true,"edits":[ + {"sourceID":"core","values":{"dependencies":{"entries":[]}}} + ]})) + .unwrap(); + assert_eq!(result["status"], "rejected", "{result}"); +} + +#[test] +fn malformed_module_trees_sections_and_entry_declarations_never_reach_ui() { + type Case = (&'static str, fn(&mut Value)); + let cases: [Case; 12] = [ + ("parent outside a sidebar", |s| { + s["sources"][3]["parent"] = json!("root") + }), + ("unknown parent", |s| { + s["sources"][1]["parent"] = json!("missing") + }), + ("parent after child", |s| { + s["sources"][0]["parent"] = json!("app"); + s["sources"][1]["parent"] = Value::Null; + }), + ("parent in another group", |s| { + s["groups"][1]["layout"] = json!("sidebar"); + s["sources"][3]["parent"] = json!("root"); + }), + ("section in a table", |s| { + s["groups"][1]["layout"] = json!("table") + }), + ("entry kinds on a text field", |s| { + s["sources"][1]["fields"][1]["entryKinds"] = + json!([{"id":"a","title":"A","input":"file"}]) + }), + ("entry list without kinds", |s| { + s["sources"][1]["fields"][0]["entryKinds"] = json!([]); + }), + ("extensions on a choice", |s| { + s["sources"][1]["fields"][3]["entryKinds"][2]["extensions"] = json!(["zip"]) + }), + ("choices on a file", |s| { + s["sources"][1]["fields"][3]["entryKinds"][0]["choices"] = + json!([{"value":"x","title":"X"}]) + }), + ("unknown input", |s| { + s["sources"][1]["fields"][3]["entryKinds"][1]["input"] = json!("text") + }), + ("duplicate entry", |s| { + s["sources"][1]["fields"][0]["value"][1] = json!({"kind":"folder","value":"src"}) + }), + ("enum attribute without options", |s| { + s["sources"][1]["fields"][3]["attributes"][1]["options"] = json!([]) + }), + ]; + for (name, change) in cases { + let mut bad = modules(); + change(&mut bad); + if bad["sources"][1]["parent"].is_null() { + bad["sources"][1].as_object_mut().unwrap().remove("parent"); + } + assert_eq!( + state_command(json!({"result":bad})).unwrap()["status"], + "rejected", + "{name}" + ); + } +} + +#[test] +fn sidebar_nesting_is_bounded() { + let mut deep = modules(); + let template = deep["sources"][2].clone(); + let sources = deep["sources"].as_array_mut().unwrap(); + let mut parent = "core".to_string(); + for depth in 0..8 { + let mut source = template.clone(); + let id = format!("level{depth}"); + source["id"] = json!(id); + source["path"] = json!(format!("{id}/build.file")); + source["parent"] = json!(parent); + sources.push(source); + parent = id; + } + assert_eq!( + state_command(json!({"result":deep})).unwrap()["status"], + "rejected" + ); +} diff --git a/rust/fixtures/plugins/settings-sources-modules.json b/rust/fixtures/plugins/settings-sources-modules.json new file mode 100644 index 00000000..0b32c98b --- /dev/null +++ b/rust/fixtures/plugins/settings-sources-modules.json @@ -0,0 +1,296 @@ +{ + "snapshot": { + "format": "litheSettingsSources", + "version": 0, + "title": "Fictional project structure", + "groups": [ + { + "id": "modules", + "title": "Modules", + "layout": "sidebar" + }, + { + "id": "workspace", + "title": "Workspace", + "layout": "form" + } + ], + "sources": [ + { + "id": "root", + "group": "modules", + "title": "example", + "path": "tool.xml", + "revision": "missing", + "writable": true, + "fields": [ + { + "id": "runtime", + "title": "Runtime", + "section": "Dependencies", + "kind": "enum", + "value": null, + "effectiveValue": "two", + "effectiveSource": "Tool default", + "description": "Runtime the tool compiles this module against.", + "options": [ + { + "value": "one", + "title": "Runtime 1" + }, + { + "value": "two", + "title": "Runtime 2" + } + ] + } + ] + }, + { + "id": "app", + "group": "modules", + "parent": "root", + "title": "app", + "path": "app/tool.xml", + "revision": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "writable": true, + "fields": [ + { + "id": "roots", + "title": "Source folders", + "section": "Sources", + "kind": "entryList", + "value": [ + { + "kind": "folder", + "value": "src" + }, + { + "kind": "folder", + "value": "test", + "attributes": { + "test": true + } + } + ], + "effectiveValue": [ + { + "kind": "folder", + "value": "src" + }, + { + "kind": "folder", + "value": "test", + "attributes": { + "test": true + } + } + ], + "effectiveSource": "app/tool.xml", + "entryKinds": [ + { + "id": "folder", + "title": "Source folder", + "input": "directory" + } + ], + "attributes": [ + { + "id": "test", + "title": "Test", + "kind": "boolean" + } + ] + }, + { + "id": "output", + "title": "Output folder", + "section": "Paths", + "kind": "text", + "value": "build", + "effectiveValue": "build", + "effectiveSource": "app/tool.xml" + }, + { + "id": "runtime", + "title": "Runtime", + "section": "Dependencies", + "kind": "enum", + "value": "one", + "effectiveValue": "one", + "inheritedValue": "two", + "effectiveSource": "app/tool.xml", + "options": [ + { + "value": "one", + "title": "Runtime 1" + }, + { + "value": "two", + "title": "Runtime 2" + } + ] + }, + { + "id": "dependencies", + "title": "Dependencies", + "section": "Dependencies", + "kind": "entryList", + "description": "Archives, folders, libraries and modules this module compiles against, in classpath order.", + "value": [ + { + "kind": "archive", + "value": "lib/one.zip", + "title": "one.zip", + "detail": "lib" + }, + { + "kind": "library", + "value": "lib:legacy", + "title": "Legacy library", + "detail": "2 archives", + "attributes": { + "exported": true + } + } + ], + "effectiveValue": [ + { + "kind": "archive", + "value": "lib/one.zip", + "title": "one.zip", + "detail": "lib" + }, + { + "kind": "library", + "value": "lib:legacy", + "title": "Legacy library", + "detail": "2 archives", + "attributes": { + "exported": true + } + } + ], + "effectiveSource": "app/tool.xml", + "entryKinds": [ + { + "id": "archive", + "title": "Archives", + "input": "file", + "extensions": [ + "zip", + "jar" + ] + }, + { + "id": "directory", + "title": "Folder", + "input": "directory" + }, + { + "id": "library", + "title": "Library", + "input": "choice", + "choices": [ + { + "value": "lib:shared", + "title": "Shared library", + "detail": "3 archives" + } + ] + }, + { + "id": "module", + "title": "Module dependency", + "input": "choice", + "choices": [ + { + "value": "core", + "title": "core" + } + ] + } + ], + "attributes": [ + { + "id": "exported", + "title": "Export", + "kind": "boolean" + }, + { + "id": "scope", + "title": "Scope", + "kind": "enum", + "options": [ + { + "value": "compile", + "title": "Compile" + }, + { + "value": "test", + "title": "Test" + } + ] + } + ] + } + ] + }, + { + "id": "core", + "group": "modules", + "parent": "root", + "title": "core", + "path": "core/build.file", + "revision": "sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "writable": false, + "fields": [ + { + "id": "dependencies", + "title": "Dependencies", + "section": "Dependencies", + "kind": "entryList", + "value": null, + "effectiveValue": [ + { + "kind": "archive", + "value": "/cache/library-1.0.zip", + "title": "library-1.0.zip", + "detail": "/cache" + } + ], + "effectiveSource": "core/build.file", + "entryKinds": [ + { + "id": "archive", + "title": "Archives", + "input": "file" + } + ] + } + ] + }, + { + "id": "settings", + "group": "workspace", + "title": "Workspace", + "path": "settings.json", + "revision": "missing", + "writable": true, + "fields": [ + { + "id": "files", + "title": "Referenced files", + "section": "Libraries", + "kind": "fileList", + "value": null, + "effectiveValue": [ + "lib/*.zip" + ], + "effectiveSource": "Tool default" + } + ] + } + ] + } +} diff --git a/shared/plugins/contract/v1/README.md b/shared/plugins/contract/v1/README.md index 87c5d861..2bd99fc3 100644 --- a/shared/plugins/contract/v1/README.md +++ b/shared/plugins/contract/v1/README.md @@ -682,7 +682,7 @@ its `source` (`project`, `global`, or `default`). #### Source-backed settings editors -An action may declare `sourceEditor: {"editFunction":"compiler.prepareSettings"}` and require `sourceSettings: 0` +An action may declare `sourceEditor: {"editFunction":"compiler.prepareSettings"}` and require `sourceSettings: 0` (or `1`, below) alongside `settings: 0`. The host invokes the read function only after an explicit user action; opening its page must not run project wrappers or tools. The function must **only read** and return the @@ -709,12 +709,29 @@ Snapshot fields (unknown fields are rejected): | Field | Contract | | --- | --- | | `format`, `version`, `title` | `litheSettingsSources`, `0`, and a localized nonblank title of at most 256 UTF-8 bytes. The complete snapshot is at most 2 MiB. | -| `groups` | 1–32 ordered `{id,title,layout,rowTitle?}` sections. `layout` is `form` or `table`; table rows use source titles in the first column and their fields as value columns. | -| `sources` | At most 1024 `{id,group,title,path,revision,writable,fields}` bindings. `path` is normalized, workspace-relative, slash-separated, at most 4096 bytes and contains no empty/dot/parent components, drive letters or backslashes. Duplicate IDs or paths are rejected. Native adapters must additionally reject native file aliases and any installation resource. | +| `groups` | 1–32 ordered `{id,title,layout,rowTitle?}` sections. `layout` is `form`, `table`, or (version 1) `sidebar`; table rows use source titles in the first column and their fields as value columns. A `sidebar` group lists its sources for navigation, like a module list, and shows the fields of the one the user selects. | +| `sources` | At most 1024 `{id,group,title,path,revision,writable,fields,parent?}` bindings. `parent` (version 1, `sidebar` groups only) is the ID of an earlier source of the same group under which the host nests this one, at most 8 levels deep. `path` is normalized, workspace-relative, slash-separated, at most 4096 bytes and contains no empty/dot/parent components, drive letters or backslashes. Duplicate IDs or paths are rejected. Native adapters must additionally reject native file aliases and any installation resource. | | `revision` | `missing`, or `sha256:` followed by 64 lowercase hexadecimal digits covering the exact source bytes. Reading a missing source does not create it. | -| `fields` | 1–32 `{id,title,description?,kind,value,effectiveValue,inheritedValue?,effectiveSource,options?}` records per source. IDs are opaque identifiers using only lowercase ASCII letters, digits and hyphens, at most 128 bytes; labels are nonblank and at most 256 bytes, descriptions at most 2048 bytes. Only explicitly non-sensitive fields may be projected. | +| `fields` | 1–32 `{id,title,description?,section?,kind,value,effectiveValue,inheritedValue?,effectiveSource,options?,entryKinds?,attributes?}` records per source. `section` (version 1) is a localized label of at most 64 bytes: in a `sidebar` group each distinct section becomes a tab, in order of first appearance, and fields without one come before the tabs; in a `form` group it is a subheading. Table fields have no section. IDs are opaque identifiers using only lowercase ASCII letters, digits and hyphens, at most 128 bytes; labels are nonblank and at most 256 bytes, descriptions at most 2048 bytes. Only explicitly non-sensitive fields may be projected. | | Field values | `value:null` means absent/inherited. `effectiveValue` comes from the upstream tool and may also be null if there is no value. `inheritedValue` is the upstream value after removing a local override; omit it or use null when unknown. `effectiveSource` is a localized origin label of at most 1024 bytes. | -| Field kinds | `enum` with 1–64 distinct `{value,title}` options; `boolean`; `text` up to 8192 bytes; `stringList` or `fileList` with at most 256 nonblank strings, each at most 4096 bytes. Non-enumeration fields omit options. `fileList` adds the host's file picker; list editing uses one item per line, preserving spaces and platform path spelling. | +| Field kinds | `enum` with 1–64 distinct `{value,title}` options; `boolean`; `text` up to 8192 bytes; `stringList` or `fileList` with at most 256 nonblank strings, each at most 4096 bytes; (version 1) `entryList`, described below. Non-enumeration fields omit options. `fileList` adds the host's file picker; list editing uses one item per line, preserving spaces and platform path spelling. Only `entryList` fields have `entryKinds` and `attributes`, and tables cannot hold them. | + +**Entry lists (version 1).** An `entryList` is an ordered list of typed +entries, such as a module's dependencies or source folders. The host shows it +as a list with an add menu, remove, move up and move down, and one column per +attribute; a read-only source shows it without those controls. + +| Member | Contract | +| --- | --- | +| `entryKinds` | 1–16 `{id,title,input,extensions?,choices?}` in add-menu order. `id` is an opaque identifier, `title` a localized menu item. `input` is `file` or `directory`, which open the host's native picker, or `choice`, which offers `choices`. A `file` kind may list up to 16 `extensions` (ASCII letters and digits, no dot) to filter the picker. A `choice` kind has 0–1024 distinct `{value,title,detail?}` choices: `value` up to 4096 bytes, `title` up to 256, `detail` up to 1024; with none, nothing of that kind can be added now. | +| `attributes` | 0–4 per-entry columns `{id,title,kind,options?}`. `kind` is `boolean` or `enum`, which has 1–64 distinct `{value,title}` options. | +| Value | Up to 256 entries `{kind,value,title?,detail?,attributes?}`. `kind` names a declared entry kind; `value` is nonblank, at most 4096 bytes, and no two entries share both `kind` and `value`. `title` (at most 256 bytes) and `detail` (at most 1024) are display text; without a title the host shows `value`. `attributes` maps declared attribute IDs to a boolean or one of the attribute's option values; an absent key means the plugin's default, which the host shows as off or as the first option. | +| Edits | `value` is the native list in its order. Display text never makes two lists differ and never reaches the edit function, which receives `[{kind,value,attributes?}]`. A `file` or `directory` entry the user adds carries the picker's absolute native path; the plugin decides how to store it, for example relative to the source. An added `choice` entry must be one of the kind's current choices or an entry the field already holds, so the host cannot introduce a value the plugin did not offer. An empty list is an explicit value, not inheritance. | + +Version 1 adds `sidebar`, `parent`, `section` and `entryList` without changing +the snapshot `version` (still `0`) or anything a version-0 snapshot means. A +plugin whose snapshots use them requires `sourceSettings: 1`; a host that +supports only version 0 rejects such a snapshot and does not install the plugin. No secret/password field, arbitrary script, CSS or host action is accepted. All plugin-provided labels and choices use the current interface language. @@ -725,7 +742,9 @@ override, maintains drafts and displays each confirmed target path. Core `plugins.settings.sourceState` supplies `inputs`, `inheritedInputs`, ordered `layout`, native I/O `limits`, and `effectiveDisplays`. The latter describes inherited non-enum values and actual values differing from explicit raw values as `unknown`, `text`, -`boolean`, or list `count`, with an `inherited` flag; the host localizes these presentation hints. +`boolean`, or list `count`, with an `inherited` flag; the host localizes these presentation hints. An +`entryList` draft is `entries`, its entries in order, and its effective display +is a `count`. On explicit Save the host uses `plugins.settings.sourceEdit` to derive only changed raw fields. It captures each target with a bounded native reader, @@ -756,7 +775,9 @@ bounded, never reusable across worktrees, and removed on every terminal path. Invalid forms, edits or receipts return `plugin.settings.invalidSourceEditor`; unknown or revoked actions retain their existing errors. These editors are local-workspace operations; remote workspaces are not supported in version 0. -Fixture: [`settings-sources.json`](../../../../rust/fixtures/plugins/settings-sources.json). +Fixtures: [`settings-sources.json`](../../../../rust/fixtures/plugins/settings-sources.json) +(version 0) and [`settings-sources-modules.json`](../../../../rust/fixtures/plugins/settings-sources-modules.json) +(version 1: a `sidebar` of nested modules with sections, entry lists, attributes and a read-only module). #### Translations diff --git a/shared/plugins/contract/v1/plugin-manifest.schema.json b/shared/plugins/contract/v1/plugin-manifest.schema.json index 49dda628..a05ad4d3 100644 --- a/shared/plugins/contract/v1/plugin-manifest.schema.json +++ b/shared/plugins/contract/v1/plugin-manifest.schema.json @@ -40,7 +40,7 @@ "packageTrust": { "description": "Required exactly when vendor.bundledSignatureRequirement is present.", "enum": [0] }, "projectGenerators": { "description": "Entries of the New Project window: fields, requirements, and steps, with tool fields that pick tool installations.", "enum": [0] }, "settings": { "description": "Required exactly when settings or settingActions is non-empty. Covers integer, enum, boolean, multiSelect, text, file, and directory options, scope, effect, page, section, and settingActions.", "enum": [0] }, - "sourceSettings": { "description": "Required exactly when a setting action declares sourceEditor. Native-source settings projection, compiler placement, confirmed staging and read-back.", "enum": [0] }, + "sourceSettings": { "description": "Required exactly when a setting action declares sourceEditor. Native-source settings projection, compiler placement, confirmed staging and read-back. Version 1 adds sidebar groups, nested sources, field sections and entry lists.", "enum": [0, 1] }, "toolDefinitions": { "enum": [0] }, "toolchainProviders": { "enum": [0] }, "keymapImportProviders": { "enum": [0] }, @@ -1426,7 +1426,7 @@ "section": { "type": "string", "minLength": 1, "maxLength": 120 }, "function": { "description": "Plugin function ID: dot-separated lowerCamelCase segments.", "type": "string", "maxLength": 128, "pattern": "^[a-z][A-Za-z0-9]*(\\.[a-z][A-Za-z0-9]*)*(?![\\s\\S])" }, "confirm": { "description": "Ask before invoking, for actions that discard state.", "type": "boolean" }, - "sourceEditor": { "description": "Read a non-sensitive native-source editor; requires sourceSettings 0. Only explicit Save invokes editFunction for private staging.", "type": "object", "additionalProperties": false, "required": ["editFunction"], "properties": { "editFunction": { "type":"string", "pattern":"^[a-z][A-Za-z0-9]*(\\.[a-z][A-Za-z0-9]*)*(?![\\s\\S])", "maxLength":128 }, "buildSystemID": {"type":"string","minLength":1,"maxLength":128}, "languageID": {"type":"string","minLength":1,"maxLength":128} } } + "sourceEditor": { "description": "Read a non-sensitive native-source editor; requires sourceSettings 0 or 1. Only explicit Save invokes editFunction for private staging.", "type": "object", "additionalProperties": false, "required": ["editFunction"], "properties": { "editFunction": { "type":"string", "pattern":"^[a-z][A-Za-z0-9]*(\\.[a-z][A-Za-z0-9]*)*(?![\\s\\S])", "maxLength":128 }, "buildSystemID": {"type":"string","minLength":1,"maxLength":128}, "languageID": {"type":"string","minLength":1,"maxLength":128} } } } }, "fileNameList": { diff --git a/shared/plugins/reference/capabilities-and-versions.md b/shared/plugins/reference/capabilities-and-versions.md index bd5a3667..541a0251 100644 --- a/shared/plugins/reference/capabilities-and-versions.md +++ b/shared/plugins/reference/capabilities-and-versions.md @@ -46,6 +46,7 @@ Core 列以本仓库 `main` 上的 Core 源码为准([`capabilities.rs`](https | `executionProviders` `0` | `executionProviders[]`:用声明的命令运行和发现测试 | ✅ | 未声明 | [语言](domains/languages.md)、[Execution providers](../contract/v1/README.md#execution-providers) | | `settings` `0` | `settings[]` 与 `settingActions[]`,含[放置位置、作用域、生效方式、页面按钮](../contract/v1/README.md#placement-scope-effect-and-page-buttons) | ✅ | ✅ | [插件设置](domains/settings.md)、[Plugin settings](../contract/v1/README.md#plugin-settings) | | `sourceSettings` `0` | 真实配置来源表单、编译器页、私有暂存与显式保存 | ✅ | 待宿主接入 / Pending host integration | [Source-backed settings editors](../contract/v1/README.md#source-backed-settings-editors) | +| `sourceSettings` `1` | 在 `0` 之上加:模块列表布局 `sidebar`(来源可用 `parent` 嵌套)、字段 `section`(标签页或小标题)、有序类型化条目列表 `entryList`(添加菜单、文件/目录选择器、可选项、按条目的属性列) | ✅ | 待宿主接入 / Pending host integration | [Entry lists](../contract/v1/README.md#source-backed-settings-editors) | | `ui` `0` | [`ui`](../contract/v1/README.md#host-owned-workbench-ui):文本、[包内网页](../contract/v1/README.md#web-content)和[原生控件](../contract/v1/README.md#host-rendered-native-content)的工具窗口、命令,以及[不打开工具窗口的后端命令](../contract/v1/README.md#backend-only-commands) | ✅ | ✅¹ | [界面](domains/ui.md) | | `buildSystems` `0` | 不带 `provider` 的 [`buildSystems[]`](../contract/v1/README.md#build-systems):检测、选项、项目模型、任务、运行入口、测试、诊断、依赖、同步和[声明式项目准备](../contract/v1/README.md#declarative-project-preparation) | ✅ | ✅¹ | [声明式构建系统](domains/build-systems.md) | | `buildProviders` `0` | `buildSystems[].provider`:[构建提供者](../contract/v1/README.md#build-providers),可以是自有进程或共享语言服务器;说 `litheBuild`,包含任务执行、测试执行与发现、运行准备、原生调试准备、原生配置、内联测试报告、语义测试选择器、类型化运行选项和注册表连接调试 | ✅ | ✅¹ | [构建提供者](domains/build-providers.md) | @@ -151,6 +152,7 @@ Each row is one capability. `requires` lists **exactly** the capabilities a mani | `executionProviders` `0` | `executionProviders[]`: run and discover tests through the declared commands | ✅ | Not declared | [Languages](domains/languages.md), [Execution providers](../contract/v1/README.md#execution-providers) | | `settings` `0` | `settings[]` and `settingActions[]`, with [placement, scope, effect, and page buttons](../contract/v1/README.md#placement-scope-effect-and-page-buttons) | ✅ | ✅ | [Plugin settings](domains/settings.md), [Plugin settings](../contract/v1/README.md#plugin-settings) | | `sourceSettings` `0` | Native source forms, compiler pages, private staging and explicit Save | ✅ | 待宿主接入 / Pending host integration | [Source-backed settings editors](../contract/v1/README.md#source-backed-settings-editors) | +| `sourceSettings` `1` | Adds to `0`: the `sidebar` module-list layout with sources nested by `parent`, field `section`s shown as tabs or subheadings, and ordered typed `entryList`s with an add menu, file and folder pickers, offered choices and per-entry attribute columns | ✅ | 待宿主接入 / Pending host integration | [Entry lists](../contract/v1/README.md#source-backed-settings-editors) | | `ui` `0` | [`ui`](../contract/v1/README.md#host-owned-workbench-ui): text, [web](../contract/v1/README.md#web-content), and [native](../contract/v1/README.md#host-rendered-native-content) tool windows, commands, and [backend-only commands](../contract/v1/README.md#backend-only-commands) without a tool window | ✅ | ✅¹ | [UI](domains/ui.md) | | `buildSystems` `0` | [`buildSystems[]`](../contract/v1/README.md#build-systems) without `provider`: detection, options, project model, tasks, run entries, tests, diagnostics, dependencies, sync, and [declarative preparation](../contract/v1/README.md#declarative-project-preparation) | ✅ | ✅¹ | [Declarative build systems](domains/build-systems.md) | | `buildProviders` `0` | `buildSystems[].provider`: [build providers](../contract/v1/README.md#build-providers), in their own process or a shared language server; they speak `litheBuild`, which covers task execution, test execution and discovery, run preparation, native debug preparation, native configuration, inline test reports, semantic test selectors, typed run options, and registry connection debugging | ✅ | ✅¹ | [Build providers](domains/build-providers.md) | diff --git a/shared/plugins/reference/domains/settings.md b/shared/plugins/reference/domains/settings.md index 949576bc..12e8dd4d 100644 --- a/shared/plugins/reference/domains/settings.md +++ b/shared/plugins/reference/domains/settings.md @@ -277,3 +277,32 @@ staging and conflict handling. The plugin must translate its labels itself. Read actions explain that they may execute the project tool or wrapper; opening a page does not authorize that execution. Only explicit Save stages changes, and the host publishes them conditionally before refreshing upstream facts. + +### Module structure pages (`sourceSettings: 1`) + +Version 1 lets a source editor look like an IDE's project structure dialog: +a list of modules on the left and, for the selected module, tabs such as +Sources, Paths and Dependencies. Put the modules in a group with +`layout: "sidebar"`, nest submodules with `parent`, and give each field a +`section` to choose its tab. A dependency list is an `entryList`: + +- Declare one `entryKinds` item per add-menu entry. Use `file` (optionally with + `extensions`) for archives, `directory` for class or source folders, and + `choice` for things the plugin knows, such as libraries or other modules. + List only the choices that can be added now; the host refuses any other new + value of that kind. +- Declare per-entry columns such as an "Export" checkbox or a scope menu in + `attributes`; leave a key out of an entry to keep your default. +- Give entries a `title` and `detail` for display. They are ignored when the + host compares values and are not sent back on Save. +- Pickers return absolute native paths. Store them the way your tool expects, + for example relative to the module, and show the stored spelling on the next + read. +- A module whose dependencies belong to a build file (Maven, Gradle, a lock + file) can still appear: make the source read-only and project the resolved + dependencies as its `effectiveValue`, with `effectiveSource` naming the file + to edit. + +Require `sourceSettings: 1` when any snapshot uses these members; hosts that +only support version 0 then do not install the plugin. The example is +[`settings-sources-modules.json`](../../../../rust/fixtures/plugins/settings-sources-modules.json). From f88dc699dcab4547b782e81c85e9d0a45e960836 Mon Sep 17 00:00:00 2001 From: lick <2188718831@qq.com> Date: Mon, 16 Nov 2026 22:12:46 -0800 Subject: [PATCH 2/2] =?UTF-8?q?docs(plugins):=20=E5=8D=8F=E8=AE=AE?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=AE=B0=E5=BD=95=E7=99=BB=E8=AE=B0=20source?= =?UTF-8?q?Settings=201=20(#79)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- shared/plugins/reference/protocol-changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shared/plugins/reference/protocol-changelog.md b/shared/plugins/reference/protocol-changelog.md index 98b9fc10..a2bc3c6d 100644 --- a/shared/plugins/reference/protocol-changelog.md +++ b/shared/plugins/reference/protocol-changelog.md @@ -51,6 +51,7 @@ | `pluginFunctions` | 0 | 2026-11-11 | [#17](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/17) | | `projectGenerators` | 0 | 2026-11-11 | [#17](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/17) | | `sourceSettings` | 0 | 2026-11-15 | [#57](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/57) | +| `sourceSettings` | 1 | 2026-11-17 | [#79](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/79) | | `settings` | 0 | 2026-11-11 | [#17](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/17) | | `toolDefinitions` | 0 | 2026-11-11 | [#17](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/17) | | `toolchainProviders` | 0 | 2026-11-11 | [#17](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/17) | @@ -137,6 +138,7 @@ | PR | 修改人 | API 编号 | 协议 / 能力 | 改了什么 | | --- | --- | --- | --- | --- | +| [#79](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/79) | [@1lck](https://github.com/1lck) | API-19 | **`sourceSettings` 1** | 原生来源设置可以做成“项目结构”页([1lck/Lithe-IDEA#2086](https://github.com/1lck/Lithe-IDEA/issues/2086)):分组布局 `sidebar` 把来源列成左侧模块列表,来源用 `parent` 嵌套(同组、在前、最多 8 层);字段 `section` 在 `sidebar` 中是标签页、在 `form` 中是小标题;新字段类型 `entryList` 是有序的类型化条目列表,`entryKinds` 声明添加菜单(`file` 可带扩展名、`directory`、`choice` 带可选项),`attributes` 声明至多 4 个布尔或枚举列。条目的 `title`、`detail` 只用于显示,比较和写回时忽略;新增的 `choice` 条目必须来自当前可选项或原值。`SourceInput` 新增 `entries`,`effectiveDisplays` 对条目列表给出 `count`。快照 `version` 仍为 0;用到这些成员的插件声明 `sourceSettings: 1`,只支持 0 的宿主不会安装。新增 fixture `settings-sources-modules.json`。没有新增宿主方法或通知。 | | [#77](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/77) | [@xiaoyumuxi](https://github.com/xiaoyumuxi) | API-29 | `buildSystems` 0 内的说明修正 | Core 不再内置运行发现探测器([1lck/Lithe-IDEA#1856](https://github.com/1lck/Lithe-IDEA/issues/1856) 第 4 项):原来按 `Cargo.toml`、`go.mod`、`package.json`、`pyproject.toml`、`Makefile`、`justfile`、`Procfile`、`compose.yaml` 自己生成的 Run 配置、指纹输入和工具链要求全部删除。Run 列表里自动生成的条目只来自已启用构建插件声明的 `buildSystems[].run`,模型何时过期只由插件的 `sync.watch` 决定。插件想让项目出现在 Run 列表里,就要声明 `run`。契约 README 只改了一句措辞(不再提“探测器生成的 Run 配置”);清单字段、校验、fixture 和能力版本都没有变,没有新增宿主方法或通知。 | ### 2026-11-16