-
Notifications
You must be signed in to change notification settings - Fork 3.8k
feat(cli): add grep/find/findstr as alternative search strategy #8616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 1 file
Prompt for AI agents (all 1 issues)
Understand the root cause of the following 1 issues and fix them.
<file name="extensions/cli/src/tools/searchCode.ts">
<violation number="1" location="extensions/cli/src/tools/searchCode.ts:75">
The fallback search uses `find -name` with the provided file pattern, but `-name` only matches the basename, so patterns with directories like `src/**/*.ts` stop working when falling back from ripgrep. Please switch to a path-aware match (e.g. `find … -path …`) to keep file filters consistent regardless of backend.</violation>
</file>
React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.
|
See failing tests and feedback |
RomneyDa
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just remove ripgrep use entirely? Is ripgrep markedly better than these alternatives? Either way looks good for now
…instinct/cli-search-alternative
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 issues found across 3 files
Prompt for AI agents (all 2 issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="extensions/cli/src/tools/searchCode.ts">
<violation number="1" location="extensions/cli/src/tools/searchCode.ts:20">
Negated `.gitignore` entries (`!pattern`) are dropped, which causes files that Git explicitly re-includes to remain excluded from search, hiding legitimate matches.</violation>
<violation number="2" location="extensions/cli/src/tools/searchCode.ts:75">
The grep fallback ignores `.gitignore` exclusions whenever `file_pattern` is used because `find | xargs` passes explicit files and `--exclude-dir` no longer filters them, so ignored directories (e.g., `node_modules/`) are searched again.</violation>
</file>
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 3 files
Prompt for AI agents (all 1 issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="extensions/cli/src/tools/searchCode.ts">
<violation number="1" location="extensions/cli/src/tools/searchCode.ts:86">
Negated .gitignore patterns are treated as `--include` filters in the grep fallback, which causes searches to only scan those negated files (e.g., repos with `!.gitignore` will only search `.gitignore`). Remove the include to avoid filtering away the rest of the codebase.</violation>
</file>
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
This reverts commit 53e16aa.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 1 file (reviewed changes from recent commits).
Prompt for AI agents (all 1 issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="extensions/cli/src/tools/searchCode.ts">
<violation number="1" location="extensions/cli/src/tools/searchCode.ts:20">
Negated entries in .gitignore are now ignored entirely, so files explicitly re-included with `!pattern` are still excluded from both ripgrep and grep/findstr searches, breaking expected .gitignore override behavior.</violation>
</file>
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
| for (let line of content.trim().split("\n")) { | ||
| line = line.trim(); | ||
| if (line.startsWith("#") || line === "") continue; // ignore comments and empty line | ||
| if (line.startsWith("!")) continue; // ignore negated ignores |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Negated entries in .gitignore are now ignored entirely, so files explicitly re-included with !pattern are still excluded from both ripgrep and grep/findstr searches, breaking expected .gitignore override behavior.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At extensions/cli/src/tools/searchCode.ts, line 20:
<comment>Negated entries in .gitignore are now ignored entirely, so files explicitly re-included with `!pattern` are still excluded from both ripgrep and grep/findstr searches, breaking expected .gitignore override behavior.</comment>
<file context>
@@ -9,25 +9,18 @@ import { Tool } from "./types.js";
- ignorePatterns.push(line);
- }
+ if (line.startsWith("#") || line === "") continue; // ignore comments and empty line
+ if (line.startsWith("!")) continue; // ignore negated ignores
+ ignorePatterns.push(line);
}
</file context>
Description
Search tool on cn relies on ripgrep for searching inside files which is often not present in the running system. This leads to the model using alternative approaches which might skip search for files altogether. This PR adds grep/find utility for linux and findstr for windows.
AI Code Review
@continue-reviewChecklist
Screen recording or screenshot
before
after
Tests
[ What tests were added or updated to ensure the changes work as expected? ]
Summary by cubic
Add a cross-platform fallback for CLI code search: use grep on Unix and findstr on Windows when ripgrep isn’t available. Improves reliability on systems without ripgrep and respects .gitignore excludes where supported.
Written for commit 57a7e59. Summary will update automatically on new commits.