visualproof 0.4.4 → 0.5.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.
Files changed (48) hide show
  1. package/README.md +16 -7
  2. package/dist/assets/tips/tour-agent.webp +0 -0
  3. package/dist/assets/tips/tour-arrange.webp +0 -0
  4. package/dist/assets/tips/tour-artwork.webp +0 -0
  5. package/dist/assets/tips/tour-checks.webp +0 -0
  6. package/dist/assets/tips/tour-keys.webp +0 -0
  7. package/dist/assets/tips/tour-library.webp +0 -0
  8. package/dist/assets/tips/tour-project.webp +0 -0
  9. package/dist/assets/tips/tour-review.webp +0 -0
  10. package/dist/assets/tips/tour-share.webp +0 -0
  11. package/dist/assets/tips/tour-source.webp +0 -0
  12. package/dist/assets/tips/tour-target.webp +0 -0
  13. package/dist/assets/tips/tour-view.webp +0 -0
  14. package/dist/assets/tips/tour.json +117 -112
  15. package/dist/assets/tips/tour.webp +0 -0
  16. package/dist/server/access.js +3 -1
  17. package/dist/server/accesspage.js +130 -0
  18. package/dist/server/agent.js +6 -1
  19. package/dist/server/buildwatch.js +133 -0
  20. package/dist/server/deploy.js +844 -0
  21. package/dist/server/doctor.js +15 -3
  22. package/dist/server/film.js +1 -1
  23. package/dist/server/historyapi.js +100 -50
  24. package/dist/server/historythread.js +206 -0
  25. package/dist/server/hover.js +8 -0
  26. package/dist/server/live.js +187 -36
  27. package/dist/server/main.js +256 -30
  28. package/dist/server/review.js +27 -7
  29. package/dist/server/status.js +119 -46
  30. package/dist/server/usage.js +51 -0
  31. package/dist/shared/board.js +2 -1
  32. package/dist/shared/deploy.js +35 -0
  33. package/dist/shared/layout.js +297 -70
  34. package/dist/shared/libm.js +366 -0
  35. package/dist/shared/palette.js +1 -1
  36. package/dist/shared/separate.js +556 -32
  37. package/dist/web/bundle/app.js +1972 -826
  38. package/dist/web/bundle/edges.js +2 -1
  39. package/dist/web/bundle/layout.js +1026 -80
  40. package/dist/web/src/canvas.js +47 -34
  41. package/dist/web/src/overview.js +4 -1
  42. package/dist/web/src/scene.js +13 -12
  43. package/dist/web/src/status.js +28 -0
  44. package/dist/web/src/theme.js +108 -0
  45. package/dist/web/style.css +102 -35
  46. package/docs/agent-api/history.md +3 -0
  47. package/docs/agent-api/requests.md +4 -3
  48. package/package.json +1 -1
package/README.md CHANGED
@@ -19,7 +19,12 @@ https://github.com/user-attachments/assets/98e435d6-f493-437d-b342-1833819c0b77
19
19
 
20
20
  ## Try it
21
21
 
22
- Set up in your Lean codebase with agent prompt:
22
+ Set it up for your team with an agent prompt, following your project's GitHub repository:
23
+ ```text
24
+ Deploy VisualProof (https://github.com/LucianoXu/VisualProof) for my Lean project's GitHub repository, following its main branch, and give me the address to open.
25
+ ```
26
+
27
+ Or on your own machine, for the code you are editing:
23
28
  ```text
24
29
  Set up VisualProof (https://github.com/LucianoXu/VisualProof) for my Lean project, and give me the address to open.
25
30
  ```
