[Feature] 清理 lithe-core 与 lithe-agent-host 的 4 处无用导入和死代码,并为 Core 增加警告门禁
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 1-2 天
- 新手友好度
- 57/100
- Issue 类型
- 重构
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- rust, typescript
调研方向
Start with the four Rust locations named in the issue: rust/lithe-core/src/network/mod.rs, rust/lithe-core/src/git/workspace_status.rs, rust/lithe-core/src/lsp/interface/plugin_function.rs, and rust/lithe-agent-host/src/lib.rs; compare the proposed cleanup with the existing tests and contract fixture at shared/contracts/plugins/v1/fixtures/backend/function-protocol.json. Then check how the Core workspace runs CI linting, using #1789 as context for the warning gate. Done when the unused code is removed, BACKEND_EXITED has an explicit mapping covered by the fixture test, and Core warnings fail the chosen CI check.
由索引模型根据 Issue 内容生成。
描述
Problem to solve / 要解决的问题
在 preview 5a54c41aa 上用 macOS arm64、rustc 1.96.0 执行 cd rust && cargo test --workspace,lithe-core 和 lithe-agent-host 会报 4 条无用代码警告。逐项核对如下,依据是全仓库搜索,范围包括 Swift、Windows、契约 fixture 和脚本:
- 网络代理类型的 re-export
- 位置:
rust/lithe-core/src/network/mod.rs:11-14,pub(crate) use proxy::{…}中的NetworkProxyMode、NetworkProxyPolicy、NetworkProxyPolicyKind、NetworkProxyType。这条 re-export 由 #1571 引入。 - 警告:rustc
unused_imports。 - 依据:crate 内只用到同一行的
proxy_policy和NetworkProxyPolicyRequest。全仓库搜索这 4 个名字,其他命中都不经过这条 re-export:Swift 里同名但无关的类型(macos/Sources/Lithe/Models/Settings/NetworkProxyPreferences.swift),以及CoreCommand::NetworkProxyPolicy这个枚举成员。
- 位置:
- 测试模块的多余导入
- 位置:
rust/lithe-core/src/git/workspace_status.rs:102,测试模块的use super::*;。 - 警告:rustc
unused_imports。 - 依据:测试只通过
crate::execute_json调用命令,没有用到父模块的符号。
- 位置:
BACKEND_EXITED常量- 位置:
rust/lithe-core/src/lsp/interface/plugin_function.rs:252,codes::BACKEND_EXITED("plugin.backend.exited"),由 #1595 引入。 - 警告:rustc
dead_code。 - 依据:Rust 内没有任何引用。这个码由宿主报给页面,macOS 在
macos/Sources/Lithe/Application/Features/PluginHostServiceDispatch.swift:66另写了同一个字符串。契约 fixtureshared/contracts/plugins/v1/fixtures/backend/function-protocol.json:713要求:宿主把它报给后端时,要改写成plugin.host.failed。host_failure(plugin_function.rs:1836-1862)现在是靠_ => codes::HOST_FAILED兜底满足这条要求,:1858的注释提到了这种情况,但代码没有用这个常量。
- 位置:
- 测试辅助函数
resolve- 位置:
rust/lithe-agent-host/src/lib.rs:296-299,#[cfg(test)] fn resolve。 - 警告:rustc
dead_code(lib test 构建)。 - 依据:
rust/lithe-agent-host/src/tests.rs:3278定义了同名闭包let resolve = |launch| resolve_with(launch, &codex_cli);,测试里的调用全部走这个闭包,lib 里的辅助函数没有调用方。
- 位置:
保留的代价:
- Core 每次构建都带着这几条警告,新出现的警告容易被淹没,评审时也分不清哪些是本次改动引入的。
BACKEND_EXITED留在codes里,看起来 Rust 会专门处理这个码,实际行为却来自兜底分支,读代码的人会误判它的处理路径。- Core crate 没有警告门禁:目前只有
scripts/remote/verify-remote-workspace.sh:44-45对 lithe-remote 运行clippy -D warnings,所以这类警告能合进 preview。
lithe-git-host 的 forward_slash_path 警告(rust/lithe-git-host/src/configuration.rs:52)已经由 #1789 跟踪,本单不重复处理。
Proposed solution / 建议方案
- re-export:从
network/mod.rs的 re-export 中删掉未用的 4 个类型,保留proxy_policy和NetworkProxyPolicyRequest。风险很低,只影响 crate 内可见性。 - 多余导入:删除
workspace_status.rs测试模块中的use super::*;。 BACKEND_EXITED(推荐方案):在host_failure里显式写一条Some(codes::BACKEND_EXITED) => codes::HOST_FAILED,把:1858的注释移到这一行。这样 fixture:713的行为由具名分支保证,常量也有了用处。- 不推荐直接删除常量:这是契约里登记的错误码,Rust 侧保留具名常量,可以防止以后被别的含义复用(错误码必须一码一义)。
- 风险:无行为变化,现有 fixture 测试即可验证。
- 测试辅助函数:删除
lithe-agent-host/src/lib.rs:296-299的#[cfg(test)] fn resolve。 - 警告门禁:清理完成后,为 Core workspace 增加警告门禁,例如在 CI 中运行
cargo clippy --workspace --all-targets -- -D warnings,并与 #1789 的处理一致。stable 工具链升级会带来新的 lint(#1789 就是这种情况),门禁放在哪个工作流、是否固定工具链版本,由维护者决定。
Target platform / 目标平台
Cross-platform / 跨平台
Area / 模块
Other / 其他
Priority / 优先级
P2 / 后续考虑:目前不着急,可安排到后续版本
Alternatives considered / 已考虑的替代方案
用 #[allow(unused_imports)] 或 #[allow(dead_code)] 压掉警告。不推荐:无用代码会继续留着,也违背 develop-lithe 第九节的清理要求。
Additional context / 补充信息
- 复现命令:
cd rust && cargo test --workspace --no-fail-fast,在构建输出中搜索^warning。 - 发现经过:2026-11-07 把 Core 拆分为 Lithe-IDEA/Lithe-core-rust 时,跑完整 workspace 测试发现。拆分出的文件与主仓库逐字节一致,所以主仓库 preview 上有相同的警告。
- 相关:#1789(
lithe-git-host、lithe-core-rules的 clippy 告警)。
Checklist / 提交前检查
- I searched existing issues for duplicates. / 我已搜索现有 Issue,确认没有重复建议。
- 主要语言
- TypeScript
- 星标
- 1.8k
- 派生
- 151
- 平均合并
- 10 小时 29 分钟
- 30 天内合并 PR
- 407
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
1lck/Lithe-IDEA 的其他 Issue
-
review: high
难度 2/5 1-3 小时 新手友好度 78/100
1lck/Lithe-IDEA#1797 ·
维护者通常 1 天内回复
-
area:other bug P2 platform:other review: high
难度 2/5 1-3 小时 新手友好度 76/100
1lck/Lithe-IDEA#1789 · 2 条评论 ·
维护者通常 1 天内回复
-
review: medium
难度 2/5 1-3 小时 新手友好度 70/100
1lck/Lithe-IDEA#1670 ·
维护者通常 1 天内回复
-
area:editor bug P0 platform:macos review: low
难度 2/5 1-3 小时 新手友好度 65/100
1lck/Lithe-IDEA#1118 · 2 条评论 ·
维护者通常 1 天内回复
-
review: high
难度 5/5 一周以上 新手友好度 25/100
1lck/Lithe-IDEA#1798 ·
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
backnotprop/plannotator#2914 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
microsoft/vscode-containers#655 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 77/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
dsh-tauri-desk/deepseek-harness-desktop#1477 · 1 条评论 ·