@thanh01.pmt/curriculum-kit 1.4.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.
@@ -6248,8 +6248,9 @@ function buildSectionAwareExcerpt(markdown, opts = {}) {
6248
6248
  };
6249
6249
  }
6250
6250
  const slcMap = normalizeSlcContract(opts.sectionLanguageContract);
6251
- const sections = parseMarkdownSections(source, slcMap, opts.artifactType);
6252
- const metaBlock = buildMetaBlock(source);
6251
+ const effectiveArtifactType = opts.artifactType || deriveArtifactTypeFromFileName(opts.fileName);
6252
+ const sections = parseMarkdownSections(source, slcMap, effectiveArtifactType);
6253
+ const metaBlock = buildMetaBlock(source, effectiveArtifactType);
6253
6254
  if (sections.length === 0) {
6254
6255
  issues.push("parse:no-sections");
6255
6256
  const excerpt2 = truncateByBudget(source, budget);
@@ -6440,7 +6441,7 @@ function truncateByBudget(source, budget) {
6440
6441
  if (fenceCount % 2 === 1) cut += "\n```";
6441
6442
  return cut;
6442
6443
  }
6443
- function buildMetaBlock(source) {
6444
+ function buildMetaBlock(source, artifactType) {
6444
6445
  const fm = source.match(/^---\s*\r?\n([\s\S]*?)\r?\n---/);
6445
6446
  const pick = (key) => {
6446
6447
  if (!fm) return "";
@@ -6449,9 +6450,17 @@ function buildMetaBlock(source) {
6449
6450
  };
6450
6451
  const id = pick("id");
6451
6452
  const title = pick("title");
6452
- const type = pick("type");
6453
+ const type = pick("type") || artifactType || "";
6453
6454
  return `<!-- SOURCE: ${type || "ARTIFACT"} | ${id || "unknown"}${title ? ` \u2014 ${title}` : ""} (section-aware excerpt; canonical knowledge, do not contradict) -->`;
6454
6455
  }
6456
+ function deriveArtifactTypeFromFileName(fileName) {
6457
+ if (!fileName) return void 0;
6458
+ const base = fileName.replace(/\.md$/i, "");
6459
+ const multiWord = base.match(/^(KNOWLEDGE_EXPOSITION|SECTION_LANGUAGE_CONTRACT|CONTENT_STYLE_GUIDE|CURRICULUM_FRAMEWORK|LEARNER_PROFILE|PROJECT_BRIEF|REFERENCE_PACK|CURRICULUM_PLAN)/i);
6460
+ if (multiWord) return multiWord[1].toUpperCase();
6461
+ const token = base.match(/^([A-Z][A-Z0-9_]*?)(?=_|$)/);
6462
+ return token ? token[1] : void 0;
6463
+ }
6455
6464
  init_errors();
6456
6465
 
6457
6466
  // src/services/languageDirective.ts