Skip to content

Commit cea4f8f

Browse files
committed
update
1 parent bc8f068 commit cea4f8f

23 files changed

+2740
-6
lines changed

.pre-commit-config.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.14.10
4+
hooks:
5+
- id: ruff
6+
args: [--fix]
7+
- id: ruff-format
8+
- repo: local
9+
hooks:
10+
- id: export-schemas
11+
name: Export LSAP Capability Schemas
12+
entry: bash -c "uv run python -m lsap.schema schema/ && git add schema/"
13+
language: system
14+
files: ^src/lsap/schema/.*\.py$
15+
pass_filenames: false

schema/definition.request.json

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
{
2+
"$defs": {
3+
"LineScope": {
4+
"description": "Scope by line range",
5+
"properties": {
6+
"line": {
7+
"anyOf": [
8+
{
9+
"type": "integer"
10+
},
11+
{
12+
"maxItems": 2,
13+
"minItems": 2,
14+
"prefixItems": [
15+
{
16+
"type": "integer"
17+
},
18+
{
19+
"type": "integer"
20+
}
21+
],
22+
"type": "array"
23+
}
24+
],
25+
"title": "Line"
26+
}
27+
},
28+
"required": [
29+
"line"
30+
],
31+
"title": "LineScope",
32+
"type": "object"
33+
},
34+
"Locate": {
35+
"description": "Two-stage location: scope \u2192 find.\n\nResolution rules:\n 1. SymbolScope without find: symbol declaration position (for references, rename)\n 2. With find containing marker: marker position\n 3. With find only: start of matched text\n 4. No scope + find: search entire file\n\nMarker Detection:\n The marker is automatically detected using nested bracket notation:\n - <|> (single level)\n - <<|>> (double level) if <|> appears more than once\n ... and so on\n\n The marker with the deepest nesting level that appears exactly once\n is chosen as the position marker.\n\nExamples:\n # Symbol declaration\n Locate(file_path=\"foo.py\", scope=SymbolScope(symbol_path=[\"MyClass\"]))\n\n # Completion trigger point - basic marker\n Locate(file_path=\"foo.py\", find=\"self.<|>\")\n\n # When <|> exists in source, use deeper nesting\n Locate(file_path=\"foo.py\", find=\"x = <|> + y <<|>> z\")\n # Will use <<|>> as the position marker\n\n # Specific location in function\n Locate(\n file_path=\"foo.py\",\n scope=SymbolScope(symbol_path=[\"process\"]),\n find=\"return <|>result\"\n )",
36+
"properties": {
37+
"file_path": {
38+
"format": "path",
39+
"title": "File Path",
40+
"type": "string"
41+
},
42+
"scope": {
43+
"anyOf": [
44+
{
45+
"$ref": "#/$defs/LineScope"
46+
},
47+
{
48+
"$ref": "#/$defs/SymbolScope"
49+
},
50+
{
51+
"type": "null"
52+
}
53+
],
54+
"default": null,
55+
"title": "Scope"
56+
},
57+
"find": {
58+
"anyOf": [
59+
{
60+
"type": "string"
61+
},
62+
{
63+
"type": "null"
64+
}
65+
],
66+
"default": null,
67+
"title": "Find"
68+
}
69+
},
70+
"required": [
71+
"file_path"
72+
],
73+
"title": "Locate",
74+
"type": "object"
75+
},
76+
"SymbolScope": {
77+
"description": "Scope by symbol, also serves as declaration locator when find is omitted",
78+
"properties": {
79+
"symbol_path": {
80+
"items": {
81+
"type": "string"
82+
},
83+
"title": "Symbol Path",
84+
"type": "array"
85+
}
86+
},
87+
"required": [
88+
"symbol_path"
89+
],
90+
"title": "SymbolScope",
91+
"type": "object"
92+
}
93+
},
94+
"description": "Finds the definition, declaration, or type definition of a symbol.\n\nUse this to jump to the actual source code where a symbol is defined,\nits declaration site, or the definition of its type/class.",
95+
"properties": {
96+
"locate": {
97+
"$ref": "#/$defs/Locate"
98+
},
99+
"mode": {
100+
"default": "definition",
101+
"enum": [
102+
"definition",
103+
"declaration",
104+
"type_definition"
105+
],
106+
"title": "Mode",
107+
"type": "string"
108+
}
109+
},
110+
"required": [
111+
"locate"
112+
],
113+
"title": "DefinitionRequest",
114+
"type": "object"
115+
}

