Repository navigation
refactor(ai): AI 命令拆成独立 crate lithe-ai - #25
Merged
Merged
Conversation
Core 对 Java 等语言零依赖、零特判,语言和工具专属知识全部由插件注入。
- 删除 execution.planLaunchCommand(JDK @argfile 规划)及 execution/launch_plan.rs
- 删除 LSP 内置语言目录:lsp/languages/catalog.rs、resources/lsp/language-providers.json、
FFI lithe_core_lsp_provider_catalog_json 与头文件声明
- 删除 tree-sitter、tree-sitter-java 依赖
- 删除 lithe-ide-host 目录里的 Java/Maven 工具
- 删除只存在于契约、fixture、测试中的 23 个命令名(java.*、lsp.jdt*、maven.*、
mybatis.index、spring.index、runConfig.selectJava、build.languageImport、
agent.attachments.retentionPlan)及其 fixture
- 删除 maven-launch-context-v1、maven-portable-configuration-v1、run-configuration-v1 schema
- run/start 的 temporaryFiles 增加 {name, base64} 字节文件,宿主原样写入
- 模板 ${field.<id>.major} 取第一个数字分量,不再特判 1.x
- 旧版工具链 pin 的条目改为不透明字符串记录,不再点名 javaHome
- 契约文档和测试 fixture 去掉 Java/Maven/JDT 专属内容
Refs 1lck/Lithe-IDEA#1856, 1lck/Lithe-IDEA#1857, 1lck/Lithe-IDEA#1858, 1lck/Lithe-IDEA#1853
run-start.json 增加三条拒绝用例:同时给出 contents 和 base64、两者都不给、 base64 不是标准编码。Core 的 fixture 回放测试改为传入临时目录, 让这些用例走到逐项校验,而不是停在缺少临时目录。
- rust-core-api.md 补回 #19 误删的命令总表(375 条,每个 CoreCommand::parse 接受的命令一行) 和 AI configuration 章节;Build systems 表补上 build.resolveStoredOptions、build.editStoredOption。 - protocol::command 新增测试:命令表与解析器逐条比对,增删改命令必须同一次提交更新表格。 - 删除 rust/fixtures/i18n(归 Lithe-IDEA i18n 生成器所有,迁到 shared/i18n/fixtures) 和无人读取的 rust/fixtures/phpunit-project。 Refs 1lck/Lithe-IDEA#1853
- rust/lithe-core/src/ai 整体移到 rust/lithe-ai:提交信息生成、PR 描述、内联编辑、 AI CLI 配置解析。新 crate 只依赖 serde、serde_json、toml、url,不做文件、网络和凭据访问。 - lithe-ai 提供 COMMANDS / execute / execute_json 和 AiError,形状与 lithe-core-rules 一致; lithe-core 的 9 个 ai.* 分发分支改为调用 lithe_ai::execute,AiError 一一映射到 CoreError。 - git.commitMessageContext 仍在 lithe-core(要跑 git),改用 lithe_ai 的敏感路径与预算规则。 - lithe_core::ai 改为 re-export lithe_ai,原有路径不变。命令名、C ABI、JSON 和错误码不变。 - 注释规范检查覆盖 lithe-ai;新增测试确认每个 lithe-ai 命令都经 Core 路由到 lithe-ai。
xiaoyumuxi
changed the base branch from
docs/core-app-contracts-single-source
to
main
November 13, 2026 16:24
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.
关联
main。lithe-ide-host、lithe-mcp)保留,不在本 PR 范围内。这个 PR 做什么
把
rust/lithe-core/src/ai整体移到新的 craterust/lithe-ai。行为不变,只是换了位置。新 crate
lithe-aiai.*命令:ai.commitInputBudget、ai.planCommit、ai.decodeCommitMessage、ai.configuration.sources、ai.configuration.parse、ai.pullRequest.plan、ai.pullRequest.decode、ai.inlineEdit.plan、ai.inlineEdit.decodeserde、serde_json(开启preserve_order,和 lithe-core 一致,规划出的请求体字段顺序不变)、toml、url。不读文件、不访问网络、不持有凭据COMMANDS、is_ai_command、execute(command, payload)、execute_json(request),形状和lithe-core-rules一致AiError { code, message },AiErrorCode只有InvalidRequest、NotSupported,序列化名和 Core 的错误码相同lithe-core 的改动
runtime/dispatcher.rs:9 个ai.*分支改为调用lithe_ai::execute,新增辅助函数ai_response。protocol/error.rs:新增From<lithe_ai::AiError> for CoreError,InvalidRequest、NotSupported一一对应,错误码不变。lib.rs:删除pub mod ai,改为pub use lithe_ai as ai,原来的lithe_core::ai::…路径仍然可用。git/commit_message_context.rs:git.commitMessageContext要执行 git,所以留在 lithe-core,改为引用lithe_ai的敏感路径判断和输入预算。为此commit_input_budget、sensitive_path(导出名为is_sensitive_commit_path)和InputBudget改为pub并补上文档注释。不动的部分
rust/contracts/(ai-commit.md、ai-generation-requests.md、rust-core-api.md的 AI configuration 章节),只各补一句“命令在lithe-aicrate 中实现”。rust/fixtures/ai/,桌面端读取路径不变。lithe-ide-host、lithe-mcp)不动。新增测试
lithe-ai的every_listed_command_is_routed:COMMANDS里的每个命令在 crate 内都有路由,未知命令返回not_supported。lithe-core的tests/protocol.rs新增every_ai_crate_command_is_routed_by_core:COMMANDS里的每个命令都能被CoreCommand::parse解析,并且经 Core 实际转发到lithe-ai。我验证过,故意把分发器里的一个命令名写错,这个测试会失败。脚本和文档
scripts/rust-core/verify-rust-core-comments.sh:SOURCE_DIRS和 rustdoc-D missing_docs检查都加上lithe-ai。scripts/rust-core/README.md:补充lithe-ai。验证
cargo fmt --all --check:通过。scripts/rust-core/verify-rust-core-comments.sh:通过。node shared/plugins/scripts/verify-docs.mjs:通过。cargo clippy -p lithe-ai --all-targets:0 个警告。cargo test --workspace:1937 passed / 0 failed。其中lithe-ai29 个,lithe-core1716 个(原 1744 个,减去随代码移走的 28 个)。