Skip to content

feat(run-config): 插件声明运行配置类型(runConfigurationTypes 0),所有运行配置加“允许多个实例” - #94

Merged
xiaoyumuxi merged 2 commits into
mainfrom
feat/2100-plugin-run-types
Nov 18, 2026
Merged

xiaoyumuxi merged 2 commits into
mainfrom
feat/2100-plugin-run-types

Conversation

@xiaoyumuxi

@xiaoyumuxi xiaoyumuxi commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

关联 Issue

类型

feat:新能力 runConfigurationTypes 0——构建插件声明自己的运行配置类型,宿主按声明画编辑器,Core 校验并展开命令行;所有运行配置(含 Core 自带的 Shell / PowerShell / 批处理 / 程序)加通用开关 allowMultipleInstances。Remote 类配置这次不做。

改动

插件契约(shared/plugins/contract/v1/)

  • 清单 buildSystems[].runConfigurationTypes(1–16 个),需要 requires.runConfigurationTypes: 0:
成员 说明
id、displayName、description? 类型 ID([A-Za-z0-9._-],≤64)、名称(≤120 字节)、说明(≤512)
execution application 或 task;不能是 service
arguments 命令行模板;只能用 ${root}、${userArguments}、${option:*}、${field:<id>},不能带条件
fields[](≤16) text、choice(options + 可选 optionLabels,≤64 项)、checkbox、file、directory、arguments;可带 default、required、placeholder、description、visibleWhen,以及字段自己的 arguments(≤8,值用 ${value})
  • 每个字段必须在类型参数或字段参数里恰好引用一次;只控制其他字段显示、自己不带参数的字段除外。${userArguments} 恰好出现一次时编辑器才显示“程序参数”。
  • 语言文件 runConfigurationTypes.<构建系统 ID>.<类型 ID>:displayName、description、fields.<id>.{title, description, placeholder, options};不合法时是 plugin.build.invalidLocalization。
  • 新 fixture fixtures/run-configuration-types/(清单 + l10n/zh-Hans.json)。
  • README 新增 “Run configuration types” 一节;构建系统字段表、模板变量表、能力表、fixture 表、错误码表、语言文件成员表各加一行。

Core

  • lithe-build:manifest/run_types.rs 校验声明,run_types.rs 校验字段值并展开 argv;template.rs 加 ${field:<id>}。
  • lithe-execution:新配置类型 build.run-type,extensions.build = {pluginID, buildSystemID, type, values},仍存 .lithe/run/plugin/<插件 ID>.toml / .local.toml;declared.rs 按声明生成编辑表单(字段 ID 为 field:<id>,visibleWhen 同样带前缀),表单带 runType。
  • 通用表头字段 allowMultipleInstances(每个编辑器都有,含 Core 自带运行),只在开启时保存。关:再次启动先停掉正在运行的进程;开:宿主在旁边再起一个,每个进程有自己的控制台。
  • run-configuration-v2.schema.json:加 allowMultipleInstances、build.run-type 分支(extensions.build 必填,execution 只能 application/task,不带 command、toolchains、debug、members)。
  • lithe-plugin-model:能力 RUN_CONFIGURATION_TYPES = &[0];语言文件解析新增 runConfigurationTypes。

宿主调用 Core 的命令(不是插件宿主方法)

原计划编号 方法 用途
API-29 build.runConfigurationPlan(Core 命令,新) 把保存的 build.run-type 配置展开成任务计划,带回 runType;工作目录落在多个实例里时取最深的那个
API-29 runConfig.configurationTypes / runConfig.editorForm / runConfig.saveConfiguration:新请求字段 runTypePlugins 宿主把已启用插件的清单和语言文件交给 Core,列出插件类型、生成编辑表单、保存;前两个返回 localizations 报告

