visualproof 0.0.0-stage → 0.2.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/LICENSE +202 -0
- package/README.md +99 -2
- package/dist/assets/fonts/JuliaMono-Regular.ttf +0 -0
- package/dist/assets/fonts/JuliaMono-RegularItalic.ttf +0 -0
- package/dist/assets/fonts/JuliaMono-SemiBold.ttf +0 -0
- package/dist/assets/fonts/LICENSE-JuliaMono.txt +93 -0
- package/dist/assets/latex/visualproof.sty +308 -0
- package/dist/assets/webfonts/LICENSE-Jost.txt +93 -0
- package/dist/assets/webfonts/LICENSE-SourceSans3.txt +93 -0
- package/dist/assets/webfonts/LICENSE-SourceSerif4.txt +93 -0
- package/dist/assets/webfonts/jost-latin-ext-wght-normal.woff2 +0 -0
- package/dist/assets/webfonts/jost-latin-wght-normal.woff2 +0 -0
- package/dist/assets/webfonts/source-sans-3-greek-wght-italic.woff2 +0 -0
- package/dist/assets/webfonts/source-sans-3-greek-wght-normal.woff2 +0 -0
- package/dist/assets/webfonts/source-sans-3-latin-ext-wght-italic.woff2 +0 -0
- package/dist/assets/webfonts/source-sans-3-latin-ext-wght-normal.woff2 +0 -0
- package/dist/assets/webfonts/source-sans-3-latin-wght-italic.woff2 +0 -0
- package/dist/assets/webfonts/source-sans-3-latin-wght-normal.woff2 +0 -0
- package/dist/assets/webfonts/source-serif-4-greek-wght-italic.woff2 +0 -0
- package/dist/assets/webfonts/source-serif-4-greek-wght-normal.woff2 +0 -0
- package/dist/assets/webfonts/source-serif-4-latin-ext-wght-italic.woff2 +0 -0
- package/dist/assets/webfonts/source-serif-4-latin-ext-wght-normal.woff2 +0 -0
- package/dist/assets/webfonts/source-serif-4-latin-wght-italic.woff2 +0 -0
- package/dist/assets/webfonts/source-serif-4-latin-wght-normal.woff2 +0 -0
- package/dist/extractor/Extract.lean +1180 -0
- package/dist/extractor/Usage.lean +900 -0
- package/dist/mcp/visualproof-mcp.mjs +476 -0
- package/dist/server/access.js +95 -0
- package/dist/server/agent.js +3270 -0
- package/dist/server/agentdocs.js +35 -0
- package/dist/server/agentlibrary.js +202 -0
- package/dist/server/agentnotes.js +701 -0
- package/dist/server/agentviews.js +703 -0
- package/dist/server/askfollow.js +286 -0
- package/dist/server/boardspots.js +159 -0
- package/dist/server/dirs.js +175 -0
- package/dist/server/doctor.js +186 -0
- package/dist/server/events.js +198 -0
- package/dist/server/export.js +420 -0
- package/dist/server/extract.js +204 -0
- package/dist/server/fetchurl.js +321 -0
- package/dist/server/figures.js +158 -0
- package/dist/server/history.js +780 -0
- package/dist/server/historyapi.js +304 -0
- package/dist/server/hover.js +595 -0
- package/dist/server/identity.js +114 -0
- package/dist/server/invites.js +241 -0
- package/dist/server/layoutthread.js +51 -0
- package/dist/server/library.js +600 -0
- package/dist/server/libraryroute.js +211 -0
- package/dist/server/live.js +1101 -0
- package/dist/server/lostfound.js +199 -0
- package/dist/server/main.js +1406 -0
- package/dist/server/mcptools.js +496 -0
- package/dist/server/pastdoc.js +73 -0
- package/dist/server/pipeline.js +159 -0
- package/dist/server/poppler.js +251 -0
- package/dist/server/presence.js +252 -0
- package/dist/server/project.js +222 -0
- package/dist/server/prompt.js +53 -0
- package/dist/server/readonly.js +152 -0
- package/dist/server/readonlygate.js +123 -0
- package/dist/server/renames.js +268 -0
- package/dist/server/review.js +334 -0
- package/dist/server/reviewapi.js +188 -0
- package/dist/server/snapshot.js +50 -0
- package/dist/server/sourcestore.js +473 -0
- package/dist/server/status.js +360 -0
- package/dist/server/talk.js +476 -0
- package/dist/server/tokens.js +221 -0
- package/dist/server/usage.js +501 -0
- package/dist/server/versions.js +82 -0
- package/dist/server/view.js +164 -0
- package/dist/server/views.js +1167 -0
- package/dist/shared/askfollow.js +46 -0
- package/dist/shared/board.js +332 -0
- package/dist/shared/build.js +2 -0
- package/dist/shared/collab.js +241 -0
- package/dist/shared/comment.js +285 -0
- package/dist/shared/context.js +157 -0
- package/dist/shared/doc/authors.js +98 -0
- package/dist/shared/doc/build.js +358 -0
- package/dist/shared/doc/latex.js +455 -0
- package/dist/shared/doc/markdown.js +159 -0
- package/dist/shared/doc/model.js +37 -0
- package/dist/shared/doc/order.js +124 -0
- package/dist/shared/doc/outline.js +45 -0
- package/dist/shared/doc/proof.js +272 -0
- package/dist/shared/doc/sections.js +93 -0
- package/dist/shared/doc/settings.js +75 -0
- package/dist/shared/edgecodec.js +102 -0
- package/dist/shared/editor.js +64 -0
- package/dist/shared/excerpt.js +87 -0
- package/dist/shared/graph.js +16 -0
- package/dist/shared/items.js +92 -0
- package/dist/shared/keys.js +203 -0
- package/dist/shared/layout.js +926 -0
- package/dist/shared/lexer.js +130 -0
- package/dist/shared/library.js +711 -0
- package/dist/shared/lostfound.js +150 -0
- package/dist/shared/moves.js +244 -0
- package/dist/shared/notecard.js +295 -0
- package/dist/shared/noteplace.js +505 -0
- package/dist/shared/palette.js +46 -0
- package/dist/shared/pastgraph.js +103 -0
- package/dist/shared/places.js +80 -0
- package/dist/shared/projectnotes.js +244 -0
- package/dist/shared/query.js +818 -0
- package/dist/shared/review.js +642 -0
- package/dist/shared/reviewqueue.js +333 -0
- package/dist/shared/ring.js +366 -0
- package/dist/shared/scope.js +255 -0
- package/dist/shared/scopeedit.js +81 -0
- package/dist/shared/search.js +191 -0
- package/dist/shared/separate.js +178 -0
- package/dist/shared/sharesnap.js +281 -0
- package/dist/shared/sticky.js +501 -0
- package/dist/shared/timeline.js +73 -0
- package/dist/shared/titles.js +300 -0
- package/dist/shared/viewgraph.js +157 -0
- package/dist/shared/views.js +859 -0
- package/dist/web/bundle/app.js +52671 -0
- package/dist/web/bundle/edges.js +407 -0
- package/dist/web/bundle/layout.js +1010 -0
- package/dist/web/bundle/pdfworker.js +48322 -0
- package/dist/web/index.html +257 -0
- package/dist/web/src/motion.js +430 -0
- package/dist/web/src/past.js +224 -0
- package/dist/web/src/scene.js +804 -0
- package/dist/web/style.css +2548 -0
- package/docs/agent-api/README.md +91 -0
- package/docs/agent-api/advice.md +108 -0
- package/docs/agent-api/export.md +120 -0
- package/docs/agent-api/following.md +140 -0
- package/docs/agent-api/history.md +142 -0
- package/docs/agent-api/library.md +65 -0
- package/docs/agent-api/mcp.md +104 -0
- package/docs/agent-api/notes.md +93 -0
- package/docs/agent-api/reading.md +166 -0
- package/docs/agent-api/requests.md +94 -0
- package/docs/agent-api/talking.md +100 -0
- package/docs/agent-api/tcb.md +135 -0
- package/docs/agent-api/views.md +125 -0
- package/docs/agent-api/words.md +56 -0
- package/package.json +39 -4
- package/test/toolchains.json +5 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// A small Lean 4 tokenizer: comments, docstrings, strings, keywords, numbers, attributes, a few
|
|
2
|
+
// operators, `sorry`. Enough to read by; it is not the elaborator's view of the text. The page
|
|
3
|
+
// renders its tokens as HTML (web/src/highlight.ts), the exported document as LaTeX
|
|
4
|
+
// (shared/doc/latex.ts), so that the two highlight alike.
|
|
5
|
+
export const KEYWORDS = new Set(("theorem lemma def abbrev instance structure class inductive axiom opaque example where " +
|
|
6
|
+
"extends deriving with match fun λ let in have show from by at calc do if then else for " +
|
|
7
|
+
"return namespace section end open variable universe import noncomputable private " +
|
|
8
|
+
"protected partial unsafe mutual termination_by decreasing_by local scoped attribute " +
|
|
9
|
+
"macro syntax notation infix infixl infixr prefix postfix set_option omit include irreducible_def " +
|
|
10
|
+
"macro_rules elab_rules elab declare_syntax_cat " +
|
|
11
|
+
"Type Prop Sort forall exists ∀ ∃ Π Σ").split(/\s+/));
|
|
12
|
+
/** The kind of a word, as a token of its own. */
|
|
13
|
+
export function wordKind(word) {
|
|
14
|
+
return word === "sorry" || word === "admit" ? "sorry" : KEYWORDS.has(word) ? "keyword" : /^[A-Z]/.test(word) ? "type" : "ident";
|
|
15
|
+
}
|
|
16
|
+
/** `src` as tokens, in order; their texts joined are `src`. A name with dots is one token. */
|
|
17
|
+
export function tokenizeLean(src) {
|
|
18
|
+
const out = [];
|
|
19
|
+
let i = 0;
|
|
20
|
+
const n = src.length;
|
|
21
|
+
let text = -1;
|
|
22
|
+
const push = (kind, from, to) => {
|
|
23
|
+
if (text >= 0) {
|
|
24
|
+
out.push({ kind: "text", text: src.slice(text, from), at: text });
|
|
25
|
+
text = -1;
|
|
26
|
+
}
|
|
27
|
+
out.push({ kind, text: src.slice(from, to), at: from });
|
|
28
|
+
};
|
|
29
|
+
while (i < n) {
|
|
30
|
+
const ch = src[i];
|
|
31
|
+
// block comment, nested
|
|
32
|
+
if (ch === "/" && src[i + 1] === "-") {
|
|
33
|
+
let depth = 0;
|
|
34
|
+
let j = i;
|
|
35
|
+
while (j < n) {
|
|
36
|
+
if (src[j] === "/" && src[j + 1] === "-") {
|
|
37
|
+
depth++;
|
|
38
|
+
j += 2;
|
|
39
|
+
}
|
|
40
|
+
else if (src[j] === "-" && src[j + 1] === "/") {
|
|
41
|
+
depth--;
|
|
42
|
+
j += 2;
|
|
43
|
+
if (depth === 0)
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
else
|
|
47
|
+
j++;
|
|
48
|
+
}
|
|
49
|
+
push(src.startsWith("/--", i) || src.startsWith("/-!", i) ? "doc" : "comment", i, j);
|
|
50
|
+
i = j;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (ch === "-" && src[i + 1] === "-") {
|
|
54
|
+
const j = src.indexOf("\n", i);
|
|
55
|
+
const end = j < 0 ? n : j;
|
|
56
|
+
push("comment", i, end);
|
|
57
|
+
i = end;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (ch === '"') {
|
|
61
|
+
let j = i + 1;
|
|
62
|
+
while (j < n && src[j] !== '"')
|
|
63
|
+
j += src[j] === "\\" ? 2 : 1;
|
|
64
|
+
const end = Math.min(n, j + 1);
|
|
65
|
+
push("string", i, end);
|
|
66
|
+
i = end;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (/[0-9]/.test(ch) && !/[\p{L}_]/u.test(src[i - 1] ?? "")) {
|
|
70
|
+
let j = i;
|
|
71
|
+
while (j < n && /[0-9a-fA-Fx_.]/.test(src[j]))
|
|
72
|
+
j++;
|
|
73
|
+
push("number", i, j);
|
|
74
|
+
i = j;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (/[\p{L}_«]/u.test(ch)) {
|
|
78
|
+
let j = i;
|
|
79
|
+
if (ch === "«")
|
|
80
|
+
j = src.indexOf("»", i) + 1 || n;
|
|
81
|
+
while (j < n && /[\p{L}\p{N}_'!?.₀-₉ₐ-ₜ«»]/u.test(src[j])) {
|
|
82
|
+
if (src[j] === "«")
|
|
83
|
+
j = src.indexOf("»", j) + 1 || n;
|
|
84
|
+
else
|
|
85
|
+
j++;
|
|
86
|
+
}
|
|
87
|
+
// a trailing dot belongs to the next token
|
|
88
|
+
while (j > i + 1 && src[j - 1] === ".")
|
|
89
|
+
j--;
|
|
90
|
+
push(wordKind(src.slice(i, j)), i, j);
|
|
91
|
+
i = j;
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (ch === "@" && src[i + 1] === "[") {
|
|
95
|
+
const j = src.indexOf("]", i);
|
|
96
|
+
const end = j < 0 ? n : j + 1;
|
|
97
|
+
push("attr", i, end);
|
|
98
|
+
i = end;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if ("∀∃λ→↔∧∨¬≤≥≠∘×".includes(ch)) {
|
|
102
|
+
push("op", i, i + 1);
|
|
103
|
+
i++;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (text < 0)
|
|
107
|
+
text = i;
|
|
108
|
+
i++;
|
|
109
|
+
}
|
|
110
|
+
if (text >= 0)
|
|
111
|
+
out.push({ kind: "text", text: src.slice(text), at: text });
|
|
112
|
+
return out;
|
|
113
|
+
}
|
|
114
|
+
/** Tokens split into lines: a token across a line break (a block comment, a docstring, a string)
|
|
115
|
+
* becomes one piece per line, of the same kind. No line holds a newline; empty pieces are dropped. */
|
|
116
|
+
export function tokenLines(tokens) {
|
|
117
|
+
const lines = [[]];
|
|
118
|
+
for (const t of tokens) {
|
|
119
|
+
const parts = t.text.split("\n");
|
|
120
|
+
let at = t.at;
|
|
121
|
+
parts.forEach((p, k) => {
|
|
122
|
+
if (k)
|
|
123
|
+
lines.push([]);
|
|
124
|
+
if (p)
|
|
125
|
+
lines[lines.length - 1].push({ kind: t.kind, text: p, at });
|
|
126
|
+
at += p.length + 1;
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
return lines;
|
|
130
|
+
}
|