Skip to content

refactor(core): crate 统一放到 rust/crates/,删除社区命令、wasm 入口和未使用依赖 - #26

Merged
xiaoyumuxi merged 2 commits into
mainfrom
refactor/core-crate-split
Nov 13, 2026
Merged

xiaoyumuxi merged 2 commits into
mainfrom
refactor/core-crate-split

Conversation

@xiaoyumuxi

@xiaoyumuxi xiaoyumuxi commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

关联

这个 PR 做什么

两个提交,可以分开看。

1. 删除社区命令、wasm 入口和未使用依赖(7ecfe2e)

改动 说明
删除 7 个 community.discourse.* 命令 auth.begin、auth.complete、auth.revoke、categories、search、topic、topics。实现、rust/fixtures/community/discourse-auth-v1.json、rust-core-api.md 和 application-boundary.md 中的对应章节一起删除。桌面端已不再调用这些命令。用户决定:社区相关的全部删除
lithe-core-rules 去掉 wasm 删除 wasm.rs、cdylib 和只给 wasm 用的 execute_json、is_rule_command。crate 只作为 rlib 链接进 Core,fixture 测试改为直接调用 execute
lithe-core 删除未使用的依赖 reqwest、rsa、sha1、shell-words、toml_edit,以及只为 num-bigint-dig 设的 profile。Cargo.lock 减少约 500 行
修复编译警告 host_failure 显式处理 BACKEND_EXITED:常量和错误码 plugin.backend.exited 都保留,映射结果仍是 plugin.host.failed,按 1lck/Lithe-IDEA#1796 的建议处理,错误码仍一码一义。另外给 forward_slash_path 加上 #[cfg(any(windows, test))],收窄 network 的重导出,删除 workspace_status.rs 中未使用的测试导入
新增测试 unparseable_requests_fail_without_an_id:请求无法解析时,响应不带 id。原来这个行为由 core-rules 的 execute_json 测试覆盖,现在改由 Core 测试

2. crate 统一放到 rust/crates/(8a89a0f)

移动前后的目录:

rust/                              rust/
├── lithe-ai/                      ├── crates/
├── lithe-core/                    │   ├── ai/
├── lithe-core-rules/              │   ├── core/
├── lithe-git-host/        →       │   ├── core-rules/
├── lithe-ide-host/                │   ├── git-host/
├── lithe-remote/                  │   ├── ide-host/
├── contracts/                     │   └── remote/
├── fixtures/                      ├── contracts/
└── logging/                       ├── fixtures/
                                   └── logging/
  • 目录名是包名去掉 lithe- 前缀,包名不变,cargo -p lithe-core 等命令照常可用。工作区成员改为 crates/*,以后新增的 crate 放进去就会自动加入工作区。
  • contracts/、fixtures/、logging/ 和 target/ 的位置不变,桌面端 LITHE_CORE_FIXTURE_DIR、LITHE_PLUGIN_CONTRACT_DIR 指向的路径不受影响。
  • 路径引用随之更新:Cargo 路径依赖、SDK e2e 的 [[test]] 路径和 sdk-e2e.mjs、三个 SDK 示例协议文件里的 fixture 路径注释、rust/contracts/ 和 shared/plugins/ 文档里的源码路径、rust/fixtures/debug/v1-baseline.json 里的 34 处源码位置,以及 README 的目录表(中英文都加了 rust/crates/、rust/contracts/、rust/fixtures/、rust/logging/ 四行)。
  • C 头文件位置变为 rust/crates/core/include/lithe_core.h。C ABI 本身不变。

注释门禁 scripts/rust-core/verify-rust-core-comments.sh 改为遍历 rust/crates/*/Cargo.toml,不再手写 crate 列表。新 crate 放进 rust/crates/ 后会自动接受检查。

  • 原来 rustdoc -D missing_docs 只检查 lithe-core、lithe-core-rules 和 lithe-ai。扩大范围后发现了下面三处缺口:
    • lithe-git-host、lithe-ide-host 缺少文档,这个 PR 已补齐。
    • 6 个文件里共有 21 条中文 log-exempt 注释,这个 PR 已改成英文;豁免类别名使用英文标签 Expected absence:、User cancellation:、Same failure already recorded:。
    • lithe-remote 有 404 处公开项缺文档,数量太多,不适合在目录整理的 PR 里补。脚本里新增一份显式名单 missing_docs_pending,名单上只有 lithe-remote,并注明 Issue [Feature] lithe-remote 补齐 404 处公开项文档注释,纳入 Core 注释门禁的 rustdoc 检查 1lck/Lithe-IDEA#1863。名单上的 crate 只跳过 missing_docs,链接检查和词法检查照常进行。Issue 完成后从名单中删除。
  • scripts/rust-core/README.md 同步说明这份名单的用法。

