@thanh01.pmt/curriculum-kit 1.4.43 → 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.
package/dist/ai/index.mjs CHANGED
@@ -1,8 +1,9 @@
1
1
  import { createGoogleGenerativeAI } from '@ai-sdk/google';
2
2
  import { createOpenAI } from '@ai-sdk/openai';
3
3
  import { createDeepSeek } from '@ai-sdk/deepseek';
4
- import fs from 'fs';
4
+ import fs2 from 'fs';
5
5
  import path from 'path';
6
+ import { fileURLToPath } from 'url';
6
7
  import { generateObject, streamObject } from 'ai';
7
8
  import { z } from 'zod';
8
9
 
@@ -126,8 +127,8 @@ function resolveApiKey(keyName, explicitKey) {
126
127
  path.resolve(currentDir, "../..", ".env")
127
128
  ];
128
129
  for (const envPath of envPaths) {
129
- if (fs.existsSync(envPath)) {
130
- const content = fs.readFileSync(envPath, "utf-8");
130
+ if (fs2.existsSync(envPath)) {
131
+ const content = fs2.readFileSync(envPath, "utf-8");
131
132
  for (const line of content.split("\n")) {
132
133
  const trimmed = line.trim();
133
134
  if (trimmed && !trimmed.startsWith("#") && trimmed.startsWith(keyName + "=")) {
@@ -1107,467 +1108,61 @@ function detectDefaultProvider() {
1107
1108
  }
1108
1109
  return getDesignatedFallbackConfig().provider;
1109
1110
  }
1110
-
1111
- // src/templates/lessonTemplate.ts
1112
- var LESSON_PLAN_TEMPLATE = `
1113
- ---
1114
- id: "{{ID}}"
1115
- title: "{{TITLE}}"
1116
- type: "LESSON_5E"
1117
- created_by: "Curriculum OS Builder"
1118
- phase: "{{PHASE}}"
1119
- deliverable: "P3-T1"
1120
- version: "{{VERSION}}"
1121
- date: "{{DATE}}"
1122
- prerequisite: []
1123
- template_contract: "lesson-plan-v2"
1124
- template_required_sections:
1125
- - "A. Lesson Design Plan"
1126
- - "Learning Objectives & Evidence"
1127
- - "Activity Sequence"
1128
- - "Resource Map"
1129
- - "Assessment Map"
1130
- - "Artifact Contract"
1131
- - "B. Lesson Flow"
1132
- ---
1133
- <!-- INJECT_BODY -->
1134
-
1135
- # LESSON [{{LESSON_ID}}]: {{TITLE}} (5E Model)
1136
-
1137
- ## [REQUIRED] A. Lesson Design Plan
1138
-
1139
- ### 1. Learning Objectives & Evidence
1140
- - **Estimated Duration:** {{DURATION}}
1141
- - **Materials & Equipment:** {{MATERIALS_SUMMARY}}
1142
- - **Keywords / Core Concepts:** {{KEYWORDS}}
1143
-
1144
- | LO | Objective (Bloom's) | Student Evidence | Success Criteria |
1145
- |---|---|---|---|
1146
- {{LEARNING_OBJECTIVES_TABLE_ROWS}}
1147
-
1148
- ### 2. Activity Sequence
1149
- > This is the canonical activity contract. Satellite artifacts must expand this sequence and must not invent a different one.
1150
-
1151
- | Seq | 5E Phase | Activity Type | Actor | Purpose | Student Action | Teacher Move | Output/Evidence | LO | Time | Artifact Contract |
1152
- |---|---|---|---|---|---|---|---|---|---|---|
1153
- {{ACTIVITY_SEQUENCE_TABLE_ROWS}}
1154
-
1155
- ### 3. Resource Map
1156
- | Resource | Used In Activity | Purpose | Owner Artifact |
1157
- |---|---|---|---|
1158
- {{RESOURCE_MAP_TABLE_ROWS}}
1159
-
1160
- ### 4. Assessment Map
1161
- | Evidence | Assessed By | Criteria | Follow-up If Missing |
1162
- |---|---|---|---|
1163
- {{ASSESSMENT_MAP_TABLE_ROWS}}
1164
-
1165
- ### 5. Artifact Contract
1166
- - **ACT must expand:** {{ACT_CONTRACT}}
1167
- - **GUIDE must support:** {{GUIDE_CONTRACT}}
1168
- - **SLIDE must visualize:** {{SLIDE_CONTRACT}}
1169
- - **HANDOUT must provide:** {{HANDOUT_CONTRACT}}
1170
- - **WKS must practice:** {{WKS_CONTRACT}}
1171
- - **QUIZ must assess:** {{QUIZ_CONTRACT}}
1172
- - **EXT must extend:** {{EXT_CONTRACT}}
1173
-
1174
- ---
1175
-
1176
- ## [REQUIRED] B. Lesson Flow
1177
-
1178
- ### 1. ENGAGE \u2014 {{ENGAGE_DURATION}} mins
1179
- - **Hook Scenario:** {{HOOK_SCENARIO}}
1180
- - **Open Question:** {{HOOK_OPEN_QUESTION}}
1181
- - **Transition:** {{HOOK_TRANSITION}}
1182
-
1183
- ### 2. EXPLORE \u2014 {{EXPLORE_DURATION}} mins
1184
- - **Activity Reference:** {{EXPLORE_ACTIVITY_REF}}
1185
- - **Student Discovery:** {{EXPLORE_STUDENT_DISCOVERY}}
1186
-
1187
- ### 3. EXPLAIN \u2014 {{EXPLAIN_DURATION}} mins
1188
- - **Definitions:**
1189
- {{EXPLAIN_DEFINITIONS}}
1190
- - **Visual Illustration (REQUIRED):**
1191
- {{EXPLAIN_VISUAL_ILLUSTRATION}}
1192
-
1193
- ### 4. ELABORATE \u2014 {{ELABORATE_DURATION}} mins
1194
- - **Tiered Scaffolding:**
1195
- - \u{1F949} **Bronze:** {{DIFFERENTIATION_BRONZE}}
1196
- - \u{1F948} **Silver:** {{DIFFERENTIATION_SILVER}}
1197
- - \u{1F947} **Gold:** {{DIFFERENTIATION_GOLD}}
1198
-
1199
- > **ACT Contract**: Detailed operational instructions must expand the Activity Sequence above and must not change the planned evidence target.
1200
-
1201
- ### 5. EVALUATE \u2014 {{EVALUATE_DURATION}} mins
1202
- - **Exit Ticket:** {{EXIT_TICKET_CONTENT}}
1203
- - **Closing:** {{CLOSING_REMARKS}}
1204
-
1205
- > **QUIZ Contract**: Detailed assessment criteria and rubrics must assess the evidence and success criteria defined in the Lesson Design Plan.
1206
-
1207
- ---
1208
-
1209
- ## [OPTIONAL] Teacher Notes
1210
- - **Common Pitfalls:**
1211
- {{COMMON_PITFALLS}}
1212
- - **Troubleshooting:**
1213
- {{TROUBLESHOOTING_ROWS}}
1214
-
1215
- ---
1216
-
1217
- ## [REQUIRED] Artifact Linkage (Master Index)
1218
- > List all satellite files used in this lesson.
1219
-
1220
- | Artifact File | Role in the Classroom | When to Use |
1221
- |---|---|---|
1222
- | \`GUIDE_{{LESSON_ID}}.md\` | Detailed Teaching Script | Teacher preparation |
1223
- | \`SLIDE_{{LESSON_ID}}.md\` | Presentation Content | Throughout the session |
1224
- | \`HANDOUT_{{LESSON_ID}}.md\` | Theory Summary for Students | During EXPLAIN phase |
1225
- | \`ACT_{{LESSON_ID}}.md\` | Detailed Learning Activity Operations | During EXPLORE / ELABORATE / checkpoint phases |
1226
- | \`WKS_{{LESSON_ID}}.md\` | Individual Worksheet | Wrap-up or Homework |
1227
- | \`QUIZ_{{LESSON_ID}}.md\` | Assessment Rubric | During EVALUATE phase |
1228
- | \`EXT_{{LESSON_ID}}.md\` | Enrichment Materials | For "Gold" students |
1229
- `.trim();
1230
-
1231
- // src/templates/actTemplate.ts
1232
- var ACT_TEMPLATE = `
1233
- ---
1234
- id: "{{ID}}"
1235
- title: "{{TITLE}}"
1236
- type: "ACT"
1237
- created_by: "Curriculum OS Builder"
1238
- phase: "{{PHASE}}"
1239
- deliverable: "P3-T2"
1240
- version: "{{VERSION}}"
1241
- date: "{{DATE}}"
1242
- template_contract: "artifact-template-v1"
1243
- template_required_sections:
1244
- - "Computational Thinking Focus"
1245
- - "Materials & Setup"
1246
- - "Constraints & Safety"
1247
- - "Active Learning Workflow"
1248
- - "3-Tier Differentiation"
1249
- - "Reflection"
1250
- ---
1251
- <!-- INJECT_BODY -->
1252
-
1253
- # INQUIRY-BASED ACTIVITY: {{TITLE}}
1254
- _Milestone: {{MILESTONE_ID}} | Module: {{MODULE_NAME}} | Lesson: {{LESSON_ID}}_
1255
-
1256
- ## [REQUIRED] Computational Thinking Focus
1257
- - **Problem Statement (Real-world Scenario):** {{PROBLEM_STATEMENT}}
1258
- - **Decomposition:**
1259
- {{DECOMPOSITION_STEPS}}
1260
- - **Algorithm Design:** {{ALGORITHM_DESIGN}}
1261
-
1262
- ## [REQUIRED] Materials & Setup
1263
- - **Reference Material:** Students should use the **HANDOUT** for this lesson as their primary technical reference (lifeline).
1264
- - **Hardware/Software:**
1265
- <!-- [HARDWARE_BOM] -->
1266
- {{HARDWARE_ITEMS}}
1267
- <!-- [/HARDWARE_BOM] -->
1268
- - **Software:** {{SOFTWARE_ITEMS}}
1269
- - **Consumables:** {{CONSUMABLES}}
1270
- - **Other Resources:** {{OTHER_RESOURCES}}
1271
-
1272
- ## [REQUIRED] Constraints & Safety
1273
- - \u26A0\uFE0F **Technical/Safety:** {{SAFETY_WARNING}}
1274
- - \u{1F4A1} **Design Constraint:** {{DESIGN_CONSTRAINT}}
1275
-
1276
- ## [REQUIRED] Active Learning Workflow
1277
-
1278
- ### Phase 1: Planning & Design \u2014 {{PHASE1_DURATION}} mins
1279
- - **Student Task:** Hand-draw (or draft in words) the algorithm flowchart or connection architecture before touching the computer/devices.
1280
- - **Teacher Action:** Walk around to check the logic of each group. Ask inquiry questions:
1281
- {{PHASE1_INQUIRY_QUESTIONS}}
1282
-
1283
- ### Phase 2: Implementation & Discovery \u2014 {{PHASE2_DURATION}} mins
1284
- - **Student Task:** Apply the knowledge from the **HANDOUT** to realize the plan designed in Phase 1. Encourage self-inquiry and documentation lookup.
1285
- - **Teacher Action:** Avoid "hand-holding." Only intervene if a group has been stuck for more than 5 minutes.
1286
- {{PHASE2_GUIDANCE_BLOCK}}
1287
-
1288
- ### Phase 3: Debugging & Testing \u2014 {{PHASE3_DURATION}} mins
1289
- - **Testing:** Students run their system.
1290
- - **Error Analysis:** Ask students to record any error codes or unexpected behaviors and compare them with the Troubleshooting table in the Handout.
1291
- {{PHASE3_TESTING_STEPS}}
1292
-
1293
- ## [REQUIRED] 3-Tier Differentiation
1294
- > MUST design tasks in 3 tiers to support diverse learner groups. Bronze is the minimum requirement for all students.
1295
- - \u{1F949} **Bronze (Foundational):** {{DIFFERENTIATION_BRONZE}}
1296
- - \u{1F948} **Silver (Application):** {{DIFFERENTIATION_SILVER}}
1297
- - \u{1F947} **Gold (Enrichment/Creative):** {{DIFFERENTIATION_GOLD}}
1298
-
1299
- ## [REQUIRED] Reflection
1300
- - **Discussion Question:** {{REFLECTION_QUESTION}}
1301
- `.trim();
1302
-
1303
- // src/templates/codeLabTemplate.ts
1304
- var CODE_LAB_TEMPLATE = `
1305
- ---
1306
- id: "{{ID}}"
1307
- title: "{{TITLE}}"
1308
- type: "LAB"
1309
- created_by: "Curriculum OS Builder"
1310
- phase: "{{PHASE}}"
1311
- deliverable: "P3-T2"
1312
- version: "{{VERSION}}"
1313
- date: "{{DATE}}"
1314
- ---
1315
- <!-- INJECT_BODY -->
1316
-
1317
- # \u{1F468}\u200D\u{1F4BB} CODE LAB: {{TITLE}}
1318
- _Milestone: {{MILESTONE_ID}} | Tech Stack: {{TECH_STACK}}_
1319
-
1320
- ## \u{1F3AF} Overview
1321
- This lab focuses on the practical implementation of core technical concepts, bridging theory into working, robust, and testable code.
1322
-
1323
- ## \u{1F6E0}\uFE0F Environment & Setup
1324
- - **Language / Framework:** {{LANGUAGE_FRAMEWORK}}
1325
- - **IDE / Editor:** {{IDE_EDITOR}}
1326
- - **Required Libraries:** {{REQUIRED_LIBRARIES}}
1327
- - **Hardware / Connection Setup:** {{HARDWARE_ENV_CONNECTION}}
1328
-
1329
- ## \u{1F4DD} Lab Tasks (3-Tier Differentiation)
1330
-
1331
- ### \u{1F949} Bronze (Foundational) \u2014 {{BRONZE_MINS}} mins
1332
- **Objective:** {{BRONZE_OBJECTIVE}}
1333
- - **Task:** {{BRONZE_TASK}}
1334
- - **Requirement:** {{BRONZE_REQUIREMENT}}
1335
-
1336
- ### \u{1F948} Silver (Application) \u2014 {{SILVER_MINS}} mins
1337
- **Objective:** {{SILVER_OBJECTIVE}}
1338
- - **Task:** {{SILVER_TASK}}
1339
- - **Requirement:** {{SILVER_REQUIREMENT}}
1340
-
1341
- ### \u{1F947} Gold (Enrichment/Creative) \u2014 {{GOLD_MINS}} mins
1342
- **Objective:** {{GOLD_OBJECTIVE}}
1343
- - **Task:** {{GOLD_TASK}}
1344
- - **Requirement:** {{GOLD_REQUIREMENT}}
1345
-
1346
- ## \u{1F4BB} Technical Reference ([SME_MANDATE])
1347
- <!-- [SME_MANDATE] -->
1348
- > Any code provided in this section is verified for syntax accuracy and runtime execution.
1349
-
1350
- ### Starter Code Template
1351
- \`\`\`{{CODE_LANGUAGE}}
1352
- {{STARTER_CODE}}
1353
- \`\`\`
1354
-
1355
- ### Solution Code
1356
- \`\`\`{{CODE_LANGUAGE}}
1357
- {{SOLUTION_CODE}}
1358
- \`\`\`
1359
- <!-- [/SME_MANDATE] -->
1360
-
1361
- ## \u{1F50D} Troubleshooting & Debugging Matrix
1362
- | Issue | Potential Cause | Solution |
1363
- | :--- | :--- | :--- |
1364
- {{TROUBLESHOOTING_ROWS}}
1365
-
1366
- ## \u{1F3C1} Submission & Verification Checklist
1367
- {{CHECKLIST_ITEMS}}
1368
- `.trim();
1369
-
1370
- // src/templates/quizTemplate.ts
1371
- var QUIZ_TEMPLATE = `
1372
- ---
1373
- id: "{{ID}}"
1374
- title: "{{TITLE}}"
1375
- type: "QUIZ"
1376
- language: "{{LANGUAGE}}"
1377
- total_questions: {{TOTAL_QUESTIONS}}
1378
- passing_score_pct: {{PASSING_SCORE_PCT}}
1379
- ---
1380
-
1381
- # \u{1F9E0} Diagnostic & Active Recall Quiz: {{TITLE}}
1382
-
1383
- > \u23F1\uFE0F **Recommended Time:** ~10-15 mins
1384
- > \u{1F3AF} **Passing Score:** {{PASSING_SCORE_PCT}}%
1385
- > \u{1F4A1} **Purpose:** Test your conceptual understanding, catch hidden misconceptions, and evaluate architectural trade-offs.
1386
-
1387
- ---
1388
-
1389
- {{QUESTIONS_SECTION}}
1390
-
1391
- ---
1392
-
1393
- ## \u{1F511} Comprehensive Answer Key & Deep Explanation (Expand after completing)
1394
- <details>
1395
- <summary><b>\u{1F449} Click to View Full Explanations & Common Pitfall Analysis</b></summary>
1396
-
1397
- {{ANSWER_KEY_SECTION}}
1398
- </details>
1399
- `.trim();
1400
-
1401
- // src/templates/selfLabTemplate.ts
1402
- var SELF_LAB_TEMPLATE = `
1403
- ---
1404
- id: "{{ID}}"
1405
- title: "{{TITLE}}"
1406
- type: "SELF_LAB"
1407
- language: "{{LANGUAGE}}"
1408
- difficulty: "{{DIFFICULTY}}"
1409
- estimated_minutes: {{ESTIMATED_MINUTES}}
1410
- tech_stack: {{TECH_STACK}}
1411
- ---
1412
-
1413
- # \u{1F680} Self-Paced Hands-On Lab: {{TITLE}}
1414
-
1415
- > \u23F1\uFE0F **Estimated Duration:** ~{{ESTIMATED_MINUTES}} mins
1416
- > \u{1F3AF} **Difficulty Level:** {{DIFFICULTY_UPPER}}
1417
- > \u{1F9F0} **Tech Stack:** {{TECH_STACK_STR}}
1418
- > \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!
1419
-
1420
- ---
1421
-
1422
- ## \u{1F4CB} Mission Briefing & Environment Setup
1423
- {{MISSION_BRIEFING}}
1424
-
1425
- ### \u{1F6EB} Preflight Checklist
1426
- {{PREFLIGHT_CHECKLIST}}
1427
-
1428
- ---
1429
-
1430
- ## \u{1F3AF} Progressive Challenges (3-Tier Differentiation)
1431
-
1432
- ### \u{1F949} Challenge 1: Foundational Core (Bronze) \u2014 ~{{BRONZE_MINS}} mins
1433
- **Objective:** {{BRONZE_OBJECTIVE}}
1434
-
1435
- #### Tasks & Implementation Details:
1436
- {{BRONZE_TASKS}}
1437
-
1438
- #### \u{1F9EA} Self-Verification Command:
1439
- \`\`\`bash
1440
- {{BRONZE_VERIFY_COMMAND}}
1441
- \`\`\`
1442
- *Expected Terminal Output:*
1443
- \`\`\`text
1444
- {{BRONZE_EXPECTED_OUTPUT}}
1445
- \`\`\`
1446
-
1447
- #### \u{1F4A1} Progressive Hints (Expand only if stuck):
1448
- <details>
1449
- <summary><b>\u{1F4A1} Hint Level 1: Conceptual Clue (H\u01B0\u1EDBng t\u01B0 duy)</b></summary>
1450
-
1451
- {{BRONZE_HINT_1}}
1452
- </details>
1453
-
1454
- <details>
1455
- <summary><b>\u{1F50D} Hint Level 2: Structural Skeleton (Khung code m\u1EABu)</b></summary>
1456
-
1457
- \`\`\`{{CODE_LANGUAGE}}
1458
- {{BRONZE_HINT_2}}
1459
- \`\`\`
1460
- </details>
1461
-
1462
- <details>
1463
- <summary><b>\u{1F6A8} Hint Level 3: Full Solution & Explanation (L\u1EDDi gi\u1EA3i tr\u1ECDn v\u1EB9n)</b></summary>
1464
-
1465
- \`\`\`{{CODE_LANGUAGE}}
1466
- {{BRONZE_HINT_3_CODE}}
1467
- \`\`\`
1468
-
1469
- **Why this solution works:**
1470
- {{BRONZE_HINT_3_EXPLANATION}}
1471
- </details>
1472
-
1473
- ---
1474
-
1475
- ### \u{1F948} Challenge 2: Logic & Error Handling (Silver) \u2014 ~{{SILVER_MINS}} mins
1476
- **Objective:** {{SILVER_OBJECTIVE}}
1477
-
1478
- #### Tasks & Implementation Details:
1479
- {{SILVER_TASKS}}
1480
-
1481
- #### \u{1F9EA} Self-Verification Command:
1482
- \`\`\`bash
1483
- {{SILVER_VERIFY_COMMAND}}
1484
- \`\`\`
1485
- *Expected Terminal Output:*
1486
- \`\`\`text
1487
- {{SILVER_EXPECTED_OUTPUT}}
1488
- \`\`\`
1489
-
1490
- #### \u{1F4A1} Progressive Hints (Expand only if stuck):
1491
- <details>
1492
- <summary><b>\u{1F4A1} Hint Level 1: Conceptual Clue (H\u01B0\u1EDBng t\u01B0 duy)</b></summary>
1493
-
1494
- {{SILVER_HINT_1}}
1495
- </details>
1496
-
1497
- <details>
1498
- <summary><b>\u{1F50D} Hint Level 2: Structural Skeleton (Khung code m\u1EABu)</b></summary>
1499
-
1500
- \`\`\`{{CODE_LANGUAGE}}
1501
- {{SILVER_HINT_2}}
1502
- \`\`\`
1503
- </details>
1504
-
1505
- <details>
1506
- <summary><b>\u{1F6A8} Hint Level 3: Full Solution & Explanation (L\u1EDDi gi\u1EA3i tr\u1ECDn v\u1EB9n)</b></summary>
1507
-
1508
- \`\`\`{{CODE_LANGUAGE}}
1509
- {{SILVER_HINT_3_CODE}}
1510
- \`\`\`
1511
-
1512
- **Why this solution works:**
1513
- {{SILVER_HINT_3_EXPLANATION}}
1514
- </details>
1515
-
1516
- ---
1517
-
1518
- ### \u{1F947} Challenge 3: Edge Cases & Optimization (Gold) \u2014 ~{{GOLD_MINS}} mins
1519
- **Objective:** {{GOLD_OBJECTIVE}}
1520
-
1521
- #### Tasks & Implementation Details:
1522
- {{GOLD_TASKS}}
1523
-
1524
- #### \u{1F9EA} Self-Verification Command:
1525
- \`\`\`bash
1526
- {{GOLD_VERIFY_COMMAND}}
1527
- \`\`\`
1528
- *Expected Terminal Output:*
1529
- \`\`\`text
1530
- {{GOLD_EXPECTED_OUTPUT}}
1531
- \`\`\`
1532
-
1533
- #### \u{1F4A1} Progressive Hints (Expand only if stuck):
1534
- <details>
1535
- <summary><b>\u{1F4A1} Hint Level 1: Conceptual Clue (H\u01B0\u1EDBng t\u01B0 duy)</b></summary>
1536
-
1537
- {{GOLD_HINT_1}}
1538
- </details>
1539
-
1540
- <details>
1541
- <summary><b>\u{1F50D} Hint Level 2: Structural Skeleton (Khung code m\u1EABu)</b></summary>
1542
-
1543
- \`\`\`{{CODE_LANGUAGE}}
1544
- {{GOLD_HINT_2}}
1545
- \`\`\`
1546
- </details>
1547
-
1548
- <details>
1549
- <summary><b>\u{1F6A8} Hint Level 3: Full Solution & Explanation (L\u1EDDi gi\u1EA3i tr\u1ECDn v\u1EB9n)</b></summary>
1550
-
1551
- \`\`\`{{CODE_LANGUAGE}}
1552
- {{GOLD_HINT_3_CODE}}
1553
- \`\`\`
1554
-
1555
- **Why this solution works:**
1556
- {{GOLD_HINT_3_EXPLANATION}}
1557
- </details>
1558
-
1559
- ---
1560
-
1561
- ## \u{1F50D} Self-Learner Troubleshooting Matrix
1562
- | Symptom / Error Message | Root Cause | Exact Fix |
1563
- | :--- | :--- | :--- |
1564
- {{TROUBLESHOOTING_ROWS}}
1565
-
1566
- ---
1567
-
1568
- ## \u{1F3C1} Final Lab Submission & Mastery Checklist
1569
- {{FINAL_CHECKLIST}}
1570
- `.trim();
1111
+ function stripTemplateFrontmatter(raw) {
1112
+ let body = raw;
1113
+ if (body.startsWith("---")) {
1114
+ const end = body.indexOf("\n---", 3);
1115
+ if (end !== -1) body = body.slice(end + 4);
1116
+ }
1117
+ return body.split("\n").filter((l) => l.trim() !== "<!-- INJECT_BODY -->").join("\n").replace(/^\s*\n/, "").trimEnd();
1118
+ }
1119
+ var KIT_TEMPLATE_FALLBACK_DIRS = [
1120
+ // Packaged with the npm bundle (dist/templates) — resolves from node_modules.
1121
+ "templates",
1122
+ // Repo checkout layouts.
1123
+ "docs/refs/templates"
1124
+ ];
1125
+ var _moduleDir = (() => {
1126
+ try {
1127
+ if (typeof import.meta !== "undefined" && typeof import.meta.url === "string") {
1128
+ return path.dirname(fileURLToPath(import.meta.url));
1129
+ }
1130
+ } catch {
1131
+ }
1132
+ return typeof __dirname !== "undefined" ? __dirname : process.cwd();
1133
+ })();
1134
+ function candidateDirs(explicitDir) {
1135
+ const dirs = [];
1136
+ if (process.env.CURRICULUM_TEMPLATES_DIR) dirs.push(process.env.CURRICULUM_TEMPLATES_DIR);
1137
+ dirs.push(path.resolve(process.cwd(), "_templates"));
1138
+ for (const rel of KIT_TEMPLATE_FALLBACK_DIRS) {
1139
+ dirs.push(path.resolve(_moduleDir, rel));
1140
+ dirs.push(path.resolve(process.cwd(), rel));
1141
+ dirs.push(path.resolve(process.cwd(), "packages/curriculum-kit", rel));
1142
+ }
1143
+ return dirs;
1144
+ }
1145
+ function findTemplatePath(templateName, explicitDir) {
1146
+ for (const dir of candidateDirs()) {
1147
+ const p = path.join(dir, templateName);
1148
+ if (!fs2.existsSync(p)) continue;
1149
+ try {
1150
+ fs2.accessSync(p, fs2.constants.R_OK);
1151
+ return p;
1152
+ } catch {
1153
+ }
1154
+ }
1155
+ return null;
1156
+ }
1157
+ function loadAuthoringTemplate(templateName, templatesDir) {
1158
+ const p = findTemplatePath(templateName);
1159
+ if (!p) return "";
1160
+ try {
1161
+ return stripTemplateFrontmatter(fs2.readFileSync(p, "utf-8"));
1162
+ } catch {
1163
+ return "";
1164
+ }
1165
+ }
1571
1166
 
1572
1167
  // src/ai/prompts/lessonMasterPrompt.ts
1573
1168
  function buildLessonMasterPrompt(input) {
@@ -1621,7 +1216,7 @@ Build a deep, rigorous, and highly pedagogical Master Lesson Plan (LESSON) that
1621
1216
  # MANDATORY TEMPLATE STRUCTURE
1622
1217
  You MUST generate structured data that will render directly into this exact Markdown template:
1623
1218
  ---
1624
- ${LESSON_PLAN_TEMPLATE}
1219
+ ${loadAuthoringTemplate("LESSON_5E_template.md") ?? "[TEMPLATE FILE NOT FOUND: LESSON_5E_template.md]"}
1625
1220
  ---
1626
1221
 
1627
1222
  # INPUT PARAMETERS
@@ -1699,7 +1294,7 @@ Transform the exact pedagogical flow and activities from the Master Lesson Plan
1699
1294
  # MANDATORY TEMPLATE STRUCTURE
1700
1295
  You MUST generate data aligned with this Markdown template:
1701
1296
  ---
1702
- ${ACT_TEMPLATE}
1297
+ ${loadAuthoringTemplate("ACT_template.md") ?? "[TEMPLATE FILE NOT FOUND: ACT_template.md]"}
1703
1298
  ---
1704
1299
 
1705
1300
  # CANONICAL MASTER LESSON CONTEXT (SOURCE OF TRUTH)
@@ -1794,7 +1389,7 @@ Generate complete, verified source code that satisfies the lesson objectives and
1794
1389
  # MANDATORY TEMPLATE STRUCTURE
1795
1390
  You MUST generate data aligned with this Markdown template:
1796
1391
  ---
1797
- ${CODE_LAB_TEMPLATE}
1392
+ ${loadAuthoringTemplate("LAB_TEMPLATE.md") ?? "[TEMPLATE FILE NOT FOUND: LAB_TEMPLATE.md]"}
1798
1393
  ---
1799
1394
 
1800
1395
  # CANONICAL LESSON CONTEXT (SOURCE OF TRUTH)
@@ -2489,7 +2084,7 @@ Build a complete, engaging Self-Paced Hands-On Lab (SELF_LAB) for autonomous lea
2489
2084
  # MANDATORY TEMPLATE STRUCTURE
2490
2085
  You MUST generate data aligned with this Markdown template:
2491
2086
  ---
2492
- ${SELF_LAB_TEMPLATE}
2087
+ ${loadAuthoringTemplate("SELF_LAB_template.md") ?? "[TEMPLATE FILE NOT FOUND: SELF_LAB_template.md]"}
2493
2088
  ---
2494
2089
 
2495
2090
  # INPUT PARAMETERS
@@ -2626,7 +2221,7 @@ Use this mapping to determine which Bloom level each question truly targets. Mat
2626
2221
  # MANDATORY TEMPLATE STRUCTURE
2627
2222
  You MUST generate data aligned with this Markdown template:
2628
2223
  ---
2629
- ${QUIZ_TEMPLATE}
2224
+ ${loadAuthoringTemplate("QUIZ_v4.6_template.md") ?? "[TEMPLATE FILE NOT FOUND: QUIZ_v4.6_template.md]"}
2630
2225
  ---
2631
2226
 
2632
2227
  # INPUT PARAMETERS