Skip to content

Conversation

@uinstinct
Copy link
Contributor

@uinstinct uinstinct commented Nov 6, 2025

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

  • Team members only: AI review runs automatically when PR is opened or marked ready for review
  • Team members can also trigger a review by commenting @continue-review

Checklist

  • [] I've read the contributing guide
  • [] The relevant docs, if any, have been updated or created
  • [] The relevant tests, if any, have been updated or created

Screen recording or screenshot

before

image

after

image

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.

  • New Features
    • Automatically falls back to grep (Unix) or findstr (Windows) if ripgrep is missing.
    • Parses .gitignore; applies excludes with ripgrep and grep on Unix (findstr cannot apply ignores).
    • Keeps file_pattern filtering for targeted searches.
    • Updates messages to surface warnings and use a unified “Error executing search” on failure.

Written for commit 57a7e59. Summary will update automatically on new commits.

@uinstinct uinstinct requested a review from a team as a code owner November 6, 2025 14:16
@uinstinct uinstinct requested review from sestinj and removed request for a team November 6, 2025 14:16
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Nov 6, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a 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.

@RomneyDa
Copy link
Collaborator

See failing tests and feedback

@uinstinct uinstinct requested a review from RomneyDa November 24, 2025 13:58
RomneyDa
RomneyDa previously approved these changes Nov 25, 2025
Copy link
Collaborator

@RomneyDa RomneyDa left a 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

@github-project-automation github-project-automation bot moved this from Todo to In Progress in Issues and PRs Nov 25, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Nov 25, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a 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

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a 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

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a 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
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Nov 26, 2025

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 &quot;./types.js&quot;;
-      ignorePatterns.push(line);
-    }
+    if (line.startsWith(&quot;#&quot;) || line === &quot;&quot;) continue; // ignore comments and empty line
+    if (line.startsWith(&quot;!&quot;)) continue; // ignore negated ignores
+    ignorePatterns.push(line);
   }
</file context>
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants