refactor(config):将原先边界过宽或是职责细碎的部分重构#254
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
|
/review -codex |
| } | ||
| } | ||
|
|
||
| func TestNormalizeContentTypesFallsBackToDefaultsWhenEmpty(t *testing.T) { |
There was a problem hiding this comment.
TestNormalizeContentTypesFallsBackToDefaultsWhenEmpty and its assertion currently describe different expectations.
- Test name implies empty input should fallback to
defaults - Assertion expects zero results for
[]string{"", " "}
Please align either the test name or the assertion with the intended behavior, so this test documents the contract unambiguously.
| } | ||
| cloned := original.Clone() | ||
| if len(cloned.Env) != 0 { | ||
| t.Fatal("expected cloned env to be empty slice, not nil") |
There was a problem hiding this comment.
The failure message says empty slice, not nil, but this assertion only checks len(cloned.Env) != 0, which cannot distinguish nil from empty slice.
Either update the assertion to check nil-vs-empty explicitly, or relax the message to match the current length-only check.
|
/simplify |
完成情况已按请求先检查评论日志中的未解决 review comment,并完成值得修复的项:
验证
提交与推送
未执行项
|
Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: phantom5099 <245659304+phantom5099@users.noreply.github.com>
变更说明
本次 PR 针对
internal/config包进行了深度的结构梳理与重构。主要目标是解决配置模块内部存在的“过度臃肿”与“过度细碎”并存的问题。通过解耦大杂烩结构、聚合零散逻辑、清理不再使用的兼容函数,我们将 Config 包还原为一个高内聚、边界清晰、无历史债务的核心管理层。主要改动
model.go):model.go。config.go(核心骨架)、context.go(上下文相关)、tools.go(内建工具)、mcp.go(MCP协议支持)和memo.go(记忆相关)。provider_runtime.go和builtin_providers.go。provider.go,消灭为了分层而分层的过度设计。config.Default()方法,统一规范使用StaticDefaults()获取静态骨架。config_model_split_test.go)。builtin_providers_test.go与provider_runtime_test.go聚合到provider_test.go,确保测试代码结构与生产代码结构严格对齐,全量测试秒过。预期收益
state/)区分开的同时,避免了拆解过细引入循环依赖的潜在风险。app,tui)因为误用旧的静态 Default 方法而获得错误的未就绪配置。