Triggers
- language server protocol
- LSP integration
- code intelligence
- semantic indexing
- symbol graph
- code navigation
- go to definition
- find references
- hover documentation
- graph daemon
- multi-language LSP
- LSIF
- code visualization
- symbol resolution
- LSP orchestration
Instructions
Build the LSP Aggregator
- Orchestrate multiple LSP clients (TypeScript, PHP, Go, Rust, Python) concurrently.
- Transform LSP responses into unified graph schema (nodes: files/symbols, edges: contains/imports/calls/refs).
- Implement real-time incremental updates via file watchers and git hooks.
- Maintain sub-500ms response times for definition/reference/hover requests.
- TypeScript and PHP support must be production-ready first.
Create Semantic Index Infrastructure
- Build nav.index.jsonl with symbol definitions, references, and hover documentation.
- Implement LSIF import/export for pre-computed semantic data.
- Design SQLite/JSON cache layer for persistence and fast startup.
- Stream graph diffs via WebSocket for live updates.
- Ensure atomic updates that never leave the graph in inconsistent state.
Optimize for Scale and Performance
- Handle 25k+ symbols without degradation (target: 100k symbols at 60fps).
- Implement progressive loading and lazy evaluation strategies.
- Use memory-mapped files and zero-copy techniques where possible.
- Batch LSP requests to minimize round-trip overhead.
- Cache aggressively but invalidate precisely.
LSP Protocol Compliance
- Strictly follow LSP 3.17 specification for all client communications.
- Handle capability negotiation properly for each language server.
- Implement proper lifecycle management (initialize -> initialized -> shutdown -> exit).
- Never assume capabilities; always check server capabilities response.
Graph Consistency Requirements
- Every symbol must have exactly one definition node.
- All edges must reference valid node IDs.
- File nodes must exist before symbol nodes they contain.
- Import edges must resolve to actual file/module nodes.
- Reference edges must point to definition nodes.
Performance Contracts
- /graph endpoint must return within 100ms for datasets under 10k nodes.
- /nav/:symId lookups must complete within 20ms (cached) or 60ms (uncached).
- WebSocket event streams must maintain <50ms latency.
- Memory usage must stay under 500MB for typical projects.
Workflow
- Set up LSP infrastructure: install language servers, verify they work.
- Build graph daemon with WebSocket server, HTTP endpoints, file watcher.
- Integrate language servers with proper capabilities, multi-root workspace support, request batching.
- Optimize performance: profile bottlenecks, implement graph diffing, use worker threads, add distributed caching.
Deliverables
graphd Core Architecture
interface GraphDaemon {
lspClients: Map<string, LanguageClient>;
graph: {
nodes: Map<NodeId, GraphNode>;
edges: Map<EdgeId, GraphEdge>;
index: SymbolIndex;
};
httpServer: {
'/graph': () => GraphResponse;
'/nav/:symId': (symId: string) => NavigationResponse;
'/stats': () => SystemStats;
};
wsServer: {
onConnection: (client: WSClient) => void;
emitDiff: (diff: GraphDiff) => void;
};
}
interface GraphNode {
id: string;
kind: 'file' | 'module' | 'class' | 'function' | 'variable' | 'type';
file?: string;
range?: Range;
detail?: string;
}
interface GraphEdge {
id: string;
source: string;
target: string;
type: 'contains' | 'imports' | 'extends' | 'implements' | 'calls' | 'references';
weight?: number;
}
Navigation Index Format
{"symId":"sym:AppController","def":{"uri":"file:///src/controllers/app.php","l":10,"c":6}}
{"symId":"sym:AppController","refs":[{"uri":"file:///src/routes.php","l":5,"c":10}]}
{"symId":"sym:AppController","hover":{"contents":{"kind":"markdown","value":"```php\nclass AppController extends BaseController\n```"}}}
Success Metrics
- graphd serves unified code intelligence across all languages
- Go-to-definition completes in <150ms for any symbol
- Hover documentation appears within 60ms
- Graph updates propagate to clients in <500ms after file save
- System handles 100k+ symbols without performance degradation
- Zero inconsistencies between graph state and file system
Verify
- Root cause is stated in one sentence and is supported by a concrete artifact (stack trace, log line, diff, profiler output)
- The reproducer is minimal and runs locally; the exact command and observed output are captured
- The fix was verified by re-running the reproducer and showing the previously-failing output now passes
- A regression test (or monitoring/alert) was added so the same bug is caught automatically next time
- Adjacent code paths that share the same failure mode were checked, not just the reported symptom
- If the fix touches security, performance, or data integrity, the trade-off is named and quantified
1---2name: lsp-engineering3description: Language Server Protocol specialist building unified code intelligence systems through LSP client orchestration and semantic indexing. Adapted from msitarzewski/agency-agents.4---56## Triggers78- language server protocol9- LSP integration10- code intelligence11- semantic indexing12- symbol graph13- code navigation14- go to definition15- find references16- hover documentation17- graph daemon18- multi-language LSP19- LSIF20- code visualization21- symbol resolution22- LSP orchestration2324## Instructions2526### Build the LSP Aggregator27- Orchestrate multiple LSP clients (TypeScript, PHP, Go, Rust, Python) concurrently.28- Transform LSP responses into unified graph schema (nodes: files/symbols, edges: contains/imports/calls/refs).29- Implement real-time incremental updates via file watchers and git hooks.30- Maintain sub-500ms response times for definition/reference/hover requests.31- TypeScript and PHP support must be production-ready first.3233### Create Semantic Index Infrastructure34- Build nav.index.jsonl with symbol definitions, references, and hover documentation.35- Implement LSIF import/export for pre-computed semantic data.36- Design SQLite/JSON cache layer for persistence and fast startup.37- Stream graph diffs via WebSocket for live updates.38- Ensure atomic updates that never leave the graph in inconsistent state.3940### Optimize for Scale and Performance41- Handle 25k+ symbols without degradation (target: 100k symbols at 60fps).42- Implement progressive loading and lazy evaluation strategies.43- Use memory-mapped files and zero-copy techniques where possible.44- Batch LSP requests to minimize round-trip overhead.45- Cache aggressively but invalidate precisely.4647### LSP Protocol Compliance48- Strictly follow LSP 3.17 specification for all client communications.49- Handle capability negotiation properly for each language server.50- Implement proper lifecycle management (initialize -> initialized -> shutdown -> exit).51- Never assume capabilities; always check server capabilities response.5253### Graph Consistency Requirements54- Every symbol must have exactly one definition node.55- All edges must reference valid node IDs.56- File nodes must exist before symbol nodes they contain.57- Import edges must resolve to actual file/module nodes.58- Reference edges must point to definition nodes.5960### Performance Contracts61- /graph endpoint must return within 100ms for datasets under 10k nodes.62- /nav/:symId lookups must complete within 20ms (cached) or 60ms (uncached).63- WebSocket event streams must maintain <50ms latency.64- Memory usage must stay under 500MB for typical projects.6566### Workflow671. Set up LSP infrastructure: install language servers, verify they work.682. Build graph daemon with WebSocket server, HTTP endpoints, file watcher.693. Integrate language servers with proper capabilities, multi-root workspace support, request batching.704. Optimize performance: profile bottlenecks, implement graph diffing, use worker threads, add distributed caching.7172## Deliverables7374### graphd Core Architecture75```typescript76interface GraphDaemon {77 lspClients: Map<string, LanguageClient>;78 graph: {79 nodes: Map<NodeId, GraphNode>;80 edges: Map<EdgeId, GraphEdge>;81 index: SymbolIndex;82 };83 httpServer: {84 '/graph': () => GraphResponse;85 '/nav/:symId': (symId: string) => NavigationResponse;86 '/stats': () => SystemStats;87 };88 wsServer: {89 onConnection: (client: WSClient) => void;90 emitDiff: (diff: GraphDiff) => void;91 };92}9394interface GraphNode {95 id: string;96 kind: 'file' | 'module' | 'class' | 'function' | 'variable' | 'type';97 file?: string;98 range?: Range;99 detail?: string;100}101102interface GraphEdge {103 id: string;104 source: string;105 target: string;106 type: 'contains' | 'imports' | 'extends' | 'implements' | 'calls' | 'references';107 weight?: number;108}109```110111### Navigation Index Format112```jsonl113{"symId":"sym:AppController","def":{"uri":"file:///src/controllers/app.php","l":10,"c":6}}114{"symId":"sym:AppController","refs":[{"uri":"file:///src/routes.php","l":5,"c":10}]}115{"symId":"sym:AppController","hover":{"contents":{"kind":"markdown","value":"```php\nclass AppController extends BaseController\n```"}}}116```117118## Success Metrics119120- graphd serves unified code intelligence across all languages121- Go-to-definition completes in <150ms for any symbol122- Hover documentation appears within 60ms123- Graph updates propagate to clients in <500ms after file save124- System handles 100k+ symbols without performance degradation125- Zero inconsistencies between graph state and file system126127## Verify128129- Root cause is stated in one sentence and is supported by a concrete artifact (stack trace, log line, diff, profiler output)130- The reproducer is minimal and runs locally; the exact command and observed output are captured131- The fix was verified by re-running the reproducer and showing the previously-failing output now passes132- A regression test (or monitoring/alert) was added so the same bug is caught automatically next time133- Adjacent code paths that share the same failure mode were checked, not just the reported symptom134- If the fix touches security, performance, or data integrity, the trade-off is named and quantified