Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
Add project filter, route group prefixes, decorator entry points, and remove limit caps
Martin Vogel555f874622c0
diff --git a/internal/cypher/cypher_test.go b/internal/cypher/cypher_test.goindex e88f3c284..e5431079d 100644--- a/internal/cypher/cypher_test.go+++ b/internal/cypher/cypher_test.go@@ -403,9 +403,9 @@ func TestExecuteWhereRegex(t *testing.T) {if err != nil {t.Fatalf("execute: %v", err)}- // HandleOrder, ValidateOrder- if len(result.Rows) != 2 {- t.Errorf("expected 2 rows, got %d", len(result.Rows))+ // HandleOrder, ValidateOrder, SubmitOrder+ if len(result.Rows) != 3 {+ t.Errorf("expected 3 rows, got %d", len(result.Rows))}}@@ -414,7 +414,7 @@ func TestExecuteWhereStartsWith(t *testing.T) {defer s.Close()exec := &Executor{Store: s}- result, err := exec.Execute(`MATCH (f:Function) WHERE f.name STARTS WITH "Send" RETURN f.name`)+ result, err := exec.Execute(`MATCH (f:Function) WHERE f.name STARTS WITH "Submit" RETURN f.name`)if err != nil {t.Fatalf("execute: %v", err)}@@ -435,8 +435,8 @@ func TestExecuteWhereContains(t *testing.T) {if err != nil {t.Fatalf("execute: %v", err)}- if len(result.Rows) != 2 {- t.Errorf("expected 2 rows (HandleOrder, ValidateOrder), got %d", len(result.Rows))+ if len(result.Rows) != 3 {+ t.Errorf("expected 3 rows (HandleOrder, ValidateOrder, SubmitOrder), got %d", len(result.Rows))}}diff --git a/internal/httplink/httplink.go b/internal/httplink/httplink.goindex 9414dea6a..5f945e48b 100644--- a/internal/httplink/httplink.go+++ b/internal/httplink/httplink.go@@ -57,6 +57,9 @@ var (// Go gin routes: .POST("/path", .GET("/path"goRouteRe = regexp.MustCompile(`\.(GET|POST|PUT|DELETE|PATCH)\(\s*["']([^"']+)["']`)+ // Go gin group: .Group("/prefix")+ goGroupRe = regexp.MustCompile(`(\w+)\s*(?::=|=)\s*\w+\.Group\(\s*["']([^"']+)["']`)+// Express.js routes: app.get("/path", router.post("/path"expressRouteRe = regexp.MustCompile(`\w+\.(get|post|put|delete|patch)\(\s*["'` + "`" + `]([^"'` + "`" + `]+)["'` + "`" + `]`)@@ -230,14 +233,51 @@ func extractPythonRoutes(f *store.Node) []RouteHandler {}// extractGoRoutes extracts route registrations from Go source code (gin patterns).+// Resolves router group prefixes by matching variable names in Group() calls+// to the receiver of .GET/.POST calls (e.g., contracts.POST("", ...) where+// contracts := rg.Group("/contracts")).func extractGoRoutes(f *store.Node, source string) []RouteHandler {var routes []RouteHandler- matches := goRouteRe.FindAllStringSubmatch(source, -1)- for _, m := range matches {+ // Build a map of variable name → group prefix from Group() calls+ groupPrefixes := map[string]string{}+ for _, gm := range goGroupRe.FindAllStringSubmatch(source, -1) {+ varName := gm[1]+ prefix := gm[2]+ groupPrefixes[varName] = prefix+ }++ // Match route registrations and try to prepend group prefix+ lines := strings.Split(source, "\n")+ for _, line := range lines {+ rm := goRouteRe.FindStringSubmatch(line)+ if rm == nil {+ continue+ }+ method := strings.ToUpper(rm[1])+ path := rm[2]++ // Try to find the receiver variable (e.g., "contracts" in "contracts.POST")+ // by looking at what's before the .METHOD( call+ idx := strings.Index(line, "."+rm[1]+"(")+ if idx > 0 {+ prefix := strings.TrimSpace(line[:idx])+ // Take the last word (variable name)+ parts := strings.Fields(prefix)+ if len(parts) > 0 {+ receiver := parts[len(parts)-1]+ if gp, ok := groupPrefixes[receiver]; ok {+ path = strings.TrimRight(gp, "/") + "/" + strings.TrimLeft(path, "/")+ if path == "/" {+ path = gp+ }+ }+ }+ }+routes = append(routes, RouteHandler{- Path: m[2],- Method: strings.ToUpper(m[1]),+ Path: path,+ Method: method,FunctionName: f.Name,QualifiedName: f.QualifiedName,})diff --git a/internal/pipeline/pipeline.go b/internal/pipeline/pipeline.goindex 83b0de7da..11349f3ff 100644--- a/internal/pipeline/pipeline.go+++ b/internal/pipeline/pipeline.go@@ -796,6 +796,8 @@ var frameworkDecoratorPrefixes = []string{"@router.get", "@router.post", "@router.put", "@router.delete", "@router.patch","@router.route", "@router.websocket","@blueprint.", "@api.", "@ns.",+ // Python middleware and exception handlers (framework-registered)+ "@app.middleware", "@app.exception_handler", "@app.on_event",// Testing frameworks"@pytest.fixture", "@pytest.mark",// CLI frameworksdiff --git a/internal/store/search.go b/internal/store/search.goindex 5071e6ef3..3712ee203 100644--- a/internal/store/search.go+++ b/internal/store/search.go@@ -30,11 +30,10 @@ type SearchResult struct {// Search executes a parameterized search query.func (s *Store) Search(params SearchParams) ([]*SearchResult, error) {- if params.Limit <= 0 {- params.Limit = 50- }- if params.Limit > 200 {- params.Limit = 200+ // Limit=0 means no limit; use a high ceiling for SQL+ unlimited := params.Limit <= 0+ if unlimited {+ params.Limit = 100000}// Build the query dynamically with parameterized valuesdiff --git a/internal/tools/code_search.go b/internal/tools/code_search.goindex 6e58f48fd..9b6cd278b 100644--- a/internal/tools/code_search.go+++ b/internal/tools/code_search.go@@ -30,9 +30,9 @@ func (s *Server) handleSearchCode(_ context.Context, req *mcp.CallToolRequest) (}fileGlob := getStringArg(args, "file_pattern")- maxResults := getIntArg(args, "max_results", 50)- if maxResults > 200 {- maxResults = 200+ maxResults := getIntArg(args, "max_results", 0)+ if maxResults <= 0 {+ maxResults = 100000 // no limit}isRegex := falsediff --git a/internal/tools/search.go b/internal/tools/search.goindex e21a009a6..04e98bd38 100644--- a/internal/tools/search.go+++ b/internal/tools/search.go@@ -22,10 +22,12 @@ func (s *Server) handleSearchGraph(_ context.Context, req *mcp.CallToolRequest)Direction: getStringArg(args, "direction"),MinDegree: getIntArg(args, "min_degree", -1),MaxDegree: getIntArg(args, "max_degree", -1),- Limit: getIntArg(args, "limit", 50),+ Limit: getIntArg(args, "limit", 0), // 0 = no limitExcludeEntryPoints: getBoolArg(args, "exclude_entry_points"),}+ projectFilter := getStringArg(args, "project")+projects, err := s.store.ListProjects()if err != nil {return errResult(fmt.Sprintf("list projects: %v", err)), nil@@ -38,7 +40,7 @@ func (s *Server) handleSearchGraph(_ context.Context, req *mcp.CallToolRequest)}), nil}- // Search across all projects, collect results+ // Search across matching projects, collect resultstype resultEntry struct {Project string `json:"project"`Name string `json:"name"`@@ -54,6 +56,9 @@ func (s *Server) handleSearchGraph(_ context.Context, req *mcp.CallToolRequest)var allResults []resultEntryfor _, p := range projects {+ if projectFilter != "" && p.Name != projectFilter {+ continue+ }params.Project = p.Nameresults, searchErr := s.store.Search(params)if searchErr != nil {diff --git a/internal/tools/tools.go b/internal/tools/tools.goindex 6a84dcc50..9b0ca0766 100644--- a/internal/tools/tools.go+++ b/internal/tools/tools.go@@ -102,13 +102,17 @@ func (s *Server) registerTools() {// 5. search_graphs.mcp.AddTool(&mcp.Tool{Name: "search_graph",- Description: "Search the code graph with structured filters. Replaces raw Cypher queries with safe, parameterized search. Supports filtering by node label, name pattern (regex), file pattern (glob), relationship type, direction, and degree (fan-in/fan-out). Returns matching nodes with properties and edge counts.",+ Description: "Search the code graph with structured filters. Replaces raw Cypher queries with safe, parameterized search. Supports filtering by project, node label, name pattern (regex), file pattern (glob), relationship type, direction, and degree (fan-in/fan-out). Returns matching nodes with properties and edge counts.",InputSchema: json.RawMessage(`{"type": "object","properties": {+ "project": {+ "type": "string",+ "description": "Filter by project name. If omitted, searches all indexed projects."+ },"label": {"type": "string",- "description": "Node label filter: Function, Class, Module, Method, Interface, Enum, Type, File, Package, Folder"+ "description": "Node label filter: Function, Class, Module, Method, Interface, Enum, Type, File, Package, Folder, Route"},"name_pattern": {"type": "string",@@ -116,7 +120,7 @@ func (s *Server) registerTools() {},"file_pattern": {"type": "string",- "description": "Glob pattern for file path (e.g. '**/order-service/**')"+ "description": "Glob pattern for file path within the project (e.g. '**/services/**', '*.py')"},"relationship": {"type": "string",@@ -141,7 +145,7 @@ func (s *Server) registerTools() {},"limit": {"type": "integer",- "description": "Max results (default 50, max 200)"+ "description": "Max results to return. If omitted, returns all matching results."}}}`),@@ -234,7 +238,7 @@ func (s *Server) registerTools() {},"max_results": {"type": "integer",- "description": "Maximum number of matches to return (default 50, max 200)"+ "description": "Maximum number of matches to return. If omitted, returns all matches."}},"required": ["pattern"]