Search file contents by regex pattern across the project.
ALWAYS use `grep` instead of `bash` with grep/rg.
Supports full regex syntax (e.g. "log.*Error", "function\\s+\\w+").

Parameters:
- pattern (required): regex or literal string to search for
- path (optional): file or directory to search in (default: cwd). Use this to search within a specific file or subdirectory.
- output_mode (optional): "content" (matching lines with line numbers), "files" (file paths only, default), "count" (match counts per file)
- type (optional): file type filter — js, ts, py, go, rs, etc. More efficient than glob for standard types.
- glob (optional): glob filter — "*.mjs", "src/**/*.ts"
- context (optional): lines of context around each match (-C)
- before_context (optional): lines before each match (-B)
- after_context (optional): lines after each match (-A)
- ignoreCase (optional): case-insensitive search
- maxCount (optional): max matches per file
- multiline (optional): enable cross-line matching. By default patterns match within single lines only. Use for patterns like "struct \\{[\\s\\S]*?field" that span multiple lines.
- head_limit (optional): limit output to first N lines/entries. Works across all output modes.
- offset (optional): skip first N lines/entries before applying head_limit. Combine with head_limit for paginated browsing.

## When NOT to Use
- Do NOT use grep to find files by *name* — use `glob` for that.
- Do NOT use grep to read a whole file — use `read` instead.
- Do NOT use grep when you already know the exact file and line — use `read` with offset/limit.
- For open-ended exploration requiring multiple search rounds, use `task` with explore subagent.

Tips:
- Use `path` to search within a specific file: grep pattern="TODO" path="src/main.mjs"
- Use `path` to search a directory: grep pattern="import" path="src/utils/"
- Use output_mode "files" for quick file discovery, "content" for understanding code
- Use multiline to match patterns spanning multiple lines
- Combine head_limit + offset for paginated browsing of large result sets:
  <example>
  # Page 1: first 20 matches
  grep pattern="TODO" output_mode="content" head_limit=20
  # Page 2: next 20 matches
  grep pattern="TODO" output_mode="content" head_limit=20 offset=20
  </example>
- Pattern syntax uses ripgrep — literal braces need escaping (use "interface\\{\\}" to find "interface{}" in Go)

## Using grep with patch/edit:
- Use output_mode="content" to see line numbers alongside matches.
- Line numbers from grep correspond directly to `read` (offset/limit) and `patch` (start_line/end_line).
- Workflow: grep to find location → read surrounding context → patch or edit the section.