visualproof 0.6.0 → 0.8.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 (96) hide show
  1. package/README.md +2 -2
  2. package/dist/assets/tips/phone-fingers.light.mp4 +0 -0
  3. package/dist/assets/tips/phone-fingers.light.webp +0 -0
  4. package/dist/assets/tips/tour-agent.webp +0 -0
  5. package/dist/assets/tips/tour-arrange.webp +0 -0
  6. package/dist/assets/tips/tour-artwork.webp +0 -0
  7. package/dist/assets/tips/tour-checks.webp +0 -0
  8. package/dist/assets/tips/tour-export.webp +0 -0
  9. package/dist/assets/tips/tour-keys.webp +0 -0
  10. package/dist/assets/tips/tour-library.webp +0 -0
  11. package/dist/assets/tips/tour-project.webp +0 -0
  12. package/dist/assets/tips/tour-review.webp +0 -0
  13. package/dist/assets/tips/tour-share.webp +0 -0
  14. package/dist/assets/tips/tour-source.webp +0 -0
  15. package/dist/assets/tips/tour-target.webp +0 -0
  16. package/dist/assets/tips/tour-view.webp +0 -0
  17. package/dist/assets/tips/tour.json +90 -90
  18. package/dist/assets/tips/tour.webp +0 -0
  19. package/dist/extractor/Extract.lean +13 -3
  20. package/dist/server/agent.js +104 -2881
  21. package/dist/server/agentactivity.js +72 -0
  22. package/dist/server/agentadvice.js +128 -0
  23. package/dist/server/agentdocs.js +1 -1
  24. package/dist/server/agententry.js +180 -0
  25. package/dist/server/agentexport.js +469 -0
  26. package/dist/server/agentfollow.js +412 -0
  27. package/dist/server/agentgraph.js +128 -0
  28. package/dist/server/agentlean.js +144 -0
  29. package/dist/server/agentlibrary.js +1 -1
  30. package/dist/server/agentplaces.js +242 -0
  31. package/dist/server/agentread.js +569 -0
  32. package/dist/server/agenttalk.js +282 -0
  33. package/dist/server/agenttcb.js +378 -0
  34. package/dist/server/agentviews.js +3 -3
  35. package/dist/server/app.js +379 -0
  36. package/dist/server/appaccess.js +127 -0
  37. package/dist/server/appagent.js +110 -0
  38. package/dist/server/appgraph.js +176 -0
  39. package/dist/server/appshare.js +179 -0
  40. package/dist/server/appsite.js +120 -0
  41. package/dist/server/apptalk.js +195 -0
  42. package/dist/server/artcmd.js +1 -1
  43. package/dist/server/events.js +1 -1
  44. package/dist/server/history.js +51 -3
  45. package/dist/server/historyapi.js +34 -2
  46. package/dist/server/hover.js +11 -7
  47. package/dist/server/identity.js +1 -1
  48. package/dist/server/libraryroute.js +3 -3
  49. package/dist/server/live.js +162 -12
  50. package/dist/server/main.js +17 -1746
  51. package/dist/server/mcptools.js +1 -1
  52. package/dist/server/options.js +350 -0
  53. package/dist/server/outside.js +311 -0
  54. package/dist/server/pastdoc.js +22 -3
  55. package/dist/server/presence.js +25 -8
  56. package/dist/server/project.js +28 -4
  57. package/dist/server/readonlygate.js +4 -0
  58. package/dist/server/reviewapi.js +10 -3
  59. package/dist/server/send.js +259 -0
  60. package/dist/server/talk.js +13 -7
  61. package/dist/server/tokens.js +3 -3
  62. package/dist/server/view.js +3 -1
  63. package/dist/server/views.js +1 -1
  64. package/dist/shared/artrecipe.js +3 -3
  65. package/dist/shared/board.js +9 -8
  66. package/dist/shared/collab.js +54 -7
  67. package/dist/shared/comment.js +1 -1
  68. package/dist/shared/doc/build.js +30 -14
  69. package/dist/shared/doc/latex.js +7 -2
  70. package/dist/shared/doc/model.js +4 -2
  71. package/dist/shared/doc/sections.js +21 -4
  72. package/dist/shared/outside.js +16 -0
  73. package/dist/shared/pastgraph.js +11 -2
  74. package/dist/shared/pointer.js +152 -0
  75. package/dist/shared/query.js +36 -5
  76. package/dist/shared/review.js +34 -2
  77. package/dist/shared/scope.js +1 -1
  78. package/dist/shared/sharesnap.js +15 -0
  79. package/dist/shared/titles.js +4 -0
  80. package/dist/web/bundle/app.js +51061 -49518
  81. package/dist/web/index.html +4 -0
  82. package/dist/web/src/canvas.js +16 -14
  83. package/dist/web/src/highlight.js +8 -3
  84. package/dist/web/src/reviewqueue.js +52 -10
  85. package/dist/web/src/selection.js +1 -1
  86. package/dist/web/src/status.js +65 -1
  87. package/dist/web/src/theme.js +1 -1
  88. package/dist/web/src/visitors.js +1 -1
  89. package/dist/web/style.css +121 -7
  90. package/docs/agent-api/advice.md +4 -1
  91. package/docs/agent-api/export.md +8 -5
  92. package/docs/agent-api/following.md +9 -3
  93. package/docs/agent-api/history.md +3 -1
  94. package/docs/agent-api/reading.md +8 -2
  95. package/docs/agent-api/views.md +3 -1
  96. package/package.json +1 -1
