visualproof 0.8.1 → 0.9.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 (41) hide show
  1. package/README.md +10 -8
  2. package/dist/assets/tips/tour-library.webp +0 -0
  3. package/dist/assets/tips/tour-source.webp +0 -0
  4. package/dist/assets/tips/tour.json +90 -90
  5. package/dist/extractor/Extract.lean +34 -11
  6. package/dist/server/agent.js +19 -7
  7. package/dist/server/agentexport.js +2 -1
  8. package/dist/server/agentfollow.js +13 -3
  9. package/dist/server/agentlean.js +91 -1
  10. package/dist/server/agentnotes.js +6 -4
  11. package/dist/server/agentread.js +33 -1
  12. package/dist/server/app.js +1 -1
  13. package/dist/server/appgraph.js +24 -0
  14. package/dist/server/boardspots.js +1 -1
  15. package/dist/server/goals.js +224 -0
  16. package/dist/server/hover.js +281 -8
  17. package/dist/server/live.js +14 -0
  18. package/dist/server/main.js +3 -2
  19. package/dist/server/mcptools.js +11 -5
  20. package/dist/server/options.js +17 -2
  21. package/dist/server/readonlygate.js +2 -1
  22. package/dist/server/reviewapi.js +5 -2
  23. package/dist/server/status.js +43 -5
  24. package/dist/shared/build.js +9 -0
  25. package/dist/shared/collab.js +14 -2
  26. package/dist/shared/declfind.js +23 -3
  27. package/dist/shared/goals.js +309 -0
  28. package/dist/shared/hygiene.js +18 -0
  29. package/dist/shared/noteplace.js +45 -19
  30. package/dist/shared/scope.js +74 -45
  31. package/dist/shared/sharesnap.js +4 -2
  32. package/dist/web/bundle/app.js +2271 -581
  33. package/dist/web/index.html +1 -1
  34. package/dist/web/src/highlight.js +53 -3
  35. package/dist/web/style.css +148 -0
  36. package/docs/agent-api/README.md +1 -1
  37. package/docs/agent-api/mcp.md +1 -1
  38. package/docs/agent-api/notes.md +3 -2
  39. package/docs/agent-api/reading.md +38 -2
  40. package/docs/agent-api/words.md +3 -2
  41. package/package.json +1 -1
@@ -34,3 +34,12 @@ export function applyBuildDelta(held, d) {
34
34
  files.push(...changed.values());
35
35
  return { epoch: d.epoch, rev: d.rev, status: { active: d.active, progress: d.progress, files, counts: d.counts } };
36
36
  }
