fix(search): resolve index root from search path, not cwd#106
Merged
Conversation
When --cwd and --path were both provided, the CLI search command blindly used cwd as the index root. If the actual index lived at the subproject's git root (not cwd), the search opened an empty/wrong DB and returned no results. Extract resolveIndexRoot() as shared path resolution logic that: - Resolves the index root from the search path (git root → ancestor index) - Only adopts cwd as index root when an index already exists there - Resolves symlinks to avoid macOS /var vs /private/var mismatches Also adds a 20s search timeout to the CLI, matching the MCP handler. Closes #97 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
--cwdis specified #97:lumen searchwith--cwd+--pathreturned no results because the CLI blindly usedcwdas the index root, opening the wrong DBresolveIndexRoot()as shared path resolution logic that resolves from the search path (git root → ancestor index → cwd-if-indexed), matching the MCP handler's behaviordefaultSearchTimeoutRoot Cause
When both
--cwd /projectand--path /project/sub-project-awere provided, the old code setindexRoot = cwddirectly. If/projecthad no index (the real index lived atsub-project-a's git root), the CLI opened an empty DB and found nothing.The MCP handler (
getOrCreate) already handles this correctly by only adoptingcwdas preferred root when an index exists there. The CLI had diverged from this logic.Test plan
TestResolveIndexRoot— 6 cases covering git root, non-git, cwd+path (the Search returns no results when--cwdis specified #97 scenario), cwd-with-index, cwd-without-index, ancestor walkcmd/tests passgolangci-lint run— 0 issues🤖 Generated with Claude Code