schema/definition.response.json

Lines changed: 259 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,259 @@
1+
{
2+
"$defs": {
3+
"DefinitionRequest": {
4+
"description": "Finds the definition, declaration, or type definition of a symbol.\n\nUse this to jump to the actual source code where a symbol is defined,\nits declaration site, or the definition of its type/class.",
5+
"properties": {
6+
"locate": {
7+
"$ref": "#/$defs/Locate"
8+
},
9+
"mode": {
10+
"default": "definition",
11+
"enum": [
12+
"definition",
13+
"declaration",
14+
"type_definition"
15+
],
16+
"title": "Mode",
17+
"type": "string"
18+
}
19+
},
20+
"required": [
21+
"locate"
22+
],
23+
"title": "DefinitionRequest",
24+
"type": "object"
25+
},
26+
"LineScope": {
27+
"description": "Scope by line range",
28+
"properties": {
29+
"line": {
30+
"anyOf": [
31+
{
32+
"type": "integer"
33+
},
34+
{
35+
"maxItems": 2,
36+
"minItems": 2,
37+
"prefixItems": [
38+
{
39+
"type": "integer"
40+
},
41+
{
42+
"type": "integer"
43+
}
44+
],
45+
"type": "array"
46+
}
47+
],
48+
"title": "Line"
49+
}
50+
},
51+
"required": [
52+
"line"
53+
],
54+
"title": "LineScope",
55+
"type": "object"
56+
},
57+
"Locate": {
58+
"description": "Two-stage location: scope \u2192 find.\n\nResolution rules:\n 1. SymbolScope without find: symbol declaration position (for references, rename)\n 2. With find containing marker: marker position\n 3. With find only: start of matched text\n 4. No scope + find: search entire file\n\nMarker Detection:\n The marker is automatically detected using nested bracket notation:\n - <|> (single level)\n - <<|>> (double level) if <|> appears more than once\n ... and so on\n\n The marker with the deepest nesting level that appears exactly once\n is chosen as the position marker.\n\nExamples:\n # Symbol declaration\n Locate(file_path=\"foo.py\", scope=SymbolScope(symbol_path=[\"MyClass\"]))\n\n # Completion trigger point - basic marker\n Locate(file_path=\"foo.py\", find=\"self.<|>\")\n\n # When <|> exists in source, use deeper nesting\n Locate(file_path=\"foo.py\", find=\"x = <|> + y <<|>> z\")\n # Will use <<|>> as the position marker\n\n # Specific location in function\n Locate(\n file_path=\"foo.py\",\n scope=SymbolScope(symbol_path=[\"process\"]),\n find=\"return <|>result\"\n )",
59+
"properties": {
60+
"file_path": {
61+
"format": "path",
62+
"title": "File Path",
63+
"type": "string"
64+
},
65+
"scope": {
66+
"anyOf": [
67+
{
68+
"$ref": "#/$defs/LineScope"
69+
},
70+
{
71+
"$ref": "#/$defs/SymbolScope"
72+
},
73+
{
74+
"type": "null"
75+
}
76+
],
77+
"default": null,
78+
"title": "Scope"
79+
},
80+
"find": {
81+
"anyOf": [
82+
{
83+
"type": "string"
84+
},
85+
{
86+
"type": "null"
87+
}
88+
],
89+
"default": null,
90+
"title": "Find"
91+
}
92+
},
93+
"required": [
94+
"file_path"
95+
],
96+
"title": "Locate",
97+
"type": "object"
98+
},
99+
"Position": {
100+
"description": "Represents a specific position in a file using line and character numbers.\n\nNote: Line and character are 1-based indices. 0-based indices are used in LSP, so conversion is needed when interfacing with LSP.",
101+
"properties": {
102+
"line": {
103+
"minimum": 1,
104+
"title": "Line",
105+
"type": "integer"
106+
},
107+
"character": {
108+
"minimum": 1,
109+
"title": "Character",
110+
"type": "integer"
111+
}
112+
},
113+
"required": [
114+
"line",
115+
"character"
116+
],
117+
"title": "Position",
118+
"type": "object"
119+
},
120+
"Range": {
121+
"properties": {
122+
"start": {
123+
"$ref": "#/$defs/Position"
124+
},
125+
"end": {
126+
"$ref": "#/$defs/Position"
127+
}
128+
},
129+
"required": [
130+
"start",
131+
"end"
132+
],
133+
"title": "Range",
134+
"type": "object"
135+
},
136+
"SymbolCodeInfo": {
137+
"properties": {
138+
"file_path": {
139+
"format": "path",
140+
"title": "File Path",
141+
"type": "string"
142+
},
143+
"name": {
144+
"title": "Name",
145+
"type": "string"
146+
},
147+
"path": {
148+
"items": {
149+
"type": "string"
150+
},
151+
"title": "Path",
152+
"type": "array"
153+
},
154+
"kind": {
155+
"$ref": "#/$defs/SymbolKind"
156+
},
157+
"range": {
158+
"anyOf": [
159+
{
160+
"$ref": "#/$defs/Range"
161+
},
162+
{
163+
"type": "null"
164+
}
165+
],
166+
"default": null
167+
},
168+
"code": {
169+
"anyOf": [
170+
{
171+
"type": "string"
172+
},
173+
{
174+
"type": "null"
175+
}
176+
],
177+
"default": null,
178+
"title": "Code"
179+
}
180+
},
181+
"required": [
182+
"file_path",
183+
"name",
184+
"path",
185+
"kind"
186+
],
187+
"title": "SymbolCodeInfo",
188+
"type": "object"
189+
},
190+
"SymbolKind": {
191+
"enum": [
192+
"file",
193+
"module",
194+
"namespace",
195+
"package",
196+
"class",
197+
"method",
198+
"property",
199+
"field",
200+
"constructor",
201+
"enum",
202+
"interface",
203+
"function",
204+
"variable",
205+
"constant",
206+
"string",
207+
"number",
208+
"boolean",
209+
"array",
210+
"object",
211+
"key",
212+
"null",
213+
"enumMember",
214+
"struct",
215+
"event",
216+
"operator",
217+
"typeParameter"
218+
],
219+
"title": "SymbolKind",
220+
"type": "string"
221+
},
222+
"SymbolScope": {
223+
"description": "Scope by symbol, also serves as declaration locator when find is omitted",
224+
"properties": {
225+
"symbol_path": {
226+
"items": {
227+
"type": "string"
228+
},
229+
"title": "Symbol Path",
230+
"type": "array"
231+
}
232+
},
233+
"required": [
234+
"symbol_path"
235+
],
236+
"title": "SymbolScope",
237+
"type": "object"
238+
}
239+
},
240+
"markdown": "\n# {{ request.mode | replace: \"_\", \" \" | capitalize }} Result\n\n{% if items.size == 0 -%}\nNo {{ request.mode | replace: \"_\", \" \" }} found.\n{%- else -%}\n{%- for item in items -%}\n## `{{ item.file_path }}`: {{ item.path | join: \".\" }} (`{{ item.kind }}`)\n\n{% if item.code != nil -%}\n### Content\n```{{ item.file_path.suffix | remove_first: \".\" }}\n{{ item.code }}\n```\n{%- endif %}\n\n{% endfor -%}\n{%- endif %}\n",
241+
"properties": {
242+
"request": {
243+
"$ref": "#/$defs/DefinitionRequest"
244+
},
245+
"items": {
246+
"items": {
247+
"$ref": "#/$defs/SymbolCodeInfo"
248+
},
249+
"title": "Items",
250+
"type": "array"
251+
}
252+
},
253+
"required": [
254+
"request",
255+
"items"
256+
],
257+
"title": "DefinitionResponse",
258+
"type": "object"
259+
}

0 commit comments

Comments
 (0)