37
+ /** Whether a module's text, of Lake hash `now`, is the one its build was compiled from, `compiled`
38
+ * (the graph's `modules[].compiled`, server/status.ts `compiledTextHash`): only where the build
39
+ * records it and it is that text. Where the build records none — a build restored from Lake's
40
+ * artifact cache whose source was modified since, a module without a trace — nothing says what was
41
+ * compiled, and the text is not taken for it: an opinion is bound to the compiled version, and
42
+ * the usage pass's places are about the compiled text. */
43
+ export function isCompiledText(compiled, now) {
44
+ return !!compiled && !!now && compiled === now;
45
+ }
@@ -270,12 +270,22 @@ export function cleanView(v) {
270
270
  const activity = av && typeof av.open === "boolean" && kind && who ? { open: av.open, kind, who, ...(typeof av.mine === "string" && validName(av.mine) ? { mine: av.mine } : {}) } : null;
271
271
  const lost = o.lostFound && typeof o.lostFound === "object" ? o.lostFound.open : undefined;
272
272
  const scheme = one(BOARD_SCHEMES, o.scheme);
273
+ // the InfoView's caret: a declaration's name, a place within any file's bounds
274
+ const cv = o.caret && typeof o.caret === "object" ? o.caret : null;
275
+ const place = (n, max) => Number.isInteger(n) && n >= 0 && n <= max;
276
+ const caretDecl = cv ? str(cv.decl) : null;
277
+ const caret = cv && caretDecl && place(cv.line, 10_000_000) && place(cv.character, 100_000)
278
+ ? { decl: caretDecl, line: cv.line, character: cv.character, ...(cv.after === true ? { after: true } : {}), ...(cv.pinned === true ? { pinned: true } : {}) }
279
+ : null;
273
280
  const pinned = Array.isArray(o.pinned)
274
281
  ? o.pinned
275
282
  .slice(0, MAX_PINNED)
276
283
  .map((w) => {
277
- const decl = w && typeof w === "object" ? str(w.decl) : null;
278
- return decl ? { decl, collapsed: w.collapsed === true } : null;
284
+ const x = w && typeof w === "object" ? w : null;
285
+ const decl = x ? str(x.decl) : null, file = x && !decl ? str(x.file, 300) : null;
286
+ if (decl)
287
+ return { decl, collapsed: x.collapsed === true, ...(x.mode === "file" ? { mode: "file" } : {}) };
288
+ return file ? { file, collapsed: x.collapsed === true } : null;
279
289
  })
280
290
  .filter((w) => w !== null)
281
291
  : [];
@@ -285,6 +295,7 @@ export function cleanView(v) {
285
295
  ...(selection !== null ? { selection } : {}),
286
296
  source,
287
297
  ...(source && o.sourceCollapsed === true ? { sourceCollapsed: true } : {}),
298
+ ...(source && o.sourceMode === "file" ? { sourceMode: "file" } : {}),
288
299
  ...(pinned.length ? { pinned } : {}),
289
300
  clusterMode: str(o.clusterMode, 16) ?? "namespace",
290
301
  cam: cx !== null && cy !== null && ck !== null ? { x: cx, y: cy, k: ck } : null,
@@ -296,6 +307,7 @@ export function cleanView(v) {
296
307
  ...(o.focus === null || str(o.focus) ? { focus: o.focus } : {}),
297
308
  ...(visitors.length ? { visitors } : {}),
298
309
  ...(paper ? { paper } : {}),
310
+ ...(caret ? { caret } : {}),
299
311
  ...(activity ? { activity } : {}),
300
312
  ...(typeof lost === "boolean" ? { lostFound: { open: lost } } : {}),
301
313
  ...(scheme ? { scheme } : {}),
@@ -29,7 +29,10 @@ export function editDistance(a, b, most) {
29
29
  * declaration or of one so generated, which is a name one component below it. A name one
30
30
  * component below a declaration that is a typo or two away from a declaration beside it is
31
31
  * taken for that typo, not for something folded, unless its last component is one Lean
32
- * generates. */
32
+ * generates. Below a declaration of the outside world only such a component folds: the graph
33
+ * holds of the outside world what the project refers to, and cannot tell a constructor or a
34
+ * field of it from a declaration of its own that nothing names (`Nat.succ_le_of_lt` is not
35
+ * `Nat`). */
33
36
  export function foldedAt(g, name) {
34
37
  const direct = g.foldedInto.get(name);
35
38
  if (direct !== undefined)
@@ -41,6 +44,8 @@ export function foldedAt(g, name) {
41
44
  const at = g.byName.get(head) ?? g.foldedInto.get(head);
42
45
  if (at === undefined || !last)
43
46
  return undefined;
47
+ if (g.isExt(at))
48
+ return GENERATED_LAST.test(last) ? at : undefined;
44
49
  if (!GENERATED_LAST.test(last)) {
45
50
  const most = last.length < 5 ? 1 : 2;
46
51
  const near = (n) => n.length > head.length + 1 && n.startsWith(head + ".") && !n.includes(".", head.length + 1) && editDistance(n.slice(head.length + 1).toLowerCase(), last.toLowerCase(), most) <= most;
@@ -53,8 +58,10 @@ export function foldedAt(g, name) {
53
58
  }
54
59
  return at;
55
60
  }
56
- /** Up to five names like `name`: the same name in another case; then the same last component,
57
- * or one a typo or two away, in the same namespace first; then what the search finds. */
61
+ /** Up to five names like `name`: the same name in another case; the declaration of the outside
62
+ * world it is one component below, whose constructor or field it may be (`foldedAt`); then the
63
+ * same last component, or one a typo or two away, in the same namespace first; then what the
64
+ * search finds. */
58
65
  export function guessNames(g, index, name) {
59
66
  const dot = name.lastIndexOf(".");
60
67
  const last = name.slice(dot + 1).toLowerCase();
@@ -64,6 +71,9 @@ export function guessNames(g, index, name) {
64
71
  if ((scored.get(n) ?? Infinity) > score)
65
72
  scored.set(n, score);
66
73
  };
74
+ const under = outsideAbove(g, name);
75
+ if (under !== undefined)
76
+ offer(g.nodes[under].name, -0.5);
67
77
  const lower = name.toLowerCase();
68
78
  const most = last.length < 5 ? 1 : 2;
69
79
  // the graph's declarations, and the names Lean generated from a command that they fold
@@ -88,6 +98,16 @@ export function guessNames(g, index, name) {
88
98
  .slice(0, 5)
89
99
  .map(([n]) => n);
90
100
  }
101
+ /** The declaration of the outside world `name` is one component below, where the graph has no
102
+ * `name` (foldedAt): what a constructor or a field of it would be folded into. */
103
+ export function outsideAbove(g, name) {
104
+ const n = name.trim();
105
+ const dot = n.lastIndexOf(".");
106
+ if (dot <= 0 || g.byName.has(n))
107
+ return undefined;
108
+ const at = g.byName.get(n.slice(0, dot));
109
+ return at !== undefined && g.isExt(at) ? at : undefined;
110
+ }
91
111
  /** The declaration `name` names, its own or the one it is folded into; undefined where none is. */
92
112
  export function declAt(g, name) {
93
113
  const n = name.trim();
@@ -0,0 +1,309 @@
1
+ // The InfoView (ReviewSpec, "The InfoView"; the owner's decisions of 2026-11-01): what Lean's
2
+ // language server says of the goals at a place of a file — before the tactic there, and after it —
3
+ // and of the expected type of the term there, as the server gives it (server/hover.ts, read from
4
+ // Lean's answers by server/goals.ts) and the page draws it (web/src/infoview.ts). Nothing of it is
5
+ // precomputed: the usage pass elaborates without proofs, so only the language server, which
6
+ // elaborates the whole file, knows the goals.
7
+ //
8
+ // Lean is asked at positions alone. Which positions is read here from the text, as Lean would split
9
+ // a line into tactics: the tactic a place is in runs from just after the `by` or the separator
10
+ // before it (`;`, `<;>`, a case's `=>`, a focusing dot) to the separator after it, at the same depth
11
+ // of brackets. Lean's own rule (`goalsAt?`) gives the goals before a tactic at its first character
12
+ // and the goals after it from just past its first character to its end, so the goals before are
13
+ // asked at the tactic's first character and those after at its end. Where the text is read wrong
14
+ // the answer is still Lean's own at that place, as an editor would show it there.
15
+ //
16
+ // A tactic that holds a block of its own (`have h : P := by simp`) ends inside that block, where
17
+ // Lean has the nested proof's goals ("No goals"), not the outer proof's: the state after the whole
18
+ // line is the one the proof goes on from, the goals at the start of its next line of code (the
19
+ // owner's decision of 2026-11-01; afterLine). Where the proof does not go on, Lean's answer at the
20
+ // end.
21
+ export const CHANGES = ["wasChanged", "willChange", "wasInserted", "willInsert", "wasDeleted", "willDelete"];
22
+ /** A tagged text as plain text. */
23
+ export function flatten(t) {
24
+ if (typeof t === "string")
25
+ return t;
26
+ if (Array.isArray(t))
27
+ return t.map(flatten).join("");
28
+ return flatten(t.t);
29
+ }
30
+ /** The text of a goal as Lean writes it in its plain answer: the case, each hypothesis, the type. */
31
+ export function goalText(g) {
32
+ const hyps = g.hyps.map((h) => `${h.names.join(" ")} : ${flatten(h.type)}${h.val !== undefined ? ` := ${flatten(h.val)}` : ""}`);
33
+ return [...(g.case ? [`case ${g.case}`] : []), ...hyps, `${g.prefix ?? "⊢ "}${flatten(g.type)}`].join("\n");
34
+ }
35
+ const OPEN = "([{⟨⦃⟦";
36
+ const CLOSE = ")]}⟩⦄⟧";
37
+ /** One line's characters as the tactic reader sees them: the code's extent (comments and the
38
+ * spaces around it left out), the bracket depth before each character, and where the separators
39
+ * between tactics are. Strings and comments hold no brackets nor separators. */
40
+ function readLine(line) {
41
+ const depth = new Array(line.length + 1).fill(0);
42
+ const seps = [];
43
+ let end = line.length;
44
+ let d = 0;
45
+ let i = 0;
46
+ const word = /[\p{L}\p{N}_'!?.₀-₉ₐ-ₜ]/u;
47
+ while (i < line.length) {
48
+ const c = line[i];
49
+ depth[i] = d;
50
+ // a comment ends the line's code
51
+ if ((c === "-" && line[i + 1] === "-") || (c === "/" && line[i + 1] === "-")) {
52
+ if (c === "/") {
53
+ const close = line.indexOf("-/", i + 2);
54
+ if (close >= 0) {
55
+ // a comment closed on the line: what follows it is code
56
+ for (let j = i; j < close + 2; j++)
57
+ depth[j] = d;
58
+ i = close + 2;
59
+ continue;
60
+ }
61
+ }
62
+ end = i;
63
+ break;
64
+ }
65
+ if (c === '"') {
66
+ let j = i + 1;
67
+ while (j < line.length && line[j] !== '"')
68
+ j += line[j] === "\\" ? 2 : 1;
69
+ for (let k = i; k <= Math.min(j, line.length - 1); k++)
70
+ depth[k] = d;
71
+ i = j + 1;
72
+ continue;
73
+ }
74
+ if (word.test(c) && !(c === "." && !word.test(line[i + 1] ?? ""))) {
75
+ let j = i;
76
+ while (j < line.length && word.test(line[j]))
77
+ j++;
78
+ if (line.slice(i, j) === "by" && !word.test(line[i - 1] ?? ""))
79
+ seps.push({ at: i, len: 2, kind: "by" });
80
+ for (let k = i; k < j; k++)
81
+ depth[k] = d;
82
+ i = j;
83
+ continue;
84
+ }
85
+ if (OPEN.includes(c))
86
+ d++;
87
+ else if (CLOSE.includes(c))
88
+ d--;
89
+ else if (line.startsWith("<;>", i)) {
90
+ seps.push({ at: i, len: 3, kind: "sep" });
91
+ depth[i + 1] = depth[i + 2] = d;
92
+ i += 3;
93
+ continue;
94
+ }
95
+ else if (c === ";")
96
+ seps.push({ at: i, len: 1, kind: "sep" });
97
+ else if (c === "=" && line[i + 1] === ">") {
98
+ seps.push({ at: i, len: 2, kind: "arrow" });
99
+ depth[i + 1] = d;
100
+ i += 2;
101
+ continue;
102
+ }
103
+ else if (c === "|" && line[i + 1] !== "|" && line[i + 1] !== ">" && line[i - 1] !== "|" && line[i - 1] !== "<")
104
+ seps.push({ at: i, len: 1, kind: "bar" });
105
+ i++;
106
+ }
107
+ depth[line.length] = d;
108
+ while (end > 0 && /\s/.test(line[end - 1]))
109
+ end--;
110
+ let start = 0;
111
+ while (start < end && /\s/.test(line[start]))
112
+ start++;
113
+ return { start, end, depth, seps: seps.filter((s) => s.at < end) };
114
+ }
115
+ /** The tactic a place of a line is in, as Lean would split the line (above): its first character
116
+ * and the one past its last, focusing dots left out; null where the line holds no code. A place
117
+ * past the code's end (the caret after it, a comment) is in the line's last tactic. */
118
+ export function tacticSpan(line, ch) {
119
+ const { start, end, depth, seps } = readLine(line);
120
+ if (start >= end)
121
+ return null;
122
+ const at = Math.max(start, Math.min(ch, end - 1));
123
+ // the innermost `by` whose block holds the place: no bracket closes below its depth between them
124
+ let blockStart = start;
125
+ let D = depth[start];
126
+ for (const s of seps) {
127
+ if (s.kind !== "by" || s.at + s.len > at)
128
+ continue;
129
+ let inside = true;
130
+ for (let j = s.at; j < at; j++)
131
+ if (depth[j + 1] < depth[s.at])
132
+ inside = false;
133
+ if (inside && s.at + s.len >= blockStart) {
134
+ blockStart = s.at + s.len;
135
+ D = depth[s.at];
136
+ }
137
+ }
138
+ // its separators at the block's depth, read from its start: `;` and `<;>`; a match arm's `|` where
139
+ // arms are (after `with`, or another arm), not an absolute value's; and a `=>` that ends a case's
140
+ // head (`| succ n ih =>`, `case h =>`, `next =>`), not a `fun x =>`, whose body is a term. A `|`
141
+ // begins the head its `=>` ends, so the head is read from it
142
+ const cuts = [];
143
+ let last = blockStart;
144
+ let armed = false;
145
+ for (const s of seps) {
146
+ if (s.kind === "by" || s.at < blockStart || depth[s.at] !== D)
147
+ continue;
148
+ const before = line.slice(last, s.at).trim();
149
+ if (s.kind === "sep")
150
+ cuts.push({ at: s.at, past: s.at + s.len });
151
+ else if (s.kind === "bar") {
152
+ if (!(armed || before === "" || /(^|\s)with$/.test(before)))
153
+ continue;
154
+ armed = true;
155
+ cuts.push({ at: s.at, past: s.at });
156
+ }
157
+ else if (/^(\||case\b|next\b)/.test(before))
158
+ cuts.push({ at: s.at, past: s.at + s.len });
159
+ else
160
+ continue;
161
+ last = cuts[cuts.length - 1].past;
162
+ }
163
+ let from = blockStart;
164
+ let to = end;
165
+ for (const c of cuts) {
166
+ if (c.at < at && c.past <= at)
167
+ from = Math.max(from, c.past);
168
+ else if (c.at >= at) {
169
+ to = Math.min(to, c.at);
170
+ break;
171
+ }
172
+ }
173
+ // a bracket that closes the block ends it
174
+ for (let j = at; j < to; j++)
175
+ if (CLOSE.includes(line[j]) && depth[j] <= D && depth[j + 1] < D) {
176
+ to = j;
177
+ break;
178
+ }
179
+ // spaces, and the focusing dots at its head (`· simp`), are not the tactic
180
+ while (from < to && /[\s·.]/.test(line[from]) && !(line[from] === "." && /[\p{L}_]/u.test(line[from + 1] ?? "")))
181
+ from++;
182
+ while (to > from && /\s/.test(line[to - 1]))
183
+ to--;
184
+ if (from >= to)
185
+ return { from: Math.min(Math.max(start, at), end), to: Math.min(Math.max(start, at), end) };
186
+ return { from, to };
187
+ }
188
+ /** Whether the tactic `from`–`to` of a line holds a `by` of its own: a block nested in it
189
+ * (`have h : P := by simp`, `exact foo (by simp)`, a `by` that ends the line). */
190
+ export function holdsBy(line, from, to) {
191
+ return readLine(line).seps.some((s) => s.kind === "by" && s.at >= from && s.at < to);
192
+ }
193
+ /** Where the state after a tactic that holds a block of its own is (holdsBy): the start of the next
194
+ * line of code of the same proof after line `k` — the first whose code starts no further right than
195
+ * the tactic (`col`): a line further right is the nested block, or the tactic's term going on. Null
196
+ * past the text's end. Whether the proof goes on there is Lean's to say (no tactic state there: it
197
+ * does not). */
198
+ export function afterLine(text, k, col) {
199
+ const has = codeLines(text);
200
+ const lines = text.split("\n");
201
+ for (let j = k + 1; j < lines.length; j++) {
202
+ if (!has[j])
203
+ continue;
204
+ const ch = /^\s*/.exec(lines[j])[0].length;
205
+ if (ch <= col)
206
+ return { line: j, ch };
207
+ }
208
+ return null;
209
+ }
210
+ /** Whether each line of `text` holds code: something outside comments and docstrings, which spread
211
+ * over lines. */
212
+ export function codeLines(text) {
213
+ const lines = text.split("\n");
214
+ const out = lines.map(() => false);
215
+ let inComment = 0;
216
+ lines.forEach((l, k) => {
217
+ let i = 0;
218
+ while (i < l.length) {
219
+ if (inComment) {
220
+ if (l.startsWith("-/", i)) {
221
+ inComment--;
222
+ i += 2;
223
+ }
224
+ else if (l.startsWith("/-", i)) {
225
+ inComment++;
226
+ i += 2;
227
+ }
228
+ else
229
+ i++;
230
+ continue;
231
+ }
232
+ if (l.startsWith("/-", i)) {
233
+ inComment++;
234
+ i += 2;
235
+ continue;
236
+ }
237
+ if (l.startsWith("--", i))
238
+ break;
239
+ if (l[i] === '"') {
240
+ out[k] = true;
241
+ let j = i + 1;
242
+ while (j < l.length && l[j] !== '"')
243
+ j += l[j] === "\\" ? 2 : 1;
244
+ i = j + 1;
245
+ continue;
246
+ }
247
+ if (!/\s/.test(l[i]))
248
+ out[k] = true;
249
+ i++;
250
+ }
251
+ });
252
+ return out;
253
+ }
254
+ /** The next line of code after line `k` of `text` (`dir` 1), or before it (-1), and where its code
255
+ * starts: what ↑ and ↓ step to in the InfoView; null past the text's ends. */
256
+ export function stepLine(text, k, dir) {
257
+ const has = codeLines(text);
258
+ const lines = text.split("\n");
259
+ for (let j = k + dir; j >= 0 && j < lines.length; j += dir)
260
+ if (has[j])
261
+ return { line: j, ch: /^\s*/.exec(lines[j])[0].length };
262
+ return null;
263
+ }
264
+ /** One goal as Lean writes it in its plain answer (`$/lean/plainGoal`, `plainTermGoal`): an optional
265
+ * `case` line, hypotheses `a b : T` (or `x : T := v`), then `⊢ T` (`| T` in `conv`); what does not
266
+ * fit on a line goes on, indented, on the next. */
267
+ export function parsePlainGoal(s) {
268
+ const entries = [];
269
+ for (const l of s.split("\n")) {
270
+ if (entries.length && (/^\s/.test(l) || l === ""))
271
+ entries[entries.length - 1] += `\n${l}`;
272
+ else
273
+ entries.push(l);
274
+ }
275
+ const g = { hyps: [], type: "" };
276
+ for (const e of entries) {
277
+ if (!g.case && !g.hyps.length && e.startsWith("case "))
278
+ g.case = e.slice(5).trim();
279
+ else if (e.startsWith("⊢") || e.startsWith("| ")) {
280
+ const p = e.startsWith("⊢") ? (e.startsWith("⊢ ") ? "⊢ " : "⊢") : "| ";
281
+ g.prefix = p === "⊢" ? "⊢ " : p;
282
+ g.type = e.slice(p.length).replace(/^\n\s*/, "");
283
+ }
284
+ else {
285
+ const m = / :(?= |\n|$)/.exec(e);
286
+ if (!m)
287
+ continue;
288
+ const names = e.slice(0, m.index).split(/\s+/).filter(Boolean);
289
+ let type = e.slice(m.index + 2).replace(/^ |^\n\s*/, "");
290
+ let val;
291
+ // a `let`'s value, after a `:=` outside brackets
292
+ let depth = 0;
293
+ for (let i = 0; i < type.length; i++) {
294
+ const c = type[i];
295
+ if (OPEN.includes(c))
296
+ depth++;
297
+ else if (CLOSE.includes(c))
298
+ depth--;
299
+ else if (depth === 0 && type.startsWith(" := ", i)) {
300
+ val = type.slice(i + 4);
301
+ type = type.slice(0, i);
302
+ break;
303
+ }
304
+ }
305
+ g.hyps.push({ names, type, ...(val !== undefined ? { val } : {}) });
306
+ }
307
+ }
308
+ return g;
309
+ }
@@ -0,0 +1,18 @@
1
+ // Names Lean's macro hygiene makes. A macro that writes a declaration under a name of its own, not one
2
+ // the reader wrote — Mathlib's `irreducible_def X` writes the value as `definition` and the opaque
3
+ // constant holding it as `wrapped` — has Lean add macro scopes to it, so that it clashes with nothing:
4
+ // `Fixture.definition._@.Fixture.Tagged._hyg.3` (with `._hygCtx` before `._hyg` on newer toolchains).
5
+ // The extractor folds such constants into the declaration the command writes (ViewNode.also). The
6
+ // page says them by what the macro wrote (`definition`, `wrapped`), and never asks Lean about one:
7
+ // what it names cannot be written in Lean source, so no `#check` or `#print` reaches it
8
+ // (server/hover.ts, `isDeclName`, refuses it).
9
+ /** Whether a name carries macro scopes: one Lean's hygiene made. */
10
+ export function hygienic(name) {
11
+ return name.includes("._@.");
12
+ }
13
+ /** A name without its macro scopes: what the macro wrote (`Fixture.definition`), as Lean's
14
+ * `Name.eraseMacroScopes` reads it; any other name as it is. */
15
+ export function withoutMacroScopes(name) {
16
+ const k = name.indexOf("._@.");
17
+ return k < 0 ? name : name.slice(0, k);
18
+ }
@@ -35,10 +35,11 @@
35
35
  // declaration wherever the board holds it — a reader's visitor counts — under every clustering,
36
36
  // and a board that holds the declaration shows a note of the project attached to it (the derived
37
37
  // clause of items). A board of a past build reads the declaration by its name in that build. Where
38
- // the board's graph does not have the declaration (gone, with no rename carrying the note), its
39
- // places stand instead, as any note's do (decision 18); where the graph has it but the board does
40
- // not, a note of the project shows only where it is linked or added, on the ring, and a view note
41
- // where its place puts it.
38
+ // the board's graph does not have the declaration (gone, with no rename carrying the note), the note
39
+ // is on the ring, still attached, toward the cluster its place had it in (the owner's decision of
40
+ // 2026-10-30), shown on the boards its places show it on (decision 18), and at the declaration
41
+ // again should it come back; where the graph has it but the board does not, a note of the project
42
+ // shows only where it is linked or added, on the ring, and a view note where its place puts it.
42
43
  //
43
44
  // A key is never matched across clusterings: a namespace and a folder may share a key.
44
45
  import { itemIn } from "./items.js";
@@ -271,18 +272,23 @@ export function itemsShownOn(notes, view, mode, nodes, full, links, nowName) {
271
272
  }
272
273
  /** Where project note `n` is on board `b`, which shows it (itemWhy): at the declaration it is
273
274
  * attached to, where the board holds it (a visitor counts); attached to one the board's graph has
274
- * but the board does not, on the ring, toward what it carries a file linked to on this board; else,
275
- * attached to none or its declaration gone, in its cluster under the board's clustering where the
276
- * board draws it; else on the ring — at the angle where it was let go, else toward what it carries
277
- * a file linked to on this board (`linked`, linkedOn), else about its cluster under the other
278
- * clustering where that holds a declaration of the board (decision 16), else in the order notes were
279
- * written. */
275
+ * but the board does not, on the ring, toward what it carries a file linked to on this board;
276
+ * attached to one the graph does not have (gone), on the ring, toward the cluster its places had it
277
+ * in (placedAbout), else toward what it carries a file linked to; else, attached to none, in its
278
+ * cluster under the board's clustering where the board draws it; else on the ring — at the angle
279
+ * where it was let go, else toward what it carries a file linked to on this board (`linked`,
280
+ * linkedOn), else about its cluster under the other clustering where that holds a declaration of
281
+ * the board (decision 16), else in the order notes were written. */
280
282
  export function itemSpot(n, b, exists, linked = []) {
281
283
  const at = declOf(n, b, exists);
282
284
  if (at && typeof at === "object")
283
285
  return { at: "decl", j: at.j, name: at.name, d: [n.decl.at[0], n.decl.at[1]] };
284
286
  if (at === "off")
285
287
  return { at: "ring", angle: null, about: linked.length ? { links: [...linked] } : null };
288
+ // its declaration gone, no rename carrying it (the owner's decision of 2026-10-30): on the ring,
289
+ // still attached, where the declaration was rather than at a spot that now holds other things
290
+ if (at === "gone")
291
+ return { at: "ring", angle: null, about: placedAbout(n.places, b, exists) ?? (linked.length ? { links: [...linked] } : null), gone: n.decl.name };
286
292
  const m = b.mode;
287
293
  const place = n.places[m];
288
294
  const h = holderOf(place, m, exists);
@@ -307,6 +313,22 @@ export function itemSpot(n, b, exists, linked = []) {
307
313
  const about = linked.length ? { links: [...linked] } : o && b.on[otherMode(m)].has(o.key) ? { mode: otherMode(m), key: o.key } : null;
308
314
  return { at: "ring", angle: place && "ring" in place ? place.ring : null, about };
309
315
  }
316
+ /** What a note on the ring whose declaration is gone is about (the owner's decision of 2026-10-30):
317
+ * the cluster its place puts it in — the innermost of its keys that is still a cluster and holds a
318
+ * declaration of board `b` —, under the board's clustering, else under the other; null where none
319
+ * does. A note attached to a declaration has its places beside it (declPlace), so this is where the
320
+ * declaration was. */
321
+ export function placedAbout(places, b, exists) {
322
+ for (const m of [b.mode, otherMode(b.mode)]) {
323
+ const p = places[m];
324
+ if (!p || !("in" in p))
325
+ continue;
326
+ const key = p.in.map((e) => e[0]).find((k) => exists(m, k) && b.on[m].has(k));
327
+ if (key)
328
+ return { mode: m, key };
329
+ }
330
+ return null;
331
+ }
310
332
  /** The declarations of board `b` a note on the ring is about, in the board's numbering: those of
311
333
  * its cluster, or those its files are linked to — a declaration, or what a namespace or a folder
312
334
  * holds on the board. */
@@ -330,21 +352,25 @@ export function aboutMembers(b, about) {
330
352
  return [...out].sort((x, y) => x - y);
331
353
  }
332
354
  /** Where view note `n` is on its board `b`: at the declaration it is attached to, where the board
333
- * holds it (a visitor counts), under every clustering; else under its own clustering as it always
334
- * was, by the keys of the layout drawn (`index`); under the other, on the ring about the innermost
335
- * cluster of its place that holds a declaration of the board. */
336
- export function viewSpot(n, b, index) {
337
- const at = declOf(n, b, NO_GRAPH);
355
+ * holds it (a visitor counts), under every clustering; attached to one the board's graph does not
356
+ * have (`exists`; unknown, it is taken to be there), on the ring about the innermost cluster of its
357
+ * place that holds a declaration of the board (the owner's decision of 2026-10-30); else under its
358
+ * own clustering as it always was, by the keys of the layout drawn (`index`); under the other, on
359
+ * the ring about that cluster. */
360
+ export function viewSpot(n, b, index, exists = NO_GRAPH) {
361
+ const at = declOf(n, b, exists);
338
362
  if (at && typeof at === "object")
339
363
  return { at: "decl", j: at.j, name: at.name, d: [n.decl.at[0], n.decl.at[1]] };
364
+ const key = n.place.in.map((e) => e[0]).find((k) => b.on[n.place.mode].has(k));
365
+ const about = key ? { mode: n.place.mode, key } : null;
366
+ if (at === "gone")
367
+ return { at: "ring", angle: null, about, gone: n.decl.name };
340
368
  const r = resolvePlace(n.place, b.mode, index);
341
369
  if (r)
342
370
  return r.c >= 0 ? { at: "offset", c: r.c, d: [r.dx, r.dy] } : { at: "world", x: r.dx, y: r.dy };
343
- const key = n.place.in.map((e) => e[0]).find((k) => b.on[n.place.mode].has(k));
344
- return { at: "ring", angle: null, about: key ? { mode: n.place.mode, key } : null };
371
+ return { at: "ring", angle: null, about };
345
372
  }
346
- /** what a view note's attachment reads where the graph is not asked: off the board or gone, its place
347
- * stands all the same */
373
+ /** what a view note's attachment reads where the graph is not asked: off the board, its place stands */
348
374
  const NO_GRAPH = () => true;
349
375
  /** The place under a layout's clustering of a note attached to declaration `i` of layout `L` (its
350
376
  * numbering), as the layout has it: the declaration's own circle and every one around it, each with