@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.cjs
CHANGED
|
@@ -6258,6 +6258,7 @@ function buildSectionAwareExcerpt(markdown, opts = {}) {
|
|
|
6258
6258
|
}
|
|
6259
6259
|
const slcMap = normalizeSlcContract(opts.sectionLanguageContract);
|
|
6260
6260
|
const sections = parseMarkdownSections(source, slcMap, opts.artifactType);
|
|
6261
|
+
const metaBlock = buildMetaBlock(source);
|
|
6261
6262
|
if (sections.length === 0) {
|
|
6262
6263
|
issues.push("parse:no-sections");
|
|
6263
6264
|
const excerpt2 = truncateByBudget(source, budget);
|
|
@@ -6291,12 +6292,13 @@ function buildSectionAwareExcerpt(markdown, opts = {}) {
|
|
|
6291
6292
|
const block = `## ${heading}
|
|
6292
6293
|
|
|
6293
6294
|
${trimmedBody}`;
|
|
6294
|
-
if (used + block.length > budget &&
|
|
6295
|
+
if (used + block.length > budget && used > 0) return false;
|
|
6295
6296
|
blocks.push(block);
|
|
6296
6297
|
used += block.length;
|
|
6297
6298
|
includedSections.push(key);
|
|
6298
6299
|
return true;
|
|
6299
6300
|
};
|
|
6301
|
+
blocks.push(metaBlock);
|
|
6300
6302
|
let sectionAware = false;
|
|
6301
6303
|
for (const key of priorities) {
|
|
6302
6304
|
const sec = byCanonical.get(key);
|
|
@@ -6313,6 +6315,9 @@ ${trimmedBody}`;
|
|
|
6313
6315
|
if (used >= budget) break;
|
|
6314
6316
|
if (!tryAdd(sec.cleanTitle, sec.body, sec.cleanTitle)) break;
|
|
6315
6317
|
}
|
|
6318
|
+
if (includedSections.length === 0 && unmatched.length > 0) {
|
|
6319
|
+
issues.push("parse:no-canonical-resolution");
|
|
6320
|
+
}
|
|
6316
6321
|
if (priorities.length > 0 && !priorities.some((k) => includedSections.includes(k))) {
|
|
6317
6322
|
issues.push("parse:no-priority-resolution");
|
|
6318
6323
|
}
|
|
@@ -6321,14 +6326,14 @@ ${trimmedBody}`;
|
|
|
6321
6326
|
excerpt = truncateByBudget(excerpt, budget);
|
|
6322
6327
|
}
|
|
6323
6328
|
const effectiveMinChars = Math.min(minContentChars, source.length);
|
|
6324
|
-
if (excerpt.length < effectiveMinChars) {
|
|
6329
|
+
if (excerpt.length - metaBlock.length < effectiveMinChars) {
|
|
6325
6330
|
issues.push("content:insufficient");
|
|
6326
6331
|
}
|
|
6327
|
-
const verified = !issues.includes("parse:no-priority-resolution") && excerpt.length >= effectiveMinChars;
|
|
6332
|
+
const verified = !issues.includes("parse:no-priority-resolution") && !issues.includes("parse:no-canonical-resolution") && excerpt.length - metaBlock.length >= effectiveMinChars;
|
|
6328
6333
|
return {
|
|
6329
6334
|
excerpt,
|
|
6330
6335
|
verified,
|
|
6331
|
-
sectionAware: sectionAware ||
|
|
6336
|
+
sectionAware: sectionAware || unmatched.length === 0,
|
|
6332
6337
|
includedSections,
|
|
6333
6338
|
issues,
|
|
6334
6339
|
tokenEstimate: Math.round(excerpt.length / 4)
|
|
@@ -6444,6 +6449,18 @@ function truncateByBudget(source, budget) {
|
|
|
6444
6449
|
if (fenceCount % 2 === 1) cut += "\n```";
|
|
6445
6450
|
return cut;
|
|
6446
6451
|
}
|
|
6452
|
+
function buildMetaBlock(source) {
|
|
6453
|
+
const fm = source.match(/^---\s*\r?\n([\s\S]*?)\r?\n---/);
|
|
6454
|
+
const pick = (key) => {
|
|
6455
|
+
if (!fm) return "";
|
|
6456
|
+
const m = fm[1].match(new RegExp(`^${key}:\\s*"?([^"\\n]+)"?`, "m"));
|
|
6457
|
+
return (m?.[1] || "").trim();
|
|
6458
|
+
};
|
|
6459
|
+
const id = pick("id");
|
|
6460
|
+
const title = pick("title");
|
|
6461
|
+
const type = pick("type");
|
|
6462
|
+
return `<!-- SOURCE: ${type || "ARTIFACT"} | ${id || "unknown"}${title ? ` \u2014 ${title}` : ""} (section-aware excerpt; canonical knowledge, do not contradict) -->`;
|
|
6463
|
+
}
|
|
6447
6464
|
init_errors();
|
|
6448
6465
|
|
|
6449
6466
|
// src/services/languageDirective.ts
|