Skip to content

Commit bc8f068

Browse files
committed
update
1 parent 8ac8c53 commit bc8f068

Some content is hidden

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

77 files changed

+918
-1072
lines changed

.github/agents/doc.agent.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,20 @@ description: Automatically generates and updates LSAP schema documentation from
55

66
# LSAP Documentation Agent
77

8-
Automatically generates and updates markdown documentation files in `docs/schemas/` based on Pydantic models and schema definitions in `schema/src/lsap_schema/`.
8+
Automatically generates and updates markdown documentation files in `docs/schemas/` based on Pydantic models and schema definitions in `schema/src/lsap.schema/`.
99

1010
## When to Use
1111

1212
Use this agent when:
13+
1314
- You've added new Pydantic models to the schema (e.g., new Request/Response classes)
1415
- You've modified existing models (added fields, changed types, updated templates)
1516
- You need to regenerate example usage sections for documentation
1617
- Documentation has drifted from the actual schema implementation
1718

1819
## How It Works
1920

20-
1. **Analyze Schema Files**: Reads all Python modules in `schema/src/lsap_schema/` to identify Request/Response classes, their fields, types, defaults, and markdown templates
21+
1. **Analyze Schema Files**: Reads all Python modules in `schema/src/lsap.schema/` to identify Request/Response classes, their fields, types, defaults, and markdown templates
2122

2223
2. **Compare with Existing Docs**: Checks `docs/schemas/` for missing documentation, outdated field specifications, and mismatched example outputs
2324

@@ -36,5 +37,3 @@ Use this agent when:
3637
- **Templates**: Ensure example outputs match the actual Liquid template rendering in `model_config.json_schema_extra`
3738
- **Pagination**: Document pagination fields (`max_items`, `start_index`, `pagination_id`) when applicable
3839
- **Cross-references**: Use `[link text](other_file.md)` format to reference related APIs
39-
40-

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,17 @@ wheels/
1212
uv.lock
1313

1414
references/
15+
# Python-generated files
16+
__pycache__/
17+
*.py[oc]
18+
build/
19+
dist/
20+
wheels/
21+
*.egg-info
22+
23+
# Virtual environments
24+
.venv
25+
26+
uv.lock
27+
28+
references/

AGENTS.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,18 @@
55
- Lint & format: `ruff check --fix && ruff format`
66
- Type checking: `ty check <dir_or_file>`
77
- Run tests: `uv run pytest`
8-
- Use `uv` for Python related commands.
8+
- Python commands: always use `uv`
99

1010
## Code Style Guidelines
1111

1212
- Python: 3.12+ required
13+
- Imports & Formatting: use ruff
14+
- Async: Use async/await, `asyncer.TaskGroup` for concurrency
1315

14-
## Schema Design
16+
## Implementation Guidelines
1517

16-
- LLM-Agent centric design: Can agent build/understand the schema effectively?
17-
- Simplify Templates: Move complex logic from templates into data models.
18-
- Avoid advanced Pydantic features (e.g., `@computed_field`) to ensure clean and compatible JSON schema exports.
18+
- Path Handling: `client.from_uri()` returns relative paths by default. Use `relative=False` explicitly when absolute paths are required (e.g., for path comparisons in exclusion sets).
1919

20-
## Template Design
20+
## Testing
2121

22-
- Always read [cheetsheet](docs/liquid_cheatsheet.md) before writing Liquid templates.
23-
- Validate templates after writing.
22+
- Run `uv sync --upgrade` before testing and fixing type errors

CONTRIBUTING.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Thank you for your interest in contributing to LSAP! This project aims to empowe
66

77
LSAP is a multi-language monorepo:
88

9-
- **`src/lsap_schema/`**: Core protocol definitions and models (Python).
9+
- **`src/lsap.schema/`**: Core protocol definitions and models (Python).
1010
- **`python/`**: Python SDK and reference implementation.
1111
- **`typescript/`**: TypeScript type definitions and Zod schemas.
1212
- **`docs/`**: Protocol documentation and Liquid templates.
@@ -34,7 +34,7 @@ cd typescript && bun install
3434

3535
### Python & Schema
3636

37-
The source of truth for LSAP schemas is the Python implementation in `src/lsap_schema/`.
37+
The source of truth for LSAP schemas is the Python implementation in `src/lsap.schema/`.
3838

3939
- **Linting & Formatting**: `uv run ruff check --fix && uv run ruff format`
4040
- **Testing**: `uv run pytest`
@@ -50,11 +50,13 @@ The source of truth for LSAP schemas is the Python implementation in `src/lsap_s
5050
## Design Guidelines
5151

5252
### Schema Design
53+
5354
- **Agent-Centric**: Design schemas that are easy for LLMs to generate and consume.
5455
- **Clean Exports**: Avoid advanced Pydantic features (like `@computed_field`) that don't translate well to standard JSON Schema.
5556
- **Simplicity**: Move complex logic from templates into the data models.
5657

5758
### Template Design
59+
5860
- **Liquid Templates**: We use Liquid for generating Markdown reports. Refer to [`docs/liquid_cheatsheet.md`](docs/liquid_cheatsheet.md).
5961
- **Validation**: Always validate templates with sample data after modification.
6062

README.md

Lines changed: 1 addition & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,128 +1 @@
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)
1+
# Language Server Agent Protocol (LSAP)

justfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@ sync:
33

44
# Export JSON schemas from Python
55
schema-json output:
6-
cd schema && uv run -m lsap_schema -o {{output}}
6+
uv run -m lsap.schema -o {{output}}
77

88
# Generate Zod schemas from JSON schemas
99
schema-zod:
1010
cd typescript && bun run scripts/gen-zod.ts
11-
12-
# Run full codegen pipeline
13-
codegen: (schema-json "../typescript/schemas") schema-zod

pyproject.toml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
[project]
2-
name = "lsap-schema"
2+
name = "lsap"
33
version = "0.1.0"
44
description = "Add your description here"
55
readme = "README.md"
6-
authors = [
7-
{ name = "observerw", email = "wozluohd@gmail.com" }
8-
]
96
requires-python = ">=3.12"
107
dependencies = [
8+
"anyio>=4.12.0",
9+
"asyncer>=0.0.11",
10+
"attrs>=25.4.0",
11+
"cattrs>=25.3.0",
12+
"lsp-client",
1113
"lsprotocol>=2025.0.0",
1214
"pydantic>=2.12.5",
1315
"python-liquid>=2.1.0",
@@ -17,7 +19,18 @@ dependencies = [
1719
requires = ["uv_build>=0.9.9,<0.10.0"]
1820
build-backend = "uv_build"
1921

22+
[tool.uv.workspace]
23+
members = ["lsap-schema"]
24+
25+
[tool.uv.sources]
26+
lsp-client = { git = "https://github.com/lsp-client/lsp-client.git", branch = "release/v0.3" }
27+
28+
[tool.pytest.ini_options]
29+
norecursedirs = ["references"]
30+
testpaths = ["tests"]
31+
2032
[dependency-groups]
2133
dev = [
2234
"pytest>=9.0.2",
35+
"pytest-asyncio>=1.3.0",
2336
]

python/.gitignore

Lines changed: 0 additions & 14 deletions
This file was deleted.

python/.ignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

python/.python-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)