Summary
find_in_file (DbReader.FilesStatus.cs:~10, exposed via the MCP tool of the same name and the CLI command) is documented as searching for a "pattern" but actually accepts only literal substrings — internally IndexOf with StringComparison. Users who pass regex anchors (^foo, bar$), word boundaries (\bfoo\b), or multiline patterns get silent zero-result responses without any diagnostic that the input was treated as a literal string. AI agents in particular will repeatedly try regex variants and never see an error explaining why nothing matched.
Where
Suggested approach
(1) Document explicitly in the tool description and --help: "literal substring match; regex is not supported." (2) Add an opt-in regex=true parameter to both the CLI and MCP tool; implement with Regex compiled lazily and a configurable timeout (default 500 ms) to prevent ReDoS. (3) When regex=true and the pattern fails to compile, return a structured error with the compilation message and the offending sub-expression. (4) When regex=false but the query contains regex-suspicious characters (^, $, [, \b), emit a one-line hint to stderr suggesting regex=true. (5) Add regression tests covering literal-match (current), valid regex, invalid regex, regex with ReDoS-prone backtracking. (6) Cross-link with #1593, #1414, #1597.
Summary
find_in_file(DbReader.FilesStatus.cs:~10, exposed via the MCP tool of the same name and the CLI command) is documented as searching for a "pattern" but actually accepts only literal substrings — internallyIndexOfwithStringComparison. Users who pass regex anchors (^foo,bar$), word boundaries (\bfoo\b), or multiline patterns get silent zero-result responses without any diagnostic that the input was treated as a literal string. AI agents in particular will repeatedly try regex variants and never see an error explaining why nothing matched.Where
src/CodeIndex/Database/DbReader.FilesStatus.cs:~10(FindInFiles implementation)src/CodeIndex/Mcp/McpToolDefinitions.cs(find_in_file tool schema)Suggested approach
(1) Document explicitly in the tool description and
--help: "literal substring match; regex is not supported." (2) Add an opt-inregex=trueparameter to both the CLI and MCP tool; implement withRegexcompiled lazily and a configurable timeout (default 500 ms) to prevent ReDoS. (3) Whenregex=trueand the pattern fails to compile, return a structured error with the compilation message and the offending sub-expression. (4) Whenregex=falsebut the query contains regex-suspicious characters (^,$,[,\b), emit a one-line hint to stderr suggestingregex=true. (5) Add regression tests covering literal-match (current), valid regex, invalid regex, regex with ReDoS-prone backtracking. (6) Cross-link with #1593, #1414, #1597.