@thanh01.pmt/curriculum-kit 1.3.0 → 1.4.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.
package/dist/index.d.cts CHANGED
@@ -166,12 +166,27 @@ interface ProduceLessonOptions {
166
166
  approvedArtifacts?: string[];
167
167
  onProgress?: (agent: string, message: string, meta?: any) => void;
168
168
  }
169
+ interface ContextInjectionMeta {
170
+ /** Which canonical source the excerpt came from (e.g. 'KNOWLEDGE_EXPOSITION', 'LESSON'). */
171
+ source: string;
172
+ /** True when the builder excerpt passed verify (priority resolution + sufficiency). */
173
+ verified: boolean;
174
+ /** True when canonical section resolution contributed to the excerpt. */
175
+ sectionAware: boolean;
176
+ /** Structured reasons when verified === false (empty otherwise). */
177
+ issues: string[];
178
+ }
169
179
  interface ProduceLessonResult {
170
180
  lessonId: string;
171
181
  pedagogy: PedagogicalModel;
172
182
  producedArtifacts: string[];
173
183
  pausedForReview: boolean;
174
184
  gateStatus?: string;
185
+ /** P43 Cụm 5: observability for context injection — surfaced by every path
186
+ * (queue, standalone, batch) so callers can record telemetry / execution
187
+ * history without re-parsing. */
188
+ contextInjection?: ContextInjectionMeta;
189
+ promptChars?: number;
175
190
  }
176
191
  /**
177
192
  * Detects pedagogical model from SOT (Framework, Style Guide, or Brief)
@@ -587,6 +602,7 @@ declare function ensureExpositionForLesson(storage: ICurriculumStorage, projectI
587
602
  relPath: string;
588
603
  context: string;
589
604
  reused: boolean;
605
+ rawContent?: string;
590
606
  } | null>;
591
607
 
592
608
  /**
@@ -649,6 +665,12 @@ interface ExcerptOptions {
649
665
  sectionLanguageContract?: Record<string, Record<string, string>> | string;
650
666
  /** File name or artifact type hint (e.g. 'LESSON', 'KNOWLEDGE_EXPOSITION'). */
651
667
  artifactType?: string;
668
+ /**
669
+ * Source file name (e.g. `LESSON_U03_M01_L06.md`) — artifact type derived
670
+ * from it when `artifactType` is not given. Matches the web app's builder
671
+ * option so both call-sites share one contract.
672
+ */
673
+ fileName?: string;
652
674
  /** Min chars below which the excerpt is flagged as insufficient (default 400). */
653
675
  minContentChars?: number;
654
676
  }
@@ -1047,4 +1069,4 @@ declare function getSlideLayoutPresetById(id: string): SlideLayoutPreset | undef
1047
1069
  */
1048
1070
  declare function getSlideLayoutPresetsByCategory(category: SlideLayoutCategory): SlideLayoutPreset[];
1049
1071
 
