lean-probe 0.2.0__tar.gz → 0.2.2__tar.gz

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.
Files changed (22) hide show
  1. {lean_probe-0.2.0/src/lean_probe.egg-info → lean_probe-0.2.2}/PKG-INFO +30 -6
  2. {lean_probe-0.2.0 → lean_probe-0.2.2}/README.md +29 -5
  3. {lean_probe-0.2.0 → lean_probe-0.2.2}/pyproject.toml +1 -1
  4. {lean_probe-0.2.0 → lean_probe-0.2.2}/src/lean_probe/cli.py +7 -1
  5. {lean_probe-0.2.0 → lean_probe-0.2.2}/src/lean_probe/mcp_server.py +14 -0
  6. {lean_probe-0.2.0 → lean_probe-0.2.2/src/lean_probe.egg-info}/PKG-INFO +30 -6
  7. {lean_probe-0.2.0 → lean_probe-0.2.2}/tests/test_cli.py +15 -0
  8. {lean_probe-0.2.0 → lean_probe-0.2.2}/tests/test_mcp_server.py +9 -0
  9. {lean_probe-0.2.0 → lean_probe-0.2.2}/LICENSE +0 -0
  10. {lean_probe-0.2.0 → lean_probe-0.2.2}/setup.cfg +0 -0
  11. {lean_probe-0.2.0 → lean_probe-0.2.2}/src/lean_probe/__init__.py +0 -0
  12. {lean_probe-0.2.0 → lean_probe-0.2.2}/src/lean_probe/benchmark.py +0 -0
  13. {lean_probe-0.2.0 → lean_probe-0.2.2}/src/lean_probe/core.py +0 -0
  14. {lean_probe-0.2.0 → lean_probe-0.2.2}/src/lean_probe/py.typed +0 -0
  15. {lean_probe-0.2.0 → lean_probe-0.2.2}/src/lean_probe.egg-info/SOURCES.txt +0 -0
  16. {lean_probe-0.2.0 → lean_probe-0.2.2}/src/lean_probe.egg-info/dependency_links.txt +0 -0
  17. {lean_probe-0.2.0 → lean_probe-0.2.2}/src/lean_probe.egg-info/entry_points.txt +0 -0
  18. {lean_probe-0.2.0 → lean_probe-0.2.2}/src/lean_probe.egg-info/requires.txt +0 -0
  19. {lean_probe-0.2.0 → lean_probe-0.2.2}/src/lean_probe.egg-info/top_level.txt +0 -0
  20. {lean_probe-0.2.0 → lean_probe-0.2.2}/tests/test_benchmark.py +0 -0
  21. {lean_probe-0.2.0 → lean_probe-0.2.2}/tests/test_core.py +0 -0
  22. {lean_probe-0.2.0 → lean_probe-0.2.2}/tests/test_integration.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lean-probe
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: Fast Lean 4 proof feedback for agents, powered by LeanInteract.
5
5
  Author: LeanProbe contributors
6
6
  License-Expression: MIT
@@ -52,8 +52,9 @@ acceptance.
52
52
  ## MCP Tools
53
53
 
54
54
  LeanProbe exposes the MCP server name `lean-probe` and the tools
55
- `lean_probe_prepare`, `lean_probe_check`, `lean_probe_feedback`,
56
- `lean_probe_state`, `lean_probe_step`, and `lean_probe_close_state`.
55
+ `lean_probe_capabilities`, `lean_probe_prepare`, `lean_probe_check`,
56
+ `lean_probe_feedback`, `lean_probe_state`, `lean_probe_step`, and
57
+ `lean_probe_close_state`.
57
58
 
58
59
  For MCP parameter details, result-field semantics, and `feedback_lean` examples,
59
60
  see [AGENT.md](AGENT.md).
@@ -96,6 +97,21 @@ The benchmark suite measures two cases:
96
97
  - sequential same-file checks: prepare a header once, then advance declaration by
97
98
  declaration with env reuse.
98
99
 
100
+ ## How It Differs From LSP MCP Tools
101
+
102
+ LeanProbe and LSP-backed Lean MCP servers are complementary. Tools such as
103
+ `lean-lsp-mcp` are broad project-navigation and interaction layers over
104
+ `lake serve`: they are the better fit for file-position diagnostics, goals,
105
+ hover information, references, completions, code actions, widgets, and theorem
106
+ search integrations.
107
+
108
+ LeanProbe is narrower: it screens complete declaration replacements against a
109
+ cached LeanInteract environment, exposes proof-state stepping for standalone
110
+ snippets, and benchmarks declaration-level agent loops against `lake env lean`.
111
+ Use it when an agent is trying many candidate declarations or moving through a
112
+ file in source order. Use an LSP MCP beside it when the agent needs editor-like
113
+ semantic context around the file.
114
+
99
115
  ## Install
