feat(config): add multi doc-root support#27
Merged
Conversation
- Add DocRootEntry and ResolvedDocRoot types to config - Add DocConfig::resolved_docs_roots() with priority chain: DOCS_ROOT env > docs_root field > [[docs_roots]] vec > default - DocRootEntry supports per-root embedding override (embed-candle) - tool_list_projects_multi: aggregate projects across all roots with root field - tool_search_global_multi: Rayon parallel search across indexed roots - tool_list_projects: delegates to multi variant, strips root field for compat - mcp.rs: resolve all_roots via resolved_docs_roots(), route list_projects and global search to multi-root variants; resolve_project iterates all roots - Global grep fallback iterates all roots until results found - Full backward compat: DOCS_ROOT env and single docs_root field unchanged - 454 tests pass, 0 clippy warnings
- Fix misleading comment in resolved_docs_roots() priority chain - Add failure logging when per-root index search fails (eprintln) - Add intent comment for grep fallback (first-match, not cross-root merge) - Add CWD cross-validation to prevent wrong root selection on name clash - Harden DocRootEntry.expand_path with canonicalize + blocked path check
- Canonicalize DOCS_ROOT env var and legacy docs_root field for consistency with expand_path() in docs_roots entries (security: defense-in-depth) - Fix misleading doc comment on tool_search_global_multi (Rayon always available) - Add WalkDir max_depth(5) in tool_list_projects_multi (performance) - Add ambiguity warning when MCP_PROJECT_NAME matches multiple roots - Derive Clone on ResolvedProject for multi-root scan - Update tests to use non-blocked paths and canonicalize-aware assertions
- Use actual query string in grep no-match response instead of empty string - Log read_dir failures in tool_list_projects_multi for debugging
- Replace Value mutation in tool_list_projects with shared list_projects_impl using include_root flag, avoiding serde_json round-trip overhead - Merge grep fallback results from all roots instead of returning only the first root with matches, ensuring comprehensive cross-root coverage - Parallelize rebuild_index across roots using rayon::par_iter - Remove unnecessary #[derive(Clone)] from ResolvedProject (move suffices)
- validate DOCS_ROOT and docs_root paths with is_dir() before accepting - improve tool_search_global_multi error message with root count - raise WalkDir max_depth from 5 to 10 for deeper doc trees - document build_index thread safety at parallel rebuild site - replace manual remove_dir_all with RAII TempDir guard in tests
…h sources, remove duplicate test - mcp.rs: fix ambiguous_env logic — was checking found.is_some() before storing the first match, so ambiguity was never detected; restructured loop to store first env match then flag on second match - config.rs: extract expand_tilde() helper; apply tilde expansion to DOCS_ROOT env var and docs_root field (previously only DocRootEntry used expand_path() which handled ~/); fixes silent failure on paths like '~/.alcove/docs' - config.rs: remove resolved_docs_roots_legacy_takes_precedence_over_vec test (duplicate of the precedence check already in resolved_docs_roots_uses_docs_roots_vec) - config.rs: add resolved_docs_roots_expands_tilde_in_docs_root test - config.rs: add resolved_docs_roots_blocked_docs_root_skips_to_fallback test
Rebase onto main introduced a stale inline resolve loop (is_global guard and a second let (docs_root, resolved) block) that was already superseded by resolve_project_multi(). Remove both dead code sections; cargo check confirms no remaining compile errors.
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.
Summary
docs_roots배열을 통해 다중 doc-root를 지원합니다. 기존docs_root단일 필드는 후방 호환으로 유지됩니다.Changes
src/config.rs:DocRootEntry,ResolvedDocRoot,resolved_docs_roots()추가src/mcp.rs:resolve_project_multi(),ok_with_root!매크로로 다중 루트 처리src/tools.rs:list_projects_impl,tool_search_global_multi다중 루트 지원Config Example
Notes
DOCS_ROOT환경변수 >docs_root>docs_roots우선순위 유지