1050
- export { ACT_TEMPLATE, AIProviderName, ARTIFACT_DEPENDENCY_ROUTING, ARTIFACT_EXECUTION_ORDER, type AcademicAuditFinding, AcademicAuditor, type AcademicDimension, ActivityLab, type ArtifactDependencyRule, type ArtifactProductionSpec, type AuditBundleInput, BELL_RINGER_TEMPLATE, BLOOM_ACTION_VERBS, BOM_TEMPLATE, BloomTaxonomyEvaluator, type BuildContextOptions, CHOICE_BOARD_TEMPLATE, CODE_LAB_TEMPLATE, CURRICULUM_SLASH_COMMANDS, CodeHardwareFeasibilityEvaluator, CodeLab, type ComprehensiveAcademicReport, ConstructiveAlignmentEvaluator, type ContextSourceKey, CrossArtifactDriftEvaluator, CurriculumError, type CurriculumErrorCode, type CurriculumErrorDetail, CurriculumPlan, DEFAULT_KX_PRIORITIES, DEFAULT_LESSON_PRIORITIES, DEFAULT_STREAM_IDLE_MS, DEFAULT_STREAM_TOTAL_MS, DependencyEdge, type DependencyValidationResult, DeterministicPipelineRunner, DeterministicStructuralLinter, DiagnosticQuiz, DiagnosticQuizInput, type DimensionScore, EXIT_TICKET_TEMPLATE, EXPOSITION_REL, EXT_TEMPLATE, type ExcerptOptions, type ExcerptResult, type ExecuteCommandResult, ExpositionApprovalError, type ExpositionLlmFn, type ExpositionResult, type ExpositionStorage, type ExtractedStreamChunk, type FindingSeverity, FiveEInstructionalEvaluator, type FrameworkLintFinding, type FrameworkLintReport, FrameworkPack, GLOSSARY_TEMPLATE, GRAPHIC_ORGANIZER_TEMPLATE, type GenerateExpositionOptions, HANDOUT_TEMPLATE, ICurriculumStorage, LAYER_TOTAL_BUDGET_MS, LESSON_PLAN_TEMPLATE, type LayerChunkCallback, type LayerPrefillOptions, type LayerPrefillResult, type LayoutBoxConfig, LessonPlan, MisconceptionEvaluator, ModelResolutionOptions, PROJECT_INSTRUCTION_TEMPLATE, type PackingSpec, type PedagogicalModel, type PipelineExecutionProgress, PlanConstraints, type PlanOptions, type PlanResult, type PlannerLlmFn, PlanningGraph, PlanningNode, type PreliminaryResearchResult, type ProduceLessonOptions, type ProduceLessonResult, type ProjectBriefingData, type ProjectClarification, type ProjectCreationPayload, type ProjectIntentAnalysisResult, ProjectStatusReport, type ProjectionMeta, QUIZ_TEMPLATE, QualityAuditReport, REVIEW_GAME_TEMPLATE, RUBRIC_TEMPLATE, ResolvedGateSettings, SCIENCE_LAB_TEMPLATE, SELF_LAB_TEMPLATE, SLIDE_LAYOUT_PRESETS, SLIDE_TEMPLATE, STATION_ROTATION_TEMPLATE, type SlashCommandDefinition, SlideDeck, type SlideLayoutCategory, type SlideLayoutData, type SlideLayoutPreset, SmartResumeContext, type StreamAbortHandle, type StreamBudget, type StreamChunkExtractor, TASK_CARDS_TEMPLATE, TEACHER_GUIDE_TEMPLATE, TIERED_PRACTICE_TEMPLATE, TranslationPolicy, type TranslationTarget, type TranslationTrigger, type ValidationOptions, WORKSHEET_TEMPLATE, analyzeProjectCreationIntent, assertAcyclic, auditQualityReport, buildCurriculumContext, buildCurriculumPlan, buildExpositionContext, buildExpositionExcerpt, buildHeadingDirective, buildLanguageDirective, buildLessonExcerpt, buildSectionAwareExcerpt, buildSessionSliceContext, closeTruncatedJson, computePackingSpec, conductPreliminaryResearch, createAiInferenceError, createContextMissingError, createStreamAbortSignal, createStreamChunkExtractor, detectProjectPedagogy, ensureExpositionForLesson, ensureKnowledgeExposition, executeCurriculumCommand, expositionCacheKey, extractScopeSequenceRows, extractSectionHeadingsFromSLC, extractSessionSlice, extractStreamChunk, generatePhase1SotArtifacts, generatePhase2SotArtifacts, getLessonMetadata, getProjectArtifactScope, getProjectStatusReport, getSlideLayoutPresetById, getSlideLayoutPresetsByCategory, getSmartResumeContext, glossaryTermsForSession, ingestProjectGraphIntoProject, initializeProjectInStorage, isExpositionFresh, isTranslationDue, lintCurriculumFramework, loadCurriculumTemplate, loadSotTemplate, normalizePlanningGraph, normalizeSlcContract, parseRoadmapJsonToProjectPayload, produceBatchLessons, produceSingleLesson, renderFrameworkFromPlan, resolveStreamBudget, resolveTargetLanguageCode, resolveTranslationTargets, safeParseJson, slugifyProjectName, streamLLMWithFallback, streamLayerPrefillWithFallback, stripLlmJsonWrappers, targetLanguageDisplayName, topoSort, validateArtifactDependencies };
1072
+ export { ACT_TEMPLATE, AIProviderName, ARTIFACT_DEPENDENCY_ROUTING, ARTIFACT_EXECUTION_ORDER, type AcademicAuditFinding, AcademicAuditor, type AcademicDimension, ActivityLab, type ArtifactDependencyRule, type ArtifactProductionSpec, type AuditBundleInput, BELL_RINGER_TEMPLATE, BLOOM_ACTION_VERBS, BOM_TEMPLATE, BloomTaxonomyEvaluator, type BuildContextOptions, CHOICE_BOARD_TEMPLATE, CODE_LAB_TEMPLATE, CURRICULUM_SLASH_COMMANDS, CodeHardwareFeasibilityEvaluator, CodeLab, type ComprehensiveAcademicReport, ConstructiveAlignmentEvaluator, type ContextInjectionMeta, type ContextSourceKey, CrossArtifactDriftEvaluator, CurriculumError, type CurriculumErrorCode, type CurriculumErrorDetail, CurriculumPlan, DEFAULT_KX_PRIORITIES, DEFAULT_LESSON_PRIORITIES, DEFAULT_STREAM_IDLE_MS, DEFAULT_STREAM_TOTAL_MS, DependencyEdge, type DependencyValidationResult, DeterministicPipelineRunner, DeterministicStructuralLinter, DiagnosticQuiz, DiagnosticQuizInput, type DimensionScore, EXIT_TICKET_TEMPLATE, EXPOSITION_REL, EXT_TEMPLATE, type ExcerptOptions, type ExcerptResult, type ExecuteCommandResult, ExpositionApprovalError, type ExpositionLlmFn, type ExpositionResult, type ExpositionStorage, type ExtractedStreamChunk, type FindingSeverity, FiveEInstructionalEvaluator, type FrameworkLintFinding, type FrameworkLintReport, FrameworkPack, GLOSSARY_TEMPLATE, GRAPHIC_ORGANIZER_TEMPLATE, type GenerateExpositionOptions, HANDOUT_TEMPLATE, ICurriculumStorage, LAYER_TOTAL_BUDGET_MS, LESSON_PLAN_TEMPLATE, type LayerChunkCallback, type LayerPrefillOptions, type LayerPrefillResult, type LayoutBoxConfig, LessonPlan, MisconceptionEvaluator, ModelResolutionOptions, PROJECT_INSTRUCTION_TEMPLATE, type PackingSpec, type PedagogicalModel, type PipelineExecutionProgress, PlanConstraints, type PlanOptions, type PlanResult, type PlannerLlmFn, PlanningGraph, PlanningNode, type PreliminaryResearchResult, type ProduceLessonOptions, type ProduceLessonResult, type ProjectBriefingData, type ProjectClarification, type ProjectCreationPayload, type ProjectIntentAnalysisResult, ProjectStatusReport, type ProjectionMeta, QUIZ_TEMPLATE, QualityAuditReport, REVIEW_GAME_TEMPLATE, RUBRIC_TEMPLATE, ResolvedGateSettings, SCIENCE_LAB_TEMPLATE, SELF_LAB_TEMPLATE, SLIDE_LAYOUT_PRESETS, SLIDE_TEMPLATE, STATION_ROTATION_TEMPLATE, type SlashCommandDefinition, SlideDeck, type SlideLayoutCategory, type SlideLayoutData, type SlideLayoutPreset, SmartResumeContext, type StreamAbortHandle, type StreamBudget, type StreamChunkExtractor, TASK_CARDS_TEMPLATE, TEACHER_GUIDE_TEMPLATE, TIERED_PRACTICE_TEMPLATE, TranslationPolicy, type TranslationTarget, type TranslationTrigger, type ValidationOptions, WORKSHEET_TEMPLATE, analyzeProjectCreationIntent, assertAcyclic, auditQualityReport, buildCurriculumContext, buildCurriculumPlan, buildExpositionContext, buildExpositionExcerpt, buildHeadingDirective, buildLanguageDirective, buildLessonExcerpt, buildSectionAwareExcerpt, buildSessionSliceContext, closeTruncatedJson, computePackingSpec, conductPreliminaryResearch, createAiInferenceError, createContextMissingError, createStreamAbortSignal, createStreamChunkExtractor, detectProjectPedagogy, ensureExpositionForLesson, ensureKnowledgeExposition, executeCurriculumCommand, expositionCacheKey, extractScopeSequenceRows, extractSectionHeadingsFromSLC, extractSessionSlice, extractStreamChunk, generatePhase1SotArtifacts, generatePhase2SotArtifacts, getLessonMetadata, getProjectArtifactScope, getProjectStatusReport, getSlideLayoutPresetById, getSlideLayoutPresetsByCategory, getSmartResumeContext, glossaryTermsForSession, ingestProjectGraphIntoProject, initializeProjectInStorage, isExpositionFresh, isTranslationDue, lintCurriculumFramework, loadCurriculumTemplate, loadSotTemplate, normalizePlanningGraph, normalizeSlcContract, parseRoadmapJsonToProjectPayload, produceBatchLessons, produceSingleLesson, renderFrameworkFromPlan, resolveStreamBudget, resolveTargetLanguageCode, resolveTranslationTargets, safeParseJson, slugifyProjectName, streamLLMWithFallback, streamLayerPrefillWithFallback, stripLlmJsonWrappers, targetLanguageDisplayName, topoSort, validateArtifactDependencies };
package/dist/index.d.ts CHANGED
@@ -166,12 +166,27 @@ interface ProduceLessonOptions {
166
166
  approvedArtifacts?: string[];
167
167
  onProgress?: (agent: string, message: string, meta?: any) => void;
168
168
  }
169
+ interface ContextInjectionMeta {
170
+ /** Which canonical source the excerpt came from (e.g. 'KNOWLEDGE_EXPOSITION', 'LESSON'). */
171
+ source: string;
172
+ /** True when the builder excerpt passed verify (priority resolution + sufficiency). */
173
+ verified: boolean;
174
+ /** True when canonical section resolution contributed to the excerpt. */
175
+ sectionAware: boolean;
176
+ /** Structured reasons when verified === false (empty otherwise). */
177
+ issues: string[];
178
+ }
169
179
  interface ProduceLessonResult {
170
180
  lessonId: string;
171
181
  pedagogy: PedagogicalModel;
172
182
  producedArtifacts: string[];
173
183
  pausedForReview: boolean;
174
184
  gateStatus?: string;
185
+ /** P43 Cụm 5: observability for context injection — surfaced by every path
186
+ * (queue, standalone, batch) so callers can record telemetry / execution
187
+ * history without re-parsing. */
188
+ contextInjection?: ContextInjectionMeta;
189
+ promptChars?: number;
175
190
  }
176
191
  /**
177
192
  * Detects pedagogical model from SOT (Framework, Style Guide, or Brief)
@@ -587,6 +602,7 @@ declare function ensureExpositionForLesson(storage: ICurriculumStorage, projectI
587
602
  relPath: string;
588
603
  context: string;
589
604
  reused: boolean;
605
+ rawContent?: string;
590
606
  } | null>;
591
607
 
592
608
  /**
@@ -649,6 +665,12 @@ interface ExcerptOptions {
649
665
  sectionLanguageContract?: Record<string, Record<string, string>> | string;
650
666
  /** File name or artifact type hint (e.g. 'LESSON', 'KNOWLEDGE_EXPOSITION'). */
