visualproof 0.4.3 → 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 (82) hide show
  1. package/README.md +16 -7
  2. package/dist/assets/latex/visualproof.sty +19 -9
  3. package/dist/assets/tips/tour-agent.webp +0 -0
  4. package/dist/assets/tips/tour-arrange.webp +0 -0
  5. package/dist/assets/tips/tour-artwork.webp +0 -0
  6. package/dist/assets/tips/tour-checks.webp +0 -0
  7. package/dist/assets/tips/tour-keys.webp +0 -0
  8. package/dist/assets/tips/tour-library.webp +0 -0
  9. package/dist/assets/tips/tour-project.webp +0 -0
  10. package/dist/assets/tips/tour-review.webp +0 -0
  11. package/dist/assets/tips/tour-share.webp +0 -0
  12. package/dist/assets/tips/tour-source.webp +0 -0
  13. package/dist/assets/tips/tour-target.webp +0 -0
  14. package/dist/assets/tips/tour-view.webp +0 -0
  15. package/dist/assets/tips/tour.json +117 -112
  16. package/dist/assets/tips/tour.webp +0 -0
  17. package/dist/mcp/visualproof-mcp.mjs +7 -3
  18. package/dist/server/access.js +37 -1
  19. package/dist/server/accesspage.js +130 -0
  20. package/dist/server/agent.js +11 -5
  21. package/dist/server/agentlibrary.js +1 -1
  22. package/dist/server/agentviews.js +1 -1
  23. package/dist/server/artcmd.js +1 -1
  24. package/dist/server/askfollow.js +1 -4
  25. package/dist/server/buildwatch.js +133 -0
  26. package/dist/server/deploy.js +844 -0
  27. package/dist/server/doctor.js +15 -3
  28. package/dist/server/events.js +20 -5
  29. package/dist/server/export.js +17 -4
  30. package/dist/server/fetchurl.js +30 -13
  31. package/dist/server/film.js +1 -1
  32. package/dist/server/history.js +3 -1
  33. package/dist/server/historyapi.js +100 -50
  34. package/dist/server/historythread.js +206 -0
  35. package/dist/server/hover.js +8 -0
  36. package/dist/server/identity.js +25 -1
  37. package/dist/server/library.js +10 -3
  38. package/dist/server/live.js +206 -28
  39. package/dist/server/lostfound.js +3 -2
  40. package/dist/server/main.js +361 -50
  41. package/dist/server/poppler.js +48 -10
  42. package/dist/server/renames.js +10 -5
  43. package/dist/server/review.js +32 -2
  44. package/dist/server/reviewapi.js +1 -1
  45. package/dist/server/status.js +144 -50
  46. package/dist/server/talk.js +7 -2
  47. package/dist/server/usage.js +51 -0
  48. package/dist/server/views.js +21 -7
  49. package/dist/shared/board.js +2 -1
  50. package/dist/shared/collab.js +14 -8
  51. package/dist/shared/deploy.js +35 -0
  52. package/dist/shared/doc/latex.js +5 -3
  53. package/dist/shared/doc/outline.js +6 -3
  54. package/dist/shared/layout.js +297 -70
  55. package/dist/shared/libm.js +366 -0
  56. package/dist/shared/library.js +11 -6
  57. package/dist/shared/palette.js +1 -1
  58. package/dist/shared/review.js +7 -5
  59. package/dist/shared/search.js +7 -3
  60. package/dist/shared/separate.js +556 -32
  61. package/dist/shared/views.js +8 -1
  62. package/dist/web/bundle/app.js +3595 -1520
  63. package/dist/web/bundle/edges.js +44 -16
  64. package/dist/web/bundle/layout.js +1026 -80
  65. package/dist/web/index.html +2 -2
  66. package/dist/web/src/artwork.js +25 -4
  67. package/dist/web/src/axiomring.js +42 -0
  68. package/dist/web/src/bundles.js +52 -16
  69. package/dist/web/src/canvas.js +109 -54
  70. package/dist/web/src/overview.js +4 -1
  71. package/dist/web/src/past.js +28 -0
  72. package/dist/web/src/scene.js +13 -12
  73. package/dist/web/src/selection.js +47 -4
  74. package/dist/web/src/status.js +32 -2
  75. package/dist/web/src/theme.js +108 -0
  76. package/dist/web/style.css +181 -45
  77. package/docs/agent-api/following.md +1 -1
  78. package/docs/agent-api/history.md +3 -0
  79. package/docs/agent-api/library.md +1 -1
  80. package/docs/agent-api/requests.md +4 -1
  81. package/docs/agent-api/views.md +1 -1
  82. package/package.json +1 -1
@@ -75,7 +75,10 @@ export function readView(raw) {
75
75
  const r = raw;
76
76
  if (typeof r.id !== "string" || !r.id)
77
77
  return "it has no id";
78
- const bad = invalidQuery(r.scope);
78
+ // the Project holds everything (ViewSpec decision 5): a scope an earlier version let it take (the
79
+ // outside world toggled, a condition added) is read as `all`
80
+ const project = r.id === PROJECT;
81
+ const bad = project ? null : invalidQuery(r.scope);
79
82
  if (bad)
80
83
  return `its scope cannot be read: ${bad}`;
81
84
  const clustering = r.clustering ?? "namespace";
@@ -95,11 +98,11 @@ export function readView(raw) {
95
98
  // a note that cannot be read is left out; the others are the view's
96
99
  const notes = cleanNotes(r.notes);
97
100
  // the notes of the project added to it and taken out of it; the Project keeps none, holding all
98
- const items = r.id === PROJECT ? {} : cleanItems(r.items);
101
+ const items = project ? {} : cleanItems(r.items);
99
102
  return {
100
103
  id: r.id,
101
104
  name: r.name ?? null,
102
- scope: cleanQuery(r.scope),
105
+ scope: project ? { op: "all" } : cleanQuery(r.scope),
103
106
  clustering: clustering,
104
107
  pins: pins,
105
108
  folds: folds,
@@ -168,21 +171,23 @@ function cleanMemory(x) {
168
171
  export function readProjectView(siteDir, layoutVersion) {
169
172
  const file = join(siteDir, "views.json");
170
173
  if (!existsSync(file))
171
- return { view: null };
174
+ return { view: null, notes: 0 };
172
175
  try {
173
176
  const raw = JSON.parse(readFileSync(file, "utf8"));
177
+ // the project's notes, every one of which the Project's board shows (AttachmentSpec decision 17)
178
+ const notes = cleanProjectNotes(raw.notes).length;
174
179
  for (const r of Array.isArray(raw.views) ? raw.views : []) {
175
180
  const v = readView(r);
176
181
  if (typeof v === "string" || v.id !== PROJECT)
177
182
  continue;
178
183
  if (raw.layoutVersion !== layoutVersion)
179
184
  v.pins = emptyLayouts();
180
- return { view: v };
185
+ return { view: v, notes };
181
186
  }
182
- return { view: null };
187
+ return { view: null, notes };
183
188
  }
184
189
  catch (e) {
185
- return { view: null, why: e instanceof Error ? e.message : String(e) };
190
+ return { view: null, notes: 0, why: e instanceof Error ? e.message : String(e) };
186
191
  }
187
192
  }
188
193
  export class Views {
@@ -235,6 +240,15 @@ export class Views {
235
240
  const has = (n) => !!n.carries?.some((c) => c.file === sha);
236
241
  return this.book.notes.some(has) || this.book.list().some((v) => (v.notes ?? []).some(has));
237
242
  }
243
+ /** Whether a note, the project's or a view's, shows page `page` of PDF `sha` — a clip of
244
+ * `region` of it (rounded as the library rounds a region), or, with none, the page a whole PDF
245
+ * carried shows (its own, else the first): what a read-only page draws of the library
246
+ * (CollabSpec decision 11). */
247
+ shows(sha, page, region) {
248
+ const same = (c) => c.file === sha && (region ? !!c.region && (c.page ?? 1) === page && c.region.every((x, k) => Math.round(x * 1e4) === Math.round(region[k] * 1e4)) : !c.region && (c.page ?? 1) === page);
249
+ const has = (n) => !!n.carries?.some(same);
250
+ return this.book.notes.some(has) || this.book.list().some((v) => (v.notes ?? []).some(has));
251
+ }
238
252
  /** A file came into the library (its first record, by upload or by URL, from a person or an agent):
239
253
  * every item shows on the Project (the owner's decision of 2026-10-11), so a note of the project
240
254
  * carries it — collapsed, its text the file's title, written by whoever added the file, at the
@@ -28,6 +28,7 @@
28
28
  // definition on a board of a target's review set — is still a path. So what is lit is exactly what a view of it holds
29
29
  // (`lightUp`, `zoomScope`), and Zoom in shows what was lit.
30
30
  import { clusterTree, computeLayout, memoryOf, regroup, stabilize, withLocal } from "./layout.js";
31
+ import { hypot } from "./libm.js";
31
32
  import { evaluate, within } from "./query.js";
32
33
  import { Graph } from "./viewgraph.js";
33
34
  /** The declarations `set` holds, as a graph of their own (edges among them only). */
@@ -272,7 +273,7 @@ export function reframePins(g, before, after, pins, mode) {
272
273
  return w;
273
274
  };
274
275
  const r = (v) => Math.round(v * 10) / 10;
275
- const away = (x1, y1, x2, y2) => Math.hypot(x1 - x2, y1 - y2) > 0.5;
276
+ const away = (x1, y1, x2, y2) => hypot(x1 - x2, y1 - y2) > 0.5;
276
277
  let extra = 0;
277
278
  // the same after, parents first, with the pins as they are made
278
279
  const wa = [];
@@ -25,23 +25,29 @@ export function cutShort(s, room) {
25
25
  export function defaultAgentName(by) {
26
26
  return `${cutShort(by.trim(), MAX_NAME - "'s AI".length)}'s AI`;
27
27
  }
28
- /** An agent's name told apart from the names `taken` (the tokens in force), whatever the case: the
28
+ /** An agent's name told apart from the names `taken` (the tokens in force), as sameName tells them: the
29
29
  * name itself, else numbered — "Alice's AI 2", "Alice's AI 3" — within the characters a name may
30
30
  * have, the name cut short to make room for the number. */
31
31
  export function uniqueName(name, taken) {
32
- const seen = new Set([...taken].map((t) => t.toLowerCase()));
32
+ const seen = new Set([...taken].map(nameKey));
33
33
  for (let n = 1;; n++) {
34
34
  const s = n === 1 ? name : `${cutShort(name, MAX_NAME - ` ${n}`.length)} ${n}`;
35
- if (!seen.has(s.toLowerCase()))
35
+ if (!seen.has(nameKey(s)))
36
36
  return s;
37
37
  }
38
38
  }
39
- /** Whether two names are the same name to a reader: whatever the case, and however Unicode writes
40
- * the same letters. A guest cannot take a name someone invited by a personal link holds in this
41
- * sense (CollabSpec decision 9), so that "alice" does not pass for "Alice". */
39
+ /** A name as a reader tells it from others: whatever the case, however Unicode writes the same
40
+ * letters, and without the characters nobody sees (zero-width spaces and joiners, soft hyphens,
41
+ * direction marks: Unicode's default-ignorable code points), which would make one name look like
42
+ * another. */
43
+ export function nameKey(s) {
44
+ return s.normalize("NFKC").replace(/\p{Default_Ignorable_Code_Point}/gu, "").trim().toLowerCase();
45
+ }
46
+ /** Whether two names are the same name to a reader (nameKey). A guest cannot take a name someone
47
+ * invited by a personal link holds in this sense (CollabSpec decision 9), so that neither "alice"
48
+ * nor "Alice" with a zero-width space passes for "Alice". */
42
49
  export function sameName(a, b) {
43
- const key = (s) => s.trim().normalize("NFKC").toLowerCase();
44
- return key(a) === key(b);
50
+ return nameKey(a) === nameKey(b);
45
51
  }
46
52
  /** Up to two letters for a name's round badge: the first letters of its first two words. */
47
53
  export function initials(name) {
@@ -0,0 +1,35 @@
1
+ // A branch of a git repository the server follows and builds itself (SPEC/DeploySpec.md), as the
2
+ // pages and agents are told it: where it comes from, the build going on, the newest commit waiting
3
+ // for it, the last build that ended; and the links into GitHub a page makes of it.
4
+ /** The same without what is for those let in fully: the builds' logs. */
5
+ export function slimDeploy(d) {
6
+ const drop = (x) => {
7
+ if (!x || x.tail === undefined)
8
+ return x;
9
+ const { tail: _, ...rest } = x;
10
+ return rest;
11
+ };
12
+ return { ...d, building: drop(d.building), last: drop(d.last) };
13
+ }
14
+ /** A commit as a page writes it. */
15
+ export const shortCommit = (c) => c.slice(0, 7);
16
+ /** What a step is doing, in words. */
17
+ export const STEP_WORDS = {
18
+ fetch: "fetching it",
19
+ checkout: "checking it out",
20
+ cache: "getting Mathlib's cache",
21
+ build: "lake build",
22
+ };
23
+ const enc = (p) => p.split("/").map(encodeURIComponent).join("/");
24
+ /** A file of the repository at a commit on GitHub, lines `from` to `to` (from 1) marked. */
25
+ export function githubBlob(repo, commit, file, from, to) {
26
+ return `https://github.com/${repo}/blob/${commit}/${enc(file)}#L${from}${to > from ? `-L${to}` : ""}`;
27
+ }
28
+ /** A commit on GitHub. */
29
+ export function githubCommit(repo, commit) {
30
+ return `https://github.com/${repo}/commit/${commit}`;
31
+ }
32
+ /** A branch on GitHub. */
33
+ export function githubTree(repo, branch) {
34
+ return `https://github.com/${repo}/tree/${enc(branch)}`;
35
+ }
@@ -375,11 +375,13 @@ function contents(doc, n) {
375
375
  * project (Mathlib 203, Init 97)`, the six largest libraries named. */
376
376
  function outsideLine(o) {
377
377
  const n = int(o.count);
378
- const named = o.by.slice(0, 6).map((b) => `${escapeLatex(b.name)} ${int(b.count)}`);
378
+ // in thousands as the Export window counts them ("2,640"), the same in every locale
379
+ const k = (x) => x.toLocaleString("en");
380
+ const named = o.by.slice(0, 6).map((b) => `${escapeLatex(b.name)} ${k(int(b.count))}`);
379
381
  const rest = o.by.slice(6).reduce((a, b) => a + int(b.count), 0);
380
382
  if (rest)
381
- named.push(`others ${rest}`);
382
- return `${n} declaration${n === 1 ? "" : "s"} from outside the project${named.length ? ` (${named.join(", ")})` : ""}, not printed`;
383
+ named.push(`others ${k(rest)}`);
384
+ return `${k(n)} declaration${n === 1 ? "" : "s"} from outside the project${named.length ? ` (${named.join(", ")})` : ""}, not printed`;
383
385
  }
384
386
  /** `n` declarations, in words. */
385
387
  const decls = (n) => `${int(n)} declaration${int(n) === 1 ? "" : "s"}`;
@@ -3,11 +3,14 @@
3
3
  // declarations and the notes in each, and the notes attached to a declaration after it. The page
4
4
  // draws the board as this outline (web/src/linear.ts); it is made from the same plan and the same
5
5
  // order the document is (shared/doc/sections.ts, shared/doc/order.ts), so that the two agree.
6
+ import { inlines } from "./markdown.js";
6
7
  import { orderDoc } from "./order.js";
7
- /** A note's first words: its first line, Markdown marks taken out, at most 60 characters. */
8
+ /** A note's first words: its first line of text (a code fence's mark is none), its Markdown marks
9
+ * taken out as its card reads them — code spans' backquotes, emphasis and strong — so that a
10
+ * name's underscores stay (`flt_regular`); at most 60 characters. */
8
11
  export function firstWords(text) {
9
- const line = text.split("\n").find((l) => l.trim()) ?? "";
10
- const plain = line.replace(/[*_`#>]+/g, "").replace(/\s+/g, " ").trim();
12
+ const line = text.split("\n").find((l) => l.trim() && !/^\s*(?:```+|~~~+)/.test(l)) ?? "";
13
+ const plain = inlines(line).map((x) => x.s).join("").replace(/\s+/g, " ").trim();
11
14
  return plain.length > 60 ? `${plain.slice(0, 59).trimEnd()}…` : plain;
12
15
  }
13
16
  /** The outline of the document of `plan` (of graph `g`) in the order of the board `spots` gives. */