Skip to content

Commit 788e61e

Browse files
1lckclaude
andauthored
feat(plugin-model): sourceSettings 1 支持模块列表、标签页和类型化条目列表 (#79)
* feat(plugin-model): sourceSettings 1 支持模块列表、标签页和类型化条目列表 - 分组布局 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 <noreply@anthropic.com> * docs(plugins): 协议更新记录登记 sourceSettings 1 (#79) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent a4d71da commit 788e61e

11 files changed

Lines changed: 870 additions & 32 deletions

File tree

‎rust/contracts/application-boundary.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ verification scripts are the executable source of boundary checks.
2020

2121
## Source-backed plugin settings
2222

23-
Source-backed plugin settings use `sourceSettings: 0` and the three
23+
Source-backed plugin settings use `sourceSettings: 0` (version 1 adds module
24+
sidebars, field sections and typed entry lists) and the three
2425
`plugins.settings.source*` commands. Plugins supply only allowlisted non-sensitive
2526
fields from their upstream configuration; Core validates and projects the form,
2627
inheritance and confirmed edits. Native adapters capture workspace identity,

‎rust/crates/core/src/tests/plugin_source_settings.rs‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,49 @@ fn source_editor_actions_require_explicit_host_capability_and_keep_their_binding
5555
assert_eq!(plan["data"]["plan"]["function"], "compiler.settings");
5656
assert_eq!(plan["data"]["plan"]["params"], json!({}));
5757
}
58+
59+
#[test]
60+
fn module_structure_editors_need_source_settings_version_one() {
61+
let fixture: Value = serde_json::from_str(include_str!(concat!(
62+
env!("CARGO_MANIFEST_DIR"),
63+
"/../../fixtures/plugins/settings-sources-modules.json"
64+
)))
65+
.unwrap();
66+
let run = |command: &str, payload: Value| -> Value {
67+
serde_json::from_str(&crate::execute_json(
68+
&json!({"command":command,"payload":payload}).to_string(),
69+
))
70+
.unwrap()
71+
};
72+
let state = run(
73+
"plugins.settings.sourceState",
74+
json!({"result":fixture["snapshot"]}),
75+
);
76+
assert_eq!(state["data"]["status"], "ok", "{state}");
77+
assert_eq!(
78+
state["data"]["state"]["inputs"]["app"]["roots"]["entries"][1]["attributes"]["test"],
79+
true
80+
);
81+
// A plugin that projects sidebars, sections or entry lists requires
82+
// version 1; a host that only offers version 0 refuses to install it.
83+
let mut manifest: Value = serde_json::from_str(include_str!(concat!(
84+
env!("CARGO_MANIFEST_DIR"),
85+
"/../../../shared/plugins/contract/v1/fixtures/settings/source-editor.plugin.json"
86+
)))
87+
.unwrap();
88+
manifest["requires"]["sourceSettings"] = json!(1);
89+
let host = |versions: Value| json!({"backend":[0],"languages":[0],"settings":[0],"sourceSettings":versions});
90+
let refused = run(
91+
"plugins.declarative.validate",
92+
json!({"manifest":manifest,"hostCapabilities":host(json!([0]))}),
93+
);
94+
assert_eq!(
95+
refused["data"]["error"]["code"], "plugin.api.unsupported",
96+
"{refused}"
97+
);
98+
let accepted = run(
99+
"plugins.declarative.validate",
100+
json!({"manifest":manifest,"hostCapabilities":host(json!([0, 1]))}),
101+
);
102+
assert_eq!(accepted["data"]["status"], "ok", "{accepted}");
103+
}

‎rust/crates/plugin-model/src/capabilities.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ pub const SUPPORTED_CAPABILITIES: &[(&str, &[u32])] = &[
124124
(PLUGIN_FUNCTIONS, &[0]),
125125
(PROJECT_GENERATORS, &[0]),
126126
(SETTINGS, &[0]),
127-
(SOURCE_SETTINGS, &[0]),
127+
(SOURCE_SETTINGS, &[0, 1]),
128128
(TOOL_DEFINITIONS, &[0]),
129129
(TOOLCHAIN_PROVIDERS, &[0]),
130130
(UI, &[0]),

0 commit comments

Comments
 (0)