Skip to content

feat: add call graph extraction and query support#11

Open
Helweg wants to merge 4 commits intomainfrom
feature/call-graph
Open

feat: add call graph extraction and query support#11
Helweg wants to merge 4 commits intomainfrom
feature/call-graph

Conversation

@Helweg
Copy link
Owner

@Helweg Helweg commented Feb 23, 2026

Summary

  • Full-stack call graph feature: Rust-based extraction of function calls, method calls, constructors, and imports across 5 languages (TypeScript/JavaScript, Python, Go, Rust)
  • SQLite storage with branch awareness: Schema v2 migration adds symbols, call_edges, and branch_symbols tables with full CRUD, GC, and batch operations
  • End-to-end integration: NAPI bindings → TypeScript wrappers → Indexer integration → call_graph OpenCode tool → MCP server tool

What's New

Rust Layer (native/)

  • call_extractor.rs (~411 lines): Tree-sitter query-based call extraction for 5 languages
  • Tree-sitter query files: typescript-calls.scm, python-calls.scm, go-calls.scm, rust-calls.scm
  • Language::from_string() added to types.rs
  • DB schema v2: symbols, call_edges, branch_symbols tables
  • 16 new Database methods (CRUD + GC + batch ops for symbols and call edges)
  • streaming-iterator dependency added

TypeScript Layer (src/)

  • NAPI bindings: extractCalls function + CallSiteData, SymbolData, CallEdgeData types
  • 16 Database wrapper methods in src/native/index.ts
  • Indexer: Automatic call extraction during indexing, branch symbol association, getCallers()/getCallees() public API
  • call_graph tool in src/tools/index.ts with callers/callees direction support
  • MCP server: call_graph tool registration + health check GC fields
  • formatHealthCheck updated for new GC counters

Tests

  • tests/call-graph.test.ts: 15 comprehensive tests (extraction, storage, resolution, branch awareness, integration)
  • Updated tests/mcp-server.test.ts (9 tools) and tests/tools-utils.test.ts (new GC fields)

Verification

  • cargo check — zero warnings
  • cargo test — 47 tests pass
  • npm run build — TypeScript + Rust build success
  • npm run typecheck — zero type errors
  • npm run test:run — 352 tests pass, 0 failures
  • npm run lint — clean

Implement full-stack call graph feature: Rust-based extraction of
function calls, method calls, constructors, and imports across 5
languages (TS/JS, Python, Go, Rust), with SQLite storage, NAPI
bindings, indexer integration, OpenCode tool, and MCP server support.

Rust layer:
- Add call_extractor.rs with tree-sitter queries for 5 languages
- Add Language::from_string() to types.rs
- DB schema v2: symbols, call_edges, branch_symbols tables
- Full CRUD + GC for symbols and call edges
- 47 Rust tests pass, zero warnings

TypeScript layer:
- NAPI bindings for extractCalls + 16 Database methods
- Indexer integration: extract calls during indexing, branch awareness
- call_graph tool (callers/callees queries)
- MCP server call_graph tool + health check updates
- 352 tests pass, zero type errors
get_callees was returning edges from all branches while get_callers
was branch-filtered. This asymmetry could return stale edges from
other branches. Add branch parameter and INNER JOIN branch_symbols
to get_callees, matching the get_callers pattern. Updated all callers
through the full chain: Rust db → NAPI lib → TS wrapper → Indexer → tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant