# ADR-0015: Pi-Lens — LSP Diagnostics & Code Navigation

**Status:** Accepted
**Date:** 2026-05-13
**Package:** `pi-lens@3.8.43`
**Maintainer:** @apmantza | **Repo:** github.com/apmantza/pi-lens
**Last published:** 2 days ago | **Publish cadence:** ~3-4/day

## Problem

Agent edits code without immediate error feedback. Syntax errors accumulate until `npm test`. Type mismatches undetected. No self-correction in the same turn. Running `tsc` after every change is slow and noisy.

## Decision

Real-time LSP integration:

- **`lsp_navigation`**: `definition`, `references`, `hover`, `implementation`, `incomingCalls`, `outgoingCalls`, `rename`, `codeAction`, `documentSymbol`, `workspaceSymbol`, `workspaceDiagnostics`
- **Auto-diagnostics**: after edits, inject LSP errors into tool output
- **`ast_grep_search` / `ast_grep_replace`**: semantic pattern matching
- Persistent warm LSP session (not per-request)

## Alternatives

| Approach            | Why Rejected                            |
| ------------------- | --------------------------------------- |
| No LSP              | No type checking, no navigation         |
| Manual `tsc` (bash) | Slow, not per-edit, noisy output        |
| `tsc --watch`       | Continuous noise, no structured results |

## Trade-offs

LSP server cold-start ~2-3s per language, then warm.

## References

- [npm](https://www.npmjs.com/package/pi-lens)
- [LSP](https://microsoft.github.io/language-server-protocol/) — Microsoft's IDE standard
- [LSAP](https://github.com/lsp-client/LSAP) — Language Server Agent Protocol (emerging standard)
- [agent-lsp](http://www.agent-lsp.com/) — stateful runtime, 53 tools, 30 languages
- [lsp-skill](https://github.com/lsp-client/lsp-skill) — agent-native LSP capabilities
