diff --git a/README.md b/README.md index 32afdca..8a12c26 100644 --- a/README.md +++ b/README.md @@ -283,7 +283,7 @@ Search for text patterns in files using ripgrep. - `file_types`: File types to search (e.g., ["go", "ts", "py"]) - `ignore_case`: Case insensitive search - `regex`: Treat pattern as regex (default: true) -- `context_lines`: Number of context lines around matches (default: 2) +- `context_lines`: Number of context lines around matches (default: 0) - `max_results`: Maximum number of results to return --- @@ -352,7 +352,7 @@ Search for AST patterns in code files using structural pattern matching. - `name_matches`: Regex pattern to filter by name - `name_exact`: Exact name to match - `kind_in`: Node types to match (e.g., function_declaration) -- `max_results`: Maximum number of results (default: 100) +- `max_results`: Maximum number of results (default: 50) **Examples**: ```json diff --git a/docs/API.md b/docs/API.md index 38561fb..2ffbd7b 100644 --- a/docs/API.md +++ b/docs/API.md @@ -70,7 +70,7 @@ Search for text patterns in files using ripgrep. Supports regex patterns, file t | `file_types` | `array[string]` | No | File types to search (e.g., ['go', 'ts', 'py']) | | `ignore_case` | `boolean` | No | Case insensitive search | | `regex` | `boolean` | No | Treat pattern as regex (default: true) | -| `context_lines` | `number` | No | Number of context lines around matches (default: 2) | +| `context_lines` | `number` | No | Number of context lines around matches (default: 0) | | `max_results` | `number` | No | Maximum number of results to return | **Examples:** @@ -153,7 +153,7 @@ Search for AST patterns in code files. Use code patterns with $VAR placeholders | `name_matches` | `string` | No | Regex pattern to filter by name | | `name_exact` | `string` | No | Exact name to match | | `kind_in` | `array[string]` | No | Node types to match (e.g., function_declaration, class_declaration) | -| `max_results` | `number` | No | Maximum number of results to return (default: 100) | +| `max_results` | `number` | No | Maximum number of results to return (default: 50) | **Examples:** diff --git a/internal/config/config.go b/internal/config/config.go index 311a69b..cb35da9 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -33,7 +33,7 @@ const ( DefaultSearchTimeout = 30 * time.Second DefaultMaxFileSize = 10 * 1024 * 1024 // 10 MB DefaultMaxParseSize = 10 * 1024 * 1024 // 10 MB - DefaultMaxSearchResults = 1000 + DefaultMaxSearchResults = 50 DefaultMaxEditSize = 100 * 1024 // 100 KB DefaultResourceLinkThresholdBytes = 64 * 1024 // 64 KiB ) diff --git a/internal/query/query.go b/internal/query/query.go index 20b4188..bc51897 100644 --- a/internal/query/query.go +++ b/internal/query/query.go @@ -509,11 +509,15 @@ func formatResults(results []MatchResult, maxResults int, format string, offset case "compact": for i := 0; i < renderCount; i++ { r := results[i] + firstLine := firstLineOf(r.Text, 80) + if !verbose { + fmt.Fprintf(&sb, "%s:%d %s\n", r.File, r.Location.Line, firstLine) + continue + } nodeType := "unknown" if r.Node != nil { nodeType = r.Node.Type() } - firstLine := firstLineOf(r.Text, 80) fmt.Fprintf(&sb, "%s:%d (%s) %s\n", r.File, r.Location.Line, nodeType, firstLine) } diff --git a/internal/server/handlers_ast.go b/internal/server/handlers_ast.go index 52e37ec..236ab5b 100644 --- a/internal/server/handlers_ast.go +++ b/internal/server/handlers_ast.go @@ -60,7 +60,7 @@ func (s *Server) resolveASTQueryParams(request mcp.CallToolRequest) (*astQueryPa prefsMaxResults = sp.DefaultMaxResults prefsFormat = sp.ASTQueryFormat } - p.maxResults = effectiveInt(request, "max_results", prefsMaxResults, 100) + p.maxResults = effectiveInt(request, "max_results", prefsMaxResults, 50) p.format = request.GetString("format", "") if p.format == "" { diff --git a/internal/server/handlers_file.go b/internal/server/handlers_file.go index cf3f2ea..1a4bf06 100644 --- a/internal/server/handlers_file.go +++ b/internal/server/handlers_file.go @@ -51,7 +51,7 @@ func (s *Server) handleFileSearch(ctx context.Context, request mcp.CallToolReque fileTypes := request.GetStringSlice("file_types", nil) ignoreCase := request.GetBool("ignore_case", false) regex := request.GetBool("regex", true) - contextLines := request.GetInt("context_lines", 2) + contextLines := request.GetInt("context_lines", 0) // Consult session prefs for max_results and cluster when not explicitly supplied. prefs := s.sessionPrefs.Load() diff --git a/internal/server/help_content.go b/internal/server/help_content.go index 33ddc7c..f452c92 100644 --- a/internal/server/help_content.go +++ b/internal/server/help_content.go @@ -49,7 +49,7 @@ const helpFileSearch = "# file_search — flags and examples\n\n" + "| `cluster=true` | Coalesce consecutive match lines into ranges (`L12-14│ text`). Drops context lines for density. |\n" + "| `cursor` | Opaque pagination token from a previous truncated response — fetches next page. |\n" + "| `max_results` | Page size for pagination. Re-run with `cursor` to get next page. |\n" + - "| `context_lines` | Number of context lines around matches (default: 2). |\n" + + "| `context_lines` | Number of context lines around matches (default: 0). |\n" + "| `ignore_case` | Case-insensitive search. |\n" + "| `regex` | Treat pattern as regex (default: true). |\n" + "| `file_types` | Restrict to file extensions, e.g. `[\"go\", \"ts\"]`. |\n" + @@ -77,7 +77,7 @@ const helpASTQuery = "# ast_query — flags and examples\n\n" + "| `verbose=true` | Emit `Found N match(es):` preamble (v1 behaviour). Default: false. |\n" + "| `format` | `compact` (default, one line per match) \\| `verbose` (full code+captures) \\| `location` (file:line only) |\n" + "| `cursor` | Opaque pagination token from a previous truncated response — fetches next page. |\n" + - "| `max_results` | Page size (default: 100). |\n" + + "| `max_results` | Page size (default: 50). |\n" + "| `name_exact` | Exact symbol name to match. |\n" + "| `name_matches` | Regex pattern to filter by name. |\n" + "| `kind_in` | Node types to match (e.g. `function_declaration`, `class_declaration`). |\n" + diff --git a/internal/server/server.go b/internal/server/server.go index dbbde9d..51897ec 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -136,7 +136,7 @@ func (s *Server) registerTools() { mcp.Description("Treat pattern as regex (default: true)"), ), mcp.WithNumber("context_lines", - mcp.Description("Number of context lines around matches (default: 2)"), + mcp.Description("Number of context lines around matches (default: 0)"), ), mcp.WithNumber("max_results", mcp.Description("Maximum number of results to return (page size for pagination)"), @@ -252,7 +252,7 @@ func (s *Server) registerTools() { mcp.WithStringItems(), ), mcp.WithNumber("max_results", - mcp.Description("Maximum number of results to return (default: 100, page size for pagination)"), + mcp.Description("Maximum number of results to return (default: 50, page size for pagination)"), ), mcp.WithString("format", mcp.Description("Output format: \"compact\" (default, one line per match), \"verbose\" (full code+captures), \"location\" (file:line only)"),