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.
- package/README.md +2 -2
- package/dist/assets/tips/phone-fingers.light.mp4 +0 -0
- package/dist/assets/tips/phone-fingers.light.webp +0 -0
- package/dist/assets/tips/tour-agent.webp +0 -0
- package/dist/assets/tips/tour-arrange.webp +0 -0
- package/dist/assets/tips/tour-artwork.webp +0 -0
- package/dist/assets/tips/tour-checks.webp +0 -0
- package/dist/assets/tips/tour-export.webp +0 -0
- package/dist/assets/tips/tour-keys.webp +0 -0
- package/dist/assets/tips/tour-library.webp +0 -0
- package/dist/assets/tips/tour-project.webp +0 -0
- package/dist/assets/tips/tour-review.webp +0 -0
- package/dist/assets/tips/tour-share.webp +0 -0
- package/dist/assets/tips/tour-source.webp +0 -0
- package/dist/assets/tips/tour-target.webp +0 -0
- package/dist/assets/tips/tour-view.webp +0 -0
- package/dist/assets/tips/tour.json +90 -90
- package/dist/assets/tips/tour.webp +0 -0
- package/dist/extractor/Extract.lean +13 -3
- package/dist/server/agent.js +104 -2881
- package/dist/server/agentactivity.js +72 -0
- package/dist/server/agentadvice.js +128 -0
- package/dist/server/agentdocs.js +1 -1
- package/dist/server/agententry.js +180 -0
- package/dist/server/agentexport.js +469 -0
- package/dist/server/agentfollow.js +412 -0
- package/dist/server/agentgraph.js +128 -0
- package/dist/server/agentlean.js +144 -0
- package/dist/server/agentlibrary.js +1 -1
- package/dist/server/agentplaces.js +242 -0
- package/dist/server/agentread.js +569 -0
- package/dist/server/agenttalk.js +282 -0
- package/dist/server/agenttcb.js +378 -0
- package/dist/server/agentviews.js +3 -3
- package/dist/server/app.js +379 -0
- package/dist/server/appaccess.js +127 -0
- package/dist/server/appagent.js +110 -0
- package/dist/server/appgraph.js +176 -0
- package/dist/server/appshare.js +179 -0
- package/dist/server/appsite.js +120 -0
- package/dist/server/apptalk.js +195 -0
- package/dist/server/artcmd.js +1 -1
- package/dist/server/events.js +1 -1
- package/dist/server/history.js +51 -3
- package/dist/server/historyapi.js +34 -2
- package/dist/server/hover.js +11 -7
- package/dist/server/identity.js +1 -1
- package/dist/server/libraryroute.js +3 -3
- package/dist/server/live.js +162 -12
- package/dist/server/main.js +17 -1746
- package/dist/server/mcptools.js +1 -1
- package/dist/server/options.js +350 -0
- package/dist/server/outside.js +311 -0
- package/dist/server/pastdoc.js +22 -3
- package/dist/server/presence.js +25 -8
- package/dist/server/project.js +28 -4
- package/dist/server/readonlygate.js +4 -0
- package/dist/server/reviewapi.js +10 -3
- package/dist/server/send.js +259 -0
- package/dist/server/talk.js +13 -7
- package/dist/server/tokens.js +3 -3
- package/dist/server/view.js +3 -1
- package/dist/server/views.js +1 -1
- package/dist/shared/artrecipe.js +3 -3
- package/dist/shared/board.js +9 -8
- package/dist/shared/collab.js +54 -7
- package/dist/shared/comment.js +1 -1
- package/dist/shared/doc/build.js +30 -14
- package/dist/shared/doc/latex.js +7 -2
- package/dist/shared/doc/model.js +4 -2
- package/dist/shared/doc/sections.js +21 -4
- package/dist/shared/outside.js +16 -0
- package/dist/shared/pastgraph.js +11 -2
- package/dist/shared/pointer.js +152 -0
- package/dist/shared/query.js +36 -5
- package/dist/shared/review.js +34 -2
- package/dist/shared/scope.js +1 -1
- package/dist/shared/sharesnap.js +15 -0
- package/dist/shared/titles.js +4 -0
- package/dist/web/bundle/app.js +51061 -49518
- package/dist/web/index.html +4 -0
- package/dist/web/src/canvas.js +16 -14
- package/dist/web/src/highlight.js +8 -3
- package/dist/web/src/reviewqueue.js +52 -10
- package/dist/web/src/selection.js +1 -1
- package/dist/web/src/status.js +65 -1
- package/dist/web/src/theme.js +1 -1
- package/dist/web/src/visitors.js +1 -1
- package/dist/web/style.css +121 -7
- package/docs/agent-api/advice.md +4 -1
- package/docs/agent-api/export.md +8 -5
- package/docs/agent-api/following.md +9 -3
- package/docs/agent-api/history.md +3 -1
- package/docs/agent-api/reading.md +8 -2
- package/docs/agent-api/views.md +3 -1
- package/package.json +1 -1
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
// Where a declaration outside the project is written (ReviewSpec, "The source window", the owner's
|
|
2
|
+
// decision of 2026-10-20): in a package of the project's lake-manifest (`.lake/packages/`), or in
|
|
3
|
+
// Lean's core (`Init`, `Std`, `Lean`, `Lake`), whose sources the toolchain carries in `src/lean/`.
|
|
4
|
+
// The source window shows it as it shows the project's files, with Lean's hovers, and links it to
|
|
5
|
+
// GitHub at the package's revision (DeploySpec decision 13).
|
|
6
|
+
//
|
|
7
|
+
// A module is found as Lake and Lean find it, never by a path a request gives: the package whose
|
|
8
|
+
// build holds its `.olean` (Lean's search path is the packages' `lib/lean` folders, then the
|
|
9
|
+
// toolchain's), then its source under that package's source folders as its lakefile sets them (the
|
|
10
|
+
// package's `srcDir`, and each library's under it: Lake's layout), the libraries that hold the
|
|
11
|
+
// module first; for core, the toolchain's `src/lean/`. Only a `.lean` file that is there, resolved
|
|
12
|
+
// with its symbolic links, inside the package's folder (or the toolchain's sources) is ever read: a
|
|
13
|
+
// module name is checked part by part before it is made a path, and the server asks only of modules
|
|
14
|
+
// the graph's outside declarations are in (server/live.ts, `outsideFile`). The lakefiles are read
|
|
15
|
+
// as text, never elaborated (server/project.ts).
|
|
16
|
+
//
|
|
17
|
+
// The revisions are what the lake-manifest pins (`rev`), and for core the toolchain: a past build's
|
|
18
|
+
// outside source is the present one only where its package is at the same revision now (HistorySpec
|
|
19
|
+
// decision 24; server/history.ts keeps each build's).
|
|
20
|
+
import { spawnSync } from "node:child_process";
|
|
21
|
+
import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
22
|
+
import { homedir } from "node:os";
|
|
23
|
+
import { join, relative, resolve, sep } from "node:path";
|
|
24
|
+
import { splitName } from "../shared/layout.js";
|
|
25
|
+
import { childEnv } from "./children.js";
|
|
26
|
+
import { parseRemote } from "./deploy.js";
|
|
27
|
+
import { readLakefileLean, readLakefileToml } from "./project.js";
|
|
28
|
+
import { lakeTextHash } from "./status.js";
|
|
29
|
+
/** A module name's parts as a path's: each a name Lake would make a file of, never `.`, `..`, a
|
|
30
|
+
* separator or a control character; null where one is not. */
|
|
31
|
+
export function modulePath(module) {
|
|
32
|
+
if (!module || module.length > 1000)
|
|
33
|
+
return null;
|
|
34
|
+
const parts = splitName(module).map((p) => (p.startsWith("«") && p.endsWith("»") ? p.slice(1, -1) : p));
|
|
35
|
+
for (const p of parts)
|
|
36
|
+
if (!p || p === "." || p === ".." || /[/\\\0-\x1f\x7f«»]/.test(p) || p.length > 255)
|
|
37
|
+
return null;
|
|
38
|
+
return parts;
|
|
39
|
+
}
|
|
40
|
+
/** Whether `path` is `dir` or inside it, both resolved. */
|
|
41
|
+
const inside = (path, dir) => path === dir || path.startsWith(dir.endsWith(sep) ? dir : dir + sep);
|
|
42
|
+
/** The resolved path of what is there, or null. */
|
|
43
|
+
function real(p) {
|
|
44
|
+
try {
|
|
45
|
+
return realpathSync(p);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/** A toolchain's revision in Lean's repository: a release's tag (`leanprover/lean4:v4.35.0`, or
|
|
52
|
+
* `v4.35.0` alone); null for any other (a nightly, a pull request's build). */
|
|
53
|
+
export function toolchainTag(toolchain) {
|
|
54
|
+
const m = /^(?:leanprover\/lean4:)?(v\d+\.\d+\.\d+(?:-rc\d+)?)$/.exec(toolchain.trim());
|
|
55
|
+
return m ? m[1] : null;
|
|
56
|
+
}
|
|
57
|
+
/** Whether a library holds a module, as Lake decides it: a root is a prefix of it, or a glob
|
|
58
|
+
* matches it. */
|
|
59
|
+
function holds(lib, module) {
|
|
60
|
+
const under = (base) => module === base || module.startsWith(`${base}.`);
|
|
61
|
+
if ((lib.roots ?? [lib.name]).some(under))
|
|
62
|
+
return true;
|
|
63
|
+
return (lib.globs ?? []).some((g) => {
|
|
64
|
+
const m = /^(.*)\.([+*])$/.exec(g);
|
|
65
|
+
return m ? (m[2] === "*" ? under(m[1]) : module.startsWith(`${m[1]}.`)) : module === g;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/** The project's packages and Lean's core as places of outside sources, read again when the
|
|
69
|
+
* manifest or the toolchain changes (a branch followed builds a new commit), and each module's
|
|
70
|
+
* file once found. */
|
|
71
|
+
export class OutsideSources {
|
|
72
|
+
root;
|
|
73
|
+
toolchain;
|
|
74
|
+
/** the manifest's packages as read, and of what: its time and size */
|
|
75
|
+
read = null;
|
|
76
|
+
/** the core, per toolchain: found only when a module of it is asked for */
|
|
77
|
+
cores = new Map();
|
|
78
|
+
found = new Map();
|
|
79
|
+
foundFor = "";
|
|
80
|
+
/** how the toolchain's folder is found (`toolchainDir`; a test gives its own) */
|
|
81
|
+
sysroot;
|
|
82
|
+
constructor(root, toolchain, sysroot = toolchainDir) {
|
|
83
|
+
this.root = root;
|
|
84
|
+
this.toolchain = toolchain;
|
|
85
|
+
this.sysroot = sysroot;
|
|
86
|
+
}
|
|
87
|
+
/** Forget what was read and found: a new graph is read (a build may have fetched a package, or
|
|
88
|
+
* installed a toolchain, the manifest unchanged), and what was not found may be there now. */
|
|
89
|
+
forget() {
|
|
90
|
+
this.read = null;
|
|
91
|
+
this.cores.clear();
|
|
92
|
+
this.found.clear();
|
|
93
|
+
}
|
|
94
|
+
/** The packages the manifest lists, read again where it changed since. */
|
|
95
|
+
packages() {
|
|
96
|
+
const manifest = join(this.root, "lake-manifest.json");
|
|
97
|
+
let stamp = "none";
|
|
98
|
+
try {
|
|
99
|
+
const st = statSync(manifest);
|
|
100
|
+
stamp = `${st.mtimeMs}:${st.size}`;
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
// no manifest: no packages, the core alone
|
|
104
|
+
}
|
|
105
|
+
if (this.read?.key === stamp)
|
|
106
|
+
return this.read.packages;
|
|
107
|
+
this.read = { key: stamp, packages: this.fromManifest(manifest) };
|
|
108
|
+
return this.read.packages;
|
|
109
|
+
}
|
|
110
|
+
/** The packages the manifest lists, each where Lake keeps it: `packagesDir/<name>` (and its
|
|
111
|
+
* `subDir`) for a git dependency, `dir` for a path one. One that is not there, or whose folder
|
|
112
|
+
* cannot be resolved, is left out. */
|
|
113
|
+
fromManifest(file) {
|
|
114
|
+
let m;
|
|
115
|
+
try {
|
|
116
|
+
m = JSON.parse(readFileSync(file, "utf8"));
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return [];
|
|
120
|
+
}
|
|
121
|
+
const packagesDir = typeof m.packagesDir === "string" ? m.packagesDir : join(".lake", "packages");
|
|
122
|
+
const out = [];
|
|
123
|
+
for (const p of (Array.isArray(m.packages) ? m.packages : [])) {
|
|
124
|
+
if (typeof p?.name !== "string" || !p.name)
|
|
125
|
+
continue;
|
|
126
|
+
const str = (x) => (typeof x === "string" && x ? x : null);
|
|
127
|
+
const sub = str(p.subDir);
|
|
128
|
+
const repoDir = p.type === "path" ? str(p.dir) && resolve(this.root, str(p.dir)) : resolve(this.root, packagesDir, p.name);
|
|
129
|
+
if (!repoDir)
|
|
130
|
+
continue;
|
|
131
|
+
const dir = real(sub ? join(repoDir, sub) : repoDir);
|
|
132
|
+
if (!dir)
|
|
133
|
+
continue;
|
|
134
|
+
const rev = str(p.rev);
|
|
135
|
+
const remote = p.type === "git" && str(p.url) ? parseRemote(str(p.url)) : null;
|
|
136
|
+
const repo = remote && !("error" in remote) ? remote.github : null;
|
|
137
|
+
out.push({
|
|
138
|
+
name: p.name,
|
|
139
|
+
core: false,
|
|
140
|
+
dir,
|
|
141
|
+
...this.layout(dir, str(p.configFile)),
|
|
142
|
+
rev,
|
|
143
|
+
github: repo && rev && /^[0-9a-f]{7,64}$/.test(rev) ? { repo, dir: sub ? sub.replace(/\\/g, "/").replace(/^\.\/|\/$/g, "") : "" } : null,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
return out;
|
|
147
|
+
}
|
|
148
|
+
/** A package's layout from its lakefile, read as text: where Lake builds it (`buildDir`, by
|
|
149
|
+
* default `.lake/build`) and its source folders — each library's `srcDir` under the package's
|
|
150
|
+
* own, and the package's — resolved, those that leave its folder left out. */
|
|
151
|
+
layout(dir, configFile) {
|
|
152
|
+
const pick = [configFile, "lakefile.toml", "lakefile.lean"].find((f) => f && /^lakefile\.(toml|lean)$/.test(f) && existsSync(join(dir, f)));
|
|
153
|
+
let lf = { libs: [] };
|
|
154
|
+
try {
|
|
155
|
+
if (pick)
|
|
156
|
+
lf = (pick.endsWith(".toml") ? readLakefileToml : readLakefileLean)(readFileSync(join(dir, pick), "utf8"));
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
// an unreadable lakefile: Lake's defaults
|
|
160
|
+
}
|
|
161
|
+
const within = (p) => {
|
|
162
|
+
const r = real(p);
|
|
163
|
+
return r && inside(r, dir) ? r : null;
|
|
164
|
+
};
|
|
165
|
+
const libDirs = [...new Set([lf.buildDir, join(".lake", "build")].filter((b) => !!b).map((b) => join(dir, b, "lib", "lean")))];
|
|
166
|
+
const pkgSrc = join(dir, lf.srcDir ?? ".");
|
|
167
|
+
const srcDirs = [];
|
|
168
|
+
const add = (p, libs) => {
|
|
169
|
+
const r = within(p);
|
|
170
|
+
if (!r)
|
|
171
|
+
return;
|
|
172
|
+
const had = srcDirs.find((s) => s.dir === r);
|
|
173
|
+
if (!had)
|
|
174
|
+
srcDirs.push({ dir: r, libs });
|
|
175
|
+
else if (had.libs && libs)
|
|
176
|
+
had.libs.push(...libs);
|
|
177
|
+
};
|
|
178
|
+
for (const lib of lf.libs)
|
|
179
|
+
add(join(pkgSrc, lib.srcDir ?? "."), [lib]);
|
|
180
|
+
add(pkgSrc, null);
|
|
181
|
+
return { libDirs, srcDirs };
|
|
182
|
+
}
|
|
183
|
+
/** Lean's core: the toolchain's `lib/lean` and its sources, `src/lean/` (Lake's own under
|
|
184
|
+
* `src/lean/lake/`), at the toolchain's release in `leanprover/lean4`, whose `src/` they are;
|
|
185
|
+
* none where the toolchain's folder is not found. */
|
|
186
|
+
core() {
|
|
187
|
+
const tc = this.toolchain();
|
|
188
|
+
if (this.cores.has(tc))
|
|
189
|
+
return this.cores.get(tc);
|
|
190
|
+
const sys = this.sysroot(this.root, tc);
|
|
191
|
+
const dir = sys ? real(join(sys, "src", "lean")) : null;
|
|
192
|
+
const tag = toolchainTag(tc);
|
|
193
|
+
const core = sys && dir
|
|
194
|
+
? {
|
|
195
|
+
name: "Lean",
|
|
196
|
+
core: true,
|
|
197
|
+
dir,
|
|
198
|
+
libDirs: [join(sys, "lib", "lean")],
|
|
199
|
+
srcDirs: [dir, real(join(dir, "lake"))].filter((d) => !!d && inside(d, dir)).map((d) => ({ dir: d, libs: null })),
|
|
200
|
+
rev: tag,
|
|
201
|
+
github: tag ? { repo: "leanprover/lean4", dir: "src" } : null,
|
|
202
|
+
}
|
|
203
|
+
: null;
|
|
204
|
+
this.cores.set(tc, core);
|
|
205
|
+
return core;
|
|
206
|
+
}
|
|
207
|
+
/** Module `module`'s file: in the package whose build holds its `.olean`, under the source folder
|
|
208
|
+
* of the library that holds it (else any of the package's), resolved inside the package's
|
|
209
|
+
* folder; null where there is none. */
|
|
210
|
+
find(module) {
|
|
211
|
+
const pkgs = this.packages();
|
|
212
|
+
// what was found is for this manifest and toolchain
|
|
213
|
+
const key = `${this.read?.key}\0${this.toolchain()}`;
|
|
214
|
+
if (key !== this.foundFor) {
|
|
215
|
+
this.found.clear();
|
|
216
|
+
this.foundFor = key;
|
|
217
|
+
}
|
|
218
|
+
if (this.found.has(module))
|
|
219
|
+
return this.found.get(module);
|
|
220
|
+
const parts = modulePath(module);
|
|
221
|
+
const result = parts ? this.locate(pkgs, module, parts) : null;
|
|
222
|
+
this.found.set(module, result);
|
|
223
|
+
if (this.found.size > 50_000)
|
|
224
|
+
this.found.delete(this.found.keys().next().value);
|
|
225
|
+
return result;
|
|
226
|
+
}
|
|
227
|
+
locate(pkgs, module, parts) {
|
|
228
|
+
const rel = join(...parts);
|
|
229
|
+
// Lean's search path: the packages' builds, then the toolchain's
|
|
230
|
+
const has = (p) => p.libDirs.some((d) => existsSync(`${join(d, rel)}.olean`));
|
|
231
|
+
let pkg = pkgs.find(has);
|
|
232
|
+
if (!pkg) {
|
|
233
|
+
const core = this.core();
|
|
234
|
+
pkg = core && has(core) ? core : undefined;
|
|
235
|
+
}
|
|
236
|
+
if (!pkg)
|
|
237
|
+
return null;
|
|
238
|
+
// the folders of the libraries that hold it first, then the others, the package's own last
|
|
239
|
+
const order = [...pkg.srcDirs.filter((s) => s.libs?.some((l) => holds(l, module))), ...pkg.srcDirs.filter((s) => !s.libs?.some((l) => holds(l, module)))];
|
|
240
|
+
for (const s of order) {
|
|
241
|
+
const path = real(`${join(s.dir, rel)}.lean`);
|
|
242
|
+
if (!path || !path.endsWith(".lean") || !inside(path, pkg.dir))
|
|
243
|
+
continue;
|
|
244
|
+
try {
|
|
245
|
+
if (!statSync(path).isFile())
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
catch {
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
const file = relative(pkg.dir, path).split(sep).join("/");
|
|
252
|
+
const repoPath = pkg.github ? [pkg.github.dir, file].filter(Boolean).join("/") : null;
|
|
253
|
+
return {
|
|
254
|
+
module,
|
|
255
|
+
path,
|
|
256
|
+
file,
|
|
257
|
+
package: { name: pkg.name, core: pkg.core, rev: pkg.rev },
|
|
258
|
+
github: pkg.github && pkg.rev && repoPath ? { repo: pkg.github.repo, rev: pkg.rev, path: repoPath } : null,
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
return null;
|
|
262
|
+
}
|
|
263
|
+
/** The package that holds module `module` now, by name (core: "Lean"), and its revision: what a
|
|
264
|
+
* past build's outside source is compared by (HistorySpec decision 24). */
|
|
265
|
+
packageOf(module) {
|
|
266
|
+
return this.find(module)?.package ?? null;
|
|
267
|
+
}
|
|
268
|
+
/** Each package's revision as the manifest pins it now: what a snapshot records (HistorySpec
|
|
269
|
+
* decision 24); the core's is the toolchain, which a snapshot has already. */
|
|
270
|
+
revisions() {
|
|
271
|
+
const out = {};
|
|
272
|
+
for (const p of this.packages())
|
|
273
|
+
if (p.rev)
|
|
274
|
+
out[p.name] = p.rev;
|
|
275
|
+
return out;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
/** Where an outside file is, as the page and the agents are told it; `changed`: its package is at
|
|
279
|
+
* another revision than when the graph was read. */
|
|
280
|
+
export function whereOf(f, changed = false) {
|
|
281
|
+
return { package: f.package.name, core: f.package.core, rev: f.package.rev, github: f.github, ...(changed ? { changed: true } : {}) };
|
|
282
|
+
}
|
|
283
|
+
/** An outside module's text as GET /api/source answers it, as it does a project file's: its file in
|
|
284
|
+
* its package, the text, its Lake hash, and where it is (shared/outside.ts); null where it cannot be
|
|
285
|
+
* read. */
|
|
286
|
+
export function outsideSource(f, changed = false) {
|
|
287
|
+
let text;
|
|
288
|
+
try {
|
|
289
|
+
text = readFileSync(f.path, "utf8");
|
|
290
|
+
}
|
|
291
|
+
catch {
|
|
292
|
+
return null;
|
|
293
|
+
}
|
|
294
|
+
return { module: f.module, file: f.file, text, hash: lakeTextHash(text), outside: whereOf(f, changed) };
|
|
295
|
+
}
|
|
296
|
+
/** The toolchain's folder (Lean's sysroot): elan's, where elan installed it (`$ELAN_HOME`, by
|
|
297
|
+
* default `~/.elan`, `toolchains/<its name>`: `leanprover/lean4:v4.35.0` is
|
|
298
|
+
* `leanprover--lean4---v4.35.0`); else what `lean --print-prefix` says in the project's folder, a
|
|
299
|
+
* Lean of its own, never one elan would install first. Null where neither is there. */
|
|
300
|
+
export function toolchainDir(root, toolchain) {
|
|
301
|
+
const full = /^v?\d+\.\d+\.\d+/.test(toolchain) ? `leanprover/lean4:${toolchain.startsWith("v") ? toolchain : `v${toolchain}`}` : toolchain;
|
|
302
|
+
const elan = process.env.ELAN_HOME || join(homedir(), ".elan");
|
|
303
|
+
const dir = join(elan, "toolchains", full.replace(/\//g, "--").replace(/:/g, "---"));
|
|
304
|
+
if (existsSync(join(dir, "lib", "lean")))
|
|
305
|
+
return dir;
|
|
306
|
+
if (existsSync(join(elan, "toolchains")))
|
|
307
|
+
return null;
|
|
308
|
+
const r = spawnSync("lean", ["--print-prefix"], { cwd: root, encoding: "utf8", timeout: 60_000, env: childEnv() });
|
|
309
|
+
const out = r.status === 0 ? r.stdout.trim() : "";
|
|
310
|
+
return out && existsSync(join(out, "lib", "lean")) ? out : null;
|
|
311
|
+
}
|
package/dist/server/pastdoc.js
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
// makes the same graph here from the same answers (server/historyapi.ts), so that the document holds
|
|
5
5
|
// exactly what the board shows, and reads each module's text of that build from the history's blobs
|
|
6
6
|
// (server/sourcestore.ts, HistorySpec decisions 20–23). A text that is not kept is said so, never
|
|
7
|
-
// stood in for by the latest build's.
|
|
7
|
+
// stood in for by the latest build's. A module outside the project is not kept per build: its text
|
|
8
|
+
// is its package's file now where that package is at the revision the build had, else not kept
|
|
9
|
+
// (decision 24; server/historyapi.ts, `pastOutside`).
|
|
8
10
|
//
|
|
9
11
|
// A snapshot's graph takes about a second to read back, and the past graph made from it a fraction
|
|
10
12
|
// more: the last few builds printed are kept, each with the texts read for it, so that a second
|
|
@@ -12,7 +14,7 @@
|
|
|
12
14
|
// again.
|
|
13
15
|
import { pastGraph } from "../shared/pastgraph.js";
|
|
14
16
|
import { pageGraph } from "./history.js";
|
|
15
|
-
import { MOST_DIFF, snapshotDiff } from "./historyapi.js";
|
|
17
|
+
import { MOST_DIFF, pastOutside, snapshotDiff } from "./historyapi.js";
|
|
16
18
|
/** how many past builds are kept: a past graph and the texts read for a large view are large on a
|
|
17
19
|
* large project (Sphere-Packing-Lean's past graph: 13.7 MB of JSON) */
|
|
18
20
|
const KEEP = 2;
|
|
@@ -53,6 +55,18 @@ export class PastBuilds {
|
|
|
53
55
|
kept[m] = r.check;
|
|
54
56
|
const past = pastGraph({ snapshot: info, modules: pg.modules, nodes: pg.nodes, projectCount: pg.projectCount, axioms: pg.axioms, axiomSets: pg.axiomSets, edgeCount: snap.edges.length, sources: kept }, Int32Array.from(pg.edges), now, diff);
|
|
55
57
|
const texts = new Map();
|
|
58
|
+
// the outside world's texts of that build: its packages' files now, where at its revisions
|
|
59
|
+
const outsideTexts = new Map();
|
|
60
|
+
const w = this.w;
|
|
61
|
+
const outsideNow = w.outsideNow && ((m) => w.outsideNow(m));
|
|
62
|
+
const outside = (m) => {
|
|
63
|
+
if (!outsideTexts.has(m)) {
|
|
64
|
+
const r = outsideNow && h.outsideModulesOf(id).has(m) ? pastOutside(info, m, outsideNow) : null;
|
|
65
|
+
const body = r?.status === 200 ? r.body : null;
|
|
66
|
+
outsideTexts.set(m, body && { file: body.file, package: body.outside.package, lines: body.text.split("\n") });
|
|
67
|
+
}
|
|
68
|
+
return outsideTexts.get(m);
|
|
69
|
+
};
|
|
56
70
|
const b = {
|
|
57
71
|
info,
|
|
58
72
|
past,
|
|
@@ -60,10 +74,15 @@ export class PastBuilds {
|
|
|
60
74
|
source: (m) => {
|
|
61
75
|
if (!texts.has(m)) {
|
|
62
76
|
const t = h.textOf(id, m);
|
|
63
|
-
|
|
77
|
+
const o = t ? null : outside(m);
|
|
78
|
+
texts.set(m, t && t.text !== null ? { lines: t.text.split("\n"), edited: false, contexts: null, hash: null, check: t.ref.check ?? "lake" } : o ? { lines: o.lines, edited: false, contexts: null, hash: null } : null);
|
|
64
79
|
}
|
|
65
80
|
return texts.get(m);
|
|
66
81
|
},
|
|
82
|
+
outside: (m) => {
|
|
83
|
+
const o = outside(m);
|
|
84
|
+
return o && { file: o.file, package: o.package };
|
|
85
|
+
},
|
|
67
86
|
};
|
|
68
87
|
this.kept.set(key, b);
|
|
69
88
|
while (this.kept.size > KEEP)
|
package/dist/server/presence.js
CHANGED
|
@@ -22,6 +22,12 @@
|
|
|
22
22
|
// afresh when it goes private and when it shows itself again (server/live.ts), so its entries under
|
|
23
23
|
// either id say nothing of the other.
|
|
24
24
|
//
|
|
25
|
+
// Who follows whom (the owner's decision of 2026-10-20): a listed page says it in its place
|
|
26
|
+
// (`following`, as shared/collab.ts personKey names the person followed), which every page reads; a
|
|
27
|
+
// private page says it alone, and is counted for the person it follows (`privateFollowers`), which
|
|
28
|
+
// only that person's pages are told (server/live.ts). A read-only page says nothing, and is seen by
|
|
29
|
+
// nobody (CollabSpec decision 11); an agent follows nobody.
|
|
30
|
+
//
|
|
25
31
|
// What an agent asks to follow the people it helps (GET /api/agent/companion) waits for the list to
|
|
26
32
|
// change: `rev` counts the changes that matter to it — someone came, went, moved, went idle, an
|
|
27
33
|
// agent went offline or came back — and leaves out a camera that moved, which a page reports
|
|
@@ -66,9 +72,11 @@ export class Presence {
|
|
|
66
72
|
notify() {
|
|
67
73
|
const list = this.list();
|
|
68
74
|
this.send(list);
|
|
69
|
-
// neither a camera that pans nor what an agent does while online is a move
|
|
70
|
-
//
|
|
71
|
-
|
|
75
|
+
// neither a camera that pans nor what an agent does while online is a move, nor whom a page
|
|
76
|
+
// follows but where it is an agent, which that agent is told (its companion's `followedBy`); an
|
|
77
|
+
// agent going offline or coming back is, and so is a private reader coming or going
|
|
78
|
+
const agents = (f) => (f?.startsWith("a:") ? f : undefined);
|
|
79
|
+
const sig = JSON.stringify([this.privateCount(), [...this.privateFollowers()].filter(([k]) => k.startsWith("a:")), list.map((p) => ({ ...p, view: p.view ? { ...p.view, cam: null, following: agents(p.view.following) } : null, talk: p.talk ? p.talk.state === "offline" : undefined }))]);
|
|
72
80
|
if (sig === this.lastSig)
|
|
73
81
|
return;
|
|
74
82
|
this.lastSig = sig;
|
|
@@ -105,16 +113,25 @@ export class Presence {
|
|
|
105
113
|
if (!same)
|
|
106
114
|
this.notify();
|
|
107
115
|
}
|
|
108
|
-
/** A private page's heartbeat (CollabSpec decision 8): it is here, and
|
|
109
|
-
* of it — no name, no place, never idle. */
|
|
110
|
-
beatPrivate(id) {
|
|
116
|
+
/** A private page's heartbeat (CollabSpec decision 8): it is here, and whom it follows, and that
|
|
117
|
+
* is all that is kept of it — no name, no place, never idle. */
|
|
118
|
+
beatPrivate(id, following = null) {
|
|
111
119
|
if (this.closed.has(id))
|
|
112
120
|
return;
|
|
113
121
|
const was = this.sessions.get(id);
|
|
114
|
-
this.sessions.set(id, { name: null, view: null, idle: false, seen: Date.now(), agent: false, private: true });
|
|
115
|
-
if (!was?.private)
|
|
122
|
+
this.sessions.set(id, { name: null, view: null, idle: false, seen: Date.now(), agent: false, private: true, ...(following ? { following } : {}) });
|
|
123
|
+
if (!was?.private || was.following !== (following ?? undefined))
|
|
116
124
|
this.notify();
|
|
117
125
|
}
|
|
126
|
+
/** How many private pages follow each person, by personKey: what that person's pages alone are
|
|
127
|
+
* told (server/live.ts), never who. */
|
|
128
|
+
privateFollowers() {
|
|
129
|
+
const out = new Map();
|
|
130
|
+
for (const e of this.sessions.values())
|
|
131
|
+
if (e.private && e.following)
|
|
132
|
+
out.set(e.following, (out.get(e.following) ?? 0) + 1);
|
|
133
|
+
return out;
|
|
134
|
+
}
|
|
118
135
|
/** A page named afresh as it went private or showed itself again (server/live.ts): its entry under
|
|
119
136
|
* `old` goes, and comes back under `id` — counted, or listed with its name and place — as one
|
|
120
137
|
* change, so that no list goes out with the page under both ids, or under neither. */
|
package/dist/server/project.js
CHANGED
|
@@ -17,6 +17,13 @@ export function readLakefileToml(text) {
|
|
|
17
17
|
const dt = head.match(/^\s*defaultTargets\s*=\s*\[([^\]]*)\]/m);
|
|
18
18
|
if (dt)
|
|
19
19
|
out.defaultTargets = strings(dt[1]);
|
|
20
|
+
const dir = (t, key) => t.match(new RegExp(String.raw `^\s*${key}\s*=\s*"([^"]*)"`, "m"))?.[1];
|
|
21
|
+
const src = dir(head, "srcDir");
|
|
22
|
+
if (src !== undefined)
|
|
23
|
+
out.srcDir = src;
|
|
24
|
+
const build = dir(head, "buildDir");
|
|
25
|
+
if (build !== undefined)
|
|
26
|
+
out.buildDir = build;
|
|
20
27
|
for (const table of text.split(/^(?=\s*\[)/m)) {
|
|
21
28
|
if (!/^\s*\[\[\s*lean_lib\s*\]\]/.test(table))
|
|
22
29
|
continue;
|
|
@@ -25,7 +32,8 @@ export function readLakefileToml(text) {
|
|
|
25
32
|
continue;
|
|
26
33
|
const roots = table.match(/^\s*roots\s*=\s*\[([^\]]*)\]/m);
|
|
27
34
|
const globs = table.match(/^\s*globs\s*=\s*\[([^\]]*)\]/m);
|
|
28
|
-
|
|
35
|
+
const libSrc = dir(table, "srcDir");
|
|
36
|
+
out.libs.push({ name: lib[1], ...(roots ? { roots: strings(roots[1]) } : {}), ...(globs ? { globs: strings(globs[1]) } : {}), ...(libSrc !== undefined ? { srcDir: libSrc } : {}) });
|
|
29
37
|
}
|
|
30
38
|
return out;
|
|
31
39
|
}
|
|
@@ -64,11 +72,24 @@ export function readLakefileLean(text) {
|
|
|
64
72
|
const name = code.match(new RegExp(String.raw `^package\s+${ident}`, "m"));
|
|
65
73
|
if (name)
|
|
66
74
|
out.name = unquote(name[1]);
|
|
75
|
+
// a declaration runs to the next line that starts at the margin
|
|
76
|
+
const blockAfter = (at) => {
|
|
77
|
+
const rest = code.slice(at);
|
|
78
|
+
return rest.slice(0, rest.search(/\n(?=\S)/) + 1 || rest.length);
|
|
79
|
+
};
|
|
80
|
+
const dir = (block, key) => block.match(new RegExp(String.raw `\b${key}\s*:=\s*"([^"]*)"`))?.[1];
|
|
81
|
+
if (name) {
|
|
82
|
+
const block = blockAfter(name.index + name[0].length);
|
|
83
|
+
const src = dir(block, "srcDir");
|
|
84
|
+
if (src !== undefined)
|
|
85
|
+
out.srcDir = src;
|
|
86
|
+
const build = dir(block, "buildDir");
|
|
87
|
+
if (build !== undefined)
|
|
88
|
+
out.buildDir = build;
|
|
89
|
+
}
|
|
67
90
|
const targets = [];
|
|
68
91
|
for (const m of code.matchAll(new RegExp(String.raw `(@\[[^\]]*\]\s*)?lean_lib\s+${ident}`, "g"))) {
|
|
69
|
-
|
|
70
|
-
const rest = code.slice(m.index + m[0].length);
|
|
71
|
-
const block = rest.slice(0, rest.search(/\n(?=\S)/) + 1 || rest.length);
|
|
92
|
+
const block = blockAfter(m.index + m[0].length);
|
|
72
93
|
const lib = { name: unquote(m[2]) };
|
|
73
94
|
const roots = block.match(/\broots\s*:=\s*#\[([^\]]*)\]/);
|
|
74
95
|
if (roots)
|
|
@@ -78,6 +99,9 @@ export function readLakefileLean(text) {
|
|
|
78
99
|
const kinds = { one: "", submodules: ".+", andSubmodules: ".*" };
|
|
79
100
|
lib.globs = [...globs[1].matchAll(new RegExp(String.raw `(?:Glob)?\.(one|submodules|andSubmodules)\s+\x60` + ident, "g"))].map((g) => unquote(g[2]) + kinds[g[1]]);
|
|
80
101
|
}
|
|
102
|
+
const libSrc = dir(block, "srcDir");
|
|
103
|
+
if (libSrc !== undefined)
|
|
104
|
+
lib.srcDir = libSrc;
|
|
81
105
|
out.libs.push(lib);
|
|
82
106
|
if (m[1] && /\bdefault_target\b/.test(m[1]))
|
|
83
107
|
targets.push(lib.name);
|
|
@@ -30,6 +30,10 @@ export function readOnlyAllows(method, path) {
|
|
|
30
30
|
// the printed document of a view as it is shared (bounded below)
|
|
31
31
|
if (method === "POST" && path === "/api/export")
|
|
32
32
|
return true;
|
|
33
|
+
// whom the page follows, so as to be sent the pointers of its room (the owner's decisions of
|
|
34
|
+
// 2026-10-20): its own pointer is relayed to nobody, and it is counted nowhere
|
|
35
|
+
if (method === "POST" && path === "/api/pointer")
|
|
36
|
+
return true;
|
|
33
37
|
return false;
|
|
34
38
|
}
|
|
35
39
|
/** Whether Lean's answer is what it says in the end, to be kept for the build: not a failure, nor
|
package/dist/server/reviewapi.js
CHANGED
|
@@ -20,6 +20,12 @@
|
|
|
20
20
|
// nothing: a declaration gone from the graph, or a file changed since compiled, keeps what was said
|
|
21
21
|
// of it withdrawable.
|
|
22
22
|
//
|
|
23
|
+
// Nobody approves twice (ReviewSpec decision 1, the owner's decision of 2026-10-20): an approval of
|
|
24
|
+
// the present version by someone whose current opinion there is an approval of it already — their
|
|
25
|
+
// own, the person's they speak for, an agent's advice — writes nothing, and is answered
|
|
26
|
+
// `{ok, unchanged: true}` (shared/review.ts, noChange); once a change has made it stale, approving
|
|
27
|
+
// again is recorded.
|
|
28
|
+
//
|
|
23
29
|
// Every refusal is an answer: a status, and words that say what to do instead.
|
|
24
30
|
import { readFileSync } from "node:fs";
|
|
25
31
|
import { join } from "node:path";
|
|
@@ -247,10 +253,11 @@ export class ReviewApi {
|
|
|
247
253
|
return appended(this.world.review.append(who, op, this.world.project.toolchain));
|
|
248
254
|
}
|
|
249
255
|
}
|
|
250
|
-
/** An append's result as an answer: the change and the event written
|
|
251
|
-
* a target marked that is one
|
|
256
|
+
/** An append's result as an answer: the change and the event written, or `unchanged` where nothing
|
|
257
|
+
* changed (a target marked that is one, an approval of the version one approved already: ReviewSpec
|
|
258
|
+
* decision 1), or why nothing was written. */
|
|
252
259
|
export function appended(r) {
|
|
253
260
|
if ("status" in r)
|
|
254
261
|
return { status: r.status, body: { error: r.error, hint: r.status === 409 ? "Mend that line of the log by hand (or ask its writer to); VisualProof never rewrites a log." : "Send {op, …}." } };
|
|
255
|
-
return { status: 200, body: { ok: true, change: r.change, ...(r.change ? { event: r.event } : {}) } };
|
|
262
|
+
return { status: 200, body: { ok: true, change: r.change, ...(r.change ? { event: r.event } : { unchanged: true }) } };
|
|
256
263
|
}
|