@thanh01.pmt/curriculum-kit 1.0.22 → 1.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/dist/index.mjs CHANGED
@@ -74,6 +74,8 @@ function getSuggestedActionForCode(code) {
74
74
  return "N\u1ED9i dung sinh ra thi\u1EBFu c\xE1c ph\u1EA7n b\u1EAFt bu\u1ED9c [REQUIRED]. H\xE3y k\xEDch ho\u1EA1t ki\u1EC3m th\u1EED ho\u1EB7c b\u1EA5m Rerun.";
75
75
  case "ERR_STORAGE_IO_FAILED":
76
76
  return "L\u1ED7i \u0111\u1ECDc/ghi t\u1EC7p tin tr\xEAn h\u1EC7 th\u1ED1ng l\u01B0u tr\u1EEF. Ki\u1EC3m tra quy\u1EC1n ghi th\u01B0 m\u1EE5c output/projects.";
77
+ case "ERR_CONTEXT_MISSING":
78
+ return "Thi\u1EBFu ngu\u1ED3n tri th\u1EE9c b\u1EAFt bu\u1ED9c (KNOWLEDGE_EXPOSITION ho\u1EB7c CANONICAL LESSON) theo Dependency Routing Matrix. Vui l\xF2ng t\u1EA1o ho\u1EB7c \u0111\u1ED3ng b\u1ED9 t\xE0i li\u1EC7u ngu\u1ED3n tr\u01B0\u1EDBc.";
77
79
  default:
78
80
  return "B\u1EA5m Rerun \u0111\u1EC3 th\u1EED l\u1EA1i ho\u1EB7c ki\u1EC3m tra nh\u1EADt k\xFD h\u1EC7 th\u1ED1ng.";
79
81
  }
@@ -91,11 +93,23 @@ function isCodeRetryable(code) {
91
93
  case "ERR_TASK_GATE_BLOCKED":
92
94
  case "ERR_METERED_LIMIT_EXCEEDED":
93
95
  case "ERR_SCHEMA_CONTRACT_VIOLATION":
96
+ case "ERR_CONTEXT_MISSING":
94
97
  return false;
95
98
  default:
96
99
  return true;
97
100
  }
98
101
  }
102
+ function createContextMissingError(params) {
103
+ return new CurriculumError({
104
+ errorCode: "ERR_CONTEXT_MISSING",
105
+ artifactType: params.artifactType,
106
+ lessonId: params.lessonId,
107
+ agent: params.agent,
108
+ message: `Required context source "${params.missingSource}" is missing for artifact "${params.artifactType}"`,
109
+ suggestedAction: `Generate or provide the authoritative "${params.missingSource}" source before producing "${params.artifactType}".`,
110
+ retryable: false
111
+ });
112
+ }
99
113
  var CurriculumError;
