Skip to content

Commit fce1912

Browse files
committed
update
1 parent 9aa789b commit fce1912

File tree

184 files changed

+489
-2742
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+489
-2742
lines changed

README.md

Lines changed: 128 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,128 @@
1-
# Language Server Agent Protocol (LSAP)
1+
# LSAP: Language Server Agent Protocol
2+
3+
[![License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
4+
[![Protocol Version](https://img.shields.io/badge/Protocol-v1.0.0--alpha-blue.svg)]()
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)

docs/schemas/rename.md

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ The Rename API provides the ability to rename a symbol throughout the entire wor
44

55
## RenameRequest
66

7-
| Field | Type | Default | Description |
8-
| :-------------- | :----------------------- | :---------- | :----------------------------------------------------- |
9-
| `locate` | [`Locate`](locate.md) | Required | The symbol to rename. |
10-
| `new_name` | `string` | Required | The new name for the symbol. |
11-
| `mode` | `"preview" \| "execute"` | `"preview"` | Whether to preview changes or execute them. |
12-
| `rename_id` | `string \| null` | `null` | ID from a previous preview (execute mode only). |
13-
| `exclude_files` | `string[]` | `[]` | File paths to exclude from rename (execute mode only). |
7+
| Field | Type | Default | Description |
8+
| :-------------- | :----------------------- | :---------- | :----------------------------------------------------------------- |
9+
| `locate` | [`Locate`](locate.md) | Required | The symbol to rename. |
10+
| `new_name` | `string` | Required | The new name for the symbol. |
11+
| `mode` | `"preview" \| "execute"` | `"preview"` | Whether to preview changes or execute them. |
12+
| `rename_id` | `string \| null` | `null` | ID from a previous preview (execute mode only). |
13+
| `exclude_files` | `string[]` | `[]` | File paths or glob patterns to exclude from rename (execute mode). |
1414

1515
## RenameResponse
1616

@@ -87,10 +87,10 @@ Line 42:
8787

8888
> [!TIP]
8989
> To apply this rename, use `mode="execute"` with `rename_id="rename_abc123"`.
90-
> To exclude files, add `exclude_files=["path/to/exclude.py"]`.
90+
> To exclude files, add `exclude_files=["path/to/exclude.py"]` or use glob patterns like `exclude_files=["tests/*", "tests/**/*", "**/*_test.py"]`.
9191
````
9292

93-
### Scenario 2: Execute a rename with exclusions
93+
### Scenario 2: Execute a rename with glob pattern exclusions
9494

9595
#### Request
9696

@@ -105,7 +105,7 @@ Line 42:
105105
"new_name": "format_datetime",
106106
"mode": "execute",
107107
"rename_id": "rename_abc123",
108-
"exclude_files": ["tests/test_utils.py"]
108+
"exclude_files": ["tests/*", "tests/**/*"]
109109
}
110110
```
111111

@@ -135,5 +135,36 @@ Line 42:
135135
---
136136

137137
> [!NOTE]
138-
> Rename completed successfully. Excluded files: `tests/test_utils.py`
138+
> Rename completed successfully. Excluded files: `tests/*`, `tests/**/*`
139+
>
140+
> [!IMPORTANT]
141+
> You must manually rename the symbol in the excluded files to maintain consistency.
139142
````
143+
144+
## Glob Pattern Support
145+
146+
The `exclude_files` parameter supports glob patterns for flexible file exclusion:
147+
148+
- **Exact paths**: `"src/main.py"`, `"tests/test_utils.py"`
149+
- **Filename patterns**: `"*.md"`, `"test_*.py"` (matches files by name in any directory)
150+
- **Directory patterns**: `"tests/*"` (direct children), `"tests/**/*"` (all descendants)
151+
- **Combined patterns**: Use multiple patterns for complex exclusions
152+
153+
### Pattern Examples
154+
155+
| Pattern | Matches |
156+
| :---------------- | :----------------------------------------------------- |
157+
| `"*.md"` | All Markdown files (by filename) |
158+
| `"test_*.py"` | All files starting with `test_` (by filename) |
159+
| `"tests/*"` | Direct children of `tests/` directory |
160+
| `"tests/**/*"` | All files in `tests/` and subdirectories |
161+
| `"docs/*.py"` | Python files directly in `docs/` directory |
162+
| `"**/test_*.py"` | All test files matching pattern in any directory |
163+
164+
### Important Notes
165+
166+
- Patterns are matched against relative paths from the workspace root
167+
- Use forward slashes `/` for path separators (automatically normalized)
168+
- `**` matches zero or more directory levels
169+
- Absolute paths and paths with `..` are rejected for security
170+
- Multiple patterns can be combined: `["tests/*", "tests/**/*", "*.md"]`
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)