651
667
  artifactType?: string;
668
+ /**
669
+ * Source file name (e.g. `LESSON_U03_M01_L06.md`) — artifact type derived
670
+ * from it when `artifactType` is not given. Matches the web app's builder
671
+ * option so both call-sites share one contract.
672
+ */
673
+ fileName?: string;
652
674
  /** Min chars below which the excerpt is flagged as insufficient (default 400). */
653
675
  minContentChars?: number;
654
676
  }
@@ -1047,4 +1069,4 @@ declare function getSlideLayoutPresetById(id: string): SlideLayoutPreset | undef
1047
1069
  */
1048
1070
  declare function getSlideLayoutPresetsByCategory(category: SlideLayoutCategory): SlideLayoutPreset[];
1049
1071
 
1050
- export { ACT_TEMPLATE, AIProviderName, ARTIFACT_DEPENDENCY_ROUTING, ARTIFACT_EXECUTION_ORDER, type AcademicAuditFinding, AcademicAuditor, type AcademicDimension, ActivityLab, type ArtifactDependencyRule, type ArtifactProductionSpec, type AuditBundleInput, BELL_RINGER_TEMPLATE, BLOOM_ACTION_VERBS, BOM_TEMPLATE, BloomTaxonomyEvaluator, type BuildContextOptions, CHOICE_BOARD_TEMPLATE, CODE_LAB_TEMPLATE, CURRICULUM_SLASH_COMMANDS, CodeHardwareFeasibilityEvaluator, CodeLab, type ComprehensiveAcademicReport, ConstructiveAlignmentEvaluator, type ContextSourceKey, CrossArtifactDriftEvaluator, CurriculumError, type CurriculumErrorCode, type CurriculumErrorDetail, CurriculumPlan, DEFAULT_KX_PRIORITIES, DEFAULT_LESSON_PRIORITIES, DEFAULT_STREAM_IDLE_MS, DEFAULT_STREAM_TOTAL_MS, DependencyEdge, type DependencyValidationResult, DeterministicPipelineRunner, DeterministicStructuralLinter, DiagnosticQuiz, DiagnosticQuizInput, type DimensionScore, EXIT_TICKET_TEMPLATE, EXPOSITION_REL, EXT_TEMPLATE, type ExcerptOptions, type ExcerptResult, type ExecuteCommandResult, ExpositionApprovalError, type ExpositionLlmFn, type ExpositionResult, type ExpositionStorage, type ExtractedStreamChunk, type FindingSeverity, FiveEInstructionalEvaluator, type FrameworkLintFinding, type FrameworkLintReport, FrameworkPack, GLOSSARY_TEMPLATE, GRAPHIC_ORGANIZER_TEMPLATE, type GenerateExpositionOptions, HANDOUT_TEMPLATE, ICurriculumStorage, LAYER_TOTAL_BUDGET_MS, LESSON_PLAN_TEMPLATE, type LayerChunkCallback, type LayerPrefillOptions, type LayerPrefillResult, type LayoutBoxConfig, LessonPlan, MisconceptionEvaluator, ModelResolutionOptions, PROJECT_INSTRUCTION_TEMPLATE, type PackingSpec, type PedagogicalModel, type PipelineExecutionProgress, PlanConstraints, type PlanOptions, type PlanResult, type PlannerLlmFn, PlanningGraph, PlanningNode, type PreliminaryResearchResult, type ProduceLessonOptions, type ProduceLessonResult, type ProjectBriefingData, type ProjectClarification, type ProjectCreationPayload, type ProjectIntentAnalysisResult, ProjectStatusReport, type ProjectionMeta, QUIZ_TEMPLATE, QualityAuditReport, REVIEW_GAME_TEMPLATE, RUBRIC_TEMPLATE, ResolvedGateSettings, SCIENCE_LAB_TEMPLATE, SELF_LAB_TEMPLATE, SLIDE_LAYOUT_PRESETS, SLIDE_TEMPLATE, STATION_ROTATION_TEMPLATE, type SlashCommandDefinition, SlideDeck, type SlideLayoutCategory, type SlideLayoutData, type SlideLayoutPreset, SmartResumeContext, type StreamAbortHandle, type StreamBudget, type StreamChunkExtractor, TASK_CARDS_TEMPLATE, TEACHER_GUIDE_TEMPLATE, TIERED_PRACTICE_TEMPLATE, TranslationPolicy, type TranslationTarget, type TranslationTrigger, type ValidationOptions, WORKSHEET_TEMPLATE, analyzeProjectCreationIntent, assertAcyclic, auditQualityReport, buildCurriculumContext, buildCurriculumPlan, buildExpositionContext, buildExpositionExcerpt, buildHeadingDirective, buildLanguageDirective, buildLessonExcerpt, buildSectionAwareExcerpt, buildSessionSliceContext, closeTruncatedJson, computePackingSpec, conductPreliminaryResearch, createAiInferenceError, createContextMissingError, createStreamAbortSignal, createStreamChunkExtractor, detectProjectPedagogy, ensureExpositionForLesson, ensureKnowledgeExposition, executeCurriculumCommand, expositionCacheKey, extractScopeSequenceRows, extractSectionHeadingsFromSLC, extractSessionSlice, extractStreamChunk, generatePhase1SotArtifacts, generatePhase2SotArtifacts, getLessonMetadata, getProjectArtifactScope, getProjectStatusReport, getSlideLayoutPresetById, getSlideLayoutPresetsByCategory, getSmartResumeContext, glossaryTermsForSession, ingestProjectGraphIntoProject, initializeProjectInStorage, isExpositionFresh, isTranslationDue, lintCurriculumFramework, loadCurriculumTemplate, loadSotTemplate, normalizePlanningGraph, normalizeSlcContract, parseRoadmapJsonToProjectPayload, produceBatchLessons, produceSingleLesson, renderFrameworkFromPlan, resolveStreamBudget, resolveTargetLanguageCode, resolveTranslationTargets, safeParseJson, slugifyProjectName, streamLLMWithFallback, streamLayerPrefillWithFallback, stripLlmJsonWrappers, targetLanguageDisplayName, topoSort, validateArtifactDependencies };
1072
+ export { ACT_TEMPLATE, AIProviderName, ARTIFACT_DEPENDENCY_ROUTING, ARTIFACT_EXECUTION_ORDER, type AcademicAuditFinding, AcademicAuditor, type AcademicDimension, ActivityLab, type ArtifactDependencyRule, type ArtifactProductionSpec, type AuditBundleInput, BELL_RINGER_TEMPLATE, BLOOM_ACTION_VERBS, BOM_TEMPLATE, BloomTaxonomyEvaluator, type BuildContextOptions, CHOICE_BOARD_TEMPLATE, CODE_LAB_TEMPLATE, CURRICULUM_SLASH_COMMANDS, CodeHardwareFeasibilityEvaluator, CodeLab, type ComprehensiveAcademicReport, ConstructiveAlignmentEvaluator, type ContextInjectionMeta, type ContextSourceKey, CrossArtifactDriftEvaluator, CurriculumError, type CurriculumErrorCode, type CurriculumErrorDetail, CurriculumPlan, DEFAULT_KX_PRIORITIES, DEFAULT_LESSON_PRIORITIES, DEFAULT_STREAM_IDLE_MS, DEFAULT_STREAM_TOTAL_MS, DependencyEdge, type DependencyValidationResult, DeterministicPipelineRunner, DeterministicStructuralLinter, DiagnosticQuiz, DiagnosticQuizInput, type DimensionScore, EXIT_TICKET_TEMPLATE, EXPOSITION_REL, EXT_TEMPLATE, type ExcerptOptions, type ExcerptResult, type ExecuteCommandResult, ExpositionApprovalError, type ExpositionLlmFn, type ExpositionResult, type ExpositionStorage, type ExtractedStreamChunk, type FindingSeverity, FiveEInstructionalEvaluator, type FrameworkLintFinding, type FrameworkLintReport, FrameworkPack, GLOSSARY_TEMPLATE, GRAPHIC_ORGANIZER_TEMPLATE, type GenerateExpositionOptions, HANDOUT_TEMPLATE, ICurriculumStorage, LAYER_TOTAL_BUDGET_MS, LESSON_PLAN_TEMPLATE, type LayerChunkCallback, type LayerPrefillOptions, type LayerPrefillResult, type LayoutBoxConfig, LessonPlan, MisconceptionEvaluator, ModelResolutionOptions, PROJECT_INSTRUCTION_TEMPLATE, type PackingSpec, type PedagogicalModel, type PipelineExecutionProgress, PlanConstraints, type PlanOptions, type PlanResult, type PlannerLlmFn, PlanningGraph, PlanningNode, type PreliminaryResearchResult, type ProduceLessonOptions, type ProduceLessonResult, type ProjectBriefingData, type ProjectClarification, type ProjectCreationPayload, type ProjectIntentAnalysisResult, ProjectStatusReport, type ProjectionMeta, QUIZ_TEMPLATE, QualityAuditReport, REVIEW_GAME_TEMPLATE, RUBRIC_TEMPLATE, ResolvedGateSettings, SCIENCE_LAB_TEMPLATE, SELF_LAB_TEMPLATE, SLIDE_LAYOUT_PRESETS, SLIDE_TEMPLATE, STATION_ROTATION_TEMPLATE, type SlashCommandDefinition, SlideDeck, type SlideLayoutCategory, type SlideLayoutData, type SlideLayoutPreset, SmartResumeContext, type StreamAbortHandle, type StreamBudget, type StreamChunkExtractor, TASK_CARDS_TEMPLATE, TEACHER_GUIDE_TEMPLATE, TIERED_PRACTICE_TEMPLATE, TranslationPolicy, type TranslationTarget, type TranslationTrigger, type ValidationOptions, WORKSHEET_TEMPLATE, analyzeProjectCreationIntent, assertAcyclic, auditQualityReport, buildCurriculumContext, buildCurriculumPlan, buildExpositionContext, buildExpositionExcerpt, buildHeadingDirective, buildLanguageDirective, buildLessonExcerpt, buildSectionAwareExcerpt, buildSessionSliceContext, closeTruncatedJson, computePackingSpec, conductPreliminaryResearch, createAiInferenceError, createContextMissingError, createStreamAbortSignal, createStreamChunkExtractor, detectProjectPedagogy, ensureExpositionForLesson, ensureKnowledgeExposition, executeCurriculumCommand, expositionCacheKey, extractScopeSequenceRows, extractSectionHeadingsFromSLC, extractSessionSlice, extractStreamChunk, generatePhase1SotArtifacts, generatePhase2SotArtifacts, getLessonMetadata, getProjectArtifactScope, getProjectStatusReport, getSlideLayoutPresetById, getSlideLayoutPresetsByCategory, getSmartResumeContext, glossaryTermsForSession, ingestProjectGraphIntoProject, initializeProjectInStorage, isExpositionFresh, isTranslationDue, lintCurriculumFramework, loadCurriculumTemplate, loadSotTemplate, normalizePlanningGraph, normalizeSlcContract, parseRoadmapJsonToProjectPayload, produceBatchLessons, produceSingleLesson, renderFrameworkFromPlan, resolveStreamBudget, resolveTargetLanguageCode, resolveTranslationTargets, safeParseJson, slugifyProjectName, streamLLMWithFallback, streamLayerPrefillWithFallback, stripLlmJsonWrappers, targetLanguageDisplayName, topoSort, validateArtifactDependencies };
package/dist/index.mjs CHANGED
@@ -9830,7 +9830,9 @@ function buildSectionAwareExcerpt(markdown, opts = {}) {
9830
9830
  };
9831
9831
  }
9832
9832
  const slcMap = normalizeSlcContract(opts.sectionLanguageContract);
9833
- const sections = parseMarkdownSections(source, slcMap, opts.artifactType);
9833
+ const effectiveArtifactType = opts.artifactType || deriveArtifactTypeFromFileName(opts.fileName);
9834
+ const sections = parseMarkdownSections(source, slcMap, effectiveArtifactType);
9835
+ const metaBlock = buildMetaBlock(source, effectiveArtifactType);
9834
9836
  if (sections.length === 0) {
9835
9837
  issues.push("parse:no-sections");
9836
9838
  const excerpt2 = truncateByBudget(source, budget);
@@ -9864,12 +9866,13 @@ function buildSectionAwareExcerpt(markdown, opts = {}) {
9864
9866
  const block = `## ${heading}
9865
9867
 
9866
9868
  ${trimmedBody}`;
9867
- if (used + block.length > budget && blocks.length > 0) return false;
9869
+ if (used + block.length > budget && used > 0) return false;
9868
9870
  blocks.push(block);
9869
9871
  used += block.length;
9870
9872
  includedSections.push(key);
9871
9873
  return true;
9872
9874
  };
9875
+ blocks.push(metaBlock);
9873
9876
  let sectionAware = false;
9874
9877
  for (const key of priorities) {
9875
9878
  const sec = byCanonical.get(key);
@@ -9886,6 +9889,9 @@ ${trimmedBody}`;
9886
9889
  if (used >= budget) break;
9887
9890
  if (!tryAdd(sec.cleanTitle, sec.body, sec.cleanTitle)) break;
9888
9891
  }
9892
+ if (includedSections.length === 0 && unmatched.length > 0) {
9893
+ issues.push("parse:no-canonical-resolution");
9894
+ }
9889
9895
  if (priorities.length > 0 && !priorities.some((k) => includedSections.includes(k))) {
9890
9896
  issues.push("parse:no-priority-resolution");
9891
9897
  }
@@ -9894,14 +9900,14 @@ ${trimmedBody}`;
9894
9900
  excerpt = truncateByBudget(excerpt, budget);
9895
9901
  }
9896
9902
  const effectiveMinChars = Math.min(minContentChars, source.length);
9897
- if (excerpt.length < effectiveMinChars) {
9903
+ if (excerpt.length - metaBlock.length < effectiveMinChars) {
9898
9904
  issues.push("content:insufficient");
9899
9905
  }
9900
- const verified = !issues.includes("parse:no-priority-resolution") && excerpt.length >= effectiveMinChars;
9906
+ const verified = !issues.includes("parse:no-priority-resolution") && !issues.includes("parse:no-canonical-resolution") && excerpt.length - metaBlock.length >= effectiveMinChars;
9901
9907
  return {
9902
9908
  excerpt,
9903
9909
  verified,
9904
- sectionAware: sectionAware || priorities.length === 0 && sections.length > 0,
9910
+ sectionAware: sectionAware || unmatched.length === 0,
9905
9911
  includedSections,
9906
9912
  issues,
9907
9913
  tokenEstimate: Math.round(excerpt.length / 4)
@@ -10017,6 +10023,26 @@ function truncateByBudget(source, budget) {
10017
10023
  if (fenceCount % 2 === 1) cut += "\n```";
10018
10024
  return cut;
10019
10025
  }
10026
+ function buildMetaBlock(source, artifactType) {
10027
+ const fm = source.match(/^---\s*\r?\n([\s\S]*?)\r?\n---/);
10028
+ const pick = (key) => {
10029
+ if (!fm) return "";
10030
+ const m = fm[1].match(new RegExp(`^${key}:\\s*"?([^"\\n]+)"?`, "m"));
10031
+ return (m?.[1] || "").trim();
10032
+ };
10033
+ const id = pick("id");
10034
+ const title = pick("title");
10035
+ const type = pick("type") || artifactType || "";
10036
+ return `<!-- SOURCE: ${type || "ARTIFACT"} | ${id || "unknown"}${title ? ` \u2014 ${title}` : ""} (section-aware excerpt; canonical knowledge, do not contradict) -->`;
10037
+ }
10038
+ function deriveArtifactTypeFromFileName(fileName) {
10039
+ if (!fileName) return void 0;
10040
+ const base = fileName.replace(/\.md$/i, "");
10041
+ const multiWord = base.match(/^(KNOWLEDGE_EXPOSITION|SECTION_LANGUAGE_CONTRACT|CONTENT_STYLE_GUIDE|CURRICULUM_FRAMEWORK|LEARNER_PROFILE|PROJECT_BRIEF|REFERENCE_PACK|CURRICULUM_PLAN)/i);
10042
+ if (multiWord) return multiWord[1].toUpperCase();
10043
+ const token = base.match(/^([A-Z][A-Z0-9_]*?)(?=_|$)/);
10044
+ return token ? token[1] : void 0;
10045
+ }
10020
10046
 
10021
10047
  // src/services/knowledgeExpositionService.ts
10022
10048
  var EXPOSITION_REL = (lessonCode) => "_sot/expositions/" + lessonCode + ".md";
@@ -10165,7 +10191,7 @@ async function ensureExpositionForLesson(storage, projectId, lessonCode, options
10165
10191
  storage,
10166
10192
  gates: options.gates
10167
10193
  });
10168
- return { relPath: result.relPath, context: buildExpositionContext(result.content), reused: result.reused };
10194
+ return { relPath: result.relPath, context: buildExpositionContext(result.content), reused: result.reused, rawContent: result.content };
10169
10195
  }
10170
10196
  init_errors();
10171
10197
  var asArr = (v) => Array.isArray(v) ? v : [];
@@ -11876,6 +11902,8 @@ async function produceSingleLesson(storage, projectId, lessonId, options = {}) {
11876
11902
  targetLang = targetLang || "vi";
11877
11903
  const languageDirective = buildLanguageDirective(targetLang);
11878
11904
  let expositionContext = "";
11905
+ let expositionInjection;
11906
+ let lessonInjection;
11879
11907
  let sessionSliceContext = "";
11880
11908
  try {
11881
11909
  const exposition = await ensureExpositionForLesson(storage, projectId, lessonCode, {
@@ -11883,7 +11911,18 @@ async function produceSingleLesson(storage, projectId, lessonId, options = {}) {
11883
11911
  force: options.force
11884
11912
  });
11885
11913
  if (exposition) {
11886
- expositionContext = exposition.context;
11914
+ const expoExcerpt = buildExpositionExcerpt(exposition.rawContent || exposition.context, {
11915
+ budget: 6e3,
11916
+ sectionLanguageContract: slcMarkdown,
11917
+ artifactType: "KNOWLEDGE_EXPOSITION"
11918
+ });
11919
+ expositionContext = expoExcerpt.excerpt || exposition.context;
11920
+ expositionInjection = {
11921
+ source: "KNOWLEDGE_EXPOSITION",
11922
+ verified: expoExcerpt.verified,
11923
+ sectionAware: expoExcerpt.sectionAware,
11924
+ issues: expoExcerpt.issues
11925
+ };
11887
11926
  onProgress?.("@content", `[EXPOSITION] ${exposition.reused ? "Reused" : "Generated"} \`\${exposition.relPath}\` (plan-driven knowledge source)...`);
11888
11927
  } else {
11889
11928
  onProgress?.("@content", "[EXPOSITION] No CURRICULUM_PLAN.json \u2014 running legacy knowledge flow (no plan-driven exposition).");
@@ -12123,6 +12162,7 @@ ${yamlBlock.trim()}
12123
12162
  };
12124
12163
  var injectYamlReviewMetadata = injectYamlReviewMetadata2;
12125
12164
  const judgeObjectives = parseLessonObjectives(lessonContent, concept, bloomLevel);
12165
+ const judgeExpositionExcerpt = expositionContext ? buildExpositionExcerpt(expositionContext, { budget: 3e3, sectionLanguageContract: slcMarkdown, artifactType: "KNOWLEDGE_EXPOSITION" }).excerpt : void 0;
12126
12166
  const judgeResult = await LLMJudgeEngine.evaluateArtifactWithLLM({
12127
12167
  targetArtifactType: "LESSON",
12128
12168
  lessonId: lessonCode,
@@ -12134,7 +12174,7 @@ ${yamlBlock.trim()}
12134
12174
  title: lessonTitle,
12135
12175
  frameworkExcerpt: framework ? buildFrameworkExcerptForLesson(framework, lessonId) : void 0,
12136
12176
  styleGuideExcerpt: effectiveStyleGuide || void 0,
12137
- canonicalExposition: expositionContext ? expositionContext.slice(0, 3e3) : void 0
12177
+ canonicalExposition: judgeExpositionExcerpt
12138
12178
  }),
12139
12179
  standardStatements: Object.keys(standardStatements).length > 0 ? standardStatements : void 0
12140
12180
  });
@@ -12189,6 +12229,16 @@ ${currentContent}` }],
12189
12229
  options.onProgress?.("@repair", chunk, { type: type || "content", artifactType: "LESSON" });
12190
12230
  }
12191
12231
  );
12232
+ const repairedExcerptCheck = buildSectionAwareExcerpt(repairedRaw, {
12233
+ priorities: DEFAULT_LESSON_PRIORITIES,
12234
+ budget: 12e3,
12235
+ sectionLanguageContract: slcMarkdown,
12236
+ artifactType: "LESSON"
12237
+ });
12238
+ if (repairedExcerptCheck.issues.includes("parse:no-priority-resolution")) {
12239
+ onProgress?.("@repair", `\u26A0\uFE0F Repair round ${round} lost mandatory section structure (no priority section resolved) \u2014 rejecting repaired draft, retaining previous`);
12240
+ break;
12241
+ }
12192
12242
  if (!repairedRaw || repairedRaw.startsWith("\u26A0\uFE0F") || repairedRaw.length < 200) {
12193
12243
  onProgress?.("@repair", `\u26A0\uFE0F Repair round ${round} produced invalid output \u2014 stopping repair loop`);
12194
12244
  break;
@@ -12213,7 +12263,7 @@ ${currentContent}` }],
12213
12263
  title: lessonTitle,