没有新增或修改 lithe/host/* 宿主方法和通知,所以 API 总表的宿主方法表和更新记录的“宿主方法(按 API 编号)”索引不加行。

文档

  • rust/contracts/rust-core-api.md:命令表加 build.runConfigurationPlan,运行配置部分加 “Plugin-declared types” 小节、runTypePlugins、allowMultipleInstances 和字段属性 label、description、placeholder、optionLabels。
  • reference/protocol-changelog.md:能力表加 runConfigurationTypes 0,2026-11-18 时间线加一行。
  • reference/capabilities-and-versions.md、reference/api-catalog.md(API-29 中英两行)、reference/domains/build-systems.md:加 runConfigurationTypes,桌面端标“未声明”(宿主 PR 接入后再改)。

错误码

码 字段 什么时候
plugin.build.invalidRunConfiguration(新) values.<id> 保存或规划时字段值不合法(类型不对、必填为空、不在可选项里、超长)
plugin.build.invalidLocalization(新) 语言文件路径 语言文件里的 runConfigurationTypes 不合法
plugin.manifest.invalid / plugin.template.invalid 清单路径 声明不合法、字段没被恰好引用一次、模板用了不允许的变量
plugin.build.invalidSelection / plugin.build.unavailable — 配置指向的插件、构建系统或类型不存在或没启用

测试

  • 新 crates/core/src/tests/plugin_run_types.rs(6 个):
    • declared_types_follow_the_built_in_kinds_with_translated_text:插件类型排在内置类型后面,名称和说明用语言文件翻译
    • a_translation_that_does_not_fit_the_declarations_is_rejected_whole:语言文件对不上声明时整份拒绝,报 plugin.build.invalidLocalization
    • the_editor_draws_declared_fields_and_shows_program_arguments_only_when_taken:表单字段、标签、占位符、可选项、显示条件,allowMultipleInstances 是复选框,没装插件时打不开编辑器
    • saved_declared_runs_expand_into_the_types_command_line:保存时按字段报错(notFound、required),隐藏字段不检查也不保存;保存后读回;build.runConfigurationPlan 展开 argv、选最深的实例;别的插件、找不到实例、未知配置、缺 workspaceRoot 时拒绝;手改保存文件里的值后规划,报 plugin.build.invalidRunConfiguration(字段 values.runKind);文件运行传绝对路径
    • a_type_without_program_arguments_stores_none:不带 ${userArguments} 的类型不存程序参数,关掉多实例时不写 allowMultipleInstances
    • run_configuration_type_declarations_are_validated:声明的各种错误(字段没被恰好引用一次、模板变量不允许、超限等)各自的错误码和字段
  • run_configuration.rs:内置程序编辑器的字段列表加 allowMultipleInstances。
  • 声明校验和模板单测在 lithe-build;fixture 用 jsonschema 对清单和语言文件 schema 校验通过。

本机 macOS 上全部通过:

  • cargo fmt --all -- --check
  • cargo clippy -p lithe-build -p lithe-execution -p lithe-core -p lithe-plugin-model -p lithe-plugin-manifest --all-targets -- -D warnings(本机和 --target x86_64-pc-windows-msvc)
  • 上述 5 个 crate 的 cargo test(lithe-core 832 个)
  • scripts/rust-core/verify-rust-core-comments.sh、node scripts/logging/generate-log-events.mjs --check、node scripts/rust-core/verify-platform-tests.mjs、node --test scripts/rust-core/*.test.mjs
  • node shared/plugins/scripts/verify-docs.mjs、node --test shared/plugins/scripts/*.test.mjs

插件后端协议(plugin-rpc、litheBuild)没有改动,没跑 sdk-e2e.mjs。

- 构建系统新增 runConfigurationTypes:类型 id、名称、说明、execution、arguments 模板和最多 16 个字段
  (text、choice、checkbox、file、directory、arguments),字段可带默认值、必填、占位符、显示条件和自己的参数
- 新模板变量 ${field:<id>};每个字段恰好引用一次;${userArguments} 恰好出现一次时编辑器显示程序参数
- 保存的配置类型 build.run-type,extensions.build 记 {pluginID, buildSystemID, type, values},
  仍存 .lithe/run/plugin/<插件 ID>.toml
- 新命令 build.runConfigurationPlan 把保存的配置展开成 argv 计划
- runConfig.configurationTypes / editorForm / saveConfiguration 新增 runTypePlugins(清单和语言文件),
  语言文件新增 runConfigurationTypes 词条
- 所有运行配置的通用开关 allowMultipleInstances,只在开启时保存
- 新增 fixture run-configuration-types/,更新契约 README、schema、Core API 文档、更新记录和能力对照
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant