@okhay-p/mivra 0.1.3 → 0.1.4
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/dist/{chunk-3RMHLZ2Z.js → chunk-KUKQU7EQ.js} +24 -5
- package/dist/{chunk-3RMHLZ2Z.js.map → chunk-KUKQU7EQ.js.map} +2 -2
- package/dist/{chunk-EICBRY5M.js → chunk-ODFBAPPH.js} +113 -5
- package/dist/chunk-ODFBAPPH.js.map +7 -0
- package/dist/{chunk-FBDML53R.js → chunk-YACRW47X.js} +447 -177
- package/dist/chunk-YACRW47X.js.map +7 -0
- package/dist/cli.js +4 -4
- package/dist/cli.js.map +2 -2
- package/dist/{client-VU3KWV3U.js → client-5YDLS4KV.js} +2 -2
- package/dist/extract-child.js +1 -1
- package/dist/{start-3J3JSJEX.js → start-76LKE3DL.js} +3524 -517
- package/dist/start-76LKE3DL.js.map +7 -0
- package/drizzle/0013_next_dormammu.sql +1 -0
- package/drizzle/0014_furry_inertia.sql +1 -0
- package/drizzle/0015_spotty_warstar.sql +1 -0
- package/drizzle/0016_fresh_wiccan.sql +1 -0
- package/drizzle/0017_amusing_james_howlett.sql +28 -0
- package/drizzle/0018_happy_hairball.sql +43 -0
- package/drizzle/meta/0013_snapshot.json +1749 -0
- package/drizzle/meta/0014_snapshot.json +1756 -0
- package/drizzle/meta/0015_snapshot.json +1763 -0
- package/drizzle/meta/0016_snapshot.json +1770 -0
- package/drizzle/meta/0017_snapshot.json +1956 -0
- package/drizzle/meta/0018_snapshot.json +2280 -0
- package/drizzle/meta/_journal.json +42 -0
- package/package.json +2 -1
- package/web/assets/index-C_DsRKCc.css +1 -0
- package/web/assets/index-DbKDW1xS.js +413 -0
- package/web/assets/notes-graph.worker-DaVQvftJ.js +1 -0
- package/web/assets/render.worker-BAfybD27.js +416 -0
- package/web/index.html +2 -2
- package/dist/chunk-EICBRY5M.js.map +0 -7
- package/dist/chunk-FBDML53R.js.map +0 -7
- package/dist/start-3J3JSJEX.js.map +0 -7
- package/web/assets/index-BUYWW1Mc.js +0 -406
- package/web/assets/index-Cmq-m9fI.css +0 -1
- package/web/assets/render.worker-BEpv9w1x.js +0 -413
- /package/dist/{client-VU3KWV3U.js.map → client-5YDLS4KV.js.map} +0 -0
|
@@ -46,6 +46,18 @@ function gradePlacementQuestion(spec, answer) {
|
|
|
46
46
|
} else result = "unsure" in answer ? "unsure" : "skipped";
|
|
47
47
|
return { result, correctOptionIndex: spec.correctOptionIndex, explanation: spec.explanation };
|
|
48
48
|
}
|
|
49
|
+
var MAX_INTERVIEW_CONTEXT_CHARS = 2e3;
|
|
50
|
+
var InterviewContextSpec = z.object({
|
|
51
|
+
question: z.string().trim().min(1).max(300).describe(`The question, e.g. "Anything else you'd like us to know about what you already understand or what you want to explore?"`)
|
|
52
|
+
}).strict();
|
|
53
|
+
var InterviewContextAnswer = z.union([
|
|
54
|
+
z.object({ text: z.string().trim().max(MAX_INTERVIEW_CONTEXT_CHARS) }).strict(),
|
|
55
|
+
z.object({ skipped: z.literal(true) }).strict()
|
|
56
|
+
]);
|
|
57
|
+
var InterviewContextGrade = z.object({ result: z.enum(["answered", "skipped"]) }).strict();
|
|
58
|
+
var gradeInterviewContext = (answer) => ({
|
|
59
|
+
result: "text" in answer && answer.text.length > 0 ? "answered" : "skipped"
|
|
60
|
+
});
|
|
49
61
|
var KnownSource = z.enum(["memory", "test", "guess"]);
|
|
50
62
|
var SyllabusTopicInput = z.object({
|
|
51
63
|
title: z.string().trim().min(1).max(120),
|
|
@@ -54,7 +66,44 @@ var SyllabusTopicInput = z.object({
|
|
|
54
66
|
requestedByLearner: z.boolean().describe("True if the learner explicitly asked for this topic. Such topics are never removed automatically."),
|
|
55
67
|
concepts: z.array(ConceptName).min(1).max(8).describe("Concept names this topic teaches; reuse names from the learner's record and the placement questions.")
|
|
56
68
|
}).strict();
|
|
69
|
+
var courseIcons = [
|
|
70
|
+
"sigma",
|
|
71
|
+
"calculator",
|
|
72
|
+
"code",
|
|
73
|
+
"terminal",
|
|
74
|
+
"cpu",
|
|
75
|
+
"database",
|
|
76
|
+
"network",
|
|
77
|
+
"shield",
|
|
78
|
+
"flask-conical",
|
|
79
|
+
"atom",
|
|
80
|
+
"dna",
|
|
81
|
+
"leaf",
|
|
82
|
+
"telescope",
|
|
83
|
+
"globe",
|
|
84
|
+
"landmark",
|
|
85
|
+
"book-open",
|
|
86
|
+
"pen-tool",
|
|
87
|
+
"languages",
|
|
88
|
+
"music",
|
|
89
|
+
"palette",
|
|
90
|
+
"camera",
|
|
91
|
+
"brain",
|
|
92
|
+
"users",
|
|
93
|
+
"chart-line",
|
|
94
|
+
"briefcase",
|
|
95
|
+
"scale",
|
|
96
|
+
"stethoscope",
|
|
97
|
+
"heart-pulse",
|
|
98
|
+
"wrench",
|
|
99
|
+
"dumbbell"
|
|
100
|
+
];
|
|
101
|
+
var CourseIcon = z.enum(courseIcons);
|
|
102
|
+
var COURSE_TITLE_MAX = 60;
|
|
57
103
|
var SyllabusInput = z.object({
|
|
104
|
+
// Bad values parse as missing rather than failing the call: a syllabus is worth more than its label (#58).
|
|
105
|
+
title: z.string().trim().min(1).max(COURSE_TITLE_MAX).optional().catch(void 0).describe('A short name for the course, 2-5 words, shown in the sidebar, e.g. "Discrete Math: Induction". Name what the syllabus covers, not the request.'),
|
|
106
|
+
icon: CourseIcon.optional().catch(void 0).describe("The subject icon that best fits the course: sigma = maths, calculator = arithmetic or accounting, code/terminal = programming, cpu = hardware, flask-conical = chemistry, atom = physics, dna = biology, leaf = ecology, telescope = astronomy, globe = geography, landmark = history, book-open = literature, pen-tool = writing, languages = languages, palette = art, brain = psychology, users = sociology, chart-line = economics or statistics, briefcase = business, scale = law, stethoscope/heart-pulse = medicine, wrench = engineering, dumbbell = sport."),
|
|
58
107
|
topics: z.array(SyllabusTopicInput).min(1).max(20).describe("The ordered topics, first to learn first. Each topic gets one lesson."),
|
|
59
108
|
known: z.array(
|
|
60
109
|
z.object({
|
|
@@ -97,7 +146,7 @@ var CourseView = z.object({
|
|
|
97
146
|
|
|
98
147
|
// ../protocol/src/lesson.ts
|
|
99
148
|
import { z as z2 } from "zod";
|
|
100
|
-
var LessonSectionKind = z2.enum(["prose", "algorithm_trace", "graph", "multiple_choice", "set_diagram", "table", "worked_steps"]);
|
|
149
|
+
var LessonSectionKind = z2.enum(["prose", "algorithm_trace", "code_walkthrough", "graph", "multiple_choice", "set_diagram", "table", "worked_steps"]);
|
|
101
150
|
var MAX_LESSON_SECTIONS = 10;
|
|
102
151
|
var LessonOutlineInput = z2.object({
|
|
103
152
|
title: z2.string().trim().min(1).max(120),
|
|
@@ -153,6 +202,8 @@ var LessonView = z2.object({
|
|
|
153
202
|
/** Whether the learner can finish it now: fully written and every check answered. */
|
|
154
203
|
canFinish: z2.boolean(),
|
|
155
204
|
error: z2.string().nullable(),
|
|
205
|
+
/** A failure the learner fixes elsewhere: "lesson-model" means the lesson model chosen in Settings can't be used. */
|
|
206
|
+
errorAction: z2.enum(["lesson-model"]).nullable(),
|
|
156
207
|
createdAt: z2.string().datetime(),
|
|
157
208
|
finishedAt: z2.string().datetime().nullable()
|
|
158
209
|
}).strict();
|
|
@@ -223,10 +274,11 @@ var AdaptSyllabusInput = z2.object({
|
|
|
223
274
|
|
|
224
275
|
// ../protocol/src/memory.ts
|
|
225
276
|
import { z as z3 } from "zod";
|
|
226
|
-
var MemoryKind = z3.enum(["goal", "preference", "misconception"]);
|
|
277
|
+
var MemoryKind = z3.enum(["goal", "preference", "misconception", "known"]);
|
|
278
|
+
var RememberKind = z3.enum(["goal", "preference", "misconception"]);
|
|
227
279
|
var MemoryText = z3.string().trim().min(1).max(300);
|
|
228
280
|
var RememberInput = z3.object({
|
|
229
|
-
kind:
|
|
281
|
+
kind: RememberKind.describe("goal = what they want to learn or do; preference = how they like to learn; misconception = something they believe that is wrong."),
|
|
230
282
|
text: MemoryText.describe("One short sentence about the learner. Never include the answer to a check they haven't answered."),
|
|
231
283
|
concept: z3.string().trim().min(1).max(80).optional().describe("Required for a misconception: the concept it is about. Use the exact name from the check or from their record, so it can be linked to their answers."),
|
|
232
284
|
replaces: z3.string().min(1).optional().describe("The id of a known memory this one corrects or updates.")
|
|
@@ -235,7 +287,7 @@ var RememberInput = z3.object({
|
|
|
235
287
|
ctx.addIssue({ code: "custom", path: ["concept"], message: "A misconception needs a concept" });
|
|
236
288
|
}
|
|
237
289
|
});
|
|
238
|
-
var MemoryBasis = z3.enum(["wrong_answer", "chat"]);
|
|
290
|
+
var MemoryBasis = z3.enum(["wrong_answer", "chat", "import"]);
|
|
239
291
|
var MemoryView = z3.object({
|
|
240
292
|
id: z3.string(),
|
|
241
293
|
kind: MemoryKind,
|
|
@@ -243,10 +295,13 @@ var MemoryView = z3.object({
|
|
|
243
295
|
text: z3.string().nullable(),
|
|
244
296
|
concept: z3.string().nullable(),
|
|
245
297
|
basis: MemoryBasis.nullable(),
|
|
298
|
+
/** For basis `import`, the note it was drawn from. Null otherwise, and while held. */
|
|
299
|
+
source: z3.object({ noteId: z3.string(), importId: z3.string(), importName: z3.string(), path: z3.string(), title: z3.string() }).strict().nullable(),
|
|
246
300
|
createdAt: z3.string().datetime(),
|
|
247
301
|
editedAt: z3.string().datetime().nullable()
|
|
248
302
|
}).strict();
|
|
249
303
|
var MemoryEdit = z3.object({ text: MemoryText }).strict();
|
|
304
|
+
var MemoryBulkDelete = z3.object({ basis: z3.literal("import") }).strict();
|
|
250
305
|
|
|
251
306
|
// ../protocol/src/document.ts
|
|
252
307
|
import { z as z4 } from "zod";
|
|
@@ -264,58 +319,151 @@ var DocumentView = z4.object({
|
|
|
264
319
|
createdAt: z4.string().datetime()
|
|
265
320
|
});
|
|
266
321
|
|
|
267
|
-
// ../protocol/src/
|
|
322
|
+
// ../protocol/src/knowledge.ts
|
|
268
323
|
import { z as z5 } from "zod";
|
|
324
|
+
var NoteRef = z5.string().regex(/^n\d{1,3}$/);
|
|
325
|
+
var ConceptName2 = z5.string().trim().min(1).max(80);
|
|
326
|
+
var MAX_PROPOSED_CONCEPTS = 30;
|
|
327
|
+
var MAX_PROPOSED_EDGES = 40;
|
|
328
|
+
var MAX_PROPOSED_MEMORIES = 30;
|
|
329
|
+
var ConceptEdgeKind = z5.enum(["prerequisite", "related"]);
|
|
330
|
+
var RecordFromNotesInput = z5.object({
|
|
331
|
+
concepts: z5.array(
|
|
332
|
+
z5.object({
|
|
333
|
+
name: ConceptName2.describe("A name from <existing_concepts> or <vault_tags> when one fits. Otherwise a new name, written as it appears in the notes."),
|
|
334
|
+
notes: z5.array(NoteRef).min(1).max(20).describe("The refs of the notes that cover it.")
|
|
335
|
+
}).strict()
|
|
336
|
+
).max(MAX_PROPOSED_CONCEPTS),
|
|
337
|
+
edges: z5.array(
|
|
338
|
+
z5.object({
|
|
339
|
+
from: ConceptName2,
|
|
340
|
+
to: ConceptName2,
|
|
341
|
+
kind: ConceptEdgeKind.describe("prerequisite = from must be understood before to; related = they're closely linked."),
|
|
342
|
+
note: NoteRef.describe("The ref of the note that shows this link.")
|
|
343
|
+
}).strict()
|
|
344
|
+
).max(MAX_PROPOSED_EDGES).describe("Edges between concepts named in this call or in <existing_concepts>."),
|
|
345
|
+
memories: z5.array(
|
|
346
|
+
z5.object({
|
|
347
|
+
kind: z5.enum(["known", "goal", "misconception"]).describe("known = the notes cover this concept; goal = a goal the notes state; misconception = a wrong belief the notes state."),
|
|
348
|
+
text: MemoryText.describe("One short sentence about the learner."),
|
|
349
|
+
concept: ConceptName2.optional().describe("Required for known and misconception: a concept named in this call or in <existing_concepts>."),
|
|
350
|
+
note: NoteRef.describe("The ref of the note it comes from.")
|
|
351
|
+
}).strict()
|
|
352
|
+
).max(MAX_PROPOSED_MEMORIES)
|
|
353
|
+
}).strict();
|
|
354
|
+
var DistillationStatus = z5.enum(["idle", "queued", "running", "cancelled", "failed"]);
|
|
355
|
+
var DistillationView = z5.object({
|
|
356
|
+
status: DistillationStatus,
|
|
357
|
+
pendingNotes: z5.number().int(),
|
|
358
|
+
groups: z5.number().int(),
|
|
359
|
+
groupsDone: z5.number().int(),
|
|
360
|
+
error: z5.string().nullable(),
|
|
361
|
+
/** Concepts and memories drawn from this import's notes so far. */
|
|
362
|
+
concepts: z5.number().int(),
|
|
363
|
+
memories: z5.number().int()
|
|
364
|
+
}).strict();
|
|
365
|
+
var ConceptGraph = z5.object({
|
|
366
|
+
concepts: z5.array(z5.object({ id: z5.string(), name: z5.string(), notes: z5.array(z5.string()) }).strict()),
|
|
367
|
+
edges: z5.array(z5.object({ from: z5.string(), to: z5.string(), kind: ConceptEdgeKind, notes: z5.array(z5.string()) }).strict())
|
|
368
|
+
}).strict();
|
|
369
|
+
|
|
370
|
+
// ../protocol/src/vault.ts
|
|
371
|
+
import { z as z6 } from "zod";
|
|
269
372
|
var MAX_VAULT_FILES = 1e4;
|
|
270
373
|
var MAX_NOTE_CHARS = 1e6;
|
|
271
374
|
var MAX_VAULT_BYTES = 64 * 1024 * 1024;
|
|
272
375
|
var MAX_PATH_CHARS = 512;
|
|
273
|
-
var VaultFile =
|
|
376
|
+
var VaultFile = z6.object({
|
|
274
377
|
/** The file's path inside the vault, with `/` between folders, e.g. `Maths/Recursion.md`. */
|
|
275
|
-
path:
|
|
276
|
-
text:
|
|
277
|
-
}).strict();
|
|
278
|
-
var VaultFiles =
|
|
279
|
-
var VaultName =
|
|
280
|
-
var VaultImportInput =
|
|
281
|
-
var VaultSnapshotInput =
|
|
282
|
-
var VaultImportView =
|
|
283
|
-
id:
|
|
284
|
-
name:
|
|
285
|
-
source:
|
|
286
|
-
noteCount:
|
|
287
|
-
createdAt:
|
|
288
|
-
updatedAt:
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
378
|
+
path: z6.string().min(1).max(MAX_PATH_CHARS),
|
|
379
|
+
text: z6.string().max(MAX_NOTE_CHARS)
|
|
380
|
+
}).strict();
|
|
381
|
+
var VaultFiles = z6.array(VaultFile).max(MAX_VAULT_FILES);
|
|
382
|
+
var VaultName = z6.string().trim().min(1).max(120);
|
|
383
|
+
var VaultImportInput = z6.object({ name: VaultName, files: VaultFiles }).strict();
|
|
384
|
+
var VaultSnapshotInput = z6.object({ files: VaultFiles }).strict();
|
|
385
|
+
var VaultImportView = z6.object({
|
|
386
|
+
id: z6.string(),
|
|
387
|
+
name: z6.string(),
|
|
388
|
+
source: z6.literal("obsidian"),
|
|
389
|
+
noteCount: z6.number().int(),
|
|
390
|
+
createdAt: z6.string().datetime(),
|
|
391
|
+
updatedAt: z6.string().datetime(),
|
|
392
|
+
/** Distilling its notes into concepts and memories, which starts after every import (ADR-014). */
|
|
393
|
+
distillation: DistillationView
|
|
394
|
+
}).strict();
|
|
395
|
+
var SkipReason = z6.enum(["not_markdown", "hidden", "bad_path", "duplicate", "too_long", "symlink", "generated"]);
|
|
396
|
+
var VaultImportResult = z6.object({
|
|
292
397
|
import: VaultImportView,
|
|
293
|
-
added:
|
|
294
|
-
updated:
|
|
295
|
-
removed:
|
|
296
|
-
unchanged:
|
|
297
|
-
skippedCount:
|
|
298
|
-
skipped:
|
|
398
|
+
added: z6.number().int(),
|
|
399
|
+
updated: z6.number().int(),
|
|
400
|
+
removed: z6.number().int(),
|
|
401
|
+
unchanged: z6.number().int(),
|
|
402
|
+
skippedCount: z6.number().int(),
|
|
403
|
+
skipped: z6.array(z6.object({ path: z6.string(), reason: SkipReason }).strict()),
|
|
299
404
|
/** Links or tags left out because a note or the vault had more than the limit. */
|
|
300
|
-
truncated:
|
|
301
|
-
}).strict();
|
|
302
|
-
var NoteView =
|
|
303
|
-
id:
|
|
304
|
-
importId:
|
|
305
|
-
path:
|
|
306
|
-
title:
|
|
307
|
-
aliases:
|
|
308
|
-
tags:
|
|
309
|
-
body:
|
|
310
|
-
updatedAt:
|
|
311
|
-
}).strict();
|
|
312
|
-
var NoteGraph =
|
|
313
|
-
notes:
|
|
314
|
-
links:
|
|
405
|
+
truncated: z6.boolean()
|
|
406
|
+
}).strict();
|
|
407
|
+
var NoteView = z6.object({
|
|
408
|
+
id: z6.string(),
|
|
409
|
+
importId: z6.string(),
|
|
410
|
+
path: z6.string(),
|
|
411
|
+
title: z6.string(),
|
|
412
|
+
aliases: z6.array(z6.string()),
|
|
413
|
+
tags: z6.array(z6.string()),
|
|
414
|
+
body: z6.string(),
|
|
415
|
+
updatedAt: z6.string().datetime()
|
|
416
|
+
}).strict();
|
|
417
|
+
var NoteGraph = z6.object({
|
|
418
|
+
notes: z6.array(z6.object({ id: z6.string(), path: z6.string(), title: z6.string(), tags: z6.array(z6.string()) }).strict()),
|
|
419
|
+
links: z6.array(z6.object({ from: z6.string(), to: z6.string().nullable(), target: z6.string(), kind: z6.enum(["link", "embed"]) }).strict())
|
|
420
|
+
}).strict();
|
|
421
|
+
var WHOLE_GRAPH_NOTES = 500;
|
|
422
|
+
var MAX_GRAPH_VIEW_NOTES = 500;
|
|
423
|
+
var MAX_GRAPH_VIEW_NODES = 1e3;
|
|
424
|
+
var MAX_GRAPH_VIEW_EDGES = 5e3;
|
|
425
|
+
var MAX_GRAPH_FACETS = 200;
|
|
426
|
+
var NoteGraphViewQuery = z6.object({
|
|
427
|
+
/** `auto` draws the whole graph when at most WHOLE_GRAPH_NOTES notes match, and the local graph otherwise. */
|
|
428
|
+
mode: z6.enum(["auto", "local"]).default("auto"),
|
|
429
|
+
/** The note the local graph is drawn around. Defaults to the matching note with the most connections. */
|
|
430
|
+
focus: z6.string().max(64).optional(),
|
|
431
|
+
/** How many hops from the focus the local graph reaches. Sharing a tag or concept is one hop, as a link is. */
|
|
432
|
+
depth: z6.coerce.number().int().min(1).max(3).default(2),
|
|
433
|
+
/** Only notes carrying this tag, or one nested under it (`maths` matches `maths/algebra`). */
|
|
434
|
+
tag: z6.string().max(200).optional(),
|
|
435
|
+
/** Only notes in this folder or below it, without a trailing `/`. */
|
|
436
|
+
folder: z6.string().max(512).optional()
|
|
315
437
|
}).strict();
|
|
438
|
+
var NoteGraphNodeKind = z6.enum(["note", "ghost", "tag", "concept"]);
|
|
439
|
+
var NoteGraphEdgeKind = z6.enum(["link", "tag", "concept", "prerequisite", "related"]);
|
|
440
|
+
var NoteGraphView = z6.object({
|
|
441
|
+
mode: z6.enum(["whole", "local"]),
|
|
442
|
+
focus: z6.string().nullable(),
|
|
443
|
+
depth: z6.number().int(),
|
|
444
|
+
totalNotes: z6.number().int(),
|
|
445
|
+
/** Notes matching the filters, drawn or not. */
|
|
446
|
+
matchingNotes: z6.number().int(),
|
|
447
|
+
/** Whether the limits left matching nodes or edges out of the drawing. */
|
|
448
|
+
truncated: z6.boolean(),
|
|
449
|
+
nodes: z6.array(
|
|
450
|
+
z6.object({
|
|
451
|
+
id: z6.string(),
|
|
452
|
+
kind: NoteGraphNodeKind,
|
|
453
|
+
label: z6.string(),
|
|
454
|
+
path: z6.string().optional(),
|
|
455
|
+
notes: z6.number().int().optional(),
|
|
456
|
+
hops: z6.number().int().optional()
|
|
457
|
+
}).strict()
|
|
458
|
+
),
|
|
459
|
+
edges: z6.array(z6.object({ from: z6.string(), to: z6.string(), kind: NoteGraphEdgeKind }).strict()),
|
|
460
|
+
tags: z6.array(z6.object({ name: z6.string(), notes: z6.number().int() }).strict()),
|
|
461
|
+
folders: z6.array(z6.object({ path: z6.string(), notes: z6.number().int() }).strict())
|
|
462
|
+
}).strict();
|
|
463
|
+
var NoteSummary = z6.object({ id: z6.string(), title: z6.string(), path: z6.string() }).strict();
|
|
316
464
|
|
|
317
465
|
// ../protocol/src/index.ts
|
|
318
|
-
import { z as
|
|
466
|
+
import { z as z15 } from "zod";
|
|
319
467
|
|
|
320
468
|
// ../protocol/src/artifact-math-input.ts
|
|
321
469
|
import "zod";
|
|
@@ -387,40 +535,84 @@ function artifactMathInput(schema, fields, extra) {
|
|
|
387
535
|
}
|
|
388
536
|
|
|
389
537
|
// ../protocol/src/algorithm-trace.ts
|
|
390
|
-
import { z as
|
|
538
|
+
import { z as z8 } from "zod";
|
|
391
539
|
var MAX_VALUES = 64;
|
|
392
540
|
var MAX_STEPS = 200;
|
|
393
|
-
var
|
|
394
|
-
var
|
|
395
|
-
var
|
|
396
|
-
|
|
541
|
+
var MAX_CODE_LINES = 40;
|
|
542
|
+
var MAX_CODE_LINE_LENGTH = 120;
|
|
543
|
+
var MAX_CODE_CHARS = 4e3;
|
|
544
|
+
function codeLines(source) {
|
|
545
|
+
return source.replace(/\r\n?/g, "\n").replace(/\n$/, "").split("\n");
|
|
546
|
+
}
|
|
547
|
+
var Label = z8.string().trim().min(1).max(40);
|
|
548
|
+
var Cell = z8.union([z8.number(), z8.string().max(24)]);
|
|
549
|
+
var Index = z8.number().int().nonnegative();
|
|
550
|
+
var TracePointer = z8.object({
|
|
397
551
|
name: Label.describe('Pointer label shown under the cell, e.g. "left", "right", "mid", "i".'),
|
|
398
552
|
index: Index.describe("0-based index into the sequence as it is at this step.")
|
|
399
553
|
}).strict();
|
|
400
|
-
var TraceRange =
|
|
554
|
+
var TraceRange = z8.object({
|
|
401
555
|
start: Index.describe("0-based start index, inclusive, within the sequence as it is at this step."),
|
|
402
556
|
end: Index.describe("0-based end index, inclusive. Must be >= start and within the sequence."),
|
|
403
557
|
label: Label.optional().describe('Optional label, e.g. "window".'),
|
|
404
|
-
tone:
|
|
558
|
+
tone: z8.enum(["active", "done", "muted"]).optional().describe("active = current focus, done = finished/sorted, muted = ruled out. Defaults to active.")
|
|
405
559
|
}).strict();
|
|
406
|
-
var TraceVariable =
|
|
560
|
+
var TraceVariable = z8.object({
|
|
407
561
|
name: Label,
|
|
408
|
-
value:
|
|
409
|
-
}).strict();
|
|
410
|
-
var
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
562
|
+
value: z8.union([z8.number(), z8.string().max(80), z8.boolean()])
|
|
563
|
+
}).strict();
|
|
564
|
+
var TraceCode = z8.object({
|
|
565
|
+
language: z8.string().trim().min(1).max(30).describe('The language the code is written in, e.g. "Python", "TypeScript", "Java" or "pseudocode". Shown as a label.'),
|
|
566
|
+
source: z8.string().min(1).max(MAX_CODE_CHARS).describe(
|
|
567
|
+
`The code, as plain text with newlines and its real indentation: at most ${MAX_CODE_LINES} lines of at most ${MAX_CODE_LINE_LENGTH} characters. Line 1 is the first line. No Markdown fences.`
|
|
568
|
+
)
|
|
569
|
+
}).strict().superRefine((code, ctx) => {
|
|
570
|
+
const lines = codeLines(code.source);
|
|
571
|
+
if (lines.every((line) => line.trim() === "")) {
|
|
572
|
+
ctx.addIssue({ code: "custom", path: ["source"], message: "source has no code" });
|
|
573
|
+
}
|
|
574
|
+
if (lines.length > MAX_CODE_LINES) {
|
|
575
|
+
ctx.addIssue({ code: "custom", path: ["source"], message: `source has ${lines.length} lines; at most ${MAX_CODE_LINES} are allowed` });
|
|
576
|
+
}
|
|
577
|
+
const long = lines.findIndex((line) => line.length > MAX_CODE_LINE_LENGTH);
|
|
578
|
+
if (long >= 0) {
|
|
579
|
+
ctx.addIssue({ code: "custom", path: ["source"], message: `line ${long + 1} is longer than ${MAX_CODE_LINE_LENGTH} characters` });
|
|
580
|
+
}
|
|
581
|
+
});
|
|
582
|
+
var TraceStep = z8.object({
|
|
583
|
+
explanation: z8.string().trim().min(1).max(500).describe("What happens in this step, in one or two sentences."),
|
|
584
|
+
values: z8.array(Cell).min(1).max(MAX_VALUES).optional().describe("The whole sequence after this step. Omit unless the values changed (e.g. a swap); omitted means unchanged."),
|
|
585
|
+
pointers: z8.array(TracePointer).max(8).optional().describe("All pointers to show at this step. Not carried over from earlier steps: repeat any that still apply."),
|
|
586
|
+
ranges: z8.array(TraceRange).max(8).optional().describe("All highlighted ranges at this step. Not carried over from earlier steps."),
|
|
587
|
+
variables: z8.array(TraceVariable).max(12).optional().describe("All running state at this step, e.g. current sum, best so far. Not carried over from earlier steps."),
|
|
588
|
+
lines: z8.array(z8.number().int().positive()).max(MAX_CODE_LINES).optional().describe(
|
|
589
|
+
"Only with code: the 1-based line numbers in code.source this step is running, highlighted beside the values. Not carried over from earlier steps; omit or leave empty to highlight none."
|
|
590
|
+
)
|
|
591
|
+
}).strict();
|
|
592
|
+
var AlgorithmTraceSpec = z8.object({
|
|
593
|
+
title: z8.string().trim().min(1).max(120),
|
|
594
|
+
values: z8.array(Cell).min(1).max(MAX_VALUES).describe("The input sequence before the first step."),
|
|
595
|
+
code: TraceCode.optional().describe(
|
|
596
|
+
"Optional source code shown beside the values, with each step's `lines` highlighted. Include it only when the code itself is the point."
|
|
597
|
+
),
|
|
598
|
+
steps: z8.array(TraceStep).min(1).max(MAX_STEPS)
|
|
421
599
|
}).strict().superRefine((spec, ctx) => {
|
|
422
600
|
let length = spec.values.length;
|
|
601
|
+
const codeLength = spec.code ? codeLines(spec.code.source).length : 0;
|
|
423
602
|
spec.steps.forEach((step, i) => {
|
|
603
|
+
if (step.lines && !spec.code) {
|
|
604
|
+
ctx.addIssue({ code: "custom", path: ["steps", i, "lines"], message: "lines need code: add code, or remove lines" });
|
|
605
|
+
} else {
|
|
606
|
+
step.lines?.forEach((line, j) => {
|
|
607
|
+
if (line > codeLength) {
|
|
608
|
+
ctx.addIssue({
|
|
609
|
+
code: "custom",
|
|
610
|
+
path: ["steps", i, "lines", j],
|
|
611
|
+
message: `line ${line} is outside the code (${codeLength} lines)`
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
});
|
|
615
|
+
}
|
|
424
616
|
if (step.values) length = step.values.length;
|
|
425
617
|
step.pointers?.forEach((p, j) => {
|
|
426
618
|
if (p.index >= length) {
|
|
@@ -443,42 +635,80 @@ var AlgorithmTraceSpec = z7.object({
|
|
|
443
635
|
});
|
|
444
636
|
});
|
|
445
637
|
|
|
638
|
+
// ../protocol/src/code-walkthrough.ts
|
|
639
|
+
import { z as z9 } from "zod";
|
|
640
|
+
var MAX_WALKTHROUGH_STEPS = 200;
|
|
641
|
+
var MAX_WALKTHROUGH_VARIABLES = 12;
|
|
642
|
+
var MAX_WALKTHROUGH_OUTPUT = 4e3;
|
|
643
|
+
var CodeWalkthroughStep = z9.object({
|
|
644
|
+
explanation: z9.string().trim().min(1).max(500).describe("What happens at this step and why, in one or two sentences."),
|
|
645
|
+
label: z9.string().trim().min(1).max(80).optional().describe('Optional short name for the step, e.g. "Initial render", "Click handler", "Render 2".'),
|
|
646
|
+
lines: z9.array(z9.number().int().positive()).max(MAX_CODE_LINES).optional().describe("The 1-based line numbers in code.source this step is at. Not carried over: omit or leave empty to highlight none."),
|
|
647
|
+
variables: z9.array(TraceVariable).max(MAX_WALKTHROUGH_VARIABLES).describe(
|
|
648
|
+
'All the state visible at this step, each name once, e.g. "n", "render.count", "handler.count", "queued update". Not carried over: list everything that still applies, or [] for none. Values are plain text, numbers or booleans; write undefined, null or a short object as a string.'
|
|
649
|
+
),
|
|
650
|
+
output: z9.string().max(MAX_WALKTHROUGH_OUTPUT).describe(
|
|
651
|
+
'Everything visible as output at this step, as plain text, e.g. printed lines or what the page shows ("Count: 0"). Not carried over: repeat earlier output that is still visible, or "" for none.'
|
|
652
|
+
)
|
|
653
|
+
}).strict();
|
|
654
|
+
var CodeWalkthroughSpec = z9.object({
|
|
655
|
+
title: z9.string().trim().min(1).max(120),
|
|
656
|
+
code: TraceCode.describe("The source shown on every step. It stays the same across steps."),
|
|
657
|
+
steps: z9.array(CodeWalkthroughStep).min(1).max(MAX_WALKTHROUGH_STEPS)
|
|
658
|
+
}).strict().superRefine((spec, ctx) => {
|
|
659
|
+
const codeLength = codeLines(spec.code.source).length;
|
|
660
|
+
spec.steps.forEach((step, i) => {
|
|
661
|
+
step.lines?.forEach((line, j) => {
|
|
662
|
+
if (line > codeLength) {
|
|
663
|
+
ctx.addIssue({ code: "custom", path: ["steps", i, "lines", j], message: `line ${line} is outside the code (${codeLength} lines)` });
|
|
664
|
+
}
|
|
665
|
+
});
|
|
666
|
+
const seen = /* @__PURE__ */ new Set();
|
|
667
|
+
step.variables.forEach((variable, j) => {
|
|
668
|
+
if (seen.has(variable.name)) {
|
|
669
|
+
ctx.addIssue({ code: "custom", path: ["steps", i, "variables", j, "name"], message: `variable "${variable.name}" appears twice in this step` });
|
|
670
|
+
}
|
|
671
|
+
seen.add(variable.name);
|
|
672
|
+
});
|
|
673
|
+
});
|
|
674
|
+
});
|
|
675
|
+
|
|
446
676
|
// ../protocol/src/graph.ts
|
|
447
|
-
import { z as
|
|
677
|
+
import { z as z10 } from "zod";
|
|
448
678
|
var MAX_NODES = 60;
|
|
449
679
|
var MAX_EDGES = 200;
|
|
450
680
|
var MAX_STEPS2 = 200;
|
|
451
|
-
var Id =
|
|
452
|
-
var Text =
|
|
453
|
-
var GraphTone =
|
|
681
|
+
var Id = z10.string().trim().min(1).max(24);
|
|
682
|
+
var Text = z10.string().trim().min(1).max(24);
|
|
683
|
+
var GraphTone = z10.enum(["active", "done", "muted"]);
|
|
454
684
|
var ToneField = GraphTone.optional().describe(
|
|
455
685
|
"active = current focus, done = finished/visited, muted = ruled out. Defaults to active."
|
|
456
686
|
);
|
|
457
|
-
var GraphNode =
|
|
687
|
+
var GraphNode = z10.object({
|
|
458
688
|
id: Id.describe("Unique id, used by edges and steps. Shown on the node if it has no label."),
|
|
459
689
|
label: Text.optional().describe("Short text on the node. Only $...$ is a formula, e.g. $v_1$.")
|
|
460
690
|
}).strict();
|
|
461
|
-
var GraphEdge =
|
|
691
|
+
var GraphEdge = z10.object({
|
|
462
692
|
from: Id.describe("Id of a node. In a tree, the parent."),
|
|
463
693
|
to: Id.describe("Id of a node, the same as `from` for a self-loop. In a tree, the child; children appear left to right in edge order unless they have a `side`."),
|
|
464
|
-
side:
|
|
694
|
+
side: z10.enum(["left", "right"]).optional().describe(
|
|
465
695
|
"Only when kind is tree: which child this is of `from`, its parent. Set it on every edge of a binary search tree or binary tree traversal, because a lone left child and a lone right child are different trees. A node has at most one child per side, and either all of its children have a side or none do."
|
|
466
696
|
),
|
|
467
|
-
weight:
|
|
697
|
+
weight: z10.number().optional().describe("Numeric weight shown on the edge. Give a weight or a label, not both."),
|
|
468
698
|
label: Text.optional().describe("Text shown on the edge. Only $...$ is a formula.")
|
|
469
699
|
}).strict();
|
|
470
|
-
var GraphNodeState =
|
|
471
|
-
var GraphEdgeState =
|
|
700
|
+
var GraphNodeState = z10.object({ id: Id.describe("Id of a node."), tone: ToneField }).strict();
|
|
701
|
+
var GraphEdgeState = z10.object({
|
|
472
702
|
from: Id,
|
|
473
703
|
to: Id,
|
|
474
|
-
nth:
|
|
704
|
+
nth: z10.number().int().nonnegative().optional().describe("Only for parallel edges, and then required: which of the edges joining these nodes, 0-based in the order of `edges`."),
|
|
475
705
|
tone: ToneField
|
|
476
706
|
}).strict().describe("An edge of the graph. In an undirected graph, from and to may be in either order.");
|
|
477
|
-
var GraphStep =
|
|
478
|
-
explanation:
|
|
479
|
-
nodeStates:
|
|
480
|
-
edgeStates:
|
|
481
|
-
variables:
|
|
707
|
+
var GraphStep = z10.object({
|
|
708
|
+
explanation: z10.string().trim().min(1).max(500).describe("What happens in this step, in one or two sentences."),
|
|
709
|
+
nodeStates: z10.array(GraphNodeState).max(MAX_NODES).optional().describe("The state of every node that has one at this step, at most one each. Not carried over from earlier steps: repeat any that still apply."),
|
|
710
|
+
edgeStates: z10.array(GraphEdgeState).max(MAX_EDGES).optional().describe("The state of every edge that has one at this step, at most one each. Not carried over from earlier steps: repeat any that still apply."),
|
|
711
|
+
variables: z10.array(TraceVariable).max(12).optional().describe("All running state at this step, e.g. the queue or current distances. Not carried over from earlier steps.")
|
|
482
712
|
}).strict();
|
|
483
713
|
var pairKey = (from, to, directed) => JSON.stringify(directed || from <= to ? [from, to] : [to, from]);
|
|
484
714
|
function graphEdgeLookup(spec) {
|
|
@@ -547,15 +777,15 @@ function checkSides(spec, ctx) {
|
|
|
547
777
|
}
|
|
548
778
|
}
|
|
549
779
|
}
|
|
550
|
-
var GraphSpec =
|
|
551
|
-
title:
|
|
552
|
-
directed:
|
|
553
|
-
kind:
|
|
780
|
+
var GraphSpec = z10.object({
|
|
781
|
+
title: z10.string().trim().min(1).max(120),
|
|
782
|
+
directed: z10.boolean().describe("True draws arrowheads from `from` to `to`."),
|
|
783
|
+
kind: z10.enum(["tree", "graph"]).optional().describe(
|
|
554
784
|
"Layout hint. tree draws a rooted tree top-down, and needs a real tree: connected with no cycles, and when directed, edges going parent to child from one root. When undirected, the first node is the root. Anything else falls back to the general layout, unless an edge has a `side`, which is then an error. Defaults to graph."
|
|
555
785
|
),
|
|
556
|
-
nodes:
|
|
557
|
-
edges:
|
|
558
|
-
steps:
|
|
786
|
+
nodes: z10.array(GraphNode).min(1).max(MAX_NODES),
|
|
787
|
+
edges: z10.array(GraphEdge).max(MAX_EDGES).describe("Self-loops and parallel edges are allowed."),
|
|
788
|
+
steps: z10.array(GraphStep).min(1).max(MAX_STEPS2).optional().describe("Omit to show the graph without stepping through it.")
|
|
559
789
|
}).strict().superRefine((spec, ctx) => {
|
|
560
790
|
const ids = /* @__PURE__ */ new Set();
|
|
561
791
|
spec.nodes.forEach((node, i) => {
|
|
@@ -592,17 +822,17 @@ var GraphSpec = z8.object({
|
|
|
592
822
|
});
|
|
593
823
|
|
|
594
824
|
// ../protocol/src/multiple-choice.ts
|
|
595
|
-
import { z as
|
|
596
|
-
var MultipleChoiceOption =
|
|
597
|
-
text:
|
|
598
|
-
feedback:
|
|
599
|
-
}).strict();
|
|
600
|
-
var MultipleChoiceSpec =
|
|
601
|
-
concept:
|
|
602
|
-
question:
|
|
603
|
-
options:
|
|
604
|
-
correctOptionIndex:
|
|
605
|
-
explanation:
|
|
825
|
+
import { z as z11 } from "zod";
|
|
826
|
+
var MultipleChoiceOption = z11.object({
|
|
827
|
+
text: z11.string().trim().min(1).max(300),
|
|
828
|
+
feedback: z11.string().trim().min(1).max(500).optional().describe("Shown if the learner picks this option: why it is right or what misconception it reflects.")
|
|
829
|
+
}).strict();
|
|
830
|
+
var MultipleChoiceSpec = z11.object({
|
|
831
|
+
concept: z11.string().trim().min(1).max(80).describe('Short label for the concept being checked, e.g. "sliding window invariant". Used to track progress.'),
|
|
832
|
+
question: z11.string().trim().min(1).max(1e3),
|
|
833
|
+
options: z11.array(MultipleChoiceOption).min(2).max(6).describe("2-6 options with distinct text."),
|
|
834
|
+
correctOptionIndex: z11.number().int().nonnegative().describe("0-based index of the single correct option; must be less than the number of options."),
|
|
835
|
+
explanation: z11.string().trim().min(1).max(1e3).describe("Shown after answering: why the correct option is correct.")
|
|
606
836
|
}).strict().superRefine((spec, ctx) => {
|
|
607
837
|
if (spec.correctOptionIndex >= spec.options.length) {
|
|
608
838
|
ctx.addIssue({
|
|
@@ -622,10 +852,10 @@ var MultipleChoiceSpec = z9.object({
|
|
|
622
852
|
}
|
|
623
853
|
});
|
|
624
854
|
});
|
|
625
|
-
var MultipleChoicePublic =
|
|
626
|
-
concept:
|
|
627
|
-
question:
|
|
628
|
-
options:
|
|
855
|
+
var MultipleChoicePublic = z11.object({
|
|
856
|
+
concept: z11.string(),
|
|
857
|
+
question: z11.string(),
|
|
858
|
+
options: z11.array(z11.object({ text: z11.string() }).strict())
|
|
629
859
|
}).strict();
|
|
630
860
|
function toMultipleChoicePublic(spec) {
|
|
631
861
|
return {
|
|
@@ -634,12 +864,12 @@ function toMultipleChoicePublic(spec) {
|
|
|
634
864
|
options: spec.options.map((o) => ({ text: o.text }))
|
|
635
865
|
};
|
|
636
866
|
}
|
|
637
|
-
var MultipleChoiceAnswer =
|
|
638
|
-
var MultipleChoiceGrade =
|
|
639
|
-
correct:
|
|
640
|
-
correctOptionIndex:
|
|
641
|
-
explanation:
|
|
642
|
-
feedback:
|
|
867
|
+
var MultipleChoiceAnswer = z11.object({ optionIndex: z11.number().int().nonnegative() }).strict();
|
|
868
|
+
var MultipleChoiceGrade = z11.object({
|
|
869
|
+
correct: z11.boolean(),
|
|
870
|
+
correctOptionIndex: z11.number().int().nonnegative(),
|
|
871
|
+
explanation: z11.string(),
|
|
872
|
+
feedback: z11.string().optional()
|
|
643
873
|
}).strict();
|
|
644
874
|
function gradeMultipleChoice(spec, answer) {
|
|
645
875
|
const chosen = spec.options[answer.optionIndex];
|
|
@@ -653,43 +883,43 @@ function gradeMultipleChoice(spec, answer) {
|
|
|
653
883
|
}
|
|
654
884
|
|
|
655
885
|
// ../protocol/src/set-diagram.ts
|
|
656
|
-
import { z as
|
|
886
|
+
import { z as z12 } from "zod";
|
|
657
887
|
var MAX_SETS = 3;
|
|
658
888
|
var MAX_REGIONS = 8;
|
|
659
889
|
var MAX_ELEMENTS = 30;
|
|
660
890
|
var MAX_STEPS3 = 40;
|
|
661
|
-
var SetId =
|
|
891
|
+
var SetId = z12.string().trim().min(1).max(24);
|
|
662
892
|
var ONE_LINE = /^[^\n\r\v\f\u0085\u2028\u2029]*$/;
|
|
663
|
-
var oneLine = (max) =>
|
|
664
|
-
var Element =
|
|
893
|
+
var oneLine = (max) => z12.string().trim().min(1).max(max).regex(ONE_LINE, "must not contain line breaks");
|
|
894
|
+
var Element = z12.union([z12.number(), oneLine(24)]);
|
|
665
895
|
function setRegionKey(ids) {
|
|
666
896
|
return JSON.stringify([...ids].sort());
|
|
667
897
|
}
|
|
668
|
-
var RegionIn =
|
|
669
|
-
var SetDiagramSet =
|
|
898
|
+
var RegionIn = z12.array(SetId).max(MAX_SETS);
|
|
899
|
+
var SetDiagramSet = z12.object({
|
|
670
900
|
id: SetId.describe('Short id used to refer to this set, e.g. "a". Unique within the diagram.'),
|
|
671
901
|
label: oneLine(32).describe('Shown next to the circle, e.g. "$A$" or "Multiples of 3", on one line. Only $...$ is a formula.')
|
|
672
902
|
}).strict();
|
|
673
|
-
var SetDiagramRegion =
|
|
903
|
+
var SetDiagramRegion = z12.object({
|
|
674
904
|
in: RegionIn.describe('Ids of the sets this region is inside. It is outside all the others: with sets a, b, c, ["a","b"] means in a and b, not c. [] means outside every set and needs `universe`. No id twice.'),
|
|
675
|
-
elements:
|
|
676
|
-
count:
|
|
905
|
+
elements: z12.array(Element).max(MAX_ELEMENTS).describe('What the region contains, each short and on one line. No element may appear twice, in this list or across regions, and 1 and "1" count as the same element. Empty if you only know the count, or the region is empty.'),
|
|
906
|
+
count: z12.number().int().nonnegative().max(1e6).optional().describe("How many elements the region has, when that's more than you list, e.g. for inclusion-exclusion. At least the number of elements listed.")
|
|
677
907
|
}).strict();
|
|
678
|
-
var SetDiagramHighlight =
|
|
908
|
+
var SetDiagramHighlight = z12.object({
|
|
679
909
|
in: RegionIn.describe("The region to highlight, named like a region's `in`, with no id twice. Any region of the diagram can be highlighted, listed or not."),
|
|
680
|
-
tone:
|
|
910
|
+
tone: z12.enum(["active", "done", "muted"]).optional().describe("active = current focus, done = finished, muted = ruled out. Defaults to active.")
|
|
681
911
|
}).strict();
|
|
682
|
-
var SetDiagramStep =
|
|
683
|
-
explanation:
|
|
684
|
-
highlights:
|
|
685
|
-
variables:
|
|
912
|
+
var SetDiagramStep = z12.object({
|
|
913
|
+
explanation: z12.string().trim().min(1).max(500).describe("What this step shows, in one or two sentences."),
|
|
914
|
+
highlights: z12.array(SetDiagramHighlight).max(MAX_REGIONS).optional().describe("All regions highlighted at this step, each at most once. They apply to this step only, not carried over: repeat any that still apply."),
|
|
915
|
+
variables: z12.array(TraceVariable).max(12).optional().describe("All running state at this step, e.g. |A \u222A B| so far. Not carried over from earlier steps.")
|
|
686
916
|
}).strict();
|
|
687
|
-
var SetDiagramSpec =
|
|
688
|
-
title:
|
|
689
|
-
sets:
|
|
917
|
+
var SetDiagramSpec = z12.object({
|
|
918
|
+
title: z12.string().trim().min(1).max(120),
|
|
919
|
+
sets: z12.array(SetDiagramSet).min(1).max(MAX_SETS).describe("The circles, 1 to 3."),
|
|
690
920
|
universe: oneLine(24).optional().describe('Label of the rectangle around the sets, e.g. "$U$", on one line. Needed to show or highlight the region outside every set, such as a complement.'),
|
|
691
|
-
regions:
|
|
692
|
-
steps:
|
|
921
|
+
regions: z12.array(SetDiagramRegion).max(MAX_REGIONS).describe("What each region contains, each region at most once."),
|
|
922
|
+
steps: z12.array(SetDiagramStep).min(1).max(MAX_STEPS3).optional().describe("Optional walk through the diagram. Omit for a static diagram.")
|
|
693
923
|
}).strict().superRefine((spec, ctx) => {
|
|
694
924
|
const ids = spec.sets.map((s) => s.id);
|
|
695
925
|
spec.sets.forEach((set, i) => {
|
|
@@ -728,34 +958,34 @@ var SetDiagramSpec = z10.object({
|
|
|
728
958
|
});
|
|
729
959
|
|
|
730
960
|
// ../protocol/src/table.ts
|
|
731
|
-
import { z as
|
|
961
|
+
import { z as z13 } from "zod";
|
|
732
962
|
var MAX_COLUMNS = 16;
|
|
733
963
|
var MAX_ROWS = 64;
|
|
734
964
|
var MAX_STEPS4 = 100;
|
|
735
|
-
var Header =
|
|
736
|
-
var CellValue =
|
|
737
|
-
var Index2 =
|
|
738
|
-
var TableHighlight =
|
|
965
|
+
var Header = z13.string().trim().min(1).max(80);
|
|
966
|
+
var CellValue = z13.union([z13.number(), z13.boolean(), z13.string().max(120)]);
|
|
967
|
+
var Index2 = z13.number().int().nonnegative();
|
|
968
|
+
var TableHighlight = z13.object({
|
|
739
969
|
row: Index2.optional().describe("0-based data row, below the number of rows. With no column, highlights the whole row. A highlight must give a row, a column or both."),
|
|
740
970
|
column: Index2.optional().describe("0-based data column, below the number of columns. With no row, highlights the whole column. With both, highlights one cell."),
|
|
741
|
-
tone:
|
|
971
|
+
tone: z13.enum(["active", "done", "muted"]).optional().describe("active = current focus, done = finished, muted = ruled out. Defaults to active. Where highlights overlap, the later one wins.")
|
|
742
972
|
}).strict();
|
|
743
|
-
var TableCellChange =
|
|
973
|
+
var TableCellChange = z13.object({
|
|
744
974
|
row: Index2.describe("0-based data row, below the number of rows."),
|
|
745
975
|
column: Index2.describe("0-based data column, below the number of columns."),
|
|
746
976
|
value: CellValue.describe("The cell's value from this step on.")
|
|
747
977
|
}).strict();
|
|
748
|
-
var TableStep =
|
|
749
|
-
explanation:
|
|
750
|
-
highlight:
|
|
751
|
-
cells:
|
|
752
|
-
}).strict();
|
|
753
|
-
var TableSpec =
|
|
754
|
-
title:
|
|
755
|
-
columns:
|
|
756
|
-
rows:
|
|
757
|
-
rowHeaders:
|
|
758
|
-
steps:
|
|
978
|
+
var TableStep = z13.object({
|
|
979
|
+
explanation: z13.string().trim().min(1).max(500).describe("What happens in this step, in one or two sentences."),
|
|
980
|
+
highlight: z13.array(TableHighlight).max(32).optional().describe("All cells, rows and columns to highlight at this step. Not carried over from earlier steps."),
|
|
981
|
+
cells: z13.array(TableCellChange).max(64).optional().describe('Cells this step fills in or changes. They keep the new value on later steps. To reveal working, start a cell as "" and set it here.')
|
|
982
|
+
}).strict();
|
|
983
|
+
var TableSpec = z13.object({
|
|
984
|
+
title: z13.string().trim().min(1).max(120),
|
|
985
|
+
columns: z13.array(Header).min(1).max(MAX_COLUMNS).describe("Column headers, one per data column. Don't include a header for rowHeaders."),
|
|
986
|
+
rows: z13.array(z13.array(CellValue).min(1).max(MAX_COLUMNS)).min(1).max(MAX_ROWS).describe('Data rows, each with exactly one cell per column. A boolean shows as T or F; "" is a blank cell.'),
|
|
987
|
+
rowHeaders: z13.array(Header).max(MAX_ROWS).optional().describe("Optional label for each row, e.g. a relation matrix's elements. Exactly one per row."),
|
|
988
|
+
steps: z13.array(TableStep).min(1).max(MAX_STEPS4).optional().describe("Omit for a static table. With steps, the learner steps through them.")
|
|
759
989
|
}).strict().superRefine((spec, ctx) => {
|
|
760
990
|
const rowCount = spec.rows.length;
|
|
761
991
|
const columnCount = spec.columns.length;
|
|
@@ -788,17 +1018,17 @@ var TableSpec = z11.object({
|
|
|
788
1018
|
});
|
|
789
1019
|
|
|
790
1020
|
// ../protocol/src/worked-steps.ts
|
|
791
|
-
import { z as
|
|
1021
|
+
import { z as z14 } from "zod";
|
|
792
1022
|
var MAX_STEPS5 = 50;
|
|
793
|
-
var WorkedStep =
|
|
794
|
-
label:
|
|
795
|
-
statement:
|
|
796
|
-
justification:
|
|
1023
|
+
var WorkedStep = z14.object({
|
|
1024
|
+
label: z14.string().trim().min(1).max(40).optional().describe('Optional heading for this part of the working, e.g. "Base case", "Inductive step".'),
|
|
1025
|
+
statement: z14.string().trim().min(1).max(1e3).describe("What this step establishes, mostly as a formula in $...$. For large sums and fractions, put \\displaystyle INSIDE the dollars, e.g. $\\displaystyle\\sum_{i=1}^{n} i$; $$ is not available."),
|
|
1026
|
+
justification: z14.string().trim().min(1).max(500).describe('Why it follows, e.g. "by the inductive hypothesis".')
|
|
797
1027
|
}).strict();
|
|
798
|
-
var WorkedStepsSpec =
|
|
799
|
-
title:
|
|
800
|
-
goal:
|
|
801
|
-
steps:
|
|
1028
|
+
var WorkedStepsSpec = z14.object({
|
|
1029
|
+
title: z14.string().trim().min(1).max(120),
|
|
1030
|
+
goal: z14.string().trim().min(1).max(500).optional().describe("Optional statement of what is being shown, e.g. the claim to prove."),
|
|
1031
|
+
steps: z14.array(WorkedStep).min(1).max(MAX_STEPS5)
|
|
802
1032
|
}).strict();
|
|
803
1033
|
|
|
804
1034
|
// ../protocol/src/index.ts
|
|
@@ -806,14 +1036,21 @@ var artifactKinds = {
|
|
|
806
1036
|
algorithm_trace: {
|
|
807
1037
|
version: 1,
|
|
808
1038
|
toolName: "show_algorithm_trace",
|
|
809
|
-
description: "Show the learner an interactive step-by-step trace of an algorithm running over a sequence (e.g. sliding window, two pointers, binary search, a simple sort). The learner steps through it with play/pause/step controls. Use it when watching state change step by step will make the idea click. Keep traces short (roughly 5-20 steps) and make each step's explanation say what changed and why.",
|
|
1039
|
+
description: "Show the learner an interactive step-by-step trace of an algorithm running over a sequence (e.g. sliding window, two pointers, binary search, a simple sort). The learner steps through it with play/pause/step controls. Use it when watching state change step by step will make the idea click. Keep traces short (roughly 5-20 steps) and make each step's explanation say what changed and why. A code pane is optional: add `code` and each step's `lines` only when the code itself is the point, such as how an implementation's lines move the state, and leave it out when the idea matters more than any code. Write that code in the programming language the learner has shown proficiency in according to <learner_memories>; if they show none, use Python or pseudocode. Keep the code short, and highlight the lines each step is running. For code that doesn't move over a sequence, such as a plain function or a React render, use show_code_walkthrough instead of inventing an array.",
|
|
810
1040
|
spec: AlgorithmTraceSpec,
|
|
811
1041
|
input: artifactMathInput(AlgorithmTraceSpec, ["title", "steps.*.explanation"])
|
|
812
1042
|
},
|
|
1043
|
+
code_walkthrough: {
|
|
1044
|
+
version: 1,
|
|
1045
|
+
toolName: "show_code_walkthrough",
|
|
1046
|
+
description: 'Show the learner a step-by-step walkthrough of a short piece of code that isn\'t about a sequence: a plain function\'s parameters, locals and return value, or a React component\'s renders, handlers and state updates. Each step highlights the source lines it is at and gives a complete snapshot of the visible state (`variables`) and the visible output (`output`, plain text such as printed lines or what the page shows, e.g. "Count: 0"); nothing carries over between steps, so repeat whatever still applies and use [] or "" for none. The source stays the same on every step. Use show_algorithm_trace instead for an algorithm moving over an array or other sequence, and show_graph for a component hierarchy. Keep the code short (a few to about 20 lines) and the walkthrough short (roughly 3-12 steps). Write the code in the language the concept belongs to (JSX for React); for a language-neutral idea, use the language the learner knows from <learner_memories>, else Python or pseudocode. The snapshots are your illustration, not a real run, so get them right. For React, keep the state a render or handler sees apart from updates it queues: inside a handler, state still has the value from the render it belongs to (name it, e.g. "handler.count" = 0, with "queued update" = "count + 1"), and the new value and its output appear only at the next render\'s step.',
|
|
1047
|
+
spec: CodeWalkthroughSpec,
|
|
1048
|
+
input: artifactMathInput(CodeWalkthroughSpec, ["title", "steps.*.explanation"])
|
|
1049
|
+
},
|
|
813
1050
|
graph: {
|
|
814
1051
|
version: 1,
|
|
815
1052
|
toolName: "show_graph",
|
|
816
|
-
description:
|
|
1053
|
+
description: `Show the learner a graph or tree, drawn for you, optionally with steps they can walk through. Use it for graphs, trees, BFS, DFS, shortest paths, spanning trees and tree traversals, whenever seeing the structure or watching an algorithm move over it will help. Never give coordinates: the layout is automatic. For a binary search tree or binary tree traversal, set kind to tree and give every edge a side, so a lone left child and a lone right child are drawn differently. The automatic layout may draw crossing edges that mean nothing, even when the graph is planar, so don't use this to show whether a graph is planar. Keep it small enough to read (roughly 4-15 nodes, 5-20 steps) and make each step's explanation say what changed and why. For a component hierarchy (such as React components), set kind to tree and directed to true, with one node per component instance (distinct ids for two instances of the same component, labelled with the short component name) and one edge from each parent to each child it renders, labelled with the props it passes (e.g. "count" or "onClick"). Use steps to highlight where state is owned and the nodes and edges its value flows through, with variables for simple state such as count = 1. The nodes and edges stay the same on every step: don't add callback edges back up the tree, and don't suggest that a component's output changes just because it re-renders.`,
|
|
817
1054
|
spec: GraphSpec,
|
|
818
1055
|
input: artifactMathInput(GraphSpec, ["title", "nodes.*.label", "edges.*.label", "steps.*.explanation"], (spec, ctx) => {
|
|
819
1056
|
spec.nodes.forEach((node, i) => {
|
|
@@ -821,10 +1058,17 @@ var artifactKinds = {
|
|
|
821
1058
|
});
|
|
822
1059
|
})
|
|
823
1060
|
},
|
|
1061
|
+
interview_context: {
|
|
1062
|
+
version: 1,
|
|
1063
|
+
toolName: "ask_interview_context",
|
|
1064
|
+
description: "Course placement interview only: ask the learner once, as the last question of the interview and in the same reply as the placement questions, whether there is anything else they want you to know about what they already understand or want to explore. They answer in their own words in the UI, or leave it blank; the answer is reported back to you with the placement results. Not graded.",
|
|
1065
|
+
spec: InterviewContextSpec,
|
|
1066
|
+
input: artifactMathInput(InterviewContextSpec, ["question"])
|
|
1067
|
+
},
|
|
824
1068
|
multiple_choice: {
|
|
825
1069
|
version: 1,
|
|
826
1070
|
toolName: "ask_multiple_choice",
|
|
827
|
-
description: "Ask the learner one multiple-choice question to check understanding of a concept you just taught. Exactly one option is correct. Write plausible wrong options that reflect real misconceptions, and give per-option feedback where useful. The learner answers in the UI; the result is reported back to you on the next turn, so do not reveal the answer in your reply.",
|
|
1071
|
+
description: "Ask the learner one multiple-choice question to check understanding of a concept you just taught. Exactly one option is correct. Write plausible wrong options that reflect real misconceptions, and give per-option feedback where useful. The learner answers in the UI; the result is reported back to you on the next turn, so do not reveal the answer in your reply. For a code prediction, put the short snippet in a fenced code block in your reply text before this call and ask what it returns, prints or displays; the question and options render maths and plain text only, so never put code fences in them.",
|
|
828
1072
|
spec: MultipleChoiceSpec,
|
|
829
1073
|
input: artifactMathInput(MultipleChoiceSpec, ["question", "options.*.text", "options.*.feedback", "explanation"])
|
|
830
1074
|
},
|
|
@@ -857,40 +1101,54 @@ var artifactKinds = {
|
|
|
857
1101
|
input: artifactMathInput(WorkedStepsSpec, ["title", "goal", "steps.*.label", "steps.*.statement", "steps.*.justification"])
|
|
858
1102
|
}
|
|
859
1103
|
};
|
|
860
|
-
var ArtifactKind =
|
|
861
|
-
var ArtifactBase = { id:
|
|
862
|
-
var MultipleChoiceAttempt =
|
|
863
|
-
var
|
|
864
|
-
var
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
1104
|
+
var ArtifactKind = z15.enum(Object.keys(artifactKinds));
|
|
1105
|
+
var ArtifactBase = { id: z15.string(), createdAt: z15.string().datetime() };
|
|
1106
|
+
var MultipleChoiceAttempt = z15.object({ answer: MultipleChoiceAnswer, grade: MultipleChoiceGrade, createdAt: z15.string().datetime() }).strict();
|
|
1107
|
+
var InterviewContextAttempt = z15.object({ answer: InterviewContextAnswer, grade: InterviewContextGrade, createdAt: z15.string().datetime() }).strict();
|
|
1108
|
+
var PlacementAttempt = z15.object({ answer: PlacementAnswer, grade: PlacementGrade, createdAt: z15.string().datetime() }).strict();
|
|
1109
|
+
var ArtifactView = z15.discriminatedUnion("kind", [
|
|
1110
|
+
z15.object({ ...ArtifactBase, kind: z15.literal("algorithm_trace"), version: z15.literal(1), spec: AlgorithmTraceSpec }).strict(),
|
|
1111
|
+
z15.object({ ...ArtifactBase, kind: z15.literal("code_walkthrough"), version: z15.literal(1), spec: CodeWalkthroughSpec }).strict(),
|
|
1112
|
+
z15.object({ ...ArtifactBase, kind: z15.literal("graph"), version: z15.literal(1), spec: GraphSpec }).strict(),
|
|
1113
|
+
z15.object({
|
|
1114
|
+
...ArtifactBase,
|
|
1115
|
+
kind: z15.literal("interview_context"),
|
|
1116
|
+
version: z15.literal(1),
|
|
1117
|
+
spec: InterviewContextSpec,
|
|
1118
|
+
latestAttempt: InterviewContextAttempt.optional()
|
|
1119
|
+
}).strict(),
|
|
1120
|
+
z15.object({
|
|
868
1121
|
...ArtifactBase,
|
|
869
|
-
kind:
|
|
870
|
-
version:
|
|
1122
|
+
kind: z15.literal("multiple_choice"),
|
|
1123
|
+
version: z15.literal(1),
|
|
871
1124
|
spec: MultipleChoicePublic,
|
|
872
1125
|
latestAttempt: MultipleChoiceAttempt.optional()
|
|
873
1126
|
}).strict(),
|
|
874
|
-
|
|
1127
|
+
z15.object({
|
|
875
1128
|
...ArtifactBase,
|
|
876
|
-
kind:
|
|
877
|
-
version:
|
|
1129
|
+
kind: z15.literal("placement_question"),
|
|
1130
|
+
version: z15.literal(1),
|
|
878
1131
|
spec: PlacementQuestionPublic,
|
|
879
1132
|
latestAttempt: PlacementAttempt.optional()
|
|
880
1133
|
}).strict(),
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
1134
|
+
z15.object({ ...ArtifactBase, kind: z15.literal("set_diagram"), version: z15.literal(1), spec: SetDiagramSpec }).strict(),
|
|
1135
|
+
z15.object({ ...ArtifactBase, kind: z15.literal("table"), version: z15.literal(1), spec: TableSpec }).strict(),
|
|
1136
|
+
z15.object({ ...ArtifactBase, kind: z15.literal("worked_steps"), version: z15.literal(1), spec: WorkedStepsSpec }).strict()
|
|
884
1137
|
]);
|
|
885
1138
|
var CHATGPT_USAGE_LIMIT_ERROR = "ChatGPT usage limit reached. Review your plan or this app's limit in ChatGPT settings.";
|
|
886
1139
|
|
|
887
1140
|
export {
|
|
888
1141
|
AlgorithmTraceSpec,
|
|
1142
|
+
CodeWalkthroughSpec,
|
|
889
1143
|
StartCourse,
|
|
890
1144
|
PlacementQuestionSpec,
|
|
891
1145
|
toPlacementQuestionPublic,
|
|
892
1146
|
PlacementAnswer,
|
|
893
1147
|
gradePlacementQuestion,
|
|
1148
|
+
InterviewContextSpec,
|
|
1149
|
+
InterviewContextAnswer,
|
|
1150
|
+
gradeInterviewContext,
|
|
1151
|
+
CourseIcon,
|
|
894
1152
|
SyllabusInput,
|
|
895
1153
|
CourseView,
|
|
896
1154
|
GraphSpec,
|
|
@@ -914,8 +1172,12 @@ export {
|
|
|
914
1172
|
RememberInput,
|
|
915
1173
|
MemoryView,
|
|
916
1174
|
MemoryEdit,
|
|
1175
|
+
MemoryBulkDelete,
|
|
917
1176
|
MAX_DOCUMENT_BYTES,
|
|
918
1177
|
DocumentView,
|
|
1178
|
+
RecordFromNotesInput,
|
|
1179
|
+
DistillationView,
|
|
1180
|
+
ConceptGraph,
|
|
919
1181
|
MAX_VAULT_FILES,
|
|
920
1182
|
MAX_NOTE_CHARS,
|
|
921
1183
|
MAX_VAULT_BYTES,
|
|
@@ -926,8 +1188,16 @@ export {
|
|
|
926
1188
|
VaultImportResult,
|
|
927
1189
|
NoteView,
|
|
928
1190
|
NoteGraph,
|
|
1191
|
+
WHOLE_GRAPH_NOTES,
|
|
1192
|
+
MAX_GRAPH_VIEW_NOTES,
|
|
1193
|
+
MAX_GRAPH_VIEW_NODES,
|
|
1194
|
+
MAX_GRAPH_VIEW_EDGES,
|
|
1195
|
+
MAX_GRAPH_FACETS,
|
|
1196
|
+
NoteGraphViewQuery,
|
|
1197
|
+
NoteGraphView,
|
|
1198
|
+
NoteSummary,
|
|
929
1199
|
artifactKinds,
|
|
930
1200
|
ArtifactView,
|
|
931
1201
|
CHATGPT_USAGE_LIMIT_ERROR
|
|
932
1202
|
};
|
|
933
|
-
//# sourceMappingURL=chunk-
|
|
1203
|
+
//# sourceMappingURL=chunk-YACRW47X.js.map
|