<!-- Markdown mirror. Canonical: https://empryo.com/docs/concepts/intelligence -->

# Code intelligence

> How the agent navigates code by symbol using LSP, ts-morph, tree-sitter, and regex fallbacks, plus diagnostics tracked after every edit.

Empryo gives the agent the same code intelligence your IDE has: go-to-definition, references, rename, diagnostics, type info. It tries LSP first, falls back to AST tools, then tree-sitter, then regex.

This replaces grep-and-read. The agent navigates the code graph by symbol, not by pattern matching across files. Cheaper, faster, correct.

You don't configure this. It picks the best available backend for every operation.

## What it can do

| Operation | Examples |
|-----------|----------|
| **Go to definition** | "where is `parseConfig` defined?" |
| **Find references** | "who calls `parseConfig`?" |
| **Rename** | "rename `useChat` to `useConversation` everywhere" |
| **Type info** | "what's the return type of `fetchUser`?" |
| **Diagnostics** | "any errors in this file?" |
| **Call hierarchy** | "what does `buildTools` call?" |

All of these come through the `navigate` and `analyze` tools.

## How it picks a backend

```
LSP → ts-morph (TS/JS) → tree-sitter (37 languages) → regex
```

If LSP isn't attached for your language, the agent still works - the lower tiers cover most queries.

## LSP always-on

The agent has LSP access even when the editor panel is closed. When you open Neovim (`Ctrl+E`), requests route through your LSP servers there. When it's closed, Empryo spawns standalone servers.

Check what's attached:

```
/lsp status
```

Install more servers through the Mason registry:

```
/lsp install
```

## After every edit

Empryo snapshots diagnostics before the edit, compares after, and tells the agent:

- New errors it just introduced
- Errors it just fixed
- Errors in other files caused by the edit

The agent sees this instantly - no need to run a full typecheck.