100
116
 
101
117
  LeanProbe is a Python package that talks to Lean through LeanInteract. `pip`
@@ -144,7 +160,7 @@ Check the Python package and CLI:
144
160
 
145
161
  ```bash
146
162
  python -c "import lean_probe, lean_interact; print('ok')"
147
- lean-probe --version # lean-probe 0.2.0
163
+ lean-probe --version # lean-probe 0.2.2
148
164
  ```
149
165
 
150
166
  Check that Lean/Lake are visible:
@@ -185,6 +201,8 @@ repository with `python -m pytest -q`.
185
201
  ```bash
186
202
  lean-probe prepare /path/to/File.lean --cwd /path/to/lake-project --theorem-id my_theorem
187
203
 
204
+ lean-probe capabilities --cwd /path/to/lake-project --pretty
205
+
188
206
  lean-probe check /path/to/File.lean my_theorem \
189
207
  --cwd /path/to/lake-project \
190
208
  --replacement-file /tmp/candidate.lean \
@@ -280,14 +298,20 @@ Example MCP configuration with LeanProbe environment variables:
280
298
  "args": ["mcp"],
281
299
  "env": {
282
300
  "LEAN_PROBE_LAKE_PATH": "/opt/homebrew/bin/lake",
283
- "LEAN_PROBE_AUTO_BUILD": "1"
301
+ "LEAN_PROBE_AUTO_BUILD": "0"
284
302
  }
285
303
  }
286
304
  }
287
305
  }
288
306
  ```
289
307
 
290
- Use `lean_probe_prepare` before repeated checks in the same file, then call
308
+ For stdio MCP clients such as Codex, keep `LEAN_PROBE_AUTO_BUILD=0` and build
309
+ the Lean project from a terminal before using LeanProbe. Some Lean/Lake build
310
+ commands print progress to stdout; stdout is reserved for MCP JSON-RPC frames,
311
+ so build output can corrupt the transport.
312
+
313
+ Use `lean_probe_capabilities` when setup is uncertain. Use
314
+ `lean_probe_prepare` before repeated checks in the same file, then call
291
315
  `lean_probe_check` for concrete target declarations or replacements. When
292
316
  ordinary diagnostics are not enough, call `lean_probe_feedback` and inspect
293
317
  `messages`, `tactics`, and `feedback_lean`. See [AGENT.md](AGENT.md) for the
@@ -15,8 +15,9 @@ acceptance.
15
15
  ## MCP Tools
16
16
 
17
17
  LeanProbe exposes the MCP server name `lean-probe` and the tools
18
- `lean_probe_prepare`, `lean_probe_check`, `lean_probe_feedback`,
19
- `lean_probe_state`, `lean_probe_step`, and `lean_probe_close_state`.
18
+ `lean_probe_capabilities`, `lean_probe_prepare`, `lean_probe_check`,
19
+ `lean_probe_feedback`, `lean_probe_state`, `lean_probe_step`, and
20
+ `lean_probe_close_state`.
20
21
 
21
22
  For MCP parameter details, result-field semantics, and `feedback_lean` examples,
22
23
  see [AGENT.md](AGENT.md).
@@ -59,6 +60,21 @@ The benchmark suite measures two cases:
59
60
  - sequential same-file checks: prepare a header once, then advance declaration by
60
61
  declaration with env reuse.
61
62
 
63
+ ## How It Differs From LSP MCP Tools
64
+
65
+ LeanProbe and LSP-backed Lean MCP servers are complementary. Tools such as
66
+ `lean-lsp-mcp` are broad project-navigation and interaction layers over
67
+ `lake serve`: they are the better fit for file-position diagnostics, goals,
68
+ hover information, references, completions, code actions, widgets, and theorem
69
+ search integrations.
70
+
71
+ LeanProbe is narrower: it screens complete declaration replacements against a
72
+ cached LeanInteract environment, exposes proof-state stepping for standalone
73
+ snippets, and benchmarks declaration-level agent loops against `lake env lean`.
74
+ Use it when an agent is trying many candidate declarations or moving through a
75
+ file in source order. Use an LSP MCP beside it when the agent needs editor-like
76
+ semantic context around the file.
77
+
62
78
  ## Install
63
79
 
64
80
  LeanProbe is a Python package that talks to Lean through LeanInteract. `pip`
@@ -107,7 +123,7 @@ Check the Python package and CLI:
107
123
 
108
124
  ```bash
109
125
  python -c "import lean_probe, lean_interact; print('ok')"
110
- lean-probe --version # lean-probe 0.2.0
126
+ lean-probe --version # lean-probe 0.2.2
111
127
  ```
112
128
 
113
129
  Check that Lean/Lake are visible:
@@ -148,6 +164,8 @@ repository with `python -m pytest -q`.
148
164
  ```bash
149
165
  lean-probe prepare /path/to/File.lean --cwd /path/to/lake-project --theorem-id my_theorem
150
166
 
167
+ lean-probe capabilities --cwd /path/to/lake-project --pretty
168
+
151
169
  lean-probe check /path/to/File.lean my_theorem \
152
170
  --cwd /path/to/lake-project \
153
171
  --replacement-file /tmp/candidate.lean \
@@ -243,14 +261,20 @@ Example MCP configuration with LeanProbe environment variables:
243
261
  "args": ["mcp"],
244
262
  "env": {
245
263
  "LEAN_PROBE_LAKE_PATH": "/opt/homebrew/bin/lake",
246
- "LEAN_PROBE_AUTO_BUILD": "1"
264
+ "LEAN_PROBE_AUTO_BUILD": "0"
247
265
  }
248
266
  }
249
267
  }
250
268
  }
251
269
  ```
252
270
 
253
- Use `lean_probe_prepare` before repeated checks in the same file, then call
271
+ For stdio MCP clients such as Codex, keep `LEAN_PROBE_AUTO_BUILD=0` and build
272
+ the Lean project from a terminal before using LeanProbe. Some Lean/Lake build
273
+ commands print progress to stdout; stdout is reserved for MCP JSON-RPC frames,
274
+ so build output can corrupt the transport.
275
+
276
+ Use `lean_probe_capabilities` when setup is uncertain. Use
277
+ `lean_probe_prepare` before repeated checks in the same file, then call
254
278
  `lean_probe_check` for concrete target declarations or replacements. When
255
279
  ordinary diagnostics are not enough, call `lean_probe_feedback` and inspect
256
280
  `messages`, `tactics`, and `feedback_lean`. See [AGENT.md](AGENT.md) for the
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "lean-probe"
7
- version = "0.2.0"
7
+ version = "0.2.2"
8
8
  description = "Fast Lean 4 proof feedback for agents, powered by LeanInteract."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -64,6 +64,8 @@ def build_parser() -> argparse.ArgumentParser:
64
64
  common_parent.add_argument("--verbose", action="store_true", help="Enable LeanInteract verbose setup")
65
65
  common_parent.add_argument("--pretty", action="store_true", help="Pretty-print JSON")
66
66
 
67
+ sub.add_parser("capabilities", parents=[common_parent], help="Report LeanProbe readiness and live sessions")
68
+
67
69
  prepare = sub.add_parser("prepare", parents=[common_parent], help="Warm imports and optional prior declarations")
68
70
  prepare.add_argument("file_path")
69
71
  prepare.add_argument("--theorem-id", default="")
@@ -249,7 +251,9 @@ def main(argv: list[str] | None = None) -> int:
249
251
 
250
252
  probe = _probe_from_args(args)
251
253
  try:
