@thanh01.pmt/domain-kit 0.1.0 → 0.2.1

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.
Files changed (81) hide show
  1. package/LICENSE +21 -0
  2. package/dist/{chunk-GEUDHZE7.mjs → chunk-23TQPTHG.mjs} +173 -4
  3. package/dist/chunk-23TQPTHG.mjs.map +1 -0
  4. package/dist/chunk-7XGWW6CB.mjs +3 -0
  5. package/dist/{chunk-F4RZNBOE.mjs.map → chunk-7XGWW6CB.mjs.map} +1 -1
  6. package/dist/{chunk-VFART56O.mjs → chunk-BL5NBKPH.mjs} +12 -8
  7. package/dist/chunk-BL5NBKPH.mjs.map +1 -0
  8. package/dist/{chunk-3VVPSRAM.mjs → chunk-CRN6D4HG.mjs} +1056 -92
  9. package/dist/chunk-CRN6D4HG.mjs.map +1 -0
  10. package/dist/{chunk-3H2HX7PR.mjs → chunk-HUDFN4IX.mjs} +58 -8
  11. package/dist/chunk-HUDFN4IX.mjs.map +1 -0
  12. package/dist/chunk-IJZUV7N3.mjs +3 -0
  13. package/dist/chunk-IJZUV7N3.mjs.map +1 -0
  14. package/dist/chunk-R57WTNXW.mjs +3 -0
  15. package/dist/chunk-R57WTNXW.mjs.map +1 -0
  16. package/dist/chunk-T4Y2DE2W.mjs +187 -0
  17. package/dist/chunk-T4Y2DE2W.mjs.map +1 -0
  18. package/dist/{chunk-PM42MMDJ.mjs → chunk-WHBAGJWN.mjs} +48 -3
  19. package/dist/chunk-WHBAGJWN.mjs.map +1 -0
  20. package/dist/chunk-ZKLT27T4.mjs +3 -0
  21. package/dist/chunk-ZKLT27T4.mjs.map +1 -0
  22. package/dist/concepts/index.d.cts +2 -2
  23. package/dist/concepts/index.d.ts +2 -2
  24. package/dist/cpp-CZUPqJt9.d.cts +98 -0
  25. package/dist/cpp-CZUPqJt9.d.ts +98 -0
  26. package/dist/curriculumFeedEmitter-E5DAJYUZ.mjs +4 -0
  27. package/dist/curriculumFeedEmitter-E5DAJYUZ.mjs.map +1 -0
  28. package/dist/detector/index.cjs +10 -6
  29. package/dist/detector/index.cjs.map +1 -1
  30. package/dist/detector/index.d.cts +4 -19
  31. package/dist/detector/index.d.ts +4 -19
  32. package/dist/detector/index.mjs +2 -1
  33. package/dist/domainProfileDetector-DHb1T0zB.d.ts +22 -0
  34. package/dist/domainProfileDetector-bzugdQmS.d.cts +22 -0
  35. package/dist/extractors/index.d.cts +3 -3
  36. package/dist/extractors/index.d.ts +3 -3
  37. package/dist/feed/index.cjs +56 -6
  38. package/dist/feed/index.cjs.map +1 -1
  39. package/dist/feed/index.mjs +2 -1
  40. package/dist/graph/index.cjs +370 -66
  41. package/dist/graph/index.cjs.map +1 -1
  42. package/dist/graph/index.d.cts +7 -67
  43. package/dist/graph/index.d.ts +7 -67
  44. package/dist/graph/index.mjs +3 -2
  45. package/dist/hybridGraphPipeline-DVZYLCAQ.d.ts +159 -0
  46. package/dist/hybridGraphPipeline-DmWRKYXf.d.cts +159 -0
  47. package/dist/index.cjs +1303 -700
  48. package/dist/index.cjs.map +1 -1
  49. package/dist/index.d.cts +9 -7
  50. package/dist/index.d.ts +9 -7
  51. package/dist/index.mjs +10 -7
  52. package/dist/{keywordExtractor-zPAz2isq.d.cts → keywordExtractor-BxlGRMHC.d.cts} +1 -1
  53. package/dist/{keywordExtractor-CKaXqSku.d.ts → keywordExtractor-DU5XRN8-.d.ts} +1 -1
  54. package/dist/parsers/index.cjs +185 -0
  55. package/dist/parsers/index.cjs.map +1 -1
  56. package/dist/parsers/index.d.cts +2 -98
  57. package/dist/parsers/index.d.ts +2 -98
  58. package/dist/parsers/index.mjs +2 -1
  59. package/dist/pipeline/index.cjs +3142 -8
  60. package/dist/pipeline/index.cjs.map +1 -1
  61. package/dist/pipeline/index.d.cts +87 -4
  62. package/dist/pipeline/index.d.ts +87 -4
  63. package/dist/pipeline/index.mjs +6 -2
  64. package/dist/schemas/index.cjs +51 -0
  65. package/dist/schemas/index.cjs.map +1 -1
  66. package/dist/schemas/index.d.cts +222 -3
  67. package/dist/schemas/index.d.ts +222 -3
  68. package/dist/schemas/index.mjs +1 -1
  69. package/dist/syllabusParser-MSX1fEzW.d.cts +40 -0
  70. package/dist/syllabusParser-MSX1fEzW.d.ts +40 -0
  71. package/package.json +9 -10
  72. package/dist/chunk-3H2HX7PR.mjs.map +0 -1
  73. package/dist/chunk-3VVPSRAM.mjs.map +0 -1
  74. package/dist/chunk-F4RZNBOE.mjs +0 -3
  75. package/dist/chunk-GEUDHZE7.mjs.map +0 -1
  76. package/dist/chunk-MOKNFLUD.mjs +0 -851
  77. package/dist/chunk-MOKNFLUD.mjs.map +0 -1
  78. package/dist/chunk-PM42MMDJ.mjs.map +0 -1
  79. package/dist/chunk-VFART56O.mjs.map +0 -1
  80. package/dist/graphVerifier-DsTP9uAN.d.ts +0 -37
  81. package/dist/graphVerifier-QjgDAJce.d.cts +0 -37
@@ -44,22 +44,47 @@ function feedNodeFromStep(step, featureId) {
44
44
  introduce_aspect: null
45
45
  };
46
46
  }
