feat: search --json, glob --file, prune --exclude, vitest worktree exclusion#88
Conversation
…worktrees from vitest Four CLI improvements from dogfooding feedback: - search command: add --json flag for machine-readable output (single + multi-query) - search --file: support glob patterns (e.g. src/*.js) alongside existing substring matching - registry prune: add --exclude flag to protect specific repos from pruning - vitest.config.js: exclude .claude/** to prevent worktree test files from interfering Impact: 6 functions changed, 10 affected
|
Claude finished @carlos-alm's task —— View job PR Review: CLI Improvements (search --json, glob --file, prune --exclude, vitest worktree exclusion)Todo List
Root Cause AnalysisProblem Being Solved: Four independent CLI usability improvements based on dogfooding feedback:
Why This Approach: All changes are straightforward, additive improvements that maintain backward compatibility. No rules are being relaxed or errors silenced—these are legitimate feature additions. Risk Assessment: ✅ LOW RISK - No configuration relaxation, no test weakening, clear justification for each change. Configuration Change Analysis✅ vitest.config.js - The
No other configuration changes detected. Test Integrity Assessment✅ Strong test coverage - 7 new tests added across 2 test files:
✅ Test quality:
Code Quality Analysissrc/cli.js (search --json addition)✅ Minimal, correct implementation:
src/embedder.js (JSON support and glob patterns)✅ Well-implemented features:
src/registry.js (exclude functionality)✅ Simple, effective implementation:
Test Files✅ Thorough coverage:
Potential Issues FoundMinor Issues (Not blocking):
Strengths:
Final AssessmentDeduction reasoning: -1 star for lack of input validation on glob patterns and exclude names, though these are minor issues that don't affect functionality. |
Greptile SummaryThis PR adds four independent CLI improvements based on dogfooding feedback:
The implementation is clean with proper error handling ( Confidence Score: 5/5
Important Files Changed
Last reviewed commit: ab0d3a0 |
| // Normalize separators to forward slashes | ||
| const normalized = filePath.replace(/\\/g, '/'); | ||
| // Escape regex specials except glob chars | ||
| let regex = pattern.replace(/\\/g, '/').replace(/[.+^${}()|[\]]/g, '\\$&'); |
There was a problem hiding this comment.
the character class [.+^${}()|[\]] has unconventional escaping for brackets - while it works, ] should be placed first or the opening [ should be escaped for clarity
| let regex = pattern.replace(/\\/g, '/').replace(/[.+^${}()|[\]]/g, '\\$&'); | |
| let regex = pattern.replace(/\\/g, '/').replace(/[.+^${}()|\][\]]/g, '\\$&'); |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Fixed in 6cf191f — used explicit \ and \ escaping inside the character class for clarity. Also added a try/catch fallback for malformed patterns and input sanitization on \ names.
- globMatch: use explicit \[ \] escaping in character class for clarity - globMatch: wrap RegExp in try/catch, fall back to substring on malformed patterns - pruneRegistry: sanitize excludeNames, filtering empty/non-string values Impact: 2 functions changed, 4 affected
|
Claude finished @carlos-alm's task —— View job PR Review: CLI Improvements (search --json, glob --file, prune --exclude, vitest worktree exclusion)Todo List
Root Cause AnalysisProblem Being Solved: Four independent CLI usability improvements based on dogfooding feedback:
Why This Approach: All changes are straightforward, additive improvements that maintain backward compatibility. No rules are being relaxed or errors silenced—these are legitimate feature additions. Risk Assessment: ✅ LOW RISK - No configuration relaxation, no test weakening, clear justification for each change. Configuration Change Analysis✅ vitest.config.js - The
No other configuration changes detected. Test Integrity Assessment✅ Strong test coverage - 7 new tests added across 2 test files:
✅ Test quality:
Code Quality Analysissrc/cli.js (search --json addition)✅ Minimal, correct implementation:
src/embedder.js (JSON support and glob patterns)✅ Well-implemented features:
src/registry.js (exclude functionality)✅ Simple, effective implementation:
Test Files✅ Thorough coverage:
Potential Issues FoundMinor Issues (Not blocking):
Strengths:
Final AssessmentDeduction reasoning: -1 star for the regex character class escaping issue and lack of input validation on glob patterns and exclude names, though these are minor issues that don't affect functionality. |
| params.push(opts.kind); | ||
| } | ||
| if (opts.filePattern) { | ||
| const isGlob = opts.filePattern && /[*?{[\]]/.test(opts.filePattern); |
There was a problem hiding this comment.
glob detection includes { and } but globMatch() doesn't support brace expansion - if a user passes src/{foo,bar}.js, it will be treated as a glob but won't match correctly
| const isGlob = opts.filePattern && /[*?{[\]]/.test(opts.filePattern); | |
| const isGlob = opts.filePattern && /[*?[\]]/.test(opts.filePattern); |
…etection
- Use Biome-compatible `[.+^${}()|[\]\]` escaping in globMatch instead
of the unconventional `]`-first convention that triggers
noEmptyCharacterClassInRegex
- Remove `{` from isGlob detection regex — globMatch does not support
brace expansion, so patterns like `src/{a,b}.js` would be misdetected
as globs and fail to match
Impact: 2 functions changed, 7 affected
|
Claude finished @carlos-alm's task —— View job PR Review: CLI Improvements (search --json, glob --file, prune --exclude, vitest worktree exclusion)Todo List
Root Cause AnalysisProblem Being Solved: Four independent CLI usability improvements based on dogfooding feedback:
Why This Approach: All changes are straightforward, additive improvements that maintain backward compatibility. No rules are being relaxed or errors silenced—these are legitimate feature additions. Risk Assessment: ✅ LOW RISK - No configuration relaxation, no test weakening, clear justification for each change. Configuration Change Analysis✅ vitest.config.js - The
No other configuration changes detected. Test Integrity Assessment✅ Strong test coverage - 7 new tests added across 2 test files:
✅ Test quality:
Code Quality Analysissrc/cli.js (search --json addition)✅ Minimal, correct implementation:
src/embedder.js (JSON support and glob patterns)✅ Well-implemented features:
src/registry.js (exclude functionality)✅ Simple, effective implementation:
Test Files✅ Thorough coverage:
Potential Issues FoundMinor Issues (Not blocking):
Strengths:
Final AssessmentDeduction reasoning: -1 star for lack of input validation on glob patterns and exclude names, though these are minor issues that don't affect functionality and are handled gracefully by the implementation. |
Summary
Four independent CLI improvements from dogfooding feedback (items 9.1–9.4):
search --json— Add-j, --jsonflag to the search command for machine-readable output, matching every other query command. Works with both single-query and multi-query (RRF) modes.claude/**from vitest to prevent test files inside.claude/worktrees/from being picked up and causing failuressearch --fileglob support — Support glob patterns (e.g.src/*.js,**/*.ts) insearch --filealongside existing substring matching. Glob detection is automatic based on*,?,[charactersregistry prune --exclude— Add--exclude <names>flag to protect specific repos from pruning, even with--ttl 0Test plan
npm run lintpassesnpm test— all 498 tests pass (7 new tests added)node src/cli.js search "parse" --json→ valid JSON outputnode src/cli.js search "parse" --json --file "src/*.js"→ filtered JSON resultsnode src/cli.js search "parse" --file builder→ substring still worksnode src/cli.js registry prune --ttl 0 --exclude myrepo→ myrepo survives