fix(explore): search file content instead of filename for similar code #21
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.
π Bug
explore similarwas searching the filename as text instead of reading and searching the file's content embeddings.$ dev explore similar coordinator.ts β No similar code found # Searched "coordinator.ts" as text ββ Fix
Read file content and search its embeddings for semantic similarity.
π Changes
1. Extracted File Utilities (
cli/src/utils/file.ts)Pure, testable functions:
resolveFilePath: Resolve paths relative to repo rootnormalizeFilePath: Create relative pathsreadFileContent: Read and validate file contentprepareFileForSearch: Prepare file for similarity search2. 100% Test Coverage (
cli/src/utils/file.test.ts)22 unit tests covering:
3. Refactored
explore similar--thresholdoption (default: 0.5)π§ͺ Verification
Before:
After:
Tests:
$ pnpm test packages/cli/src/utils/file.test.ts β 22 tests passing βπ Stats
π Impact
Users can now find semantically similar code based on actual file content, not filenames. Feature works as intended!