> ## Documentation Index
> Fetch the complete documentation index at: https://kasava.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Code Intelligence

> Semantic code search, symbol navigation, and AI-powered codebase understanding

Code Intelligence is Kasava's core indexing and search system. It parses your repositories to extract symbols, relationships, and meaning — giving the AI deep understanding of your codebase.

## How It Works

When you connect a repository, Kasava runs a four-stage indexing pipeline:

<Steps>
  <Step title="File Fetching">
    Source code is downloaded from GitHub with batched processing for performance.
  </Step>

  <Step title="AST Parsing">
    Each file is parsed using tree-sitter to extract symbols (functions, classes, variables), their relationships (imports, calls, inheritance), and metadata (complexity, parameters, decorators).
  </Step>

  <Step title="Embedding Generation">
    Code is embedded using Voyage AI for semantic search — so you can find code by describing what it does, not just matching keywords.
  </Step>

  <Step title="Storage">
    Symbols, relationships, embeddings, and the full call graph are stored in PostgreSQL with pgvector for fast retrieval.
  </Step>
</Steps>

**Performance:**

* Small repos (under 100 files): less than 10 seconds
* Medium repos (1,000 files): under 1 minute
* Large repos (10,000+ files): 2–5 minutes

## Language Support

Kasava supports **32+ languages** via tree-sitter parsing:

| Category      | Languages                                                    |
| ------------- | ------------------------------------------------------------ |
| **Web**       | JavaScript, TypeScript, HTML, CSS, SCSS, GraphQL             |
| **Backend**   | Python, Java, Go, Ruby, PHP, C#, Kotlin, Scala, Rust, Elixir |
| **Systems**   | C, C++, Swift, Haskell, Lua                                  |
| **Scripting** | Shell/Bash, Perl, R                                          |
| **Data**      | SQL, JSON, YAML, XML, Markdown                               |
| **Infra**     | Dockerfile                                                   |

## Triggering Indexing

There are three ways to index a repository:

1. **During onboarding** — Repositories linked during setup are indexed automatically.
2. **Manual** — Toggle "Index repository" in the repository settings page.
3. **Automatic** — Push events via GitHub webhooks trigger incremental updates, processing only changed files.

<Info>
  Incremental indexing on push events only processes changed files, not the entire repository. This keeps updates fast even for large codebases.
</Info>

## What Gets Extracted

For each file, Kasava extracts:

* **Symbols** — Functions, classes, methods, variables, types, interfaces
* **Signatures** — Full parameter lists, return types, generics
* **Relationships** — Import/export chains, inheritance hierarchies, interface implementations
* **Call graph** — Which functions call which, with edge metadata
* **Complexity** — Cyclomatic and cognitive complexity scores per function
* **Metadata** — Async/static/visibility modifiers, decorators, line counts
* **Comments** — TODOs, FIXMEs, HACKs, and docstrings

## Code Search

Navigate to **Code Search** in any Product sidebar to search across your indexed repositories.

### Search Strategies

| Strategy     | How it works                                      | Best for                                      |
| ------------ | ------------------------------------------------- | --------------------------------------------- |
| **Symbolic** | Fuzzy matching on extracted symbol names          | Finding a specific function or class by name  |
| **Semantic** | Vector similarity using Voyage AI embeddings      | Describing what code does in natural language |
| **Hybrid**   | Both symbolic + semantic, merged and deduplicated | General-purpose search (default)              |

### Example Queries

| Query                                             | What it finds                                                    |
| ------------------------------------------------- | ---------------------------------------------------------------- |
| `validateToken`                                   | Direct symbol match on function name                             |
| "function that checks if a user is authenticated" | Semantic match — finds auth middleware even if named differently |
| "database connection pool setup"                  | Finds connection config, pool initialization, retry logic        |
| "error handling in API routes"                    | Finds try-catch patterns, error middleware, response formatters  |

### Search Filters

* **Repository** — Scope to a specific repo
* **Language** — Filter by programming language
* **Symbol type** — Functions, classes, interfaces, etc.

### Results

Each result includes:

* Source code snippet with syntax highlighting
* File path and line number
* Similarity score
* Symbol type and signature
* Complexity metrics
* Related comments (TODOs, docstrings)

## Symbol Explorer

The repository detail page includes a **Code Intelligence** tab with interactive tools:

* **Symbol Treemap** — Visualize code complexity and test coverage across your codebase
* **Call Graph** — Explore function call chains and dependencies visually
* **File Dependencies** — See import relationships between files
* **Churn × Complexity** — Scatter plot highlighting hotspots (high churn + high complexity = risk)
* **Dead Code Detection** — Find unused exported symbols with confidence scoring
* **Tech Debt** — Browse TODO, FIXME, and HACK markers across your codebase

## How AI Chat Uses Code Intelligence

When you [chat with the AI](/docs/features/ai-chat), it uses Code Intelligence behind the scenes to:

1. **Search symbols** to find relevant code for your question
2. **Trace dependencies** to understand how components connect
3. **Read definitions** to provide accurate, specific answers
4. **Check the call graph** to assess impact of proposed changes

This is why indexing your repository unlocks significantly better AI responses — the AI can reference your actual code rather than guessing.

## Repository Detail Page

Each connected repository has a detail page at **Repositories → \[repo name]** with tabs:

| Tab                   | What it shows                                      |
| --------------------- | -------------------------------------------------- |
| **Overview**          | Quick stats, recent activity, quick actions        |
| **Activity**          | Timeline of commits and pull requests              |
| **Code Intelligence** | Symbol explorer, call graphs, dead code, tech debt |
| **Settings**          | Indexing toggle, branch selection, sync history    |

## Best Practices

<Tip>
  **Index your main branch first.** Kasava indexes the default branch by default. You can configure additional branches in repository settings.
</Tip>

<Tip>
  **Use natural language for broad searches.** "How does authentication work?" finds more relevant results than searching for `auth`.
</Tip>

<Tip>
  **Check the call graph before refactoring.** The symbol dependency view shows exactly what will be affected by changes.
</Tip>

## Related

<CardGroup cols={2}>
  <Card title="AI Chat" icon="comments" href="/docs/features/ai-chat">
    Ask questions about your indexed code
  </Card>

  <Card title="Products" icon="layer-group" href="/docs/features/products">
    Connect repositories to your products
  </Card>

  <Card title="Agent Code Impact" icon="code" href="/docs/agent/code-impact">
    AI-powered impact analysis
  </Card>

  <Card title="Agent Code Health" icon="heart-pulse" href="/docs/agent/code-health">
    Automated code quality insights
  </Card>
</CardGroup>
