Files
nexus/wiki/sources/lsp-index-engineer.md
2026-04-21 00:02:55 +08:00

81 lines
3.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "LSP/Index Engineer"
type: source
tags: [agent, lsp, code-intelligence]
date: 2026-04-20
---
## Source File
- [[raw/Agent/agency-agents/specialized/lsp-index-engineer.md]]
## Summary
- 核心主题LSP/Index Engineer 智能体角色定义专注于语言服务器协议LSP客户端编排和统一代码语义图谱构建
- 问题域:异构语言服务器整合、实时语义索引构建、跨语言代码智能查询
- 方法/机制:通过 LSP 客户端编排将 TypeScript/PHP/Go/Rust/Python 等语言服务器响应转换为统一图谱,使用 WebSocket 实现实时增量更新
- 结论/价值:实现 <500ms 的定义/引用/悬停响应,支持 100k+ 符号规模,构建统一代码智能基础设施
## Key Claims
- graphd LSP Aggregator 通过并发编排多个 LSP 客户端实现异构语言服务器统一管理
- 语义索引基础设施nav.index.jsonl、LSIF实现代码导航和文档的持久化
- 增量更新机制通过文件监视器和 git hooks 实现图谱实时同步
- 性能目标:/graph 端点 <100ms<10k 节点),/nav/:symId <20ms缓存或 <60ms未缓存
## Key Quotes
> "You transform heterogeneous language servers into a cohesive semantic graph that powers immersive code visualization."
> "Every symbol must have exactly one definition node" — 图谱一致性要求
> "Handle 25k+ symbols without degradation (target: 100k symbols at 60fps)" — 性能目标
## Key Concepts
- [[LSP (Language Server Protocol)]]:语言服务器协议,为编辑器提供编程语言智能功能的通信协议
- [[Semantic Index]]:语义索引,存储符号定义、引用和悬停文档的数据结构
- [[Graph Construction Pipeline]]:图谱构建管道,从 LSP 响应提取节点和边构建统一语义图
- [[Incremental Updates]]:增量更新机制,通过文件监视器实现图谱实时同步
- [[LSIF (Language Server Index Format)]]:语言服务器索引格式,用于预计算语义数据的导入/导出
- [[LSP Client Orchestration]]LSP 客户端编排,并发管理多个语言服务器客户端
## Key Entities
- [[graphd]]:核心 LSP 聚合守护进程,管理多语言 LSP 客户端和图谱状态
- [[TypeScript Language Server]]TypeScript 语言服务器,提供 TS/JS 代码智能
- [[Intelephense]]PHP 语言服务器,提供 PHP 代码智能
- [[gopls]]Go 语言服务器,提供 Go 代码智能
- [[rust-analyzer]]Rust 语言服务器,提供 Rust 代码智能
- [[pyright]]Python 语言服务器,提供 Python 代码智能
## Connections
- [[LSP (Language Server Protocol)]] ← enables ← [[graphd]]
- [[Semantic Index]] ← powers ← [[Code Navigation]]
- [[graphd]] ← depends_on ← [[LSP Client Orchestration]]
- [[Incremental Updates]] ← implements ← [[File Watcher]] + [[Git Hooks]]
## Contradictions
- 无冲突
## Technical Architecture
### Graph Node Schema
- `file:<path>`:文件节点
- `sym:<name>`符号节点class/function/variable/type
### Graph Edge Types
- `contains`:文件包含符号
- `imports`:导入关系
- `extends/implements`:继承/实现
- `calls`:函数调用
- `references`:符号引用
### Navigation Index Format (nav.index.jsonl)
```jsonl
{"symId":"sym:AppController","def":{"uri":"file:///src/app.php","l":10,"c":6},"refs":[...],"hover":{...}}
```
## Performance Contracts
| Endpoint | Target Latency | Condition |
|----------|---------------|-----------|
| /graph | <100ms | <10k nodes |
| /nav/:symId | <20ms | cached |
| /nav/:symId | <60ms | uncached |
| WebSocket events | <50ms | latency |
| Memory | <500MB | typical project |