fix(mcp): preserve multi_grep constraints and OR results - #739
fix(mcp): preserve multi_grep constraints and OR results#739Kh05ifr4nD wants to merge 2 commits into
Conversation
| let parsed_constraints = parser.parse(constraint_query); | ||
| let constraints = parsed_constraints.constraints.as_slice(); | ||
| if !is_multi_cursor { | ||
| let parsed_constraints = parser.parse_constraints(&constraint_query); |
There was a problem hiding this comment.
I am not sure this whole situation with demote_lone_constraints is needed cause we never ever want to consider a pattern AI submits to the query field as a constraint, please remove this
| ..fallback_options | ||
| let mut cursor = multi_cursor | ||
| .unwrap_or_else(|| MultiGrepCursor::new(patterns.clone(), constraint_query.clone())); | ||
| let (fallback_options, _) = make_grep_options(output_mode, GrepMode::PlainText, 0, context); |
There was a problem hiding this comment.
I don't think we do have correct support for fallbacks for multi grep
| ], | ||
| ); | ||
| let cases = [ | ||
| ( |
There was a problem hiding this comment.
make a struct for every case so it is more readable
| use super::*; | ||
| use std::fs; | ||
| use std::sync::atomic::Ordering; | ||
| use tempfile::TempDir; |
There was a problem hiding this comment.
we already have a tempdir depenency no need in tempfile
| /// Parse a query supplied as an independent set of search constraints. | ||
| /// Unlike ordinary single-token search, a lone path or filename remains a | ||
| /// constraint instead of being promoted to fuzzy text. | ||
| pub fn parse_constraints<'a>(&self, query: &'a str) -> FFFQuery<'a> { |
There was a problem hiding this comment.
I think this should be solved at the configuration level rather than as a boolean flag or maybe not, but i don't like this separation via flag
|
Superseded by #753. The replacement handles the standalone constraint field directly and removes the unsupported fallback. |
Closes #738
Root cause
multi_grepreceivesconstraintsseparately frompatterns, but the MCP implementation parsed a standalone positive path token with the single-token query path. That dropped positive directory and exact-file constraints. Its fallback also returned after the first pattern, so OR queries lost later pattern results.Fix
parse_constraintsparser entry point for independently supplied constraints. Ordinaryparsesemantics remain unchanged, while standalone paths and exact filenames stay constraints instead of becoming fuzzy text.Verification
nix develop --command cargo test --workspacenix develop --command cargo clippy -p fff-query-parser -p fff-mcp --all-targets -- -D warningsnix develop --command cargo fmt --all -- --checknix develop --command cargo build -p fff-mcp --releasefiles_with_matchesdeduplication, and all output modes.All checks passed on commit
affbdaadd640387a3e4976faaba75c1c88efe923.