Skip to content

Structural code tools: find_definition / find_references / symbol_outline / call_graph (tree-sitter) #11

Description

@imkp1

Summary

Add structural code-navigation tools (tree-sitter based) alongside the existing semantic search: find_definition, find_references, symbol_outline, and call_graph. Semantic embeddings are fuzzy; structural questions deserve exact answers.

Motivation

The README explicitly advertises "what calls this function?" and "trace a request end to end." Those are structural queries that pure vector search answers only approximately. A symbol/reference index gives precise, verifiable results and is the highest-ROI accuracy improvement to the core loop. It also strengthens citations (#8) and pairs with the lexical fallback direction already in flight (PR #7).

Proposed tools (exposed as indexer MCP tools)

  • find_definition(symbol) — locations where a symbol is defined.
  • find_references(symbol) — call/usage sites.
  • symbol_outline(path) — top-level defs/classes/methods for a file.
  • call_graph(symbol) — direct callers/callees (bounded depth).

Implementation notes

  • Build a tree-sitter symbol index during the index pass (multi-language via tree-sitter grammars), stored alongside the existing Qdrant data.
  • Expose as new indexer MCP tools — the backend injects the indexer MCP endpoint into every ask Job already, and the proxy is transparent, so no backend changes are required.
  • Respect the same per-user repo gating as semantic_search (X-User-Token / X-Repo-Access enforced in the indexer's access.py).
  • Sequence with PR Make semantic search optional with a graceful lexical fallback #7 (graceful degraded / lexical fallback) — both extend the indexer's non-embedding retrieval surface.

Scope

In-scope: single-workspace, Claude-only. Extends the indexer; no new services.

Acceptance

  • The four tools return correct results on the indexed repo for at least Go/Python/TypeScript.
  • Tools honour per-user repo access gating.
  • Tests added (make test-indexer).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions