leanwarp 0.2.3__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.
- leanwarp-0.2.3/.gitignore +13 -0
- leanwarp-0.2.3/LICENSE +21 -0
- leanwarp-0.2.3/PKG-INFO +210 -0
- leanwarp-0.2.3/README.md +178 -0
- leanwarp-0.2.3/docs/README.md +16 -0
- leanwarp-0.2.3/docs/agents.md +97 -0
- leanwarp-0.2.3/docs/assets/leanwarp-banner.svg +7 -0
- leanwarp-0.2.3/docs/getting-started.md +180 -0
- leanwarp-0.2.3/docs/http-api.md +271 -0
- leanwarp-0.2.3/examples/lean-4.26/.gitignore +2 -0
- leanwarp-0.2.3/examples/lean-4.26/LeanWarpExample.lean +2 -0
- leanwarp-0.2.3/examples/lean-4.26/README.md +35 -0
- leanwarp-0.2.3/examples/lean-4.26/lake-manifest.json +95 -0
- leanwarp-0.2.3/examples/lean-4.26/lakefile.toml +8 -0
- leanwarp-0.2.3/examples/lean-4.26/lean-toolchain +1 -0
- leanwarp-0.2.3/examples/lean-4.34/.gitignore +2 -0
- leanwarp-0.2.3/examples/lean-4.34/LeanWarpExample.lean +2 -0
- leanwarp-0.2.3/examples/lean-4.34/README.md +35 -0
- leanwarp-0.2.3/examples/lean-4.34/lake-manifest.json +95 -0
- leanwarp-0.2.3/examples/lean-4.34/lakefile.toml +7 -0
- leanwarp-0.2.3/examples/lean-4.34/lean-toolchain +1 -0
- leanwarp-0.2.3/pyproject.toml +49 -0
- leanwarp-0.2.3/src/leanwarp_cloud/__init__.py +25 -0
- leanwarp-0.2.3/src/leanwarp_cloud/_version.py +8 -0
- leanwarp-0.2.3/src/leanwarp_cloud/agents.py +173 -0
- leanwarp-0.2.3/src/leanwarp_cloud/amounts.py +20 -0
- leanwarp-0.2.3/src/leanwarp_cloud/cli.py +700 -0
- leanwarp-0.2.3/src/leanwarp_cloud/client.py +781 -0
- leanwarp-0.2.3/src/leanwarp_cloud/config.py +82 -0
- leanwarp-0.2.3/src/leanwarp_cloud/edits.py +72 -0
- leanwarp-0.2.3/src/leanwarp_cloud/endpoints.py +39 -0
- leanwarp-0.2.3/src/leanwarp_cloud/mcp_server.py +568 -0
- leanwarp-0.2.3/src/leanwarp_cloud/outcome.py +112 -0
- leanwarp-0.2.3/src/leanwarp_cloud/project.py +613 -0
- leanwarp-0.2.3/src/leanwarp_cloud/py.typed +0 -0
- leanwarp-0.2.3/src/leanwarp_cloud/resources.py +50 -0
- leanwarp-0.2.3/src/leanwarp_cloud/session.py +1334 -0
- leanwarp-0.2.3/src/leanwarp_cloud/skills/leanwarp/SKILL.md +215 -0
- leanwarp-0.2.3/src/leanwarp_cloud/skills/leanwarp/references/usage.md +460 -0
- leanwarp-0.2.3/src/leanwarp_cloud/transport.py +221 -0
- leanwarp-0.2.3/src/leanwarp_cloud/updates.py +144 -0
- leanwarp-0.2.3/tests/__init__.py +0 -0
- leanwarp-0.2.3/tests/test_amounts.py +24 -0
- leanwarp-0.2.3/tests/test_client.py +722 -0
- leanwarp-0.2.3/tests/test_config.py +201 -0
- leanwarp-0.2.3/tests/test_deadline_transport.py +215 -0
- leanwarp-0.2.3/tests/test_environment_compatibility.py +311 -0
- leanwarp-0.2.3/tests/test_feedback.py +261 -0
- leanwarp-0.2.3/tests/test_install.py +299 -0
- leanwarp-0.2.3/tests/test_project.py +375 -0
- leanwarp-0.2.3/tests/test_resources.py +79 -0
- leanwarp-0.2.3/tests/test_session.py +1870 -0
- leanwarp-0.2.3/tests/test_tools.py +806 -0
leanwarp-0.2.3/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Isagoge Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
leanwarp-0.2.3/PKG-INFO
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: leanwarp
|
|
3
|
+
Version: 0.2.3
|
|
4
|
+
Summary: Check and verify Lean proofs on LeanWarp from the command line, MCP or Python
|
|
5
|
+
Project-URL: Repository, https://github.com/Isagoge-Labs/LeanWarp-SDK
|
|
6
|
+
Project-URL: Homepage, https://isagoge.in
|
|
7
|
+
Project-URL: Documentation, https://github.com/Isagoge-Labs/LeanWarp-SDK/blob/main/docs/README.md
|
|
8
|
+
Project-URL: Issues, https://github.com/Isagoge-Labs/LeanWarp-SDK/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/Isagoge-Labs/LeanWarp-SDK/releases
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: agents,formal-verification,lean,lean4,mathlib,mcp,theorem-proving
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: Operating System :: MacOS
|
|
17
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
18
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
23
|
+
Requires-Python: >=3.12
|
|
24
|
+
Requires-Dist: httpcore<2,>=1.0.9
|
|
25
|
+
Requires-Dist: httpx<1,>=0.28.1
|
|
26
|
+
Requires-Dist: mcp<2,>=1.28.1
|
|
27
|
+
Requires-Dist: pathspec<2,>=1.1
|
|
28
|
+
Requires-Dist: pydantic<3,>=2.12
|
|
29
|
+
Provides-Extra: test
|
|
30
|
+
Requires-Dist: pytest<10,>=8.4; extra == 'test'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
<h1><img src="https://raw.githubusercontent.com/Isagoge-Labs/LeanWarp-SDK/main/docs/assets/leanwarp-banner.svg" alt="LeanWarp" width="960"></h1>
|
|
34
|
+
|
|
35
|
+
LeanWarp checks and verifies Lean 4 proofs on hosted workers that stay warm
|
|
36
|
+
between edits. This SDK is how you and your agents use it: the `leanwarp`
|
|
37
|
+
command, an MCP server and a Python library.
|
|
38
|
+
|
|
39
|
+
**[Get started](https://github.com/Isagoge-Labs/LeanWarp-SDK/blob/main/docs/getting-started.md)** · [Agent setup](https://github.com/Isagoge-Labs/LeanWarp-SDK/blob/main/docs/agents.md) ·
|
|
40
|
+
[Reference](https://github.com/Isagoge-Labs/LeanWarp-SDK/blob/main/src/leanwarp_cloud/skills/leanwarp/references/usage.md) ·
|
|
41
|
+
[HTTP API](https://github.com/Isagoge-Labs/LeanWarp-SDK/blob/main/docs/http-api.md) · [Website](https://isagoge.in/leanwarp)
|
|
42
|
+
|
|
43
|
+
## What it does
|
|
44
|
+
|
|
45
|
+
| Operation | What you get | CLI |
|
|
46
|
+
| --- | --- | --- |
|
|
47
|
+
| Check | Lean's errors and warnings for a file; `--draft` reuses Lean's work on the unchanged part while you edit. | `leanwarp check` |
|
|
48
|
+
| Inspect | The goals and local context at a position in a proof. | `leanwarp inspect` |
|
|
49
|
+
| Try tactics | Several tactics from the same captured goal: which close it, which leave goals, which fail. The file is not edited. | `leanwarp try-tactics` |
|
|
50
|
+
| Verify | Whether a declaration proves exactly the statement you give, checked by Lean's kernel. | `leanwarp verify` |
|
|
51
|
+
| Holes | Every `sorry` and `?_` in a file, with its position, and the goals of the first 16. | `leanwarp holes` |
|
|
52
|
+
| Suggest | A tactic that closes a hole, accepted only if nothing else changes and the proof gains no unproved lemma or extra axiom. `apply` writes it into the file. | `leanwarp suggest`, `leanwarp apply` |
|
|
53
|
+
| Sorry to lemma | The proof of each theorem that still has a `sorry` moved into a new named lemma the theorem then uses; the lemma keeps its `sorry`. `apply` writes it. | `leanwarp sorry2lemma` |
|
|
54
|
+
| Declarations | The declarations a file adds, with their types and dependencies. | `leanwarp declarations` |
|
|
55
|
+
| Check files | Up to 64 files checked in one operation. | `leanwarp check-files` |
|
|
56
|
+
|
|
57
|
+
The [reference](https://github.com/Isagoge-Labs/LeanWarp-SDK/blob/main/src/leanwarp_cloud/skills/leanwarp/references/usage.md#commands)
|
|
58
|
+
lists every command and option; `leanwarp skill --reference` prints it.
|
|
59
|
+
|
|
60
|
+
### Coming soon
|
|
61
|
+
|
|
62
|
+
These are planned and not available yet:
|
|
63
|
+
|
|
64
|
+
- **Proof simplification**: replace a proof with a shorter one that still checks.
|
|
65
|
+
- **`have` extraction**: lift named `have` blocks into top-level lemmas.
|
|
66
|
+
- **Batch repair**: fill several holes in one operation.
|
|
67
|
+
|
|
68
|
+
## Install in two steps
|
|
69
|
+
|
|
70
|
+
**1. Install.** In a terminal, with [uv](https://docs.astral.sh/uv/getting-started/installation/):
|
|
71
|
+
|
|
72
|
+
```sh
|
|
73
|
+
uv tool install leanwarp && leanwarp setup
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
This installs the `leanwarp` command and its MCP server from
|
|
77
|
+
[PyPI](https://pypi.org/project/leanwarp/). `leanwarp setup` adds the LeanWarp
|
|
78
|
+
skill and MCP server to Claude Code, Codex and Cursor where they are installed,
|
|
79
|
+
and the skill to `~/.agents/skills`. It runs on Linux, macOS and WSL. You don't
|
|
80
|
+
need Lean installed: LeanWarp runs Lean and Mathlib for you.
|
|
81
|
+
|
|
82
|
+
Or paste this into your agent:
|
|
83
|
+
|
|
84
|
+
> Install LeanWarp: run `uv tool install leanwarp && leanwarp setup`, then ask me
|
|
85
|
+
> to sign in.
|
|
86
|
+
|
|
87
|
+
Already have LeanWarp 0.2 from GitHub? Its `leanwarp-sdk` tool owns the
|
|
88
|
+
`leanwarp` command, so replace it instead:
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
uv tool uninstall leanwarp-sdk && uv tool install leanwarp && leanwarp setup
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**2. Sign in**, in your own terminal:
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
leanwarp auth login
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
It opens the dashboard to create an API key; paste the key at the hidden prompt.
|
|
101
|
+
Never paste it into an agent conversation. Then restart your agent.
|
|
102
|
+
|
|
103
|
+
When a new release is out, results include `update_available`; run
|
|
104
|
+
`leanwarp update` to upgrade and refresh the installed skills.
|
|
105
|
+
|
|
106
|
+
## Quick start
|
|
107
|
+
|
|
108
|
+
From your Lean project or one of the [examples](https://github.com/Isagoge-Labs/LeanWarp-SDK/tree/main/examples):
|
|
109
|
+
|
|
110
|
+
```sh
|
|
111
|
+
leanwarp doctor # which environment this project runs on
|
|
112
|
+
leanwarp connect # create the project's workspace
|
|
113
|
+
leanwarp check LeanWarpExample.lean
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
If a command returns `success: null` (exit `3`), run `leanwarp wait` until it
|
|
117
|
+
finishes before submitting another operation. Then verify:
|
|
118
|
+
|
|
119
|
+
```sh
|
|
120
|
+
leanwarp verify LeanWarpExample.lean \
|
|
121
|
+
--declaration add_zero_example --target '∀ n : Nat, n + 0 = n'
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Wait for that operation to finish too, then run `leanwarp stop` when you are done.
|
|
125
|
+
|
|
126
|
+
Every command prints one JSON object. Results start with `success`: `true` when
|
|
127
|
+
the check passed or the proof was verified, `false` when it did not, and `null`
|
|
128
|
+
while the work is still running, in which case run `leanwarp wait`. The exit code
|
|
129
|
+
says the same thing: `0` passed, `1` did not pass, `2` the command failed, `3`
|
|
130
|
+
still running.
|
|
131
|
+
|
|
132
|
+
## Use with an agent
|
|
133
|
+
|
|
134
|
+
Give your agent the project directory and this instruction:
|
|
135
|
+
|
|
136
|
+
> Run `leanwarp skill` and follow it. Use LeanWarp to check this Lean project
|
|
137
|
+
> and verify proofs against their intended statements. Reuse the workspace
|
|
138
|
+
> while you edit, and run `leanwarp stop` when you are done.
|
|
139
|
+
|
|
140
|
+
For MCP clients, add the server `leanwarp --project /absolute/path/to/project mcp`,
|
|
141
|
+
or `uvx leanwarp --project /absolute/path/to/project mcp`
|
|
142
|
+
without installing. It uses the same key and project state as the CLI. See [agent setup](https://github.com/Isagoge-Labs/LeanWarp-SDK/blob/main/docs/agents.md).
|
|
143
|
+
Keep API keys out of prompts, source files and tool arguments.
|
|
144
|
+
|
|
145
|
+
## Your project and its environment
|
|
146
|
+
|
|
147
|
+
LeanWarp uploads only your `.lean` files. Lean, Mathlib and every other
|
|
148
|
+
dependency come from an **environment**: a Lean release with Mathlib, already
|
|
149
|
+
built on LeanWarp's workers. Run `leanwarp environments` to list them.
|
|
150
|
+
`leanwarp files` lists what would upload; patterns in `.gitignore` and
|
|
151
|
+
`.leanwarpignore` leave files out.
|
|
152
|
+
|
|
153
|
+
`leanwarp connect` picks the environment for you:
|
|
154
|
+
|
|
155
|
+
- If your project's `lean-toolchain` and `lake-manifest.json` match an
|
|
156
|
+
environment, it uses that one, so results agree with your local build.
|
|
157
|
+
- If your project has neither file, as with a folder of `.lean` files, it uses
|
|
158
|
+
the only served environment, or the newest served stable Lean release when there are several.
|
|
159
|
+
- If they match no environment, it stops and lists the ones available. Run
|
|
160
|
+
`leanwarp connect --environment NAME` to check your files there anyway; they
|
|
161
|
+
then compile against that environment's Lean and Mathlib.
|
|
162
|
+
|
|
163
|
+
To start a new project, copy one of the [examples](https://github.com/Isagoge-Labs/LeanWarp-SDK/tree/main/examples), which match the
|
|
164
|
+
environments LeanWarp serves.
|
|
165
|
+
|
|
166
|
+
## Billing
|
|
167
|
+
|
|
168
|
+
You pay from prepaid credit, billed by the second while a worker runs. Run
|
|
169
|
+
`leanwarp resources` to see the published worker's starting minute price, whether
|
|
170
|
+
charges depend on usage, startup credit hold and idle timeout. LeanWarp selects
|
|
171
|
+
the worker. Use `leanwarp connect --max-spend 2` to create a workspace with a $2
|
|
172
|
+
cap, or edit an existing cap in the dashboard. Reconnecting without a cap keeps
|
|
173
|
+
the saved cap.
|
|
174
|
+
|
|
175
|
+
When the worker uses usage billing, CPU and RAM charges increase independently
|
|
176
|
+
above their reserved baselines. The starting rate is a paid minimum while the
|
|
177
|
+
worker runs, including idle time. Bursting depends on available host capacity.
|
|
178
|
+
Otherwise, the listed minute rate applies for the time the worker runs. Existing
|
|
179
|
+
workspaces keep their saved billing terms.
|
|
180
|
+
|
|
181
|
+
A worker starts with your first operation and stays warm between calls. Run
|
|
182
|
+
`leanwarp stop` when finished; closing the SDK client or your terminal does not
|
|
183
|
+
stop it. Unused held credit is released once shutdown and final usage are confirmed.
|
|
184
|
+
Stopping keeps your uploaded files and
|
|
185
|
+
completed results; the next operation reconstructs the worker. Set a spending cap
|
|
186
|
+
for each workspace in the [dashboard](https://isagoge.in/dashboard).
|
|
187
|
+
|
|
188
|
+
## Concepts
|
|
189
|
+
|
|
190
|
+
| Term | Meaning |
|
|
191
|
+
| --- | --- |
|
|
192
|
+
| Environment | A Lean release with Mathlib, prebuilt on LeanWarp, such as `lean-4.26-mathlib`. |
|
|
193
|
+
| Workspace | Your project's files on LeanWarp. One per project; creating it starts no compute. |
|
|
194
|
+
| Worker | The machine that runs Lean for a workspace. It starts on demand and stays warm. |
|
|
195
|
+
| Operation | One request, such as a check or a verification, and its result. |
|
|
196
|
+
| Revision | A numbered version of the workspace's files. Each result names the one it checked. |
|
|
197
|
+
| Receipt | The part of a verification result that records exactly what was checked. |
|
|
198
|
+
|
|
199
|
+
## Documentation
|
|
200
|
+
|
|
201
|
+
| Start here | Reference |
|
|
202
|
+
| --- | --- |
|
|
203
|
+
| [Verify your first proof](https://github.com/Isagoge-Labs/LeanWarp-SDK/blob/main/docs/getting-started.md) | [Commands](https://github.com/Isagoge-Labs/LeanWarp-SDK/blob/main/src/leanwarp_cloud/skills/leanwarp/references/usage.md#commands) |
|
|
204
|
+
| [Set up an agent with the CLI or MCP](https://github.com/Isagoge-Labs/LeanWarp-SDK/blob/main/docs/agents.md) | [Results and exit codes](https://github.com/Isagoge-Labs/LeanWarp-SDK/blob/main/src/leanwarp_cloud/skills/leanwarp/references/usage.md#results) |
|
|
205
|
+
| [Use the Python library](https://github.com/Isagoge-Labs/LeanWarp-SDK/blob/main/src/leanwarp_cloud/skills/leanwarp/references/usage.md#python) | [Recover an interrupted request](https://github.com/Isagoge-Labs/LeanWarp-SDK/blob/main/src/leanwarp_cloud/skills/leanwarp/references/usage.md#recovery) |
|
|
206
|
+
| [Call the HTTP API directly](https://github.com/Isagoge-Labs/LeanWarp-SDK/blob/main/docs/http-api.md) | [Credentials, credit and limits](https://github.com/Isagoge-Labs/LeanWarp-SDK/blob/main/src/leanwarp_cloud/skills/leanwarp/references/usage.md#credentials-credit-and-limits) |
|
|
207
|
+
|
|
208
|
+
The agent instructions ship with the package: `leanwarp skill` prints the
|
|
209
|
+
workflow and `leanwarp skill --reference` the full reference. Run
|
|
210
|
+
`leanwarp --help` or `leanwarp COMMAND --help` for arguments.
|
leanwarp-0.2.3/README.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
<h1><img src="https://raw.githubusercontent.com/Isagoge-Labs/LeanWarp-SDK/main/docs/assets/leanwarp-banner.svg" alt="LeanWarp" width="960"></h1>
|
|
2
|
+
|
|
3
|
+
LeanWarp checks and verifies Lean 4 proofs on hosted workers that stay warm
|
|
4
|
+
between edits. This SDK is how you and your agents use it: the `leanwarp`
|
|
5
|
+
command, an MCP server and a Python library.
|
|
6
|
+
|
|
7
|
+
**[Get started](https://github.com/Isagoge-Labs/LeanWarp-SDK/blob/main/docs/getting-started.md)** · [Agent setup](https://github.com/Isagoge-Labs/LeanWarp-SDK/blob/main/docs/agents.md) ·
|
|
8
|
+
[Reference](https://github.com/Isagoge-Labs/LeanWarp-SDK/blob/main/src/leanwarp_cloud/skills/leanwarp/references/usage.md) ·
|
|
9
|
+
[HTTP API](https://github.com/Isagoge-Labs/LeanWarp-SDK/blob/main/docs/http-api.md) · [Website](https://isagoge.in/leanwarp)
|
|
10
|
+
|
|
11
|
+
## What it does
|
|
12
|
+
|
|
13
|
+
| Operation | What you get | CLI |
|
|
14
|
+
| --- | --- | --- |
|
|
15
|
+
| Check | Lean's errors and warnings for a file; `--draft` reuses Lean's work on the unchanged part while you edit. | `leanwarp check` |
|
|
16
|
+
| Inspect | The goals and local context at a position in a proof. | `leanwarp inspect` |
|
|
17
|
+
| Try tactics | Several tactics from the same captured goal: which close it, which leave goals, which fail. The file is not edited. | `leanwarp try-tactics` |
|
|
18
|
+
| Verify | Whether a declaration proves exactly the statement you give, checked by Lean's kernel. | `leanwarp verify` |
|
|
19
|
+
| Holes | Every `sorry` and `?_` in a file, with its position, and the goals of the first 16. | `leanwarp holes` |
|
|
20
|
+
| Suggest | A tactic that closes a hole, accepted only if nothing else changes and the proof gains no unproved lemma or extra axiom. `apply` writes it into the file. | `leanwarp suggest`, `leanwarp apply` |
|
|
21
|
+
| Sorry to lemma | The proof of each theorem that still has a `sorry` moved into a new named lemma the theorem then uses; the lemma keeps its `sorry`. `apply` writes it. | `leanwarp sorry2lemma` |
|
|
22
|
+
| Declarations | The declarations a file adds, with their types and dependencies. | `leanwarp declarations` |
|
|
23
|
+
| Check files | Up to 64 files checked in one operation. | `leanwarp check-files` |
|
|
24
|
+
|
|
25
|
+
The [reference](https://github.com/Isagoge-Labs/LeanWarp-SDK/blob/main/src/leanwarp_cloud/skills/leanwarp/references/usage.md#commands)
|
|
26
|
+
lists every command and option; `leanwarp skill --reference` prints it.
|
|
27
|
+
|
|
28
|
+
### Coming soon
|
|
29
|
+
|
|
30
|
+
These are planned and not available yet:
|
|
31
|
+
|
|
32
|
+
- **Proof simplification**: replace a proof with a shorter one that still checks.
|
|
33
|
+
- **`have` extraction**: lift named `have` blocks into top-level lemmas.
|
|
34
|
+
- **Batch repair**: fill several holes in one operation.
|
|
35
|
+
|
|
36
|
+
## Install in two steps
|
|
37
|
+
|
|
38
|
+
**1. Install.** In a terminal, with [uv](https://docs.astral.sh/uv/getting-started/installation/):
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
uv tool install leanwarp && leanwarp setup
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
This installs the `leanwarp` command and its MCP server from
|
|
45
|
+
[PyPI](https://pypi.org/project/leanwarp/). `leanwarp setup` adds the LeanWarp
|
|
46
|
+
skill and MCP server to Claude Code, Codex and Cursor where they are installed,
|
|
47
|
+
and the skill to `~/.agents/skills`. It runs on Linux, macOS and WSL. You don't
|
|
48
|
+
need Lean installed: LeanWarp runs Lean and Mathlib for you.
|
|
49
|
+
|
|
50
|
+
Or paste this into your agent:
|
|
51
|
+
|
|
52
|
+
> Install LeanWarp: run `uv tool install leanwarp && leanwarp setup`, then ask me
|
|
53
|
+
> to sign in.
|
|
54
|
+
|
|
55
|
+
Already have LeanWarp 0.2 from GitHub? Its `leanwarp-sdk` tool owns the
|
|
56
|
+
`leanwarp` command, so replace it instead:
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
uv tool uninstall leanwarp-sdk && uv tool install leanwarp && leanwarp setup
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**2. Sign in**, in your own terminal:
|
|
63
|
+
|
|
64
|
+
```sh
|
|
65
|
+
leanwarp auth login
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
It opens the dashboard to create an API key; paste the key at the hidden prompt.
|
|
69
|
+
Never paste it into an agent conversation. Then restart your agent.
|
|
70
|
+
|
|
71
|
+
When a new release is out, results include `update_available`; run
|
|
72
|
+
`leanwarp update` to upgrade and refresh the installed skills.
|
|
73
|
+
|
|
74
|
+
## Quick start
|
|
75
|
+
|
|
76
|
+
From your Lean project or one of the [examples](https://github.com/Isagoge-Labs/LeanWarp-SDK/tree/main/examples):
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
leanwarp doctor # which environment this project runs on
|
|
80
|
+
leanwarp connect # create the project's workspace
|
|
81
|
+
leanwarp check LeanWarpExample.lean
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
If a command returns `success: null` (exit `3`), run `leanwarp wait` until it
|
|
85
|
+
finishes before submitting another operation. Then verify:
|
|
86
|
+
|
|
87
|
+
```sh
|
|
88
|
+
leanwarp verify LeanWarpExample.lean \
|
|
89
|
+
--declaration add_zero_example --target '∀ n : Nat, n + 0 = n'
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Wait for that operation to finish too, then run `leanwarp stop` when you are done.
|
|
93
|
+
|
|
94
|
+
Every command prints one JSON object. Results start with `success`: `true` when
|
|
95
|
+
the check passed or the proof was verified, `false` when it did not, and `null`
|
|
96
|
+
while the work is still running, in which case run `leanwarp wait`. The exit code
|
|
97
|
+
says the same thing: `0` passed, `1` did not pass, `2` the command failed, `3`
|
|
98
|
+
still running.
|
|
99
|
+
|
|
100
|
+
## Use with an agent
|
|
101
|
+
|
|
102
|
+
Give your agent the project directory and this instruction:
|
|
103
|
+
|
|
104
|
+
> Run `leanwarp skill` and follow it. Use LeanWarp to check this Lean project
|
|
105
|
+
> and verify proofs against their intended statements. Reuse the workspace
|
|
106
|
+
> while you edit, and run `leanwarp stop` when you are done.
|
|
107
|
+
|
|
108
|
+
For MCP clients, add the server `leanwarp --project /absolute/path/to/project mcp`,
|
|
109
|
+
or `uvx leanwarp --project /absolute/path/to/project mcp`
|
|
110
|
+
without installing. It uses the same key and project state as the CLI. See [agent setup](https://github.com/Isagoge-Labs/LeanWarp-SDK/blob/main/docs/agents.md).
|
|
111
|
+
Keep API keys out of prompts, source files and tool arguments.
|
|
112
|
+
|
|
113
|
+
## Your project and its environment
|
|
114
|
+
|
|
115
|
+
LeanWarp uploads only your `.lean` files. Lean, Mathlib and every other
|
|
116
|
+
dependency come from an **environment**: a Lean release with Mathlib, already
|
|
117
|
+
built on LeanWarp's workers. Run `leanwarp environments` to list them.
|
|
118
|
+
`leanwarp files` lists what would upload; patterns in `.gitignore` and
|
|
119
|
+
`.leanwarpignore` leave files out.
|
|
120
|
+
|
|
121
|
+
`leanwarp connect` picks the environment for you:
|
|
122
|
+
|
|
123
|
+
- If your project's `lean-toolchain` and `lake-manifest.json` match an
|
|
124
|
+
environment, it uses that one, so results agree with your local build.
|
|
125
|
+
- If your project has neither file, as with a folder of `.lean` files, it uses
|
|
126
|
+
the only served environment, or the newest served stable Lean release when there are several.
|
|
127
|
+
- If they match no environment, it stops and lists the ones available. Run
|
|
128
|
+
`leanwarp connect --environment NAME` to check your files there anyway; they
|
|
129
|
+
then compile against that environment's Lean and Mathlib.
|
|
130
|
+
|
|
131
|
+
To start a new project, copy one of the [examples](https://github.com/Isagoge-Labs/LeanWarp-SDK/tree/main/examples), which match the
|
|
132
|
+
environments LeanWarp serves.
|
|
133
|
+
|
|
134
|
+
## Billing
|
|
135
|
+
|
|
136
|
+
You pay from prepaid credit, billed by the second while a worker runs. Run
|
|
137
|
+
`leanwarp resources` to see the published worker's starting minute price, whether
|
|
138
|
+
charges depend on usage, startup credit hold and idle timeout. LeanWarp selects
|
|
139
|
+
the worker. Use `leanwarp connect --max-spend 2` to create a workspace with a $2
|
|
140
|
+
cap, or edit an existing cap in the dashboard. Reconnecting without a cap keeps
|
|
141
|
+
the saved cap.
|
|
142
|
+
|
|
143
|
+
When the worker uses usage billing, CPU and RAM charges increase independently
|
|
144
|
+
above their reserved baselines. The starting rate is a paid minimum while the
|
|
145
|
+
worker runs, including idle time. Bursting depends on available host capacity.
|
|
146
|
+
Otherwise, the listed minute rate applies for the time the worker runs. Existing
|
|
147
|
+
workspaces keep their saved billing terms.
|
|
148
|
+
|
|
149
|
+
A worker starts with your first operation and stays warm between calls. Run
|
|
150
|
+
`leanwarp stop` when finished; closing the SDK client or your terminal does not
|
|
151
|
+
stop it. Unused held credit is released once shutdown and final usage are confirmed.
|
|
152
|
+
Stopping keeps your uploaded files and
|
|
153
|
+
completed results; the next operation reconstructs the worker. Set a spending cap
|
|
154
|
+
for each workspace in the [dashboard](https://isagoge.in/dashboard).
|
|
155
|
+
|
|
156
|
+
## Concepts
|
|
157
|
+
|
|
158
|
+
| Term | Meaning |
|
|
159
|
+
| --- | --- |
|
|
160
|
+
| Environment | A Lean release with Mathlib, prebuilt on LeanWarp, such as `lean-4.26-mathlib`. |
|
|
161
|
+
| Workspace | Your project's files on LeanWarp. One per project; creating it starts no compute. |
|
|
162
|
+
| Worker | The machine that runs Lean for a workspace. It starts on demand and stays warm. |
|
|
163
|
+
| Operation | One request, such as a check or a verification, and its result. |
|
|
164
|
+
| Revision | A numbered version of the workspace's files. Each result names the one it checked. |
|
|
165
|
+
| Receipt | The part of a verification result that records exactly what was checked. |
|
|
166
|
+
|
|
167
|
+
## Documentation
|
|
168
|
+
|
|
169
|
+
| Start here | Reference |
|
|
170
|
+
| --- | --- |
|
|
171
|
+
| [Verify your first proof](https://github.com/Isagoge-Labs/LeanWarp-SDK/blob/main/docs/getting-started.md) | [Commands](https://github.com/Isagoge-Labs/LeanWarp-SDK/blob/main/src/leanwarp_cloud/skills/leanwarp/references/usage.md#commands) |
|
|
172
|
+
| [Set up an agent with the CLI or MCP](https://github.com/Isagoge-Labs/LeanWarp-SDK/blob/main/docs/agents.md) | [Results and exit codes](https://github.com/Isagoge-Labs/LeanWarp-SDK/blob/main/src/leanwarp_cloud/skills/leanwarp/references/usage.md#results) |
|
|
173
|
+
| [Use the Python library](https://github.com/Isagoge-Labs/LeanWarp-SDK/blob/main/src/leanwarp_cloud/skills/leanwarp/references/usage.md#python) | [Recover an interrupted request](https://github.com/Isagoge-Labs/LeanWarp-SDK/blob/main/src/leanwarp_cloud/skills/leanwarp/references/usage.md#recovery) |
|
|
174
|
+
| [Call the HTTP API directly](https://github.com/Isagoge-Labs/LeanWarp-SDK/blob/main/docs/http-api.md) | [Credentials, credit and limits](https://github.com/Isagoge-Labs/LeanWarp-SDK/blob/main/src/leanwarp_cloud/skills/leanwarp/references/usage.md#credentials-credit-and-limits) |
|
|
175
|
+
|
|
176
|
+
The agent instructions ship with the package: `leanwarp skill` prints the
|
|
177
|
+
workflow and `leanwarp skill --reference` the full reference. Run
|
|
178
|
+
`leanwarp --help` or `leanwarp COMMAND --help` for arguments.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# LeanWarp documentation
|
|
2
|
+
|
|
3
|
+
- [Getting started](getting-started.md): sign in, choose a project and verify a proof.
|
|
4
|
+
- [Use with an agent](agents.md): the agent instruction, skill and MCP setup.
|
|
5
|
+
- [Commands](../src/leanwarp_cloud/skills/leanwarp/references/usage.md#commands) and
|
|
6
|
+
[environments](../src/leanwarp_cloud/skills/leanwarp/references/usage.md#environments).
|
|
7
|
+
- [Results and exit codes](../src/leanwarp_cloud/skills/leanwarp/references/usage.md#results):
|
|
8
|
+
what `success` means and where Lean's messages are.
|
|
9
|
+
- [Python](../src/leanwarp_cloud/skills/leanwarp/references/usage.md#python): use the library.
|
|
10
|
+
- [Recovery](../src/leanwarp_cloud/skills/leanwarp/references/usage.md#recovery): lost
|
|
11
|
+
responses, timeouts and conflicting edits.
|
|
12
|
+
- [Credentials, credit and limits](../src/leanwarp_cloud/skills/leanwarp/references/usage.md#credentials-credit-and-limits).
|
|
13
|
+
- [HTTP API](http-api.md): for building your own client.
|
|
14
|
+
|
|
15
|
+
The reference ships with the SDK: `leanwarp skill --reference` prints it without a
|
|
16
|
+
key. Run `leanwarp --help` or `leanwarp COMMAND --help` for arguments.
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Use LeanWarp with an agent
|
|
2
|
+
|
|
3
|
+
An agent uses LeanWarp through the `leanwarp` command or its MCP server. Both
|
|
4
|
+
share the same key and the same project state in `.leanwarp/`, so you can switch
|
|
5
|
+
between them. [Install and sign in](getting-started.md) first, then choose the Lean
|
|
6
|
+
project the agent may work in.
|
|
7
|
+
|
|
8
|
+
## Set up your agents
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
leanwarp setup
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
This installs the LeanWarp skill for Claude Code (`~/.claude/skills`), Codex
|
|
15
|
+
(`~/.codex/skills`) and other agents (`~/.agents/skills`), and adds the MCP
|
|
16
|
+
server to Claude Code (`claude mcp add`), Codex (`~/.codex/config.toml`) and
|
|
17
|
+
Cursor (`~/.cursor/mcp.json`). Only agents whose configuration folder exists are
|
|
18
|
+
set up; `--agent NAME` sets up one anyway, and `--no-mcp` installs skills only.
|
|
19
|
+
An existing `leanwarp` MCP entry is never replaced. Run `leanwarp auth login`
|
|
20
|
+
yourself, then restart the agent. `leanwarp update` upgrades the command and
|
|
21
|
+
refreshes the installed skills.
|
|
22
|
+
|
|
23
|
+
## The instruction
|
|
24
|
+
|
|
25
|
+
Give the agent the project directory and this instruction:
|
|
26
|
+
|
|
27
|
+
> Run `leanwarp skill` and follow it. Use LeanWarp to check this Lean project
|
|
28
|
+
> and verify proofs against their intended statements. Reuse the workspace
|
|
29
|
+
> while you edit, and run `leanwarp stop` when you are done.
|
|
30
|
+
|
|
31
|
+
`leanwarp skill` prints the workflow: connecting, checking, reading results,
|
|
32
|
+
verifying against a fixed statement, recovering from lost responses and stopping
|
|
33
|
+
the worker. It also asks the agent to report confirmed problems with LeanWarp
|
|
34
|
+
itself through `leanwarp feedback`, naming the operation instead of quoting your
|
|
35
|
+
source, and to tell you when it does. `leanwarp skill --reference` prints the full reference. Neither needs
|
|
36
|
+
a key or starts compute.
|
|
37
|
+
|
|
38
|
+
Sign in yourself with `leanwarp auth login`, or inject `LEANWARP_API_KEY` into the
|
|
39
|
+
agent's environment. Never put the key in the instruction.
|
|
40
|
+
|
|
41
|
+
## Agents with shell access
|
|
42
|
+
|
|
43
|
+
The CLI is built for agents: every command prints one JSON object, results start
|
|
44
|
+
with `success` (`true`, `false`, or `null` while running), and exit codes separate
|
|
45
|
+
"did not pass" (`1`) from "could not run" (`2`) and "still running" (`3`).
|
|
46
|
+
|
|
47
|
+
`leanwarp setup` installs the instructions as a skill agents discover
|
|
48
|
+
automatically. For another agent, point its skill installer at the
|
|
49
|
+
[skill directory](../src/leanwarp_cloud/skills/leanwarp), including `references/`.
|
|
50
|
+
|
|
51
|
+
## MCP
|
|
52
|
+
|
|
53
|
+
Add this server to your MCP client, with the absolute path of your project:
|
|
54
|
+
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"mcpServers": {
|
|
58
|
+
"leanwarp": {
|
|
59
|
+
"command": "leanwarp",
|
|
60
|
+
"args": ["--project", "/absolute/path/to/lean-project", "mcp"]
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Use the absolute path of `leanwarp` if the client can't find it on its `PATH`.
|
|
67
|
+
To run the server without installing the command, use
|
|
68
|
+
[uv](https://docs.astral.sh/uv/getting-started/installation/) to fetch it from PyPI:
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"mcpServers": {
|
|
73
|
+
"leanwarp": {
|
|
74
|
+
"command": "uvx",
|
|
75
|
+
"args": ["leanwarp", "--project", "/absolute/path/to/lean-project", "mcp"]
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
The server starts even before you sign in, so the agent can read its guides; tools
|
|
82
|
+
that call LeanWarp then explain how to sign in.
|
|
83
|
+
|
|
84
|
+
If the user specifies a workspace budget, pass it to `connect` as
|
|
85
|
+
`max_spend_microusd` ($1 = 1,000,000). Reconnecting without that argument keeps
|
|
86
|
+
the existing cap; a supplied different cap is rejected. Existing caps can be
|
|
87
|
+
changed in the dashboard.
|
|
88
|
+
|
|
89
|
+
The agent should read the resources `leanwarp://guide` and `leanwarp://reference`
|
|
90
|
+
first. The tools mirror the CLI commands: setup (`doctor`, `files`,
|
|
91
|
+
`environments`, `connect`), proof operations (`check`, `inspect`, `try_tactics`,
|
|
92
|
+
`verify_target`, `holes`, `suggest`, `sorry2lemma`, `extract_decls`,
|
|
93
|
+
`check_files`, and `apply` to write a result into its file), operation control
|
|
94
|
+
(`wait`, `status`, `cancel`, `stop`, `recover`), and workspace and account
|
|
95
|
+
management. The [MCP reference](../src/leanwarp_cloud/skills/leanwarp/references/usage.md#mcp)
|
|
96
|
+
lists the tools and their arguments. Operation tools wait up to 20 seconds for
|
|
97
|
+
their result by default (`wait_seconds`, at most 40).
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="960" height="232" viewBox="0 0 960 232" role="img" aria-labelledby="title desc">
|
|
2
|
+
<title id="title">LeanWarp</title>
|
|
3
|
+
<desc id="desc">Lean proofs, checked on warm workers</desc>
|
|
4
|
+
<rect width="960" height="232" rx="12" fill="#080f14"/>
|
|
5
|
+
<text x="480" y="112" text-anchor="middle" fill="#f1f6fa" font-family="ui-sans-serif,system-ui,sans-serif" font-size="52" font-weight="650" letter-spacing="-1.5">LeanWarp</text>
|
|
6
|
+
<text x="480" y="150" text-anchor="middle" fill="#b0c3cf" font-family="ui-sans-serif,system-ui,sans-serif" font-size="20">Lean proofs, checked on warm workers</text>
|
|
7
|
+
</svg>
|