252
- if args.command == "prepare":
254
+ if args.command == "capabilities":
255
+ payload = probe.capabilities(cwd=args.cwd or None)
256
+ elif args.command == "prepare":
253
257
  payload = probe.prepare_file(
254
258
  args.file_path,
255
259
  theorem_id=args.theorem_id,
@@ -305,6 +309,8 @@ def main(argv: list[str] | None = None) -> int:
305
309
  probe.close()
306
310
 
307
311
  _emit(payload, pretty=bool(getattr(args, "pretty", False)))
312
+ if args.command == "capabilities":
313
+ return 0 if payload.get("available") else 1
308
314
  return 0 if payload.get("success") else 1
309
315
 
310
316
 
@@ -25,6 +25,7 @@ def ParamField(*, description: str) -> Any:
25
25
 
26
26
  MCP_SERVER_NAME = "lean-probe"
27
27
  TOOL_NAMES = [
28
+ "lean_probe_capabilities",
28
29
  "lean_probe_prepare",
29
30
  "lean_probe_check",
30
31
  "lean_probe_feedback",
@@ -105,6 +106,19 @@ def create_server(probe: LeanProbe | None = None) -> Any:
105
106
  active_probe = probe or _probe_from_env()
106
107
  mcp = FastMCP(MCP_SERVER_NAME)
107
108
 
109
+ @mcp.tool()
110
+ def lean_probe_capabilities(
111
+ cwd: Cwd = "",
112
+ ) -> dict[str, Any]:
113
+ """Report LeanProbe readiness, selected project root/REPL, and live sessions.
114
+
115
+ Use this first when setup is uncertain. `available=false` means the
116
+ response includes `degraded_codes` and `degraded_reasons` describing
117
+ missing LeanInteract support, project-root detection, or REPL setup.
118
+ """
119
+
120
+ return active_probe.capabilities(cwd=cwd or None)
121
+
108
122
  @mcp.tool()
109
123
  def lean_probe_prepare(
110
124
  file_path: FilePath,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lean-probe
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: Fast Lean 4 proof feedback for agents, powered by LeanInteract.
5
5
  Author: LeanProbe contributors
6
6
  License-Expression: MIT
@@ -52,8 +52,9 @@ acceptance.
52
52
  ## MCP Tools
53
53
 
54
54
  LeanProbe exposes the MCP server name `lean-probe` and the tools
55
- `lean_probe_prepare`, `lean_probe_check`, `lean_probe_feedback`,
56
- `lean_probe_state`, `lean_probe_step`, and `lean_probe_close_state`.
55
+ `lean_probe_capabilities`, `lean_probe_prepare`, `lean_probe_check`,
56
+ `lean_probe_feedback`, `lean_probe_state`, `lean_probe_step`, and
57
+ `lean_probe_close_state`.
57
58
 
58
59
  For MCP parameter details, result-field semantics, and `feedback_lean` examples,
59
60
  see [AGENT.md](AGENT.md).
@@ -96,6 +97,21 @@ The benchmark suite measures two cases:
96
97
  - sequential same-file checks: prepare a header once, then advance declaration by
97
98
  declaration with env reuse.
98
99
 
100
+ ## How It Differs From LSP MCP Tools
101
+
102
+ LeanProbe and LSP-backed Lean MCP servers are complementary. Tools such as
103
+ `lean-lsp-mcp` are broad project-navigation and interaction layers over
104
+ `lake serve`: they are the better fit for file-position diagnostics, goals,
105
+ hover information, references, completions, code actions, widgets, and theorem
106
+ search integrations.
107
+
108
+ LeanProbe is narrower: it screens complete declaration replacements against a
109
+ cached LeanInteract environment, exposes proof-state stepping for standalone
110
+ snippets, and benchmarks declaration-level agent loops against `lake env lean`.
111
+ Use it when an agent is trying many candidate declarations or moving through a
112
+ file in source order. Use an LSP MCP beside it when the agent needs editor-like
113
+ semantic context around the file.
114
+
99
115
  ## Install
100
116
 
101
117
  LeanProbe is a Python package that talks to Lean through LeanInteract. `pip`
@@ -144,7 +160,7 @@ Check the Python package and CLI:
144
160
 
145
161
  ```bash
146
162
  python -c "import lean_probe, lean_interact; print('ok')"
147
- lean-probe --version # lean-probe 0.2.0
163
+ lean-probe --version # lean-probe 0.2.2
148
164
  ```
149
165
 
150
166
  Check that Lean/Lake are visible:
@@ -185,6 +201,8 @@ repository with `python -m pytest -q`.
185
201
  ```bash
186
202
  lean-probe prepare /path/to/File.lean --cwd /path/to/lake-project --theorem-id my_theorem
187
203
 
204
+ lean-probe capabilities --cwd /path/to/lake-project --pretty
205
+
188
206
  lean-probe check /path/to/File.lean my_theorem \
189
207
  --cwd /path/to/lake-project \
190
208
  --replacement-file /tmp/candidate.lean \
@@ -280,14 +298,20 @@ Example MCP configuration with LeanProbe environment variables:
280
298
  "args": ["mcp"],
281
299
  "env": {
282
300
  "LEAN_PROBE_LAKE_PATH": "/opt/homebrew/bin/lake",
283
- "LEAN_PROBE_AUTO_BUILD": "1"
301
+ "LEAN_PROBE_AUTO_BUILD": "0"
284
302
  }
285
303
  }
286
304
  }
287
305
  }
288
306
  ```
289
307
 
290
- Use `lean_probe_prepare` before repeated checks in the same file, then call
308
+ For stdio MCP clients such as Codex, keep `LEAN_PROBE_AUTO_BUILD=0` and build
309
+ the Lean project from a terminal before using LeanProbe. Some Lean/Lake build
310
+ commands print progress to stdout; stdout is reserved for MCP JSON-RPC frames,
311
+ so build output can corrupt the transport.
312
+
313
+ Use `lean_probe_capabilities` when setup is uncertain. Use
314
+ `lean_probe_prepare` before repeated checks in the same file, then call
291
315
  `lean_probe_check` for concrete target declarations or replacements. When
292
316
  ordinary diagnostics are not enough, call `lean_probe_feedback` and inspect
293
317
  `messages`, `tactics`, and `feedback_lean`. See [AGENT.md](AGENT.md) for the
@@ -101,6 +101,21 @@ def test_cli_check_outputs_json(monkeypatch, tmp_path, capsys):
101
101
  assert output["target"] == "demo"
102
102
 
103
103
 
104
+ def test_cli_capabilities_outputs_readiness(monkeypatch, tmp_path, capsys):
105
+ _install_fake_lean_interact(monkeypatch)
106
+ project = tmp_path / "Demo"
107
+ project.mkdir()
108
+ (project / "lakefile.lean").write_text("import Lake\n", encoding="utf-8")
109
+
110
+ code = cli.main(["capabilities", "--cwd", str(project)])
111
+ output = json.loads(capsys.readouterr().out)
112
+
113
+ assert code == 0
114
+ assert output["available"] is True
115
+ assert output["project_root"] == str(project)
116
+ assert output["degraded_codes"] == []
117
+
118
+
104
119
  def test_cli_prepare_and_feedback_pretty(monkeypatch, tmp_path, capsys):
105
120
  _install_fake_lean_interact(monkeypatch)
106
121
  project = tmp_path / "Demo"
@@ -9,6 +9,9 @@ class _FakeProbe:
9
9
  def __init__(self):
10
10
  self.closed = False
11
11
 
12
+ def capabilities(self, *args, **kwargs):
13
+ return {"action": "capabilities", "args": args, "kwargs": kwargs}
14
+
12
15
  def prepare_file(self, *args, **kwargs):
13
16
  return {"action": "prepare", "args": args, "kwargs": kwargs}
14
17
 
@@ -34,6 +37,7 @@ class _FakeProbe:
34
37
  def test_mcp_public_names_are_stable():
35
38
  assert MCP_SERVER_NAME == "lean-probe"
36
39
  assert TOOL_NAMES == [
40
+ "lean_probe_capabilities",
37
41
  "lean_probe_prepare",
38
42
  "lean_probe_check",
39
43
  "lean_probe_feedback",
@@ -52,6 +56,8 @@ def test_mcp_tool_descriptions_expose_agent_contracts():
52
56
  server = create_server(probe=_FakeProbe())
53
57
  tools = server._tool_manager._tools
54
58
 
59
+ assert "readiness" in tools["lean_probe_capabilities"].description
60
+ assert "degraded_codes" in tools["lean_probe_capabilities"].description
55
61
  assert "cached only inside this running MCP server process" in tools["lean_probe_prepare"].description
56
62
  assert "complete declaration chunk" in tools["lean_probe_check"].description
57
63
  assert "success=false" in tools["lean_probe_check"].description
@@ -72,6 +78,7 @@ def test_mcp_tool_wrappers_call_injected_probe():
72
78
  server = create_server(probe=_FakeProbe())
73
79
  tools = server._tool_manager._tools
74
80
 
81
+ capabilities = tools["lean_probe_capabilities"].fn(cwd="/tmp/project")
75
82
  check = tools["lean_probe_check"].fn(
76
83
  file_path="Demo.lean",
77
84
  theorem_id="demo",
@@ -83,6 +90,8 @@ def test_mcp_tool_wrappers_call_injected_probe():
83
90
  step = tools["lean_probe_step"].fn(session_id="session", proof_state=3, tactic="rfl", timeout_s=5)
84
91
  close = tools["lean_probe_close_state"].fn(session_id="session")
85
92
 
93
+ assert capabilities["action"] == "capabilities"
94
+ assert capabilities["kwargs"]["cwd"] == "/tmp/project"
86
95
  assert check["action"] == "check"
87
96
  assert check["kwargs"]["cwd"] == "/tmp/project"
88
97
  assert check["kwargs"]["include_tactics"] is True
File without changes
File without changes