visualproof 0.4.4 → 0.6.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 +16 -7
- 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-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 +132 -117
- package/dist/assets/tips/tour.webp +0 -0
- package/dist/mcp/visualproof-mcp.mjs +20 -9
- package/dist/server/access.js +31 -1
- package/dist/server/accesspage.js +130 -0
- package/dist/server/agent.js +143 -50
- package/dist/server/askfollow.js +1 -1
- package/dist/server/buildwatch.js +133 -0
- package/dist/server/deploy.js +995 -0
- package/dist/server/doctor.js +15 -3
- package/dist/server/film.js +1 -1
- package/dist/server/historyapi.js +100 -50
- package/dist/server/historythread.js +206 -0
- package/dist/server/hover.js +8 -0
- package/dist/server/invites.js +113 -20
- package/dist/server/live.js +308 -60
- package/dist/server/main.js +450 -77
- package/dist/server/mcptools.js +33 -20
- package/dist/server/presence.js +3 -3
- package/dist/server/prompt.js +8 -3
- package/dist/server/readonlygate.js +4 -4
- package/dist/server/review.js +27 -7
- package/dist/server/reviewapi.js +51 -17
- package/dist/server/status.js +119 -46
- package/dist/server/talk.js +231 -115
- package/dist/server/tokens.js +10 -2
- package/dist/server/usage.js +51 -0
- package/dist/shared/board.js +2 -1
- package/dist/shared/build.js +35 -1
- package/dist/shared/collab.js +8 -0
- package/dist/shared/deploy.js +35 -0
- package/dist/shared/keys.js +66 -37
- package/dist/shared/layout.js +297 -70
- package/dist/shared/libm.js +366 -0
- package/dist/shared/lostfound.js +1 -0
- package/dist/shared/mentions.js +83 -0
- package/dist/shared/palette.js +1 -1
- package/dist/shared/query.js +13 -4
- package/dist/shared/review.js +91 -21
- package/dist/shared/reviewqueue.js +6 -1
- package/dist/shared/separate.js +556 -32
- package/dist/web/bundle/app.js +5022 -2736
- package/dist/web/bundle/edges.js +2 -1
- package/dist/web/bundle/layout.js +1026 -80
- package/dist/web/index.html +45 -9
- package/dist/web/src/canvas.js +47 -34
- package/dist/web/src/overview.js +4 -1
- package/dist/web/src/reviewqueue.js +52 -19
- package/dist/web/src/scene.js +13 -12
- package/dist/web/src/status.js +28 -0
- package/dist/web/src/theme.js +108 -0
- package/dist/web/src/trust.js +271 -0
- package/dist/web/style.css +283 -105
- package/docs/agent-api/README.md +13 -11
- package/docs/agent-api/advice.md +8 -2
- package/docs/agent-api/export.md +1 -1
- package/docs/agent-api/following.md +11 -12
- package/docs/agent-api/history.md +6 -2
- package/docs/agent-api/mcp.md +15 -15
- package/docs/agent-api/notes.md +1 -1
- package/docs/agent-api/reading.md +2 -2
- package/docs/agent-api/requests.md +16 -18
- package/docs/agent-api/talking.md +60 -55
- package/docs/agent-api/tcb.md +21 -21
- package/docs/agent-api/views.md +3 -4
- package/docs/agent-api/words.md +8 -8
- package/package.json +2 -1
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// What tells the live loop (server/live.ts) to look at the build again. It looked every second at
|
|
2
|
+
// every module's files, three stats each and three more, and listed every process (`ps`): on
|
|
3
|
+
// NavierStokesAndEuler (2,657 modules) 26,000 stats a second, 7 to 10 % of a core with nothing
|
|
4
|
+
// happening. Now the folders the modules' sources and outputs are in are watched (`fs.watch`:
|
|
5
|
+
// inotify, FSEvents, ReadDirectoryChangesW), and the loop looks when one says something moved in
|
|
6
|
+
// it, while a build goes on and settles, and every SAFETY_MS besides. Where watching cannot be
|
|
7
|
+
// trusted, the loop looks every second as before: on a network or FUSE filesystem, which does not
|
|
8
|
+
// tell of changes made elsewhere (statfs, Linux); where a folder cannot be watched (too many
|
|
9
|
+
// watches); or once looks found changes no watch told of, twice.
|
|
10
|
+
import { existsSync, statfsSync, watch } from "node:fs";
|
|
11
|
+
import { dirname, join } from "node:path";
|
|
12
|
+
/** how often the loop looks whatever the watches say: a change they did not tell is found then */
|
|
13
|
+
export const SAFETY_MS = 30_000;
|
|
14
|
+
/** looks that found a change no watch told, before the watches are given up */
|
|
15
|
+
const MISSES = 2;
|
|
16
|
+
/** Linux filesystems that do not tell inotify of changes made elsewhere (linux/magic.h): NFS, SMB
|
|
17
|
+
* and CIFS, FUSE (sshfs, virtiofs: Docker's shares), 9p (WSL's Windows drives), Ceph, AFS, Coda,
|
|
18
|
+
* VirtualBox's shared folders, GPFS, Lustre */
|
|
19
|
+
const REMOTE = new Map([
|
|
20
|
+
[0x6969, "NFS"], [0x517b, "SMB"], [0xff534d42, "CIFS"], [0xfe534d42, "SMB2"], [0x65735546, "FUSE"], [0x01021997, "9p"],
|
|
21
|
+
[0x00c36400, "Ceph"], [0x5346414f, "AFS"], [0x73757245, "Coda"], [0x786f4256, "vboxsf"], [0x47504653, "GPFS"], [0x0bd00bd0, "Lustre"],
|
|
22
|
+
]);
|
|
23
|
+
/** Whether the live loop looks at the build's files now: when a watch said something moved, where
|
|
24
|
+
* the watches cannot be trusted, while a compile runs or the set of them changed, while a build
|
|
25
|
+
* goes on and settles or its files are still to be read, and every SAFETY_MS besides. A server
|
|
26
|
+
* at rest does none of these. */
|
|
27
|
+
export function shouldLook(r) {
|
|
28
|
+
return r.heard || r.polling || r.running > 0 || r.runsChanged || r.active || r.sinceMove < r.settle + 2 * r.tick || r.unread || r.sinceLook >= SAFETY_MS;
|
|
29
|
+
}
|
|
30
|
+
/** The folders a project's modules are in: their sources' and their outputs'. */
|
|
31
|
+
export function moduleDirs(p, mods) {
|
|
32
|
+
const out = new Set();
|
|
33
|
+
for (const m of mods.values()) {
|
|
34
|
+
out.add(dirname(join(p.root, m.file)));
|
|
35
|
+
out.add(dirname(join(p.libDir, ...m.name.split("."))));
|
|
36
|
+
}
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
/** The filesystem `dir` is on, where it is one that does not tell of changes made elsewhere. */
|
|
40
|
+
function remoteFs(dir) {
|
|
41
|
+
if (process.platform !== "linux")
|
|
42
|
+
return null;
|
|
43
|
+
try {
|
|
44
|
+
return REMOTE.get(statfsSync(dir).type) ?? null;
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export class BuildWatch {
|
|
51
|
+
/** something moved since the last look; at first, so that the first look is made at once */
|
|
52
|
+
dirty = true;
|
|
53
|
+
/** why the folders are not watched and the loop looks every second; null while they are */
|
|
54
|
+
polling = null;
|
|
55
|
+
watchers = new Map();
|
|
56
|
+
misses = 0;
|
|
57
|
+
say;
|
|
58
|
+
constructor(say = () => { }) {
|
|
59
|
+
this.say = say;
|
|
60
|
+
}
|
|
61
|
+
/** Watch the folders `dirs` (each, or where it is not there yet, the nearest one above it that is,
|
|
62
|
+
* up to `root`), and no others. */
|
|
63
|
+
watch(dirs, root) {
|
|
64
|
+
if (this.polling)
|
|
65
|
+
return;
|
|
66
|
+
const wanted = new Set();
|
|
67
|
+
for (const d of dirs) {
|
|
68
|
+
let at = d;
|
|
69
|
+
// an output folder not built yet: the project's own folder at the highest
|
|
70
|
+
while (!existsSync(at) && at !== root && dirname(at) !== at)
|
|
71
|
+
at = dirname(at);
|
|
72
|
+
wanted.add(at);
|
|
73
|
+
}
|
|
74
|
+
for (const [d, w] of this.watchers)
|
|
75
|
+
if (!wanted.has(d)) {
|
|
76
|
+
w.close();
|
|
77
|
+
this.watchers.delete(d);
|
|
78
|
+
}
|
|
79
|
+
for (const d of wanted) {
|
|
80
|
+
if (this.watchers.has(d))
|
|
81
|
+
continue;
|
|
82
|
+
const fs = remoteFs(d);
|
|
83
|
+
if (fs)
|
|
84
|
+
return this.poll(`${d} is on ${fs}, which does not tell of changes made elsewhere`);
|
|
85
|
+
let w;
|
|
86
|
+
try {
|
|
87
|
+
// never what keeps the server running
|
|
88
|
+
w = watch(d, { persistent: false });
|
|
89
|
+
}
|
|
90
|
+
catch (e) {
|
|
91
|
+
return this.poll(`${d} cannot be watched (${e instanceof Error ? e.message : String(e)})`);
|
|
92
|
+
}
|
|
93
|
+
w.on("change", () => (this.dirty = true));
|
|
94
|
+
// a folder gone, a watch the system dropped: watched again at the next look that finds it
|
|
95
|
+
w.on("error", () => {
|
|
96
|
+
w.close();
|
|
97
|
+
if (this.watchers.get(d) === w)
|
|
98
|
+
this.watchers.delete(d);
|
|
99
|
+
this.dirty = true;
|
|
100
|
+
});
|
|
101
|
+
this.watchers.set(d, w);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/** A look found a change no watch told of: the watches are made again, and given up once that
|
|
105
|
+
* happened MISSES times. */
|
|
106
|
+
missed() {
|
|
107
|
+
if (this.polling)
|
|
108
|
+
return;
|
|
109
|
+
if (++this.misses >= MISSES)
|
|
110
|
+
return this.poll("looks found changes no watch told of");
|
|
111
|
+
for (const w of this.watchers.values())
|
|
112
|
+
w.close();
|
|
113
|
+
this.watchers.clear();
|
|
114
|
+
// made again at the next look, made at once
|
|
115
|
+
this.dirty = true;
|
|
116
|
+
}
|
|
117
|
+
/** How many folders are watched. */
|
|
118
|
+
get size() {
|
|
119
|
+
return this.watchers.size;
|
|
120
|
+
}
|
|
121
|
+
poll(why) {
|
|
122
|
+
this.polling = why;
|
|
123
|
+
for (const w of this.watchers.values())
|
|
124
|
+
w.close();
|
|
125
|
+
this.watchers.clear();
|
|
126
|
+
this.say(`watch: ${why}; the build is looked at every second`);
|
|
127
|
+
}
|
|
128
|
+
close() {
|
|
129
|
+
for (const w of this.watchers.values())
|
|
130
|
+
w.close();
|
|
131
|
+
this.watchers.clear();
|
|
132
|
+
}
|
|
133
|
+
}
|