其他:

  • 给 lithe-ide-host 的 Cargo.toml 补上 description。
  • search_index 测试的权限写法从 0 改成八进制 0o000。原写法触发 clippy 的 deny 级 lint non_octal_unix_permissions。

不动的部分

  • 命令名(删除的社区命令除外)、C ABI、JSON 字段、错误码都不变。
  • 没有拆分或合并任何模块,没有改动任何 crate 的依赖关系(删除未使用依赖除外)。
  • CI 工作流不变。

桌面端(1lck/Lithe-IDEA)跟进

这个 PR 合入后,从最新 preview 开分支,在同一个 PR 里完成:

  • scripts/desktop/build-desktop-core.sh:PINNED_CORE_REVISION 升到包含这个 PR 的 commit;第 145 行的头文件路径改为 rust/crates/core/include/lithe_core.h。不改这一行,升级固定版本后桌面构建会失败。
  • desktop/internal/core/desktop_go_test.go:128:测试构造的头文件路径同步修改。
  • desktop/internal/core/errors.go:9:注释中的 rust/lithe-core/src/protocol/error.rs 改为新路径。
  • scripts/resources/worktree-resources.json 及其测试中的 rust/lithe-core/src/diagnostics/catalog_generated.rs、docs/ci-builds.md 中的 rust/lithe-core/、rust/lithe-remote/ 路径;develop-lithe Skill 及 references/logging.md 中的 Core 源码路径。
  • 删除社区相关的功能矩阵条目和 docs/viva-migration.md 中关于社区的段落。

验证

  • cargo fmt --all --check:通过。
  • scripts/rust-core/verify-rust-core-comments.sh:通过(lithe-remote 按上面的名单跳过 missing_docs)。
  • node shared/plugins/scripts/verify-docs.mjs:通过。
  • node shared/plugins/scripts/sdk-e2e.mjs:Node、Java、Rust 三个 SDK 和构建场景全部通过。
  • cargo check -p lithe-remote --no-default-features --features server:通过,远端服务器的构建方式不受影响。
  • cargo check --workspace --all-targets:第一个提交单独构建时没有警告。
  • cargo test --workspace:1933 passed / 0 failed,rustc 没有警告。原来是 1937 个,减去随社区命令删除的 5 个,加上新增的 1 个。
  • cargo clippy --workspace --all-targets:86 条告警都是原有代码产生的,这个 PR 没有新增告警。lithe-core 的 84 条记在 [Feature] 清零 lithe-core 在 rustc 1.96 下的 84 条 clippy 告警 1lck/Lithe-IDEA#1864;lithe-git-host、lithe-core-rules 各剩 1 条,记在 [Bug] rustc 1.96 下 lithe-git-host、lithe-core-rules 出现 3 条新 clippy 告警 1lck/Lithe-IDEA#1789。

- 删除 community.discourse.* 七个命令、实现和 fixture,桌面端已不再调用
- lithe-core-rules 去掉 wasm 入口和 cdylib,只作为 rlib 链接进 Core
- lithe-core 删除未使用的 reqwest、rsa、sha1、shell-words、toml_edit 依赖,去掉 num-bigint-dig 专用 profile
- 修复工作区编译警告:host_failure 显式处理 BACKEND_EXITED(错误码保留,仍映射为 plugin.host.failed)、限定 forward_slash_path 的编译条件、收窄 network 重导出
- 新增 unparseable_requests_fail_without_an_id 测试
- 六个 crate 从 rust/lithe-*/ 移到 rust/crates/<包名去掉 lithe- 前缀>/,包名不变;工作区成员改为 crates/*
- 同步更新路径引用:Cargo 路径依赖、SDK e2e 测试路径、fixture 和契约文档里的源码路径、README 目录表
- C 头文件的位置变为 rust/crates/core/include/lithe_core.h
- 注释门禁改为遍历 rust/crates/ 下的全部 crate;lithe-remote 缺 404 处公开项文档(1lck/Lithe-IDEA#1863),暂时只跳过它的 missing_docs,链接检查照常进行
- 为 lithe-git-host、lithe-ide-host 的公开项补齐文档,把 log-exempt 注释改成英文
- search_index 测试的权限写成八进制 0o000,修复 clippy 的 deny 级 lint
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