@mmon-co/ncept-default-theory 3.0.18 → 3.0.20

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.
@@ -56,10 +56,6 @@ export interface FetchPageToolInput {
56
56
  readonly url: string;
57
57
  readonly op?: "read" | "download";
58
58
  }
59
- export interface ProposeToolInput {
60
- readonly op: "graph-diff" | "mission" | "revision" | "preferences" | "settings" | "mode" | "missing-capability";
61
- readonly input: CatalogArguments;
62
- }
63
59
  export interface SkillToolInput {
64
60
  readonly name: string;
65
61
  /** A relative resource filename in the named Skill, never an arbitrary filesystem path. */
@@ -73,12 +69,21 @@ export interface GraphReadOptions {
73
69
  readonly projection?: "compact" | "source";
74
70
  readonly provenance?: boolean;
75
71
  }
72
+ export type GuidanceEntryInput = {
73
+ readonly text: string;
74
+ readonly nodes?: readonly NodeId[];
75
+ readonly mode?: "replace" | "keep";
76
+ readonly from?: {
77
+ readonly tags?: readonly string[];
78
+ readonly nodes?: readonly NodeId[];
79
+ };
80
+ };
76
81
  /**
77
- * A compact graph stores every surviving origin entry once. Expanding a Node's ordered
78
- * references must equal nodeTutorGuidance(graph, node), with independent keep/replace per kind.
82
+ * A compact graph stores every surviving origin entry once, in the same shape the tutor writes.
83
+ * A Node's ordered references follow nodeTutorGuidance(graph, node), with independent cascades per kind.
79
84
  */
80
85
  export interface CompactGuidance {
81
- readonly guidance: Readonly<Record<string, TutorGuidanceEntry>>;
86
+ readonly guidance: Readonly<Record<string, GuidanceEntryInput & Pick<TutorGuidanceEntry, "kind" | "origin">>>;
82
87
  readonly effectiveGuidance: Readonly<Partial<Record<NodeId, readonly string[]>>>;
83
88
  }
84
89
  /** Modes whose evaluation is narrower than Lesson's; the rest mount every operation. Chart records self-report, and grading happens in Lessons. */
@@ -94,11 +99,14 @@ export declare const CATALOG_MODE_TITLES: {
94
99
  readonly authoring: "Author";
95
100
  readonly lesson: "Lesson";
96
101
  };
102
+ export declare const PROPOSAL_TOOL_NAMES: readonly ["propose_graph_draft", "propose_mission", "propose_mission_revision", "propose_mode", "propose_settings", "propose_preferences", "record_missing_capability"];
103
+ export declare function isProposalToolName(name: string): name is (typeof PROPOSAL_TOOL_NAMES)[number];
97
104
  export declare const CATALOG_MODE_TOOLS: {
98
- readonly empty: readonly ["query", "read", "theory", "skill", "report_friction", "propose"];
99
- readonly charting: readonly ["evaluation", "query", "read", "theory", "skill", "report_friction", "edit_graph_draft", "propose", "web_search", "fetch_page", "code", "bash", "undo"];
100
- readonly authoring: readonly ["query", "read", "theory", "skill", "report_friction", "edit_graph_draft", "propose", "web_search", "fetch_page", "code", "bash", "undo", "material"];
101
- readonly lesson: readonly ["query", "read", "theory", "skill", "report_friction", "material", "edit_graph_draft", "edit_metadata", "evaluation", "propose", "web_search", "fetch_page", "code", "bash", "undo"];
105
+ readonly empty: readonly ["query", "read", "theory", "skill", "report_friction", "propose_mode", "propose_settings", "propose_preferences"];
106
+ readonly charting: readonly ["evaluation", "query", "read", "theory", "skill", "report_friction", "edit_graph_draft", "propose_graph_draft", "propose_mission", "propose_mission_revision", "propose_mode", "propose_settings", "propose_preferences", "web_search", "fetch_page", "code", "bash", "undo"];
107
+ readonly authoring: readonly ["query", "read", "theory", "skill", "report_friction", "edit_graph_draft", "propose_graph_draft", "propose_mission", "propose_mission_revision", "propose_mode", "propose_settings", "propose_preferences", "web_search", "fetch_page", "code", "bash", "undo", "material"];
108
+ readonly lesson: readonly ["query", "read", "theory", "skill", "report_friction", "material", "edit_graph_draft", "edit_metadata", "evaluation", "propose_graph_draft", "propose_mission", "propose_mission_revision", "propose_mode", "propose_settings", "propose_preferences", "record_missing_capability", "web_search", "fetch_page", "code", "bash", "undo"];
102
109
  };
110
+ export declare function catalogRootNames(mode: string | undefined): readonly string[] | undefined;
103
111
  /** The keys each mode's edit_metadata may write; the tool is mounted only where a list exists. */
104
112
  export declare const CATALOG_MODE_METADATA_KEYS: Readonly<Partial<Record<keyof typeof CATALOG_MODE_TOOLS, readonly string[]>>>;
@@ -20,8 +20,19 @@ export const CATALOG_MODE_TITLES = {
20
20
  authoring: "Author",
21
21
  lesson: "Lesson",
22
22
  };
23
+ const CHAT_PROPOSAL_TOOLS = ["propose_mode", "propose_settings", "propose_preferences"];
24
+ const GRAPH_PROPOSAL_TOOLS = [
25
+ "propose_graph_draft",
26
+ "propose_mission",
27
+ "propose_mission_revision",
28
+ ...CHAT_PROPOSAL_TOOLS,
29
+ ];
30
+ export const PROPOSAL_TOOL_NAMES = [...GRAPH_PROPOSAL_TOOLS, "record_missing_capability"];
31
+ export function isProposalToolName(name) {
32
+ return PROPOSAL_TOOL_NAMES.some((tool) => tool === name);
33
+ }
23
34
  export const CATALOG_MODE_TOOLS = {
24
- empty: ["query", "read", "theory", "skill", "report_friction", "propose"],
35
+ empty: ["query", "read", "theory", "skill", "report_friction", ...CHAT_PROPOSAL_TOOLS],
25
36
  charting: [
26
37
  "evaluation",
27
38
  "query",
@@ -30,7 +41,7 @@ export const CATALOG_MODE_TOOLS = {
30
41
  "skill",
31
42
  "report_friction",
32
43
  "edit_graph_draft",
33
- "propose",
44
+ ...GRAPH_PROPOSAL_TOOLS,
34
45
  "web_search",
35
46
  "fetch_page",
36
47
  "code",
@@ -45,7 +56,7 @@ export const CATALOG_MODE_TOOLS = {
45
56
  "skill",
46
57
  "report_friction",
47
58
  "edit_graph_draft",
48
- "propose",
59
+ ...GRAPH_PROPOSAL_TOOLS,
49
60
  "web_search",
50
61
  "fetch_page",
51
62
  "code",
@@ -63,7 +74,7 @@ export const CATALOG_MODE_TOOLS = {
63
74
  "edit_graph_draft",
64
75
  "edit_metadata",
65
76
  "evaluation",
66
- "propose",
77
+ ...PROPOSAL_TOOL_NAMES,
67
78
  "web_search",
68
79
  "fetch_page",
69
80
  "code",
@@ -71,6 +82,9 @@ export const CATALOG_MODE_TOOLS = {
71
82
  "undo",
72
83
  ],
73
84
  };
85
+ export function catalogRootNames(mode) {
86
+ return Object.entries(CATALOG_MODE_TOOLS).find(([name]) => name === mode)?.[1];
87
+ }
74
88
  /** The keys each mode's edit_metadata may write; the tool is mounted only where a list exists. */
75
89
  export const CATALOG_MODE_METADATA_KEYS = {
76
90
  lesson: ["pedagogy:completion"],
package/dist/chat.d.ts CHANGED
@@ -75,9 +75,128 @@ export declare const modes: {
75
75
  }[];
76
76
  entry: {
77
77
  required: false;
78
- kinds: ("mission" | "checkpoint" | "target" | "goal")[];
78
+ kinds: ("checkpoint" | "target" | "mission" | "goal")[];
79
79
  };
80
80
  capabilities: readonly HostCapability[];
81
+ graphDraftBatch: {
82
+ properties: {
83
+ nodes: {
84
+ type: "array";
85
+ items: {
86
+ type: "object";
87
+ properties: {
88
+ id: {
89
+ description: string;
90
+ type: "string";
91
+ };
92
+ label: {
93
+ type: "string";
94
+ };
95
+ criterion: {
96
+ type: "string";
97
+ };
98
+ priority: {
99
+ type: "number";
100
+ description: string;
101
+ };
102
+ milestone: {
103
+ type: "boolean";
104
+ };
105
+ elaborate: {
106
+ type: "boolean";
107
+ };
108
+ review: {
109
+ type: "object";
110
+ properties: {
111
+ kind: {
112
+ enum: string[];
113
+ type: "string";
114
+ };
115
+ days: {
116
+ type: "number";
117
+ exclusiveMinimum: number;
118
+ description: string;
119
+ };
120
+ };
121
+ required: ("kind" | "days")[];
122
+ additionalProperties: false;
123
+ };
124
+ };
125
+ required: ("review" | "id" | "label" | "milestone" | "priority" | "criterion" | "elaborate")[];
126
+ additionalProperties: false;
127
+ };
128
+ };
129
+ edges: {
130
+ type: "array";
131
+ items: {
132
+ type: "object";
133
+ properties: {
134
+ from: {
135
+ description: string;
136
+ type: "string";
137
+ };
138
+ to: {
139
+ description: string;
140
+ type: "string";
141
+ };
142
+ id: {
143
+ description: string;
144
+ type: "string";
145
+ };
146
+ because: {
147
+ type: "string";
148
+ };
149
+ };
150
+ required: ("id" | "to" | "from" | "because")[];
151
+ additionalProperties: false;
152
+ };
153
+ };
154
+ tags: {
155
+ type: "array";
156
+ items: {
157
+ type: "object";
158
+ properties: {
159
+ name: {
160
+ description: string;
161
+ type: "string";
162
+ };
163
+ nodes: {
164
+ type: "array";
165
+ items: {
166
+ description: string;
167
+ type: "string";
168
+ };
169
+ };
170
+ edges: {
171
+ type: "array";
172
+ items: {
173
+ description: string;
174
+ type: "string";
175
+ };
176
+ };
177
+ priority: {
178
+ type: "number";
179
+ description: string;
180
+ };
181
+ };
182
+ required: ("nodes" | "name" | "edges" | "priority")[];
183
+ additionalProperties: false;
184
+ };
185
+ };
186
+ targets: {
187
+ description: string;
188
+ type: "array";
189
+ items: {
190
+ description: string;
191
+ type: "string";
192
+ };
193
+ };
194
+ };
195
+ compile(input: Readonly<Record<string, unknown>>, graph: Pick<import("@mmon-co/ncept-core/patch").ResolvedGraph, "nodes" | "edges">, previous: readonly import("@mmon-co/ncept-core/patch").SemanticOperation[]): {
196
+ targets?: `node-${string}`[] | undefined;
197
+ operations: import("@mmon-co/ncept-core/patch").SemanticOperation[];
198
+ };
199
+ };
81
200
  switches: {
82
201
  mode: string;
83
202
  then: "next";
@@ -111,6 +230,125 @@ export declare const modes: {
111
230
  kinds: ("mission" | "goal")[];
112
231
  };
113
232
  capabilities: readonly HostCapability[];
233
+ graphDraftBatch: {
234
+ properties: {
235
+ nodes: {
236
+ type: "array";
237
+ items: {
238
+ type: "object";
239
+ properties: {
240
+ id: {
241
+ description: string;
242
+ type: "string";
243
+ };
244
+ label: {
245
+ type: "string";
246
+ };
247
+ criterion: {
248
+ type: "string";
249
+ };
250
+ priority: {
251
+ type: "number";
252
+ description: string;
253
+ };
254
+ milestone: {
255
+ type: "boolean";
256
+ };
257
+ elaborate: {
258
+ type: "boolean";
259
+ };
260
+ review: {
261
+ type: "object";
262
+ properties: {
263
+ kind: {
264
+ enum: string[];
265
+ type: "string";
266
+ };
267
+ days: {
268
+ type: "number";
269
+ exclusiveMinimum: number;
270
+ description: string;
271
+ };
272
+ };
273
+ required: ("kind" | "days")[];
274
+ additionalProperties: false;
275
+ };
276
+ };
277
+ required: ("review" | "id" | "label" | "milestone" | "priority" | "criterion" | "elaborate")[];
278
+ additionalProperties: false;
279
+ };
280
+ };
281
+ edges: {
282
+ type: "array";
283
+ items: {
284
+ type: "object";
285
+ properties: {
286
+ from: {
287
+ description: string;
288
+ type: "string";
289
+ };
290
+ to: {
291
+ description: string;
292
+ type: "string";
293
+ };
294
+ id: {
295
+ description: string;
296
+ type: "string";
297
+ };
298
+ because: {
299
+ type: "string";
300
+ };
301
+ };
302
+ required: ("id" | "to" | "from" | "because")[];
303
+ additionalProperties: false;
304
+ };
305
+ };
306
+ tags: {
307
+ type: "array";
308
+ items: {
309
+ type: "object";
310
+ properties: {
311
+ name: {
312
+ description: string;
313
+ type: "string";
314
+ };
315
+ nodes: {
316
+ type: "array";
317
+ items: {
318
+ description: string;
319
+ type: "string";
320
+ };
321
+ };
322
+ edges: {
323
+ type: "array";
324
+ items: {
325
+ description: string;
326
+ type: "string";
327
+ };
328
+ };
329
+ priority: {
330
+ type: "number";
331
+ description: string;
332
+ };
333
+ };
334
+ required: ("nodes" | "name" | "edges" | "priority")[];
335
+ additionalProperties: false;
336
+ };
337
+ };
338
+ targets: {
339
+ description: string;
340
+ type: "array";
341
+ items: {
342
+ description: string;
343
+ type: "string";
344
+ };
345
+ };
346
+ };
347
+ compile(input: Readonly<Record<string, unknown>>, graph: Pick<import("@mmon-co/ncept-core/patch").ResolvedGraph, "nodes" | "edges">, previous: readonly import("@mmon-co/ncept-core/patch").SemanticOperation[]): {
348
+ targets?: `node-${string}`[] | undefined;
349
+ operations: import("@mmon-co/ncept-core/patch").SemanticOperation[];
350
+ };
351
+ };
114
352
  switches: never[];
115
353
  setup: (ctx: ChatContext<DefaultState>) => Program<Readonly<{
116
354
  prompt: string;
@@ -135,9 +373,128 @@ export declare const modes: {
135
373
  frontTab: string;
136
374
  entry: {
137
375
  required: true;
138
- kinds: ("lesson" | "review")[];
376
+ kinds: ("review" | "target" | "mission")[];
139
377
  };
140
378
  capabilities: readonly HostCapability[];
379
+ graphDraftBatch: {
380
+ properties: {
381
+ nodes: {
382
+ type: "array";
383
+ items: {
384
+ type: "object";
385
+ properties: {
386
+ id: {
387
+ description: string;
388
+ type: "string";
389
+ };
390
+ label: {
391
+ type: "string";
392
+ };
393
+ criterion: {
394
+ type: "string";
395
+ };
396
+ priority: {
397
+ type: "number";
398
+ description: string;
399
+ };
400
+ milestone: {
401
+ type: "boolean";
402
+ };
403
+ elaborate: {
404
+ type: "boolean";
405
+ };
406
+ review: {
407
+ type: "object";
408
+ properties: {
409
+ kind: {
410
+ enum: string[];
411
+ type: "string";
412
+ };
413
+ days: {
414
+ type: "number";
415
+ exclusiveMinimum: number;
416
+ description: string;
417
+ };
418
+ };
419
+ required: ("kind" | "days")[];
420
+ additionalProperties: false;
421
+ };
422
+ };
423
+ required: ("review" | "id" | "label" | "milestone" | "priority" | "criterion" | "elaborate")[];
424
+ additionalProperties: false;
425
+ };
426
+ };
427
+ edges: {
428
+ type: "array";
429
+ items: {
430
+ type: "object";
431
+ properties: {
432
+ from: {
433
+ description: string;
434
+ type: "string";
435
+ };
436
+ to: {
437
+ description: string;
438
+ type: "string";
439
+ };
440
+ id: {
441
+ description: string;
442
+ type: "string";
443
+ };
444
+ because: {
445
+ type: "string";
446
+ };
447
+ };
448
+ required: ("id" | "to" | "from" | "because")[];
449
+ additionalProperties: false;
450
+ };
451
+ };
452
+ tags: {
453
+ type: "array";
454
+ items: {
455
+ type: "object";
456
+ properties: {
457
+ name: {
458
+ description: string;
459
+ type: "string";
460
+ };
461
+ nodes: {
462
+ type: "array";
463
+ items: {
464
+ description: string;
465
+ type: "string";
466
+ };
467
+ };
468
+ edges: {
469
+ type: "array";
470
+ items: {
471
+ description: string;
472
+ type: "string";
473
+ };
474
+ };
475
+ priority: {
476
+ type: "number";
477
+ description: string;
478
+ };
479
+ };
480
+ required: ("nodes" | "name" | "edges" | "priority")[];
481
+ additionalProperties: false;
482
+ };
483
+ };
484
+ targets: {
485
+ description: string;
486
+ type: "array";
487
+ items: {
488
+ description: string;
489
+ type: "string";
490
+ };
491
+ };
492
+ };
493
+ compile(input: Readonly<Record<string, unknown>>, graph: Pick<import("@mmon-co/ncept-core/patch").ResolvedGraph, "nodes" | "edges">, previous: readonly import("@mmon-co/ncept-core/patch").SemanticOperation[]): {
494
+ targets?: `node-${string}`[] | undefined;
495
+ operations: import("@mmon-co/ncept-core/patch").SemanticOperation[];
496
+ };
497
+ };
141
498
  metadataKeys: readonly string[] | undefined;
142
499
  switches: ({
143
500
  mode: string;
package/dist/chat.js CHANGED
@@ -8,6 +8,7 @@ import { catalogToolsForMode } from "./catalog.js";
8
8
  import { evaluationContext, evaluateWatchedReply } from "./evaluation.js";
9
9
  import { lessonOpening, openingLanguage } from "./opening.js";
10
10
  import { nodeReviewSchedule } from "./path.js";
11
+ import { graphDraftBatch } from "./graph-draft-batch.js";
11
12
  const COMMON_CONCEPT_PATCH_PROPERTY = "app:common-concept";
12
13
  const RAISE_WHEN_PROPERTY = "pedagogy:raise-when";
13
14
  const DOCS_URL_PROPERTY = "app:docs-url";
@@ -132,11 +133,10 @@ function scopedMemory(ctx) {
132
133
  function tutorOpening(ctx) {
133
134
  if (!ctx.opening)
134
135
  return undefined;
135
- const entry = ctx.entry;
136
- const nodes = entry?.kind === "lesson" ? entry.lesson.nodes : [];
137
- const lesson = entry?.kind === "lesson"
138
- ? lessonOpening(ctx.graph, nodes, ctx.missions?.find(({ id }) => id === entry.lesson.mission.id))
139
- : undefined;
136
+ const here = ctx.lesson?.here;
137
+ const nodes = here?.nodes ?? [];
138
+ const lesson = here &&
139
+ lessonOpening(ctx.graph, nodes, ctx.missions?.find(({ id }) => id === here.mission.id));
140
140
  return [
141
141
  "Initial tutor-led turn (host context, not learner speech). " +
142
142
  (lesson?.instruction ?? "Begin this Session in its selected mode."),
@@ -158,6 +158,7 @@ function* setup(ctx, mode) {
158
158
  for (const node of ctx.about)
159
159
  if (!ctx.graph.nodes.some(({ id }) => id === node))
160
160
  throw new Error(`Missing Node ${node}`);
161
+ const { here, ...progress } = ctx.lesson ?? {};
161
162
  const prompt = tutorSystemPrompt(mode);
162
163
  const { documents, candidates } = documentListing(ctx);
163
164
  const offered = linkedDocuments(ctx, documents, ctx.tutorMessages ?? []);
@@ -189,12 +190,13 @@ function* setup(ctx, mode) {
189
190
  })}`,
190
191
  ]
191
192
  : []),
192
- ...(ctx.lesson === undefined
193
+ ...(here === undefined
193
194
  ? []
194
195
  : [
195
- `Current Lesson progress (fixed checklist; current theory reading):\n${JSON.stringify({
196
- ...ctx.lesson,
197
- completion: ctx.lesson.lesson.nodes.map((node) => ({
196
+ `Current Lesson progress (current theory reading):\n${JSON.stringify({
197
+ lesson: here,
198
+ ...progress,
199
+ completion: here.nodes.map((node) => ({
198
200
  node,
199
201
  query: ctx.state.nodes[node]?.completion.query ?? "no completion set",
200
202
  counts: ctx.state.nodes[node]?.completion.counts ?? [],
@@ -249,6 +251,7 @@ export const modes = {
249
251
  ],
250
252
  entry: { required: false, kinds: ["goal", "mission", "target", "checkpoint"] },
251
253
  capabilities: catalogCapabilities("charting"),
254
+ graphDraftBatch,
252
255
  switches: [{ mode: "lesson", then: "next", carry: { kind: "brief" } }],
253
256
  setup: (ctx) => setup(ctx, "charting"),
254
257
  },
@@ -257,14 +260,16 @@ export const modes = {
257
260
  frontTab: "map",
258
261
  entry: { required: false, kinds: ["goal", "mission"] },
259
262
  capabilities: catalogCapabilities("authoring"),
263
+ graphDraftBatch,
260
264
  switches: [],
261
265
  setup: (ctx) => setup(ctx, "authoring"),
262
266
  },
263
267
  lesson: {
264
268
  title: CATALOG_MODE_TITLES.lesson,
265
269
  frontTab: "document",
266
- entry: { required: true, kinds: ["lesson", "review"] },
270
+ entry: { required: true, kinds: ["mission", "target", "review"] },
267
271
  capabilities: catalogCapabilities("lesson"),
272
+ graphDraftBatch,
268
273
  metadataKeys: CATALOG_MODE_METADATA_KEYS.lesson,
269
274
  switches: [
270
275
  { mode: "lesson", then: "next", carry: { kind: "brief" } },