@thanh01.pmt/curriculum-kit 1.3.0 → 1.4.0
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.cjs +68 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.mjs +68 -12
- package/dist/index.mjs.map +1 -1
- package/dist/workflow/index.cjs +21 -4
- package/dist/workflow/index.cjs.map +1 -1
- package/dist/workflow/index.mjs +21 -4
- package/dist/workflow/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/workflow/index.mjs
CHANGED
|
@@ -6249,6 +6249,7 @@ function buildSectionAwareExcerpt(markdown, opts = {}) {
|
|
|
6249
6249
|
}
|
|
6250
6250
|
const slcMap = normalizeSlcContract(opts.sectionLanguageContract);
|
|
6251
6251
|
const sections = parseMarkdownSections(source, slcMap, opts.artifactType);
|
|
6252
|
+
const metaBlock = buildMetaBlock(source);
|
|
6252
6253
|
if (sections.length === 0) {
|
|
6253
6254
|
issues.push("parse:no-sections");
|
|
6254
6255
|
const excerpt2 = truncateByBudget(source, budget);
|
|
@@ -6282,12 +6283,13 @@ function buildSectionAwareExcerpt(markdown, opts = {}) {
|
|
|
6282
6283
|
const block = `## ${heading}
|
|
6283
6284
|
|
|
6284
6285
|
${trimmedBody}`;
|
|
6285
|
-
if (used + block.length > budget &&
|
|
6286
|
+
if (used + block.length > budget && used > 0) return false;
|
|
6286
6287
|
blocks.push(block);
|
|
6287
6288
|
used += block.length;
|
|
6288
6289
|
includedSections.push(key);
|
|
6289
6290
|
return true;
|
|
6290
6291
|
};
|
|
6292
|
+
blocks.push(metaBlock);
|
|
6291
6293
|
let sectionAware = false;
|
|
6292
6294
|
for (const key of priorities) {
|
|
6293
6295
|
const sec = byCanonical.get(key);
|
|
@@ -6304,6 +6306,9 @@ ${trimmedBody}`;
|
|
|
6304
6306
|
if (used >= budget) break;
|
|
6305
6307
|
if (!tryAdd(sec.cleanTitle, sec.body, sec.cleanTitle)) break;
|
|
6306
6308
|
}
|
|
6309
|
+
if (includedSections.length === 0 && unmatched.length > 0) {
|
|
6310
|
+
issues.push("parse:no-canonical-resolution");
|
|
6311
|
+
}
|
|
6307
6312
|
if (priorities.length > 0 && !priorities.some((k) => includedSections.includes(k))) {
|
|
6308
6313
|
issues.push("parse:no-priority-resolution");
|
|
6309
6314
|
}
|
|
@@ -6312,14 +6317,14 @@ ${trimmedBody}`;
|
|
|
6312
6317
|
excerpt = truncateByBudget(excerpt, budget);
|
|
6313
6318
|
}
|
|
6314
6319
|
const effectiveMinChars = Math.min(minContentChars, source.length);
|
|
6315
|
-
if (excerpt.length < effectiveMinChars) {
|
|
6320
|
+
if (excerpt.length - metaBlock.length < effectiveMinChars) {
|
|
6316
6321
|
issues.push("content:insufficient");
|
|
6317
6322
|
}
|
|
6318
|
-
const verified = !issues.includes("parse:no-priority-resolution") && excerpt.length >= effectiveMinChars;
|
|
6323
|
+
const verified = !issues.includes("parse:no-priority-resolution") && !issues.includes("parse:no-canonical-resolution") && excerpt.length - metaBlock.length >= effectiveMinChars;
|
|
6319
6324
|
return {
|
|
6320
6325
|
excerpt,
|
|
6321
6326
|
verified,
|
|
6322
|
-
sectionAware: sectionAware ||
|
|
6327
|
+
sectionAware: sectionAware || unmatched.length === 0,
|
|
6323
6328
|
includedSections,
|
|
6324
6329
|
issues,
|
|
6325
6330
|
tokenEstimate: Math.round(excerpt.length / 4)
|
|
@@ -6435,6 +6440,18 @@ function truncateByBudget(source, budget) {
|
|
|
6435
6440
|
if (fenceCount % 2 === 1) cut += "\n```";
|
|
6436
6441
|
return cut;
|
|
6437
6442
|
}
|
|
6443
|
+
function buildMetaBlock(source) {
|
|
6444
|
+
const fm = source.match(/^---\s*\r?\n([\s\S]*?)\r?\n---/);
|
|
6445
|
+
const pick = (key) => {
|
|
6446
|
+
if (!fm) return "";
|
|
6447
|
+
const m = fm[1].match(new RegExp(`^${key}:\\s*"?([^"\\n]+)"?`, "m"));
|
|
6448
|
+
return (m?.[1] || "").trim();
|
|
6449
|
+
};
|
|
6450
|
+
const id = pick("id");
|
|
6451
|
+
const title = pick("title");
|
|
6452
|
+
const type = pick("type");
|
|
6453
|
+
return `<!-- SOURCE: ${type || "ARTIFACT"} | ${id || "unknown"}${title ? ` \u2014 ${title}` : ""} (section-aware excerpt; canonical knowledge, do not contradict) -->`;
|
|
6454
|
+
}
|
|
6438
6455
|
init_errors();
|
|
6439
6456
|
|
|
6440
6457
|
// src/services/languageDirective.ts
|