|
1 | | -# LSAP: Language Server Agent Protocol |
2 | | - |
3 | | -[](LICENSE) |
4 | | -[]() |
5 | | - |
6 | | -**LSAP (Language Server Agent Protocol)** transforms low-level LSP capabilities into high-level, **Agent-Native** cognitive tools, empowering Coding Agents with **Repository-Scale Intelligence**. |
7 | | - |
8 | | -As an **Orchestration Layer**, LSAP composes atomic LSP operations into semantic interfaces. This aligns with Agent cognitive logic, allowing them to focus on high-level "intent realization" rather than tedious "editor operations." |
9 | | - |
10 | | -## Core Concept: Atomic Capabilities vs. Cognitive Capabilities |
11 | | - |
12 | | -The core difference of LSAP lies in how it defines "capabilities." LSP is designed for editors, providing **Atomic** operations; whereas LSAP is designed for Agents, providing **Cognitive** capabilities. |
13 | | - |
14 | | -- **LSP (Editor Perspective - Atomic)**: |
15 | | - - Editors require very low-level instructions: `textDocument/definition` (jump), `textDocument/hover` (hover), `textDocument/documentSymbol` (outline). |
16 | | - - **The Agent's Dilemma**: If an Agent uses LSP directly, it needs to execute a dozen interactions sequentially like a script (open file -> calculate offset -> request definition -> parse URI -> read file -> extract snippet) just to get a useful context. |
17 | | -- **LSAP (Agent Perspective - Cognitive)**: |
18 | | - - LSAP encapsulates the complex chain of atomic operations above into a single semantic instruction. |
19 | | - - **Example**: A single request to "Find all references" triggers background execution of symbol localization, reference search, and context extraction, returning a consolidated **Markdown Report**. |
20 | | - |
21 | | -```mermaid |
22 | | -sequenceDiagram |
23 | | - participant Agent as 🤖 Agent |
24 | | - participant LSAP as 🧠 LSAP Layer |
25 | | - participant LSP as 🔧 Language Server |
26 | | -
|
27 | | - Note left of Agent: Goal: Find all references of "User" |
28 | | -
|
29 | | - Agent->>LSAP: 1. Semantic Request (Locate + References) |
30 | | -
|
31 | | - rect rgb(245, 245, 245) |
32 | | - Note right of LSAP: ⚡️ Auto Orchestration |
33 | | - LSAP->>LSAP: Parse Semantic Anchor (Fuzzy Match) |
34 | | - LSAP->>LSP: textDocument/hover (Confirm Symbol Info) |
35 | | - LSAP->>LSP: textDocument/references (Get Reference List) |
36 | | - LSP-->>LSAP: Return List<Location> |
37 | | -
|
38 | | - loop For each reference point |
39 | | - LSAP->>LSP: textDocument/documentSymbol (Identify Function/Class) |
40 | | - LSAP->>LSAP: Read Surrounding Code (Context Lines) |
41 | | - end |
42 | | - end |
43 | | -
|
44 | | - LSAP-->>Agent: 2. Structured Markdown (Callers + Code Context) |
45 | | -``` |
46 | | - |
47 | | -## Interaction Example |
48 | | - |
49 | | -LSAP's interaction design strictly follows the **Markdown-First** principle: input expresses intent, and output provides refined knowledge. |
50 | | - |
51 | | -### Request: Semantic Search (Demonstrating Composed Capabilities) |
52 | | - |
53 | | -The Agent only needs to issue a high-level command without worrying about underlying row/column calculations or file reading: |
54 | | - |
55 | | -```jsonc |
56 | | -// Intent: Find all usages of 'format_date' to refactor it |
57 | | -{ |
58 | | - "locate": { |
59 | | - "file_path": "src/utils.py", |
60 | | - "find": "def format_date<|>", // Semantic Anchor |
61 | | - }, |
62 | | - "mode": "references", |
63 | | - "max_items": 10, |
64 | | -} |
65 | | -``` |
66 | | - |
67 | | -### Response: Structured Knowledge |
68 | | - |
69 | | -LSAP aggregates the results of `references` (locations), `documentSymbol` (caller context), and `read` (code snippets): |
70 | | - |
71 | | -````markdown |
72 | | -# References Found |
73 | | - |
74 | | -Total references: 45 | Showing: 2 |
75 | | - |
76 | | -### `src/ui/header.py`:28 |
77 | | - |
78 | | -In `Header.render` (`Method`) |
79 | | - |
80 | | -```python |
81 | | -formatted = format_date(user.last_login) |
82 | | -``` |
83 | | - |
84 | | -### `src/api/views.py`:42 |
85 | | - |
86 | | -In `UserDetail.get` (`Method`) |
87 | | - |
88 | | -```python |
89 | | -return {"date": format_date(obj.created_at)} |
90 | | -``` |
91 | | -```` |
92 | | - |
93 | | -## I'm Not Convinced... |
94 | | - |
95 | | -### "LSAP Just Replicates LSP—What's Special?" |
96 | | - |
97 | | -While LSP provides **atomic operations**, LSAP offers **composed capabilities**. |
98 | | - |
99 | | -For instance, the **[Relation API](docs/schemas/draft/relation.md)** finds call paths between functions in a single request (handling traversal, cycles, and formatting), a task requiring complex orchestration in raw LSP. Similarly, the **[Unified Hierarchy API](docs/schemas/draft/hierarchy.md)** delivers unified graph representations optimized for agents. |
100 | | - |
101 | | -LSAP centralizes these patterns, preventing agents from wasting tokens on orchestration and enabling advanced capabilities like architectural and impact analysis. |
102 | | - |
103 | | -### "This Adds Complexity" |
104 | | - |
105 | | -LSAP **centralizes** complexity. Instead of every Agent reimplementing LSP orchestration logic, LSAP provides a shared, optimized layer for these common patterns. |
106 | | - |
107 | | -## Project Structure |
108 | | - |
109 | | -- [`docs/`](docs/): Core protocol definitions and Schema documentation. |
110 | | -- [`python/`](python/): Python SDK reference implementation. |
111 | | -- [`typescript/`](typescript/): TypeScript type definitions and utility library. |
112 | | -- [`web/`](web/): Protocol documentation site. |
113 | | - |
114 | | -## Alternatives |
115 | | - |
116 | | -- Claude Code have native LSP supports now. |
117 | | -- [claude-code-lsps](https://github.com/Piebald-AI/claude-code-lsps) |
118 | | -- [serena](https://github.com/oraios/serena) |
119 | | -- [cclsp](https://github.com/ktnyt/cclsp) |
120 | | -- [mcpls](https://github.com/bug-ops/mcpls) |
121 | | - |
122 | | -## Contributing |
123 | | - |
124 | | -We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details on development workflows and design principles. |
125 | | - |
126 | | -## License |
127 | | - |
128 | | -[MIT](LICENSE) |
| 1 | +# Language Server Agent Protocol (LSAP) |
0 commit comments