lean-lsp-mcp 0.16.0__py3-none-any.whl → 0.16.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lean_lsp_mcp/server.py +37 -31
- {lean_lsp_mcp-0.16.0.dist-info → lean_lsp_mcp-0.16.1.dist-info}/METADATA +1 -1
- {lean_lsp_mcp-0.16.0.dist-info → lean_lsp_mcp-0.16.1.dist-info}/RECORD +7 -7
- {lean_lsp_mcp-0.16.0.dist-info → lean_lsp_mcp-0.16.1.dist-info}/WHEEL +0 -0
- {lean_lsp_mcp-0.16.0.dist-info → lean_lsp_mcp-0.16.1.dist-info}/entry_points.txt +0 -0
- {lean_lsp_mcp-0.16.0.dist-info → lean_lsp_mcp-0.16.1.dist-info}/licenses/LICENSE +0 -0
- {lean_lsp_mcp-0.16.0.dist-info → lean_lsp_mcp-0.16.1.dist-info}/top_level.txt +0 -0
lean_lsp_mcp/server.py
CHANGED
|
@@ -9,7 +9,6 @@ from dataclasses import dataclass
|
|
|
9
9
|
import urllib
|
|
10
10
|
import orjson
|
|
11
11
|
import functools
|
|
12
|
-
import subprocess
|
|
13
12
|
import uuid
|
|
14
13
|
from pathlib import Path
|
|
15
14
|
|
|
@@ -196,7 +195,7 @@ def rate_limited(category: str, max_requests: int, per_seconds: int):
|
|
|
196
195
|
annotations=ToolAnnotations(
|
|
197
196
|
title="Build Project",
|
|
198
197
|
readOnlyHint=False,
|
|
199
|
-
destructiveHint=
|
|
198
|
+
destructiveHint=True,
|
|
200
199
|
idempotentHint=True,
|
|
201
200
|
openWorldHint=False,
|
|
202
201
|
),
|
|
@@ -207,6 +206,9 @@ async def lsp_build(
|
|
|
207
206
|
Optional[str], Field(description="Path to Lean project")
|
|
208
207
|
] = None,
|
|
209
208
|
clean: Annotated[bool, Field(description="Run lake clean first (slow)")] = False,
|
|
209
|
+
output_lines: Annotated[
|
|
210
|
+
int, Field(description="Return last N lines of build log (0=none)")
|
|
211
|
+
] = 20,
|
|
210
212
|
) -> BuildResult:
|
|
211
213
|
"""Build the Lean project and restart LSP. Use only if needed (e.g. new imports)."""
|
|
212
214
|
if not lean_project_path:
|
|
@@ -220,7 +222,7 @@ async def lsp_build(
|
|
|
220
222
|
"Lean project path not known yet. Provide `lean_project_path` explicitly or call another tool first."
|
|
221
223
|
)
|
|
222
224
|
|
|
223
|
-
|
|
225
|
+
log_lines: List[str] = []
|
|
224
226
|
errors: List[str] = []
|
|
225
227
|
|
|
226
228
|
try:
|
|
@@ -230,13 +232,21 @@ async def lsp_build(
|
|
|
230
232
|
client.close()
|
|
231
233
|
|
|
232
234
|
if clean:
|
|
233
|
-
|
|
234
|
-
|
|
235
|
+
await ctx.report_progress(
|
|
236
|
+
progress=1, total=16, message="Running `lake clean`"
|
|
237
|
+
)
|
|
238
|
+
clean_proc = await asyncio.create_subprocess_exec(
|
|
239
|
+
"lake", "clean", cwd=lean_project_path_obj
|
|
240
|
+
)
|
|
241
|
+
await clean_proc.wait()
|
|
235
242
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
243
|
+
await ctx.report_progress(
|
|
244
|
+
progress=2, total=16, message="Running `lake exe cache get`"
|
|
245
|
+
)
|
|
246
|
+
cache_proc = await asyncio.create_subprocess_exec(
|
|
247
|
+
"lake", "exe", "cache", "get", cwd=lean_project_path_obj
|
|
239
248
|
)
|
|
249
|
+
await cache_proc.wait()
|
|
240
250
|
|
|
241
251
|
# Run build with progress reporting
|
|
242
252
|
process = await asyncio.create_subprocess_exec(
|
|
@@ -248,32 +258,24 @@ async def lsp_build(
|
|
|
248
258
|
stderr=asyncio.subprocess.STDOUT,
|
|
249
259
|
)
|
|
250
260
|
|
|
251
|
-
while
|
|
252
|
-
line = await process.stdout.readline()
|
|
253
|
-
if not line:
|
|
254
|
-
break
|
|
255
|
-
|
|
261
|
+
while line := await process.stdout.readline():
|
|
256
262
|
line_str = line.decode("utf-8", errors="replace").rstrip()
|
|
257
|
-
output_lines.append(line_str)
|
|
258
263
|
|
|
259
|
-
|
|
264
|
+
if line_str.startswith("trace:") or "LEAN_PATH=" in line_str:
|
|
265
|
+
continue
|
|
266
|
+
|
|
267
|
+
log_lines.append(line_str)
|
|
260
268
|
if "error" in line_str.lower():
|
|
261
269
|
errors.append(line_str)
|
|
262
270
|
|
|
263
|
-
# Parse progress:
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
total_jobs = int(match.group(2))
|
|
268
|
-
|
|
269
|
-
# Extract what's being built
|
|
270
|
-
desc_match = re.search(
|
|
271
|
-
r"\[\d+/\d+\]\s+(.+?)(?:\s+\(\d+\.?\d*[ms]+\))?$", line_str
|
|
272
|
-
)
|
|
273
|
-
description = desc_match.group(1) if desc_match else "Building"
|
|
274
|
-
|
|
271
|
+
# Parse progress: "[2/8] Building Foo (1.2s)" -> (2, 8, "Building Foo")
|
|
272
|
+
if m := re.search(
|
|
273
|
+
r"\[(\d+)/(\d+)\]\s*(.+?)(?:\s+\(\d+\.?\d*[ms]+\))?$", line_str
|
|
274
|
+
):
|
|
275
275
|
await ctx.report_progress(
|
|
276
|
-
progress=
|
|
276
|
+
progress=int(m.group(1)),
|
|
277
|
+
total=int(m.group(2)),
|
|
278
|
+
message=m.group(3) or "Building",
|
|
277
279
|
)
|
|
278
280
|
|
|
279
281
|
await process.wait()
|
|
@@ -281,7 +283,7 @@ async def lsp_build(
|
|
|
281
283
|
if process.returncode != 0:
|
|
282
284
|
return BuildResult(
|
|
283
285
|
success=False,
|
|
284
|
-
output="\n".join(output_lines),
|
|
286
|
+
output="\n".join(log_lines[-output_lines:]) if output_lines else "",
|
|
285
287
|
errors=errors
|
|
286
288
|
or [f"Build failed with return code {process.returncode}"],
|
|
287
289
|
)
|
|
@@ -295,12 +297,16 @@ async def lsp_build(
|
|
|
295
297
|
logger.info("Built project and re-started LSP client")
|
|
296
298
|
ctx.request_context.lifespan_context.client = client
|
|
297
299
|
|
|
298
|
-
return BuildResult(
|
|
300
|
+
return BuildResult(
|
|
301
|
+
success=True,
|
|
302
|
+
output="\n".join(log_lines[-output_lines:]) if output_lines else "",
|
|
303
|
+
errors=[],
|
|
304
|
+
)
|
|
299
305
|
|
|
300
306
|
except Exception as e:
|
|
301
307
|
return BuildResult(
|
|
302
308
|
success=False,
|
|
303
|
-
output="\n".join(output_lines),
|
|
309
|
+
output="\n".join(log_lines[-output_lines:]) if output_lines else "",
|
|
304
310
|
errors=[str(e)],
|
|
305
311
|
)
|
|
306
312
|
|
|
@@ -7,11 +7,11 @@ lean_lsp_mcp/loogle.py,sha256=ChybtPM8jOxP8s28358yNqcLiYvGlQqkAEFFLzR87Zw,11971
|
|
|
7
7
|
lean_lsp_mcp/models.py,sha256=M8CmTg0_NL7KwcQ7UX_Zk7ZG1zXoWLINr41NPs_no2Y,4301
|
|
8
8
|
lean_lsp_mcp/outline_utils.py,sha256=-eoZNbx2eaKaYmuyFJnwUMWP8I9YXNWusue_2OYpDBM,10981
|
|
9
9
|
lean_lsp_mcp/search_utils.py,sha256=X2LPynDNLi767UDxbxHpMccOkbnfKJKv_HxvRNxIXM4,3984
|
|
10
|
-
lean_lsp_mcp/server.py,sha256=
|
|
10
|
+
lean_lsp_mcp/server.py,sha256=8QEkRlbLEKif4NfagD2l1min1w1IFF7Jw1TUUOK-xFg,39481
|
|
11
11
|
lean_lsp_mcp/utils.py,sha256=355kzyB3dkwU7_4Mfcg--JXEorFaE2gtqs6-HbH5rRE,11722
|
|
12
|
-
lean_lsp_mcp-0.16.
|
|
13
|
-
lean_lsp_mcp-0.16.
|
|
14
|
-
lean_lsp_mcp-0.16.
|
|
15
|
-
lean_lsp_mcp-0.16.
|
|
16
|
-
lean_lsp_mcp-0.16.
|
|
17
|
-
lean_lsp_mcp-0.16.
|
|
12
|
+
lean_lsp_mcp-0.16.1.dist-info/licenses/LICENSE,sha256=CQlxnf0tQyoVrBE93JYvAUYxv6Z5Yg6sX0pwogOkFvo,1071
|
|
13
|
+
lean_lsp_mcp-0.16.1.dist-info/METADATA,sha256=nwfjUYlagiUb49IkT3AWoOmJwH4fnwJ5ElyvD9V8zGw,20819
|
|
14
|
+
lean_lsp_mcp-0.16.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
15
|
+
lean_lsp_mcp-0.16.1.dist-info/entry_points.txt,sha256=nQbvwctWkWD7I-2f4VrdVQBZYGUw8CnUnFC6QjXxOSE,51
|
|
16
|
+
lean_lsp_mcp-0.16.1.dist-info/top_level.txt,sha256=LGEK0lgMSNPIQ6mG8EO-adaZEGPi_0daDs004epOTF0,13
|
|
17
|
+
lean_lsp_mcp-0.16.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|