visualproof 0.8.1 → 0.9.0
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.
- package/README.md +10 -8
- package/dist/assets/tips/tour-library.webp +0 -0
- package/dist/assets/tips/tour-source.webp +0 -0
- package/dist/assets/tips/tour.json +90 -90
- package/dist/extractor/Extract.lean +34 -11
- package/dist/server/agent.js +19 -7
- package/dist/server/agentexport.js +2 -1
- package/dist/server/agentfollow.js +13 -3
- package/dist/server/agentlean.js +91 -1
- package/dist/server/agentnotes.js +6 -4
- package/dist/server/agentread.js +33 -1
- package/dist/server/app.js +1 -1
- package/dist/server/appgraph.js +24 -0
- package/dist/server/boardspots.js +1 -1
- package/dist/server/goals.js +224 -0
- package/dist/server/hover.js +281 -8
- package/dist/server/live.js +14 -0
- package/dist/server/main.js +3 -2
- package/dist/server/mcptools.js +11 -5
- package/dist/server/options.js +17 -2
- package/dist/server/readonlygate.js +2 -1
- package/dist/server/reviewapi.js +5 -2
- package/dist/server/status.js +43 -5
- package/dist/shared/build.js +9 -0
- package/dist/shared/collab.js +14 -2
- package/dist/shared/declfind.js +23 -3
- package/dist/shared/goals.js +309 -0
- package/dist/shared/hygiene.js +18 -0
- package/dist/shared/noteplace.js +45 -19
- package/dist/shared/scope.js +74 -45
- package/dist/shared/sharesnap.js +4 -2
- package/dist/web/bundle/app.js +2271 -581
- package/dist/web/index.html +1 -1
- package/dist/web/src/highlight.js +53 -3
- package/dist/web/style.css +148 -0
- package/docs/agent-api/README.md +1 -1
- package/docs/agent-api/mcp.md +1 -1
- package/docs/agent-api/notes.md +3 -2
- package/docs/agent-api/reading.md +38 -2
- package/docs/agent-api/words.md +3 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
# VisualProof
|
|
2
2
|
|
|
3
|
-
<
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
</
|
|
10
|
-
|
|
3
|
+
<table align="center">
|
|
4
|
+
<tr>
|
|
5
|
+
<td align="center" valign="top"><a href="docs/images/artwork-sphere-packing-full.webp?raw=true"><img src="docs/images/artwork-sphere-packing.webp" width="134" alt="Sphere Packing"></a><br><sub><a href="https://github.com/math-inc/Sphere-Packing-Lean">Sphere-Packing-Lean</a></sub></td>
|
|
6
|
+
<td align="center" valign="top"><a href="docs/images/artwork-flt-regular-full.webp?raw=true"><img src="docs/images/artwork-flt-regular.webp" width="134" alt="FLT Regular"></a><br><sub><a href="https://github.com/leanprover-community/flt-regular">flt-regular</a></sub></td>
|
|
7
|
+
<td align="center" valign="top"><a href="docs/images/artwork-prime-numbers-full.webp?raw=true"><img src="docs/images/artwork-prime-numbers.webp" width="134" alt="Prime Numbers"></a><br><sub><a href="https://github.com/AlexKontorovich/PrimeNumberTheoremAnd">PrimeNumberTheoremAnd</a></sub></td>
|
|
8
|
+
<td align="center" valign="top"><a href="docs/images/artwork-navier-stokes-full.webp?raw=true"><img src="docs/images/artwork-navier-stokes.webp" width="134" alt="Navier–Stokes"></a><br><sub><a href="https://github.com/openai/NavierStokesAndEuler">NavierStokesAndEuler</a></sub></td>
|
|
9
|
+
<td align="center" valign="top"><a href="docs/images/artwork-cedar-full.webp?raw=true"><img src="docs/images/artwork-cedar.webp" width="134" alt="Cedar"></a><br><sub><a href="https://github.com/cedar-policy/cedar-spec">cedar-spec</a></sub></td>
|
|
10
|
+
</tr>
|
|
11
|
+
</table>
|
|
12
|
+
<p align="center"><sub>Five Lean codebases, drawn by <code>visualproof artwork</code>. A poster opens at its full size, A2 at 300 dpi.</sub></p>
|
|
11
13
|
|
|
12
14
|
https://github.com/user-attachments/assets/5d090578-ba18-493f-83d9-7529bcbc689c
|
|
13
15
|
|
|
Binary file
|
|
Binary file
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"film": {
|
|
3
|
-
"file": "tour-
|
|
4
|
-
"sha256": "
|
|
5
|
-
"size":
|
|
3
|
+
"file": "tour-a275ca51494d.mp4",
|
|
4
|
+
"sha256": "a275ca51494ddd2557eaaf2f86f4ffaccd6e975c26a2b006c482e0aa8ee10aec",
|
|
5
|
+
"size": 48096998,
|
|
6
6
|
"width": 2560,
|
|
7
7
|
"height": 1600,
|
|
8
|
-
"duration": 209
|
|
8
|
+
"duration": 209.13333333333333
|
|
9
9
|
},
|
|
10
10
|
"chapters": [
|
|
11
11
|
{
|
|
@@ -26,52 +26,52 @@
|
|
|
26
26
|
{
|
|
27
27
|
"id": "source",
|
|
28
28
|
"start": 45.666666666666664,
|
|
29
|
-
"end": 55.
|
|
29
|
+
"end": 55.833333333333336
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
"id": "keys",
|
|
33
|
-
"start": 55.
|
|
34
|
-
"end":
|
|
33
|
+
"start": 55.833333333333336,
|
|
34
|
+
"end": 77.03333333333333
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
37
|
"id": "checks",
|
|
38
|
-
"start":
|
|
39
|
-
"end": 94.
|
|
38
|
+
"start": 77.03333333333333,
|
|
39
|
+
"end": 94.8
|
|
40
40
|
},
|
|
41
41
|
{
|
|
42
42
|
"id": "review",
|
|
43
|
-
"start": 94.
|
|
44
|
-
"end": 110.
|
|
43
|
+
"start": 94.8,
|
|
44
|
+
"end": 110.66666666666667
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
47
|
"id": "project",
|
|
48
|
-
"start": 110.
|
|
49
|
-
"end": 117.
|
|
48
|
+
"start": 110.66666666666667,
|
|
49
|
+
"end": 117.4
|
|
50
50
|
},
|
|
51
51
|
{
|
|
52
52
|
"id": "share",
|
|
53
|
-
"start": 117.
|
|
54
|
-
"end": 129.
|
|
53
|
+
"start": 117.4,
|
|
54
|
+
"end": 129.23333333333332
|
|
55
55
|
},
|
|
56
56
|
{
|
|
57
57
|
"id": "agent",
|
|
58
|
-
"start": 129.
|
|
59
|
-
"end": 145.
|
|
58
|
+
"start": 129.23333333333332,
|
|
59
|
+
"end": 145.93333333333334
|
|
60
60
|
},
|
|
61
61
|
{
|
|
62
62
|
"id": "library",
|
|
63
|
-
"start": 145.
|
|
64
|
-
"end": 173.
|
|
63
|
+
"start": 145.93333333333334,
|
|
64
|
+
"end": 173.66666666666666
|
|
65
65
|
},
|
|
66
66
|
{
|
|
67
67
|
"id": "export",
|
|
68
|
-
"start": 173.
|
|
69
|
-
"end": 191.
|
|
68
|
+
"start": 173.66666666666666,
|
|
69
|
+
"end": 191.93333333333334
|
|
70
70
|
},
|
|
71
71
|
{
|
|
72
72
|
"id": "artwork",
|
|
73
|
-
"start": 191.
|
|
74
|
-
"end": 209
|
|
73
|
+
"start": 191.93333333333334,
|
|
74
|
+
"end": 209.13333333333333
|
|
75
75
|
}
|
|
76
76
|
],
|
|
77
77
|
"captions": [
|
|
@@ -132,172 +132,172 @@
|
|
|
132
132
|
},
|
|
133
133
|
{
|
|
134
134
|
"start": 49.7,
|
|
135
|
-
"end": 52.
|
|
135
|
+
"end": 52.9,
|
|
136
136
|
"text": "Rest on a name: Lean says what it is."
|
|
137
137
|
},
|
|
138
138
|
{
|
|
139
|
-
"start": 52.
|
|
140
|
-
"end": 55.
|
|
139
|
+
"start": 52.9,
|
|
140
|
+
"end": 55.833333333333336,
|
|
141
141
|
"text": "Click it to go there: its source, its panel."
|
|
142
142
|
},
|
|
143
143
|
{
|
|
144
|
-
"start": 55.
|
|
145
|
-
"end": 58.
|
|
144
|
+
"start": 55.833333333333336,
|
|
145
|
+
"end": 58.9,
|
|
146
146
|
"text": "Keys: the definitions that carry what it says."
|
|
147
147
|
},
|
|
148
148
|
{
|
|
149
|
-
"start": 58.
|
|
150
|
-
"end": 70.
|
|
149
|
+
"start": 58.9,
|
|
150
|
+
"end": 70.33333333333333,
|
|
151
151
|
"text": "Mark each as a key, in its source or its panel."
|
|
152
152
|
},
|
|
153
153
|
{
|
|
154
|
-
"start": 70.
|
|
155
|
-
"end":
|
|
154
|
+
"start": 70.33333333333333,
|
|
155
|
+
"end": 77.03333333333333,
|
|
156
156
|
"text": "Rests on · Keys lights them, joined to the target."
|
|
157
157
|
},
|
|
158
158
|
{
|
|
159
|
-
"start": 77.
|
|
160
|
-
"end": 79.
|
|
159
|
+
"start": 77.43333333333334,
|
|
160
|
+
"end": 79.8,
|
|
161
161
|
"text": "Selection: the statement alone."
|
|
162
162
|
},
|
|
163
163
|
{
|
|
164
|
-
"start": 79.
|
|
165
|
-
"end": 82.
|
|
164
|
+
"start": 79.8,
|
|
165
|
+
"end": 82.6,
|
|
166
166
|
"text": "Least effort — you trust every name in it."
|
|
167
167
|
},
|
|
168
168
|
{
|
|
169
|
-
"start": 82.
|
|
170
|
-
"end":
|
|
169
|
+
"start": 82.6,
|
|
170
|
+
"end": 85.06666666666666,
|
|
171
171
|
"text": "Keys: the few that carry the meaning."
|
|
172
172
|
},
|
|
173
173
|
{
|
|
174
|
-
"start":
|
|
175
|
-
"end": 87.
|
|
174
|
+
"start": 85.06666666666666,
|
|
175
|
+
"end": 87.13333333333334,
|
|
176
176
|
"text": "Little effort, good confidence."
|
|
177
177
|
},
|
|
178
178
|
{
|
|
179
|
-
"start": 87.
|
|
180
|
-
"end": 89.
|
|
179
|
+
"start": 87.13333333333334,
|
|
180
|
+
"end": 89.13333333333334,
|
|
181
181
|
"text": "TCB: everything it rests on."
|
|
182
182
|
},
|
|
183
183
|
{
|
|
184
|
-
"start": 89.
|
|
185
|
-
"end": 91.
|
|
184
|
+
"start": 89.13333333333334,
|
|
185
|
+
"end": 91.13333333333334,
|
|
186
186
|
"text": "Most effort, most confidence."
|
|
187
187
|
},
|
|
188
188
|
{
|
|
189
|
-
"start": 91.
|
|
190
|
-
"end": 94.
|
|
189
|
+
"start": 91.13333333333334,
|
|
190
|
+
"end": 94.8,
|
|
191
191
|
"text": "Choose how far to read: the counts say what each costs."
|
|
192
192
|
},
|
|
193
193
|
{
|
|
194
|
-
"start": 94.
|
|
195
|
-
"end": 98.
|
|
194
|
+
"start": 94.8,
|
|
195
|
+
"end": 98.36666666666666,
|
|
196
196
|
"text": "Read a definition, then say what you think of it."
|
|
197
197
|
},
|
|
198
198
|
{
|
|
199
|
-
"start": 98.
|
|
200
|
-
"end": 104.
|
|
199
|
+
"start": 98.36666666666666,
|
|
200
|
+
"end": 104.4,
|
|
201
201
|
"text": "Approve it, with why: the comment stays with it."
|
|
202
202
|
},
|
|
203
203
|
{
|
|
204
|
-
"start": 104.
|
|
205
|
-
"end": 107.
|
|
204
|
+
"start": 104.4,
|
|
205
|
+
"end": 107.2,
|
|
206
206
|
"text": "Changed your mind? Withdraw takes it back."
|
|
207
207
|
},
|
|
208
208
|
{
|
|
209
|
-
"start": 107.
|
|
210
|
-
"end": 110.
|
|
209
|
+
"start": 107.2,
|
|
210
|
+
"end": 110.66666666666667,
|
|
211
211
|
"text": "The target's progress counts your approval."
|
|
212
212
|
},
|
|
213
213
|
{
|
|
214
|
-
"start": 110.
|
|
215
|
-
"end": 114.
|
|
214
|
+
"start": 110.66666666666667,
|
|
215
|
+
"end": 114.76666666666667,
|
|
216
216
|
"text": "The Project tab: the whole codebase."
|
|
217
217
|
},
|
|
218
218
|
{
|
|
219
|
-
"start": 114.
|
|
220
|
-
"end": 117.
|
|
219
|
+
"start": 114.76666666666667,
|
|
220
|
+
"end": 117.4,
|
|
221
221
|
"text": "Every board shows the same review."
|
|
222
222
|
},
|
|
223
223
|
{
|
|
224
|
-
"start": 117.
|
|
225
|
-
"end":
|
|
224
|
+
"start": 117.4,
|
|
225
|
+
"end": 123.03333333333333,
|
|
226
226
|
"text": "Share → AI agent: a token, and a prompt for it."
|
|
227
227
|
},
|
|
228
228
|
{
|
|
229
|
-
"start":
|
|
230
|
-
"end": 126.
|
|
229
|
+
"start": 123.03333333333333,
|
|
230
|
+
"end": 126.23333333333333,
|
|
231
231
|
"text": "Paste the prompt into your agent: it joins here."
|
|
232
232
|
},
|
|
233
233
|
{
|
|
234
|
-
"start": 126.
|
|
235
|
-
"end": 129.
|
|
234
|
+
"start": 126.23333333333333,
|
|
235
|
+
"end": 129.2333333333333,
|
|
236
236
|
"text": "The token is the agent's own: revoke it here."
|
|
237
237
|
},
|
|
238
238
|
{
|
|
239
|
-
"start": 129.
|
|
240
|
-
"end": 136.
|
|
239
|
+
"start": 129.73333333333332,
|
|
240
|
+
"end": 136.76666666666668,
|
|
241
241
|
"text": "Its menu → Talk: your private channel with it."
|
|
242
242
|
},
|
|
243
243
|
{
|
|
244
|
-
"start": 136.
|
|
245
|
-
"end": 140.
|
|
244
|
+
"start": 136.76666666666668,
|
|
245
|
+
"end": 140.36666666666667,
|
|
246
246
|
"text": "It reads the code; its state says what it does."
|
|
247
247
|
},
|
|
248
248
|
{
|
|
249
|
-
"start": 140.
|
|
250
|
-
"end": 142.
|
|
249
|
+
"start": 140.36666666666667,
|
|
250
|
+
"end": 142.83333333333334,
|
|
251
251
|
"text": "Its answer links to what it explains."
|
|
252
252
|
},
|
|
253
253
|
{
|
|
254
|
-
"start": 142.
|
|
255
|
-
"end": 145.
|
|
254
|
+
"start": 142.83333333333334,
|
|
255
|
+
"end": 145.93333333333334,
|
|
256
256
|
"text": "Click the link: your board goes there."
|
|
257
257
|
},
|
|
258
258
|
{
|
|
259
|
-
"start":
|
|
260
|
-
"end": 151.
|
|
259
|
+
"start": 147.06666666666666,
|
|
260
|
+
"end": 151.7,
|
|
261
261
|
"text": "Library: add a paper about the code."
|
|
262
262
|
},
|
|
263
263
|
{
|
|
264
|
-
"start": 151.
|
|
265
|
-
"end": 162.
|
|
264
|
+
"start": 151.7,
|
|
265
|
+
"end": 162.93333333333334,
|
|
266
266
|
"text": "Link it to the theorem, at its page."
|
|
267
267
|
},
|
|
268
268
|
{
|
|
269
|
-
"start": 162.
|
|
270
|
-
"end": 167.
|
|
269
|
+
"start": 162.93333333333334,
|
|
270
|
+
"end": 167.33333333333334,
|
|
271
271
|
"text": "Space: its source, and the paper beside it at its page."
|
|
272
272
|
},
|
|
273
273
|
{
|
|
274
|
-
"start": 167.
|
|
275
|
-
"end": 173.
|
|
274
|
+
"start": 167.33333333333334,
|
|
275
|
+
"end": 173.66666666666666,
|
|
276
276
|
"text": "Pin a note on the target: where to start."
|
|
277
277
|
},
|
|
278
278
|
{
|
|
279
|
-
"start": 173.
|
|
280
|
-
"end":
|
|
279
|
+
"start": 173.66666666666666,
|
|
280
|
+
"end": 181.1,
|
|
281
281
|
"text": "Export prints a view: here, the target's TCB."
|
|
282
282
|
},
|
|
283
283
|
{
|
|
284
|
-
"start":
|
|
285
|
-
"end":
|
|
284
|
+
"start": 181.1,
|
|
285
|
+
"end": 185,
|
|
286
286
|
"text": "Drag a section to change the document's order."
|
|
287
287
|
},
|
|
288
288
|
{
|
|
289
|
-
"start":
|
|
290
|
-
"end": 191.
|
|
289
|
+
"start": 185,
|
|
290
|
+
"end": 191.93333333333334,
|
|
291
291
|
"text": "Typeset: the PDF follows the order you set."
|
|
292
292
|
},
|
|
293
293
|
{
|
|
294
|
-
"start": 191.
|
|
295
|
-
"end":
|
|
294
|
+
"start": 191.93333333333334,
|
|
295
|
+
"end": 196,
|
|
296
296
|
"text": "Artwork: the board as a picture to keep."
|
|
297
297
|
},
|
|
298
298
|
{
|
|
299
|
-
"start":
|
|
300
|
-
"end": 205.
|
|
299
|
+
"start": 196,
|
|
300
|
+
"end": 205.93333333333334,
|
|
301
301
|
"text": "Frame it, then save it as PNG or SVG."
|
|
302
302
|
}
|
|
303
303
|
]
|
|
@@ -697,14 +697,20 @@ def run (out : System.FilePath) (projectDir : String) (roots : Array Name)
|
|
|
697
697
|
continue
|
|
698
698
|
let some ci := env.find? c | continue
|
|
699
699
|
let u := (privateToUserName? c).getD c
|
|
700
|
+
-- a name a command made hygienic (`wrapped._@.M._hygCtx._hyg.3`, as Mathlib's
|
|
701
|
+
-- `irreducible_def` names the value and the opaque constant it writes beside `X`) is read
|
|
702
|
+
-- without its macro scopes: beneath them it says whether Lean generated the constant
|
|
703
|
+
-- (`wrapped._proof_1`) or the command wrote it, which 2b folds by its range into the
|
|
704
|
+
-- declaration the command writes
|
|
705
|
+
let w := u.eraseMacroScopes
|
|
700
706
|
let ranged := (← findDeclarationRanges? c).isSome
|
|
701
707
|
if isNotationConst ci && ranged then
|
|
702
708
|
notations := notations.insert c; nodes := nodes.push c; continue
|
|
703
709
|
let generated :=
|
|
704
710
|
ci matches .ctorInfo _ || ci matches .recInfo _ || isAuxRecursor env c
|
|
705
711
|
|| isNoConfusion env c || isMatcherCore env c || (env.getProjectionFnInfo? c).isSome
|
|
706
|
-
||
|
|
707
|
-
|| (
|
|
712
|
+
|| w.isInternalDetail || generatedSuffixes.contains w.getString!
|
|
713
|
+
|| (w.getString! == "elim" && (env.find? c.getPrefix matches some (.ctorInfo _)))
|
|
708
714
|
if generated || !(ranged || Meta.isInstanceCore env c) then auxs := auxs.push c
|
|
709
715
|
else nodes := nodes.push c
|
|
710
716
|
let written : Std.HashSet Name := nodes.foldl (·.insert ·) {}
|
|
@@ -732,8 +738,18 @@ def run (out : System.FilePath) (projectDir : String) (roots : Array Name)
|
|
|
732
738
|
| some (.ctorInfo v) => v.induct
|
|
733
739
|
| _ => c.getPrefix
|
|
734
740
|
| none => c.getPrefix
|
|
735
|
-
let mut p := (privateToUserName? start).getD start
|
|
736
741
|
let mut found : Option Name := none
|
|
742
|
+
-- one a command made under a hygienic name belongs with the constant of the same macro scopes
|
|
743
|
+
-- it is named beneath (`wrapped._proof_1._@.M._hyg.3` with `wrapped._@.M._hyg.3`), not with a
|
|
744
|
+
-- declaration the namespace the command ran in names (`Point` for `Point.wrapped._proof_1._@…`)
|
|
745
|
+
let uc := (privateToUserName? c).getD c
|
|
746
|
+
if uc.hasMacroScopes then
|
|
747
|
+
let v := extractMacroScopes uc
|
|
748
|
+
let mut q := v.name.getPrefix
|
|
749
|
+
while !q.isAnonymous && found.isNone do
|
|
750
|
+
found := byUser[{ v with name := q }.review]?
|
|
751
|
+
q := q.getPrefix
|
|
752
|
+
let mut p := (privateToUserName? start).getD start
|
|
737
753
|
while !p.isAnonymous && found.isNone do
|
|
738
754
|
found := byUser[p]?
|
|
739
755
|
p := p.getPrefix
|
|
@@ -750,9 +766,12 @@ def run (out : System.FilePath) (projectDir : String) (roots : Array Name)
|
|
|
750
766
|
-- command writes beside the declaration it names, the lemmas of `@[simps]`) has no name of its own in the text: its
|
|
751
767
|
-- selection range is its whole range, where a written one's is its name. It belongs to the
|
|
752
768
|
-- declaration that command writes, the smallest range of a written declaration of its module
|
|
753
|
-
-- that holds its own, and folds into it as a constructor folds into its type.
|
|
754
|
-
--
|
|
755
|
-
--
|
|
769
|
+
-- that holds its own, and folds into it as a constructor folds into its type. Where a theorem's
|
|
770
|
+
-- range is as small as another's, the other's: a command that writes `X` and the lemma `X_def`
|
|
771
|
+
-- under one name (Mathlib's `irreducible_def`) generates `X`'s value, which `X`'s TCB and
|
|
772
|
+
-- version must hold, and a theorem is no part of a TCB. One for which no such declaration is
|
|
773
|
+
-- found stays a node of its own, marked `gen`. What syntax extension commands generate is left
|
|
774
|
+
-- to 2c: such a command writes no declaration.
|
|
756
775
|
let modName (c : Name) : String :=
|
|
757
776
|
match env.getModuleIdxFor? c with
|
|
758
777
|
| some i => modNames[i.toNat]!.toString
|
|
@@ -771,16 +790,17 @@ def run (out : System.FilePath) (projectDir : String) (roots : Array Name)
|
|
|
771
790
|
for h : i in [0:nodes.size] do
|
|
772
791
|
let some r := rngs[i]! | continue
|
|
773
792
|
if !generatedAt r || notations.contains nodes[i] then continue
|
|
774
|
-
let mut best : Option (Nat × Nat) := none
|
|
793
|
+
let mut best : Option (Nat × Nat × Bool) := none
|
|
775
794
|
for j in ofModule.getD (modName nodes[i]) #[] do
|
|
776
795
|
let some rj := rngs[j]! | continue
|
|
777
796
|
if j == i || generatedAt rj || notations.contains nodes[j]! then continue
|
|
778
797
|
if !(posLe rj.range.pos r.range.pos && posLe r.range.endPos rj.range.endPos) then continue
|
|
779
798
|
let span := (rj.range.endPos.line - rj.range.pos.line) * 100000
|
|
780
799
|
+ (rj.range.endPos.column + 100000 - rj.range.pos.column)
|
|
781
|
-
|
|
800
|
+
let thm := env.find? nodes[j]! matches some (.thmInfo _)
|
|
801
|
+
if best.all (fun (_, s, t) => span < s || (span == s && t && !thm)) then best := some (j, span, thm)
|
|
782
802
|
match best with
|
|
783
|
-
| some (j, _) => genOwner := genOwner.insert nodes[i] nodes[j]!
|
|
803
|
+
| some (j, _, _) => genOwner := genOwner.insert nodes[i] nodes[j]!
|
|
784
804
|
| none => genLost := genLost.insert nodes[i]
|
|
785
805
|
-- 2c. notation units (decision 2): the constants one syntax extension command generates share
|
|
786
806
|
-- its range, and make one unit of kind `notation`. It is named after the syntax kind it
|
|
@@ -1075,11 +1095,14 @@ def run (out : System.FilePath) (projectDir : String) (roots : Array Name)
|
|
|
1075
1095
|
let name := nameOf.getD c u.toString
|
|
1076
1096
|
-- a constant of the project is written by its unit's name, then, after a space, what it is of
|
|
1077
1097
|
-- that unit (`Fixture.Point mk`; nothing for the unit itself), so that the server maps it
|
|
1078
|
-
-- through a rename of the unit whatever the constant is; one from outside by its own name
|
|
1098
|
+
-- through a rename of the unit whatever the constant is; one from outside by its own name. A
|
|
1099
|
+
-- constant a command named hygienically is written without its macro scopes, which Lean makes
|
|
1100
|
+
-- from the command's whole text: a rename of what the command mentions, or its doc comment
|
|
1101
|
+
-- edited, would make them new and the unit a new version, its content unchanged
|
|
1079
1102
|
let refName (r : Name) : String := match owner[r]? with
|
|
1080
1103
|
| some o =>
|
|
1081
1104
|
let uo := (userName o).toString
|
|
1082
|
-
let ur := (userName r).toString
|
|
1105
|
+
let ur := (userName r).eraseMacroScopes.toString
|
|
1083
1106
|
let rest := if r == o then "" else if ur.startsWith uo then (ur.drop uo.length).toString else ur
|
|
1084
1107
|
let own := nameOf.getD o uo
|
|
1085
1108
|
if rest.isEmpty then own else s!"{own} {(rest.dropWhile (· == '.')).toString}"
|
package/dist/server/agent.js
CHANGED
|
@@ -46,7 +46,7 @@ import { advice, fresh, STANDARD_AXIOMS, trustedBy } from "../shared/review.js";
|
|
|
46
46
|
import { keyGraph } from "../shared/keys.js";
|
|
47
47
|
import { SETTINGS_HELP } from "../shared/doc/settings.js";
|
|
48
48
|
import { nonStandardAxiom } from "../shared/reviewqueue.js";
|
|
49
|
-
import { foldedAt, guessNames } from "../shared/declfind.js";
|
|
49
|
+
import { foldedAt, guessNames, outsideAbove } from "../shared/declfind.js";
|
|
50
50
|
import { noteEndpoints } from "./agentnotes.js";
|
|
51
51
|
import { libraryEndpoints } from "./agentlibrary.js";
|
|
52
52
|
import { askEndpoints } from "./askfollow.js";
|
|
@@ -59,7 +59,7 @@ import { DOC_TOPICS } from "./agentdocs.js";
|
|
|
59
59
|
import { View } from "./agentgraph.js";
|
|
60
60
|
import { TALKING, conversation, doingOf, inbox, publicChannel, reply, status } from "./agenttalk.js";
|
|
61
61
|
import { docs, endpointList, index, mcpFile, mcpInstallGet, mcpTools } from "./agententry.js";
|
|
62
|
-
import { MAX_PRINT, describe, print } from "./agentlean.js";
|
|
62
|
+
import { MAX_PRINT, describe, goals, print } from "./agentlean.js";
|
|
63
63
|
import { MAX_NAMES, PARTS, context, declaration, declarations, moduleGet, refsGet, searchGet, source } from "./agentread.js";
|
|
64
64
|
import { MAX_OPINIONS, opinionPost, opinionsPost, withdrawPost } from "./agentadvice.js";
|
|
65
65
|
import { keyPost, keysGet, targetPost, targets, tcb, trustPost, why } from "./agenttcb.js";
|
|
@@ -67,6 +67,7 @@ import { companion, viewLink, viewPost } from "./agentfollow.js";
|
|
|
67
67
|
import { MAX_PINS, pins, place, undoPost } from "./agentplaces.js";
|
|
68
68
|
import { EXPORT_PARAMS, artwork, exportFileGet, exportGet, exportJob, exportPost } from "./agentexport.js";
|
|
69
69
|
import { activity } from "./agentactivity.js";
|
|
70
|
+
import { isCompiledText } from "../shared/build.js";
|
|
70
71
|
export const AGENT_LEVELS = ["read", "advise", "full"];
|
|
71
72
|
/** An error, as every refusal is shaped: what went wrong, and what to do instead. */
|
|
72
73
|
export function fail(status, error, hint, more = {}, headers) {
|
|
@@ -196,7 +197,12 @@ export class AgentApi {
|
|
|
196
197
|
if (i !== undefined)
|
|
197
198
|
return i;
|
|
198
199
|
const guesses = this.guess(v, name.trim());
|
|
199
|
-
|
|
200
|
+
// below a declaration of the outside world, of which the graph holds what the project refers to
|
|
201
|
+
const under = outsideAbove(v.g, name.trim());
|
|
202
|
+
const above = under === undefined ? null : v.g.nodes[under].name;
|
|
203
|
+
return fail(404, `There is no declaration ${name} in the graph.`, above
|
|
204
|
+
? `Of ${above}'s package the graph holds what the project refers to: a constructor or field of ${above} is ${above}; any other name the project never refers to. GET /api/agent/describe?name=${encodeURIComponent(name.trim())} asks Lean about it.`
|
|
205
|
+
: guesses.length ? `Did you mean ${guesses[0]}? Names are full, as the search gives them.` : "Search for it: GET /api/agent/search?q=<words>.", { didYouMean: guesses });
|
|
200
206
|
}
|
|
201
207
|
/** The declaration a name the graph has no node for is folded into (shared/declfind.ts,
|
|
202
208
|
* `foldedAt`). */
|
|
@@ -256,7 +262,7 @@ export class AgentApi {
|
|
|
256
262
|
}
|
|
257
263
|
const compiled = v.modules.get(module)?.compiled ?? null;
|
|
258
264
|
const hash = lakeTextHash(text);
|
|
259
|
-
return { rel, lines: text.split("\n"), edited:
|
|
265
|
+
return { rel, lines: text.split("\n"), edited: !isCompiledText(compiled, hash), hash };
|
|
260
266
|
}
|
|
261
267
|
/** The file of a module outside the project, as the source window reads it (server/outside.ts):
|
|
262
268
|
* its path in its package, its lines, its package and revision; `edited` where the package is at
|
|
@@ -315,9 +321,9 @@ export class AgentApi {
|
|
|
315
321
|
{ method: "GET", path: "/api/agent", about: "The entry: who you are here and what you may do, how to begin, the rules, the documentation's topics, the most used endpoints.", params: {}, returns: "{about, you: {name, kind, level, may, token?}, level, requests, start, rules, docs, topics, endpoints, errors, graph}", run: (a) => index(this, a) },
|
|
316
322
|
{ method: "GET", path: "/api/agent/endpoints", about: "Every endpoint of this API: what it does, its parameters, its answer and the level it needs.", params: { path: "optional: only this path's (e.g. /api/agent/tcb)" }, returns: "{endpoints: [{method, path, about, params, returns, needs?}]}", run: (a) => endpointList(this, a) },
|
|
317
323
|
{
|
|
318
|
-
method: "GET", path: "/api/agent/module", about: "A module of the project: its file's doc comments (/-! … -/, where a project keeps the reasons behind its definitions), what it imports and what imports it, and every declaration in it in the order of the file — what sits beside a declaration: a variant, a weaker or stronger form.",
|
|
319
|
-
params: { name: "a module, e.g. Mathlib.NumberTheory.FLT.Four — or —", of: "a declaration: its module" },
|
|
320
|
-
returns: "{name, file, compiled, note?, imports, importedBy, docs: [{line, endLine, text}], docsCut?, count, declarations: [{name, kind, line, display?, grammar?, also?}]}",
|
|
324
|
+
method: "GET", path: "/api/agent/module", about: "A module of the project: its file's doc comments (/-! … -/, where a project keeps the reasons behind its definitions), what it imports and what imports it, and every declaration in it in the order of the file — what sits beside a declaration: a variant, a weaker or stronger form. With lines, the file itself, as the source window's File mode shows it, at most 400 lines at a time; outside the project too, for a module an outside declaration of the graph is in.",
|
|
325
|
+
params: { name: "a module, e.g. Mathlib.NumberTheory.FLT.Four — or —", of: "a declaration: its module", lines: "optional, <from>-<to> from 1 (at most 400): those lines of the file, as text" },
|
|
326
|
+
returns: "{name, file, compiled, note?, imports, importedBy, docs: [{line, endLine, text}], docsCut?, count, declarations: [{name, kind, line, display?, grammar?, also?}], lines?: {from, to, of}, text?, more?: the next lines to ask}; outside the project: {name, file, outside, compiled, lines, text, more?}",
|
|
321
327
|
run: (a) => moduleGet(this, a),
|
|
322
328
|
},
|
|
323
329
|
{
|
|
@@ -420,6 +426,12 @@ export class AgentApi {
|
|
|
420
426
|
returns: "{name, unit?, module, moduleChosen, inGraph, proofs, lean: text, truncated?: {shown, length}, note?, warnings?, seeAlso?: [names Lean generated from the same command], seeAlsoNote?}",
|
|
421
427
|
run: (a) => print(this, a),
|
|
422
428
|
},
|
|
429
|
+
{
|
|
430
|
+
method: "GET", path: "/api/agent/goals", brief: "Lean's goals at a line of a proof, before and after its tactic", about: "What Lean's InfoView shows at a place, live from Lean's language server: the goals before the tactic there and after it, and the expected type of the term there, as Lean writes them. The place: a line of a declaration's text (name; 1 is its first line, as source gives the text), or of a module's file (module; 1 is the file's first); column from 1, by default where the line's code starts. The tactic is read from the line (what runs from the separator before the column to the one after it: ;, <;>, a by, a case's =>). The build's text only: 409 for a file changed since it was compiled. A widget there is counted, never shown. 503 with Retry-After while Lean elaborates the file (elaborated: how far).",
|
|
431
|
+
params: { name: "a declaration of the graph — or —", module: "a module of the graph (or one an outside declaration is in)", line: "the line, from 1: of the declaration's text with name, of the file with module", column: "optional, from 1: the column (default: where the line's code starts)", wait: "how long to wait for Lean, ms (default 20000, at most 60000)" },
|
|
432
|
+
returns: "{name?, module, file, line (the file's, from 1), column, text (the line), tactic: its text | null, before: [goal] | null, after: [goal] | null, afterFrom?: the line after holds the goals of, expected: goal | null, widgets?, note?} — a goal as Lean writes it: case, hypotheses, ⊢ type; null: no tactic state there (not in a proof's tactic block), or no term",
|
|
433
|
+
run: (a) => goals(this, a),
|
|
434
|
+
},
|
|
423
435
|
{
|
|
424
436
|
method: "GET", path: "/api/agent/targets", brief: "the targets, and how far each review has come", about: "The targets people review, each with how far its review has come.",
|
|
425
437
|
params: {},
|
|
@@ -26,6 +26,7 @@ import { SERVER_WRITER } from "./review.js";
|
|
|
26
26
|
import { lakeTextHash } from "./status.js";
|
|
27
27
|
import { View } from "./agentgraph.js";
|
|
28
28
|
import { body, fail, needAgent, ok } from "./agent.js";
|
|
29
|
+
import { isCompiledText } from "../shared/build.js";
|
|
29
30
|
/** The build the document of view `rec` is of (ExportSpec decision 16): the view's own where the
|
|
30
31
|
* request names none — the past build it is kept at, if it is (HistorySpec decision 19) — else
|
|
31
32
|
* the one `raw` names, as the Time Machine shows a view at another build than its own (null, 0 or
|
|
@@ -105,7 +106,7 @@ async function docInput(api, view, settings, retired = {}, version) {
|
|
|
105
106
|
try {
|
|
106
107
|
const text = readFileSync(join(root, rel), "utf8");
|
|
107
108
|
const hash = lakeTextHash(text);
|
|
108
|
-
return { lines: text.split("\n"), edited:
|
|
109
|
+
return { lines: text.split("\n"), edited: !isCompiledText(m?.compiled, hash), contexts: api.world.contextsOf?.(module) ?? null, hash };
|
|
109
110
|
}
|
|
110
111
|
catch {
|
|
111
112
|
return null;
|
|
@@ -82,6 +82,14 @@ export function followersOf(P, peers, key) {
|
|
|
82
82
|
people.sort((a, b) => (a ?? "\uffff").localeCompare(b ?? "\uffff"));
|
|
83
83
|
return { people, private: P.privateFollowers().get(key) ?? 0 };
|
|
84
84
|
}
|
|
85
|
+
/** The pinned windows in words: the declarations whose source is pinned (the whole file of some,
|
|
86
|
+
* File mode), then the file windows. */
|
|
87
|
+
function pinnedWords(pinned) {
|
|
88
|
+
const decls = pinned.flatMap((w) => ("decl" in w ? [`${w.decl}${w.mode === "file" ? " (its whole file)" : ""}`] : []));
|
|
89
|
+
const files = pinned.flatMap((w) => ("file" in w ? [`the file ${w.file}`] : []));
|
|
90
|
+
const all = [...(decls.length ? [`the source of ${decls.join(", ")}`] : []), ...files];
|
|
91
|
+
return all.length ? `, with ${all.join(" and ")} pinned` : "";
|
|
92
|
+
}
|
|
85
93
|
/** A page's or an agent's place, as the companion tells it (and a conversation's message, where
|
|
86
94
|
* its writer was): with its source windows, the one following the selection and those pinned,
|
|
87
95
|
* each collapsed or not (decided 2026-10-09: what a follower's windows mirror), the build it
|
|
@@ -98,9 +106,9 @@ export function placeOf(api, v) {
|
|
|
98
106
|
const words = (on && on.id !== PROJECT ? `the view ${JSON.stringify(title)}` : v.scope ? `a view on ${v.scope}` : "the Project view") +
|
|
99
107
|
(on?.targets ? `, ${on.targets.join(" and ")}'s view` : "") +
|
|
100
108
|
(v.focus !== undefined ? (v.focus ? `, focused on ${v.focus} for themselves` : ", with no focus for themselves") : "") +
|
|
101
|
-
(v.sel ? `, ${v.source ? "reading the source of" : "looking at"} ${v.sel}` : "") +
|
|
109
|
+
(v.sel ? `, ${v.source ? (v.sourceMode === "file" ? "reading the whole file of" : "reading the source of") : "looking at"} ${v.sel}` : "") +
|
|
102
110
|
(v.selection ? `, with ${v.selection} selected` : "") +
|
|
103
|
-
(v.pinned
|
|
111
|
+
pinnedWords(v.pinned ?? []);
|
|
104
112
|
const built = v.history ? api.world.history?.get(v.history.snapshot)?.at ?? null : null;
|
|
105
113
|
const then = v.history ? `, in the Time Machine at snapshot ${v.history.snapshot}${built ? ` (built ${built})` : ""}` : "";
|
|
106
114
|
// the panels and the board besides, in words where they are not as a page starts
|
|
@@ -127,7 +135,9 @@ export function placeOf(api, v) {
|
|
|
127
135
|
declaration: v.sel,
|
|
128
136
|
source: v.source,
|
|
129
137
|
sourceCollapsed: v.source && v.sourceCollapsed === true,
|
|
130
|
-
|
|
138
|
+
// the whole file shown (File mode, the owner's decision of 2026-11-01), and a file window
|
|
139
|
+
...(v.source && v.sourceMode === "file" ? { sourceMode: "file" } : {}),
|
|
140
|
+
pinned: (v.pinned ?? []).map((w) => ("file" in w ? { file: w.file, collapsed: w.collapsed } : { declaration: w.decl, collapsed: w.collapsed, ...(w.mode === "file" ? { mode: "file" } : {}) })),
|
|
131
141
|
...(v.history ? { history: { snapshot: v.history.snapshot, built } } : {}),
|
|
132
142
|
...(v.activity ? { activity: { ...v.activity } } : {}),
|
|
133
143
|
...(v.lostFound ? { lostAndFound: { open: v.lostFound.open } } : {}),
|