Skip to content

Add tool for searching a regex pattern in a single file or across a specified list of files (with structured/truncated output) #29

@eh-main-bot

Description

@eh-main-bot

Currently, text search functionality is oriented toward searching across all files or a broad set of files. There is a need for a targeted tool that:

  • Efficiently searches for a given regex pattern in a single specified file.
  • Supports searching for the same regex pattern across a user-provided list of files (not the entire repo or directory tree).
  • Returns detailed match information (file, line number, match context, etc.).
  • Handles exceptions for invalid regex or file issues (missing, unreadable, etc.).
  • Optionally supports context lines around matches.
  • Follows the existing tool conventions: supports a max characters output limit and returns a structured response object that indicates whether output was truncated, how many characters were returned, and other relevant metadata.

Potential Benefits:

  • Allows more focused and faster searches when the user knows the relevant file(s).
  • Reduces unnecessary IO and improves performance for targeted queries.
  • Consistent interface and output structure with other search tools.

Acceptance Criteria:

  • New tool can search a regex in a single file and/or a provided list of files.
  • Handles all edge cases for missing or invalid files and regex errors.
  • Outputs match metadata (file, line, context).
  • Optionally supports context lines in output.
  • Accepts and applies a maximum character output limit.
  • Returns a response structure indicating if the output was truncated, how many characters were returned, and other relevant metadata, matching conventions of existing search tools.

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions