Repository navigation
refactor(core): 拆出领域、LSP 和插件 crate,lithe-core 只留分发器与 FFI - #28
Merged
Merged
Conversation
- 日志目录、通道、记录、查询、格式化、保留、收集计划、诊断包脱敏与清单、 Core 事件队列移到 rust/crates/diagnostics,只依赖 lithe-protocol。 - 请求轨迹和辅助 crate 失败接线留在 core runtime;远程错误分类 (failure_category、is_resource_already_gone)归 lithe-remote 的 ClientError。 - 测试钩子通过 test-support feature 只对 core 的 dev-dependencies 开放; diagnostics.* 分发测试移到 core/src/tests/diagnostics_dispatch.rs。 - 修正 capabilities 文档里指向私有项的链接和 logging README 的旧路径。
- lithe-text:UTF-16 位置与范围、文本编辑校验与规划、行索引,以及无语言服务器时的补全、悬停、导航和代码片段(原 lsp/lightweight 与 lsp 位置类型) - lithe-editor:editor.* 命令的实现(原 core/src/editor),依赖 lithe-text - editor.* 的分发测试移到 core/src/tests/editor_dispatch.rs
请求范围内的状态单独成 crate:来源 Source、请求追踪关联(trace),以及发往宿主的有序事件通道和脱敏(events,原 git::execution_events 的通用部分)。 Git 进程调用的 started/output/finished 事件仍在 git::execution_events,改用通道的 next_invocation、invocation_started、invocation_finished;remote、project、runtime 直接使用新 crate,不再经过 git。 execute_json_with_events 的回调测试移到 core/src/tests/request_events.rs。
FileNameKey、compare_file_names、compare_reference_names 移到 lithe_core_rules::file_names,git、lsp、project 直接引用; workspace.orderEntries 命令和错误文本留在 core。纯比较的夹具测试 随之移到 lithe-core-rules。
core 的 remote 模块整体移到新 crate lithe-workspace:probe(SSH 探测)、 sessions(连接注册表)、host(宿主请求与进程/终端/监听资源)、upload、 fs(本地或远程文件系统),请求作用域的 Host/Scope 放在 crate 根。 remote 工作区命令白名单留在 core dispatcher,判定顺序和错误文本不变。 依赖 execute_json 的端到端测试移到 core/src/tests/remote_sessions.rs, 通过 test-support 特性注册进程内宿主会话。
core 的 git 模块整体移到新 crate lithe-git(约 2.9 万行),core 的 dispatcher 只负责路由 git.* 命令。Git 响应类型从 protocol/contracts.rs 移到 lithe_git::contracts,core 原样重新导出,JSON 形状、错误码不变。 - 只有 core 用到的入口和类型改为 pub 并补文档;只经 serde 读写的 请求、响应字段收窄为 pub(crate),缩小跨 crate 的公开面。 - 依赖 execute_json 的共享 fixture 测试移到 core/src/tests/git_*.rs; 其余测试留在 lithe-git,改为直接调用类型化入口,并在 crate 根加 test_request/test_envelope 两个测试辅助,模拟 dispatcher 的解码与 ok/data/error 包装。 - diff block fixture 入口和未跟踪目录阈值放在 test-support 特性下, 供 core 的集成测试使用。 - branch-name 对照 fixture 移到 crates/git/tests/fixtures/。 - 顺手修 lithe-git 内可自动修复的 clippy 提示和两处指向私有项的文档链接, logging README 的 command_trace.rs 路径改到新位置。
把声明式插件清单各部分共用的基础定义抽成最底层的 crate
lithe-plugin-model(约 2600 行),为后续把 toolchain、vcs、debug、
build 等插件领域拆成独立 crate 打掉 plugins ↔ 领域的循环依赖。
JSON 形状、错误码不变。
- rejection:PluginRejection、Validation、invalid、invalid_template
(原 template)、decode_payload、outcome;code()/field() 不再只在
测试中可用,供 core 测试断言。
- names / version / template / icon:ID 与路径字母表、版本比较、
`${...}` 模板解析、UIIcon。
- process:ServerProcess、LanguageServerLaunch、LaunchVariable 等
服务进程声明与校验,连同原在 language_server_sessions 的解析超时
常量和 validate_resolve_timeout。
- settings(含 documents、pages)与 executables 整体移入。
- 只有 core 用到的项改为 pub 并补文档,crate 内部用的保持 pub(crate)。
- marketplace 里与共用版本相同的 decode_payload 删除,改用共用版本;
MAX_SETTINGS 移到 settings;KNOWN_RUNTIME_TOOLS 移到 build/manifest。
- 依赖 execute_json 的设置文档测试移到 core/src/tests/plugin_settings_documents.rs。
工具链策略(定义注册、查询回复、目录固定、固定来源、使用方偏好、解析与候选) 移到 rust/crates/toolchain,约 4.9k 行,只依赖 lithe-protocol 与 lithe-plugin-model。 - 清单校验仍属插件宿主:toolchain 定义 ManifestValidator,重建注册表的 命令由 Core 注入 plugins::declarative::validated_manifest_json, toolchain 不再反向依赖 lithe-core。 - Core 以 `pub use lithe_toolchain as toolchain` 保留原路径,命令、JSON 形状和错误码不变。 - 用 execute_json 的两个用例移到 core/src/tests;仅测试用的 path_within 随用例移入测试文件。 - 测试总数不变:lithe-core 1380 + lithe-toolchain 10。
统一 VCS 模型(提供者声明、根目录检测、请求规划、回复校验)移到 rust/crates/vcs,约 2.2k 行,只依赖 lithe-protocol 与 lithe-plugin-model。 - vcs.detectRoots 需要重新校验整份清单:lithe-vcs 定义 VcsManifest trait,Core 为 DeclarativePluginManifest 实现,并在派发时注入 validate_manifest_value;删去被 trait 取代的重复访问器。 - 补齐 Operation 各变体、PlannedRequest 与 DeclarationContext 字段的文档。 - Node SDK 注释里的 Core 路径改为 rust/crates/vcs/。 - 测试总数不变:lithe-core 1361 + lithe-vcs 19。
运行配置(三层文档合并、生成层、启动计划、参数文本、环境变量、上下文选择、 工作区扫描与运行发现)整体移到 rust/crates/execution,Core 用 `pub use lithe_execution as execution` 保留原路径,C ABI、JSON 形状和错误码不变。 - 依赖:lithe-diagnostics、lithe-plugin-model、lithe-protocol、lithe-toolchain、 lithe-workspace;serde_yaml_ng 随 compose 检测器移入,Core 不再依赖它。 - 经调度器调用的 4 个测试移到 core/src/tests/execution_commands.rs; generated_layer::seed 只在 test-support 特性下公开,供 Core 测试预置生成层。 - 补齐公开字段文档,删去过时的“Crate-visible”注释。 - detectors/ 下的 cargo、compose、go、make、npm、procfile、python、shell 检测器暂留,改由插件注入由 1lck/Lithe-IDEA#1856 跟进。 测试总数不变:lithe-core 1353 + lithe-execution 8 = 拆分前 1361。
DAP 调试引擎(会话、传输生命周期、断点重定位、变量/反汇编/内存分页、 projection v2、调试适配器声明校验与启动参数)整体移到 rust/crates/debug, Core 用 `use lithe_debug as debug` 保留原路径,C ABI、JSON 形状和错误码不变。 - 依赖:base64、lithe-diagnostics、lithe-plugin-model、lithe-protocol、 serde、serde_json、sha2,不依赖 Core。 - `debug.decodeBackendConfiguration` 原先直接调插件宿主的清单校验;现在由 宿主通过 `DebugManifest` trait 和注入的校验函数提供,与 lithe-vcs 同一做法。 DeclarativePluginManifest 实现该 trait,去掉了只剩这一个调用方的 `debug_adapters()` 固有方法。 - 根模块不再整体 glob 导出 engine、types 等模块,只显式导出 Core 调度器 用到的命令函数和请求类型;请求、声明类型的字段收窄为 crate 内可见, 只放开 Core 实际读取的字段,并补齐这些公开项的文档。 - fixtures/debug/v1-baseline.json 里的源码路径改到 rust/crates/debug/src/。 测试总数不变:lithe-core 1248 + lithe-debug 105 = 拆分前 1353。
- project_generators 整体移到 rust/crates/project-generators(lithe-project-generators),
只依赖 lithe-plugin-model 和 lithe-protocol。
- 新增 GeneratorManifest trait;project.generatorCatalog、generatorForm、generationPlan
三个命令改为接收插件宿主注入的清单校验函数,Core 的 DeclarativePluginManifest
实现该 trait,dispatcher 传入 validate_manifest_value。
- 能力表 capabilities.rs 移到 lithe-plugin-model(仍可经 lithe_core::plugins::capabilities
访问),同步更新 README 与 shared/plugins/reference 两页里的源码路径。
- 工具 ID 校验原有两份实现(toolchain::definitions::tool_id 与 pins::valid_tool_id),
合并为 lithe_plugin_model::{is_tool_id, is_tool_namespace, is_local_tool_id}。
- zip、rand 只被项目生成器使用,从 lithe-core 依赖中移出。
命令名、JSON 形状和错误码不变;单测总数不变(Core 1219 + 新 crate 29 = 原 1248)。
lithe-plugin-model 新增 PluginManifest trait(validate + id)。VcsManifest、DebugManifest、 GeneratorManifest 都以它为父 trait,命令改为泛型 cmd::<M>,不再逐个传入校验函数; Core 的 DeclarativePluginManifest 实现 PluginManifest,dispatcher 与测试统一写 cmd::<Manifest>。为接下来拆 build(约 25 个读取清单的命令)准备同一种写法。 命令名、JSON 形状和错误码不变;测试数不变。
构建系统模型(声明校验、静态模型、argv 计划、输出解码)搬进独立 crate。 读插件清单的 26 条 build 命令改为泛型 BuildManifest,由 Core 的 DeclarativePluginManifest 实现;Core 删去不再使用的 chrono、quick-xml、 toml、ignore 依赖。
工作区文件与可见性、索引策略、搜索与搜索索引、本地历史、文档持久化决策和 Markdown 渲染搬进独立 crate,项目服务的响应模型(原 protocol/contracts.rs)随之搬入。语言服务会话在它之上:改动索引策略或搜索索引的三个入口改为接收 update_providers 回调,由 Core 传入 lsp::indexing_changed,调用顺序不变。目录访问计数通过 test-support feature 供 Core 测试读取。Core 删去 ammonia、comrak、encoding_rs,base64 与 sha2 只留在 dev-dependencies。
原生路径与 LSP 文档 URI 的互转(lsp.documentUri、请求路径解析、file: URI 解码与百分号解码)搬进 lithe-document-uri,语言服务运行时和策略命令都依赖它。文档身份、导航目标、工作区编辑计划、声明或用法、补全合并、激活策略和问题查询这七个纯决策命令连同只被它们使用的 WorkspaceScope 搬进 lithe-lsp-policy,原 lsp/host_policy 目录取消。两个 crate 互不依赖语言服务运行时,可与之并行编译。 七个命令的共享 fixture 测试走 execute_json,合并到 Core 的 tests/lsp_policy.rs;file URI 解码测试随函数搬进 lithe-document-uri。命令名、JSON 形状和错误码不变。
语言服务的进程边界(LspProcessSpec、进程句柄与启动器、本地子进程及 Windows 进程树)、远程工作区上的 stdio 转发、LSP Content-Length 分帧,以及引擎测试用的脚本化服务器,从 lsp/interface 搬进独立 crate。原 transport.rs 在新 crate 里改名为 framing.rs;脚本化服务器通过 test-support feature 供 Core 测试使用。Windows 专属测试重新启动自身测试二进制时使用的 libtest 名称随模块路径改为 process::tests::*,已用 x86_64-pc-windows-msvc 目标检查通过。分帧测试随函数搬入新 crate。
把各插件贡献的声明与校验从 lithe-core 的 plugins 模块拆成独立 crate, 只依赖 lithe-plugin-model 和 lithe-protocol,可与其它领域 crate 并行编译: - lithe-plugin-editor:编辑器动作(actions)与编辑器提供者(providers) - lithe-plugin-grammar:语法声明与语言配置 - lithe-plugin-native-ui:原生插件界面描述 - lithe-plugin-content-providers:内容提供者 - lithe-plugin-language-servers:语言服务器会话声明、启动答复与门控 - lithe-plugin-output-links:输出链接匹配与解析 PluginVersion 和已安装版本比较移入 lithe-plugin-model;经由 execute_json 的已安装版本 fixture 测试移入 core tests。命令、JSON 形状和错误码不变。
…-functions、lithe-plugin-keymap-import - 插件函数协议(原 lsp/interface/plugin_function.rs)和宿主方法目录(原 plugins/host_api.rs) 移入 lithe-plugin-rpc,打断 declarative 与 lsp::interface 之间的循环依赖。 - 插件后端声明(backend.rs)、插件导出函数(plugin_functions.rs)、快捷键导入(keymap_import.rs) 各自独立成 crate。 - keymap-import 通过 KeymapImportManifest trait 读取清单里的提供者,不再依赖 declarative; 经由 execute_json 和 declarative 的测试移到 core/src/tests/keymap_import.rs。 - offered_versions 移到 lithe-plugin-model::capabilities。 - 契约 README、协议更新记录、三个 SDK 的源码注释里的路径改为 rust/crates/plugin-rpc/src/lib.rs。 命令、JSON 形状、错误码均未改变。
- 声明式插件清单(原 plugins/declarative.rs 和 settings_surfaces.rs)移入 lithe-plugin-manifest:清单校验、规范化,以及运行、测试、调试、设置、语言服务器计划。 - 该 crate 只依赖 build、vcs、debug、project-generators、toolchain 和各插件叶子 crate, 不再经过 lithe-core。 - core 改用 lithe_plugin_manifest:: 路径;契约 README、能力与版本参考页、 plugin-model 文档里的旧 lithe_core::plugins 路径一并更新。 命令、JSON 形状、错误码均未改变。
…删除 core 的 plugins 模块 - 插件网页(原 plugins/web_content.rs 及其测试)移入 lithe-plugin-web-content。 - 插件市场(原 plugins/marketplace.rs)移入 lithe-plugin-marketplace。 - core 的 plugins 模块只剩 capabilities 再导出,一并删除;调用方直接用 lithe_plugin_model::capabilities。 - core 不再使用 regex,移除该依赖。 命令、JSON 形状、错误码均未改变。
- 删除只在测试里使用的 Swift 宿主模型适配器 lsp/languages/swift.rs;LSP 测试直接调用 生产路径 client_feature_request_canonical,输入改用标准 LSP 形状(1lck/Lithe-IDEA#1858)。 - 删除无读者的 rust/fixtures/modules/built-in-v1.json 和 application-boundary.md 的 Module Lifecycle Contract 一节(1lck/Lithe-IDEA#1858)。 - 删除没有任何代码构造的 protocol::CoreEvent 及其专用的再导出;4 处仍点名 Swift、C++、TypeScript 客户端的注释改为描述当前宿主(1lck/Lithe-IDEA#1868)。 - 清空 rust/logging/events/agent.json 中 8 个没有发送方的事件,保留 agent 根, catalog_generated.rs 同步删除对应条目(1lck/Lithe-IDEA#1865)。 命令、JSON 形状、错误码均未改变。
- 语言服务器的 hostIntegration 解析为任意值后立即以 plugin.integration.unsupported 拒绝(字段仍是 languageServers[i].hostIntegration.id);删除空名单、能力与资源 模型、与执行提供者的重复声明检查、程序清单和启动计划里的输出 - 构建系统的 hostIntegration 同样存在即拒绝;删除 ModelSource、TestResultsSource、 DependenciesSource 的 HostIntegration 成员及 outputs、plans、detect 的分支, 以及只为它存在的官方插件检查和 DeclarationContext.official - 契约 schema 删除三处 const "hostIntegration" 来源分支和语言服务器侧的 capabilities、resources;README、指南与参考页同步,顺手去掉构建文档里的“社区插件”说法 - 现有 fixture 不变,错误码和字段路径不变 Refs 1lck/Lithe-IDEA#1857
…-server-policy,删除 core 的 lsp 模块 - lithe-lsp-client:纯状态的 LSP 客户端(协商、文档、功能请求、各提供者协议) - lithe-lsp-engine:语言服务器会话、进程、超时、事件队列、插件服务器调用和跨插件函数中转 - lithe-plugin-function-relay:跨插件函数调用的准入规则和在途调用表 - lithe-plugin-server-policy:插件语言服务器的会话策略(准入、门、合并命令、操作归属) - 文本、文档 URI 的测试随实现移到 lithe-text、lithe-document-uri;引擎日志命令的分发测试留在 core - SUPPORTED_PLUGIN_API_VERSIONS 移到 plugin-model 的 capabilities - client_feature_request_canonical 的布尔参数恒为 true,合并成 client_feature_request - 只在 crate 内用的字段收回 pub(crate),其余公开项补全文档;契约 README 改指新路径
- clippy --fix 处理可机械修复的项 - 手工修复:冗余守卫、复杂类型改别名、strip_prefix、相同分支合并、stash 只剩 drop 的 match、 diff_blocks 的 old/new 改名 old_lines/new_lines、as_infrastructure 改名 into_infrastructure、 sort_by_key、clamp、slice::from_ref - 8 个参数的三个函数沿用仓库已有的 too_many_arguments 放行写法
- project indexing 的 contains 在 Windows 下把小写化后的 String 再借成 &str,修复 clippy 改动后 String 不满足 Pattern - workspace probe 测试的 json 宏不再只在 unix 下导入;四个依赖会话的测试只在 unix 下运行 - lsp-engine 只给 unix 测试用的 ScratchDirectory 与 open_document 加 cfg(unix)
- lsp-engine 的 runtime_error 把请求方法、文档、底层原因和进程退出码收进 FailureContext, 19 处调用改用 FailureContext::request / default 加 with_underlying、with_exit_code - 只被两处调用的 push_issue_log_event 内联,直接构造错误后交给 push_classified_log_event - git 的 emit_output 改为 OutputTarget::emit:事件去向、操作 ID、调用 ID 和待定进度行 收进 OutputTarget,Invocation 用 output_target() 取得 - 行为不变;build 里原有的两处放行保持不变
lib.rs 从 9895 行拆成 18 个主题模块和 tests.rs,根文件只留模块索引、 常量和测试辅助函数。条目正文不变,跨模块用到的私有条目放宽为 pub(crate)。
lib.rs 从 5844 行拆成 14 个主题模块,根文件只留公开入口函数。 impl RuntimeSession 按方法分组切成几个 impl 块放进对应模块; 条目正文不变,跨模块用到的私有条目和字段放宽为 pub(crate)。
engine.rs 从 7333 行拆成 engine/ 下 7 个主题模块和 tests.rs, 根文件只留会话生命周期的入口函数。条目正文不变,跨模块用到的 私有条目和字段放宽为 pub(crate);测试的 fixture 相对路径多一级。
CoreCommand 里 14 个大家族(git、lsp、debug、plugins、build、workspace、 diagnostics、toolchains、remote、runConfig、history、editor、ai、keymap) 改成嵌套子枚举,例如 CoreCommand::Git(GitCommand::Status)。命令名映射仍只在 CoreCommand::parse 一处,顺序不变;子枚举保留每个变体的原注释。 每个家族的分支搬到 runtime/dispatcher/<家族>.rs 的 dispatch 函数,分支体只把 CoreCommand::GitX 换成 GitCommand::X、parsed.payload 换成 payload;编译器仍检查 每个家族的分支穷尽。只有一个家族用的辅助函数随家族搬走(ai_response 到 ai, CoreEventConfiguration 和 log_v2_result 到 diagnostics)。dispatcher.rs 从 4120 行降到约 760 行,只留请求入口、作用域设置和小家族的分支。 命令名、JSON 形状、错误码和 C ABI 都不变。
lib.rs 从 3515 行降到约 60 行,只留 crate 说明、依赖和模块索引。 新模块:manifest(清单模型与访问器)、providers(领域 crate 读取清单的 trait 实现)、templates、validation、ui、permissions、declarations、 run_plans、launch、provider_launch、commands、settings。 条目内容不变,只把跨模块用到的条目和字段放宽到 pub(crate),并在拆开的 impl 块前补上 impl 头。
按 rust/contracts/remote-workspace-protocol-v1.md 的语义为协议方法、事件、 消息、帧、客户端会话、传输链、端口转发、启动与安装引导的全部公开项补上 Rustdoc;代码不变。所有 crate 现在都按 -D missing_docs 检查,脚本和 README 不再保留豁免名单。 Closes 1lck/Lithe-IDEA#1863
engine.rs 拆分后测试搬到 engine/tests.rs,基线 fixture 里 27 处证据路径 还指着 engine.rs。按测试函数名重新定位,只改路径。
- lithe-build manifest.rs 2571 行 -> manifest/ 下 11 个模块,父文件 230 行 - lithe-execution configuration.rs 2471 行 -> configuration/ 下 11 个模块 - lithe-debug adapters.rs 2175 行 -> adapters/ 下 9 个模块 - lithe-project files.rs 2341 行 -> files/ 下 10 个模块,父文件 145 行 - lithe-lsp-client client.rs 2564 行 -> client/ 下 8 个模块,父文件 284 行 - lithe-plugin-rpc lib.rs 2452 行 -> 5 个模块,lib.rs 留协议常量和测试 - lithe-toolchain resolution.rs 1616 行 -> resolution/ 下 7 个模块 函数体不变;子模块里的 super:: 改成 crate::,跨模块用到的项改成 pub(crate),大 impl 块按方法切开放到对应主题。插件函数协议已不止一个 文件,README、契约、协议更新记录和三个 SDK 的注释改成指向 rust/crates/plugin-rpc/src/ 目录。
1 task done
21 of 24 tasks
Contributor
Author
|
桌面端跟进 PR:1lck/Lithe-IDEA#1887(Draft)。它把 本 PR 合入后,要先把 #1887 的 pin 改成 main 上的合并 commit,再合 #1887。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联
built-in-v1.json)protocol::CoreEvent,4 处点名已删除客户端的注释)agent.json中 8 个没有发送方的事件)hostIntegration不可达的集成模型和来源)KNOWN_RUNTIME_TOOLS里的 go/node、execution 的项目探测器和fingerprint_input、行注释符表。改为插件注入需要单独设计契约,不在这个 PR 里做。这个 PR 做什么
1. lithe-core 只剩分发器和 FFI
crates/core/src总行数lithe-core 现在只有这些文件:
lib.rsprotocol/command.rs、protocol/mod.rsCoreCommand和 14 个命令家族子枚举runtime/dispatcher.rsruntime/dispatcher/*.rs(14 个)git.rs、lsp.rs、plugins.rsruntime/ffi.rsruntime/request_trace.rsruntime/helper_failures.rstests/lsp、plugins以及各领域模块已从 lithe-core 删除。2. 新增 34 个 crate
都放在
rust/crates/下。代码从 lithe-core 原样搬出,只调整了可见性和导入路径。“内容”一列取自各 crate 的Cargo.tomldescription。pluginFunctions:插件导出给其他插件的函数,以及它调用的导出函数litheFunctions协商、函数调用、宿主方法和宿主通知目录及授权文件名自然排序(
file_names)移到了 lithe-core-rules。3. 依赖层级
按普通依赖分层,同一层的 crate 互不依赖,可以并行编译:
4. 编译时间
测法:
cargo build -p lithe-core --lib,dev profile,10 核 macOS。外部依赖已预先编好,只清掉工作区 crate。两边在同一台机器上依次运行,测量期间没有编辑代码,也没有运行其他编译。lsp-client/src/client.rs)后增量编译core/src/runtime/dispatcher.rs)后增量编译这组数字测于第 6 节的文件拆分之前。文件拆分不改变 crate 边界,只影响单个 crate 内部。
5. 拆分时顺手做的整理
PluginManifesttrait(validate和id)。VCS、调试、项目生成器、构建四个领域 crate 的命令改为泛型cmd::<M>,不再逐个传入校验函数。lsp/languages/swift.rs。LSP 测试改为直接调用生产路径client_feature_request_canonical。rust/fixtures/modules/built-in-v1.json,以及application-boundary.md的 Module Lifecycle Contract 一节。protocol::CoreEvent。agent.json的 8 个事件,保留 agent 根。hostIntegration只保留“存在即拒绝”:hostIntegration不论取什么值,都以plugin.integration.unsupported拒绝,字段路径不变。ModelSource/TestResultsSource/DependenciesSource的HostIntegration成员,以及只为它存在的官方插件检查。#[allow]:runtime_error改为接收FailureContext,同时删除push_issue_log_event。OutputTarget。min,这个写法已删除,默认值仍是不限深度。verify-rust-core-comments.sh删掉待补名单,现在每个 crate 都按missing_docs检查,没有例外。6. 文件拆分
超过约 1 500 行生产代码的文件全部按主题拆成子模块。条目原样搬动,只把
super::改成crate::、把跨模块用到的私有项放宽到pub(crate),不改函数体。剩下最大的手写文件,生产代码在 1 200–1 450 行之间(如protocol/command.rs、git/src/history.rs)。diagnostics/src/catalog_generated.rs是生成文件,不拆。src/lib.rssrc/下按主题的约 60 个模块(状态、提交、历史、变基、补丁、推送、搁置等),测试在tests.rs、graph_tests.rssrc/engine.rsengine/{state,messages,execution,breakpoints,inspection,step_filters,fields,tests}.rssrc/lib.rssrc/{engine,state,lifecycle,documents,requests,operations,events,server_messages,host_requests,function_calls,function_provider,plugin_server_calls,relay_hub,provider_events,configuration,scan_settings,validation,logging}.rsruntime/dispatcher.rsruntime/dispatcher/下 14 个家族文件;CoreCommand的这些家族改为嵌套子枚举(如CoreCommand::Git(GitCommand::Status)),命令名字符串不变src/lib.rssrc/{manifest,validation,declarations,providers,provider_launch,launch,run_plans,commands,permissions,settings,settings_surfaces,templates,ui}.rssrc/manifest.rsmanifest/{provider,detection,invocation,options,model,tasks,run,testing,diagnostics,dependencies,checks}.rssrc/client.rsclient/{lifecycle,server_messages,json_rpc,validation,requests,diagnostics,results,capabilities}.rssrc/configuration.rsconfiguration/{requests,document,generation,resolve,editing,launch,validation,merge,layers,requirements,inputs}.rssrc/lib.rssrc/{functions,host_requests,host_notifications,host_params,failures}.rs;常量、错误码codes和测试留在lib.rssrc/files.rsfiles/{events,requests,snapshot,visibility,search,search_everywhere,replace,text_io,paths,matcher}.rssrc/adapters.rsadapters/{declaration,process,validate_adapter,validate_configuration,validate_launch,resources,start,plan,checks}.rssrc/resolution.rsresolution/{probe,launch,discovery,snapshot,project,installations,automatic}.rs;resolve留在父文件跟着改的引用:
rust/fixtures/debug/v1-baseline.json的 27 条测试证据路径从engine.rs改为engine/tests.rs。rust/crates/plugin-rpc/src/目录。契约和协议
插件契约有一处行为变化,已写进
shared/plugins/reference/protocol-changelog.md的 2026-11-14 一行(本 PR #28):model、test.results、dependencies中不可达的source: "hostIntegration"分支,以及语言服务器hostIntegration的capabilities/resources。source: "hostIntegration"现在按未知来源处理,报plugin.manifest.invalid。原来带名字时报plugin.integration.unsupported。这个来源从未被接受过,现有 fixture 不受影响。capabilities.rs→rust/crates/plugin-model/src/capabilities.rs,插件函数协议 →rust/crates/plugin-rpc/src/,函数中转 →rust/crates/plugin-function-relay/。不动的部分
lsp-engine/src/lib.rs、lsp-engine/src/tests.rs。rust/crates/*,新 crate 自动接受检查。capabilities.rs、plugin_function.rs)。hostIntegration检查。验证
在
rust/下:cargo fmt --all --check:通过。cargo check --workspace --all-targets:本机目标和x86_64-pc-windows-msvc都没有警告。cargo clippy --workspace --all-targets:本机目标和x86_64-pc-windows-msvc都是 0 条告警。cargo test --workspace:1936 passed / 0 failed。在仓库根:
scripts/rust-core/verify-rust-core-comments.sh:通过。node shared/plugins/scripts/verify-docs.mjs:通过。node shared/plugins/scripts/sdk-e2e.mjs:Node、Java、Rust 三个 SDK 和构建场景全部通过。