From fda8ee63d3c03fd9b25814235dcc51c177ba8cc2 Mon Sep 17 00:00:00 2001 From: lick <2188718831@qq.com> Date: Fri, 20 Nov 2026 10:45:44 -0800 Subject: [PATCH 1/3] fix(build): allow registry debug for provider applications --- rust/crates/build/src/manifest.rs | 12 +++++ rust/crates/build/src/manifest/provider.rs | 4 +- rust/crates/build/src/manifest/run.rs | 7 ++- rust/crates/build/src/run_preparation.rs | 2 +- rust/crates/core/src/tests/build_systems.rs | 48 +++++++++++++++++++ rust/crates/plugin-manifest/src/validation.rs | 14 ++++++ rust/crates/plugin-model/src/capabilities.rs | 5 +- shared/plugins/contract/v1/README.md | 17 ++++--- .../contract/v1/plugin-manifest.schema.json | 6 +-- .../reference/capabilities-and-versions.md | 2 + 10 files changed, 101 insertions(+), 16 deletions(-) diff --git a/rust/crates/build/src/manifest.rs b/rust/crates/build/src/manifest.rs index e1b8d888..617616fe 100644 --- a/rust/crates/build/src/manifest.rs +++ b/rust/crates/build/src/manifest.rs @@ -195,6 +195,18 @@ impl BuildSystemDeclaration { self.run.iter().any(|run| run.entrypoints) } + /// Whether any provider application needs the registry attach feature in + /// `buildSystems` 2. Existing service declarations work in earlier versions. + pub fn has_application_connection_debug(&self) -> bool { + self.run.iter().any(|run| { + run.execution.unwrap_or(BuildExecution::Application) == BuildExecution::Application + && run + .debug + .as_ref() + .is_some_and(|debug| debug.configuration_type.is_some()) + }) + } + /// Folder names every workspace hides at any depth while the plugin is /// enabled (`layout.hiddenDirectoryNames`), sorted and unique once validated. pub fn hidden_directory_names(&self) -> &[String] { diff --git a/rust/crates/build/src/manifest/provider.rs b/rust/crates/build/src/manifest/provider.rs index 4b9e877e..b93f9478 100644 --- a/rust/crates/build/src/manifest/provider.rs +++ b/rust/crates/build/src/manifest/provider.rs @@ -156,9 +156,9 @@ impl BuildSystemDeclaration { } (None, Some(kind)) if crate::run_preparation::valid_configuration_type(kind) - && run.execution == Some(BuildExecution::Service) => {} + && run.execution != Some(BuildExecution::Task) => {} _ => return Err(invalid(&field, - "Debug requires a same-package native adapter, or one registry configurationType for a service.")), + "Debug requires a same-package native adapter, or one registry configurationType for an application or service.")), } } } diff --git a/rust/crates/build/src/manifest/run.rs b/rust/crates/build/src/manifest/run.rs index d1963499..6c6e1032 100644 --- a/rust/crates/build/src/manifest/run.rs +++ b/rust/crates/build/src/manifest/run.rs @@ -121,14 +121,17 @@ impl BuildSystemDeclaration { || !run.extension.is_empty() || run.execution.unwrap_or(BuildExecution::Application) != BuildExecution::Application - || run.debug.is_some() + || run + .debug + .as_ref() + .is_some_and(|debug| debug.adapter.is_some()) || run.name.as_ref().is_some_and(|name| { name.trim().is_empty() || name.len() > MAX_TEXT || name.contains("${") }) { return Err(invalid( &field, - "Entrypoint runs are provider applications without targets, templates or debug.", + "Entrypoint runs are provider applications without targets, templates or native debug preparation.", )); } continue; diff --git a/rust/crates/build/src/run_preparation.rs b/rust/crates/build/src/run_preparation.rs index 054e8fd7..8e62eafd 100644 --- a/rust/crates/build/src/run_preparation.rs +++ b/rust/crates/build/src/run_preparation.rs @@ -91,7 +91,7 @@ impl LaunchOptions { debug.target.kind != "connection" || debug.target.host != "127.0.0.1" || debug.target.port == 0 - || self.execution != BuildExecution::Service + || self.execution == BuildExecution::Task || !valid_configuration_type(&debug.configuration_type) || !debug .adapter_id diff --git a/rust/crates/core/src/tests/build_systems.rs b/rust/crates/core/src/tests/build_systems.rs index d8210850..bdfdeeed 100644 --- a/rust/crates/core/src/tests/build_systems.rs +++ b/rust/crates/core/src/tests/build_systems.rs @@ -3330,6 +3330,54 @@ fn provider_run_options_refuse_explicit_cwd_symlinks_outside_workspace() { assert_eq!(result["error"]["code"], "plugin.build.invalidOutput"); } +/// Source entrypoints support registry attach without rewriting existing +/// application configurations or giving the provider a remote endpoint. +#[test] +fn provider_application_entrypoints_support_connection_debug_with_build_systems_v2() { + let mut manifest: Value = serde_json::from_str(contract_file!( + "fixtures/build-providers/build-provider-run-entrypoints.plugin.json" + )) + .unwrap(); + let mut request = serde_json::from_str::(contract_file!( + "fixtures/build-providers/build-run-entrypoints.json" + )) + .unwrap()["prepareRun"] + .clone(); + let debug = serde_json::from_str::(contract_file!( + "fixtures/build-providers/build-connection-debug-options.json" + )) + .unwrap()["launchOptions"]["debug"] + .clone(); + let workspace = TemporaryWorkspace::new("entrypoint-attach"); + workspace.write("app/src/main/java/example/Tool.java", "class Tool {}"); + request["workspaceRoot"] = json!(workspace.root()); + let plan = |request: &Value, manifest: &Value| { + build_prepare_run_plan_command::(super::support::trusted_payload( + json!({"manifest":manifest,"buildSystemID":"gradle","request":request}), + )) + .unwrap() + }; + assert_eq!(plan(&request, &manifest)["status"], "ok"); + request["launchOptions"]["debug"] = debug; + assert_eq!(plan(&request, &manifest)["status"], "rejected"); + + manifest["buildSystems"][0]["run"][1]["debug"] = json!({"configurationType":"java"}); + assert_eq!( + validate(manifest.clone())["error"]["field"], + "requires.buildSystems" + ); + manifest["requires"]["buildSystems"] = json!(2); + assert_eq!(validate(manifest.clone())["status"], "ok"); + let planned = plan(&request, &manifest); + assert_eq!(planned["status"], "ok", "{planned}"); + let params = &planned["plan"]["provider"]["params"]; + assert!(params.get("target").is_none()); + assert_eq!(params["launchOptions"], request["launchOptions"]); + + request["launchOptions"]["debug"]["target"]["host"] = json!("remote.example"); + assert_eq!(plan(&request, &manifest)["status"], "rejected"); +} + /// Model-supplied default choices and exclusion prefixes let a build tool's /// profiles or features show default-active entries, deactivate them on CLI /// even before the model reloads, and clear the local override once the user diff --git a/rust/crates/plugin-manifest/src/validation.rs b/rust/crates/plugin-manifest/src/validation.rs index 097043ba..28914d44 100644 --- a/rust/crates/plugin-manifest/src/validation.rs +++ b/rust/crates/plugin-manifest/src/validation.rs @@ -127,6 +127,20 @@ impl DeclarativePluginManifest { "Entrypoint runs need buildProviders 1.", )); } + if self + .build_systems + .iter() + .any(|system| system.has_application_connection_debug()) + && self + .requires + .get(capabilities::BUILD_SYSTEMS) + .is_none_or(|version| *version < 2) + { + return Err(invalid( + "requires.buildSystems", + "Registry connection debugging for applications needs buildSystems 2.", + )); + } if self .build_systems .iter() diff --git a/rust/crates/plugin-model/src/capabilities.rs b/rust/crates/plugin-model/src/capabilities.rs index 87cc2a77..6b7ebb7d 100644 --- a/rust/crates/plugin-model/src/capabilities.rs +++ b/rust/crates/plugin-model/src/capabilities.rs @@ -64,7 +64,8 @@ pub const SOURCE_SETTINGS: &str = "sourceSettings"; /// settings regions, and commands. pub const UI: &str = "ui"; /// Declarative build detection, models, and command plans. -/// Version 1 adds command-based test discovery. +/// Version 1 adds command-based test discovery. Version 2 adds registry +/// connection debugging for provider applications. pub const BUILD_SYSTEMS: &str = "buildSystems"; /// `buildSystems[].provider`, whether it owns or shares a language server process. /// Version 1 adds runs with `entrypoints: true`, which start an entrypoint the @@ -131,7 +132,7 @@ pub const SUPPORTED_CAPABILITIES: &[(&str, &[u32])] = &[ (BEFORE_LAUNCH_TASKS, &[0]), (BUILD_MODEL_INPUTS, &[0]), (BUILD_PROVIDERS, &[0, 1]), - (BUILD_SYSTEMS, &[0, 1]), + (BUILD_SYSTEMS, &[0, 1, 2]), (COMMAND_INSTALLERS, &[0, 1]), (DEBUG_ADAPTERS, &[0]), (EXECUTION_PROVIDERS, &[0]), diff --git a/shared/plugins/contract/v1/README.md b/shared/plugins/contract/v1/README.md index 0a7f2cc2..a7aacd8c 100644 --- a/shared/plugins/contract/v1/README.md +++ b/shared/plugins/contract/v1/README.md @@ -2529,8 +2529,9 @@ A provider run may declare `entrypoints: true` instead of `fromTargets`. It is an application that starts an entrypoint the provider names, such as a class with a `main` method, in one of its projects. It requires `source: "provider"` and `buildProviders` 1 in `requires`; `fromTargets`, `fromTasks`, `arguments`, -`extension`, `debug`, and a `service` or `task` execution are refused. It -applies to no target, so the host never lists it per target: the user starts +`extension`, a native `debug.adapter`, and a `service` or `task` execution +are refused. A registry `debug.configurationType` requires `buildSystems` 2. +It applies to no target, so the host never lists it per target: the user starts it from a source file. `build.runEntrypointsPlan` takes the common plan fields, optional `refresh` @@ -2567,8 +2568,12 @@ and `fixtures/build-providers/build-run-entrypoints.json`. #### Registry connection debugging -A provider service run may declare -`debug: {"configurationType":"example"}`. This is a public DebugAdapter Registry +A provider service run may declare `debug: {"configurationType":"example"}`. +With `buildSystems` 2, a provider application (including an entrypoint run) +may make the same declaration. Saved application configurations keep +`execution: "application"` for Run and Debug. Debug sends the existing +connection fields in `launchOptions.debug`, with no change to the +negotiated `litheBuild` version. The declaration names a public DebugAdapter Registry alias, not another plugin's private language server or a local adapter ID. The host selects one currently enabled adapter advertising the type and `attach`, respecting an explicit qualified adapter selection. Missing or ambiguous entries @@ -2581,9 +2586,9 @@ fail before starting the provider process. It sends: These are the exact three debug fields and three target fields. The host owns the port (integer 1–65535), process, readiness and cleanup. Explicit null, unknown -fields, remote hosts and application/task execution are rejected. The type must +fields, remote hosts and task execution are rejected. The type must match the selected run declaration. The provider uses its -upstream engine to suspend the service until attachment; it owns runtime-specific +upstream engine to suspend the debuggee until attachment; it owns runtime-specific flags and fails if it cannot honor the request. It returns the ordinary portable Run process plan, without selecting an endpoint or returning DAP arguments. diff --git a/shared/plugins/contract/v1/plugin-manifest.schema.json b/shared/plugins/contract/v1/plugin-manifest.schema.json index 785e958f..a6cff7a2 100644 --- a/shared/plugins/contract/v1/plugin-manifest.schema.json +++ b/shared/plugins/contract/v1/plugin-manifest.schema.json @@ -37,7 +37,7 @@ "beforeLaunchTasks": { "description": "Required exactly when any buildSystems[].beforeLaunchTasks is non-empty: kinds of step a run configuration's Before Launch list runs first, offered in its Add New Task menu, drawn from declared fields and run through a declared command line. Needs buildSystems.", "enum": [0] }, "buildModelInputs": {"description": "Optional public model sharing between already enabled workspace plugins; no installation, private function, or process authority. Required exactly when modelSharing or modelInputs is used. Consumers require buildProviders. A producer cannot also consume inputs.", "enum": [0]}, "buildProviders": { "description": "Required exactly when any buildSystems[].provider is present, including own-process and shared language-server providers. Declares host support for Provider orchestration (task execution, test execution and discovery, run preparation, native debug preparation, optional read-only model inputs, non-sensitive native configuration sources, inline test reports, opaque semantic test selectors, typed run options and service/task preparation, registry-selected adapters and host-owned connection targets for service debugging), independent of declarative buildSystems. Version 1 adds entrypoint runs (lithe/build/runEntrypoints).", "enum": [0, 1] }, - "buildSystems": { "description": "Declarative build detection, models, and command plans. Version 1 adds command-based test discovery. Neither version implies buildProviders support.", "enum": [0, 1] }, + "buildSystems": { "description": "Declarative build detection, models, and command plans. Version 1 adds command-based test discovery. Version 2 adds registry connection debugging for provider applications. These versions do not imply buildProviders support.", "enum": [0, 1, 2] }, "commandInstallers": { "description": "Required exactly when commandInstallers is non-empty: installations of bare commands that systemCommand launches name, run by the host only after the user confirms them. Version 1 adds download installers: pinned per-platform archives the host downloads, checks and extracts into the plugin's managed directory.", "enum": [0, 1] }, "debugAdapters": { "description": "Required exactly when debugAdapters is non-empty. Covers bounded target argument and environment bindings and debugAdapters[].features and defaults. The DAP session itself is negotiated by the adapter in initialize.", "enum": [0] }, "executionProviders": { "enum": [0] }, @@ -3413,7 +3413,7 @@ ], "properties": { "debug": { - "description": "Same-package native launch adapter, or a public registry configurationType for connection attach (service runs).", + "description": "Same-package native launch adapter, or a public registry configurationType for connection attach (services and, with buildSystems 2, applications).", "type": "object", "additionalProperties": false, "oneOf": [{"required": ["adapter"]}, {"required": ["configurationType"]}], "properties": { @@ -3491,7 +3491,7 @@ } }, "entrypoints": { - "description": "buildProviders 1: a provider application that starts an entrypoint lithe/build/runEntrypoints names in a source file, in its project and without a target. Requires source provider; refuses fromTargets, fromTasks, arguments, extension, debug and a service or task execution.", + "description": "buildProviders 1: a provider application that starts an entrypoint lithe/build/runEntrypoints names in a source file, in its project and without a target. Requires source provider; refuses fromTargets, fromTasks, arguments, extension, native debug and a service or task execution. Registry connection debugging requires buildSystems 2.", "type": "boolean" } }, diff --git a/shared/plugins/reference/capabilities-and-versions.md b/shared/plugins/reference/capabilities-and-versions.md index fb5c2ae8..9cd0791c 100644 --- a/shared/plugins/reference/capabilities-and-versions.md +++ b/shared/plugins/reference/capabilities-and-versions.md @@ -50,6 +50,7 @@ Core 列以本仓库 `main` 上的 Core 源码为准([`capabilities.rs`](https | `ui` `0` | [`ui`](../contract/v1/README.md#host-owned-workbench-ui):文本、[包内网页](../contract/v1/README.md#web-content)和[插件视图](../contract/v1/README.md#plugin-views)的工具窗口、设置区域里的插件视图、命令,以及[不打开工具窗口的后端命令](../contract/v1/README.md#backend-only-commands);视图函数的结果由 Core 命令 `plugins.ui.applyResult` 校验,形状见 [`plugin-ui.schema.json`](../contract/v1/plugin-ui.schema.json) | ✅ | ✅¹ | [界面](domains/ui.md) | | `buildSystems` `0` | 不带 `provider` 的 [`buildSystems[]`](../contract/v1/README.md#build-systems):检测、选项、项目模型、任务、运行入口、测试、诊断、依赖、同步和[声明式项目准备](../contract/v1/README.md#declarative-project-preparation) | ✅ | ✅¹ | [声明式构建系统](domains/build-systems.md) | | `buildSystems` `1` | 新增 [命令式测试发现](../contract/v1/README.md#test-discovery),复用声明的构建工具和测试选择器 | ✅ | 待宿主声明 | [声明式构建系统](domains/build-systems.md) | +| `buildSystems` `2` | 构建提供者的应用运行声明可使用 `debug.configurationType`,包括按源文件发现的入口 | ✅ | 待宿主接入 | [构建提供者](domains/build-providers.md) | | `buildProviders` `0` | `buildSystems[].provider`:[构建提供者](../contract/v1/README.md#build-providers),可以是自有进程或共享语言服务器;说 `litheBuild`,包含任务执行、测试执行与发现、运行准备、原生调试准备、原生配置、内联测试报告、语义测试选择器、类型化运行选项和注册表连接调试 | ✅ | ✅¹ | [构建提供者](domains/build-providers.md) | | `buildProviders` `1` | 在 `0` 之上加:运行声明 `entrypoints: true`(入口运行,不需要目标),提供者用 `lithe/build/runEntrypoints` 回答一个源文件里可运行的入口,宿主把它保存为运行配置并按入口启动 | ✅ | ✅ | [Run entrypoints](../contract/v1/README.md#run-entrypoints-buildproviders-1) | | `buildModelInputs` `0` | `buildSystems[].modelSharing` 与 `modelInputs`:[已启用工作区插件之间共享的只读模型输入](../contract/v1/README.md#optional-read-only-model-inputs)(可选) | ✅ | 未声明 | [构建提供者](domains/build-providers.md) | @@ -166,6 +167,7 @@ Each row is one capability. `requires` lists **exactly** the capabilities a mani | `ui` `0` | [`ui`](../contract/v1/README.md#host-owned-workbench-ui): text, [web](../contract/v1/README.md#web-content), and [plugin view](../contract/v1/README.md#plugin-views) tool windows, plugin views in settings regions, commands, and [backend-only commands](../contract/v1/README.md#backend-only-commands) without a tool window; the Core command `plugins.ui.applyResult` checks view function results, shaped as in [`plugin-ui.schema.json`](../contract/v1/plugin-ui.schema.json) | ✅ | ✅¹ | [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) | | `buildSystems` `1` | Adds [command test discovery](../contract/v1/README.md#test-discovery) using the declared build tool and the existing test selectors | ✅ | Pending host declaration | [Declarative build systems](domains/build-systems.md) | +| `buildSystems` `2` | Allows build provider application runs to declare `debug.configurationType`, including source entrypoints | ✅ | Pending host integration | [Build providers](domains/build-providers.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) | | `buildProviders` `1` | Adds to `0`: run declarations with `entrypoints: true` (entrypoint runs, without a target); the provider answers `lithe/build/runEntrypoints` with the runnable entrypoints of one source file, which the host saves as run configurations and starts | ✅ | ✅ | [Run entrypoints](../contract/v1/README.md#run-entrypoints-buildproviders-1) | | `buildModelInputs` `0` | `buildSystems[].modelSharing` and `modelInputs`: [optional read-only model inputs](../contract/v1/README.md#optional-read-only-model-inputs) shared between enabled workspace plugins | ✅ | Not declared | [Build providers](domains/build-providers.md) | From 7935a7311fb1b108ab39c29cc9f5539fbb6685f2 Mon Sep 17 00:00:00 2001 From: lick <2188718831@qq.com> Date: Fri, 20 Nov 2026 10:46:44 -0800 Subject: [PATCH 2/3] docs(plugins): index buildSystems capability 2 --- 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 548fe34c..324908f0 100644 --- a/shared/plugins/reference/protocol-changelog.md +++ b/shared/plugins/reference/protocol-changelog.md @@ -14,6 +14,7 @@ ## 待合入 +- [#139](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/139),[@1lck](https://github.com/1lck),**`buildSystems` 2**(API-29):构建提供者的 `application` 运行声明(含 `entrypoints: true`)可以通过 `debug.configurationType` 复用已注册的连接调试器。`lithe/build/prepareRun` 复用原有 `launchOptions.debug`,入口运行仍不带 `target`。已有服务运行声明继续适用旧版本。没有新增 RPC 方法、通知或 SDK 版本。 - [#135](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/135),[@xiaoyumuxi](https://github.com/xiaoyumuxi),`toolDefinitions` 0 内的行为修正(API-23):外部安装的 `executableLayouts` 文件链接到另一个文件名时,`toolchains.candidates` 的待探针路径和 `toolchains.resolve` 的 `executable` 改为规范主目录下的布局路径,不再是链接目标。rustup 把 `cargo`、`rust-analyzer` 链接到自身、按启动时的名字决定运行哪个工具,以前 Core 返回 `rustup`,版本探针失败。链接目标的类型、可执行位和越界检查不变;同名链接仍返回规范路径。没有新增字段、版本号、宿主方法、通知或 SDK 版本。 ## 按协议查首次出现 @@ -47,6 +48,7 @@ | `buildProviders` | 1 | 2026-11-18 | [#89](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/89) | | `buildSystems` | 0 | 2026-11-11 | [#17](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/17) | | `buildSystems` | 1 | 2026-11-19 | [#112](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/112) | +| `buildSystems` | 2 | 待合入 | [#139](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/139) | | `commandInstallers` | 0 | 2026-11-15 | [#53](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/53) | | `commandInstallers` | 1 | 2026-11-20 | [#133](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/133) | | `debugAdapters` | 0 | 2026-11-11 | [#17](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/17) | From bb413fe49092ad2e5c19ba79449640a95350f73e Mon Sep 17 00:00:00 2001 From: lick <2188718831@qq.com> Date: Fri, 20 Nov 2026 10:54:20 -0800 Subject: [PATCH 3/3] test(plugins): reject the next undefined build capability version --- .../contract/v1/fixtures/manifest/invalid-manifests.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/plugins/contract/v1/fixtures/manifest/invalid-manifests.json b/shared/plugins/contract/v1/fixtures/manifest/invalid-manifests.json index b0e682e3..66b0f08b 100644 --- a/shared/plugins/contract/v1/fixtures/manifest/invalid-manifests.json +++ b/shared/plugins/contract/v1/fixtures/manifest/invalid-manifests.json @@ -698,7 +698,7 @@ "edits": [{ "op": "set", "path": "/requires/buildSystems", "value": 5 }], "expectedCode": "plugin.api.unsupported" }, - {"name": "capability version 2 is not defined", "base": "build-static-file.plugin.json", "edits": [{"op": "set", "path": "/requires/buildSystems", "value": 2}], "expectedCode": "plugin.api.unsupported", "expectedField": "requires.buildSystems"}, + {"name": "capability version 3 is not defined", "base": "build-static-file.plugin.json", "edits": [{"op": "set", "path": "/requires/buildSystems", "value": 3}], "expectedCode": "plugin.api.unsupported", "expectedField": "requires.buildSystems"}, { "name": "used capability missing from requires", "base": "build-provider-language-server.plugin.json",