@thanh01.pmt/curriculum-kit 1.0.2 → 1.0.3

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.
@@ -1,4 +1,4 @@
1
- export { I as ApprovalPayload, y as CurriculumArtifactType, C as CurriculumGateMode, D as DEFAULT_GATE_SETTINGS, L as ExecuteWithRateLimitOptions, z as GateSettings, G as GenerateMasterLessonStepInput, Q as GenerateRoadmapWorkflowInput, J as JudgeMasterLessonStepInput, q as JudgeSatelliteStepInput, N as MilestoneWorkflowInput, O as MilestoneWorkflowResult, e as RepairMasterLessonStepInput, R as ResolvedGateSettings, T as RoadmapWorkflowSummary, t as SaveMilestoneArtifactsInput, u as SavedMilestoneResult, H as approvalPayloadSchema, V as executeSingleArtifactStep, F as gateModeFor, f as generateActivityStep, h as generateCodeLabStep, k as generateDiagnosticQuizStep, p as generateExtensionStep, m as generateHandoutStep, d as generateMasterLessonStep, P as generateMilestoneWorkflow, U as generateRoadmapWorkflow, i as generateSelfLabStep, W as generateSingleArtifactWorkflow, l as generateSlidesStep, o as generateTeacherGuideStep, n as generateWorksheetStep, j as judgeMasterLessonStep, s as judgeSatelliteStep, K as lessonApprovalHook, B as parseGateSettings, w as publishToGitStep, x as publishToSupabaseStep, r as repairMasterLessonStep, E as resolveGateSettings, v as saveMilestoneToWorkspaceStep, M as withRateLimitBackoff } from '../index-PDw11tpD.cjs';
1
+ export { I as ApprovalPayload, y as CurriculumArtifactType, C as CurriculumGateMode, D as DEFAULT_GATE_SETTINGS, L as ExecuteWithRateLimitOptions, z as GateSettings, G as GenerateMasterLessonStepInput, Q as GenerateRoadmapWorkflowInput, J as JudgeMasterLessonStepInput, q as JudgeSatelliteStepInput, N as MilestoneWorkflowInput, O as MilestoneWorkflowResult, e as RepairMasterLessonStepInput, R as ResolvedGateSettings, T as RoadmapWorkflowSummary, t as SaveMilestoneArtifactsInput, u as SavedMilestoneResult, H as approvalPayloadSchema, V as executeSingleArtifactStep, F as gateModeFor, f as generateActivityStep, h as generateCodeLabStep, k as generateDiagnosticQuizStep, p as generateExtensionStep, m as generateHandoutStep, d as generateMasterLessonStep, P as generateMilestoneWorkflow, U as generateRoadmapWorkflow, i as generateSelfLabStep, W as generateSingleArtifactWorkflow, l as generateSlidesStep, o as generateTeacherGuideStep, n as generateWorksheetStep, j as judgeMasterLessonStep, s as judgeSatelliteStep, K as lessonApprovalHook, B as parseGateSettings, w as publishToGitStep, x as publishToSupabaseStep, r as repairMasterLessonStep, E as resolveGateSettings, v as saveMilestoneToWorkspaceStep, M as withRateLimitBackoff } from '../index-BIhxrUEa.cjs';
2
2
  import '../schemas/index.cjs';
3
3
  import 'zod';
4
4
  import '../provider-factory-DH3udYlN.cjs';
@@ -1,4 +1,4 @@
1
- export { I as ApprovalPayload, y as CurriculumArtifactType, C as CurriculumGateMode, D as DEFAULT_GATE_SETTINGS, L as ExecuteWithRateLimitOptions, z as GateSettings, G as GenerateMasterLessonStepInput, Q as GenerateRoadmapWorkflowInput, J as JudgeMasterLessonStepInput, q as JudgeSatelliteStepInput, N as MilestoneWorkflowInput, O as MilestoneWorkflowResult, e as RepairMasterLessonStepInput, R as ResolvedGateSettings, T as RoadmapWorkflowSummary, t as SaveMilestoneArtifactsInput, u as SavedMilestoneResult, H as approvalPayloadSchema, V as executeSingleArtifactStep, F as gateModeFor, f as generateActivityStep, h as generateCodeLabStep, k as generateDiagnosticQuizStep, p as generateExtensionStep, m as generateHandoutStep, d as generateMasterLessonStep, P as generateMilestoneWorkflow, U as generateRoadmapWorkflow, i as generateSelfLabStep, W as generateSingleArtifactWorkflow, l as generateSlidesStep, o as generateTeacherGuideStep, n as generateWorksheetStep, j as judgeMasterLessonStep, s as judgeSatelliteStep, K as lessonApprovalHook, B as parseGateSettings, w as publishToGitStep, x as publishToSupabaseStep, r as repairMasterLessonStep, E as resolveGateSettings, v as saveMilestoneToWorkspaceStep, M as withRateLimitBackoff } from '../index-BAUtASfr.js';
1
+ export { I as ApprovalPayload, y as CurriculumArtifactType, C as CurriculumGateMode, D as DEFAULT_GATE_SETTINGS, L as ExecuteWithRateLimitOptions, z as GateSettings, G as GenerateMasterLessonStepInput, Q as GenerateRoadmapWorkflowInput, J as JudgeMasterLessonStepInput, q as JudgeSatelliteStepInput, N as MilestoneWorkflowInput, O as MilestoneWorkflowResult, e as RepairMasterLessonStepInput, R as ResolvedGateSettings, T as RoadmapWorkflowSummary, t as SaveMilestoneArtifactsInput, u as SavedMilestoneResult, H as approvalPayloadSchema, V as executeSingleArtifactStep, F as gateModeFor, f as generateActivityStep, h as generateCodeLabStep, k as generateDiagnosticQuizStep, p as generateExtensionStep, m as generateHandoutStep, d as generateMasterLessonStep, P as generateMilestoneWorkflow, U as generateRoadmapWorkflow, i as generateSelfLabStep, W as generateSingleArtifactWorkflow, l as generateSlidesStep, o as generateTeacherGuideStep, n as generateWorksheetStep, j as judgeMasterLessonStep, s as judgeSatelliteStep, K as lessonApprovalHook, B as parseGateSettings, w as publishToGitStep, x as publishToSupabaseStep, r as repairMasterLessonStep, E as resolveGateSettings, v as saveMilestoneToWorkspaceStep, M as withRateLimitBackoff } from '../index-BvWC_xXe.js';
2
2
  import '../schemas/index.js';