12214
12264
  frameworkExcerpt: framework ? buildFrameworkExcerptForLesson(framework, lessonId) : void 0,
12215
12265
  styleGuideExcerpt: effectiveStyleGuide || void 0,
12216
- canonicalExposition: expositionContext ? expositionContext.slice(0, 3e3) : void 0
12266
+ canonicalExposition: expositionContext ? buildExpositionExcerpt(expositionContext, { budget: 3e3, sectionLanguageContract: slcMarkdown, artifactType: "KNOWLEDGE_EXPOSITION" }).excerpt : void 0
12217
12267
  }),
12218
12268
  standardStatements: Object.keys(standardStatements).length > 0 ? standardStatements : void 0
12219
12269
  });
@@ -12271,7 +12321,9 @@ ${currentContent}` }],
12271
12321
  pedagogy,
12272
12322
  producedArtifacts,
12273
12323
  pausedForReview: true,
12274
- gateStatus: "judge_needs_revision"
12324
+ gateStatus: "judge_needs_revision",
12325
+ contextInjection: expositionInjection || lessonInjection,
12326
+ promptChars: commonContext.length
12275
12327
  };
12276
12328
  }
12277
12329
  }
@@ -12294,7 +12346,9 @@ ${currentContent}` }],
12294
12346
  pedagogy,