100
114
  var init_errors = __esm({
101
115
  "src/errors/index.ts"() {
@@ -2421,9 +2435,20 @@ var SessionPlanSchema = z.object({
2421
2435
  differentiation: z.object({ bronze: z.string(), silver: z.string(), gold: z.string() })
2422
2436
  });
2423
2437
  var TranslationPolicySchema = z.object({
2424
- policy: z.enum(["after_artifact", "end_of_unit", "at_publish"]).default("at_publish"),
2438
+ policy: z.enum(["after_artifact", "end_of_unit", "at_publish", "native"]).default("native"),
2425
2439
  target_language: z.string().nullable().default(null)
2426
- });
2440
+ }).refine(
2441
+ (data) => {
2442
+ if (data.policy === "native") {
2443
+ return typeof data.target_language === "string" && data.target_language.trim().length > 0;
2444
+ }
2445
+ return true;
2446
+ },
2447
+ {
2448
+ message: "When translation policy is 'native', target_language must be a non-empty string",
2449
+ path: ["target_language"]
2450
+ }
2451
+ );
2427
2452
  var CoverageReportSchema = z.object({
2428
2453
  assigned_node_ids: z.array(z.string()),
2429
2454
  unassigned_node_ids: z.array(z.string()),
@@ -5357,6 +5382,45 @@ Return a single valid JSON object matching SlideDeckSchema with these exact keys
5357
5382
  }
5358
5383
  `.trim();
5359
5384
  }
5385
+ var SLIDE_CANONICAL_METHODOLOGY = `
5386
+ MANDATORY 12-14 SLIDE MICRO-CYCLE STRUCTURE (Delimited by '---'):
5387
+ 1. **Slide 1 [Title & Mission]:** Real-world inquiry hook and overarching build mission
5388
+ 2. **Slide 2 [Agenda & Roadmap]:** Timing and milestone breakdown table
5389
+ 3. **Slide 3 [Warm-Up / Prior Knowledge]:** 2-column recall + 60-second diagnostic challenge card
5390
+ 4. **Slide 4 [High-Stakes Hook Scenario]:** Authentic engineering/domain crisis card + dilemma constraint
5391
+ 5. **Slide 5 [Core Concept 1: Mental Model]:** Definition, intuitive everyday analogy, and golden rule card
5392
+ 6. **Slide 6 [Architecture & Visual Flow]:** Clean Mermaid diagram (flowchart or sequenceDiagram) + 3 flow steps
5393
+ 7. **Slide 7 [Core Concept 2: Syntax / Mechanism Anatomy]:** Side-by-side runnable code + anatomy breakdown & syntax trap card
5394
+ 8. **Slide 8 [Guided Practice: Try It Now]:** 3-minute active desk task card with starter hint and success criteria
5395
+ 9. **Slide 9 [Integrated Hands-On Lab]:** 3-tier differentiated challenge cards (Bronze / Silver / Gold) + gotcha alert card
5396
+ 10. **Slide 10 [Traffic Light Checkpoint & Pitfalls]:** Formative self-check cards (\u{1F7E2}/\u{1F7E1}/\u{1F534}) & diagnostic test question
5397
+ 11. **Slide 11 [Exit Ticket & Metacognition]:** 2 scenario-based check questions + 1 metacognitive reflection prompt
5398
+ 12. **Slide 12 [Summary & Next Steps]:** 3 core golden rules + preview card of next upcoming milestone
5399
+
5400
+ Mandatory Canvas & Presentation Invariants:
5401
+ - A slide is an INTERACTIVE PROJECTION CANVAS, NOT a textbook! Absolutely NO dense paragraphs or walls of text.
5402
+ - Follow the 6x6 rule: Maximum 4-6 bullet points per slide, maximum 8-12 words per bullet.
5403
+ - Structure slides using \`<div class="columns"><div>...</div><div>...</div></div>\` and \`<div class="card">\`, \`<div class="card highlight">\`, \`<div class="card warning">\`, \`<div class="card success">\`.
5404
+ - MANDATORY PRESENTER NOTES ON EVERY SLIDE: Every slide MUST end with \`<!-- Presenter Notes: ... -->\` containing:
5405
+ * SCRIPT: 60-90s teacher talk track with intuitive analogies.
5406
+ * COLD CALL / CHECK: Specific diagnostic question to ask students.
5407
+ * SCAFFOLDING / GOTCHA: Guidance for students who get stuck.
5408
+ * PACING: Recommended minutes for the slide.
5409
+ - Output 100% valid Marp Markdown.
5410
+ `.trim();
5411
+ function buildMarpMarkdownSlidePrompt(input) {
5412
+ return `You are @illustrator & @content (Pedagogical Slide Deck Presentation Specialists).
5413
+ Based on Master Lesson Plan \`LESSON_${input.lessonCode}.md\`, lesson context, and the MARP SLIDE TEMPLATE below, author the complete, highly engaging Marp presentation deck: \`SLIDE_${input.lessonCode}.md\`.
5414
+
5415
+ [MARP SLIDE TEMPLATE SCAFFOLD]:
5416
+ ${input.templateScaffold}
5417
+
5418
+ ${SLIDE_CANONICAL_METHODOLOGY}
5419
+
5420
+ ${input.languageDirective}
5421
+
5422
+ ${input.headingDirective}`.trim();
5423
+ }
5360
5424
 
5361
5425
  // src/ai/prompts/teacherGuidePrompt.ts
5362
5426
  function buildTeacherGuidePrompt(input) {
@@ -9689,6 +9753,224 @@ function resolveGateSettings(raw) {
9689
9753
  function gateModeFor(resolved, type) {
9690
9754
  return resolved[type] ?? "OFF";
9691
9755
  }
9756
+
9757
+ // src/services/contextBuilder.ts
9758
+ var DEFAULT_LESSON_PRIORITIES = [
9759
+ "A. Lesson Design Plan",
9760
+ "B. Lesson Flow",
9761
+ "Learning Objectives & Evidence",
9762
+ "Activity Sequence"
9763
+ ];
9764
+ var DEFAULT_KX_PRIORITIES = [
9765
+ "Key Terms",
9766
+ "Concept Narratives",
9767
+ "Worked Micro-Examples"
9768
+ ];
9769
+ function buildSectionAwareExcerpt(markdown, opts = {}) {
9770
+ const budget = opts.budget ?? 12e3;
9771
+ const minContentChars = opts.minContentChars ?? 400;
9772
+ const issues = [];
9773
+ const source = (markdown || "").trim();
9774
+ if (!source) {
9775
+ return {
9776
+ excerpt: "",
9777
+ verified: false,
9778
+ sectionAware: false,
9779
+ includedSections: [],
9780
+ issues: ["empty-source"],
9781
+ tokenEstimate: 0
9782
+ };
9783
+ }
9784
+ const slcMap = normalizeSlcContract(opts.sectionLanguageContract);
9785
+ const sections = parseMarkdownSections(source, slcMap, opts.artifactType);
9786
+ if (sections.length === 0) {
9787
+ issues.push("parse:no-sections");
9788
+ const excerpt2 = truncateByBudget(source, budget);
9789
+ const verified2 = excerpt2.length >= minContentChars;
9790
+ if (excerpt2.length < minContentChars) issues.push("content:insufficient");
9791
+ return {
9792
+ excerpt: excerpt2,
9793
+ verified: verified2,
9794
+ sectionAware: false,
9795
+ includedSections: [],
9796
+ issues,
9797
+ tokenEstimate: Math.round(excerpt2.length / 4)
9798
+ };
9799
+ }
9800
+ const byCanonical = /* @__PURE__ */ new Map();
9801
+ const unmatched = [];
9802
+ for (const s of sections) {
9803
+ if (s.canonicalKey && !byCanonical.has(s.canonicalKey)) {
9804
+ byCanonical.set(s.canonicalKey, s);
9805
+ } else {
9806
+ unmatched.push(s);
9807
+ }
9808
+ }
9809
+ const priorities = opts.priorities ?? DEFAULT_LESSON_PRIORITIES;
9810
+ const includedSections = [];
9811
+ const blocks = [];
9812
+ let used = 0;
9813
+ const tryAdd = (heading, body, key) => {
9814
+ const trimmedBody = body.trim();
9815
+ if (!trimmedBody) return false;
9816
+ const block = `## ${heading}
9817
+
9818
+ ${trimmedBody}`;
9819
+ if (used + block.length > budget && blocks.length > 0) return false;
9820
+ blocks.push(block);
9821
+ used += block.length;
9822
+ includedSections.push(key);
9823
+ return true;
9824
+ };
9825
+ let sectionAware = false;
9826
+ for (const key of priorities) {
9827
+ const sec = byCanonical.get(key);
9828
+ if (!sec) continue;
9829
+ sectionAware = true;
9830
+ if (!tryAdd(sec.cleanTitle, sec.body, key)) break;
9831
+ }
9832
+ for (const [key, sec] of byCanonical) {
9833
+ if (includedSections.includes(key)) continue;
9834
+ if (used >= budget) break;
9835
+ if (!tryAdd(sec.cleanTitle, sec.body, key)) break;
9836
+ }
9837
+ for (const sec of unmatched) {
9838
+ if (used >= budget) break;
9839
+ if (!tryAdd(sec.cleanTitle, sec.body, sec.cleanTitle)) break;
9840
+ }
9841
+ if (priorities.length > 0 && !priorities.some((k) => includedSections.includes(k))) {
9842
+ issues.push("parse:no-priority-resolution");
9843
+ }
9844
+ let excerpt = blocks.join("\n\n");
9845
+ if (excerpt.length > budget) {
9846
+ excerpt = truncateByBudget(excerpt, budget);
9847
+ }
9848
+ const effectiveMinChars = Math.min(minContentChars, source.length);
9849
+ if (excerpt.length < effectiveMinChars) {
9850
+ issues.push("content:insufficient");
9851
+ }
9852
+ const verified = !issues.includes("parse:no-priority-resolution") && excerpt.length >= effectiveMinChars;
9853
+ return {
9854
+ excerpt,
9855
+ verified,
9856
+ sectionAware: sectionAware || priorities.length === 0 && sections.length > 0,
9857
+ includedSections,
9858
+ issues,
9859
+ tokenEstimate: Math.round(excerpt.length / 4)
9860
+ };
9861
+ }
9862
+ function buildExpositionExcerpt(markdown, opts = {}) {
9863
+ return buildSectionAwareExcerpt(markdown, {
9864
+ ...opts,
9865
+ priorities: DEFAULT_KX_PRIORITIES
9866
+ });
9867
+ }
9868
+ function buildLessonExcerpt(markdown, opts = {}) {
9869
+ return buildSectionAwareExcerpt(markdown, {
9870
+ ...opts,
9871
+ priorities: DEFAULT_LESSON_PRIORITIES
9872
+ });
9873
+ }
9874
+ function normalizeSlcContract(slc) {
9875
+ if (!slc) return void 0;
9876
+ if (typeof slc !== "string") return slc;
9877
+ const out = {};
9878
+ const blocks = slc.split(/\n(?=#{2,3}\s+[A-Z0-9_]+)/g);
9879
+ for (const block of blocks) {
9880
+ const header = block.match(/^#{2,3}\s+([A-Z0-9_]+)/);
9881
+ if (!header?.[1]) continue;
9882
+ const mapping = {};
9883
+ for (const line of block.split("\n")) {
9884
+ const t = line.trim();
9885
+ if (!t.startsWith("|") || t.includes("---")) continue;
9886
+ const cells = t.split("|").map((c) => c.trim()).filter((_, i, a) => i > 0 && i < a.length - 1);
9887
+ const [c0, c1] = cells;
9888
+ if (c0 && c1 && !c0.toLowerCase().includes("canonical") && !c1.toLowerCase().includes("localized")) {
9889
+ mapping[c0] = c1;
9890
+ }
9891
+ }
9892
+ if (Object.keys(mapping).length > 0) out[header[1]] = mapping;
9893
+ }
9894
+ return Object.keys(out).length > 0 ? out : void 0;
9895
+ }
9896
+ function parseMarkdownSections(markdown, slcMap, artifactType) {
9897
+ const sections = [];
9898
+ const lines = markdown.split("\n");
9899
+ let currentHeading = "";
9900
+ let currentBody = [];
9901
+ const reverseMap = /* @__PURE__ */ new Map();
9902
+ if (slcMap) {
9903
+ const maps = artifactType && slcMap[artifactType] ? [slcMap[artifactType]] : Object.values(slcMap);
9904
+ for (const m of maps) {
9905
+ for (const [canonical, localized] of Object.entries(m)) {
9906
+ reverseMap.set(normalizeHeading(localized), canonical);
9907
+ reverseMap.set(normalizeHeading(canonical), canonical);
9908
+ }
9909
+ }
9910
+ }
9911
+ const flush = () => {
9912
+ if (!currentHeading && currentBody.length === 0) return;
9913
+ const cleanTitle = currentHeading.replace(/^#{1,4}\s+/, "").trim();
9914
+ const norm = normalizeHeading(cleanTitle);
9915
+ const canonicalKey = reverseMap.get(norm) || findCanonicalFuzzy(norm);
9916
+ sections.push({
9917
+ rawHeading: currentHeading,
9918
+ cleanTitle,
9919
+ canonicalKey,
9920
+ body: currentBody.join("\n")
9921
+ });
9922
+ currentBody = [];
9923
+ };
9924
+ const hasH2 = lines.some((l) => /^##\s+/.test(l));
9925
+ const headingRegex = hasH2 ? /^##\s+(.*)$/ : /^#{2,3}\s+(.*)$/;
9926
+ for (const line of lines) {
9927
+ const headingMatch = line.match(headingRegex);
9928
+ if (headingMatch) {
9929
+ flush();
9930
+ currentHeading = line.trim();
9931
+ } else {
9932
+ currentBody.push(line);
9933
+ }
9934
+ }
9935
+ flush();
9936
+ return sections;
9937
+ }
9938
+ function normalizeHeading(str) {
9939
+ return str.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\w\s]/g, " ").replace(/\s+/g, " ").trim();
9940
+ }
9941
+ function findCanonicalFuzzy(norm) {
9942
+ if (norm.includes("lesson design plan") || norm.includes("ke hoach thiet ke")) {
9943
+ return "A. Lesson Design Plan";
9944
+ }
9945
+ if (norm.includes("lesson flow") || norm.includes("tien trinh giang day")) {
9946
+ return "B. Lesson Flow";
9947
+ }
9948
+ if (norm.includes("learning objective") || norm.includes("muc tieu bai hoc")) {
9949
+ return "Learning Objectives & Evidence";
9950
+ }
9951
+ if (norm.includes("activity sequence") || norm.includes("chuoi hoat dong")) {
9952
+ return "Activity Sequence";
9953
+ }
9954
+ if (norm.includes("key term") || norm.includes("thuat ngu")) {
9955
+ return "Key Terms";
9956
+ }
9957
+ if (norm.includes("concept narrative") || norm.includes("dien giai khai niem")) {
9958
+ return "Concept Narratives";
9959
+ }
9960
+ if (norm.includes("worked example") || norm.includes("vi du")) {
9961
+ return "Worked Micro-Examples";
9962
+ }
9963
+ return void 0;
9964
+ }
9965
+ function truncateByBudget(source, budget) {
9966
+ if (source.length <= budget) return source;
9967
+ let cut = source.slice(0, budget);
9968
+ const fenceCount = (cut.match(/^```/gm) || []).length;
9969
+ if (fenceCount % 2 === 1) cut += "\n```";
9970
+ return cut;
9971
+ }
9972
+
9973
+ // src/services/knowledgeExpositionService.ts
9692
9974
  var EXPOSITION_REL = (lessonCode) => "_sot/expositions/" + lessonCode + ".md";
9693
9975
  var ExpositionApprovalError = class extends Error {
9694
9976
  constructor(message) {
@@ -9795,15 +10077,8 @@ async function ensureKnowledgeExposition(options) {
9795
10077
  return { relPath: EXPOSITION_REL(lessonCode), content: stamped, reused: false, gateMode: gateModeFor(options.gates ?? {}, "KNOWLEDGE_EXPOSITION") };
9796
10078
  }
9797
10079
  function buildExpositionContext(expositionContent, maxChars = 6e3) {
9798
- const trimmed = expositionContent.trim();
9799
- if (trimmed.length <= maxChars) return trimmed;
9800
- const sections = trimmed.split(/\n(?=## )/);
9801
- let out = sections[0];
9802
- for (let i = 1; i < sections.length && out.length < maxChars; i++) {
9803
- const s = sections[i];
9804
- out += "\n" + s.slice(0, Math.max(400, maxChars - out.length));
9805
- }
9806
- return out.slice(0, maxChars);
10080
+ if (!expositionContent || !expositionContent.trim()) return "";
10081
+ return buildExpositionExcerpt(expositionContent, { budget: maxChars }).excerpt;
9807
10082
  }
9808
10083
  function expositionCacheKey(planHash, lessonCode) {
9809
10084
  return createHash("sha256").update(planHash + "|" + lessonCode).digest("hex").slice(0, 16);
@@ -9844,6 +10119,7 @@ async function ensureExpositionForLesson(storage, projectId, lessonCode, options
9844
10119
  });
9845
10120
  return { relPath: result.relPath, context: buildExpositionContext(result.content), reused: result.reused };
9846
10121
  }
10122
+ init_errors();
9847
10123
  var asArr = (v) => Array.isArray(v) ? v : [];
9848
10124
  var asStr = (v, dflt = "") => typeof v === "string" ? v : dflt;
9849
10125
  var asNum = (v, dflt) => typeof v === "number" && Number.isFinite(v) ? v : dflt;
@@ -10486,7 +10762,15 @@ function extractSessionSlice(plan, lessonCode) {
10486
10762
  }
10487
10763
  function buildSessionSliceContext(plan, lessonCode) {
10488
10764
  const s = plan.sessions.find((x) => x.id === lessonCode);
10489
- if (!s) return "";
10765
+ if (!s) {
10766
+ throw new CurriculumError({
10767
+ errorCode: "ERR_LESSON_NOT_IN_SOT",
10768
+ message: `Session "${lessonCode}" not found in CURRICULUM_PLAN.json (${plan.plan_hash})`,
10769
+ suggestedAction: "\u0110\u1ED3ng b\u1ED9 CURRICULUM_PLAN r\u1ED3i ch\u1EA1y l\u1EA1i",
10770
+ retryable: false,
10771
+ lessonId: lessonCode
10772
+ });
10773
+ }
10490
10774
  const lines = [];
10491
10775
  lines.push("[SESSION SLICE (from CURRICULUM_PLAN " + plan.plan_hash + ")]");
10492
10776
  lines.push("- Objective: " + s.prose_objective);
@@ -11053,6 +11337,90 @@ function resolveStandardsPacks(packIds) {
11053
11337
  return packs;
11054
11338
  }
11055
11339
 
11340
+ // src/services/languageDirective.ts
11341
+ function resolveTargetLanguageCode(language) {
11342
+ const raw = String(language || "vi").trim().toLowerCase();
11343
+ if (raw.startsWith("vi")) return "vi";
11344
+ if (raw.startsWith("en")) return "en";
11345
+ return raw || "vi";
11346
+ }
11347
+ function targetLanguageDisplayName(code) {
11348
+ const map = {
11349
+ vi: "Vietnamese (Ti\u1EBFng Vi\u1EC7t)",
11350
+ en: "English (US)"
11351
+ };
11352
+ return map[code] || code;
11353
+ }
11354
+ function buildLanguageDirective(targetLanguage) {
11355
+ const code = resolveTargetLanguageCode(targetLanguage);
11356
+ const name = targetLanguageDisplayName(code);
11357
+ const perLanguageExamples = {
11358
+ vi: `- V\xED d\u1EE5 ti\xEAu \u0111\u1EC1 b\xE0i h\u1ECDc \u0111\xFAng chu\u1EA9n: "B\xE0i 1: Kh\xE1m ph\xE1 m\u1EA1ch \u0111i\u1EC7n c\u01A1 b\u1EA3n", "B\xE0i 2: \u0110i\u1EC1u khi\u1EC3n \u0111\xE8n LED nh\u1EA5p nh\xE1y" \u2014 KH\xD4NG d\xF9ng ti\xEAu \u0111\u1EC1 ti\u1EBFng Anh.`,
11359
+ en: `- Example compliant lesson title: "Lesson 1: Exploring Basic Circuits" \u2014 natural, idiomatic English throughout.`
11360
+ };
11361
+ const exampleLine = perLanguageExamples[code] || "";
11362
+ return `MANDATORY LANGUAGE DIRECTIVE (TARGET OUTPUT LANGUAGE: ${name}):
11363
+ - The TARGET OUTPUT LANGUAGE for this course is ${name}. You MUST author the ENTIRE document in ${name}.
11364
+ - All section titles, table headers, table cells, lesson names, learning objectives, pedagogical narratives, and cognitive analyses MUST be written in natural, fluent, academic ${name}.
11365
+ - Technical identifiers, code keywords (e.g. setup(), loop(), pinMode()), standard protocols (I2C, SPI, UART, GPIO), and component model numbers (ESP32, Arduino Uno) remain in standard technical notation, but all surrounding explanations MUST be in ${name}.
11366
+ - DO NOT mix in paragraphs, tables, or titles written in any other language. Strict adherence is required.${exampleLine ? `
11367
+ ${exampleLine}` : ""}`;
11368
+ }
11369
+ function extractSectionHeadingsFromSLC(slcInput, artifactType) {
11370
+ if (!slcInput) return {};
11371
+ const upperType = artifactType.trim().toUpperCase();
11372
+ if (typeof slcInput === "object") {
11373
+ if (slcInput[upperType]) return slcInput[upperType];
11374
+ for (const [key, mapping] of Object.entries(slcInput)) {
11375
+ if (key.toUpperCase() === upperType || upperType.startsWith("LESSON") && key.toUpperCase().startsWith("LESSON")) {
11376
+ return mapping;
11377
+ }
11378
+ }
11379
+ return {};
11380
+ }
11381
+ const slcMarkdown = slcInput;
11382
+ const blocks = slcMarkdown.split(/\n(?=#{2,3}\s+[A-Z0-9_]+)/g);
11383
+ for (const block of blocks) {
11384
+ const headerMatch = block.match(/^#{2,3}\s+([A-Z0-9_]+)/);
11385
+ if (!headerMatch) continue;
11386
+ const blockType = headerMatch[1].trim().toUpperCase();
11387
+ if (blockType === upperType || upperType.startsWith("LESSON") && blockType.startsWith("LESSON")) {
11388
+ const mapping = {};
11389
+ const lines = block.split("\n");
11390
+ for (const line of lines) {
11391
+ const trimmed = line.trim();
11392
+ if (trimmed.startsWith("|") && !trimmed.includes("---")) {
11393
+ const cells = trimmed.split("|").map((c) => c.trim()).filter((_, idx, arr) => idx > 0 && idx < arr.length - 1);
11394
+ if (cells.length >= 2 && !cells[0].toLowerCase().includes("canonical") && !cells[1].toLowerCase().includes("localized")) {
11395
+ mapping[cells[0]] = cells[1];
11396
+ }
11397
+ } else {
11398
+ const bullet = line.match(/^[-*]\s+([^:]+):\s+(.+)$/);
11399
+ if (bullet) {
11400
+ mapping[bullet[1].trim()] = bullet[2].trim();
11401
+ }
11402
+ }
11403
+ }
11404
+ if (Object.keys(mapping).length > 0) return mapping;
11405
+ }
11406
+ }
11407
+ return {};
11408
+ }
11409
+ function buildHeadingDirective(artifactType, slcMarkdown, targetLanguage = "vi") {
11410
+ const headings = extractSectionHeadingsFromSLC(slcMarkdown, artifactType);
11411
+ if (Object.keys(headings).length === 0) {
11412
+ return "";
11413
+ }
11414
+ const lines = Object.entries(headings).map(
11415
+ ([canonical, localized]) => ` - "${canonical}" -> Use Display Heading: "${localized}"`
11416
+ );
11417
+ return `MANDATORY SECTION HEADINGS FROM SECTION_LANGUAGE_CONTRACT:
11418
+ - The YAML frontmatter \`template_required_sections\` MUST preserve the exact English canonical keys.
11419
+ - In the markdown body, section headers MUST use the EXACT Localized Display Labels below (do NOT translate or paraphrase):
11420
+ ${lines.join("\n")}
11421
+ - For example: if canonical section is "Computational Thinking Focus", your heading must be "## [REQUIRED] ${headings["Computational Thinking Focus"] || "Computational Thinking Focus"}".`;
11422
+ }
11423
+
11056
11424
  // src/services/lessonProductionService.ts
11057
11425
  var __filename2 = typeof import.meta?.url === "string" ? fileURLToPath(import.meta.url) : "";
11058
11426
  var _resolvedDir = __filename2 ? path3.dirname(__filename2) : typeof __dirname !== "undefined" ? __dirname : process.cwd();
@@ -11094,11 +11462,44 @@ function detectProjectPedagogy(frameworkText, styleGuideText, explicitPedagogy)
11094
11462
  return "5e";
11095
11463
  }
11096
11464
  async function getLessonMetadata(storage, projectId, lessonId) {
11097
- const framework = await storage.readSotDocument(projectId, "CURRICULUM_FRAMEWORK.md") || "";
11098
11465
  const parts = lessonId.split("_");
11099
11466
  const unitCode = parts[0] || "U01";
11100
11467
  const moduleCode = parts.length >= 2 ? `${parts[0]}_${parts[1]}` : `${unitCode}_M01`;
11101
11468
  const lessonCode = lessonId;
11469
+ let planStr = null;
11470
+ try {
11471
+ planStr = await storage.readSotDocument(projectId, "CURRICULUM_PLAN.json") || await storage.readArtifact(projectId, "_sot/CURRICULUM_PLAN.json") || await storage.readArtifact(projectId, "CURRICULUM_PLAN.json");
11472
+ } catch {
11473
+ }
11474
+ if (planStr) {
11475
+ try {
11476
+ const plan = JSON.parse(planStr);
11477
+ if (Array.isArray(plan.sessions)) {
11478
+ const session = plan.sessions.find((s) => s.id === lessonId);
11479
+ if (session) {
11480
+ const lessonTitle2 = session.title || `Lesson ${lessonId}`;
11481
+ const keywords = Array.isArray(session.new_keywords) && session.new_keywords.length > 0 ? ` T\u1EEB kh\xF3a: ${session.new_keywords.join(", ")}` : "";
11482
+ const objective2 = session.prose_objective || session.title || "";
11483
+ const concept2 = objective2 ? `${objective2}.${keywords}` : session.title || "Core Technical Competency";
11484
+ const prerequisites2 = session.anchor_type ? `Anchor: ${session.anchor_type}` : "None";
11485
+ const depth = Array.isArray(session.depth_assignments) ? session.depth_assignments[0]?.depth : session.depth_assignments?.knowledge_depth;
11486
+ const bloomLevel2 = depth === "sio" ? "Create" : depth === "cio" ? "Apply" : "Understand";
11487
+ return {
11488
+ unitCode: session.unit_id || unitCode,
11489
+ moduleCode,
11490
+ lessonCode,
11491
+ lessonTitle: lessonTitle2,
11492
+ concept: `M\u1EE5c ti\xEAu bu\u1ED5i h\u1ECDc: ${concept2}`,
11493
+ prerequisites: prerequisites2,
11494
+ bloomLevel: bloomLevel2
11495
+ };
11496
+ }
11497
+ }
11498
+ } catch (planErr) {
11499
+ console.warn(`[getLessonMetadata] Error parsing CURRICULUM_PLAN.json for ${projectId}:`, planErr);
11500
+ }
11501
+ }
11502
+ const framework = await storage.readSotDocument(projectId, "CURRICULUM_FRAMEWORK.md") || "";
11102
11503
  let lessonTitle = `Lesson ${lessonId}`;
11103
11504
  let concept = "Core Technical Competency";
11104
11505
  let prerequisites = "None";
@@ -11143,15 +11544,24 @@ async function getLessonMetadata(storage, projectId, lessonId) {
11143
11544
  }
11144
11545
  if (found) break;
11145
11546
  }
11146
- return {
11147
- unitCode,
11148
- moduleCode,
11149
- lessonCode,
11150
- lessonTitle,
11151
- concept: objective ? `${concept}. M\u1EE5c ti\xEAu bu\u1ED5i h\u1ECDc: ${objective}` : concept,
11152
- prerequisites: deliverable ? `${prerequisites}. S\u1EA3n ph\u1EA9m hands-on c\u1EE7a bu\u1ED5i: ${deliverable}` : prerequisites,
11153
- bloomLevel
11154
- };
11547
+ if (found) {
11548
+ return {
11549
+ unitCode,
11550
+ moduleCode,
11551
+ lessonCode,
11552
+ lessonTitle,
11553
+ concept: objective ? `${concept}. M\u1EE5c ti\xEAu bu\u1ED5i h\u1ECDc: ${objective}` : concept,
11554
+ prerequisites: deliverable ? `${prerequisites}. S\u1EA3n ph\u1EA9m hands-on c\u1EE7a bu\u1ED5i: ${deliverable}` : prerequisites,
11555
+ bloomLevel
11556
+ };
11557
+ }
11558
+ throw new CurriculumError({
11559
+ errorCode: "ERR_LESSON_NOT_IN_SOT",
11560
+ lessonId,
11561
+ message: `ERR_LESSON_NOT_IN_SOT: B\xE0i h\u1ECDc "${lessonId}" kh\xF4ng t\u1ED3n t\u1EA1i trong CURRICULUM_PLAN.json ho\u1EB7c CURRICULUM_FRAMEWORK.md c\u1EE7a d\u1EF1 \xE1n "${projectId}".`,
11562
+ suggestedAction: "\u0110\u1ED3ng b\u1ED9 CURRICULUM_PLAN r\u1ED3i ch\u1EA1y l\u1EA1i",
11563
+ retryable: false
11564
+ });
11155
11565
  }
11156
11566
  function buildFrameworkExcerptForLesson(framework, lessonId) {
11157
11567
  if (!framework) return "";
@@ -11193,7 +11603,7 @@ ${nextRow}`
11193
11603
  ].filter(Boolean);
11194
11604
  return parts.join("\n\n") || framework.slice(0, 1500);
11195
11605
  }
11196
- function buildLessonPrompt(pedagogy, lessonCode, unitCode, lessonTitle, concept, bloomLevel, dateStr) {
11606
+ function buildLessonPrompt(pedagogy, lessonCode, unitCode, lessonTitle, concept, bloomLevel, dateStr, targetLanguage = "vi", sectionLanguageContract) {
11197
11607
  const commonFrontmatter = `id: "LESSON_${lessonCode}"
11198
11608
  title: "${lessonTitle}"
11199
11609
  created_by: "Curriculum OS Builder"
@@ -11213,8 +11623,9 @@ template_required_sections:
11213
11623
  - "Artifact Contract"
11214
11624
  - "B. Lesson Flow"
11215
11625
  - "Artifact Linkage"`;
11626
+ let prompt = "";
11216
11627
  if (pedagogy === "edp") {
11217
- return `You are @content (Educational Content Editor & EDP Engineering Design Process Specialist).
11628
+ prompt = `You are @content (Educational Content Editor & EDP Engineering Design Process Specialist).
11218
11629
  Author the comprehensive Master Lesson Plan adhering strictly to \`LESSON_EDP_template.md\` standards for:
11219
11630
  - Lesson Code: ${lessonCode}
11220
11631
  - Title: ${lessonTitle}
@@ -11263,9 +11674,8 @@ Linkage ledger mapping all satellite artifacts (\`ACT_...\`, \`QUIZ_...\`, \`SLI
11263
11674
 
11264
11675
  3. Ensure all sample code and schemas are 100% syntax-valid and executable.
11265
11676
  4. Output 100% clean Markdown directly.`;
11266
- }
11267
- if (pedagogy === "pbl" || pedagogy === "general") {
11268
- return `You are @content (Educational Content Editor & PBL/General Pedagogy Specialist).
11677
+ } else if (pedagogy === "pbl" || pedagogy === "general") {
11678
+ prompt = `You are @content (Educational Content Editor & PBL/General Pedagogy Specialist).
11269
11679
  Author the comprehensive Master Lesson Plan adhering strictly to \`LESSON_GENERAL_template.md\` standards for:
11270
11680
  - Lesson Code: ${lessonCode}
11271
11681
  - Title: ${lessonTitle}
@@ -11312,8 +11722,8 @@ type: "LESSON_GENERAL"
11312
11722
  Linkage ledger mapping all satellite artifacts (\`ACT_...\`, \`QUIZ_...\`, \`SLIDE_...\`).
11313
11723
 
11314
11724
  3. Output 100% clean Markdown directly.`;
11315
- }
11316
- return `You are @content (Educational Content Editor & 5E Instructional Model Specialist).
11725
+ } else {
11726
+ prompt = `You are @content (Educational Content Editor & 5E Instructional Model Specialist).
11317
11727
  Author the comprehensive Master Lesson Plan adhering strictly to \`LESSON_5E_template.md\` standards for:
11318
11728
  - Lesson Code: ${lessonCode}
11319
11729
  - Title: ${lessonTitle}
@@ -11361,6 +11771,18 @@ Linkage ledger mapping all satellite artifacts (\`GUIDE_...\`, \`SLIDE_...\`, \`
11361
11771
 
11362
11772
  3. Ensure all sample code and syntax are 100% verified and runnable.
11363
11773
  4. Output 100% clean Markdown directly.`;
11774
+ }
11775
+ const langDirective = buildLanguageDirective(targetLanguage);
11776
+ const headingDirective = buildHeadingDirective(
11777
+ pedagogy === "edp" ? "LESSON_EDP" : pedagogy === "general" || pedagogy === "pbl" ? "LESSON_GENERAL" : "LESSON_5E",
11778
+ sectionLanguageContract,
11779
+ targetLanguage
11780
+ );
11781
+ return `${prompt}
11782
+
11783
+ ${langDirective}${headingDirective ? `
11784
+
11785
+ ${headingDirective}` : ""}`;
11364
11786
  }
11365
11787
  async function produceSingleLesson(storage, projectId, lessonId, options = {}) {
11366
11788
  const {
@@ -11391,6 +11813,20 @@ async function produceSingleLesson(storage, projectId, lessonId, options = {}) {
11391
11813
  const styleGuide = await storage.readSotDocument(projectId, "CONTENT_STYLE_GUIDE.md") || "";
11392
11814
  const refPack = await storage.readSotDocument(projectId, "REFERENCE_PACK.md") || "";
11393
11815
  await storage.readSotDocument(projectId, "LEARNER_PROFILE.md") || "";
11816
+ const slcMarkdown = options.sectionLanguageContract || await storage.readSotDocument(projectId, "SECTION_LANGUAGE_CONTRACT.md") || "";
11817
+ let targetLang = options.targetLanguage;
11818
+ if (!targetLang) {
11819
+ try {
11820
+ const planRaw = await storage.readArtifact(projectId, "_sot/CURRICULUM_PLAN.json");
11821
+ if (planRaw) {
11822
+ const p = JSON.parse(planRaw);
11823
+ targetLang = p?.translation?.target_language;
11824
+ }
11825
+ } catch {
11826
+ }
11827
+ }
11828
+ targetLang = targetLang || "vi";
11829
+ const languageDirective = buildLanguageDirective(targetLang);
11394
11830
  let expositionContext = "";
11395
11831
  let sessionSliceContext = "";
11396
11832
  try {
@@ -11425,6 +11861,18 @@ async function produceSingleLesson(storage, projectId, lessonId, options = {}) {
11425
11861
  }
11426
11862
  const pedagogy = detectProjectPedagogy(framework, styleGuide, options.pedagogy);
11427
11863
  const pedagogyLabel = pedagogy.toUpperCase();
11864
+ const styleGuideExcerpt = styleGuide ? buildSectionAwareExcerpt(styleGuide, {
11865
+ priorities: ["Voice & Tone", "Standard Terminology (Glossary)", "Lesson Content Standards"],
11866
+ budget: 2e3
11867
+ }).excerpt : "";
11868
+ const refPackExcerpt = refPack ? buildSectionAwareExcerpt(refPack, {
11869
+ priorities: [
11870
+ "Technical Overview & Architecture Blueprint",
11871
+ "Hardware Pinout & Wiring Configuration Matrix",
11872
+ "Core Pedagogical Concept Anchor & Real-World Domain Bridge"
11873
+ ],
11874
+ budget: 2500
11875
+ }).excerpt : "";
11428
11876
  const commonContext = `PROJECT & ACADEMIC CONTEXT:
11429
11877
  - Project ID: ${projectId}
11430
11878
  - Pedagogical Model: ${pedagogyLabel}
@@ -11438,10 +11886,10 @@ async function produceSingleLesson(storage, projectId, lessonId, options = {}) {
11438
11886
  ${buildFrameworkExcerptForLesson(framework, lessonId)}
11439
11887
 
11440
11888
  [CONTENT STYLE GUIDE EXCERPT]:
11441
- ${styleGuide.slice(0, 1500)}
11889
+ ${styleGuideExcerpt}
11442
11890
 
11443
11891
  [REFERENCE PACK GROUND TRUTH]:
11444
- ${refPack.slice(0, 1e3)}${standardsContext ? "\n\n" + standardsContext : ""}${expositionContext ? "\n\n[KNOWLEDGE_EXPOSITION (CANONICAL KNOWLEDGE \u2014 teach from this, do not contradict)]:\n" + expositionContext : ""}${sessionSliceContext ? "\n\n" + sessionSliceContext : ""}`;
11892
+ ${refPackExcerpt}${standardsContext ? "\n\n" + standardsContext : ""}${expositionContext ? "\n\n[KNOWLEDGE_EXPOSITION (CANONICAL KNOWLEDGE \u2014 teach from this, do not contradict)]:\n" + expositionContext : ""}${sessionSliceContext ? "\n\n" + sessionSliceContext : ""}`;
11445
11893
  const producedArtifacts = [];
11446
11894
  const lessonRelPath = `_content/${unitCode}/LESSON_${lessonCode}.md`;
11447
11895
  const existingLessonContent = await storage.readArtifact(projectId, lessonRelPath);
@@ -11460,7 +11908,9 @@ Khi n\u1ED9i dung c\u1EA7n minh h\u1ECDa (diagram quy tr\xECnh, s\u01A1 \u0111\u
11460
11908
  lessonTitle,
11461
11909
  concept,
11462
11910
  bloomLevel,
11463
- dateStr
11911
+ dateStr,
11912
+ targetLang,
11913
+ slcMarkdown
11464
11914
  ) + mediaDirective;
11465
11915
  const rawLesson = await runCurriculumAIInference(
11466
11916
  [{ role: "user", content: lessonPrompt }],
@@ -11559,14 +12009,15 @@ ${yamlBlock.trim()}
11559
12009
  const judgeResult = await LLMJudgeEngine.evaluateArtifactWithLLM({
11560
12010
  targetArtifactType: "LESSON",
11561
12011
  lessonId: lessonCode,
11562
- expectedLanguage: "en",
12012
+ expectedLanguage: targetLang || "en",
11563
12013
  targetObjectives: judgeObjectives,
11564
12014
  generatedContentJson: JSON.stringify({
11565
12015
  lessonContent,
11566
12016
  lessonId: lessonCode,
11567
12017
  title: lessonTitle,
11568
- frameworkExcerpt: framework ? framework.slice(0, 2500) : void 0,
11569
- styleGuideExcerpt: styleGuide ? styleGuide.slice(0, 1500) : void 0
12018
+ frameworkExcerpt: framework ? buildFrameworkExcerptForLesson(framework, lessonId) : void 0,
12019
+ styleGuideExcerpt: styleGuideExcerpt || void 0,
12020
+ canonicalExposition: expositionContext ? expositionContext.slice(0, 3e3) : void 0
11570
12021
  }),
11571
12022
  standardStatements: Object.keys(standardStatements).length > 0 ? standardStatements : void 0
11572
12023
  });
@@ -11631,14 +12082,15 @@ ${currentContent}` }],
11631
12082
  const reJudge = await LLMJudgeEngine.evaluateArtifactWithLLM({
11632
12083
  targetArtifactType: "LESSON",
11633
12084
  lessonId: lessonCode,
11634
- expectedLanguage: "en",
12085
+ expectedLanguage: targetLang || "en",
11635
12086
  targetObjectives: parseLessonObjectives(currentContent, concept, bloomLevel),
11636
12087
  generatedContentJson: JSON.stringify({
11637
12088
  lessonContent: currentContent,
11638
12089
  lessonId: lessonCode,
11639
12090
  title: lessonTitle,
11640
- frameworkExcerpt: framework ? framework.slice(0, 2500) : void 0,
11641
- styleGuideExcerpt: styleGuide ? styleGuide.slice(0, 1500) : void 0
12091
+ frameworkExcerpt: framework ? buildFrameworkExcerptForLesson(framework, lessonId) : void 0,
12092
+ styleGuideExcerpt: styleGuideExcerpt || void 0,
12093
+ canonicalExposition: expositionContext ? expositionContext.slice(0, 3e3) : void 0
11642
12094
  }),
11643
12095
  standardStatements: Object.keys(standardStatements).length > 0 ? standardStatements : void 0
11644
12096
  });
@@ -11759,10 +12211,34 @@ ${currentContent}` }],
11759
12211
  contentHash
11760
12212
  });
11761
12213
  }
12214
+ const lessonExcerptResult = buildSectionAwareExcerpt(lessonContent, {
12215
+ priorities: DEFAULT_LESSON_PRIORITIES,
12216
+ budget: 12e3,
12217
+ sectionLanguageContract: slcMarkdown,
12218
+ artifactType: "LESSON"
12219
+ });
12220
+ const lessonExcerpt = lessonExcerptResult.excerpt;
11762
12221
  const satelliteContext = `${commonContext}
11763
12222
 
11764
12223
  [CANONICAL LESSON PLAN (${pedagogyLabel})]:
11765
- ${lessonContent.slice(0, 4e3)}`;
12224
+ ${lessonExcerpt}`;
12225
+ const judgeSat = (sat, content) => {
12226
+ if (gateModeFor(gates, sat) !== "LLM_JUDGE") return Promise.resolve();
12227
+ return judgeSatelliteArtifact({
12228
+ storage,
12229
+ projectId,
12230
+ lessonCode,
12231
+ sat,
12232
+ content,
12233
+ concept,
12234
+ bloomLevel,
12235
+ standardStatements,
12236
+ onProgress,
12237
+ targetLang,
12238
+ canonicalLessonContent: lessonContent,
12239
+ canonicalLessonExcerpt: lessonExcerpt
12240
+ });
12241
+ };
11766
12242
  const actRelPath = `_content/${unitCode}/ACT_${lessonCode}.md`;
11767
12243
  if (artifactScope.includes("ACT") && (!await storage.readArtifact(projectId, actRelPath) || force)) {
11768
12244
  onProgress?.("@activity", `[2/4] Authoring Hands-on Lab: \`ACT_${lessonCode}.md\`...`);
@@ -11801,7 +12277,11 @@ template_required_sections:
11801
12277
  - ### Phase 3: Debugging & Testing
11802
12278
  - ## [REQUIRED] 3-Tier Differentiation (Bronze/Silver/Gold tasks)
11803
12279
  - ## [REQUIRED] Reflection (Discussion question)
11804
- 3. Output 100% clean Markdown directly \u2014 NO code fences around the document.`;
12280
+ 3. Output 100% clean Markdown directly \u2014 NO code fences around the document.
12281
+
12282
+ ${languageDirective}
12283
+
12284
+ ${buildHeadingDirective("ACT", slcMarkdown, targetLang)}`;
11805
12285
  const rawAct = await runCurriculumAIInference(
11806
12286
  [{ role: "user", content: actPrompt }],
11807
12287
  satelliteContext,
@@ -11827,19 +12307,7 @@ template_required_sections:
11827
12307
  contentHash: computeContentHash(rawAct)
11828
12308
  });
11829
12309
  producedArtifacts.push(`ACT_${lessonCode}.md`);
11830
- if (gateModeFor(gates, "ACT") === "LLM_JUDGE") {
11831
- await judgeSatelliteArtifact({
11832
- storage,
11833
- projectId,
11834
- lessonCode,
11835
- sat: "ACT",
11836
- content: rawAct,
11837
- concept,
11838
- bloomLevel,
11839
- standardStatements,
11840
- onProgress
11841
- });
11842
- }
12310
+ await judgeSat("ACT", rawAct);
11843
12311
  }
11844
12312
  const quizRelPath = `_content/${unitCode}/QUIZ_${lessonCode}.md`;
11845
12313
  if (artifactScope.includes("QUIZ") && (!await storage.readArtifact(projectId, quizRelPath) || force)) {
@@ -11873,7 +12341,11 @@ template_required_sections:
11873
12341
  - ## [REQUIRED] Multiple-Choice Question Bank (\u22655 scenario-based 4-option questions with: Question text, A/B/C/D options, Correct answer, Bloom level, Detailed distractor rationale)
11874
12342
  - ## [REQUIRED] Code Analysis / Debugging Question (1 deep code tracing question requiring students to predict output or identify bugs)
11875
12343
  - ## [REQUIRED] Competency Rubric (4-tier matrix: Developing \u2192 Proficient \u2192 Advanced \u2192 Exemplary)
11876
- 3. Output 100% clean Markdown directly \u2014 NO code fences around the document.`;
12344
+ 3. Output 100% clean Markdown directly \u2014 NO code fences around the document.
12345
+
12346
+ ${languageDirective}
12347
+
12348
+ ${buildHeadingDirective("QUIZ", slcMarkdown, targetLang)}`;
11877
12349
  const rawQuiz = await runCurriculumAIInference(
11878
12350
  [{ role: "user", content: quizPrompt }],
11879
12351
  satelliteContext,
@@ -11899,60 +12371,25 @@ template_required_sections:
11899
12371
  contentHash: computeContentHash(rawQuiz)
11900
12372
  });
11901
12373
  producedArtifacts.push(`QUIZ_${lessonCode}.md`);
11902
- if (gateModeFor(gates, "QUIZ") === "LLM_JUDGE") {
11903
- await judgeSatelliteArtifact({
11904
- storage,
11905
- projectId,
11906
- lessonCode,
11907
- sat: "QUIZ",
11908
- content: rawQuiz,
11909
- concept,
11910
- bloomLevel,
11911
- standardStatements,
11912
- onProgress
11913
- });
11914
- }
12374
+ await judgeSat("QUIZ", rawQuiz);
11915
12375
  }
11916
12376
  const slideRelPath = `_content/${unitCode}/SLIDE_${lessonCode}.md`;
11917
12377
  if (artifactScope.includes("SLIDE") && (!await storage.readArtifact(projectId, slideRelPath) || force)) {
11918
12378
  onProgress?.("@illustrator", `[4/4] Authoring Presentation Slide Deck: \`SLIDE_${lessonCode}.md\`...`);
11919
12379
  const canonicalSlideTemplate = loadCurriculumTemplate("SLIDE_template.md");
11920
- const slidePrompt = `You are @illustrator & @content (Pedagogical Slide Deck Presentation Specialists).
11921
- Based on Master Lesson Plan \`LESSON_${lessonCode}.md\`, lesson context, and the MARP SLIDE TEMPLATE below, author the complete, highly engaging Marp presentation deck: \`SLIDE_${lessonCode}.md\`.
11922
-
11923
- [MARP SLIDE TEMPLATE SCAFFOLD]:
11924
- ${canonicalSlideTemplate || `---
12380
+ const templateScaffold = canonicalSlideTemplate || `---
11925
12381
  marp: true
11926
12382
  theme: default
11927
12383
  paginate: true
11928
12384
  header: "${titleHeader(lessonTitle)}"
11929
12385
  footer: "Curriculum OS \u2022 ${lessonCode} (${pedagogyLabel})"
11930
- ---`}
11931
-
11932
- MANDATORY 12-14 SLIDE MICRO-CYCLE STRUCTURE (Delimited by '---'):
11933
- 1. **Slide 1 [Title & Mission]:** ${lessonCode}: ${lessonTitle} + Real-world inquiry hook
11934
- 2. **Slide 2 [Agenda & Roadmap]:** Timing and milestone breakdown table (${pedagogyLabel})
11935
- 3. **Slide 3 [Warm-Up / Prior Knowledge]:** 2-column recall + 60-second diagnostic challenge card
11936
- 4. **Slide 4 [High-Stakes Hook Scenario]:** Authentic engineering/domain crisis card + dilemma constraint
11937
- 5. **Slide 5 [Core Concept 1: Mental Model]:** Definition, intuitive everyday analogy, and golden rule card
11938
- 6. **Slide 6 [Architecture & Visual Flow]:** Clean Mermaid diagram (flowchart or sequenceDiagram) + 3 flow steps
11939
- 7. **Slide 7 [Core Concept 2: Syntax / Mechanism Anatomy]:** Side-by-side 6-10 lines runnable code + anatomy breakdown & syntax trap card
11940
- 8. **Slide 8 [Guided Practice: Try It Now]:** 3-minute active desk task card with starter hint and success criteria
11941
- 9. **Slide 9 [Integrated Hands-On Lab]:** 3-tier differentiated challenge cards (Bronze / Silver / Gold) + gotcha alert card
11942
- 10. **Slide 10 [Traffic Light Checkpoint & Pitfalls]:** Formative self-check cards (\u{1F7E2}/\u{1F7E1}/\u{1F534}) & diagnostic test question
11943
- 11. **Slide 11 [Exit Ticket & Metacognition]:** 2 scenario-based check questions + 1 metacognitive reflection prompt
11944
- 12. **Slide 12 [Summary & Next Steps]:** 3 core golden rules + preview card of next upcoming milestone
11945
-
11946
- Mandatory Canvas & Presentation Invariants:
11947
- - A slide is an INTERACTIVE PROJECTION CANVAS, NOT a textbook! Absolutely NO dense paragraphs or walls of text.
11948
- - Follow the 6x6 rule: Maximum 4-6 bullet points per slide, maximum 8-12 words per bullet.
11949
- - Structure slides using \`<div class="columns"><div>...</div><div>...</div></div>\` and \`<div class="card">\`, \`<div class="card highlight">\`, \`<div class="card warning">\`, \`<div class="card success">\`.
11950
- - MANDATORY PRESENTER NOTES ON EVERY SLIDE: Every slide MUST end with \`<!-- Presenter Notes: ... -->\` containing:
11951
- * SCRIPT: 60-90s teacher talk track with intuitive analogies.
11952
- * COLD CALL / CHECK: Specific diagnostic question to ask students.
11953
- * SCAFFOLDING / GOTCHA: Guidance for students who get stuck.
11954
- * PACING: Recommended minutes for the slide.
11955
- - Output 100% valid Marp Markdown.`;
12386
+ ---`;
12387
+ const slidePrompt = buildMarpMarkdownSlidePrompt({
12388
+ lessonCode,
12389
+ templateScaffold,
12390
+ languageDirective,
12391
+ headingDirective: buildHeadingDirective("SLIDE", slcMarkdown, targetLang)
12392
+ });
11956
12393
  const rawSlide = await runCurriculumAIInference(
11957
12394
  [{ role: "user", content: slidePrompt }],
11958
12395
  satelliteContext,
@@ -11978,19 +12415,7 @@ Mandatory Canvas & Presentation Invariants:
11978
12415
  contentHash: computeContentHash(rawSlide)
11979
12416
  });
11980
12417
  producedArtifacts.push(`SLIDE_${lessonCode}.md`);
11981
- if (gateModeFor(gates, "SLIDE") === "LLM_JUDGE") {
11982
- await judgeSatelliteArtifact({
11983
- storage,
11984
- projectId,
11985
- lessonCode,
11986
- sat: "SLIDE",
11987
- content: rawSlide,
11988
- concept,
11989
- bloomLevel,
11990
- standardStatements,
11991
- onProgress
11992
- });
11993
- }
12418
+ await judgeSat("SLIDE", rawSlide);
11994
12419
  }
11995
12420
  const guideRelPath = `_content/${unitCode}/GUIDE_${lessonCode}.md`;
11996
12421
  if (artifactScope.includes("GUIDE") && (!await storage.readArtifact(projectId, guideRelPath) || force)) {
@@ -12019,7 +12444,11 @@ template_contract: "artifact-template-v1"
12019
12444
  - ## [REQUIRED] Facilitation Script & Timeline (Phase-by-phase teacher moves, inquiry questions, transitions)
12020
12445
  - ## [REQUIRED] Common Misconceptions & Diagnostic Remediation Matrix
12021
12446
  - ## [REQUIRED] Differentiated Support Strategies (Support scaffolds vs Extension challenges)
12022
- 3. Output 100% clean Markdown directly \u2014 NO code fences around the document.`;
12447
+ 3. Output 100% clean Markdown directly \u2014 NO code fences around the document.
12448
+
12449
+ ${languageDirective}
12450
+
12451
+ ${buildHeadingDirective("GUIDE", slcMarkdown, targetLang)}`;
12023
12452
  const rawGuide = await runCurriculumAIInference(
12024
12453
  [{ role: "user", content: guidePrompt }],
12025
12454
  satelliteContext,
@@ -12036,19 +12465,7 @@ template_contract: "artifact-template-v1"
12036
12465
  contentHash: computeContentHash(rawGuide)
12037
12466
  });
12038
12467
  producedArtifacts.push(`GUIDE_${lessonCode}.md`);
12039
- if (gateModeFor(gates, "GUIDE") === "LLM_JUDGE") {
12040
- await judgeSatelliteArtifact({
12041
- storage,
12042
- projectId,
12043
- lessonCode,
12044
- sat: "GUIDE",
12045
- content: rawGuide,
12046
- concept,
12047
- bloomLevel,
12048
- standardStatements,
12049
- onProgress
12050
- });
12051
- }
12468
+ await judgeSat("GUIDE", rawGuide);
12052
12469
  }
12053
12470
  }
12054
12471
  const handoutRelPath = `_content/${unitCode}/HANDOUT_${lessonCode}.md`;
@@ -12078,7 +12495,11 @@ template_contract: "artifact-template-v1"
12078
12495
  - ## [REQUIRED] Visual Mental Model / Architecture Diagram (Mermaid or ASCII diagram)
12079
12496
  - ## [REQUIRED] Step-by-Step Practical Quick-Start Guide
12080
12497
  - ## [REQUIRED] Self-Check Diagnostic Checklist (Can-do statements for student self-assessment)
12081
- 3. Output 100% clean Markdown directly \u2014 NO code fences around the document.`;
12498
+ 3. Output 100% clean Markdown directly \u2014 NO code fences around the document.
12499
+
12500
+ ${languageDirective}
12501
+
12502
+ ${buildHeadingDirective("HANDOUT", slcMarkdown, targetLang)}`;
12082
12503
  const rawHandout = await runCurriculumAIInference(
12083
12504
  [{ role: "user", content: handoutPrompt }],
12084
12505
  satelliteContext,
@@ -12095,19 +12516,7 @@ template_contract: "artifact-template-v1"
12095
12516
  contentHash: computeContentHash(rawHandout)
12096
12517
  });
12097
12518
  producedArtifacts.push(`HANDOUT_${lessonCode}.md`);
12098
- if (gateModeFor(gates, "HANDOUT") === "LLM_JUDGE") {
12099
- await judgeSatelliteArtifact({
12100
- storage,
12101
- projectId,
12102
- lessonCode,
12103
- sat: "HANDOUT",
12104
- content: rawHandout,
12105
- concept,
12106
- bloomLevel,
12107
- standardStatements,
12108
- onProgress
12109
- });
12110
- }
12519
+ await judgeSat("HANDOUT", rawHandout);
12111
12520
  }
12112
12521
  }
12113
12522
  const wksRelPath = `_content/${unitCode}/WKS_${lessonCode}.md`;
@@ -12141,7 +12550,11 @@ template_contract: "artifact-template-v1"
12141
12550
  - ## [REQUIRED] Part 3: Code Analysis & Bug Hunting Challenge
12142
12551
  - ## [REQUIRED] Part 4: Synthesis & Problem-Solving Application
12143
12552
  - ## [REQUIRED] Part 5: Self-Reflection & Learning Log
12144
- 3. Output 100% clean Markdown directly \u2014 NO code fences around the document.`;
12553
+ 3. Output 100% clean Markdown directly \u2014 NO code fences around the document.
12554
+
12555
+ ${languageDirective}
12556
+
12557
+ ${buildHeadingDirective("WKS", slcMarkdown, targetLang)}`;
12145
12558
  const rawWks = await runCurriculumAIInference(
12146
12559
  [{ role: "user", content: wksPrompt }],
12147
12560
  satelliteContext,
@@ -12158,19 +12571,7 @@ template_contract: "artifact-template-v1"
12158
12571
  contentHash: computeContentHash(rawWks)
12159
12572
  });
12160
12573
  producedArtifacts.push(`WKS_${lessonCode}.md`);
12161
- if (gateModeFor(gates, "WKS") === "LLM_JUDGE") {
12162
- await judgeSatelliteArtifact({
12163
- storage,
12164
- projectId,
12165
- lessonCode,
12166
- sat: "WKS",
12167
- content: rawWks,
12168
- concept,
12169
- bloomLevel,
12170
- standardStatements,
12171
- onProgress
12172
- });
12173
- }
12574
+ await judgeSat("WKS", rawWks);
12174
12575
  }
12175
12576
  }
12176
12577
  const codeRelPath = `_content/${unitCode}/CODE_${lessonCode}.md`;
@@ -12208,7 +12609,11 @@ template_required_sections:
12208
12609
  - ## [REQUIRED] Verified Reference Solution Code (100% syntactically valid, production-ready, fully commented)
12209
12610
  - ## [REQUIRED] Automated Test / Verification Script (How to compile, flash, or unit test)
12210
12611
  - ## [REQUIRED] Common Syntax & Runtime Pitfalls Matrix
12211
- 3. Output 100% clean Markdown directly with runnable code snippets \u2014 NO outer code fences around the document.`;
12612
+ 3. Output 100% clean Markdown directly with runnable code snippets \u2014 NO outer code fences around the document.
12613
+
12614
+ ${languageDirective}
12615
+
12616
+ ${buildHeadingDirective("CODE", slcMarkdown, targetLang)}`;
12212
12617
  const rawCode = await runCurriculumAIInference(
12213
12618
  [{ role: "user", content: codePrompt }],
12214
12619
  satelliteContext,
@@ -12230,19 +12635,7 @@ template_required_sections:
12230
12635
  contentHash: computeContentHash(rawCode)
12231
12636
  });
12232
12637
  producedArtifacts.push(`CODE_${lessonCode}.md`);
12233
- if (gateModeFor(gates, "CODE") === "LLM_JUDGE") {
12234
- await judgeSatelliteArtifact({
12235
- storage,
12236
- projectId,
12237
- lessonCode,
12238
- sat: "CODE",
12239
- content: rawCode,
12240
- concept,
12241
- bloomLevel,
12242
- standardStatements,
12243
- onProgress
12244
- });
12245
- }
12638
+ await judgeSat("CODE", rawCode);
12246
12639
  }
12247
12640
  }
12248
12641
  const extRelPath = `_content/${unitCode}/EXT_${lessonCode}.md`;
@@ -12274,7 +12667,11 @@ template_contract: "artifact-template-v1"
12274
12667
  - ### Challenge 2: [Name] (Difficulty: \u2B50\u2B50\u2B50\u2B50) \u2014 Advanced Architectural Constraints & Edge Cases
12275
12668
  - ### Challenge 3: [Name] (Difficulty: \u2B50\u2B50\u2B50\u2B50\u2B50) \u2014 Extension Milestones (Level 1: Ninja \u2192 Level 2: Guru \u2192 Level 3: Master)
12276
12669
  - ## [REQUIRED] Metacognitive Deep Dive & Engineering Trade-offs
12277
- 3. Output 100% clean Markdown directly \u2014 NO code fences around the document.`;
12670
+ 3. Output 100% clean Markdown directly \u2014 NO code fences around the document.
12671
+
12672
+ ${languageDirective}
12673
+
12674
+ ${buildHeadingDirective("EXT", slcMarkdown, targetLang)}`;
12278
12675
  const rawExt = await runCurriculumAIInference(
12279
12676
  [{ role: "user", content: extPrompt }],
12280
12677
  satelliteContext,
@@ -12291,19 +12688,7 @@ template_contract: "artifact-template-v1"
12291
12688
  contentHash: computeContentHash(rawExt)
12292
12689
  });
12293
12690
  producedArtifacts.push(`EXT_${lessonCode}.md`);
12294
- if (gateModeFor(gates, "EXT") === "LLM_JUDGE") {
12295
- await judgeSatelliteArtifact({
12296
- storage,
12297
- projectId,
12298
- lessonCode,
12299
- sat: "EXT",
12300
- content: rawExt,
12301
- concept,
12302
- bloomLevel,
12303
- standardStatements,
12304
- onProgress
12305
- });
12306
- }
12691
+ await judgeSat("EXT", rawExt);
12307
12692
  }
12308
12693
  }
12309
12694
  onProgress?.("@reviewer", `\u2705 Successfully authored all requested artifacts for \`${lessonCode}\` (${pedagogyLabel})!`);
@@ -12369,12 +12754,22 @@ async function judgeSatelliteArtifact(ctx) {
12369
12754
  const { storage, projectId, lessonCode, sat, content } = ctx;
12370
12755
  try {
12371
12756
  ctx.onProgress?.("@reviewer", `\u{1F916} Judging ${sat}_${lessonCode}...`);
12757
+ const targetObjectives = parseLessonObjectives(
12758
+ ctx.canonicalLessonContent || content,
12759
+ ctx.concept,
12760
+ ctx.bloomLevel
12761
+ );
12372
12762
  const result = await LLMJudgeEngine.evaluateArtifactWithLLM({
12373
12763
  targetArtifactType: sat,
12374
12764
  lessonId: lessonCode,
12375
- expectedLanguage: "en",
12376
- targetObjectives: parseLessonObjectives(content, ctx.concept, ctx.bloomLevel),
12377
- generatedContentJson: JSON.stringify({ content, artifactType: sat, lessonId: lessonCode }),
12765
+ expectedLanguage: ctx.targetLang || "en",
12766
+ targetObjectives,
12767
+ generatedContentJson: JSON.stringify({
12768
+ content,
12769
+ artifactType: sat,
12770
+ lessonId: lessonCode,
12771
+ canonicalLessonExcerpt: ctx.canonicalLessonExcerpt
12772
+ }),
12378
12773
  standardStatements: Object.keys(ctx.standardStatements).length > 0 ? ctx.standardStatements : void 0
12379
12774
  });
12380
12775
  const passed = result.passed && result.score >= 85;
@@ -12497,6 +12892,87 @@ async function produceBatchLessons(storage, projectId, lessonIds, options = {})
12497
12892
  // src/services/singleArtifactService.ts
12498
12893
  init_streamRunner();
12499
12894
  init_errors();
12895
+
12896
+ // src/services/contextRouting.ts
12897
+ init_errors();
12898
+ var ARTIFACT_DEPENDENCY_ROUTING = {
12899
+ LESSON: {
12900
+ required: ["KNOWLEDGE_EXPOSITION", "SESSION_SLICE", "FRAMEWORK_EXCERPT"],
12901
+ optional: ["STYLE_GUIDE", "REFERENCE_PACK"],
12902
+ rationale: "D\u1EA1y theo ki\u1EBFn th\u1EE9c chu\u1EA9n c\u1EE7a plan, ph\xE2n b\u1ED5 m\u1EE5c ti\xEAu v\xE0 khung ch\u01B0\u01A1ng tr\xECnh"
12903
+ },
12904
+ HANDOUT: {
12905
+ required: ["KNOWLEDGE_EXPOSITION"],
12906
+ optional: ["SESSION_SLICE"],
12907
+ rationale: "T\xE0i li\u1EC7u t\u1EF1 h\u1ECDc \u2014 b\xE1m kh\xE1i ni\u1EC7m chu\u1EA9n, kh\xF4ng c\u1EA7n activity timeline"
12908
+ },
12909
+ EXT: {
12910
+ required: ["KNOWLEDGE_EXPOSITION"],
12911
+ optional: ["SESSION_SLICE"],
12912
+ rationale: "Th\u1EED th\xE1ch m\u1EDF r\u1ED9ng chuy\xEAn s\xE2u b\xE1m kh\xE1i ni\u1EC7m"
12913
+ },
12914
+ CODE: {
12915
+ required: ["KNOWLEDGE_EXPOSITION"],
12916
+ optional: ["LESSON_OBJECTIVES"],
12917
+ rationale: "Code lab th\u1EF1c h\xE0nh b\xE1m kh\xE1i ni\u1EC7m k\u1EF9 thu\u1EADt v\xE0 v\xED d\u1EE5 worked examples"
12918
+ },
12919
+ ACT: {
12920
+ required: ["CANONICAL_LESSON"],
12921
+ optional: ["KNOWLEDGE_EXPOSITION", "SESSION_SLICE"],
12922
+ rationale: "STEM Activity Lab b\u1EAFt bu\u1ED9c ph\u1EA3i kh\u1EDBp 100% Activity Sequence v\xE0 Lesson Flow c\u1EE7a LESSON"
12923
+ },
12924
+ WKS: {
12925
+ required: ["CANONICAL_LESSON"],
12926
+ optional: ["KNOWLEDGE_EXPOSITION"],
12927
+ rationale: "Phi\u1EBFu h\u1ECDc t\u1EADp (Worksheet) luy\u1EC7n t\u1EADp theo c\xE1c ch\u1EB7ng ho\u1EA1t \u0111\u1ED9ng c\u1EE7a gi\xE1o \xE1n"
12928
+ },
12929
+ GUIDE: {
12930
+ required: ["CANONICAL_LESSON"],
12931
+ optional: ["SESSION_SLICE"],
12932
+ rationale: "K\u1ECBch b\u1EA3n s\u01B0 ph\u1EA1m gi\xE1o vi\xEAn (Teacher Guide) b\xE1m s\xE1t timeline t\u1EEBng ph\xFAt c\u1EE7a LESSON"
12933
+ },
12934
+ SLIDE: {
12935
+ required: ["CANONICAL_LESSON"],
12936
+ optional: ["KNOWLEDGE_EXPOSITION"],
12937
+ rationale: "Slide b\xE0i gi\u1EA3ng tr\xECnh chi\u1EBFu theo c\u1EA5u tr\xFAc ph\xE2n ph\u1ED1i n\u1ED9i dung c\u1EE7a gi\xE1o \xE1n"
12938
+ },
12939
+ QUIZ: {
12940
+ required: ["KNOWLEDGE_EXPOSITION", "CANONICAL_LESSON"],
12941
+ optional: ["SESSION_SLICE"],
12942
+ rationale: "Ng\xE2n h\xE0ng c\xE2u h\u1ECFi \u0111\xE1nh gi\xE1 c\u1EA3 ki\u1EBFn th\u1EE9c chu\u1EA9n m\u1EF1c (KX) l\u1EABn m\u1EE5c ti\xEAu b\xE0i d\u1EA1y (LESSON)"
12943
+ }
12944
+ };
12945
+ function validateArtifactDependencies(artifactType, availableSources, opts = {}) {
12946
+ const normType = (artifactType || "").toUpperCase().trim();
12947
+ const rule = ARTIFACT_DEPENDENCY_ROUTING[normType];
12948
+ const failClosed = opts.failClosed ?? true;
12949
+ if (!rule) {
12950
+ return { valid: true, missing: [] };
12951
+ }
12952
+ const missing = [];
12953
+ for (const req of rule.required) {
12954
+ const val = availableSources[req];
12955
+ const isPresent = val !== void 0 && val !== null && (typeof val === "string" ? val.trim().length > 0 : true);
12956
+ if (!isPresent) {
12957
+ missing.push(req);
12958
+ }
12959
+ }
12960
+ if (missing.length > 0) {
12961
+ const err = createContextMissingError({
12962
+ artifactType: normType,
12963
+ missingSource: missing[0],
12964
+ lessonId: opts.lessonId,
12965
+ agent: opts.agent
12966
+ });
12967
+ if (failClosed) {
12968
+ throw err;
12969
+ }
12970
+ return { valid: false, missing, error: err };
12971
+ }
12972
+ return { valid: true, missing: [] };
12973
+ }
12974
+
12975
+ // src/services/singleArtifactService.ts
12500
12976
  function getArtifactMetadata(type, lessonId, pedagogy) {
12501
12977
  const id = lessonId || "ON_DEMAND";
12502
12978
  switch (type) {
@@ -12576,9 +13052,24 @@ async function generateSingleArtifact(req) {
12576
13052
  const templateContent = loadedTemplate || getDefaultFallbackTemplate(artifactType, displayTitle, lessonId || "ON_DEMAND");
12577
13053
  const hwStr = hardwarePlatform.join(", ");
12578
13054
  const selectedDevices = (config?.devices || (hardwarePlatform[0]?.toLowerCase().includes("paper") ? "paper-only" : "laptop")).toLowerCase();
12579
- const isBilingual = language.toLowerCase().includes("bilingual") || language.toLowerCase().includes("song");
12580
- const isVietnamese = !isBilingual && language.toLowerCase().includes("viet");
12581
- const langRule = isBilingual ? `1. AUTHORING LANGUAGE: Bilingual (Vietnamese - English). Headings and core conceptual definitions should be presented in Vietnamese with English technical terms in parentheses. Explanations and instructional text are in Vietnamese. Key code terms, comments, and challenge summaries are presented bilingually.` : isVietnamese ? `1. AUTHORING LANGUAGE: Vietnamese for all instructional text, explanations, questions, rubrics, and presenter notes. Programming code, syntax keywords, and standard API identifiers remain in standard English (with Vietnamese explanation comments/notes).` : `1. AUTHORING LANGUAGE: 100% English (Plan C Canonical Specification).`;
13055
+ language.toLowerCase().includes("bilingual") || language.toLowerCase().includes("song");
13056
+ const targetLang = resolveTargetLanguageCode(language);
13057
+ const langDirective = buildLanguageDirective(language);
13058
+ const headingDirective = buildHeadingDirective(
13059
+ artifactType.toUpperCase(),
13060
+ req.sectionLanguageContract,
13061
+ targetLang
13062
+ );
13063
+ const availableSources = {
13064
+ KNOWLEDGE_EXPOSITION: contextSot.exposition || researchContext,
13065
+ CANONICAL_LESSON: contextSot.lessonPlan,
13066
+ FRAMEWORK_EXCERPT: contextSot.framework
13067
+ };
13068
+ validateArtifactDependencies(artifactType.toUpperCase(), availableSources, {
13069
+ lessonId,
13070
+ agent: meta.persona,
13071
+ failClosed: req.failClosedContext ?? false
13072
+ });
12582
13073
  const isPaperOnly = selectedDevices === "paper-only" || hwStr.toLowerCase().includes("paper") || hwStr.toLowerCase().includes("print-ready");
12583
13074
  const deviceRule = isPaperOnly ? `
12584
13075
  - \u{1F4C4} PAPER-ONLY / NO-DEVICE ENVIRONMENT: The learning space has NO computers or screens. All exercises, worksheets, task cards, exit tickets, and code analyses MUST be 100% printable. Provide write-in blank boxes, printed code snippets with line numbers, tracing tables, and physical manipulative instructions.` : selectedDevices === "tablet" || selectedDevices === "smartphone" ? `
@@ -12599,7 +13090,8 @@ async function generateSingleArtifact(req) {
12599
13090
  Your task is to author a canonical, publication-grade learning artifact of type "${artifactType.toUpperCase()}".
12600
13091
 
12601
13092
  ### CORE OPERATIONAL INVARIANTS:
12602
- ${langRule}
13093
+ ${langDirective}
13094
+ ${headingDirective}
12603
13095
  2. NON-MOCK CODE INVARIANT: Any code snippet provided MUST be 100% syntactically valid, idiomatic, and executable without placeholders or fake functions.
12604
13096
  3. PEDAGOGICAL GROUNDING: Strictly align with the ${pedagogy.toUpperCase()} model, Bloom's Revised Taxonomy, and IEEE/ACM CS2023 guidelines.
12605
13097
  4. SCAFFOLDING LEVEL: "${scaffoldingLevel.toUpperCase()}".${scaffoldingRule}
@@ -12608,6 +13100,11 @@ ${langRule}
12608
13100
 
12609
13101
  IMAGE PLANNING (media ledger) \u2014 QUOTA GEN: t\u1ED1i \u0111a ${mediaPolicy.maxGenImagesPerArtifact} \u1EA3nh AI cho artifact n\xE0y (\u1EA3nh search kho kh\xF4ng gi\u1EDBi h\u1EA1n).
12610
13102
  Khi n\u1ED9i dung c\u1EA7n minh h\u1ECDa (diagram quy tr\xECnh, s\u01A1 \u0111\u1ED3 kh\xE1i ni\u1EC7m, step-by-step visual), ch\xE8n placeholder \u0111\xFAng format [IMAGE: slug] (slug ch\u1EEF th\u01B0\u1EDDng-g\u1EA1ch ngang, unique trong b\xE0i, vd img-for-loop-diagram) T\u1EA0I \u0110\xDANG CH\u1ED6 c\u1EA7n \u1EA3nh, tr\xEAn d\xF2ng ri\xEAng. KH\xD4NG t\u1EF1 sinh \u1EA3nh, KH\xD4NG d\xF9ng markdown image \u2014 placeholder s\u1EBD \u0111\u01B0\u1EE3c thay b\u1EB1ng \u1EA3nh th\u1EADt sau khi Media Curator duy\u1EC7t. Ch\u1EC9 \u0111\u1EB7t cho \u1EA3nh TH\u1EF0C S\u1EF0 c\u1EA7n thi\u1EBFt.` : ""}`;
13103
+ const slcContract = req.sectionLanguageContract;
13104
+ const frameworkExcerpt = contextSot.framework ? buildSectionAwareExcerpt(contextSot.framework, { budget: 2500, sectionLanguageContract: slcContract }).excerpt : "";
13105
+ const lessonPlanExcerpt = contextSot.lessonPlan ? buildLessonExcerpt(contextSot.lessonPlan, { budget: 8e3, sectionLanguageContract: slcContract, artifactType: "LESSON" }).excerpt : "";
13106
+ const handoutExcerpt = contextSot.handout ? buildSectionAwareExcerpt(contextSot.handout, { budget: 2e3, sectionLanguageContract: slcContract }).excerpt : "";
13107
+ const expositionExcerpt = contextSot.exposition ? buildExpositionExcerpt(contextSot.exposition, { budget: 6e3, sectionLanguageContract: slcContract }).excerpt : "";
12611
13108
  const userPrompt = `### CONTEXT GROUND TRUTH:
12612
13109
  - Topic / Concept Domain: "${topic}"
12613
13110
  - Lesson ID: "${lessonId || "ON_DEMAND"}"
@@ -12625,14 +13122,17 @@ ${selectedDevices ? `- Device Mode: "${selectedDevices}"
12625
13122
  ${researchContext ? `### RESEARCH GROUND TRUTH (fact-checked context \u2014 \u01B0u ti\xEAn d\xF9ng, KH\xD4NG b\u1ECBa s\u1ED1 li\u1EC7u):
12626
13123
  ${researchContext.slice(0, 4e3)}
12627
13124
  ` : ""}
12628
- ${contextSot.framework ? `### SOT CURRICULUM FRAMEWORK:
12629
- ${contextSot.framework.slice(0, 1500)}
13125
+ ${expositionExcerpt ? `### SOT KNOWLEDGE EXPOSITION (CANONICAL KNOWLEDGE \u2014 teach from this, do not contradict):
13126
+ ${expositionExcerpt}
13127
+ ` : ""}
13128
+ ${frameworkExcerpt ? `### SOT CURRICULUM FRAMEWORK:
13129
+ ${frameworkExcerpt}
12630
13130
  ` : ""}
12631
- ${contextSot.lessonPlan ? `### SOT CANONICAL LESSON PLAN:
12632
- ${contextSot.lessonPlan.slice(0, 1500)}
13131
+ ${lessonPlanExcerpt ? `### SOT CANONICAL LESSON PLAN:
13132
+ ${lessonPlanExcerpt}
12633
13133
  ` : ""}
12634
- ${contextSot.handout ? `### SOT STUDENT HANDOUT:
12635
- ${contextSot.handout.slice(0, 1e3)}
13134
+ ${handoutExcerpt ? `### SOT STUDENT HANDOUT:
13135
+ ${handoutExcerpt}
12636
13136
  ` : ""}
12637
13137
 
12638
13138
  ### MANDATORY CANONICAL TEMPLATE CONTRACT:
@@ -12721,9 +13221,16 @@ ${yaml.trim()}
12721
13221
  const verdict = await LLMJudgeEngine.evaluateArtifactWithLLM({
12722
13222
  targetArtifactType: artifactType.toUpperCase(),
12723
13223
  lessonId: lessonId || "ON_DEMAND",
12724
- expectedLanguage: language.toLowerCase().includes("viet") ? "vietnamese" : "english",
13224
+ expectedLanguage: targetLang || "en",
12725
13225
  targetObjectives: judgeObjectives,
12726
- generatedContentJson: JSON.stringify({ content: finalContent, artifactType, lessonId: lessonId || "ON_DEMAND", title: displayTitle })
13226
+ generatedContentJson: JSON.stringify({
13227
+ content: finalContent,
13228
+ artifactType,
13229
+ lessonId: lessonId || "ON_DEMAND",
13230
+ title: displayTitle,
13231
+ canonicalLessonExcerpt: lessonPlanExcerpt || void 0,
13232
+ canonicalExposition: expositionExcerpt || void 0
13233
+ })
12727
13234
  });
12728
13235
  const passed = Boolean(verdict.passed) && verdict.score >= 85;
12729
13236
  if (passed) {
@@ -12765,9 +13272,16 @@ ${finalContent}` }
12765
13272
  const reVerdict = await LLMJudgeEngine.evaluateArtifactWithLLM({
12766
13273
  targetArtifactType: artifactType.toUpperCase(),
12767
13274
  lessonId: lessonId || "ON_DEMAND",
12768
- expectedLanguage: language.toLowerCase().includes("viet") ? "vietnamese" : "english",
13275
+ expectedLanguage: targetLang || "en",
12769
13276
  targetObjectives: judgeObjectives,
12770
- generatedContentJson: JSON.stringify({ content: repaired, artifactType, lessonId: lessonId || "ON_DEMAND", title: displayTitle })
13277
+ generatedContentJson: JSON.stringify({
13278
+ content: repaired,
13279
+ artifactType,
13280
+ lessonId: lessonId || "ON_DEMAND",
13281
+ title: displayTitle,
13282
+ canonicalLessonExcerpt: lessonPlanExcerpt || void 0,
13283
+ canonicalExposition: expositionExcerpt || void 0
13284
+ })
12771
13285
  });
12772
13286
  if (reVerdict.passed && reVerdict.score >= 85) {
12773
13287
  return {
@@ -16718,6 +17232,6 @@ function renderMediaPlaceholder(entry) {
16718
17232
  return `> \u{1F5BC}\uFE0F [\u1EA2nh \u0111ang ch\u1EDD: ${entry.name} \u2014 s\u1EBD \u0111\u01B0\u1EE3c t\u1EA1o sau khi duy\u1EC7t media]`;
16719
17233
  }
16720
17234
 
16721
- export { ACT_TEMPLATE, ARTIFACT_EXECUTION_ORDER, AcademicAuditor, ActiveLearningWorkflowSchema, ActivityLabSchema, ActivitySeqRowSchema, ActivityStepSchema, ArtifactContractRowSchema, AssessmentMapRowSchema, AssessmentObjectiveSchema, BELL_RINGER_TEMPLATE, BLOOM_ACTION_VERBS, BOM_TEMPLATE, BUNDLED_STANDARDS_PACK_IDS, BellRingerDaySchema, BellRingerSchema, BloomHintSchema, BloomLevelSchema, BloomTaxonomyEvaluator, BronzeTierSchema, CERConclusionSchema, CHOICE_BOARD_TEMPLATE, CODE_LAB_TEMPLATE, CURRICULUM_SLASH_COMMANDS, CardTierEnum, ChoiceBoardRubricRowSchema, ChoiceBoardSchema, ChoiceRuleSchema, ChoiceSquareSchema, ClassificationSchema, CodeHardwareFeasibilityEvaluator, CodeLabSchema, CodeSnippetSchema, CompetencyRubricRowSchema, ComputationalThinkingSchema, ConstructiveAlignmentEvaluator, CoreConceptSchema, CourseObjectiveSchema, CoverageReportSchema, CrossArtifactDriftEvaluator, CurriculumArtifactSchema, CurriculumError, CurriculumPlanSchema, CurriculumQualityReportSchema, DEFAULT_ARTIFACT_STREAM_IDLE_MS, DEFAULT_ARTIFACT_STREAM_TOTAL_MS, DEFAULT_ENABLED_PROVIDERS, DEFAULT_GATE_SETTINGS, DEFAULT_STREAM_IDLE_MS, DEFAULT_STREAM_TOTAL_MS, DependencyEdgeSchema, DepthAssignmentSchema, DepthLevelSchema, DeterministicPipelineRunner, DeterministicStructuralLinter, DiagnosticQuestionSchema, DiagnosticQuizSchema, EDPPhaseEnum, EXIT_TICKET_TEMPLATE, EXPOSITION_REL, EXT_TEMPLATE, EntryLevelSchema, ExitTicketBugHuntSchema, ExitTicketMetacognitionSchema, ExitTicketQuickItemSchema, ExitTicketRecallPromptSchema, ExitTicketSchema, ExperimentalDesignSchema, ExpositionApprovalError, ExtensionChallengeSchema, ExtensionSchema, FileSystemCurriculumAdapter, FiveEFlowPhaseSchema, FiveEInstructionalEvaluator, FiveEPhaseEnum, FrameworkMappingSchema, FrameworkPackManifestSchema, FrameworkPackSchema, FrameworkStatementSchema, GLOSSARY_TEMPLATE, GRAPHIC_ORGANIZER_TEMPLATE, GlossaryQuickRefRowSchema, GlossarySchema, GlossaryTermSchema, GoldTierSchema, GradeBandSchema, GraphicOrganizerItemSchema, GraphicOrganizerSchema, HANDOUT_TEMPLATE, HandoutSchema, HandoutSectionSchema, InstructionSectionSchema, InstructionStepSchema, JudgeCriterionSchema, LAYER_TOTAL_BUDGET_MS, LESSON_PLAN_TEMPLATE, LLMJudgeEngine, LabTierTaskSchema, LearningObjectiveInputSchema, LearningObjectiveRowSchema, LessonFlowPhaseSchema, LessonPlan5ESchema, LessonPlanEDPSchema, LessonPlanSchema, LessonSectionSchema, LocalWorkspaceManager, MappingKindSchema, MarpSlideSchema, MediaError, MediaLedger, MentorCheatsheetSchema, MilestoneInputSchema, MisconceptionEvaluator, MisconceptionSchema, ModelPolicyResolver, NVIDIA_MODELS, NodeKindSchema, OrganizerTypeEnum, PROJECT_INSTRUCTION_TEMPLATE, PhaseInputSchema, PlanConstraintsSchema, PlannerInputSchema, PlanningGraphSchema, PlanningNodeSchema, PrerequisiteDecisionEntrySchema, PrerequisiteDecisionSchema, ProductGoalSchema, ProgressiveHintsSchema, ProjectGraphSchema, ProjectInstructionSchema, ProjectProfileSchema, QUIZ_TEMPLATE, QualityAuditVerdictSchema, QuizOptionSchema, REVIEW_GAME_TEMPLATE, RUBRIC_TEMPLATE, RecordProvenanceSchema, ResourceMapRowSchema, ReviewGameExportRowSchema, ReviewGameQuestionSchema, ReviewGameSchema, RoadmapInputSchema, RotationStationSchema, RubricCriteriaSchema, RubricSchema, SCIENCE_LAB_TEMPLATE, SELF_LAB_TEMPLATE, SLIDE_LAYOUT_PRESETS, SLIDE_TEMPLATE, STANDARD_SOT_FILES, STATION_ROTATION_TEMPLATE, ScaffoldDecisionEntrySchema, ScaffoldDecisionSchema, ScienceLabSchema, ScoringRubricRowSchema, SelfLabSchema, SelfPacedBundleSchema, SelfPacedChallengeSchema, SessionPlanSchema, SilverTierSchema, SlideDeckSchema, StandardizedTermRowSchema, StandardsRegistryAdapter, StationRecordRowSchema, StationRotationSchema, StationTypeEnum, SupabaseCurriculumAdapter, TASK_CARDS_TEMPLATE, TEACHER_GUIDE_TEMPLATE, TIERED_PRACTICE_TEMPLATE, TaskCardSchema, TaskCardsSchema, TeacherGuideSchema, TeachingScriptPhaseSchema, TierLevelEnum, TierObjectiveSchema, TieredPracticeSchema, TranslationPolicySchema, TroubleshootingEntrySchema, TroubleshootingRowSchema, UnitPlanSchema, UserJourneySchema, WORKSHEET_TEMPLATE, WorksheetItemSchema, WorksheetItemTypeEnum, WorksheetPartSchema, WorksheetSchema, activityTools, analystTools, analyzeProjectCreationIntent, assertAcyclic, assessorTools, auditCurriculumQualityFlow, auditQualityReport, buildActivityPrompt, buildCodeLabPrompt, buildCurriculumContext, buildCurriculumPlan, buildDeliveryPackages, buildDiagnosticQuizPrompt, buildExpositionContext, buildExtensionPrompt, buildHandoutPrompt, buildImagePrompt, buildJudgePrompt, buildLessonMasterPrompt, buildProjectInstructionPrompt, buildSelfLabPrompt, buildSessionSliceContext, buildSlidesPrompt, buildStandardStackMarkdown, buildStandardsContext, buildStandardsContextBlock, buildTeacherGuidePrompt, buildWorksheetPrompt, closeTruncatedJson, computeContentHash, computePackingSpec, conductPreliminaryResearch, contentTools, convertRoadmapToFoundationSot, createAiInferenceError, createCurriculumStorage, createIdleAbortController, createStreamAbortController, createStreamAbortSignal, createStreamChunkExtractor, curateMediaLedger, designerTools, detectProjectPedagogy, ensureExpositionForLesson, ensureKnowledgeExposition, evaluateStandardsCoverage, executeCurriculumCommand, exportAllProjectQuizzes, expositionCacheKey, extractScopeSequenceRows, extractSessionSlice, extractStreamChunk, extractThoughtAndContent, formatQuizzesToCsv, fulfillMediaLedger, gateModeFor, generateActivityFlow, generateCodeLabFlow, generateDiagnosticQuizFlow, generateEducationalImage, generateExtensionFlow, generateHandoutFlow, generateLessonMasterFlow, generateMilestoneCurriculumBundle, generatePhase1SotArtifacts, generatePhase2SotArtifacts, generateProjectInstruction, generateProjectInstructionFlow, generateRoadmapCurriculum, generateSelfLabFlow, generateSelfPacedBundle, generateSingleArtifact, generateSlidesFlow, generateTeacherGuideFlow, generateWorksheetFlow, getAIModel, getArtifactMetadata, getDesignatedFallbackChain, getDesignatedFallbackConfig, getLessonMetadata, getProjectArtifactScope, getProjectStatusReport, getSlideLayoutPresetById, getSlideLayoutPresetsByCategory, getSmartResumeContext, glossaryTermsForSession, illustratorTools, importRoadmapToProject, ingestProjectGraphIntoProject, initializeProjectInStorage, injectMediaIntoMarkdown, isExpositionFresh, isModelAllowed, isProviderEnabled, isTranslationDue, lintAndSanitizeArtifact, lintCurriculumFramework, lintFrameworkPack, loadCurriculumTemplate, loadSotTemplate, normalizePlanningGraph, packagerTools, parseGateSettings, parseQuizMarkdown, parseRoadmapJsonToProjectPayload, produceBatchLessons, produceSingleLesson, publishToGitHub, publishToSupabase, rankGenCandidates, renderFrameworkFromPlan, renderMediaPlaceholder, researcherTools, resolveGateSettings, resolveStandardsPacks, resolveStreamBudget, resolveTranslationTargets, reviewerTools, runCurriculumAIInference, safeParseJson, searchEducationalImages, searchEducationalVideos, selectStatementsForLesson, serializeActivityToMarkdown, serializeCodeLabToMarkdown, serializeDiagnosticQuizToMarkdown, serializeHandoutToMarkdown, serializeLessonToMarkdown, serializeProjectInstructionToMarkdown, serializeSelfLabToMarkdown, slugifyProjectName, streamCurriculumAIInference, streamCurriculumAIInferenceWithTools, streamDiagnosticQuizFlow, streamLLMWithFallback, streamLayerPrefillWithFallback, streamLessonMasterFlow, streamSelfLabFlow, stripLlmJsonWrappers, techSmeTools, topoSort, uploadAssetToBucket, validateCurriculumPlan, validateFrameworkPack, validateMarkdownTables, validateMermaidSyntax, withAutoRepair };
17235
+ export { ACT_TEMPLATE, ARTIFACT_DEPENDENCY_ROUTING, ARTIFACT_EXECUTION_ORDER, AcademicAuditor, ActiveLearningWorkflowSchema, ActivityLabSchema, ActivitySeqRowSchema, ActivityStepSchema, ArtifactContractRowSchema, AssessmentMapRowSchema, AssessmentObjectiveSchema, BELL_RINGER_TEMPLATE, BLOOM_ACTION_VERBS, BOM_TEMPLATE, BUNDLED_STANDARDS_PACK_IDS, BellRingerDaySchema, BellRingerSchema, BloomHintSchema, BloomLevelSchema, BloomTaxonomyEvaluator, BronzeTierSchema, CERConclusionSchema, CHOICE_BOARD_TEMPLATE, CODE_LAB_TEMPLATE, CURRICULUM_SLASH_COMMANDS, CardTierEnum, ChoiceBoardRubricRowSchema, ChoiceBoardSchema, ChoiceRuleSchema, ChoiceSquareSchema, ClassificationSchema, CodeHardwareFeasibilityEvaluator, CodeLabSchema, CodeSnippetSchema, CompetencyRubricRowSchema, ComputationalThinkingSchema, ConstructiveAlignmentEvaluator, CoreConceptSchema, CourseObjectiveSchema, CoverageReportSchema, CrossArtifactDriftEvaluator, CurriculumArtifactSchema, CurriculumError, CurriculumPlanSchema, CurriculumQualityReportSchema, DEFAULT_ARTIFACT_STREAM_IDLE_MS, DEFAULT_ARTIFACT_STREAM_TOTAL_MS, DEFAULT_ENABLED_PROVIDERS, DEFAULT_GATE_SETTINGS, DEFAULT_KX_PRIORITIES, DEFAULT_LESSON_PRIORITIES, DEFAULT_STREAM_IDLE_MS, DEFAULT_STREAM_TOTAL_MS, DependencyEdgeSchema, DepthAssignmentSchema, DepthLevelSchema, DeterministicPipelineRunner, DeterministicStructuralLinter, DiagnosticQuestionSchema, DiagnosticQuizSchema, EDPPhaseEnum, EXIT_TICKET_TEMPLATE, EXPOSITION_REL, EXT_TEMPLATE, EntryLevelSchema, ExitTicketBugHuntSchema, ExitTicketMetacognitionSchema, ExitTicketQuickItemSchema, ExitTicketRecallPromptSchema, ExitTicketSchema, ExperimentalDesignSchema, ExpositionApprovalError, ExtensionChallengeSchema, ExtensionSchema, FileSystemCurriculumAdapter, FiveEFlowPhaseSchema, FiveEInstructionalEvaluator, FiveEPhaseEnum, FrameworkMappingSchema, FrameworkPackManifestSchema, FrameworkPackSchema, FrameworkStatementSchema, GLOSSARY_TEMPLATE, GRAPHIC_ORGANIZER_TEMPLATE, GlossaryQuickRefRowSchema, GlossarySchema, GlossaryTermSchema, GoldTierSchema, GradeBandSchema, GraphicOrganizerItemSchema, GraphicOrganizerSchema, HANDOUT_TEMPLATE, HandoutSchema, HandoutSectionSchema, InstructionSectionSchema, InstructionStepSchema, JudgeCriterionSchema, LAYER_TOTAL_BUDGET_MS, LESSON_PLAN_TEMPLATE, LLMJudgeEngine, LabTierTaskSchema, LearningObjectiveInputSchema, LearningObjectiveRowSchema, LessonFlowPhaseSchema, LessonPlan5ESchema, LessonPlanEDPSchema, LessonPlanSchema, LessonSectionSchema, LocalWorkspaceManager, MappingKindSchema, MarpSlideSchema, MediaError, MediaLedger, MentorCheatsheetSchema, MilestoneInputSchema, MisconceptionEvaluator, MisconceptionSchema, ModelPolicyResolver, NVIDIA_MODELS, NodeKindSchema, OrganizerTypeEnum, PROJECT_INSTRUCTION_TEMPLATE, PhaseInputSchema, PlanConstraintsSchema, PlannerInputSchema, PlanningGraphSchema, PlanningNodeSchema, PrerequisiteDecisionEntrySchema, PrerequisiteDecisionSchema, ProductGoalSchema, ProgressiveHintsSchema, ProjectGraphSchema, ProjectInstructionSchema, ProjectProfileSchema, QUIZ_TEMPLATE, QualityAuditVerdictSchema, QuizOptionSchema, REVIEW_GAME_TEMPLATE, RUBRIC_TEMPLATE, RecordProvenanceSchema, ResourceMapRowSchema, ReviewGameExportRowSchema, ReviewGameQuestionSchema, ReviewGameSchema, RoadmapInputSchema, RotationStationSchema, RubricCriteriaSchema, RubricSchema, SCIENCE_LAB_TEMPLATE, SELF_LAB_TEMPLATE, SLIDE_CANONICAL_METHODOLOGY, SLIDE_LAYOUT_PRESETS, SLIDE_TEMPLATE, STANDARD_SOT_FILES, STATION_ROTATION_TEMPLATE, ScaffoldDecisionEntrySchema, ScaffoldDecisionSchema, ScienceLabSchema, ScoringRubricRowSchema, SelfLabSchema, SelfPacedBundleSchema, SelfPacedChallengeSchema, SessionPlanSchema, SilverTierSchema, SlideDeckSchema, StandardizedTermRowSchema, StandardsRegistryAdapter, StationRecordRowSchema, StationRotationSchema, StationTypeEnum, SupabaseCurriculumAdapter, TASK_CARDS_TEMPLATE, TEACHER_GUIDE_TEMPLATE, TIERED_PRACTICE_TEMPLATE, TaskCardSchema, TaskCardsSchema, TeacherGuideSchema, TeachingScriptPhaseSchema, TierLevelEnum, TierObjectiveSchema, TieredPracticeSchema, TranslationPolicySchema, TroubleshootingEntrySchema, TroubleshootingRowSchema, UnitPlanSchema, UserJourneySchema, WORKSHEET_TEMPLATE, WorksheetItemSchema, WorksheetItemTypeEnum, WorksheetPartSchema, WorksheetSchema, activityTools, analystTools, analyzeProjectCreationIntent, assertAcyclic, assessorTools, auditCurriculumQualityFlow, auditQualityReport, buildActivityPrompt, buildCodeLabPrompt, buildCurriculumContext, buildCurriculumPlan, buildDeliveryPackages, buildDiagnosticQuizPrompt, buildExpositionContext, buildExpositionExcerpt, buildExtensionPrompt, buildHandoutPrompt, buildHeadingDirective, buildImagePrompt, buildJudgePrompt, buildLanguageDirective, buildLessonExcerpt, buildLessonMasterPrompt, buildMarpMarkdownSlidePrompt, buildProjectInstructionPrompt, buildSectionAwareExcerpt, buildSelfLabPrompt, buildSessionSliceContext, buildSlidesPrompt, buildStandardStackMarkdown, buildStandardsContext, buildStandardsContextBlock, buildTeacherGuidePrompt, buildWorksheetPrompt, closeTruncatedJson, computeContentHash, computePackingSpec, conductPreliminaryResearch, contentTools, convertRoadmapToFoundationSot, createAiInferenceError, createContextMissingError, createCurriculumStorage, createIdleAbortController, createStreamAbortController, createStreamAbortSignal, createStreamChunkExtractor, curateMediaLedger, designerTools, detectProjectPedagogy, ensureExpositionForLesson, ensureKnowledgeExposition, evaluateStandardsCoverage, executeCurriculumCommand, exportAllProjectQuizzes, expositionCacheKey, extractScopeSequenceRows, extractSectionHeadingsFromSLC, extractSessionSlice, extractStreamChunk, extractThoughtAndContent, formatQuizzesToCsv, fulfillMediaLedger, gateModeFor, generateActivityFlow, generateCodeLabFlow, generateDiagnosticQuizFlow, generateEducationalImage, generateExtensionFlow, generateHandoutFlow, generateLessonMasterFlow, generateMilestoneCurriculumBundle, generatePhase1SotArtifacts, generatePhase2SotArtifacts, generateProjectInstruction, generateProjectInstructionFlow, generateRoadmapCurriculum, generateSelfLabFlow, generateSelfPacedBundle, generateSingleArtifact, generateSlidesFlow, generateTeacherGuideFlow, generateWorksheetFlow, getAIModel, getArtifactMetadata, getDesignatedFallbackChain, getDesignatedFallbackConfig, getLessonMetadata, getProjectArtifactScope, getProjectStatusReport, getSlideLayoutPresetById, getSlideLayoutPresetsByCategory, getSmartResumeContext, glossaryTermsForSession, illustratorTools, importRoadmapToProject, ingestProjectGraphIntoProject, initializeProjectInStorage, injectMediaIntoMarkdown, isExpositionFresh, isModelAllowed, isProviderEnabled, isTranslationDue, lintAndSanitizeArtifact, lintCurriculumFramework, lintFrameworkPack, loadCurriculumTemplate, loadSotTemplate, normalizePlanningGraph, normalizeSlcContract, packagerTools, parseGateSettings, parseQuizMarkdown, parseRoadmapJsonToProjectPayload, produceBatchLessons, produceSingleLesson, publishToGitHub, publishToSupabase, rankGenCandidates, renderFrameworkFromPlan, renderMediaPlaceholder, researcherTools, resolveGateSettings, resolveStandardsPacks, resolveStreamBudget, resolveTargetLanguageCode, resolveTranslationTargets, reviewerTools, runCurriculumAIInference, safeParseJson, searchEducationalImages, searchEducationalVideos, selectStatementsForLesson, serializeActivityToMarkdown, serializeCodeLabToMarkdown, serializeDiagnosticQuizToMarkdown, serializeHandoutToMarkdown, serializeLessonToMarkdown, serializeProjectInstructionToMarkdown, serializeSelfLabToMarkdown, slugifyProjectName, streamCurriculumAIInference, streamCurriculumAIInferenceWithTools, streamDiagnosticQuizFlow, streamLLMWithFallback, streamLayerPrefillWithFallback, streamLessonMasterFlow, streamSelfLabFlow, stripLlmJsonWrappers, targetLanguageDisplayName, techSmeTools, topoSort, uploadAssetToBucket, validateArtifactDependencies, validateCurriculumPlan, validateFrameworkPack, validateMarkdownTables, validateMermaidSyntax, withAutoRepair };
16722
17236
  //# sourceMappingURL=index.mjs.map
16723
17237
  //# sourceMappingURL=index.mjs.map