3
3
  import 'zod';
4
4
  import '../provider-factory-DH3udYlN.js';
@@ -1,5 +1,5 @@
1
1
  import fs from 'fs';
2
- import path from 'path';
2
+ import path4 from 'path';
3
3
  import { generateObject } from 'ai';
4
4
  import { createGoogleGenerativeAI } from '@ai-sdk/google';
5
5
  import { createOpenAI } from '@ai-sdk/openai';
@@ -128,14 +128,14 @@ function resolveApiKey(keyName, explicitKey) {
128
128
  try {
129
129
  const currentDir = process.cwd();
130
130
  const envPaths = [
131
- path.resolve(currentDir, ".env.local"),
132
- path.resolve(currentDir, ".env"),
133
- path.resolve(currentDir, "apps/web/.env.local"),
134
- path.resolve(currentDir, "packages/learnwell-platform/.env"),
135
- path.resolve(currentDir, "..", ".env.local"),
136
- path.resolve(currentDir, "..", ".env"),
137
- path.resolve(currentDir, "../..", ".env.local"),
138
- path.resolve(currentDir, "../..", ".env")
131
+ path4.resolve(currentDir, ".env.local"),
132
+ path4.resolve(currentDir, ".env"),
133
+ path4.resolve(currentDir, "apps/web/.env.local"),
134
+ path4.resolve(currentDir, "packages/learnwell-platform/.env"),
135
+ path4.resolve(currentDir, "..", ".env.local"),
136
+ path4.resolve(currentDir, "..", ".env"),
137
+ path4.resolve(currentDir, "../..", ".env.local"),
138
+ path4.resolve(currentDir, "../..", ".env")
139
139
  ];
140
140
  for (const envPath of envPaths) {
141
141
  if (fs.existsSync(envPath)) {
@@ -4574,10 +4574,10 @@ ${answerKeySection}
4574
4574
  var LocalWorkspaceManager = class {
4575
4575
  baseDir;
4576
4576
  constructor(baseDir) {
4577
- this.baseDir = baseDir || path.resolve(process.cwd(), "output", "workspace-jobs");
4577
+ this.baseDir = baseDir || path4.resolve(process.cwd(), "output", "workspace-jobs");
4578
4578
  }
4579
4579
  getJobDirectory(jobId) {
4580
- return path.join(this.baseDir, jobId);
4580
+ return path4.join(this.baseDir, jobId);
4581
4581
  }
4582
4582
  async initJobWorkspace(jobId, initialInfo) {
4583
4583
  const jobDir = this.getJobDirectory(jobId);
@@ -4600,9 +4600,9 @@ var LocalWorkspaceManager = class {
4600
4600
  }
4601
4601
  async saveArtifact(jobId, milestoneSlug, filename, content, artifactType) {
4602
4602
  const jobDir = this.getJobDirectory(jobId);
4603
- const targetDir = path.join(jobDir, milestoneSlug);
4603
+ const targetDir = path4.join(jobDir, milestoneSlug);
4604
4604
  await fs2.mkdir(targetDir, { recursive: true });
4605
- const filePath = path.join(targetDir, filename);
4605
+ const filePath = path4.join(targetDir, filename);
4606
4606
  await fs2.writeFile(filePath, content, "utf-8");
4607
4607
  const stat = await fs2.stat(filePath);
4608
4608
  const manifest = await this.getManifest(jobId);
@@ -4610,7 +4610,7 @@ var LocalWorkspaceManager = class {
4610
4610
  manifest.artifacts.push({
4611
4611
  milestoneId: milestoneSlug,
4612
4612
  artifactType,
4613
- filePath: path.relative(jobDir, filePath),
4613
+ filePath: path4.relative(jobDir, filePath),
4614
4614
  sizeBytes: stat.size,
4615
4615
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
4616
4616
  });
@@ -4620,7 +4620,7 @@ var LocalWorkspaceManager = class {
4620
4620
  return filePath;
4621
4621
  }
4622
4622
  async getManifest(jobId) {
4623
- const manifestPath = path.join(this.getJobDirectory(jobId), "manifest.json");
4623
+ const manifestPath = path4.join(this.getJobDirectory(jobId), "manifest.json");
4624
4624
  try {
4625
4625
  const data = await fs2.readFile(manifestPath, "utf-8");
4626
4626
  return JSON.parse(data);
@@ -4629,7 +4629,7 @@ var LocalWorkspaceManager = class {
4629
4629
  }
4630
4630
  }
4631
4631
  async saveManifest(jobId, manifest) {
4632
- const manifestPath = path.join(this.getJobDirectory(jobId), "manifest.json");
4632
+ const manifestPath = path4.join(this.getJobDirectory(jobId), "manifest.json");
4633
4633
  manifest.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
4634
4634
  await fs2.writeFile(manifestPath, JSON.stringify(manifest, null, 2), "utf-8");
4635
4635
  }
@@ -4670,12 +4670,12 @@ async function publishToGitHub(options) {
4670
4670
  async function scanDir(currentDir) {
4671
4671
  const entries = await fs2.readdir(currentDir, { withFileTypes: true });
4672
4672
  for (const entry of entries) {
4673
- const fullPath = path.join(currentDir, entry.name);
4673
+ const fullPath = path4.join(currentDir, entry.name);
4674
4674
  if (entry.isDirectory()) {
4675
4675
  await scanDir(fullPath);
4676
4676
  } else if (entry.isFile() && !entry.name.startsWith(".")) {
4677
4677
  const content = await fs2.readFile(fullPath, "utf-8");
4678
- const relPath = path.relative(options.localJobDir, fullPath);
4678
+ const relPath = path4.relative(options.localJobDir, fullPath);
4679
4679
  filesToUpload.push({ path: relPath, content });
4680
4680
  }
4681
4681
  }
@@ -5892,16 +5892,18 @@ init_errors();
5892
5892
 
5893
5893
  // src/services/lessonProductionService.ts
5894
5894
  var __filename$1 = typeof import.meta?.url === "string" ? fileURLToPath(import.meta.url) : "";
5895
- var _resolvedDir = __filename$1 ? path.dirname(__filename$1) : typeof __dirname !== "undefined" ? __dirname : process.cwd();
5895
+ var _resolvedDir = __filename$1 ? path4.dirname(__filename$1) : typeof __dirname !== "undefined" ? __dirname : process.cwd();
5896
5896
  function loadCurriculumTemplate(templateName) {
5897
5897
  const candidatePaths = [
5898
- path.resolve(process.cwd(), "_templates", templateName),
5899
- path.resolve(process.cwd(), "packages/curriculum-kit/docs/refs/templates", templateName),
5900
- path.resolve(process.cwd(), "docs/refs/templates", templateName),
5901
- path.resolve(_resolvedDir, "../docs/refs/templates", templateName),
5902
- path.resolve(_resolvedDir, "../../docs/refs/templates", templateName),
5903
- path.resolve(_resolvedDir, "../../../docs/refs/templates", templateName),
5904
- path.resolve(_resolvedDir, "../../../../the-ultimate-curriculum-agent-os/_templates", templateName)
5898
+ path4.resolve("/Users/tonypham/MEGA/WebApp/WIP/learnwell-platform/packages/curriculum-kit/docs/refs/templates", templateName),
5899
+ path4.resolve(process.cwd(), "packages/curriculum-kit/docs/refs/templates", templateName),
5900
+ path4.resolve(process.cwd(), "_templates", templateName),
5901
+ path4.resolve(process.cwd(), "docs/refs/templates", templateName),
5902
+ path4.resolve(_resolvedDir, "../docs/refs/templates", templateName),
5903
+ path4.resolve(_resolvedDir, "../../docs/refs/templates", templateName),
5904
+ path4.resolve(_resolvedDir, "../../../docs/refs/templates", templateName),
5905
+ path4.resolve("/Users/tonypham/MEGA/WebApp/content-gen/the-ultimate-curriculum-agent-os/_templates", templateName),
5906
+ path4.resolve(_resolvedDir, "../../../../the-ultimate-curriculum-agent-os/_templates", templateName)
5905
5907
  ];
5906
5908
  for (const p of candidatePaths) {
5907
5909
  if (fs.existsSync(p)) {
@@ -5917,11 +5919,14 @@ function loadCurriculumTemplate(templateName) {
5917
5919
 
5918
5920
  // src/services/singleArtifactService.ts
5919
5921
  init_errors();
5920
- function getArtifactMetadata(type, lessonId) {
5922
+ function getArtifactMetadata(type, lessonId, pedagogy) {
5921
5923
  const id = lessonId || "ON_DEMAND";
5922
5924
  switch (type) {
5923
- case "lesson":
5924
- return { filename: `LESSON_${id}.md`, persona: "@content", templateFile: "LESSON_5E_template.md" };
5925
+ case "lesson": {
5926
+ const p = (pedagogy || "").toLowerCase();
5927
+ const templateFile = p === "edp" ? "LESSON_EDP_template.md" : p === "general" ? "LESSON_GENERAL_template.md" : "LESSON_5E_template.md";
5928
+ return { filename: `LESSON_${id}.md`, persona: "@content", templateFile };
5929
+ }
5925
5930
  case "slide":
5926
5931
  return { filename: `SLIDE_${id}.md`, persona: "@illustrator", templateFile: "SLIDE_template.md" };
5927
5932
  case "act":
@@ -5962,6 +5967,8 @@ function getArtifactMetadata(type, lessonId) {
5962
5967
  return { filename: `REVIEW_GAME_${id}.md`, persona: "@assessor", templateFile: "REVIEW_GAME_template.md" };
5963
5968
  case "graphic_organizer":
5964
5969
  return { filename: `GRAPHIC_ORGANIZER_${id}.md`, persona: "@illustrator", templateFile: "GRAPHIC_ORGANIZER_template.md" };
5970
+ default:
5971
+ return { filename: `ARTIFACT_${id}.md`, persona: "@content", templateFile: "LESSON_5E_template.md" };
5965
5972
  }
5966
5973
  }
5967
5974
  async function generateSingleArtifact(req) {
@@ -5974,24 +5981,50 @@ async function generateSingleArtifact(req) {
5974
5981
  targetAge = "14-18 years old (High School / Early College)",
5975
5982
  scaffoldingLevel = "balanced",
5976
5983
  hardwarePlatform = ["MacBook Lab (macOS 14+ / Swift 6)"],
5984
+ gradeLevel,
5985
+ studentCount,
5986
+ language = "Vietnamese",
5987
+ extraContext,
5988
+ config,
5977
5989
  contextSot = {},
5978
5990
  options = {},
5979
5991
  onChunk
5980
5992
  } = req;
5981
- const meta = getArtifactMetadata(artifactType, lessonId);
5982
- const templateContent = loadCurriculumTemplate(meta.templateFile);
5993
+ const meta = getArtifactMetadata(artifactType, lessonId, pedagogy || config?.pedagogicalModel);
5983
5994
  const displayTitle = lessonTitle || topic;
5995
+ const loadedTemplate = loadCurriculumTemplate(meta.templateFile);
5996
+ const templateContent = loadedTemplate || getDefaultFallbackTemplate(artifactType, displayTitle, lessonId || "ON_DEMAND");
5984
5997
  const hwStr = hardwarePlatform.join(", ");
5998
+ const selectedDevices = (config?.devices || (hardwarePlatform[0]?.toLowerCase().includes("paper") ? "paper-only" : "laptop")).toLowerCase();
5999
+ const isBilingual = language.toLowerCase().includes("bilingual") || language.toLowerCase().includes("song");
6000
+ const isVietnamese = !isBilingual && language.toLowerCase().includes("viet");
6001
+ 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).`;
6002
+ const isPaperOnly = selectedDevices === "paper-only" || hwStr.toLowerCase().includes("paper") || hwStr.toLowerCase().includes("print-ready");
6003
+ const deviceRule = isPaperOnly ? `
6004
+ - \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" ? `
6005
+ - \u{1F4F1} MOBILE/TABLET ENVIRONMENT: Activities should be optimized for touch interfaces and mobile/tablet sandboxes (e.g. Swift Playgrounds, Web IDEs, tap/touch interactions).` : `
6006
+ - \u{1F4BB} LAPTOP/DESKTOP ENVIRONMENT: Full keyboard, terminal, multi-file code editing, and browser developer tooling are available.`;
6007
+ const classDynamicsRule = studentCount ? `
6008
+ - \u{1F465} CLASS SIZE LOGISTICS: Class has exactly ${studentCount} students. Structure group sizes, pair-programming pairs, station rotations, and material distribution to realistically accommodate ${studentCount} students without bottlenecks.` : "";
6009
+ const scaffoldingRule = scaffoldingLevel === "foundation" ? `
6010
+ - \u{1FA9C} FOUNDATION SCAFFOLDING: High instructional support. Provide step-by-step numbered breakdowns, concrete real-world analogies, hints for every problem, scaffolded starter code/fill-in-the-blanks, and frequent check-for-understanding prompts.` : scaffoldingLevel === "advanced" ? `
6011
+ - \u{1F680} ADVANCED CHALLENGE: Minimal scaffolding. Focus on deeper system architecture, edge case handling, computational complexity, performance optimization, and open-ended extension challenges.` : `
6012
+ - \u2696\uFE0F BALANCED SCAFFOLDING: Balanced approach combining structured teacher guidance with independent inquiry and problem solving.`;
6013
+ const extraContextRule = extraContext ? `
6014
+ - \u{1F3AF} CRITICAL USER INSTRUCTIONS (MANDATORY): "${extraContext}". You MUST directly reflect and satisfy every point of this user guidance in the generated artifact!` : "";
6015
+ const artifactSpecializedPrompt = getArtifactSpecializedInvariants(artifactType, {
6016
+ ...req,
6017
+ studentCount});
5985
6018
  const systemPrompt = `You are ${meta.persona}, an expert Curriculum & Pedagogical Specialist in the Curriculum OS Multi-Agent Team.
5986
6019
  Your task is to author a canonical, publication-grade learning artifact of type "${artifactType.toUpperCase()}".
5987
6020
 
5988
6021
  ### CORE OPERATIONAL INVARIANTS:
5989
- 1. AUTHORING LANGUAGE: 100% English (Plan C Canonical Specification).
6022
+ ${langRule}
5990
6023
  2. NON-MOCK CODE INVARIANT: Any code snippet provided MUST be 100% syntactically valid, idiomatic, and executable without placeholders or fake functions.
5991
6024
  3. PEDAGOGICAL GROUNDING: Strictly align with the ${pedagogy.toUpperCase()} model, Bloom's Revised Taxonomy, and IEEE/ACM CS2023 guidelines.
5992
- 4. SCAFFOLDING LEVEL: "${scaffoldingLevel.toUpperCase()}" (Foundation: High support & concrete analogies; Balanced: Application & problem solving; Advanced: Systems architecture & concurrency invariants).
5993
- 5. TARGET AUDIENCE: ${targetAge} on ${hwStr}.
5994
- 6. OUTPUT INTEGRITY: Output clean Markdown starting directly with YAML frontmatter. Do not wrap entire response in triple backticks.`;
6025
+ 4. SCAFFOLDING LEVEL: "${scaffoldingLevel.toUpperCase()}".${scaffoldingRule}
6026
+ 5. TARGET AUDIENCE: ${gradeLevel ? `Grade ${gradeLevel}, ` : ""}${targetAge} on ${hwStr}.${deviceRule}${classDynamicsRule}${extraContextRule}
6027
+ 6. OUTPUT INTEGRITY: Output clean Markdown starting directly with YAML frontmatter. Do not wrap entire response in triple backticks.${artifactSpecializedPrompt}`;
5995
6028
  const userPrompt = `### CONTEXT GROUND TRUTH:
5996
6029
  - Topic / Concept Domain: "${topic}"
5997
6030
  - Lesson ID: "${lessonId || "ON_DEMAND"}"
@@ -5999,7 +6032,13 @@ Your task is to author a canonical, publication-grade learning artifact of type
5999
6032
  - Pedagogy: "${pedagogy.toUpperCase()}"
6000
6033
  - Scaffolding Level: "${scaffoldingLevel}"
6001
6034
  - Hardware Environment: "${hwStr}"
6002
-
6035
+ ${gradeLevel ? `- Target Grade Level: "${gradeLevel}"
6036
+ ` : ""}${studentCount ? `- Class Size: "${studentCount} students"
6037
+ ` : ""}- Target Language: "${language}"
6038
+ ${selectedDevices ? `- Device Mode: "${selectedDevices}"
6039
+ ` : ""}${extraContext ? `- User Specific Guidance & Requirements: "${extraContext}"
6040
+ ` : ""}${config ? `- Full Task Config: ${JSON.stringify(config)}
6041
+ ` : ""}
6003
6042
  ${contextSot.framework ? `### SOT CURRICULUM FRAMEWORK:
6004
6043
  ${contextSot.framework.slice(0, 1500)}
6005
6044
  ` : ""}
@@ -6013,15 +6052,10 @@ ${contextSot.handout.slice(0, 1e3)}
6013
6052
  ### MANDATORY CANONICAL TEMPLATE CONTRACT:
6014
6053
  Use the following reference template structure as the exact specification:
6015
6054
 
6016
- ${templateContent || `---
6017
- id: "${lessonId || "ON_DEMAND"}"
6018
- title: "${displayTitle}"
6019
- type: "${artifactType.toUpperCase()}"
6020
- ---
6021
- # ${displayTitle}`}
6055
+ ${templateContent}
6022
6056
 
6023
6057
  ### TASK INSTRUCTION:
6024
- Generate the complete, thorough, production-grade "${artifactType.toUpperCase()}" artifact for "${displayTitle}". Ensure all [REQUIRED] sections are fully developed with realistic, detailed engineering content.`;
6058
+ Generate the complete, thorough, publication-grade "${artifactType.toUpperCase()}" artifact for "${displayTitle}". Ensure all [REQUIRED] sections are fully developed with realistic, detailed pedagogical and technical content. Strictly follow the specialized invariants for "${artifactType.toUpperCase()}".`;
6025
6059
  let accumulatedContent = "";
6026
6060
  let accumulatedThought = "";
6027
6061
  try {
@@ -6060,6 +6094,248 @@ Generate the complete, thorough, production-grade "${artifactType.toUpperCase()}
6060
6094
  });
6061
6095
  }
6062
6096
  }
6097
+ function getArtifactSpecializedInvariants(type, req) {
6098
+ const cfg = req.config || {};
6099
+ const isPaperOnly = cfg.devices === "paper-only" || req.hardwarePlatform?.some((h) => h.toLowerCase().includes("paper"));
6100
+ const studentCount = req.studentCount || "25";
6101
+ switch (type) {
6102
+ case "slide": {
6103
+ const slideCount = cfg.slideCount || 10;
6104
+ const presentationStyle = cfg.presentationStyle || "modern";
6105
+ const presentationDuration = cfg.presentationDuration || 45;
6106
+ const includeSpeakerNotes = cfg.includeSpeakerNotes !== false;
6107
+ return `
6108
+ ### \u{1F3AC} SLIDE PRESENTATION & MARP ARCHITECTURE INVARIANTS:
6109
+ 1. **SLIDE COUNT & TIMING TARGET**:
6110
+ - Generate EXACTLY ${slideCount} slides separated by \`---\` horizontal rules.
6111
+ - Pacing: Target total duration is ${presentationDuration} minutes (~${Math.round(Number(presentationDuration) / Number(slideCount))} mins per slide).
6112
+ - Visual Style: "${presentationStyle.toUpperCase()}". Maintain high visual clarity, contrasting accents, and executive polish.
6113
+ 2. **STRICT CONCISENESS & 6x6 RULE (ABSOLUTELY NO TEXT WALLS)**:
6114
+ - A slide is a VISUAL PROJECTION CANVAS, NOT a textbook or lesson plan!
6115
+ - Maximum 4\u20136 bullet points per slide.
6116
+ - Maximum 8\u201312 words per bullet point. Forbid dense multi-sentence paragraphs on the slide surface.
6117
+ 3. **SPEAKER NOTES FOR ALL SPOKEN WORDS (<!-- Presenter Notes: ... -->)**:
6118
+ ${includeSpeakerNotes ? "- MANDATORY: Every single slide MUST contain comprehensive presenter notes in `<!-- Presenter Notes: ... -->` at the bottom, giving the teacher the exact verbal talking points, analogies, and pacing tips." : "- Optional brief presenter notes."}
6119
+ 4. **CLICK-TO-REVEAL SYSTEM**:
6120
+ - Use \`<!-- clicks -->\` before bulleted lists (\`<ul>\` or \`<ol>\`) for incremental click-to-reveal.
6121
+ - Use \`<!-- click -->\` before answers, code reveals, or key callouts.
6122
+ 5. **2-COLUMN / SPLIT LAYOUT**:
6123
+ - Use <div class="columns"><div>...</div><div>...</div></div> for side-by-side concept vs. code or problem vs. solution comparisons.
6124
+ 6. **CONCISE CODE SNIPPETS**:
6125
+ - Maximum 6\u201310 lines of clean code per snippet with inline comments. Never paste whole files.
6126
+ 7. **MERMAID VISUALS**:
6127
+ - Use Mermaid flowcharts or sequence diagrams for workflows and control loops.`;
6128
+ }
6129
+ case "tiered_practice": {
6130
+ const techStack = cfg.techStack || (req.hardwarePlatform?.[0] || "Modern Programming Language");
6131
+ const includeUnitTests = cfg.includeUnitTests !== false;
6132
+ return `
6133
+ ### \u{1FA9C} TIERED PRACTICE ARCHITECTURE INVARIANTS (3-TIER ADAPTIVE):
6134
+ - Target Technology Stack: "${techStack}"
6135
+ ${includeUnitTests ? "- Automated Testing: Include explicit executable Unit Tests / Assertions for verifying Bronze, Silver, and Gold tiers." : ""}
6136
+ 1. **3 EXPLICIT RIGOR TIERS**:
6137
+ - **\u{1F949} Tier 1 (Bronze / C\u01A1 b\u1EA3n)**: 70% starter boilerplate / 30% fill-in. Direct recall, scaffolded fill-in-the-blanks, single-concept recognition with starter hints.
6138
+ - **\u{1F948} Tier 2 (Silver / Ti\xEAu chu\u1EA9n)**: 30% starter boilerplate / 70% implementation. Independent multi-step problem solving, bug identification, synthesis of 2+ concepts.
6139
+ - **\u{1F947} Tier 3 (Gold / Th\u1EED th\xE1ch)**: 0% code / open architecture. Edge case handling, algorithmic optimization, open-ended architectural design or extension.
6140
+ 2. **COMPLETE WORKED SOLUTIONS & ANSWER KEYS**:
6141
+ - Provide step-by-step worked solutions for every problem across all 3 tiers.
6142
+ 3. **SELF-DIAGNOSTIC RUBRIC**:
6143
+ - Include a clear student rubric with criteria for when a student is ready to level up from Bronze \u2794 Silver \u2794 Gold.`;
6144
+ }
6145
+ case "exit_ticket": {
6146
+ const questionCount = cfg.questionCount || 3;
6147
+ const diagnosticFocus = cfg.diagnosticFocus || "misconceptions";
6148
+ return `
6149
+ ### \u{1F39F}\uFE0F EXIT TICKET ARCHITECTURE INVARIANTS:
6150
+ 1. **EXACTLY ${questionCount} TARGETED ITEMS (3\u20135 MINUTE DURATION)**:
6151
+ - Item 1: Quick diagnostic checking mastery of the core objective.
6152
+ - Item 2: Application with diagnostic trap focusing on: "${diagnosticFocus}".
6153
+ - Item 3: Metacognitive self-check (Confidence rating 1\u20135 + "Explain what is still fuzzy").
6154
+ 2. **TEACHER DIAGNOSTIC INTERVENTION GUIDE**:
6155
+ - Provide a quick lookup table: "If student chooses/writes X \u2794 Misconception is Y \u2794 Quick remedy is Z".${isPaperOnly ? "\n3. **PRINTABLE CUT-OUT FORMAT**: Include student name/date line and cut-border dashed line." : ""}`;
6156
+ }
6157
+ case "quiz": {
6158
+ const questionCount = cfg.questionCount || 5;
6159
+ const questionTypes = Array.isArray(cfg.questionTypes) ? cfg.questionTypes.join(", ") : cfg.questionTypes || "multiple_choice";
6160
+ const diagnosticFocus = cfg.diagnosticFocus || "balanced";
6161
+ return `
6162
+ ### \u{1F4DD} BLOOM-ALIGNED QUIZ ARCHITECTURE INVARIANTS:
6163
+ 1. **EXACTLY ${questionCount} QUESTIONS (${questionTypes.toUpperCase()})**:
6164
+ - Diagnostic emphasis: "${diagnosticFocus}".
6165
+ - 40% Remember/Understand (Conceptual foundations).
6166
+ - 40% Apply/Analyze (Bug finding, code tracing, scenario application).
6167
+ - 20% Evaluate/Create (Algorithmic reasoning, trade-off evaluation).
6168
+ 2. **HIGH-QUALITY DISTRACTORS WITH RATIONALE**:
6169
+ - For every multiple choice item, explain WHY each incorrect option is a plausible misconception and WHY the key is correct.
6170
+ 3. **COMPLETE ANSWER KEY & SCORING RUBRIC**:
6171
+ - Explicit point distribution, partial credit guidelines, and sample ideal answers for open-ended questions.`;
6172
+ }
6173
+ case "task_cards": {
6174
+ const cardCount = cfg.cardCount || 12;
6175
+ const cardUsage = cfg.cardUsage || "stations";
6176
+ return `
6177
+ ### \u{1F4CB} TASK CARDS ARCHITECTURE INVARIANTS:
6178
+ 1. **SET OF EXACTLY ${cardCount} NUMBERED CARDS (Optimized for ${cardUsage.toUpperCase()})**:
6179
+ - Clearly mark each card: Card # (1 to ${cardCount}), Difficulty (Foundation / Standard / Challenge), and Target Skill.
6180
+ 2. **STUDENT RECORDING SHEET (B\u1EA2NG GHI \u0110\xC1P \xC1N)**:
6181
+ - Include a structured printable grid where students record answers for Cards 1\u2013${cardCount}.
6182
+ 3. **TEACHER MASTER KEY**:
6183
+ - Quick reference key with verified answers and explanations.${isPaperOnly ? "\n4. **PRINT-READY CARD BORDERS**: Layout with clean visual borders ready for physical printing and cutting." : ""}`;
6184
+ }
6185
+ case "graphic_organizer": {
6186
+ const diagramType = cfg.diagramType || "concept_map";
6187
+ const includeFillIn = cfg.includeFillInExercise !== false;
6188
+ return `
6189
+ ### \u{1F4CA} GRAPHIC ORGANIZER ARCHITECTURE INVARIANTS:
6190
+ 1. **VISUAL MODEL TYPE: "${diagramType.toUpperCase()}"**:
6191
+ - Structure a clear cognitive thinking tool: Concept Map, Flowchart, Venn Diagram, Hierarchy Tree, or Cause-Effect Matrix.
6192
+ 2. **VALID MERMAID SYNTAX**:
6193
+ - Embed complete, 100% syntactically correct Mermaid diagrams showing the knowledge structure.
6194
+ 3. **ACTIVE STUDENT INTERACTION PROMPTS**:
6195
+ ${includeFillIn ? "- Include interactive fill-in-the-blank nodes and connection articulation challenges." : "- Include synthesis and reflection prompts based on the visual model."}`;
6196
+ }
6197
+ case "choice_board": {
6198
+ const gridSize = cfg.gridSize || "3x3";
6199
+ const completionRule = cfg.completionRule || "row_column_diagonal";
6200
+ return `
6201
+ ### \u{1F3AF} CHOICE BOARD ARCHITECTURE INVARIANTS (UDL ${gridSize.toUpperCase()} MATRIX):
6202
+ 1. **${gridSize.toUpperCase()} MENU (UDL MULTIPLE MEANS OF EXPRESSION)**:
6203
+ - Option tasks spanning practical coding, architectural diagrams, analytical writing, and real-world scenarios.
6204
+ 2. **COMPLETION CONTRACT: "${completionRule.toUpperCase()}"**:
6205
+ - Explicit rule (e.g. Tic-Tac-Toe 3-in-a-row/column/diagonal, or Point Bounty system).
6206
+ 3. **UNIFIED EVALUATION RUBRIC**:
6207
+ - Consistent grading criteria applicable across all task choices on the board.`;
6208
+ }
6209
+ case "station_rotation": {
6210
+ const stationCount = cfg.stationCount || 3;
6211
+ const stationDuration = cfg.stationDuration || 15;
6212
+ return `
6213
+ ### \u{1F504} STATION ROTATION ARCHITECTURE INVARIANTS:
6214
+ 1. **EXACTLY ${stationCount} STATIONS SCALED FOR ${studentCount} STUDENTS**:
6215
+ - Group size: ~${Math.ceil(Number(studentCount) / Number(stationCount)) || 7} students per group.
6216
+ - Distinct station roles: Teacher-Led Small Group, Independent Practical Lab, Collaborative / Unplugged Peer Challenge.
6217
+ 2. **TIMING & TRANSITIONS (${stationDuration} MINS/STATION)**:
6218
+ - ${stationDuration} minutes per station + 3-minute structured rotation protocol.
6219
+ 3. **STATION DELIVERABLES & ACCOUNTABILITY**:
6220
+ - Clear check-in deliverable required at each station to ensure on-task accountability.`;
6221
+ }
6222
+ case "act":
6223
+ case "codelab":
6224
+ case "science_lab": {
6225
+ const techStack = cfg.techStack || (req.hardwarePlatform?.[0] || "Modern Programming Language");
6226
+ const includeUnitTests = cfg.includeUnitTests !== false;
6227
+ return `
6228
+ ### \u{1F4BB} HANDS-ON LAB & CODE ACTIVITY ARCHITECTURE INVARIANTS:
6229
+ - Technology Stack: "${techStack}"
6230
+ ${includeUnitTests ? "- Unit Testing: Provide automated assertions or test runner checks." : ""}
6231
+ 1. **100% RUNNABLE CODE / RIGOROUS PROCEDURE**:
6232
+ - Absolutely no fake APIs, mock functions, or non-executable pseudocode.
6233
+ 2. **STRUCTURED LAB PHASES**:
6234
+ - Objective & Environmental Prerequisites.
6235
+ - Starter Skeleton Code with clear \`// TODO [Student Task]\` comments.
6236
+ - Step-by-step Guided Challenges (Level 1 \u2794 Level 2 \u2794 Level 3).
6237
+ - Automated Verification / Test Cases.
6238
+ - Complete Reference Solution with design explanation.`;
6239
+ }
6240
+ case "bell_ringer":
6241
+ return `
6242
+ ### \u{1F514} BELL RINGER ARCHITECTURE INVARIANTS (3\u20135 MIN WARM-UP):
6243
+ 1. **3 QUICK HOOK QUESTIONS**:
6244
+ - 2 rapid-fire recall questions activating previous knowledge.
6245
+ - 1 curiosity hook question bridging into today's core topic.
6246
+ 2. **60-SECOND TEACHER REVIEW KEY**:
6247
+ - Quick-glance answer key for instant whole-class review.`;
6248
+ case "review_game":
6249
+ return `
6250
+ ### \u{1F3AE} REVIEW GAME ARCHITECTURE INVARIANTS:
6251
+ 1. **GAMIFIED STRUCTURE**:
6252
+ - Jeopardy-style board (3\u20134 Categories x 3 Point Values: 100 / 200 / 300) OR 3-Round Interactive Trivia.
6253
+ 2. **CLEAR RULES & TEAM DYNAMICS**:
6254
+ - Team scoring rules, buzz-in protocol, and tie-breaker challenge.
6255
+ 3. **COMPLETE QUESTION & ANSWER DECK**:
6256
+ - Verified answers and point values for the host/teacher.`;
6257
+ case "guide": {
6258
+ const lessonDuration = cfg.lessonDuration || 90;
6259
+ return `
6260
+ ### \u{1F4D6} TEACHER GUIDE ARCHITECTURE INVARIANTS (${lessonDuration} MINS LESSON):
6261
+ 1. **MINUTE-BY-MINUTE PACING TIMELINE**:
6262
+ - Pacing broken down for ${lessonDuration} minutes (Hook, Modeling, Guided Practice, Independent Practice, Debrief).
6263
+ 2. **SOCRATIC QUESTIONS & PROMPTS**:
6264
+ - Cold-call questions with anticipated student misconceptions and remediation scripts.
6265
+ 3. **DIFFERENTIATION STRATEGIES**:
6266
+ - Specific adaptations for students needing support vs. high-flyers needing extension.`;
6267
+ }
6268
+ case "worksheet":
6269
+ case "handout":
6270
+ return `
6271
+ ### \u{1F4D1} WORKSHEET / HANDOUT ARCHITECTURE INVARIANTS:
6272
+ 1. **I DO \u2794 WE DO \u2794 YOU DO SCAFFOLDING**:
6273
+ - Part 1 (I Do): Fully worked and annotated example.
6274
+ - Part 2 (We Do): Guided problem with fill-in hints and scaffolding scaffolds.
6275
+ - Part 3 (You Do): Independent mastery challenge.
6276
+ 2. **SELF-CHECK RUBRIC**:
6277
+ - End-of-worksheet self-evaluation checklist.${isPaperOnly ? "\n3. **PRINTABLE WORKSPACES**: Include spacious, clean write-in boxes and workspace for calculations/code." : ""}`;
6278
+ case "rubric": {
6279
+ const rubricScale = cfg.rubricScale || "4_levels";
6280
+ return `
6281
+ ### \u{1F4CA} ANALYTIC RUBRIC ARCHITECTURE INVARIANTS (${rubricScale.toUpperCase()} SCALE):
6282
+ 1. **RIGOROUS PROFICIENCY LEVELS**:
6283
+ - 4 Proficiency Levels: Level 4 (Exemplary) | Level 3 (Proficient) | Level 2 (Developing) | Level 1 (Beginning).
6284
+ 2. **CONCRETE OBSERVABLE CRITERIA**:
6285
+ - Each cell MUST describe concrete, observable behavioral evidence, not vague words like "good" or "average".`;
6286
+ }
6287
+ case "glossary":
6288
+ return `
6289
+ ### \u{1F4DA} TECHNICAL GLOSSARY ARCHITECTURE INVARIANTS:
6290
+ 1. **COMPREHENSIVE TERM PROFILES**:
6291
+ - For every key term: Technical Definition, Real-world Analogy, Code Syntax Example, and Common Misconception.`;
6292
+ case "bom":
6293
+ return `
6294
+ ### \u{1F4E6} BILL OF MATERIALS (BOM) ARCHITECTURE INVARIANTS:
6295
+ 1. **CLASS-SCALED INVENTORY FOR ${studentCount} STUDENTS**:
6296
+ - Exact quantities calculated for ${studentCount} students.
6297
+ - Component specifications, estimated unit cost, and affordable alternatives.`;
6298
+ case "lesson": {
6299
+ const lessonDuration = cfg.lessonDuration || 90;
6300
+ const pedagogicalModel = cfg.pedagogicalModel || req.pedagogy || "5e";
6301
+ return `
6302
+ ### \u{1F393} CANONICAL LESSON PLAN INVARIANTS (${pedagogicalModel.toUpperCase()} MODEL, ${lessonDuration} MINS):
6303
+ 1. **A. LESSON DESIGN PLAN**:
6304
+ - Learning Objectives (Bloom-aligned) & Observable Student Evidence.
6305
+ - Activity Sequence mapping every phase with timing totaling ${lessonDuration} minutes.
6306
+ - Resource Map & Assessment Map with explicit Artifact Contracts.
6307
+ 2. **B. LESSON FLOW**:
6308
+ - Detailed teacher moves, student actions, scripted key questions, and check-for-understanding points for every activity phase.`;
6309
+ }
6310
+ default:
6311
+ return "";
6312
+ }
6313
+ }
6314
+ function getDefaultFallbackTemplate(type, title, id) {
6315
+ const upperType = type.toUpperCase();
6316
+ return `---
6317
+ id: "${id}"
6318
+ title: "${title}"
6319
+ type: "${upperType}"
6320
+ version: "1.0.0"
6321
+ date: "${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}"
6322
+ ---
6323
+
6324
+ # ${title}
6325
+
6326
+ ## 1. Overview & Learning Objectives
6327
+ <!-- [REQUIRED] State 2-3 measurable, Bloom-aligned learning objectives -->
6328
+
6329
+ ## 2. Core Pedagogical Content
6330
+ <!-- [REQUIRED] Provide the core educational substance, questions, problems, and diagrams -->
6331
+
6332
+ ## 3. Practice & Differentiation
6333
+ <!-- [REQUIRED] Tiered support, worked examples, and challenges -->
6334
+
6335
+ ## 4. Assessment & Answer Key
6336
+ <!-- [REQUIRED] Complete solutions, rubrics, and diagnostic teacher feedback -->
6337
+ `;
6338
+ }
6063
6339
 
6064
6340
  // src/workflow/workflows/singleArtifactWorkflow.ts
6065
6341
  async function executeSingleArtifactStep(request) {