Skip to content

fix(sandbox): GNU grep fallback when ripgrep is unavailable#3571

Open
guitavano wants to merge 1 commit into
mainfrom
fix/sandbox-grep-gnu-fallback
Open

fix(sandbox): GNU grep fallback when ripgrep is unavailable#3571
guitavano wants to merge 1 commit into
mainfrom
fix/sandbox-grep-gnu-fallback

Conversation

@guitavano
Copy link
Copy Markdown
Contributor

@guitavano guitavano commented May 29, 2026

Summary

  • Adds a GNU grep fallback for the sandbox grep tool when rg is not on PATH (common in user-desktop dev), while keeping ripgrep as the preferred backend in Docker/K8s sandboxes.
  • Normalizes grep output for all backends: repo-relative paths, accurate matchCount when context is set, and friendly 400 errors for invalid regex.
  • Expands brace globs ({ts,tsx}) and line-start patterns for the GNU grep path.

Test plan

  • bun test packages/sandbox/daemon/routes/grep-search.test.ts
  • bun test packages/sandbox/daemon/routes/fs.test.ts
  • Manual grep tool checks: content/files/count modes, context, case-insensitive, brace globs, invalid regex
  • Verified prod sandbox (ripgrep present) behavior unchanged

Made with Cursor


Summary by cubic

Adds a GNU grep fallback for the sandbox search tool when rg isn’t available, while keeping ripgrep preferred. Normalizes output across backends with repo-relative paths and accurate match counts.

  • Bug Fixes

    • Fallback to GNU grep when rg is missing; supports brace globs and line-start patterns.
    • Normalize results: repo-relative paths and matchCount excludes context lines.
    • Return 400 with clear message for invalid regex.
  • Refactors

    • Extracted grep handler to packages/sandbox/daemon/routes/grep-search.ts; fs.ts re-exports makeGrepHandler.
    • Expanded tests to cover both backends, glob handling, and error cases.
    • Updated Decopilot tool description to reflect backend preference.

Written for commit 956f438. Summary will update on new commits.

Review in cubic

When ripgrep is unavailable (e.g. user-desktop dev on macOS), fall back to GNU grep with brace glob expansion and friendlier regex errors. Normalize paths to repo-relative and count real matches when context lines are included.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions
Copy link
Copy Markdown
Contributor

🧪 Benchmark

Should we run the Virtual MCP strategy benchmark for this PR?

React with 👍 to run the benchmark.

Reaction Action
👍 Run quick benchmark (10 & 128 tools)

Benchmark will run on the next push after you react.

@github-actions
Copy link
Copy Markdown
Contributor

Release Options

Suggested: Patch (2.371.2) — based on fix: prefix

React with an emoji to override the release type:

Reaction Type Next Version
👍 Prerelease 2.371.2-alpha.1
🎉 Patch 2.371.2
❤️ Minor 2.372.0
🚀 Major 3.0.0

Current version: 2.371.1

Note: If multiple reactions exist, the smallest bump wins. If no reactions, the suggested bump is used (default: patch).

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.

1 participant