Skip to content

feat(run-config): 插件声明启动前任务(beforeLaunchTasks 0),启动前可添加插件任务 - #97

Merged
xiaoyumuxi merged 2 commits into
mainfrom
feat/api-29-before-launch-tasks
Nov 18, 2026
Merged

xiaoyumuxi merged 2 commits into
mainfrom
feat/api-29-before-launch-tasks

Conversation

@xiaoyumuxi

@xiaoyumuxi xiaoyumuxi commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

关联 Issue

类型

feat:新能力 beforeLaunchTasks 0。构建插件声明启动前任务的种类,运行配置的“启动前”列表在“运行另一个配置”之外还能加这些任务。宿主按声明画任务表单,Core 负责校验值、保存步骤,并在拥有该列表的配置的工作目录里展开命令行。Core 不含任何插件或语言的特判。

改动

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

  • 清单新增 buildSystems[].beforeLaunchTasks(1–16 个),需要 requires.beforeLaunchTasks: 0(schema 用 allOf 的 if/then 强制)。
成员 说明
id、displayName、description?、icon? 与 runConfigurationTypes 相同的规则;任务 ID 和类型 ID 各自唯一,同一构建系统可以有同名的类型和任务
fields[](≤16) 与运行配置类型的字段完全相同(text、choice、checkbox、file、directory、arguments,visibleWhen 等)
arguments 命令行模板,可用 ${field:<id>};不能用 ${userArguments}(plugin.template.invalid)
execution 不能声明:任务总是运行到结束(plugin.manifest.invalid)
  • 语言文件新增 beforeLaunchTasks.<构建系统 ID>.<任务 ID>,结构同 runConfigurationTypes;不合法时是 plugin.build.invalidLocalization。
  • 新 fixture fixtures/before-launch-tasks/:command(必填 arguments 字段)和 generate 两个任务,带 l10n/zh-Hans.json。
  • README 新增 “Before-launch tasks” 一节;语言文件成员表、能力表、构建系统字段表、错误码表各加一行。

Core

  • lithe-build:
    • manifest/run_types.rs 用同一套声明校验处理类型和任务,RunTypeRole::{Configuration, BeforeLaunchTask} 区分两者的差异(execution、${userArguments});
    • run_types.rs 新增 declared_plan,build.beforeLaunchTaskPlan 和 build.runConfigurationPlan 共用;
    • 语言文件按角色分两节读取。
  • lithe-execution:
    • before_launch.rs 重写。步骤是 {configuration} 或 {task: {pluginID, buildSystemID, type, values}},两种都 deny_unknown_fields。展开时任务步骤用拥有该列表的配置的工作目录。指纹覆盖 {task, workingDirectory}。
    • declared.rs 给任务生成表单(task_kind_item)、字段值项(task_step_item)和一行摘要(summary),declared_task_launch 解析工作目录(项目外的目录会失败)。
    • 修复 runConfigurationTypes 的必填 arguments 字段留空不会被拒绝:store 和 launch_values 现在都执行 required。
  • lithe-plugin-model:能力 BEFORE_LAUNCH_TASKS = &[0]。
  • run-configuration-v2.schema.json:beforeLaunch 的每一项改为 oneOf {configuration} / {task: runTypeReference}。

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

原计划编号 方法 用途
API-29 runConfig.checkBeforeLaunchTask(Core 命令,新) 校验“添加新任务”小表单的值。成功时返回 {status: "ok", step},step 是要放进 beforeLaunch 字段值的步骤;失败时返回 {status: "invalid", errors},错误按 field:<id> 给出。未声明的任务返回 not_supported。不写文件
API-29 runConfig.beforeLaunchField(Core 命令,新) 给不用 runConfig.editorForm 的编辑器(构建运行的编辑器)读取已保存配置的 beforeLaunch 字段:返回 {candidates, tasks, value},和 editorForm 的字段相同,value 是当前生效的列表;编辑后的值交给 runConfig.updateOptions。未知配置返回 invalid_request。宿主不再自己算可选的配置
API-29 build.beforeLaunchTaskPlan(Core 命令,新) 把 runConfig.beforeLaunch 返回的任务步骤展开成 argv 计划,带回 beforeLaunchTask。实例的选择方式同 build.runConfigurationPlan;保存的值不合法时返回 plugin.build.invalidBeforeLaunchTask(字段 values.<id>)
API-29 runConfig.beforeLaunch / runConfig.updateOptions / runConfig.saveEditorChanges:新请求字段 runTypePlugins 宿主交给 Core 已启用插件的清单,用来识别任务步骤。runConfig.beforeLaunch 的任务步骤返回 {task, name, summary, workingDirectory};拒绝码新增 taskNotDeclared、invalidTaskValues,拒绝时带 task
API-29 runConfig.editorForm:beforeLaunch 字段新增 tasks 已安装插件声明的任务种类,每个是 {runType, displayName, description?, icon?, fields, values}。字段值里的任务步骤是 {task, name, summary, values};插件已卸载的步骤是 {task, name, summary, missing: true},编辑器照样显示并保留它

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

文档

  • rust/contracts/rust-core-api.md:
    • 命令表加三条新命令;
    • “Plugin-declared types”补一段讲 beforeLaunchTasks;
    • “Steps before launch”重写:两种步骤、runTypePlugins、新拒绝码、指纹、编辑器 tasks、checkBeforeLaunchTask;
    • build 请求表加 build.beforeLaunchTaskPlan。
  • reference/protocol-changelog.md:能力表加 beforeLaunchTasks 0,2026-11-18 时间线加本 PR。另外,feat(plugins): add managed runtime preparation and isolated resolver sessions #96 已合入,但它的 managedRuntimes 0 还留在“待合入”,这次一并移进时间线和能力首次出现表,“待合入”改为“目前没有”。
  • reference/capabilities-and-versions.md、reference/api-catalog.md(API-29 中英两行)、reference/domains/build-systems.md:加 beforeLaunchTasks,桌面端标“未声明”,等宿主 PR 接入后再改。

错误码

码 字段 什么时候
plugin.build.invalidBeforeLaunchTask(新) values.<id> 规划时,步骤里保存的值已不符合任务声明
plugin.build.invalidLocalization 语言文件路径 现在也覆盖语言文件里的 beforeLaunchTasks 一节
plugin.manifest.invalid / plugin.template.invalid 清单路径 任务写了 execution,或者 arguments 用了 ${userArguments},以及与类型相同的声明错误
拒绝码 taskNotDeclared / invalidTaskValues(新) beforeLaunch 没有已安装插件声明这个任务,或者保存的值不再合法(例如必填项为空);编辑器保存时报 {field: "beforeLaunch", code}

测试

  • 新文件 crates/core/src/tests/before_launch_tasks.rs,4 个测试:
    • task_kinds_are_offered_on_the_step_field_and_not_as_configurations:
      • 任务不出现在 runConfig.configurationTypes 里;
      • beforeLaunch 字段的 tasks 带译文、图标、field:<id> 字段和默认值;
      • 没装插件时只列运行配置。
    • task_steps_are_checked_saved_and_reopened:
      • checkBeforeLaunchTask 按字段报错,成功时返回步骤;未声明的任务返回 not_supported;
      • 保存后重新打开,能拿回表单值;beforeLaunchField 返回同样的值、可选配置和任务种类,未知配置返回 invalid_request;
      • 卸载插件后显示为 missing,保存时报 taskNotDeclared;
      • updateOptions 也会检查任务步骤。
    • task_steps_run_in_the_owning_configuration_directory:
      • 被引用的运行先展开自己的步骤;
      • 每个任务用拥有它的配置的工作目录;
      • 来自项目文件时需要确认,改了任务值后指纹会变;
      • 拒绝码 taskNotDeclared / invalidTaskValues 带 task;
      • build.beforeLaunchTaskPlan 选中包含工作目录的实例,返回 execution: task 和 beforeLaunchTask;
      • 必填值为空时报 values.command;项目外的目录和别的插件的任务都会失败。
    • before_launch_task_declarations_are_validated:
      • 缺 requires.beforeLaunchTasks、写了 execution、用了 ${userArguments} 时,各报对应的错误码和字段。
  • declarative_plugins.rs:新 fixture 加入“契约 fixture 都能通过校验”的测试。
  • 本地:
    • cargo test --workspace:2235 个通过,0 失败;
    • cargo fmt --check、cargo clippy --workspace --all-targets --all-features -D warnings,以及改动 crate 的 --target x86_64-pc-windows-msvc clippy:都通过;
    • scripts/rust-core/verify-rust-core-comments.sh(改动的 5 个 crate)、node scripts/logging/generate-log-events.mjs --check、node shared/plugins/scripts/verify-docs.mjs、node --test shared/plugins/scripts/*.test.mjs:都通过;
    • 没有改插件后端协议和 SDK,没跑 sdk-e2e.mjs。

对标 IntelliJ IDEA 运行配置“启动前”的“添加新任务”(如 Go 插件的“运行 Go 命令”),
由插件注入任务种类,Core 不含任何插件特判(1lck/Lithe-IDEA#2100)。

- 契约:buildSystems[].beforeLaunchTasks(最多 16 个),声明方式同 runConfigurationTypes,
  但不能写 execution,arguments 不能用 ${userArguments};任务 ID 与类型 ID 各自唯一;
  requires.beforeLaunchTasks 0;语言文件新增 beforeLaunchTasks 一节;新 fixture before-launch-tasks/。
- 运行配置:beforeLaunch 步骤新增 {task: {pluginID, buildSystemID, type, values}},
  在拥有该列表的配置的工作目录里运行;步骤对象不允许其他键。
- 命令:新增 runConfig.checkBeforeLaunchTask(校验“添加新任务”表单值)和
  build.beforeLaunchTaskPlan(把任务步骤展开成 argv 计划);runConfig.beforeLaunch、
  updateOptions、saveEditorChanges 新增 runTypePlugins;拒绝码新增 taskNotDeclared、
  invalidTaskValues;确认指纹覆盖任务、值和工作目录。
- 编辑器:beforeLaunch 字段新增 tasks(任务种类与表单),字段值里的任务步骤为
  {task, name, summary, values},插件已卸载的为 {task, name, summary, missing: true}。
- 修复:runConfigurationTypes 的必填 arguments 字段留空以前不会被拒绝。
- 文档:rust-core-api、run-configuration-v2 schema、契约 README 与两份 schema、
  能力表、API 总表、build-systems 领域页、协议更新记录(同时把已合入的 #96 managedRuntimes
  从“待合入”移进时间线和首次出现表)。没有新增宿主方法或通知。
…取启动前列表

构建运行的编辑器不走 runConfig.editorForm,以前由宿主自己算可选配置,也看不到插件任务。
新命令按已保存配置返回 beforeLaunch 字段的 candidates、tasks 和当前生效的 value,
编辑后的值照旧交给 runConfig.updateOptions。未知配置返回 invalid_request。
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