47
+ function deriveConceptDepthHint(concept) {
48
+ const explicit = str(concept.depth_hint);
49
+ if (explicit === "ulo" || explicit === "cio" || explicit === "sio") return explicit;
50
+ const sio = arr(concept.sio);
51
+ const prereqs = strs(concept.prerequisites);
52
+ const pts = arr(concept.problem_types);
53
+ const hasHighBloom = pts.some((p) => {
54
+ const b = str(p.bloom_level);
55
+ return b === "Apply" || b === "Analyze" || b === "Evaluate" || b === "Create";
56
+ });
57
+ if (sio.length >= 2 || hasHighBloom) return "sio";
58
+ if (str(concept.cio) || prereqs.length >= 1) return "cio";
59
+ return "ulo";
60
+ }
47
61
  function feedNodeFromConcept(concept) {
48
62
  const id = str(concept.id);
49
63
  const pts = arr(concept.problem_types).map((p) => str(p.bloom_level, "Understand")).filter((b) => b in BLOOM_RANK).sort((a, b) => BLOOM_RANK[a] - BLOOM_RANK[b]);
50
64
  const topBloom = pts[pts.length - 1] ?? "Understand";
65
+ const rawRefs = arr(concept.references);
66
+ const references = rawRefs.length > 0 ? rawRefs.map((r) => ({ file: str(r.file, "syllabus.md"), evidence: str(r.evidence, str(concept.name)) })).filter((r) => r.file) : [{ file: "syllabus.md", evidence: str(concept.category ? `Topic under category ${str(concept.category)}` : str(concept.name), id) }];
67
+ const problemScaffolds = arr(concept.problem_types).map((pt) => ({
68
+ item: str(pt.name, "Problem type"),
69
+ reason: str(pt.description, "Formative practice check"),
70
+ minutes_saved: num(pt.estimated_minutes, 10),
71
+ suggest: "provide_partial"
72
+ }));
51
73
  return {
52
74
  id,
53
75
  kind: "concept",
54
76
  name: str(concept.name, id),
55
77
  concept_codes: [str(concept.code) || id].filter(Boolean),
56
78
  keywords: { all: strs(concept.keywords), new: [], prerequisite: [] },
57
- estimated_minutes: Math.max(0, Math.round(num(concept.estimated_minutes, 30))),
79
+ estimated_minutes: Math.max(0, Math.round(num(concept.estimated_minutes, 15))),
58
80
  bloom_hint: topBloom,
59
- depth_hint: null,
81
+ depth_hint: deriveConceptDepthHint(concept),
60
82
  completion_level: "standard",
61
- scaffolding: { scaffold_candidates: [], core_value_minutes: 0 },
62
- references: [],
83
+ scaffolding: {
84
+ scaffold_candidates: problemScaffolds,
85
+ core_value_minutes: Math.max(0, Math.round(num(concept.estimated_minutes, 15)))
86
+ },
87
+ references,
63
88
  feature_id: null,
64
89
  concept_ref: id,
65
90
  phase_id: "",
@@ -265,16 +290,41 @@ function emitFromKnowledge(kg, opts) {
265
290
  const nodes = [];
266
291
  const edges = [];
267
292
  const groupings = [];
293
+ const conceptIds = new Set(arr(kg.concepts).map((c) => str(c.id)));
268
294
  for (const c of arr(kg.concepts)) {
269
295
  const node = feedNodeFromConcept(c);
270
296
  nodes.push(node);
271
- for (const p of strs(c.prerequisites)) edges.push({ from: p, to: node.id, kind: "knowledge", reason: "concept prerequisite" });
297
+ for (const p of strs(c.prerequisites)) {
298
+ if (p !== node.id && conceptIds.has(p)) {
299
+ edges.push({
300
+ from: p,
301
+ to: node.id,
302
+ kind: "knowledge",
303
+ reason: `concept prerequisite: ${p} must be understood before ${node.id}`
304
+ });
305
+ }
306
+ }
307
+ }
308
+ if (arr(kg.learning_path).length > 0) {
309
+ const orderMap = /* @__PURE__ */ new Map();
310
+ arr(kg.learning_path).forEach((s, idx) => {
311
+ const cid = str(s.concept_id);
312
+ if (cid) orderMap.set(cid, num(s.order, idx + 1));
313
+ });
314
+ nodes.sort((a, b) => (orderMap.get(a.id) ?? 999) - (orderMap.get(b.id) ?? 999));
272
315
  }
273
316
  let ci = 0;
274
317
  for (const cat of arr(kg.categories)) {
275
318
  ci += 1;
276
319
  const ids = strs(cat.concept_ids).filter((id) => nodes.some((n) => n.id === id));
277
- if (ids.length > 0) groupings.push({ id: str(cat.id, "cat" + ci), name: str(cat.name, "Category " + ci), node_ids: ids, rationale: str(cat.description, "") });
320
+ if (ids.length > 0) {
321
+ groupings.push({
322
+ id: str(cat.id, "cat" + ci),
323
+ name: str(cat.name, "Category " + ci),
324
+ node_ids: ids,
325
+ rationale: str(cat.description, "")
326
+ });
327
+ }
278
328
  }
279
329
  newKeywordsInOrder(nodes);
280
330
  return validateCurriculumFeed({
@@ -320,5 +370,5 @@ function emitCurriculumFeed(graph, opts = {}) {
320
370
  }
321
371
 
322
372
  export { emitCurriculumFeed };
323
- //# sourceMappingURL=chunk-3H2HX7PR.mjs.map
324
- //# sourceMappingURL=chunk-3H2HX7PR.mjs.map
373
+ //# sourceMappingURL=chunk-HUDFN4IX.mjs.map
374
+ //# sourceMappingURL=chunk-HUDFN4IX.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/feed/curriculumFeedEmitter.ts"],"names":[],"mappings":";;;AAsBA,IAAM,UAAA,GAAqC,EAAE,QAAA,EAAU,CAAA,EAAG,UAAA,EAAY,CAAA,EAAG,KAAA,EAAO,CAAA,EAAG,OAAA,EAAS,CAAA,EAAG,QAAA,EAAU,CAAA,EAAG,QAAQ,CAAA,EAAE;AACtH,IAAM,IAAA,GAAO,CAAC,CAAA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Feed, type FeedNode, type FeedEdge, type FeedGrouping,\n} from '../schemas/curriculumFeedSchema';\n\n/**\n * CurriculumFeed emitter - pure transformation from a VERIFIED domain graph\n * to the planner-ready feed. No LLM calls: hints derive from existing\n * annotations only. Validates its own output (fail-closed).\n *\n * Phase-driven emission (hybrid graphs with development phases): the teaching\n * sequence IS the phase sequence. Concepts are emitted at the phase that\n * introduces them (aspect new) or revisits them at higher depth (aspect\n * advanced) - never as a trailing knowledge appendix. Concept minutes stay\n * UNMERGED: no prerequisite-minute inflation (the planner schedules the\n * revisit, not the total).\n */\n\nexport interface EmitFeedOptions {\n hallucinationCount?: number;\n warnings?: string[];\n}\n\nconst BLOOM_RANK: Record<string, number> = { Remember: 0, Understand: 1, Apply: 2, Analyze: 3, Evaluate: 4, Create: 5 };\nconst pad2 = (n: number): string => String(n).padStart(2, '0');\n\ntype Rec = Record<string, unknown>;\nconst arr = (v: unknown): Rec[] => (Array.isArray(v) ? (v as Rec[]) : []);\nconst str = (v: unknown, d = ''): string => (typeof v === 'string' ? v : d);\nconst num = (v: unknown, d: number): number => (typeof v === 'number' && Number.isFinite(v) ? v : d);\nconst strs = (v: unknown): string[] => (Array.isArray(v) ? v.filter((x): x is string => typeof x === 'string') : []);\n\nfunction stepMinutes(step: Rec): number {\n const effort = (step.effort ?? {}) as Rec;\n return Math.max(0, Math.round(num(effort.estimated_minutes, num(step.estimated_minutes, 45))));\n}\n\nfunction newKeywordsInOrder(nodes: FeedNode[]): void {\n // First appearance in emission order becomes 'new'; everything seen before is 'prerequisite'.\n const seen = new Set<string>();\n for (const n of nodes) {\n const all = n.keywords.all;\n n.keywords.new = [];\n n.keywords.prerequisite = [];\n for (const k of all) {\n if (seen.has(k)) n.keywords.prerequisite.push(k);\n else n.keywords.new.push(k);\n seen.add(k);\n }\n }\n}\n\nfunction feedNodeFromStep(step: Rec, featureId: string): FeedNode {\n const id = str(step.id);\n return {\n id,\n kind: 'product_step',\n name: str(step.name, id),\n concept_codes: strs(step.concept_codes),\n keywords: { all: strs(step.keywords), new: [], prerequisite: [] },\n estimated_minutes: stepMinutes(step),\n bloom_hint: 'Apply',\n depth_hint: null,\n completion_level: 'standard',\n scaffolding: { scaffold_candidates: [], core_value_minutes: stepMinutes(step) },\n references: arr(step.files).map((f) => ({ file: str(f), evidence: 'step file' })).filter((f) => f.file),\n feature_id: featureId,\n concept_ref: null,\n phase_id: '',\n introduce_aspect: null,\n };\n}\n\nfunction deriveConceptDepthHint(concept: Rec): FeedNode['depth_hint'] {\n const explicit = str(concept.depth_hint);\n if (explicit === 'ulo' || explicit === 'cio' || explicit === 'sio') return explicit;\n\n const sio = arr(concept.sio);\n const prereqs = strs(concept.prerequisites);\n const pts = arr(concept.problem_types);\n const hasHighBloom = pts.some((p) => {\n const b = str(p.bloom_level);\n return b === 'Apply' || b === 'Analyze' || b === 'Evaluate' || b === 'Create';\n });\n\n if (sio.length >= 2 || hasHighBloom) return 'sio';\n if (str(concept.cio) || prereqs.length >= 1) return 'cio';\n return 'ulo';\n}\n\nfunction feedNodeFromConcept(concept: Rec): FeedNode {\n const id = str(concept.id);\n const pts = arr(concept.problem_types)\n .map((p) => str(p.bloom_level, 'Understand'))\n .filter((b) => b in BLOOM_RANK)\n .sort((a, b) => BLOOM_RANK[a] - BLOOM_RANK[b]);\n const topBloom = pts[pts.length - 1] ?? 'Understand';\n\n const rawRefs = arr(concept.references);\n const references = rawRefs.length > 0\n ? rawRefs.map((r) => ({ file: str(r.file, 'syllabus.md'), evidence: str(r.evidence, str(concept.name)) })).filter((r) => r.file)\n : [{ file: 'syllabus.md', evidence: str(concept.category ? `Topic under category ${str(concept.category)}` : str(concept.name), id) }];\n\n const problemScaffolds = arr(concept.problem_types).map((pt) => ({\n item: str(pt.name, 'Problem type'),\n reason: str(pt.description, 'Formative practice check'),\n minutes_saved: num(pt.estimated_minutes, 10),\n suggest: 'provide_partial' as const,\n }));\n\n return {\n id,\n kind: 'concept',\n name: str(concept.name, id),\n concept_codes: [str(concept.code) || id].filter(Boolean),\n keywords: { all: strs(concept.keywords), new: [], prerequisite: [] },\n estimated_minutes: Math.max(0, Math.round(num(concept.estimated_minutes, 15))),\n bloom_hint: topBloom as FeedNode['bloom_hint'],\n depth_hint: deriveConceptDepthHint(concept),\n completion_level: 'standard',\n scaffolding: {\n scaffold_candidates: problemScaffolds,\n core_value_minutes: Math.max(0, Math.round(num(concept.estimated_minutes, 15))),\n },\n references,\n feature_id: null,\n concept_ref: id,\n phase_id: '',\n introduce_aspect: null,\n };\n}\n\nfunction addFeatureGroup(\n f: Rec, fid: string, nodes: FeedNode[], edges: FeedEdge[], groupings: FeedGrouping[],\n): string[] {\n const steps = arr(f.steps);\n const stepIds: string[] = [];\n let prev = '';\n for (let i = 0; i < steps.length; i++) {\n const stepNode = feedNodeFromStep(steps[i], fid);\n if (!stepNode.id) continue;\n stepIds.push(stepNode.id);\n nodes.push(stepNode);\n if (prev) edges.push({ from: prev, to: stepNode.id, kind: 'task', reason: 'feature build order' });\n prev = stepNode.id;\n }\n for (const dep of strs(f.depends_on)) {\n const depFirst = nodes.find((n) => n.feature_id === dep);\n if (depFirst && stepIds[0]) edges.push({ from: depFirst.id, to: stepIds[0], kind: 'task', reason: 'feature depends_on ' + dep });\n }\n if (stepIds.length > 0) groupings.push({ id: 'G-' + fid, name: str(f.name, fid), node_ids: stepIds, rationale: str(f.description, '') });\n return stepIds;\n}\n\ninterface EmitPhaseCtx {\n id: string;\n order: number;\n name: string;\n productCompletion: string;\n conceptOrder: string[]; // concept node ids in teaching order (new first, then advanced)\n featureIds: string[];\n}\n\n/**\n * Phase-driven hybrid emission:\n * - emit concepts per phase (aspect new first, then advanced) BEFORE the\n * phase's features; knowledge edges concept -> first step of consumer\n * features carry the JIT relation\n * - feature order inside a phase follows the project graph order\n * - phases and their node_ids go into feed.phases (teaching sequence)\n * - concept minutes stay UNMERGED (no prereq-minute accumulation)\n */\nfunction emitFromHybrid(hybrid: Rec, opts: EmitFeedOptions): CurriculumFeed {\n const nodes: FeedNode[] = [];\n const edges: FeedEdge[] = [];\n const groupings: FeedGrouping[] = [];\n const pg = (hybrid.project_graph ?? {}) as Rec;\n const kg = (hybrid.knowledge_graph ?? {}) as Rec;\n const rawPhases = arr(hybrid.phases).filter((p) => str(p.id));\n\n const features = arr(pg.features);\n const conceptRecs = arr(kg.concepts);\n const conceptById = new Map(conceptRecs.map((c) => [str(c.id), c]));\n\n // --- no phases -> legacy path (concepts first, then features) -----------\n if (rawPhases.length === 0) {\n for (const c of conceptRecs) {\n const node = feedNodeFromConcept(c);\n nodes.push(node);\n for (const p of strs(c.prerequisites)) edges.push({ from: p, to: node.id, kind: 'knowledge', reason: 'concept prerequisite' });\n }\n features.forEach((f, fi) => addFeatureGroup(f, str(f.id, 'F' + pad2(fi + 1)), nodes, edges, groupings));\n linkHybridKnowledgeEdges(hybrid, nodes, edges, true);\n newKeywordsInOrder(nodes);\n return validateCurriculumFeed({\n schema_version: 2,\n source: { graph_type: 'hybrid_graph', warnings: opts.warnings ?? [], hallucination_count: opts.hallucinationCount ?? 0 },\n learning_nodes: nodes,\n dependency_edges: edges,\n suggested_groupings: groupings,\n phases: [],\n });\n }\n\n // --- phase-driven emission ----------------------------------------------\n const featureOrder = new Map<string, number>();\n features.forEach((f, fi) => featureOrder.set(str(f.id, 'F' + pad2(fi + 1)), fi));\n const stepIdsByFeature = new Map<string, string[]>();\n for (const f of features) {\n const fid = str(f.id);\n stepIdsByFeature.set(fid, arr(f.steps).map((s) => str(s.id)).filter(Boolean));\n }\n\n const emitCtx: EmitPhaseCtx[] = [];\n const emittedConcepts = new Set<string>();\n const linkList = arr(hybrid.links);\n\n for (const rp of rawPhases) {\n const pid = str(rp.id);\n const order = num(rp.order, emitCtx.length + 1);\n const conceptOrder: string[] = [];\n const intros = arr(rp.introduces);\n // new introductions first, then advanced revisits (teaching order)\n const news = intros.filter((i) => str(i.aspect, 'new') === 'new');\n const advanced = intros.filter((i) => str(i.aspect) === 'advanced');\n for (const intro of [...news, ...advanced]) {\n const cid = str(intro.concept_id);\n const c = conceptById.get(cid);\n if (!c) {\n throw new Error('Phase ' + pid + ' introduces unknown concept ' + cid + ' - fail-closed');\n }\n if (str(intro.aspect, 'new') === 'advanced' && !emittedConcepts.has(cid)) {\n throw new Error('Phase ' + pid + ' advanced-revisits concept ' + cid + ' that was never emitted - fail-closed');\n }\n if (!emittedConcepts.has(cid)) {\n const node = feedNodeFromConcept(c);\n node.phase_id = pid;\n node.introduce_aspect = 'new';\n nodes.push(node);\n for (const p of strs(c.prerequisites)) {\n if (!emittedConcepts.has(p)) {\n throw new Error('Concept ' + cid + ' (phase ' + pid + ') has prerequisite ' + p + ' that is not introduced in an earlier phase - fail-closed');\n }\n edges.push({ from: p, to: cid, kind: 'knowledge', reason: 'concept prerequisite' });\n }\n emittedConcepts.add(cid);\n conceptOrder.push(cid);\n } else {\n // advanced revisit: re-emit as a NEW node with a revisit id so the\n // planner can schedule the higher-depth pass without double-counting\n // the first introduction\n const revisitId = cid + '__ADV' + pad2(order);\n const node = feedNodeFromConcept(c);\n node.id = revisitId;\n node.name = str(c.name, cid) + ' (advanced)';\n node.phase_id = pid;\n node.introduce_aspect = 'advanced';\n node.estimated_minutes = Math.max(15, Math.round(node.estimated_minutes * 0.5));\n node.concept_codes = [str(c.code) || cid];\n edges.push({ from: cid, to: revisitId, kind: 'knowledge', reason: 'advanced revisit of ' + cid + ' at phase ' + pid });\n nodes.push(node);\n conceptOrder.push(revisitId);\n }\n }\n const featureIds = strs(rp.feature_ids)\n .filter((fid) => featureOrder.has(fid))\n .sort((a, b) => featureOrder.get(a)! - featureOrder.get(b)!);\n emitCtx.push({ id: pid, order, name: str(rp.name, pid), productCompletion: str(rp.product_completion), conceptOrder, featureIds });\n }\n\n // Fail-closed: every concept consumed by a link must be emitted somewhere\n for (const l of linkList) {\n const cid = str(l.concept_id);\n if (cid && conceptById.has(cid) && !emittedConcepts.has(cid)) {\n throw new Error('Concept ' + cid + ' is consumed by links but never introduced in any phase - fail-closed');\n }\n }\n // Fail-closed: every feature must sit in exactly one emitted phase\n const seenFeatures = new Set(emitCtx.flatMap((e) => e.featureIds));\n const missingFeatures = features.map((f) => str(f.id)).filter((fid) => fid && !seenFeatures.has(fid));\n if (missingFeatures.length > 0) {\n throw new Error('Features not covered by any phase: ' + missingFeatures.join(', ') + ' - fail-closed');\n }\n\n // Emit feature steps phase by phase (teaching sequence)\n const phaseNodeIds: string[][] = [];\n for (const ctx of emitCtx) {\n const ids: string[] = [...ctx.conceptOrder];\n for (const fid of ctx.featureIds) {\n const f = features.find((x) => str(x.id) === fid)!;\n const stepIds = addFeatureGroup(f, fid, nodes, edges, groupings);\n for (const sid of stepIds) {\n const node = nodes.find((n) => n.id === sid)!;\n node.phase_id = ctx.id;\n }\n ids.push(...stepIds);\n }\n phaseNodeIds.push(ids);\n }\n\n // Knowledge edges: concept -> first step of each consumer feature (JIT).\n // Deduped by (from,to): several links may target the same feature.\n const edgeSeen = new Set(edges.map((e) => e.from + '>' + e.to));\n const pushEdge = (from: string, to: string, reason: string) => {\n const key = from + '>' + to;\n if (edgeSeen.has(key)) return;\n edgeSeen.add(key);\n edges.push({ from, to, kind: 'knowledge', reason });\n };\n for (const l of linkList) {\n const cid = str(l.concept_id);\n const fid = str(l.feature_id);\n if (!conceptById.has(cid)) continue;\n const firstStep = (stepIdsByFeature.get(fid) || [])[0];\n if (!firstStep) continue;\n const depth = str(l.depth, 'cio');\n pushEdge(cid, firstStep, str(l.relationship, 'hybrid link') + ' [' + depth + ']');\n // Advanced revisits feed only features of the revisit's OWN phase: a PH2\n // revisit must never become a prerequisite of a PH1 feature (teaching\n // order is phase-ordered).\n for (const n of nodes) {\n if (n.kind === 'concept' && n.concept_ref === cid && n.introduce_aspect === 'advanced' && n.phase_id === str(l.phase_id)) {\n pushEdge(n.id, firstStep, 'advanced application [' + depth + ']');\n }\n }\n }\n\n newKeywordsInOrder(nodes);\n\n // Deterministic keyword-prerequisite materialization: when a node declares a\n // keyword as PREREQUISITE, some other node must INTRODUCE it (new) EARLIER in\n // feed order. Missing edge = planner can schedule the consumer first while the\n // audit flags ordering it cannot fix. Edge kind 'keyword' — the planner\n // honors it for topological order; 'mastered_before_course' entries are exempt\n // (entry-level keywords need no introducer).\n const feedOrder = new Map(nodes.map((n, i) => [n.id, i]));\n const introducer = new Map<string, string>();\n for (const n of nodes) for (const k of n.keywords?.new ?? []) {\n const key = k.toLowerCase();\n if (!introducer.has(key)) introducer.set(key, n.id);\n }\n for (const n of nodes) {\n for (const k of n.keywords?.prerequisite ?? []) {\n const src = introducer.get(k.toLowerCase());\n if (!src || src === n.id) continue;\n if (feedOrder.get(src)! < feedOrder.get(n.id)!) pushEdge(src, n.id, 'keyword prerequisite [' + k + ']');\n }\n }\n\n const phases = emitCtx.map((ctx, i) => ({\n id: ctx.id,\n order: ctx.order,\n name: ctx.name,\n product_completion: ctx.productCompletion || 'Phase ' + (i + 1) + ' deliverable',\n node_ids: phaseNodeIds[i],\n }));\n\n return validateCurriculumFeed({\n schema_version: 2,\n source: { graph_type: 'hybrid_graph', warnings: opts.warnings ?? [], hallucination_count: opts.hallucinationCount ?? 0 },\n learning_nodes: nodes,\n dependency_edges: edges,\n suggested_groupings: groupings,\n phases,\n });\n}\n\n/** Legacy helper: knowledge edges from hybrid links (used by the no-phase path). */\nfunction linkHybridKnowledgeEdges(hybrid: Rec, nodes: FeedNode[], edges: FeedEdge[], setStepHints: boolean): void {\n const conceptIds = new Set(nodes.filter((n) => n.kind === 'concept').map((n) => n.concept_ref || n.id));\n for (const l of arr(hybrid.links)) {\n const conceptId = str(l.concept_id);\n const featureId = str(l.feature_id);\n if (!conceptIds.has(conceptId)) continue;\n const depth = str(l.depth, 'cio');\n const firstStep = nodes.find((n) => n.feature_id === featureId);\n if (firstStep) {\n edges.push({ from: conceptId, to: firstStep.id, kind: 'knowledge', reason: str(l.relationship, 'hybrid link') + ' [' + depth + ']' });\n if (setStepHints && !firstStep.depth_hint) {\n firstStep.depth_hint = (['ulo', 'cio', 'sio'] as const).includes(depth as 'ulo') ? (depth as FeedNode['depth_hint']) : 'cio';\n }\n }\n }\n}\n\nfunction emitFromKnowledge(kg: Rec, opts: EmitFeedOptions): CurriculumFeed {\n const nodes: FeedNode[] = [];\n const edges: FeedEdge[] = [];\n const groupings: FeedGrouping[] = [];\n const conceptIds = new Set(arr(kg.concepts).map((c) => str(c.id)));\n for (const c of arr(kg.concepts)) {\n const node = feedNodeFromConcept(c);\n nodes.push(node);\n for (const p of strs(c.prerequisites)) {\n if (p !== node.id && conceptIds.has(p)) {\n edges.push({\n from: p,\n to: node.id,\n kind: 'knowledge',\n reason: `concept prerequisite: ${p} must be understood before ${node.id}`,\n });\n }\n }\n }\n\n // Sort nodes by learning_path order if present\n if (arr(kg.learning_path).length > 0) {\n const orderMap = new Map<string, number>();\n arr(kg.learning_path).forEach((s, idx) => {\n const cid = str(s.concept_id);\n if (cid) orderMap.set(cid, num(s.order, idx + 1));\n });\n nodes.sort((a, b) => (orderMap.get(a.id) ?? 999) - (orderMap.get(b.id) ?? 999));\n }\n\n let ci = 0;\n for (const cat of arr(kg.categories)) {\n ci += 1;\n const ids = strs(cat.concept_ids).filter((id) => nodes.some((n) => n.id === id));\n if (ids.length > 0) {\n groupings.push({\n id: str(cat.id, 'cat' + ci),\n name: str(cat.name, 'Category ' + ci),\n node_ids: ids,\n rationale: str(cat.description, ''),\n });\n }\n }\n newKeywordsInOrder(nodes);\n return validateCurriculumFeed({\n schema_version: 2,\n source: { graph_type: 'knowledge_graph', warnings: opts.warnings ?? [], hallucination_count: opts.hallucinationCount ?? 0 },\n learning_nodes: nodes,\n dependency_edges: edges,\n suggested_groupings: groupings,\n phases: [],\n });\n}\n\nfunction emitFromProject(pg: Rec, opts: EmitFeedOptions): CurriculumFeed {\n const nodes: FeedNode[] = [];\n const edges: FeedEdge[] = [];\n const groupings: FeedGrouping[] = [];\n arr(pg.features).forEach((f, fi) => addFeatureGroup(f, str(f.id, 'F' + pad2(fi + 1)), nodes, edges, groupings));\n if (nodes.length === 0 && arr(pg.features).length > 0) {\n const hasTasks = arr((pg.implementation ?? {}) as Rec).length > 0 || arr((pg.implementation as Rec | undefined)?.tasks).length > 0;\n throw new Error(\n 'Project graph has ' + arr(pg.features).length + ' features but NO features[].steps - the curriculum feed cannot emit planning nodes.' +\n (hasTasks\n ? ' This looks like a legacy knowledge-tree graph (implementation.tasks). Regenerate it with the domain-kit v3 pipeline (runProjectGraphPipeline / hybridGraphPipeline), then re-run.'\n : ' Every feature must carry at least one step with id/name/keywords/effort for curriculum planning.'),\n );\n }\n newKeywordsInOrder(nodes);\n return validateCurriculumFeed({\n schema_version: 2,\n source: { graph_type: 'project_graph', warnings: opts.warnings ?? [], hallucination_count: opts.hallucinationCount ?? 0 },\n learning_nodes: nodes,\n dependency_edges: edges,\n suggested_groupings: groupings,\n phases: [],\n });\n}\n\n/** Emit a CurriculumFeed from whichever graph shape is provided (already verified upstream). */\nexport function emitCurriculumFeed(\n graph: unknown,\n opts: EmitFeedOptions = {},\n): CurriculumFeed {\n const g = graph as Rec;\n if (arr(g.learning_nodes).length > 0) {\n return validateCurriculumFeed(g); // already a feed - pass-through validation\n }\n if (g.project_graph || g.knowledge_graph || arr(g.links).length > 0 || arr(g.phases).length > 0) {\n return emitFromHybrid(g, opts);\n }\n if (arr(g.concepts).length > 0 || str(g.type) === 'knowledge_graph') return emitFromKnowledge(g, opts);\n return emitFromProject(g, opts);\n}\n"]}
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=chunk-IJZUV7N3.mjs.map
3
+ //# sourceMappingURL=chunk-IJZUV7N3.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-IJZUV7N3.mjs"}
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=chunk-R57WTNXW.mjs.map
3
+ //# sourceMappingURL=chunk-R57WTNXW.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-R57WTNXW.mjs"}
@@ -0,0 +1,187 @@
1
+ // src/parsers/syllabusParser.ts
2
+ var STOP_WORDS = /* @__PURE__ */ new Set([
3
+ "and",
4
+ "the",
5
+ "for",
6
+ "with",
7
+ "from",
8
+ "that",
9
+ "this",
10
+ "into",
11
+ "when",
12
+ "while",
13
+ "using",
14
+ "their",
15
+ "your",
16
+ "each",
17
+ "how",
18
+ "why",
19
+ "what",
20
+ "between",
21
+ "through",
22
+ "about",
23
+ "trong",
24
+ "nhung",
25
+ "cac",
26
+ "cua",
27
+ "cho",
28
+ "voi",
29
+ "duoc",
30
+ "khong",
31
+ "theo",
32
+ "tren",
33
+ "duoi",
34
+ "va",
35
+ "hoac",
36
+ "thi",
37
+ "la",
38
+ "nhu"
39
+ ]);
40
+ function extractTokens(text) {
41
+ const words = text.toLowerCase().replace(/[^a-z0-9à-ỹ\s-]/gi, " ").split(/\s+/).filter((w) => w.length >= 3 && !STOP_WORDS.has(w));
42
+ return [...new Set(words)];
43
+ }
44
+ function extractGradeBand(text) {
45
+ const gbMatch = text.match(/(?:grade\s*band|độ\s*tuổi|lớp)\s*[:=]?\s*(?:lớp\s*)?(\d{1,2})\s*(?:-|đến|to)\s*(?:lớp\s*)?(\d{1,2})/i);
46
+ if (gbMatch && gbMatch[1] && gbMatch[2]) {
47
+ const min = parseInt(gbMatch[1], 10);
48
+ const max = parseInt(gbMatch[2], 10);
49
+ return [Math.min(min, max), Math.max(min, max)];
50
+ }
51
+ return void 0;
52
+ }
53
+ function extractDomain(text) {
54
+ const lower = text.toLowerCase();
55
+ if (lower.includes("computer science") || lower.includes("l\u1EADp tr\xECnh") || lower.includes("algorithm") || lower.includes("software")) return "software";
56
+ if (lower.includes("to\xE1n") || lower.includes("geometry") || lower.includes("algebra") || lower.includes("h\xECnh h\u1ECDc") || lower.includes("mathematics")) return "math";
57
+ if (lower.includes("v\u1EADt l\xFD") || lower.includes("h\xF3a h\u1ECDc") || lower.includes("sinh h\u1ECDc") || lower.includes("physics") || lower.includes("chemistry") || lower.includes("biology") || lower.includes("science")) return "science";
58
+ if (lower.includes("ti\u1EBFng") || lower.includes("ng\u1EEF v\u0103n") || lower.includes("grammar") || lower.includes("language") || lower.includes("writing") || lower.includes("literature")) return "language";
59
+ return void 0;
60
+ }
61
+ function parseSyllabus(rawText) {
62
+ const lines = rawText.split(/\r?\n/);
63
+ let subjectTitle = "";
64
+ let subjectDesc = "";
65
+ const units = [];
66
+ const allTopics = [];
67
+ const globalKeywordsSet = /* @__PURE__ */ new Set();
68
+ let currentUnit = null;
69
+ let currentTopic = null;
70
+ let unitIndex = 0;
71
+ let topicIndex = 0;
72
+ for (let i = 0; i < lines.length; i++) {
73
+ const line = lines[i].trim();
74
+ const lineNum = i + 1;
75
+ if (!line) continue;
76
+ if (line.startsWith("# ") && !subjectTitle) {
77
+ subjectTitle = line.replace(/^#\s+/, "").trim();
78
+ continue;
79
+ }
80
+ if (!currentUnit) {
81
+ if (line.toLowerCase().startsWith("m\xF4n h\u1ECDc:") || line.toLowerCase().startsWith("subject:")) {
82
+ const val = line.split(":")[1]?.trim() || "";
83
+ if (val && !subjectTitle) subjectTitle = val;
84
+ }
85
+ if (line.toLowerCase().startsWith("m\xF4 t\u1EA3:") || line.toLowerCase().startsWith("description:")) {
86
+ subjectDesc = line.split(":")[1]?.trim() || "";
87
+ }
88
+ }
89
+ const isUnitHeading = /^##\s+(?:chương|module|unit|phần|chủ đề)\s*(\d+|[ivx]+)?[:.-]?\s*(.*)/i.test(line) || /^##\s+([^#].*)/.test(line);
90
+ if (isUnitHeading) {
91
+ if (currentTopic) {
92
+ currentTopic.rawLineEnd = lineNum - 1;
93
+ currentTopic = null;
94
+ }
95
+ unitIndex += 1;
96
+ const titleMatch = line.replace(/^##\s+/, "").trim();
97
+ currentUnit = {
98
+ id: `U${String(unitIndex).padStart(2, "0")}`,
99
+ title: titleMatch,
100
+ order: unitIndex,
101
+ topics: []
102
+ };
103
+ units.push(currentUnit);
104
+ continue;
105
+ }
106
+ const isTopicItem = /^(?:-\s*\*\*(?:bài|topic|lesson|chủ đề)\s*(\d+(?:\.\d+)?|\w+)?[:.-]?\s*(.*?)\*\*)/i.exec(line) || /^###\s+(?:bài|topic|lesson)?\s*(\d+(?:\.\d+)?|\w+)?[:.-]?\s*(.*)/i.exec(line) || /^-\s+\*\*(.*?)\*\*/.exec(line) || /^(\d+)\.\s+(?:(?:\*\*)?(?:bài|topic|lesson)?\s*(\d+(?:\.\d+)?|\w+)?[:.-]?\s*(.*?)(?:\*\*)?)$/i.exec(line);
107
+ if (isTopicItem) {
108
+ if (currentTopic) {
109
+ currentTopic.rawLineEnd = lineNum - 1;
110
+ }
111
+ if (!currentUnit) {
112
+ unitIndex += 1;
113
+ currentUnit = {
114
+ id: `U${String(unitIndex).padStart(2, "0")}`,
115
+ title: subjectTitle || "General",
116
+ order: unitIndex,
117
+ topics: []
118
+ };
119
+ units.push(currentUnit);
120
+ }
121
+ topicIndex += 1;
122
+ const rawName = (isTopicItem[3] || isTopicItem[2] || isTopicItem[1] || `Topic ${topicIndex}`).trim();
123
+ currentTopic = {
124
+ id: `T${String(topicIndex).padStart(2, "0")}`,
125
+ title: rawName,
126
+ unitId: currentUnit.id,
127
+ unitTitle: currentUnit.title,
128
+ description: "",
129
+ learningObjectives: [],
130
+ keywords: [],
131
+ rawLineStart: lineNum,
132
+ rawLineEnd: lineNum
133
+ };
134
+ currentUnit.topics.push(currentTopic);
135
+ allTopics.push(currentTopic);
136
+ continue;
137
+ }
138
+ if (currentTopic) {
139
+ currentTopic.rawLineEnd = lineNum;
140
+ const stripped = line.replace(/^[-*•\s]+/, "").trim();
141
+ if (stripped.toLowerCase().startsWith("m\u1EE5c ti\xEAu:") || stripped.toLowerCase().startsWith("objectives:")) {
142
+ const content = stripped.replace(/^(?:mục tiêu|objectives):\s*/i, "").trim();
143
+ if (content) currentTopic.learningObjectives.push(content);
144
+ continue;
145
+ }
146
+ if (stripped.toLowerCase().startsWith("t\u1EEB kh\xF3a:") || stripped.toLowerCase().startsWith("keywords:")) {
147
+ const rawKw = stripped.replace(/^(?:từ khóa|keywords):\s*/i, "").trim();
148
+ const tokens = rawKw.split(/[,;]+/).map((k) => k.trim()).filter(Boolean);
149
+ for (const tok of tokens) {
150
+ currentTopic.keywords.push(tok);
151
+ globalKeywordsSet.add(tok);
152
+ }
153
+ continue;
154
+ }
155
+ if (currentTopic.description) {
156
+ currentTopic.description += " " + stripped;
157
+ } else {
158
+ currentTopic.description = stripped;
159
+ }
160
+ for (const tok of extractTokens(stripped)) {
161
+ if (tok.length >= 4) globalKeywordsSet.add(tok);
162
+ }
163
+ }
164
+ }
165
+ if (currentTopic) {
166
+ currentTopic.rawLineEnd = lines.length;
167
+ }
168
+ if (!subjectTitle && units.length > 0) {
169
+ subjectTitle = units[0]?.title || "Untitled Subject";
170
+ }
171
+ return {
172
+ subject: {
173
+ title: subjectTitle || "Untitled Subject",
174
+ domain: extractDomain(rawText),
175
+ gradeBand: extractGradeBand(rawText),
176
+ description: subjectDesc
177
+ },
178
+ units,
179
+ allTopics,
180
+ extractedKeywords: [...globalKeywordsSet],
181
+ rawText
182
+ };
183
+ }
184
+
185
+ export { parseSyllabus };
186
+ //# sourceMappingURL=chunk-T4Y2DE2W.mjs.map
187
+ //# sourceMappingURL=chunk-T4Y2DE2W.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/parsers/syllabusParser.ts"],"names":[],"mappings":";AAsCA,IAAM,UAAA,uBAAiB,GAAA,CAAI;AAAA,EACzB,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,MAAA;AAAA,EAAQ,MAAA;AAAA,EAAQ,MAAA;AAAA,EAAQ,MAAA;AAAA,EAAQ,MAAA;AAAA,EAAQ,MAAA;AAAA,EAAQ,OAAA;AAAA,EACrE,OAAA;AAAA,EAAS,OAAA;AAAA,EAAS,MAAA;AAAA,EAAQ,MAAA;AAAA,EAAQ,KAAA;AAAA,EAAO,KAAA;AAAA,EA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IAAS,kBAAA;AAAA,EACpC;AAEA,EAAA,OAAO;AAAA,IACL,OAAA,EAAS;AAAA,MACP,OAAO,YAAA,IAAgB,kBAAA;AAAA,MACvB,MAAA,EAAQ,cAAc,OAAO,CAAA;AAAA,MAC7B,SAAA,EAAW,iBAAiB,OAAO,CAAA;AAAA,MACnC,WAAA,EAAa;AAAA,KACf;AAAA,IACA,KAAA;AAAA,IACA,SAAA;AAAA,IACA,iBAAA,EAAmB,CAAC,GAAG,iBAAiB,CAAA;AAAA,IACxC;AAAA,GACF;AACF","file":"chunk-T4Y2DE2W.mjs","sourcesContent":["/**\n * Syllabus Parser — parses structured Markdown, numbered text, or outlines\n * into a structured ParsedSyllabus object with traceable line references.\n */\n\nexport interface SyllabusTopic {\n id: string;\n title: string;\n unitId: string;\n unitTitle: string;\n description: string;\n learningObjectives: string[];\n keywords: string[];\n rawLineStart: number;\n rawLineEnd: number;\n}\n\nexport interface SyllabusUnit {\n id: string;\n title: string;\n order: number;\n topics: SyllabusTopic[];\n}\n\nexport interface ParsedSyllabus {\n subject: {\n title: string;\n domain?: string;\n gradeBand?: [number, number];\n description?: string;\n estimatedHours?: number;\n };\n units: SyllabusUnit[];\n allTopics: SyllabusTopic[];\n extractedKeywords: string[];\n rawText: string;\n}\n\nconst STOP_WORDS = new Set([\n 'and', 'the', 'for', 'with', 'from', 'that', 'this', 'into', 'when', 'while',\n 'using', 'their', 'your', 'each', 'how', 'why', 'what', 'between', 'through',\n 'about', 'trong', 'nhung', 'cac', 'cua', 'cho', 'voi', 'duoc', 'khong', 'theo',\n 'tren', 'duoi', 'va', 'hoac', 'thi', 'la', 'nhu',\n]);\n\n/**\n * Heuristically extracts meaningful terminology keywords from text tokens.\n */\nfunction extractTokens(text: string): string[] {\n const words = text\n .toLowerCase()\n .replace(/[^a-z0-9à-ỹ\\s-]/gi, ' ')\n .split(/\\s+/)\n .filter((w) => w.length >= 3 && !STOP_WORDS.has(w));\n return [...new Set(words)];\n}\n\n/**\n * Detect grade band from raw text patterns like \"Lớp 7 - Lớp 9\", \"Grade Band: 15-18\", \"12 - 15 tuổi\".\n */\nfunction extractGradeBand(text: string): [number, number] | undefined {\n const gbMatch = text.match(/(?:grade\\s*band|độ\\s*tuổi|lớp)\\s*[:=]?\\s*(?:lớp\\s*)?(\\d{1,2})\\s*(?:-|đến|to)\\s*(?:lớp\\s*)?(\\d{1,2})/i);\n if (gbMatch && gbMatch[1] && gbMatch[2]) {\n const min = parseInt(gbMatch[1], 10);\n const max = parseInt(gbMatch[2], 10);\n return [Math.min(min, max), Math.max(min, max)];\n }\n return undefined;\n}\n\n/**\n * Detect domain from text keywords.\n */\nfunction extractDomain(text: string): string | undefined {\n const lower = text.toLowerCase();\n if (lower.includes('computer science') || lower.includes('lập trình') || lower.includes('algorithm') || lower.includes('software')) return 'software';\n if (lower.includes('toán') || lower.includes('geometry') || lower.includes('algebra') || lower.includes('hình học') || lower.includes('mathematics')) return 'math';\n if (lower.includes('vật lý') || lower.includes('hóa học') || lower.includes('sinh học') || lower.includes('physics') || lower.includes('chemistry') || lower.includes('biology') || lower.includes('science')) return 'science';\n if (lower.includes('tiếng') || lower.includes('ngữ văn') || lower.includes('grammar') || lower.includes('language') || lower.includes('writing') || lower.includes('literature')) return 'language';\n return undefined;\n}\n\n/**\n * Main syllabus parser function.\n */\nexport function parseSyllabus(rawText: string): ParsedSyllabus {\n const lines = rawText.split(/\\r?\\n/);\n let subjectTitle = '';\n let subjectDesc = '';\n\n const units: SyllabusUnit[] = [];\n const allTopics: SyllabusTopic[] = [];\n const globalKeywordsSet = new Set<string>();\n\n let currentUnit: SyllabusUnit | null = null;\n let currentTopic: SyllabusTopic | null = null;\n let unitIndex = 0;\n let topicIndex = 0;\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i]!.trim();\n const lineNum = i + 1;\n if (!line) continue;\n\n // 1. Level 1 Heading: Subject Title\n if (line.startsWith('# ') && !subjectTitle) {\n subjectTitle = line.replace(/^#\\s+/, '').trim();\n continue;\n }\n\n // 2. Metadata lines at root\n if (!currentUnit) {\n if (line.toLowerCase().startsWith('môn học:') || line.toLowerCase().startsWith('subject:')) {\n const val = line.split(':')[1]?.trim() || '';\n if (val && !subjectTitle) subjectTitle = val;\n }\n if (line.toLowerCase().startsWith('mô tả:') || line.toLowerCase().startsWith('description:')) {\n subjectDesc = line.split(':')[1]?.trim() || '';\n }\n }\n\n // 3. Level 2 Heading: Unit / Chapter / Module\n const isUnitHeading = /^##\\s+(?:chương|module|unit|phần|chủ đề)\\s*(\\d+|[ivx]+)?[:.-]?\\s*(.*)/i.test(line)\n || /^##\\s+([^#].*)/.test(line);\n\n if (isUnitHeading) {\n if (currentTopic) {\n currentTopic.rawLineEnd = lineNum - 1;\n currentTopic = null;\n }\n unitIndex += 1;\n const titleMatch = line.replace(/^##\\s+/, '').trim();\n currentUnit = {\n id: `U${String(unitIndex).padStart(2, '0')}`,\n title: titleMatch,\n order: unitIndex,\n topics: [],\n };\n units.push(currentUnit);\n continue;\n }\n\n // 4. Topic heading inside Unit: \"- **Bài X: ...**\", \"### Topic ...\", \"1. Bài ...\", or \"- **...**\"\n const isTopicItem = /^(?:-\\s*\\*\\*(?:bài|topic|lesson|chủ đề)\\s*(\\d+(?:\\.\\d+)?|\\w+)?[:.-]?\\s*(.*?)\\*\\*)/i.exec(line)\n || /^###\\s+(?:bài|topic|lesson)?\\s*(\\d+(?:\\.\\d+)?|\\w+)?[:.-]?\\s*(.*)/i.exec(line)\n || /^-\\s+\\*\\*(.*?)\\*\\*/.exec(line)\n || /^(\\d+)\\.\\s+(?:(?:\\*\\*)?(?:bài|topic|lesson)?\\s*(\\d+(?:\\.\\d+)?|\\w+)?[:.-]?\\s*(.*?)(?:\\*\\*)?)$/i.exec(line);\n\n if (isTopicItem) {\n if (currentTopic) {\n currentTopic.rawLineEnd = lineNum - 1;\n }\n if (!currentUnit) {\n unitIndex += 1;\n currentUnit = {\n id: `U${String(unitIndex).padStart(2, '0')}`,\n title: subjectTitle || 'General',\n order: unitIndex,\n topics: [],\n };\n units.push(currentUnit);\n }\n topicIndex += 1;\n const rawName = (isTopicItem[3] || isTopicItem[2] || isTopicItem[1] || `Topic ${topicIndex}`).trim();\n currentTopic = {\n id: `T${String(topicIndex).padStart(2, '0')}`,\n title: rawName,\n unitId: currentUnit.id,\n unitTitle: currentUnit.title,\n description: '',\n learningObjectives: [],\n keywords: [],\n rawLineStart: lineNum,\n rawLineEnd: lineNum,\n };\n currentUnit.topics.push(currentTopic);\n allTopics.push(currentTopic);\n continue;\n }\n\n // 5. Content lines inside Topic\n if (currentTopic) {\n currentTopic.rawLineEnd = lineNum;\n const stripped = line.replace(/^[-*•\\s]+/, '').trim();\n\n // Objectives line\n if (stripped.toLowerCase().startsWith('mục tiêu:') || stripped.toLowerCase().startsWith('objectives:')) {\n const content = stripped.replace(/^(?:mục tiêu|objectives):\\s*/i, '').trim();\n if (content) currentTopic.learningObjectives.push(content);\n continue;\n }\n\n // Keywords line\n if (stripped.toLowerCase().startsWith('từ khóa:') || stripped.toLowerCase().startsWith('keywords:')) {\n const rawKw = stripped.replace(/^(?:từ khóa|keywords):\\s*/i, '').trim();\n const tokens = rawKw.split(/[,;]+/).map((k) => k.trim()).filter(Boolean);\n for (const tok of tokens) {\n currentTopic.keywords.push(tok);\n globalKeywordsSet.add(tok);\n }\n continue;\n }\n\n // General description line\n if (currentTopic.description) {\n currentTopic.description += ' ' + stripped;\n } else {\n currentTopic.description = stripped;\n }\n\n // Harvest tokens\n for (const tok of extractTokens(stripped)) {\n if (tok.length >= 4) globalKeywordsSet.add(tok);\n }\n }\n }\n\n // Close last topic if open\n if (currentTopic) {\n currentTopic.rawLineEnd = lines.length;\n }\n\n // Fallback subject title\n if (!subjectTitle && units.length > 0) {\n subjectTitle = units[0]?.title || 'Untitled Subject';\n }\n\n return {\n subject: {\n title: subjectTitle || 'Untitled Subject',\n domain: extractDomain(rawText),\n gradeBand: extractGradeBand(rawText),\n description: subjectDesc,\n },\n units,\n allTopics,\n extractedKeywords: [...globalKeywordsSet],\n rawText,\n };\n}\n"]}
@@ -372,6 +372,51 @@ var ThreeDesignTechStackExtensionSchema = z.object({
372
372
  canvas_size: z.string().optional(),
373
373
  export_formats: z.array(z.string()).optional().default([]).describe("STL, OBJ, STEP")
374
374
  });
375
+ var MathTheoremSchema = z.object({
376
+ name: z.string(),
377
+ statement: z.string(),
378
+ proof_outline: z.string().optional(),
379
+ converse_statement: z.string().optional()
380
+ });
381
+ var MathConceptExtensionSchema = z.object({
382
+ formulas: z.array(z.string()).optional().default([]).describe("Mathematical formulas, e.g. a^2 + b^2 = c^2"),
383
+ theorems: z.array(MathTheoremSchema).optional().default([]),
384
+ constructions: z.array(z.string()).optional().default([]).describe("Compass and ruler constructions, auxiliary lines"),
385
+ visual_aids: z.array(z.string()).optional().default([]).describe("Geometric figures, function graphs"),
386
+ common_mistakes: z.array(z.string()).optional().default([]).describe("False intuitions or algebraic traps")
387
+ });
388
+ var ExperimentProcedureSchema = z.object({
389
+ name: z.string(),
390
+ apparatus: z.array(z.string()).optional().default([]),
391
+ steps: z.array(z.string()).optional().default([]),
392
+ safety_warnings: z.array(z.string()).optional().default([]),
393
+ expected_observation: z.string().optional()
394
+ });
395
+ var ScienceConceptExtensionSchema = z.object({
396
+ experiments: z.array(ExperimentProcedureSchema).optional().default([]),
397
+ instruments: z.array(z.string()).optional().default([]).describe("Lab equipment: microscope, beaker, sensor"),
398
+ variables: z.object({
399
+ independent: z.string().optional(),
400
+ dependent: z.string().optional(),
401
+ controlled: z.array(z.string()).optional().default([])
402
+ }).optional(),
403
+ hypotheses: z.array(z.string()).optional().default([]),
404
+ laws_and_theories: z.array(z.string()).optional().default([])
405
+ });
406
+ var GrammarRuleSchema = z.object({
407
+ rule_name: z.string(),
408
+ pattern: z.string(),
409
+ example_correct: z.string(),
410
+ example_incorrect: z.string().optional(),
411
+ exceptions: z.array(z.string()).optional().default([])
412
+ });
413
+ var LanguageConceptExtensionSchema = z.object({
414
+ reading_genres: z.array(z.string()).optional().default([]).describe("argumentative, narrative, expository"),
415
+ grammar_rules: z.array(GrammarRuleSchema).optional().default([]),
416
+ writing_tasks: z.array(z.string()).optional().default([]),
417
+ lexicon_keywords: z.array(z.string()).optional().default([]),
418
+ rhetorical_devices: z.array(z.string()).optional().default([])
419
+ });
375
420
  var ProjectConceptLinkSchema = z.object({
376
421
  feature_id: z.string().describe("Feature ID from project_graph"),
377
422
  concept_id: z.string().describe("Concept ID from knowledge_graph"),
@@ -511,6 +556,6 @@ var DomainProfileSchema = z.object({
511
556
  syllabusText: z.string().optional().default("")
512
557
  });
513
558
 
514
- export { ArchEdgeSchema, ArchNodeSchema, ArchitectureDetailSchema, CapabilitySchema, ConceptCategorySchema, ConceptIntroductionSchema, ConceptSchema, DataIntegrationSchema, DecompositionSchema, DetectionConfidenceSchema, DevelopmentPhaseSchema, DevelopmentStageSchema, DomainCategorySchema, DomainProfileSchema, ExperienceComponentSchema, ExperienceSchema, FeatureSchema, GraphTypeSchema, HardwareFeatureExtensionSchema, HardwareStepSchema, HardwareTaskExtensionSchema, HardwareTechStackExtensionSchema, HybridGraphSchema, ImplementationSchema, InputTypeSchema, JourneySchema, JourneyStepSchema, KnowledgeGraphSchema, LearningModeSchema, LearningPathStepSchema, MilestoneDecompositionSchema, MissingGapSchema, NavigationSchema, ProblemTypeSchema, ProductGoalSchema, ProductSchema, ProductUserSchema, ProjectConceptLinkSchema, ProjectGraphSchema, ProjectInfoSchema, RequirementSchema, ScreenSchema, ShapeSchema, StepEffortSchema, StepOutcomeSchema, StepSchema, SubjectInfoSchema, TaskEffortSchema, TaskOutcomeSchema, TaskSchema, TechDebtSchema, TechStackSchema, ThreeDesignFeatureExtensionSchema, ThreeDesignTaskExtensionSchema, ThreeDesignTechStackExtensionSchema, UiStateSchema, WiringSchema };
515
- //# sourceMappingURL=chunk-PM42MMDJ.mjs.map
516
- //# sourceMappingURL=chunk-PM42MMDJ.mjs.map
559
+ export { ArchEdgeSchema, ArchNodeSchema, ArchitectureDetailSchema, CapabilitySchema, ConceptCategorySchema, ConceptIntroductionSchema, ConceptSchema, DataIntegrationSchema, DecompositionSchema, DetectionConfidenceSchema, DevelopmentPhaseSchema, DevelopmentStageSchema, DomainCategorySchema, DomainProfileSchema, ExperienceComponentSchema, ExperienceSchema, ExperimentProcedureSchema, FeatureSchema, GrammarRuleSchema, GraphTypeSchema, HardwareFeatureExtensionSchema, HardwareStepSchema, HardwareTaskExtensionSchema, HardwareTechStackExtensionSchema, HybridGraphSchema, ImplementationSchema, InputTypeSchema, JourneySchema, JourneyStepSchema, KnowledgeGraphSchema, LanguageConceptExtensionSchema, LearningModeSchema, LearningPathStepSchema, MathConceptExtensionSchema, MathTheoremSchema, MilestoneDecompositionSchema, MissingGapSchema, NavigationSchema, ProblemTypeSchema, ProductGoalSchema, ProductSchema, ProductUserSchema, ProjectConceptLinkSchema, ProjectGraphSchema, ProjectInfoSchema, RequirementSchema, ScienceConceptExtensionSchema, ScreenSchema, ShapeSchema, StepEffortSchema, StepOutcomeSchema, StepSchema, SubjectInfoSchema, TaskEffortSchema, TaskOutcomeSchema, TaskSchema, TechDebtSchema, TechStackSchema, ThreeDesignFeatureExtensionSchema, ThreeDesignTaskExtensionSchema, ThreeDesignTechStackExtensionSchema, UiStateSchema, WiringSchema };
560
+ //# sourceMappingURL=chunk-WHBAGJWN.mjs.map
561
+ //# sourceMappingURL=chunk-WHBAGJWN.mjs.map