@@ -33,13 +38,16 @@ What the agent does, step by step: [A poster from the command line](docs/MANUAL.
33
38
  Set up manually:
34
39
  ```bash
35
40
  npm install --global visualproof
36
- cd my-lean-project && lake build
37
- visualproof serve .
41
+ visualproof serve https://github.com/<owner>/<repo>
38
42
  ```
43
+ It follows the repository's default branch and builds each new commit itself ([Following a
44
+ branch](docs/MANUAL.md#following-a-branch)). Or, for the code you are editing:
45
+ `cd my-lean-project && lake build && visualproof serve .`
39
46
 
40
- It needs Node, elan and Poppler ([Requirements](#requirements)). On the first visit the page offers
41
- a short tour of your own project; `?` holds the tips — a film of a review on Sphere-Packing-Lean in
42
- thirteen scenes, with captions, and a row for each thing it does not show — and every key.
47
+ It needs Node, elan and Poppler, and git to follow a branch ([Requirements](#requirements)). On the
48
+ first visit the page offers a short tour of your own project; `?` holds the tips — a film of a
49
+ review on Sphere-Packing-Lean in thirteen scenes, with captions, and a row for each thing it does not
50
+ show — and every key.
43
51
 
44
52
  ## See what a Lean theorem actually rests on
45
53
 
@@ -91,7 +99,8 @@ project's edge.
91
99
  - Optionally XeLaTeX, for the printed document.
92
100
 
93
101
  The project must have been built with `lake build`: VisualProof only reads what the build left,
94
- and never builds it.
102
+ and never builds it. A branch of a git repository it follows (`serve <git URL>`) it builds itself,
103
+ in a clone of its own, and needs git.
95
104
 
96
105
  ## Where it keeps things
97
106
 
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,288 +1,293 @@
1
1
  {
2
2
  "film": {
3
- "file": "tour-9d4241345aaf.mp4",
4
- "sha256": "9d4241345aaf68755b689fd0ba6b3139a2b077a68996361445b8098398079620",
5
- "size": 53706647,
3
+ "file": "tour-5d6d75f7fa38.mp4",
4
+ "sha256": "5d6d75f7fa38eb34d3e0f071d105825618f95a6d5e50b53fca939924d1261b63",
5
+ "size": 48300562,
6
6
  "width": 2560,
7
7
  "height": 1600,
8
- "duration": 238.96666666666667
8
+ "duration": 205.5
9
9
  },
10
10
  "chapters": [
11
11
  {
12
12
  "id": "target",
13
13
  "start": 0,
14
- "end": 19.466666666666665
14
+ "end": 16.733333333333334
15
15
  },
16
16
  {
17
17
  "id": "view",
18
- "start": 19.466666666666665,
19
- "end": 31.833333333333332
18
+ "start": 16.733333333333334,
19
+ "end": 28.233333333333334
20
20
  },
21
21
  {
22
22
  "id": "arrange",
23
- "start": 31.833333333333332,
24
- "end": 53.666666666666664
23
+ "start": 28.233333333333334,
24
+ "end": 45.63333333333333
25
25
  },
26
26
  {
27
27
  "id": "source",
28
- "start": 53.666666666666664,
29
- "end": 66.06666666666666
28
+ "start": 45.63333333333333,
29
+ "end": 55.9
30
30
  },
31
31
  {
32
32
  "id": "keys",
33
- "start": 66.06666666666666,
34
- "end": 92.8
33
+ "start": 55.9,
34
+ "end": 76.2
35
35
  },
36
36
  {
37
37
  "id": "checks",
38
- "start": 92.8,
39
- "end": 111.3
38
+ "start": 76.2,
39
+ "end": 93.9
40
40
  },
41
41
  {
42
42
  "id": "review",
43
- "start": 111.3,
44
- "end": 129.73333333333332
43
+ "start": 93.9,
44
+ "end": 106.96666666666667
45
45
  },
46
46
  {
47
47
  "id": "project",
48
- "start": 129.73333333333332,
49
- "end": 138.66666666666666
48
+ "start": 106.96666666666667,
49
+ "end": 113.7
50
50
  },
51
51
  {
52
52
  "id": "share",
53
- "start": 138.66666666666666,
54
- "end": 152
53
+ "start": 113.7,
54
+ "end": 125.6
55
55
  },
56
56
  {
57
57
  "id": "agent",
58
- "start": 152,
59
- "end": 171.33333333333334
58
+ "start": 125.6,
59
+ "end": 141.83333333333334
60
60
  },
61
61
  {
62
62
  "id": "library",
63
- "start": 171.33333333333334,
64
- "end": 199.73333333333332
63
+ "start": 141.83333333333334,
64
+ "end": 169.93333333333334
65
65
  },
66
66
  {
67
67
  "id": "export",
68
- "start": 199.73333333333332,
69
- "end": 219.23333333333332
68
+ "start": 169.93333333333334,
69
+ "end": 188.26666666666668
70
70
  },
71
71
  {
72
72
  "id": "artwork",
73
- "start": 219.23333333333332,
74
- "end": 238.96666666666667
73
+ "start": 188.26666666666668,
74
+ "end": 205.5
75
75
  }
76
76
  ],
77
77
  "captions": [
78
78
  {
79
79
  "start": 4.1,
80
- "end": 7.9,
80
+ "end": 6.633333333333334,
81
81
  "text": "Search the theorem to review: press /."
82
82
  },
83
83
  {
84
- "start": 7.9,
85
- "end": 11.9,
84
+ "start": 6.633333333333334,
85
+ "end": 9.966666666666667,
86
86
  "text": "There are two MainTheorems: take the one in Dim24."
87
87
  },
88
88
  {
89
- "start": 11.9,
90
- "end": 15.866666666666667,
89
+ "start": 9.966666666666667,
90
+ "end": 13.133333333333333,
91
91
  "text": "Mark it as the target of the review."
92
92
  },
93
93
  {
94
- "start": 15.866666666666667,
95
- "end": 19.466666666666665,
94
+ "start": 13.133333333333333,
95
+ "end": 16.733333333333334,
96
96
  "text": "The side panel lists the targets, with their progress."
97
97
  },
98
98
  {
99
- "start": 19.466666666666665,
100
- "end": 25.333333333333332,
99
+ "start": 16.733333333333334,
100
+ "end": 21.9,
101
101
  "text": "Rests on · Uses: everything the theorem uses."
102
102
  },
103
103
  {
104
- "start": 25.333333333333332,
105
- "end": 28.833333333333332,
104
+ "start": 21.9,
105
+ "end": 25.233333333333334,
106
106
  "text": "Zoom in: a view of just that, in a tab of its own."
107
107
  },
108
108
  {
109
- "start": 28.833333333333332,
110
- "end": 31.833333333333332,
109
+ "start": 25.233333333333334,
110
+ "end": 28.233333333333334,
111
111
  "text": "The view is laid out for what it holds alone."
112
112
  },
113
113
  {
114
- "start": 34.13333333333333,
115
- "end": 39.5,
114
+ "start": 30.133333333333333,
115
+ "end": 34.666666666666664,
116
116
  "text": "Drag a cluster with Ctrl held: it stays there, for everyone."
117
117
  },
118
118
  {
119
- "start": 39.5,
120
- "end": 46.53333333333333,
119
+ "start": 34.666666666666664,
120
+ "end": 39.8,
121
121
  "text": "Or let the lock go with l, and drag without Ctrl."
122
122
  },
123
123
  {
124
- "start": 46.53333333333333,
125
- "end": 53.666666666666664,
124
+ "start": 39.8,
125
+ "end": 45.63333333333333,
126
126
  "text": "Double-click a circle to fold it to a point; again to open."
127
127
  },
128
128
  {
129
- "start": 53.666666666666664,
130
- "end": 58.7,
129
+ "start": 45.63333333333333,
130
+ "end": 49.666666666666664,
131
131
  "text": "Space opens the source of what is selected."
132
132
  },
133
133
  {
134
- "start": 58.7,
135
- "end": 62.5,
134
+ "start": 49.666666666666664,
135
+ "end": 52.96666666666667,
136
136
  "text": "Rest on a name: Lean says what it is."
137
137
  },
138
138
  {
139
- "start": 62.5,
140
- "end": 66.06666666666666,
139
+ "start": 52.96666666666667,
140
+ "end": 55.9,
141
141
  "text": "Click it to go there: its source, its panel."
142
142
  },
143
143
  {
144
- "start": 66.06666666666666,
145
- "end": 69.13333333333334,
144
+ "start": 55.9,
145
+ "end": 58.96666666666667,
146
146
  "text": "Keys: the definitions that carry what it says."
147
147
  },
148
148
  {
149
- "start": 69.13333333333334,
150
- "end": 84.53333333333333,
149
+ "start": 58.96666666666667,
150
+ "end": 69.56666666666666,
151
151
  "text": "Mark each as a key with the mouse, in its panel."
152
152
  },
153
153
  {
154
- "start": 84.53333333333333,
155
- "end": 92.8,
154
+ "start": 69.56666666666666,
155
+ "end": 76.2,
156
156
  "text": "Rests on · Keys lights them, joined to the target."
157
157
  },
158
158
  {
159
- "start": 93.4,
160
- "end": 96.1,
159
+ "start": 76.6,
160
+ "end": 78.9,
161
161
  "text": "Selection: the statement alone."
162
162
  },
163
163
  {
164
- "start": 96.1,
165
- "end": 98.9,
164
+ "start": 78.9,
165
+ "end": 81.7,
166
166
  "text": "Least effort — you trust every name in it."
167
167
  },
168
168
  {
169
- "start": 98.9,
170
- "end": 101.36666666666666,
169
+ "start": 81.7,
170
+ "end": 84.16666666666667,
171
171
  "text": "Keys: the few that carry the meaning."
172
172
  },
173
173
  {
174
- "start": 101.36666666666666,
175
- "end": 103.43333333333334,
174
+ "start": 84.16666666666667,
175
+ "end": 86.23333333333333,
176
176
  "text": "Little effort, good confidence."
177
177
  },
178
178
  {
179
- "start": 103.43333333333334,
180
- "end": 105.63333333333334,
179
+ "start": 86.23333333333333,
180
+ "end": 88.23333333333333,
181
181
  "text": "TCB: everything it rests on."
182
182
  },
183
183
  {
184
- "start": 105.63333333333334,
185
- "end": 107.63333333333334,
184
+ "start": 88.23333333333333,
185
+ "end": 90.23333333333333,
186
186
  "text": "Most effort, most confidence."
187
187
  },
188
188
  {
189
- "start": 107.63333333333334,
190
- "end": 111.3,
189
+ "start": 90.23333333333333,
190
+ "end": 93.9,
191
191
  "text": "Choose how far to read: the counts say what each costs."
192
192
  },
193
193
  {
194
- "start": 111.3,
195
- "end": 116.6,
194
+ "start": 93.9,
195
+ "end": 97.46666666666667,
196
196
  "text": "Read a definition, then say what you think of it."
197
197
  },
198
198
  {
199
- "start": 116.6,
200
- "end": 125.96666666666667,
199
+ "start": 97.46666666666667,
200
+ "end": 103.8,
201
201
  "text": "Approve it, with why: the comment stays with it."
202
202
  },
203
203
  {
204
- "start": 125.96666666666667,
205
- "end": 129.73333333333332,
204
+ "start": 103.8,
205
+ "end": 106.96666666666667,
206
206
  "text": "The target's progress counts your approval."
207
207
  },
208
208
  {
209
- "start": 129.73333333333332,
210
- "end": 135.03333333333333,
209
+ "start": 106.96666666666667,
210
+ "end": 111.06666666666666,
211
211
  "text": "The Project tab: the whole codebase."
212
212
  },
213
213
  {
214
- "start": 135.03333333333333,
215
- "end": 138.66666666666666,
214
+ "start": 111.06666666666666,
215
+ "end": 113.7,
216
216
  "text": "Every board shows the same review."
217
217
  },
218
218
  {
219
- "start": 138.66666666666666,
220
- "end": 145.56666666666666,
219
+ "start": 113.7,
220
+ "end": 119.4,
221
221
  "text": "Share → AI agent: a token, and a prompt for it."
222
222
  },
223
223
  {
224
- "start": 145.56666666666666,
225
- "end": 148.76666666666668,
224
+ "start": 119.4,
225
+ "end": 122.6,
226
226
  "text": "Paste the prompt into your agent: it joins here."
227
227
  },
228
228
  {
229
- "start": 148.76666666666668,
230
- "end": 152,
229
+ "start": 122.6,
230
+ "end": 125.6,
231
231
  "text": "The token is the agent's own: revoke it here."
232
232
  },
233
233
  {
234
- "start": 152.7,
235
- "end": 160.13333333333333,
234
+ "start": 126.1,
235
+ "end": 132.33333333333334,
236
236
  "text": "Click the agent to follow it, and ask."
237
237
  },
238
238
  {
239
- "start": 160.13333333333333,
240
- "end": 165.83333333333334,
239
+ "start": 132.33333333333334,
240
+ "end": 136.83333333333334,
241
241
  "text": "It reads the code, and takes your view along."
242
242
  },
243
243
  {
244
- "start": 165.83333333333334,
245
- "end": 171.33333333333334,
244
+ "start": 136.83333333333334,
245
+ "end": 141.83333333333334,
246
246
  "text": "Its answer names what it explains."
247
247
  },
248
248
  {
249
- "start": 172.13333333333333,
250
- "end": 178.23333333333332,
249
+ "start": 142.63333333333333,
250
+ "end": 148.03333333333333,
251
251
  "text": "Library: add a paper about the code."
252
252
  },
253
253
  {
254
- "start": 178.23333333333332,
255
- "end": 191.53333333333333,
254
+ "start": 148.03333333333333,
255
+ "end": 159.2,
256
256
  "text": "Link it to the theorem, at its page."
257
257
  },
258
258
  {
259
- "start": 191.53333333333333,
260
- "end": 199.73333333333332,
259
+ "start": 159.2,
260
+ "end": 163.6,
261
+ "text": "Space: its source, and the paper beside it at its page."
262
+ },
263
+ {
264
+ "start": 163.6,
265
+ "end": 169.93333333333334,
261
266
  "text": "Pin a note on the target: where to start."
262
267
  },
263
268
  {
264
- "start": 199.73333333333332,
265
- "end": 207.66666666666666,
269
+ "start": 169.93333333333334,
270
+ "end": 177.36666666666667,
266
271
  "text": "Export prints a view: here, the target's TCB."
267
272
  },
268
273
  {
269
- "start": 207.66666666666666,
270
- "end": 212.26666666666668,
274
+ "start": 177.36666666666667,
275
+ "end": 181.33333333333334,
271
276
  "text": "Drag a section to change the document's order."
272
277
  },
273
278
  {
274
- "start": 212.26666666666668,
275
- "end": 219.23333333333332,
279
+ "start": 181.33333333333334,
280
+ "end": 188.26666666666668,
276
281
  "text": "Typeset: the PDF follows the order you set."
277
282
  },
278
283
  {
279
- "start": 219.23333333333332,
280
- "end": 224,
284
+ "start": 188.26666666666668,
285
+ "end": 192.33333333333334,
281
286
  "text": "Artwork: the board as a picture to keep."
282
287
  },
283
288
  {
284
- "start": 224,
285
- "end": 235.36666666666667,
289
+ "start": 192.33333333333334,
290
+ "end": 202.3,
286
291
  "text": "Frame it, then save it as PNG or SVG."
287
292
  }
288
293
  ]
Binary file
@@ -3,7 +3,9 @@
3
3
  // sends it on to the page, so that the key does not stay in the address (the history, a
4
4
  // screenshot, a link copied from the bar). Every other request — the page, its data, the event
5
5
  // stream, the agents' API — needs that cookie, or the key itself as `Authorization: Bearer <key>`
6
- // (an agent), and is answered 404 without it, as if there were nothing here.
6
+ // (an agent), and is answered 404 without it, as if there were nothing here; but a browser asking
7
+ // for a page, which is shown one that says the site is private, and nothing of it (CollabSpec
8
+ // decision 7, the owner's decision of 2026-10-18: server/accesspage.ts).
7
9
  //
8
10
  // One key for everyone: who has the link is in, and taking someone out means a new key for all.
9
11
  // Over plain HTTP the key and the cookie cross the network in the clear: this keeps out who has
@@ -0,0 +1,130 @@
1
+ // What a browser is shown where nothing lets it in (CollabSpec decisions 7 and 12, the owner's
2
+ // decision of 2026-10-18). A server with `--access-key-file` answered every request without the key
3
+ // or its cookie 404 `{"error":"not found"}`, as if there were nothing there: whoever opened the
4
+ // address without the link, or in a browser that had forgotten the cookie, took the service for
5
+ // down. A browser asking for a page is now shown a small page that says the site is private and
6
+ // what to do; everything else — the API, the event stream, agents, files — is answered as before.
7
+ //
8
+ // The page tells an outsider that a VisualProof server is there, and nothing else: it is the same
9
+ // bytes on every server, made from the variant alone (and whether the address alone opens the site,
10
+ // `--public`), never from the site — no project name, version, people, counts or anything the site
11
+ // holds. Of a link that does not open the site, it never says which it was (a key replaced, a
12
+ // personal or read-only link revoked, one never made): only someone who once held a real link could
13
+ // tell revoked from unknown, and the names of who revoked it are the site's.
14
+ //
15
+ // Self-contained: its style inline (allowed by its digest, nothing else), light and dark by the
16
+ // system's choice, no script, nothing fetched.
17
+ import { createHash } from "node:crypto";
18
+ import { KIND_HEADER } from "./identity.js";
19
+ /** Whether a request is a browser asking for a page: GET or HEAD, accepting HTML, for a page's
20
+ * path — not the API (the event stream and the agents' documentation are in it), not a file (a
21
+ * name with an extension, but for `.html`; the fonts, the tips, pdf.js) — and from no agent: one
22
+ * that sends `Authorization: Bearer` or says it is one. A sign-in proxy's `Authorization: Basic`,
23
+ * passed on, is still a browser's. Anything else keeps the answer it had. */
24
+ export function asksForPage(req, path) {
25
+ if (req.method !== "GET" && req.method !== "HEAD")
26
+ return false;
27
+ if (/^Bearer\s/i.test(req.headers.authorization ?? ""))
28
+ return false;
29
+ const kind = req.headers[KIND_HEADER];
30
+ if ((Array.isArray(kind) ? kind[0] : kind)?.trim().toLowerCase() === "agent")
31
+ return false;
32
+ if (!acceptsHtml(req.headers.accept))
33
+ return false;
34
+ if (path === "/api" || path.startsWith("/api/") || /^\/(fonts|tips|pdfjs)\//.test(path))
35
+ return false;
36
+ const last = path.slice(path.lastIndexOf("/") + 1);
37
+ return !/\.[A-Za-z0-9]+$/.test(last) || /\.html$/i.test(last);
38
+ }
39
+ /** Whether an `Accept` header takes HTML: `text/html` among its media ranges, not at q=0. A browser
40
+ * navigating says so first; a script's fetch, curl and an `<img>` do not. */
41
+ export function acceptsHtml(accept) {
42
+ return (accept ?? "").split(",").some((range) => {
43
+ const [type, ...params] = range.split(";").map((s) => s.trim());
44
+ if (type.toLowerCase() !== "text/html")
45
+ return false;
46
+ const q = params.find((p) => /^q=/i.test(p));
47
+ return q === undefined || Number(q.slice(2)) > 0;
48
+ });
49
+ }
50
+ /** The page's style: the wordmark as the page's `.logo` draws it (web/style.css), the page's
51
+ * colours, light or dark as the system is. */
52
+ const STYLE = `
53
+ :root { color-scheme: light dark; --bg: #f5f5f7; --text: #1d1d1f; --text-2: #6e6e73; --code: rgba(0, 0, 0, 0.05); --link: #6a4be0; --grad: linear-gradient(100deg, #5e5ce6 0%, #bf5af2 52%, #ff375f 100%); }
54
+ @media (prefers-color-scheme: dark) { :root { --bg: #0b0b0d; --text: #f5f5f7; --text-2: #a1a1a6; --code: rgba(255, 255, 255, 0.08); --link: #ab97ff; } }
55
+ * { box-sizing: border-box; }
56
+ html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
57
+ body { margin: 0; min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 20px; background: var(--bg); color: var(--text); font: 16px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif; }
58
+ main { max-width: 30rem; text-align: center; }
59
+ .logo { display: inline-block; margin-bottom: 18px; font-size: 40px; font-weight: 700; letter-spacing: -0.02em; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
60
+ h1 { margin: 0 0 8px; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }
61
+ p { margin: 0 0 8px; color: var(--text-2); }
62
+ code { font: 0.86em "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace; padding: 1px 5px; border-radius: 5px; background: var(--code); color: var(--text); white-space: nowrap; }
63
+ a { color: var(--link); }
64
+ @media (max-width: 480px) { .logo { font-size: 34px; } h1 { font-size: 18px; } p { font-size: 15px; } }
65
+ `;
66
+ /** what the page's CSP allows: its style, by its digest; the `data:` icon (no request for one) */
67
+ export const ACCESS_PAGE_CSP = `default-src 'none'; style-src 'sha256-${createHash("sha256").update(STYLE).digest("base64")}'; img-src data:; base-uri 'none'; form-action 'none'; frame-ancestors 'none'`;
68
+ /** Each page's title and words, as HTML: the same for every server. */
69
+ const WORDS = {
70
+ private: {
71
+ title: "Private",
72
+ head: "This site is private",
73
+ lines: ["Open it with the link you were given. If you could open it before, this browser has forgotten the link: open it again."],
74
+ },
75
+ link: {
76
+ title: "Link no longer valid",
77
+ head: "This link no longer opens this site",
78
+ lines: ["It was replaced or revoked. Ask whoever runs the site for a new one."],
79
+ },
80
+ host: {
81
+ title: "Name not answered",
82
+ head: "This server does not answer this name",
83
+ lines: ["It answers only the names it was started for. Whoever runs it can add this one: start it with <code>--public-url &lt;its address&gt;</code> or <code>--allowed-host &lt;name&gt;</code>."],
84
+ },
85
+ };
86
+ /** The line a link's page adds where the address alone opens the site read-only (`--public`). */
87
+ const PUBLIC_LINE = `Anyone may read the site without one: <a href="/">open it read-only</a>.`;
88
+ /** The page, whole: made from `kind` alone, and whether the address opens the site read-only. */
89
+ export function accessPageHtml(kind, publicRead = false) {
90
+ const w = WORDS[kind];
91
+ const lines = kind === "link" && publicRead ? [...w.lines, PUBLIC_LINE] : w.lines;
92
+ return `<!doctype html>
93
+ <html lang="en">
94
+ <head>
95
+ <meta charset="utf-8">
96
+ <meta name="viewport" content="width=device-width, initial-scale=1">
97
+ <meta name="color-scheme" content="light dark">
98
+ <meta name="robots" content="noindex">
99
+ <title>${w.title} · VisualProof</title>
100
+ <link rel="icon" href="data:,">
101
+ <style>${STYLE}</style>
102
+ </head>
103
+ <body>
104
+ <main>
105
+ <div class="logo">VisualProof</div>
106
+ <h1>${w.head}</h1>
107
+ ${lines.map((l) => `<p>${l}</p>`).join("\n")}
108
+ </main>
109
+ </body>
110
+ </html>
111
+ `;
112
+ }
113
+ /** Answer a request with the page: 403, never kept by a cache, with the headers a page needs to
114
+ * stand alone. Cookies to forget (a revoked link's) are set on `res` before. */
115
+ export function sendAccessPage(res, kind, publicRead = false) {
116
+ if (res.headersSent || res.writableEnded)
117
+ return;
118
+ const body = Buffer.from(accessPageHtml(kind, publicRead));
119
+ res.writeHead(403, {
120
+ "content-type": "text/html; charset=utf-8",
121
+ "content-length": String(body.length),
122
+ "cache-control": "no-store",
123
+ // the same address answers JSON to what does not accept HTML
124
+ vary: "accept",
125
+ "content-security-policy": ACCESS_PAGE_CSP,
126
+ "x-content-type-options": "nosniff",
127
+ "referrer-policy": "no-referrer",
128
+ });
129
+ res.end(body);
130
+ }
@@ -572,7 +572,8 @@ export class AgentApi {
572
572
  settings: st.settings,
573
573
  source,
574
574
  fileOf: (module) => v.modules.get(module)?.file ?? null,
575
- build: { fingerprint: this.world.graph?.fingerprint ?? null, commit: commitOf(root) },
575
+ // a branch's build is of its commit, not of what is checked out meanwhile (DeploySpec)
576
+ build: { fingerprint: this.world.graph?.fingerprint ?? null, commit: shownOr(this.world.shownCommit?.(), root) },
576
577
  ...(tv !== undefined ? { titles: titleContext(this.world) } : {}),
577
578
  board: boardSpots({ g: v.g, review, rec, memory: this.world.views?.book.memoryOf(rec.id, rec.clustering) ?? null, whole: v.meta.layouts?.[rec.clustering], notes }),
578
579
  files,
@@ -3256,6 +3257,10 @@ function clampInt(s, dflt, lo, hi) {
3256
3257
  /** The project's commit, where it is a git repository: `git rev-parse`, which only reads (and is
3257
3258
  * told to take no lock), asked at most once every ten seconds. Null where git is not there or the
3258
3259
  * project is not a repository. */
3260
+ /** The commit a document of the graph on show is of: a branch's build's, else what git says now. */
3261
+ function shownOr(shown, root) {
3262
+ return shown === undefined ? commitOf(root) : shown;
3263
+ }
3259
3264
  export function commitOf(root) {
3260
3265
  const now = Date.now();
3261
3266
  const was = commits.get(root);