12295
12347
  producedArtifacts,
12296
12348
  pausedForReview: true,
12297
- gateStatus: "judge_error"
12349
+ gateStatus: "judge_error",
12350
+ contextInjection: expositionInjection,
12351
+ promptChars: commonContext.length
12298
12352
  };
12299
12353
  }
12300
12354
  }
@@ -12324,7 +12378,9 @@ ${currentContent}` }],
12324
12378
  pedagogy,
12325
12379
  producedArtifacts,
12326
12380
  pausedForReview: true,
12327
- gateStatus: "awaiting_approval"
12381
+ gateStatus: "awaiting_approval",
12382
+ contextInjection: expositionInjection,
12383
+ promptChars: commonContext.length
12328
12384
  };
12329
12385
  }
12330
12386
  if (isLessonApproved && currentLessonInfo?.state !== "approved") {
@@ -12341,6 +12397,13 @@ ${currentContent}` }],
12341
12397
  artifactType: "LESSON"
12342
12398
  });
12343
12399
  const lessonExcerpt = lessonExcerptResult.excerpt;
12400
+ const lessonInjectionMeta = {
12401
+ source: "LESSON",
12402
+ verified: lessonExcerptResult.verified,
12403
+ sectionAware: lessonExcerptResult.sectionAware,
12404
+ issues: lessonExcerptResult.issues
12405
+ };
12406
+ lessonInjection = lessonInjectionMeta;
12344
12407
  const satelliteContext = `${commonContext}
12345
12408
 
12346
12409
  [CANONICAL LESSON PLAN (${pedagogyLabel})]:
@@ -12980,7 +13043,9 @@ ${buildHeadingDirective("EXT", slcMarkdown, targetLang)}`;
12980
13043
  lessonId: lessonCode,
12981
13044
  pedagogy,
12982
13045
  producedArtifacts,
12983
- pausedForReview: false
13046
+ pausedForReview: false,
13047
+ contextInjection: lessonInjection && lessonInjection.verified ? expositionInjection || lessonInjection : lessonInjection || expositionInjection,
13048
+ promptChars: commonContext.length
12984
13049
  };
12985
13050
  }
12986
13051
  function parseLessonObjectives(lessonContent, concept, bloomLevel) {