[Feature] 清理 lithe-core 与 lithe-agent-host 的 4 处无用导入和死代码,并为 Core 增加警告门禁
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 57/100
- Loại issue
- Tái cấu trúc
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- rust, typescript
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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,确认没有重复建议。
- Ngôn ngữ chính
- TypeScript
- Star
- 1.8k
- Fork
- 151
- Merge trung bình
- 10 giờ 29 phút
- Pull request đã merge (30 ngày)
- 407
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của 1lck/Lithe-IDEA
-
review: high
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
1lck/Lithe-IDEA#1797 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:other bug P2 platform:other review: high
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
1lck/Lithe-IDEA#1789 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
review: medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
1lck/Lithe-IDEA#1670 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:editor bug P0 platform:macos review: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
1lck/Lithe-IDEA#1118 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
review: high
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
1lck/Lithe-IDEA#1798 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của 1lck/Lithe-IDEA
Issue tương tự
-
Waiting for: Product Owner
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
getsentry/sentry-javascript#26203 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
bytedance/flowgram.ai#1235 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
devswha/herdr-web-ui#3325 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100