Skip to content

fix(search): resolve index root from search path, not cwd#106

Merged
aeneasr merged 1 commit intomainfrom
fix/search-cwd-resolution
Apr 7, 2026
Merged

fix(search): resolve index root from search path, not cwd#106
aeneasr merged 1 commit intomainfrom
fix/search-cwd-resolution

Conversation

@aeneasr
Copy link
Copy Markdown
Member

@aeneasr aeneasr commented Apr 7, 2026

Summary

  • Fixes Search returns no results when --cwd is specified #97: lumen search with --cwd + --path returned no results because the CLI blindly used cwd as the index root, opening the wrong DB
  • Extracts resolveIndexRoot() as shared path resolution logic that resolves from the search path (git root → ancestor index → cwd-if-indexed), matching the MCP handler's behavior
  • Adds 20s search timeout to CLI search, matching the MCP handler's defaultSearchTimeout

Root Cause

When both --cwd /project and --path /project/sub-project-a were provided, the old code set indexRoot = cwd directly. If /project had no index (the real index lived at sub-project-a's git root), the CLI opened an empty DB and found nothing.

The MCP handler (getOrCreate) already handles this correctly by only adopting cwd as preferred root when an index exists there. The CLI had diverged from this logic.

Test plan

🤖 Generated with Claude Code

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>
@aeneasr aeneasr merged commit 47cb457 into main Apr 7, 2026
4 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.

Search returns no results when --cwd is specified

1 participant