@@ -58,7 +58,7 @@ export const TOOLS = [
58
58
  },
59
59
  {
60
60
  name: "companion",
61
- about: "Who is on the page now and where each one looks (view, selection, the declaration in their panel, source windows); with wait, the answer comes when someone comes, goes or moves.",
61
+ about: "Who is on the page now and where each one looks (view, selection, the declaration in their panel, source windows), and who follows you; with wait, the answer comes when someone comes, goes or moves.",
62
62
  call: { method: "GET", path: "/api/agent/companion" },
63
63
  args: { wait: int("seconds to wait for a change (at most 60)"), since: int("the rev of an earlier answer") },
64
64
  },
@@ -0,0 +1,350 @@
1
+ // The command line, as server/main.ts reads it: each command's options, the usage `--help` prints,
2
+ // and what is checked before anything runs — what goes only with a git address, with a key or with
3
+ // a command, a branch's name, a template that cannot make a link — each said in a line, with status 2.
4
+ import { join, resolve } from "node:path";
5
+ import { AGENT_LEVELS } from "./agent.js";
6
+ import { branchProblem, DEFAULT_BUILD_HOURS, DEFAULT_POLL_MINUTES, isGitAddress, MATHLIB_CACHES, MAX_BUILD_HOURS, MIN_BUILD_HOURS, MIN_POLL_MINUTES, parseBuildHours, parseRemote } from "./deploy.js";
7
+ import { cacheHome, dataHome } from "./dirs.js";
8
+ import { packageVersion } from "./doctor.js";
9
+ import { UPDATE_MODES } from "./updates.js";
10
+ import { DEFAULT_JOBS } from "./usage.js";
11
+ import { invalidTemplate } from "../shared/editor.js";
12
+ import { DEFAULT_LIBRARY_LIMIT, validSha } from "../shared/library.js";
13
+ /** The usage, to stderr with status 2 for a command line it cannot read; asked for (`--help`),
14
+ * to stdout with status 0. */
15
+ function usage(code = 2) {
16
+ (code === 0 ? console.log : console.error)(`usage: visualproof serve <lean-project | git URL> [--branch name] [--poll ${DEFAULT_POLL_MINUTES}] [--build-timeout ${DEFAULT_BUILD_HOURS}]
17
+ [--mathlib-cache shared|own] [--root Name]... [--port 4173] [--host 127.0.0.1]
18
+ [--site dir] [--cache dir] [--graph saved.json]
19
+ [--identity-header X-Forwarded-User] [--editor URL-template]
20
+ [--agents read|advise|full] [--access-key-file file] [--public] [--jobs ${DEFAULT_JOBS}]
21
+ [--public-url https://host] [--allowed-host name]... [--library-limit GB]
22
+ [--updates auto|notify|off]
23
+ visualproof purge-file <lean-project> <sha256> [--site dir] [--cache dir]
24
+ visualproof export <lean-project> -o page.html [--label text] [--root Name]... [--graph saved.json]
25
+ [--jobs ${DEFAULT_JOBS}] [--site dir] [--cache dir]
26
+ visualproof artwork <lean-project> --recipe recipe.json [-o name] [--png] [--svg] [--root Name]...
27
+ [--site dir] [--cache dir] [--jobs ${DEFAULT_JOBS}] [--screen 1920x1200] [--graph saved.json]
28
+ visualproof doctor [<lean-project>] [--root Name]... [--site dir] [--cache dir]
29
+ visualproof --version
30
+
31
+ Reads what \`lake build\` left in <lean-project>/.lake. It never builds the project, and writes
32
+ nothing into it.
33
+
34
+ A git URL where the project goes (https://github.com/owner/repo, ssh://…, git@host:owner/repo, or
35
+ file:///path for a repository on this machine): the server follows that branch of the repository
36
+ in a clone of its own in the cache, never a workspace, and builds each new commit itself —
37
+ \`lake exe cache get\` where the project is on Mathlib, then \`lake build\` — one at a time, the
38
+ newest commit pushed meanwhile the only one built after it; the board shows the last build
39
+ meanwhile. Git's own credentials (an SSH key, a deploy key, a credential helper): VisualProof keeps
40
+ none, and nothing waits on a prompt. Whoever can push to the branch runs code on this machine, as
41
+ the server's user (SECURITY.md): run it as a user of its own, and protect the branch.
42
+ --branch the branch followed (default: the remote's default branch); never a pull request's or
43
+ a fork's
44
+ --poll how often the remote is asked for the branch's head, in minutes (default ${DEFAULT_POLL_MINUTES})
45
+ --build-timeout the hours past which \`lake build\` is stopped and the build failed, its commit
46
+ not tried again (default ${DEFAULT_BUILD_HOURS}; ${MIN_BUILD_HOURS} to ${MAX_BUILD_HOURS}, fractions too: 1.5)
47
+ --mathlib-cache where \`lake exe cache get\` keeps Mathlib's files: shared (the default) — the
48
+ user's, as their own builds' (~/.cache/mathlib, or MATHLIB_CACHE_DIR), so that a build
49
+ fetches only what they have not; own — the deployment's, in its folder of the cache
50
+ (deploy/<repo>-<hash>/mathlib-cache/): about 0.45 GB, the version of Mathlib checked
51
+ out alone (\`lake exe cache clean\` after each fetch), removed with that folder
52
+
53
+ --root what to read: a library of the lakefile (the modules Lake builds of it) or a module;
54
+ repeatable. By default the lakefile's default targets.
55
+ --site the site's folder: the review's logs and what this running site accumulates — the
56
+ history of builds, the library's files, the views and their layouts, the timeline,
57
+ conversations with agents, agents' tokens and personal links. It cannot be derived
58
+ again and holds secrets: back it up, never commit it. One server at a time uses a
59
+ site. Relative to the current directory, or absolute; default:
60
+ ${join(dataHome(), "sites", "<project>-<hash>")}
61
+ --cache the root of the caches, which a rebuild makes again: the project's (extractions, the
62
+ usage pass's results, prepared views, typeset documents, Lean's language server's
63
+ folder) in projects/<project>-<hash>/, the Lean programs compiled per toolchain in
64
+ lean/, the page's bundle in web/, VisualProof's own releases in updates.json and the
65
+ patches downloaded in versions/ (code the servers run: keep the root yours alone),
66
+ and the tips' tour film in media/.
67
+ Default: ${cacheHome()}
68
+ (XDG_DATA_HOME and XDG_CACHE_HOME move both homes, on any platform)
69
+
70
+ --graph use a saved extraction (a projects/*/extract/*.json of the cache) instead of reading
71
+ the build; the project path still supplies the sources
72
+ export writes one self-contained HTML file: the page, its data and the sources, frozen
73
+
74
+ artwork makes the picture an artwork recipe says (the agents' API's, docs/agent-api/export.md:
75
+ the size, the look, names by a rule, the targets, the selection), as the page's
76
+ artwork mode makes it, without a browser: an SVG and a PNG (--png or --svg for one),
77
+ named by -o (a name, or a path without its extension), else the recipe's title, else
78
+ the project. With --site, the board as that site keeps it (its layout, pins and folds)
79
+ and its review's targets; without, the board as a new site would lay it out, and the
80
+ targets the recipe names. --screen: the screen the board is drawn on, as a reader's
81
+ (default 1920x1200, at least 640x480): how large names are in the picture. It reads
82
+ the site, never writes it; it writes the files and the cache's extraction. Anything
83
+ that fails ends it with status 1. Notes are not drawn yet.
84
+
85
+ --identity-header behind a proxy that authenticates (Tailscale, oauth2-proxy, …): take each
86
+ reader's name from this header instead of the name the page gives. Only use it when
87
+ the proxy is the only way to reach the server: the header is believed as it comes.
88
+
89
+ --editor link each declaration to its place in an editor, through a URL template:
90
+ "vscode://file/{path}:{line}:{col}" for VS Code on this machine, or
91
+ "vscode://vscode-remote/ssh-remote+HOST{path}:{line}" for VS Code over SSH to it.
92
+ {path} is the file on this machine, {rel} the file in the project, {line} and {col}
93
+ where the declaration starts. Each reader can set their own in the page (?).
94
+
95
+ --agents what AI agents (requests with X-VisualProof-Kind: agent; their API is /api/agent) may
96
+ change: read — nothing; advise — give advice and leave notes; full (the default) — also
97
+ whatever a person can do through the page (targets, key declarations, trust, views,
98
+ pins), each recorded as the agent's. An agent's opinion is advice whatever the level:
99
+ shown apart, never counted; agent tokens stay with people.
100
+
101
+ --jobs how many modules the usage pass elaborates at once (default ${DEFAULT_JOBS}; 0: no pass). The
102
+ pass finds which notation each declaration is written in and the exact context it is
103
+ written in (TCBSpec.md, decisions 2 and 4); its findings follow the extractor's graph
104
+ as its next version. Each worker takes about 400 MB of its own, several GB on a large
105
+ project on Mathlib (serve and doctor say which --jobs the memory fits); with memory
106
+ short, fewer run at a time. The import of a module is bound by memory bandwidth: past
107
+ about a quarter of the cores it gains little.
108
+
109
+ --access-key-file let in only those given the link http://<host>:<port>/k/<key>, the key being
110
+ what the file holds (one is made there, readable by its owner alone, if there is none).
111
+ The link leaves a cookie in the browser; agents send Authorization: Bearer <key>.
112
+ Anything else is answered 404, but a browser asking for a page, which is shown one
113
+ that says the site is private and nothing of it. Over plain HTTP the key crosses the
114
+ network in the clear: it keeps out who was not given the link, not who can watch the
115
+ traffic.
116
+ Share also gives an AI agent a token of its own (vpa_…), which reaches /api/agent only,
117
+ and a person a link of their own (/i/vpp_…), which lets them in and says who they are,
118
+ and anyone a read-only link (/r/vpr_…), which lets them see and change nothing shared.
119
+
120
+ --public with --access-key-file: whoever comes without the key or a link of their own is let
121
+ in read-only, rather than turned away: they see the project, its review and its
122
+ history, change nothing that is shared, and are seen by nobody. For a project anyone
123
+ may read (a showcase); never for a private one.
124
+
125
+ --public-url the address people reach this server at, when it is not the one their browser
126
+ sends (a proxy in front): the links Share and Copy link make, and the prompt Share
127
+ makes for an agent, carry it.
128
+
129
+ --allowed-host without --access-key-file, a name this server is reached by; repeatable. A
130
+ server without a key answers only requests for an IP address, localhost (and the names
131
+ under it), --public-url's host and these: any other name is answered 403, so that a web
132
+ page that makes its own name resolve to this machine (DNS rebinding) cannot use it. Give
133
+ the names people reach it by: a proxy's in front of it, this machine's own. With a key,
134
+ the key keeps everyone else out, whatever the name.
135
+
136
+ --updates what the server does with VisualProof's own releases, asked of the npm registry
137
+ (through npm) at start and once a day: auto (the default) — a patch of the version it
138
+ runs (0.4.x) is downloaded into the cache and taken at a quiet moment, nobody on a page,
139
+ open pages reloading where they were; a newer version (0.5.0) is told of, in the log
140
+ and the help, with the command that installs it, after which the server restarts into
141
+ it by itself; notify — told of, never downloaded; off — never asked (and no
142
+ supervisor process), and the tips' tour film never fetched: the server reaches the
143
+ network for nothing of its own. VISUALPROOF_UPDATES says the same. From a checkout,
144
+ never asked.
145
+
146
+ --library-limit the most the project's library of papers and images may take, in GB (default
147
+ ${DEFAULT_LIBRARY_LIMIT / 1024 ** 3}); its files are kept in the site directory, by their hash.
148
+
149
+ purge-file deletes a file's bytes from the library for good (a file added by mistake), and what
150
+ was read of it; its record and its links stay in the review, saying this server lacks it.
151
+ Nothing else deletes a file: removing one from the page archives it.
152
+
153
+ doctor checks what VisualProof needs on this machine (Node, elan, Poppler, XeLaTeX) and, given
154
+ a project, its toolchain, its build and its site, and says what to do; it changes
155
+ nothing.`);
156
+ process.exit(code);
157
+ }
158
+ export function parseArgs(argv) {
159
+ const [cmd, ...rest] = argv;
160
+ if (cmd === "--help" || cmd === "-h" || cmd === "help")
161
+ usage(0);
162
+ if (cmd === "--version" || cmd === "-v") {
163
+ console.log(packageVersion());
164
+ process.exit(0);
165
+ }
166
+ if (cmd !== "serve" && cmd !== "export" && cmd !== "purge-file" && cmd !== "doctor" && cmd !== "artwork")
167
+ usage();
168
+ const fromEnv = process.env.VISUALPROOF_UPDATES;
169
+ if (cmd === "serve" && fromEnv !== undefined && !UPDATE_MODES.includes(fromEnv)) {
170
+ console.error(`visualproof: VISUALPROOF_UPDATES=${fromEnv}: say auto, notify or off`);
171
+ process.exit(2);
172
+ }
173
+ const o = { cmd, path: "", roots: [], port: 4173, host: "127.0.0.1", site: null, cache: null, graph: null, out: null, label: "VisualProof", identityHeader: null, editor: null, agents: "full", accessKeyFile: null, jobs: DEFAULT_JOBS, publicUrl: null, allowedHosts: [], libraryLimit: DEFAULT_LIBRARY_LIMIT, sha: null, publicRead: false, recipe: null, png: false, svg: false, screen: { w: 1920, h: 1200 }, updates: UPDATE_MODES.includes(fromEnv) ? fromEnv : "auto", remote: null, branch: null, poll: null, buildHours: null, mathlibCache: null };
174
+ for (let i = 0; i < rest.length; i++) {
175
+ const a = rest[i];
176
+ const val = () => rest[++i] ?? usage();
177
+ if (a === "--root")
178
+ o.roots.push(val());
179
+ else if (a === "--port")
180
+ o.port = Number(val());
181
+ else if (a === "--host")
182
+ o.host = val();
183
+ else if (a === "--site")
184
+ o.site = val();
185
+ else if (a === "--cache")
186
+ o.cache = val();
187
+ else if (a === "--graph")
188
+ o.graph = resolve(val());
189
+ else if (a === "-o" || a === "--out")
190
+ o.out = resolve(val());
191
+ else if (a === "--label")
192
+ o.label = val();
193
+ else if (a === "--identity-header")
194
+ o.identityHeader = val();
195
+ else if (a === "--editor")
196
+ o.editor = val();
197
+ else if (a === "--access-key-file")
198
+ o.accessKeyFile = resolve(val());
199
+ else if (a === "--public")
200
+ o.publicRead = true;
201
+ else if (a === "--recipe" && cmd === "artwork")
202
+ o.recipe = resolve(val());
203
+ else if (a === "--png" && cmd === "artwork")
204
+ o.png = true;
205
+ else if (a === "--svg" && cmd === "artwork")
206
+ o.svg = true;
207
+ else if (a === "--screen" && cmd === "artwork") {
208
+ const v = val();
209
+ const m = /^(\d+)x(\d+)$/.exec(v);
210
+ // said in a line, as --public-url is, rather than the whole usage
211
+ if (!m || +m[1] < 640 || +m[2] < 480 || +m[1] > 10000 || +m[2] > 10000) {
212
+ console.error(`visualproof artwork: --screen ${v}: give the screen's width and height in pixels, e.g. 1920x1200, from 640x480 to 10000x10000`);
213
+ process.exit(2);
214
+ }
215
+ o.screen = { w: +m[1], h: +m[2] };
216
+ }
217
+ else if (a === "--public-url") {
218
+ const u = val();
219
+ if (!/^https?:\/\/[^\s/?#]+\/?$/.test(u)) {
220
+ console.error(`visualproof: --public-url ${u}: give the scheme and the host (and port), e.g. https://example.org`);
221
+ process.exit(2);
222
+ }
223
+ o.publicUrl = u.replace(/\/+$/, "");
224
+ }
225
+ else if (a === "--allowed-host" && cmd === "serve") {
226
+ const h = val();
227
+ // a name, as a Host header gives it without its port (CollabSpec decision 12)
228
+ if (!/^[A-Za-z0-9]([A-Za-z0-9_-]*[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9_-]*[A-Za-z0-9])?)*\.?$/.test(h)) {
229
+ console.error(`visualproof: --allowed-host ${h}: give a name this server is reached by, without a scheme or a port, e.g. vp.example.org`);
230
+ process.exit(2);
231
+ }
232
+ o.allowedHosts.push(h);
233
+ }
234
+ else if (a === "--jobs") {
235
+ const n = Number(val());
236
+ if (!Number.isInteger(n) || n < 0 || n > 256)
237
+ usage();
238
+ o.jobs = n;
239
+ }
240
+ else if (a === "--branch" && cmd === "serve")
241
+ o.branch = val();
242
+ else if (a === "--poll" && cmd === "serve") {
243
+ const v = val();
244
+ const m = Number(v);
245
+ // said in a line, as --screen is
246
+ if (!/^\d+(\.\d+)?$/.test(v) || m < MIN_POLL_MINUTES || m > 1440) {
247
+ console.error(`visualproof: --poll ${v}: say how often the remote is asked, in minutes, from ${MIN_POLL_MINUTES} to 1440 (a day)`);
248
+ process.exit(2);
249
+ }
250
+ o.poll = m;
251
+ }
252
+ else if (a === "--build-timeout" && cmd === "serve") {
253
+ const h = parseBuildHours(val());
254
+ if (typeof h !== "number") {
255
+ console.error(`visualproof: ${h.error}`);
256
+ process.exit(2);
257
+ }
258
+ o.buildHours = h;
259
+ }
260
+ else if (a === "--mathlib-cache" && cmd === "serve") {
261
+ const v = val();
262
+ if (!MATHLIB_CACHES.includes(v)) {
263
+ console.error(`visualproof: --mathlib-cache ${v.slice(0, 40)}: say shared (the user's Mathlib cache, as their builds': the default) or own (the deployment's, in its folder of the cache)`);
264
+ process.exit(2);
265
+ }
266
+ o.mathlibCache = v;
267
+ }
268
+ else if (a === "--updates" && cmd === "serve") {
269
+ const mode = val();
270
+ if (!UPDATE_MODES.includes(mode))
271
+ usage();
272
+ o.updates = mode;
273
+ }
274
+ else if (a === "--agents") {
275
+ const level = val();
276
+ if (!AGENT_LEVELS.includes(level))
277
+ usage();
278
+ o.agents = level;
279
+ }
280
+ else if (a === "--library-limit") {
281
+ const gb = Number(val());
282
+ if (!Number.isFinite(gb) || gb <= 0 || gb > 10000)
283
+ usage();
284
+ o.libraryLimit = Math.round(gb * 1024 ** 3);
285
+ }
286
+ else if (a.startsWith("-"))
287
+ usage();
288
+ else if (!o.path)
289
+ o.path = a;
290
+ else if (cmd === "purge-file" && !o.sha)
291
+ o.sha = a;
292
+ else
293
+ usage();
294
+ }
295
+ if ((!o.path && cmd !== "doctor") || (cmd === "export" && !o.out) || (cmd === "artwork" && !o.recipe))
296
+ usage();
297
+ // a git address where the project goes: the branch followed and built (DeploySpec decisions 1,
298
+ // 10 and 11), its address and branch checked before anything is run
299
+ if (o.path && isGitAddress(o.path)) {
300
+ if (cmd !== "serve") {
301
+ console.error(`visualproof ${cmd}: ${o.path.slice(0, 200)} is a git address: only serve follows a branch. Give the folder of its clone, which serve names as it starts (its "clone:" line).`);
302
+ process.exit(2);
303
+ }
304
+ const r = parseRemote(o.path);
305
+ if ("error" in r) {
306
+ console.error(`visualproof: ${r.error}`);
307
+ process.exit(2);
308
+ }
309
+ if (o.graph) {
310
+ console.error("visualproof: --graph does not go with a git address: the server builds what it shows");
311
+ process.exit(2);
312
+ }
313
+ const why = o.branch === null ? null : branchProblem(o.branch);
314
+ if (why) {
315
+ console.error(`visualproof: --branch ${why}`);
316
+ process.exit(2);
317
+ }
318
+ o.remote = r;
319
+ }
320
+ else {
321
+ // what is about following a branch and building it: a folder is never built (DeploySpec
322
+ // decision 15)
323
+ const given = [["--branch", o.branch], ["--poll", o.poll], ["--build-timeout", o.buildHours], ["--mathlib-cache", o.mathlibCache]].filter(([, v]) => v !== null).map(([n]) => n);
324
+ if (given.length) {
325
+ console.error(`visualproof: ${given.length > 1 ? `${given.slice(0, -1).join(", ")} and ${given[given.length - 1]} go` : `${given[0]} goes`} with a git address (serve https://github.com/owner/repo): a folder is read as its owner's builds leave it, never built`);
326
+ process.exit(2);
327
+ }
328
+ }
329
+ // read-only for whoever comes, beside those the key or a link lets in: without a key, everyone is in
330
+ // already; behind a sign-in, there is nobody else
331
+ if (o.publicRead && (!o.accessKeyFile || o.identityHeader)) {
332
+ console.error("visualproof: --public lets in read-only whoever has no key: it needs --access-key-file, and does not go with --identity-header");
333
+ process.exit(2);
334
+ }
335
+ // the names a server without a key answers: with one, the key keeps everyone else out whatever
336
+ // the name (CollabSpec decision 12)
337
+ if (o.allowedHosts.length && o.accessKeyFile)
338
+ console.warn("visualproof: --allowed-host changes nothing with --access-key-file: the key lets in whoever has it, by any name");
339
+ if (cmd === "purge-file" && !validSha(o.sha)) {
340
+ console.error("visualproof purge-file: give the file's SHA-256, 64 hex digits, as the page's library shows it.");
341
+ process.exit(2);
342
+ }
343
+ // a template that cannot make a link is said at the start, not found out by a reader's click
344
+ const why = o.editor === null ? null : invalidTemplate(o.editor);
345
+ if (why) {
346
+ console.error(`visualproof: --editor ${o.editor}: ${why}`);
347
+ process.exit(2);
348
+ }
349
+ return o;
350
+ }