refactor:优化当前provider分层,让职责更清晰#130
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
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.
变更说明
本次调整围绕
internal/provider的职责边界展开,目标是解决以下三个问题:provider.Service同时承担 provider 构建、模型发现、catalog 缓存、后台刷新、provider 选择和 model 选择,职责过多。internal/provider/builtin同时处理内建 driver 注册和默认配置装配,存在职责越界。internal/provider根包混入应用服务与基础设施实现,语义层次不够清晰。调整后的原则是:
internal/provider根包只保留 Provider 契约、通用领域类型、错误和 driver 注册入口。catalog包。selection包。builtin只负责内建 driver 注册,不再负责默认配置装配。runtime只依赖 provider 构建能力,tui只依赖 provider 选择能力。主要改动
internal/provider/catalog/service.gointernal/provider/catalog/store.goprovider.Service中拆出internal/provider/catalog/service_test.go和internal/provider/catalog/store_test.gointernal/provider/selection/service.goConfigManager同步逻辑拆出internal/provider/selection/service_test.goruntime保持只依赖 provider 构建接口provider.Registry作为 runtime 的 provider 构建入口catalog.Service + selection.Service作为 TUI 的 provider 能力入口internal/provider/builtin/builtin.go中的内建 driver 注册逻辑internal/config/default_config.gointernal/config/default_config_test.gointernal/provider/service.gointernal/provider/model_catalog_store.gointernal/provider根包中的契约、错误、V2 类型和 registrydocs/provider-layering.md说明新的分层边界README.md中的 provider 结构描述与文档入口预期收益
runtime、tui、catalog 缓存三条职责线解耦,不再共同依赖一个“万能 Service”。builtin不再越界处理默认配置,装配职责回到config/app层。ProviderV2、anthropic、openai responses、gemini native等能力预留了更稳定的边界。