@thanh01.pmt/curriculum-kit 1.4.42 → 1.4.44

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.
@@ -2,9 +2,10 @@ import { generateObject } from 'ai';
2
2
  import { createGoogleGenerativeAI } from '@ai-sdk/google';
3
3
  import { createOpenAI } from '@ai-sdk/openai';
4
4
  import { createDeepSeek } from '@ai-sdk/deepseek';
5
- import fs from 'fs';
5
+ import fs2 from 'fs';
6
6
  import path from 'path';
7
7
  import { z } from 'zod';
8
+ import { fileURLToPath } from 'url';
8
9
  import pLimit from 'p-limit';
9
10
  import fsPromises from 'fs/promises';
10
11
 
@@ -594,8 +595,8 @@ function resolveApiKey(keyName, explicitKey) {
594
595
  path.resolve(currentDir, "../..", ".env")
595
596
  ];
596
597
  for (const envPath of envPaths) {
597
- if (fs.existsSync(envPath)) {
598
- const content = fs.readFileSync(envPath, "utf-8");
598
+ if (fs2.existsSync(envPath)) {
599
+ const content = fs2.readFileSync(envPath, "utf-8");
599
600
  for (const line of content.split("\n")) {
600
601
  const trimmed = line.trim();
601
602
  if (trimmed && !trimmed.startsWith("#") && trimmed.startsWith(keyName + "=")) {
@@ -2473,467 +2474,61 @@ z.object({
2473
2474
  }),
2474
2475
  phases: z.array(PhaseInputSchema).default([])
2475
2476
  });
2476
-
2477
- // src/templates/lessonTemplate.ts
2478
- var LESSON_PLAN_TEMPLATE = `
2479
- ---
2480
- id: "{{ID}}"
2481
- title: "{{TITLE}}"
2482
- type: "LESSON_5E"
2483
- created_by: "Curriculum OS Builder"
2484
- phase: "{{PHASE}}"
2485
- deliverable: "P3-T1"
2486
- version: "{{VERSION}}"
2487
- date: "{{DATE}}"
2488
- prerequisite: []
2489
- template_contract: "lesson-plan-v2"
2490
- template_required_sections:
2491
- - "A. Lesson Design Plan"
2492
- - "Learning Objectives & Evidence"
2493
- - "Activity Sequence"
2494
- - "Resource Map"
2495
- - "Assessment Map"
2496
- - "Artifact Contract"
2497
- - "B. Lesson Flow"
2498
- ---
2499
- <!-- INJECT_BODY -->
2500
-
2501
- # LESSON [{{LESSON_ID}}]: {{TITLE}} (5E Model)
2502
-
2503
- ## [REQUIRED] A. Lesson Design Plan
2504
-
2505
- ### 1. Learning Objectives & Evidence
2506
- - **Estimated Duration:** {{DURATION}}
2507
- - **Materials & Equipment:** {{MATERIALS_SUMMARY}}
2508
- - **Keywords / Core Concepts:** {{KEYWORDS}}
2509
-
2510
- | LO | Objective (Bloom's) | Student Evidence | Success Criteria |
2511
- |---|---|---|---|
2512
- {{LEARNING_OBJECTIVES_TABLE_ROWS}}
2513
-
2514
- ### 2. Activity Sequence
2515
- > This is the canonical activity contract. Satellite artifacts must expand this sequence and must not invent a different one.
2516
-
2517
- | Seq | 5E Phase | Activity Type | Actor | Purpose | Student Action | Teacher Move | Output/Evidence | LO | Time | Artifact Contract |
2518
- |---|---|---|---|---|---|---|---|---|---|---|
2519
- {{ACTIVITY_SEQUENCE_TABLE_ROWS}}
2520
-
2521
- ### 3. Resource Map
2522
- | Resource | Used In Activity | Purpose | Owner Artifact |
2523
- |---|---|---|---|
2524
- {{RESOURCE_MAP_TABLE_ROWS}}
2525
-
2526
- ### 4. Assessment Map
2527
- | Evidence | Assessed By | Criteria | Follow-up If Missing |
2528
- |---|---|---|---|
2529
- {{ASSESSMENT_MAP_TABLE_ROWS}}
2530
-
2531
- ### 5. Artifact Contract
2532
- - **ACT must expand:** {{ACT_CONTRACT}}
2533
- - **GUIDE must support:** {{GUIDE_CONTRACT}}
2534
- - **SLIDE must visualize:** {{SLIDE_CONTRACT}}
2535
- - **HANDOUT must provide:** {{HANDOUT_CONTRACT}}
2536
- - **WKS must practice:** {{WKS_CONTRACT}}
2537
- - **QUIZ must assess:** {{QUIZ_CONTRACT}}
2538
- - **EXT must extend:** {{EXT_CONTRACT}}
2539
-
2540
- ---
2541
-
2542
- ## [REQUIRED] B. Lesson Flow
2543
-
2544
- ### 1. ENGAGE \u2014 {{ENGAGE_DURATION}} mins
2545
- - **Hook Scenario:** {{HOOK_SCENARIO}}
2546
- - **Open Question:** {{HOOK_OPEN_QUESTION}}
2547
- - **Transition:** {{HOOK_TRANSITION}}
2548
-
2549
- ### 2. EXPLORE \u2014 {{EXPLORE_DURATION}} mins
2550
- - **Activity Reference:** {{EXPLORE_ACTIVITY_REF}}
2551
- - **Student Discovery:** {{EXPLORE_STUDENT_DISCOVERY}}
2552
-
2553
- ### 3. EXPLAIN \u2014 {{EXPLAIN_DURATION}} mins
2554
- - **Definitions:**
2555
- {{EXPLAIN_DEFINITIONS}}
2556
- - **Visual Illustration (REQUIRED):**
2557
- {{EXPLAIN_VISUAL_ILLUSTRATION}}
2558
-
2559
- ### 4. ELABORATE \u2014 {{ELABORATE_DURATION}} mins
2560
- - **Tiered Scaffolding:**
2561
- - \u{1F949} **Bronze:** {{DIFFERENTIATION_BRONZE}}
2562
- - \u{1F948} **Silver:** {{DIFFERENTIATION_SILVER}}
2563
- - \u{1F947} **Gold:** {{DIFFERENTIATION_GOLD}}
2564
-
2565
- > **ACT Contract**: Detailed operational instructions must expand the Activity Sequence above and must not change the planned evidence target.
2566
-
2567
- ### 5. EVALUATE \u2014 {{EVALUATE_DURATION}} mins
2568
- - **Exit Ticket:** {{EXIT_TICKET_CONTENT}}
2569
- - **Closing:** {{CLOSING_REMARKS}}
2570
-
2571
- > **QUIZ Contract**: Detailed assessment criteria and rubrics must assess the evidence and success criteria defined in the Lesson Design Plan.
2572
-
2573
- ---
2574
-
2575
- ## [OPTIONAL] Teacher Notes
2576
- - **Common Pitfalls:**
2577
- {{COMMON_PITFALLS}}
2578
- - **Troubleshooting:**
2579
- {{TROUBLESHOOTING_ROWS}}
2580
-
2581
- ---
2582
-
2583
- ## [REQUIRED] Artifact Linkage (Master Index)
2584
- > List all satellite files used in this lesson.
2585
-
2586
- | Artifact File | Role in the Classroom | When to Use |
2587
- |---|---|---|
2588
- | \`GUIDE_{{LESSON_ID}}.md\` | Detailed Teaching Script | Teacher preparation |
2589
- | \`SLIDE_{{LESSON_ID}}.md\` | Presentation Content | Throughout the session |
2590
- | \`HANDOUT_{{LESSON_ID}}.md\` | Theory Summary for Students | During EXPLAIN phase |
2591
- | \`ACT_{{LESSON_ID}}.md\` | Detailed Learning Activity Operations | During EXPLORE / ELABORATE / checkpoint phases |
2592
- | \`WKS_{{LESSON_ID}}.md\` | Individual Worksheet | Wrap-up or Homework |
2593
- | \`QUIZ_{{LESSON_ID}}.md\` | Assessment Rubric | During EVALUATE phase |
2594
- | \`EXT_{{LESSON_ID}}.md\` | Enrichment Materials | For "Gold" students |
2595
- `.trim();
2596
-
2597
- // src/templates/actTemplate.ts
2598
- var ACT_TEMPLATE = `
2599
- ---
2600
- id: "{{ID}}"
2601
- title: "{{TITLE}}"
2602
- type: "ACT"
2603
- created_by: "Curriculum OS Builder"
2604
- phase: "{{PHASE}}"
2605
- deliverable: "P3-T2"
2606
- version: "{{VERSION}}"
2607
- date: "{{DATE}}"
2608
- template_contract: "artifact-template-v1"
2609
- template_required_sections:
2610
- - "Computational Thinking Focus"
2611
- - "Materials & Setup"
2612
- - "Constraints & Safety"
2613
- - "Active Learning Workflow"
2614
- - "3-Tier Differentiation"
2615
- - "Reflection"
2616
- ---
2617
- <!-- INJECT_BODY -->
2618
-
2619
- # INQUIRY-BASED ACTIVITY: {{TITLE}}
2620
- _Milestone: {{MILESTONE_ID}} | Module: {{MODULE_NAME}} | Lesson: {{LESSON_ID}}_
2621
-
2622
- ## [REQUIRED] Computational Thinking Focus
2623
- - **Problem Statement (Real-world Scenario):** {{PROBLEM_STATEMENT}}
2624
- - **Decomposition:**
2625
- {{DECOMPOSITION_STEPS}}
2626
- - **Algorithm Design:** {{ALGORITHM_DESIGN}}
2627
-
2628
- ## [REQUIRED] Materials & Setup
2629
- - **Reference Material:** Students should use the **HANDOUT** for this lesson as their primary technical reference (lifeline).
2630
- - **Hardware/Software:**
2631
- <!-- [HARDWARE_BOM] -->
2632
- {{HARDWARE_ITEMS}}
2633
- <!-- [/HARDWARE_BOM] -->
2634
- - **Software:** {{SOFTWARE_ITEMS}}
2635
- - **Consumables:** {{CONSUMABLES}}
2636
- - **Other Resources:** {{OTHER_RESOURCES}}
2637
-
2638
- ## [REQUIRED] Constraints & Safety
2639
- - \u26A0\uFE0F **Technical/Safety:** {{SAFETY_WARNING}}
2640
- - \u{1F4A1} **Design Constraint:** {{DESIGN_CONSTRAINT}}
2641
-
2642
- ## [REQUIRED] Active Learning Workflow
2643
-
2644
- ### Phase 1: Planning & Design \u2014 {{PHASE1_DURATION}} mins
2645
- - **Student Task:** Hand-draw (or draft in words) the algorithm flowchart or connection architecture before touching the computer/devices.
2646
- - **Teacher Action:** Walk around to check the logic of each group. Ask inquiry questions:
2647
- {{PHASE1_INQUIRY_QUESTIONS}}
2648
-
2649
- ### Phase 2: Implementation & Discovery \u2014 {{PHASE2_DURATION}} mins
2650
- - **Student Task:** Apply the knowledge from the **HANDOUT** to realize the plan designed in Phase 1. Encourage self-inquiry and documentation lookup.
2651
- - **Teacher Action:** Avoid "hand-holding." Only intervene if a group has been stuck for more than 5 minutes.
2652
- {{PHASE2_GUIDANCE_BLOCK}}
2653
-
2654
- ### Phase 3: Debugging & Testing \u2014 {{PHASE3_DURATION}} mins
2655
- - **Testing:** Students run their system.
2656
- - **Error Analysis:** Ask students to record any error codes or unexpected behaviors and compare them with the Troubleshooting table in the Handout.
2657
- {{PHASE3_TESTING_STEPS}}
2658
-
2659
- ## [REQUIRED] 3-Tier Differentiation
2660
- > MUST design tasks in 3 tiers to support diverse learner groups. Bronze is the minimum requirement for all students.
2661
- - \u{1F949} **Bronze (Foundational):** {{DIFFERENTIATION_BRONZE}}
2662
- - \u{1F948} **Silver (Application):** {{DIFFERENTIATION_SILVER}}
2663
- - \u{1F947} **Gold (Enrichment/Creative):** {{DIFFERENTIATION_GOLD}}
2664
-
2665
- ## [REQUIRED] Reflection
2666
- - **Discussion Question:** {{REFLECTION_QUESTION}}
2667
- `.trim();
2668
-
2669
- // src/templates/codeLabTemplate.ts
2670
- var CODE_LAB_TEMPLATE = `
2671
- ---
2672
- id: "{{ID}}"
2673
- title: "{{TITLE}}"
2674
- type: "LAB"
2675
- created_by: "Curriculum OS Builder"
2676
- phase: "{{PHASE}}"
2677
- deliverable: "P3-T2"
2678
- version: "{{VERSION}}"
2679
- date: "{{DATE}}"
2680
- ---
2681
- <!-- INJECT_BODY -->
2682
-
2683
- # \u{1F468}\u200D\u{1F4BB} CODE LAB: {{TITLE}}
2684
- _Milestone: {{MILESTONE_ID}} | Tech Stack: {{TECH_STACK}}_
2685
-
2686
- ## \u{1F3AF} Overview
2687
- This lab focuses on the practical implementation of core technical concepts, bridging theory into working, robust, and testable code.
2688
-
2689
- ## \u{1F6E0}\uFE0F Environment & Setup
2690
- - **Language / Framework:** {{LANGUAGE_FRAMEWORK}}
2691
- - **IDE / Editor:** {{IDE_EDITOR}}
2692
- - **Required Libraries:** {{REQUIRED_LIBRARIES}}
2693
- - **Hardware / Connection Setup:** {{HARDWARE_ENV_CONNECTION}}
2694
-
2695
- ## \u{1F4DD} Lab Tasks (3-Tier Differentiation)
2696
-
2697
- ### \u{1F949} Bronze (Foundational) \u2014 {{BRONZE_MINS}} mins
2698
- **Objective:** {{BRONZE_OBJECTIVE}}
2699
- - **Task:** {{BRONZE_TASK}}
2700
- - **Requirement:** {{BRONZE_REQUIREMENT}}
2701
-
2702
- ### \u{1F948} Silver (Application) \u2014 {{SILVER_MINS}} mins
2703
- **Objective:** {{SILVER_OBJECTIVE}}
2704
- - **Task:** {{SILVER_TASK}}
2705
- - **Requirement:** {{SILVER_REQUIREMENT}}
2706
-
2707
- ### \u{1F947} Gold (Enrichment/Creative) \u2014 {{GOLD_MINS}} mins
2708
- **Objective:** {{GOLD_OBJECTIVE}}
2709
- - **Task:** {{GOLD_TASK}}
2710
- - **Requirement:** {{GOLD_REQUIREMENT}}
2711
-
2712
- ## \u{1F4BB} Technical Reference ([SME_MANDATE])
2713
- <!-- [SME_MANDATE] -->
2714
- > Any code provided in this section is verified for syntax accuracy and runtime execution.
2715
-
2716
- ### Starter Code Template
2717
- \`\`\`{{CODE_LANGUAGE}}
2718
- {{STARTER_CODE}}
2719
- \`\`\`
2720
-
2721
- ### Solution Code
2722
- \`\`\`{{CODE_LANGUAGE}}
2723
- {{SOLUTION_CODE}}
2724
- \`\`\`
2725
- <!-- [/SME_MANDATE] -->
2726
-
2727
- ## \u{1F50D} Troubleshooting & Debugging Matrix
2728
- | Issue | Potential Cause | Solution |
2729
- | :--- | :--- | :--- |
2730
- {{TROUBLESHOOTING_ROWS}}
2731
-
2732
- ## \u{1F3C1} Submission & Verification Checklist
2733
- {{CHECKLIST_ITEMS}}
2734
- `.trim();
2735
-
2736
- // src/templates/quizTemplate.ts
2737
- var QUIZ_TEMPLATE = `
2738
- ---
2739
- id: "{{ID}}"
2740
- title: "{{TITLE}}"
2741
- type: "QUIZ"
2742
- language: "{{LANGUAGE}}"
2743
- total_questions: {{TOTAL_QUESTIONS}}
2744
- passing_score_pct: {{PASSING_SCORE_PCT}}
2745
- ---
2746
-
2747
- # \u{1F9E0} Diagnostic & Active Recall Quiz: {{TITLE}}
2748
-
2749
- > \u23F1\uFE0F **Recommended Time:** ~10-15 mins
2750
- > \u{1F3AF} **Passing Score:** {{PASSING_SCORE_PCT}}%
2751
- > \u{1F4A1} **Purpose:** Test your conceptual understanding, catch hidden misconceptions, and evaluate architectural trade-offs.
2752
-
2753
- ---
2754
-
2755
- {{QUESTIONS_SECTION}}
2756
-
2757
- ---
2758
-
2759
- ## \u{1F511} Comprehensive Answer Key & Deep Explanation (Expand after completing)
2760
- <details>
2761
- <summary><b>\u{1F449} Click to View Full Explanations & Common Pitfall Analysis</b></summary>
2762
-
2763
- {{ANSWER_KEY_SECTION}}
2764
- </details>
2765
- `.trim();
2766
-
2767
- // src/templates/selfLabTemplate.ts
2768
- var SELF_LAB_TEMPLATE = `
2769
- ---
2770
- id: "{{ID}}"
2771
- title: "{{TITLE}}"
2772
- type: "SELF_LAB"
2773
- language: "{{LANGUAGE}}"
2774
- difficulty: "{{DIFFICULTY}}"
2775
- estimated_minutes: {{ESTIMATED_MINUTES}}
2776
- tech_stack: {{TECH_STACK}}
2777
- ---
2778
-
2779
- # \u{1F680} Self-Paced Hands-On Lab: {{TITLE}}
2780
-
2781
- > \u23F1\uFE0F **Estimated Duration:** ~{{ESTIMATED_MINUTES}} mins
2782
- > \u{1F3AF} **Difficulty Level:** {{DIFFICULTY_UPPER}}
2783
- > \u{1F9F0} **Tech Stack:** {{TECH_STACK_STR}}
2784
- > \u{1F4A1} **Self-Learner Notice:** You are in full control of this lab. Follow the progressive challenges below. If you get stuck at any point, use the **Progressive Hints System** to get unstuck without ruining the learning experience!
2785
-
2786
- ---
2787
-
2788
- ## \u{1F4CB} Mission Briefing & Environment Setup
2789
- {{MISSION_BRIEFING}}
2790
-
2791
- ### \u{1F6EB} Preflight Checklist
2792
- {{PREFLIGHT_CHECKLIST}}
2793
-
2794
- ---
2795
-
2796
- ## \u{1F3AF} Progressive Challenges (3-Tier Differentiation)
2797
-
2798
- ### \u{1F949} Challenge 1: Foundational Core (Bronze) \u2014 ~{{BRONZE_MINS}} mins
2799
- **Objective:** {{BRONZE_OBJECTIVE}}
2800
-
2801
- #### Tasks & Implementation Details:
2802
- {{BRONZE_TASKS}}
2803
-
2804
- #### \u{1F9EA} Self-Verification Command:
2805
- \`\`\`bash
2806
- {{BRONZE_VERIFY_COMMAND}}
2807
- \`\`\`
2808
- *Expected Terminal Output:*
2809
- \`\`\`text
2810
- {{BRONZE_EXPECTED_OUTPUT}}
2811
- \`\`\`
2812
-
2813
- #### \u{1F4A1} Progressive Hints (Expand only if stuck):
2814
- <details>
2815
- <summary><b>\u{1F4A1} Hint Level 1: Conceptual Clue (H\u01B0\u1EDBng t\u01B0 duy)</b></summary>
2816
-
2817
- {{BRONZE_HINT_1}}
2818
- </details>
2819
-
2820
- <details>
2821
- <summary><b>\u{1F50D} Hint Level 2: Structural Skeleton (Khung code m\u1EABu)</b></summary>
2822
-
2823
- \`\`\`{{CODE_LANGUAGE}}
2824
- {{BRONZE_HINT_2}}
2825
- \`\`\`
2826
- </details>
2827
-
2828
- <details>
2829
- <summary><b>\u{1F6A8} Hint Level 3: Full Solution & Explanation (L\u1EDDi gi\u1EA3i tr\u1ECDn v\u1EB9n)</b></summary>
2830
-
2831
- \`\`\`{{CODE_LANGUAGE}}
2832
- {{BRONZE_HINT_3_CODE}}
2833
- \`\`\`
2834
-
2835
- **Why this solution works:**
2836
- {{BRONZE_HINT_3_EXPLANATION}}
2837
- </details>
2838
-
2839
- ---
2840
-
2841
- ### \u{1F948} Challenge 2: Logic & Error Handling (Silver) \u2014 ~{{SILVER_MINS}} mins
2842
- **Objective:** {{SILVER_OBJECTIVE}}
2843
-
2844
- #### Tasks & Implementation Details:
2845
- {{SILVER_TASKS}}
2846
-
2847
- #### \u{1F9EA} Self-Verification Command:
2848
- \`\`\`bash
2849
- {{SILVER_VERIFY_COMMAND}}
2850
- \`\`\`
2851
- *Expected Terminal Output:*
2852
- \`\`\`text
2853
- {{SILVER_EXPECTED_OUTPUT}}
2854
- \`\`\`
2855
-
2856
- #### \u{1F4A1} Progressive Hints (Expand only if stuck):
2857
- <details>
2858
- <summary><b>\u{1F4A1} Hint Level 1: Conceptual Clue (H\u01B0\u1EDBng t\u01B0 duy)</b></summary>
2859
-
2860
- {{SILVER_HINT_1}}
2861
- </details>
2862
-
2863
- <details>
2864
- <summary><b>\u{1F50D} Hint Level 2: Structural Skeleton (Khung code m\u1EABu)</b></summary>
2865
-
2866
- \`\`\`{{CODE_LANGUAGE}}
2867
- {{SILVER_HINT_2}}
2868
- \`\`\`
2869
- </details>
2870
-
2871
- <details>
2872
- <summary><b>\u{1F6A8} Hint Level 3: Full Solution & Explanation (L\u1EDDi gi\u1EA3i tr\u1ECDn v\u1EB9n)</b></summary>
2873
-
2874
- \`\`\`{{CODE_LANGUAGE}}
2875
- {{SILVER_HINT_3_CODE}}
2876
- \`\`\`
2877
-
2878
- **Why this solution works:**
2879
- {{SILVER_HINT_3_EXPLANATION}}
2880
- </details>
2881
-
2882
- ---
2883
-
2884
- ### \u{1F947} Challenge 3: Edge Cases & Optimization (Gold) \u2014 ~{{GOLD_MINS}} mins
2885
- **Objective:** {{GOLD_OBJECTIVE}}
2886
-
2887
- #### Tasks & Implementation Details:
2888
- {{GOLD_TASKS}}
2889
-
2890
- #### \u{1F9EA} Self-Verification Command:
2891
- \`\`\`bash
2892
- {{GOLD_VERIFY_COMMAND}}
2893
- \`\`\`
2894
- *Expected Terminal Output:*
2895
- \`\`\`text
2896
- {{GOLD_EXPECTED_OUTPUT}}
2897
- \`\`\`
2898
-
2899
- #### \u{1F4A1} Progressive Hints (Expand only if stuck):
2900
- <details>
2901
- <summary><b>\u{1F4A1} Hint Level 1: Conceptual Clue (H\u01B0\u1EDBng t\u01B0 duy)</b></summary>
2902
-
2903
- {{GOLD_HINT_1}}
2904
- </details>
2905
-
2906
- <details>
2907
- <summary><b>\u{1F50D} Hint Level 2: Structural Skeleton (Khung code m\u1EABu)</b></summary>
2908
-
2909
- \`\`\`{{CODE_LANGUAGE}}
2910
- {{GOLD_HINT_2}}
2911
- \`\`\`
2912
- </details>
2913
-
2914
- <details>
2915
- <summary><b>\u{1F6A8} Hint Level 3: Full Solution & Explanation (L\u1EDDi gi\u1EA3i tr\u1ECDn v\u1EB9n)</b></summary>
2916
-
2917
- \`\`\`{{CODE_LANGUAGE}}
2918
- {{GOLD_HINT_3_CODE}}
2919
- \`\`\`
2920
-
2921
- **Why this solution works:**
2922
- {{GOLD_HINT_3_EXPLANATION}}
2923
- </details>
2924
-
2925
- ---
2926
-
2927
- ## \u{1F50D} Self-Learner Troubleshooting Matrix
2928
- | Symptom / Error Message | Root Cause | Exact Fix |
2929
- | :--- | :--- | :--- |
2930
- {{TROUBLESHOOTING_ROWS}}
2931
-
2932
- ---
2933
-
2934
- ## \u{1F3C1} Final Lab Submission & Mastery Checklist
2935
- {{FINAL_CHECKLIST}}
2936
- `.trim();
2477
+ function stripTemplateFrontmatter(raw) {
2478
+ let body = raw;
2479
+ if (body.startsWith("---")) {
2480
+ const end = body.indexOf("\n---", 3);
2481
+ if (end !== -1) body = body.slice(end + 4);
2482
+ }
2483
+ return body.split("\n").filter((l) => l.trim() !== "<!-- INJECT_BODY -->").join("\n").replace(/^\s*\n/, "").trimEnd();
2484
+ }
2485
+ var KIT_TEMPLATE_FALLBACK_DIRS = [
2486
+ // Packaged with the npm bundle (dist/templates) — resolves from node_modules.
2487
+ "templates",
2488
+ // Repo checkout layouts.
2489
+ "docs/refs/templates"
2490
+ ];
2491
+ var _moduleDir = (() => {
2492
+ try {
2493
+ if (typeof import.meta !== "undefined" && typeof import.meta.url === "string") {
2494
+ return path.dirname(fileURLToPath(import.meta.url));
2495
+ }
2496
+ } catch {
2497
+ }
2498
+ return typeof __dirname !== "undefined" ? __dirname : process.cwd();
2499
+ })();
2500
+ function candidateDirs(explicitDir) {
2501
+ const dirs = [];
2502
+ if (process.env.CURRICULUM_TEMPLATES_DIR) dirs.push(process.env.CURRICULUM_TEMPLATES_DIR);
2503
+ dirs.push(path.resolve(process.cwd(), "_templates"));
2504
+ for (const rel of KIT_TEMPLATE_FALLBACK_DIRS) {
2505
+ dirs.push(path.resolve(_moduleDir, rel));
2506
+ dirs.push(path.resolve(process.cwd(), rel));
2507
+ dirs.push(path.resolve(process.cwd(), "packages/curriculum-kit", rel));
2508
+ }
2509
+ return dirs;
2510
+ }
2511
+ function findTemplatePath(templateName, explicitDir) {
2512
+ for (const dir of candidateDirs()) {
2513
+ const p = path.join(dir, templateName);
2514
+ if (!fs2.existsSync(p)) continue;
2515
+ try {
2516
+ fs2.accessSync(p, fs2.constants.R_OK);
2517
+ return p;
2518
+ } catch {
2519
+ }
2520
+ }
2521
+ return null;
2522
+ }
2523
+ function loadAuthoringTemplate(templateName, templatesDir) {
2524
+ const p = findTemplatePath(templateName);
2525
+ if (!p) return "";
2526
+ try {
2527
+ return stripTemplateFrontmatter(fs2.readFileSync(p, "utf-8"));
2528
+ } catch {
2529
+ return "";
2530
+ }
2531
+ }
2937
2532
 
2938
2533
  // src/ai/prompts/lessonMasterPrompt.ts
2939
2534
  function buildLessonMasterPrompt(input) {
@@ -2987,7 +2582,7 @@ Build a deep, rigorous, and highly pedagogical Master Lesson Plan (LESSON) that
2987
2582
  # MANDATORY TEMPLATE STRUCTURE
2988
2583
  You MUST generate structured data that will render directly into this exact Markdown template:
2989
2584
  ---
2990
- ${LESSON_PLAN_TEMPLATE}
2585
+ ${loadAuthoringTemplate("LESSON_5E_template.md") ?? "[TEMPLATE FILE NOT FOUND: LESSON_5E_template.md]"}
2991
2586
  ---
2992
2587
 
2993
2588
  # INPUT PARAMETERS
@@ -3065,7 +2660,7 @@ Transform the exact pedagogical flow and activities from the Master Lesson Plan
3065
2660
  # MANDATORY TEMPLATE STRUCTURE
3066
2661
  You MUST generate data aligned with this Markdown template:
3067
2662
  ---
3068
- ${ACT_TEMPLATE}
2663
+ ${loadAuthoringTemplate("ACT_template.md") ?? "[TEMPLATE FILE NOT FOUND: ACT_template.md]"}
3069
2664
  ---
3070
2665
 
3071
2666
  # CANONICAL MASTER LESSON CONTEXT (SOURCE OF TRUTH)
@@ -3160,7 +2755,7 @@ Generate complete, verified source code that satisfies the lesson objectives and
3160
2755
  # MANDATORY TEMPLATE STRUCTURE
3161
2756
  You MUST generate data aligned with this Markdown template:
3162
2757
  ---
3163
- ${CODE_LAB_TEMPLATE}
2758
+ ${loadAuthoringTemplate("LAB_TEMPLATE.md") ?? "[TEMPLATE FILE NOT FOUND: LAB_TEMPLATE.md]"}
3164
2759
  ---
3165
2760
 
3166
2761
  # CANONICAL LESSON CONTEXT (SOURCE OF TRUTH)
@@ -3658,7 +3253,7 @@ Build a complete, engaging Self-Paced Hands-On Lab (SELF_LAB) for autonomous lea
3658
3253
  # MANDATORY TEMPLATE STRUCTURE
3659
3254
  You MUST generate data aligned with this Markdown template:
3660
3255
  ---
3661
- ${SELF_LAB_TEMPLATE}
3256
+ ${loadAuthoringTemplate("SELF_LAB_template.md") ?? "[TEMPLATE FILE NOT FOUND: SELF_LAB_template.md]"}
3662
3257
  ---
3663
3258
 
3664
3259
  # INPUT PARAMETERS
@@ -3795,7 +3390,7 @@ Use this mapping to determine which Bloom level each question truly targets. Mat
3795
3390
  # MANDATORY TEMPLATE STRUCTURE
3796
3391
  You MUST generate data aligned with this Markdown template:
3797
3392
  ---
3798
- ${QUIZ_TEMPLATE}
3393
+ ${loadAuthoringTemplate("QUIZ_v4.6_template.md") ?? "[TEMPLATE FILE NOT FOUND: QUIZ_v4.6_template.md]"}
3799
3394
  ---
3800
3395
 
3801
3396
  # INPUT PARAMETERS