Commit Graph
912 Commits
Author SHA1 Message Date
Colby McHenry b712e4de63 feat: Add C# property/field extraction and inheritance support
Addresses C#'s property_declaration nodes (public string Name { get; set; }) by adding propertyTypes support and extractProperty method. Improves field extraction to handle C#'s nested variable_declaration > variable_declarator structure. Adds base_list handling in extractInheritance for C#'s `: Parent, IInterface` syntax where base class and interfaces are combined in a single colon-separated list.
2026-04-06 23:53:30 -05:00
Colby McHenry 4a8d2f0396 feat: Add content-based C++ detection for .h headers
Addresses C++ classes missing from .h files where extension-based detection defaults to 'c' language which has no class extraction support. Adds looksLikeCpp() heuristic that scans first 8KB for C++-specific patterns (namespace, class, template, access specifiers) to promote .h files to 'cpp' language when C++ constructs are detected. Ensures cpp grammar is loaded alongside c to handle potential .h promotion during parsing.
2026-04-06 23:38:13 -05:00
Colby McHenry 237fb3b206 feat: Add C++ macro misparse handling and structural node extraction in function bodies
Addresses C++ macros like NLOHMANN_JSON_NAMESPACE_BEGIN that cause tree-sitter to misparse namespace blocks as function_definitions. Adds isMisparsedFunction hook to filter macro artifacts while still visiting their bodies to extract legitimate class/struct/enum definitions hidden inside the misparsed "function" scope.
2026-04-06 23:24:26 -05:00
Colby McHenry 6f34be38aa feat: Add C/C++ typedef enum and struct extraction with inner type resolution
Addresses C/C++ typedef syntax where anonymous enum/struct definitions are wrapped in typedef declarations (e.g. `typedef enum { A, B } MyEnum;`). Adds resolveTypeAliasKind to identify inner enum_specifier and struct_specifier nodes within typedefs, enabling proper extraction of enum members and struct fields from the inner anonymous definitions rather than treating them as simple type aliases.
2026-04-06 22:58:35 -05:00
Colby McHenry da248f9a8e feat: Improve C/C++ name extraction and skip forward declarations in struct/enum processing
Addresses C/C++ pointer declarator unwrapping where pointer_declarator nodes need to be resolved to find the actual function/variable name. Adds forward declaration filtering by checking for body field presence before processing struct and enum definitions, preventing extraction of incomplete type declarations.
2026-04-06 22:49:09 -05:00
Colby McHenry e848e6f22f feat: Add PHP inheritance extraction and improve method call handling
Addresses PHP's base_clause syntax for class inheritance (extends) and implements clause for interface implementation. Adds trait_declaration support and separates property_declaration into fieldTypes. Improves PHP method call extraction by handling member_call_expression and scoped_call_expression with proper receiver name processing, including $ prefix stripping and self/this/parent/static receiver filtering.
2026-04-06 22:10:23 -05:00
Colby McHenry 2d14503258 feat: Add Rust trait inheritance and impl block extraction with method receiver type support
Addresses Rust's impl block syntax where trait implementations (`impl Trait for Type`) and trait supertraits (`trait Sub: Super`) create inheritance relationships. Adds getReceiverType to extract method receiver types from impl blocks, enabling proper method-to-struct relationships and qualified name resolution. Verified against Deno codebase and moved from "Needs Verification" to completed language support.
2026-04-06 21:50:03 -05:00
Colby McHenry ce7b7684db feat: Fix TypeScript inheritance extraction by properly handling class_heritage wrapper nodes
Addresses TypeScript's AST structure where class_heritage nodes wrap extends_clause and implements_clause rather than directly indicating inheritance relationships. Moves class_heritage from direct inheritance extraction to recursive container processing to properly traverse the wrapped inheritance syntax.
2026-04-06 21:13:57 -05:00
Colby McHenry 5046c760cb feat: Add Swift inheritance extraction for class, struct, enum, and protocol relationships
Addresses Swift's inheritance_specifier syntax where type relationships are specified after colons (e.g. `class UploadRequest: DataRequest, Sendable`). Extracts user_type > type_identifier children from inheritance_specifier nodes as 'extends' references to properly model Swift's inheritance, protocol conformance, and struct conformance patterns in the code graph.
2026-04-06 20:52:42 -05:00
Colby McHenry 80fd0f8381 feat: Mark Python as verified for method extraction without receiver type handling
Addresses tree-sitter AST structure verification where Python methods are nested within class bodies like Java and Swift, eliminating the need for getReceiverType extraction. Verified against Flask codebase and moved from "Needs Verification" to completed language support.
2026-04-06 20:39:51 -05:00
Colby McHenry e12bd7ce91 feat: Include receiver names in method call extraction and improve built-in filtering
Addresses method call resolution ambiguity where bare method names couldn't be distinguished from function calls. Modifies tree-sitter extraction to include receiver names (e.g., "console.log" instead of just "log") while skipping common instance references like self/this. Updates built-in filtering to be language-specific and adds Python built-in method detection based on receiver types and method names.
2026-04-06 20:31:37 -05:00
Colby McHenry a0f599e00b feat: Add Python class inheritance extraction for superclass relationships
Addresses Python's class definition syntax where parent classes are specified in argument_list nodes (e.g. `class Child(Parent, Mixin):`). Extracts identifier and attribute children from argument_list as 'extends' references to properly model Python's inheritance patterns in the code graph.
2026-04-06 20:13:25 -05:00
Colby McHenry 392c146810 feat: Add optional stem control to search term extraction and improve name match scoring
Addresses path relevance scoring inflation where stem variants created many near-duplicate terms that all matched the same path segments. Adds stems option to extractSearchTerms (default true) and disables stems for path scoring while keeping them for FTS matching. Also improves name match bonus scoring with length-based prefix matching and higher exact match scores.
2026-04-06 19:50:53 -05:00
Colby McHenry 902cb0ef9d feat: Add Go selector_expression support to function call extraction
Addresses Go's tree-sitter parsing where method calls use selector_expression nodes with 'field' children instead of member_expression nodes with 'property' children. Extends function call extraction to handle Go's obj.method() syntax alongside existing JavaScript/TypeScript support.
2026-04-06 19:13:57 -05:00
Colby McHenry b1224bcc6a feat: Remove file path from qualified names to prevent FTS pollution and add Go import reference tracking
Addresses qualified name pollution where file paths contaminated full-text search results. Removes file path prefix from buildQualifiedName output and method qualified names, keeping semantic hierarchy only. Also adds unresolved reference creation for Go imports to enable proper import edge resolution in the dependency graph.
2026-04-06 18:59:35 -05:00
Colby McHenry 1244c62193 feat: Add Go struct and interface embedding extraction for inheritance relationships
Addresses Go's embedding mechanism where structs can embed other types without field names (e.g. `type DB struct { *Head; Queryable }`) and interfaces can embed other interfaces via constraint_elem nodes. Extracts these embedded types as 'extends' relationships to properly model Go's composition-based inheritance patterns in the code graph.
2026-04-06 18:47:12 -05:00
Colby McHenry 982d987349 feat: Fix Go struct/interface extraction by refactoring type_spec handling through type alias resolver
Addresses Go's tree-sitter parsing where structs and interfaces are wrapped in type_spec nodes rather than appearing as direct node types. Moves struct_type and interface_type detection from direct node type matching to a new resolveTypeAliasKind resolver that examines the inner type field, ensuring proper extraction with field visiting and inheritance detection.
2026-04-06 18:33:37 -05:00
Colby McHenry 630053f3a3 feat: Improve exact name match scoring and expand stop word filtering
Uses max FTS score as baseline for exact name matches to ensure nameMatchBonus differentiation during rescoring, increases exact match limit from 5 to 20 candidates, and adds common conversational terms to stop words to reduce query noise.
2026-04-06 16:55:09 -05:00
Colby McHenry f3a0fd402f feat: Add exact name match supplement to prevent BM25 burial in search results
Addresses cases where BM25 can bury short exact-match names (e.g. "Query") under hundreds of compound names (e.g. "QueryParserTokenManager") in large codebases, pushing them past the FTS fetch limit before post-hoc scoring can help. Supplements primary search results with direct case-insensitive name lookups for each query term, ensuring exact matches are always candidates for scoring.
2026-04-06 16:35:20 -05:00
Colby McHenry e41431abc2 feat: Fix stem variant inflation in multi-term search boosting by grouping related terms
Addresses cases where stem variants like "index", "indexed", "indexe" were counted as separate term matches, artificially inflating match counts and giving false multi-term boosts to symbols matching one root word multiple times. Groups terms that are substrings of each other before counting matches to ensure each conceptual term contributes only once to the boost calculation.
2026-04-06 16:16:25 -05:00
Colby McHenry d9e973cffc feat: Add edge recovery to restore connectivity after node trimming in context building
Addresses cases where BFS with multiple entry points leaves most nodes disconnected after trimming. Discovers edges between already-selected nodes using specific relationship types (calls, extends, implements, references, overrides) to recover inter-node connectivity that would otherwise be lost during the node selection process.
2026-04-06 16:08:42 -05:00
Colby McHenry f668b2cd1c feat: Add stem variants to search term extraction for broader definition matching
Expands symbol lookup with morphological variants (e.g., "caching"→"cache", "eviction"→"evict") to find related class definitions that FTS prefix matching would otherwise miss. Includes comprehensive stemming rules for common English suffixes (-ing, -tion, -ed, -er, etc.) and integrates stem expansion into definition prefix search for improved symbol discovery.
2026-04-06 15:56:31 -05:00
Colby McHenry c626dfa989 feat: Improve multi-term search ranking with co-occurrence boosting and compound matching
Addresses cases where multi-word queries like "search execution from request to shard" return generic single-term matches instead of highly relevant classes matching multiple terms. Applies co-occurrence boosting before truncation to prioritize nodes matching 2+ query terms, adds compound term matching to catch classes like "SearchShardsRequest" that contain multiple query terms at any position, and widens per-term accumulation pools to prevent relevant multi-term matches from being filtered out early.
2026-04-06 14:27:13 -05:00
Colby McHenry 88d9c2a2f4 feat: Add CamelCase substring search and type hierarchy expansion to context building
Introduces LIKE-based substring matching to find symbols like "Search" within "TransportSearchAction" that FTS cannot match due to tokenization boundaries. Adds dedicated type hierarchy traversal to ensure parent/child classes and interfaces are included in context results, preventing BFS budget exhaustion on method-level nodes before reaching inheritance relationships.
2026-04-06 14:00:03 -05:00
Colby McHenry 13d3ff3613 feat: Add comprehensive evaluation framework for CodeGraph API testing
Introduces automated testing infrastructure to measure CodeGraph performance across searchNodes and findRelevantContext APIs. Includes recall/MRR scoring metrics, predefined test cases for symbol lookup and context exploration, and JSON report generation. Enhances context building with acronym extraction, definition prefix matching, and improved FTS filtering to exclude imports by default.
2026-04-06 13:24:27 -05:00
Colby McHenry d4258b1651 docs: Simplify getImpactRadius API call in verification guide
Updates example code to use the simplified two-parameter form of getImpactRadius instead of the options object pattern, making the documentation consistent with current API usage.
2026-04-06 13:07:38 -05:00
Colby McHenry e5663c5952 feat: Enhance search ranking with name matching and field extraction improvements
Adds nameMatchBonus scoring to prioritize results where node names exactly or partially match query terms. Implements dedicated field extraction for Java/C# to properly categorize class fields vs variables. Optimizes BM25 search with column weights favoring name matches and increased result fetching before post-processing. Refines stop words list to preserve common programming terms like "get", "find", "list".
2026-04-06 12:20:44 -05:00
Colby McHenry b04ee9f9bb docs: Replace search quality loop guide with comprehensive language verification framework
Replaces the focused search quality improvement loop with a complete language verification system. The new guide provides a systematic battery of tests (explore, search, call chains, impact analysis, edge extraction, node completeness, and real-world LLM prompts) to verify CodeGraph fully supports a programming language before marking it as production-ready.
2026-04-06 12:04:31 -05:00
Colby McHenry fba9da53cd docs: Mark Swift as completed for receiver type extraction
Swift methods in extension blocks are already parsed correctly by tree-sitter, which treats `extension Type { }` as `class_declaration` and automatically includes the owner type in qualified names. No getReceiverType implementation needed.
2026-04-06 11:49:25 -05:00
Colby McHenry c0c8a3bb43 feat: Add enum member extraction support across all language extractors
Extends AST parsing to identify and extract individual enum members/cases for better code analysis. Adds enumMemberTypes configuration to each language extractor with language-specific node types (e.g., 'enum_variant' for Rust, 'enum_case' for PHP, 'enum_entry' for Swift/Kotlin). Implements flexible member name resolution supporting both field-based and identifier-based extraction patterns.
2026-04-06 11:32:56 -05:00
Colby McHenry 6598904d06 docs: Add search quality improvement guide for CodeGraph language extractors
Documents the systematic process for testing and improving search result relevance when LLMs query CodeGraph. Provides step-by-step loop for diagnosing issues with method search ranking, implementing getReceiverType hooks for languages where methods appear outside their owner type in the AST, and validating fixes with real codebases.
2026-04-06 11:20:37 -05:00
Colby McHenry 7a3afc9124 feat: Enhance symbol search with co-location boosting and receiver type support
Improves search accuracy by boosting results when multiple query symbols appear in the same file, addressing cases where common names like "run" return too many results. Adds Go method receiver type extraction to qualified names for better searchability (e.g., "scrapeLoop.run"). Optimizes database queries with two-pass approach to handle distinctive vs common symbol names efficiently.
2026-04-06 11:16:56 -05:00
Colby McHenry d256af3a23 feat: Optimize reference resolution with indexed queries and built-in filtering
Replaces O(n) file scanning with O(log n) indexed database lookups by adding getAllNodeNames query and caching node lookups by name/qualified name. Pre-filters references against known symbol names to skip expensive resolution for non-existent symbols. Consolidates Go resolver helper functions into a unified resolveByNameAndKind function and moves built-in symbol sets to module-level constants for better performance.
2026-04-06 10:45:14 -05:00
Colby McHenry cacc213f09 feat: Remove unused 'finalizing' phase from indexing progress
Eliminates the intermediate 'finalizing' phase that was added as a progress bar transition state but served no functional purpose. Simplifies the progress flow by going directly from 'storing' to 'resolving' phases, removing associated UI labels and progress callbacks.
2026-04-06 09:57:53 -05:00
Colby McHenry 9a2d3d9a13 feat: Fix progress bar hanging and improve UI responsiveness during indexing
Adds strategic yield points and direct stdout writes to prevent progress animation from freezing when the main thread is blocked by synchronous operations. Introduces 'finalizing' phase to smooth transition between parsing and resolving steps, ensuring progress reaches 100% completion.
2026-04-06 09:50:30 -05:00
Colby McHenry b768a9aa18 feat: Improve benchmark results presentation and add average performance metrics
Restructures the benchmark table for better readability by separating queries into a details section and highlighting the overall 92% fewer tool calls and 71% faster performance. Makes the compelling efficiency gains more prominent while maintaining all detailed information in an expandable section.
2026-04-06 09:24:53 -05:00
Colby McHenry 77432fe4ea feat: Add dynamic codegraph_explore call budgets based on project size
Replaces fixed 6-call limit with adaptive budgets that scale from 2 calls for small projects (
2026-04-06 09:21:49 -05:00
Colby McHenry 8e8759ff13 feat: Add Swift Compiler benchmark and increase codegraph_explore call limit to 6
Updates benchmark results with the largest tested codebase (25,874 files, 272,898 nodes) demonstrating CodeGraph's scalability. Increases the recommended call limit from 3 to 6 to accommodate more complex cross-cutting queries while maintaining efficiency gains over traditional file-reading approaches.
2026-04-04 23:21:47 -05:00
Colby McHenry 9249c4692a feat: Add comment-stripping fallback for WASM memory failures and improve retry strategy
Recycles workers before each retry attempt instead of once per batch to maximize WASM memory headroom. Adds final fallback that strips comment-only lines from files that still crash on clean workers, reducing memory pressure from compiler test files with extensive CHECK directives while preserving line numbers for accurate node positions.
2026-04-04 23:08:50 -05:00
Colby McHenry 1271ad9161 feat: Add adaptive timeouts and WASM memory error recovery for robust parsing
Implements file-size-based timeouts (base 10s + 10s per 100KB), more frequent worker recycling (250 files), and automatic retry logic for WASM memory corruption failures. Workers now crash immediately on memory errors to prevent cascading failures, with failed files automatically retried on fresh workers with clean heaps.
2026-04-04 22:49:36 -05:00
Colby McHenry c19c0ca8fd feat: Add verbose mode with worker lifecycle monitoring and improved error handling
Adds --verbose flag to init and index commands that shows timestamped progress output instead of animated progress bars. Implements worker timeout protection (10s per file) and periodic worker recycling (every 500 files) to prevent WASM memory crashes from hanging the entire indexing process. Includes detailed logging of worker lifecycle events and memory usage for debugging large repository indexing issues.
2026-04-04 22:28:25 -05:00
Colby McHenry 64d844c938 feat: Move parsing to worker threads for smooth progress animation
Offloads tree-sitter parsing to a dedicated worker thread, keeping the main thread unblocked so shimmer progress animations render smoothly during indexing. Refactors shimmer progress renderer into separate worker for consistent 50ms animation updates. Falls back to in-process parsing when worker compilation unavailable (e.g., tests).
2026-04-04 11:36:20 -05:00
Colby McHenry ed35d65f4c feat: Replace figlet with @clack/prompts for polished CLI experience
Replaces ASCII art banner and basic readline prompts with @clack/prompts for a modern interactive CLI. Adds animated shimmer progress bars with spinner glyphs during indexing operations. Improves installer UX with structured prompts, better error handling, and cleaner output formatting throughout all CLI commands.
2026-04-04 11:07:18 -05:00
Colby McHenry 3a44d5c4d1 fix: Improve CLI progress display and prevent tree-sitter WASM memory crashes
Replaces fixed-width padding with terminal escape sequences for proper progress line clearing across different terminal widths. Adds periodic parser reset every 5000 parses per language to prevent WASM heap fragmentation that causes "memory access out of bounds" crashes in large repositories. Includes filename truncation to fit available terminal width.
2026-04-04 10:28:07 -05:00
Colby McHenry e4908e1270 feat: Add database schema v3 with optimized node lookups and improved error handling
Adds expression index on lower(name) for memory-efficient case-insensitive searches, replacing in-memory caches that caused OOM on large codebases. Includes batched reference resolution, enhanced error reporting with detailed breakdown by error type, and improved CLI progress display for scanning phases.
2026-04-04 10:19:08 -05:00
Colby MchenryandGitHub 9cd5ef9870 Merge pull request #78 from colbymchenry/fix/explore-depth-and-qualified-symbol-lookup
fix: Improve explore depth and qualified symbol lookups
2026-04-03 19:58:34 -05:00
Colby McHenryandClaude Opus 4.6 b986b78fa9 fix: Increase explore traversal depth and support qualified symbol lookups
Two fixes discovered while benchmarking Swift (Alamofire):

1. codegraph_explore traversalDepth 2→3: Deep call chains (e.g., Alamofire's
   9-step Session.request()→URLSession flow) couldn't be followed in a single
   explore call, forcing agents to fall back to file reads.

2. findSymbol/findAllSymbols now support "Parent.child" notation (e.g.,
   "Session.request") by matching against qualified names (::Parent::child).
   Previously only checked node.name === symbol, which never matched qualified
   queries since node names are unqualified.

Also adds Alamofire Swift benchmark data to README (91% fewer tool calls,
78% faster with CodeGraph).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 19:56:58 -05:00
Colby McHenry 0d6f460b15 fix: Reduce codegraph_explore output limit to stay under MCP client token limits
Decreases maximum output from 50,000 to 35,000 characters to prevent exceeding ~10k token limits in MCP clients that could cause truncation or errors when processing exploration results.
2026-04-03 19:34:56 -05:00
Colby MchenryandGitHub eefa622965 Merge pull request #77 from colbymchenry/refactor/extract-language-configs
refactor: Extract per-language configs from tree-sitter.ts
2026-04-03 19:26:32 -05:00
Colby McHenryandClaude Opus 4.6 c8407ad007 refactor: Extract per-language configs and standalone extractors from tree-sitter.ts
Splits the monolithic tree-sitter.ts (3,358 lines) into modular files:
- 14 language config files under src/extraction/languages/
- 3 standalone extractors (Liquid, Svelte, DFM)
- Shared helpers and types modules to avoid circular imports

Also fixes a bug where Java's extractImport hook incorrectly set
handledRefs: true, preventing unresolved reference creation and
degrading codegraph_explore results for Java codebases.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 19:25:59 -05:00