Skip to content

refactor(mcp): trait-ize remaining inline crate:: calls in repo.rs#14

Merged
juice094 merged 2 commits into
mainfrom
refactor/mcp-trait-decouple
May 11, 2026
Merged

refactor(mcp): trait-ize remaining inline crate:: calls in repo.rs#14
juice094 merged 2 commits into
mainfrom
refactor/mcp-trait-decouple

Conversation

@juice094
Copy link
Copy Markdown
Owner

Summary

完成 Phase A MCP trait 化收尾:将 repo.rs 中剩余 4 个内联 crate:: 调用全部抽象为 trait,消除模块间硬编码耦合。

Changes

  • 新增 trait (clients.rs)
    • SearchClient: index_is_empty_at, search_repos_at
    • RepoAnalyzer: compute_workspace_hash, analyze_repo
  • 无状态实现
    • search.rsSearchClientImpl
    • health.rsRepoAnalyzerImpl
  • 重构调用点 (repo.rs)
    • DevkitQueryReposTool / DevkitNaturalLanguageQueryTool 改用 trait
    • 删除 nl_filter_repos,改为通过 ctx.storage.index_path() 获取路径
    • nl_filter_repos_at / apply_nl_filters / analyze_repo_for_repo 泛型化
  • 测试同步 (mcp/tests.rs)

Verification

  • cargo check / cargo fmt / cargo clippy -W warnings
  • 427 tests all pass ✅

juice094 added 2 commits May 11, 2026 19:53
- Add SearchClient trait (index_is_empty_at, search_repos_at)
- Add RepoAnalyzer trait (compute_workspace_hash, analyze_repo)
- Provide SearchClientImpl in search.rs and RepoAnalyzerImpl in health.rs
- Remove nl_filter_repos (eliminated DefaultStorageBackend inline call)
- Convert nl_filter_repos_at, apply_nl_filters, analyze_repo_for_repo to generic over traits
- Update DevkitQueryReposTool and DevkitNaturalLanguageQueryTool to use trait impls
- Sync mcp/tests.rs callers to new generic signatures
- Result: repo.rs crate:: references reduced to 8 use-statements, 0 inline calls
@juice094 juice094 merged commit 835a555 into main May 11, 2026
6 checks passed
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